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-4527: Add an attachment in Visit Patient Scenario #79

Merged
merged 5 commits into from
Mar 13, 2025
Merged
Changes from 1 commit
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
Next Next commit
O3-4527: Added "Upload Attachment" Request to the Visit scenario
  • Loading branch information
UNCANNY69 committed Mar 11, 2025
commit fb8c01944b9094280c0e57dfc3a40fcedc84cbd3
15 changes: 15 additions & 0 deletions src/test/java/org/openmrs/performance/http/DoctorHttpService.java
Original file line number Diff line number Diff line change
@@ -16,6 +16,8 @@
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.RawFileBodyPart;
import static io.gatling.javaapi.http.HttpDsl.StringBodyPart;
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;
@@ -218,6 +220,19 @@ public HttpRequestActionBuilder getAllowedFileExtensions() {
.get("/openmrs/ws/rest/v1/systemsetting?&v=custom:(value)&q=attachments.allowedFileExtensions");
}

public HttpRequestActionBuilder uploadAttachment(String patientUuid) {
return http("Upload Attachment Request")
.post("/openmrs/ws/rest/v1/attachment")
.bodyPart(StringBodyPart("fileCaption", "Test Image"))
.bodyPart(StringBodyPart("patient", patientUuid))
.bodyPart(
RawFileBodyPart("file", "TestImage.png")
.contentType("image/png")
.fileName("TestImage.png")
)
.asMultipartForm();
}

public HttpRequestActionBuilder getLabResults(String patientUuid) {
return http("Get Lab Results of Patient")
.get("/openmrs/ws/fhir2/R4/Observation?category=laboratory&patient=" + patientUuid + "&_count=100&_summary=data")
Original file line number Diff line number Diff line change
@@ -131,6 +131,11 @@ public ChainBuilder openAttachmentsTab(String patientUuid) {
.exec(httpService.getAllowedFileExtensions());
}

public ChainBuilder addAttachment(String patientUuid){
return exec(httpService.uploadAttachment(patientUuid))
.exec(httpService.getAttachments(patientUuid));
}

public ChainBuilder openVisitsTab(String patientUuid) {
return exec(httpService.getVisitsOfPatient(patientUuid));
}
Original file line number Diff line number Diff line change
@@ -48,6 +48,8 @@ public ScenarioBuilder getScenarioBuilder() {
.pause(5)
.exec(registry.openAttachmentsTab("#{patient_uuid}"))
.pause(5)
.exec(registry.addAttachment("#{patient_uuid}"))
.pause(5)
.exec(registry.addDrugOrder("#{patient_uuid}", "#{visitUuid}", "#{currentUserUuid}"))
.pause(5)
.exec(registry.addVisitNote("#{patient_uuid}", "#{currentUserUuid}"))
Binary file added src/test/resources/TestImage.png
Copy link
Collaborator

@Bawanthathilan Bawanthathilan Mar 13, 2025

Choose a reason for hiding this comment

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

Please use a realistic file-sized image. You can download one from here, rename it, and upload it.

Copy link
Member

Choose a reason for hiding this comment

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

Yep, I'd prefer a 1MB one to make it more realistic with the file size. Rename it to "Sample 1MB image.jpg" or something to highlight the file size.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed the changes

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use a realistic file-sized image. You can download one from here, rename it, and upload it.

@UNCANNY69 check this

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove the previous image.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved it, thanks a lot @Bawanthathilan for the review :)

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.