@medplum/react 0.9.38 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/AttachmentButton.d.ts +9 -0
- package/dist/cjs/CodeInput.d.ts +2 -1
- package/dist/cjs/CodeableConceptInput.d.ts +2 -1
- package/dist/cjs/CodingInput.d.ts +2 -1
- package/dist/cjs/DateTimeInput.d.ts +9 -2
- package/dist/cjs/DiagnosticReportDisplay.d.ts +0 -1
- package/dist/cjs/ReferenceInput.d.ts +1 -0
- package/dist/cjs/ResourceAvatar.d.ts +8 -0
- package/dist/cjs/ResourceBadge.d.ts +0 -1
- package/dist/cjs/ResourceHistoryTable.d.ts +0 -1
- package/dist/cjs/ResourceInput.d.ts +2 -3
- package/dist/cjs/SearchPopupMenu.d.ts +0 -4
- package/dist/cjs/SearchUtils.d.ts +5 -5
- package/dist/cjs/StatusBadge.d.ts +0 -1
- package/dist/cjs/ValueSetAutocomplete.d.ts +10 -0
- package/dist/cjs/auth/RegisterForm.d.ts +0 -1
- package/dist/cjs/auth/SignInForm.d.ts +0 -1
- package/dist/cjs/defaulttheme.css +0 -51
- package/dist/cjs/index.d.ts +3 -21
- package/dist/cjs/index.js +859 -1560
- 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/stories/{UploadButton.stories.d.ts → AttachmentButton.stories.d.ts} +1 -0
- package/dist/cjs/stories/{FormSection.stories.d.ts → CodeInput.stories.d.ts} +0 -0
- package/dist/cjs/stories/{Input.stories.d.ts → CodeableConceptInput.stories.d.ts} +0 -0
- package/dist/cjs/stories/PeriodInput.stories.d.ts +6 -0
- package/dist/cjs/stories/{Avatar.stories.d.ts → ResourceAvatar.stories.d.ts} +0 -0
- package/dist/cjs/stories/ResourceForm.stories.d.ts +1 -0
- package/dist/cjs/stories/{Loading.stories.d.ts → ResourceInput.stories.d.ts} +2 -1
- package/dist/cjs/stories/SearchControl.stories.d.ts +1 -0
- package/dist/cjs/styles.css +35 -1206
- package/dist/cjs/utils/outcomes.d.ts +1 -0
- package/dist/esm/AddressInput.js +9 -21
- package/dist/esm/AddressInput.js.map +1 -1
- package/dist/esm/AnnotationInput.js +2 -2
- package/dist/esm/AnnotationInput.js.map +1 -1
- package/dist/esm/AttachmentArrayInput.js +11 -8
- package/dist/esm/AttachmentArrayInput.js.map +1 -1
- package/dist/esm/AttachmentButton.d.ts +9 -0
- package/dist/esm/{UploadButton.js → AttachmentButton.js} +9 -9
- package/dist/esm/AttachmentButton.js.map +1 -0
- package/dist/esm/AttachmentInput.js +3 -3
- package/dist/esm/AttachmentInput.js.map +1 -1
- package/dist/esm/CalendarInput.js +6 -7
- package/dist/esm/CalendarInput.js.map +1 -1
- package/dist/esm/CodeInput.d.ts +2 -1
- package/dist/esm/CodeInput.js +16 -21
- package/dist/esm/CodeInput.js.map +1 -1
- package/dist/esm/CodeableConceptInput.d.ts +2 -1
- package/dist/esm/CodeableConceptInput.js +18 -33
- package/dist/esm/CodeableConceptInput.js.map +1 -1
- package/dist/esm/CodingInput.d.ts +2 -1
- package/dist/esm/CodingInput.js +24 -23
- package/dist/esm/CodingInput.js.map +1 -1
- package/dist/esm/ContactDetailInput.js +3 -4
- package/dist/esm/ContactDetailInput.js.map +1 -1
- package/dist/esm/ContactPointInput.js +5 -21
- package/dist/esm/ContactPointInput.js.map +1 -1
- package/dist/esm/DateTimeInput.d.ts +9 -2
- package/dist/esm/DateTimeInput.js +13 -3
- package/dist/esm/DateTimeInput.js.map +1 -1
- package/dist/esm/DiagnosticReportDisplay.d.ts +0 -1
- package/dist/esm/DiagnosticReportDisplay.js +21 -2
- package/dist/esm/DiagnosticReportDisplay.js.map +1 -1
- package/dist/esm/EncounterTimeline.js +2 -0
- package/dist/esm/EncounterTimeline.js.map +1 -1
- package/dist/esm/ExtensionInput.js +2 -2
- package/dist/esm/ExtensionInput.js.map +1 -1
- package/dist/esm/FhirPathTable.js +4 -5
- package/dist/esm/FhirPathTable.js.map +1 -1
- package/dist/esm/HumanNameInput.js +7 -17
- package/dist/esm/HumanNameInput.js.map +1 -1
- package/dist/esm/IdentifierInput.js +4 -5
- package/dist/esm/IdentifierInput.js.map +1 -1
- package/dist/esm/Logo.js +4 -4
- package/dist/esm/Logo.js.map +1 -1
- package/dist/esm/PatientTimeline.js +2 -0
- package/dist/esm/PatientTimeline.js.map +1 -1
- package/dist/esm/PeriodInput.js +5 -5
- package/dist/esm/PeriodInput.js.map +1 -1
- package/dist/esm/PlanDefinitionBuilder.js +17 -29
- package/dist/esm/PlanDefinitionBuilder.js.map +1 -1
- package/dist/esm/QuantityInput.js +5 -12
- package/dist/esm/QuantityInput.js.map +1 -1
- package/dist/esm/QuestionnaireBuilder.js +22 -25
- package/dist/esm/QuestionnaireBuilder.js.map +1 -1
- package/dist/esm/QuestionnaireForm.js +35 -29
- package/dist/esm/QuestionnaireForm.js.map +1 -1
- package/dist/esm/RangeInput.js +2 -2
- package/dist/esm/RangeInput.js.map +1 -1
- package/dist/esm/RatioInput.js +2 -2
- package/dist/esm/RatioInput.js.map +1 -1
- package/dist/esm/ReferenceInput.d.ts +1 -0
- package/dist/esm/ReferenceInput.js +4 -6
- package/dist/esm/ReferenceInput.js.map +1 -1
- package/dist/esm/RequestGroupDisplay.js +1 -1
- package/dist/esm/RequestGroupDisplay.js.map +1 -1
- package/dist/esm/ResourceArrayInput.js +10 -7
- package/dist/esm/ResourceArrayInput.js.map +1 -1
- package/dist/esm/ResourceAvatar.d.ts +8 -0
- package/dist/esm/ResourceAvatar.js +24 -0
- package/dist/esm/ResourceAvatar.js.map +1 -0
- package/dist/esm/ResourceBadge.d.ts +0 -1
- package/dist/esm/ResourceBadge.js +2 -3
- package/dist/esm/ResourceBadge.js.map +1 -1
- package/dist/esm/ResourceBlame.js +3 -3
- package/dist/esm/ResourceBlame.js.map +1 -1
- package/dist/esm/ResourceForm.js +10 -10
- package/dist/esm/ResourceForm.js.map +1 -1
- package/dist/esm/ResourceHistoryTable.d.ts +0 -1
- package/dist/esm/ResourceHistoryTable.js +2 -1
- package/dist/esm/ResourceHistoryTable.js.map +1 -1
- package/dist/esm/ResourceInput.d.ts +2 -3
- package/dist/esm/ResourceInput.js +37 -29
- package/dist/esm/ResourceInput.js.map +1 -1
- package/dist/esm/ResourcePropertyInput.js +30 -18
- package/dist/esm/ResourcePropertyInput.js.map +1 -1
- package/dist/esm/ResourceTimeline.js +23 -17
- package/dist/esm/ResourceTimeline.js.map +1 -1
- package/dist/esm/Scheduler.js +7 -7
- package/dist/esm/Scheduler.js.map +1 -1
- package/dist/esm/SearchControl.js +76 -58
- package/dist/esm/SearchControl.js.map +1 -1
- package/dist/esm/SearchControlField.js.map +1 -1
- package/dist/esm/SearchFieldEditor.js +7 -7
- package/dist/esm/SearchFieldEditor.js.map +1 -1
- package/dist/esm/SearchFilterEditor.js +11 -15
- package/dist/esm/SearchFilterEditor.js.map +1 -1
- package/dist/esm/SearchFilterValueDialog.js +4 -3
- package/dist/esm/SearchFilterValueDialog.js.map +1 -1
- package/dist/esm/SearchFilterValueInput.js +6 -7
- package/dist/esm/SearchFilterValueInput.js.map +1 -1
- package/dist/esm/SearchPopupMenu.d.ts +0 -4
- package/dist/esm/SearchPopupMenu.js +59 -73
- package/dist/esm/SearchPopupMenu.js.map +1 -1
- package/dist/esm/SearchUtils.d.ts +5 -5
- package/dist/esm/SearchUtils.js +11 -12
- package/dist/esm/SearchUtils.js.map +1 -1
- package/dist/esm/ServiceRequestTimeline.js +2 -0
- package/dist/esm/ServiceRequestTimeline.js.map +1 -1
- package/dist/esm/StatusBadge.d.ts +0 -1
- package/dist/esm/StatusBadge.js +55 -1
- package/dist/esm/StatusBadge.js.map +1 -1
- package/dist/esm/Timeline.js +12 -20
- package/dist/esm/Timeline.js.map +1 -1
- package/dist/esm/TimingInput.js +14 -17
- package/dist/esm/TimingInput.js.map +1 -1
- package/dist/esm/ValueSetAutocomplete.d.ts +10 -0
- package/dist/esm/ValueSetAutocomplete.js +65 -0
- package/dist/esm/ValueSetAutocomplete.js.map +1 -0
- package/dist/esm/auth/AuthenticationForm.js +12 -20
- package/dist/esm/auth/AuthenticationForm.js.map +1 -1
- package/dist/esm/auth/ChooseProfileForm.js +10 -10
- package/dist/esm/auth/ChooseProfileForm.js.map +1 -1
- package/dist/esm/auth/NewProjectForm.js +12 -15
- package/dist/esm/auth/NewProjectForm.js.map +1 -1
- package/dist/esm/auth/NewUserForm.js +25 -33
- package/dist/esm/auth/NewUserForm.js.map +1 -1
- package/dist/esm/auth/RegisterForm.d.ts +0 -1
- package/dist/esm/auth/RegisterForm.js.map +1 -1
- package/dist/esm/auth/SignInForm.d.ts +0 -1
- package/dist/esm/auth/SignInForm.js.map +1 -1
- package/dist/esm/defaulttheme.css +0 -51
- package/dist/esm/index.d.ts +3 -21
- package/dist/esm/index.js +4 -22
- 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/node_modules/tslib/tslib.es6.js +13 -1
- package/dist/esm/node_modules/tslib/tslib.es6.js.map +1 -1
- package/dist/esm/stories/{UploadButton.stories.d.ts → AttachmentButton.stories.d.ts} +1 -0
- package/dist/{cjs/stories/Select.stories.d.ts → esm/stories/CodeInput.stories.d.ts} +0 -0
- package/dist/esm/stories/{FormSection.stories.d.ts → CodeableConceptInput.stories.d.ts} +0 -0
- package/dist/esm/stories/PeriodInput.stories.d.ts +6 -0
- package/dist/esm/stories/{Avatar.stories.d.ts → ResourceAvatar.stories.d.ts} +0 -0
- package/dist/esm/stories/ResourceForm.stories.d.ts +1 -0
- package/dist/{cjs/stories/Dialog.stories.d.ts → esm/stories/ResourceInput.stories.d.ts} +2 -1
- package/dist/esm/stories/SearchControl.stories.d.ts +1 -0
- package/dist/esm/styles.css +35 -1206
- package/dist/esm/utils/outcomes.d.ts +1 -0
- package/dist/esm/utils/outcomes.js +5 -1
- package/dist/esm/utils/outcomes.js.map +1 -1
- package/package.json +27 -19
- package/dist/cjs/Autocomplete.d.ts +0 -20
- package/dist/cjs/Avatar.d.ts +0 -12
- package/dist/cjs/Button.d.ts +0 -15
- package/dist/cjs/Checkbox.d.ts +0 -12
- package/dist/cjs/Dialog.d.ts +0 -10
- package/dist/cjs/FooterLinks.d.ts +0 -6
- package/dist/cjs/Header.d.ts +0 -12
- package/dist/cjs/HeaderSearchInput.d.ts +0 -10
- package/dist/cjs/Input.d.ts +0 -22
- package/dist/cjs/InputRow.d.ts +0 -7
- package/dist/cjs/Loading.d.ts +0 -3
- package/dist/cjs/MenuItem.d.ts +0 -9
- package/dist/cjs/MenuSeparator.d.ts +0 -3
- package/dist/cjs/Popup.d.ts +0 -14
- package/dist/cjs/Scrollable.d.ts +0 -9
- package/dist/cjs/Select.d.ts +0 -16
- package/dist/cjs/SubMenu.d.ts +0 -7
- package/dist/cjs/Tab.d.ts +0 -12
- package/dist/cjs/TabList.d.ts +0 -10
- package/dist/cjs/TabPanel.d.ts +0 -6
- package/dist/cjs/TabSwitch.d.ts +0 -6
- package/dist/cjs/TextArea.d.ts +0 -18
- package/dist/cjs/TitleBar.d.ts +0 -6
- package/dist/cjs/UploadButton.d.ts +0 -7
- package/dist/cjs/stories/Autocomplete.stories.d.ts +0 -9
- package/dist/cjs/stories/Button.stories.d.ts +0 -9
- package/dist/cjs/stories/Header.stories.d.ts +0 -8
- package/dist/cjs/stories/Tabs.stories.d.ts +0 -6
- package/dist/esm/Autocomplete.d.ts +0 -20
- package/dist/esm/Autocomplete.js +0 -281
- package/dist/esm/Autocomplete.js.map +0 -1
- package/dist/esm/Avatar.d.ts +0 -12
- package/dist/esm/Avatar.js +0 -24
- package/dist/esm/Avatar.js.map +0 -1
- package/dist/esm/Button.d.ts +0 -15
- package/dist/esm/Button.js +0 -13
- package/dist/esm/Button.js.map +0 -1
- package/dist/esm/Checkbox.d.ts +0 -12
- package/dist/esm/Checkbox.js +0 -13
- package/dist/esm/Checkbox.js.map +0 -1
- package/dist/esm/Dialog.d.ts +0 -10
- package/dist/esm/Dialog.js +0 -43
- package/dist/esm/Dialog.js.map +0 -1
- package/dist/esm/FooterLinks.d.ts +0 -6
- package/dist/esm/FooterLinks.js +0 -8
- package/dist/esm/FooterLinks.js.map +0 -1
- package/dist/esm/Header.d.ts +0 -12
- package/dist/esm/Header.js +0 -99
- package/dist/esm/Header.js.map +0 -1
- package/dist/esm/HeaderSearchInput.d.ts +0 -10
- package/dist/esm/HeaderSearchInput.js +0 -181
- package/dist/esm/HeaderSearchInput.js.map +0 -1
- package/dist/esm/Input.d.ts +0 -22
- package/dist/esm/Input.js +0 -26
- package/dist/esm/Input.js.map +0 -1
- package/dist/esm/InputRow.d.ts +0 -7
- package/dist/esm/InputRow.js +0 -8
- package/dist/esm/InputRow.js.map +0 -1
- package/dist/esm/Loading.d.ts +0 -3
- package/dist/esm/Loading.js +0 -11
- package/dist/esm/Loading.js.map +0 -1
- package/dist/esm/MenuItem.d.ts +0 -9
- package/dist/esm/MenuItem.js +0 -8
- package/dist/esm/MenuItem.js.map +0 -1
- package/dist/esm/MenuSeparator.d.ts +0 -3
- package/dist/esm/MenuSeparator.js +0 -8
- package/dist/esm/MenuSeparator.js.map +0 -1
- package/dist/esm/Popup.d.ts +0 -14
- package/dist/esm/Popup.js +0 -78
- package/dist/esm/Popup.js.map +0 -1
- package/dist/esm/Scrollable.d.ts +0 -9
- package/dist/esm/Scrollable.js +0 -12
- package/dist/esm/Scrollable.js.map +0 -1
- package/dist/esm/Select.d.ts +0 -16
- package/dist/esm/Select.js +0 -16
- package/dist/esm/Select.js.map +0 -1
- package/dist/esm/SubMenu.d.ts +0 -7
- package/dist/esm/SubMenu.js +0 -38
- package/dist/esm/SubMenu.js.map +0 -1
- package/dist/esm/Tab.d.ts +0 -12
- package/dist/esm/Tab.js +0 -19
- package/dist/esm/Tab.js.map +0 -1
- package/dist/esm/TabList.d.ts +0 -10
- package/dist/esm/TabList.js +0 -23
- package/dist/esm/TabList.js.map +0 -1
- package/dist/esm/TabPanel.d.ts +0 -6
- package/dist/esm/TabPanel.js +0 -8
- package/dist/esm/TabPanel.js.map +0 -1
- package/dist/esm/TabSwitch.d.ts +0 -6
- package/dist/esm/TabSwitch.js +0 -16
- package/dist/esm/TabSwitch.js.map +0 -1
- package/dist/esm/TextArea.d.ts +0 -18
- package/dist/esm/TextArea.js +0 -16
- package/dist/esm/TextArea.js.map +0 -1
- package/dist/esm/TitleBar.d.ts +0 -6
- package/dist/esm/TitleBar.js +0 -8
- package/dist/esm/TitleBar.js.map +0 -1
- package/dist/esm/UploadButton.d.ts +0 -7
- package/dist/esm/UploadButton.js.map +0 -1
- package/dist/esm/stories/Autocomplete.stories.d.ts +0 -9
- package/dist/esm/stories/Button.stories.d.ts +0 -9
- package/dist/esm/stories/Dialog.stories.d.ts +0 -5
- package/dist/esm/stories/Header.stories.d.ts +0 -8
- package/dist/esm/stories/Input.stories.d.ts +0 -6
- package/dist/esm/stories/Loading.stories.d.ts +0 -5
- package/dist/esm/stories/Select.stories.d.ts +0 -6
- package/dist/esm/stories/Tabs.stories.d.ts +0 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReferenceInput.js","sources":["../../src/ReferenceInput.tsx"],"sourcesContent":["import { createReference } from '@medplum/core';\nimport { Reference, Resource } from '@medplum/fhirtypes';\nimport React, { useRef, useState } from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"ReferenceInput.js","sources":["../../src/ReferenceInput.tsx"],"sourcesContent":["import { Group, NativeSelect, TextInput } from '@mantine/core';\nimport { createReference } from '@medplum/core';\nimport { Reference, Resource, ResourceType } from '@medplum/fhirtypes';\nimport React, { useRef, useState } from 'react';\nimport { ResourceInput } from './ResourceInput';\n\nexport interface ReferenceInputProps {\n name: string;\n placeholder?: string;\n defaultValue?: Reference;\n targetTypes?: string[];\n onChange?: (value: Reference | undefined) => void;\n}\n\nexport function ReferenceInput(props: ReferenceInputProps): JSX.Element {\n const targetTypes = props.targetTypes;\n const initialResourceType = getInitialResourceType(props.defaultValue, targetTypes);\n const [value, setValue] = useState<Reference | undefined>(props.defaultValue);\n const [resourceType, setResourceType] = useState<string | undefined>(initialResourceType);\n\n const valueRef = useRef<Reference>();\n valueRef.current = value;\n\n const resourceTypeRef = useRef<string>();\n resourceTypeRef.current = resourceType;\n\n function setValueHelper(newValue: Reference | undefined): void {\n setValue(newValue);\n if (props.onChange) {\n props.onChange(newValue);\n }\n }\n\n return (\n <Group spacing=\"xs\" grow noWrap>\n {targetTypes ? (\n <NativeSelect\n data-testid=\"reference-input-resource-type-select\"\n defaultValue={resourceType}\n onChange={(e) => setResourceType(e.currentTarget.value)}\n data={targetTypes}\n />\n ) : (\n <TextInput\n data-testid=\"reference-input-resource-type-input\"\n defaultValue={resourceType}\n onChange={(e) => setResourceType(e.currentTarget.value)}\n />\n )}\n <ResourceInput\n resourceType={resourceType as ResourceType}\n name={props.name + '-id'}\n placeholder={props.placeholder}\n defaultValue={value}\n onChange={(item: Resource | undefined) => {\n setValueHelper(item ? createReference(item) : undefined);\n }}\n />\n </Group>\n );\n}\n\nfunction getInitialResourceType(\n defaultValue: Reference | undefined,\n targetTypes: string[] | undefined\n): string | undefined {\n const defaultValueResourceType = defaultValue?.reference?.split('/')[0];\n if (defaultValueResourceType) {\n return defaultValueResourceType;\n }\n\n if (targetTypes && targetTypes.length > 0) {\n return targetTypes[0];\n }\n\n return undefined;\n}\n"],"names":[],"mappings":";;;;;AAcM,SAAU,cAAc,CAAC,KAA0B,EAAA;AACvD,IAAA,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;IACtC,MAAM,mBAAmB,GAAG,sBAAsB,CAAC,KAAK,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;AACpF,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAwB,KAAK,CAAC,YAAY,CAAC,CAAC;IAC9E,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAA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,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC;aAC1D,EAAA,CACD,CACI,EACR;AACJ,CAAC;AAED,SAAS,sBAAsB,CAC7B,YAAmC,EACnC,WAAiC,EAAA;;AAEjC,IAAA,MAAM,wBAAwB,GAAG,CAAA,EAAA,GAAA,YAAY,KAAA,IAAA,IAAZ,YAAY,KAAZ,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,YAAY,CAAE,SAAS,0CAAE,KAAK,CAAC,GAAG,CAAE,CAAA,CAAC,CAAC,CAAC;AACxE,IAAA,IAAI,wBAAwB,EAAE;AAC5B,QAAA,OAAO,wBAAwB,CAAC;AACjC,KAAA;AAED,IAAA,IAAI,WAAW,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;AACzC,QAAA,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC;AACvB,KAAA;AAED,IAAA,OAAO,SAAS,CAAC;AACnB;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Button } from '@mantine/core';
|
|
1
2
|
import { formatDateTime, getReferenceString } from '@medplum/core';
|
|
2
3
|
import React, { useState, useEffect } from 'react';
|
|
3
|
-
import { Button } from './Button.js';
|
|
4
4
|
import { useMedplum } from './MedplumProvider.js';
|
|
5
5
|
import { ResourceName } from './ResourceName.js';
|
|
6
6
|
import { StatusBadge } from './StatusBadge.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestGroupDisplay.js","sources":["../../src/RequestGroupDisplay.tsx"],"sourcesContent":["import { formatDateTime, getReferenceString } from '@medplum/core';\nimport { Bundle, BundleEntry, Reference, RequestGroup, Resource, Task } from '@medplum/fhirtypes';\nimport React, { useEffect, useState } from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"RequestGroupDisplay.js","sources":["../../src/RequestGroupDisplay.tsx"],"sourcesContent":["import { Button } from '@mantine/core';\nimport { formatDateTime, getReferenceString } from '@medplum/core';\nimport { Bundle, BundleEntry, Reference, RequestGroup, Resource, Task } from '@medplum/fhirtypes';\nimport React, { useEffect, useState } from 'react';\nimport { useMedplum } from './MedplumProvider';\nimport { ResourceName } from './ResourceName';\nimport { StatusBadge } from './StatusBadge';\nimport { useResource } from './useResource';\n\nimport './RequestGroupDisplay.css';\n\nexport interface RequestGroupDisplayProps {\n value?: RequestGroup | Reference<RequestGroup>;\n onStart: (task: Task, input: Reference) => void;\n onEdit: (task: Task, input: Reference, output: Reference) => void;\n}\n\nexport function RequestGroupDisplay(props: RequestGroupDisplayProps): JSX.Element | null {\n const medplum = useMedplum();\n const requestGroup = useResource(props.value);\n const [startedLoading, setStartedLoading] = useState(false);\n const [responseBundle, setResponseBundle] = useState<Bundle>();\n\n useEffect(() => {\n if (requestGroup && !startedLoading) {\n medplum.executeBatch(buildBatchRequest(requestGroup)).then(setResponseBundle).catch(console.log);\n setStartedLoading(true);\n }\n }, [medplum, requestGroup, startedLoading]);\n\n if (!requestGroup || !responseBundle) {\n return null;\n }\n\n return (\n <div className=\"medplum-request-group\">\n {requestGroup.action?.map((action, index) => {\n const task = action.resource && findBundleEntry(action.resource as Reference<Task>);\n const taskInput = task?.input?.[0]?.valueReference;\n const taskOutput = task?.output?.[0]?.valueReference;\n return (\n <div className=\"medplum-request-group-task\" key={`action-${index}`}>\n <div className=\"medplum-request-group-task-checkmark\">{task?.status === 'completed' ? '🗹' : '☐'}</div>\n <div className=\"medplum-request-group-task-details\">\n <div className=\"medplum-request-group-task-title\">{action.title}</div>\n {action.description && <div>{action.description}</div>}\n <div>\n Last edited by \n <ResourceName value={task?.meta?.author as Reference} />\n on \n {formatDateTime(task?.meta?.lastUpdated)}\n </div>\n <div>\n Status: <StatusBadge status={task?.status || 'unknown'} />\n </div>\n </div>\n <div className=\"medplum-request-group-task-actions\">\n {taskInput && !taskOutput && <Button onClick={() => props.onStart(task, taskInput)}>Start</Button>}\n {taskInput && taskOutput && (\n <Button onClick={() => props.onEdit(task, taskInput, taskOutput)}>Edit</Button>\n )}\n </div>\n </div>\n );\n })}\n </div>\n );\n\n function buildBatchRequest(request: RequestGroup): Bundle {\n const batchEntries = [] as BundleEntry[];\n if (request.action) {\n for (const action of request.action) {\n if (action.resource?.reference) {\n batchEntries.push({ request: { method: 'GET', url: action.resource.reference } });\n }\n }\n }\n\n return {\n resourceType: 'Bundle',\n type: 'batch',\n entry: batchEntries,\n };\n }\n\n function findBundleEntry<T extends Resource>(reference: Reference<T>): T | undefined {\n for (const entry of responseBundle?.entry as BundleEntry[]) {\n if (entry.resource && reference.reference === getReferenceString(entry.resource)) {\n return entry.resource as T;\n }\n }\n return undefined;\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAiBM,SAAU,mBAAmB,CAAC,KAA+B,EAAA;;AACjE,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5D,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,EAAU,CAAC;IAE/D,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,YAAY,IAAI,CAAC,cAAc,EAAE;YACnC,OAAO,CAAC,YAAY,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACjG,iBAAiB,CAAC,IAAI,CAAC,CAAC;AACzB,SAAA;KACF,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC;AAE5C,IAAA,IAAI,CAAC,YAAY,IAAI,CAAC,cAAc,EAAE;AACpC,QAAA,OAAO,IAAI,CAAC;AACb,KAAA;AAED,IAAA,QACE,KAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAC,uBAAuB,EAAA,EACnC,MA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ACF,SAAA;AACD,QAAA,OAAO,SAAS,CAAC;KAClB;AACH;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { ActionIcon } from '@mantine/core';
|
|
2
|
+
import { IconCircleMinus, IconCirclePlus } from '@tabler/icons';
|
|
1
3
|
import React, { useState, useRef } from 'react';
|
|
2
|
-
import { Button } from './Button.js';
|
|
3
4
|
import { ResourcePropertyInput } from './ResourcePropertyInput.js';
|
|
4
5
|
import { killEvent } from './utils/dom.js';
|
|
5
6
|
|
|
@@ -15,8 +16,8 @@ function ResourceArrayInput(props) {
|
|
|
15
16
|
}
|
|
16
17
|
return (React.createElement("table", { style: { width: '100%', borderCollapse: 'collapse' } },
|
|
17
18
|
React.createElement("colgroup", null,
|
|
18
|
-
React.createElement("col", { width: "
|
|
19
|
-
React.createElement("col", { width: "
|
|
19
|
+
React.createElement("col", { width: "97%" }),
|
|
20
|
+
React.createElement("col", { width: "3%" })),
|
|
20
21
|
React.createElement("tbody", null,
|
|
21
22
|
values.map((v, index) => (React.createElement("tr", { key: `${index}-${values.length}` },
|
|
22
23
|
React.createElement("td", null,
|
|
@@ -26,21 +27,23 @@ function ResourceArrayInput(props) {
|
|
|
26
27
|
setValuesWrapper(copy);
|
|
27
28
|
} })),
|
|
28
29
|
React.createElement("td", { style: { textAlign: 'right' } },
|
|
29
|
-
React.createElement(
|
|
30
|
+
React.createElement(ActionIcon, { title: "Remove", size: "sm", onClick: (e) => {
|
|
30
31
|
killEvent(e);
|
|
31
32
|
const copy = [...valuesRef.current];
|
|
32
33
|
copy.splice(index, 1);
|
|
33
34
|
setValuesWrapper(copy);
|
|
34
|
-
} },
|
|
35
|
+
} },
|
|
36
|
+
React.createElement(IconCircleMinus, null)))))),
|
|
35
37
|
React.createElement("tr", null,
|
|
36
38
|
React.createElement("td", null),
|
|
37
39
|
React.createElement("td", { style: { textAlign: 'right' } },
|
|
38
|
-
React.createElement(
|
|
40
|
+
React.createElement(ActionIcon, { title: "Add", size: "sm", color: "green", onClick: (e) => {
|
|
39
41
|
killEvent(e);
|
|
40
42
|
const copy = [...valuesRef.current];
|
|
41
43
|
copy.push(undefined);
|
|
42
44
|
setValuesWrapper(copy);
|
|
43
|
-
} },
|
|
45
|
+
} },
|
|
46
|
+
React.createElement(IconCirclePlus, null)))))));
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
export { ResourceArrayInput };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceArrayInput.js","sources":["../../src/ResourceArrayInput.tsx"],"sourcesContent":["import { ElementDefinition } from '@medplum/fhirtypes';\nimport
|
|
1
|
+
{"version":3,"file":"ResourceArrayInput.js","sources":["../../src/ResourceArrayInput.tsx"],"sourcesContent":["import { ActionIcon } from '@mantine/core';\nimport { ElementDefinition } from '@medplum/fhirtypes';\nimport { IconCircleMinus, IconCirclePlus } from '@tabler/icons';\nimport React, { useRef, useState } from 'react';\nimport { ResourcePropertyInput } from './ResourcePropertyInput';\nimport { killEvent } from './utils/dom';\n\ninterface ResourceArrayInputProps {\n property: ElementDefinition;\n name: string;\n defaultValue?: any[];\n arrayElement?: boolean;\n onChange?: (value: any[]) => void;\n}\n\nexport function ResourceArrayInput(props: ResourceArrayInputProps): JSX.Element {\n const [values, setValues] = useState(\n props.defaultValue && Array.isArray(props.defaultValue) ? props.defaultValue : []\n );\n\n const valuesRef = useRef<any[]>();\n valuesRef.current = values;\n\n function setValuesWrapper(newValues: any[]): void {\n setValues(newValues);\n if (props.onChange) {\n props.onChange(newValues);\n }\n }\n\n return (\n <table style={{ width: '100%', borderCollapse: 'collapse' }}>\n <colgroup>\n <col width=\"97%\" />\n <col width=\"3%\" />\n </colgroup>\n <tbody>\n {values.map((v, index) => (\n <tr key={`${index}-${values.length}`}>\n <td>\n <ResourcePropertyInput\n arrayElement={true}\n property={props.property}\n name={props.name + '.' + index}\n defaultValue={v}\n onChange={(newValue: any) => {\n const copy = [...(valuesRef.current as any[])];\n copy[index] = newValue;\n setValuesWrapper(copy);\n }}\n />\n </td>\n <td style={{ textAlign: 'right' }}>\n <ActionIcon\n title=\"Remove\"\n size=\"sm\"\n onClick={(e: React.MouseEvent) => {\n killEvent(e);\n const copy = [...(valuesRef.current as any[])];\n copy.splice(index, 1);\n setValuesWrapper(copy);\n }}\n >\n <IconCircleMinus />\n </ActionIcon>\n </td>\n </tr>\n ))}\n <tr>\n <td></td>\n <td style={{ textAlign: 'right' }}>\n <ActionIcon\n title=\"Add\"\n size=\"sm\"\n color=\"green\"\n onClick={(e: React.MouseEvent) => {\n killEvent(e);\n const copy = [...(valuesRef.current as any[])];\n copy.push(undefined);\n setValuesWrapper(copy);\n }}\n >\n <IconCirclePlus />\n </ActionIcon>\n </td>\n </tr>\n </tbody>\n </table>\n );\n}\n"],"names":[],"mappings":";;;;;;AAeM,SAAU,kBAAkB,CAAC,KAA8B,EAAA;AAC/D,IAAA,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAClC,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,YAAY,GAAG,EAAE,CAClF,CAAC;AAEF,IAAA,MAAM,SAAS,GAAG,MAAM,EAAS,CAAC;AAClC,IAAA,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC;IAE3B,SAAS,gBAAgB,CAAC,SAAgB,EAAA;QACxC,SAAS,CAAC,SAAS,CAAC,CAAC;QACrB,IAAI,KAAK,CAAC,QAAQ,EAAE;AAClB,YAAA,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAC3B,SAAA;KACF;AAED,IAAA,QACE,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAO,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,EAAA;AACzD,QAAA,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,IAAA;YACE,KAAK,CAAA,aAAA,CAAA,KAAA,EAA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CAAC,CAAC;4BACtB,gBAAgB,CAAC,IAAI,CAAC,CAAC;yBACxB,EAAA;AAED,wBAAA,KAAA,CAAA,aAAA,CAAC,eAAe,EAAG,IAAA,CAAA,CACR,CACV,CACF,CACN,CAAC;AACF,YAAA,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,IAAA;gBACE,KAAS,CAAA,aAAA,CAAA,IAAA,EAAA,IAAA,CAAA;AACT,gBAAA,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAI,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,EAAA;AAC/B,oBAAA,KAAA,CAAA,aAAA,CAAC,UAAU,EACT,EAAA,KAAK,EAAC,KAAK,EACX,IAAI,EAAC,IAAI,EACT,KAAK,EAAC,OAAO,EACb,OAAO,EAAE,CAAC,CAAmB,KAAI;4BAC/B,SAAS,CAAC,CAAC,CAAC,CAAC;4BACb,MAAM,IAAI,GAAG,CAAC,GAAI,SAAS,CAAC,OAAiB,CAAC,CAAC;AAC/C,4BAAA,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;4BACrB,gBAAgB,CAAC,IAAI,CAAC,CAAC;yBACxB,EAAA;wBAED,KAAC,CAAA,aAAA,CAAA,cAAc,OAAG,CACP,CACV,CACF,CACC,CACF,EACR;AACJ;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { AvatarProps } from '@mantine/core';
|
|
3
|
+
import { Reference, Resource } from '@medplum/fhirtypes';
|
|
4
|
+
export interface ResourceAvatarProps extends AvatarProps {
|
|
5
|
+
value?: Reference | Resource;
|
|
6
|
+
link?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function ResourceAvatar(props: ResourceAvatarProps): JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Avatar } from '@mantine/core';
|
|
2
|
+
import { getDisplayString, getImageSrc } from '@medplum/core';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { MedplumLink } from './MedplumLink.js';
|
|
5
|
+
import { useResource } from './useResource.js';
|
|
6
|
+
|
|
7
|
+
function ResourceAvatar(props) {
|
|
8
|
+
var _a, _b, _c;
|
|
9
|
+
const resource = useResource(props.value);
|
|
10
|
+
const text = resource ? getDisplayString(resource) : (_a = props.alt) !== null && _a !== void 0 ? _a : '';
|
|
11
|
+
const imageUrl = (_b = (resource && getImageSrc(resource))) !== null && _b !== void 0 ? _b : props.src;
|
|
12
|
+
const radius = (_c = props.radius) !== null && _c !== void 0 ? _c : 'xl';
|
|
13
|
+
const avatarProps = Object.assign({}, props);
|
|
14
|
+
delete avatarProps.value;
|
|
15
|
+
delete avatarProps.link;
|
|
16
|
+
if (props.link) {
|
|
17
|
+
return (React.createElement(MedplumLink, { to: resource },
|
|
18
|
+
React.createElement(Avatar, Object.assign({ src: imageUrl, alt: text, radius: radius }, avatarProps))));
|
|
19
|
+
}
|
|
20
|
+
return React.createElement(Avatar, Object.assign({ src: imageUrl, alt: text, radius: radius }, avatarProps));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { ResourceAvatar };
|
|
24
|
+
//# sourceMappingURL=ResourceAvatar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResourceAvatar.js","sources":["../../src/ResourceAvatar.tsx"],"sourcesContent":["import { Avatar, AvatarProps } from '@mantine/core';\nimport { getDisplayString, getImageSrc } from '@medplum/core';\nimport { Reference, Resource } from '@medplum/fhirtypes';\nimport React from 'react';\nimport { MedplumLink } from './MedplumLink';\nimport { useResource } from './useResource';\n\nexport interface ResourceAvatarProps extends AvatarProps {\n value?: Reference | Resource;\n link?: boolean;\n}\n\nexport function ResourceAvatar(props: ResourceAvatarProps): JSX.Element {\n const resource = useResource(props.value);\n const text = resource ? getDisplayString(resource) : props.alt ?? '';\n const imageUrl = (resource && getImageSrc(resource)) ?? props.src;\n const radius = props.radius ?? 'xl';\n\n const avatarProps = { ...props };\n delete avatarProps.value;\n delete avatarProps.link;\n\n if (props.link) {\n return (\n <MedplumLink to={resource}>\n <Avatar src={imageUrl} alt={text} radius={radius} {...avatarProps} />\n </MedplumLink>\n );\n }\n\n return <Avatar src={imageUrl} alt={text} radius={radius} {...avatarProps} />;\n}\n"],"names":[],"mappings":";;;;;;AAYM,SAAU,cAAc,CAAC,KAA0B,EAAA;;IACvD,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC1C,IAAA,MAAM,IAAI,GAAG,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAA,EAAA,GAAA,KAAK,CAAC,GAAG,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,EAAE,CAAC;AACrE,IAAA,MAAM,QAAQ,GAAG,CAAA,EAAA,IAAC,QAAQ,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,KAAK,CAAC,GAAG,CAAC;IAClE,MAAM,MAAM,GAAG,CAAA,EAAA,GAAA,KAAK,CAAC,MAAM,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,IAAI,CAAC;AAEpC,IAAA,MAAM,WAAW,GAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAQ,KAAK,CAAE,CAAC;IACjC,OAAO,WAAW,CAAC,KAAK,CAAC;IACzB,OAAO,WAAW,CAAC,IAAI,CAAC;IAExB,IAAI,KAAK,CAAC,IAAI,EAAE;AACd,QAAA,QACE,KAAC,CAAA,aAAA,CAAA,WAAW,EAAC,EAAA,EAAE,EAAE,QAAQ,EAAA;AACvB,YAAA,KAAA,CAAA,aAAA,CAAC,MAAM,EAAC,MAAA,CAAA,MAAA,CAAA,EAAA,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAA,EAAM,WAAW,CAAI,CAAA,CACzD,EACd;AACH,KAAA;AAED,IAAA,OAAO,oBAAC,MAAM,EAAA,MAAA,CAAA,MAAA,CAAA,EAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAM,EAAA,WAAW,EAAI,CAAC;AAC/E;;;;"}
|
|
@@ -3,7 +3,6 @@ import { Reference, Resource } from '@medplum/fhirtypes';
|
|
|
3
3
|
import './ResourceBadge.css';
|
|
4
4
|
export interface ResourceBadgeProps {
|
|
5
5
|
value?: Reference | Resource;
|
|
6
|
-
size?: 'xsmall' | 'small' | 'medium' | 'large';
|
|
7
6
|
link?: boolean;
|
|
8
7
|
}
|
|
9
8
|
export declare function ResourceBadge(props: ResourceBadgeProps): JSX.Element;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ResourceAvatar } from './ResourceAvatar.js';
|
|
3
3
|
import { ResourceName } from './ResourceName.js';
|
|
4
4
|
|
|
5
5
|
function ResourceBadge(props) {
|
|
6
|
-
var _a;
|
|
7
6
|
return (React.createElement("div", { className: "medplum-resource-badge" },
|
|
8
|
-
React.createElement(
|
|
7
|
+
React.createElement(ResourceAvatar, { size: 24, radius: 12, value: props.value, link: props.link }),
|
|
9
8
|
React.createElement(ResourceName, { value: props.value, link: props.link })));
|
|
10
9
|
}
|
|
11
10
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceBadge.js","sources":["../../src/ResourceBadge.tsx"],"sourcesContent":["import { Reference, Resource } from '@medplum/fhirtypes';\nimport React from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"ResourceBadge.js","sources":["../../src/ResourceBadge.tsx"],"sourcesContent":["import { Reference, Resource } from '@medplum/fhirtypes';\nimport React from 'react';\nimport { ResourceAvatar } from './ResourceAvatar';\nimport { ResourceName } from './ResourceName';\n\nimport './ResourceBadge.css';\n\nexport interface ResourceBadgeProps {\n value?: Reference | Resource;\n link?: boolean;\n}\n\nexport function ResourceBadge(props: ResourceBadgeProps): JSX.Element {\n return (\n <div className=\"medplum-resource-badge\">\n <ResourceAvatar size={24} radius={12} value={props.value} link={props.link} />\n <ResourceName value={props.value} link={props.link} />\n </div>\n );\n}\n"],"names":[],"mappings":";;;;AAYM,SAAU,aAAa,CAAC,KAAyB,EAAA;AACrD,IAAA,QACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,wBAAwB,EAAA;QACrC,KAAC,CAAA,aAAA,CAAA,cAAc,IAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAI,CAAA;AAC9E,QAAA,KAAA,CAAA,aAAA,CAAC,YAAY,EAAC,EAAA,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAI,CAAA,CAClD,EACN;AACJ;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Group } from '@mantine/core';
|
|
1
2
|
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import { InputRow } from './InputRow.js';
|
|
3
3
|
import { MedplumLink } from './MedplumLink.js';
|
|
4
4
|
import { useMedplum } from './MedplumProvider.js';
|
|
5
5
|
import { ResourceBadge } from './ResourceBadge.js';
|
|
@@ -23,8 +23,8 @@ function ResourceBlame(props) {
|
|
|
23
23
|
React.createElement("table", { className: "medplum-blame" },
|
|
24
24
|
React.createElement("tbody", null, table.map((row, index) => (React.createElement("tr", { key: 'row-' + index, className: row.span > 0 ? 'start-row' : 'normal-row' },
|
|
25
25
|
row.span > 0 && (React.createElement("td", { className: "details", rowSpan: row.span },
|
|
26
|
-
React.createElement(
|
|
27
|
-
React.createElement(ResourceBadge, { value: row.meta.author,
|
|
26
|
+
React.createElement(Group, { spacing: "xs", grow: true, noWrap: true },
|
|
27
|
+
React.createElement(ResourceBadge, { value: row.meta.author, link: true }),
|
|
28
28
|
React.createElement(MedplumLink, { to: getVersionUrl(resource, row.meta.versionId) }, getTimeString(row.meta.lastUpdated))))),
|
|
29
29
|
React.createElement("td", { className: "line-number" }, index + 1),
|
|
30
30
|
React.createElement("td", { className: "line" },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceBlame.js","sources":["../../src/ResourceBlame.tsx"],"sourcesContent":["import { Bundle, Resource, ResourceType } from '@medplum/fhirtypes';\nimport React, { useEffect, useState } from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"ResourceBlame.js","sources":["../../src/ResourceBlame.tsx"],"sourcesContent":["import { Group } from '@mantine/core';\nimport { Bundle, Resource, ResourceType } from '@medplum/fhirtypes';\nimport React, { useEffect, useState } from 'react';\nimport { MedplumLink } from './MedplumLink';\nimport { useMedplum } from './MedplumProvider';\nimport { ResourceBadge } from './ResourceBadge';\nimport { blame } from './utils/blame';\n\nimport './ResourceBlame.css';\n\nexport interface ResourceBlameProps {\n history?: Bundle;\n resourceType?: ResourceType;\n id?: string;\n}\n\nexport function ResourceBlame(props: ResourceBlameProps): JSX.Element {\n const medplum = useMedplum();\n const [value, setValue] = useState<Bundle | undefined>(props.history);\n\n useEffect(() => {\n if (!props.history && props.resourceType && props.id) {\n medplum.readHistory(props.resourceType, props.id).then(setValue).catch(console.log);\n }\n }, [medplum, props.history, props.resourceType, props.id]);\n\n if (!value) {\n return <div>Loading...</div>;\n }\n\n const resource = value.entry?.[0]?.resource as Resource;\n const table = blame(value);\n return (\n <div className=\"medplum-blame-container\">\n <table className=\"medplum-blame\">\n <tbody>\n {table.map((row, index) => (\n <tr key={'row-' + index} className={row.span > 0 ? 'start-row' : 'normal-row'}>\n {row.span > 0 && (\n <td className=\"details\" rowSpan={row.span}>\n <Group spacing=\"xs\" grow noWrap>\n <ResourceBadge value={row.meta.author} link={true} />\n <MedplumLink to={getVersionUrl(resource, row.meta.versionId as string)}>\n {getTimeString(row.meta.lastUpdated as string)}\n </MedplumLink>\n </Group>\n </td>\n )}\n <td className=\"line-number\">{index + 1}</td>\n <td className=\"line\">\n <pre className=\"line-pre\">{row.value}</pre>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n}\n\nfunction getVersionUrl(resource: Resource, versionId: string): string {\n return `/${resource.resourceType}/${resource.id}/_history/${versionId}`;\n}\n\nexport function getTimeString(lastUpdated: string): string {\n const seconds = Math.floor((Date.now() - Date.parse(lastUpdated)) / 1000);\n\n const years = Math.floor(seconds / 31536000);\n if (years > 0) {\n return pluralizeTime(years, 'year');\n }\n\n const months = Math.floor(seconds / 2592000);\n if (months > 0) {\n return pluralizeTime(months, 'month');\n }\n\n const days = Math.floor(seconds / 86400);\n if (days > 0) {\n return pluralizeTime(days, 'day');\n }\n\n const hours = Math.floor(seconds / 3600);\n if (hours > 0) {\n return pluralizeTime(hours, 'hour');\n }\n\n const minutes = Math.floor(seconds / 60);\n if (minutes > 0) {\n return pluralizeTime(minutes, 'minute');\n }\n\n return pluralizeTime(seconds, 'second');\n}\n\nfunction pluralizeTime(count: number, noun: string): string {\n return `${count} ${count === 1 ? noun : noun + 's'} ago`;\n}\n"],"names":[],"mappings":";;;;;;;AAgBM,SAAU,aAAa,CAAC,KAAyB,EAAA;;AACrD,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;AAC7B,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAqB,KAAK,CAAC,OAAO,CAAC,CAAC;IAEtE,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,EAAE,EAAE;YACpD,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,C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ED,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC;IAC7C,IAAI,MAAM,GAAG,CAAC,EAAE;AACd,QAAA,OAAO,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACvC,KAAA;IAED,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC;IACzC,IAAI,IAAI,GAAG,CAAC,EAAE;AACZ,QAAA,OAAO,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACnC,KAAA;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IACzC,IAAI,KAAK,GAAG,CAAC,EAAE;AACb,QAAA,OAAO,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AACrC,KAAA;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;IACzC,IAAI,OAAO,GAAG,CAAC,EAAE;AACf,QAAA,OAAO,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACzC,KAAA;AAED,IAAA,OAAO,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,aAAa,CAAC,KAAa,EAAE,IAAY,EAAA;AAChD,IAAA,OAAO,GAAG,KAAK,CAAA,CAAA,EAAI,KAAK,KAAK,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,MAAM,CAAC;AAC3D;;;;"}
|
package/dist/esm/ResourceForm.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { TextInput, Group, Button } from '@mantine/core';
|
|
1
2
|
import { capitalize } from '@medplum/core';
|
|
2
3
|
import React, { useState, useEffect } from 'react';
|
|
3
4
|
import { BackboneElementInput } from './BackboneElementInput.js';
|
|
4
|
-
import { Button } from './Button.js';
|
|
5
5
|
import { FormSection } from './FormSection.js';
|
|
6
|
-
import { Input } from './Input.js';
|
|
7
6
|
import { useMedplum } from './MedplumProvider.js';
|
|
8
7
|
import { useResource } from './useResource.js';
|
|
9
8
|
|
|
@@ -27,15 +26,16 @@ function ResourceForm(props) {
|
|
|
27
26
|
props.onSubmit(value);
|
|
28
27
|
}
|
|
29
28
|
} },
|
|
30
|
-
React.createElement(FormSection, { title: "Resource Type" },
|
|
31
|
-
React.createElement(
|
|
32
|
-
React.createElement(FormSection, { title: "ID" },
|
|
33
|
-
React.createElement(
|
|
29
|
+
React.createElement(FormSection, { title: "Resource Type", htmlFor: "resourceType", outcome: props.outcome },
|
|
30
|
+
React.createElement(TextInput, { name: "resourceType", defaultValue: value.resourceType, disabled: true })),
|
|
31
|
+
React.createElement(FormSection, { title: "ID", htmlFor: "id", outcome: props.outcome },
|
|
32
|
+
React.createElement(TextInput, { name: "id", defaultValue: value.id, disabled: true })),
|
|
34
33
|
React.createElement(BackboneElementInput, { typeName: value.resourceType, defaultValue: value, outcome: props.outcome, onChange: setValue }),
|
|
35
|
-
React.createElement(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
React.createElement(Group, null,
|
|
35
|
+
React.createElement(Button, { type: "submit" }, "OK"),
|
|
36
|
+
props.onDelete && (React.createElement(Button, { variant: "outline", color: "red", type: "button", onClick: () => {
|
|
37
|
+
props.onDelete(value);
|
|
38
|
+
} }, "Delete")))));
|
|
39
39
|
}
|
|
40
40
|
function setPropertyValue(obj, key, propName, elementDefinition, value) {
|
|
41
41
|
const types = elementDefinition.type;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceForm.js","sources":["../../src/ResourceForm.tsx"],"sourcesContent":["import { capitalize, IndexedStructureDefinition } from '@medplum/core';\nimport { ElementDefinition, ElementDefinitionType, OperationOutcome, Reference, Resource } from '@medplum/fhirtypes';\nimport React, { useEffect, useState } from 'react';\nimport { BackboneElementInput } from './BackboneElementInput';\nimport {
|
|
1
|
+
{"version":3,"file":"ResourceForm.js","sources":["../../src/ResourceForm.tsx"],"sourcesContent":["import { Button, Group, TextInput } from '@mantine/core';\nimport { capitalize, IndexedStructureDefinition } from '@medplum/core';\nimport { ElementDefinition, ElementDefinitionType, OperationOutcome, Reference, Resource } from '@medplum/fhirtypes';\nimport React, { useEffect, useState } from 'react';\nimport { BackboneElementInput } from './BackboneElementInput';\nimport { FormSection } from './FormSection';\nimport { useMedplum } from './MedplumProvider';\nimport { useResource } from './useResource';\n\nexport interface ResourceFormProps {\n defaultValue: Resource | Reference;\n outcome?: OperationOutcome;\n onSubmit: (resource: Resource) => void;\n onDelete?: (resource: Resource) => void;\n}\n\nexport function ResourceForm(props: ResourceFormProps): JSX.Element {\n const medplum = useMedplum();\n const defaultValue = useResource(props.defaultValue);\n const [schema, setSchema] = useState<IndexedStructureDefinition | undefined>();\n const [value, setValue] = useState<Resource | undefined>();\n\n useEffect(() => {\n if (defaultValue) {\n setValue(JSON.parse(JSON.stringify(defaultValue)));\n medplum.requestSchema(defaultValue.resourceType).then(setSchema).catch(console.log);\n }\n }, [medplum, defaultValue]);\n\n if (!schema || !value) {\n return <div>Loading...</div>;\n }\n\n return (\n <form\n noValidate\n autoComplete=\"off\"\n onSubmit={(e: React.FormEvent) => {\n e.preventDefault();\n if (props.onSubmit) {\n props.onSubmit(value);\n }\n }}\n >\n <FormSection title=\"Resource Type\" htmlFor=\"resourceType\" outcome={props.outcome}>\n <TextInput name=\"resourceType\" defaultValue={value.resourceType} disabled={true} />\n </FormSection>\n <FormSection title=\"ID\" htmlFor=\"id\" outcome={props.outcome}>\n <TextInput name=\"id\" defaultValue={value.id} disabled={true} />\n </FormSection>\n <BackboneElementInput\n typeName={value.resourceType}\n defaultValue={value}\n outcome={props.outcome}\n onChange={setValue}\n />\n <Group>\n <Button type=\"submit\">OK</Button>\n {props.onDelete && (\n <Button\n variant=\"outline\"\n color=\"red\"\n type=\"button\"\n onClick={() => {\n (props.onDelete as (resource: Resource) => void)(value);\n }}\n >\n Delete\n </Button>\n )}\n </Group>\n </form>\n );\n}\n\nexport function setPropertyValue(\n obj: any,\n key: string,\n propName: string,\n elementDefinition: ElementDefinition,\n value: any\n): any {\n const types = elementDefinition.type as ElementDefinitionType[];\n if (types.length > 1) {\n for (const type of types) {\n const compoundKey = key.replace('[x]', capitalize(type.code as string));\n if (compoundKey in obj) {\n delete obj[compoundKey];\n }\n }\n }\n obj[propName] = value;\n return obj;\n}\n"],"names":[],"mappings":";;;;;;;;AAgBM,SAAU,YAAY,CAAC,KAAwB,EAAA;AACnD,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACrD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,EAA0C,CAAC;IAC/E,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAwB,CAAC;IAE3D,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,YAAY,EAAE;AAChB,YAAA,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AACnD,YAAA,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AACrF,SAAA;AACH,KAAC,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;AAE5B,IAAA,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE;AACrB,QAAA,OAAO,8CAAqB,CAAC;AAC9B,KAAA;AAED,IAAA,QACE,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EACE,UAAU,EAAA,IAAA,EACV,YAAY,EAAC,KAAK,EAClB,QAAQ,EAAE,CAAC,CAAkB,KAAI;YAC/B,CAAC,CAAC,cA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AAC,EAGM,EAAA,QAAA,CAAA,CACV,CACK,CACH,EACP;AACJ,CAAC;AAEK,SAAU,gBAAgB,CAC9B,GAAQ,EACR,GAAW,EACX,QAAgB,EAChB,iBAAoC,EACpC,KAAU,EAAA;AAEV,IAAA,MAAM,KAAK,GAAG,iBAAiB,CAAC,IAA+B,CAAC;AAChE,IAAA,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;AACpB,QAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;AACxB,YAAA,MAAM,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,IAAc,CAAC,CAAC,CAAC;YACxE,IAAI,WAAW,IAAI,GAAG,EAAE;AACtB,gBAAA,OAAO,GAAG,CAAC,WAAW,CAAC,CAAC;AACzB,aAAA;AACF,SAAA;AACF,KAAA;AACD,IAAA,GAAG,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;AACtB,IAAA,OAAO,GAAG,CAAC;AACb;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Table } from '@mantine/core';
|
|
1
2
|
import { formatDateTime, normalizeErrorString } from '@medplum/core';
|
|
2
3
|
import React, { useState, useEffect } from 'react';
|
|
3
4
|
import { MedplumLink } from './MedplumLink.js';
|
|
@@ -19,7 +20,7 @@ function ResourceHistoryTable(props) {
|
|
|
19
20
|
if (!value) {
|
|
20
21
|
return React.createElement("div", null, "Loading...");
|
|
21
22
|
}
|
|
22
|
-
return (React.createElement(
|
|
23
|
+
return (React.createElement(Table, { withBorder: true, withColumnBorders: true },
|
|
23
24
|
React.createElement("thead", null,
|
|
24
25
|
React.createElement("tr", null,
|
|
25
26
|
React.createElement("th", null, "Author"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceHistoryTable.js","sources":["../../src/ResourceHistoryTable.tsx"],"sourcesContent":["import { formatDateTime, normalizeErrorString } from '@medplum/core';\nimport { Bundle, BundleEntry, Resource, ResourceType } from '@medplum/fhirtypes';\nimport React, { useEffect, useState } from 'react';\nimport { MedplumLink } from './MedplumLink';\nimport { useMedplum } from './MedplumProvider';\nimport { ResourceBadge } from './ResourceBadge';\
|
|
1
|
+
{"version":3,"file":"ResourceHistoryTable.js","sources":["../../src/ResourceHistoryTable.tsx"],"sourcesContent":["import { Table } from '@mantine/core';\nimport { formatDateTime, normalizeErrorString } from '@medplum/core';\nimport { Bundle, BundleEntry, Resource, ResourceType } from '@medplum/fhirtypes';\nimport React, { useEffect, useState } from 'react';\nimport { MedplumLink } from './MedplumLink';\nimport { useMedplum } from './MedplumProvider';\nimport { ResourceBadge } from './ResourceBadge';\n\nexport interface ResourceHistoryTableProps {\n history?: Bundle;\n resourceType?: string;\n id?: string;\n}\n\nexport function ResourceHistoryTable(props: ResourceHistoryTableProps): JSX.Element {\n const medplum = useMedplum();\n const [value, setValue] = useState<Bundle | undefined>(props.history);\n\n useEffect(() => {\n if (!props.history && props.resourceType && props.id) {\n medplum\n .readHistory(props.resourceType as ResourceType, props.id)\n .then(setValue)\n .catch(console.log);\n }\n }, [medplum, props.history, props.resourceType, props.id]);\n\n if (!value) {\n return <div>Loading...</div>;\n }\n\n return (\n <Table withBorder withColumnBorders>\n <thead>\n <tr>\n <th>Author</th>\n <th>Date</th>\n <th>Version</th>\n </tr>\n </thead>\n <tbody>\n {value.entry?.map((entry, index) => (\n <HistoryRow key={'entry-' + index} entry={entry} />\n ))}\n </tbody>\n </Table>\n );\n}\n\ninterface HistoryRowProps {\n entry: BundleEntry;\n}\n\nfunction HistoryRow(props: HistoryRowProps): JSX.Element {\n const { response, resource } = props.entry;\n if (resource) {\n return (\n <tr>\n <td>\n <ResourceBadge value={resource.meta?.author} link={true} />\n </td>\n <td>{formatDateTime(resource.meta?.lastUpdated)}</td>\n <td>\n <MedplumLink to={getVersionUrl(resource)}>{resource.meta?.versionId}</MedplumLink>\n </td>\n </tr>\n );\n } else {\n return (\n <tr>\n <td colSpan={3}>{normalizeErrorString(response?.outcome)}</td>\n </tr>\n );\n }\n}\n\nfunction getVersionUrl(resource: Resource): string {\n return `/${resource.resourceType}/${resource.id}/_history/${resource.meta?.versionId}`;\n}\n"],"names":[],"mappings":";;;;;;;AAcM,SAAU,oBAAoB,CAAC,KAAgC,EAAA;;AACnE,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;AAC7B,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAqB,KAAK,CAAC,OAAO,CAAC,CAAC;IAEtE,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,EAAE,EAAE;YACpD,OAAO;iBACJ,WAAW,CAAC,KAAK,CAAC,YAA4B,EAAE,KAAK,CAAC,EAAE,CAAC;iBACzD,IAAI,CAAC,QAAQ,CAAC;AACd,iBAAA,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AACvB,SAAA;AACH,KAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IAE3D,IAAI,CAAC,KAAK,EAAE;AACV,QAAA,OAAO,8CAAqB,CAAC;AAC9B,KAAA;AAED,IAAA,QACE,KAAC,CAAA,aAAA,CAAA,KAAK,EAAC,EAAA,UAAU,QAAC,iBAAiB,EAAA,IAAA,EAAA;AACjC,QAAA,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,IAAA;AACE,YAAA,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,IAAA;gBACE,KAAe,CAAA,aAAA,CAAA,IAAA,EAAA,IAAA,EAAA,QAAA,CAAA;gBACf,KAAa,CAAA,aAAA,CAAA,IAAA,EAAA,IAAA,EAAA,MAAA,CAAA;AACb,gBAAA,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,IAAA,EAAA,SA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AA,SAAS,CAAe,CAC/E,CACF,EACL;AACH,KAAA;AAAM,SAAA;AACL,QAAA,QACE,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,IAAA;AACE,YAAA,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAI,OAAO,EAAE,CAAC,EAAG,EAAA,oBAAoB,CAAC,QAAQ,KAAA,IAAA,IAAR,QAAQ,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAR,QAAQ,CAAE,OAAO,CAAC,CAAM,CAC3D,EACL;AACH,KAAA;AACH,CAAC;AAED,SAAS,aAAa,CAAC,QAAkB,EAAA;;AACvC,IAAA,OAAO,IAAI,QAAQ,CAAC,YAAY,CAAA,CAAA,EAAI,QAAQ,CAAC,EAAE,CAAa,UAAA,EAAA,CAAA,EAAA,GAAA,QAAQ,CAAC,IAAI,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,SAAS,EAAE,CAAC;AACzF;;;;"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Reference, Resource } from '@medplum/fhirtypes';
|
|
2
|
+
import { Reference, Resource, ResourceType } from '@medplum/fhirtypes';
|
|
3
3
|
export interface ResourceInputProps<T extends Resource = Resource> {
|
|
4
|
-
readonly resourceType:
|
|
4
|
+
readonly resourceType: ResourceType;
|
|
5
5
|
readonly name: string;
|
|
6
6
|
readonly defaultValue?: T | Reference<T>;
|
|
7
|
-
readonly className?: string;
|
|
8
7
|
readonly placeholder?: string;
|
|
9
8
|
readonly loadOnFocus?: boolean;
|
|
10
9
|
readonly onChange?: (value: T | undefined) => void;
|
|
@@ -1,41 +1,49 @@
|
|
|
1
|
-
import { __awaiter } from './node_modules/tslib/tslib.es6.js';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { __rest, __awaiter } from './node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { Group, Text, Autocomplete, Loader } from '@mantine/core';
|
|
3
|
+
import { getDisplayString } from '@medplum/core';
|
|
4
|
+
import React, { forwardRef, useState } from 'react';
|
|
5
5
|
import { useMedplum } from './MedplumProvider.js';
|
|
6
|
-
import {
|
|
6
|
+
import { ResourceAvatar } from './ResourceAvatar.js';
|
|
7
7
|
import { useResource } from './useResource.js';
|
|
8
8
|
|
|
9
9
|
function ResourceInput(props) {
|
|
10
10
|
const medplum = useMedplum();
|
|
11
|
-
const
|
|
12
|
-
const [value, setValue] = useState();
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
const defaultValue = useResource(props.defaultValue);
|
|
12
|
+
const [value, setValue] = useState(defaultValue ? getDisplayString(defaultValue) : '');
|
|
13
|
+
const [loading, setLoading] = useState(false);
|
|
14
|
+
const [data, setData] = useState([]);
|
|
15
|
+
function loadValues(input) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
setLoading(true);
|
|
18
|
+
const resources = yield medplum.searchResources(props.resourceType, 'name=' + encodeURIComponent(input) + '&_count=10');
|
|
19
|
+
setData(resources.map((resource) => ({ value: getDisplayString(resource), resource })));
|
|
20
|
+
setLoading(false);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function handleChange(val) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
setValue(val);
|
|
26
|
+
return loadValues(val);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function handleSelect(item) {
|
|
30
|
+
setValue(item.value);
|
|
31
|
+
setData([]);
|
|
20
32
|
if (props.onChange) {
|
|
21
|
-
props.onChange(
|
|
33
|
+
props.onChange(item.resource);
|
|
22
34
|
}
|
|
23
35
|
}
|
|
24
|
-
return (React.createElement(Autocomplete, {
|
|
25
|
-
return medplum
|
|
26
|
-
.search(resourceTypeRef.current, 'name=' + encodeURIComponent(input) + '&_count=10')
|
|
27
|
-
.then((bundle) => bundle.entry.map((entry) => entry.resource));
|
|
28
|
-
}), getId: (item) => {
|
|
29
|
-
return item.id;
|
|
30
|
-
}, getIcon: (item) => React.createElement(Avatar, { value: item }), getDisplay: (item) => React.createElement(ResourceName, { value: item }), getHelpText: (item) => {
|
|
31
|
-
if (item.resourceType === 'Patient' && item.birthDate) {
|
|
32
|
-
return 'DoB: ' + item.birthDate;
|
|
33
|
-
}
|
|
34
|
-
return undefined;
|
|
35
|
-
}, name: props.name, defaultValue: value ? [value] : undefined, className: props.className, placeholder: props.placeholder, loadOnFocus: props.loadOnFocus, onChange: (items) => {
|
|
36
|
-
setValueWrapper(items.length > 0 ? items[0] : undefined);
|
|
37
|
-
} }));
|
|
36
|
+
return (React.createElement(Autocomplete, { itemComponent: ItemComponent, value: value, data: data, placeholder: props.placeholder, onFocus: () => loadValues(value), onChange: handleChange, onItemSubmit: handleSelect, rightSection: loading ? React.createElement(Loader, { size: 16 }) : null }));
|
|
38
37
|
}
|
|
38
|
+
const ItemComponent = forwardRef((_a, ref) => {
|
|
39
|
+
var { value, resource } = _a, others = __rest(_a, ["value", "resource"]);
|
|
40
|
+
return (React.createElement("div", Object.assign({ ref: ref }, others),
|
|
41
|
+
React.createElement(Group, { noWrap: true },
|
|
42
|
+
React.createElement(ResourceAvatar, { value: resource }),
|
|
43
|
+
React.createElement("div", null,
|
|
44
|
+
React.createElement(Text, null, value),
|
|
45
|
+
React.createElement(Text, { size: "xs", color: "dimmed" }, resource.birthDate)))));
|
|
46
|
+
});
|
|
39
47
|
|
|
40
48
|
export { ResourceInput };
|
|
41
49
|
//# sourceMappingURL=ResourceInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceInput.js","sources":["../../src/ResourceInput.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"ResourceInput.js","sources":["../../src/ResourceInput.tsx"],"sourcesContent":["import { Autocomplete, AutocompleteItem, Group, Loader, Text } from '@mantine/core';\nimport { getDisplayString } from '@medplum/core';\nimport { Patient, Reference, Resource, ResourceType } from '@medplum/fhirtypes';\nimport React, { forwardRef, useState } from 'react';\nimport { useMedplum } from './MedplumProvider';\nimport { ResourceAvatar } from './ResourceAvatar';\nimport { useResource } from './useResource';\n\nexport interface ResourceInputProps<T extends Resource = Resource> {\n readonly resourceType: ResourceType;\n readonly name: string;\n readonly defaultValue?: T | Reference<T>;\n readonly placeholder?: string;\n readonly loadOnFocus?: boolean;\n readonly onChange?: (value: T | undefined) => void;\n}\n\nexport function ResourceInput<T extends Resource = Resource>(props: ResourceInputProps<T>): JSX.Element {\n const medplum = useMedplum();\n const defaultValue = useResource(props.defaultValue);\n const [value, setValue] = useState<string>(defaultValue ? getDisplayString(defaultValue) : '');\n const [loading, setLoading] = useState(false);\n const [data, setData] = useState<AutocompleteItem[]>([]);\n\n async function loadValues(input: string): Promise<void> {\n setLoading(true);\n const resources = await medplum.searchResources(\n props.resourceType,\n 'name=' + encodeURIComponent(input) + '&_count=10'\n );\n setData(resources.map((resource) => ({ value: getDisplayString(resource), resource })));\n setLoading(false);\n }\n\n async function handleChange(val: string): Promise<void> {\n setValue(val);\n return loadValues(val);\n }\n\n function handleSelect(item: AutocompleteItem): void {\n setValue(item.value);\n setData([]);\n if (props.onChange) {\n props.onChange(item.resource);\n }\n }\n\n return (\n <Autocomplete\n itemComponent={ItemComponent}\n value={value}\n data={data}\n placeholder={props.placeholder}\n onFocus={() => loadValues(value)}\n onChange={handleChange}\n onItemSubmit={handleSelect}\n rightSection={loading ? <Loader size={16} /> : null}\n />\n );\n}\n\nconst ItemComponent = forwardRef<HTMLDivElement, any>(({ value, resource, ...others }: any, ref) => {\n return (\n <div ref={ref} {...others}>\n <Group noWrap>\n <ResourceAvatar value={resource} />\n <div>\n <Text>{value}</Text>\n <Text size=\"xs\" color=\"dimmed\">\n {(resource as Patient).birthDate}\n </Text>\n </div>\n </Group>\n </div>\n );\n});\n"],"names":[],"mappings":";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