Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into serachinput_design…
Browse files Browse the repository at this point in the history
…_update
  • Loading branch information
AdityaJ2305 committed Jan 12, 2025
2 parents c8a7254 + c991839 commit 91e9334
Show file tree
Hide file tree
Showing 42 changed files with 1,111 additions and 413 deletions.
74 changes: 74 additions & 0 deletions cypress/e2e/patient_spec/patient_creation.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { patientCreation } from "pageObject/Patients/PatientCreation";
import { patientDashboard } from "pageObject/Patients/PatientDashboard";
import { patientVerify } from "pageObject/Patients/PatientVerify";

import {
generateAddress,
generatePatientName,
generatePhoneNumber,
} from "../../utils/commonUtils";

const ENCOUNTER_TYPE = "Observation";
const ENCOUNTER_STATUS = "In Progress";
const ENCOUNTER_PRIORITY = "ASAP";

describe("Patient Management", () => {
const TEST_PHONE = "9495031234";
const PATIENT_DETAILS = {
name: "Nihal",
sex: "Male",
phone: TEST_PHONE,
};

const testPatientData = {
name: generatePatientName(),
phoneNumber: generatePhoneNumber(),
gender: "male",
bloodGroup: "B+",
dateOfBirth: "01-01-1990",
address: generateAddress(),
pincode: "682001",
state: "Kerala",
district: "Ernakulam",
localBody: "Aluva",
ward: "4",
};

beforeEach(() => {
cy.visit("/login");
});

it("create a new patient and verify details", () => {
cy.loginByApi("doctor");
patientCreation
.selectFacility("Arike")
.clickSearchPatients()
.clickCreateNewPatient()
.fillPatientDetails(testPatientData)
.submitPatientForm()
.assertPatientRegistrationSuccess();
patientVerify
.verifyPatientName(testPatientData.name)
.verifyCreateEncounterButton()
.clickCreateEncounter()
.selectEncounterType(ENCOUNTER_TYPE)
.selectEncounterStatus(ENCOUNTER_STATUS)
.selectEncounterPriority(ENCOUNTER_PRIORITY)
.clickSubmitEncounter()
.assertEncounterCreationSuccess();
patientDashboard.verifyEncounterPatientInfo([
ENCOUNTER_TYPE,
ENCOUNTER_STATUS,
ENCOUNTER_PRIORITY,
]);
});

it("search patient with phone number and verifies details", () => {
cy.loginByApi("staff");
patientCreation
.selectFacility("Arike")
.clickSearchPatients()
.searchPatient(TEST_PHONE)
.verifySearchResults(PATIENT_DETAILS);
});
});
23 changes: 0 additions & 23 deletions cypress/e2e/patient_spec/patient_search.cy.ts

This file was deleted.

6 changes: 5 additions & 1 deletion cypress/fixtures/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
"username": "nihal-nurse",
"password": "Test@123"
},
"doctor": {
"username": "arjun-doctor",
"password": "Test@123"
},
"staff": {
"username": "nihal-staff",
"password": "Test@123"
}
}
}
156 changes: 156 additions & 0 deletions cypress/pageObject/Patients/PatientCreation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
interface PatientFormData {
name: string;
phoneNumber: string;
dateOfBirth: string;
gender: string;
bloodGroup: string;
address: string;
pincode: string;
state: string;
district: string;
localBody: string;
ward: string;
}

