diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index dbeff965240..24343ec8fc3 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -65,7 +65,7 @@ jobs: build: needs: test - if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/staging' || github.ref == 'refs/tags/v*' + if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/staging' || startsWith(github.event.ref, 'refs/tags/v') name: Build & Push to container registries runs-on: ubuntu-latest steps: @@ -135,7 +135,7 @@ jobs: notify-release: needs: build - if: github.ref == 'refs/tags/v*' + if: startsWith(github.event.ref, 'refs/tags/v') name: Notify release runs-on: ubuntu-latest steps: diff --git a/cypress/e2e/facility_spec/facility_manage.cy.ts b/cypress/e2e/facility_spec/facility_manage.cy.ts index c5f56f97170..ce459d2d66b 100644 --- a/cypress/e2e/facility_spec/facility_manage.cy.ts +++ b/cypress/e2e/facility_spec/facility_manage.cy.ts @@ -141,6 +141,7 @@ describe("Facility Manage Functions", () => { facilityManage.verifySuccessMessageVisibilityAndContent( "Bed capacity added successfully" ); + cy.closeNotification(); facilityManage.verifyFacilityBedCapacity(totalCapacity); facilityManage.verifyFacilityBedCapacity(currentOccupied); // edit a existing bed @@ -151,6 +152,7 @@ describe("Facility Manage Functions", () => { facilityManage.verifySuccessMessageVisibilityAndContent( "Bed capacity updated successfully" ); + cy.closeNotification(); facilityManage.verifyFacilityBedCapacity(totalUpdatedCapacity); facilityManage.verifyFacilityBedCapacity(currentUpdatedOccupied); // delete a bed diff --git a/cypress/e2e/patient_spec/patient_detailpage.cy.ts b/cypress/e2e/patient_spec/patient_detailpage.cy.ts deleted file mode 100644 index c3bc4b0cf8d..00000000000 --- a/cypress/e2e/patient_spec/patient_detailpage.cy.ts +++ /dev/null @@ -1,106 +0,0 @@ -import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress"; -import LoginPage from "../../pageobject/Login/LoginPage"; -import { PatientPage } from "../../pageobject/Patient/PatientCreation"; -import { PatientFileUpload } from "../../pageobject/Patient/PatientFileupload"; - -describe("Patient Details", () => { - const loginPage = new LoginPage(); - const patientPage = new PatientPage(); - const patientFileUpload = new PatientFileUpload(); - const cypressAudioName = "cypress audio"; - const cypressFileName = "cypress name"; - const newFileName = "cypress modified name"; - const patientNameOne = "Dummy Patient 3"; - const patientNameTwo = "Dummy Patient 4"; - const patientNameThree = "Dummy Patient 5"; - before(() => { - loginPage.loginAsDisctrictAdmin(); - cy.saveLocalStorage(); - }); - - beforeEach(() => { - cy.restoreLocalStorage(); - cy.clearLocalStorage(/filters--.+/); - cy.awaitUrl("/patients"); - }); - - it("Record an Audio and download the file", () => { - // Record an audio - patientPage.visitPatient(patientNameOne); - patientFileUpload.visitPatientDetailsPage(); - patientFileUpload.recordAudio(); - patientFileUpload.typeAudioName(cypressAudioName); - patientFileUpload.clickUploadAudioFile(); - // Verify the audio file is uploaded - cy.verifyNotification("File Uploaded Successfully"); - patientFileUpload.verifyUploadFilePresence(cypressAudioName); - // Verify the download of the audio file - cy.get("button").contains("DOWNLOAD").click(); - cy.verifyNotification("Downloading file..."); - }); - - it("Upload a File and archive it", () => { - // Upload the file - patientPage.visitPatient(patientNameTwo); - patientFileUpload.visitPatientDetailsPage(); - patientFileUpload.uploadFile(); - patientFileUpload.typeFileName(cypressFileName); - patientFileUpload.clickUploadFile(); - // Verify the file is uploaded - cy.verifyNotification("File Uploaded Successfully"); - cy.closeNotification(); - patientFileUpload.verifyUploadFilePresence(cypressFileName); - // Archive the file - patientFileUpload.archiveFile(); - patientFileUpload.clickSaveArchiveFile(); - cy.verifyNotification("File archived successfully"); - patientFileUpload.verifyArchiveFile(cypressFileName); - }); - - it("User-level Based Permission for File Modification", () => { - // Login as Nurse 1 - loginPage.login("dummynurse1", "Coronasafe@123"); - cy.reload(); - // Visit the patient details page - patientPage.visitPatient(patientNameThree); - patientFileUpload.visitPatientDetailsPage(); - // Upload the file - patientFileUpload.uploadFile(); - patientFileUpload.typeFileName(cypressFileName); - patientFileUpload.clickUploadFile(); - // Verify the file is uploaded - cy.verifyNotification("File Uploaded Successfully"); - cy.closeNotification(); - patientFileUpload.verifyUploadFilePresence(cypressFileName); - // Edit the file name - patientFileUpload.verifyFileRenameOption(true); - patientFileUpload.renameFile(newFileName); - patientFileUpload.clickSaveFileName(); - // Verify the file name is changed - cy.verifyNotification("File name changed successfully"); - cy.closeNotification(); - patientFileUpload.verifyUploadFilePresence(newFileName); - // Login as Nurse 2 - loginPage.login("dummynurse2", "Coronasafe@123"); - cy.reload(); - // Verify the file edit option is not available - patientFileUpload.verifyUploadFilePresence(newFileName); - patientFileUpload.verifyFileRenameOption(false); - // Login as District Admin - loginPage.loginAsDisctrictAdmin(); - cy.reload(); - // Verify the file edit option is available - patientFileUpload.verifyUploadFilePresence(newFileName); - patientFileUpload.verifyFileRenameOption(true); - patientFileUpload.renameFile(cypressFileName); - patientFileUpload.clickSaveFileName(); - // Verify the file name is changed - cy.verifyNotification("File name changed successfully"); - cy.closeNotification(); - patientFileUpload.verifyUploadFilePresence(cypressFileName); - }); - - afterEach(() => { - cy.saveLocalStorage(); - }); -}); diff --git a/cypress/e2e/patient_spec/patient_fileupload.cy.ts b/cypress/e2e/patient_spec/patient_fileupload.cy.ts new file mode 100644 index 00000000000..20a884fd149 --- /dev/null +++ b/cypress/e2e/patient_spec/patient_fileupload.cy.ts @@ -0,0 +1,117 @@ +import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress"; +import LoginPage from "../../pageobject/Login/LoginPage"; +import { PatientPage } from "../../pageobject/Patient/PatientCreation"; +import { PatientFileUpload } from "../../pageobject/Patient/PatientFileupload"; +const loginPage = new LoginPage(); +const patientPage = new PatientPage(); +const patientFileUpload = new PatientFileUpload(); + +function runTests(testDescription, visitPatientFileUploadSection) { + describe(testDescription, () => { + const cypressAudioName = "cypress audio"; + const cypressFileName = "cypress name"; + const newFileName = "cypress modified name"; + const patientNameOne = "Dummy Patient 3"; + const patientNameTwo = "Dummy Patient 4"; + const patientNameThree = "Dummy Patient 5"; + before(() => { + loginPage.loginAsDisctrictAdmin(); + cy.saveLocalStorage(); + }); + + beforeEach(() => { + cy.restoreLocalStorage(); + cy.clearLocalStorage(/filters--.+/); + cy.awaitUrl("/patients"); + }); + + it("Record an Audio and download the file", () => { + // Record an audio + patientPage.visitPatient(patientNameOne); + visitPatientFileUploadSection.call(patientFileUpload); + patientFileUpload.recordAudio(); + patientFileUpload.typeAudioName(cypressAudioName); + patientFileUpload.clickUploadAudioFile(); + // Verify the audio file is uploaded + cy.verifyNotification("File Uploaded Successfully"); + patientFileUpload.verifyUploadFilePresence(cypressAudioName); + // Verify the download of the audio file + cy.get("button").contains("DOWNLOAD").click(); + cy.verifyNotification("Downloading file..."); + }); + + it("Upload a File and archive it", () => { + // Upload the file + patientPage.visitPatient(patientNameTwo); + visitPatientFileUploadSection.call(patientFileUpload); + patientFileUpload.uploadFile(); + patientFileUpload.typeFileName(cypressFileName); + patientFileUpload.clickUploadFile(); + // Verify the file is uploaded + cy.verifyNotification("File Uploaded Successfully"); + cy.closeNotification(); + patientFileUpload.verifyUploadFilePresence(cypressFileName); + // Archive the file + patientFileUpload.archiveFile(); + patientFileUpload.clickSaveArchiveFile(); + cy.verifyNotification("File archived successfully"); + patientFileUpload.verifyArchiveFile(cypressFileName); + }); + + it("User-level Based Permission for File Modification", () => { + // Login as Nurse 1 + loginPage.login("dummynurse1", "Coronasafe@123"); + cy.reload(); + // Visit the patient details page + patientPage.visitPatient(patientNameThree); + visitPatientFileUploadSection.call(patientFileUpload); + // Upload the file + patientFileUpload.uploadFile(); + patientFileUpload.typeFileName(cypressFileName); + patientFileUpload.clickUploadFile(); + // Verify the file is uploaded + cy.verifyNotification("File Uploaded Successfully"); + cy.closeNotification(); + patientFileUpload.verifyUploadFilePresence(cypressFileName); + // Edit the file name + patientFileUpload.verifyFileRenameOption(true); + patientFileUpload.renameFile(newFileName); + patientFileUpload.clickSaveFileName(); + // Verify the file name is changed + cy.verifyNotification("File name changed successfully"); + cy.closeNotification(); + patientFileUpload.verifyUploadFilePresence(newFileName); + // Login as Nurse 2 + loginPage.login("dummynurse2", "Coronasafe@123"); + cy.reload(); + // Verify the file edit option is not available + patientFileUpload.verifyUploadFilePresence(newFileName); + patientFileUpload.verifyFileRenameOption(false); + // Login as District Admin + loginPage.loginAsDisctrictAdmin(); + cy.reload(); + // Verify the file edit option is available + patientFileUpload.verifyUploadFilePresence(newFileName); + patientFileUpload.verifyFileRenameOption(true); + patientFileUpload.renameFile(cypressFileName); + patientFileUpload.clickSaveFileName(); + // Verify the file name is changed + cy.verifyNotification("File name changed successfully"); + cy.closeNotification(); + patientFileUpload.verifyUploadFilePresence(cypressFileName); + }); + + afterEach(() => { + cy.saveLocalStorage(); + }); + }); +} + +runTests( + "Patient File upload in patient details page", + patientFileUpload.clickFileUploadIcon +); +runTests( + "Patient File upload in patient consultation page", + patientFileUpload.clickFileTab +); diff --git a/cypress/e2e/patient_spec/patient_manage.cy.ts b/cypress/e2e/patient_spec/patient_manage.cy.ts index 32e6faf880e..35b89aedb7f 100644 --- a/cypress/e2e/patient_spec/patient_manage.cy.ts +++ b/cypress/e2e/patient_spec/patient_manage.cy.ts @@ -58,13 +58,6 @@ describe("Patient", () => { cy.verifyNotification("Medicine prescribed"); }); - it("Upload consultations file ", () => { - patientPage.visitPatient("Dummy Patient 5"); - patientConsultationPage.visitFilesPage(); - patientConsultationPage.uploadFile(); - patientConsultationPage.clickUploadFile(); - }); - it("Discharge a patient", () => { patientPage.visitPatient("Dummy Patient 6"); patientConsultationPage.clickDischargePatient(); diff --git a/cypress/e2e/patient_spec/patient_registration.cy.ts b/cypress/e2e/patient_spec/patient_registration.cy.ts index 76c3e2b7199..28b92340654 100644 --- a/cypress/e2e/patient_spec/patient_registration.cy.ts +++ b/cypress/e2e/patient_spec/patient_registration.cy.ts @@ -5,7 +5,7 @@ import FacilityPage from "../../pageobject/Facility/FacilityCreation"; import { generatePhoneNumber, generateEmergencyPhoneNumber, -} from "../../pageobject/constants"; +} from "../../pageobject/utils/constants"; import PatientTransfer from "../../pageobject/Patient/PatientTransfer"; import PatientExternal from "../../pageobject/Patient/PatientExternal"; import PatientInsurance from "../../pageobject/Patient/PatientInsurance"; @@ -247,7 +247,7 @@ describe("Patient Creation with consultation", () => { patientTransfer.clickAdmitPatientRecordButton(); patientTransfer.clickTransferPopupContinueButton(); patientTransfer.clickTransferPatientNameList(patientTransferName); - patientTransfer.clickTransferPatientDob(patientDateOfBirth); + patientTransfer.clickTransferPatientYOB(yearOfBirth); patientTransfer.clickTransferSubmitButton(); patientTransfer.verifyFacilitySuccessfullMessage(); patientTransfer.clickConsultationCancelButton(); @@ -263,7 +263,7 @@ describe("Patient Creation with consultation", () => { patientTransfer.clickAdmitPatientRecordButton(); patientTransfer.clickTransferPopupContinueButton(); patientTransfer.clickTransferPatientNameList(patientTransferName); - patientTransfer.clickTransferPatientDob(patientDateOfBirth); + patientTransfer.clickTransferPatientYOB(yearOfBirth); patientTransfer.clickTransferSubmitButton(); patientTransfer.verifyFacilityErrorMessage(); }); diff --git a/cypress/e2e/users_spec/user_creation.cy.ts b/cypress/e2e/users_spec/user_creation.cy.ts index 33fd7cb958d..e40ebbbc71f 100644 --- a/cypress/e2e/users_spec/user_creation.cy.ts +++ b/cypress/e2e/users_spec/user_creation.cy.ts @@ -7,7 +7,7 @@ import { UserCreationPage } from "../../pageobject/Users/UserCreation"; import { generatePhoneNumber, generateEmergencyPhoneNumber, -} from "../../pageobject/constants"; +} from "../../pageobject/utils/constants"; describe("User Creation", () => { const userPage = new UserPage(); diff --git a/cypress/pageobject/Patient/PatientConsultation.ts b/cypress/pageobject/Patient/PatientConsultation.ts index db72765444f..0a39a1f839a 100644 --- a/cypress/pageobject/Patient/PatientConsultation.ts +++ b/cypress/pageobject/Patient/PatientConsultation.ts @@ -95,24 +95,6 @@ export class PatientConsultationPage { cy.searchAndSelectOption("#referred_from_facility", referringFacility); } - visitFilesPage() { - cy.get("#consultation_tab_nav").scrollIntoView(); - cy.get("#consultation_tab_nav").contains("Files").click(); - } - - uploadFile() { - cy.get("#file_upload_patient").selectFile( - "cypress/fixtures/sampleAsset.xlsx", - { force: true } - ); - } - - clickUploadFile() { - cy.intercept("POST", "**/api/v1/files/").as("uploadFile"); - cy.get("#upload_file_button").click(); - cy.wait("@uploadFile").its("response.statusCode").should("eq", 201); - } - clickEditConsultationButton() { cy.get("#consultation-buttons").scrollIntoView(); cy.get("button").contains("Manage Patient").click(); diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index 919b16c7c20..a708f754964 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -46,7 +46,7 @@ export class PatientPage { } typePatientDateOfBirth(dateOfBirth: string) { - cy.clickAndSelectOption("#patientAge", "D.O.B"); + cy.clickAndSelectOption("#patientAge", "DOB"); cy.get("#date_of_birth").scrollIntoView(); cy.get("#date_of_birth").should("be.visible").click(); cy.get("#date-input").click().type(dateOfBirth); diff --git a/cypress/pageobject/Patient/PatientFileupload.ts b/cypress/pageobject/Patient/PatientFileupload.ts index 6a970e66578..0250ffcc07d 100644 --- a/cypress/pageobject/Patient/PatientFileupload.ts +++ b/cypress/pageobject/Patient/PatientFileupload.ts @@ -1,7 +1,7 @@ import { cy } from "local-cypress"; export class PatientFileUpload { - visitPatientDetailsPage() { + clickFileUploadIcon() { cy.get("#patient-details").click(); cy.get("#upload-patient-files").click(); } @@ -11,6 +11,10 @@ export class PatientFileUpload { cy.get("#consultation_audio_file").click().type(name); } + clickFileTab() { + cy.verifyAndClickElement("#consultation_tab_nav", "Files"); + } + typeFileName(name: string) { cy.get("#consultation_file").clear(); cy.get("#consultation_file").click().type(name); diff --git a/cypress/pageobject/Patient/PatientPredefined.ts b/cypress/pageobject/Patient/PatientPredefined.ts index 6b2bcc0d472..f0a005ec97b 100644 --- a/cypress/pageobject/Patient/PatientPredefined.ts +++ b/cypress/pageobject/Patient/PatientPredefined.ts @@ -6,7 +6,7 @@ import PatientMedicalHistory from "../../pageobject/Patient/PatientMedicalHistor import { generatePhoneNumber, generateEmergencyPhoneNumber, -} from "../../pageobject/constants"; +} from "../utils/constants"; class PatientPredefined { createPatient() { diff --git a/cypress/pageobject/Patient/PatientTransfer.ts b/cypress/pageobject/Patient/PatientTransfer.ts index 293490a8bdd..726b888a6ee 100644 --- a/cypress/pageobject/Patient/PatientTransfer.ts +++ b/cypress/pageobject/Patient/PatientTransfer.ts @@ -12,10 +12,9 @@ class PatientTransfer { cy.get("li[role=option]").contains(facilityName).click(); } - clickTransferPatientDob(dateOfBirth: string) { - cy.get("#dateofbirth-transferform").scrollIntoView(); - cy.get("#dateofbirth-transferform").should("be.visible").click(); - cy.get("#date-input").click().type(dateOfBirth); + clickTransferPatientYOB(yearOfBirth: string) { + cy.get("#year_of_birth").scrollIntoView(); + cy.get("#year_of_birth").should("be.visible").click().type(yearOfBirth); } clickTransferSubmitButton() { diff --git a/cypress/pageobject/constants.ts b/cypress/pageobject/utils/constants.ts similarity index 100% rename from cypress/pageobject/constants.ts rename to cypress/pageobject/utils/constants.ts diff --git a/src/Components/DeathReport/DeathReport.tsx b/src/Components/DeathReport/DeathReport.tsx index 9c30fbea429..e25a59c8732 100644 --- a/src/Components/DeathReport/DeathReport.tsx +++ b/src/Components/DeathReport/DeathReport.tsx @@ -6,7 +6,7 @@ import TextFormField from "../Form/FormFields/TextFormField"; import TextAreaFormField from "../Form/FormFields/TextAreaFormField"; import DateFormField from "../Form/FormFields/DateFormField"; import PhoneNumberFormField from "../Form/FormFields/PhoneNumberFormField"; -import { formatDateTime } from "../../Utils/utils"; +import { formatDateTime, patientAgeInYears } from "../../Utils/utils"; import Page from "../Common/components/Page"; import Form from "../Form/Form"; import { useTranslation } from "react-i18next"; @@ -106,6 +106,7 @@ export default function PrintDeathReport(props: { id: string }) { const patientComorbidities = getPatientComorbidities(res.data); const data = { ...res.data, + age: patientAgeInYears(res.data!), gender: patientGender, address: patientAddress, comorbidities: patientComorbidities, diff --git a/src/Components/Facility/TransferPatientDialog.tsx b/src/Components/Facility/TransferPatientDialog.tsx index 4c38965c235..012f58d4e53 100644 --- a/src/Components/Facility/TransferPatientDialog.tsx +++ b/src/Components/Facility/TransferPatientDialog.tsx @@ -1,18 +1,14 @@ import * as Notification from "../../Utils/Notifications.js"; - import { Cancel, Submit } from "../Common/components/ButtonV2"; import { useReducer, useState } from "react"; - -import DateFormField from "../Form/FormFields/DateFormField"; import { DupPatientModel } from "./models"; -import { FieldLabel } from "../Form/FormFields/FormField"; import { OptionsType } from "../../Common/constants"; import { SelectFormField } from "../Form/FormFields/SelectFormField"; import { navigate } from "raviger"; -import { dateQueryString } from "../../Utils/utils.js"; -import dayjs from "dayjs"; import request from "../../Utils/request/request.js"; import routes from "../../Redux/api.js"; +import TextFormField from "../Form/FormFields/TextFormField.js"; +import { FieldChangeEvent } from "../Form/FormFields/Utils.js"; interface Props { patientList: Array; @@ -21,9 +17,9 @@ interface Props { facilityId: string; } -const initForm: any = { +const initForm = { patient: "", - date_of_birth: null, + year_of_birth: null, }; const initError = Object.assign( @@ -36,9 +32,6 @@ const initialState = { errors: { ...initError }, }; -const getDate = (value: any) => - value && dayjs(value).isValid() && dayjs(value).toDate(); - const patientFormReducer = (state = initialState, action: any) => { switch (action.type) { case "set_form": { @@ -69,18 +62,26 @@ const TransferPatientDialog = (props: Props) => { }; }); - const handleChange = (e: any) => { - const form = { ...state.form }; - form[e.name] = e.value; - dispatch({ type: "set_form", form }); - }; - - const handleDateChange = (e: any) => { - if (dayjs(e.value).isValid()) { - const form = { ...state.form }; - form[e.name] = dateQueryString(e.value); - dispatch({ type: "set_form", form }); + const maxYear = new Date().getFullYear(); + + const handleChange = (e: FieldChangeEvent) => { + if ( + e.name === "year_of_birth" && + parseInt((e.value as string) || "0") > maxYear + ) { + dispatch({ + type: "set_error", + errors: { + ...state.errors, + [e.name]: `Cannot be greater than ${maxYear}`, + }, + }); + return; } + dispatch({ + type: "set_form", + form: { ...state.form, [e.name]: e.value }, + }); }; const validateForm = () => { @@ -94,9 +95,14 @@ const TransferPatientDialog = (props: Props) => { invalidForm = true; } return; - case "date_of_birth": + case "year_of_birth": if (!state.form[field]) { - errors[field] = "Please enter date in YYYY/MM/DD format"; + errors[field] = "This field is required"; + invalidForm = true; + } + + if (parseInt(state.form[field] || "0") > maxYear) { + errors[field] = `Cannot be greater than ${maxYear}`; invalidForm = true; } return; @@ -108,15 +114,14 @@ const TransferPatientDialog = (props: Props) => { return !invalidForm; }; - const handleSubmit = async (e: any) => { - e.preventDefault(); + const handleSubmit = async () => { const validForm = validateForm(); if (validForm) { setIsLoading(true); const { res, data } = await request(routes.transferPatient, { body: { facility: facilityId, - date_of_birth: dateQueryString(state.form.date_of_birth), + year_of_birth: state.form.year_of_birth, }, pathParams: { id: state.form.patient, @@ -156,37 +161,34 @@ const TransferPatientDialog = (props: Props) => {

-
- - Patient - - patient.text} - optionValue={(patient) => patient.id} - value={state.form.patient} - onChange={handleChange} - error={state.errors.patient} - /> -
-
- -
+ patient.text} + optionValue={(patient) => patient.id} + value={state.form.patient} + onChange={handleChange} + error={state.errors.patient} + /> +
@@ -195,7 +197,10 @@ const TransferPatientDialog = (props: Props) => { { + e.preventDefault(); + handleSubmit(); + }} label="Transfer Suspect / Patient" /> diff --git a/src/Components/Facility/models.tsx b/src/Components/Facility/models.tsx index 73e027421a7..a08865f2938 100644 --- a/src/Components/Facility/models.tsx +++ b/src/Components/Facility/models.tsx @@ -593,6 +593,11 @@ export type InventoryLogResponse = InventorySummaryResponse & { created_by: number; }; +export type PatientTransferRequest = { + facility: string; + year_of_birth: string; +}; + export type PatientTransferResponse = { id: string; patient: string; diff --git a/src/Components/Form/SelectMenuV2.tsx b/src/Components/Form/SelectMenuV2.tsx index 2c22510cef1..dc2c57f4592 100644 --- a/src/Components/Form/SelectMenuV2.tsx +++ b/src/Components/Form/SelectMenuV2.tsx @@ -102,7 +102,7 @@ const SelectMenuV2 = (props: SelectMenuProps) => { {value.icon} )} -

