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

Fixes: Add Health Details in Consultation form #3698

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 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
10 changes: 0 additions & 10 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -356,16 +356,6 @@ export const TEST_TYPE = [
"POCPCR",
];

export const VACCINES = [
"CoviShield",
"Covaxin",
"Sputnik",
"Moderna",
"Pfizer",
"Janssen",
"Sinovac",
];

export const BLOOD_GROUPS = [
"UNK",
"A+",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function PrescriptionDropdown(props: {
<div
ref={dropRef}
className={clsx([
"absolute z-40 top-[calc(100%+10px)] left-0 w-full rounded-md shadow-lg bg-white max-h-[300px] overflow-auto",
"absolute z-40 top-[calc(100%+15px)] left-0 w-full rounded-md shadow-lg bg-white max-h-[300px] overflow-auto",
{ hidden: !open },
])}
>
Expand Down
133 changes: 133 additions & 0 deletions src/Components/Common/prescription-builder/VaccinationBuilder.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import { PrescriptionDropdown } from "./PrescriptionDropdown";

// eslint-disable-next-line @typescript-eslint/no-var-requires
export const vaccines = require("./assets/vaccines");

interface VaccinationBuilderProps<T> {
vaccinations: T[];
setVaccinations: React.Dispatch<React.SetStateAction<T[]>>;
}

export type VaccinationDetails = {
vaccine?: string;
doses?: number;
last_vaccinated_date?: string;
};

export const emptyValues = {
vaccine: "",
doses: 0,
last_vaccinated_date: "",
};

export default function VaccinationBuilder(
props: VaccinationBuilderProps<VaccinationDetails>
) {
const { vaccinations, setVaccinations } = props;

const setItem = (object: VaccinationDetails, i: number) => {
setVaccinations(
vaccinations.map((vaccination, index) =>
index === i ? object : vaccination
)
);
};

return (
<div className="mt-2">
{vaccinations.map((vaccination, i) => {
const setVaccine = (vaccine: string) => {
setItem(
{
...vaccination,
vaccine,
},
i
);
};

return (
<div
key={i}
className="border-b border-b-gray-500 border-dashed py-2 text-xs text-gray-600"
>
<div className="flex gap-2 flex-col md:flex-row">
<div>
Vaccine
<PrescriptionDropdown
placeholder="Vaccine"
options={vaccines}
value={vaccination.vaccine || ""}
setValue={setVaccine}
/>
</div>
<div>
Doses
<input
type="number"
className="w-full focus:ring-primary-500 focus:border-primary-500 block border border-gray-400 rounded py-2 px-4 text-sm bg-gray-100 hover:bg-gray-200 focus:outline-none focus:bg-white"
value={vaccination.doses}
placeholder="Doses"
min={0}
onChange={(e) => {
let value = parseInt(e.target.value);
if (value < 0) {
value = 0;
}
setItem(
{
...vaccination,
doses: value,
},
i
);
}}
required
/>
</div>
<div>
Date
<input
type="date"
className="focus:ring-primary-500 focus:border-primary-500 block border border-gray-400 rounded py-2 px-4 text-sm bg-gray-100 hover:bg-gray-200 focus:outline-none focus:bg-white"
value={vaccination.last_vaccinated_date}
placeholder="Date"
onChange={(e) => {
setItem(
{
...vaccination,
last_vaccinated_date: e.target.value,
},
i
);
}}
required
/>
</div>
<button
type="button"
className="text-gray-400 text-base transition hover:text-red-500"
onClick={() => {
setVaccinations(
vaccinations.filter((vaccination, index) => i != index)
);
}}
>
<i className="fas fa-trash" />
</button>
</div>
</div>
);
})}
<button
type="button"
onClick={() => {
setVaccinations([...vaccinations, emptyValues]);
}}
className="shadow-sm mt-4 bg-gray-200 w-full font-bold block px-4 py-2 text-sm leading-5 text-left text-gray-700 hover:bg-gray-300 hover:text-gray-900 focus:outline-none focus:bg-gray-100 focus:text-gray-900"
>
+ Add Vaccination History
</button>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
"CoviShield",
"Covaxin",
"Sputnik",
"Moderna",
"Pfizer",
"Janssen",
"Sinovac"
]
27 changes: 16 additions & 11 deletions src/Components/Facility/ConsultationDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -528,22 +528,20 @@ export const ConsultationDetails = (props: any) => {

<div className="flex px-4 flex-col-reverse lg:flex-row gap-2">
<div className="flex flex-col w-3/4 h-full">
{/*consultationData.other_symptoms && (
<div className="capitalize">
<span className="font-semibold leading-relaxed">
Other Symptoms:{" "}
</span>
{consultationData.other_symptoms}
</div>
)*/}

{/* consultationData.other_symptoms && (
<div className="capitalize">
<span className="font-semibold leading-relaxed">
Other Symptoms:{" "}
</span>
{consultationData.other_symptoms}
</div>
) */}
<ShowDiagnosis
diagnoses={
consultationData?.icd11_provisional_diagnoses_object
}
label="Provisional Diagnosis"
/>

<ShowDiagnosis
diagnoses={[
...(consultationData?.diagnosis
Expand All @@ -559,7 +557,14 @@ export const ConsultationDetails = (props: any) => {
]}
label="Diagnosis"
/>

{consultationData?.health_details_object?.allergies && (
<div className="capitalize">
<span className="font-semibold leading-relaxed">
Allergies:{" "}
</span>
{consultationData?.health_details_object?.allergies}
</div>
)}
{consultationData.verified_by && (
<div className="text-sm mt-2">
<span className="font-semibold leading-relaxed">
Expand Down
Loading