Skip to content

Commit

Permalink
(feat) Add config to handle bill submission in start visit form
Browse files Browse the repository at this point in the history
  • Loading branch information
CynthiaKamau committed Feb 28, 2024
1 parent dc31057 commit be61635
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/esm-patient-chart-app/src/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -146,4 +152,5 @@ export interface ChartConfig {
};
disableChangingVisitLocation: boolean;
numberOfVisitsToLoad: number;
showExtraVisitAttributesSlot: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const StartVisitForm: React.FC<StartVisitFormProps> = ({
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,
Expand Down Expand Up @@ -316,6 +317,17 @@ const StartVisitForm: React.FC<StartVisitFormProps> = ({
}

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
Expand Down Expand Up @@ -642,7 +654,7 @@ const StartVisitForm: React.FC<StartVisitFormProps> = ({
</section>
)}

<ExtensionSlot state={{ patientUuid }} name="extra-visit-attribute-slot" />
<ExtensionSlot state={{ patientUuid, setExtraVisitInfo }} name="extra-visit-attribute-slot" />

{/* Visit type attribute fields. These get shown when visit attribute types are configured */}
<section>
Expand Down

0 comments on commit be61635

Please sign in to comment.