Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Treament Summary Report #8295

Merged
merged 8 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/pageobject/Patient/PatientLogupdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class PatientLogupdate {

selectBed(bed: string) {
cy.searchAndSelectOption("input[name='bed']", bed);
cy.submitButton("Move to bed");
cy.submitButton("Update");
cy.wait(2000);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Components/Facility/Consultations/Beds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ const Beds = (props: BedsProps) => {
<div>
<ButtonV2 variant="primary" type="submit">
<CareIcon icon="l-bed" className="text-xl" />
Move to bed
Update
khavinshankar marked this conversation as resolved.
Show resolved Hide resolved
</ButtonV2>
</div>
</div>
Expand Down
168 changes: 104 additions & 64 deletions src/Components/Facility/TreatmentSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import useAppHistory from "../../Common/hooks/useAppHistory";
import routes from "../../Redux/api";
import useQuery from "../../Utils/request/useQuery";
import CareIcon from "../../CAREUI/icons/CareIcon";
import { ConsultationModel } from "./models";
import { useMemo } from "react";
import { ConsultationDiagnosis } from "../Diagnosis/types";

const TreatmentSummary = (props: any) => {
const { consultationId, patientId } = props;
Expand Down Expand Up @@ -108,74 +111,40 @@ const TreatmentSummary = (props: any) => {
</div>
</div>

<div className="border-b-2 border-gray-800 px-5 py-2">
<b>Comorbidities :</b>
<div className="mx-0 sm:mx-5 print:mx-5">
<table className="w-full border-collapse border border-gray-800">
<thead>
<tr>
<th className="border border-gray-800">Disease</th>
<th className="border border-gray-800">Details</th>
</tr>
</thead>
<tbody>
{patientData?.medical_history &&
patientData.medical_history.length > 0 ? (
patientData.medical_history.map(
(obj: any, index: number) => {
return (
<tr key={index}>
<td className="border border-gray-800 text-center">
{obj["disease"]}
</td>
<td className="border border-gray-800 text-center">
{obj["details"] ? obj["details"] : "---"}
</td>
</tr>
);
},
)
) : (
{/* Comorbidities */}
{!!patientData?.medical_history?.filter(
(comorbidities) => comorbidities.disease !== "NO",
).length && (
<div className="border-b-2 border-gray-800 px-5 py-2">
<b>Comorbidities :</b>
<div className="mx-0 sm:mx-5 print:mx-5">
<table className="w-full border-collapse border border-gray-800">
<thead>
<tr>
<td className="border border-gray-800 text-center">
---
</td>
<td className="border border-gray-800 text-center">
---
</td>
<th className="border border-gray-800">Disease</th>
<th className="border border-gray-800">Details</th>
</tr>
)}
</tbody>
</table>
</div>
</div>

<div className="border-b-2 border-gray-800 px-5 py-2">
<b>Diagnosis :</b>
<div className="mx-5">
<div>
<b>History of present illness :</b>
{consultationData?.history_of_present_illness
? consultationData.history_of_present_illness
: " ---"}
</div>

<div>
<b>Examination details and clinical conditions :</b>
{consultationData?.examination_details
? consultationData.examination_details
: " ---"}
</div>

<div>
<b>Physical Examination info :</b>
{consultationData?.last_daily_round?.physical_examination_info
? consultationData.last_daily_round
?.physical_examination_info
: " ---"}
</thead>
<tbody>
{patientData.medical_history.map((obj, index) => {
return (
<tr key={index}>
<td className="border border-gray-800 text-center">
{obj["disease"]}
</td>
<td className="border border-gray-800 text-center">
{obj["details"] || "---"}
</td>
</tr>
);
})}
</tbody>
</table>
</div>
</div>
</div>
)}

<DiagnosisSection consultationData={consultationData} />

<div className="border-b-2 border-gray-800 px-5 py-2">
<b>General Instructions :</b>
Expand Down Expand Up @@ -337,3 +306,74 @@ const TreatmentSummary = (props: any) => {
};

export default TreatmentSummary;

interface IDiagnosisSection {
consultationData?: ConsultationModel;
}

type DiagnosisType =
| "principal"
| "confirmed"
| "provisional"
| "unconfirmed"
khavinshankar marked this conversation as resolved.
Show resolved Hide resolved
| "differential";

function DiagnosisSection({ consultationData }: IDiagnosisSection) {
const diagnoses = useMemo(() => {
return consultationData?.diagnoses?.reduce(
(acc, curr) => {
if (curr.is_principal) {
acc.principal.push(curr);
} else if (
["confirmed", "provisional", "unconfirmed", "differential"].includes(
curr.verification_status,
)
khavinshankar marked this conversation as resolved.
Show resolved Hide resolved
) {
acc[curr.verification_status as keyof typeof acc].push(curr);
}

return acc;
},
{
principal: [],
confirmed: [],
provisional: [],
unconfirmed: [],
differential: [],
} as Record<DiagnosisType, ConsultationDiagnosis[]>,
);
}, [consultationData?.diagnoses]);

if (!diagnoses) {
return null;
}

return (
<div className="border-b-2 border-gray-800 px-5 py-2">
<b>Diagnosis :</b>
<div className="mx-5">
{(
[
{ key: "principal", title: "Principal Diagnosis" },
{ key: "confirmed", title: "Confirmed Diagnosis" },
{ key: "provisional", title: "Provisional Diagnosis" },
{ key: "unconfirmed", title: "Unconfirmed Diagnosis" },
{ key: "differential", title: "Differential Diagnosis" },
khavinshankar marked this conversation as resolved.
Show resolved Hide resolved
] as { key: DiagnosisType; title: string }[]
).map(
(item) =>
!!diagnoses[item.key].length && (
<div>
<b>{item.title} :</b>
<ol className="mx-6 list-decimal">
{diagnoses[item.key].map((d) => (
<li key={d.id}>{d.diagnosis_object.label}</li>
))}
</ol>
</div>
),
)}
</div>
</div>
);
}
Loading