Skip to content

Commit cdc1d2a

Browse files
committed
Add itemPopulationContext converter
1 parent 32ecf64 commit cdc1d2a

6 files changed

Lines changed: 35 additions & 13 deletions

File tree

contrib/aidbox-types/index.d.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14056,9 +14056,6 @@ export interface Questionnaire {
1405614056
implicitRules?: uri;
1405714057
/** Questions and sections within the Questionnaire */
1405814058
item?: QuestionnaireItem[];
14059-
/** NOTE: from extension http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemContext */
14060-
/** Deprecated in favour itemPopulationContext */
14061-
itemContext?: Expression;
1406214059
/** NOTE: from extension http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemPopulationContext */
1406314060
/** Specifies a query that identifies the resource (or set of resources for a repeating item) that should be used to populate this Questionnaire or Questionnaire.item on initial population. */
1406414061
itemPopulationContext?: Expression;
@@ -14147,9 +14144,6 @@ export interface QuestionnaireItem {
1414714144
initialExpression?: Expression;
1414814145
/** Nested questionnaire items */
1414914146
item?: QuestionnaireItem[];
14150-
/** NOTE: from extension http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemContext */
14151-
/** Deprecated in favour itemPopulationContext */
14152-
itemContext?: Expression;
1415314147
/** NOTE: from extension http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl */
1415414148
/** The type of data entry control or structure that should be used to render the item. */
1415514149
itemControl?: CodeableConcept;

src/converter/__tests__/resources/questionnaire_fce/assemble_context.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
"status": "active",
88
"assembledFrom": "assemble_context",
99
"assembleContext": ["prefix1", "prefix2"],
10+
"itemPopulationContext": {
11+
"language": "text/fhirpath",
12+
"expression": "%LaunchPatient.name"
13+
},
1014
"item": [
1115
{
1216
"type": "string",

src/converter/__tests__/resources/questionnaire_fhir/assemble_context.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
{
2525
"url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-assembleContext",
2626
"valueString": "prefix2"
27+
},
28+
{
29+
"url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemPopulationContext",
30+
"valueExpression": {
31+
"language": "text/fhirpath",
32+
"expression": "%LaunchPatient.name"
33+
}
2734
}
2835
],
2936
"status": "active",

src/converter/fceToFhir/questionnaire/processExtensions.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export function processExtensions(questionnaire: FCEQuestionnaire): FHIRQuestion
99
targetStructureMap,
1010
assembledFrom,
1111
assembleContext,
12+
itemPopulationContext,
1213
...fhirQuestionnaire
1314
} = questionnaire;
1415

@@ -89,6 +90,13 @@ export function processExtensions(questionnaire: FCEQuestionnaire): FHIRQuestion
8990
);
9091
}
9192

93+
if (itemPopulationContext) {
94+
extensions.push({
95+
url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemPopulationContext',
96+
valueExpression: itemPopulationContext,
97+
});
98+
}
99+
92100
if (extensions.length) {
93101
fhirQuestionnaire.extension = (fhirQuestionnaire.extension ?? []).concat(extensions);
94102
}

src/converter/fhirToFce/questionnaire/processExtensions.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Questionnaire as FHIRQuestionnaire } from 'fhir/r4b';
1+
import { Questionnaire as FHIRQuestionnaire, Expression as FHIRExpression } from 'fhir/r4b';
22

33
export function processExtensions(fhirQuestionnaire: FHIRQuestionnaire): {
44
launchContext?: any[];
@@ -7,13 +7,15 @@ export function processExtensions(fhirQuestionnaire: FHIRQuestionnaire): {
77
targetStructureMap?: any[];
88
assembledFrom?: any;
99
assembleContext?: string[];
10+
itemPopulationContext?: FHIRExpression;
1011
} {
1112
const launchContext = processLaunchContext(fhirQuestionnaire);
1213
const mapping = processMapping(fhirQuestionnaire);
1314
const sourceQueries = processSourceQueries(fhirQuestionnaire);
1415
const targetStructureMap = processTargetStructureMap(fhirQuestionnaire);
1516
const assembledFrom = processAssembledFrom(fhirQuestionnaire);
1617
const assembleContext = processAssembleContext(fhirQuestionnaire);
18+
const itemPopulationContext = processItemPopulationContext(fhirQuestionnaire);
1719

1820
return {
1921
launchContext: launchContext?.length ? launchContext : undefined,
@@ -22,6 +24,7 @@ export function processExtensions(fhirQuestionnaire: FHIRQuestionnaire): {
2224
targetStructureMap: targetStructureMap?.length ? targetStructureMap : undefined,
2325
assembledFrom: assembledFrom ? assembledFrom : undefined,
2426
assembleContext: assembleContext.length ? assembleContext : undefined,
27+
itemPopulationContext: itemPopulationContext ? itemPopulationContext : undefined,
2528
};
2629
}
2730

@@ -122,3 +125,15 @@ function processAssembleContext(fhirQuestionnaire: FHIRQuestionnaire): string[]
122125

123126
return (extensions ?? []).map((extension) => extension.valueString!);
124127
}
128+
129+
function processItemPopulationContext(fhirQuestionnaire: FHIRQuestionnaire): FHIRExpression | undefined {
130+
const extension = fhirQuestionnaire.extension?.find(
131+
(ext) => ext.url === 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemPopulationContext',
132+
);
133+
134+
if (!extension) {
135+
return undefined;
136+
}
137+
138+
return extension.valueExpression;
139+
}

src/fce.types.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ export interface FCEQuestionnaire extends Questionnaire {
1818
/** NOTE: from extension https://jira.hl7.org/browse/FHIR-22356#assembledFrom */
1919
assembledFrom?: string;
2020
item?: FCEQuestionnaireItem[];
21-
/** NOTE: from extension http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemContext */
22-
/** Deprecated in favour itemPopulationContext */
23-
itemContext?: Expression;
2421
/** NOTE: from extension http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemPopulationContext */
2522
/** Specifies a query that identifies the resource (or set of resources for a repeating item) that should be used to populate this Questionnaire or Questionnaire.item on initial population. */
2623
itemPopulationContext?: Expression;
@@ -64,9 +61,6 @@ export interface FCEQuestionnaireItem extends QuestionnaireItem {
6461
initialExpression?: Expression;
6562
/** Nested questionnaire items */
6663
item?: FCEQuestionnaireItem[];
67-
/** NOTE: from extension http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemContext */
68-
/** Deprecated in favour itemPopulationContext */
69-
itemContext?: Expression;
7064
/** NOTE: from extension http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl */
7165
/** The type of data entry control or structure that should be used to render the item. */
7266
itemControl?: CodeableConcept;

0 commit comments

Comments
 (0)