Repository: openmrs/openmrs-contrib-performance-test
Pull request #99: O3-4632: Changing the request calls for medication orders
Author: login: jayg2002
Created: 2025-04-11T18:54:03Z | Merged: 2025-04-18T16:55:09Z

As observed in the openMedicationsTab triggers different calls in the code compared to the one present in the code base this PR is to tackle that issue

JIRA: https://openmrs.atlassian.net/browse/O3-4632


Diff:
diff --git a/src/test/java/org/openmrs/performance/http/DoctorHttpService.java b/src/test/java/org/openmrs/performance/http/DoctorHttpService.java
index 5f0f3ba0f..d32042ff4 100644
--- a/src/test/java/org/openmrs/performance/http/DoctorHttpService.java
+++ b/src/test/java/org/openmrs/performance/http/DoctorHttpService.java
@@ -57,12 +57,12 @@ public HttpRequestActionBuilder getVisitTypes() {
 	}
 
 	public HttpRequestActionBuilder getVisitsOfPatient(String patientUuid) {
-		String customRepresentation = "custom:(uuid,location,encounters:(uuid,diagnoses:(uuid,display,rank,diagnosis,voided)," +
-				"form:(uuid,display),encounterDatetime,orders:full,obs:(uuid,concept:(uuid,display,conceptClass:(uuid,display))," +
-				"display,groupMembers:(uuid,concept:(uuid,display),value:(uuid,display),display),value,obsDatetime)," +
-				"encounterType:(uuid,display,viewPrivilege,editPrivilege),encounterProviders:(uuid,display,encounterRole:(uuid,display)," +
-				"provider:(uuid,person:(uuid,display)))),visitType:(uuid,name,display),startDatetime,stopDatetime,patient," +
-				"attributes:(attributeType:ref,display,uuid,value)";
+		String customRepresentation = "custom:(uuid,location,encounters:(uuid,diagnoses:(uuid,display,rank,diagnosis,voided),"
+		        + "form:(uuid,display),encounterDatetime,orders:full,obs:(uuid,concept:(uuid,display,conceptClass:(uuid,display)),"
+		        + "display,groupMembers:(uuid,concept:(uuid,display),value:(uuid,display),display),value,obsDatetime),"
+		        + "encounterType:(uuid,display,viewPrivilege,editPrivilege),encounterProviders:(uuid,display,encounterRole:(uuid,display),"
+		        + "provider:(uuid,person:(uuid,display)))),visitType:(uuid,name,display),startDatetime,stopDatetime,patient,"
+		        + "attributes:(attributeType:ref,display,uuid,value)";
 
 		return http("Get Visits of Patient")
 		        .get("/openmrs/ws/rest/v1/visit?patient=" + patientUuid + "&v=" + customRepresentation + "&limit=5");
@@ -149,22 +149,32 @@ public HttpRequestActionBuilder getAllActiveOrders(String patientUuid) {
 		    "/openmrs/ws/rest/v1/order?patient=" + patientUuid + "&careSetting=" + CARE_SETTING_UUID + "&status=ACTIVE");
 	}
 
