Skip to content

Commit 711dd69

Browse files
committedJan 20, 2025
O3-4357:break into two actions
1 parent ffe6d9e commit 711dd69

File tree

3 files changed

+65
-24
lines changed

3 files changed

+65
-24
lines changed
 

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

+49-21
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
import java.time.ZonedDateTime;
88
import java.time.format.DateTimeFormatter;
9+
import java.util.Collections;
910
import java.util.HashMap;
11+
import java.util.List;
1012
import java.util.Map;
1113

1214
import static io.gatling.javaapi.core.CoreDsl.StringBody;
@@ -162,37 +164,63 @@ public HttpRequestActionBuilder searchPatient(String searchQuery) {
162164
"&includeDead=" + true +
163165
"&limit=" + 10);
164166
}
165-
167+
168+
166169

167170
public HttpRequestActionBuilder getAllergies(String patientUuid) {
168171
return http("Get Allergies of Patient")
169172
.get("/openmrs/ws/fhir2/R4/AllergyIntolerance?patient=" + patientUuid + "&_summary=data");
170173
}
171174

175+
public HttpRequestActionBuilder GetDrugAllergens(String drugAllergenUuid) {
176+
return http("Get Drug Allergens")
177+
.get("/openmrs/ws/rest/v1/concept/" + drugAllergenUuid + "?v=full");
178+
}
179+
180+
public HttpRequestActionBuilder GetEnvironmentAllergens(String environmentalAllergenUuid) {
181+
return http("Get Environment Allergens")
182+
.get("/openmrs/ws/rest/v1/concept/" + environmentalAllergenUuid + "?v=full");
183+
}
184+
185+
public HttpRequestActionBuilder GetFoodAllergens(String foodAllergenUuid) {
186+
return http("Get Food Allergens")
187+
.get("/openmrs/ws/rest/v1/concept/" + foodAllergenUuid + "?v=full");
188+
}
189+
190+
public HttpRequestActionBuilder GetAllergicReactions(String allergyReactionUuid) {
191+
return http("Get Allergic Reactions")
192+
.get("/openmrs/ws/rest/v1/concept/" + allergyReactionUuid + "?v=full");
193+
}
194+
172195
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-
"}";
196+
Map<String, Object> payload = new HashMap<>();
197+
198+
Map<String,String> codedAllergen = new HashMap<>();
199+
codedAllergen.put("uuid", "71617AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
200+
201+
Map<String,Object>allergen = new HashMap<>();
202+
allergen.put("allergenType", "DRUG");
203+
allergen.put("codedAllergen", codedAllergen);
204+
205+
Map<String,String>severity = new HashMap<>();
206+
severity.put("uuid", "1498AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
207+
208+
Map<String, String> reactionUuid = new HashMap<>();
209+
reactionUuid.put("uuid", "121677AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
210+
211+
Map<String, Object> reaction = new HashMap<>();
212+
reaction.put("reaction", reactionUuid);
213+
List<Map<String, Object>> reactions = Collections.singletonList(reaction);
214+
215+
payload.put("allergen", allergen);
216+
payload.put("severity", severity);
217+
payload.put("comment", "test");
218+
payload.put("reactions", reactions);
219+
192220

193221
return http("Save Allergies of Patient")
194222
.get("/openmrs/ws/rest/v1/patient/"+ patientUuid +"/allergy")
195-
.body(StringBody(payload));
223+
.body(StringBody(payload.toString()));
196224

197225

198226
}

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

+15-3
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,22 @@ public ChainBuilder openAllergiesTab(String patientUuid) {
9595
return exec(httpService.getAllergies(patientUuid));
9696
}
9797

98-
public ChainBuilder addAllergies(String patientUuid) {
98+
public ChainBuilder OpenAllergiesForm(){
99+
String drugAllergenUuid = "162555AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
100+
String environmentalAllergenUuid = "162552AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
101+
String foodAllergenUuid = "162554AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
102+
String allergyReactionUuid = "162553AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
103+
104+
return exec(
105+
httpService.GetDrugAllergens(drugAllergenUuid),
106+
httpService.GetEnvironmentAllergens(environmentalAllergenUuid),
107+
httpService.GetFoodAllergens(foodAllergenUuid),
108+
httpService.GetAllergicReactions(allergyReactionUuid)
109+
);
110+
}
111+
112+
public ChainBuilder addAllergies(String patientUuid) {
99113
return exec(
100-
httpService.searchPatient("test location test"),
101-
httpService.getAllergies(patientUuid),
102114
httpService.saveAllergies(patientUuid)
103115
);
104116
}

‎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.OpenAllergiesForm())
3233
.exec(registry.addAllergies("#{patient_uuid}"))
3334
.exec(registry.openConditionsTab("#{patient_uuid}"))
3435
.exec(registry.openImmunizationsTab("#{patient_uuid}"))

0 commit comments

Comments
 (0)
Failed to load comments.