Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

O3-4487 Save Vitals Data in Visit Patient scenario #71

Merged
merged 9 commits into from
Mar 4, 2025
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/test/java/org/openmrs/performance/Constants.java
Original file line number Diff line number Diff line change
@@ -53,4 +53,6 @@ public class Constants {
public static final String DIABETIC_KETOSIS_CONCEPT = "123107AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
public static final String DIABETIC_FOOT_ULCER_CONCEPT = "149069AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";

// Vitals
public static final String VITALS_CONCEPT = "5085AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
}
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@

import static io.gatling.javaapi.core.CoreDsl.StringBody;
import static io.gatling.javaapi.core.CoreDsl.bodyString;
import static io.gatling.javaapi.core.CoreDsl.exec;
import static io.gatling.javaapi.core.CoreDsl.jsonPath;
import static io.gatling.javaapi.http.HttpDsl.http;
import static org.openmrs.performance.Constants.ALLERGY_REACTION_UUID;
39 changes: 39 additions & 0 deletions src/test/java/org/openmrs/performance/http/HttpService.java
Original file line number Diff line number Diff line change
@@ -2,13 +2,24 @@

import io.gatling.javaapi.http.HttpRequestActionBuilder;

import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringJoiner;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import static io.gatling.javaapi.core.CoreDsl.StringBody;
import static io.gatling.javaapi.core.CoreDsl.jsonPath;
import static io.gatling.javaapi.http.HttpDsl.http;
import static org.openmrs.performance.Constants.OUTPATIENT_CLINIC_LOCATION_UUID;
import static org.openmrs.performance.Constants.VISIT_NOTE_ENCOUNTER_TYPE_UUID;
import static org.openmrs.performance.Constants.VISIT_NOTE_FORM_UUID;
import static org.openmrs.performance.Constants.VITALS_CONCEPT;

public abstract class HttpService {
public HttpRequestActionBuilder loginRequest() {
@@ -115,4 +126,32 @@ public HttpRequestActionBuilder getActiveOrders(String patientUuid) {
return http("Get Active Orders")
.get("/openmrs/ws/rest/v1/order?patient="+patientUuid+"&careSetting=6f0c9a92-6f24-11e3-af88-005056821db0&status=ACTIVE&orderType=131168f4-15f5-102d-96e4-000c29c2a5d7&v=custom:(uuid,dosingType,orderNumber,accessionNumber,patient:ref,action,careSetting:ref,previousOrder:ref,dateActivated,scheduledDate,dateStopped,autoExpireDate,orderType:ref,encounter:ref,orderer:(uuid,display,person:(display)),orderReason,orderReasonNonCoded,orderType,urgency,instructions,commentToFulfiller,drug:(uuid,display,strength,dosageForm:(display,uuid),concept),dose,doseUnits:ref,frequency:ref,asNeeded,asNeededCondition,quantity,quantityUnits:ref,numRefills,dosingInstructions,duration,durationUnits:ref,route:ref,brandName,dispenseAsWritten)");
}

public HttpRequestActionBuilder saveVitalsData(String patientUuid, int value) {
ZonedDateTime now = ZonedDateTime.now();
String encounterDatetime = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ"));

Map<String, Object> saveVitals = new HashMap<>();
saveVitals.put("form", VISIT_NOTE_FORM_UUID);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The form here is different: 9f26aad4-244a-46ca-be49-1196df1a8c9a

saveVitals.put("patient", patientUuid);
saveVitals.put("location", OUTPATIENT_CLINIC_LOCATION_UUID);
saveVitals.put("encounterType", VISIT_NOTE_ENCOUNTER_TYPE_UUID);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be changed

saveVitals.put("encounterDatetime", encounterDatetime);

Map<String, Object> obs = new HashMap<>();
obs.put("concept", Map.of("uuid", VITALS_CONCEPT));
obs.put("value", value);

saveVitals.put("obs", List.of(obs));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A single submission contains all the vitals (and biometrics) in it as a list of obs. ex: temperature is one observation.
ex: 5085AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA (the value corresponding to the VITALS_CONCEPT you defined) concept id is systolic Blood Pressure.

Full list of concept ids can be found here:

https://github.com/openmrs/openmrs-esm-patient-chart/blob/1bb5ccbc827def608924545747d55d0fe2c67b66/packages/esm-patient-vitals-app/src/config-schema.ts#L3

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank @jayasanka-sack for reviewing my PR. I will make the necessary changes


try {
String body = new ObjectMapper().writeValueAsString(saveVitals); // Convert Map to JSON

return http("Save Vitals").post("/openmrs/ws/rest/v1/encounter").body(StringBody(body));

}
catch (JsonProcessingException e) {
throw new RuntimeException("Error converting visitNote to JSON", e);
}
}
}
Original file line number Diff line number Diff line change
@@ -73,7 +73,8 @@ public ChainBuilder openVitalsAndBiometricsTab(String patientUuid) {
MID_UPPER_ARM_CIRCUMFERENCE
);
return exec(httpService.getPatientObservations(patientUuid, vitals))
.exec(httpService.getPatientObservations(patientUuid, biometrics));
.exec(httpService.getPatientObservations(patientUuid, biometrics))
.exec(httpService.saveVitalsData(patientUuid, 34));
}

public ChainBuilder openMedicationsTab(String patientUuid) {