-	public HttpRequestActionBuilder getDrugOrders(String patientUuid) {
+	public HttpRequestActionBuilder getDrugOrdersExceptCancelledAndExpired(String patientUuid) {
 		String customRepresentation = """
-		        custom:(uuid,dosingType,orderNumber,accessionNumber,
-		        	patient:ref,action,careSetting:ref,previousOrder:ref,dateActivated,scheduledDate,dateStopped,autoExpireDate,
-		        	orderType:ref,encounter:ref,
-		        	orderer:(uuid,display,person:(display)),
-		        	orderReason,orderReasonNonCoded,orderType,urgency,instructions,
-		        	commentToFulfiller,
-		        	drug:(uuid,display,strength,
-		        		dosageForm:(display,uuid),concept),
-		        		dose,doseUnits:ref,
-		        	frequency:ref,asNeeded,asNeededCondition,quantity,quantityUnits:ref,numRefills,dosingInstructions,
-		        	duration,durationUnits:ref,route:ref,brandName,dispenseAsWritten)
+		        custom:(uuid,dosingType,orderNumber,accessionNumber,patient:ref,action,careSetting:ref,
+		        previousOrder:ref,dateActivated,scheduledDate,dateStopped,autoExpireDate,orderType:ref,
+		        encounter:ref,orderer:(uuid,display,person:(display)),orderReason,orderReasonNonCoded,
+		        orderType,urgency,instructions,commentToFulfiller,drug:(uuid,display,strength,dosageForm:(display,uuid),concept),
+		        dose,doseUnits:ref,frequency:ref,asNeeded,asNeededCondition,quantity,quantityUnits:ref,
+		        numRefills,dosingInstructions,duration,durationUnits:ref,route:ref,brandName,dispenseAsWritten)
 		        """;
-		return http("Get Orders").get("/openmrs/ws/rest/v1/order" + "?patient=" + patientUuid + "&careSetting="
-		        + CARE_SETTING_UUID + "&status=any&orderType=" + DRUG_ORDER + "&v=" + customRepresentation);
+		return http("Get Drug Orders except the cancelled and expired").get(
+		    "/openmrs/ws/rest/v1/order" + "?patient=" + patientUuid + "&careSetting=" + CARE_SETTING_UUID
+		            + "&status=any&orderType=" + DRUG_ORDER + "&excludeCanceledAndExpired=true&v=" + customRepresentation);
+	}
+
+	public HttpRequestActionBuilder getDrugOrdersExceptDiscontinuedOrders(String patientUuid) {
+		String customRepresentation = """
+		        custom:(uuid,dosingType,orderNumber,accessionNumber,patient:ref,action,careSetting:ref,
+		        previousOrder:ref,dateActivated,scheduledDate,dateStopped,autoExpireDate,orderType:ref,
+		        encounter:ref,orderer:(uuid,display,person:(display)),orderReason,orderReasonNonCoded,
+		        orderType,urgency,instructions,commentToFulfiller,drug:(uuid,display,strength,dosageForm:(display,uuid),concept),
+		        dose,doseUnits:ref,frequency:ref,asNeeded,asNeededCondition,quantity,quantityUnits:ref,
+		        numRefills,dosingInstructions,duration,durationUnits:ref,route:ref,brandName,dispenseAsWritten)
+		        """;
+		return http("Get Drug Orders except the discontinued orders").get("/openmrs/ws/rest/v1/order" + "?patient="
+		        + patientUuid + "&careSetting=" + CARE_SETTING_UUID + "&status=any&orderType=" + DRUG_ORDER + "&v="
+		        + customRepresentation + "&excludeDiscontinueOrders=true");
 	}
 
 	public HttpRequestActionBuilder getAllergies(String patientUuid) {
diff --git a/src/test/java/org/openmrs/performance/registries/DoctorRegistry.java b/src/test/java/org/openmrs/performance/registries/DoctorRegistry.java
index f0da97266..c93b93738 100644
--- a/src/test/java/org/openmrs/performance/registries/DoctorRegistry.java
+++ b/src/test/java/org/openmrs/performance/registries/DoctorRegistry.java
@@ -68,7 +68,9 @@ public ChainBuilder recordVitals(String patientUuid) {
 	}
 
 	public ChainBuilder openMedicationsTab(String patientUuid) {
-		return exec(httpService.getDrugOrders(patientUuid));
+		return exec(httpService.getDrugOrdersExceptCancelledAndExpired(patientUuid))
+		        .exec(httpService.getDrugOrdersExceptDiscontinuedOrders(patientUuid))
+		        .exec(httpService.getActiveVisitOfPatient(patientUuid));
 	}
 
 	public ChainBuilder openOrdersTab(String patientUuid) {


Reviews:
user: login: jayasanka-sack
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-18T05:58:22Z
user: login: jayasanka-sack
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-18T06:02:56Z
user: login: Bawanthathilan
body: Thanks for getting this done @UNCANNY69 
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-04-18T16:54:37Z

Review comments:
diff_hunk: @@ -149,22 +149,33 @@ public HttpRequestActionBuilder getAllActiveOrders(String patientUuid) {
 		    "/openmrs/ws/rest/v1/order?patient=" + patientUuid + "&careSetting=" + CARE_SETTING_UUID + "&status=ACTIVE");
 	}
 
-	public HttpRequestActionBuilder getDrugOrders(String patientUuid) {
+
+	public HttpRequestActionBuilder getDrugOrdersExceptCancelledAndExpired(String patientUuid) {
 		String customRepresentation = """
-		        custom:(uuid,dosingType,orderNumber,accessionNumber,
-		        	patient:ref,action,careSetting:ref,previousOrder:ref,dateActivated,scheduledDate,dateStopped,autoExpireDate,
-		        	orderType:ref,encounter:ref,
-		        	orderer:(uuid,display,person:(display)),
-		        	orderReason,orderReasonNonCoded,orderType,urgency,instructions,
-		        	commentToFulfiller,
-		        	drug:(uuid,display,strength,
-		        		dosageForm:(display,uuid),concept),
-		        		dose,doseUnits:ref,
-		        	frequency:ref,asNeeded,asNeededCondition,quantity,quantityUnits:ref,numRefills,dosingInstructions,
-		        	duration,durationUnits:ref,route:ref,brandName,dispenseAsWritten)
-		        """;
-		return http("Get Orders").get("/openmrs/ws/rest/v1/order" + "?patient=" + patientUuid + "&careSetting="
-		        + CARE_SETTING_UUID + "&status=any&orderType=" + DRUG_ORDER + "&v=" + customRepresentation);
+        custom:(uuid,dosingType,orderNumber,accessionNumber,patient:ref,action,careSetting:ref,
+        previousOrder:ref,dateActivated,scheduledDate,dateStopped,autoExpireDate,orderType:ref,
+        encounter:ref,orderer:(uuid,display,person:(display)),orderReason,orderReasonNonCoded,
+        orderType,urgency,instructions,commentToFulfiller,drug:(uuid,display,strength,dosageForm:(display,uuid),concept),
+        dose,doseUnits:ref,frequency:ref,asNeeded,asNeededCondition,quantity,quantityUnits:ref,
+        numRefills,dosingInstructions,duration,durationUnits:ref,route:ref,brandName,dispenseAsWritten)
+        """;
+		return http("Get Drug Orders except the cancelled and expired").get(
+				"/openmrs/ws/rest/v1/order" + "?patient=" + patientUuid + "&careSetting=" + CARE_SETTING_UUID
+						+ "&status=any&orderType=" + DRUG_ORDER + "&excludeCanceledAndExpired=true&v=" + customRepresentation);
+	}
+
+	public HttpRequestActionBuilder getDrugOrdersExceptDiscontinuedOrders(String patientUuid) {
+		String customRepresentation = """
+        &v=custom:(uuid,dosingType,orderNumber,accessionNumber,patient:ref,action,careSetting:ref,
+        previousOrder:ref,dateActivated,scheduledDate,dateStopped,autoExpireDate,orderType:ref,
+        encounter:ref,orderer:(uuid,display,person:(display)),orderReason,orderReasonNonCoded,
+        orderType,urgency,instructions,commentToFulfiller,drug:(uuid,display,strength,dosageForm:(display,uuid),concept),
+        dose,doseUnits:ref,frequency:ref,asNeeded,asNeededCondition,quantity,quantityUnits:ref,
+        numRefills,dosingInstructions,duration,durationUnits:ref,route:ref,brandName,dispenseAsWritten)
+        """;
path: src/test/java/org/openmrs/performance/http/DoctorHttpService.java
user: login: jayasanka-sack
body: @Bawanthathilan this looks like a formatting issue. I'm not sure why the validator didn't catch this. Any idea?
created_at: 2025-04-18T05:58:22Z
author_association: MEMBER
diff_hunk: @@ -149,22 +149,33 @@ public HttpRequestActionBuilder getAllActiveOrders(String patientUuid) {
 		    "/openmrs/ws/rest/v1/order?patient=" + patientUuid + "&careSetting=" + CARE_SETTING_UUID + "&status=ACTIVE");
 	}
 
-	public HttpRequestActionBuilder getDrugOrders(String patientUuid) {
+
+	public HttpRequestActionBuilder getDrugOrdersExceptCancelledAndExpired(String patientUuid) {
 		String customRepresentation = """
-		        custom:(uuid,dosingType,orderNumber,accessionNumber,
-		        	patient:ref,action,careSetting:ref,previousOrder:ref,dateActivated,scheduledDate,dateStopped,autoExpireDate,
-		        	orderType:ref,encounter:ref,
-		        	orderer:(uuid,display,person:(display)),
-		        	orderReason,orderReasonNonCoded,orderType,urgency,instructions,
-		        	commentToFulfiller,
-		        	drug:(uuid,display,strength,
-		        		dosageForm:(display,uuid),concept),
-		        		dose,doseUnits:ref,
-		        	frequency:ref,asNeeded,asNeededCondition,quantity,quantityUnits:ref,numRefills,dosingInstructions,
-		        	duration,durationUnits:ref,route:ref,brandName,dispenseAsWritten)
-		        """;
-		return http("Get Orders").get("/openmrs/ws/rest/v1/order" + "?patient=" + patientUuid + "&careSetting="
-		        + CARE_SETTING_UUID + "&status=any&orderType=" + DRUG_ORDER + "&v=" + customRepresentation);
+        custom:(uuid,dosingType,orderNumber,accessionNumber,patient:ref,action,careSetting:ref,
+        previousOrder:ref,dateActivated,scheduledDate,dateStopped,autoExpireDate,orderType:ref,
+        encounter:ref,orderer:(uuid,display,person:(display)),orderReason,orderReasonNonCoded,
+        orderType,urgency,instructions,commentToFulfiller,drug:(uuid,display,strength,dosageForm:(display,uuid),concept),
+        dose,doseUnits:ref,frequency:ref,asNeeded,asNeededCondition,quantity,quantityUnits:ref,
+        numRefills,dosingInstructions,duration,durationUnits:ref,route:ref,brandName,dispenseAsWritten)
+        """;
+		return http("Get Drug Orders except the cancelled and expired").get(
+				"/openmrs/ws/rest/v1/order" + "?patient=" + patientUuid + "&careSetting=" + CARE_SETTING_UUID
+						+ "&status=any&orderType=" + DRUG_ORDER + "&excludeCanceledAndExpired=true&v=" + customRepresentation);
+	}
+
+	public HttpRequestActionBuilder getDrugOrdersExceptDiscontinuedOrders(String patientUuid) {
+		String customRepresentation = """
+        &v=custom:(uuid,dosingType,orderNumber,accessionNumber,patient:ref,action,careSetting:ref,
+        previousOrder:ref,dateActivated,scheduledDate,dateStopped,autoExpireDate,orderType:ref,
+        encounter:ref,orderer:(uuid,display,person:(display)),orderReason,orderReasonNonCoded,
+        orderType,urgency,instructions,commentToFulfiller,drug:(uuid,display,strength,dosageForm:(display,uuid),concept),
+        dose,doseUnits:ref,frequency:ref,asNeeded,asNeededCondition,quantity,quantityUnits:ref,
+        numRefills,dosingInstructions,duration,durationUnits:ref,route:ref,brandName,dispenseAsWritten)
+        """;
+		return http("Get Drug Orders except the discontinued orders")
+				.get("/openmrs/ws/rest/v1/order" + "?patient=" + patientUuid + "&careSetting=" + CARE_SETTING_UUID
+						+ "&status=any&orderType=" + DRUG_ORDER + customRepresentation + "&excludeDiscontinueOrders=true");
path: src/test/java/org/openmrs/performance/http/DoctorHttpService.java
user: login: jayasanka-sack
body: move `&v` from the custom representation to here.
created_at: 2025-04-18T06:02:55Z
author_association: MEMBER

PR comments:
user: login: jayg2002
created_at: 2025-04-11T18:55:02Z
body: Hi @Bawanthathilan , @jayasanka-sack can this PR also be reviewed. Thanks!
author_association: COLLABORATOR
user: login: jayasanka-sack
created_at: 2025-04-18T06:01:27Z
body: @UNCANNY69 make sure to include a link to the ticket in the description. 
author_association: MEMBER
user: login: Bawanthathilan
created_at: 2025-04-19T04:10:16Z
body: @UNCANNY69  Please update the ticket status
author_association: COLLABORATOR