/
patient_registration.cy.ts
298 lines (288 loc) · 11.5 KB
/
patient_registration.cy.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress";
import LoginPage from "../../pageobject/Login/LoginPage";
import { PatientPage } from "../../pageobject/Patient/PatientCreation";
import FacilityPage from "../../pageobject/Facility/FacilityCreation";
import {
generatePhoneNumber,
generateEmergencyPhoneNumber,
} from "../../pageobject/constants";
import PatientTransfer from "../../pageobject/Patient/PatientTransfer";
import PatientExternal from "../../pageobject/Patient/PatientExternal";
import PatientInsurance from "../../pageobject/Patient/PatientInsurance";
import PatientMedicalHistory from "../../pageobject/Patient/PatientMedicalHistory";
const yearOfBirth = "2001";
const calculateAge = () => {
const currentYear = new Date().getFullYear();
return currentYear - parseInt(yearOfBirth);
};
describe("Patient Creation with consultation", () => {
const loginPage = new LoginPage();
const patientPage = new PatientPage();
const facilityPage = new FacilityPage();
const patientTransfer = new PatientTransfer();
const patientExternal = new PatientExternal();
const patientInsurance = new PatientInsurance();
const patientMedicalHistory = new PatientMedicalHistory();
const phone_number = generatePhoneNumber();
const emergency_phone_number = generateEmergencyPhoneNumber();
const age = calculateAge();
const patientFacility = "Dummy Facility 40";
const patientDateOfBirth = "01012001";
const patientOneName = "Patient With No Consultation";
const patientOneGender = "Male";
const patientOneUpdatedGender = "Female";
const patientOneAddress = "Test Patient Address";
const patientOnePincode = "682001";
const patientOneState = "Kerala";
const patientOneDistrict = "Ernakulam";
const patientOneLocalbody = "Aluva";
const patientOneWard = "4";
const patientOnePresentHealth = "Present Health Condition";
const patientOneOngoingMedication = "Ongoing Medication";
const patientOneAllergies = "Allergies";
const patientOneBloodGroup = "O+";
const patientOneUpdatedBloodGroup = "AB+";
const patientOneFirstInsuranceId = "insurance-details-0";
const patientOneFirstSubscriberId = "member id 01";
const patientOneFirstPolicyId = "policy name 01";
const patientOneFirstInsurerId = "insurer id 01";
const patientOneFirstInsurerName = "insurer name 01";
const patientOneSecondInsuranceId = "insurance-details-1";
const patientOneSecondSubscriberId = "member id 02";
const patientOneSecondPolicyId = "policy name 02";
const patientOneSecondInsurerId = "insurer id 02";
const patientOneSecondInsurerName = "insurer name 02";
const patientTransferPhoneNumber = "9849511866";
const patientTransferFacility = "Dummy Shifting Center";
const patientTransferName = "Dummy Patient 10";
const patientExternalName = "Patient 20";
const patientOccupation = "Student";
before(() => {
loginPage.loginAsDisctrictAdmin();
cy.saveLocalStorage();
});
beforeEach(() => {
cy.restoreLocalStorage();
cy.clearLocalStorage(/filters--.+/);
cy.awaitUrl("/patients");
});
it("Create a new patient with all field in registration form and no consultation", () => {
// patient details with all the available fields except covid
patientPage.createPatient();
patientPage.selectFacility(patientFacility);
patientPage.patientformvisibility();
// Patient Details page
patientPage.typePatientPhoneNumber(phone_number);
patientPage.typePatientEmergencyNumber(emergency_phone_number);
patientPage.typePatientDateOfBirth(patientDateOfBirth);
patientPage.typePatientName(patientOneName);
patientPage.selectPatientGender(patientOneGender);
patientPage.typePatientAddress(patientOneAddress);
facilityPage.fillPincode(patientOnePincode);
facilityPage.selectStateOnPincode(patientOneState);
facilityPage.selectDistrictOnPincode(patientOneDistrict);
facilityPage.selectLocalBody(patientOneLocalbody);
facilityPage.selectWard(patientOneWard);
patientPage.selectPatientOccupation(patientOccupation);
// Patient Medical History
patientMedicalHistory.typePatientPresentHealth(patientOnePresentHealth);
patientMedicalHistory.typePatientOngoingMedication(
patientOneOngoingMedication
);
patientMedicalHistory.typeMedicalHistory(2, "Diabetes");
patientMedicalHistory.typeMedicalHistory(3, "Heart Disease");
patientMedicalHistory.typeMedicalHistory(4, "HyperTension");
patientMedicalHistory.typeMedicalHistory(5, "Kidney Diseases");
patientMedicalHistory.typeMedicalHistory(6, "Lung Diseases/Asthma");
patientMedicalHistory.typeMedicalHistory(7, "Cancer");
patientMedicalHistory.typeMedicalHistory(8, "Other");
patientMedicalHistory.typePatientAllergies(patientOneAllergies);
patientPage.selectPatientBloodGroup(patientOneBloodGroup);
patientPage.clickCreatePatient();
patientPage.verifyPatientIsCreated();
// Verify the patient details
patientPage.clickCancelButton();
cy.wait(3000);
patientPage.savePatientUrl();
patientPage.verifyPatientDashboardDetails(
patientOneGender,
age,
patientOneName,
phone_number,
emergency_phone_number,
yearOfBirth,
patientOneBloodGroup,
patientOccupation
);
patientMedicalHistory.verifyPatientMedicalDetails(
patientOnePresentHealth,
patientOneOngoingMedication,
patientOneAllergies,
"Diabetes",
"Heart Disease",
"HyperTension",
"Kidney Diseases",
"Lung Diseases/Asthma",
"Cancer",
"Other"
);
// verify its presence in the patient detail page
cy.visit("/patients");
patientPage.typePatientNameList(patientOneName);
patientPage.verifyPatientNameList(patientOneName);
});
it("Edit the patient details with no consultation and verify", () => {
patientPage.interceptFacilities();
patientPage.visitUpdatePatientUrl();
patientPage.verifyStatusCode();
patientPage.patientformvisibility();
// change the gender to female and input data to related changed field
cy.wait(3000);
patientPage.selectPatientGender(patientOneUpdatedGender);
patientPage.clickPatientAntenatalStatusYes();
patientPage.selectPatientBloodGroup(patientOneUpdatedBloodGroup);
// Edit the patient consultation , select none medical history and multiple health ID
patientMedicalHistory.clickNoneMedicialHistory();
patientInsurance.clickAddInsruanceDetails();
patientInsurance.typePatientInsuranceDetail(
patientOneFirstInsuranceId,
"subscriber_id",
patientOneFirstSubscriberId
);
patientInsurance.typePatientInsuranceDetail(
patientOneFirstInsuranceId,
"policy_id",
patientOneFirstPolicyId
);
patientInsurance.typePatientInsuranceDetail(
patientOneFirstInsuranceId,
"insurer_id",
patientOneFirstInsurerId
);
patientInsurance.typePatientInsuranceDetail(
patientOneFirstInsuranceId,
"insurer_name",
patientOneFirstInsurerName
);
patientInsurance.clickAddInsruanceDetails();
patientInsurance.typePatientInsuranceDetail(
patientOneSecondInsuranceId,
"subscriber_id",
patientOneSecondSubscriberId
);
patientInsurance.typePatientInsuranceDetail(
patientOneSecondInsuranceId,
"policy_id",
patientOneSecondPolicyId
);
patientInsurance.typePatientInsuranceDetail(
patientOneSecondInsuranceId,
"insurer_id",
patientOneSecondInsurerId
);
patientInsurance.typePatientInsuranceDetail(
patientOneSecondInsuranceId,
"insurer_name",
patientOneSecondInsurerName
);
patientPage.clickUpdatePatient();
cy.wait(3000);
patientPage.verifyPatientUpdated();
patientPage.visitPatientUrl();
// Verify Female Gender change reflection, No Medical History and Insurance Details
cy.wait(5000);
patientPage.verifyPatientDashboardDetails(
patientOneUpdatedGender,
age,
patientOneName,
phone_number,
emergency_phone_number,
yearOfBirth,
patientOneUpdatedBloodGroup,
patientOccupation
);
// Verify No medical history
patientMedicalHistory.verifyNoSymptosPresent("Diabetes");
// verify insurance details and dedicatd page
cy.get("[data-testid=patient-details]")
.contains(patientOneFirstSubscriberId)
.scrollIntoView();
cy.wait(2000);
patientInsurance.verifyPatientPolicyDetails(
patientOneFirstSubscriberId,
patientOneFirstPolicyId,
patientOneFirstInsurerId,
patientOneFirstInsurerName
);
patientInsurance.clickPatientInsuranceViewDetail();
cy.wait(3000);
patientInsurance.verifyPatientPolicyDetails(
patientOneFirstSubscriberId,
patientOneFirstPolicyId,
patientOneFirstInsurerId,
patientOneFirstInsurerName
);
patientInsurance.verifyPatientPolicyDetails(
patientOneSecondSubscriberId,
patientOneSecondPolicyId,
patientOneSecondInsurerId,
patientOneSecondInsurerName
);
});
it("Patient Registration using the transfer with no consultation", () => {
// transfer the patient and no consulation
patientPage.createPatient();
patientPage.selectFacility(patientTransferFacility);
patientPage.patientformvisibility();
patientPage.typePatientPhoneNumber(patientTransferPhoneNumber);
patientTransfer.clickAdmitPatientRecordButton();
patientTransfer.clickTransferPopupContinueButton();
patientTransfer.clickTransferPatientNameList(patientTransferName);
patientTransfer.clickTransferPatientDob(patientDateOfBirth);
patientTransfer.clickTransferSubmitButton();
patientTransfer.verifyFacilitySuccessfullMessage();
patientTransfer.clickConsultationCancelButton();
cy.wait(3000);
// allow the transfer button of a patient
patientTransfer.clickAllowPatientTransferButton();
// Verify the patient error message for the same facility
cy.awaitUrl("/patients");
patientPage.createPatient();
patientPage.selectFacility(patientTransferFacility);
patientPage.patientformvisibility();
patientPage.typePatientPhoneNumber(patientTransferPhoneNumber);
patientTransfer.clickAdmitPatientRecordButton();
patientTransfer.clickTransferPopupContinueButton();
patientTransfer.clickTransferPatientNameList(patientTransferName);
patientTransfer.clickTransferPatientDob(patientDateOfBirth);
patientTransfer.clickTransferSubmitButton();
patientTransfer.verifyFacilityErrorMessage();
});
it("Patient Registration using External Result Import", () => {
// copy the patient external ID from external results
cy.awaitUrl("/external_results");
patientExternal.verifyExternalListPatientName(patientExternalName);
patientExternal.verifyExternalIdVisible();
// cypress have a limitation to work only asynchronously
// import the result and create a new patient
let extractedId = "";
cy.get("#patient-external-id")
.invoke("text")
.then((text) => {
extractedId = text.split("Care external results ID: ")[1];
cy.log(`Extracted Care external results ID: ${extractedId}`);
cy.awaitUrl("/patients");
patientPage.createPatient();
patientPage.selectFacility(patientFacility);
patientPage.patientformvisibility();
patientExternal.clickImportFromExternalResultsButton();
patientExternal.typeCareExternalResultId(extractedId);
patientExternal.clickImportPatientData();
});
// verify the patient is successfully created
patientExternal.verifyExternalPatientName(patientExternalName);
});
afterEach(() => {
cy.saveLocalStorage();
});
});