sdc-qrf 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components.d.ts +3 -3
- package/lib/components.js +12 -12
- package/lib/components.js.map +1 -1
- package/lib/context.d.ts +0 -1
- package/lib/converter/extensions.d.ts +35 -0
- package/lib/converter/extensions.js +128 -0
- package/lib/converter/extensions.js.map +1 -0
- package/lib/converter/fceToFhir/index.d.ts +4 -0
- package/lib/converter/fceToFhir/index.js +15 -0
- package/lib/converter/fceToFhir/index.js.map +1 -0
- package/lib/converter/fceToFhir/questionnaire/index.d.ts +3 -0
- package/lib/converter/fceToFhir/questionnaire/index.js +17 -0
- package/lib/converter/fceToFhir/questionnaire/index.js.map +1 -0
- package/lib/converter/fceToFhir/questionnaire/processExtensions.d.ts +3 -0
- package/lib/converter/fceToFhir/questionnaire/processExtensions.js +61 -0
- package/lib/converter/fceToFhir/questionnaire/processExtensions.js.map +1 -0
- package/lib/converter/fceToFhir/questionnaire/processItems.d.ts +3 -0
- package/lib/converter/fceToFhir/questionnaire/processItems.js +144 -0
- package/lib/converter/fceToFhir/questionnaire/processItems.js.map +1 -0
- package/lib/converter/fceToFhir/questionnaire/processMeta.d.ts +3 -0
- package/lib/converter/fceToFhir/questionnaire/processMeta.js +20 -0
- package/lib/converter/fceToFhir/questionnaire/processMeta.js.map +1 -0
- package/lib/converter/fceToFhir/questionnaireResponse/index.d.ts +3 -0
- package/lib/converter/fceToFhir/questionnaireResponse/index.js +20 -0
- package/lib/converter/fceToFhir/questionnaireResponse/index.js.map +1 -0
- package/lib/converter/fceToFhir/questionnaireResponse/processAnswers.d.ts +2 -0
- package/lib/converter/fceToFhir/questionnaireResponse/processAnswers.js +48 -0
- package/lib/converter/fceToFhir/questionnaireResponse/processAnswers.js.map +1 -0
- package/lib/converter/fceToFhir/questionnaireResponse/processMeta.d.ts +3 -0
- package/lib/converter/fceToFhir/questionnaireResponse/processMeta.js +18 -0
- package/lib/converter/fceToFhir/questionnaireResponse/processMeta.js.map +1 -0
- package/lib/converter/fceToFhir/questionnaireResponse/processReference.d.ts +3 -0
- package/lib/converter/fceToFhir/questionnaireResponse/processReference.js +19 -0
- package/lib/converter/fceToFhir/questionnaireResponse/processReference.js.map +1 -0
- package/lib/converter/fhirToFce/index.d.ts +4 -0
- package/lib/converter/fhirToFce/index.js +15 -0
- package/lib/converter/fhirToFce/index.js.map +1 -0
- package/lib/converter/fhirToFce/questionnaire/index.d.ts +3 -0
- package/lib/converter/fhirToFce/questionnaire/index.js +21 -0
- package/lib/converter/fhirToFce/questionnaire/index.js.map +1 -0
- package/lib/converter/fhirToFce/questionnaire/processExtensions.d.ts +8 -0
- package/lib/converter/fhirToFce/questionnaire/processExtensions.js +89 -0
- package/lib/converter/fhirToFce/questionnaire/processExtensions.js.map +1 -0
- package/lib/converter/fhirToFce/questionnaire/processItems.d.ts +3 -0
- package/lib/converter/fhirToFce/questionnaire/processItems.js +131 -0
- package/lib/converter/fhirToFce/questionnaire/processItems.js.map +1 -0
- package/lib/converter/fhirToFce/questionnaire/processMeta.d.ts +32 -0
- package/lib/converter/fhirToFce/questionnaire/processMeta.js +14 -0
- package/lib/converter/fhirToFce/questionnaire/processMeta.js.map +1 -0
- package/lib/converter/fhirToFce/questionnaireResponse/index.d.ts +3 -0
- package/lib/converter/fhirToFce/questionnaireResponse/index.js +20 -0
- package/lib/converter/fhirToFce/questionnaireResponse/index.js.map +1 -0
- package/lib/converter/fhirToFce/questionnaireResponse/processAnswers.d.ts +2 -0
- package/lib/converter/fhirToFce/questionnaireResponse/processAnswers.js +46 -0
- package/lib/converter/fhirToFce/questionnaireResponse/processAnswers.js.map +1 -0
- package/lib/converter/fhirToFce/questionnaireResponse/processMeta.d.ts +3 -0
- package/lib/converter/fhirToFce/questionnaireResponse/processMeta.js +15 -0
- package/lib/converter/fhirToFce/questionnaireResponse/processMeta.js.map +1 -0
- package/lib/converter/fhirToFce/questionnaireResponse/processReference.d.ts +3 -0
- package/lib/converter/fhirToFce/questionnaireResponse/processReference.js +18 -0
- package/lib/converter/fhirToFce/questionnaireResponse/processReference.js.map +1 -0
- package/lib/converter/fhirToFce/utils.d.ts +3 -0
- package/lib/converter/fhirToFce/utils.js +37 -0
- package/lib/converter/fhirToFce/utils.js.map +1 -0
- package/lib/converter/index.d.ts +12 -0
- package/lib/converter/index.js +84 -0
- package/lib/converter/index.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/setupTests.d.ts +1 -0
- package/lib/setupTests.js +4 -0
- package/lib/setupTests.js.map +1 -0
- package/lib/types.d.ts +10 -10
- package/lib/utils.d.ts +4 -1
- package/lib/utils.js +9 -2
- package/lib/utils.js.map +1 -1
- package/package.json +4 -5
- package/src/components.tsx +12 -12
- package/src/converter/__tests__/fce.test.ts +224 -0
- package/src/converter/__tests__/resources/questionnaire_fce/allergies.json +405 -0
- package/src/converter/__tests__/resources/questionnaire_fce/beverages.json +72 -0
- package/src/converter/__tests__/resources/questionnaire_fce/choice_answer_option.json +53 -0
- package/src/converter/__tests__/resources/questionnaire_fce/consent.json +86 -0
- package/src/converter/__tests__/resources/questionnaire_fce/enable_when.json +103 -0
- package/src/converter/__tests__/resources/questionnaire_fce/encounter_create.json +126 -0
- package/src/converter/__tests__/resources/questionnaire_fce/gad_7.json +459 -0
- package/src/converter/__tests__/resources/questionnaire_fce/immunization.json +182 -0
- package/src/converter/__tests__/resources/questionnaire_fce/medication.json +189 -0
- package/src/converter/__tests__/resources/questionnaire_fce/multiple_type_launch_context.json +406 -0
- package/src/converter/__tests__/resources/questionnaire_fce/patient_create.json +84 -0
- package/src/converter/__tests__/resources/questionnaire_fce/patient_edit.json +125 -0
- package/src/converter/__tests__/resources/questionnaire_fce/phq_2_phq_9.json +552 -0
- package/src/converter/__tests__/resources/questionnaire_fce/physicalexam.json +385 -0
- package/src/converter/__tests__/resources/questionnaire_fce/practitioner_create.json +90 -0
- package/src/converter/__tests__/resources/questionnaire_fce/practitioner_create_structure_map.json +91 -0
- package/src/converter/__tests__/resources/questionnaire_fce/practitioner_edit.json +144 -0
- package/src/converter/__tests__/resources/questionnaire_fce/practitioner_role_create.json +37 -0
- package/src/converter/__tests__/resources/questionnaire_fce/public_appointment.json +91 -0
- package/src/converter/__tests__/resources/questionnaire_fce/review_of_systems.json +389 -0
- package/src/converter/__tests__/resources/questionnaire_fce/source_queries.json +34 -0
- package/src/converter/__tests__/resources/questionnaire_fce/vitals.json +234 -0
- package/src/converter/__tests__/resources/questionnaire_fhir/allergies.json +433 -0
- package/src/converter/__tests__/resources/questionnaire_fhir/beverages.json +99 -0
- package/src/converter/__tests__/resources/questionnaire_fhir/choice_answer_option.json +49 -0
- package/src/converter/__tests__/resources/questionnaire_fhir/consent.json +119 -0
- package/src/converter/__tests__/resources/questionnaire_fhir/enable_when.json +87 -0
- package/src/converter/__tests__/resources/questionnaire_fhir/encounter_create.json +171 -0
- package/src/converter/__tests__/resources/questionnaire_fhir/gad_7.json +489 -0
- package/src/converter/__tests__/resources/questionnaire_fhir/immunization.json +215 -0
- package/src/converter/__tests__/resources/questionnaire_fhir/medication.json +226 -0
- package/src/converter/__tests__/resources/questionnaire_fhir/multiple_type_launch_context.json +416 -0
- package/src/converter/__tests__/resources/questionnaire_fhir/patient_create.json +97 -0
- package/src/converter/__tests__/resources/questionnaire_fhir/patient_edit.json +183 -0
- package/src/converter/__tests__/resources/questionnaire_fhir/phq_2_phq_9.json +580 -0
- package/src/converter/__tests__/resources/questionnaire_fhir/physicalexam.json +544 -0
- package/src/converter/__tests__/resources/questionnaire_fhir/practitioner_create.json +87 -0
- package/src/converter/__tests__/resources/questionnaire_fhir/practitioner_create_structure_map.json +91 -0
- package/src/converter/__tests__/resources/questionnaire_fhir/practitioner_edit.json +193 -0
- package/src/converter/__tests__/resources/questionnaire_fhir/practitioner_role_create.json +44 -0
- package/src/converter/__tests__/resources/questionnaire_fhir/public_appointment.json +116 -0
- package/src/converter/__tests__/resources/questionnaire_fhir/review_of_systems.json +368 -0
- package/src/converter/__tests__/resources/questionnaire_fhir/source_queries.json +37 -0
- package/src/converter/__tests__/resources/questionnaire_fhir/vitals.json +317 -0
- package/src/converter/__tests__/resources/questionnaire_response_fce/allergies_inprogress.json +78 -0
- package/src/converter/__tests__/resources/questionnaire_response_fce/cardiology.json +96 -0
- package/src/converter/__tests__/resources/questionnaire_response_fce/few_answers.json +48 -0
- package/src/converter/__tests__/resources/questionnaire_response_fce/gad_7.json +165 -0
- package/src/converter/__tests__/resources/questionnaire_response_fce/immunization.json +86 -0
- package/src/converter/__tests__/resources/questionnaire_response_fce/medication.json +116 -0
- package/src/converter/__tests__/resources/questionnaire_response_fce/new_appointment.json +96 -0
- package/src/converter/__tests__/resources/questionnaire_response_fce/patient.json +87 -0
- package/src/converter/__tests__/resources/questionnaire_response_fce/phq_2_phq_9.json +193 -0
- package/src/converter/__tests__/resources/questionnaire_response_fce/physicalexam.json +187 -0
- package/src/converter/__tests__/resources/questionnaire_response_fce/practitioner.json +57 -0
- package/src/converter/__tests__/resources/questionnaire_response_fce/reference_answer_with_assoc.json +147 -0
- package/src/converter/__tests__/resources/questionnaire_response_fce/review_of_systems.json +129 -0
- package/src/converter/__tests__/resources/questionnaire_response_fce/vitals.json +168 -0
- package/src/converter/__tests__/resources/questionnaire_response_fhir/allergies_inprogress.json +73 -0
- package/src/converter/__tests__/resources/questionnaire_response_fhir/cardiology.json +87 -0
- package/src/converter/__tests__/resources/questionnaire_response_fhir/few_answers.json +46 -0
- package/src/converter/__tests__/resources/questionnaire_response_fhir/gad_7.json +146 -0
- package/src/converter/__tests__/resources/questionnaire_response_fhir/immunization.json +77 -0
- package/src/converter/__tests__/resources/questionnaire_response_fhir/medication.json +101 -0
- package/src/converter/__tests__/resources/questionnaire_response_fhir/new_appointment.json +86 -0
- package/src/converter/__tests__/resources/questionnaire_response_fhir/patient.json +78 -0
- package/src/converter/__tests__/resources/questionnaire_response_fhir/phq_2_phq_9.json +170 -0
- package/src/converter/__tests__/resources/questionnaire_response_fhir/physicalexam.json +158 -0
- package/src/converter/__tests__/resources/questionnaire_response_fhir/practitioner.json +54 -0
- package/src/converter/__tests__/resources/questionnaire_response_fhir/reference_answer_with_assoc.json +86 -0
- package/src/converter/__tests__/resources/questionnaire_response_fhir/review_of_systems.json +118 -0
- package/src/converter/__tests__/resources/questionnaire_response_fhir/vitals.json +145 -0
- package/src/converter/extensions.ts +149 -0
- package/src/converter/fceToFhir/index.ts +27 -0
- package/src/converter/fceToFhir/questionnaire/index.ts +15 -0
- package/src/converter/fceToFhir/questionnaire/processExtensions.ts +75 -0
- package/src/converter/fceToFhir/questionnaire/processItems.ts +194 -0
- package/src/converter/fceToFhir/questionnaire/processMeta.ts +19 -0
- package/src/converter/fceToFhir/questionnaireResponse/index.ts +21 -0
- package/src/converter/fceToFhir/questionnaireResponse/processAnswers.ts +53 -0
- package/src/converter/fceToFhir/questionnaireResponse/processMeta.ts +16 -0
- package/src/converter/fceToFhir/questionnaireResponse/processReference.ts +24 -0
- package/src/converter/fhirToFce/index.ts +27 -0
- package/src/converter/fhirToFce/questionnaire/index.ts +25 -0
- package/src/converter/fhirToFce/questionnaire/processExtensions.ts +113 -0
- package/src/converter/fhirToFce/questionnaire/processItems.ts +159 -0
- package/src/converter/fhirToFce/questionnaire/processMeta.ts +17 -0
- package/src/converter/fhirToFce/questionnaireResponse/index.ts +21 -0
- package/src/converter/fhirToFce/questionnaireResponse/processAnswers.ts +53 -0
- package/src/converter/fhirToFce/questionnaireResponse/processMeta.ts +14 -0
- package/src/converter/fhirToFce/questionnaireResponse/processReference.ts +20 -0
- package/src/converter/fhirToFce/utils.ts +36 -0
- package/src/converter/index.ts +106 -0
- package/src/index.ts +1 -0
- package/src/setupTests.ts +1 -0
- package/src/utils.ts +13 -2
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Quantity as QuantityFHIR,
|
|
3
|
+
QuestionnaireItemEnableWhen as FHIRQuestionnaireItemEnableWhen,
|
|
4
|
+
QuestionnaireItem as FHIRQuestionnaireItem,
|
|
5
|
+
QuestionnaireItemAnswerOption as FHIRQuestionnaireItemAnswerOption,
|
|
6
|
+
QuestionnaireItemInitial as FHIRQuestionnaireItemInitial,
|
|
7
|
+
} from 'fhir/r4b';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
QuestionnaireItem as FCEQuestionnaireItem,
|
|
11
|
+
QuestionnaireItemEnableWhen as FCEQuestionnaireItemEnableWhen,
|
|
12
|
+
QuestionnaireItemEnableWhenAnswer as FCEQuestionnaireItemEnableWhenAnswer,
|
|
13
|
+
QuestionnaireItemAnswerOption as FCEQuestionnaireItemAnswerOption,
|
|
14
|
+
QuestionnaireItemInitial as FCEQuestionnaireItemInitial,
|
|
15
|
+
} from 'shared/src/contrib/aidbox';
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
convertFromFHIRExtension,
|
|
19
|
+
convertToFHIRExtension,
|
|
20
|
+
toFHIRReference,
|
|
21
|
+
} from '../../../converter';
|
|
22
|
+
|
|
23
|
+
export function processItems(items: FCEQuestionnaireItem[]): FHIRQuestionnaireItem[] {
|
|
24
|
+
return items.map((item) => {
|
|
25
|
+
const extensions = convertToFHIRExtension(item);
|
|
26
|
+
if (extensions.length > 0) {
|
|
27
|
+
const fieldsToOmit = extensions
|
|
28
|
+
.map(convertFromFHIRExtension)
|
|
29
|
+
.filter((ext): ext is Partial<FCEQuestionnaireItem> => ext !== undefined)
|
|
30
|
+
.flatMap(Object.keys);
|
|
31
|
+
for (const field of fieldsToOmit) {
|
|
32
|
+
delete item[field];
|
|
33
|
+
}
|
|
34
|
+
item.extension = extensions.sort();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const {
|
|
38
|
+
enableBehavior,
|
|
39
|
+
enableWhen,
|
|
40
|
+
answerOption,
|
|
41
|
+
initial,
|
|
42
|
+
item: nestedItems,
|
|
43
|
+
type,
|
|
44
|
+
...commonOptions
|
|
45
|
+
} = item;
|
|
46
|
+
|
|
47
|
+
const fhirItem: FHIRQuestionnaireItem = {
|
|
48
|
+
...commonOptions,
|
|
49
|
+
type: type as FHIRQuestionnaireItem['type'],
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
if (answerOption !== undefined) {
|
|
53
|
+
fhirItem.answerOption = processAnswerOption(answerOption);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (enableBehavior !== undefined) {
|
|
57
|
+
fhirItem.enableBehavior = enableBehavior as FHIRQuestionnaireItem['enableBehavior'];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (enableWhen !== undefined) {
|
|
61
|
+
fhirItem.enableWhen = processEnableWhen(enableWhen);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (initial) {
|
|
65
|
+
fhirItem.initial = processInitial(initial);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (nestedItems) {
|
|
69
|
+
fhirItem.item = processItems(nestedItems);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return fhirItem;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const convertEnableWhen = (
|
|
77
|
+
answer: FCEQuestionnaireItemEnableWhenAnswer,
|
|
78
|
+
answerType: string,
|
|
79
|
+
result: FHIRQuestionnaireItemEnableWhen,
|
|
80
|
+
) => {
|
|
81
|
+
if (answer[answerType] !== undefined) {
|
|
82
|
+
switch (answerType) {
|
|
83
|
+
case 'boolean':
|
|
84
|
+
result.answerBoolean = answer[answerType];
|
|
85
|
+
break;
|
|
86
|
+
case 'decimal':
|
|
87
|
+
result.answerDecimal = answer[answerType];
|
|
88
|
+
break;
|
|
89
|
+
case 'integer':
|
|
90
|
+
result.answerInteger = answer[answerType];
|
|
91
|
+
break;
|
|
92
|
+
case 'date':
|
|
93
|
+
result.answerDate = answer[answerType];
|
|
94
|
+
break;
|
|
95
|
+
case 'dateTime':
|
|
96
|
+
result.answerDateTime = answer[answerType];
|
|
97
|
+
break;
|
|
98
|
+
case 'time':
|
|
99
|
+
result.answerTime = answer[answerType];
|
|
100
|
+
break;
|
|
101
|
+
case 'string':
|
|
102
|
+
result.answerString = answer[answerType];
|
|
103
|
+
break;
|
|
104
|
+
case 'Coding':
|
|
105
|
+
result.answerCoding = answer[answerType];
|
|
106
|
+
break;
|
|
107
|
+
case 'Quantity':
|
|
108
|
+
result.answerQuantity = answer[answerType] as QuantityFHIR;
|
|
109
|
+
break;
|
|
110
|
+
case 'Reference':
|
|
111
|
+
result.answerReference = toFHIRReference(answer[answerType]);
|
|
112
|
+
break;
|
|
113
|
+
default:
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
function processAnswerOption(
|
|
120
|
+
options: FCEQuestionnaireItemAnswerOption[],
|
|
121
|
+
): FHIRQuestionnaireItemAnswerOption[] {
|
|
122
|
+
return options.map((option) => {
|
|
123
|
+
const { value, ...commonOptions } = option;
|
|
124
|
+
|
|
125
|
+
const fhirOption: FHIRQuestionnaireItemAnswerOption = { ...commonOptions };
|
|
126
|
+
|
|
127
|
+
if (value?.Coding) {
|
|
128
|
+
fhirOption.valueCoding = value.Coding;
|
|
129
|
+
}
|
|
130
|
+
if (value?.string) {
|
|
131
|
+
fhirOption.valueString = value.string;
|
|
132
|
+
}
|
|
133
|
+
if (value?.Reference) {
|
|
134
|
+
fhirOption.valueReference = toFHIRReference(value.Reference);
|
|
135
|
+
}
|
|
136
|
+
if (value?.date) {
|
|
137
|
+
fhirOption.valueDate = value.date;
|
|
138
|
+
}
|
|
139
|
+
if (value?.integer) {
|
|
140
|
+
fhirOption.valueInteger = value.integer;
|
|
141
|
+
}
|
|
142
|
+
if (value?.time) {
|
|
143
|
+
fhirOption.valueTime = value.time;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return fhirOption;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function processEnableWhen(options: FCEQuestionnaireItemEnableWhen[]) {
|
|
151
|
+
return options.map((item: FCEQuestionnaireItemEnableWhen) => {
|
|
152
|
+
const { question, operator, answer } = item;
|
|
153
|
+
const result: FHIRQuestionnaireItemEnableWhen = {
|
|
154
|
+
question,
|
|
155
|
+
operator: operator as 'exists' | '=' | '!=' | '>' | '<' | '>=' | '<=',
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
if (!answer) {
|
|
159
|
+
return result;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const answerTypes = [
|
|
163
|
+
'boolean',
|
|
164
|
+
'decimal',
|
|
165
|
+
'integer',
|
|
166
|
+
'date',
|
|
167
|
+
'dateTime',
|
|
168
|
+
'time',
|
|
169
|
+
'string',
|
|
170
|
+
'Coding',
|
|
171
|
+
'Quantity',
|
|
172
|
+
'Reference',
|
|
173
|
+
];
|
|
174
|
+
|
|
175
|
+
answerTypes.forEach((answerType) => {
|
|
176
|
+
convertEnableWhen(answer, answerType, result);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
return result;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function processInitial(options: FCEQuestionnaireItemInitial[]): FHIRQuestionnaireItemInitial[] {
|
|
184
|
+
return options.map((entry) => {
|
|
185
|
+
const result: FHIRQuestionnaireItemInitial = {};
|
|
186
|
+
if (entry.value?.boolean !== undefined) {
|
|
187
|
+
result.valueBoolean = entry.value.boolean;
|
|
188
|
+
}
|
|
189
|
+
if (entry.value?.Coding !== undefined) {
|
|
190
|
+
result.valueCoding = entry.value.Coding;
|
|
191
|
+
}
|
|
192
|
+
return result;
|
|
193
|
+
});
|
|
194
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Meta as FHIRMeta } from 'fhir/r4b';
|
|
2
|
+
|
|
3
|
+
import { Meta as FCEMeta } from 'shared/src/contrib/aidbox';
|
|
4
|
+
|
|
5
|
+
export function processMeta(meta: FCEMeta): FHIRMeta {
|
|
6
|
+
const { createdAt, ...fhirMeta } = meta;
|
|
7
|
+
|
|
8
|
+
if (createdAt) {
|
|
9
|
+
fhirMeta.extension = [
|
|
10
|
+
...(meta.extension ?? []),
|
|
11
|
+
{
|
|
12
|
+
url: 'ex:createdAt',
|
|
13
|
+
valueInstant: createdAt,
|
|
14
|
+
},
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return fhirMeta;
|
|
19
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { QuestionnaireResponse as FHIRQuestionnaireResponse } from 'fhir/r4b';
|
|
2
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
3
|
+
|
|
4
|
+
import { QuestionnaireResponse as FCEQuestionnaireResponse } from 'shared/src/contrib/aidbox';
|
|
5
|
+
|
|
6
|
+
import { processAnswers } from './processAnswers';
|
|
7
|
+
import { processMeta } from './processMeta';
|
|
8
|
+
import { processReference } from './processReference';
|
|
9
|
+
|
|
10
|
+
export function convertQuestionnaireResponse(
|
|
11
|
+
questionnaireResponse: FCEQuestionnaireResponse,
|
|
12
|
+
): FHIRQuestionnaireResponse {
|
|
13
|
+
questionnaireResponse = cloneDeep(questionnaireResponse);
|
|
14
|
+
if (questionnaireResponse.item) {
|
|
15
|
+
processAnswers(questionnaireResponse.item);
|
|
16
|
+
}
|
|
17
|
+
questionnaireResponse.meta = questionnaireResponse.meta
|
|
18
|
+
? processMeta(questionnaireResponse.meta)
|
|
19
|
+
: questionnaireResponse.meta;
|
|
20
|
+
return processReference(questionnaireResponse);
|
|
21
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { QuestionnaireResponseItemAnswer as FHIRQuestionnaireResponseItemAnswer } from 'fhir/r4b';
|
|
2
|
+
import isEmpty from 'lodash/isEmpty';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
QuestionnaireResponseItem as FCEQuestionnaireResponseItem,
|
|
6
|
+
QuestionnaireResponseItemAnswer as FCEQuestionnaireResponseItemAnswer,
|
|
7
|
+
} from 'shared/src/contrib/aidbox';
|
|
8
|
+
|
|
9
|
+
import { toFHIRReference } from '../../../converter';
|
|
10
|
+
|
|
11
|
+
export function processAnswers(items: FCEQuestionnaireResponseItem[]) {
|
|
12
|
+
for (const item of items) {
|
|
13
|
+
if (item.answer) {
|
|
14
|
+
item.answer = item.answer.map(processAnswer).filter((answer) => !isEmpty(answer));
|
|
15
|
+
}
|
|
16
|
+
if (item.item) {
|
|
17
|
+
processAnswers(item.item);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function processAnswer(
|
|
23
|
+
answerItem: FCEQuestionnaireResponseItemAnswer,
|
|
24
|
+
): FHIRQuestionnaireResponseItemAnswer {
|
|
25
|
+
if (!answerItem.value) {
|
|
26
|
+
return answerItem;
|
|
27
|
+
}
|
|
28
|
+
const { value, ...item } = answerItem;
|
|
29
|
+
const fhirAnswerItem: FHIRQuestionnaireResponseItemAnswer = item;
|
|
30
|
+
const valueMappings = {
|
|
31
|
+
string: 'valueString',
|
|
32
|
+
decimal: 'valueDecimal',
|
|
33
|
+
integer: 'valueInteger',
|
|
34
|
+
boolean: 'valueBoolean',
|
|
35
|
+
Coding: 'valueCoding',
|
|
36
|
+
date: 'valueDate',
|
|
37
|
+
dateTime: 'valueDateTime',
|
|
38
|
+
time: 'valueTime',
|
|
39
|
+
};
|
|
40
|
+
for (const key in valueMappings) {
|
|
41
|
+
if (key in value) {
|
|
42
|
+
const newKey = valueMappings[key];
|
|
43
|
+
if (newKey) {
|
|
44
|
+
fhirAnswerItem[newKey] = value[key];
|
|
45
|
+
}
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (value.Reference) {
|
|
50
|
+
fhirAnswerItem.valueReference = toFHIRReference(value.Reference);
|
|
51
|
+
}
|
|
52
|
+
return fhirAnswerItem;
|
|
53
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Meta as FHIRMeta } from 'fhir/r4b';
|
|
2
|
+
|
|
3
|
+
import { Meta as FCEMeta } from 'shared/src/contrib/aidbox';
|
|
4
|
+
|
|
5
|
+
export function processMeta(meta: FCEMeta): FHIRMeta {
|
|
6
|
+
const { createdAt, ...fhirMeta } = meta;
|
|
7
|
+
if (createdAt) {
|
|
8
|
+
fhirMeta.extension = [
|
|
9
|
+
{
|
|
10
|
+
url: 'ex:createdAt',
|
|
11
|
+
valueInstant: meta.createdAt,
|
|
12
|
+
},
|
|
13
|
+
];
|
|
14
|
+
}
|
|
15
|
+
return fhirMeta;
|
|
16
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { QuestionnaireResponse as FHIRQuestionnaireResponse } from 'fhir/r4b';
|
|
2
|
+
|
|
3
|
+
import { QuestionnaireResponse as FCEQuestionnaireResponse } from 'shared/src/contrib/aidbox';
|
|
4
|
+
|
|
5
|
+
export function processReference(fceQR: FCEQuestionnaireResponse): FHIRQuestionnaireResponse {
|
|
6
|
+
const { encounter, source, ...commonProprties } = fceQR;
|
|
7
|
+
const fhirQuestionnaireResponse: FHIRQuestionnaireResponse =
|
|
8
|
+
commonProprties as FHIRQuestionnaireResponse;
|
|
9
|
+
if (encounter && encounter.resourceType && encounter.id) {
|
|
10
|
+
const { id, resourceType, ...encounterProperties } = encounter;
|
|
11
|
+
fhirQuestionnaireResponse.encounter = {
|
|
12
|
+
reference: `${resourceType}/${id}`,
|
|
13
|
+
...encounterProperties,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
if (source && source.resourceType && source.id) {
|
|
17
|
+
const { id, resourceType, ...sourceProperties } = source;
|
|
18
|
+
fhirQuestionnaireResponse.source = {
|
|
19
|
+
reference: `${resourceType}/${id}`,
|
|
20
|
+
...sourceProperties,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return fhirQuestionnaireResponse;
|
|
24
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Questionnaire as FHIRQuestionnaire,
|
|
3
|
+
QuestionnaireResponse as FHIRQuestionnaireResponse,
|
|
4
|
+
} from 'fhir/r4b';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Questionnaire as FCEQuestionnaire,
|
|
8
|
+
QuestionnaireResponse as FCEQuestionnaireResponse,
|
|
9
|
+
} from 'shared/src/contrib/aidbox';
|
|
10
|
+
|
|
11
|
+
import { convertQuestionnaire } from './questionnaire';
|
|
12
|
+
import { convertQuestionnaireResponse } from './questionnaireResponse';
|
|
13
|
+
|
|
14
|
+
export function toFirstClassExtension(
|
|
15
|
+
fhirQuestionnaireResponse: FHIRQuestionnaireResponse,
|
|
16
|
+
): FCEQuestionnaireResponse;
|
|
17
|
+
export function toFirstClassExtension(fhirQuestionnaire: FHIRQuestionnaire): FCEQuestionnaire;
|
|
18
|
+
export function toFirstClassExtension(
|
|
19
|
+
fhirResource: FHIRQuestionnaire | FHIRQuestionnaireResponse,
|
|
20
|
+
): FCEQuestionnaireResponse | FCEQuestionnaire {
|
|
21
|
+
switch (fhirResource.resourceType) {
|
|
22
|
+
case 'Questionnaire':
|
|
23
|
+
return convertQuestionnaire(fhirResource);
|
|
24
|
+
case 'QuestionnaireResponse':
|
|
25
|
+
return convertQuestionnaireResponse(fhirResource);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Questionnaire as FHIRQuestionnaire } from 'fhir/r4b';
|
|
2
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
3
|
+
|
|
4
|
+
import { Questionnaire as FCEQuestionnaire } from 'shared/src/contrib/aidbox';
|
|
5
|
+
|
|
6
|
+
import { processExtensions } from './processExtensions';
|
|
7
|
+
import { processItems } from './processItems';
|
|
8
|
+
import { processMeta } from './processMeta';
|
|
9
|
+
import { checkFhirQuestionnaireProfile, trimUndefined } from '../utils';
|
|
10
|
+
|
|
11
|
+
export function convertQuestionnaire(fhirQuestionnaire: FHIRQuestionnaire): FCEQuestionnaire {
|
|
12
|
+
checkFhirQuestionnaireProfile(fhirQuestionnaire);
|
|
13
|
+
fhirQuestionnaire = cloneDeep(fhirQuestionnaire);
|
|
14
|
+
const meta = processMeta(fhirQuestionnaire);
|
|
15
|
+
const item = processItems(fhirQuestionnaire);
|
|
16
|
+
const extensions = processExtensions(fhirQuestionnaire);
|
|
17
|
+
const questionnaire = trimUndefined({
|
|
18
|
+
...fhirQuestionnaire,
|
|
19
|
+
meta,
|
|
20
|
+
item,
|
|
21
|
+
...extensions,
|
|
22
|
+
extension: undefined,
|
|
23
|
+
});
|
|
24
|
+
return questionnaire as unknown as FCEQuestionnaire;
|
|
25
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Questionnaire as FHIRQuestionnaire } from 'fhir/r4b';
|
|
2
|
+
|
|
3
|
+
export function processExtensions(fhirQuestionnaire: FHIRQuestionnaire): {
|
|
4
|
+
launchContext?: any[];
|
|
5
|
+
mapping?: any[];
|
|
6
|
+
sourceQueries?: any[];
|
|
7
|
+
targetStructureMap?: any[];
|
|
8
|
+
} {
|
|
9
|
+
const launchContext = processLaunchContext(fhirQuestionnaire);
|
|
10
|
+
const mapping = processMapping(fhirQuestionnaire);
|
|
11
|
+
const sourceQueries = processSourceQueries(fhirQuestionnaire);
|
|
12
|
+
const targetStructureMap = processTargetStructureMap(fhirQuestionnaire);
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
launchContext: launchContext?.length ? launchContext : undefined,
|
|
16
|
+
mapping: mapping?.length ? mapping : undefined,
|
|
17
|
+
sourceQueries: sourceQueries?.length ? sourceQueries : undefined,
|
|
18
|
+
targetStructureMap: targetStructureMap?.length ? targetStructureMap : undefined,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function processLaunchContext(fhirQuestionnaire: FHIRQuestionnaire): any[] | undefined {
|
|
23
|
+
let launchContextExtensions = fhirQuestionnaire.extension ?? [];
|
|
24
|
+
|
|
25
|
+
launchContextExtensions = launchContextExtensions.filter(
|
|
26
|
+
(ext) =>
|
|
27
|
+
ext.url ===
|
|
28
|
+
'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-launchContext',
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
if (launchContextExtensions.length === 0) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const launchContextArray = [];
|
|
36
|
+
for (const launchContextExtension of launchContextExtensions) {
|
|
37
|
+
const nameExtension = launchContextExtension.extension?.find((ext) => ext.url === 'name');
|
|
38
|
+
const typeExtensions = launchContextExtension.extension?.filter(
|
|
39
|
+
(ext) => ext.url === 'type',
|
|
40
|
+
);
|
|
41
|
+
const descriptionExtension = launchContextExtension.extension?.find(
|
|
42
|
+
(ext) => ext.url === 'description',
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const nameCode = nameExtension?.valueCoding?.code;
|
|
46
|
+
const typeCodes = typeExtensions?.map((typeExtension) => typeExtension.valueCode!);
|
|
47
|
+
const description = descriptionExtension?.valueString;
|
|
48
|
+
|
|
49
|
+
let contextFound = false;
|
|
50
|
+
for (const context of launchContextArray) {
|
|
51
|
+
if (context.name.code === nameCode) {
|
|
52
|
+
context.type.push(...(typeCodes ?? []));
|
|
53
|
+
contextFound = true;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!contextFound) {
|
|
59
|
+
const context: any = {
|
|
60
|
+
name: nameExtension?.valueCoding,
|
|
61
|
+
type: typeCodes ?? [],
|
|
62
|
+
};
|
|
63
|
+
if (description) {
|
|
64
|
+
context.description = description;
|
|
65
|
+
}
|
|
66
|
+
launchContextArray.push(context);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return launchContextArray;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function processMapping(fhirQuestionnaire: FHIRQuestionnaire): any[] | undefined {
|
|
74
|
+
const mapperExtensions = fhirQuestionnaire.extension?.filter(
|
|
75
|
+
(ext: any) => ext.url === 'http://beda.software/fhir-extensions/questionnaire-mapper',
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
if (!mapperExtensions) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return mapperExtensions.map((mapperExtension: any) => ({
|
|
83
|
+
id: mapperExtension.valueReference?.reference?.split('/')[1],
|
|
84
|
+
resourceType: 'Mapping',
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function processSourceQueries(fhirQuestionnaire: FHIRQuestionnaire): any[] {
|
|
89
|
+
const extensions =
|
|
90
|
+
fhirQuestionnaire.extension?.filter(
|
|
91
|
+
(ext) =>
|
|
92
|
+
ext.url ===
|
|
93
|
+
'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-sourceQueries',
|
|
94
|
+
) ?? [];
|
|
95
|
+
|
|
96
|
+
return extensions.map((ext) => ({
|
|
97
|
+
localRef: ext.valueReference?.reference?.substring(1) ?? '',
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function processTargetStructureMap(fhirQuestionnaire: FHIRQuestionnaire): string[] | undefined {
|
|
102
|
+
const extensions = fhirQuestionnaire.extension?.filter(
|
|
103
|
+
(ext) =>
|
|
104
|
+
ext.url ===
|
|
105
|
+
'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-targetStructureMap',
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
if (!extensions) {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return extensions.map((extension) => extension.valueCanonical!);
|
|
113
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import {
|
|
2
|
+
QuestionnaireItemEnableWhen as FHIRQuestionnaireItemEnableWhen,
|
|
3
|
+
Questionnaire as FHIRQuestionnaire,
|
|
4
|
+
QuestionnaireItem as FHIRQuestionnaireItem,
|
|
5
|
+
QuestionnaireItemAnswerOption as FHIRQuestionnaireItemAnswerOption,
|
|
6
|
+
QuestionnaireItemInitial as FHIRQuestionnaireItemInitial,
|
|
7
|
+
} from 'fhir/r4b';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
QuestionnaireItem as FCEQuestionnaireItem,
|
|
11
|
+
QuestionnaireItemEnableWhen as FCEQuestionnaireItemEnableWhen,
|
|
12
|
+
QuestionnaireItemEnableWhenAnswer as FCEQuestionnaireItemEnableWhenAnswer,
|
|
13
|
+
QuestionnaireItemAnswerOption as FCEQuestionnaireItemAnswerOption,
|
|
14
|
+
QuestionnaireItemInitial as FCEQuestionnaireItemInitial,
|
|
15
|
+
} from 'shared/src/contrib/aidbox';
|
|
16
|
+
|
|
17
|
+
import { convertFromFHIRExtension, findExtension, fromFHIRReference } from '../../../converter';
|
|
18
|
+
import { ExtensionIdentifier } from '../../../converter/extensions';
|
|
19
|
+
|
|
20
|
+
export function processItems(fhirQuestionnaire: FHIRQuestionnaire) {
|
|
21
|
+
return fhirQuestionnaire.item?.map(convertItemProperties);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function convertItemProperties(item: FHIRQuestionnaireItem): FCEQuestionnaireItem {
|
|
25
|
+
const updatedProperties = getUpdatedPropertiesFromItem(item);
|
|
26
|
+
const newItem = { ...item, ...updatedProperties };
|
|
27
|
+
|
|
28
|
+
newItem.item = item.item?.map((nestedItem) => convertItemProperties(nestedItem));
|
|
29
|
+
|
|
30
|
+
if (newItem.extension) {
|
|
31
|
+
delete newItem.extension;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return newItem;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function getUpdatedPropertiesFromItem(item: FHIRQuestionnaireItem) {
|
|
38
|
+
let updatedProperties: FCEQuestionnaireItem = { linkId: item.linkId, type: item.type };
|
|
39
|
+
|
|
40
|
+
for (const identifer in ExtensionIdentifier) {
|
|
41
|
+
const identifierURI = ExtensionIdentifier[identifer];
|
|
42
|
+
const extension = findExtension(item, identifierURI);
|
|
43
|
+
if (extension !== undefined) {
|
|
44
|
+
updatedProperties = {
|
|
45
|
+
...updatedProperties,
|
|
46
|
+
...convertFromFHIRExtension(extension),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
updatedProperties.answerOption = item.answerOption?.map(processItemOption);
|
|
52
|
+
updatedProperties.initial = item.initial?.map(processItemOption);
|
|
53
|
+
updatedProperties.enableWhen = item.enableWhen?.map(processEnableWhenItem);
|
|
54
|
+
|
|
55
|
+
return updatedProperties;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function processEnableWhenItem(
|
|
59
|
+
item: FHIRQuestionnaireItemEnableWhen,
|
|
60
|
+
): FCEQuestionnaireItemEnableWhen {
|
|
61
|
+
return {
|
|
62
|
+
question: item.question,
|
|
63
|
+
operator: item.operator,
|
|
64
|
+
answer: processEnableWhenAnswerOption(item),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function processEnableWhenAnswerOption(item: FHIRQuestionnaireItemEnableWhen) {
|
|
69
|
+
const answer: FCEQuestionnaireItemEnableWhenAnswer = {};
|
|
70
|
+
|
|
71
|
+
switch (true) {
|
|
72
|
+
case 'answerBoolean' in item:
|
|
73
|
+
answer['boolean'] = item.answerBoolean;
|
|
74
|
+
break;
|
|
75
|
+
case 'answerDecimal' in item:
|
|
76
|
+
answer['decimal'] = item.answerDecimal;
|
|
77
|
+
break;
|
|
78
|
+
case 'answerInteger' in item:
|
|
79
|
+
answer['integer'] = item.answerInteger;
|
|
80
|
+
break;
|
|
81
|
+
case 'answerDate' in item:
|
|
82
|
+
answer['date'] = item.answerDate;
|
|
83
|
+
break;
|
|
84
|
+
case 'answerDateTime' in item:
|
|
85
|
+
answer['dateTime'] = item.answerDateTime;
|
|
86
|
+
break;
|
|
87
|
+
case 'answerTime' in item:
|
|
88
|
+
answer['time'] = item.answerTime;
|
|
89
|
+
break;
|
|
90
|
+
case 'answerString' in item:
|
|
91
|
+
answer['string'] = item.answerString;
|
|
92
|
+
break;
|
|
93
|
+
case 'answerCoding' in item:
|
|
94
|
+
answer['Coding'] = item.answerCoding;
|
|
95
|
+
break;
|
|
96
|
+
case 'answerQuantity' in item:
|
|
97
|
+
answer['Quantity'] = item.answerQuantity;
|
|
98
|
+
break;
|
|
99
|
+
case 'answerReference' in item:
|
|
100
|
+
if (item.answerReference) {
|
|
101
|
+
answer['Reference'] = fromFHIRReference(item.answerReference);
|
|
102
|
+
} else {
|
|
103
|
+
throw Error("Can not process 'answerReference' with no reference inside");
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
default:
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return answer;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function processItemOption(
|
|
114
|
+
option: FHIRQuestionnaireItemAnswerOption | FHIRQuestionnaireItemInitial,
|
|
115
|
+
): FCEQuestionnaireItemAnswerOption | FCEQuestionnaireItemInitial {
|
|
116
|
+
if (option.valueString) {
|
|
117
|
+
return {
|
|
118
|
+
value: {
|
|
119
|
+
string: option.valueString,
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
if (option.valueCoding) {
|
|
124
|
+
return {
|
|
125
|
+
value: {
|
|
126
|
+
Coding: option.valueCoding,
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
if (option.valueReference) {
|
|
131
|
+
return {
|
|
132
|
+
value: {
|
|
133
|
+
Reference: fromFHIRReference(option.valueReference),
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
if (option.valueDate) {
|
|
138
|
+
return {
|
|
139
|
+
value: {
|
|
140
|
+
date: option.valueDate,
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
if (option.valueInteger) {
|
|
145
|
+
return {
|
|
146
|
+
value: {
|
|
147
|
+
integer: option.valueInteger,
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
if ('valueBoolean' in option) {
|
|
152
|
+
return {
|
|
153
|
+
value: {
|
|
154
|
+
boolean: option.valueBoolean,
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
return option;
|
|
159
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Questionnaire as FHIRQuestionnaire } from 'fhir/r4b';
|
|
2
|
+
|
|
3
|
+
export function processMeta(fhirQuestionnaire: FHIRQuestionnaire) {
|
|
4
|
+
const createdAt = getCreatedAt(fhirQuestionnaire);
|
|
5
|
+
return {
|
|
6
|
+
...fhirQuestionnaire.meta,
|
|
7
|
+
...createdAt,
|
|
8
|
+
extension: undefined,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getCreatedAt(fhirQuestionnaire: FHIRQuestionnaire) {
|
|
13
|
+
const metaExtension = fhirQuestionnaire.meta?.extension?.find(
|
|
14
|
+
(ext) => ext.url === 'ex:createdAt',
|
|
15
|
+
);
|
|
16
|
+
return metaExtension ? { createdAt: metaExtension.valueInstant } : {};
|
|
17
|
+
}
|