export class PatientCreation {
// Selectors
private selectors = {
patientsButton: '[data-cy="patients-button"]',
searchInput: "#patient-search",
patientCard: "#patient-search-results",
patientName: '[data-cy="patient-name"]',
patientDetails: "#patient-search-results",
createNewPatientButton: '[data-cy="create-new-patient-button"]',
};

// Actions
clickCreateNewPatient() {
cy.get(this.selectors.createNewPatientButton).click();
cy.url().should("include", "/patient/create");
return this;
}

searchPatient(searchQuery: string) {
cy.get(this.selectors.searchInput).type(searchQuery);

// Wait for results to load
cy.get(this.selectors.patientCard).should("be.visible");
return this;
}

verifySearchResults(patientDetails: {
name: string;
sex: string;
phone: string;
}) {
// Convert object values to an array of strings
const detailsArray = Object.values(patientDetails);
cy.verifyContentPresence(this.selectors.patientDetails, detailsArray);
}

selectFacility(facilityName: string) {
cy.verifyAndClickElement("[data-cy='facility-list']", facilityName);
return this;
}

clickSearchPatients() {
cy.get('[data-sidebar="content"]').contains("Search Patients").click();
return this;
}

enterName(name: string) {
cy.typeIntoField('[data-cy="patient-name-input"]', name);
return this;
}

enterPhoneNumber(phoneNumber: string) {
cy.typeIntoField('[data-cy="patient-phone-input"]', phoneNumber, {
skipVerification: true,
});
return this;
}

enterDateOfBirth(dateString: string) {
// Split the date string (expected format: "DD-MM-YYYY")
const [day, month, year] = dateString.split("-");

cy.get('[data-cy="dob-day-input"]').type(day);
cy.get('[data-cy="dob-month-input"]').type(month);
cy.get('[data-cy="dob-year-input"]').type(year);

return this;
}

selectGender(gender: string) {
const lowercaseGender = gender.toLowerCase();
cy.get(`[data-cy="gender-radio-${lowercaseGender}"]`).click();
return this;
}

selectBloodGroup(bloodGroup: string) {
cy.clickAndSelectOption('[data-cy="blood-group-select"]', bloodGroup);
return this;
}

enterAddress(address: string) {
cy.typeIntoField('[data-cy="current-address-input"]', address);
return this;
}

enterPincode(pincode: string) {
cy.typeIntoField('[data-cy="pincode-input"]', pincode);
return this;
}

fillPatientDetails(patient: PatientFormData) {
return this.enterName(patient.name)
.enterPhoneNumber(patient.phoneNumber)
.clickSamePhoneNumberCheckbox()
.selectGender(patient.gender)
.selectBloodGroup(patient.bloodGroup)
.enterDateOfBirth(patient.dateOfBirth)
.enterAddress(patient.address)
.enterPincode(patient.pincode)
.selectState(patient.state)
.selectDistrict(patient.district)
.selectLocalBody(patient.localBody)
.selectWard(patient.ward);
}

selectState(state: string) {
cy.typeAndSelectOption('[data-cy="select-state"]', state);
return this;
}

selectDistrict(district: string) {
cy.typeAndSelectOption('[data-cy="select-district"]', district);
return this;
}

selectLocalBody(localBody: string) {
cy.typeAndSelectOption('[data-cy="select-local_body"]', localBody);
return this;
}

selectWard(ward: string) {
cy.typeAndSelectOption('[data-cy="select-ward"]', ward);
return this;
}

submitPatientForm() {
cy.clickSubmitButton("Save and Continue");
return this;
}

clickSamePhoneNumberCheckbox() {
cy.get('[data-cy="same-phone-number-checkbox"]').click();
return this;
}

assertPatientRegistrationSuccess() {
cy.verifyNotification("Patient Registered Successfully");
return this;
}
}

export const patientCreation = new PatientCreation();
8 changes: 8 additions & 0 deletions cypress/pageObject/Patients/PatientDashboard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class PatientDashboard {
verifyEncounterPatientInfo(contents: string[]) {
cy.verifyContentPresence("#patient-infobadges", contents);
return this;
}
}

export const patientDashboard = new PatientDashboard();
41 changes: 0 additions & 41 deletions cypress/pageObject/Patients/PatientSearch.ts

This file was deleted.

63 changes: 63 additions & 0 deletions cypress/pageObject/Patients/PatientVerify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
class PatientVerify {
verifyPatientName(expectedName: string) {
cy.get('[data-cy="verify-patient-name"]').should("contain", expectedName);
return this;
}

verifyCreateEncounterButton() {
cy.get('[data-cy="create-encounter-button"]').should(
"contain",
"Create Encounter",
);
return this;
}

clickCreateEncounter() {
cy.verifyAndClickElement(
'[data-cy="create-encounter-button"]',
"Create Encounter",
);
return this;
}

// Map display text to data-cy values for better maintainability
private encounterTypeMap = {
Observation: "obsenc",
Inpatient: "imp",
Ambulatory: "amb",
Emergency: "emer",
Virtual: "vr",
"Home Health": "hh",
};

selectEncounterType(displayText: string) {
const dataCyValue = this.encounterTypeMap[displayText];
cy.verifyAndClickElement(
`[data-cy="encounter-type-${dataCyValue}"]`,
displayText,
);
return this;
}

selectEncounterStatus(status: string) {
cy.clickAndSelectOption('[data-cy="encounter-status"]', status);
return this;
}

selectEncounterPriority(priority: string) {
cy.clickAndSelectOption('[data-cy="encounter-priority"]', priority);
return this;
}

clickSubmitEncounter() {
cy.clickSubmitButton("Create Encounter");
return this;
}

assertEncounterCreationSuccess() {
cy.verifyNotification("Encounter created successfully");
return this;
}
}

export const patientVerify = new PatientVerify();
Loading

0 comments on commit 91e9334

Please sign in to comment.