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-4357: Add Allergy Recording to Patient Visit Scenario #54

Merged
merged 8 commits into from
Jan 22, 2025
Merged
Prev Previous commit
Next Next commit
O3-4357:break into two actions
  • Loading branch information
Bawanthathilan committed Jan 21, 2025
commit dd5d198cfd0e260c05fdab9d1bfe681b7976dffe
70 changes: 49 additions & 21 deletions src/test/java/org/openmrs/performance/http/DoctorHttpService.java
Original file line number Diff line number Diff line change
@@ -6,7 +6,9 @@

import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static io.gatling.javaapi.core.CoreDsl.StringBody;
@@ -162,37 +164,63 @@ public HttpRequestActionBuilder searchPatient(String searchQuery) {
"&includeDead=" + true +
"&limit=" + 10);
}




public HttpRequestActionBuilder getAllergies(String patientUuid) {
return http("Get Allergies of Patient")
.get("/openmrs/ws/fhir2/R4/AllergyIntolerance?patient=" + patientUuid + "&_summary=data");
}

public HttpRequestActionBuilder GetDrugAllergens(String drugAllergenUuid) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public HttpRequestActionBuilder GetDrugAllergens(String drugAllergenUuid) {
public HttpRequestActionBuilder getDrugAllergens(String drugAllergenUuid) {

Method names should be named in lower camel case (starts with a lowercase).

return http("Get Drug Allergens")
.get("/openmrs/ws/rest/v1/concept/" + drugAllergenUuid + "?v=full");
}

public HttpRequestActionBuilder GetEnvironmentAllergens(String environmentalAllergenUuid) {
return http("Get Environment Allergens")
.get("/openmrs/ws/rest/v1/concept/" + environmentalAllergenUuid + "?v=full");
}
Copy link
Member

Choose a reason for hiding this comment

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

Since it's the same API call, how about we make it a single call and use the passed parameter?

ex:

getAllergens(environmentalAllergenUuid),
getAllergens(drugAllergenUuid),
...


public HttpRequestActionBuilder GetFoodAllergens(String foodAllergenUuid) {
return http("Get Food Allergens")
.get("/openmrs/ws/rest/v1/concept/" + foodAllergenUuid + "?v=full");
}

public HttpRequestActionBuilder GetAllergicReactions(String allergyReactionUuid) {
return http("Get Allergic Reactions")
.get("/openmrs/ws/rest/v1/concept/" + allergyReactionUuid + "?v=full");
}

public HttpRequestActionBuilder saveAllergies(String patientUuid) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public HttpRequestActionBuilder saveAllergies(String patientUuid) {
public HttpRequestActionBuilder saveAllergy(String patientUuid) {

String payload = "{\n" +
" \"allergen\": {\n" +
" \"allergenType\": \"DRUG\",\n" +
" \"codedAllergen\": {\n" +
" \"uuid\": \"71617AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"\n" +
" }\n" +
" },\n" +
" \"severity\": {\n" +
" \"uuid\": \"1498AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"\n" +
" },\n" +
" \"comment\": \"test\",\n" +
" \"reactions\": [\n" +
" {\n" +
" \"reaction\": {\n" +
" \"uuid\": \"121677AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"\n" +
" }\n" +
" }\n" +
" ]\n" +
"}";
Map<String, Object> payload = new HashMap<>();

Map<String,String> codedAllergen = new HashMap<>();
codedAllergen.put("uuid", "71617AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
Copy link
Member

Choose a reason for hiding this comment

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

Let's make the UUID a constant and move it to the Constants.java file. That way it’ll be super clear what this UUID is for and we can easily reuse it in other parts of the code.


Map<String,Object>allergen = new HashMap<>();
allergen.put("allergenType", "DRUG");
allergen.put("codedAllergen", codedAllergen);

Map<String,String>severity = new HashMap<>();
severity.put("uuid", "1498AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");

Map<String, String> reactionUuid = new HashMap<>();
reactionUuid.put("uuid", "121677AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");

Map<String, Object> reaction = new HashMap<>();
reaction.put("reaction", reactionUuid);
List<Map<String, Object>> reactions = Collections.singletonList(reaction);

payload.put("allergen", allergen);
payload.put("severity", severity);
payload.put("comment", "test");
payload.put("reactions", reactions);


return http("Save Allergies of Patient")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return http("Save Allergies of Patient")
return http("Save an Allergy")

.get("/openmrs/ws/rest/v1/patient/"+ patientUuid +"/allergy")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.get("/openmrs/ws/rest/v1/patient/"+ patientUuid +"/allergy")
.post("/openmrs/ws/rest/v1/patient/"+ patientUuid +"/allergy")

.body(StringBody(payload));
.body(StringBody(payload.toString()));


}
Original file line number Diff line number Diff line change
@@ -95,10 +95,22 @@ public ChainBuilder openAllergiesTab(String patientUuid) {
return exec(httpService.getAllergies(patientUuid));
}

public ChainBuilder addAllergies(String patientUuid) {
public ChainBuilder OpenAllergiesForm(){
String drugAllergenUuid = "162555AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
String environmentalAllergenUuid = "162552AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
String foodAllergenUuid = "162554AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
String allergyReactionUuid = "162553AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
Copy link
Member

Choose a reason for hiding this comment

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

Let’s add this to the constants.java file too.


return exec(
httpService.GetDrugAllergens(drugAllergenUuid),
httpService.GetEnvironmentAllergens(environmentalAllergenUuid),
httpService.GetFoodAllergens(foodAllergenUuid),
httpService.GetAllergicReactions(allergyReactionUuid)
);
}

public ChainBuilder addAllergies(String patientUuid) {
return exec(
httpService.searchPatient("test location test"),
httpService.getAllergies(patientUuid),
httpService.saveAllergies(patientUuid)
);
}
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ public ScenarioBuilder getScenarioBuilder() {
.exec(registry.openOrdersTab("#{patient_uuid}"))
.exec(registry.openLabResultsTab("#{patient_uuid}"))
.exec(registry.openAllergiesTab("#{patient_uuid}"))
.exec(registry.OpenAllergiesForm())
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.exec(registry.OpenAllergiesForm())
.exec(registry.openAllergiesForm())

.exec(registry.addAllergies("#{patient_uuid}"))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.exec(registry.addAllergies("#{patient_uuid}"))
.exec(registry.recordAllergy("#{patient_uuid}"))

.exec(registry.openConditionsTab("#{patient_uuid}"))
.exec(registry.openImmunizationsTab("#{patient_uuid}"))