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:add constants
  • Loading branch information
Bawanthathilan committed Jan 21, 2025
commit f15c26a1c57d5b73128e1d10c46893e846a712e5
8 changes: 8 additions & 0 deletions src/test/java/org/openmrs/performance/Constants.java
Original file line number Diff line number Diff line change
@@ -34,5 +34,13 @@ public class Constants {
public static final String ORDER = "39da3525-afe4-45ff-8977-c53b7b359158";

public static final String DEFAULT_DOSING_TYPE = "org.openmrs.SimpleDosingInstructions";

// Allergies
public static final String DRUG_ALLERGEN_UUID = "162555AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
public static final String ENVIRONMENTAL_ALLERGEN_UUID = "162552AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
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 static final String ENVIRONMENTAL_ALLERGEN_UUID = "162552AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
public static final String ENVIRONMENTAL_ALLERGEN_UUID = "162552AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";

public static final String FOOD_ALLERGEN_UUID = "162554AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
public static final String ALLERGY_REACTION_UUID = "162553AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
public static final String CODED_ALLERGEN_UUID = "71617AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
public static final String SEVERITY_UUID = "1498AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
Copy link
Member

Choose a reason for hiding this comment

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

There's an extra space here.


}
33 changes: 11 additions & 22 deletions src/test/java/org/openmrs/performance/http/DoctorHttpService.java
Original file line number Diff line number Diff line change
@@ -15,14 +15,17 @@
import static io.gatling.javaapi.core.CoreDsl.bodyString;
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.CODED_ALLERGEN_UUID;
import static org.openmrs.performance.Constants.DAYS;
import static org.openmrs.performance.Constants.DEFAULT_DOSING_TYPE;
import static org.openmrs.performance.Constants.DRUG_ORDER;
import static org.openmrs.performance.Constants.ONCE_DAILY;
import static org.openmrs.performance.Constants.ORAL;
import static org.openmrs.performance.Constants.ORDER;
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;

public class DoctorHttpService extends HttpService {
@@ -151,23 +154,9 @@ public HttpRequestActionBuilder getDrugOrders(String patientUuid) {
"&careSetting=" + CARE_SETTING_UUID +
"&status=any&orderType=" + DRUG_ORDER +
"&v=" + customRepresentation);
}

public HttpRequestActionBuilder searchPatient(String searchQuery) {
String customRepresentation = """
custom:(patientId,uuid,identifiers,display,patientIdentifier:(uuid,identifier),person:(gender,age,birthdate,birthdateEstimated,personName,addresses,display,dead,deathDate),attributes:(value,attributeType:(uuid,display)))
""";
return http("Get Orders")
.get("/openmrs/ws/rest/v1/patient" +
"?q=" + searchQuery +
"&v=" + customRepresentation +
"&includeDead=" + true +
"&limit=" + 10);
}


}
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 getAllergies(String patientUuid) {
public HttpRequestActionBuilder GetAllergies(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 GetAllergies(String patientUuid) {
public HttpRequestActionBuilder getAllergies(String patientUuid) {

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

return http("Get Allergies of Patient")
.get("/openmrs/ws/fhir2/R4/AllergyIntolerance?patient=" + patientUuid + "&_summary=data");
}
@@ -192,21 +181,21 @@ public HttpRequestActionBuilder GetAllergicReactions(String allergyReactionUuid)
.get("/openmrs/ws/rest/v1/concept/" + allergyReactionUuid + "?v=full");
}

public HttpRequestActionBuilder saveAllergies(String patientUuid) {
public HttpRequestActionBuilder saveAllergy(String patientUuid) {
Map<String, Object> payload = new HashMap<>();

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

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

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

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

Map<String, Object> reaction = new HashMap<>();
reaction.put("reaction", reactionUuid);
@@ -218,8 +207,8 @@ public HttpRequestActionBuilder saveAllergies(String patientUuid) {
payload.put("reactions", reactions);


return http("Save Allergies of Patient")
.get("/openmrs/ws/rest/v1/patient/"+ patientUuid +"/allergy")
return http("Save an Allergies")
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 an Allergies")
return http("Save an Allergy")

.post("/openmrs/ws/rest/v1/patient/"+ patientUuid +"/allergy")
.body(StringBody(payload.toString()));


Original file line number Diff line number Diff line change
@@ -7,9 +7,13 @@
import java.util.Set;

import static io.gatling.javaapi.core.CoreDsl.exec;
import static org.openmrs.performance.Constants.ALLERGY_REACTION_UUID;
import static org.openmrs.performance.Constants.ARTERIAL_BLOOD_OXYGEN_SATURATION;
import static org.openmrs.performance.Constants.DIASTOLIC_BLOOD_PRESSURE;
import static org.openmrs.performance.Constants.DRUG_ALLERGEN_UUID;
import static org.openmrs.performance.Constants.ENVIRONMENTAL_ALLERGEN_UUID;
import static org.openmrs.performance.Constants.FACULTY_VISIT_TYPE_UUID;
import static org.openmrs.performance.Constants.FOOD_ALLERGEN_UUID;
import static org.openmrs.performance.Constants.HEIGHT_CM;
import static org.openmrs.performance.Constants.MID_UPPER_ARM_CIRCUMFERENCE;
import static org.openmrs.performance.Constants.OUTPATIENT_CLINIC_LOCATION_UUID;
@@ -21,6 +25,8 @@
import static org.openmrs.performance.Constants.WEIGHT_KG;
import static org.openmrs.performance.utils.CommonUtils.extractConceptIds;



public class DoctorRegistry extends Registry<DoctorHttpService>{

public DoctorRegistry() {
@@ -92,26 +98,21 @@ public ChainBuilder openLabResultsTab(String patientUuid) {
}

public ChainBuilder openAllergiesTab(String patientUuid) {
return exec(httpService.getAllergies(patientUuid));
return exec(httpService.GetAllergies(patientUuid));
}

public ChainBuilder OpenAllergiesForm(){
String drugAllergenUuid = "162555AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
String environmentalAllergenUuid = "162552AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
String foodAllergenUuid = "162554AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
String allergyReactionUuid = "162553AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";

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

public ChainBuilder addAllergies(String patientUuid) {
public ChainBuilder recordAllergy(String patientUuid) {
return exec(
httpService.saveAllergies(patientUuid)
httpService.saveAllergy(patientUuid)
);
}

Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ public ScenarioBuilder getScenarioBuilder() {
.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}"))
.exec(registry.recordAllergy("#{patient_uuid}"))
.exec(registry.openConditionsTab("#{patient_uuid}"))
.exec(registry.openImmunizationsTab("#{patient_uuid}"))
.exec(registry.openAttachmentsTab("#{patient_uuid}"))