Skip to content

Commit

Permalink
Improve strength of the caution message for potentially incorrect dis…
Browse files Browse the repository at this point in the history
…charge dates
  • Loading branch information
rithviknishad committed Jul 16, 2024
1 parent ae23c51 commit 00be2b6
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions src/Components/Facility/DischargeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,18 @@ const DischargeModal = ({
}));
};

const encounterDuration = dayjs
.duration(
dayjs(
preDischargeForm[
discharge_reason ===
DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id
? "death_datetime"
: "discharge_date"
],
).diff(consultationData.encounter_date),
)
.humanize();
const encounterDuration = dayjs.duration(
dayjs(
preDischargeForm[
discharge_reason ===
DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id
? "death_datetime"
: "discharge_date"
],
).diff(consultationData.encounter_date),
);

const durationNeedsAttention = encounterDuration.asDays() >= 30;

return (
<DialogModal
Expand Down Expand Up @@ -386,9 +386,19 @@ const DischargeModal = ({
)}

<div className="py-4">
<span className="text-gray-700">
<span
className={
durationNeedsAttention ? "text-warning-500" : "text-gray-700"
}
>
{durationNeedsAttention && (
<>
<CareIcon icon="l-exclamation-triangle" className="text-lg" />
<strong> Caution: </strong>
</>
)}
{t("encounter_duration_confirmation")}{" "}
<strong>{encounterDuration}</strong>.
<strong>{encounterDuration.humanize()}</strong>.
</span>
</div>
<div className="cui-form-button-group">
Expand Down

0 comments on commit 00be2b6

Please sign in to comment.