Skip to content

Commit

Permalink
SUSHI 2.x: Use R5 5.0.0 for cross-version (implied) extensions (#1277)
Browse files Browse the repository at this point in the history
* Use R5 5.0.0 for cross-version (implied) extensions (#1276)

(cherry picked from commit 2b31b92)

* Fix remaining issues for replacing R5 current w/ 5.0.0
  • Loading branch information
cmoesel authored May 15, 2023
1 parent e20b97e commit e84d4ab
Show file tree
Hide file tree
Showing 31 changed files with 56 additions and 29,550 deletions.
2 changes: 1 addition & 1 deletion src/fhirdefs/impliedExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const VERSION_TO_PACKAGE_MAP: { [key: string]: string } = {
'1.0': 'hl7.fhir.r2.core#1.0.2',
'3.0': 'hl7.fhir.r3.core#3.0.2',
'4.0': 'hl7.fhir.r4.core#4.0.1',
'5.0': 'hl7.fhir.r5.core#current'
'5.0': 'hl7.fhir.r5.core#5.0.0'
};

// This map represents how old resource types (R2/R3) map to R4/R5 or how new resource types (R5) map to R4.
Expand Down
2 changes: 1 addition & 1 deletion src/utils/Processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const EXT_PKG_TO_FHIR_PKG_MAP: { [key: string]: string } = {
'hl7.fhir.extensions.r2': 'hl7.fhir.r2.core#1.0.2',
'hl7.fhir.extensions.r3': 'hl7.fhir.r3.core#3.0.2',
'hl7.fhir.extensions.r4': 'hl7.fhir.r4.core#4.0.1',
'hl7.fhir.extensions.r5': 'hl7.fhir.r5.core#current'
'hl7.fhir.extensions.r5': 'hl7.fhir.r5.core#5.0.0'
};

const CERTIFICATE_MESSAGE =
Expand Down
2 changes: 1 addition & 1 deletion test/export/InstanceExporter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5263,7 +5263,7 @@ describe('InstanceExporter R5', () => {
doc = new FSHDocument('fileName');
const input = new FSHTank([doc], minimalConfig);
const pkg = new Package(input.config);
const fisher = new TestFisher(input, defs, pkg, 'hl7.fhir.r5.core#current', 'r5-definitions');
const fisher = new TestFisher(input, defs, pkg, 'hl7.fhir.r5.core#5.0.0', 'r5-definitions');
sdExporter = new StructureDefinitionExporter(input, pkg, fisher);
exporter = new InstanceExporter(input, pkg, fisher);
exportInstance = (instance: Instance) => {
Expand Down
2 changes: 1 addition & 1 deletion test/export/StructureDefinitionExporter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8174,7 +8174,7 @@ describe('StructureDefinitionExporter R5', () => {
doc = new FSHDocument('fileName');
const input = new FSHTank([doc], minimalConfig);
pkg = new Package(input.config);
const fisher = new TestFisher(input, defs, pkg, 'hl7.fhir.r5.core#current', 'r5-definitions');
const fisher = new TestFisher(input, defs, pkg, 'hl7.fhir.r5.core#5.0.0', 'r5-definitions');
exporter = new StructureDefinitionExporter(input, pkg, fisher);
loggerSpy.reset();
});
Expand Down
6 changes: 3 additions & 3 deletions test/fhirdefs/FHIRDefinitions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -911,12 +911,12 @@ describe('FHIRDefinitions', () => {
const r3 = new FHIRDefinitions(true);
r3.packages.push('hl7.fhir.r3.core#3.0.2');
const r5 = new FHIRDefinitions(true);
r5.packages.push('hl7.fhir.r5.core#current');
r5.packages.push('hl7.fhir.r5.core#5.0.0');
defs.addSupplementalFHIRDefinitions('hl7.fhir.r3.core#3.0.2', r3);
defs.addSupplementalFHIRDefinitions('hl7.fhir.r5.core#current', r5);
defs.addSupplementalFHIRDefinitions('hl7.fhir.r5.core#5.0.0', r5);
expect(defs.supplementalFHIRPackages).toEqual([
'hl7.fhir.r3.core#3.0.2',
'hl7.fhir.r5.core#current'
'hl7.fhir.r5.core#5.0.0'
]);
});
});
Expand Down
25 changes: 12 additions & 13 deletions test/fhirdefs/impliedExtension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('impliedExtensions', () => {
defs.addSupplementalFHIRDefinitions('hl7.fhir.r3.core#3.0.2', r3Defs);
const r5Defs = new FHIRDefinitions(true);
loadFromPath(path.join(__dirname, '..', 'testhelpers', 'testdefs'), 'r5-definitions', r5Defs);
defs.addSupplementalFHIRDefinitions('hl7.fhir.r5.core#current', r5Defs);
defs.addSupplementalFHIRDefinitions('hl7.fhir.r5.core#5.0.0', r5Defs);
loggerSpy.reset();
});

Expand Down Expand Up @@ -694,7 +694,7 @@ describe('impliedExtensions', () => {
resourceType: 'StructureDefinition',
id: 'extension-MedicationRequest.informationSource',
url: 'http://hl7.org/fhir/5.0/StructureDefinition/extension-MedicationRequest.informationSource',
version: '4.6.0',
version: '5.0.0',
name: 'Extension_MedicationRequest_informationSource',
title: 'Implied extension for MedicationRequest.informationSource',
status: 'active',
Expand All @@ -718,8 +718,7 @@ describe('impliedExtensions', () => {
definition:
'The person or organization who provided the information about this request, if the ' +
'source is someone other than the requestor. This is often used when the ' +
'MedicationRequest is reported by another person.',
max: '1'
'MedicationRequest is reported by another person.'
});
const snapRoot = ext.snapshot?.element?.[0];
expect(snapRoot).toMatchObject(diffRoot);
Expand Down Expand Up @@ -781,7 +780,7 @@ describe('impliedExtensions', () => {
resourceType: 'StructureDefinition',
id: 'extension-MedicationRequest.substitution',
url: 'http://hl7.org/fhir/5.0/StructureDefinition/extension-MedicationRequest.substitution',
version: '4.6.0',
version: '5.0.0',
name: 'Extension_MedicationRequest_substitution',
title: 'Implied extension for MedicationRequest.substitution',
status: 'active',
Expand Down Expand Up @@ -893,7 +892,7 @@ describe('impliedExtensions', () => {
type: [{ code: 'boolean' }, { code: 'CodeableConcept' }],
binding: {
description: 'Identifies the type of substitution allowed.',
strength: 'example',
strength: 'preferred',
valueSet: 'http://terminology.hl7.org/ValueSet/v3-ActSubstanceAdminSubstitutionCode'
}
});
Expand Down Expand Up @@ -966,7 +965,7 @@ describe('impliedExtensions', () => {
resourceType: 'StructureDefinition',
id: 'extension-MedicationRequest.medication',
url: 'http://hl7.org/fhir/5.0/StructureDefinition/extension-MedicationRequest.medication',
version: '4.6.0',
version: '5.0.0',
name: 'Extension_MedicationRequest_medication',
title: 'Implied extension for MedicationRequest.medication',
status: 'active',
Expand Down Expand Up @@ -1046,8 +1045,8 @@ describe('impliedExtensions', () => {
sliceName: 'concept',
short: 'Reference to a concept (by class)',
definition:
"A reference to a concept - e.g. the information is identified by it's general " +
'classto the degree of precision found in the terminology.',
'A reference to a concept - e.g. the information is identified by its general ' +
'class to the degree of precision found in the terminology.',
min: 0,
max: '1',
type: [{ code: 'Extension' }]
Expand Down Expand Up @@ -1332,7 +1331,7 @@ describe('impliedExtensions', () => {
)
).toBeUndefined();
expect(loggerSpy.getLastMessage('error')).toMatch(
/The extension http:\/\/hl7\.org\/fhir\/3\.0\/StructureDefinition\/extension-Patient\.animal\.species requires .*\n.*hl7\.fhir\.extensions\.r3: 4\.6\.0/
/The extension http:\/\/hl7\.org\/fhir\/3\.0\/StructureDefinition\/extension-Patient\.animal\.species requires .*\n.*hl7\.fhir\.extensions\.r3: 5\.0\.0/
);
});

Expand All @@ -1353,7 +1352,7 @@ describe('impliedExtensions', () => {
title: 'Implied extension for Bundle.timestamp',
status: 'active',
description: 'Implied extension for Bundle.timestamp',
fhirVersion: '4.6.0',
fhirVersion: '5.0.0',
kind: 'complex-type',
abstract: false,
context: [{ type: 'element', expression: 'Element' }],
Expand Down Expand Up @@ -1470,7 +1469,7 @@ describe('impliedExtensions', () => {
title: 'Implied extension for Bundle.signature',
status: 'active',
description: 'Implied extension for Bundle.signature',
fhirVersion: '4.6.0',
fhirVersion: '5.0.0',
kind: 'complex-type',
abstract: false,
context: [{ type: 'element', expression: 'Element' }],
Expand Down Expand Up @@ -1553,7 +1552,7 @@ describe('impliedExtensions', () => {
title: 'Implied extension for Bundle.link',
status: 'active',
description: 'Implied extension for Bundle.link',
fhirVersion: '4.6.0',
fhirVersion: '5.0.0',
kind: 'complex-type',
abstract: false,
context: [{ type: 'element', expression: 'Element' }],
Expand Down
15 changes: 13 additions & 2 deletions test/fhirdefs/load.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ describe('#loadDependency()', () => {
uri === 'https://packages.fhir.org/hl7.fhir.r4b.core/4.3.0' ||
uri === 'https://packages2.fhir.org/packages/hl7.fhir.r5.core/4.5.0' ||
uri === 'https://packages.fhir.org/hl7.fhir.r4.core/4.0.1' ||
uri === 'https://packages.fhir.org/hl7.fhir.r5.core/5.0.0' ||
uri === 'https://packages2.fhir.org/packages/fhir.dicom/2021.4.20210910'
) {
return {
Expand Down Expand Up @@ -321,6 +322,16 @@ describe('#loadDependency()', () => {
);
});

it('should try to load FHIR R5 (5.0.0) from packages.fhir.org when it is not cached', async () => {
await expect(loadDependency('hl7.fhir.r5.core', '5.0.0', defs, 'foo')).rejects.toThrow(
'The package hl7.fhir.r5.core#5.0.0 could not be loaded locally or from the FHIR package registry'
); // the package is never actually added to the cache, since tar is mocked
expectDownloadSequence(
'https://packages.fhir.org/hl7.fhir.r5.core/5.0.0',
path.join('foo', 'hl7.fhir.r5.core#5.0.0')
);
});

it('should try to load a package from packages2.fhir.org when it is not on packages.fhir.org', async () => {
await expect(loadDependency('fhir.dicom', '2021.4.20210910', defs, 'foo')).rejects.toThrow(
'The package fhir.dicom#2021.4.20210910 could not be loaded locally or from the FHIR package registry'
Expand Down Expand Up @@ -724,7 +735,7 @@ describe('#loadSupplementalFHIRPackage()', () => {
const promises = [
'hl7.fhir.r2.core#1.0.2',
'hl7.fhir.r3.core#3.0.2',
'hl7.fhir.r5.core#current'
'hl7.fhir.r5.core#5.0.0'
].map(version => {
return loadSupplementalFHIRPackage(version, defs);
});
Expand All @@ -734,7 +745,7 @@ describe('#loadSupplementalFHIRPackage()', () => {
expect(defs.supplementalFHIRPackages).toEqual([
'hl7.fhir.r2.core#1.0.2',
'hl7.fhir.r3.core#3.0.2',
'hl7.fhir.r5.core#current'
'hl7.fhir.r5.core#5.0.0'
]);
expect(defs.isSupplementalFHIRDefinitions).toBeFalsy();
expect(loggerSpy.getAllLogs('error')).toHaveLength(0);
Expand Down
2 changes: 1 addition & 1 deletion test/fhirtypes/ElementDefinition.bindToVS.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ describe('ElementDefinition R5', () => {
loadFromPath(path.join(__dirname, '..', 'testhelpers', 'testdefs'), 'r5-definitions', defs);
fisher = new TestFisher()
.withFHIR(defs)
.withCachePackageName('hl7.fhir.r5.core#current')
.withCachePackageName('hl7.fhir.r5.core#5.0.0')
.withTestPackageName('r5-definitions');
});
beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion test/fhirtypes/ElementDefinition.constrainType.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ describe('ElementDefinition R5', () => {
fisher = new TestFisher()
.withFHIR(defs)
.withPackage(pkg)
.withCachePackageName('hl7.fhir.r5.core#current')
.withCachePackageName('hl7.fhir.r5.core#5.0.0')
.withTestPackageName('r5-definitions');
});

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit e84d4ab

Please sign in to comment.