diff --git a/omod/src/main/java/org/openmrs/module/emrapi/web/controller/VisitController.java b/omod/src/main/java/org/openmrs/module/emrapi/web/controller/VisitController.java index f9709af8..a9a7b91f 100644 --- a/omod/src/main/java/org/openmrs/module/emrapi/web/controller/VisitController.java +++ b/omod/src/main/java/org/openmrs/module/emrapi/web/controller/VisitController.java @@ -2,6 +2,7 @@ import lombok.Setter; import org.openmrs.Diagnosis; +import org.openmrs.Patient; import org.openmrs.module.emrapi.visit.VisitWithDiagnoses; import org.openmrs.module.emrapi.visit.EmrApiVisitService; import org.openmrs.module.webservices.rest.SimpleObject; @@ -10,12 +11,14 @@ import org.openmrs.module.webservices.rest.web.RestUtil; import org.openmrs.module.webservices.rest.web.representation.Representation; import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; +import org.openmrs.module.webservices.rest.web.v1_0.controller.BaseRestController; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -24,7 +27,7 @@ @Setter @Controller -public class VisitController { +public class VisitController extends BaseRestController { EmrApiVisitService emrApiVisitService; @@ -32,7 +35,9 @@ public class VisitController { public ResponseEntity getVisitsWithDiagnosesByPatient( HttpServletRequest request, HttpServletResponse response, - @PathVariable("patientUuid") String patientUuid) { + @PathVariable("patientUuid") String patientUuid, + @RequestParam("patient") Patient patient) { + RequestContext context = RestUtil.getRequestContext(request, response, Representation.DEFAULT); List visitsEntries; visitsEntries = emrApiVisitService.getVisitsWithNotesAndDiagnosesByPatient(patientUuid, context.getStartIndex(), context.getLimit()); diff --git a/omod/src/test/java/org/openmrs/module/emrapi/web/controller/VisitControllerTest.java b/omod/src/test/java/org/openmrs/module/emrapi/web/controller/VisitControllerTest.java index 29d70d1e..c2a7cc91 100644 --- a/omod/src/test/java/org/openmrs/module/emrapi/web/controller/VisitControllerTest.java +++ b/omod/src/test/java/org/openmrs/module/emrapi/web/controller/VisitControllerTest.java @@ -39,7 +39,7 @@ public void shouldGetVisitsWithNotesAndDiagnosesByPatient() throws Exception { String secondVisitUuid = "1c72e1ac-9b18-11e0-93c3-18a905e044dc"; String thirdVisitUuid = "3c72f2bc-9b18-11e0-93c3-18a905e044ec"; - MvcResult response = mockMvc.perform(get("/rest/v1/emrapi/patient/" + patientUuid + "/visitWithNotesAndDiagnoses") + MvcResult response = mockMvc.perform(get("/rest/v1/emrapi/patient/" + patientUuid + "/visitWithNotesAndDiagnoses?patient="+patientUuid) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andReturn();