@medplum/react 0.9.20 → 0.9.21
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/dist/cjs/index.js +59 -19
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.min.js +1 -1
- package/dist/cjs/index.min.js.map +1 -1
- package/dist/esm/index.js +59 -19
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/types/stories/QuestionnaireForm.stories.d.ts +2 -0
- package/package.json +5 -5
package/dist/esm/index.js
CHANGED
|
@@ -2178,8 +2178,7 @@ function ResourceTimeline(props) {
|
|
|
2178
2178
|
setHistory({});
|
|
2179
2179
|
return;
|
|
2180
2180
|
}
|
|
2181
|
-
|
|
2182
|
-
medplum.post('fhir/R4', batchRequest).then(handleBatchResponse);
|
|
2181
|
+
medplum.executeBatch(buildSearchRequests(resource)).then(handleBatchResponse);
|
|
2183
2182
|
}, [medplum, resource, buildSearchRequests]);
|
|
2184
2183
|
useEffect(() => {
|
|
2185
2184
|
loadTimeline();
|
|
@@ -4607,31 +4606,64 @@ function QuestionnaireFormItem(props) {
|
|
|
4607
4606
|
return (React.createElement(TextArea, { name: name, defaultValue: initial === null || initial === void 0 ? void 0 : initial.valueString, onChange: (newValue) => onChangeAnswer({ valueString: newValue }) }));
|
|
4608
4607
|
case QuestionnaireItemType.url:
|
|
4609
4608
|
return (React.createElement(Input, { type: "url", name: name, defaultValue: initial === null || initial === void 0 ? void 0 : initial.valueUri, onChange: (newValue) => onChangeAnswer({ valueUri: newValue }) }));
|
|
4610
|
-
case QuestionnaireItemType.choice:
|
|
4611
|
-
case QuestionnaireItemType.openChoice:
|
|
4612
|
-
return (React.createElement("div", null, item.answerOption &&
|
|
4613
|
-
item.answerOption.map((option, index) => {
|
|
4614
|
-
const valueElementDefinition = globalSchema.types['QuestionnaireItemAnswerOption'].properties['value[x]'];
|
|
4615
|
-
const optionValue = getTypedPropertyValue({ type: 'QuestionnaireItemAnswerOption', value: option }, 'value');
|
|
4616
|
-
const initialValue = getTypedPropertyValue({ type: 'QuestionnaireItemInitial', value: initial }, 'value');
|
|
4617
|
-
const propertyName = 'value' + capitalize(optionValue.type);
|
|
4618
|
-
const optionName = `${name}-option-${index}`;
|
|
4619
|
-
return (React.createElement("div", { key: optionName, className: "medplum-questionnaire-option-row" },
|
|
4620
|
-
React.createElement("div", { className: "medplum-questionnaire-option-checkbox" },
|
|
4621
|
-
React.createElement("input", { type: "radio", id: optionName, name: name, value: optionValue.value, defaultChecked: initialValue && stringify(optionValue) === stringify(initialValue), onChange: () => onChangeAnswer({ [propertyName]: optionValue.value }) })),
|
|
4622
|
-
React.createElement("div", null,
|
|
4623
|
-
React.createElement("label", { htmlFor: optionName },
|
|
4624
|
-
React.createElement(ResourcePropertyDisplay, { property: valueElementDefinition, propertyType: optionValue.type, value: optionValue.value })))));
|
|
4625
|
-
})));
|
|
4626
4609
|
case QuestionnaireItemType.attachment:
|
|
4627
4610
|
return (React.createElement(AttachmentInput, { name: name, defaultValue: initial === null || initial === void 0 ? void 0 : initial.valueAttachment, onChange: (newValue) => onChangeAnswer({ valueAttachment: newValue }) }));
|
|
4628
4611
|
case QuestionnaireItemType.reference:
|
|
4629
4612
|
return (React.createElement(ReferenceInput, { name: name, defaultValue: initial === null || initial === void 0 ? void 0 : initial.valueReference, onChange: (newValue) => onChangeAnswer({ valueReference: newValue }) }));
|
|
4630
4613
|
case QuestionnaireItemType.quantity:
|
|
4631
4614
|
return (React.createElement(QuantityInput, { name: name, defaultValue: initial === null || initial === void 0 ? void 0 : initial.valueQuantity, onChange: (newValue) => onChangeAnswer({ valueQuantity: newValue }) }));
|
|
4615
|
+
case QuestionnaireItemType.choice:
|
|
4616
|
+
case QuestionnaireItemType.openChoice:
|
|
4617
|
+
if (isDropDownChoice(item)) {
|
|
4618
|
+
return (React.createElement(QuestionnaireChoiceDropDownInput, { name: name, item: item, initial: initial, onChangeAnswer: onChangeAnswer }));
|
|
4619
|
+
}
|
|
4620
|
+
else {
|
|
4621
|
+
return (React.createElement(QuestionnaireChoiceRadioInput, { name: name, item: item, initial: initial, onChangeAnswer: onChangeAnswer }));
|
|
4622
|
+
}
|
|
4632
4623
|
}
|
|
4633
4624
|
return null;
|
|
4634
4625
|
}
|
|
4626
|
+
function QuestionnaireChoiceDropDownInput(props) {
|
|
4627
|
+
const { name, item, initial } = props;
|
|
4628
|
+
const valueElementDefinition = globalSchema.types['QuestionnaireItemAnswerOption'].properties['value[x]'];
|
|
4629
|
+
const initialValue = getTypedPropertyValue({ type: 'QuestionnaireItemInitial', value: initial }, 'value');
|
|
4630
|
+
return (React.createElement("select", { id: name, name: name, className: "medplum-select", onChange: (e) => {
|
|
4631
|
+
const index = e.currentTarget.selectedIndex;
|
|
4632
|
+
if (index === 0) {
|
|
4633
|
+
props.onChangeAnswer({});
|
|
4634
|
+
return;
|
|
4635
|
+
}
|
|
4636
|
+
const option = item.answerOption[index - 1];
|
|
4637
|
+
const optionValue = getTypedPropertyValue({ type: 'QuestionnaireItemAnswerOption', value: option }, 'value');
|
|
4638
|
+
const propertyName = 'value' + capitalize(optionValue.type);
|
|
4639
|
+
props.onChangeAnswer({ [propertyName]: optionValue.value });
|
|
4640
|
+
} },
|
|
4641
|
+
React.createElement("option", null),
|
|
4642
|
+
item.answerOption &&
|
|
4643
|
+
item.answerOption.map((option, index) => {
|
|
4644
|
+
const optionValue = getTypedPropertyValue({ type: 'QuestionnaireItemAnswerOption', value: option }, 'value');
|
|
4645
|
+
const optionName = `${name}-option-${index}`;
|
|
4646
|
+
return (React.createElement("option", { key: optionName, value: optionValue.value, selected: initialValue && stringify(optionValue) === stringify(initialValue) },
|
|
4647
|
+
React.createElement(ResourcePropertyDisplay, { property: valueElementDefinition, propertyType: optionValue.type, value: optionValue.value })));
|
|
4648
|
+
})));
|
|
4649
|
+
}
|
|
4650
|
+
function QuestionnaireChoiceRadioInput(props) {
|
|
4651
|
+
const { name, item, initial, onChangeAnswer } = props;
|
|
4652
|
+
const valueElementDefinition = globalSchema.types['QuestionnaireItemAnswerOption'].properties['value[x]'];
|
|
4653
|
+
const initialValue = getTypedPropertyValue({ type: 'QuestionnaireItemInitial', value: initial }, 'value');
|
|
4654
|
+
return (React.createElement(React.Fragment, null, item.answerOption &&
|
|
4655
|
+
item.answerOption.map((option, index) => {
|
|
4656
|
+
const optionValue = getTypedPropertyValue({ type: 'QuestionnaireItemAnswerOption', value: option }, 'value');
|
|
4657
|
+
const propertyName = 'value' + capitalize(optionValue.type);
|
|
4658
|
+
const optionName = `${name}-option-${index}`;
|
|
4659
|
+
return (React.createElement("div", { key: optionName, className: "medplum-questionnaire-option-row" },
|
|
4660
|
+
React.createElement("div", { className: "medplum-questionnaire-option-checkbox" },
|
|
4661
|
+
React.createElement("input", { type: "radio", id: optionName, name: name, value: optionValue.value, defaultChecked: initialValue && stringify(optionValue) === stringify(initialValue), onChange: () => onChangeAnswer({ [propertyName]: optionValue.value }) })),
|
|
4662
|
+
React.createElement("div", null,
|
|
4663
|
+
React.createElement("label", { htmlFor: optionName },
|
|
4664
|
+
React.createElement(ResourcePropertyDisplay, { property: valueElementDefinition, propertyType: optionValue.type, value: optionValue.value })))));
|
|
4665
|
+
})));
|
|
4666
|
+
}
|
|
4635
4667
|
function buildInitialResponse(questionnaire) {
|
|
4636
4668
|
const response = {
|
|
4637
4669
|
resourceType: 'QuestionnaireResponse',
|
|
@@ -4657,6 +4689,14 @@ function buildInitialResponseAnswer(answer) {
|
|
|
4657
4689
|
// have the same properties.
|
|
4658
4690
|
return Object.assign({}, answer);
|
|
4659
4691
|
}
|
|
4692
|
+
function isDropDownChoice(item) {
|
|
4693
|
+
var _a;
|
|
4694
|
+
return !!((_a = item.extension) === null || _a === void 0 ? void 0 : _a.some((e) => {
|
|
4695
|
+
var _a, _b, _c;
|
|
4696
|
+
return e.url === 'http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl' &&
|
|
4697
|
+
((_c = (_b = (_a = e.valueCodeableConcept) === null || _a === void 0 ? void 0 : _a.coding) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.code) === 'drop-down';
|
|
4698
|
+
}));
|
|
4699
|
+
}
|
|
4660
4700
|
|
|
4661
4701
|
function QuestionnaireBuilder(props) {
|
|
4662
4702
|
const medplum = useMedplum();
|
|
@@ -4870,7 +4910,7 @@ function RequestGroupDisplay(props) {
|
|
|
4870
4910
|
const [responseBundle, setResponseBundle] = useState();
|
|
4871
4911
|
useEffect(() => {
|
|
4872
4912
|
if (requestGroup && !startedLoading) {
|
|
4873
|
-
medplum.
|
|
4913
|
+
medplum.executeBatch(buildBatchRequest(requestGroup)).then(setResponseBundle);
|
|
4874
4914
|
setStartedLoading(true);
|
|
4875
4915
|
}
|
|
4876
4916
|
}, [medplum, requestGroup, startedLoading]);
|