From 71d5c365ddcb430e48f3b15830419d6092a17901 Mon Sep 17 00:00:00 2001 From: Onkar Jadhav Date: Sun, 7 Jan 2024 18:13:28 +0530 Subject: [PATCH 1/9] Collect postpartum data --- src/Components/Patient/PatientRegister.tsx | 73 +++++++++++++++++++++- src/Components/Patient/models.tsx | 3 + 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index 77088ef57e7..140e321a4d6 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -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 @@ -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": @@ -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, @@ -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} /> @@ -1310,7 +1338,7 @@ export const PatientRegister = (props: PatientRegisterProps) => {
{
} + + { +
+ +
+ } +
+ + option.label} + optionValue={(option) => option.value} + /> + + + +
Date: Wed, 17 Jan 2024 05:10:55 +0530 Subject: [PATCH 2/9] Make is_postpartum a frontend only field and fix validtion issue --- src/Components/Patient/PatientRegister.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index 140e321a4d6..fb35ba706e3 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -423,8 +423,8 @@ export const PatientRegister = (props: PatientRegisterProps) => { 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, + 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 @@ -565,9 +565,17 @@ export const PatientRegister = (props: PatientRegisterProps) => { case "name": case "gender": 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": - errors[field] = RequiredFieldValidator()(form[field]); + if (form.is_postpartum === "true") { + errors[field] = RequiredFieldValidator()(form[field]); + } return; case "permanent_address": if (!form.sameAddress) { @@ -781,7 +789,6 @@ 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) From 48c34acf10aec351c5e9602b96fe9aa6acbd6453 Mon Sep 17 00:00:00 2001 From: Onkar Jadhav Date: Wed, 17 Jan 2024 05:14:26 +0530 Subject: [PATCH 3/9] Typo fix --- src/Components/Patient/PatientRegister.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index fb35ba706e3..774f756c817 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -1378,7 +1378,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { > Date: Sat, 24 Feb 2024 02:23:01 +0530 Subject: [PATCH 4/9] fix failing test: type last menstruation date --- cypress/e2e/patient_spec/patient_registration.cy.ts | 1 + cypress/pageobject/Patient/PatientCreation.ts | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/cypress/e2e/patient_spec/patient_registration.cy.ts b/cypress/e2e/patient_spec/patient_registration.cy.ts index 1dce2c7c6f7..cd1c257509f 100644 --- a/cypress/e2e/patient_spec/patient_registration.cy.ts +++ b/cypress/e2e/patient_spec/patient_registration.cy.ts @@ -142,6 +142,7 @@ describe("Patient Creation with consultation", () => { cy.wait(3000); patientPage.selectPatientGender(patientOneUpdatedGender); patientPage.clickPatientAntenatalStatusYes(); + patientPage.typeLastMenstruationStartDate("01012021"); patientPage.selectPatientBloodGroup(patientOneUpdatedBloodGroup); // Edit the patient consultation , select none medical history and multiple health ID patientMedicalHistory.clickNoneMedicialHistory(); diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index 07d87e024a1..b0c0eb25664 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -72,6 +72,11 @@ export class PatientPage { .type(address); } + typeLastMenstruationStartDate(date: string) { + cy.get("#last_menstruation_start_date").click(); + cy.get("#date-input").click().type(date); + } + clickPermanentAddress() { cy.get("[data-testid=permanent-address] input").check(); } From a338cf6128ec585e78eb980c7a5f6b4cb4dfcd90 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Thu, 2 May 2024 14:43:34 +0530 Subject: [PATCH 5/9] show post partum badge in patient details page --- src/Components/Patient/PatientHome.tsx | 33 +++++++++++++++------- src/Components/Patient/PatientRegister.tsx | 2 +- src/Components/Patient/models.tsx | 1 - 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/Components/Patient/PatientHome.tsx b/src/Components/Patient/PatientHome.tsx index 3e1e9b0a09a..f4bcfbccf92 100644 --- a/src/Components/Patient/PatientHome.tsx +++ b/src/Components/Patient/PatientHome.tsx @@ -368,16 +368,29 @@ export const PatientHome = (props: any) => { ) : ( )} - {patientData.gender === 2 && - patientData.is_antenatal && - patientData.is_active && ( - - )} + {patientData.gender === 2 && ( + <> + {patientData.is_antenatal && ( + + )} + {dayjs(patientData.date_of_delivery).diff( + undefined, + "week", + ) <= 6 && ( + + )} + + )} {patientData.contact_with_confirmed_carrier && ( { )} <>
- + defaults={id ? state.form : initForm} validate={validateForm} onSubmit={handleSubmit} diff --git a/src/Components/Patient/models.tsx b/src/Components/Patient/models.tsx index d9cd9222656..9a56962fa7d 100644 --- a/src/Components/Patient/models.tsx +++ b/src/Components/Patient/models.tsx @@ -69,7 +69,6 @@ export interface PatientModel { is_active?: boolean; is_antenatal?: boolean; last_menstruation_start_date?: string; - is_postpartum?: boolean; date_of_delivery?: string; is_migrant_worker?: boolean; ward?: string; From 4659f7a837b53833226387562aec74a37bd02a0d Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Thu, 2 May 2024 15:09:54 +0530 Subject: [PATCH 6/9] show perinatal status in consultation dashboard --- .../ConsultationUpdatesTab.tsx | 51 +++++++++++++++++++ src/Components/Patient/PatientHome.tsx | 6 +-- src/Utils/utils.ts | 4 ++ 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx index f4150617f1f..2dae90bc9d3 100644 --- a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx +++ b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx @@ -19,6 +19,7 @@ import { formatDate, formatDateTime, formatPatientAge, + isPostPartum, } from "../../../Utils/utils"; import ReadMore from "../../Common/components/Readmore"; import DailyRoundsList from "../Consultations/DailyRoundsList"; @@ -26,6 +27,7 @@ import EventsList from "./Events/EventsList"; import SwitchTabs from "../../Common/components/SwitchTabs"; import { getVitalsMonitorSocketUrl } from "../../VitalsMonitor/utils"; import { FileUpload } from "../../Patient/FileUpload"; +import CareIcon from "../../../CAREUI/icons/CareIcon"; const PageTitle = lazy(() => import("../../Common/PageTitle")); @@ -321,6 +323,55 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => {
)} + {(props.patientData.is_antenatal || + isPostPartum(props.patientData.date_of_delivery)) && ( +
+

+ Perinatal Status +

+ +
+ {props.patientData.is_antenatal && ( + + )} + {isPostPartum(props.patientData.date_of_delivery) && ( + + )} +
+ + {props.patientData.last_menstruation_start_date && ( +

+ + Last Menstruation: + + {formatDate( + props.patientData.last_menstruation_start_date, + )} + +

+ )} + + {props.patientData.date_of_delivery && ( +

+ + Date of Delivery: + + {formatDate(props.patientData.date_of_delivery)} + +

+ )} +
+ )} {props.consultationData.symptoms_text && (
diff --git a/src/Components/Patient/PatientHome.tsx b/src/Components/Patient/PatientHome.tsx index f4bcfbccf92..5b3468fbbba 100644 --- a/src/Components/Patient/PatientHome.tsx +++ b/src/Components/Patient/PatientHome.tsx @@ -19,6 +19,7 @@ import { formatDate, formatDateTime, formatPatientAge, + isPostPartum, } from "../../Utils/utils"; import ButtonV2 from "../Common/components/ButtonV2"; import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor"; @@ -378,10 +379,7 @@ export const PatientHome = (props: any) => { text="Antenatal" /> )} - {dayjs(patientData.date_of_delivery).diff( - undefined, - "week", - ) <= 6 && ( + {isPostPartum(patientData.date_of_delivery) && ( { } return value.toFixed(2); }; + +export const isPostPartum = (data_of_delivery?: string) => { + return dayjs(data_of_delivery).diff(undefined, "week") <= 6; +}; From 11c4e13069bbd78b5eae863e65da82d592a6f8f5 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Tue, 7 May 2024 13:56:30 +0530 Subject: [PATCH 7/9] fix cypress --- .../patient_spec/patient_registration.cy.ts | 20 +++++++++++++++- cypress/pageobject/Patient/PatientCreation.ts | 18 +++++++++++++++ .../ConsultationUpdatesTab.tsx | 23 +++++++++++-------- src/Components/Patient/PatientHome.tsx | 20 +++++++++------- src/Utils/utils.ts | 4 ++++ 5 files changed, 67 insertions(+), 18 deletions(-) diff --git a/cypress/e2e/patient_spec/patient_registration.cy.ts b/cypress/e2e/patient_spec/patient_registration.cy.ts index ddbf7857a5b..c6433e5ed83 100644 --- a/cypress/e2e/patient_spec/patient_registration.cy.ts +++ b/cypress/e2e/patient_spec/patient_registration.cy.ts @@ -18,6 +18,20 @@ const calculateAge = () => { return currentYear - parseInt(yearOfBirth); }; +const getRelativeDateString = (deltaDays = 0) => { + const date = new Date(); + if (deltaDays) { + date.setDate(date.getDate() + deltaDays); + } + return date + .toLocaleDateString("en-IN", { + day: "2-digit", + month: "2-digit", + year: "numeric", + }) + .replace("/", ""); +}; + describe("Patient Creation with consultation", () => { const loginPage = new LoginPage(); const patientPage = new PatientPage(); @@ -31,6 +45,8 @@ describe("Patient Creation with consultation", () => { const age = calculateAge(); const patientFacility = "Dummy Facility 40"; const patientDateOfBirth = "01012001"; + const patientMenstruationStartDate = getRelativeDateString(-10); + const patientDateOfDelivery = getRelativeDateString(-20); const patientOneName = "Patient With No Consultation"; const patientOneGender = "Male"; const patientOneUpdatedGender = "Female"; @@ -148,7 +164,9 @@ describe("Patient Creation with consultation", () => { patientPage.selectPatientGender(patientOneUpdatedGender); patientPage.typePatientDateOfBirth(patientDateOfBirth); patientPage.clickPatientAntenatalStatusYes(); - patientPage.typeLastMenstruationStartDate("01012021"); + patientPage.typeLastMenstruationStartDate(patientMenstruationStartDate); + patientPage.clickPatientPostPartumStatusYes(); + patientPage.typeDateOfDelivery(patientDateOfDelivery); patientPage.selectPatientBloodGroup(patientOneUpdatedBloodGroup); // Edit the patient consultation , select none medical history and multiple health ID patientMedicalHistory.clickNoneMedicialHistory(); diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index 84db89ad61d..e622b8c7206 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -79,6 +79,11 @@ export class PatientPage { cy.get("#date-input").click().type(date); } + typeDateOfDelivery(date: string) { + cy.get("#date_of_delivery").click(); + cy.get("#date-input").click().type(date); + } + clickPermanentAddress() { cy.get("[data-testid=permanent-address] input").check(); } @@ -87,6 +92,10 @@ export class PatientPage { cy.get("#is_antenatal-0").click(); } + clickPatientPostPartumStatusYes() { + cy.get("#is_postpartum-0").click(); + } + clickCancelButton() { cy.get("#cancel").click(); } @@ -151,6 +160,8 @@ export class PatientPage { yearOfBirth, bloodGroup, occupation, + isAntenatal, + isPostPartum, ) { cy.url().should("include", "/facility/"); cy.get("[data-testid=patient-dashboard]").then(($dashboard) => { @@ -162,6 +173,13 @@ export class PatientPage { expect($dashboard).to.contain(yearOfBirth); expect($dashboard).to.contain(bloodGroup); expect($dashboard).to.contain(occupation); + + if (isAntenatal) { + expect($dashboard).to.contain("Antenatal"); + } + if (isPostPartum) { + expect($dashboard).to.contain("Post-partum"); + } }); } diff --git a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx index 2dae90bc9d3..2b44e873d1e 100644 --- a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx +++ b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx @@ -19,6 +19,7 @@ import { formatDate, formatDateTime, formatPatientAge, + isAntenatal, isPostPartum, } from "../../../Utils/utils"; import ReadMore from "../../Common/components/Readmore"; @@ -323,7 +324,8 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => {
)} - {(props.patientData.is_antenatal || + {((props.patientData.is_antenatal && + isAntenatal(props.patientData.last_menstruation_start_date)) || isPostPartum(props.patientData.date_of_delivery)) && (

@@ -331,14 +333,17 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => {

- {props.patientData.is_antenatal && ( - - )} + {props.patientData.is_antenatal && + isAntenatal( + props.patientData.last_menstruation_start_date, + ) && ( + + )} {isPostPartum(props.patientData.date_of_delivery) && ( { )} {patientData.gender === 2 && ( <> - {patientData.is_antenatal && ( - - )} + {patientData.is_antenatal && + isAntenatal( + patientData.last_menstruation_start_date, + ) && ( + + )} {isPostPartum(patientData.date_of_delivery) && ( { export const isPostPartum = (data_of_delivery?: string) => { return dayjs(data_of_delivery).diff(undefined, "week") <= 6; }; + +export const isAntenatal = (menstruation_start_date?: string) => { + return dayjs(menstruation_start_date).diff(undefined, "month") <= 9; +}; From 53294b3b8746ea02bc26a888da2337c0b55fad29 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Wed, 8 May 2024 15:07:59 +0530 Subject: [PATCH 8/9] reverse the diff check for post partum and antenatal checks --- src/Utils/utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Utils/utils.ts b/src/Utils/utils.ts index eff9ada0ef6..38ffc2e1c66 100644 --- a/src/Utils/utils.ts +++ b/src/Utils/utils.ts @@ -440,9 +440,9 @@ export const properRoundOf = (value: number) => { }; export const isPostPartum = (data_of_delivery?: string) => { - return dayjs(data_of_delivery).diff(undefined, "week") <= 6; + return dayjs().diff(data_of_delivery, "week") <= 6; }; export const isAntenatal = (menstruation_start_date?: string) => { - return dayjs(menstruation_start_date).diff(undefined, "month") <= 9; + return dayjs().diff(menstruation_start_date, "month") <= 9; }; From 098e07c7e7a2190457c2cb9043c47ecdb29adab5 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Wed, 8 May 2024 16:52:36 +0530 Subject: [PATCH 9/9] hide antental filters --- src/Components/Patient/ManagePatients.tsx | 7 ++++++- src/Components/Patient/PatientFilter.tsx | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Components/Patient/ManagePatients.tsx b/src/Components/Patient/ManagePatients.tsx index 894cea89e6e..ff4838c5822 100644 --- a/src/Components/Patient/ManagePatients.tsx +++ b/src/Components/Patient/ManagePatients.tsx @@ -31,7 +31,11 @@ import RecordMeta from "../../CAREUI/display/RecordMeta"; import SearchInput from "../Form/SearchInput"; import SortDropdownMenu from "../Common/SortDropdown"; import SwitchTabs from "../Common/components/SwitchTabs"; -import { formatPatientAge, parsePhoneNumber } from "../../Utils/utils.js"; +import { + formatPatientAge, + isAntenatal, + parsePhoneNumber, +} from "../../Utils/utils.js"; import useFilters from "../../Common/hooks/useFilters"; import { useTranslation } from "react-i18next"; import Page from "../Common/components/Page.js"; @@ -597,6 +601,7 @@ export const PatientManager = () => { )} {patient.gender === 2 && patient.is_antenatal && + isAntenatal(patient.last_menstruation_start_date) && patient.is_active && (
-
+ {/*
Is Antenatal -
+
*/}
Review Missed