diff --git a/src/Components/Patient/PatientInfoCard.tsx b/src/Components/Patient/PatientInfoCard.tsx index 8cbb24c61a9..c954438e6c2 100644 --- a/src/Components/Patient/PatientInfoCard.tsx +++ b/src/Components/Patient/PatientInfoCard.tsx @@ -471,347 +471,350 @@ export default function PatientInfoCard(props: { )} - {[ - [ - `/facility/${patient.facility}/patient/${patient.id}/consultation/${consultation?.id}/daily-rounds`, - "Log Update", - "plus", - patient.is_active && - consultation?.id && - !consultation?.discharge_date, +
+ {[ [ - !(consultation?.facility !== patient.facility) && - !(consultation?.discharge_date ?? !patient.is_active) && - dayjs(consultation?.modified_date).isBefore( - dayjs().subtract(1, "day") - ), -
- No update - filed in the last 24 hours -
, + `/facility/${patient.facility}/patient/${patient.id}/consultation/${consultation?.id}/daily-rounds`, + "Log Update", + "plus", + patient.is_active && + consultation?.id && + !consultation?.discharge_date, + [ + !(consultation?.facility !== patient.facility) && + !(consultation?.discharge_date ?? !patient.is_active) && + dayjs(consultation?.modified_date).isBefore( + dayjs().subtract(1, "day") + ), +
+ No + update filed in the last 24 hours +
, + ], ], - ], - ].map( - (action: any, i) => - action[3] && ( -
- + action[3] && ( +
{ - if ( + > + - - -

{action[1]}

-
-
- {action?.[4]?.[0] && ( - <> -

- {action[4][1]} -

- - )} -
- ) - )} - } - containerClassName="w-full lg:w-auto mt-2 2xl:mt-0" - > -
- {[ - [ - `/facility/${patient.facility}/patient/${patient.id}/consultation/${consultation?.id}/update`, - "Edit Consultation Details", - "pen", - patient.is_active && - consultation?.id && - !consultation?.discharge_date, - ], - [ - `/patient/${patient.id}/investigation_reports`, - "Investigation Summary", - "align-alt", - true, - ], - [ - `/facility/${patient.facility}/patient/${patient.id}/consultation/${consultation?.id}/treatment-summary`, - "Treatment Summary", - "file-medical", - consultation?.id, - ], - ] - .concat( - enable_hcx - ? [ - [ - `/facility/${patient.facility}/patient/${patient.id}/consultation/${consultation?.id}/claims`, - "Claims", - "copy-landscape", - consultation?.id, - ], - ] - : [] + onClick={() => { + if ( + consultation?.admitted && + !consultation?.current_bed && + i === 1 + ) { + Notification.Error({ + msg: "Please assign a bed to the patient", + }); + setOpen(true); + } + }} + className="w-full" + > + + +

{action[1]}

+
+ + {action?.[4]?.[0] && ( + <> +

+ {action[4][1]} +

+ + )} +
) - .map( - (action: any, i) => - action[3] && ( -
- { - if ( + )} + } + className="xl:justify-center" + containerClassName="w-full lg:w-auto mt-2 2xl:mt-0 flex justify-center" + > +
+ {[ + [ + `/facility/${patient.facility}/patient/${patient.id}/consultation/${consultation?.id}/update`, + "Edit Consultation Details", + "pen", + patient.is_active && + consultation?.id && + !consultation?.discharge_date, + ], + [ + `/patient/${patient.id}/investigation_reports`, + "Investigation Summary", + "align-alt", + true, + ], + [ + `/facility/${patient.facility}/patient/${patient.id}/consultation/${consultation?.id}/treatment-summary`, + "Treatment Summary", + "file-medical", + consultation?.id, + ], + ] + .concat( + enable_hcx + ? [ + [ + `/facility/${patient.facility}/patient/${patient.id}/consultation/${consultation?.id}/claims`, + "Claims", + "copy-landscape", + consultation?.id, + ], + ] + : [] + ) + .map( + (action: any, i) => + action[3] && ( +
+ - - {action[1]} - - {action?.[4]?.[0] && ( + onClick={() => { + if ( + action[1] !== "Treatment Summary" && + consultation?.admitted && + !consultation?.current_bed && + i === 1 + ) { + Notification.Error({ + msg: "Please assign a bed to the patient", + }); + setOpen(true); + } + triggerGoal("Patient Card Button Clicked", { + buttonName: action[1], + consultationId: consultation?.id, + userId: authUser?.id, + }); + }} + > + + {action[1]} + + {action?.[4]?.[0] && ( + <> +

+ {action[4][1]} +

+ + )} +
+ ) + )} +
+ +
+ {enable_abdm && + (patient.abha_number ? ( + <> + + {({ close }) => ( <> -

- {action[4][1]} -

+
{ + close(); + setShowABHAProfile(true); + triggerGoal("Patient Card Button Clicked", { + buttonName: "Show ABHA Profile", + consultationId: consultation?.id, + userId: authUser?.id, + }); + }} + > + + Show ABHA Profile +
+
{ + triggerGoal("Patient Card Button Clicked", { + buttonName: "Link Care Context", + consultationId: consultation?.id, + userId: authUser?.id, + }); + close(); + setShowLinkCareContext(true); + }} + > + + Link Care Context +
)} -
- ) - )} -
- -
- {enable_abdm && - (patient.abha_number ? ( - <> + + + ) : ( {({ close }) => ( - <> +
{ + close(); + setShowLinkABHANumber(true); + }} + > + + +

Link ABHA Number

+
+
+ )} +
+ ))} +
+
+ {!consultation?.discharge_date && ( + + {({ close }) => ( + <> + {hasActiveShiftingRequest() ? (
{ close(); - setShowABHAProfile(true); - triggerGoal("Patient Card Button Clicked", { - buttonName: "Show ABHA Profile", - consultationId: consultation?.id, - userId: authUser?.id, - }); + navigate( + `/shifting/${ + activeShiftingData[ + activeShiftingData.length - 1 + ].id + }` + ); }} > - - Show ABHA Profile + + +

Track Shifting

+
+ ) : (
{ - triggerGoal("Patient Card Button Clicked", { - buttonName: "Link Care Context", - consultationId: consultation?.id, - userId: authUser?.id, - }); close(); - setShowLinkCareContext(true); + navigate( + `/facility/${patient.facility}/patient/${patient.id}/shift/new` + ); }} > - - Link Care Context + + +

Shift Patient

+
- - )} -
- - ) : ( - - {({ close }) => ( -
{ - close(); - setShowLinkABHANumber(true); - }} - > - - -

Link ABHA Number

-
-
+ )} + )}
- ))} -
-
- {!consultation?.discharge_date && ( + )} {({ close }) => ( - <> - {hasActiveShiftingRequest() ? ( -
{ - close(); - navigate( - `/shifting/${ - activeShiftingData[ - activeShiftingData.length - 1 - ].id - }` - ); - }} - > - - -

Track Shifting

-
-
- ) : ( -
{ - close(); - navigate( - `/facility/${patient.facility}/patient/${patient.id}/shift/new` - ); - }} - > - - -

Shift Patient

-
-
- )} - +
{ + close(); + setOpenDischargeSummaryDialog(true); + }} + > + + +

