diff --git a/src/Components/Patient/SampleDetails.tsx b/src/Components/Patient/SampleDetails.tsx index dc5995792ab..cc3d04ce30f 100644 --- a/src/Components/Patient/SampleDetails.tsx +++ b/src/Components/Patient/SampleDetails.tsx @@ -1,17 +1,18 @@ -import loadable from "@loadable/component"; -import { useCallback, useState } from "react"; -import { useDispatch } from "react-redux"; -import { statusType, useAbortableEffect } from "../../Common/utils"; -import { getTestSample } from "../../Redux/actions"; import { FlowModel, SampleTestModel } from "./models"; -import { FileUpload } from "./FileUpload"; -import { navigate } from "raviger"; import { GENDER_TYPES, TEST_TYPE_CHOICES } from "../../Common/constants"; -import _ from "lodash"; -import { formatDate } from "../../Utils/utils"; +import { statusType, useAbortableEffect } from "../../Common/utils"; +import { useCallback, useState } from "react"; + +import ButtonV2 from "../Common/components/ButtonV2"; import Card from "../../CAREUI/display/Card"; +import { FileUpload } from "./FileUpload"; import Page from "../Common/components/Page"; -import ButtonV2 from "../Common/components/ButtonV2"; +import _ from "lodash"; +import { formatDate } from "../../Utils/utils"; +import { getTestSample } from "../../Redux/actions"; +import loadable from "@loadable/component"; +import { navigate } from "raviger"; +import { useDispatch } from "react-redux"; const Loading = loadable(() => import("../Common/Loading")); diff --git a/src/Components/Patient/SamplePreview.tsx b/src/Components/Patient/SamplePreview.tsx index dbcfe8812b8..480e2f1b7da 100644 --- a/src/Components/Patient/SamplePreview.tsx +++ b/src/Components/Patient/SamplePreview.tsx @@ -1,94 +1,70 @@ +import { classNames, formatDate } from "../../Utils/utils"; +import { statusType, useAbortableEffect } from "../../Common/utils"; import { useCallback, useState } from "react"; -import { Box, Button, Paper, Typography } from "@material-ui/core"; -import { makeStyles } from "@material-ui/core/styles"; + +import ButtonV2 from "../Common/components/ButtonV2"; +import Page from "../Common/components/Page"; +import { SampleReportModel } from "./models"; import loadable from "@loadable/component"; -import { useDispatch } from "react-redux"; import { sampleReport } from "../../Redux/actions"; -import { statusType, useAbortableEffect } from "../../Common/utils"; -import { SampleReportModel } from "./models"; -import { formatDate } from "../../Utils/utils"; -const Loading = loadable(() => import("../Common/Loading")); -const PageTitle = loadable(() => import("../Common/PageTitle")); +import useConfig from "../../Common/hooks/useConfig"; +import { useDispatch } from "react-redux"; -const useStyles = makeStyles({ - root: { - width: "100%", - }, - contentDiv: { - minHeight: "100vh", - }, - internalUse: { - color: "#FC1514 !important", - }, - allLogo: { - maxWidth: "400px", - height: "50px", - objectFit: "contain", - }, - printBtn: { - margin: "10px", - paddingTop: "10px", - }, - mainHeader: { - fontWeight: 600, - backgroundColor: "#000000 !important", - color: "#FFFFFF !important", - }, - subHeader: { - fontWeight: 600, - backgroundColor: "#444444 !important", - color: "#FFFFFF !important", - }, - borderTop: { - borderTop: "1px solid gray", - }, - borderBottom: { - borderBottom: "1px solid gray", - }, - borderRight: { - borderRight: "1px solid gray", - }, - borderLeft: { - borderLeft: "1px solid gray", - }, - cellTitle: { - textAlign: "right", - fontWeight: 600, - paddingRight: "8px", - paddingLeft: "4px", - }, - cellText: { - textAlign: "left", - paddingLeft: "8px", - paddingRight: "4px", - whiteSpace: "pre-wrap", - wordBreak: "break-word", - }, - cellTBPadding: { - paddingTop: "8px", - paddingBottom: "8px", - }, - marginRight10: { - marginRight: "10px", - }, - boldText: { - fontWeight: "bold", - }, -}); -const coronasafeLogo = "https://cdn.coronasafe.network/coronaSafeLogo.webp"; +const Loading = loadable(() => import("../Common/Loading")); -interface samplePreviewProps { +interface ISamplePreviewProps { id: string; sampleId: string; } -export default function SampleReport(props: samplePreviewProps) { - const classes = useStyles(); + +interface ISampleReportSectionProps { + title: string; + fields: { + title: string; + value: string | undefined | null; + }[]; +} + +function SampleReportSection({ title, fields }: ISampleReportSectionProps) { + return ( + <> +
+
{title}
+
+
+ {fields.map((field, i) => ( +
+
+

+ {field.title} +

+
+
+

+ {field.value} +

+
+
+ ))} +
+ + ); +} + +export default function SampleReport(props: ISamplePreviewProps) { const dispatch: any = useDispatch(); const { id, sampleId } = props; const [isLoading, setIsLoading] = useState(false); const [sampleData, setSampleData] = useState({}); - let report: any = null; - let reportData: any = null; + const { static_ohc_green_logo } = useConfig(); + + let report: JSX.Element = <>; + let reportData: JSX.Element = <>; const fetchData = useCallback( async (status: statusType) => { @@ -115,1649 +91,388 @@ export default function SampleReport(props: samplePreviewProps) { if (sampleData) { reportData = ( <> - - - - - - - - - + + +
+
+
+
+
+
Coronasafe - - - - - - +
+
+
+
+
+

ICMR Specimen Referral Data for COVID-19 (SARS-CoV2) - - - - - +

+
+
+
+
FOR INTERNAL USE ONLY - - - - - - Sample Id : {sampleId} - - - +
+
+
+
Sample Id : {sampleId}
+
+
+
Patient Id : {id}
+
+
- - Patient Id : {id} - - -
- - - SECTION A - MANDATORY FIELDS - - - - - A.1 PERSON DETAILS - - - - - - - Patient Name - - - - - {sampleData && - sampleData.personal_details && - sampleData.personal_details.name} - - - - - - - Age - - - - - {sampleData && - sampleData.personal_details && - sampleData.personal_details.age_years}{" "} - years{""}{" "} - {sampleData && - sampleData.personal_details && - sampleData.personal_details.age_months}{" "} - Months - - - - - - - - - - Present Patient Village or Town - - - - - {sampleData && - sampleData.personal_details && - sampleData.personal_details.local_body_name} - - - - - - - Gender - - - - - {sampleData && - sampleData.personal_details && - sampleData.personal_details.gender} - - - - - - - - - - Mobile Number (Self) - - - - - {sampleData && - sampleData.personal_details && - sampleData.personal_details.phone_number} - - - - - - - District of Present Residence - - - - - {sampleData && - sampleData.personal_details && - sampleData.personal_details.district_name} - - - - - - - - - - Nationality - - - - - Indian - - - - - - - State Of Present Residence - - - - - {sampleData && - sampleData.personal_details && - sampleData.personal_details.state_name} - - - - - - - - A.2 SPECIMEN INFORMATION FROM REFERRING AGENCY - - - - - - - - Collection Date - - - - - {sampleData && - sampleData.specimen_details && - sampleData.specimen_details.created_date && - formatDate(sampleData.specimen_details.created_date)} - - - - - - - Label - - - - - {sampleData && - sampleData.specimen_details && - sampleData.specimen_details.icmr_label} - - - - - - - - - - Sample Repeated - - - - - {sampleData && - sampleData.specimen_details && - sampleData.specimen_details.is_repeated_sample !== null - ? sampleData.specimen_details.is_repeated_sample +
+
SECTION A - MANDATORY FIELDS
+
+ + + -
-
- - - - Sample Collection Facility Name - - - - - {sampleData && - sampleData.medical_conditions && - sampleData.medical_conditions.hospital_name} - - - -
- - - - - - Collection Facility Pin code - - - - - {sampleData && - sampleData.medical_conditions && - sampleData.medical_conditions.hospital_pincode} - - - - - - - - A.3 Patient Category - - - - - - {sampleData && - sampleData.specimen_details && - sampleData.specimen_details.icmr_category === "Cat 0" && ( - - - Cat 0 - Repeat Sample of Positive Case / Follow Up - case - - - )} - {sampleData && - sampleData.specimen_details && - sampleData.specimen_details.icmr_category === "Cat 1" && ( - - - Cat 1 - Symptomatic International Traveller in last - 14 days - - - )} - {sampleData && - sampleData.specimen_details && - sampleData.specimen_details.icmr_category === "Cat 2" && ( - - - Cat 2 - Symptomatic contact of lab confirmed Case - - - )} - {sampleData && - sampleData.specimen_details && - sampleData.specimen_details.icmr_category === "Cat 3" && ( - - - Cat 3 - Symptomatic Healthcare Worker - - - )} - {sampleData && - sampleData.specimen_details && - sampleData.specimen_details.icmr_category === "Cat 4" && ( - - - Cat 4 - Hospitalized SARI (Severe Acute Respiratory - illness Patient) - - - )} - {sampleData && - sampleData.specimen_details && - sampleData.specimen_details.icmr_category === - "Cat 5a" && ( - - - Cat 5a - Asymptomatic Direct and High Risk contact - of confirmed case - family Member - - - )} - {sampleData && - sampleData.specimen_details && - sampleData.specimen_details.icmr_category === - "Cat 5b" && ( - - - Cat 5b - Asymptomatic Healthcare worker in contact - with confimred case without adequete protection - - - )} - - - - - + : "NA", + }, + { + title: "Sample Collection Facility Name", + value: sampleData?.medical_conditions?.hospital_name, + }, + { + title: "Collection Facility Pin code", + value: sampleData?.medical_conditions?.hospital_pincode, + }, + ]} + /> + + { + switch (sampleData?.specimen_details?.icmr_category) { + case "Cat 0": + return "Repeat Sample of Positive Case / Follow Up case"; + case "Cat 1": + return "Symptomatic International Traveller in last 14 days"; + case "Cat 2": + return "Symptomatic contact of lab confirmed Case"; + case "Cat 3": + return "Symptomatic Healthcare Worker"; + case "Cat 4": + return "Hospitalized SARI (Severe Acute Respiratory illness Patient)"; + case "Cat 5a": + return "Asymptomatic Direct and High Risk contact of confirmed case - family Member"; + case "Cat 5b": + return "Asymptomatic Healthcare worker in contact with confimred case without adequete protection"; + } + })(), + }, + ]} + /> + +
+
SECTION B - OTHER FIELDS TO BE UPDATED - - - - - B.1 PERSON DETAILS - - - - - - - - Present Patient Address - - - - - {sampleData && - sampleData.personal_details && - sampleData.personal_details.address} - - - - - - - Pin code - - - - - {sampleData && - sampleData.personal_details && - sampleData.personal_details.pincode} - - - - - - - - - - Email Id - - - - - {sampleData && - sampleData.personal_details && - sampleData.personal_details.email} - - - - - - - Date Of Birth - - - - - {sampleData && - sampleData.personal_details && - sampleData.personal_details.date_of_birth} - - - - - - - - - - Patient Aadhar Number - - - - - .................... - - - - - - - Patient Passport Number - - - - - {sampleData && - sampleData.personal_details && - sampleData.personal_details.passport_no} - - - - - - - - B.2 EXPOSURE HISTORY ( 2 WEEKS BEFORE THE ONSET OF SYMPTOMS - ) - - - - - - - - Travel to foreign country in last 14 days - - - - - {sampleData && - sampleData.exposure_history && - sampleData.exposure_history - .has_travel_to_foreign_last_14_days !== null - ? sampleData.exposure_history - .has_travel_to_foreign_last_14_days +
+
+ + + + -
- - {/* Places of travel only if above is true*/} - - - - Places of travel - - - - - {sampleData && - sampleData.exposure_history && - sampleData.exposure_history.places_of_travel && - sampleData.exposure_history.places_of_travel.join( - ", " - )} - - - - - - - - - - Travel Start Date - - - - - {sampleData && - sampleData.exposure_history && - sampleData.exposure_history.travel_start_date} - - - - - - - Travel End Date - - - - - {sampleData && - sampleData.exposure_history && - sampleData.exposure_history.travel_end_date} - - - - - - - - - - In Contact with lab confimed Covid 19 Patient - - - - - {sampleData && - sampleData.exposure_history && - sampleData.exposure_history - .contact_with_confirmed_case !== null + : "NA", + }, + { + title: "Places of travel", + value: + sampleData?.exposure_history?.places_of_travel?.join( + ", " + ), + }, + { + title: "Travel Start Date", + value: sampleData?.exposure_history?.travel_start_date, + }, + { + title: "Travel End Date", + value: sampleData?.exposure_history?.travel_end_date, + }, + { + title: "In Contact with lab confimed Covid 19 Patient", + value: + sampleData?.exposure_history + ?.contact_with_confirmed_case !== null ? sampleData.exposure_history - .contact_with_confirmed_case + ?.contact_with_confirmed_case ? "Yes" : "No" - : ""} - - - - - - - Name of Confirmed Contacted Covid Patient - - - - - {sampleData && - sampleData.exposure_history && - sampleData.exposure_history.contact_case_name} - - - - - - - - - - Quarantine Status - - - - - {sampleData && - sampleData.exposure_history && - sampleData.exposure_history.was_quarantined !== null - ? sampleData.exposure_history.was_quarantined + : "NA", + }, + { + title: "Name of Confirmed Contacted Covid Patient", + value: sampleData?.exposure_history?.contact_case_name, + }, + { + title: "Quarantine Status", + value: + sampleData?.exposure_history?.was_quarantined !== null + ? sampleData?.exposure_history?.was_quarantined ? "Yes" : "No" - : ""} - - - - - - - Quarantine Location - - - - - {sampleData && - sampleData.exposure_history && - sampleData.exposure_history.quarantined_type} - - - - - - - - - - Health care worker working in a hospital involved in - managing patients - - - - - {sampleData && - sampleData.exposure_history && - sampleData.exposure_history.healthcare_worker !== null - ? sampleData.exposure_history.healthcare_worker + : "NA", + }, + { + title: "Quarantine Location", + value: sampleData?.exposure_history?.quarantined_type, + }, + { + title: + "Health care worker working in a hospital involved in managing patients", + value: + sampleData?.exposure_history?.healthcare_worker !== null + ? sampleData?.exposure_history?.healthcare_worker ? "Yes" : "No" - : ""} - - - - - - - - B.3 CLINICAL SYMPTOMS AND SIGNS - - - - - - - - Date of Onset of Symptoms - - - - - {sampleData && - sampleData.medical_conditions && - sampleData.medical_conditions - .date_of_onset_of_symptoms} - - - - - - - Symptoms - - - - - {sampleData && - sampleData.medical_conditions && - sampleData.medical_conditions.symptoms && - !!sampleData.medical_conditions.symptoms.length && - sampleData.medical_conditions.symptoms.join(", ")} - - - - - - - - - - First Symptom - - - - - - - - - - - - - Person has Severe Acute Respiratory illness - - - - - {sampleData && - sampleData.medical_conditions && - sampleData.medical_conditions.has_sari !== null - ? sampleData.medical_conditions.has_sari + : "NA", + }, + ]} + /> + + - - - - - - - - - Person Has Acute Respiratory Illness - - - - - {sampleData && - sampleData.medical_conditions && - sampleData.medical_conditions.has_ari !== null - ? sampleData.medical_conditions.has_ari + : "NA", + }, + { + title: "Person Has Acute Respiratory Illness", + value: + sampleData?.medical_conditions?.has_ari !== null + ? sampleData?.medical_conditions?.has_ari ? "Yes" : "No" - : ""} - - - - - - - - B.4 UNDERLYING MEDICAL CONDITIONS - - - - - {/* */} - - - Medical Conditions - - - - - {sampleData && - sampleData.medical_conditions && - sampleData.medical_conditions.medical_conditions_list && - !!sampleData.medical_conditions.medical_conditions_list - .length && - sampleData.medical_conditions.medical_conditions_list.join( + : "NA", + }, + ]} + /> + + - - {/* */} - {/**/} - {/* */} - {/* */} - {/* Immuno Compromised Conditions*/} - {/* */} - {/* */} - {/* */} - {/* */} - {/* {sampleData && sampleData.medical_conditions && sampleData.medical_conditions.has_sari}*/} - {/* */} - {/* */} - {/**/} - - - - - B.5 HOSPITALIZATION , TREATMENT AND INVESTIGATION - - - - - - - - Hospitalization Date - - - - - {sampleData && - sampleData.medical_conditions && - sampleData.medical_conditions.hospitalization_date} - - - - - - - Diagnosis - - - - - {sampleData && - sampleData.medical_conditions && - sampleData.medical_conditions.diagnosis} - - - - - - - - - - Differential diagnosis - - - - - {sampleData && - sampleData.medical_conditions && - sampleData.medical_conditions.diff_diagnosis} - - - - - - - Etiology Identified - - - - - {sampleData && - sampleData.medical_conditions && - sampleData.medical_conditions.etiology_identified} - - - - - - - - - - Asypical Presentation - - - - - {sampleData && - sampleData.medical_conditions && - sampleData.medical_conditions - .is_atypical_presentation !== null - ? sampleData.medical_conditions - .is_atypical_presentation + ), + }, + ]} + /> + + - - - - - - Unusual or Unexpected Course - - - - - {sampleData && - sampleData.medical_conditions && - sampleData.medical_conditions.is_unusual_course !== null - ? sampleData.medical_conditions.is_unusual_course + : "NA", + }, + { + title: "Unusual or Unexpected Course", + value: + sampleData?.medical_conditions?.is_unusual_course !== + null + ? sampleData?.medical_conditions?.is_unusual_course ? "Yes" : "No" - : ""} - - - - - - - {/* */} - - - Outcome - - - - - {sampleData && - sampleData.medical_conditions && - sampleData.medical_conditions.diagnosis} - - - {/* */} - {/**/} - {/* */} - {/* */} - {/* Outcome Date*/} - {/* */} - {/* */} - {/* */} - {/* */} - {/* 20-01-2020*/} - {/* */} - {/* */} - {/**/} - - - - - - - Hospital Name / Address - - - - - {sampleData && - sampleData.medical_conditions && - sampleData.medical_conditions.hospital_name} - - - - - - - Hospital Phone Number - - - - - {sampleData && - sampleData.medical_conditions && - sampleData.medical_conditions.hospital_phone_number} - - - - - - - - - - Name of Doctor - - - - - {sampleData && - sampleData.medical_conditions && - sampleData.medical_conditions.doctor_name} - - - - - - - Signature & Date - - - - + : "NA", + }, + { + title: "Hospital Name / Address", + value: sampleData?.medical_conditions?.hospital_name, + }, + { + title: "Hospital Phone Number", + value: + sampleData?.medical_conditions?.hospital_phone_number, + }, + { + title: "Name of Doctor", + value: sampleData?.medical_conditions?.doctor_name, + }, + { + title: "Signature & Date", + value: "", + }, + ]} + />
- - - +
+
+
); } if (isLoading) { report = ( - +
- +
); } else if (sampleData && reportData) { report = reportData; } else if (!sampleData) { report = ( - - - No Data Found - - +
+
No Data Found
+
); } return ( - - - {report} - +
+ + {report} + +
); }