Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/fhirtypes/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,12 @@ export function getUrlFromFshDefinition(
fhirType = 'ValueSet';
} else if (fshDefinition instanceof FshCodeSystem) {
fhirType = 'CodeSystem';
} else if (
fshDefinition instanceof Instance &&
(fshDefinition.instanceOf === 'ValueSet' || fshDefinition.instanceOf === 'CodeSystem')
) {
// match the default URL that the InstanceExporter assigns to definitional instances
fhirType = fshDefinition.instanceOf;
} else {
fhirType = 'StructureDefinition';
}
Expand Down
40 changes: 40 additions & 0 deletions test/import/FSHTank.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,15 @@ describe('FSHTank', () => {
expect(tank.fish('ExtensionInstance|2.0.0', Type.Extension)).toBeUndefined();
});

it('should find an extension defined as an instance definition when fishing by its default url', () => {
expect(
tank.fish(
'http://hl7.org/fhir/us/minimal/StructureDefinition/ExtensionInstance',
Type.Extension
).name
).toBe('ExtensionInstance');
});

it('should only find logical models when logical models are requested', () => {
expect(tank.fish('log1', Type.Logical).name).toBe('Logical1');
expect(
Expand Down Expand Up @@ -744,6 +753,21 @@ describe('FSHTank', () => {
expect(tank.fish('ValueSetInstance|2.0.0', Type.ValueSet)).toBeUndefined();
});

it('should find a valueset defined as an instance definition when fishing by its default url', () => {
expect(
tank.fish('http://hl7.org/fhir/us/minimal/ValueSet/ValueSetInstance2', Type.ValueSet).name
).toBe('ValueSetInstance2');
});

it('should not find a valueset defined as an instance definition when fishing by a StructureDefinition url', () => {
expect(
tank.fish(
'http://hl7.org/fhir/us/minimal/StructureDefinition/ValueSetInstance2',
Type.ValueSet
)
).toBeUndefined();
});

it('should only find codesystems when codesystems are requested', () => {
expect(tank.fish('cs1', Type.CodeSystem).name).toBe('CodeSystem1');
expect(
Expand Down Expand Up @@ -813,6 +837,22 @@ describe('FSHTank', () => {
expect(tank.fish('CodeSystemInstance|2.0.0', Type.CodeSystem)).toBeUndefined();
});

it('should find a codesystem defined as an instance definition when fishing by its default url', () => {
expect(
tank.fish('http://hl7.org/fhir/us/minimal/CodeSystem/CodeSystemInstance2', Type.CodeSystem)
.name
).toBe('CodeSystemInstance2');
});

it('should not find a codesystem defined as an instance definition when fishing by a StructureDefinition url', () => {
expect(
tank.fish(
'http://hl7.org/fhir/us/minimal/StructureDefinition/CodeSystemInstance2',
Type.CodeSystem
)
).toBeUndefined();
});

it('should only find instances when instances are requested', () => {
expect(tank.fish('inst1', Type.Instance).name).toBe('Instance1');
expect(
Expand Down
Loading