Skip to content

Commit

Permalink
changed the discharged logic in patient consultation dashboard (#5379)
Browse files Browse the repository at this point in the history
  • Loading branch information
khavinshankar authored Apr 26, 2023
1 parent f013a27 commit 33b2530
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
7 changes: 2 additions & 5 deletions src/Components/Facility/ConsultationDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ export const ConsultationDetails = (props: any) => {
backUrl="/patients"
/>
<div className="w-full sm:w-min lg:absolute xl:right-0 -right-6 top-0 flex sm:flex-row sm:items-center flex-col space-y-1 sm:space-y-0 sm:divide-x-2">
{patientData.is_active && (
{!consultationData.discharge_date && (
<div className="w-full flex flex-col sm:flex-row px-2">
<ButtonV2
onClick={() =>
Expand Down Expand Up @@ -493,10 +493,7 @@ export const ConsultationDetails = (props: any) => {
<button
className="btn btn-primary"
onClick={handleDischageClickOpen}
disabled={
!patientData.is_active ||
patientData.last_consultation?.facility !== facilityId
}
disabled={!!consultationData.discharge_date}
>
<i className="fas fa-hospital-user"></i>
&nbsp; Discharge from CARE
Expand Down
38 changes: 22 additions & 16 deletions src/Components/Patient/PatientInfoCard.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import { Link } from "raviger";
import { getDimensionOrDash } from "../../Common/utils";
import { PatientModel } from "./models";
import DialogModal from "../Common/Dialog";
import Beds from "../Facility/Consultations/Beds";
import { useState } from "react";
import { ConsultationModel, PatientCategory } from "../Facility/models";
import * as Notification from "../../Utils/Notifications.js";

import {
CONSULTATION_SUGGESTION,
DISCHARGE_REASONS,
PATIENT_CATEGORIES,
RESPIRATORY_SUPPORT,
} from "../../Common/constants";
import moment from "moment";
import { ConsultationModel, PatientCategory } from "../Facility/models";

import Beds from "../Facility/Consultations/Beds";
import ButtonV2 from "../Common/components/ButtonV2";
import CareIcon from "../../CAREUI/icons/CareIcon";
import * as Notification from "../../Utils/Notifications.js";
import DialogModal from "../Common/Dialog";
import { Link } from "raviger";
import { PatientModel } from "./models";
import { getDimensionOrDash } from "../../Common/utils";
import moment from "moment";
import useConfig from "../../Common/hooks/useConfig";
import { useState } from "react";

export default function PatientInfoCard(props: {
patient: PatientModel;
Expand All @@ -36,7 +38,7 @@ export default function PatientInfoCard(props: {
? PATIENT_CATEGORIES.find((c) => c.text === category)?.twClass
: "patient-unknown";

const bedDialogTitle = !patient.is_active
const bedDialogTitle = consultation?.discharge_date
? "Bed History"
: !consultation?.current_bed
? "Assign Bed"
Expand All @@ -54,7 +56,7 @@ export default function PatientInfoCard(props: {
<Beds
facilityId={patient?.facility}
patientId={patient?.id}
discharged={!patient.is_active}
discharged={!!consultation?.discharge_date}
consultationId={consultation?.id}
setState={setOpen}
fetchPatientData={props.fetchPatientData}
Expand Down Expand Up @@ -154,7 +156,7 @@ export default function PatientInfoCard(props: {
</span>
)}
</div>
{!patient.is_active && (
{!!consultation?.discharge_date && (
<p className="bg-red-100 text-red-600 inline-block rounded-lg px-2 py-1 my-1 text-sm">
Discharged from CARE
</p>
Expand Down Expand Up @@ -199,7 +201,7 @@ export default function PatientInfoCard(props: {
);
})}
</div>
{patient.is_active === false && (
{!!consultation?.discharge_date && (
<div className="flex gap-4 text-sm mt-3 px-3 py-1 font-medium bg-cyan-300">
<div>
<span>
Expand Down Expand Up @@ -241,7 +243,7 @@ export default function PatientInfoCard(props: {
</div>

<div className="w-full lg:w-fit flex gap-2 flex-col px-4 py-1 lg:p-6">
{patient.is_active === false && (
{!!consultation?.discharge_date && (
<div className="flex flex-col justify-center items-center">
<div className="text-sm leading-5 font-normal text-gray-500">
Discharge Reason
Expand All @@ -264,13 +266,17 @@ export default function PatientInfoCard(props: {
`/facility/${patient.facility}/patient/${patient.id}/consultation/${consultation?.id}/update`,
"Edit Consultation Details",
"pen",
patient.is_active && consultation?.id,
patient.is_active &&
consultation?.id &&
!consultation?.discharge_date,
],
[
`/facility/${patient.facility}/patient/${patient.id}/consultation/${consultation?.id}/daily-rounds`,
"Log Update",
"plus",
patient.is_active && consultation?.id,
patient.is_active &&
consultation?.id &&
!consultation?.discharge_date,
[
!(consultation?.facility !== patient.facility) &&
!(consultation?.discharge_date || !patient.is_active) &&
Expand Down

0 comments on commit 33b2530

Please sign in to comment.