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-4280: implement Save a note in Visit Patient scenario #66

Merged
merged 9 commits into from
Feb 25, 2025
Prev Previous commit
Next Next commit
remove saveDiagnosis and fix indentation
  • Loading branch information
Bawanthathilan committed Feb 25, 2025
commit ebb0822e6eeaf26394388d4425d1b042caf08406
48 changes: 8 additions & 40 deletions src/test/java/org/openmrs/performance/http/DoctorHttpService.java
Original file line number Diff line number Diff line change
@@ -299,58 +299,26 @@ public HttpRequestActionBuilder saveVisitNote(String patientUuid, String current
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) {
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) {
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);
}
}
}
Loading
Oops, something went wrong.