|
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;
|
13 | 15 | import static io.gatling.javaapi.core.CoreDsl.bodyString;
|
14 | 16 | import static io.gatling.javaapi.core.CoreDsl.jsonPath;
|
15 | 17 | import static io.gatling.javaapi.http.HttpDsl.http;
|
| 18 | +import static org.openmrs.performance.Constants.ALLERGY_REACTION_UUID; |
16 | 19 | import static org.openmrs.performance.Constants.CARE_SETTING_UUID;
|
| 20 | +import static org.openmrs.performance.Constants.CODED_ALLERGEN_UUID; |
17 | 21 | import static org.openmrs.performance.Constants.DAYS;
|
18 | 22 | import static org.openmrs.performance.Constants.DEFAULT_DOSING_TYPE;
|
19 | 23 | import static org.openmrs.performance.Constants.DRUG_ORDER;
|
20 | 24 | import static org.openmrs.performance.Constants.ONCE_DAILY;
|
21 | 25 | import static org.openmrs.performance.Constants.ORAL;
|
22 | 26 | import static org.openmrs.performance.Constants.ORDER;
|
23 | 27 | import static org.openmrs.performance.Constants.OUTPATIENT_CLINIC_LOCATION_UUID;
|
| 28 | +import static org.openmrs.performance.Constants.SEVERITY_UUID; |
24 | 29 | import static org.openmrs.performance.Constants.TABLET;
|
25 | 30 |
|
26 | 31 | public class DoctorHttpService extends HttpService {
|
@@ -60,6 +65,8 @@ public HttpRequestActionBuilder getActiveVisitOfPatient(String patientUuid) {
|
60 | 65 | return http("Get Active Visits of Patient")
|
61 | 66 | .get("/openmrs/ws/rest/v1/visit?patient=" + patientUuid + "&v=" + customRepresentation + "&includeInactive=false");
|
62 | 67 | }
|
| 68 | + |
| 69 | + |
63 | 70 |
|
64 | 71 | public HttpRequestActionBuilder getProgramEnrollments(String patientUuid) {
|
65 | 72 | String customRepresentation = "custom:(uuid,display,program,dateEnrolled,dateCompleted," +
|
@@ -153,6 +160,46 @@ public HttpRequestActionBuilder getAllergies(String patientUuid) {
|
153 | 160 | return http("Get Allergies of Patient")
|
154 | 161 | .get("/openmrs/ws/fhir2/R4/AllergyIntolerance?patient=" + patientUuid + "&_summary=data");
|
155 | 162 | }
|
| 163 | + |
| 164 | + public HttpRequestActionBuilder getAllergens(String allergenType, String allergenUuid) { |
| 165 | + return http("Get " + allergenType + " Allergens") |
| 166 | + .get("/openmrs/ws/rest/v1/concept/" + allergenUuid + "?v=full"); |
| 167 | + } |
| 168 | + |
| 169 | + |
| 170 | + public HttpRequestActionBuilder saveAllergy(String patientUuid) { |
| 171 | + Map<String, Object> payload = new HashMap<>(); |
| 172 | + |
| 173 | + Map<String,String> codedAllergen = new HashMap<>(); |
| 174 | + codedAllergen.put("uuid", CODED_ALLERGEN_UUID); |
| 175 | + |
| 176 | + Map<String,Object>allergen = new HashMap<>(); |
| 177 | + allergen.put("allergenType", "DRUG"); |
| 178 | + allergen.put("codedAllergen", codedAllergen); |
| 179 | + |
| 180 | + Map<String,String>severity = new HashMap<>(); |
| 181 | + severity.put("uuid", SEVERITY_UUID); |
| 182 | + |
| 183 | + Map<String, String> reactionUuid = new HashMap<>(); |
| 184 | + reactionUuid.put("uuid", ALLERGY_REACTION_UUID); |
| 185 | + |
| 186 | + Map<String, Object> reaction = new HashMap<>(); |
| 187 | + reaction.put("reaction", reactionUuid); |
| 188 | + List<Map<String, Object>> reactions = Collections.singletonList(reaction); |
| 189 | + |
| 190 | + payload.put("allergen", allergen); |
| 191 | + payload.put("severity", severity); |
| 192 | + payload.put("comment", "test"); |
| 193 | + payload.put("reactions", reactions); |
| 194 | + |
| 195 | + try { |
| 196 | + return http("Save an Allergy") |
| 197 | + .post("/openmrs/ws/rest/v1/patient/" + patientUuid + "/allergy") |
| 198 | + .body(StringBody(new ObjectMapper().writeValueAsString(payload))); |
| 199 | + } catch (JsonProcessingException e) { |
| 200 | + throw new RuntimeException(e); |
| 201 | + } |
| 202 | + } |
156 | 203 |
|
157 | 204 | public HttpRequestActionBuilder getConditions(String patientUuid) {
|
158 | 205 | return http("Get Conditions of Patient")
|
|
0 commit comments