lforms 29.3.0 → 33.2.0
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/CHANGELOG.md +261 -0
- package/README.md +97 -14
- package/changed-features.md +99 -0
- package/dist/lforms/LICENSE.md +70 -0
- package/dist/lforms/README.md +100 -0
- package/dist/lforms/fhir/R4/lformsFHIR.min.js +2 -0
- package/dist/lforms/fhir/R4/lformsFHIR.min.js.map +1 -0
- package/dist/lforms/fhir/STU3/lformsFHIR.min.js +2 -0
- package/dist/lforms/fhir/STU3/lformsFHIR.min.js.map +1 -0
- package/dist/lforms/fhir/lformsFHIRAll.min.js +2 -0
- package/dist/lforms/fhir/lformsFHIRAll.min.js.map +1 -0
- package/dist/lforms/webcomponent/assets/lib/zone.min.js +134 -0
- package/dist/lforms/webcomponent/down_arrow_gray_10_10.png +0 -0
- package/dist/lforms/webcomponent/favicon.ico +0 -0
- package/dist/lforms/webcomponent/index.html +9 -0
- package/dist/lforms/webcomponent/lhc-forms.js +2471 -0
- package/dist/lforms/webcomponent/magnifying_glass.png +0 -0
- package/dist/lforms/webcomponent/main.js +2464 -0
- package/dist/lforms/webcomponent/main.js.map +1 -0
- package/dist/lforms/webcomponent/polyfills.js +2 -0
- package/dist/lforms/webcomponent/polyfills.js.map +1 -0
- package/dist/lforms/webcomponent/runtime.js +2 -0
- package/dist/lforms/webcomponent/runtime.js.map +1 -0
- package/dist/lforms/webcomponent/scripts.js +3 -0
- package/dist/lforms/webcomponent/scripts.js.map +1 -0
- package/dist/lforms/webcomponent/styles.css +3 -0
- package/dist/lforms/webcomponent/styles.css.map +1 -0
- package/form_definition.md +382 -0
- package/lforms-33.2.0.tgz +0 -0
- package/package.json +94 -88
- package/r4-support.md +147 -0
- package/sdc-support.md +127 -0
- package/app/.npmignore +0 -3
- package/app/images/blank.gif +0 -0
- package/app/images/signal-stop.png +0 -0
- package/app/index.html +0 -10
- package/app/lforms.js +0 -56
- package/app/lforms.tpl.js +0 -964
- package/app/scripts/angular-packages.js +0 -11
- package/app/scripts/bootstrap-decorators.js +0 -31
- package/app/scripts/bower-index.js +0 -14
- package/app/scripts/fhir/R4/export.js +0 -33
- package/app/scripts/fhir/R4/fhirRequire.js +0 -36
- package/app/scripts/fhir/R4/lformsFHIR.js +0 -27260
- package/app/scripts/fhir/R4/sdc-export.js +0 -455
- package/app/scripts/fhir/R4/sdc-import.js +0 -483
- package/app/scripts/fhir/STU3/export.js +0 -27
- package/app/scripts/fhir/STU3/fhirRequire.js +0 -36
- package/app/scripts/fhir/STU3/lformsFHIR.js +0 -27291
- package/app/scripts/fhir/STU3/sdc-export.js +0 -493
- package/app/scripts/fhir/STU3/sdc-import.js +0 -494
- package/app/scripts/fhir/diagnostic-report.js +0 -707
- package/app/scripts/fhir/export-common.js +0 -209
- package/app/scripts/fhir/expression-processor.js +0 -670
- package/app/scripts/fhir/extensions/rendering-style.js +0 -23
- package/app/scripts/fhir/fhir-common.js +0 -3
- package/app/scripts/fhir/obs-prepop.mjs +0 -97
- package/app/scripts/fhir/runtime-common.js +0 -33
- package/app/scripts/fhir/sdc-common.js +0 -334
- package/app/scripts/fhir/sdc-export-common.js +0 -1046
- package/app/scripts/fhir/sdc-import-common.js +0 -1343
- package/app/scripts/fhir/versions.js +0 -8
- package/app/scripts/index.js +0 -20
- package/app/scripts/lforms-config.js +0 -12
- package/app/scripts/lforms-constants.js +0 -10
- package/app/scripts/lforms-controllers.js +0 -1196
- package/app/scripts/lforms-directives.js +0 -424
- package/app/scripts/lforms-index.js +0 -20
- package/app/scripts/lib/cross_browser.js +0 -21
- package/app/scripts/lib/lforms-data.js +0 -3591
- package/app/scripts/lib/lforms-hl7.js +0 -525
- package/app/scripts/lib/lforms-util.js +0 -1122
- package/app/scripts/lib/lforms-validate.js +0 -277
- package/app/scripts/lib/polyfill.js +0 -81
- package/app/scripts/themeList.js +0 -17
- package/app/styles/lforms.css +0 -1219
- package/app/styles/redmond-theme/README.txt +0 -2
- package/app/styles/redmond-theme/images/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
- package/app/styles/redmond-theme/images/ui-bg_glass_85_dfeffc_1x400.png +0 -0
- package/app/styles/redmond-theme/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- package/app/styles/redmond-theme/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
- package/app/styles/redmond-theme/images/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
- package/app/styles/redmond-theme/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
- package/app/styles/redmond-theme/images/ui-icons_217bc0_256x240.png +0 -0
- package/app/styles/redmond-theme/images/ui-icons_2e83ff_256x240.png +0 -0
- package/app/styles/redmond-theme/images/ui-icons_469bdd_256x240.png +0 -0
- package/app/styles/redmond-theme/images/ui-icons_6da8d5_256x240.png +0 -0
- package/app/styles/redmond-theme/images/ui-icons_cd0a0a_256x240.png +0 -0
- package/app/styles/redmond-theme/images/ui-icons_d8e7f3_256x240.png +0 -0
- package/app/styles/redmond-theme/images/ui-icons_f9bd01_256x240.png +0 -0
- package/app/styles/redmond-theme/jquery-ui.css +0 -1311
- package/app/styles/redmond-theme/jquery-ui.min.css +0 -7
- package/app/styles/redmond-theme/theme.css +0 -443
- package/app/styles/themes.css +0 -1541
- package/app/styles/themes.css.map +0 -9
- package/app/styles/themes.scss +0 -411
- package/app/version.json +0 -1
- package/app/views/partials/attachment.html +0 -38
- package/app/views/partials/field-answers.html +0 -67
- package/app/views/partials/field-units.html +0 -24
- package/app/views/partials/form-controls.html +0 -19
- package/app/views/partials/form-header.html +0 -35
- package/app/views/partials/form-options.html +0 -50
- package/app/views/partials/form-title.html +0 -20
- package/app/views/partials/form-view.html +0 -13
- package/app/views/partials/item-options.html +0 -48
- package/app/views/partials/item.html +0 -126
- package/app/views/partials/itemPrefixAndText.html +0 -4
- package/app/views/partials/layout-horizontal.html +0 -156
- package/app/views/partials/layout-matrix.html +0 -145
- package/app/views/partials/popover-content.html +0 -1
- package/app/views/partials/repeating-button.html +0 -16
- package/app/views/partials/table-item.html +0 -30
- package/app/views/partials/template-table.html +0 -69
- package/app/views/partials/uib-popover-templates/uib-popover-template.html +0 -13
- package/app/views/partials/uib-popover-templates/uib-popover.html +0 -11
|
@@ -1,483 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A package to handle conversion from FHIR SDC Questionnaire to LForms
|
|
3
|
-
*
|
|
4
|
-
* It provides the following functions:
|
|
5
|
-
* convertQuestionnaireToLForms()
|
|
6
|
-
* -- Convert FHIR SDC QuestionnaireResponse data into corresponding LForms data
|
|
7
|
-
* mergeQuestionnaireResponseToLForms() (defined in sdc-import-common.js)
|
|
8
|
-
* -- Merge FHIR SDC QuestionnaireResponse data into corresponding LForms data
|
|
9
|
-
*/
|
|
10
|
-
function addSDCImportFns(ns) {
|
|
11
|
-
"use strict";
|
|
12
|
-
|
|
13
|
-
var self = ns;
|
|
14
|
-
|
|
15
|
-
// FHIR extension urls
|
|
16
|
-
self.fhirExtUrlOptionScore = "http://hl7.org/fhir/StructureDefinition/ordinalValue";
|
|
17
|
-
self.fhirExtUrlValueSetScore = self.fhirExtUrlOptionScore;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Extract contained VS (if any) from the given questionnaire resource object.
|
|
22
|
-
* @param questionnaire the FHIR questionnaire resource object
|
|
23
|
-
* @return when there are contained value sets, returns a hash from the ValueSet url to the answers
|
|
24
|
-
* options object, which, in turn, is a hash with 4 entries:
|
|
25
|
-
* - "answers" is the list of LF answers converted from the value set.
|
|
26
|
-
* - "systems" is the list of code systems for each answer item; and
|
|
27
|
-
* returns undefined if no contained value set is present.
|
|
28
|
-
* @private
|
|
29
|
-
*/
|
|
30
|
-
self._extractContainedVS = function (questionnaire) {
|
|
31
|
-
var answersVS;
|
|
32
|
-
|
|
33
|
-
if(questionnaire.contained && questionnaire.contained.length > 0) {
|
|
34
|
-
answersVS = {};
|
|
35
|
-
questionnaire.contained.forEach(function (vs) {
|
|
36
|
-
if(vs.resourceType === 'ValueSet') {
|
|
37
|
-
var answers = self.answersFromVS(vs);
|
|
38
|
-
if (!answers)
|
|
39
|
-
answers = []; // continuing with previous default; not sure if needed
|
|
40
|
-
|
|
41
|
-
// Support both id and url based lookup - we are only supporting our non-standard url approach
|
|
42
|
-
// for backward-compatibility with previous LForms versions. For more details on FHIR contained
|
|
43
|
-
// resource references, please see "http://hl7.org/fhir/references.html#canonical-fragments"
|
|
44
|
-
var lfVS = {answers: answers};
|
|
45
|
-
if(vs.id) {
|
|
46
|
-
answersVS['#' + vs.id] = lfVS;
|
|
47
|
-
}
|
|
48
|
-
if(vs.url) {
|
|
49
|
-
answersVS[vs.url] = lfVS;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return answersVS;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Process questionnaire item recursively
|
|
61
|
-
*
|
|
62
|
-
* @param qItem - item object as defined in FHIR Questionnaire.
|
|
63
|
-
* @param containedVS - contained ValueSet info, see _extractContainedVS() for data format details
|
|
64
|
-
* @param linkIdItemMap - Map of items from link ID to item from the imported resource.
|
|
65
|
-
* @returns {{}} - Converted 'item' field object as defined by LForms definition.
|
|
66
|
-
* @private
|
|
67
|
-
*/
|
|
68
|
-
self._processQuestionnaireItem = function (qItem, containedVS, linkIdItemMap) {
|
|
69
|
-
|
|
70
|
-
var targetItem = {};
|
|
71
|
-
//A lot of parsing depends on data type. Extract it first.
|
|
72
|
-
self._processDataType(targetItem, qItem);
|
|
73
|
-
self._processTextAndPrefix(targetItem, qItem);
|
|
74
|
-
self._processCodeAndLinkId(targetItem, qItem);
|
|
75
|
-
self._processDisplayItemCode(targetItem, qItem);
|
|
76
|
-
self._processEditable(targetItem, qItem);
|
|
77
|
-
self._processFHIRQuestionAndAnswerCardinality(targetItem, qItem);
|
|
78
|
-
self._processDisplayControl(targetItem, qItem);
|
|
79
|
-
self._processDataControl(targetItem, qItem);
|
|
80
|
-
self._processRestrictions(targetItem, qItem);
|
|
81
|
-
self._processHiddenItem(targetItem, qItem);
|
|
82
|
-
self._processUnitList(targetItem, qItem);
|
|
83
|
-
self._processAnswers(targetItem, qItem, containedVS);
|
|
84
|
-
self._processDefaultAnswer(targetItem, qItem);
|
|
85
|
-
self._processExternallyDefined(targetItem, qItem);
|
|
86
|
-
self._processTerminologyServer(targetItem, qItem);
|
|
87
|
-
self._processSkipLogic(targetItem, qItem, linkIdItemMap);
|
|
88
|
-
self._processExtensions(targetItem, qItem);
|
|
89
|
-
self.copyFields(qItem, targetItem, self.itemLevelIgnoredFields);
|
|
90
|
-
self._processChildItems(targetItem, qItem, containedVS, linkIdItemMap);
|
|
91
|
-
|
|
92
|
-
return targetItem;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Parse questionnaire object for skip logic information
|
|
98
|
-
*
|
|
99
|
-
* @param lfItem {object} - LForms item object to assign the skip logic
|
|
100
|
-
* @param qItem {object} - Questionnaire item object
|
|
101
|
-
* @param linkIdItemMap - Map of items from link ID to item from the imported resource.
|
|
102
|
-
* @private
|
|
103
|
-
*/
|
|
104
|
-
self._processSkipLogic = function (lfItem, qItem, linkIdItemMap) {
|
|
105
|
-
if(qItem.enableWhen) {
|
|
106
|
-
lfItem.skipLogic = {conditions: [], action: 'show'};
|
|
107
|
-
for(var i = 0; i < qItem.enableWhen.length; i++) {
|
|
108
|
-
var dataType = self._getDataType(linkIdItemMap[qItem.enableWhen[i].question]);
|
|
109
|
-
var condition = {source: qItem.enableWhen[i].question, trigger: {}};
|
|
110
|
-
var answer = self._getFHIRValueWithPrefixKey(qItem.enableWhen[i], /^answer/);
|
|
111
|
-
var opMapping = self._operatorMapping[qItem.enableWhen[i].operator];
|
|
112
|
-
if(! opMapping) {
|
|
113
|
-
throw new Error('Unable to map FHIR enableWhen operator: ' + qItem.enableWhen[i].operator);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if(opMapping === 'exists') {
|
|
117
|
-
condition.trigger.exists = answer; // boolean value here regardless of data type
|
|
118
|
-
}
|
|
119
|
-
else if(dataType === 'CWE' || dataType === 'CNE') {
|
|
120
|
-
condition.trigger[opMapping] = self._copyTriggerCoding(answer, null, false);
|
|
121
|
-
}
|
|
122
|
-
else if(dataType === 'QTY') {
|
|
123
|
-
condition.trigger[opMapping] = answer.value;
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
condition.trigger[opMapping] = answer;
|
|
127
|
-
}
|
|
128
|
-
lfItem.skipLogic.conditions.push(condition);
|
|
129
|
-
}
|
|
130
|
-
if(qItem.enableBehavior) {
|
|
131
|
-
lfItem.skipLogic.logic = qItem.enableBehavior.toUpperCase();
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Parse Questionnaire item for externallyDefined url
|
|
139
|
-
*
|
|
140
|
-
* @param lfItem - LForms item object to assign externallyDefined
|
|
141
|
-
* @param qItem - Questionnaire item object
|
|
142
|
-
* @private
|
|
143
|
-
*/
|
|
144
|
-
self._processExternallyDefined = function (lfItem, qItem) {
|
|
145
|
-
var externallyDefined = LForms.Util.findObjectInArray(qItem.extension, 'url', self.fhirExtUrlExternallyDefined);
|
|
146
|
-
if (externallyDefined && externallyDefined.valueUri) {
|
|
147
|
-
lfItem.externallyDefined = externallyDefined.valueUri;
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Parse questionnaire item for "hidden" extension
|
|
154
|
-
*
|
|
155
|
-
* @param lfItem {object} - LForms item object to be assigned the _isHiddenInDef flag if the item is to be hidden.
|
|
156
|
-
* @param qItem {object} - Questionnaire item object
|
|
157
|
-
* @private
|
|
158
|
-
* @return true if the item is hidden or if its ancestor is hidden, false otherwise
|
|
159
|
-
*/
|
|
160
|
-
self._processHiddenItem = function(lfItem, qItem) {
|
|
161
|
-
var ci = LForms.Util.findObjectInArray(qItem.extension, 'url', self.fhirExtUrlHidden);
|
|
162
|
-
if(ci) {
|
|
163
|
-
lfItem._isHiddenInDef = typeof ci.valueBoolean === 'boolean'? ci.valueBoolean: ci.valueBoolean === 'true';
|
|
164
|
-
}
|
|
165
|
-
return lfItem._isHiddenInDef;
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Parse questionnaire item for answers list
|
|
171
|
-
*
|
|
172
|
-
* @param lfItem {object} - LForms item object to assign answer list
|
|
173
|
-
* @param qItem {object} - Questionnaire item object
|
|
174
|
-
* @param containedVS - contained ValueSet info, see _extractContainedVS() for data format details
|
|
175
|
-
* @private
|
|
176
|
-
*/
|
|
177
|
-
self._processAnswers = function (lfItem, qItem, containedVS) {
|
|
178
|
-
if(qItem.answerOption) {
|
|
179
|
-
lfItem.answers = [];
|
|
180
|
-
for(var i = 0; i < qItem.answerOption.length; i++) {
|
|
181
|
-
var answer = {};
|
|
182
|
-
var option = qItem.answerOption[i];
|
|
183
|
-
var label = LForms.Util.findObjectInArray(option.extension, 'url', self.fhirExtUrlOptionPrefix);
|
|
184
|
-
if(label) {
|
|
185
|
-
answer.label = label.valueString;
|
|
186
|
-
}
|
|
187
|
-
var score = LForms.Util.findObjectInArray(option.extension, 'url', self.fhirExtUrlOptionScore);
|
|
188
|
-
// Look for argonaut extension.
|
|
189
|
-
score = !score ? LForms.Util.findObjectInArray(option.extension, 'url', self.argonautExtUrlExtensionScore) : score;
|
|
190
|
-
if(score) {
|
|
191
|
-
answer.score = score.valueDecimal.toString();
|
|
192
|
-
}
|
|
193
|
-
var optionKey = Object.keys(option).filter(function(key) {return (key.indexOf('value') === 0);});
|
|
194
|
-
if(optionKey && optionKey.length > 0) {
|
|
195
|
-
if(optionKey[0] === 'valueCoding') { // Only one value[x] is expected
|
|
196
|
-
if(option[optionKey[0]].code !== undefined) answer.code = option[optionKey[0]].code;
|
|
197
|
-
if(option[optionKey[0]].display !== undefined) answer.text = option[optionKey[0]].display;
|
|
198
|
-
// TBD- Lforms has answer code system at item level, expects all options to have one code system!
|
|
199
|
-
if(option[optionKey[0]].system !== undefined) {
|
|
200
|
-
answer.system = option[optionKey[0]].system;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
answer.text = option[optionKey[0]].toString();
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
lfItem.answers.push(answer);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
else if (qItem.answerValueSet) {
|
|
212
|
-
if (containedVS)
|
|
213
|
-
var vs = containedVS[qItem.answerValueSet];
|
|
214
|
-
if(vs) { // contained
|
|
215
|
-
lfItem.answers = vs.answers;
|
|
216
|
-
}
|
|
217
|
-
else
|
|
218
|
-
lfItem.answerValueSet = qItem.answerValueSet; // a URI for a ValueSet
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Parse questionnaire item for editable
|
|
225
|
-
*
|
|
226
|
-
* @param lfItem {object} - LForms item object to assign editable
|
|
227
|
-
* @param qItem {object} - Questionnaire item object
|
|
228
|
-
* @private
|
|
229
|
-
*/
|
|
230
|
-
self._processEditable = function (lfItem, qItem) {
|
|
231
|
-
if (qItem.readOnly) {
|
|
232
|
-
lfItem.editable = '0';
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Parse questionnaire item for default answer
|
|
239
|
-
*
|
|
240
|
-
* @param lfItem {object} - LForms item object to assign default answer
|
|
241
|
-
* @param qItem {object} - Questionnaire item object
|
|
242
|
-
* @private
|
|
243
|
-
*/
|
|
244
|
-
self._processDefaultAnswer = function (lfItem, qItem) {
|
|
245
|
-
|
|
246
|
-
if(!qItem.initial) {
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
var vals = [];
|
|
251
|
-
qItem.initial.forEach(function(elem) {
|
|
252
|
-
var answer = null;
|
|
253
|
-
elem = LForms.Util.deepCopy(elem); // Use a clone to avoid changing the original
|
|
254
|
-
var val = elem.valueCoding;
|
|
255
|
-
if (val)
|
|
256
|
-
val._type = 'Coding';
|
|
257
|
-
else
|
|
258
|
-
val = self._getFHIRValueWithPrefixKey(elem, /^value/);
|
|
259
|
-
if (val)
|
|
260
|
-
vals.push(val);
|
|
261
|
-
});
|
|
262
|
-
if (vals.length > 0)
|
|
263
|
-
this._processFHIRValues(lfItem, vals, true);
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* Returns the first initial quanitity for the given Questionnaire item, or
|
|
269
|
-
* null if there isn't one.
|
|
270
|
-
*/
|
|
271
|
-
self.getFirstInitialQuantity = function(qItem) {
|
|
272
|
-
return qItem.initial && qItem.initial.length > 0 && qItem.initial[0].valueQuantity || null;
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Parse 'linkId' for the LForms questionCode of a 'display' item, which does not have a 'code'
|
|
278
|
-
*
|
|
279
|
-
* @param lfItem {object} - LForms item object to assign questionCode
|
|
280
|
-
* @param qItem {object} - Questionnaire item object
|
|
281
|
-
* @private
|
|
282
|
-
*/
|
|
283
|
-
self._processDisplayItemCode = function (lfItem, qItem) {
|
|
284
|
-
if (qItem.type === "display" && qItem.linkId) {
|
|
285
|
-
var codes = qItem.linkId.split("/");
|
|
286
|
-
if (codes && codes[codes.length-1]) {
|
|
287
|
-
lfItem.questionCode = codes[codes.length-1];
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Parse questionnaire item for data type
|
|
295
|
-
*
|
|
296
|
-
* @param lfItem {object} - LForms item object to assign data type
|
|
297
|
-
* @param qItem {object} - Questionnaire item object
|
|
298
|
-
* @private
|
|
299
|
-
*/
|
|
300
|
-
self._processDataType = function (lfItem, qItem) {
|
|
301
|
-
var type = self._getDataType(qItem);
|
|
302
|
-
if(type === 'SECTION') {
|
|
303
|
-
lfItem.header = true;
|
|
304
|
-
}
|
|
305
|
-
lfItem.dataType = type;
|
|
306
|
-
};
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
// Quesitonnaire Response Import
|
|
310
|
-
self._mergeQR = {
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Get structure information of a QuestionnaireResponse instance
|
|
314
|
-
* @param qr a QuestionnaireResponse instance
|
|
315
|
-
* @returns {{}} a QuestionnaireResponse data structure object
|
|
316
|
-
* @private
|
|
317
|
-
*/
|
|
318
|
-
_getQRStructure : function(qr) {
|
|
319
|
-
var qrInfo = {
|
|
320
|
-
qrItemsInfo: []
|
|
321
|
-
};
|
|
322
|
-
if (qr) {
|
|
323
|
-
this._checkQRItems(qrInfo, qr);
|
|
324
|
-
}
|
|
325
|
-
return qrInfo;
|
|
326
|
-
},
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* Get structural info of a QuestionnaireResponse by going though each level of items
|
|
331
|
-
* @param parentQRItemInfo the structural info of a parent item
|
|
332
|
-
* @param parentItem a parent item in a QuestionnaireResponse object
|
|
333
|
-
* @private
|
|
334
|
-
*/
|
|
335
|
-
_checkQRItems : function(parentQRItemInfo, parentQRItem) {
|
|
336
|
-
|
|
337
|
-
var qrItemsInfo = [];
|
|
338
|
-
var repeatingItemProcessed = {};
|
|
339
|
-
|
|
340
|
-
if (parentQRItem && parentQRItem.item) {
|
|
341
|
-
for (var i=0, iLen=parentQRItem.item.length; i<iLen; i++) {
|
|
342
|
-
var item = parentQRItem.item[i];
|
|
343
|
-
var linkId = item.linkId; //code is not necessary included in linkId
|
|
344
|
-
// first item that has the same code, either repeating or non-repeating
|
|
345
|
-
if (!repeatingItemProcessed[linkId]) {
|
|
346
|
-
var repeatingInfo = this._findTotalRepeatingNum(linkId, parentQRItem);
|
|
347
|
-
|
|
348
|
-
// create structure info for the item
|
|
349
|
-
var repeatingItems = repeatingInfo.repeatingItems;
|
|
350
|
-
for (var j=0, jLen=repeatingItems.length; j<jLen; j++) {
|
|
351
|
-
var qrItemInfo = {
|
|
352
|
-
linkId: linkId,
|
|
353
|
-
item: repeatingItems[j],
|
|
354
|
-
index: j,
|
|
355
|
-
total: repeatingInfo.total
|
|
356
|
-
};
|
|
357
|
-
// check observation instances in the sub level
|
|
358
|
-
this._checkQRItems(qrItemInfo, repeatingItems[j]);
|
|
359
|
-
self._checkQRItemAnswerItems(qrItemInfo, repeatingItems[j]);
|
|
360
|
-
qrItemsInfo.push(qrItemInfo);
|
|
361
|
-
}
|
|
362
|
-
repeatingItemProcessed[linkId] = true;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
parentQRItemInfo.qrItemsInfo = qrItemsInfo;
|
|
366
|
-
}
|
|
367
|
-
},
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Find the number of the repeating items that have the same code
|
|
372
|
-
* @param linkId an item's linkId
|
|
373
|
-
* @param parentQRItem a parent item in a QuestionnaireResponse object
|
|
374
|
-
* @returns a structural info object for a repeating item
|
|
375
|
-
* @private
|
|
376
|
-
*/
|
|
377
|
-
_findTotalRepeatingNum : function(linkId, parentQRItem) {
|
|
378
|
-
|
|
379
|
-
var total = 0;
|
|
380
|
-
var repeatingItems = [];
|
|
381
|
-
for (var i=0, iLen=parentQRItem.item.length; i<iLen; i++) {
|
|
382
|
-
var item = parentQRItem.item[i];
|
|
383
|
-
if (linkId === item.linkId) {
|
|
384
|
-
repeatingItems.push(item);
|
|
385
|
-
if (Array.isArray(item.answer)) {
|
|
386
|
-
total += item.answer.length; // answers for repeating questions and repeating answers
|
|
387
|
-
}
|
|
388
|
-
else {
|
|
389
|
-
total += 1;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
return {
|
|
395
|
-
total: total,
|
|
396
|
-
repeatingItems: repeatingItems
|
|
397
|
-
};
|
|
398
|
-
},
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* Add repeating items into LForms definition data object
|
|
403
|
-
* @param parentItem a parent item
|
|
404
|
-
* @param linkId linkId of a repeating item
|
|
405
|
-
* @param total total number of the repeating item with the same code
|
|
406
|
-
* @private
|
|
407
|
-
*/
|
|
408
|
-
_addRepeatingItems : function(parentItem, linkId, total) {
|
|
409
|
-
// find the first (and the only one) item
|
|
410
|
-
var item = null;
|
|
411
|
-
if (parentItem.items) {
|
|
412
|
-
for(var i=0, iLen=parentItem.items.length; i<iLen; i++) {
|
|
413
|
-
if (linkId === parentItem.items[i].linkId) {
|
|
414
|
-
item = parentItem.items[i];
|
|
415
|
-
break;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
// insert new items
|
|
419
|
-
if (item) {
|
|
420
|
-
while(total > 1) {
|
|
421
|
-
var newItem = LForms.Util.deepCopy(item);
|
|
422
|
-
parentItem.items.splice(i, 0, newItem);
|
|
423
|
-
total -= 1;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
},
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
/**
|
|
431
|
-
* Find a matching repeating item by item code and the index in the items array
|
|
432
|
-
* @param parentItem a parent item
|
|
433
|
-
* @param linkId linkId of a repeating (or non-repeating) item
|
|
434
|
-
* @param index index of the item in the sub item array of the parent item
|
|
435
|
-
* @returns {{}} a matching item
|
|
436
|
-
* @private
|
|
437
|
-
*/
|
|
438
|
-
_findTheMatchingItemByLinkIdAndIndex : function(parentItem, linkId, index) {
|
|
439
|
-
var item = null;
|
|
440
|
-
var idx = 0;
|
|
441
|
-
if (parentItem.items) {
|
|
442
|
-
for(var i=0, iLen=parentItem.items.length; i<iLen; i++) {
|
|
443
|
-
if (linkId === parentItem.items[i].linkId) {
|
|
444
|
-
if (idx === index) {
|
|
445
|
-
item = parentItem.items[i];
|
|
446
|
-
break;
|
|
447
|
-
}
|
|
448
|
-
else {
|
|
449
|
-
idx += 1;
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
return item;
|
|
455
|
-
},
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* Find a matching repeating item by item code alone
|
|
460
|
-
* When used on the LForms definition data object, there is no repeating items yet.
|
|
461
|
-
* @param parentItem a parent item
|
|
462
|
-
* @param linkId linkId of an item
|
|
463
|
-
* @returns {{}} a matching item
|
|
464
|
-
* @private
|
|
465
|
-
*/
|
|
466
|
-
_findTheMatchingItemByLinkId : function(parentItem, linkId) {
|
|
467
|
-
var item = null;
|
|
468
|
-
if (parentItem.items) {
|
|
469
|
-
for(var i=0, iLen=parentItem.items.length; i<iLen; i++) {
|
|
470
|
-
if (linkId === parentItem.items[i].linkId) {
|
|
471
|
-
item = parentItem.items[i];
|
|
472
|
-
break;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
return item;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
export default addSDCImportFns;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// STU3-specific export code common to DiagnosticReport and SDC.
|
|
2
|
-
|
|
3
|
-
import commonExport from '../export-common.js';
|
|
4
|
-
|
|
5
|
-
let self = Object.create(commonExport); // copies properties to self.prototype
|
|
6
|
-
Object.assign(self, {
|
|
7
|
-
/**
|
|
8
|
-
* Creates a structure for use by _createObservation() in constructing an
|
|
9
|
-
* Observation value for the given integer value.
|
|
10
|
-
* @param item an LForms item with the integer value to be represented in an Observation.
|
|
11
|
-
* It is assumed that the caller has already checked the data type.
|
|
12
|
-
* @return an object with a "key" property that will be the property name for
|
|
13
|
-
* the value in the Observation object, and a "val" property that holds the
|
|
14
|
-
* value (formatted for the Observation).
|
|
15
|
-
*/
|
|
16
|
-
_createObsIntValue: function(item) {
|
|
17
|
-
// In STU3, there is no valueInteger in Observation, so we use
|
|
18
|
-
// valueQuantity.
|
|
19
|
-
let quantity = {value: item.value};
|
|
20
|
-
this._setFHIRQuantityUnit(quantity, item.unit);
|
|
21
|
-
let rtn = {key: 'valueQuantity', val: quantity};
|
|
22
|
-
|
|
23
|
-
return rtn;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export default self;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// Initializes the FHIR structure for STU3
|
|
2
|
-
let fhirVersion = 'STU3';
|
|
3
|
-
if (!LForms.FHIR)
|
|
4
|
-
LForms.FHIR = {};
|
|
5
|
-
import {LOINC_URI} from '../fhir-common';
|
|
6
|
-
var fhir = LForms.FHIR[fhirVersion] = {
|
|
7
|
-
LOINC_URI: LOINC_URI
|
|
8
|
-
}
|
|
9
|
-
fhir.fhirpath = require('fhirpath');
|
|
10
|
-
fhir.fhirpathModel = require('fhirpath/fhir-context/stu3');
|
|
11
|
-
import dr from '../diagnostic-report.js';
|
|
12
|
-
fhir.DiagnosticReport = dr;
|
|
13
|
-
import commonExport from './export.js';
|
|
14
|
-
fhir.DiagnosticReport._commonExport = commonExport;
|
|
15
|
-
import fhir_sdc from './sdc-export.js';
|
|
16
|
-
fhir.SDC = fhir_sdc;
|
|
17
|
-
fhir.SDC._commonExport = commonExport;
|
|
18
|
-
import addCommonSDCExportFns from '../sdc-export-common.js'
|
|
19
|
-
addCommonSDCExportFns(fhir.SDC);
|
|
20
|
-
import addSDCImportFns from './sdc-import.js';
|
|
21
|
-
addSDCImportFns(fhir.SDC);
|
|
22
|
-
import addCommonSDCFns from '../sdc-common.js';
|
|
23
|
-
addCommonSDCFns(fhir.SDC);
|
|
24
|
-
import addCommonSDCImportFns from '../sdc-import-common.js';
|
|
25
|
-
addCommonSDCImportFns(fhir.SDC);
|
|
26
|
-
import { addCommonRuntimeFns } from '../runtime-common.js';
|
|
27
|
-
addCommonRuntimeFns(fhir.SDC);
|
|
28
|
-
import { ExpressionProcessor } from '../expression-processor.js';
|
|
29
|
-
fhir.SDC.ExpressionProcessor = ExpressionProcessor;
|
|
30
|
-
fhir.SDC.fhirVersion = fhirVersion; // Needed by lfData for fhirpath, etc.
|
|
31
|
-
|
|
32
|
-
fhir.reservedVarNames = {};
|
|
33
|
-
['context', 'resource'].forEach(function(name) {
|
|
34
|
-
fhir.reservedVarNames[name] = true;
|
|
35
|
-
});
|
|
36
|
-
|