Skip to content

Commit

Permalink
add more medical history fields
Browse files Browse the repository at this point in the history
  • Loading branch information
AshrafMd-1 committed May 22, 2024
1 parent 0815b94 commit 2a2027f
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 23 deletions.
9 changes: 5 additions & 4 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,11 @@ export const MEDICAL_HISTORY_CHOICES: Array<OptionsType> = [
{ id: 8, text: "Bronchitis" },
{ id: 9, text: "Chronic Neurological Or Neuromuscular Disease" },
{ id: 10, text: "Immunocompromised Condition" },
{ id: 11, text: "TB" },
{ id: 12, text: "Other Chronic Lung Diseases" },
{ id: 13, text: "Cancer" },
{ id: 14, text: "OTHER" },
{ id: 11, text: "Liver Disease" },
{ id: 12, text: "TB" },
{ id: 13, text: "Other Chronic Lung Diseases" },
{ id: 14, text: "Cancer" },
{ id: 15, text: "OTHER" },
];

export const REVIEW_AT_CHOICES: Array<OptionsType> = [
Expand Down
10 changes: 10 additions & 0 deletions src/Components/Patient/PatientHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@ export const PatientHome = (props: any) => {
<div className="sm:col-span-1" key={`med_his_${idx}`}>
<div className="break-words text-sm font-semibold leading-5 text-zinc-400">
{item.disease}
{item.disease === "Cancer" && item.type && (
<span className="text-sm font-semibold leading-5 text-zinc-400">
{` [ ${item.type} ]`}
</span>
)}
{item.disease === "TB" && (item.duration || item.status) && (
<span className="text-sm font-semibold leading-5 text-zinc-400">
{` [ ${item.status} - ${item.duration} ]`}
</span>
)}
</div>
<div className="mt-1 whitespace-normal break-words text-sm font-medium leading-5">
{item.details}
Expand Down
49 changes: 31 additions & 18 deletions src/Components/Patient/PatientRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ interface medicalHistoryModel {
id?: number;
disease: string | number;
details: string;
extra_info?: object;
duration?: number;
status?: string;
type?: string;
}

const medicalHistoryChoices = MEDICAL_HISTORY_CHOICES.reduce(
Expand Down Expand Up @@ -437,6 +439,12 @@ export const PatientRegister = (props: PatientRegisterProps) => {
formData.medical_history.push(Number(medicalHistory.id));
(formData as any)[`medical_history_${medicalHistory.id}`] =
i.details;
if (medicalHistory.id === 12) {
(formData as any)["tb_status"] = i.status;
(formData as any)["tb_duration"] = i.duration;
} else if (medicalHistory.id === 14) {
(formData as any)["cancer_type"] = i.type;
}
}
},
);
Expand Down Expand Up @@ -667,22 +675,18 @@ export const PatientRegister = (props: PatientRegisterProps) => {
const medData = MEDICAL_HISTORY_CHOICES.find((i) => i.id === id);
if (medData) {
const details = formData[`medical_history_${medData.id}`];
if (medData.id === 11) {
if (medData.id === 12) {
medical_history.push({
disease: medData.text,
details: details ? details : "",
extra_info: {
tb_status: formData["tb_status"] ?? "",
tb_duration: formData["tb_duration"] ?? "",
},
status: formData["tb_status"] ?? undefined,
duration: Number(formData["tb_duration"]) ?? undefined,
});
} else if (medData.id === 13) {
} else if (medData.id === 14) {
medical_history.push({
disease: medData.text,
details: details ? details : "",
extra_info: {
cancer_type: formData["cancer_type"] ?? "",
},
type: formData["cancer_type"] ?? undefined,
});
} else {
medical_history.push({
Expand Down Expand Up @@ -958,6 +962,17 @@ export const PatientRegister = (props: PatientRegisterProps) => {
const renderMedicalHistory = (id: number, title: string, field: any) => {
const checkboxField = `medical_history_check_${id}`;
const textField = `medical_history_${id}`;
const filteredCancerHistoryChoices = CANCER_HISTORY_CHOICES.filter((i) => {
const gender = field("gender").value;
if (gender === 1) {
return i.id !== 1 && i.id !== 5;
} else if (gender === 2) {
return i.id !== 8;
} else {
return true;
}
}).map((i) => i.text);

return (
<div key={textField}>
<div>
Expand All @@ -969,13 +984,12 @@ export const PatientRegister = (props: PatientRegisterProps) => {
/>
</div>
{/* TB */}
{id === 11 && (field("medical_history").value ?? []).includes(id) && (
{id === 12 && (field("medical_history").value ?? []).includes(id) && (
<div>
<SelectFormField
{...field("tb_status")}
position="above"
placeholder={"Status"}
required
options={["Active", "Old"]}
optionLabel={(o: any) => o}
optionValue={(o: any) => o}
Expand All @@ -989,16 +1003,15 @@ export const PatientRegister = (props: PatientRegisterProps) => {
</div>
)}
{/* Cancer */}
{id === 13 && (field("medical_history").value ?? []).includes(id) && (
{id === 14 && (field("medical_history").value ?? []).includes(id) && (
<div className="mx-4">
<SelectFormField
{...field("cancer_type")}
position="above"
required
placeholder={"Cancer Type"}
options={CANCER_HISTORY_CHOICES.map((i) => i.text)}
optionLabel={(o: any) => o}
optionValue={(o: any) => o}
placeholder="Cancer Type"
options={filteredCancerHistoryChoices}
optionLabel={(o) => o}
optionValue={(o) => o}
/>
</div>
)}
Expand Down
10 changes: 9 additions & 1 deletion src/Components/Patient/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ export interface AssignedToObjectModel {
user_type: string;
}

export interface MedicalHistoryModel {
disease: string | number;
details: string;
type?: string;
duration?: number;
status?: string;
}

export interface AbhaObject {
id: number;
created_date: string;
Expand Down Expand Up @@ -61,7 +69,7 @@ export interface PatientModel {
phone_number?: string;
emergency_phone_number?: string;
allergies?: string;
medical_history?: Array<{ disease: string | number; details: string }>;
medical_history?: Array<MedicalHistoryModel>;
facility_object?: {
id: number;
name: string;
Expand Down

0 comments on commit 2a2027f

Please sign in to comment.