-
Notifications
You must be signed in to change notification settings - Fork 12
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
Changes from 1 commit
3d94ed8
0c1507e
e603771
b30bd80
e07020b
e4e0157
a4bdb66
c4c3217
cd3ccf6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,22 @@ | |
|
||
import io.gatling.javaapi.http.HttpRequestActionBuilder; | ||
|
||
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 +124,28 @@ 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) { | ||
Map<String, Object> saveVitals = new HashMap<>(); | ||
saveVitals.put("form", VISIT_NOTE_FORM_UUID); | ||
saveVitals.put("patient", patientUuid); | ||
saveVitals.put("location", OUTPATIENT_CLINIC_LOCATION_UUID); | ||
saveVitals.put("encounterType", VISIT_NOTE_ENCOUNTER_TYPE_UUID); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be changed |
||
|
||
Map<String, Object> obs = new HashMap<>(); | ||
obs.put("concept", Map.of("uuid", VITALS_CONCEPT)); | ||
obs.put("value", value); | ||
|
||
saveVitals.put("obs", List.of(obs)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. Full list of concept ids can be found here: There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
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