From be6163531e5a6d55cc3e1b9b1d941cb533b43639 Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Wed, 28 Feb 2024 11:47:03 +0300 Subject: [PATCH] (feat) Add config to handle bill submission in start visit form --- .../esm-patient-chart-app/src/config-schema.ts | 7 +++++++ .../src/visit/visit-form/visit-form.component.tsx | 14 +++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/esm-patient-chart-app/src/config-schema.ts b/packages/esm-patient-chart-app/src/config-schema.ts index da83fb7dea..0090bb3bb4 100644 --- a/packages/esm-patient-chart-app/src/config-schema.ts +++ b/packages/esm-patient-chart-app/src/config-schema.ts @@ -123,6 +123,12 @@ export const esmPatientChartSchema = { _description: 'The number of visits to load initially in the Visits Summary tab. Defaults to 5', _default: 5, }, + showExtraVisitAttributesSlot: { + _type: Type.Boolean, + _description: + 'Whether on start visit form should handle submission of the extra visit attributes from the extra visit attributes slot', + _default: false, + }, }; export interface ChartConfig { offlineVisitTypeUuid: string; @@ -146,4 +152,5 @@ export interface ChartConfig { }; disableChangingVisitLocation: boolean; numberOfVisitsToLoad: number; + showExtraVisitAttributesSlot: boolean; } diff --git a/packages/esm-patient-chart-app/src/visit/visit-form/visit-form.component.tsx b/packages/esm-patient-chart-app/src/visit/visit-form/visit-form.component.tsx index 513b364a64..6f59ed970b 100644 --- a/packages/esm-patient-chart-app/src/visit/visit-form/visit-form.component.tsx +++ b/packages/esm-patient-chart-app/src/visit/visit-form/visit-form.component.tsx @@ -91,6 +91,7 @@ const StartVisitForm: React.FC = ({ const visitQueueNumberAttributeUuid = config.visitQueueNumberAttributeUuid; const [visitUuid, setVisitUuid] = useState(''); const { mutate: mutateQueueEntry } = useVisitQueueEntry(patientUuid, visitUuid); + const [extraVisitInfo, setExtraVisitInfo] = useState(null); const displayVisitStopDateTimeFields = useMemo( () => visitToEdit?.stopDatetime || showVisitEndDateTimeFields, @@ -316,6 +317,17 @@ const StartVisitForm: React.FC = ({ } const abortController = new AbortController(); + if (config.showExtraVisitAttributesSlot) { + const { handleCreateExtraVisitInfo, attributes } = extraVisitInfo ?? {}; + payload.attributes = [ + ...(payload.attributes || []), + ...Object.entries(attributes).map(([key, value]) => ({ + attributeType: key, + value: value as string, + })), + ]; + handleCreateExtraVisitInfo && handleCreateExtraVisitInfo(); + } if (isOnline) { (visitToEdit?.uuid @@ -642,7 +654,7 @@ const StartVisitForm: React.FC = ({ )} - + {/* Visit type attribute fields. These get shown when visit attribute types are configured */}