|
6 | 6 |
|
7 | 7 | import java.time.ZonedDateTime;
|
8 | 8 | import java.time.format.DateTimeFormatter;
|
| 9 | +import java.util.Collections; |
9 | 10 | import java.util.HashMap;
|
| 11 | +import java.util.List; |
10 | 12 | import java.util.Map;
|
11 | 13 |
|
12 | 14 | import static io.gatling.javaapi.core.CoreDsl.StringBody;
|
@@ -162,37 +164,63 @@ public HttpRequestActionBuilder searchPatient(String searchQuery) {
|
162 | 164 | "&includeDead=" + true +
|
163 | 165 | "&limit=" + 10);
|
164 | 166 | }
|
165 |
| - |
| 167 | + |
| 168 | + |
166 | 169 |
|
167 | 170 | public HttpRequestActionBuilder getAllergies(String patientUuid) {
|
168 | 171 | return http("Get Allergies of Patient")
|
169 | 172 | .get("/openmrs/ws/fhir2/R4/AllergyIntolerance?patient=" + patientUuid + "&_summary=data");
|
170 | 173 | }
|
171 | 174 |
|
| 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 | + |
172 | 195 | 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 | + |
192 | 220 |
|
193 | 221 | return http("Save Allergies of Patient")
|
194 | 222 | .get("/openmrs/ws/rest/v1/patient/"+ patientUuid +"/allergy")
|
195 |
| - .body(StringBody(payload)); |
| 223 | + .body(StringBody(payload.toString())); |
196 | 224 |
|
197 | 225 |
|
198 | 226 | }
|
|
0 commit comments