+

{value.selectedLabel}

diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index 2a7a42279bb..0ab72370178 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -1335,7 +1335,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { [ { value: "date_of_birth", - text: "D.O.B.", + text: "DOB", }, { value: "age", text: "Age" }, ] as const diff --git a/src/Redux/api.tsx b/src/Redux/api.tsx index e1ed6161cc3..50a6d627537 100644 --- a/src/Redux/api.tsx +++ b/src/Redux/api.tsx @@ -64,6 +64,7 @@ import { PatientNotesEditModel, PatientNotesModel, PatientStatsModel, + PatientTransferRequest, PatientTransferResponse, StateModel, WardModel, @@ -700,6 +701,7 @@ const routes = { transferPatient: { path: "/api/v1/patient/{id}/transfer/", method: "POST", + TBody: Type(), TRes: Type(), }, getPatientNotes: { diff --git a/src/Utils/utils.ts b/src/Utils/utils.ts index 0d350267d1a..3178ef311f0 100644 --- a/src/Utils/utils.ts +++ b/src/Utils/utils.ts @@ -405,6 +405,20 @@ const getRelativeDateSuffix = (abbreviated: boolean) => { }; }; +export const patientAgeInYears = (obj: PatientModel) => { + const start = dayjs( + obj.date_of_birth + ? new Date(obj.date_of_birth) + : new Date(obj.year_of_birth!, 0, 1) + ); + + const end = dayjs( + obj.death_datetime ? new Date(obj.death_datetime) : new Date() + ); + + return end.diff(start, "years"); +}; + export const formatPatientAge = (obj: PatientModel, abbreviated = false) => { const suffixes = getRelativeDateSuffix(abbreviated);