|
7 | 7 |
|
8 | 8 | import java.time.ZonedDateTime;
|
9 | 9 | import java.time.format.DateTimeFormatter;
|
| 10 | +import java.util.ArrayList; |
10 | 11 | import java.util.Collections;
|
11 | 12 | import java.util.HashMap;
|
12 | 13 | import java.util.List;
|
13 | 14 | import java.util.Map;
|
14 | 15 |
|
15 | 16 | import static io.gatling.javaapi.core.CoreDsl.StringBody;
|
16 | 17 | import static io.gatling.javaapi.core.CoreDsl.bodyString;
|
17 |
| -import static io.gatling.javaapi.core.CoreDsl.exec; |
18 | 18 | import static io.gatling.javaapi.core.CoreDsl.jsonPath;
|
19 | 19 | import static io.gatling.javaapi.http.HttpDsl.RawFileBodyPart;
|
20 | 20 | import static io.gatling.javaapi.http.HttpDsl.StringBodyPart;
|
21 | 21 | import static io.gatling.javaapi.http.HttpDsl.http;
|
22 | 22 | import static org.openmrs.performance.Constants.ALLERGY_REACTION_UUID;
|
| 23 | +import static org.openmrs.performance.Constants.ARTERIAL_BLOOD_OXYGEN_SATURATION; |
23 | 24 | import static org.openmrs.performance.Constants.CARE_SETTING_UUID;
|
24 | 25 | import static org.openmrs.performance.Constants.CLINICIAN_ENCOUNTER_ROLE;
|
25 | 26 | import static org.openmrs.performance.Constants.CODED_ALLERGEN_UUID;
|
26 | 27 | import static org.openmrs.performance.Constants.DAYS;
|
27 | 28 | import static org.openmrs.performance.Constants.DEFAULT_DOSING_TYPE;
|
| 29 | +import static org.openmrs.performance.Constants.DIASTOLIC_BLOOD_PRESSURE; |
28 | 30 | import static org.openmrs.performance.Constants.DRUG_ORDER;
|
| 31 | +import static org.openmrs.performance.Constants.HEIGHT_CM; |
| 32 | +import static org.openmrs.performance.Constants.MID_UPPER_ARM_CIRCUMFERENCE; |
29 | 33 | import static org.openmrs.performance.Constants.ONCE_DAILY;
|
30 | 34 | import static org.openmrs.performance.Constants.ORAL;
|
31 | 35 | import static org.openmrs.performance.Constants.ORDER;
|
32 | 36 | import static org.openmrs.performance.Constants.OUTPATIENT_CLINIC_LOCATION_UUID;
|
| 37 | +import static org.openmrs.performance.Constants.PULSE; |
| 38 | +import static org.openmrs.performance.Constants.RESPIRATORY_RATE; |
33 | 39 | import static org.openmrs.performance.Constants.SEVERITY_UUID;
|
| 40 | +import static org.openmrs.performance.Constants.SYSTOLIC_BLOOD_PRESSURE; |
34 | 41 | import static org.openmrs.performance.Constants.TABLET;
|
| 42 | +import static org.openmrs.performance.Constants.TEMPERATURE_C; |
35 | 43 | import static org.openmrs.performance.Constants.VISIT_NOTE_CONCEPT_UUID;
|
36 | 44 | import static org.openmrs.performance.Constants.VISIT_NOTE_ENCOUNTER_TYPE_UUID;
|
37 | 45 | import static org.openmrs.performance.Constants.VISIT_NOTE_FORM_UUID;
|
| 46 | +import static org.openmrs.performance.Constants.VITALS_ENCOUNTER_TYPE_UUID; |
| 47 | +import static org.openmrs.performance.Constants.VITALS_FORM_UUID; |
| 48 | +import static org.openmrs.performance.Constants.VITALS_LOCATION_UUID; |
| 49 | +import static org.openmrs.performance.Constants.WEIGHT_KG; |
38 | 50 |
|
39 | 51 | public class DoctorHttpService extends HttpService {
|
40 | 52 |
|
@@ -362,4 +374,37 @@ public HttpRequestActionBuilder saveDiagnosis(String patientUuid, String encount
|
362 | 374 | }
|
363 | 375 | }
|
364 | 376 |
|
| 377 | + public HttpRequestActionBuilder saveVitalsData(String patientUuid) { |
| 378 | + ZonedDateTime now = ZonedDateTime.now(); |
| 379 | + String encounterDatetime = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ")); |
| 380 | + |
| 381 | + Map<String, Object> encounter = new HashMap<>(); |
| 382 | + encounter.put("form", VITALS_FORM_UUID); |
| 383 | + encounter.put("patient", patientUuid); |
| 384 | + encounter.put("location", VITALS_LOCATION_UUID); |
| 385 | + encounter.put("encounterType", VITALS_ENCOUNTER_TYPE_UUID); |
| 386 | + encounter.put("encounterDatetime", encounterDatetime); |
| 387 | + |
| 388 | + List<Map<String, Object>> observations = new ArrayList<>(); |
| 389 | + observations.add(Map.of("concept", SYSTOLIC_BLOOD_PRESSURE, "value", 34)); |
| 390 | + observations.add(Map.of("concept", DIASTOLIC_BLOOD_PRESSURE, "value", 44)); |
| 391 | + observations.add(Map.of("concept", RESPIRATORY_RATE, "value", 100)); |
| 392 | + observations.add(Map.of("concept", ARTERIAL_BLOOD_OXYGEN_SATURATION, "value", 20)); |
| 393 | + observations.add(Map.of("concept", PULSE, "value", 120)); |
| 394 | + observations.add(Map.of("concept", TEMPERATURE_C, "value", 28)); |
| 395 | + observations.add(Map.of("concept", WEIGHT_KG, "value", 60)); |
| 396 | + observations.add(Map.of("concept", HEIGHT_CM, "value", 121)); |
| 397 | + observations.add(Map.of("concept", MID_UPPER_ARM_CIRCUMFERENCE, "value", 34)); |
| 398 | + |
| 399 | + encounter.put("obs", observations); |
| 400 | + |
| 401 | + try { |
| 402 | + String body = new ObjectMapper().writeValueAsString(encounter); // Convert Map to JSON |
| 403 | + return http("Save Vitals").post("/openmrs/ws/rest/v1/encounter").body(StringBody(body)); |
| 404 | + } |
| 405 | + catch (JsonProcessingException e) { |
| 406 | + throw new RuntimeException("Error converting visitNote to JSON", e); |
| 407 | + } |
| 408 | + } |
| 409 | + |
365 | 410 | }
|
0 commit comments