From 145726781dadc472aefba85ee9c0cbaf0ef376ff Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Fri, 1 Sep 2023 06:44:41 +0000 Subject: [PATCH 01/10] Improve Prescriptions table when No Medicines prescribed (#6200) --- .../PrescriptionAdministrationsTable.tsx | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Components/Medicine/PrescriptionAdministrationsTable.tsx b/src/Components/Medicine/PrescriptionAdministrationsTable.tsx index d1fc610d055..c60d531baa3 100644 --- a/src/Components/Medicine/PrescriptionAdministrationsTable.tsx +++ b/src/Components/Medicine/PrescriptionAdministrationsTable.tsx @@ -126,6 +126,9 @@ export default function PrescriptionAdministrationsTable({ border onClick={() => setShowBulkAdminister(true)} className="w-full" + disabled={ + state === undefined || state.prescriptions.length === 0 + } > @@ -221,18 +224,19 @@ export default function PrescriptionAdministrationsTable({ refetch={refetch} /> ))} - {state?.prescriptions.length === 0 && ( -
- -

- {prn - ? "No PRN Prescriptions Prescribed" - : "No Prescriptions Prescribed"} -

-
- )} + + {state?.prescriptions.length === 0 && ( +
+ +

+ {prn + ? "No PRN Prescriptions Prescribed" + : "No Prescriptions Prescribed"} +

+
+ )} ); @@ -547,7 +551,7 @@ function getAdministrationBounds(prescriptions: Prescription[]) { curr.last_administered_on && curr.last_administered_on > latest ? curr.last_administered_on : latest, - prescriptions[0].created_date ?? new Date() + prescriptions[0]?.created_date ?? new Date() ) ); From e21652b96948981d589319fa85080d45e5f26244 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Fri, 1 Sep 2023 20:51:19 +0530 Subject: [PATCH 02/10] Fix Patient Crud Cypress (#6202) * Fix Patient Crud * Fix asset creation cypress test * Update cypress to 13.1 --------- Co-authored-by: Ashesh3 <3626859+Ashesh3@users.noreply.github.com> --- cypress/e2e/assets_spec/assets_manage.cy.ts | 4 +-- cypress/e2e/patient_spec/patient_crud.cy.ts | 15 ++++----- cypress/e2e/users_spec/user_crud.cy.ts | 6 ++-- cypress/pageobject/Asset/AssetCreation.ts | 7 +++-- package-lock.json | 34 +++++++++++++++------ package.json | 2 +- 6 files changed, 43 insertions(+), 25 deletions(-) diff --git a/cypress/e2e/assets_spec/assets_manage.cy.ts b/cypress/e2e/assets_spec/assets_manage.cy.ts index 27843d7fa85..d04a7733c0d 100644 --- a/cypress/e2e/assets_spec/assets_manage.cy.ts +++ b/cypress/e2e/assets_spec/assets_manage.cy.ts @@ -56,7 +56,7 @@ describe("Asset", () => { "email@support.com", "Vendor's Name", serialNumber, - "2021-12-25", + "25122021", "Test note for asset creation!" ); @@ -80,7 +80,7 @@ describe("Asset", () => { "email@support.com", "Vendor's Name", serialNumber, - "2021-12-25", + "25122021", "Test note for asset creation!" ); diff --git a/cypress/e2e/patient_spec/patient_crud.cy.ts b/cypress/e2e/patient_spec/patient_crud.cy.ts index d555e14ec19..ff8ffaefcfc 100644 --- a/cypress/e2e/patient_spec/patient_crud.cy.ts +++ b/cypress/e2e/patient_spec/patient_crud.cy.ts @@ -3,7 +3,8 @@ import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress"; const username = "devdistrictadmin"; const password = "Coronasafe@123"; const phone_number = "9" + Math.floor(100000000 + Math.random() * 900000000); -const emergency_phone_number = "9430123487"; +const emergency_phone_number = + "9" + Math.floor(100000000 + Math.random() * 900000000); const yearOfBirth = "2023"; let patient_url = ""; @@ -104,9 +105,11 @@ describe("Patient Creation with consultation", () => { cy.get("[data-testid=name] input").clear(); cy.get("[data-testid=name] input").type("Test E2E User Edited"); cy.get("#phone_number-div").clear(); - cy.get("#phone_number-div").type("+919846856666"); + cy.get("#phone_number-div").type("+91").type(phone_number); cy.get("#emergency_phone_number-div").clear(); - cy.get("#emergency_phone_number-div").type("+919120330220"); + cy.get("#emergency_phone_number-div") + .type("+91") + .type(emergency_phone_number); cy.get("#present_health").type("Severe Cough"); cy.get("#ongoing_medication").type("Paracetamol"); cy.get("#allergies").type("Dust"); @@ -142,10 +145,7 @@ describe("Patient Creation with consultation", () => { "contain", "Test E2E User Edited" ); - cy.get("[data-testid=patient-dashboard]").should( - "contain", - "+919120330220" - ); + cy.get("[data-testid=patient-dashboard]").should("contain", phone_number); const patientDetails_values: string[] = [ "Severe Cough", "Paracetamol", @@ -165,6 +165,7 @@ describe("Patient Creation with consultation", () => { cy.intercept("GET", "**/api/v1/patient/**").as("getFacilities"); cy.visit(patient_url + "/consultation"); cy.wait("@getFacilities").its("response.statusCode").should("eq", 200); + cy.get("#history_of_present_illness").scrollIntoView; cy.get("#history_of_present_illness").should("be.visible"); cy.get("#history_of_present_illness").click().type("histroy"); cy.get("#consultation_status") diff --git a/cypress/e2e/users_spec/user_crud.cy.ts b/cypress/e2e/users_spec/user_crud.cy.ts index 18ee627851c..41a12a891a8 100644 --- a/cypress/e2e/users_spec/user_crud.cy.ts +++ b/cypress/e2e/users_spec/user_crud.cy.ts @@ -38,7 +38,7 @@ describe("User management", () => { cy.intercept(/\/api\/v1\/facility/).as("facility"); cy.get("[name='facilities']") .click() - .type("cypress facility") + .type("Dummy Facility 1") .wait("@facility"); cy.get("li[role='option']").first().click(); cy.get("input[type='checkbox']").click(); @@ -93,7 +93,7 @@ describe("User management", () => { cy.get("button[id='facilities']").click(); cy.wait("@userFacility") .getAttached("div[id=facility_0] > div > span") - .contains("cypress facility"); + .contains("Dummy Facility 1"); }); }); @@ -102,7 +102,7 @@ describe("User management", () => { cy.intercept(/\/api\/v1\/facility/).as("getFacilities"); cy.get("[name='facility']") .click() - .type("cypress facility") + .type("Dummy Facility 1") .wait("@getFacilities"); cy.get("li[role='option']").first().click(); cy.intercept(/\/api\/v1\/users\/\w+\/add_facility\//).as("addFacility"); diff --git a/cypress/pageobject/Asset/AssetCreation.ts b/cypress/pageobject/Asset/AssetCreation.ts index 44841a34a65..d24c93d0197 100644 --- a/cypress/pageobject/Asset/AssetCreation.ts +++ b/cypress/pageobject/Asset/AssetCreation.ts @@ -67,9 +67,10 @@ export class AssetPage { cy.get("[data-testid=asset-support-email-input] input").type(supportEmail); cy.get("[data-testid=asset-vendor-name-input] input").type(vendorName); cy.get("[data-testid=asset-serial-number-input] input").type(serialNumber); - cy.get("[data-testid=asset-last-serviced-on-input] input").type( - lastServicedOn - ); + cy.get( + "[data-testid=asset-last-serviced-on-input] input[type='text']" + ).click(); + cy.get("#date-input").click().type(lastServicedOn); cy.get("[data-testid=asset-notes-input] textarea").type(notes); } diff --git a/package-lock.json b/package-lock.json index bc74da4e4d4..dda8ac9dd79 100644 --- a/package-lock.json +++ b/package-lock.json @@ -92,7 +92,7 @@ "@typescript-eslint/parser": "^5.61.0", "@vitejs/plugin-react-swc": "^3.3.2", "autoprefixer": "^10.4.14", - "cypress": "^12.17.4", + "cypress": "^13.1.0", "cypress-localstorage-commands": "^2.2.3", "eslint": "^8.44.0", "eslint-config-prettier": "^8.8.0", @@ -2261,9 +2261,9 @@ } }, "node_modules/@cypress/request": { - "version": "2.88.12", - "resolved": "https://registry.npmjs.org/@cypress/request/-/request-2.88.12.tgz", - "integrity": "sha512-tOn+0mDZxASFM+cuAP9szGUGPI1HwWVSvdzm7V4cCsPdFTx6qMj29CwaQmRAMIEhORIUBFBsYROYJcveK4uOjA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@cypress/request/-/request-3.0.0.tgz", + "integrity": "sha512-GKFCqwZwMYmL3IBoNeR2MM1SnxRIGERsQOTWeQKoYBt2JLqcqiy7JXqO894FLrpjZYqGxW92MNwRH2BN56obdQ==", "dev": true, "dependencies": { "aws-sign2": "~0.7.0", @@ -7789,13 +7789,13 @@ "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==" }, "node_modules/cypress": { - "version": "12.17.4", - "resolved": "https://registry.npmjs.org/cypress/-/cypress-12.17.4.tgz", - "integrity": "sha512-gAN8Pmns9MA5eCDFSDJXWKUpaL3IDd89N9TtIupjYnzLSmlpVr+ZR+vb4U/qaMp+lB6tBvAmt7504c3Z4RU5KQ==", + "version": "13.1.0", + "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.1.0.tgz", + "integrity": "sha512-LUKxCYlB973QBFls1Up4FAE9QIYobT+2I8NvvAwMfQS2YwsWbr6yx7y9hmsk97iqbHkKwZW3MRjoK1RToBFVdQ==", "dev": true, "hasInstallScript": true, "dependencies": { - "@cypress/request": "2.88.12", + "@cypress/request": "^3.0.0", "@cypress/xvfb": "^1.2.4", "@types/node": "^16.18.39", "@types/sinonjs__fake-timers": "8.1.1", @@ -7843,7 +7843,7 @@ "cypress": "bin/cypress" }, "engines": { - "node": "^14.0.0 || ^16.0.0 || >=18.0.0" + "node": "^16.0.0 || ^18.0.0 || >=20.0.0" } }, "node_modules/cypress-localstorage-commands": { @@ -14564,6 +14564,8 @@ }, "node_modules/npm/node_modules/cross-spawn/node_modules/which": { "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, "inBundle": true, "license": "ISC", @@ -15364,6 +15366,8 @@ }, "node_modules/npm/node_modules/minipass": { "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", "dev": true, "inBundle": true, "license": "ISC", @@ -16582,6 +16586,8 @@ }, "node_modules/npm/node_modules/tar": { "version": "6.1.15", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.15.tgz", + "integrity": "sha512-/zKt9UyngnxIT/EAGYuxaMYgOIJiP81ab9ZfkILq4oNLPFX50qyYmu7jRj9qeXoxmJHjGlbH0+cm2uy1WCs10A==", "dev": true, "inBundle": true, "license": "ISC", @@ -16686,6 +16692,8 @@ }, "node_modules/npm/node_modules/util-deprecate": { "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "dev": true, "inBundle": true, "license": "MIT" @@ -16753,6 +16761,8 @@ }, "node_modules/npm/node_modules/wrap-ansi": { "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", "dev": true, "inBundle": true, "license": "MIT", @@ -16771,6 +16781,8 @@ "node_modules/npm/node_modules/wrap-ansi-cjs": { "name": "wrap-ansi", "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "dev": true, "inBundle": true, "license": "MIT", @@ -16860,6 +16872,8 @@ }, "node_modules/npm/node_modules/wrappy": { "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true, "inBundle": true, "license": "ISC" @@ -16879,6 +16893,8 @@ }, "node_modules/npm/node_modules/yallist": { "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true, "inBundle": true, "license": "ISC" diff --git a/package.json b/package.json index a06ba30f38d..2e894f22288 100644 --- a/package.json +++ b/package.json @@ -132,7 +132,7 @@ "@typescript-eslint/parser": "^5.61.0", "@vitejs/plugin-react-swc": "^3.3.2", "autoprefixer": "^10.4.14", - "cypress": "^12.17.4", + "cypress": "^13.1.0", "cypress-localstorage-commands": "^2.2.3", "eslint": "^8.44.0", "eslint-config-prettier": "^8.8.0", From f535fd3b9018b602f7efc66c53ef55a31210b55c Mon Sep 17 00:00:00 2001 From: Pranshu Aggarwal <70687348+Pranshu1902@users.noreply.github.com> Date: Tue, 5 Sep 2023 19:41:24 +0530 Subject: [PATCH 03/10] Enhance UI of Import External Results page (#6163) * enhance ui * place cancel button to righ * fix width --- .../ExternalResult/ExternalResultUpload.tsx | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/Components/ExternalResult/ExternalResultUpload.tsx b/src/Components/ExternalResult/ExternalResultUpload.tsx index 4d517f1a442..5f39cb213a4 100644 --- a/src/Components/ExternalResult/ExternalResultUpload.tsx +++ b/src/Components/ExternalResult/ExternalResultUpload.tsx @@ -8,6 +8,8 @@ import { externalResultUploadCsv } from "../../Redux/actions"; import * as Notification from "../../Utils/Notifications.js"; const PageTitle = lazy(() => import("../Common/PageTitle")); import { useTranslation } from "react-i18next"; +import { Cancel, Submit } from "../Common/components/ButtonV2"; +import useAppHistory from "../../Common/hooks/useAppHistory"; export default function ExternalResultUpload() { const { sample_format_external_result_import } = useConfig(); @@ -20,6 +22,7 @@ export default function ExternalResultUpload() { setCsvData(data); }; const { t } = useTranslation(); + const { goBack } = useAppHistory(); const papaparseOptions = { header: true, @@ -67,11 +70,11 @@ export default function ExternalResultUpload() { backUrl="/external_results" className="mt-4" /> -
-
+
+
-
+
-
- + disabled={loading} + label={t("save")} + data-testid="submit-button" + />
From b0c61dc0044bf80a6a13277f92a6eec59973a644 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Tue, 5 Sep 2023 14:32:01 +0000 Subject: [PATCH 04/10] Medicine: Adds `type` filter for medibase search (#6186) * add type filter for medibase * Consultation: Verified By Doctor as Dropdown * add missing model changes * Revert "add missing model changes" This reverts commit 149592e98a610ee0661076f05df5bfeaed8b25bf. * Revert "Consultation: Verified By Doctor as Dropdown" This reverts commit 4113172c929c99e96b7dfee74f597cc4fd13fb61. --- src/CAREUI/interactive/Switch.tsx | 39 +++++++++++++++++++ .../MedibaseAutocompleteFormField.tsx | 30 +++++++++++++- src/Redux/actions.tsx | 8 +++- 3 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 src/CAREUI/interactive/Switch.tsx diff --git a/src/CAREUI/interactive/Switch.tsx b/src/CAREUI/interactive/Switch.tsx new file mode 100644 index 00000000000..3e18795b034 --- /dev/null +++ b/src/CAREUI/interactive/Switch.tsx @@ -0,0 +1,39 @@ +import { classNames } from "../../Utils/utils"; + +interface Props { + tabs: Record; + selected: T; + onChange: (tab: T) => void; + size?: "sm" | "md" | "lg"; +} + +export default function Switch({ + size = "sm", + ...props +}: Props) { + return ( +
    + {Object.keys(props.tabs).map((tab) => { + return ( +
  • props.onChange(tab as T)} + > + {props.tabs[tab as T]} +
  • + ); + })} +
+ ); +} diff --git a/src/Components/Medicine/MedibaseAutocompleteFormField.tsx b/src/Components/Medicine/MedibaseAutocompleteFormField.tsx index 473bb3a2598..337546691f9 100644 --- a/src/Components/Medicine/MedibaseAutocompleteFormField.tsx +++ b/src/Components/Medicine/MedibaseAutocompleteFormField.tsx @@ -1,3 +1,5 @@ +import { useEffect, useState } from "react"; +import Switch from "../../CAREUI/interactive/Switch"; import { useAsyncOptions } from "../../Common/hooks/useAsyncOptions"; import { listMedibaseMedicines } from "../../Redux/actions"; import { Autocomplete } from "../Form/FormFields/Autocomplete"; @@ -15,8 +17,32 @@ export default function MedibaseAutocompleteFormField( const { isLoading, options, fetchOptions } = useAsyncOptions("id"); + const [query, setQuery] = useState(""); + const [type, setType] = useState(); + + useEffect(() => { + fetchOptions(listMedibaseMedicines(query, type)); + }, [query, type]); + return ( - + { + setType(type === "all" ? undefined : type); + }} + /> + ), + }} + > ) } - onQuery={(query) => fetchOptions(listMedibaseMedicines(query))} + onQuery={setQuery} isLoading={isLoading} /> diff --git a/src/Redux/actions.tsx b/src/Redux/actions.tsx index 0ea1270f741..e3212685d2f 100644 --- a/src/Redux/actions.tsx +++ b/src/Redux/actions.tsx @@ -1,5 +1,6 @@ import { HCXClaimModel, HCXPolicyModel } from "../Components/HCX/models"; import { + MedibaseMedicine, MedicineAdministrationRecord, Prescription, } from "../Components/Medicine/models"; @@ -803,8 +804,11 @@ export const listICD11Diagnosis = (params: object, key: string) => { return fireRequest("listICD11Diagnosis", [], params, null, key); }; // Medibase -export const listMedibaseMedicines = (query: string) => { - return fireRequest("listMedibaseMedicines", [], { query }); +export const listMedibaseMedicines = ( + query: string, + type?: MedibaseMedicine["type"] +) => { + return fireRequest("listMedibaseMedicines", [], { query, type }); }; // Resource From 14f6ff1e239c3bc8f17a945dc36eb1bb0a29b774 Mon Sep 17 00:00:00 2001 From: Pranshu Aggarwal <70687348+Pranshu1902@users.noreply.github.com> Date: Tue, 5 Sep 2023 20:06:17 +0530 Subject: [PATCH 05/10] remove extra space (#6215) --- src/Components/Facility/TriageForm.tsx | 28 +++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Components/Facility/TriageForm.tsx b/src/Components/Facility/TriageForm.tsx index a627fda1bbe..3c8e6b1497b 100644 --- a/src/Components/Facility/TriageForm.tsx +++ b/src/Components/Facility/TriageForm.tsx @@ -283,20 +283,20 @@ export const TriageForm = (props: triageFormProps) => { handleSubmit(); }} > -
- -
+
+ +
{ />
-
+
goBack()} />
From 1631e7953c4f64400b7e357b11c772af3836a17b Mon Sep 17 00:00:00 2001 From: Pranshu Aggarwal <70687348+Pranshu1902@users.noreply.github.com> Date: Tue, 5 Sep 2023 20:07:13 +0530 Subject: [PATCH 06/10] remove extra loader and add success notification (#6210) --- src/Components/Users/SkillsSlideOver.tsx | 47 ++++++++++++------------ 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/Components/Users/SkillsSlideOver.tsx b/src/Components/Users/SkillsSlideOver.tsx index cf43b738181..343ea9062cc 100644 --- a/src/Components/Users/SkillsSlideOver.tsx +++ b/src/Components/Users/SkillsSlideOver.tsx @@ -55,6 +55,10 @@ export default ({ show, setShow, username }: IProps) => { Notification.Error({ msg: "Error while adding skill", }); + } else { + Notification.Success({ + msg: "Skill added successfully", + }); } setSelectedSkill(null); setIsLoading(false); @@ -110,21 +114,19 @@ export default ({ show, setShow, username }: IProps) => { >
-
- - {isLoading ? ( - - ) : ( + {!isLoading && ( +
+ addSkill(username, selectedSkill)} @@ -132,14 +134,13 @@ export default ({ show, setShow, username }: IProps) => { > {t("add")} - )} - {!authorizeForAddSkill && ( - - {t("contact_your_admin_to_add_skills")} - - )} -
- {/* While loading skills, we display an additional circular progress to show we are fetching the information*/} + {!authorizeForAddSkill && ( + + {t("contact_your_admin_to_add_skills")} + + )} +
+ )} {isLoading ? (
From 9d9bb5e5a182934507b4f2a0f5d22f2d01658464 Mon Sep 17 00:00:00 2001 From: Mustafa Azad <97380192+mustafaazad03@users.noreply.github.com> Date: Tue, 5 Sep 2023 20:17:41 +0530 Subject: [PATCH 07/10] Bug Fixed : Default filters on patients page loads (#6189) * URL Bug fixed * filters issue fixed * default filters apply on patient page : Bug Fixed * Update src/Components/Patient/ManagePatients.tsx Co-authored-by: Rithvik Nishad * Update src/Components/Patient/ManagePatients.tsx Co-authored-by: Rithvik Nishad --------- Co-authored-by: Rithvik Nishad --- src/Components/Patient/ManagePatients.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Components/Patient/ManagePatients.tsx b/src/Components/Patient/ManagePatients.tsx index 677e3725289..b29c112c5a1 100644 --- a/src/Components/Patient/ManagePatients.tsx +++ b/src/Components/Patient/ManagePatients.tsx @@ -121,7 +121,7 @@ export const PatientManager = () => { if (phone_number === "+91" || phone_number === "") { setPhoneNumberError(""); - updateQuery({ phone_number: "" }); + qParams.phone_number && updateQuery({ phone_number: null }); return; } @@ -138,7 +138,8 @@ export const PatientManager = () => { if (emergency_phone_number === "+91" || emergency_phone_number === "") { setEmergencyPhoneNumberError(""); - updateQuery({ emergency_phone_number: "" }); + qParams.emergency_phone_number && + updateQuery({ emergency_phone_number: null }); return; } From bbb07b773f9e6bcddfd1589b20069f0fb3ef32e3 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Tue, 5 Sep 2023 15:12:47 +0000 Subject: [PATCH 08/10] Support for direnv and use `CARE_API` from env in vite config (#6201) * optionally use `careapi` from env * update cypress ci * bring back quotes * fix cypress env properly * support for `direnv` --------- Co-authored-by: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> --- .envrc | 1 + .github/workflows/cypress.yaml | 4 +--- vite.config.ts | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 .envrc diff --git a/.envrc b/.envrc new file mode 100644 index 00000000000..fc7d890f90a --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +test -f .env.local && dotenv .env.local \ No newline at end of file diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index e98f5b01e7d..4f23fbe4937 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -35,9 +35,6 @@ jobs: - name: Check care is up ♻ run: curl -o /dev/null -s -w "%{http_code}\n" http://localhost:9000 - - name: Change api proxy url 📝 - run: 'sed --in-place "s^target: .*,^target: \"http://localhost:9000\",^g" vite.config.ts' - - name: Install dependencies 📦 run: npm install @@ -55,6 +52,7 @@ jobs: browser: chrome record: true env: + CARE_API: http://localhost:9000 CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NODE_OPTIONS: --max_old_space_size=4096 diff --git a/vite.config.ts b/vite.config.ts index 1c88d8e0022..7aafe6e1d5c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -84,7 +84,7 @@ export default defineConfig({ port: 4000, proxy: { "/api": { - target: "https://careapi.ohc.network", + target: process.env.CARE_API ?? "https://careapi.ohc.network", changeOrigin: true, }, }, @@ -93,7 +93,7 @@ export default defineConfig({ port: 4000, proxy: { "/api": { - target: "https://careapi.ohc.network", + target: process.env.CARE_API ?? "https://careapi.ohc.network", changeOrigin: true, }, }, From 539beecc51200417059258faf1c7c5b8e2efb213 Mon Sep 17 00:00:00 2001 From: Suprabath <34211797+suprabathk@users.noreply.github.com> Date: Wed, 6 Sep 2023 08:38:58 +0530 Subject: [PATCH 09/10] Added nav link for bed status in consultation form (#6170) --- src/Components/Facility/ConsultationForm.tsx | 22 +++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx index ed7fd7b57b6..c71c70b162c 100644 --- a/src/Components/Facility/ConsultationForm.tsx +++ b/src/Components/Facility/ConsultationForm.tsx @@ -198,7 +198,8 @@ const consultationFormReducer = (state = initialState, action: FormAction) => { type ConsultationFormSection = | "Consultation Details" | "Diagnosis" - | "Treatment Plan"; + | "Treatment Plan" + | "Bed Status"; export const ConsultationForm = (props: any) => { const { goBack } = useAppHistory(); @@ -223,6 +224,7 @@ export const ConsultationForm = (props: any) => { const [consultationDetailsVisible, consultationDetailsRef] = useVisibility(); const [diagnosisVisible, diagnosisRef] = useVisibility(-300); const [treatmentPlanVisible, treatmentPlanRef] = useVisibility(-300); + const [bedStatusVisible, bedStatusRef] = useVisibility(-300); const [disabledFields, setDisabledFields] = useState([]); const sections = { @@ -241,6 +243,11 @@ export const ConsultationForm = (props: any) => { visible: treatmentPlanVisible, ref: treatmentPlanRef, }, + "Bed Status": { + iconClass: "care-l-bed", + visible: bedStatusVisible, + ref: bedStatusRef, + }, }; useEffect(() => { @@ -248,9 +255,15 @@ export const ConsultationForm = (props: any) => { if (consultationDetailsVisible) return "Consultation Details"; if (diagnosisVisible) return "Diagnosis"; if (treatmentPlanVisible) return "Treatment Plan"; + if (bedStatusVisible) return "Bed Status"; return prev; }); - }, [consultationDetailsVisible, diagnosisVisible, treatmentPlanVisible]); + }, [ + consultationDetailsVisible, + diagnosisVisible, + treatmentPlanVisible, + bedStatusVisible, + ]); useEffect(() => { async function fetchPatientName() { @@ -817,6 +830,9 @@ export const ConsultationForm = (props: any) => { if (state.form.consultation_status === 1) { return null; } + if (!isUpdate && sectionTitle === "Bed Status") { + return null; + } const isCurrent = currentSection === sectionTitle; const section = sections[sectionTitle as ConsultationFormSection]; return ( @@ -1306,7 +1322,7 @@ export const ConsultationForm = (props: any) => { {isUpdate && ( <>
-

Update Bed

+ {sectionTitle("Bed Status")} Date: Wed, 6 Sep 2023 03:10:03 +0000 Subject: [PATCH 10/10] Medicine Administrations: Adds `administered_date` input (#6206) * Add input: `administered_date` to Administer Dialog * add administered_date for bulk administer too * fix cypress --- cypress/e2e/patient_spec/patient_crud.cy.ts | 2 +- .../Form/FormFields/CheckBoxFormField.tsx | 1 + .../Medicine/AdministerMedicine.tsx | 61 ++++++++++--- .../Medicine/MedicineAdministration.tsx | 88 +++++++++++++++---- .../PrescriptionAdministrationsTable.tsx | 2 +- src/Components/Medicine/models.ts | 2 +- 6 files changed, 125 insertions(+), 31 deletions(-) diff --git a/cypress/e2e/patient_spec/patient_crud.cy.ts b/cypress/e2e/patient_spec/patient_crud.cy.ts index ff8ffaefcfc..b9e03851897 100644 --- a/cypress/e2e/patient_spec/patient_crud.cy.ts +++ b/cypress/e2e/patient_spec/patient_crud.cy.ts @@ -28,7 +28,7 @@ describe("Patient Creation with consultation", () => { cy.get("#add-patient-details").should("be.visible"); cy.get("#add-patient-details").click(); cy.get("input[name='facilities']") - .type("cypress facility") + .type("dummy facility") .then(() => { cy.get("[role='option']").first().click(); }); diff --git a/src/Components/Form/FormFields/CheckBoxFormField.tsx b/src/Components/Form/FormFields/CheckBoxFormField.tsx index 90c4513f4b7..f3382d522de 100644 --- a/src/Components/Form/FormFields/CheckBoxFormField.tsx +++ b/src/Components/Form/FormFields/CheckBoxFormField.tsx @@ -14,6 +14,7 @@ export default function CheckBoxFormField(props: FormFieldBaseProps) { name={field.name} checked={field.value} onChange={(e) => field.handleChange(e.target.checked)} + disabled={field.disabled} /> (); const [isLoading, setIsLoading] = useState(false); const [notes, setNotes] = useState(""); + const [isCustomTime, setIsCustomTime] = useState(false); + const [customTime, setCustomTime] = useState( + dayjs().format("YYYY-MM-DDTHH:mm") + ); return ( props.onClose(false)} - // variant="primary" onConfirm={async () => { setIsLoading(true); - const res = await dispatch(props.actions.administer({ notes })); + const res = await dispatch( + props.actions.administer({ + notes, + administered_date: isCustomTime ? customTime : undefined, + }) + ); if (res.status === 201) { Success({ msg: t("medicines_administered") }); } @@ -61,15 +72,43 @@ export default function AdministerMedicine({ prescription, ...props }: Props) { readonly actions={props.actions} /> - setNotes(value)} - errorClassName="hidden" - disabled={isLoading} - /> + +
+ setNotes(value)} + errorClassName="hidden" + disabled={isLoading} + /> +
+ { + setIsCustomTime(value); + if (!value) { + setCustomTime(dayjs().format("YYYY-MM-DDTHH:mm")); + } + }} + errorClassName="hidden" + /> + setCustomTime(value)} + disabled={!isCustomTime} + min={dayjs(prescription.created_date).format("YYYY-MM-DDTHH:mm")} + max={dayjs().format("YYYY-MM-DDTHH:mm")} + /> +
+
); diff --git a/src/Components/Medicine/MedicineAdministration.tsx b/src/Components/Medicine/MedicineAdministration.tsx index 16926b32f7b..5d8347ba5a5 100644 --- a/src/Components/Medicine/MedicineAdministration.tsx +++ b/src/Components/Medicine/MedicineAdministration.tsx @@ -10,6 +10,8 @@ import { useDispatch } from "react-redux"; import { Error, Success } from "../../Utils/Notifications"; import { formatDateTime } from "../../Utils/utils"; import { useTranslation } from "react-i18next"; +import dayjs from "../../Utils/dayjs"; +import TextFormField from "../Form/FormFields/TextFormField"; interface Props { prescriptions: Prescription[]; @@ -24,6 +26,8 @@ export default function MedicineAdministration(props: Props) { const [notes, setNotes] = useState( [] ); + const [isCustomTime, setIsCustomTime] = useState([]); + const [customTime, setCustomTime] = useState([]); const prescriptions = useMemo( () => @@ -36,13 +40,21 @@ export default function MedicineAdministration(props: Props) { useEffect(() => { setShouldAdminister(Array(prescriptions.length).fill(false)); setNotes(Array(prescriptions.length).fill("")); + setIsCustomTime(Array(prescriptions.length).fill(false)); + setCustomTime( + Array(prescriptions.length).fill(dayjs().format("YYYY-MM-DDTHH:mm")) + ); }, [props.prescriptions]); const handleSubmit = () => { const records: MedicineAdministrationRecord[] = []; prescriptions.forEach((prescription, i) => { if (shouldAdminister[i]) { - records.push({ prescription, notes: notes[i] }); + records.push({ + prescription, + notes: notes[i], + administered_date: isCustomTime[i] ? customTime[i] : undefined, + }); } }); @@ -73,7 +85,7 @@ export default function MedicineAdministration(props: Props) { actions={props.action(obj?.id ?? "")} selected={shouldAdminister[index]} > -
+
- - setNotes((notes) => { - const newNotes = [...notes]; - newNotes[index] = event.value; - return newNotes; - }) - } - errorClassName="hidden" - /> +
+ + setNotes((notes) => { + const newNotes = [...notes]; + newNotes[index] = event.value; + return newNotes; + }) + } + errorClassName="hidden" + /> +
+ { + setIsCustomTime((arr) => { + const newArr = [...arr]; + newArr[index] = value; + return newArr; + }); + if (!value) { + setCustomTime((arr) => { + const newArr = [...arr]; + newArr[index] = dayjs().format("YYYY-MM-DDTHH:mm"); + return newArr; + }); + } + }} + errorClassName="hidden" + /> + { + setCustomTime((arr) => { + const newArr = [...arr]; + newArr[index] = value; + return newArr; + }); + }} + disabled={!shouldAdminister[index] || !isCustomTime[index]} + min={dayjs(obj.created_date).format("YYYY-MM-DDTHH:mm")} + max={dayjs().format("YYYY-MM-DDTHH:mm")} + /> +
+
))} diff --git a/src/Components/Medicine/PrescriptionAdministrationsTable.tsx b/src/Components/Medicine/PrescriptionAdministrationsTable.tsx index c60d531baa3..81282126d7c 100644 --- a/src/Components/Medicine/PrescriptionAdministrationsTable.tsx +++ b/src/Components/Medicine/PrescriptionAdministrationsTable.tsx @@ -85,7 +85,7 @@ export default function PrescriptionAdministrationsTable({ {state?.prescriptions && ( diff --git a/src/Components/Medicine/models.ts b/src/Components/Medicine/models.ts index cb48e9cc174..62aea46b6d2 100644 --- a/src/Components/Medicine/models.ts +++ b/src/Components/Medicine/models.ts @@ -53,8 +53,8 @@ export type MedicineAdministrationRecord = { readonly id?: string; readonly prescription?: Prescription; notes: string; + administered_date?: string; readonly administered_by?: PerformedByModel; - readonly administered_date?: string; readonly created_date?: string; readonly modified_date?: string; };