-
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-4280: implement Save a note in Visit Patient scenario #66
Changes from 1 commit
acb7d35
ebb0822
dc17c06
65803f8
a03acd7
2168ef4
b575882
92ef73f
1d5fef1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,10 +13,12 @@ | |
|
||
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; | ||
import static org.openmrs.performance.Constants.CARE_SETTING_UUID; | ||
import static org.openmrs.performance.Constants.CLINICIAN_ENCOUNTER_ROLE; | ||
import static org.openmrs.performance.Constants.CODED_ALLERGEN_UUID; | ||
import static org.openmrs.performance.Constants.DAYS; | ||
import static org.openmrs.performance.Constants.DEFAULT_DOSING_TYPE; | ||
|
@@ -27,6 +29,9 @@ | |
import static org.openmrs.performance.Constants.OUTPATIENT_CLINIC_LOCATION_UUID; | ||
import static org.openmrs.performance.Constants.SEVERITY_UUID; | ||
import static org.openmrs.performance.Constants.TABLET; | ||
import static org.openmrs.performance.Constants.VISIT_NOTE_CONCEPT_UUID; | ||
import static org.openmrs.performance.Constants.VISIT_NOTE_ENCOUNTER_TYPE_UUID; | ||
import static org.openmrs.performance.Constants.VISIT_NOTE_FORM_UUID; | ||
|
||
public class DoctorHttpService extends HttpService { | ||
|
||
|
@@ -287,4 +292,65 @@ public HttpRequestActionBuilder saveOrder(String patientUuid, String visitUuid, | |
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public HttpRequestActionBuilder saveVisitNote(String patientUuid, String currentUser, String value) { | ||
Map<String, Object> visitNote = new HashMap<>(); | ||
visitNote.put("form", VISIT_NOTE_FORM_UUID); | ||
visitNote.put("patient", patientUuid); | ||
visitNote.put("location", OUTPATIENT_CLINIC_LOCATION_UUID); | ||
visitNote.put("encounterType", VISIT_NOTE_ENCOUNTER_TYPE_UUID); | ||
|
||
Map<String, Object> encounterProvider = new HashMap<>(); | ||
encounterProvider.put("encounterRole", CLINICIAN_ENCOUNTER_ROLE); | ||
encounterProvider.put("provider", currentUser); | ||
|
||
Map<String, Object> obs = new HashMap<>(); | ||
obs.put("concept", Map.of("uuid", VISIT_NOTE_CONCEPT_UUID)); | ||
obs.put("value", value); | ||
|
||
visitNote.put("encounterProviders", List.of(encounterProvider)); | ||
visitNote.put("obs", List.of(obs)); | ||
|
||
try { | ||
String body = new ObjectMapper().writeValueAsString(visitNote); // Convert Map to JSON | ||
|
||
return http("Save Visit Note") | ||
.post("/openmrs/ws/rest/v1/encounter") | ||
.body(StringBody(body)) | ||
.check(jsonPath("$.uuid").saveAs("encounterUuid")); // Store encounter UUID | ||
} catch (JsonProcessingException e) { | ||
throw new RuntimeException("Error converting visitNote to JSON", e); | ||
} | ||
} | ||
|
||
|
||
public HttpRequestActionBuilder saveDiagnosis(String patientUuid, String encounterUuid, String diagnosisUuid,String certainty, int rank) { | ||
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. Let's move this to a separate PR |
||
try { | ||
Map<String, Object> patientDiagnosis = new HashMap<>(); | ||
patientDiagnosis.put("patient", patientUuid); | ||
patientDiagnosis.put("encounter", encounterUuid); | ||
patientDiagnosis.put("certainty", certainty); | ||
patientDiagnosis.put("rank", rank); | ||
patientDiagnosis.put("condition", null); | ||
|
||
Map<String, Object> diagnosis = new HashMap<>(); | ||
diagnosis.put("coded", diagnosisUuid); | ||
patientDiagnosis.put("diagnosis", diagnosis); | ||
|
||
ObjectMapper objectMapper = new ObjectMapper(); | ||
String body = objectMapper.writeValueAsString(patientDiagnosis); | ||
|
||
exec(seassion -> { | ||
System.out.println(body); | ||
return seassion; | ||
}); | ||
|
||
return http("Save Patient Diagnosis") | ||
.post("/openmrs/ws/rest/v1/patientdiagnoses") | ||
.body(StringBody(body)); | ||
|
||
} catch (Exception e) { | ||
throw new RuntimeException("Error while serializing diagnosis data", e); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,4 +144,11 @@ public ChainBuilder addDrugOrder(String patientUuid, String visitUuid, String cu | |
); | ||
|
||
} | ||
|
||
public ChainBuilder addVisitNote(String patientUuid, String currentUserUuid) { | ||
String visitNoteText = "Patient visit note"; | ||
return exec( | ||
httpService.saveVisitNote(patientUuid, currentUserUuid, visitNoteText) | ||
); | ||
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. The indentation looks a bit weird. |
||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -35,6 +35,7 @@ public ScenarioBuilder getScenarioBuilder() { | |||||||||||||||||
.exec(registry.openImmunizationsTab("#{patient_uuid}")) | ||||||||||||||||||
.exec(registry.openAttachmentsTab("#{patient_uuid}")) | ||||||||||||||||||
.exec(registry.addDrugOrder("#{patient_uuid}", "#{visitUuid}", "#{currentUserUuid}")) | ||||||||||||||||||
.exec(registry.addVisitNote("#{patient_uuid}", "#{currentUserUuid}")) | ||||||||||||||||||
.exec(registry.endVisit("#{patient_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. Let's add some pauses to make it realistic. In real world, users takes time to perform actions. Also this may fix the
Suggested change
|
||||||||||||||||||
} | ||||||||||||||||||
} |
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.