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
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.


}
54 changes: 52 additions & 2 deletions src/test/java/org/openmrs/performance/http/DoctorHttpService.java
Original file line number Diff line number Diff line change
@@ -6,21 +6,26 @@

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;
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 {
@@ -60,6 +65,8 @@ public HttpRequestActionBuilder getActiveVisitOfPatient(String patientUuid) {
return http("Get Active Visits of Patient")
.get("/openmrs/ws/rest/v1/visit?patient=" + patientUuid + "&v=" + customRepresentation + "&includeInactive=false");
}



public HttpRequestActionBuilder getProgramEnrollments(String patientUuid) {
String customRepresentation = "custom:(uuid,display,program,dateEnrolled,dateCompleted," +
@@ -147,11 +154,54 @@ public HttpRequestActionBuilder getDrugOrders(String patientUuid) {
"&careSetting=" + CARE_SETTING_UUID +
"&status=any&orderType=" + DRUG_ORDER +
"&v=" + customRepresentation);
}
}
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");
}

public HttpRequestActionBuilder getAllergen(String allergenType, String allergenUuid) {
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 getAllergen(String allergenType, String allergenUuid) {
public HttpRequestActionBuilder getAllergens(String allergenType, String allergenUuid) {

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


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

Map<String,String> codedAllergen = new HashMap<>();
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", SEVERITY_UUID);

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

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);

try{
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(new ObjectMapper().writeValueAsString(payload)));
}catch (JsonProcessingException e) {
throw new RuntimeException(e);
}



}

public HttpRequestActionBuilder getConditions(String patientUuid) {
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,7 +98,22 @@ public ChainBuilder openLabResultsTab(String patientUuid) {
}

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

public ChainBuilder OpenAllergiesForm(){
return exec(
httpService.getAllergen("Drug",DRUG_ALLERGEN_UUID),
httpService.getAllergen("Environment",ENVIRONMENTAL_ALLERGEN_UUID),
httpService.getAllergen("Food",FOOD_ALLERGEN_UUID),
httpService.getAllergen("Allergic Reactions",ALLERGY_REACTION_UUID)
);
}

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

public ChainBuilder openConditionsTab(String patientUuid) {
Original file line number Diff line number Diff line change
@@ -29,6 +29,8 @@ 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.recordAllergy("#{patient_uuid}"))
.exec(registry.openConditionsTab("#{patient_uuid}"))
.exec(registry.openImmunizationsTab("#{patient_uuid}"))
.exec(registry.openAttachmentsTab("#{patient_uuid}"))
Loading