@medplum/react 2.0.2 → 2.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/OperationOutcomeAlert/OperationOutcomeAlert.d.ts +2 -1
- package/dist/cjs/ResourceDiffTable/ResourceDiffTable.stories.d.ts +5 -0
- package/dist/cjs/ResourceTable/ResourceTable.d.ts +13 -0
- package/dist/cjs/ResourceTimeline/ResourceTimeline.d.ts +2 -2
- package/dist/cjs/index.cjs +1833 -1211
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/cjs/useResource/useResource.d.ts +2 -2
- package/dist/cjs/utils/date.d.ts +2 -1
- package/dist/esm/AddressDisplay/AddressDisplay.mjs +2 -2
- package/dist/esm/AddressDisplay/AddressDisplay.mjs.map +1 -1
- package/dist/esm/AddressInput/AddressInput.mjs +9 -9
- package/dist/esm/AddressInput/AddressInput.mjs.map +1 -1
- package/dist/esm/AnnotationInput/AnnotationInput.mjs +2 -2
- package/dist/esm/AnnotationInput/AnnotationInput.mjs.map +1 -1
- package/dist/esm/AsyncAutocomplete/AsyncAutocomplete.mjs +2 -2
- package/dist/esm/AsyncAutocomplete/AsyncAutocomplete.mjs.map +1 -1
- package/dist/esm/AttachmentArrayDisplay/AttachmentArrayDisplay.mjs +4 -4
- package/dist/esm/AttachmentArrayDisplay/AttachmentArrayDisplay.mjs.map +1 -1
- package/dist/esm/AttachmentArrayInput/AttachmentArrayInput.mjs +20 -19
- package/dist/esm/AttachmentArrayInput/AttachmentArrayInput.mjs.map +1 -1
- package/dist/esm/AttachmentButton/AttachmentButton.mjs +3 -3
- package/dist/esm/AttachmentButton/AttachmentButton.mjs.map +1 -1
- package/dist/esm/AttachmentDisplay/AttachmentDisplay.mjs +9 -9
- package/dist/esm/AttachmentDisplay/AttachmentDisplay.mjs.map +1 -1
- package/dist/esm/AttachmentInput/AttachmentInput.mjs +5 -5
- package/dist/esm/AttachmentInput/AttachmentInput.mjs.map +1 -1
- package/dist/esm/BackboneElementDisplay/BackboneElementDisplay.mjs +6 -6
- package/dist/esm/BackboneElementDisplay/BackboneElementDisplay.mjs.map +1 -1
- package/dist/esm/BackboneElementInput/BackboneElementInput.mjs +7 -7
- package/dist/esm/BackboneElementInput/BackboneElementInput.mjs.map +1 -1
- package/dist/esm/CalendarInput/CalendarInput.mjs +18 -18
- package/dist/esm/CalendarInput/CalendarInput.mjs.map +1 -1
- package/dist/esm/CheckboxFormSection/CheckboxFormSection.mjs +5 -5
- package/dist/esm/CheckboxFormSection/CheckboxFormSection.mjs.map +1 -1
- package/dist/esm/CodeInput/CodeInput.mjs +2 -2
- package/dist/esm/CodeInput/CodeInput.mjs.map +1 -1
- package/dist/esm/CodeableConceptDisplay/CodeableConceptDisplay.mjs +2 -2
- package/dist/esm/CodeableConceptDisplay/CodeableConceptDisplay.mjs.map +1 -1
- package/dist/esm/CodeableConceptInput/CodeableConceptInput.mjs +2 -2
- package/dist/esm/CodeableConceptInput/CodeableConceptInput.mjs.map +1 -1
- package/dist/esm/CodingDisplay/CodingDisplay.mjs +2 -2
- package/dist/esm/CodingDisplay/CodingDisplay.mjs.map +1 -1
- package/dist/esm/CodingInput/CodingInput.mjs +2 -2
- package/dist/esm/CodingInput/CodingInput.mjs.map +1 -1
- package/dist/esm/ContactDetailDisplay/ContactDetailDisplay.mjs +3 -3
- package/dist/esm/ContactDetailDisplay/ContactDetailDisplay.mjs.map +1 -1
- package/dist/esm/ContactDetailInput/ContactDetailInput.mjs +4 -4
- package/dist/esm/ContactDetailInput/ContactDetailInput.mjs.map +1 -1
- package/dist/esm/ContactPointDisplay/ContactPointDisplay.mjs +2 -2
- package/dist/esm/ContactPointDisplay/ContactPointDisplay.mjs.map +1 -1
- package/dist/esm/ContactPointInput/ContactPointInput.mjs +5 -5
- package/dist/esm/ContactPointInput/ContactPointInput.mjs.map +1 -1
- package/dist/esm/Container/Container.mjs +2 -2
- package/dist/esm/Container/Container.mjs.map +1 -1
- package/dist/esm/DateTimeInput/DateTimeInput.mjs +2 -2
- package/dist/esm/DateTimeInput/DateTimeInput.mjs.map +1 -1
- package/dist/esm/DefaultResourceTimeline/DefaultResourceTimeline.mjs +3 -7
- package/dist/esm/DefaultResourceTimeline/DefaultResourceTimeline.mjs.map +1 -1
- package/dist/esm/DescriptionList/DescriptionList.mjs +5 -5
- package/dist/esm/DescriptionList/DescriptionList.mjs.map +1 -1
- package/dist/esm/DiagnosticReportDisplay/DiagnosticReportDisplay.mjs +49 -49
- package/dist/esm/DiagnosticReportDisplay/DiagnosticReportDisplay.mjs.map +1 -1
- package/dist/esm/Document/Document.mjs +3 -3
- package/dist/esm/Document/Document.mjs.map +1 -1
- package/dist/esm/EncounterTimeline/EncounterTimeline.mjs +7 -7
- package/dist/esm/EncounterTimeline/EncounterTimeline.mjs.map +1 -1
- package/dist/esm/ErrorBoundary/ErrorBoundary.mjs +4 -4
- package/dist/esm/ErrorBoundary/ErrorBoundary.mjs.map +1 -1
- package/dist/esm/ExtensionInput/ExtensionInput.mjs +2 -2
- package/dist/esm/ExtensionInput/ExtensionInput.mjs.map +1 -1
- package/dist/esm/FhirPathDisplay/FhirPathDisplay.mjs +2 -2
- package/dist/esm/FhirPathDisplay/FhirPathDisplay.mjs.map +1 -1
- package/dist/esm/FhirPathTable/FhirPathTable.mjs +19 -19
- package/dist/esm/FhirPathTable/FhirPathTable.mjs.map +1 -1
- package/dist/esm/Form/Form.mjs +2 -2
- package/dist/esm/Form/Form.mjs.map +1 -1
- package/dist/esm/FormSection/FormSection.mjs +2 -2
- package/dist/esm/FormSection/FormSection.mjs.map +1 -1
- package/dist/esm/GoogleButton/GoogleButton.mjs +4 -4
- package/dist/esm/GoogleButton/GoogleButton.mjs.map +1 -1
- package/dist/esm/HumanNameDisplay/HumanNameDisplay.mjs +2 -2
- package/dist/esm/HumanNameDisplay/HumanNameDisplay.mjs.map +1 -1
- package/dist/esm/HumanNameInput/HumanNameInput.mjs +7 -7
- package/dist/esm/HumanNameInput/HumanNameInput.mjs.map +1 -1
- package/dist/esm/IdentifierDisplay/IdentifierDisplay.mjs +2 -2
- package/dist/esm/IdentifierDisplay/IdentifierDisplay.mjs.map +1 -1
- package/dist/esm/IdentifierInput/IdentifierInput.mjs +4 -4
- package/dist/esm/IdentifierInput/IdentifierInput.mjs.map +1 -1
- package/dist/esm/Logo/Logo.mjs +8 -8
- package/dist/esm/Logo/Logo.mjs.map +1 -1
- package/dist/esm/MedplumLink/MedplumLink.mjs +2 -2
- package/dist/esm/MedplumLink/MedplumLink.mjs.map +1 -1
- package/dist/esm/MedplumProvider/MedplumProvider.mjs +2 -2
- package/dist/esm/MedplumProvider/MedplumProvider.mjs.map +1 -1
- package/dist/esm/MoneyDisplay/MoneyDisplay.mjs +2 -2
- package/dist/esm/MoneyDisplay/MoneyDisplay.mjs.map +1 -1
- package/dist/esm/MoneyInput/MoneyInput.mjs +4 -4
- package/dist/esm/MoneyInput/MoneyInput.mjs.map +1 -1
- package/dist/esm/NoteDisplay/NoteDisplay.mjs +2 -2
- package/dist/esm/NoteDisplay/NoteDisplay.mjs.map +1 -1
- package/dist/esm/OperationOutcomeAlert/OperationOutcomeAlert.d.ts +2 -1
- package/dist/esm/OperationOutcomeAlert/OperationOutcomeAlert.mjs +5 -4
- package/dist/esm/OperationOutcomeAlert/OperationOutcomeAlert.mjs.map +1 -1
- package/dist/esm/Panel/Panel.mjs +2 -2
- package/dist/esm/Panel/Panel.mjs.map +1 -1
- package/dist/esm/PatientTimeline/PatientTimeline.mjs +12 -12
- package/dist/esm/PatientTimeline/PatientTimeline.mjs.map +1 -1
- package/dist/esm/PeriodInput/PeriodInput.mjs +4 -4
- package/dist/esm/PeriodInput/PeriodInput.mjs.map +1 -1
- package/dist/esm/PlanDefinitionBuilder/PlanDefinitionBuilder.mjs +34 -34
- package/dist/esm/PlanDefinitionBuilder/PlanDefinitionBuilder.mjs.map +1 -1
- package/dist/esm/QuantityDisplay/QuantityDisplay.mjs +2 -2
- package/dist/esm/QuantityDisplay/QuantityDisplay.mjs.map +1 -1
- package/dist/esm/QuantityInput/QuantityInput.mjs +5 -5
- package/dist/esm/QuantityInput/QuantityInput.mjs.map +1 -1
- package/dist/esm/QuestionnaireBuilder/QuestionnaireBuilder.mjs +31 -31
- package/dist/esm/QuestionnaireBuilder/QuestionnaireBuilder.mjs.map +1 -1
- package/dist/esm/QuestionnaireForm/QuestionnaireForm.mjs +32 -32
- package/dist/esm/QuestionnaireForm/QuestionnaireForm.mjs.map +1 -1
- package/dist/esm/RangeDisplay/RangeDisplay.mjs +2 -2
- package/dist/esm/RangeDisplay/RangeDisplay.mjs.map +1 -1
- package/dist/esm/RangeInput/RangeInput.mjs +4 -4
- package/dist/esm/RangeInput/RangeInput.mjs.map +1 -1
- package/dist/esm/RatioDisplay/RatioDisplay.mjs +4 -4
- package/dist/esm/RatioDisplay/RatioDisplay.mjs.map +1 -1
- package/dist/esm/RatioInput/RatioInput.mjs +4 -4
- package/dist/esm/RatioInput/RatioInput.mjs.map +1 -1
- package/dist/esm/ReferenceDisplay/ReferenceDisplay.mjs +3 -3
- package/dist/esm/ReferenceDisplay/ReferenceDisplay.mjs.map +1 -1
- package/dist/esm/ReferenceInput/ReferenceInput.mjs +4 -4
- package/dist/esm/ReferenceInput/ReferenceInput.mjs.map +1 -1
- package/dist/esm/ReferenceRangeEditor/ReferenceRangeEditor.mjs +32 -31
- package/dist/esm/ReferenceRangeEditor/ReferenceRangeEditor.mjs.map +1 -1
- package/dist/esm/RequestGroupDisplay/RequestGroupDisplay.mjs +16 -15
- package/dist/esm/RequestGroupDisplay/RequestGroupDisplay.mjs.map +1 -1
- package/dist/esm/ResourceArrayDisplay/ResourceArrayDisplay.mjs +3 -3
- package/dist/esm/ResourceArrayDisplay/ResourceArrayDisplay.mjs.map +1 -1
- package/dist/esm/ResourceArrayInput/ResourceArrayInput.mjs +19 -18
- package/dist/esm/ResourceArrayInput/ResourceArrayInput.mjs.map +1 -1
- package/dist/esm/ResourceAvatar/ResourceAvatar.mjs +4 -4
- package/dist/esm/ResourceAvatar/ResourceAvatar.mjs.map +1 -1
- package/dist/esm/ResourceBadge/ResourceBadge.mjs +4 -4
- package/dist/esm/ResourceBadge/ResourceBadge.mjs.map +1 -1
- package/dist/esm/ResourceBlame/ResourceBlame.mjs +13 -13
- package/dist/esm/ResourceBlame/ResourceBlame.mjs.map +1 -1
- package/dist/esm/ResourceDiff/ResourceDiff.mjs +7 -7
- package/dist/esm/ResourceDiff/ResourceDiff.mjs.map +1 -1
- package/dist/esm/ResourceDiffTable/ResourceDiffTable.mjs +18 -18
- package/dist/esm/ResourceDiffTable/ResourceDiffTable.mjs.map +1 -1
- package/dist/esm/ResourceDiffTable/ResourceDiffTable.stories.d.ts +5 -0
- package/dist/esm/ResourceForm/ResourceForm.mjs +12 -12
- package/dist/esm/ResourceForm/ResourceForm.mjs.map +1 -1
- package/dist/esm/ResourceHistoryTable/ResourceHistoryTable.mjs +17 -17
- package/dist/esm/ResourceHistoryTable/ResourceHistoryTable.mjs.map +1 -1
- package/dist/esm/ResourceInput/ResourceInput.mjs +8 -8
- package/dist/esm/ResourceInput/ResourceInput.mjs.map +1 -1
- package/dist/esm/ResourceName/ResourceName.mjs +2 -2
- package/dist/esm/ResourceName/ResourceName.mjs.map +1 -1
- package/dist/esm/ResourcePropertyDisplay/ResourcePropertyDisplay.mjs +26 -26
- package/dist/esm/ResourcePropertyDisplay/ResourcePropertyDisplay.mjs.map +1 -1
- package/dist/esm/ResourcePropertyInput/ResourcePropertyInput.mjs +34 -34
- package/dist/esm/ResourcePropertyInput/ResourcePropertyInput.mjs.map +1 -1
- package/dist/esm/ResourceTable/ResourceTable.d.ts +13 -0
- package/dist/esm/ResourceTable/ResourceTable.mjs +5 -2
- package/dist/esm/ResourceTable/ResourceTable.mjs.map +1 -1
- package/dist/esm/ResourceTimeline/ResourceTimeline.d.ts +2 -2
- package/dist/esm/ResourceTimeline/ResourceTimeline.mjs +105 -76
- package/dist/esm/ResourceTimeline/ResourceTimeline.mjs.map +1 -1
- package/dist/esm/Scheduler/Scheduler.mjs +22 -22
- package/dist/esm/Scheduler/Scheduler.mjs.map +1 -1
- package/dist/esm/SearchControl/SearchControl.mjs +55 -49
- package/dist/esm/SearchControl/SearchControl.mjs.map +1 -1
- package/dist/esm/SearchControl/SearchUtils.mjs +4 -4
- package/dist/esm/SearchControl/SearchUtils.mjs.map +1 -1
- package/dist/esm/SearchFieldEditor/SearchFieldEditor.mjs +25 -25
- package/dist/esm/SearchFieldEditor/SearchFieldEditor.mjs.map +1 -1
- package/dist/esm/SearchFilterEditor/SearchFilterEditor.mjs +37 -37
- package/dist/esm/SearchFilterEditor/SearchFilterEditor.mjs.map +1 -1
- package/dist/esm/SearchFilterValueDialog/SearchFilterValueDialog.mjs +6 -6
- package/dist/esm/SearchFilterValueDialog/SearchFilterValueDialog.mjs.map +1 -1
- package/dist/esm/SearchFilterValueDisplay/SearchFilterValueDisplay.mjs +4 -4
- package/dist/esm/SearchFilterValueDisplay/SearchFilterValueDisplay.mjs.map +1 -1
- package/dist/esm/SearchFilterValueInput/SearchFilterValueInput.mjs +8 -8
- package/dist/esm/SearchFilterValueInput/SearchFilterValueInput.mjs.map +1 -1
- package/dist/esm/SearchPopupMenu/SearchPopupMenu.mjs +75 -62
- package/dist/esm/SearchPopupMenu/SearchPopupMenu.mjs.map +1 -1
- package/dist/esm/ServiceRequestTimeline/ServiceRequestTimeline.mjs +8 -8
- package/dist/esm/ServiceRequestTimeline/ServiceRequestTimeline.mjs.map +1 -1
- package/dist/esm/StatusBadge/StatusBadge.mjs +2 -2
- package/dist/esm/StatusBadge/StatusBadge.mjs.map +1 -1
- package/dist/esm/Timeline/Timeline.mjs +20 -20
- package/dist/esm/Timeline/Timeline.mjs.map +1 -1
- package/dist/esm/TimingInput/TimingInput.mjs +19 -19
- package/dist/esm/TimingInput/TimingInput.mjs.map +1 -1
- package/dist/esm/ValueSetAutocomplete/ValueSetAutocomplete.mjs +2 -2
- package/dist/esm/ValueSetAutocomplete/ValueSetAutocomplete.mjs.map +1 -1
- package/dist/esm/auth/AuthenticationForm.mjs +22 -22
- package/dist/esm/auth/AuthenticationForm.mjs.map +1 -1
- package/dist/esm/auth/ChooseProfileForm.mjs +11 -11
- package/dist/esm/auth/ChooseProfileForm.mjs.map +1 -1
- package/dist/esm/auth/ChooseScopeForm.mjs +9 -9
- package/dist/esm/auth/ChooseScopeForm.mjs.map +1 -1
- package/dist/esm/auth/MfaForm.mjs +12 -12
- package/dist/esm/auth/MfaForm.mjs.map +1 -1
- package/dist/esm/auth/NewProjectForm.mjs +12 -12
- package/dist/esm/auth/NewProjectForm.mjs.map +1 -1
- package/dist/esm/auth/NewUserForm.mjs +22 -22
- package/dist/esm/auth/NewUserForm.mjs.map +1 -1
- package/dist/esm/auth/RegisterForm.mjs +5 -5
- package/dist/esm/auth/RegisterForm.mjs.map +1 -1
- package/dist/esm/auth/SignInForm.mjs +8 -8
- package/dist/esm/auth/SignInForm.mjs.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.min.mjs +1 -1
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/createReactComponent.mjs +69 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/createReactComponent.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.mjs +18 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconAdjustmentsHorizontal.mjs +24 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconAdjustmentsHorizontal.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconAlertCircle.mjs +14 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconAlertCircle.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconBleach.mjs +18 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconBleach.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconBleachOff.mjs +19 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconBleachOff.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconBoxMultiple.mjs +25 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconBoxMultiple.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconBracketsContain.mjs +16 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconBracketsContain.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconBucket.mjs +19 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconBucket.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconBucketOff.mjs +26 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconBucketOff.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconCalendar.mjs +23 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconCalendar.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconCheck.mjs +12 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconCheck.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconCheckbox.mjs +19 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconCheckbox.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleMinus.mjs +13 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleMinus.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconCirclePlus.mjs +14 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconCirclePlus.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconCloudUpload.mjs +20 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconCloudUpload.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconColumns.mjs +19 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconColumns.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconCurrencyDollar.mjs +19 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconCurrencyDollar.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconDots.mjs +14 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconDots.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconEdit.mjs +26 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconEdit.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconEqual.mjs +13 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconEqual.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconEqualNot.mjs +14 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconEqualNot.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconFileAlert.mjs +21 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconFileAlert.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconFilePlus.mjs +21 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconFilePlus.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconFilter.mjs +18 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconFilter.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconListDetails.mjs +29 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconListDetails.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconMathGreater.mjs +12 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconMathGreater.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconMathLower.mjs +12 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconMathLower.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconMessage.mjs +20 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconMessage.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconPin.mjs +20 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconPin.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconPinnedOff.mjs +21 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconPinnedOff.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconSettings.mjs +19 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconSettings.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconSortAscending.mjs +16 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconSortAscending.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconSortDescending.mjs +16 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconSortDescending.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconSquare.mjs +18 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconSquare.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconTableExport.mjs +18 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconTableExport.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconTrash.mjs +19 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconTrash.mjs.map +1 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconX.mjs +13 -0
- package/dist/esm/node_modules/@tabler/icons-react/dist/esm/icons/IconX.mjs.map +1 -0
- package/dist/esm/useResource/useResource.d.ts +2 -2
- package/dist/esm/useResource/useResource.mjs +62 -42
- package/dist/esm/useResource/useResource.mjs.map +1 -1
- package/dist/esm/utils/date.d.ts +2 -1
- package/dist/esm/utils/date.mjs +31 -25
- package/dist/esm/utils/date.mjs.map +1 -1
- package/icons-unique.txt +36 -0
- package/icons.txt +44 -0
- package/package.json +6 -6
- package/dist/esm/node_modules/@tabler/icons/icons-react/dist/index.esm.mjs +0 -6
- package/dist/esm/node_modules/@tabler/icons/icons-react/dist/index.esm.mjs.map +0 -1
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { createStyles, Center, Loader, Group, TextInput, ActionIcon, ScrollArea, Menu } from '@mantine/core';
|
|
2
2
|
import { updateNotification, showNotification } from '@mantine/notifications';
|
|
3
3
|
import { normalizeErrorString, getReferenceString } from '@medplum/core';
|
|
4
|
-
import
|
|
5
|
-
import e__default, { useRef, useState, useCallback, useEffect } from 'react';
|
|
4
|
+
import React, { useRef, useState, useCallback, useEffect } from 'react';
|
|
6
5
|
import { AttachmentButton } from '../AttachmentButton/AttachmentButton.mjs';
|
|
7
6
|
import { AttachmentDisplay } from '../AttachmentDisplay/AttachmentDisplay.mjs';
|
|
8
7
|
import { DiagnosticReportDisplay } from '../DiagnosticReportDisplay/DiagnosticReportDisplay.mjs';
|
|
@@ -15,6 +14,15 @@ import { ResourceTable } from '../ResourceTable/ResourceTable.mjs';
|
|
|
15
14
|
import { Timeline, TimelineItem } from '../Timeline/Timeline.mjs';
|
|
16
15
|
import { useResource } from '../useResource/useResource.mjs';
|
|
17
16
|
import { sortByDateAndPriority } from '../utils/date.mjs';
|
|
17
|
+
import IconMessage from '../node_modules/@tabler/icons-react/dist/esm/icons/IconMessage.mjs';
|
|
18
|
+
import IconCloudUpload from '../node_modules/@tabler/icons-react/dist/esm/icons/IconCloudUpload.mjs';
|
|
19
|
+
import IconCheck from '../node_modules/@tabler/icons-react/dist/esm/icons/IconCheck.mjs';
|
|
20
|
+
import IconFileAlert from '../node_modules/@tabler/icons-react/dist/esm/icons/IconFileAlert.mjs';
|
|
21
|
+
import IconPin from '../node_modules/@tabler/icons-react/dist/esm/icons/IconPin.mjs';
|
|
22
|
+
import IconPinnedOff from '../node_modules/@tabler/icons-react/dist/esm/icons/IconPinnedOff.mjs';
|
|
23
|
+
import IconListDetails from '../node_modules/@tabler/icons-react/dist/esm/icons/IconListDetails.mjs';
|
|
24
|
+
import IconEdit from '../node_modules/@tabler/icons-react/dist/esm/icons/IconEdit.mjs';
|
|
25
|
+
import IconTrash from '../node_modules/@tabler/icons-react/dist/esm/icons/IconTrash.mjs';
|
|
18
26
|
|
|
19
27
|
const useStyles = createStyles((theme) => ({
|
|
20
28
|
pinnedComment: {
|
|
@@ -32,28 +40,38 @@ function ResourceTimeline(props) {
|
|
|
32
40
|
const loadTimelineResources = props.loadTimelineResources;
|
|
33
41
|
const itemsRef = useRef(items);
|
|
34
42
|
itemsRef.current = items;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Sorts and sets the items.
|
|
45
|
+
*
|
|
46
|
+
* Sorting is primarily a function of meta.lastUpdated, but there are special cases.
|
|
47
|
+
* When displaying connected resources, for example a Communication in the context of an Encounter,
|
|
48
|
+
* the Communication.sent time is used rather than Communication.meta.lastUpdated.
|
|
49
|
+
*
|
|
50
|
+
* Other examples of special cases:
|
|
51
|
+
* - DiagnosticReport.issued
|
|
52
|
+
* - Media.issued
|
|
53
|
+
* - Observation.issued
|
|
54
|
+
* - DocumentReference.date
|
|
55
|
+
*
|
|
56
|
+
* See "sortByDateAndPriority()" for more details.
|
|
57
|
+
*/
|
|
58
|
+
const sortAndSetItems = useCallback((newItmes) => {
|
|
59
|
+
sortByDateAndPriority(newItmes, resource);
|
|
60
|
+
newItmes.reverse();
|
|
61
|
+
setItems(newItmes);
|
|
62
|
+
}, [resource]);
|
|
46
63
|
/**
|
|
47
64
|
* Handles a batch request response.
|
|
48
65
|
* @param batchResponse The batch response.
|
|
49
66
|
*/
|
|
50
|
-
|
|
67
|
+
const handleBatchResponse = useCallback((batchResponse) => {
|
|
51
68
|
const newItems = [];
|
|
52
|
-
for (const
|
|
53
|
-
if (
|
|
69
|
+
for (const settledResult of batchResponse) {
|
|
70
|
+
if (settledResult.status !== 'fulfilled') {
|
|
54
71
|
// User may not have access to all resource types
|
|
55
72
|
continue;
|
|
56
73
|
}
|
|
74
|
+
const bundle = settledResult.value;
|
|
57
75
|
if (bundle.type === 'history') {
|
|
58
76
|
setHistory(bundle);
|
|
59
77
|
}
|
|
@@ -63,20 +81,29 @@ function ResourceTimeline(props) {
|
|
|
63
81
|
}
|
|
64
82
|
}
|
|
65
83
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
setItems(newItems);
|
|
69
|
-
}
|
|
84
|
+
sortAndSetItems(newItems);
|
|
85
|
+
}, [sortAndSetItems]);
|
|
70
86
|
/**
|
|
71
87
|
* Adds an array of resources to the timeline.
|
|
72
|
-
* @param
|
|
88
|
+
* @param resource Resource to add.
|
|
73
89
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
90
|
+
const addResource = useCallback((resource) => sortAndSetItems([...itemsRef.current, resource]), [sortAndSetItems]);
|
|
91
|
+
/**
|
|
92
|
+
* Loads the timeline.
|
|
93
|
+
*/
|
|
94
|
+
const loadTimeline = useCallback(() => {
|
|
95
|
+
let resourceType;
|
|
96
|
+
let id;
|
|
97
|
+
if ('resourceType' in props.value) {
|
|
98
|
+
resourceType = props.value.resourceType;
|
|
99
|
+
id = props.value.id;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
[resourceType, id] = props.value.reference?.split('/');
|
|
103
|
+
}
|
|
104
|
+
loadTimelineResources(medplum, resourceType, id).then(handleBatchResponse).catch(console.log);
|
|
105
|
+
}, [medplum, props.value, loadTimelineResources, handleBatchResponse]);
|
|
106
|
+
useEffect(() => loadTimeline(), [loadTimeline]);
|
|
80
107
|
/**
|
|
81
108
|
* Adds a Communication resource to the timeline.
|
|
82
109
|
* @param contentString The comment content.
|
|
@@ -88,9 +115,7 @@ function ResourceTimeline(props) {
|
|
|
88
115
|
}
|
|
89
116
|
medplum
|
|
90
117
|
.createResource(props.createCommunication(resource, sender, contentString))
|
|
91
|
-
.then((result) =>
|
|
92
|
-
addResources([result]);
|
|
93
|
-
})
|
|
118
|
+
.then((result) => addResource(result))
|
|
94
119
|
.catch(console.log);
|
|
95
120
|
}
|
|
96
121
|
/**
|
|
@@ -104,13 +129,13 @@ function ResourceTimeline(props) {
|
|
|
104
129
|
}
|
|
105
130
|
medplum
|
|
106
131
|
.createResource(props.createMedia(resource, sender, attachment))
|
|
107
|
-
.then((result) =>
|
|
132
|
+
.then((result) => addResource(result))
|
|
108
133
|
.then(() => updateNotification({
|
|
109
134
|
id: 'upload-notification',
|
|
110
135
|
color: 'teal',
|
|
111
136
|
title: 'Upload complete',
|
|
112
137
|
message: '',
|
|
113
|
-
icon:
|
|
138
|
+
icon: React.createElement(IconCheck, { size: 16 }),
|
|
114
139
|
autoClose: 2000,
|
|
115
140
|
}))
|
|
116
141
|
.catch((reason) => updateNotification({
|
|
@@ -118,7 +143,7 @@ function ResourceTimeline(props) {
|
|
|
118
143
|
color: 'red',
|
|
119
144
|
title: 'Upload error',
|
|
120
145
|
message: normalizeErrorString(reason),
|
|
121
|
-
icon:
|
|
146
|
+
icon: React.createElement(IconFileAlert, { size: 16 }),
|
|
122
147
|
autoClose: 2000,
|
|
123
148
|
}));
|
|
124
149
|
}
|
|
@@ -164,12 +189,12 @@ function ResourceTimeline(props) {
|
|
|
164
189
|
});
|
|
165
190
|
}
|
|
166
191
|
if (!resource) {
|
|
167
|
-
return (
|
|
168
|
-
|
|
192
|
+
return (React.createElement(Center, { style: { width: '100%', height: '100%' } },
|
|
193
|
+
React.createElement(Loader, null)));
|
|
169
194
|
}
|
|
170
|
-
return (
|
|
171
|
-
props.createCommunication && (
|
|
172
|
-
|
|
195
|
+
return (React.createElement(Timeline, null,
|
|
196
|
+
props.createCommunication && (React.createElement(Panel, null,
|
|
197
|
+
React.createElement(Form, { testid: "timeline-form", onSubmit: (formData) => {
|
|
173
198
|
createComment(formData.text);
|
|
174
199
|
const input = inputRef.current;
|
|
175
200
|
if (input) {
|
|
@@ -177,55 +202,59 @@ function ResourceTimeline(props) {
|
|
|
177
202
|
input.focus();
|
|
178
203
|
}
|
|
179
204
|
} },
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
205
|
+
React.createElement(Group, { spacing: "xs", noWrap: true, style: { width: '100%' } },
|
|
206
|
+
React.createElement(ResourceAvatar, { value: sender }),
|
|
207
|
+
React.createElement(TextInput, { name: "text", ref: inputRef, placeholder: "Add comment", style: { width: '100%', maxWidth: 300 } }),
|
|
208
|
+
React.createElement(ActionIcon, { type: "submit", radius: "xl", color: "blue", variant: "filled" },
|
|
209
|
+
React.createElement(IconMessage, { size: 16 })),
|
|
210
|
+
React.createElement(AttachmentButton, { onUpload: createMedia, onUploadStart: onUploadStart, onUploadProgress: onUploadProgress }, (props) => (React.createElement(ActionIcon, { ...props, radius: "xl", color: "blue", variant: "filled" },
|
|
211
|
+
React.createElement(IconCloudUpload, { size: 16 })))))))),
|
|
187
212
|
items.map((item) => {
|
|
213
|
+
if (!item) {
|
|
214
|
+
// TODO: Handle null history items for deleted versions.
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
188
217
|
const key = `${item.resourceType}/${item.id}/${item.meta?.versionId}`;
|
|
189
218
|
if (item.resourceType === resource.resourceType && item.id === resource.id) {
|
|
190
|
-
return (
|
|
219
|
+
return (React.createElement(HistoryTimelineItem, { key: key, history: history, resource: item, onDetails: onVersionDetails }));
|
|
191
220
|
}
|
|
192
221
|
switch (item.resourceType) {
|
|
193
222
|
case 'AuditEvent':
|
|
194
|
-
return
|
|
223
|
+
return React.createElement(AuditEventTimelineItem, { key: key, resource: item, onDetails: onDetails });
|
|
195
224
|
case 'Communication':
|
|
196
|
-
return (
|
|
225
|
+
return (React.createElement(CommunicationTimelineItem, { key: key, resource: item, onPin: item.priority !== 'stat' ? onPin : undefined, onUnpin: item.priority === 'stat' ? onUnpin : undefined, onDetails: onDetails, onEdit: onEdit, onDelete: onDelete }));
|
|
197
226
|
case 'DiagnosticReport':
|
|
198
|
-
return (
|
|
227
|
+
return (React.createElement(DiagnosticReportTimelineItem, { key: key, resource: item, onDetails: onDetails, onEdit: onEdit, onDelete: onDelete }));
|
|
199
228
|
case 'Media':
|
|
200
|
-
return (
|
|
229
|
+
return (React.createElement(MediaTimelineItem, { key: key, resource: item, onDetails: onDetails, onEdit: onEdit, onDelete: onDelete }));
|
|
201
230
|
default:
|
|
202
|
-
return (
|
|
203
|
-
|
|
231
|
+
return (React.createElement(TimelineItem, { key: key, resource: item, padding: true },
|
|
232
|
+
React.createElement(ResourceTable, { value: item, ignoreMissingValues: true })));
|
|
204
233
|
}
|
|
205
234
|
})));
|
|
206
235
|
}
|
|
207
236
|
function TimelineItemPopupMenu(props) {
|
|
208
|
-
return (
|
|
209
|
-
|
|
210
|
-
props.onPin && (
|
|
211
|
-
props.onUnpin && (
|
|
212
|
-
props.onDetails && (
|
|
213
|
-
props.onEdit && (
|
|
214
|
-
props.onDelete && (
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
237
|
+
return (React.createElement(Menu.Dropdown, null,
|
|
238
|
+
React.createElement(Menu.Label, null, "Resource"),
|
|
239
|
+
props.onPin && (React.createElement(Menu.Item, { icon: React.createElement(IconPin, { size: 14 }), onClick: () => props.onPin(props.resource), "aria-label": `Pin ${getReferenceString(props.resource)}` }, "Pin")),
|
|
240
|
+
props.onUnpin && (React.createElement(Menu.Item, { icon: React.createElement(IconPinnedOff, { size: 14 }), onClick: () => props.onUnpin(props.resource), "aria-label": `Unpin ${getReferenceString(props.resource)}` }, "Unpin")),
|
|
241
|
+
props.onDetails && (React.createElement(Menu.Item, { icon: React.createElement(IconListDetails, { size: 14 }), onClick: () => props.onDetails(props.resource), "aria-label": `Details ${getReferenceString(props.resource)}` }, "Details")),
|
|
242
|
+
props.onEdit && (React.createElement(Menu.Item, { icon: React.createElement(IconEdit, { size: 14 }), onClick: () => props.onEdit(props.resource), "aria-label": `Edit ${getReferenceString(props.resource)}` }, "Edit")),
|
|
243
|
+
props.onDelete && (React.createElement(React.Fragment, null,
|
|
244
|
+
React.createElement(Menu.Divider, null),
|
|
245
|
+
React.createElement(Menu.Label, null, "Danger zone"),
|
|
246
|
+
React.createElement(Menu.Item, { color: "red", icon: React.createElement(IconTrash, { size: 14 }), onClick: () => props.onDelete(props.resource), "aria-label": `Delete ${getReferenceString(props.resource)}` }, "Delete")))));
|
|
218
247
|
}
|
|
219
248
|
function HistoryTimelineItem(props) {
|
|
220
249
|
const previous = getPrevious(props.history, props.resource);
|
|
221
250
|
if (previous) {
|
|
222
|
-
return (
|
|
223
|
-
|
|
251
|
+
return (React.createElement(TimelineItem, { resource: props.resource, padding: true, popupMenuItems: React.createElement(TimelineItemPopupMenu, { ...props }) },
|
|
252
|
+
React.createElement(ResourceDiffTable, { original: previous, revised: props.resource })));
|
|
224
253
|
}
|
|
225
254
|
else {
|
|
226
|
-
return (
|
|
227
|
-
|
|
228
|
-
|
|
255
|
+
return (React.createElement(TimelineItem, { resource: props.resource, padding: true, popupMenuItems: React.createElement(TimelineItemPopupMenu, { ...props }) },
|
|
256
|
+
React.createElement("h3", null, "Created"),
|
|
257
|
+
React.createElement(ResourceTable, { value: props.resource, ignoreMissingValues: true, forceUseInput: true })));
|
|
229
258
|
}
|
|
230
259
|
}
|
|
231
260
|
function getPrevious(history, version) {
|
|
@@ -240,8 +269,8 @@ function CommunicationTimelineItem(props) {
|
|
|
240
269
|
const { classes } = useStyles();
|
|
241
270
|
const routine = !props.resource.priority || props.resource.priority === 'routine';
|
|
242
271
|
const className = routine ? undefined : classes.pinnedComment;
|
|
243
|
-
return (
|
|
244
|
-
|
|
272
|
+
return (React.createElement(TimelineItem, { resource: props.resource, profile: props.resource.sender, padding: true, className: className, popupMenuItems: React.createElement(TimelineItemPopupMenu, { ...props }) },
|
|
273
|
+
React.createElement("p", null, props.resource.payload?.[0]?.contentString)));
|
|
245
274
|
}
|
|
246
275
|
function MediaTimelineItem(props) {
|
|
247
276
|
const contentType = props.resource.content?.contentType;
|
|
@@ -249,17 +278,17 @@ function MediaTimelineItem(props) {
|
|
|
249
278
|
!contentType.startsWith('image/') &&
|
|
250
279
|
!contentType.startsWith('video/') &&
|
|
251
280
|
contentType !== 'application/pdf';
|
|
252
|
-
return (
|
|
253
|
-
|
|
281
|
+
return (React.createElement(TimelineItem, { resource: props.resource, padding: !!padding, popupMenuItems: React.createElement(TimelineItemPopupMenu, { ...props }) },
|
|
282
|
+
React.createElement(AttachmentDisplay, { value: props.resource.content })));
|
|
254
283
|
}
|
|
255
284
|
function AuditEventTimelineItem(props) {
|
|
256
|
-
return (
|
|
257
|
-
|
|
258
|
-
|
|
285
|
+
return (React.createElement(TimelineItem, { resource: props.resource, padding: true, popupMenuItems: React.createElement(TimelineItemPopupMenu, { ...props }) },
|
|
286
|
+
React.createElement(ScrollArea, null,
|
|
287
|
+
React.createElement("pre", null, props.resource.outcomeDesc))));
|
|
259
288
|
}
|
|
260
289
|
function DiagnosticReportTimelineItem(props) {
|
|
261
|
-
return (
|
|
262
|
-
|
|
290
|
+
return (React.createElement(TimelineItem, { resource: props.resource, padding: true, popupMenuItems: React.createElement(TimelineItemPopupMenu, { ...props }) },
|
|
291
|
+
React.createElement(DiagnosticReportDisplay, { value: props.resource })));
|
|
263
292
|
}
|
|
264
293
|
function getProgressMessage(e) {
|
|
265
294
|
if (e.lengthComputable) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceTimeline.mjs","sources":["../../../src/ResourceTimeline/ResourceTimeline.tsx"],"sourcesContent":["import { ActionIcon, Center, createStyles, Group, Loader, Menu, ScrollArea, TextInput } from '@mantine/core';\nimport { showNotification, updateNotification } from '@mantine/notifications';\nimport { getReferenceString, MedplumClient, normalizeErrorString, ProfileResource } from '@medplum/core';\nimport {\n Attachment,\n AuditEvent,\n Bundle,\n BundleEntry,\n Communication,\n DiagnosticReport,\n Media,\n Reference,\n Resource,\n} from '@medplum/fhirtypes';\nimport {\n IconCheck,\n IconCloudUpload,\n IconEdit,\n IconFileAlert,\n IconListDetails,\n IconMessage,\n IconPin,\n IconPinnedOff,\n IconTrash,\n} from '@tabler/icons';\nimport React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { AttachmentButton } from '../AttachmentButton/AttachmentButton';\nimport { AttachmentDisplay } from '../AttachmentDisplay/AttachmentDisplay';\nimport { DiagnosticReportDisplay } from '../DiagnosticReportDisplay/DiagnosticReportDisplay';\nimport { Form } from '../Form/Form';\nimport { useMedplum, useMedplumNavigate } from '../MedplumProvider/MedplumProvider';\nimport { Panel } from '../Panel/Panel';\nimport { ResourceAvatar } from '../ResourceAvatar/ResourceAvatar';\nimport { ResourceDiffTable } from '../ResourceDiffTable/ResourceDiffTable';\nimport { ResourceTable } from '../ResourceTable/ResourceTable';\nimport { Timeline, TimelineItem } from '../Timeline/Timeline';\nimport { useResource } from '../useResource/useResource';\nimport { sortByDateAndPriority } from '../utils/date';\n\nconst useStyles = createStyles((theme) => ({\n pinnedComment: {\n backgroundColor: theme.colors.blue[0],\n },\n}));\n\nexport interface ResourceTimelineProps<T extends Resource> {\n value: T | Reference<T>;\n loadTimelineResources: (medplum: MedplumClient, resource: T) => Promise<Bundle[]>;\n createCommunication?: (resource: T, sender: ProfileResource, text: string) => Communication;\n createMedia?: (resource: T, operator: ProfileResource, attachment: Attachment) => Media;\n}\n\nexport function ResourceTimeline<T extends Resource>(props: ResourceTimelineProps<T>): JSX.Element {\n const medplum = useMedplum();\n const navigate = useMedplumNavigate();\n const sender = medplum.getProfile() as ProfileResource;\n const inputRef = useRef<HTMLInputElement>(null);\n const resource = useResource(props.value);\n const [history, setHistory] = useState<Bundle>();\n const [items, setItems] = useState<Resource[]>([]);\n const loadTimelineResources = props.loadTimelineResources;\n\n const itemsRef = useRef<Resource[]>(items);\n itemsRef.current = items;\n\n const loadTimeline = useCallback(() => {\n if (!resource) {\n setItems([]);\n setHistory({} as Bundle);\n return;\n }\n loadTimelineResources(medplum, resource).then(handleBatchResponse).catch(console.log);\n }, [medplum, resource, loadTimelineResources]);\n\n useEffect(() => {\n loadTimeline();\n }, [loadTimeline]);\n\n /**\n * Handles a batch request response.\n * @param batchResponse The batch response.\n */\n function handleBatchResponse(bundles: Bundle[]): void {\n const newItems = [];\n\n for (const bundle of bundles) {\n if (!bundle) {\n // User may not have access to all resource types\n continue;\n }\n\n if (bundle.type === 'history') {\n setHistory(bundle);\n }\n\n if (bundle.entry) {\n for (const entry of bundle.entry) {\n newItems.push(entry.resource as Resource);\n }\n }\n }\n\n sortByDateAndPriority(newItems);\n newItems.reverse();\n setItems(newItems);\n }\n\n /**\n * Adds an array of resources to the timeline.\n * @param resources Array of resources.\n */\n function addResources(resources: Resource[]): void {\n const newItems = [...itemsRef.current, ...resources];\n sortByDateAndPriority(newItems);\n newItems.reverse();\n setItems(newItems);\n }\n\n /**\n * Adds a Communication resource to the timeline.\n * @param contentString The comment content.\n */\n function createComment(contentString: string): void {\n if (!resource || !props.createCommunication) {\n // Encounter not loaded yet\n return;\n }\n medplum\n .createResource(props.createCommunication(resource, sender, contentString))\n .then((result) => {\n addResources([result]);\n })\n .catch(console.log);\n }\n\n /**\n * Adds a Media resource to the timeline.\n * @param attachment The media attachment.\n */\n function createMedia(attachment: Attachment): void {\n if (!resource || !props.createMedia) {\n // Encounter not loaded yet\n return;\n }\n medplum\n .createResource(props.createMedia(resource, sender, attachment))\n .then((result) => addResources([result]))\n .then(() =>\n updateNotification({\n id: 'upload-notification',\n color: 'teal',\n title: 'Upload complete',\n message: '',\n icon: <IconCheck size={16} />,\n autoClose: 2000,\n })\n )\n .catch((reason) =>\n updateNotification({\n id: 'upload-notification',\n color: 'red',\n title: 'Upload error',\n message: normalizeErrorString(reason),\n icon: <IconFileAlert size={16} />,\n autoClose: 2000,\n })\n );\n }\n\n function setPriority(\n communication: Communication,\n priority: 'routine' | 'urgent' | 'asap' | 'stat'\n ): Promise<Communication> {\n return medplum.updateResource({ ...communication, priority });\n }\n\n function onPin(communication: Communication): void {\n setPriority(communication, 'stat').then(loadTimeline).catch(console.log);\n }\n\n function onUnpin(communication: Communication): void {\n setPriority(communication, 'routine').then(loadTimeline).catch(console.log);\n }\n\n function onDetails(timelineItem: Resource): void {\n navigate(`/${timelineItem.resourceType}/${timelineItem.id}`);\n }\n\n function onEdit(timelineItem: Resource): void {\n navigate(`/${timelineItem.resourceType}/${timelineItem.id}/edit`);\n }\n\n function onDelete(timelineItem: Resource): void {\n navigate(`/${timelineItem.resourceType}/${timelineItem.id}/delete`);\n }\n\n function onVersionDetails(version: Resource): void {\n navigate(`/${version.resourceType}/${version.id}/_history/${version.meta?.versionId}`);\n }\n\n function onUploadStart(): void {\n showNotification({\n id: 'upload-notification',\n loading: true,\n title: 'Initializing upload...',\n message: 'Please wait...',\n autoClose: false,\n disallowClose: true,\n });\n }\n\n function onUploadProgress(e: ProgressEvent): void {\n updateNotification({\n id: 'upload-notification',\n loading: true,\n title: 'Uploading...',\n message: getProgressMessage(e),\n autoClose: false,\n disallowClose: true,\n });\n }\n\n if (!resource) {\n return (\n <Center style={{ width: '100%', height: '100%' }}>\n <Loader />\n </Center>\n );\n }\n\n return (\n <Timeline>\n {props.createCommunication && (\n <Panel>\n <Form\n testid=\"timeline-form\"\n onSubmit={(formData: Record<string, string>) => {\n createComment(formData.text);\n\n const input = inputRef.current;\n if (input) {\n input.value = '';\n input.focus();\n }\n }}\n >\n <Group spacing=\"xs\" noWrap style={{ width: '100%' }}>\n <ResourceAvatar value={sender} />\n <TextInput\n name=\"text\"\n ref={inputRef}\n placeholder=\"Add comment\"\n style={{ width: '100%', maxWidth: 300 }}\n />\n <ActionIcon type=\"submit\" radius=\"xl\" color=\"blue\" variant=\"filled\">\n <IconMessage size={16} />\n </ActionIcon>\n <AttachmentButton\n onUpload={createMedia}\n onUploadStart={onUploadStart}\n onUploadProgress={onUploadProgress}\n >\n {(props) => (\n <ActionIcon {...props} radius=\"xl\" color=\"blue\" variant=\"filled\">\n <IconCloudUpload size={16} />\n </ActionIcon>\n )}\n </AttachmentButton>\n </Group>\n </Form>\n </Panel>\n )}\n {items.map((item) => {\n const key = `${item.resourceType}/${item.id}/${item.meta?.versionId}`;\n if (item.resourceType === resource.resourceType && item.id === resource.id) {\n return (\n <HistoryTimelineItem\n key={key}\n history={history as Bundle<Resource>}\n resource={item}\n onDetails={onVersionDetails}\n />\n );\n }\n switch (item.resourceType) {\n case 'AuditEvent':\n return <AuditEventTimelineItem key={key} resource={item} onDetails={onDetails} />;\n case 'Communication':\n return (\n <CommunicationTimelineItem\n key={key}\n resource={item}\n onPin={item.priority !== 'stat' ? onPin : undefined}\n onUnpin={item.priority === 'stat' ? onUnpin : undefined}\n onDetails={onDetails}\n onEdit={onEdit}\n onDelete={onDelete}\n />\n );\n case 'DiagnosticReport':\n return (\n <DiagnosticReportTimelineItem\n key={key}\n resource={item}\n onDetails={onDetails}\n onEdit={onEdit}\n onDelete={onDelete}\n />\n );\n case 'Media':\n return (\n <MediaTimelineItem key={key} resource={item} onDetails={onDetails} onEdit={onEdit} onDelete={onDelete} />\n );\n default:\n return (\n <TimelineItem key={key} resource={item} padding={true}>\n <ResourceTable value={item} ignoreMissingValues={true} />\n </TimelineItem>\n );\n }\n })}\n </Timeline>\n );\n}\n\ninterface BaseTimelineItemProps<T extends Resource> {\n resource: T;\n onPin?: (resource: T) => void;\n onUnpin?: (resource: T) => void;\n onDetails?: (resource: T) => void;\n onEdit?: (resource: T) => void;\n onDelete?: (resource: T) => void;\n}\n\nfunction TimelineItemPopupMenu<T extends Resource>(props: BaseTimelineItemProps<T>): JSX.Element {\n return (\n <Menu.Dropdown>\n <Menu.Label>Resource</Menu.Label>\n {props.onPin && (\n <Menu.Item\n icon={<IconPin size={14} />}\n onClick={() => (props.onPin as (resource: T) => void)(props.resource)}\n aria-label={`Pin ${getReferenceString(props.resource)}`}\n >\n Pin\n </Menu.Item>\n )}\n {props.onUnpin && (\n <Menu.Item\n icon={<IconPinnedOff size={14} />}\n onClick={() => (props.onUnpin as (resource: T) => void)(props.resource)}\n aria-label={`Unpin ${getReferenceString(props.resource)}`}\n >\n Unpin\n </Menu.Item>\n )}\n {props.onDetails && (\n <Menu.Item\n icon={<IconListDetails size={14} />}\n onClick={() => (props.onDetails as (resource: T) => void)(props.resource)}\n aria-label={`Details ${getReferenceString(props.resource)}`}\n >\n Details\n </Menu.Item>\n )}\n {props.onEdit && (\n <Menu.Item\n icon={<IconEdit size={14} />}\n onClick={() => (props.onEdit as (resource: T) => void)(props.resource)}\n aria-label={`Edit ${getReferenceString(props.resource)}`}\n >\n Edit\n </Menu.Item>\n )}\n {props.onDelete && (\n <>\n <Menu.Divider />\n <Menu.Label>Danger zone</Menu.Label>\n <Menu.Item\n color=\"red\"\n icon={<IconTrash size={14} />}\n onClick={() => (props.onDelete as (resource: T) => void)(props.resource)}\n aria-label={`Delete ${getReferenceString(props.resource)}`}\n >\n Delete\n </Menu.Item>\n </>\n )}\n </Menu.Dropdown>\n );\n}\n\ninterface HistoryTimelineItemProps extends BaseTimelineItemProps<Resource> {\n history: Bundle;\n}\n\nfunction HistoryTimelineItem(props: HistoryTimelineItemProps): JSX.Element {\n const previous = getPrevious(props.history, props.resource);\n if (previous) {\n return (\n <TimelineItem resource={props.resource} padding={true} popupMenuItems={<TimelineItemPopupMenu {...props} />}>\n <ResourceDiffTable original={previous} revised={props.resource} />\n </TimelineItem>\n );\n } else {\n return (\n <TimelineItem resource={props.resource} padding={true} popupMenuItems={<TimelineItemPopupMenu {...props} />}>\n <h3>Created</h3>\n <ResourceTable value={props.resource} ignoreMissingValues={true} />\n </TimelineItem>\n );\n }\n}\n\nfunction getPrevious(history: Bundle, version: Resource): Resource | undefined {\n const entries = history.entry as BundleEntry[];\n const index = entries.findIndex((entry) => entry.resource?.meta?.versionId === version.meta?.versionId);\n if (index >= entries.length - 1) {\n return undefined;\n }\n return entries[index + 1].resource;\n}\n\nfunction CommunicationTimelineItem(props: BaseTimelineItemProps<Communication>): JSX.Element {\n const { classes } = useStyles();\n const routine = !props.resource.priority || props.resource.priority === 'routine';\n const className = routine ? undefined : classes.pinnedComment;\n return (\n <TimelineItem\n resource={props.resource}\n profile={props.resource.sender}\n padding={true}\n className={className}\n popupMenuItems={<TimelineItemPopupMenu {...props} />}\n >\n <p>{props.resource.payload?.[0]?.contentString}</p>\n </TimelineItem>\n );\n}\n\nfunction MediaTimelineItem(props: BaseTimelineItemProps<Media>): JSX.Element {\n const contentType = props.resource.content?.contentType;\n const padding =\n contentType &&\n !contentType.startsWith('image/') &&\n !contentType.startsWith('video/') &&\n contentType !== 'application/pdf';\n return (\n <TimelineItem resource={props.resource} padding={!!padding} popupMenuItems={<TimelineItemPopupMenu {...props} />}>\n <AttachmentDisplay value={props.resource.content} />\n </TimelineItem>\n );\n}\n\nfunction AuditEventTimelineItem(props: BaseTimelineItemProps<AuditEvent>): JSX.Element {\n return (\n <TimelineItem resource={props.resource} padding={true} popupMenuItems={<TimelineItemPopupMenu {...props} />}>\n <ScrollArea>\n <pre>{props.resource.outcomeDesc}</pre>\n </ScrollArea>\n </TimelineItem>\n );\n}\n\nfunction DiagnosticReportTimelineItem(props: BaseTimelineItemProps<DiagnosticReport>): JSX.Element {\n return (\n <TimelineItem resource={props.resource} padding={true} popupMenuItems={<TimelineItemPopupMenu {...props} />}>\n <DiagnosticReportDisplay value={props.resource} />\n </TimelineItem>\n );\n}\n\nfunction getProgressMessage(e: ProgressEvent): string {\n if (e.lengthComputable) {\n const percent = (100 * e.loaded) / e.total;\n return `Uploaded: ${formatFileSize(e.loaded)} / ${formatFileSize(e.total)} ${percent.toFixed(2)}%`;\n }\n return `Uploaded: ${formatFileSize(e.loaded)}`;\n}\n\nfunction formatFileSize(bytes: number): string {\n if (bytes == 0) {\n return '0.00 B';\n }\n const e = Math.floor(Math.log(bytes) / Math.log(1024));\n return (bytes / Math.pow(1024, e)).toFixed(2) + ' ' + ' KMGTP'.charAt(e) + 'B';\n}\n"],"names":["React","IconCheck","IconFileAlert","IconMessage","IconCloudUpload","IconPin","IconPinnedOff","IconListDetails","IconEdit","IconTrash"],"mappings":";;;;;;;;;;;;;;;;;;AAuCA,MAAM,SAAS,GAAG,YAAY,CAAC,CAAC,KAAK,MAAM;AACzC,IAAA,aAAa,EAAE;QACb,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACtC,KAAA;AACF,CAAA,CAAC,CAAC,CAAC;AASE,SAAU,gBAAgB,CAAqB,KAA+B,EAAA;AAClF,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;AAC7B,IAAA,MAAM,QAAQ,GAAG,kBAAkB,EAAE,CAAC;AACtC,IAAA,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,EAAqB,CAAC;AACvD,IAAA,MA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AAI,CAAC,CAAC,CAAC;AACvD,IAAA,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;AACjF;;;;"}
|
|
1
|
+
{"version":3,"file":"ResourceTimeline.mjs","sources":["../../../src/ResourceTimeline/ResourceTimeline.tsx"],"sourcesContent":["import { ActionIcon, Center, createStyles, Group, Loader, Menu, ScrollArea, TextInput } from '@mantine/core';\nimport { showNotification, updateNotification } from '@mantine/notifications';\nimport { getReferenceString, MedplumClient, normalizeErrorString, ProfileResource } from '@medplum/core';\nimport {\n Attachment,\n AuditEvent,\n Bundle,\n BundleEntry,\n Communication,\n DiagnosticReport,\n Media,\n Reference,\n Resource,\n ResourceType,\n} from '@medplum/fhirtypes';\nimport {\n IconCheck,\n IconCloudUpload,\n IconEdit,\n IconFileAlert,\n IconListDetails,\n IconMessage,\n IconPin,\n IconPinnedOff,\n IconTrash,\n} from '@tabler/icons-react';\nimport React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { AttachmentButton } from '../AttachmentButton/AttachmentButton';\nimport { AttachmentDisplay } from '../AttachmentDisplay/AttachmentDisplay';\nimport { DiagnosticReportDisplay } from '../DiagnosticReportDisplay/DiagnosticReportDisplay';\nimport { Form } from '../Form/Form';\nimport { useMedplum, useMedplumNavigate } from '../MedplumProvider/MedplumProvider';\nimport { Panel } from '../Panel/Panel';\nimport { ResourceAvatar } from '../ResourceAvatar/ResourceAvatar';\nimport { ResourceDiffTable } from '../ResourceDiffTable/ResourceDiffTable';\nimport { ResourceTable } from '../ResourceTable/ResourceTable';\nimport { Timeline, TimelineItem } from '../Timeline/Timeline';\nimport { useResource } from '../useResource/useResource';\nimport { sortByDateAndPriority } from '../utils/date';\n\nconst useStyles = createStyles((theme) => ({\n pinnedComment: {\n backgroundColor: theme.colors.blue[0],\n },\n}));\n\nexport interface ResourceTimelineProps<T extends Resource> {\n value: T | Reference<T>;\n loadTimelineResources: (\n medplum: MedplumClient,\n resourceType: ResourceType,\n id: string\n ) => Promise<PromiseSettledResult<Bundle>[]>;\n createCommunication?: (resource: T, sender: ProfileResource, text: string) => Communication;\n createMedia?: (resource: T, operator: ProfileResource, attachment: Attachment) => Media;\n}\n\nexport function ResourceTimeline<T extends Resource>(props: ResourceTimelineProps<T>): JSX.Element {\n const medplum = useMedplum();\n const navigate = useMedplumNavigate();\n const sender = medplum.getProfile() as ProfileResource;\n const inputRef = useRef<HTMLInputElement>(null);\n const resource = useResource(props.value);\n const [history, setHistory] = useState<Bundle>();\n const [items, setItems] = useState<Resource[]>([]);\n const loadTimelineResources = props.loadTimelineResources;\n\n const itemsRef = useRef<Resource[]>(items);\n itemsRef.current = items;\n\n /**\n * Sorts and sets the items.\n *\n * Sorting is primarily a function of meta.lastUpdated, but there are special cases.\n * When displaying connected resources, for example a Communication in the context of an Encounter,\n * the Communication.sent time is used rather than Communication.meta.lastUpdated.\n *\n * Other examples of special cases:\n * - DiagnosticReport.issued\n * - Media.issued\n * - Observation.issued\n * - DocumentReference.date\n *\n * See \"sortByDateAndPriority()\" for more details.\n */\n const sortAndSetItems = useCallback(\n (newItmes: Resource[]): void => {\n sortByDateAndPriority(newItmes, resource);\n newItmes.reverse();\n setItems(newItmes);\n },\n [resource]\n );\n\n /**\n * Handles a batch request response.\n * @param batchResponse The batch response.\n */\n const handleBatchResponse = useCallback(\n (batchResponse: PromiseSettledResult<Bundle>[]): void => {\n const newItems = [];\n\n for (const settledResult of batchResponse) {\n if (settledResult.status !== 'fulfilled') {\n // User may not have access to all resource types\n continue;\n }\n\n const bundle = settledResult.value;\n if (bundle.type === 'history') {\n setHistory(bundle);\n }\n\n if (bundle.entry) {\n for (const entry of bundle.entry) {\n newItems.push(entry.resource as Resource);\n }\n }\n }\n\n sortAndSetItems(newItems);\n },\n [sortAndSetItems]\n );\n\n /**\n * Adds an array of resources to the timeline.\n * @param resource Resource to add.\n */\n const addResource = useCallback(\n (resource: Resource): void => sortAndSetItems([...itemsRef.current, resource]),\n [sortAndSetItems]\n );\n\n /**\n * Loads the timeline.\n */\n const loadTimeline = useCallback(() => {\n let resourceType: ResourceType;\n let id: string;\n if ('resourceType' in props.value) {\n resourceType = props.value.resourceType;\n id = props.value.id as string;\n } else {\n [resourceType, id] = props.value.reference?.split('/') as [ResourceType, string];\n }\n loadTimelineResources(medplum, resourceType, id).then(handleBatchResponse).catch(console.log);\n }, [medplum, props.value, loadTimelineResources, handleBatchResponse]);\n\n useEffect(() => loadTimeline(), [loadTimeline]);\n\n /**\n * Adds a Communication resource to the timeline.\n * @param contentString The comment content.\n */\n function createComment(contentString: string): void {\n if (!resource || !props.createCommunication) {\n // Encounter not loaded yet\n return;\n }\n medplum\n .createResource(props.createCommunication(resource, sender, contentString))\n .then((result) => addResource(result))\n .catch(console.log);\n }\n\n /**\n * Adds a Media resource to the timeline.\n * @param attachment The media attachment.\n */\n function createMedia(attachment: Attachment): void {\n if (!resource || !props.createMedia) {\n // Encounter not loaded yet\n return;\n }\n medplum\n .createResource(props.createMedia(resource, sender, attachment))\n .then((result) => addResource(result))\n .then(() =>\n updateNotification({\n id: 'upload-notification',\n color: 'teal',\n title: 'Upload complete',\n message: '',\n icon: <IconCheck size={16} />,\n autoClose: 2000,\n })\n )\n .catch((reason) =>\n updateNotification({\n id: 'upload-notification',\n color: 'red',\n title: 'Upload error',\n message: normalizeErrorString(reason),\n icon: <IconFileAlert size={16} />,\n autoClose: 2000,\n })\n );\n }\n\n function setPriority(\n communication: Communication,\n priority: 'routine' | 'urgent' | 'asap' | 'stat'\n ): Promise<Communication> {\n return medplum.updateResource({ ...communication, priority });\n }\n\n function onPin(communication: Communication): void {\n setPriority(communication, 'stat').then(loadTimeline).catch(console.log);\n }\n\n function onUnpin(communication: Communication): void {\n setPriority(communication, 'routine').then(loadTimeline).catch(console.log);\n }\n\n function onDetails(timelineItem: Resource): void {\n navigate(`/${timelineItem.resourceType}/${timelineItem.id}`);\n }\n\n function onEdit(timelineItem: Resource): void {\n navigate(`/${timelineItem.resourceType}/${timelineItem.id}/edit`);\n }\n\n function onDelete(timelineItem: Resource): void {\n navigate(`/${timelineItem.resourceType}/${timelineItem.id}/delete`);\n }\n\n function onVersionDetails(version: Resource): void {\n navigate(`/${version.resourceType}/${version.id}/_history/${version.meta?.versionId}`);\n }\n\n function onUploadStart(): void {\n showNotification({\n id: 'upload-notification',\n loading: true,\n title: 'Initializing upload...',\n message: 'Please wait...',\n autoClose: false,\n disallowClose: true,\n });\n }\n\n function onUploadProgress(e: ProgressEvent): void {\n updateNotification({\n id: 'upload-notification',\n loading: true,\n title: 'Uploading...',\n message: getProgressMessage(e),\n autoClose: false,\n disallowClose: true,\n });\n }\n\n if (!resource) {\n return (\n <Center style={{ width: '100%', height: '100%' }}>\n <Loader />\n </Center>\n );\n }\n\n return (\n <Timeline>\n {props.createCommunication && (\n <Panel>\n <Form\n testid=\"timeline-form\"\n onSubmit={(formData: Record<string, string>) => {\n createComment(formData.text);\n\n const input = inputRef.current;\n if (input) {\n input.value = '';\n input.focus();\n }\n }}\n >\n <Group spacing=\"xs\" noWrap style={{ width: '100%' }}>\n <ResourceAvatar value={sender} />\n <TextInput\n name=\"text\"\n ref={inputRef}\n placeholder=\"Add comment\"\n style={{ width: '100%', maxWidth: 300 }}\n />\n <ActionIcon type=\"submit\" radius=\"xl\" color=\"blue\" variant=\"filled\">\n <IconMessage size={16} />\n </ActionIcon>\n <AttachmentButton\n onUpload={createMedia}\n onUploadStart={onUploadStart}\n onUploadProgress={onUploadProgress}\n >\n {(props) => (\n <ActionIcon {...props} radius=\"xl\" color=\"blue\" variant=\"filled\">\n <IconCloudUpload size={16} />\n </ActionIcon>\n )}\n </AttachmentButton>\n </Group>\n </Form>\n </Panel>\n )}\n {items.map((item) => {\n if (!item) {\n // TODO: Handle null history items for deleted versions.\n return null;\n }\n const key = `${item.resourceType}/${item.id}/${item.meta?.versionId}`;\n if (item.resourceType === resource.resourceType && item.id === resource.id) {\n return (\n <HistoryTimelineItem\n key={key}\n history={history as Bundle<Resource>}\n resource={item}\n onDetails={onVersionDetails}\n />\n );\n }\n switch (item.resourceType) {\n case 'AuditEvent':\n return <AuditEventTimelineItem key={key} resource={item} onDetails={onDetails} />;\n case 'Communication':\n return (\n <CommunicationTimelineItem\n key={key}\n resource={item}\n onPin={item.priority !== 'stat' ? onPin : undefined}\n onUnpin={item.priority === 'stat' ? onUnpin : undefined}\n onDetails={onDetails}\n onEdit={onEdit}\n onDelete={onDelete}\n />\n );\n case 'DiagnosticReport':\n return (\n <DiagnosticReportTimelineItem\n key={key}\n resource={item}\n onDetails={onDetails}\n onEdit={onEdit}\n onDelete={onDelete}\n />\n );\n case 'Media':\n return (\n <MediaTimelineItem key={key} resource={item} onDetails={onDetails} onEdit={onEdit} onDelete={onDelete} />\n );\n default:\n return (\n <TimelineItem key={key} resource={item} padding={true}>\n <ResourceTable value={item} ignoreMissingValues={true} />\n </TimelineItem>\n );\n }\n })}\n </Timeline>\n );\n}\n\ninterface BaseTimelineItemProps<T extends Resource> {\n resource: T;\n onPin?: (resource: T) => void;\n onUnpin?: (resource: T) => void;\n onDetails?: (resource: T) => void;\n onEdit?: (resource: T) => void;\n onDelete?: (resource: T) => void;\n}\n\nfunction TimelineItemPopupMenu<T extends Resource>(props: BaseTimelineItemProps<T>): JSX.Element {\n return (\n <Menu.Dropdown>\n <Menu.Label>Resource</Menu.Label>\n {props.onPin && (\n <Menu.Item\n icon={<IconPin size={14} />}\n onClick={() => (props.onPin as (resource: T) => void)(props.resource)}\n aria-label={`Pin ${getReferenceString(props.resource)}`}\n >\n Pin\n </Menu.Item>\n )}\n {props.onUnpin && (\n <Menu.Item\n icon={<IconPinnedOff size={14} />}\n onClick={() => (props.onUnpin as (resource: T) => void)(props.resource)}\n aria-label={`Unpin ${getReferenceString(props.resource)}`}\n >\n Unpin\n </Menu.Item>\n )}\n {props.onDetails && (\n <Menu.Item\n icon={<IconListDetails size={14} />}\n onClick={() => (props.onDetails as (resource: T) => void)(props.resource)}\n aria-label={`Details ${getReferenceString(props.resource)}`}\n >\n Details\n </Menu.Item>\n )}\n {props.onEdit && (\n <Menu.Item\n icon={<IconEdit size={14} />}\n onClick={() => (props.onEdit as (resource: T) => void)(props.resource)}\n aria-label={`Edit ${getReferenceString(props.resource)}`}\n >\n Edit\n </Menu.Item>\n )}\n {props.onDelete && (\n <>\n <Menu.Divider />\n <Menu.Label>Danger zone</Menu.Label>\n <Menu.Item\n color=\"red\"\n icon={<IconTrash size={14} />}\n onClick={() => (props.onDelete as (resource: T) => void)(props.resource)}\n aria-label={`Delete ${getReferenceString(props.resource)}`}\n >\n Delete\n </Menu.Item>\n </>\n )}\n </Menu.Dropdown>\n );\n}\n\ninterface HistoryTimelineItemProps extends BaseTimelineItemProps<Resource> {\n history: Bundle;\n}\n\nfunction HistoryTimelineItem(props: HistoryTimelineItemProps): JSX.Element {\n const previous = getPrevious(props.history, props.resource);\n if (previous) {\n return (\n <TimelineItem resource={props.resource} padding={true} popupMenuItems={<TimelineItemPopupMenu {...props} />}>\n <ResourceDiffTable original={previous} revised={props.resource} />\n </TimelineItem>\n );\n } else {\n return (\n <TimelineItem resource={props.resource} padding={true} popupMenuItems={<TimelineItemPopupMenu {...props} />}>\n <h3>Created</h3>\n <ResourceTable value={props.resource} ignoreMissingValues forceUseInput />\n </TimelineItem>\n );\n }\n}\n\nfunction getPrevious(history: Bundle, version: Resource): Resource | undefined {\n const entries = history.entry as BundleEntry[];\n const index = entries.findIndex((entry) => entry.resource?.meta?.versionId === version.meta?.versionId);\n if (index >= entries.length - 1) {\n return undefined;\n }\n return entries[index + 1].resource;\n}\n\nfunction CommunicationTimelineItem(props: BaseTimelineItemProps<Communication>): JSX.Element {\n const { classes } = useStyles();\n const routine = !props.resource.priority || props.resource.priority === 'routine';\n const className = routine ? undefined : classes.pinnedComment;\n return (\n <TimelineItem\n resource={props.resource}\n profile={props.resource.sender}\n padding={true}\n className={className}\n popupMenuItems={<TimelineItemPopupMenu {...props} />}\n >\n <p>{props.resource.payload?.[0]?.contentString}</p>\n </TimelineItem>\n );\n}\n\nfunction MediaTimelineItem(props: BaseTimelineItemProps<Media>): JSX.Element {\n const contentType = props.resource.content?.contentType;\n const padding =\n contentType &&\n !contentType.startsWith('image/') &&\n !contentType.startsWith('video/') &&\n contentType !== 'application/pdf';\n return (\n <TimelineItem resource={props.resource} padding={!!padding} popupMenuItems={<TimelineItemPopupMenu {...props} />}>\n <AttachmentDisplay value={props.resource.content} />\n </TimelineItem>\n );\n}\n\nfunction AuditEventTimelineItem(props: BaseTimelineItemProps<AuditEvent>): JSX.Element {\n return (\n <TimelineItem resource={props.resource} padding={true} popupMenuItems={<TimelineItemPopupMenu {...props} />}>\n <ScrollArea>\n <pre>{props.resource.outcomeDesc}</pre>\n </ScrollArea>\n </TimelineItem>\n );\n}\n\nfunction DiagnosticReportTimelineItem(props: BaseTimelineItemProps<DiagnosticReport>): JSX.Element {\n return (\n <TimelineItem resource={props.resource} padding={true} popupMenuItems={<TimelineItemPopupMenu {...props} />}>\n <DiagnosticReportDisplay value={props.resource} />\n </TimelineItem>\n );\n}\n\nfunction getProgressMessage(e: ProgressEvent): string {\n if (e.lengthComputable) {\n const percent = (100 * e.loaded) / e.total;\n return `Uploaded: ${formatFileSize(e.loaded)} / ${formatFileSize(e.total)} ${percent.toFixed(2)}%`;\n }\n return `Uploaded: ${formatFileSize(e.loaded)}`;\n}\n\nfunction formatFileSize(bytes: number): string {\n if (bytes == 0) {\n return '0.00 B';\n }\n const e = Math.floor(Math.log(bytes) / Math.log(1024));\n return (bytes / Math.pow(1024, e)).toFixed(2) + ' ' + ' KMGTP'.charAt(e) + 'B';\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAM,SAAS,GAAG,YAAY,CAAC,CAAC,KAAK,MAAM;AACzC,IAAA,aAAa,EAAE;QACb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,EAAI,CAAA,EAAA;QACzG,KAAC,CAAA,aAAA,CAAA,uBAAuB,EAAC,EAAA,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAA,CAAI,CACrC,EACf;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,CAAgB,EAAA;IAC1C,IAAI,CAAC,CAAC,gBAAgB,EAAE;AACtB,QAAA,MAAM,OAAO,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC;QAC3C,OAAO,CAAA,UAAA,EAAa,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAM,GAAA,EAAA,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA,CAAA,CAAG,CAAC;AACpG,KAAA;IACD,OAAO,CAAA,UAAA,EAAa,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;AACjD,CAAC;AAED,SAAS,cAAc,CAAC,KAAa,EAAA;IACnC,IAAI,KAAK,IAAI,CAAC,EAAE;AACd,QAAA,OAAO,QAAQ,CAAC;AACjB,KAAA;IACD,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AACvD,IAAA,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;AACjF;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createStyles, Text, Stack, Button } from '@mantine/core';
|
|
2
2
|
import { getReferenceString } from '@medplum/core';
|
|
3
|
-
import
|
|
3
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
4
4
|
import { getStartMonth, CalendarInput } from '../CalendarInput/CalendarInput.mjs';
|
|
5
5
|
import { useMedplum } from '../MedplumProvider/MedplumProvider.mjs';
|
|
6
6
|
import { QuestionnaireForm } from '../QuestionnaireForm/QuestionnaireForm.mjs';
|
|
@@ -56,30 +56,30 @@ function Scheduler(props) {
|
|
|
56
56
|
return null;
|
|
57
57
|
}
|
|
58
58
|
const actor = schedule.actor?.[0];
|
|
59
|
-
return (
|
|
60
|
-
|
|
61
|
-
actor &&
|
|
62
|
-
actor && (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
date &&
|
|
66
|
-
slot &&
|
|
67
|
-
|
|
68
|
-
!date && (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
date && !slot && (
|
|
72
|
-
|
|
73
|
-
|
|
59
|
+
return (React.createElement("div", { className: classes.container, "data-testid": "scheduler" },
|
|
60
|
+
React.createElement("div", { className: classes.info },
|
|
61
|
+
actor && React.createElement(ResourceAvatar, { value: actor, size: "xl" }),
|
|
62
|
+
actor && (React.createElement(Text, { size: "xl", weight: 500 },
|
|
63
|
+
React.createElement(ResourceName, { value: actor }))),
|
|
64
|
+
React.createElement("p", null, "1 hour"),
|
|
65
|
+
date && React.createElement("p", null, date.toLocaleDateString()),
|
|
66
|
+
slot && React.createElement("p", null, formatTime(new Date(slot.start)))),
|
|
67
|
+
React.createElement("div", { className: classes.selection },
|
|
68
|
+
!date && (React.createElement("div", null,
|
|
69
|
+
React.createElement("h3", null, "Select date"),
|
|
70
|
+
React.createElement(CalendarInput, { slots: slots, onChangeMonth: setMonth, onClick: setDate }))),
|
|
71
|
+
date && !slot && (React.createElement("div", null,
|
|
72
|
+
React.createElement("h3", null, "Select time"),
|
|
73
|
+
React.createElement(Stack, null, slots.map((s) => {
|
|
74
74
|
const slotStart = new Date(s.start);
|
|
75
75
|
return (slotStart.getTime() > date.getTime() &&
|
|
76
|
-
slotStart.getTime() < date.getTime() + 24 * 3600 * 1000 && (
|
|
77
|
-
|
|
76
|
+
slotStart.getTime() < date.getTime() + 24 * 3600 * 1000 && (React.createElement("div", { key: s.id },
|
|
77
|
+
React.createElement(Button, { variant: "outline", style: { width: 150 }, onClick: () => setSlot(s) }, formatTime(slotStart)))));
|
|
78
78
|
})))),
|
|
79
|
-
date && slot && !response && (
|
|
80
|
-
date && slot && response && (
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
date && slot && !response && (React.createElement(QuestionnaireForm, { questionnaire: questionnaire, submitButtonText: 'Next', onSubmit: setResponse })),
|
|
80
|
+
date && slot && response && (React.createElement("div", null,
|
|
81
|
+
React.createElement("h3", null, "You're all set!"),
|
|
82
|
+
React.createElement("p", null, "Check your email for a calendar invite."))))));
|
|
83
83
|
}
|
|
84
84
|
function getStart(month) {
|
|
85
85
|
return formatSlotInstant(month.getTime());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scheduler.mjs","sources":["../../../src/Scheduler/Scheduler.tsx"],"sourcesContent":["import { Button, createStyles, Stack, Text } from '@mantine/core';\nimport { getReferenceString } from '@medplum/core';\nimport { Questionnaire, QuestionnaireResponse, Reference, Schedule, Slot } from '@medplum/fhirtypes';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { CalendarInput, getStartMonth } from '../CalendarInput/CalendarInput';\nimport { useMedplum } from '../MedplumProvider/MedplumProvider';\nimport { QuestionnaireForm } from '../QuestionnaireForm/QuestionnaireForm';\nimport { ResourceAvatar } from '../ResourceAvatar/ResourceAvatar';\nimport { ResourceName } from '../ResourceName/ResourceName';\nimport { useResource } from '../useResource/useResource';\n\nconst useStyles = createStyles((theme) => ({\n container: {\n display: 'flex',\n minHeight: 400,\n },\n\n info: {\n minWidth: 300,\n padding: 20,\n borderRight: `1px solid ${theme.colors.gray[3]}`,\n },\n\n selection: {\n minWidth: 300,\n padding: 20,\n },\n}));\n\nexport interface SchedulerProps {\n schedule: Schedule | Reference<Schedule>;\n questionnaire: Questionnaire | Reference<Questionnaire>;\n}\n\nexport function Scheduler(props: SchedulerProps): JSX.Element | null {\n const { classes } = useStyles();\n const medplum = useMedplum();\n const schedule = useResource(props.schedule);\n const questionnaire = useResource(props.questionnaire);\n\n const [slots, setSlots] = useState<Slot[]>();\n const slotsRef = useRef<Slot[]>();\n slotsRef.current = slots;\n\n const [month, setMonth] = useState<Date>(getStartMonth());\n const [date, setDate] = useState<Date>();\n const [slot, setSlot] = useState<Slot>();\n const [response, setResponse] = useState<QuestionnaireResponse>();\n\n useEffect(() => {\n if (schedule) {\n setSlots([]);\n medplum\n .searchResources(\n 'Slot',\n new URLSearchParams([\n ['_count', (30 * 24).toString()],\n ['schedule', getReferenceString(schedule)],\n ['start', 'gt' + getStart(month)],\n ['start', 'lt' + getEnd(month)],\n ])\n )\n .then(setSlots)\n .catch(console.log);\n } else {\n setSlots(undefined);\n }\n }, [medplum, schedule, month]);\n\n if (!schedule || !slots || !questionnaire) {\n return null;\n }\n\n const actor = schedule.actor?.[0];\n\n return (\n <div className={classes.container} data-testid=\"scheduler\">\n <div className={classes.info}>\n {actor && <ResourceAvatar value={actor} size=\"xl\" />}\n {actor && (\n <Text size=\"xl\" weight={500}>\n <ResourceName value={actor} />\n </Text>\n )}\n <p>1 hour</p>\n {date && <p>{date.toLocaleDateString()}</p>}\n {slot && <p>{formatTime(new Date(slot.start as string))}</p>}\n </div>\n <div className={classes.selection}>\n {!date && (\n <div>\n <h3>Select date</h3>\n <CalendarInput slots={slots} onChangeMonth={setMonth} onClick={setDate} />\n </div>\n )}\n {date && !slot && (\n <div>\n <h3>Select time</h3>\n <Stack>\n {slots.map((s) => {\n const slotStart = new Date(s.start as string);\n return (\n slotStart.getTime() > date.getTime() &&\n slotStart.getTime() < date.getTime() + 24 * 3600 * 1000 && (\n <div key={s.id}>\n <Button variant=\"outline\" style={{ width: 150 }} onClick={() => setSlot(s)}>\n {formatTime(slotStart)}\n </Button>\n </div>\n )\n );\n })}\n </Stack>\n </div>\n )}\n {date && slot && !response && (\n <QuestionnaireForm questionnaire={questionnaire} submitButtonText={'Next'} onSubmit={setResponse} />\n )}\n {date && slot && response && (\n <div>\n <h3>You're all set!</h3>\n <p>Check your email for a calendar invite.</p>\n </div>\n )}\n </div>\n </div>\n );\n}\n\nfunction getStart(month: Date): string {\n return formatSlotInstant(month.getTime());\n}\n\nfunction getEnd(month: Date): string {\n return formatSlotInstant(month.getTime() + 31 * 24 * 60 * 60 * 1000);\n}\n\nfunction formatSlotInstant(time: number): string {\n return new Date(Math.max(Date.now(), time)).toISOString();\n}\n\nfunction formatTime(date: Date): string {\n return date.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' });\n}\n"],"names":[
|
|
1
|
+
{"version":3,"file":"Scheduler.mjs","sources":["../../../src/Scheduler/Scheduler.tsx"],"sourcesContent":["import { Button, createStyles, Stack, Text } from '@mantine/core';\nimport { getReferenceString } from '@medplum/core';\nimport { Questionnaire, QuestionnaireResponse, Reference, Schedule, Slot } from '@medplum/fhirtypes';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { CalendarInput, getStartMonth } from '../CalendarInput/CalendarInput';\nimport { useMedplum } from '../MedplumProvider/MedplumProvider';\nimport { QuestionnaireForm } from '../QuestionnaireForm/QuestionnaireForm';\nimport { ResourceAvatar } from '../ResourceAvatar/ResourceAvatar';\nimport { ResourceName } from '../ResourceName/ResourceName';\nimport { useResource } from '../useResource/useResource';\n\nconst useStyles = createStyles((theme) => ({\n container: {\n display: 'flex',\n minHeight: 400,\n },\n\n info: {\n minWidth: 300,\n padding: 20,\n borderRight: `1px solid ${theme.colors.gray[3]}`,\n },\n\n selection: {\n minWidth: 300,\n padding: 20,\n },\n}));\n\nexport interface SchedulerProps {\n schedule: Schedule | Reference<Schedule>;\n questionnaire: Questionnaire | Reference<Questionnaire>;\n}\n\nexport function Scheduler(props: SchedulerProps): JSX.Element | null {\n const { classes } = useStyles();\n const medplum = useMedplum();\n const schedule = useResource(props.schedule);\n const questionnaire = useResource(props.questionnaire);\n\n const [slots, setSlots] = useState<Slot[]>();\n const slotsRef = useRef<Slot[]>();\n slotsRef.current = slots;\n\n const [month, setMonth] = useState<Date>(getStartMonth());\n const [date, setDate] = useState<Date>();\n const [slot, setSlot] = useState<Slot>();\n const [response, setResponse] = useState<QuestionnaireResponse>();\n\n useEffect(() => {\n if (schedule) {\n setSlots([]);\n medplum\n .searchResources(\n 'Slot',\n new URLSearchParams([\n ['_count', (30 * 24).toString()],\n ['schedule', getReferenceString(schedule)],\n ['start', 'gt' + getStart(month)],\n ['start', 'lt' + getEnd(month)],\n ])\n )\n .then(setSlots)\n .catch(console.log);\n } else {\n setSlots(undefined);\n }\n }, [medplum, schedule, month]);\n\n if (!schedule || !slots || !questionnaire) {\n return null;\n }\n\n const actor = schedule.actor?.[0];\n\n return (\n <div className={classes.container} data-testid=\"scheduler\">\n <div className={classes.info}>\n {actor && <ResourceAvatar value={actor} size=\"xl\" />}\n {actor && (\n <Text size=\"xl\" weight={500}>\n <ResourceName value={actor} />\n </Text>\n )}\n <p>1 hour</p>\n {date && <p>{date.toLocaleDateString()}</p>}\n {slot && <p>{formatTime(new Date(slot.start as string))}</p>}\n </div>\n <div className={classes.selection}>\n {!date && (\n <div>\n <h3>Select date</h3>\n <CalendarInput slots={slots} onChangeMonth={setMonth} onClick={setDate} />\n </div>\n )}\n {date && !slot && (\n <div>\n <h3>Select time</h3>\n <Stack>\n {slots.map((s) => {\n const slotStart = new Date(s.start as string);\n return (\n slotStart.getTime() > date.getTime() &&\n slotStart.getTime() < date.getTime() + 24 * 3600 * 1000 && (\n <div key={s.id}>\n <Button variant=\"outline\" style={{ width: 150 }} onClick={() => setSlot(s)}>\n {formatTime(slotStart)}\n </Button>\n </div>\n )\n );\n })}\n </Stack>\n </div>\n )}\n {date && slot && !response && (\n <QuestionnaireForm questionnaire={questionnaire} submitButtonText={'Next'} onSubmit={setResponse} />\n )}\n {date && slot && response && (\n <div>\n <h3>You're all set!</h3>\n <p>Check your email for a calendar invite.</p>\n </div>\n )}\n </div>\n </div>\n );\n}\n\nfunction getStart(month: Date): string {\n return formatSlotInstant(month.getTime());\n}\n\nfunction getEnd(month: Date): string {\n return formatSlotInstant(month.getTime() + 31 * 24 * 60 * 60 * 1000);\n}\n\nfunction formatSlotInstant(time: number): string {\n return new Date(Math.max(Date.now(), time)).toISOString();\n}\n\nfunction formatTime(date: Date): string {\n return date.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' });\n}\n"],"names":[],"mappings":";;;;;;;;;;AAWA,MAAM,SAAS,GAAG,YAAY,CAAC,CAAC,KAAK,MAAM;AACzC,IAAA,SAAS,EAAE;AACT,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,SAAS,EAAE,GAAG;AACf,KAAA;AAED,IAAA,IAAI,EAAE;AACJ,QAAA,QAAQ,EAAE,GAAG;AACb,QAAA,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,CAAa,UAAA,EAAA,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAE,CAAA;AACjD,KAAA;AAED,IAAA,SAAS,EAAE;AACT,QAAA,QAAQ,EAAE,GAAG;AACb,QAAA,OAAO,EAAE,EAAE;AACZ,KAAA;AACF,CAAA,CAAC,CAAC,CAAC;AAOE,SAAU,SAAS,CAAC,KAAqB,EAAA;AAC7C,IAAA,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,CAAC;AAChC,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC7C,MAAM,aAAa,GAAG,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAEvD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAU,CAAC;AAC7C,IAAA,MAAM,QAAQ,GAAG,MAAM,EAAU,CAAC;AAClC,IAAA,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;IAEzB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,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