{t("discharge_summary")}

+
+
)}
- )} - - {({ close }) => ( -
{ - close(); - setOpenDischargeSummaryDialog(true); - }} - > - - -

{t("discharge_summary")}

-
-
- )} -
- - {({ close }) => ( -
{ - if (!consultation?.discharge_date) { - close(); - setOpenDischargeDialog(true); - } - }} - > - - -

{t("discharge_from_care")}

-
-
- )} -
-
-
- - { - triggerGoal("Patient Card Button Clicked", { - buttonName: "Medico Legal Case", - consultationId: consultation?.id, - userId: authUser?.id, - }); - setMedicoLegalCase(checked); - switchMedicoLegalCase(checked); - }} - className={classNames( - medicoLegalCase ? "bg-primary" : "bg-gray-200", - "relative inline-flex h-4 w-8 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none " + + {({ close }) => ( +
{ + if (!consultation?.discharge_date) { + close(); + setOpenDischargeDialog(true); + } + }} + > + + +

{t("discharge_from_care")}

+
+
)} - > -
+
+ + { + triggerGoal("Patient Card Button Clicked", { + buttonName: "Medico Legal Case", + consultationId: consultation?.id, + userId: authUser?.id, + }); + setMedicoLegalCase(checked); + switchMedicoLegalCase(checked); + }} className={classNames( - medicoLegalCase ? "translate-x-4" : "translate-x-0", - "pointer-events-none inline-block h-3 w-3 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out" + medicoLegalCase ? "bg-primary" : "bg-gray-200", + "relative inline-flex h-4 w-8 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none " )} - /> - - - - Medico-Legal Case - {" "} - - -
-
+ > +
+ +