Skip to content

Commit

Permalink
isInstance assignment rules bug fix, no copyright change (#1000)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Moesel <[email protected]>
  • Loading branch information
julianxcarter and cmoesel authored Jan 5, 2022
1 parent 2f6adfd commit a5b83e6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/export/InstanceExporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,12 @@ export class InstanceExporter implements Fishable {
if (fshDefinition) {
this.exportInstance(fshDefinition);
result = this.pkg.fish(item, Type.Instance) as InstanceDefinition;
} else {
// If we don't find any Instances with the name, fish for other resources
const fishedFHIR = this.fisher.fishForFHIR(item);
if (fishedFHIR && fishedFHIR.resourceType) {
result = InstanceDefinition.fromJSON(fishedFHIR);
}
}
}
return result;
Expand Down
18 changes: 18 additions & 0 deletions test/export/InstanceExporter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3703,6 +3703,24 @@ describe('InstanceExporter', () => {
]);
});

it('should assign other resources to an instance', () => {
const containedRule1 = new AssignmentRule('contained[0]');
containedRule1.value = 'allergyintolerance-clinical';
containedRule1.isInstance = true;
patientInstance.rules.push(containedRule1); // * contained[0] = allergyintolerance-clinical

const containedRule2 = new AssignmentRule('contained[1]');
containedRule2.value = 'w3c-provenance-activity-type';
containedRule2.isInstance = true;
patientInstance.rules.push(containedRule2); // * contained[1] = w3c-provenance-activity-type

const exported = exportInstance(patientInstance);
expect(exported.contained[0].id).toBe('allergyintolerance-clinical');
expect(exported.contained[0].resourceType).toBe('ValueSet');
expect(exported.contained[1].id).toBe('w3c-provenance-activity-type');
expect(exported.contained[1].resourceType).toBe('CodeSystem');
});

it('should assign an inline resource to an instance element with a specific type', () => {
const bundleValRule = new AssignmentRule('entry[PatientsOnly].resource');
bundleValRule.value = 'MyInlinePatient';
Expand Down

0 comments on commit a5b83e6

Please sign in to comment.