Skip to content

Commit

Permalink
Collect postpartum data
Browse files Browse the repository at this point in the history
  • Loading branch information
Omkar76 committed Jan 7, 2024
1 parent f066a36 commit 71d5c36
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 1 deletion.
73 changes: 72 additions & 1 deletion src/Components/Patient/PatientRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ export const PatientRegister = (props: PatientRegisterProps) => {
village: res.data.village ? res.data.village : "",
medical_history: [],
is_antenatal: String(!!res.data.is_antenatal),
last_menstruation_start_date: res.data.last_menstruation_start_date,
is_postpartum: String(!!res.data.is_postpartum),
date_of_delivery: res.data.date_of_delivery,
allergies: res.data.allergies ? res.data.allergies : "",
pincode: res.data.pincode ? res.data.pincode : "",
ongoing_medication: res.data.ongoing_medication
Expand Down Expand Up @@ -562,6 +565,8 @@ export const PatientRegister = (props: PatientRegisterProps) => {
case "name":
case "gender":
case "date_of_birth":
case "last_menstruation_start_date":
case "date_of_delivery":
errors[field] = RequiredFieldValidator()(form[field]);
return;
case "permanent_address":
Expand Down Expand Up @@ -776,6 +781,15 @@ export const PatientRegister = (props: PatientRegisterProps) => {
gender: Number(formData.gender),
nationality: formData.nationality,
is_antenatal: formData.is_antenatal,
is_postpartum: formData.is_postpartum,
last_menstruation_start_date:
formData.is_antenatal === "true"
? dateQueryString(formData.last_menstruation_start_date)
: null,
date_of_delivery:
formData.is_postpartum === "true"
? dateQueryString(formData.date_of_delivery)
: null,
passport_no:
formData.nationality !== "India" ? formData.passport_no : undefined,
state: formData.nationality === "India" ? formData.state : undefined,
Expand Down Expand Up @@ -1299,6 +1313,20 @@ export const PatientRegister = (props: PatientRegisterProps) => {
required
label="Gender"
options={genderTypes}
onChange={(e) => {
field("gender").onChange(e);
if (e.value !== "2") {
field("is_antenatal").onChange({
name: "is_antenatal",
value: "false",
});

field("is_postpartum").onChange({
name: "is_postpartum",
value: "false",
});
}
}}
optionLabel={(o: any) => o.text}
optionValue={(o: any) => o.id}
/>
Expand All @@ -1310,7 +1338,7 @@ export const PatientRegister = (props: PatientRegisterProps) => {
<div id="is_antenatal-div" className="col-span-2">
<RadioFormField
{...field("is_antenatal")}
label="Is antenatal ?"
label="Is antenatal?"
aria-label="is_antenatal"
options={[
{ label: "Yes", value: "true" },
Expand All @@ -1322,6 +1350,49 @@ export const PatientRegister = (props: PatientRegisterProps) => {
</div>
}
</CollapseV2>
<CollapseV2
opened={field("is_antenatal").value === "true"}
>
{
<div className="col-span-2">
<DateFormField
containerClassName="w-full"
{...field("last_menstruation_start_date")}
label="Last Menstruation Start Date"
position="LEFT"
disableFuture
required
/>
</div>
}
</CollapseV2>
<CollapseV2
opened={String(field("gender").value) === "2"}
>
<RadioFormField
{...field("is_postpartum")}
label="Is post partum (<6 weeks)"
className="font-bold"
options={[
{ label: "Yes", value: "true" },
{ label: "No", value: "false" },
]}
optionDisplay={(option) => option.label}
optionValue={(option) => option.value}
/>
</CollapseV2>
<CollapseV2
opened={field("is_postpartum").value === "true"}
>
<DateFormField
containerClassName="w-full"
{...field("date_of_delivery")}
label="Date of Delivery"
position="LEFT"
disableFuture
required
/>
</CollapseV2>
<div data-testid="current-address" id="address-div">
<TextAreaFormField
{...field("address")}
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Patient/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ export interface PatientModel {
medical_history_details?: string;
is_active?: boolean;
is_antenatal?: boolean;
last_menstruation_start_date?: string;
is_postpartum?: boolean;
date_of_delivery?: string;
is_migrant_worker?: boolean;
ward?: string;
local_body_object?: { id: number; name: string };
Expand Down

0 comments on commit 71d5c36

Please sign in to comment.