Skip to content

Commit ffe6d9e

Browse files
committedJan 20, 2025
O3-4357:Add Allergy Recording to Patient Visit Scenario
1 parent 758dc15 commit ffe6d9e

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed
 

‎src/test/java/org/openmrs/performance/http/DoctorHttpService.java

+43
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ public HttpRequestActionBuilder getActiveVisitOfPatient(String patientUuid) {
6060
return http("Get Active Visits of Patient")
6161
.get("/openmrs/ws/rest/v1/visit?patient=" + patientUuid + "&v=" + customRepresentation + "&includeInactive=false");
6262
}
63+
64+
6365

6466
public HttpRequestActionBuilder getProgramEnrollments(String patientUuid) {
6567
String customRepresentation = "custom:(uuid,display,program,dateEnrolled,dateCompleted," +
@@ -148,11 +150,52 @@ public HttpRequestActionBuilder getDrugOrders(String patientUuid) {
148150
"&status=any&orderType=" + DRUG_ORDER +
149151
"&v=" + customRepresentation);
150152
}
153+
154+
public HttpRequestActionBuilder searchPatient(String searchQuery) {
155+
String customRepresentation = """
156+
custom:(patientId,uuid,identifiers,display,patientIdentifier:(uuid,identifier),person:(gender,age,birthdate,birthdateEstimated,personName,addresses,display,dead,deathDate),attributes:(value,attributeType:(uuid,display)))
157+
""";
158+
return http("Get Orders")
159+
.get("/openmrs/ws/rest/v1/patient" +
160+
"?q=" + searchQuery +
161+
"&v=" + customRepresentation +
162+
"&includeDead=" + true +
163+
"&limit=" + 10);
164+
}
165+
151166

152167
public HttpRequestActionBuilder getAllergies(String patientUuid) {
153168
return http("Get Allergies of Patient")
154169
.get("/openmrs/ws/fhir2/R4/AllergyIntolerance?patient=" + patientUuid + "&_summary=data");
155170
}
171+
172+
public HttpRequestActionBuilder saveAllergies(String patientUuid) {
173+
String payload = "{\n" +
174+
" \"allergen\": {\n" +
175+
" \"allergenType\": \"DRUG\",\n" +
176+
" \"codedAllergen\": {\n" +
177+
" \"uuid\": \"71617AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"\n" +
178+
" }\n" +
179+
" },\n" +
180+
" \"severity\": {\n" +
181+
" \"uuid\": \"1498AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"\n" +
182+
" },\n" +
183+
" \"comment\": \"test\",\n" +
184+
" \"reactions\": [\n" +
185+
" {\n" +
186+
" \"reaction\": {\n" +
187+
" \"uuid\": \"121677AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"\n" +
188+
" }\n" +
189+
" }\n" +
190+
" ]\n" +
191+
"}";
192+
193+
return http("Save Allergies of Patient")
194+
.get("/openmrs/ws/rest/v1/patient/"+ patientUuid +"/allergy")
195+
.body(StringBody(payload));
196+
197+
198+
}
156199

157200
public HttpRequestActionBuilder getConditions(String patientUuid) {
158201
return http("Get Conditions of Patient")

‎src/test/java/org/openmrs/performance/registries/DoctorRegistry.java

+8
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ public ChainBuilder openLabResultsTab(String patientUuid) {
9494
public ChainBuilder openAllergiesTab(String patientUuid) {
9595
return exec(httpService.getAllergies(patientUuid));
9696
}
97+
98+
public ChainBuilder addAllergies(String patientUuid) {
99+
return exec(
100+
httpService.searchPatient("test location test"),
101+
httpService.getAllergies(patientUuid),
102+
httpService.saveAllergies(patientUuid)
103+
);
104+
}
97105

98106
public ChainBuilder openConditionsTab(String patientUuid) {
99107
return exec(httpService.getConditions(patientUuid));

‎src/test/java/org/openmrs/performance/scenarios/VisitPatientScenario.java

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public ScenarioBuilder getScenarioBuilder() {
2929
.exec(registry.openOrdersTab("#{patient_uuid}"))
3030
.exec(registry.openLabResultsTab("#{patient_uuid}"))
3131
.exec(registry.openAllergiesTab("#{patient_uuid}"))
32+
.exec(registry.addAllergies("#{patient_uuid}"))
3233
.exec(registry.openConditionsTab("#{patient_uuid}"))
3334
.exec(registry.openImmunizationsTab("#{patient_uuid}"))
3435
.exec(registry.openAttachmentsTab("#{patient_uuid}"))

0 commit comments

Comments
 (0)
Failed to load comments.