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

Collect postpartum data #6993

Merged
merged 18 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
80 changes: 79 additions & 1 deletion src/Components/Patient/PatientRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,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,
date_of_delivery: res.data.date_of_delivery,
is_postpartum: String(!!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 @@ -567,6 +570,16 @@ export const PatientRegister = (props: PatientRegisterProps) => {
case "date_of_birth":
errors[field] = RequiredFieldValidator()(form[field]);
return;
case "last_menstruation_start_date":
if (form.is_antenatal === "true") {
errors[field] = RequiredFieldValidator()(form[field]);
}
return;
case "date_of_delivery":
if (form.is_postpartum === "true") {
errors[field] = RequiredFieldValidator()(form[field]);
}
return;
case "permanent_address":
if (!form.sameAddress) {
errors[field] = RequiredFieldValidator()(form[field]);
Expand Down Expand Up @@ -779,6 +792,14 @@ export const PatientRegister = (props: PatientRegisterProps) => {
gender: Number(formData.gender),
nationality: formData.nationality,
is_antenatal: formData.is_antenatal,
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 @@ -1316,6 +1337,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 @@ -1327,7 +1362,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 @@ -1339,6 +1374,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 postpartum? (<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
Loading