Skip to content

Commit 03d7d46

Browse files
authoredMar 13, 2025
O3-4527: Add an attachment in Visit Patient Scenario (#79)
* O3-4527: Added "Upload Attachment" Request to the Visit scenario * Changing the image * Deleting the previous image * Deleting the previous image
1 parent d324b8b commit 03d7d46

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed
 

‎src/test/java/org/openmrs/performance/http/DoctorHttpService.java

+15
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import static io.gatling.javaapi.core.CoreDsl.StringBody;
1717
import static io.gatling.javaapi.core.CoreDsl.bodyString;
1818
import static io.gatling.javaapi.core.CoreDsl.jsonPath;
19+
import static io.gatling.javaapi.http.HttpDsl.RawFileBodyPart;
20+
import static io.gatling.javaapi.http.HttpDsl.StringBodyPart;
1921
import static io.gatling.javaapi.http.HttpDsl.http;
2022
import static org.openmrs.performance.Constants.ALLERGY_REACTION_UUID;
2123
import static org.openmrs.performance.Constants.ARTERIAL_BLOOD_OXYGEN_SATURATION;
@@ -230,6 +232,19 @@ public HttpRequestActionBuilder getAllowedFileExtensions() {
230232
.get("/openmrs/ws/rest/v1/systemsetting?&v=custom:(value)&q=attachments.allowedFileExtensions");
231233
}
232234

235+
public HttpRequestActionBuilder uploadAttachment(String patientUuid) {
236+
return http("Upload Attachment Request")
237+
.post("/openmrs/ws/rest/v1/attachment")
238+
.bodyPart(StringBodyPart("fileCaption", "Test Image"))
239+
.bodyPart(StringBodyPart("patient", patientUuid))
240+
.bodyPart(
241+
RawFileBodyPart("file", "Sample_1MB_image.jpg")
242+
.contentType("image/jpg")
243+
.fileName("Sample_1MB_image.jpg")
244+
)
245+
.asMultipartForm();
246+
}
247+
233248
public HttpRequestActionBuilder getLabResults(String patientUuid) {
234249
return http("Get Lab Results of Patient")
235250
.get("/openmrs/ws/fhir2/R4/Observation?category=laboratory&patient=" + patientUuid + "&_count=100&_summary=data")

‎src/test/java/org/openmrs/performance/registries/DoctorRegistry.java

+5
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ public ChainBuilder openAttachmentsTab(String patientUuid) {
135135
.exec(httpService.getAllowedFileExtensions());
136136
}
137137

138+
public ChainBuilder addAttachment(String patientUuid){
139+
return exec(httpService.uploadAttachment(patientUuid))
140+
.exec(httpService.getAttachments(patientUuid));
141+
}
142+
138143
public ChainBuilder openVisitsTab(String patientUuid) {
139144
return exec(httpService.getVisitsOfPatient(patientUuid));
140145
}

‎src/test/java/org/openmrs/performance/scenarios/VisitPatientScenario.java

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public ScenarioBuilder getScenarioBuilder() {
5050
.pause(5)
5151
.exec(registry.openAttachmentsTab("#{patient_uuid}"))
5252
.pause(5)
53+
.exec(registry.addAttachment("#{patient_uuid}"))
54+
.pause(5)
5355
.exec(registry.addDrugOrder("#{patient_uuid}", "#{visitUuid}", "#{currentUserUuid}"))
5456
.pause(5)
5557
.exec(registry.addVisitNote("#{patient_uuid}", "#{currentUserUuid}"))
1010 KB
Loading

0 commit comments

Comments
 (0)
Failed to load comments.