@medplum/react 0.9.18 → 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/defaulttheme.css +9 -7
- package/dist/cjs/index.js +293 -138
- 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/cjs/styles.css +75 -59
- package/dist/esm/defaulttheme.css +9 -7
- package/dist/esm/index.js +291 -140
- 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/esm/styles.css +75 -59
- package/dist/types/BackboneElementInput.d.ts +2 -3
- package/dist/types/Checkbox.d.ts +12 -0
- package/dist/types/CheckboxFormSection.d.ts +9 -0
- package/dist/types/ContactDetailDisplay.d.ts +6 -0
- package/dist/types/ContactDetailInput.d.ts +8 -0
- package/dist/types/ContactPointInput.d.ts +1 -1
- package/dist/types/GoogleButton.d.ts +3 -3
- package/dist/types/Input.d.ts +2 -1
- package/dist/types/SignInForm.d.ts +11 -8
- package/dist/types/TextArea.d.ts +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/stories/QuestionnaireForm.stories.d.ts +2 -0
- package/package.json +5 -5
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { formatAddress, getDisplayString, getImageSrc, globalSchema, getPropertyDisplayName, formatHumanName, stringify, buildTypeName, PropertyType, getTypedPropertyValue, createReference,
|
|
1
|
+
import { formatAddress, getDisplayString, getImageSrc, capitalize, globalSchema, getPropertyDisplayName, formatHumanName, stringify, buildTypeName, PropertyType, getTypedPropertyValue, createReference, toTypedValue, getReferenceString, evalFhirPath, getSearchParameterDetails, Operator, evalFhirPathTyped, SearchParameterType, formatSearchQuery, parseSearchDefinition, DEFAULT_SEARCH_COUNT, isUUID } from '@medplum/core';
|
|
2
2
|
import React, { useState, useRef, createContext, useEffect, useContext, useCallback } from 'react';
|
|
3
3
|
import { useNavigate, useLocation } from 'react-router-dom';
|
|
4
4
|
|
|
@@ -16,10 +16,10 @@ function getIssuesForExpression(outcome, expression) {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
function Input(props) {
|
|
19
|
-
const className = 'medplum-input';
|
|
19
|
+
const className = 'medplum-input';
|
|
20
20
|
const issues = getIssuesForExpression(props.outcome, props.name);
|
|
21
21
|
const invalid = issues && issues.length > 0;
|
|
22
|
-
return (React.createElement("input", { id: props.name, name: props.name, type: getInputType(props.type), size: props.size, step: props.step, className: className, defaultValue: props.defaultValue || '', required: props.required, autoCapitalize: props.autoCapitalize, autoComplete: props.autoComplete, autoFocus: props.autoFocus, ref: props.inputRef, "aria-invalid": invalid, "aria-describedby": invalid ? props.name + '-errors' : '', placeholder: props.placeholder, "data-testid": props.testid, disabled: props.disabled, onChange: (e) => {
|
|
22
|
+
return (React.createElement("input", { id: props.name, name: props.name, type: getInputType(props.type), size: props.size, step: props.step, className: className, style: props.style, defaultValue: props.defaultValue || '', required: props.required, autoCapitalize: props.autoCapitalize, autoComplete: props.autoComplete, autoFocus: props.autoFocus, ref: props.inputRef, "aria-invalid": invalid, "aria-describedby": invalid ? props.name + '-errors' : '', placeholder: props.placeholder, "data-testid": props.testid, disabled: props.disabled, onChange: (e) => {
|
|
23
23
|
if (props.onChange) {
|
|
24
24
|
props.onChange(e.currentTarget.value);
|
|
25
25
|
}
|
|
@@ -281,7 +281,7 @@ function AttachmentArrayInput(props) {
|
|
|
281
281
|
props.onChange(newValues);
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
|
-
return (React.createElement("table",
|
|
284
|
+
return (React.createElement("table", { style: { width: '100%' } },
|
|
285
285
|
React.createElement("colgroup", null,
|
|
286
286
|
React.createElement("col", { width: "90%" }),
|
|
287
287
|
React.createElement("col", { width: "10%" })),
|
|
@@ -707,6 +707,14 @@ function getInitials(text) {
|
|
|
707
707
|
.join('');
|
|
708
708
|
}
|
|
709
709
|
|
|
710
|
+
function CheckboxFormSection(props) {
|
|
711
|
+
return (React.createElement("div", { className: "medplum-checkbox-form-section" },
|
|
712
|
+
React.createElement("div", { className: "medplum-checkbox-form-section-checkbox-container" }, props.children),
|
|
713
|
+
React.createElement("div", { className: "medplum-checkbox-form-section-details-container" },
|
|
714
|
+
React.createElement("label", { htmlFor: props.htmlFor }, props.title),
|
|
715
|
+
React.createElement("p", null, props.description))));
|
|
716
|
+
}
|
|
717
|
+
|
|
710
718
|
const DEFAULT_IGNORED_PROPERTIES = [
|
|
711
719
|
'meta',
|
|
712
720
|
'implicitRules',
|
|
@@ -720,9 +728,9 @@ const DEFAULT_IGNORED_PROPERTIES = [
|
|
|
720
728
|
function FormSection(props) {
|
|
721
729
|
const issues = getIssuesForExpression(props.outcome, props.htmlFor);
|
|
722
730
|
const invalid = issues && issues.length > 0;
|
|
723
|
-
return (React.createElement("fieldset",
|
|
731
|
+
return (React.createElement("fieldset", { className: "medplum-form-section" },
|
|
724
732
|
props.title && React.createElement("label", { htmlFor: props.htmlFor }, props.title),
|
|
725
|
-
props.description && React.createElement("
|
|
733
|
+
props.description && React.createElement("p", null, props.description),
|
|
726
734
|
props.children,
|
|
727
735
|
invalid && (React.createElement("div", { id: props.htmlFor + '-errors', className: "medplum-input-error" }, issues === null || issues === void 0 ? void 0 : issues.map((issue) => {
|
|
728
736
|
var _a, _b;
|
|
@@ -730,6 +738,50 @@ function FormSection(props) {
|
|
|
730
738
|
})))));
|
|
731
739
|
}
|
|
732
740
|
|
|
741
|
+
function ResourceForm(props) {
|
|
742
|
+
const medplum = useMedplum();
|
|
743
|
+
const defaultValue = useResource(props.defaultValue);
|
|
744
|
+
const [schema, setSchema] = useState();
|
|
745
|
+
const [value, setValue] = useState();
|
|
746
|
+
useEffect(() => {
|
|
747
|
+
if (defaultValue) {
|
|
748
|
+
setValue(JSON.parse(JSON.stringify(defaultValue)));
|
|
749
|
+
medplum.requestSchema(defaultValue.resourceType).then(setSchema);
|
|
750
|
+
}
|
|
751
|
+
}, [medplum, defaultValue]);
|
|
752
|
+
if (!schema || !value) {
|
|
753
|
+
return React.createElement("div", null, "Loading...");
|
|
754
|
+
}
|
|
755
|
+
return (React.createElement("form", { noValidate: true, autoComplete: "off", onSubmit: (e) => {
|
|
756
|
+
e.preventDefault();
|
|
757
|
+
if (props.onSubmit) {
|
|
758
|
+
props.onSubmit(value);
|
|
759
|
+
}
|
|
760
|
+
} },
|
|
761
|
+
React.createElement(FormSection, { title: "Resource Type" },
|
|
762
|
+
React.createElement(Input, { name: "resourceType", defaultValue: value.resourceType, disabled: true })),
|
|
763
|
+
React.createElement(FormSection, { title: "ID" },
|
|
764
|
+
React.createElement(Input, { name: "id", defaultValue: value.id, disabled: true })),
|
|
765
|
+
React.createElement(BackboneElementInput, { typeName: value.resourceType, defaultValue: value, outcome: props.outcome, onChange: setValue }),
|
|
766
|
+
React.createElement(Button, { type: "submit", size: "large" }, "OK"),
|
|
767
|
+
props.onDelete && (React.createElement(Button, { type: "button", size: "large", onClick: () => {
|
|
768
|
+
props.onDelete(value);
|
|
769
|
+
} }, "Delete"))));
|
|
770
|
+
}
|
|
771
|
+
function setPropertyValue(obj, key, propName, elementDefinition, value) {
|
|
772
|
+
const types = elementDefinition.type;
|
|
773
|
+
if (types.length > 1) {
|
|
774
|
+
for (const type of types) {
|
|
775
|
+
const compoundKey = key.replace('[x]', capitalize(type.code));
|
|
776
|
+
if (compoundKey in obj) {
|
|
777
|
+
delete obj[compoundKey];
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
obj[propName] = value;
|
|
782
|
+
return obj;
|
|
783
|
+
}
|
|
784
|
+
|
|
733
785
|
function DescriptionList(props) {
|
|
734
786
|
return React.createElement("dl", { className: 'medplum-description-list' + (props.compact ? ' compact' : '') }, props.children);
|
|
735
787
|
}
|
|
@@ -818,6 +870,18 @@ function ContactPointDisplay(props) {
|
|
|
818
870
|
return React.createElement(React.Fragment, null, builder.join('').trim());
|
|
819
871
|
}
|
|
820
872
|
|
|
873
|
+
function ContactDetailDisplay(props) {
|
|
874
|
+
var _a;
|
|
875
|
+
const contactDetail = props.value;
|
|
876
|
+
if (!contactDetail) {
|
|
877
|
+
return null;
|
|
878
|
+
}
|
|
879
|
+
return (React.createElement(React.Fragment, null,
|
|
880
|
+
contactDetail.name,
|
|
881
|
+
contactDetail.name && ': ', (_a = contactDetail.telecom) === null || _a === void 0 ? void 0 :
|
|
882
|
+
_a.map((telecom, index) => (React.createElement(ContactPointDisplay, { key: 'telecom-' + index, value: telecom })))));
|
|
883
|
+
}
|
|
884
|
+
|
|
821
885
|
function DateTimeDisplay(props) {
|
|
822
886
|
if (!props.value) {
|
|
823
887
|
return null;
|
|
@@ -966,6 +1030,8 @@ function ResourcePropertyDisplay(props) {
|
|
|
966
1030
|
return React.createElement(CodeableConceptDisplay, { value: value });
|
|
967
1031
|
case PropertyType.Coding:
|
|
968
1032
|
return React.createElement(CodingDisplay, { value: value });
|
|
1033
|
+
case PropertyType.ContactDetail:
|
|
1034
|
+
return React.createElement(ContactDetailDisplay, { value: value });
|
|
969
1035
|
case PropertyType.ContactPoint:
|
|
970
1036
|
return React.createElement(ContactPointDisplay, { value: value });
|
|
971
1037
|
case PropertyType.HumanName:
|
|
@@ -1031,6 +1097,15 @@ function AnnotationInput(props) {
|
|
|
1031
1097
|
return (React.createElement(Input, { name: props.name, type: "text", placeholder: "Annotation text", defaultValue: value.text, onChange: setText }));
|
|
1032
1098
|
}
|
|
1033
1099
|
|
|
1100
|
+
function Checkbox(props) {
|
|
1101
|
+
const className = 'medplum-checkbox';
|
|
1102
|
+
return (React.createElement("input", { id: props.name, name: props.name, className: className, type: "checkbox", value: "true", defaultChecked: !!props.defaultValue, required: props.required, ref: props.inputRef, "data-testid": props.testid, disabled: props.disabled, onChange: (e) => {
|
|
1103
|
+
if (props.onChange) {
|
|
1104
|
+
props.onChange(e.currentTarget.checked);
|
|
1105
|
+
}
|
|
1106
|
+
} }));
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1034
1109
|
function CodeableConceptInput(props) {
|
|
1035
1110
|
const medplum = useMedplum();
|
|
1036
1111
|
let defaultValue = undefined;
|
|
@@ -1126,19 +1201,34 @@ function ContactPointInput(props) {
|
|
|
1126
1201
|
const ref = useRef();
|
|
1127
1202
|
ref.current = contactPoint;
|
|
1128
1203
|
function setContactPointWrapper(newValue) {
|
|
1204
|
+
if (newValue && Object.keys(newValue).length === 0) {
|
|
1205
|
+
newValue = undefined;
|
|
1206
|
+
}
|
|
1129
1207
|
setContactPoint(newValue);
|
|
1130
1208
|
if (props.onChange) {
|
|
1131
1209
|
props.onChange(newValue);
|
|
1132
1210
|
}
|
|
1133
1211
|
}
|
|
1134
1212
|
function setSystem(system) {
|
|
1135
|
-
|
|
1213
|
+
const newValue = Object.assign(Object.assign({}, ref.current), { system });
|
|
1214
|
+
if (!system) {
|
|
1215
|
+
delete newValue.system;
|
|
1216
|
+
}
|
|
1217
|
+
setContactPointWrapper(newValue);
|
|
1136
1218
|
}
|
|
1137
1219
|
function setUse(use) {
|
|
1138
|
-
|
|
1220
|
+
const newValue = Object.assign(Object.assign({}, ref.current), { use });
|
|
1221
|
+
if (!use) {
|
|
1222
|
+
delete newValue.use;
|
|
1223
|
+
}
|
|
1224
|
+
setContactPointWrapper(newValue);
|
|
1139
1225
|
}
|
|
1140
1226
|
function setValue(value) {
|
|
1141
|
-
|
|
1227
|
+
const newValue = Object.assign(Object.assign({}, ref.current), { value });
|
|
1228
|
+
if (!value) {
|
|
1229
|
+
delete newValue.value;
|
|
1230
|
+
}
|
|
1231
|
+
setContactPointWrapper(newValue);
|
|
1142
1232
|
}
|
|
1143
1233
|
return (React.createElement(InputRow, null,
|
|
1144
1234
|
React.createElement(Select, { defaultValue: contactPoint === null || contactPoint === void 0 ? void 0 : contactPoint.system, onChange: setSystem, testid: "system" },
|
|
@@ -1159,6 +1249,36 @@ function ContactPointInput(props) {
|
|
|
1159
1249
|
React.createElement(Input, { placeholder: "Value", defaultValue: contactPoint === null || contactPoint === void 0 ? void 0 : contactPoint.value, onChange: setValue })));
|
|
1160
1250
|
}
|
|
1161
1251
|
|
|
1252
|
+
function ContactDetailInput(props) {
|
|
1253
|
+
var _a;
|
|
1254
|
+
const [contactPoint, setContactDetail] = useState(props.defaultValue);
|
|
1255
|
+
const ref = useRef();
|
|
1256
|
+
ref.current = contactPoint;
|
|
1257
|
+
function setContactDetailWrapper(newValue) {
|
|
1258
|
+
setContactDetail(newValue);
|
|
1259
|
+
if (props.onChange) {
|
|
1260
|
+
props.onChange(newValue);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
function setName(name) {
|
|
1264
|
+
const newValue = Object.assign(Object.assign({}, ref.current), { name });
|
|
1265
|
+
if (!name) {
|
|
1266
|
+
delete newValue.name;
|
|
1267
|
+
}
|
|
1268
|
+
setContactDetailWrapper(newValue);
|
|
1269
|
+
}
|
|
1270
|
+
function setTelecom(telecom) {
|
|
1271
|
+
const newValue = Object.assign(Object.assign({}, ref.current), { telecom: telecom && [telecom] });
|
|
1272
|
+
if (!telecom) {
|
|
1273
|
+
delete newValue.telecom;
|
|
1274
|
+
}
|
|
1275
|
+
setContactDetailWrapper(newValue);
|
|
1276
|
+
}
|
|
1277
|
+
return (React.createElement(InputRow, null,
|
|
1278
|
+
React.createElement(Input, { name: props.name + '-name', placeholder: "Name", style: { width: 180 }, defaultValue: contactPoint === null || contactPoint === void 0 ? void 0 : contactPoint.name, onChange: setName }),
|
|
1279
|
+
React.createElement(ContactPointInput, { name: props.name + '-telecom', defaultValue: (_a = contactPoint === null || contactPoint === void 0 ? void 0 : contactPoint.telecom) === null || _a === void 0 ? void 0 : _a[0], onChange: setTelecom })));
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1162
1282
|
/**
|
|
1163
1283
|
* The DateTimeInput component is a wrapper around the HTML5 input type="datetime-local".
|
|
1164
1284
|
* The main purpose is to reconcile time zones.
|
|
@@ -1217,7 +1337,7 @@ function isValidDate(date) {
|
|
|
1217
1337
|
}
|
|
1218
1338
|
|
|
1219
1339
|
function TextArea(props) {
|
|
1220
|
-
const className = 'medplum-textarea';
|
|
1340
|
+
const className = 'medplum-textarea' + (props.monospace ? ' monospace' : '');
|
|
1221
1341
|
const issues = getIssuesForExpression(props.outcome, props.name);
|
|
1222
1342
|
const invalid = issues && issues.length > 0;
|
|
1223
1343
|
return (React.createElement("textarea", { id: props.name, name: props.name, className: className, defaultValue: props.defaultValue || '', required: props.required, autoComplete: props.autoComplete, autoFocus: props.autoFocus, ref: props.inputRef, "aria-invalid": invalid, "aria-describedby": invalid ? props.name + '-errors' : '', placeholder: props.placeholder, "data-testid": props.testid, style: props.style, onChange: (e) => {
|
|
@@ -1228,7 +1348,7 @@ function TextArea(props) {
|
|
|
1228
1348
|
}
|
|
1229
1349
|
|
|
1230
1350
|
function ExtensionInput(props) {
|
|
1231
|
-
return (React.createElement(TextArea, { testid: "extension-input", name: props.name, defaultValue: stringify(props.defaultValue), onChange: (newValue) => {
|
|
1351
|
+
return (React.createElement(TextArea, { testid: "extension-input", name: props.name, defaultValue: stringify(props.defaultValue), monospace: true, onChange: (newValue) => {
|
|
1232
1352
|
if (props.onChange) {
|
|
1233
1353
|
props.onChange(JSON.parse(newValue));
|
|
1234
1354
|
}
|
|
@@ -1451,35 +1571,34 @@ function ResourceArrayInput(props) {
|
|
|
1451
1571
|
props.onChange(newValues);
|
|
1452
1572
|
}
|
|
1453
1573
|
}
|
|
1454
|
-
return (React.createElement("
|
|
1455
|
-
React.createElement("
|
|
1456
|
-
React.createElement("
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
React.createElement("
|
|
1460
|
-
|
|
1461
|
-
React.createElement(
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
React.createElement(
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
React.createElement("
|
|
1475
|
-
|
|
1476
|
-
React.createElement(
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
} }, "Add")))))));
|
|
1574
|
+
return (React.createElement("table", { style: { width: '100%', borderCollapse: 'collapse' } },
|
|
1575
|
+
React.createElement("colgroup", null,
|
|
1576
|
+
React.createElement("col", { width: "90%" }),
|
|
1577
|
+
React.createElement("col", { width: "10%" })),
|
|
1578
|
+
React.createElement("tbody", null,
|
|
1579
|
+
values.map((v, index) => (React.createElement("tr", { key: `${index}-${values.length}` },
|
|
1580
|
+
React.createElement("td", null,
|
|
1581
|
+
React.createElement(ResourcePropertyInput, { arrayElement: true, property: props.property, name: props.name + '.' + index, defaultValue: v, onChange: (newValue) => {
|
|
1582
|
+
const copy = [...valuesRef.current];
|
|
1583
|
+
copy[index] = newValue;
|
|
1584
|
+
setValuesWrapper(copy);
|
|
1585
|
+
} })),
|
|
1586
|
+
React.createElement("td", { style: { textAlign: 'right' } },
|
|
1587
|
+
React.createElement(Button, { onClick: (e) => {
|
|
1588
|
+
killEvent(e);
|
|
1589
|
+
const copy = [...valuesRef.current];
|
|
1590
|
+
copy.splice(index, 1);
|
|
1591
|
+
setValuesWrapper(copy);
|
|
1592
|
+
} }, "Remove"))))),
|
|
1593
|
+
React.createElement("tr", null,
|
|
1594
|
+
React.createElement("td", null),
|
|
1595
|
+
React.createElement("td", { style: { textAlign: 'right' } },
|
|
1596
|
+
React.createElement(Button, { onClick: (e) => {
|
|
1597
|
+
killEvent(e);
|
|
1598
|
+
const copy = [...valuesRef.current];
|
|
1599
|
+
copy.push(undefined);
|
|
1600
|
+
setValuesWrapper(copy);
|
|
1601
|
+
} }, "Add"))))));
|
|
1483
1602
|
}
|
|
1484
1603
|
|
|
1485
1604
|
function ResourcePropertyInput(props) {
|
|
@@ -1523,6 +1642,7 @@ function ElementDefinitionInputSelector(props) {
|
|
|
1523
1642
|
} }))));
|
|
1524
1643
|
}
|
|
1525
1644
|
function ElementDefinitionTypeInput(props) {
|
|
1645
|
+
var _a;
|
|
1526
1646
|
const property = props.property;
|
|
1527
1647
|
const propertyType = props.elementDefinitionType.code;
|
|
1528
1648
|
const name = props.name;
|
|
@@ -1554,7 +1674,11 @@ function ElementDefinitionTypeInput(props) {
|
|
|
1554
1674
|
case PropertyType.code:
|
|
1555
1675
|
return React.createElement(CodeInput, { property: property, name: name, defaultValue: value, onChange: props.onChange });
|
|
1556
1676
|
case PropertyType.boolean:
|
|
1557
|
-
return (React.createElement(
|
|
1677
|
+
return (React.createElement(Checkbox, { name: name, testid: name, defaultValue: !!value, onChange: (newValue) => {
|
|
1678
|
+
if (props.onChange) {
|
|
1679
|
+
props.onChange(newValue);
|
|
1680
|
+
}
|
|
1681
|
+
} }));
|
|
1558
1682
|
case PropertyType.markdown:
|
|
1559
1683
|
return React.createElement(TextArea, { name: name, testid: name, defaultValue: value, onChange: props.onChange });
|
|
1560
1684
|
// 2.24.0.2 Complex Types
|
|
@@ -1569,6 +1693,8 @@ function ElementDefinitionTypeInput(props) {
|
|
|
1569
1693
|
return React.createElement(CodeableConceptInput, { property: property, name: name, defaultValue: value, onChange: props.onChange });
|
|
1570
1694
|
case PropertyType.Coding:
|
|
1571
1695
|
return React.createElement(CodingInput, { property: property, name: name, defaultValue: value, onChange: props.onChange });
|
|
1696
|
+
case PropertyType.ContactDetail:
|
|
1697
|
+
return React.createElement(ContactDetailInput, { name: name, defaultValue: value, onChange: props.onChange });
|
|
1572
1698
|
case PropertyType.ContactPoint:
|
|
1573
1699
|
return React.createElement(ContactPointInput, { name: name, defaultValue: value, onChange: props.onChange });
|
|
1574
1700
|
case PropertyType.Extension:
|
|
@@ -1588,7 +1714,7 @@ function ElementDefinitionTypeInput(props) {
|
|
|
1588
1714
|
case PropertyType.Reference:
|
|
1589
1715
|
return (React.createElement(ReferenceInput, { name: name, defaultValue: value, targetTypes: getTargetTypes(property), onChange: props.onChange }));
|
|
1590
1716
|
default:
|
|
1591
|
-
return (React.createElement(BackboneElementInput, {
|
|
1717
|
+
return (React.createElement(BackboneElementInput, { typeName: buildTypeName((_a = property.path) === null || _a === void 0 ? void 0 : _a.split('.')), defaultValue: value, onChange: props.onChange, outcome: props.outcome }));
|
|
1592
1718
|
}
|
|
1593
1719
|
}
|
|
1594
1720
|
function getTargetTypes(property) {
|
|
@@ -1596,65 +1722,8 @@ function getTargetTypes(property) {
|
|
|
1596
1722
|
return (_c = (_b = (_a = property === null || property === void 0 ? void 0 : property.type) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.targetProfile) === null || _c === void 0 ? void 0 : _c.map((p) => p.split('/').pop());
|
|
1597
1723
|
}
|
|
1598
1724
|
|
|
1599
|
-
function ResourceForm(props) {
|
|
1600
|
-
const medplum = useMedplum();
|
|
1601
|
-
const defaultValue = useResource(props.defaultValue);
|
|
1602
|
-
const [schema, setSchema] = useState();
|
|
1603
|
-
const [value, setValue] = useState();
|
|
1604
|
-
useEffect(() => {
|
|
1605
|
-
if (defaultValue) {
|
|
1606
|
-
setValue(JSON.parse(JSON.stringify(defaultValue)));
|
|
1607
|
-
medplum.requestSchema(defaultValue.resourceType).then(setSchema);
|
|
1608
|
-
}
|
|
1609
|
-
}, [medplum, defaultValue]);
|
|
1610
|
-
if (!schema || !value) {
|
|
1611
|
-
return React.createElement("div", null, "Loading...");
|
|
1612
|
-
}
|
|
1613
|
-
const typeSchema = schema.types[value.resourceType];
|
|
1614
|
-
const typedValue = { type: value.resourceType, value };
|
|
1615
|
-
return (React.createElement("form", { noValidate: true, autoComplete: "off", onSubmit: (e) => {
|
|
1616
|
-
e.preventDefault();
|
|
1617
|
-
if (props.onSubmit) {
|
|
1618
|
-
props.onSubmit(value);
|
|
1619
|
-
}
|
|
1620
|
-
} },
|
|
1621
|
-
React.createElement(FormSection, { title: "Resource Type" },
|
|
1622
|
-
React.createElement(Input, { name: "resourceType", defaultValue: value.resourceType, disabled: true })),
|
|
1623
|
-
React.createElement(FormSection, { title: "ID" },
|
|
1624
|
-
React.createElement(Input, { name: "id", defaultValue: value.id, disabled: true })),
|
|
1625
|
-
Object.entries(typeSchema.properties).map((entry) => {
|
|
1626
|
-
const key = entry[0];
|
|
1627
|
-
if (key === 'id' || DEFAULT_IGNORED_PROPERTIES.indexOf(key) >= 0) {
|
|
1628
|
-
return null;
|
|
1629
|
-
}
|
|
1630
|
-
const property = entry[1];
|
|
1631
|
-
const [propertyValue, propertyType] = getValueAndType(typedValue, key);
|
|
1632
|
-
return (React.createElement(FormSection, { key: key, title: getPropertyDisplayName(key), description: property.definition, htmlFor: key, outcome: props.outcome },
|
|
1633
|
-
React.createElement(ResourcePropertyInput, { property: property, name: key, defaultValue: propertyValue, defaultPropertyType: propertyType, outcome: props.outcome, onChange: (newValue, propName) => {
|
|
1634
|
-
setValue(setPropertyValue(value, key, propName !== null && propName !== void 0 ? propName : key, entry[1], newValue));
|
|
1635
|
-
} })));
|
|
1636
|
-
}),
|
|
1637
|
-
React.createElement(Button, { type: "submit", size: "large" }, "OK"),
|
|
1638
|
-
props.onDelete && (React.createElement(Button, { type: "button", size: "large", onClick: () => {
|
|
1639
|
-
props.onDelete(value);
|
|
1640
|
-
} }, "Delete"))));
|
|
1641
|
-
}
|
|
1642
|
-
function setPropertyValue(obj, key, propName, elementDefinition, value) {
|
|
1643
|
-
const types = elementDefinition.type;
|
|
1644
|
-
if (types.length > 1) {
|
|
1645
|
-
for (const type of types) {
|
|
1646
|
-
const compoundKey = key.replace('[x]', capitalize(type.code));
|
|
1647
|
-
if (compoundKey in obj) {
|
|
1648
|
-
delete obj[compoundKey];
|
|
1649
|
-
}
|
|
1650
|
-
}
|
|
1651
|
-
}
|
|
1652
|
-
obj[propName] = value;
|
|
1653
|
-
return obj;
|
|
1654
|
-
}
|
|
1655
|
-
|
|
1656
1725
|
function BackboneElementInput(props) {
|
|
1657
|
-
var _a
|
|
1726
|
+
var _a;
|
|
1658
1727
|
const [value, setValue] = useState((_a = props.defaultValue) !== null && _a !== void 0 ? _a : {});
|
|
1659
1728
|
function setValueWrapper(newValue) {
|
|
1660
1729
|
setValue(newValue);
|
|
@@ -1662,13 +1731,14 @@ function BackboneElementInput(props) {
|
|
|
1662
1731
|
props.onChange(newValue);
|
|
1663
1732
|
}
|
|
1664
1733
|
}
|
|
1665
|
-
const typeName =
|
|
1734
|
+
const typeName = props.typeName;
|
|
1666
1735
|
const typeSchema = globalSchema.types[typeName];
|
|
1667
1736
|
if (!typeSchema) {
|
|
1668
1737
|
return React.createElement("div", null,
|
|
1669
1738
|
typeName,
|
|
1670
1739
|
"\u00A0not implemented");
|
|
1671
1740
|
}
|
|
1741
|
+
const typedValue = { type: typeName, value };
|
|
1672
1742
|
return (React.createElement(React.Fragment, null, Object.entries(typeSchema.properties).map((entry) => {
|
|
1673
1743
|
const key = entry[0];
|
|
1674
1744
|
if (key === 'id' || DEFAULT_IGNORED_PROPERTIES.indexOf(key) >= 0) {
|
|
@@ -1678,7 +1748,13 @@ function BackboneElementInput(props) {
|
|
|
1678
1748
|
if (!property.type) {
|
|
1679
1749
|
return null;
|
|
1680
1750
|
}
|
|
1681
|
-
const [propertyValue, propertyType] = getValueAndType(
|
|
1751
|
+
const [propertyValue, propertyType] = getValueAndType(typedValue, key);
|
|
1752
|
+
if (property.type.length === 1 && property.type[0].code === 'boolean') {
|
|
1753
|
+
return (React.createElement(CheckboxFormSection, { key: key, title: getPropertyDisplayName(key), description: property.definition, htmlFor: key },
|
|
1754
|
+
React.createElement(ResourcePropertyInput, { property: property, name: key, defaultValue: propertyValue, defaultPropertyType: propertyType, outcome: props.outcome, onChange: (newValue, propName) => {
|
|
1755
|
+
setValueWrapper(setPropertyValue(value, key, propName !== null && propName !== void 0 ? propName : key, entry[1], newValue));
|
|
1756
|
+
} })));
|
|
1757
|
+
}
|
|
1682
1758
|
return (React.createElement(FormSection, { key: key, title: getPropertyDisplayName(key), description: property.definition, htmlFor: key, outcome: props.outcome },
|
|
1683
1759
|
React.createElement(ResourcePropertyInput, { property: property, name: key, defaultValue: propertyValue, defaultPropertyType: propertyType, outcome: props.outcome, onChange: (newValue, propName) => {
|
|
1684
1760
|
setValueWrapper(setPropertyValue(value, key, propName !== null && propName !== void 0 ? propName : key, entry[1], newValue));
|
|
@@ -2102,8 +2178,7 @@ function ResourceTimeline(props) {
|
|
|
2102
2178
|
setHistory({});
|
|
2103
2179
|
return;
|
|
2104
2180
|
}
|
|
2105
|
-
|
|
2106
|
-
medplum.post('fhir/R4', batchRequest).then(handleBatchResponse);
|
|
2181
|
+
medplum.executeBatch(buildSearchRequests(resource)).then(handleBatchResponse);
|
|
2107
2182
|
}, [medplum, resource, buildSearchRequests]);
|
|
2108
2183
|
useEffect(() => {
|
|
2109
2184
|
loadTimeline();
|
|
@@ -3196,7 +3271,7 @@ function SearchFilterValueInput(props) {
|
|
|
3196
3271
|
}
|
|
3197
3272
|
} }));
|
|
3198
3273
|
case SearchParameterType.BOOLEAN:
|
|
3199
|
-
return (React.createElement(
|
|
3274
|
+
return (React.createElement(Checkbox, { name: name, testid: name, defaultValue: props.defaultValue === 'true', onChange: (newValue) => props.onChange(newValue.toString()) }));
|
|
3200
3275
|
case SearchParameterType.DATE:
|
|
3201
3276
|
return React.createElement(Input, { type: "date", testid: name, defaultValue: props.defaultValue, onChange: props.onChange });
|
|
3202
3277
|
case SearchParameterType.DATETIME:
|
|
@@ -3892,7 +3967,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
3892
3967
|
function HeaderSearchInput(props) {
|
|
3893
3968
|
const medplum = useMedplum();
|
|
3894
3969
|
return (React.createElement(Autocomplete, { loadOptions: (input, signal) => __awaiter(this, void 0, void 0, function* () {
|
|
3895
|
-
return getResourcesFromResponse((yield medplum.graphql(buildGraphQLQuery(input), { signal })), input);
|
|
3970
|
+
return getResourcesFromResponse((yield medplum.graphql(buildGraphQLQuery(input), undefined, undefined, { signal })), input);
|
|
3896
3971
|
}), getId: (item) => {
|
|
3897
3972
|
return item.id;
|
|
3898
3973
|
}, getIcon: (item) => React.createElement(Avatar, { value: item }), getDisplay: (item) => React.createElement(ResourceName, { value: item }), getHelpText: (item) => {
|
|
@@ -4466,8 +4541,24 @@ function QuestionnaireFormItemArray(props) {
|
|
|
4466
4541
|
setResponseItems(newResponseItems);
|
|
4467
4542
|
props.onChange(newResponseItems);
|
|
4468
4543
|
}
|
|
4469
|
-
return (React.createElement(React.Fragment, null, props.items.map((item, index) =>
|
|
4470
|
-
|
|
4544
|
+
return (React.createElement(React.Fragment, null, props.items.map((item, index) => {
|
|
4545
|
+
if (item.type === QuestionnaireItemType.display) {
|
|
4546
|
+
return React.createElement("p", { key: item.linkId }, item.text);
|
|
4547
|
+
}
|
|
4548
|
+
if (item.type === QuestionnaireItemType.group) {
|
|
4549
|
+
return (React.createElement(QuestionnaireFormItem, { key: item.linkId, item: item, onChange: (newResponseItem) => setResponseItem(index, newResponseItem) }));
|
|
4550
|
+
}
|
|
4551
|
+
if (item.type === QuestionnaireItemType.boolean) {
|
|
4552
|
+
const initial = item.initial && item.initial.length > 0 ? item.initial[0] : undefined;
|
|
4553
|
+
return (React.createElement(CheckboxFormSection, { key: item.linkId, title: item.text, htmlFor: item.linkId },
|
|
4554
|
+
React.createElement(Checkbox, { name: item.linkId, defaultValue: initial === null || initial === void 0 ? void 0 : initial.valueBoolean, onChange: (newValue) => setResponseItem(index, {
|
|
4555
|
+
linkId: item.linkId,
|
|
4556
|
+
answer: [{ valueBoolean: newValue }],
|
|
4557
|
+
}) })));
|
|
4558
|
+
}
|
|
4559
|
+
return (React.createElement(FormSection, { key: item.linkId, htmlFor: item.linkId, title: item.text || '' },
|
|
4560
|
+
React.createElement(QuestionnaireFormItem, { item: item, onChange: (newResponseItem) => setResponseItem(index, newResponseItem) })));
|
|
4561
|
+
})));
|
|
4471
4562
|
}
|
|
4472
4563
|
function QuestionnaireFormItem(props) {
|
|
4473
4564
|
const item = props.item;
|
|
@@ -4498,7 +4589,7 @@ function QuestionnaireFormItem(props) {
|
|
|
4498
4589
|
React.createElement("h3", null, item.text),
|
|
4499
4590
|
item.item && React.createElement(QuestionnaireFormItemArray, { items: item.item, onChange: onChangeItem })));
|
|
4500
4591
|
case QuestionnaireItemType.boolean:
|
|
4501
|
-
return (React.createElement(
|
|
4592
|
+
return (React.createElement(Checkbox, { name: name, defaultValue: initial === null || initial === void 0 ? void 0 : initial.valueBoolean, onChange: (newValue) => onChangeAnswer({ valueBoolean: newValue }) }));
|
|
4502
4593
|
case QuestionnaireItemType.decimal:
|
|
4503
4594
|
return (React.createElement(Input, { type: "number", step: "any", name: name, defaultValue: initial === null || initial === void 0 ? void 0 : initial.valueDecimal, onChange: (newValue) => onChangeAnswer({ valueDecimal: parseFloat(newValue) }) }));
|
|
4504
4595
|
case QuestionnaireItemType.integer:
|
|
@@ -4515,31 +4606,64 @@ function QuestionnaireFormItem(props) {
|
|
|
4515
4606
|
return (React.createElement(TextArea, { name: name, defaultValue: initial === null || initial === void 0 ? void 0 : initial.valueString, onChange: (newValue) => onChangeAnswer({ valueString: newValue }) }));
|
|
4516
4607
|
case QuestionnaireItemType.url:
|
|
4517
4608
|
return (React.createElement(Input, { type: "url", name: name, defaultValue: initial === null || initial === void 0 ? void 0 : initial.valueUri, onChange: (newValue) => onChangeAnswer({ valueUri: newValue }) }));
|
|
4518
|
-
case QuestionnaireItemType.choice:
|
|
4519
|
-
case QuestionnaireItemType.openChoice:
|
|
4520
|
-
return (React.createElement("div", null, item.answerOption &&
|
|
4521
|
-
item.answerOption.map((option, index) => {
|
|
4522
|
-
const valueElementDefinition = globalSchema.types['QuestionnaireItemAnswerOption'].properties['value[x]'];
|
|
4523
|
-
const optionValue = getTypedPropertyValue({ type: 'QuestionnaireItemAnswerOption', value: option }, 'value');
|
|
4524
|
-
const initialValue = getTypedPropertyValue({ type: 'QuestionnaireItemInitial', value: initial }, 'value');
|
|
4525
|
-
const propertyName = 'value' + capitalize(optionValue.type);
|
|
4526
|
-
const optionName = `${name}-option-${index}`;
|
|
4527
|
-
return (React.createElement("div", { key: optionName, className: "medplum-questionnaire-option-row" },
|
|
4528
|
-
React.createElement("div", { className: "medplum-questionnaire-option-checkbox" },
|
|
4529
|
-
React.createElement("input", { type: "radio", id: optionName, name: name, value: optionValue.value, defaultChecked: initialValue && stringify(optionValue) === stringify(initialValue), onChange: () => onChangeAnswer({ [propertyName]: optionValue.value }) })),
|
|
4530
|
-
React.createElement("div", null,
|
|
4531
|
-
React.createElement("label", { htmlFor: optionName },
|
|
4532
|
-
React.createElement(ResourcePropertyDisplay, { property: valueElementDefinition, propertyType: optionValue.type, value: optionValue.value })))));
|
|
4533
|
-
})));
|
|
4534
4609
|
case QuestionnaireItemType.attachment:
|
|
4535
4610
|
return (React.createElement(AttachmentInput, { name: name, defaultValue: initial === null || initial === void 0 ? void 0 : initial.valueAttachment, onChange: (newValue) => onChangeAnswer({ valueAttachment: newValue }) }));
|
|
4536
4611
|
case QuestionnaireItemType.reference:
|
|
4537
4612
|
return (React.createElement(ReferenceInput, { name: name, defaultValue: initial === null || initial === void 0 ? void 0 : initial.valueReference, onChange: (newValue) => onChangeAnswer({ valueReference: newValue }) }));
|
|
4538
4613
|
case QuestionnaireItemType.quantity:
|
|
4539
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
|
+
}
|
|
4540
4623
|
}
|
|
4541
4624
|
return null;
|
|
4542
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
|
+
}
|
|
4543
4667
|
function buildInitialResponse(questionnaire) {
|
|
4544
4668
|
const response = {
|
|
4545
4669
|
resourceType: 'QuestionnaireResponse',
|
|
@@ -4565,6 +4689,14 @@ function buildInitialResponseAnswer(answer) {
|
|
|
4565
4689
|
// have the same properties.
|
|
4566
4690
|
return Object.assign({}, answer);
|
|
4567
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
|
+
}
|
|
4568
4700
|
|
|
4569
4701
|
function QuestionnaireBuilder(props) {
|
|
4570
4702
|
const medplum = useMedplum();
|
|
@@ -4778,7 +4910,7 @@ function RequestGroupDisplay(props) {
|
|
|
4778
4910
|
const [responseBundle, setResponseBundle] = useState();
|
|
4779
4911
|
useEffect(() => {
|
|
4780
4912
|
if (requestGroup && !startedLoading) {
|
|
4781
|
-
medplum.
|
|
4913
|
+
medplum.executeBatch(buildBatchRequest(requestGroup)).then(setResponseBundle);
|
|
4782
4914
|
setStartedLoading(true);
|
|
4783
4915
|
}
|
|
4784
4916
|
}, [medplum, requestGroup, startedLoading]);
|
|
@@ -5195,7 +5327,7 @@ function createScriptTag(src, onload) {
|
|
|
5195
5327
|
|
|
5196
5328
|
function GoogleButton(props) {
|
|
5197
5329
|
const medplum = useMedplum();
|
|
5198
|
-
const {
|
|
5330
|
+
const { handleGoogleCredential } = props;
|
|
5199
5331
|
const googleClientId = getGoogleClientId(props.googleClientId);
|
|
5200
5332
|
const parentRef = useRef(null);
|
|
5201
5333
|
const [scriptLoaded, setScriptLoaded] = useState(typeof google !== 'undefined');
|
|
@@ -5209,7 +5341,7 @@ function GoogleButton(props) {
|
|
|
5209
5341
|
if (!initialized) {
|
|
5210
5342
|
google.accounts.id.initialize({
|
|
5211
5343
|
client_id: googleClientId,
|
|
5212
|
-
callback:
|
|
5344
|
+
callback: handleGoogleCredential,
|
|
5213
5345
|
});
|
|
5214
5346
|
setInitialized(true);
|
|
5215
5347
|
}
|
|
@@ -5217,7 +5349,7 @@ function GoogleButton(props) {
|
|
|
5217
5349
|
google.accounts.id.renderButton(parentRef.current, {});
|
|
5218
5350
|
setButtonRendered(true);
|
|
5219
5351
|
}
|
|
5220
|
-
}, [medplum, googleClientId, initialized, scriptLoaded, parentRef, buttonRendered,
|
|
5352
|
+
}, [medplum, googleClientId, initialized, scriptLoaded, parentRef, buttonRendered, handleGoogleCredential]);
|
|
5221
5353
|
if (!googleClientId) {
|
|
5222
5354
|
return null;
|
|
5223
5355
|
}
|
|
@@ -5248,19 +5380,24 @@ function SignInForm(props) {
|
|
|
5248
5380
|
setMemberships(response.memberships);
|
|
5249
5381
|
}
|
|
5250
5382
|
if (response.code) {
|
|
5251
|
-
|
|
5252
|
-
.
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5383
|
+
if (props.onCode) {
|
|
5384
|
+
props.onCode(response.code);
|
|
5385
|
+
}
|
|
5386
|
+
else {
|
|
5387
|
+
medplum
|
|
5388
|
+
.processCode(response.code)
|
|
5389
|
+
.then(() => {
|
|
5390
|
+
if (props.onSuccess) {
|
|
5391
|
+
props.onSuccess();
|
|
5392
|
+
}
|
|
5393
|
+
})
|
|
5394
|
+
.catch(console.log);
|
|
5395
|
+
}
|
|
5259
5396
|
}
|
|
5260
5397
|
}
|
|
5261
5398
|
return (React.createElement(Document, { width: 450 }, (() => {
|
|
5262
5399
|
if (!login) {
|
|
5263
|
-
return (React.createElement(AuthenticationForm, { googleClientId: props.googleClientId, onForgotPassword: props.onForgotPassword, onRegister: props.onRegister, handleAuthResponse: handleAuthResponse }, props.children));
|
|
5400
|
+
return (React.createElement(AuthenticationForm, { clientId: props.clientId, scope: props.scope, nonce: props.nonce, googleClientId: props.googleClientId, onForgotPassword: props.onForgotPassword, onRegister: props.onRegister, handleAuthResponse: handleAuthResponse }, props.children));
|
|
5264
5401
|
}
|
|
5265
5402
|
else if (memberships) {
|
|
5266
5403
|
return React.createElement(ProfileForm, { login: login, memberships: memberships, handleAuthResponse: handleAuthResponse });
|
|
@@ -5277,6 +5414,9 @@ function AuthenticationForm(props) {
|
|
|
5277
5414
|
return (React.createElement(Form, { style: { maxWidth: 400 }, onSubmit: (formData) => {
|
|
5278
5415
|
medplum
|
|
5279
5416
|
.startLogin({
|
|
5417
|
+
clientId: props.clientId,
|
|
5418
|
+
scope: props.scope,
|
|
5419
|
+
nonce: props.nonce,
|
|
5280
5420
|
email: formData.email,
|
|
5281
5421
|
password: formData.password,
|
|
5282
5422
|
remember: formData.remember === 'true',
|
|
@@ -5303,7 +5443,18 @@ function AuthenticationForm(props) {
|
|
|
5303
5443
|
React.createElement("div", null,
|
|
5304
5444
|
React.createElement(Button, { type: "submit", testid: "submit" }, "Sign in"))),
|
|
5305
5445
|
React.createElement("div", { className: "medplum-signin-google-container" },
|
|
5306
|
-
React.createElement(GoogleButton, { googleClientId: props.googleClientId,
|
|
5446
|
+
React.createElement(GoogleButton, { googleClientId: props.googleClientId, handleGoogleCredential: (response) => {
|
|
5447
|
+
medplum
|
|
5448
|
+
.startGoogleLogin({
|
|
5449
|
+
clientId: props.clientId,
|
|
5450
|
+
scope: props.scope,
|
|
5451
|
+
nonce: props.nonce,
|
|
5452
|
+
googleClientId: response.clientId,
|
|
5453
|
+
googleCredential: response.credential,
|
|
5454
|
+
})
|
|
5455
|
+
.then(props.handleAuthResponse)
|
|
5456
|
+
.catch(setOutcome);
|
|
5457
|
+
} }))));
|
|
5307
5458
|
}
|
|
5308
5459
|
function ProfileForm(props) {
|
|
5309
5460
|
const medplum = useMedplum();
|
|
@@ -5375,5 +5526,5 @@ function TabSwitch(props) {
|
|
|
5375
5526
|
})));
|
|
5376
5527
|
}
|
|
5377
5528
|
|
|
5378
|
-
export { AddressDisplay, AddressInput, AttachmentArrayDisplay, AttachmentArrayInput, AttachmentInput, Autocomplete, Avatar, BackboneElementInput, Button, CodeInput, CodeableConceptDisplay, CodeableConceptInput, ContactPointDisplay, ContactPointInput, DateTimeDisplay, DateTimeInput, DefaultResourceTimeline, DiagnosticReportDisplay, Document, ElementDefinitionInputSelector, ElementDefinitionTypeInput, EncounterTimeline, ErrorBoundary, FhirPathTable, FooterLinks, Form, FormSection, Header, HumanNameDisplay, HumanNameInput, IdentifierInput, Input, Loading, Logo, MedplumLink, MedplumProvider, MemoizedFhirPathTable, MemoizedSearchControl, MenuItem, ObservationTable, PatientTimeline, PlanDefinitionBuilder, Popup, QuestionnaireBuilder, QuestionnaireForm, QuestionnaireFormItem, QuestionnaireItemType, RangeDisplay, RangeInput, ReferenceInput, RequestGroupDisplay, ResourceArrayDisplay, ResourceArrayInput, ResourceBadge, ResourceBlame, ResourceDiff, ResourceForm, ResourceHistoryTable, ResourceInput, ResourceName, ResourcePropertyDisplay, ResourcePropertyInput, ResourceTable, ResourceTimeline, Scrollable, SearchChangeEvent, SearchClickEvent, SearchControl, SearchFieldEditor, SearchFilterEditor, SearchLoadEvent, Select, ServiceRequestTimeline, SignInForm, StatusBadge, Tab, TabList, TabPanel, TabSwitch, TextArea, Timeline, TimelineItem, TitleBar, UploadButton, addDateEqualsFilter, addDateFilter, addDateFilterBetween, addField, addFilter, addLastMonthFilter, addMissingFilter, addNextMonthFilter, addQuestionnaireInitialValues, addThisMonthFilter, addTodayFilter, addTomorrowFilter, addYearToDateFilter, addYesterdayFilter, buildFieldNameString, clearFilters, clearFiltersOnField, convertIsoToLocal, convertLocalToIso, createScriptTag, deleteFilter, formatRangeString, getOpString, getSearchOperators, getSortField, getTimeString, getValueAndType, hasFilterOnField, isChoiceQuestion, isSortDescending, movePage, parseForm, renderValue, setFilters, setOffset, setPropertyValue, setSort, sortByDateAndPriority, toggleSort, useMedplum, useMedplumContext, useMedplumProfile, useResource };
|
|
5529
|
+
export { AddressDisplay, AddressInput, AttachmentArrayDisplay, AttachmentArrayInput, AttachmentInput, Autocomplete, Avatar, BackboneElementInput, Button, Checkbox, CheckboxFormSection, CodeInput, CodeableConceptDisplay, CodeableConceptInput, ContactDetailDisplay, ContactDetailInput, ContactPointDisplay, ContactPointInput, DateTimeDisplay, DateTimeInput, DefaultResourceTimeline, DiagnosticReportDisplay, Document, ElementDefinitionInputSelector, ElementDefinitionTypeInput, EncounterTimeline, ErrorBoundary, FhirPathTable, FooterLinks, Form, FormSection, Header, HumanNameDisplay, HumanNameInput, IdentifierInput, Input, Loading, Logo, MedplumLink, MedplumProvider, MemoizedFhirPathTable, MemoizedSearchControl, MenuItem, ObservationTable, PatientTimeline, PlanDefinitionBuilder, Popup, QuestionnaireBuilder, QuestionnaireForm, QuestionnaireFormItem, QuestionnaireItemType, RangeDisplay, RangeInput, ReferenceInput, RequestGroupDisplay, ResourceArrayDisplay, ResourceArrayInput, ResourceBadge, ResourceBlame, ResourceDiff, ResourceForm, ResourceHistoryTable, ResourceInput, ResourceName, ResourcePropertyDisplay, ResourcePropertyInput, ResourceTable, ResourceTimeline, Scrollable, SearchChangeEvent, SearchClickEvent, SearchControl, SearchFieldEditor, SearchFilterEditor, SearchLoadEvent, Select, ServiceRequestTimeline, SignInForm, StatusBadge, Tab, TabList, TabPanel, TabSwitch, TextArea, Timeline, TimelineItem, TitleBar, UploadButton, addDateEqualsFilter, addDateFilter, addDateFilterBetween, addField, addFilter, addLastMonthFilter, addMissingFilter, addNextMonthFilter, addQuestionnaireInitialValues, addThisMonthFilter, addTodayFilter, addTomorrowFilter, addYearToDateFilter, addYesterdayFilter, buildFieldNameString, clearFilters, clearFiltersOnField, convertIsoToLocal, convertLocalToIso, createScriptTag, deleteFilter, formatRangeString, getOpString, getSearchOperators, getSortField, getTimeString, getValueAndType, hasFilterOnField, isChoiceQuestion, isSortDescending, movePage, parseForm, renderValue, setFilters, setOffset, setPropertyValue, setSort, sortByDateAndPriority, toggleSort, useMedplum, useMedplumContext, useMedplumProfile, useResource };
|
|
5379
5530
|
//# sourceMappingURL=index.js.map
|