Repository: FHIR/sushi (ts)

Issue:
SUSHI does not auto-load extensions / terminology packages for FHIR R6
SUSHI does not automatically load the extensions package or terminology package for projects that specify their fhirVersion as 6.0.0-ballot2. I think this is because our auto-package loading mechanism looks up those packages based on FHIR version, and SUSHI is missing a mapping for version 6.

We should update that code to account for R6 and/or to fall back to the latest known FHIR-specific versions (E.g., currently the R5 versions) when we don't  have a mapping for the requested FHIR version.

Currently, authors can work around this by adding the latest R5 versions to their dependencies:
```yaml
dependencies:
  hl7.fhir.uv.extensions.r5: latest
  hl7.terminology.r5: latest
```

Pull request description:
Load automatic dependencies for FHIR R6 versions
**Description:**
R6 prerelease versions of FHIR are available, but R6 versions of the terminology and extension packages are not yet available. Load the R5 versions of this packages when an R6 version of FHIR is used.

**Testing Instructions:**
Confirm that tests pass. Run SUSHI on a project that uses R6 prerelease FHIR along with official extensions and confirm that no errors are produced.

**Related Issue:**
Fixes #1533.

Patch:
diff --git a/src/utils/Processing.ts b/src/utils/Processing.ts
index 0f8083e..4caa6d4 100644
--- a/src/utils/Processing.ts
+++ b/src/utils/Processing.ts
@@ -70,7 +70,7 @@ export const AUTOMATIC_DEPENDENCIES: AutomaticDependency[] = [
   {
     packageId: 'hl7.terminology.r5',
     version: 'latest',
-    fhirVersions: ['R5']
+    fhirVersions: ['R5', 'R6']
   },
   {
     packageId: 'hl7.fhir.uv.extensions.r4',
@@ -80,7 +80,7 @@ export const AUTOMATIC_DEPENDENCIES: AutomaticDependency[] = [
   {
     packageId: 'hl7.fhir.uv.extensions.r5',
     version: 'latest',
-    fhirVersions: ['R5']
+    fhirVersions: ['R5', 'R6']
   }
 ];
 


Test patch:
diff --git a/test/utils/Processing.test.ts b/test/utils/Processing.test.ts
index 1aecc6a..0821f87 100644
--- a/test/utils/Processing.test.ts
+++ b/test/utils/Processing.test.ts
@@ -1339,6 +1339,19 @@ describe('Processing', () => {
       });
     });
 
+    it('should load each automatic dependency for FHIR R6 prerelease', () => {
+      const config = cloneDeep(minimalConfig);
+      config.dependencies = [{ packageId: 'hl7.fhir.us.core', version: '3.1.0' }];
+      const defs = new FHIRDefinitions();
+      return loadAutomaticDependencies('6.0.0-ballot2', config.dependencies, defs).then(() => {
+        expect(loadedPackages).toHaveLength(3);
+        expect(loadedPackages).toContain('hl7.fhir.uv.tools#current');
+        expect(loadedPackages).toContain('hl7.terminology.r5#1.2.3-test');
+        expect(loadedPackages).toContain('hl7.fhir.uv.extensions.r5#4.5.6-test');
+        expect(loggerSpy.getAllMessages('warn')).toHaveLength(0);
+      });
+    });
+
     it('should should use the package server query to get the terminology version', () => {
       // Change the version to 2.4.6-test just to be sure
       nock.removeInterceptor(termR4NockScope);
@@ -1552,6 +1565,20 @@ describe('Processing', () => {
       });
     });
 
+    it('should load each automatic dependency for FHIR R6 prerelease from a custom registry', () => {
+      process.env.FPL_REGISTRY = 'https://custom-registry.example.org';
+      const config = cloneDeep(minimalConfig);
+      config.dependencies = [{ packageId: 'hl7.fhir.us.core', version: '3.1.0' }];
+      const defs = new FHIRDefinitions();
+      return loadAutomaticDependencies('6.0.0-ballot2', config.dependencies, defs).then(() => {
+        expect(loadedPackages).toHaveLength(3);
+        expect(loadedPackages).toContain('hl7.fhir.uv.tools#current');
+        expect(loadedPackages).toContain('hl7.terminology.r5#1.2.3-test');
+        expect(loadedPackages).toContain('hl7.fhir.uv.extensions.r5#4.5.6-test');
+        expect(loggerSpy.getAllMessages('warn')).toHaveLength(0);
+      });
+    });
+
     it('should should use the package server query to get the terminology version', () => {
       process.env.FPL_REGISTRY = 'https://custom-registry.example.org';
       // Change the version to 2.4.6-test just to be sure