@medplum/react 1.0.2 → 1.0.3
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/CodeableConceptDisplay/CodeableConceptDisplay.d.ts +1 -1
- package/dist/cjs/index.d.ts +11 -0
- package/dist/cjs/index.js +396 -408
- 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/CodeableConceptDisplay/CodeableConceptDisplay.d.ts +1 -1
- package/dist/esm/CodeableConceptDisplay/CodeableConceptDisplay.js +2 -14
- package/dist/esm/CodeableConceptDisplay/CodeableConceptDisplay.js.map +1 -1
- package/dist/esm/CodingDisplay/CodingDisplay.js +2 -2
- package/dist/esm/CodingDisplay/CodingDisplay.js.map +1 -1
- package/dist/esm/DiagnosticReportDisplay/DiagnosticReportDisplay.js +2 -15
- package/dist/esm/DiagnosticReportDisplay/DiagnosticReportDisplay.js.map +1 -1
- package/dist/esm/ResourceTimeline/ResourceTimeline.js.map +1 -1
- package/dist/esm/index.d.ts +11 -0
- package/dist/esm/index.js +11 -0
- 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/package.json +5 -5
package/dist/cjs/index.js
CHANGED
|
@@ -64,28 +64,6 @@
|
|
|
64
64
|
React.createElement(core$1.TextInput, { placeholder: "Postal Code", defaultValue: value.postalCode, onChange: (e) => setPostalCode(e.currentTarget.value) })));
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
function AttachmentDisplay(props) {
|
|
68
|
-
const value = props.value;
|
|
69
|
-
const { contentType, url, title } = value !== null && value !== void 0 ? value : {};
|
|
70
|
-
if (!url) {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
return (React.createElement("div", { "data-testid": "attachment-display" },
|
|
74
|
-
(contentType === null || contentType === void 0 ? void 0 : contentType.startsWith('image/')) && (React.createElement("img", { "data-testid": "attachment-image", style: { maxWidth: props.maxWidth }, src: url, alt: value === null || value === void 0 ? void 0 : value.title })),
|
|
75
|
-
(contentType === null || contentType === void 0 ? void 0 : contentType.startsWith('video/')) && (React.createElement("video", { "data-testid": "attachment-video", style: { maxWidth: props.maxWidth }, controls: true },
|
|
76
|
-
React.createElement("source", { type: contentType, src: url }))),
|
|
77
|
-
contentType === 'application/pdf' && !(title === null || title === void 0 ? void 0 : title.endsWith('.pdf')) && (React.createElement("div", { "data-testid": "attachment-pdf", style: { maxWidth: props.maxWidth, minHeight: 400 } },
|
|
78
|
-
React.createElement("iframe", { width: "100%", height: "400", src: url + '#navpanes=0', allowFullScreen: true, frameBorder: 0, seamless: true }))),
|
|
79
|
-
React.createElement("div", { "data-testid": "download-link", style: { padding: '2px 16px 16px 16px' } },
|
|
80
|
-
React.createElement("a", { href: value === null || value === void 0 ? void 0 : value.url, "data-testid": "attachment-details", target: "_blank", rel: "noopener noreferrer" }, (value === null || value === void 0 ? void 0 : value.title) || 'Download'))));
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function AttachmentArrayDisplay(props) {
|
|
84
|
-
return (React.createElement("div", null, props.values &&
|
|
85
|
-
props.values.map((v, index) => (React.createElement("div", { key: 'attatchment-' + index },
|
|
86
|
-
React.createElement(AttachmentDisplay, { value: v, maxWidth: props.maxWidth }))))));
|
|
87
|
-
}
|
|
88
|
-
|
|
89
67
|
const reactContext = React.createContext(undefined);
|
|
90
68
|
/**
|
|
91
69
|
* The MedplumProvider component provides Medplum context state.
|
|
@@ -132,6 +110,49 @@
|
|
|
132
110
|
return useMedplumContext().profile;
|
|
133
111
|
}
|
|
134
112
|
|
|
113
|
+
function AnnotationInput(props) {
|
|
114
|
+
const author = useMedplumProfile();
|
|
115
|
+
const [value, setValue] = React.useState(props.defaultValue || {});
|
|
116
|
+
const valueRef = React.useRef();
|
|
117
|
+
valueRef.current = value;
|
|
118
|
+
function setText(text) {
|
|
119
|
+
const newValue = text
|
|
120
|
+
? {
|
|
121
|
+
text,
|
|
122
|
+
authorReference: author && core.createReference(author),
|
|
123
|
+
time: new Date().toISOString(),
|
|
124
|
+
}
|
|
125
|
+
: {};
|
|
126
|
+
setValue(newValue);
|
|
127
|
+
if (props.onChange) {
|
|
128
|
+
props.onChange(newValue);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return (React.createElement(core$1.TextInput, { name: props.name, placeholder: "Annotation text", defaultValue: value.text, onChange: (e) => setText(e.currentTarget.value) }));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function AttachmentDisplay(props) {
|
|
135
|
+
const value = props.value;
|
|
136
|
+
const { contentType, url, title } = value !== null && value !== void 0 ? value : {};
|
|
137
|
+
if (!url) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
return (React.createElement("div", { "data-testid": "attachment-display" },
|
|
141
|
+
(contentType === null || contentType === void 0 ? void 0 : contentType.startsWith('image/')) && (React.createElement("img", { "data-testid": "attachment-image", style: { maxWidth: props.maxWidth }, src: url, alt: value === null || value === void 0 ? void 0 : value.title })),
|
|
142
|
+
(contentType === null || contentType === void 0 ? void 0 : contentType.startsWith('video/')) && (React.createElement("video", { "data-testid": "attachment-video", style: { maxWidth: props.maxWidth }, controls: true },
|
|
143
|
+
React.createElement("source", { type: contentType, src: url }))),
|
|
144
|
+
contentType === 'application/pdf' && !(title === null || title === void 0 ? void 0 : title.endsWith('.pdf')) && (React.createElement("div", { "data-testid": "attachment-pdf", style: { maxWidth: props.maxWidth, minHeight: 400 } },
|
|
145
|
+
React.createElement("iframe", { width: "100%", height: "400", src: url + '#navpanes=0', allowFullScreen: true, frameBorder: 0, seamless: true }))),
|
|
146
|
+
React.createElement("div", { "data-testid": "download-link", style: { padding: '2px 16px 16px 16px' } },
|
|
147
|
+
React.createElement("a", { href: value === null || value === void 0 ? void 0 : value.url, "data-testid": "attachment-details", target: "_blank", rel: "noopener noreferrer" }, (value === null || value === void 0 ? void 0 : value.title) || 'Download'))));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function AttachmentArrayDisplay(props) {
|
|
151
|
+
return (React.createElement("div", null, props.values &&
|
|
152
|
+
props.values.map((v, index) => (React.createElement("div", { key: 'attatchment-' + index },
|
|
153
|
+
React.createElement(AttachmentDisplay, { value: v, maxWidth: props.maxWidth }))))));
|
|
154
|
+
}
|
|
155
|
+
|
|
135
156
|
/**
|
|
136
157
|
* Kills a browser event.
|
|
137
158
|
* Prevents default behavior.
|
|
@@ -769,13 +790,6 @@
|
|
|
769
790
|
})()));
|
|
770
791
|
}
|
|
771
792
|
|
|
772
|
-
function CheckboxFormSection(props) {
|
|
773
|
-
return (React.createElement(core$1.Group, { noWrap: true },
|
|
774
|
-
React.createElement("div", null, props.children),
|
|
775
|
-
React.createElement("div", null,
|
|
776
|
-
React.createElement(core$1.Input.Wrapper, { id: props.htmlFor, label: props.title, description: props.description }, (() => null)()))));
|
|
777
|
-
}
|
|
778
|
-
|
|
779
793
|
const DEFAULT_IGNORED_PROPERTIES = [
|
|
780
794
|
'meta',
|
|
781
795
|
'implicitRules',
|
|
@@ -786,116 +800,6 @@
|
|
|
786
800
|
'modifierExtension',
|
|
787
801
|
];
|
|
788
802
|
|
|
789
|
-
function FormSection(props) {
|
|
790
|
-
return (React.createElement(core$1.Input.Wrapper, { id: props.htmlFor, label: props.title, description: props.description, error: getErrorsForInput(props.outcome, props.htmlFor) }, props.children));
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
const system = {
|
|
794
|
-
resourceType: 'Device',
|
|
795
|
-
id: 'system',
|
|
796
|
-
deviceName: [
|
|
797
|
-
{
|
|
798
|
-
name: 'System',
|
|
799
|
-
},
|
|
800
|
-
],
|
|
801
|
-
};
|
|
802
|
-
/**
|
|
803
|
-
* React Hook to use a FHIR reference.
|
|
804
|
-
* Handles the complexity of resolving references and caching resources.
|
|
805
|
-
* @param value The resource or reference to resource.
|
|
806
|
-
* @returns The resolved resource.
|
|
807
|
-
*/
|
|
808
|
-
function useResource(value) {
|
|
809
|
-
const medplum = useMedplum();
|
|
810
|
-
const [resource, setResource] = React.useState(getInitialResource(medplum, value));
|
|
811
|
-
React.useEffect(() => {
|
|
812
|
-
let subscribed = true;
|
|
813
|
-
if (!resource && value && 'reference' in value && value.reference) {
|
|
814
|
-
medplum
|
|
815
|
-
.readReference(value)
|
|
816
|
-
.then((r) => {
|
|
817
|
-
if (subscribed) {
|
|
818
|
-
setResource(r);
|
|
819
|
-
}
|
|
820
|
-
})
|
|
821
|
-
.catch(() => setResource(undefined));
|
|
822
|
-
}
|
|
823
|
-
return (() => (subscribed = false));
|
|
824
|
-
}, [medplum, resource, value]);
|
|
825
|
-
return resource;
|
|
826
|
-
}
|
|
827
|
-
/**
|
|
828
|
-
* Returns the initial resource value based on the input value.
|
|
829
|
-
* If the input value is a resource, returns the resource.
|
|
830
|
-
* If the input value is a reference to system, returns the system resource.
|
|
831
|
-
* If the input value is a reference to a resource available in the cache, returns the resource.
|
|
832
|
-
* Otherwise, returns undefined.
|
|
833
|
-
* @param medplum The medplum client.
|
|
834
|
-
* @param value The resource or reference to resource.
|
|
835
|
-
* @returns An initial resource if available; undefined otherwise.
|
|
836
|
-
*/
|
|
837
|
-
function getInitialResource(medplum, value) {
|
|
838
|
-
if (!value) {
|
|
839
|
-
return undefined;
|
|
840
|
-
}
|
|
841
|
-
if ('resourceType' in value) {
|
|
842
|
-
return value;
|
|
843
|
-
}
|
|
844
|
-
if ('reference' in value) {
|
|
845
|
-
if (value.reference === 'system') {
|
|
846
|
-
return system;
|
|
847
|
-
}
|
|
848
|
-
return medplum.getCachedReference(value);
|
|
849
|
-
}
|
|
850
|
-
return undefined;
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
function ResourceForm(props) {
|
|
854
|
-
const medplum = useMedplum();
|
|
855
|
-
const defaultValue = useResource(props.defaultValue);
|
|
856
|
-
const [schema, setSchema] = React.useState();
|
|
857
|
-
const [value, setValue] = React.useState();
|
|
858
|
-
React.useEffect(() => {
|
|
859
|
-
if (defaultValue) {
|
|
860
|
-
setValue(JSON.parse(JSON.stringify(defaultValue)));
|
|
861
|
-
medplum.requestSchema(defaultValue.resourceType).then(setSchema).catch(console.log);
|
|
862
|
-
}
|
|
863
|
-
}, [medplum, defaultValue]);
|
|
864
|
-
if (!schema || !value) {
|
|
865
|
-
return React.createElement("div", null, "Loading...");
|
|
866
|
-
}
|
|
867
|
-
return (React.createElement("form", { noValidate: true, autoComplete: "off", onSubmit: (e) => {
|
|
868
|
-
e.preventDefault();
|
|
869
|
-
if (props.onSubmit) {
|
|
870
|
-
props.onSubmit(value);
|
|
871
|
-
}
|
|
872
|
-
} },
|
|
873
|
-
React.createElement(core$1.Stack, { mb: "xl" },
|
|
874
|
-
React.createElement(FormSection, { title: "Resource Type", htmlFor: "resourceType", outcome: props.outcome },
|
|
875
|
-
React.createElement(core$1.TextInput, { name: "resourceType", defaultValue: value.resourceType, disabled: true })),
|
|
876
|
-
React.createElement(FormSection, { title: "ID", htmlFor: "id", outcome: props.outcome },
|
|
877
|
-
React.createElement(core$1.TextInput, { name: "id", defaultValue: value.id, disabled: true }))),
|
|
878
|
-
React.createElement(BackboneElementInput, { typeName: value.resourceType, defaultValue: value, outcome: props.outcome, onChange: setValue }),
|
|
879
|
-
React.createElement(core$1.Group, { position: "right", mt: "xl" },
|
|
880
|
-
React.createElement(core$1.Button, { type: "submit" }, "OK"),
|
|
881
|
-
props.onDelete && (React.createElement(core$1.Button, { variant: "outline", color: "red", type: "button", onClick: () => {
|
|
882
|
-
props.onDelete(value);
|
|
883
|
-
} }, "Delete")))));
|
|
884
|
-
}
|
|
885
|
-
function setPropertyValue(obj, key, propName, elementDefinition, value) {
|
|
886
|
-
const types = elementDefinition.type;
|
|
887
|
-
if (types.length > 1) {
|
|
888
|
-
for (const type of types) {
|
|
889
|
-
const compoundKey = key.replace('[x]', core.capitalize(type.code));
|
|
890
|
-
if (compoundKey in obj) {
|
|
891
|
-
delete obj[compoundKey];
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
obj[propName] = value;
|
|
896
|
-
return obj;
|
|
897
|
-
}
|
|
898
|
-
|
|
899
803
|
const useStyles$b = core$1.createStyles((theme) => ({
|
|
900
804
|
root: {
|
|
901
805
|
display: 'grid',
|
|
@@ -926,63 +830,12 @@
|
|
|
926
830
|
React.createElement("dd", null, props.children)));
|
|
927
831
|
}
|
|
928
832
|
|
|
929
|
-
function
|
|
930
|
-
|
|
931
|
-
const value = typedValue.value;
|
|
932
|
-
if (!value) {
|
|
933
|
-
return null;
|
|
934
|
-
}
|
|
935
|
-
const typeName = typedValue.type;
|
|
936
|
-
const typeSchema = core.globalSchema.types[typeName];
|
|
937
|
-
if (!typeSchema) {
|
|
938
|
-
return React.createElement("div", null,
|
|
939
|
-
typeName,
|
|
940
|
-
"\u00A0not implemented");
|
|
941
|
-
}
|
|
942
|
-
if (typeof value === 'object' &&
|
|
943
|
-
'name' in value &&
|
|
944
|
-
Object.keys(value).length === 1 &&
|
|
945
|
-
typeof value.name === 'string') {
|
|
946
|
-
// Special case for common BackboneElement pattern
|
|
947
|
-
// Where there is an object with a single property 'name'
|
|
948
|
-
// Just display the name value.
|
|
949
|
-
return React.createElement("div", null, value.name);
|
|
950
|
-
}
|
|
951
|
-
return (React.createElement(DescriptionList, { compact: props.compact }, Object.entries(typeSchema.properties).map((entry) => {
|
|
952
|
-
const key = entry[0];
|
|
953
|
-
if (DEFAULT_IGNORED_PROPERTIES.indexOf(key) >= 0) {
|
|
954
|
-
return null;
|
|
955
|
-
}
|
|
956
|
-
const property = entry[1];
|
|
957
|
-
const [propertyValue, propertyType] = getValueAndType(typedValue, key);
|
|
958
|
-
if (props.ignoreMissingValues &&
|
|
959
|
-
(!propertyValue || (Array.isArray(propertyValue) && propertyValue.length === 0))) {
|
|
960
|
-
return null;
|
|
961
|
-
}
|
|
962
|
-
return (React.createElement(DescriptionListEntry, { key: key, term: core.getPropertyDisplayName(key) },
|
|
963
|
-
React.createElement(ResourcePropertyDisplay, { property: property, propertyType: propertyType, value: propertyValue, ignoreMissingValues: props.ignoreMissingValues, link: props.link })));
|
|
964
|
-
})));
|
|
833
|
+
function CodeableConceptDisplay(props) {
|
|
834
|
+
return React.createElement(React.Fragment, null, core.formatCodeableConcept(props.value));
|
|
965
835
|
}
|
|
966
836
|
|
|
967
837
|
function CodingDisplay(props) {
|
|
968
|
-
|
|
969
|
-
return React.createElement(React.Fragment, null, ((_a = props.value) === null || _a === void 0 ? void 0 : _a.display) || ((_b = props.value) === null || _b === void 0 ? void 0 : _b.code));
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
function CodeableConceptDisplay(props) {
|
|
973
|
-
const value = props.value;
|
|
974
|
-
if (!value) {
|
|
975
|
-
return null;
|
|
976
|
-
}
|
|
977
|
-
if (value.text) {
|
|
978
|
-
return React.createElement(React.Fragment, null, value.text);
|
|
979
|
-
}
|
|
980
|
-
if (value.coding) {
|
|
981
|
-
return (React.createElement(React.Fragment, null, value.coding.map((coding, index) => (React.createElement(React.Fragment, { key: 'coding-' + index },
|
|
982
|
-
index > 0 && React.createElement(React.Fragment, null, ', '),
|
|
983
|
-
React.createElement(CodingDisplay, { value: coding }))))));
|
|
984
|
-
}
|
|
985
|
-
return null;
|
|
838
|
+
return React.createElement(React.Fragment, null, core.formatCoding(props.value));
|
|
986
839
|
}
|
|
987
840
|
|
|
988
841
|
function ContactPointDisplay(props) {
|
|
@@ -1212,25 +1065,159 @@
|
|
|
1212
1065
|
return [typedResult.value, typedResult.type];
|
|
1213
1066
|
}
|
|
1214
1067
|
|
|
1215
|
-
function
|
|
1216
|
-
const
|
|
1217
|
-
const
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1068
|
+
function BackboneElementDisplay(props) {
|
|
1069
|
+
const typedValue = props.value;
|
|
1070
|
+
const value = typedValue.value;
|
|
1071
|
+
if (!value) {
|
|
1072
|
+
return null;
|
|
1073
|
+
}
|
|
1074
|
+
const typeName = typedValue.type;
|
|
1075
|
+
const typeSchema = core.globalSchema.types[typeName];
|
|
1076
|
+
if (!typeSchema) {
|
|
1077
|
+
return React.createElement("div", null,
|
|
1078
|
+
typeName,
|
|
1079
|
+
"\u00A0not implemented");
|
|
1080
|
+
}
|
|
1081
|
+
if (typeof value === 'object' &&
|
|
1082
|
+
'name' in value &&
|
|
1083
|
+
Object.keys(value).length === 1 &&
|
|
1084
|
+
typeof value.name === 'string') {
|
|
1085
|
+
// Special case for common BackboneElement pattern
|
|
1086
|
+
// Where there is an object with a single property 'name'
|
|
1087
|
+
// Just display the name value.
|
|
1088
|
+
return React.createElement("div", null, value.name);
|
|
1089
|
+
}
|
|
1090
|
+
return (React.createElement(DescriptionList, { compact: props.compact }, Object.entries(typeSchema.properties).map((entry) => {
|
|
1091
|
+
const key = entry[0];
|
|
1092
|
+
if (DEFAULT_IGNORED_PROPERTIES.indexOf(key) >= 0) {
|
|
1093
|
+
return null;
|
|
1094
|
+
}
|
|
1095
|
+
const property = entry[1];
|
|
1096
|
+
const [propertyValue, propertyType] = getValueAndType(typedValue, key);
|
|
1097
|
+
if (props.ignoreMissingValues &&
|
|
1098
|
+
(!propertyValue || (Array.isArray(propertyValue) && propertyValue.length === 0))) {
|
|
1099
|
+
return null;
|
|
1100
|
+
}
|
|
1101
|
+
return (React.createElement(DescriptionListEntry, { key: key, term: core.getPropertyDisplayName(key) },
|
|
1102
|
+
React.createElement(ResourcePropertyDisplay, { property: property, propertyType: propertyType, value: propertyValue, ignoreMissingValues: props.ignoreMissingValues, link: props.link })));
|
|
1103
|
+
})));
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
function CheckboxFormSection(props) {
|
|
1107
|
+
return (React.createElement(core$1.Group, { noWrap: true },
|
|
1108
|
+
React.createElement("div", null, props.children),
|
|
1109
|
+
React.createElement("div", null,
|
|
1110
|
+
React.createElement(core$1.Input.Wrapper, { id: props.htmlFor, label: props.title, description: props.description }, (() => null)()))));
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
function FormSection(props) {
|
|
1114
|
+
return (React.createElement(core$1.Input.Wrapper, { id: props.htmlFor, label: props.title, description: props.description, error: getErrorsForInput(props.outcome, props.htmlFor) }, props.children));
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
const system = {
|
|
1118
|
+
resourceType: 'Device',
|
|
1119
|
+
id: 'system',
|
|
1120
|
+
deviceName: [
|
|
1121
|
+
{
|
|
1122
|
+
name: 'System',
|
|
1123
|
+
},
|
|
1124
|
+
],
|
|
1125
|
+
};
|
|
1126
|
+
/**
|
|
1127
|
+
* React Hook to use a FHIR reference.
|
|
1128
|
+
* Handles the complexity of resolving references and caching resources.
|
|
1129
|
+
* @param value The resource or reference to resource.
|
|
1130
|
+
* @returns The resolved resource.
|
|
1131
|
+
*/
|
|
1132
|
+
function useResource(value) {
|
|
1133
|
+
const medplum = useMedplum();
|
|
1134
|
+
const [resource, setResource] = React.useState(getInitialResource(medplum, value));
|
|
1135
|
+
React.useEffect(() => {
|
|
1136
|
+
let subscribed = true;
|
|
1137
|
+
if (!resource && value && 'reference' in value && value.reference) {
|
|
1138
|
+
medplum
|
|
1139
|
+
.readReference(value)
|
|
1140
|
+
.then((r) => {
|
|
1141
|
+
if (subscribed) {
|
|
1142
|
+
setResource(r);
|
|
1143
|
+
}
|
|
1144
|
+
})
|
|
1145
|
+
.catch(() => setResource(undefined));
|
|
1146
|
+
}
|
|
1147
|
+
return (() => (subscribed = false));
|
|
1148
|
+
}, [medplum, resource, value]);
|
|
1149
|
+
return resource;
|
|
1150
|
+
}
|
|
1151
|
+
/**
|
|
1152
|
+
* Returns the initial resource value based on the input value.
|
|
1153
|
+
* If the input value is a resource, returns the resource.
|
|
1154
|
+
* If the input value is a reference to system, returns the system resource.
|
|
1155
|
+
* If the input value is a reference to a resource available in the cache, returns the resource.
|
|
1156
|
+
* Otherwise, returns undefined.
|
|
1157
|
+
* @param medplum The medplum client.
|
|
1158
|
+
* @param value The resource or reference to resource.
|
|
1159
|
+
* @returns An initial resource if available; undefined otherwise.
|
|
1160
|
+
*/
|
|
1161
|
+
function getInitialResource(medplum, value) {
|
|
1162
|
+
if (!value) {
|
|
1163
|
+
return undefined;
|
|
1164
|
+
}
|
|
1165
|
+
if ('resourceType' in value) {
|
|
1166
|
+
return value;
|
|
1167
|
+
}
|
|
1168
|
+
if ('reference' in value) {
|
|
1169
|
+
if (value.reference === 'system') {
|
|
1170
|
+
return system;
|
|
1171
|
+
}
|
|
1172
|
+
return medplum.getCachedReference(value);
|
|
1173
|
+
}
|
|
1174
|
+
return undefined;
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
function ResourceForm(props) {
|
|
1178
|
+
const medplum = useMedplum();
|
|
1179
|
+
const defaultValue = useResource(props.defaultValue);
|
|
1180
|
+
const [schema, setSchema] = React.useState();
|
|
1181
|
+
const [value, setValue] = React.useState();
|
|
1182
|
+
React.useEffect(() => {
|
|
1183
|
+
if (defaultValue) {
|
|
1184
|
+
setValue(JSON.parse(JSON.stringify(defaultValue)));
|
|
1185
|
+
medplum.requestSchema(defaultValue.resourceType).then(setSchema).catch(console.log);
|
|
1186
|
+
}
|
|
1187
|
+
}, [medplum, defaultValue]);
|
|
1188
|
+
if (!schema || !value) {
|
|
1189
|
+
return React.createElement("div", null, "Loading...");
|
|
1190
|
+
}
|
|
1191
|
+
return (React.createElement("form", { noValidate: true, autoComplete: "off", onSubmit: (e) => {
|
|
1192
|
+
e.preventDefault();
|
|
1193
|
+
if (props.onSubmit) {
|
|
1194
|
+
props.onSubmit(value);
|
|
1195
|
+
}
|
|
1196
|
+
} },
|
|
1197
|
+
React.createElement(core$1.Stack, { mb: "xl" },
|
|
1198
|
+
React.createElement(FormSection, { title: "Resource Type", htmlFor: "resourceType", outcome: props.outcome },
|
|
1199
|
+
React.createElement(core$1.TextInput, { name: "resourceType", defaultValue: value.resourceType, disabled: true })),
|
|
1200
|
+
React.createElement(FormSection, { title: "ID", htmlFor: "id", outcome: props.outcome },
|
|
1201
|
+
React.createElement(core$1.TextInput, { name: "id", defaultValue: value.id, disabled: true }))),
|
|
1202
|
+
React.createElement(BackboneElementInput, { typeName: value.resourceType, defaultValue: value, outcome: props.outcome, onChange: setValue }),
|
|
1203
|
+
React.createElement(core$1.Group, { position: "right", mt: "xl" },
|
|
1204
|
+
React.createElement(core$1.Button, { type: "submit" }, "OK"),
|
|
1205
|
+
props.onDelete && (React.createElement(core$1.Button, { variant: "outline", color: "red", type: "button", onClick: () => {
|
|
1206
|
+
props.onDelete(value);
|
|
1207
|
+
} }, "Delete")))));
|
|
1208
|
+
}
|
|
1209
|
+
function setPropertyValue(obj, key, propName, elementDefinition, value) {
|
|
1210
|
+
const types = elementDefinition.type;
|
|
1211
|
+
if (types.length > 1) {
|
|
1212
|
+
for (const type of types) {
|
|
1213
|
+
const compoundKey = key.replace('[x]', core.capitalize(type.code));
|
|
1214
|
+
if (compoundKey in obj) {
|
|
1215
|
+
delete obj[compoundKey];
|
|
1226
1216
|
}
|
|
1227
|
-
: {};
|
|
1228
|
-
setValue(newValue);
|
|
1229
|
-
if (props.onChange) {
|
|
1230
|
-
props.onChange(newValue);
|
|
1231
1217
|
}
|
|
1232
1218
|
}
|
|
1233
|
-
|
|
1219
|
+
obj[propName] = value;
|
|
1220
|
+
return obj;
|
|
1234
1221
|
}
|
|
1235
1222
|
|
|
1236
1223
|
function valueSetElementToAutocompleteItem(element) {
|
|
@@ -1995,49 +1982,177 @@
|
|
|
1995
1982
|
return (React.createElement(BackboneElementInput, { typeName: core.buildTypeName((_a = property.path) === null || _a === void 0 ? void 0 : _a.split('.')), defaultValue: value, onChange: props.onChange, outcome: props.outcome }));
|
|
1996
1983
|
}
|
|
1997
1984
|
}
|
|
1998
|
-
function getTargetTypes(property) {
|
|
1999
|
-
var _a, _b, _c;
|
|
2000
|
-
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());
|
|
1985
|
+
function getTargetTypes(property) {
|
|
1986
|
+
var _a, _b, _c;
|
|
1987
|
+
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());
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
function BackboneElementInput(props) {
|
|
1991
|
+
var _a;
|
|
1992
|
+
const [value, setValue] = React.useState((_a = props.defaultValue) !== null && _a !== void 0 ? _a : {});
|
|
1993
|
+
function setValueWrapper(newValue) {
|
|
1994
|
+
setValue(newValue);
|
|
1995
|
+
if (props.onChange) {
|
|
1996
|
+
props.onChange(newValue);
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
const typeName = props.typeName;
|
|
2000
|
+
const typeSchema = core.globalSchema.types[typeName];
|
|
2001
|
+
if (!typeSchema) {
|
|
2002
|
+
return React.createElement("div", null,
|
|
2003
|
+
typeName,
|
|
2004
|
+
"\u00A0not implemented");
|
|
2005
|
+
}
|
|
2006
|
+
const typedValue = { type: typeName, value };
|
|
2007
|
+
return (React.createElement(core$1.Stack, null, Object.entries(typeSchema.properties).map((entry) => {
|
|
2008
|
+
const key = entry[0];
|
|
2009
|
+
if (key === 'id' || DEFAULT_IGNORED_PROPERTIES.indexOf(key) >= 0) {
|
|
2010
|
+
return null;
|
|
2011
|
+
}
|
|
2012
|
+
const property = entry[1];
|
|
2013
|
+
if (!property.type) {
|
|
2014
|
+
return null;
|
|
2015
|
+
}
|
|
2016
|
+
const [propertyValue, propertyType] = getValueAndType(typedValue, key);
|
|
2017
|
+
if (property.type.length === 1 && property.type[0].code === 'boolean') {
|
|
2018
|
+
return (React.createElement(CheckboxFormSection, { key: key, title: core.getPropertyDisplayName(key), description: property.definition, htmlFor: key },
|
|
2019
|
+
React.createElement(ResourcePropertyInput, { property: property, name: key, defaultValue: propertyValue, defaultPropertyType: propertyType, outcome: props.outcome, onChange: (newValue, propName) => {
|
|
2020
|
+
setValueWrapper(setPropertyValue(value, key, propName !== null && propName !== void 0 ? propName : key, entry[1], newValue));
|
|
2021
|
+
} })));
|
|
2022
|
+
}
|
|
2023
|
+
return (React.createElement(FormSection, { key: key, title: core.getPropertyDisplayName(key), description: property.definition, htmlFor: key, outcome: props.outcome },
|
|
2024
|
+
React.createElement(ResourcePropertyInput, { property: property, name: key, defaultValue: propertyValue, defaultPropertyType: propertyType, outcome: props.outcome, onChange: (newValue, propName) => {
|
|
2025
|
+
setValueWrapper(setPropertyValue(value, key, propName !== null && propName !== void 0 ? propName : key, entry[1], newValue));
|
|
2026
|
+
} })));
|
|
2027
|
+
})));
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
const useStyles$a = core$1.createStyles((theme) => ({
|
|
2031
|
+
table: {
|
|
2032
|
+
width: 350,
|
|
2033
|
+
'& th': {
|
|
2034
|
+
fontWeight: 'normal',
|
|
2035
|
+
fontSize: 11,
|
|
2036
|
+
padding: 8,
|
|
2037
|
+
textAlign: 'center',
|
|
2038
|
+
},
|
|
2039
|
+
'& td': {
|
|
2040
|
+
padding: '2px 4px',
|
|
2041
|
+
},
|
|
2042
|
+
'& td button': {
|
|
2043
|
+
width: 44,
|
|
2044
|
+
height: 44,
|
|
2045
|
+
color: theme.colors[theme.primaryColor][5],
|
|
2046
|
+
fontSize: 16,
|
|
2047
|
+
fontWeight: 500,
|
|
2048
|
+
textAlign: 'center',
|
|
2049
|
+
padding: 0,
|
|
2050
|
+
backgroundColor: theme.colors[theme.primaryColor][0],
|
|
2051
|
+
border: 0,
|
|
2052
|
+
borderRadius: '50%',
|
|
2053
|
+
cursor: 'pointer',
|
|
2054
|
+
},
|
|
2055
|
+
'& td button:hover': {
|
|
2056
|
+
backgroundColor: theme.colors[theme.primaryColor][1],
|
|
2057
|
+
},
|
|
2058
|
+
'& td button:disabled': {
|
|
2059
|
+
backgroundColor: 'transparent',
|
|
2060
|
+
cursor: 'default',
|
|
2061
|
+
color: theme.colors.gray[4],
|
|
2062
|
+
fontWeight: 'normal',
|
|
2063
|
+
},
|
|
2064
|
+
},
|
|
2065
|
+
}));
|
|
2066
|
+
/**
|
|
2067
|
+
* Returns a month display string (e.g. "January 2020").
|
|
2068
|
+
* @param date Any date within the month.
|
|
2069
|
+
* @returns The month display string (e.g. "January 2020")
|
|
2070
|
+
*/
|
|
2071
|
+
function getMonthString(date) {
|
|
2072
|
+
return date.toLocaleString('default', { month: 'long' }) + ' ' + date.getFullYear();
|
|
2073
|
+
}
|
|
2074
|
+
function CalendarInput(props) {
|
|
2075
|
+
const { classes } = useStyles$a();
|
|
2076
|
+
const { onChangeMonth, onClick } = props;
|
|
2077
|
+
const [month, setMonth] = React.useState(getStartMonth);
|
|
2078
|
+
function moveMonth(delta) {
|
|
2079
|
+
setMonth((currMonth) => {
|
|
2080
|
+
const newMonth = new Date(currMonth.getTime());
|
|
2081
|
+
newMonth.setMonth(currMonth.getMonth() + delta);
|
|
2082
|
+
onChangeMonth(newMonth);
|
|
2083
|
+
return newMonth;
|
|
2084
|
+
});
|
|
2085
|
+
}
|
|
2086
|
+
const grid = React.useMemo(() => buildGrid(month, props.slots), [month, props.slots]);
|
|
2087
|
+
return (React.createElement("div", null,
|
|
2088
|
+
React.createElement(core$1.Group, { position: "apart", spacing: "xs", grow: true, noWrap: true },
|
|
2089
|
+
React.createElement("p", { style: { flex: 1 } }, getMonthString(month)),
|
|
2090
|
+
React.createElement(core$1.Group, { position: "right", spacing: "xs" },
|
|
2091
|
+
React.createElement(core$1.Button, { variant: "outline", "aria-label": "Previous month", onClick: () => moveMonth(-1) }, "<"),
|
|
2092
|
+
React.createElement(core$1.Button, { variant: "outline", "aria-label": "Next month", onClick: () => moveMonth(1) }, ">"))),
|
|
2093
|
+
React.createElement("table", { className: classes.table },
|
|
2094
|
+
React.createElement("thead", null,
|
|
2095
|
+
React.createElement("tr", null,
|
|
2096
|
+
React.createElement("th", null, "SUN"),
|
|
2097
|
+
React.createElement("th", null, "MON"),
|
|
2098
|
+
React.createElement("th", null, "TUE"),
|
|
2099
|
+
React.createElement("th", null, "WED"),
|
|
2100
|
+
React.createElement("th", null, "THU"),
|
|
2101
|
+
React.createElement("th", null, "FRI"),
|
|
2102
|
+
React.createElement("th", null, "SAT"))),
|
|
2103
|
+
React.createElement("tbody", null, grid.map((week, weekIndex) => (React.createElement("tr", { key: 'week-' + weekIndex }, week.map((day, dayIndex) => (React.createElement("td", { key: 'day-' + dayIndex }, day && (React.createElement(core$1.Button, { disabled: !day.available, onClick: () => onClick(day.date) }, day.date.getDate()))))))))))));
|
|
2104
|
+
}
|
|
2105
|
+
function getStartMonth() {
|
|
2106
|
+
const result = new Date();
|
|
2107
|
+
result.setDate(1);
|
|
2108
|
+
result.setHours(0, 0, 0, 0);
|
|
2109
|
+
return result;
|
|
2001
2110
|
}
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
props.onChange(newValue);
|
|
2010
|
-
}
|
|
2011
|
-
}
|
|
2012
|
-
const typeName = props.typeName;
|
|
2013
|
-
const typeSchema = core.globalSchema.types[typeName];
|
|
2014
|
-
if (!typeSchema) {
|
|
2015
|
-
return React.createElement("div", null,
|
|
2016
|
-
typeName,
|
|
2017
|
-
"\u00A0not implemented");
|
|
2111
|
+
function buildGrid(startDate, slots) {
|
|
2112
|
+
const d = new Date(startDate.getFullYear(), startDate.getMonth());
|
|
2113
|
+
const grid = [];
|
|
2114
|
+
let row = [];
|
|
2115
|
+
// Fill leading empty days
|
|
2116
|
+
for (let i = 0; i < d.getDay(); i++) {
|
|
2117
|
+
row.push(undefined);
|
|
2018
2118
|
}
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2119
|
+
while (d.getMonth() === startDate.getMonth()) {
|
|
2120
|
+
row.push({
|
|
2121
|
+
date: new Date(d.getTime()),
|
|
2122
|
+
available: isDayAvailable(d, slots),
|
|
2123
|
+
});
|
|
2124
|
+
if (d.getDay() === 6) {
|
|
2125
|
+
grid.push(row);
|
|
2126
|
+
row = [];
|
|
2024
2127
|
}
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2128
|
+
d.setDate(d.getDate() + 1);
|
|
2129
|
+
}
|
|
2130
|
+
// Fill trailing empty days
|
|
2131
|
+
if (d.getDay() !== 0) {
|
|
2132
|
+
for (let i = d.getDay(); i < 7; i++) {
|
|
2133
|
+
row.push(undefined);
|
|
2028
2134
|
}
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2135
|
+
grid.push(row);
|
|
2136
|
+
}
|
|
2137
|
+
return grid;
|
|
2138
|
+
}
|
|
2139
|
+
/**
|
|
2140
|
+
* Returns true if the given date is available for booking.
|
|
2141
|
+
* @param day The day to check.
|
|
2142
|
+
* @param slots The list of available slots.
|
|
2143
|
+
* @returns True if there are any available slots for the day.
|
|
2144
|
+
*/
|
|
2145
|
+
function isDayAvailable(day, slots) {
|
|
2146
|
+
// Note that slot start and end time may or may not be in UTC.
|
|
2147
|
+
for (const slot of slots) {
|
|
2148
|
+
const slotStart = new Date(slot.start);
|
|
2149
|
+
if (slotStart.getFullYear() === day.getFullYear() &&
|
|
2150
|
+
slotStart.getMonth() === day.getMonth() &&
|
|
2151
|
+
slotStart.getDate() === day.getDate()) {
|
|
2152
|
+
return true;
|
|
2035
2153
|
}
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
setValueWrapper(setPropertyValue(value, key, propName !== null && propName !== void 0 ? propName : key, entry[1], newValue));
|
|
2039
|
-
} })));
|
|
2040
|
-
})));
|
|
2154
|
+
}
|
|
2155
|
+
return false;
|
|
2041
2156
|
}
|
|
2042
2157
|
|
|
2043
2158
|
function ResourceName(props) {
|
|
@@ -2056,7 +2171,7 @@
|
|
|
2056
2171
|
React.createElement(ResourceName, { value: props.value, link: props.link })));
|
|
2057
2172
|
}
|
|
2058
2173
|
|
|
2059
|
-
const useStyles$
|
|
2174
|
+
const useStyles$9 = core$1.createStyles((theme) => ({
|
|
2060
2175
|
table: {
|
|
2061
2176
|
border: `0.1px solid ${theme.colors.gray[5]}`,
|
|
2062
2177
|
borderCollapse: 'collapse',
|
|
@@ -2117,7 +2232,7 @@
|
|
|
2117
2232
|
}
|
|
2118
2233
|
function ObservationTable(props) {
|
|
2119
2234
|
var _a;
|
|
2120
|
-
const { classes } = useStyles$
|
|
2235
|
+
const { classes } = useStyles$9();
|
|
2121
2236
|
return (React.createElement("table", { className: classes.table },
|
|
2122
2237
|
React.createElement("thead", null,
|
|
2123
2238
|
React.createElement("tr", null,
|
|
@@ -2128,7 +2243,7 @@
|
|
|
2128
2243
|
React.createElement("tbody", null, (_a = props.value) === null || _a === void 0 ? void 0 : _a.map((observation, index) => (React.createElement(ObservationRow, { key: 'obs-' + index, value: observation }))))));
|
|
2129
2244
|
}
|
|
2130
2245
|
function ObservationRow(props) {
|
|
2131
|
-
const { classes, cx } = useStyles$
|
|
2246
|
+
const { classes, cx } = useStyles$9();
|
|
2132
2247
|
const observation = useResource(props.value);
|
|
2133
2248
|
if (!observation) {
|
|
2134
2249
|
return null;
|
|
@@ -2145,20 +2260,8 @@
|
|
|
2145
2260
|
React.createElement("td", null, observation.interpretation && observation.interpretation.length > 0 && (React.createElement(CodeableConceptDisplay, { value: observation.interpretation[0] })))));
|
|
2146
2261
|
}
|
|
2147
2262
|
function ObservationValueDisplay(props) {
|
|
2148
|
-
var _a;
|
|
2149
2263
|
const obs = props.value;
|
|
2150
|
-
|
|
2151
|
-
return React.createElement(QuantityDisplay, { value: (_a = props.value) === null || _a === void 0 ? void 0 : _a.valueQuantity });
|
|
2152
|
-
}
|
|
2153
|
-
if (obs === null || obs === void 0 ? void 0 : obs.valueString) {
|
|
2154
|
-
return React.createElement(React.Fragment, null, obs.valueString);
|
|
2155
|
-
}
|
|
2156
|
-
if (obs && 'component' in obs && (obs === null || obs === void 0 ? void 0 : obs.component)) {
|
|
2157
|
-
return (React.createElement(React.Fragment, null, obs.component
|
|
2158
|
-
.map((component, index) => (React.createElement(ObservationValueDisplay, { key: `obs-${index}`, value: component })))
|
|
2159
|
-
.reduce((prev, curr) => [prev, ' / ', curr])));
|
|
2160
|
-
}
|
|
2161
|
-
return null;
|
|
2264
|
+
return React.createElement(React.Fragment, null, core.formatObservationValue(obs));
|
|
2162
2265
|
}
|
|
2163
2266
|
function ReferenceRangeDisplay(props) {
|
|
2164
2267
|
const range = props.value && props.value.length > 0 && props.value[0];
|
|
@@ -2182,7 +2285,7 @@
|
|
|
2182
2285
|
return code === 'AA' || code === 'LL' || code === 'HH' || code === 'A';
|
|
2183
2286
|
}
|
|
2184
2287
|
|
|
2185
|
-
const useStyles$
|
|
2288
|
+
const useStyles$8 = core$1.createStyles((theme) => ({
|
|
2186
2289
|
root: {
|
|
2187
2290
|
borderCollapse: 'collapse',
|
|
2188
2291
|
width: '100%',
|
|
@@ -2203,7 +2306,7 @@
|
|
|
2203
2306
|
},
|
|
2204
2307
|
}));
|
|
2205
2308
|
function ResourceDiffTable(props) {
|
|
2206
|
-
const { classes } = useStyles$
|
|
2309
|
+
const { classes } = useStyles$8();
|
|
2207
2310
|
const medplum = useMedplum();
|
|
2208
2311
|
const [schema, setSchema] = React.useState();
|
|
2209
2312
|
React.useEffect(() => {
|
|
@@ -2364,7 +2467,7 @@
|
|
|
2364
2467
|
return new Date(dateTime).getTime();
|
|
2365
2468
|
}
|
|
2366
2469
|
|
|
2367
|
-
const useStyles$
|
|
2470
|
+
const useStyles$7 = core$1.createStyles((theme) => ({
|
|
2368
2471
|
pinnedComment: {
|
|
2369
2472
|
backgroundColor: theme.colors.blue[0],
|
|
2370
2473
|
},
|
|
@@ -2593,7 +2696,7 @@
|
|
|
2593
2696
|
}
|
|
2594
2697
|
function CommunicationTimelineItem(props) {
|
|
2595
2698
|
var _a, _b;
|
|
2596
|
-
const { classes } = useStyles$
|
|
2699
|
+
const { classes } = useStyles$7();
|
|
2597
2700
|
const routine = !props.resource.priority || props.resource.priority === 'routine';
|
|
2598
2701
|
const className = routine ? undefined : classes.pinnedComment;
|
|
2599
2702
|
return (React.createElement(TimelineItem, { resource: props.resource, profile: props.resource.sender, padding: true, className: className, popupMenuItems: React.createElement(TimelineItemPopupMenu, Object.assign({}, props)) },
|
|
@@ -3742,7 +3845,7 @@
|
|
|
3742
3845
|
this.browserEvent = browserEvent;
|
|
3743
3846
|
}
|
|
3744
3847
|
}
|
|
3745
|
-
const useStyles$
|
|
3848
|
+
const useStyles$6 = core$1.createStyles((theme) => ({
|
|
3746
3849
|
root: {
|
|
3747
3850
|
maxWidth: '100%',
|
|
3748
3851
|
overflow: 'auto',
|
|
@@ -3780,7 +3883,7 @@
|
|
|
3780
3883
|
*/
|
|
3781
3884
|
function SearchControl(props) {
|
|
3782
3885
|
var _a, _b, _c;
|
|
3783
|
-
const { classes } = useStyles$
|
|
3886
|
+
const { classes } = useStyles$6();
|
|
3784
3887
|
const medplum = useMedplum();
|
|
3785
3888
|
const [schemaLoaded, setSchemaLoaded] = React.useState(false);
|
|
3786
3889
|
const [outcome, setOutcome] = React.useState();
|
|
@@ -4155,7 +4258,7 @@
|
|
|
4155
4258
|
}) }));
|
|
4156
4259
|
}
|
|
4157
4260
|
|
|
4158
|
-
const useStyles$
|
|
4261
|
+
const useStyles$5 = core$1.createStyles((theme) => ({
|
|
4159
4262
|
section: {
|
|
4160
4263
|
position: 'relative',
|
|
4161
4264
|
margin: '4px 4px 8px 0',
|
|
@@ -4221,7 +4324,7 @@
|
|
|
4221
4324
|
React.createElement(core$1.Button, { type: "submit" }, "Save"))));
|
|
4222
4325
|
}
|
|
4223
4326
|
function ActionArrayBuilder(props) {
|
|
4224
|
-
const { classes } = useStyles$
|
|
4327
|
+
const { classes } = useStyles$5();
|
|
4225
4328
|
const actionsRef = React.useRef();
|
|
4226
4329
|
actionsRef.current = props.actions;
|
|
4227
4330
|
function changeAction(changedAction) {
|
|
@@ -4244,7 +4347,7 @@
|
|
|
4244
4347
|
} }, "Add action"))));
|
|
4245
4348
|
}
|
|
4246
4349
|
function ActionBuilder(props) {
|
|
4247
|
-
const { classes, cx } = useStyles$
|
|
4350
|
+
const { classes, cx } = useStyles$5();
|
|
4248
4351
|
const { action } = props;
|
|
4249
4352
|
const actionType = getInitialActionType(action);
|
|
4250
4353
|
const editing = props.selectedKey === props.action.id;
|
|
@@ -4665,7 +4768,7 @@
|
|
|
4665
4768
|
}
|
|
4666
4769
|
}
|
|
4667
4770
|
|
|
4668
|
-
const useStyles$
|
|
4771
|
+
const useStyles$4 = core$1.createStyles((theme) => ({
|
|
4669
4772
|
section: {
|
|
4670
4773
|
position: 'relative',
|
|
4671
4774
|
margin: '4px 4px 8px 0',
|
|
@@ -4744,7 +4847,7 @@
|
|
|
4744
4847
|
}
|
|
4745
4848
|
function ItemBuilder(props) {
|
|
4746
4849
|
var _a;
|
|
4747
|
-
const { classes, cx } = useStyles$
|
|
4850
|
+
const { classes, cx } = useStyles$4();
|
|
4748
4851
|
const resource = props.item;
|
|
4749
4852
|
const item = props.item;
|
|
4750
4853
|
const isResource = 'resourceType' in props.item;
|
|
@@ -4921,7 +5024,7 @@
|
|
|
4921
5024
|
return options.map((option) => (Object.assign(Object.assign({}, option), { id: option.id || generateId() })));
|
|
4922
5025
|
}
|
|
4923
5026
|
|
|
4924
|
-
const useStyles$
|
|
5027
|
+
const useStyles$3 = core$1.createStyles((theme) => ({
|
|
4925
5028
|
section: {
|
|
4926
5029
|
position: 'relative',
|
|
4927
5030
|
margin: '4px 4px 8px 0',
|
|
@@ -5025,7 +5128,7 @@
|
|
|
5025
5128
|
}
|
|
5026
5129
|
function ReferenceRangeGroupEditor(props) {
|
|
5027
5130
|
const { intervalGroup, unit } = props;
|
|
5028
|
-
const { classes } = useStyles$
|
|
5131
|
+
const { classes } = useStyles$3();
|
|
5029
5132
|
return (React.createElement(core$1.Container, { "data-testid": intervalGroup.id, className: classes.section },
|
|
5030
5133
|
React.createElement(core$1.Stack, { spacing: 'lg' },
|
|
5031
5134
|
React.createElement(core$1.Group, { position: "right" },
|
|
@@ -5487,7 +5590,7 @@
|
|
|
5487
5590
|
}
|
|
5488
5591
|
}
|
|
5489
5592
|
|
|
5490
|
-
const useStyles$
|
|
5593
|
+
const useStyles$2 = core$1.createStyles((theme) => ({
|
|
5491
5594
|
container: {
|
|
5492
5595
|
overflowX: 'auto',
|
|
5493
5596
|
},
|
|
@@ -5536,7 +5639,7 @@
|
|
|
5536
5639
|
}));
|
|
5537
5640
|
function ResourceBlame(props) {
|
|
5538
5641
|
var _a, _b;
|
|
5539
|
-
const { classes } = useStyles$
|
|
5642
|
+
const { classes } = useStyles$2();
|
|
5540
5643
|
const medplum = useMedplum();
|
|
5541
5644
|
const [value, setValue] = React.useState(props.history);
|
|
5542
5645
|
React.useEffect(() => {
|
|
@@ -5592,7 +5695,7 @@
|
|
|
5592
5695
|
return `${count} ${count === 1 ? noun : noun + 's'} ago`;
|
|
5593
5696
|
}
|
|
5594
5697
|
|
|
5595
|
-
const useStyles$
|
|
5698
|
+
const useStyles$1 = core$1.createStyles((theme) => ({
|
|
5596
5699
|
removed: {
|
|
5597
5700
|
color: theme.colors.red[7],
|
|
5598
5701
|
textDecoration: 'line-through',
|
|
@@ -5614,7 +5717,7 @@
|
|
|
5614
5717
|
return (React.createElement("pre", { style: { color: 'gray' } }, deltas.map((delta, index) => (React.createElement(ChangeDiff, { key: 'delta' + index, delta: delta })))));
|
|
5615
5718
|
}
|
|
5616
5719
|
function ChangeDiff(props) {
|
|
5617
|
-
const { classes } = useStyles$
|
|
5720
|
+
const { classes } = useStyles$1();
|
|
5618
5721
|
return (React.createElement(React.Fragment, null,
|
|
5619
5722
|
"...",
|
|
5620
5723
|
React.createElement("br", null),
|
|
@@ -5668,134 +5771,6 @@
|
|
|
5668
5771
|
return `/${resource.resourceType}/${resource.id}/_history/${(_a = resource.meta) === null || _a === void 0 ? void 0 : _a.versionId}`;
|
|
5669
5772
|
}
|
|
5670
5773
|
|
|
5671
|
-
const useStyles$1 = core$1.createStyles((theme) => ({
|
|
5672
|
-
table: {
|
|
5673
|
-
width: 350,
|
|
5674
|
-
'& th': {
|
|
5675
|
-
fontWeight: 'normal',
|
|
5676
|
-
fontSize: 11,
|
|
5677
|
-
padding: 8,
|
|
5678
|
-
textAlign: 'center',
|
|
5679
|
-
},
|
|
5680
|
-
'& td': {
|
|
5681
|
-
padding: '2px 4px',
|
|
5682
|
-
},
|
|
5683
|
-
'& td button': {
|
|
5684
|
-
width: 44,
|
|
5685
|
-
height: 44,
|
|
5686
|
-
color: theme.colors[theme.primaryColor][5],
|
|
5687
|
-
fontSize: 16,
|
|
5688
|
-
fontWeight: 500,
|
|
5689
|
-
textAlign: 'center',
|
|
5690
|
-
padding: 0,
|
|
5691
|
-
backgroundColor: theme.colors[theme.primaryColor][0],
|
|
5692
|
-
border: 0,
|
|
5693
|
-
borderRadius: '50%',
|
|
5694
|
-
cursor: 'pointer',
|
|
5695
|
-
},
|
|
5696
|
-
'& td button:hover': {
|
|
5697
|
-
backgroundColor: theme.colors[theme.primaryColor][1],
|
|
5698
|
-
},
|
|
5699
|
-
'& td button:disabled': {
|
|
5700
|
-
backgroundColor: 'transparent',
|
|
5701
|
-
cursor: 'default',
|
|
5702
|
-
color: theme.colors.gray[4],
|
|
5703
|
-
fontWeight: 'normal',
|
|
5704
|
-
},
|
|
5705
|
-
},
|
|
5706
|
-
}));
|
|
5707
|
-
/**
|
|
5708
|
-
* Returns a month display string (e.g. "January 2020").
|
|
5709
|
-
* @param date Any date within the month.
|
|
5710
|
-
* @returns The month display string (e.g. "January 2020")
|
|
5711
|
-
*/
|
|
5712
|
-
function getMonthString(date) {
|
|
5713
|
-
return date.toLocaleString('default', { month: 'long' }) + ' ' + date.getFullYear();
|
|
5714
|
-
}
|
|
5715
|
-
function CalendarInput(props) {
|
|
5716
|
-
const { classes } = useStyles$1();
|
|
5717
|
-
const { onChangeMonth, onClick } = props;
|
|
5718
|
-
const [month, setMonth] = React.useState(getStartMonth);
|
|
5719
|
-
function moveMonth(delta) {
|
|
5720
|
-
setMonth((currMonth) => {
|
|
5721
|
-
const newMonth = new Date(currMonth.getTime());
|
|
5722
|
-
newMonth.setMonth(currMonth.getMonth() + delta);
|
|
5723
|
-
onChangeMonth(newMonth);
|
|
5724
|
-
return newMonth;
|
|
5725
|
-
});
|
|
5726
|
-
}
|
|
5727
|
-
const grid = React.useMemo(() => buildGrid(month, props.slots), [month, props.slots]);
|
|
5728
|
-
return (React.createElement("div", null,
|
|
5729
|
-
React.createElement(core$1.Group, { position: "apart", spacing: "xs", grow: true, noWrap: true },
|
|
5730
|
-
React.createElement("p", { style: { flex: 1 } }, getMonthString(month)),
|
|
5731
|
-
React.createElement(core$1.Group, { position: "right", spacing: "xs" },
|
|
5732
|
-
React.createElement(core$1.Button, { variant: "outline", "aria-label": "Previous month", onClick: () => moveMonth(-1) }, "<"),
|
|
5733
|
-
React.createElement(core$1.Button, { variant: "outline", "aria-label": "Next month", onClick: () => moveMonth(1) }, ">"))),
|
|
5734
|
-
React.createElement("table", { className: classes.table },
|
|
5735
|
-
React.createElement("thead", null,
|
|
5736
|
-
React.createElement("tr", null,
|
|
5737
|
-
React.createElement("th", null, "SUN"),
|
|
5738
|
-
React.createElement("th", null, "MON"),
|
|
5739
|
-
React.createElement("th", null, "TUE"),
|
|
5740
|
-
React.createElement("th", null, "WED"),
|
|
5741
|
-
React.createElement("th", null, "THU"),
|
|
5742
|
-
React.createElement("th", null, "FRI"),
|
|
5743
|
-
React.createElement("th", null, "SAT"))),
|
|
5744
|
-
React.createElement("tbody", null, grid.map((week, weekIndex) => (React.createElement("tr", { key: 'week-' + weekIndex }, week.map((day, dayIndex) => (React.createElement("td", { key: 'day-' + dayIndex }, day && (React.createElement(core$1.Button, { disabled: !day.available, onClick: () => onClick(day.date) }, day.date.getDate()))))))))))));
|
|
5745
|
-
}
|
|
5746
|
-
function getStartMonth() {
|
|
5747
|
-
const result = new Date();
|
|
5748
|
-
result.setDate(1);
|
|
5749
|
-
result.setHours(0, 0, 0, 0);
|
|
5750
|
-
return result;
|
|
5751
|
-
}
|
|
5752
|
-
function buildGrid(startDate, slots) {
|
|
5753
|
-
const d = new Date(startDate.getFullYear(), startDate.getMonth());
|
|
5754
|
-
const grid = [];
|
|
5755
|
-
let row = [];
|
|
5756
|
-
// Fill leading empty days
|
|
5757
|
-
for (let i = 0; i < d.getDay(); i++) {
|
|
5758
|
-
row.push(undefined);
|
|
5759
|
-
}
|
|
5760
|
-
while (d.getMonth() === startDate.getMonth()) {
|
|
5761
|
-
row.push({
|
|
5762
|
-
date: new Date(d.getTime()),
|
|
5763
|
-
available: isDayAvailable(d, slots),
|
|
5764
|
-
});
|
|
5765
|
-
if (d.getDay() === 6) {
|
|
5766
|
-
grid.push(row);
|
|
5767
|
-
row = [];
|
|
5768
|
-
}
|
|
5769
|
-
d.setDate(d.getDate() + 1);
|
|
5770
|
-
}
|
|
5771
|
-
// Fill trailing empty days
|
|
5772
|
-
if (d.getDay() !== 0) {
|
|
5773
|
-
for (let i = d.getDay(); i < 7; i++) {
|
|
5774
|
-
row.push(undefined);
|
|
5775
|
-
}
|
|
5776
|
-
grid.push(row);
|
|
5777
|
-
}
|
|
5778
|
-
return grid;
|
|
5779
|
-
}
|
|
5780
|
-
/**
|
|
5781
|
-
* Returns true if the given date is available for booking.
|
|
5782
|
-
* @param day The day to check.
|
|
5783
|
-
* @param slots The list of available slots.
|
|
5784
|
-
* @returns True if there are any available slots for the day.
|
|
5785
|
-
*/
|
|
5786
|
-
function isDayAvailable(day, slots) {
|
|
5787
|
-
// Note that slot start and end time may or may not be in UTC.
|
|
5788
|
-
for (const slot of slots) {
|
|
5789
|
-
const slotStart = new Date(slot.start);
|
|
5790
|
-
if (slotStart.getFullYear() === day.getFullYear() &&
|
|
5791
|
-
slotStart.getMonth() === day.getMonth() &&
|
|
5792
|
-
slotStart.getDate() === day.getDate()) {
|
|
5793
|
-
return true;
|
|
5794
|
-
}
|
|
5795
|
-
}
|
|
5796
|
-
return false;
|
|
5797
|
-
}
|
|
5798
|
-
|
|
5799
5774
|
const useStyles = core$1.createStyles((theme) => ({
|
|
5800
5775
|
container: {
|
|
5801
5776
|
display: 'flex',
|
|
@@ -5934,15 +5909,21 @@
|
|
|
5934
5909
|
|
|
5935
5910
|
exports.AddressDisplay = AddressDisplay;
|
|
5936
5911
|
exports.AddressInput = AddressInput;
|
|
5912
|
+
exports.AnnotationInput = AnnotationInput;
|
|
5937
5913
|
exports.AttachmentArrayDisplay = AttachmentArrayDisplay;
|
|
5938
5914
|
exports.AttachmentArrayInput = AttachmentArrayInput;
|
|
5939
5915
|
exports.AttachmentButton = AttachmentButton;
|
|
5916
|
+
exports.AttachmentDisplay = AttachmentDisplay;
|
|
5940
5917
|
exports.AttachmentInput = AttachmentInput;
|
|
5918
|
+
exports.BackboneElementDisplay = BackboneElementDisplay;
|
|
5941
5919
|
exports.BackboneElementInput = BackboneElementInput;
|
|
5920
|
+
exports.CalendarInput = CalendarInput;
|
|
5942
5921
|
exports.CheckboxFormSection = CheckboxFormSection;
|
|
5943
5922
|
exports.CodeInput = CodeInput;
|
|
5944
5923
|
exports.CodeableConceptDisplay = CodeableConceptDisplay;
|
|
5945
5924
|
exports.CodeableConceptInput = CodeableConceptInput;
|
|
5925
|
+
exports.CodingDisplay = CodingDisplay;
|
|
5926
|
+
exports.CodingInput = CodingInput;
|
|
5946
5927
|
exports.ContactDetailDisplay = ContactDetailDisplay;
|
|
5947
5928
|
exports.ContactDetailInput = ContactDetailInput;
|
|
5948
5929
|
exports.ContactPointDisplay = ContactPointDisplay;
|
|
@@ -5962,6 +5943,7 @@
|
|
|
5962
5943
|
exports.FormSection = FormSection;
|
|
5963
5944
|
exports.HumanNameDisplay = HumanNameDisplay;
|
|
5964
5945
|
exports.HumanNameInput = HumanNameInput;
|
|
5946
|
+
exports.IdentifierDisplay = IdentifierDisplay;
|
|
5965
5947
|
exports.IdentifierInput = IdentifierInput;
|
|
5966
5948
|
exports.Logo = Logo;
|
|
5967
5949
|
exports.MedplumLink = MedplumLink;
|
|
@@ -5971,11 +5953,14 @@
|
|
|
5971
5953
|
exports.ObservationTable = ObservationTable;
|
|
5972
5954
|
exports.PatientTimeline = PatientTimeline;
|
|
5973
5955
|
exports.PlanDefinitionBuilder = PlanDefinitionBuilder;
|
|
5956
|
+
exports.QuantityDisplay = QuantityDisplay;
|
|
5957
|
+
exports.QuantityInput = QuantityInput;
|
|
5974
5958
|
exports.QuestionnaireBuilder = QuestionnaireBuilder;
|
|
5975
5959
|
exports.QuestionnaireForm = QuestionnaireForm;
|
|
5976
5960
|
exports.QuestionnaireFormItem = QuestionnaireFormItem;
|
|
5977
5961
|
exports.RangeDisplay = RangeDisplay;
|
|
5978
5962
|
exports.RangeInput = RangeInput;
|
|
5963
|
+
exports.ReferenceDisplay = ReferenceDisplay;
|
|
5979
5964
|
exports.ReferenceInput = ReferenceInput;
|
|
5980
5965
|
exports.ReferenceRangeEditor = ReferenceRangeEditor;
|
|
5981
5966
|
exports.ReferenceRangeGroupEditor = ReferenceRangeGroupEditor;
|
|
@@ -6007,6 +5992,7 @@
|
|
|
6007
5992
|
exports.StatusBadge = StatusBadge;
|
|
6008
5993
|
exports.Timeline = Timeline;
|
|
6009
5994
|
exports.TimelineItem = TimelineItem;
|
|
5995
|
+
exports.TimingInput = TimingInput;
|
|
6010
5996
|
exports.addDateFilterBetween = addDateFilterBetween;
|
|
6011
5997
|
exports.addField = addField;
|
|
6012
5998
|
exports.addFilter = addFilter;
|
|
@@ -6027,10 +6013,12 @@
|
|
|
6027
6013
|
exports.deleteFilter = deleteFilter;
|
|
6028
6014
|
exports.getErrorsForInput = getErrorsForInput;
|
|
6029
6015
|
exports.getIssuesForExpression = getIssuesForExpression;
|
|
6016
|
+
exports.getMonthString = getMonthString;
|
|
6030
6017
|
exports.getOpString = getOpString;
|
|
6031
6018
|
exports.getRecaptcha = getRecaptcha;
|
|
6032
6019
|
exports.getSearchOperators = getSearchOperators;
|
|
6033
6020
|
exports.getSortField = getSortField;
|
|
6021
|
+
exports.getStartMonth = getStartMonth;
|
|
6034
6022
|
exports.getTimeString = getTimeString;
|
|
6035
6023
|
exports.getValueAndType = getValueAndType;
|
|
6036
6024
|
exports.initRecaptcha = initRecaptcha;
|