@Test public void getPatientsInPatientList_shouldGetPatientsInPatientList() throws Exception { HashMap<String, String> hashMap = new HashMap<String, String>(); hashMap.put("encounterType", "61ae96f4-6afe-4351-b6f8-cd4fc383cce1"); hashMap.put("startDate", "2000-01-01T00:00:00.0"); hashMap.put("endDate", "2012-01-02T00:00:00.0"); String result = controller.getPatientsInPatientList(hashMap, request); SimpleObject patientList = SimpleObject.parseJson(result); Assert.assertNotNull(result); Assert.assertEquals(3, ((ArrayList) patientList.get("patients")).size()); }
@RequestMapping(method = RequestMethod.GET, params = "encounterType") @WSDoc("Gets Patients Without Saving the Patient list") @ResponseBody() public String getPatientsInPatientList(@RequestParam Map<String, String> params, HttpServletRequest request) throws ResponseException { initPatientListController(); PatientList patientList = new PatientList(); patientList.setSearchQuery("?" + Joiner.on("&").withKeyValueSeparator("=").join(params)); SimpleObject obj = new SimpleObject(); obj.add("uuid", patientList.getUuid()); obj.add("name", patientList.getName()); obj.add("description", patientList.getDescription()); obj.add("searchQuery", patientList.getSearchQuery()); ArrayList patients = new ArrayList(); List<Patient> patientsInPatientList = service.getPatientsInPatientList(patientList); for (Patient p : patientsInPatientList) { SimpleObject patient = new SimpleObject(); patient.add("uuid", p.getUuid()); patient.add("display", p.getPersonName().getFullName()); patient.add("gender", p.getGender()); patient.add("age", p.getAge()); ArrayList encounters = new ArrayList(); List<Encounter> encountersInPatientList = service.getEncountersInPatientList(patientList); for (Encounter e : encountersInPatientList) { if (e.getPatient().equals(p)) { SimpleObject encounter = new SimpleObject(); encounter.add("uuid", e.getUuid()); encounter.add("display", e.getEncounterType().getName() + " - " + e.getEncounterDatetime()); encounter.add("encounterType", e.getEncounterType().getUuid()); encounter.add("encounterDatetime", df.format(e.getEncounterDatetime())); if (e.getProvider() != null) { encounter.add("provider", e.getProvider().getUuid()); } else { encounter.add("provider", null); } ArrayList obsArray = new ArrayList(); Set<Obs> obsAll = e.getObs(); for (Obs o : obsAll) { SimpleObject obs = new SimpleObject(); obs.add("uuid", o.getUuid()); obs.add("display", o.getConcept().getName().getName() + " = " + o.getValueAsString(request.getLocale())); obs.add("obsDatetime", df.format(o.getObsDatetime())); obs.add("value", o.getValueAsString(request.getLocale())); obs.add("comment", o.getComment()); if (o.getOrder() != null) { obs.add("order", o.getOrder().getUuid()); } else { obs.add("order", null); } obsArray.add(obs); } encounter.add("obs", obsArray); encounters.add(encounter); } } patient.add("encounters", encounters); patients.add(patient); } obj.add("patients", patients); obj.add("resourceVersion", getResourceVersion()); return gson.toJson(obj); }
PatientListController extends BaseRestController { @RequestMapping(method = RequestMethod.GET, params = "encounterType") @WSDoc("Gets Patients Without Saving the Patient list") @ResponseBody() public String getPatientsInPatientList(@RequestParam Map<String, String> params, HttpServletRequest request) throws ResponseException { initPatientListController(); PatientList patientList = new PatientList(); patientList.setSearchQuery("?" + Joiner.on("&").withKeyValueSeparator("=").join(params)); SimpleObject obj = new SimpleObject(); obj.add("uuid", patientList.getUuid()); obj.add("name", patientList.getName()); obj.add("description", patientList.getDescription()); obj.add("searchQuery", patientList.getSearchQuery()); ArrayList patients = new ArrayList(); List<Patient> patientsInPatientList = service.getPatientsInPatientList(patientList); for (Patient p : patientsInPatientList) { SimpleObject patient = new SimpleObject(); patient.add("uuid", p.getUuid()); patient.add("display", p.getPersonName().getFullName()); patient.add("gender", p.getGender()); patient.add("age", p.getAge()); ArrayList encounters = new ArrayList(); List<Encounter> encountersInPatientList = service.getEncountersInPatientList(patientList); for (Encounter e : encountersInPatientList) { if (e.getPatient().equals(p)) { SimpleObject encounter = new SimpleObject(); encounter.add("uuid", e.getUuid()); encounter.add("display", e.getEncounterType().getName() + " - " + e.getEncounterDatetime()); encounter.add("encounterType", e.getEncounterType().getUuid()); encounter.add("encounterDatetime", df.format(e.getEncounterDatetime())); if (e.getProvider() != null) { encounter.add("provider", e.getProvider().getUuid()); } else { encounter.add("provider", null); } ArrayList obsArray = new ArrayList(); Set<Obs> obsAll = e.getObs(); for (Obs o : obsAll) { SimpleObject obs = new SimpleObject(); obs.add("uuid", o.getUuid()); obs.add("display", o.getConcept().getName().getName() + " = " + o.getValueAsString(request.getLocale())); obs.add("obsDatetime", df.format(o.getObsDatetime())); obs.add("value", o.getValueAsString(request.getLocale())); obs.add("comment", o.getComment()); if (o.getOrder() != null) { obs.add("order", o.getOrder().getUuid()); } else { obs.add("order", null); } obsArray.add(obs); } encounter.add("obs", obsArray); encounters.add(encounter); } } patient.add("encounters", encounters); patients.add(patient); } obj.add("patients", patients); obj.add("resourceVersion", getResourceVersion()); return gson.toJson(obj); } }
PatientListController extends BaseRestController { @RequestMapping(method = RequestMethod.GET, params = "encounterType") @WSDoc("Gets Patients Without Saving the Patient list") @ResponseBody() public String getPatientsInPatientList(@RequestParam Map<String, String> params, HttpServletRequest request) throws ResponseException { initPatientListController(); PatientList patientList = new PatientList(); patientList.setSearchQuery("?" + Joiner.on("&").withKeyValueSeparator("=").join(params)); SimpleObject obj = new SimpleObject(); obj.add("uuid", patientList.getUuid()); obj.add("name", patientList.getName()); obj.add("description", patientList.getDescription()); obj.add("searchQuery", patientList.getSearchQuery()); ArrayList patients = new ArrayList(); List<Patient> patientsInPatientList = service.getPatientsInPatientList(patientList); for (Patient p : patientsInPatientList) { SimpleObject patient = new SimpleObject(); patient.add("uuid", p.getUuid()); patient.add("display", p.getPersonName().getFullName()); patient.add("gender", p.getGender()); patient.add("age", p.getAge()); ArrayList encounters = new ArrayList(); List<Encounter> encountersInPatientList = service.getEncountersInPatientList(patientList); for (Encounter e : encountersInPatientList) { if (e.getPatient().equals(p)) { SimpleObject encounter = new SimpleObject(); encounter.add("uuid", e.getUuid()); encounter.add("display", e.getEncounterType().getName() + " - " + e.getEncounterDatetime()); encounter.add("encounterType", e.getEncounterType().getUuid()); encounter.add("encounterDatetime", df.format(e.getEncounterDatetime())); if (e.getProvider() != null) { encounter.add("provider", e.getProvider().getUuid()); } else { encounter.add("provider", null); } ArrayList obsArray = new ArrayList(); Set<Obs> obsAll = e.getObs(); for (Obs o : obsAll) { SimpleObject obs = new SimpleObject(); obs.add("uuid", o.getUuid()); obs.add("display", o.getConcept().getName().getName() + " = " + o.getValueAsString(request.getLocale())); obs.add("obsDatetime", df.format(o.getObsDatetime())); obs.add("value", o.getValueAsString(request.getLocale())); obs.add("comment", o.getComment()); if (o.getOrder() != null) { obs.add("order", o.getOrder().getUuid()); } else { obs.add("order", null); } obsArray.add(obs); } encounter.add("obs", obsArray); encounters.add(encounter); } } patient.add("encounters", encounters); patients.add(patient); } obj.add("patients", patients); obj.add("resourceVersion", getResourceVersion()); return gson.toJson(obj); }  }
PatientListController extends BaseRestController { @RequestMapping(method = RequestMethod.GET, params = "encounterType") @WSDoc("Gets Patients Without Saving the Patient list") @ResponseBody() public String getPatientsInPatientList(@RequestParam Map<String, String> params, HttpServletRequest request) throws ResponseException { initPatientListController(); PatientList patientList = new PatientList(); patientList.setSearchQuery("?" + Joiner.on("&").withKeyValueSeparator("=").join(params)); SimpleObject obj = new SimpleObject(); obj.add("uuid", patientList.getUuid()); obj.add("name", patientList.getName()); obj.add("description", patientList.getDescription()); obj.add("searchQuery", patientList.getSearchQuery()); ArrayList patients = new ArrayList(); List<Patient> patientsInPatientList = service.getPatientsInPatientList(patientList); for (Patient p : patientsInPatientList) { SimpleObject patient = new SimpleObject(); patient.add("uuid", p.getUuid()); patient.add("display", p.getPersonName().getFullName()); patient.add("gender", p.getGender()); patient.add("age", p.getAge()); ArrayList encounters = new ArrayList(); List<Encounter> encountersInPatientList = service.getEncountersInPatientList(patientList); for (Encounter e : encountersInPatientList) { if (e.getPatient().equals(p)) { SimpleObject encounter = new SimpleObject(); encounter.add("uuid", e.getUuid()); encounter.add("display", e.getEncounterType().getName() + " - " + e.getEncounterDatetime()); encounter.add("encounterType", e.getEncounterType().getUuid()); encounter.add("encounterDatetime", df.format(e.getEncounterDatetime())); if (e.getProvider() != null) { encounter.add("provider", e.getProvider().getUuid()); } else { encounter.add("provider", null); } ArrayList obsArray = new ArrayList(); Set<Obs> obsAll = e.getObs(); for (Obs o : obsAll) { SimpleObject obs = new SimpleObject(); obs.add("uuid", o.getUuid()); obs.add("display", o.getConcept().getName().getName() + " = " + o.getValueAsString(request.getLocale())); obs.add("obsDatetime", df.format(o.getObsDatetime())); obs.add("value", o.getValueAsString(request.getLocale())); obs.add("comment", o.getComment()); if (o.getOrder() != null) { obs.add("order", o.getOrder().getUuid()); } else { obs.add("order", null); } obsArray.add(obs); } encounter.add("obs", obsArray); encounters.add(encounter); } } patient.add("encounters", encounters); patients.add(patient); } obj.add("patients", patients); obj.add("resourceVersion", getResourceVersion()); return gson.toJson(obj); }  void initPatientListController(); @RequestMapping(method = RequestMethod.POST) @WSDoc("Save New PatientList") @ResponseBody Object createNewPatientList(@RequestBody SimpleObject post, HttpServletRequest request,
	        HttpServletResponse response); @RequestMapping(value = "/{uuid}", method = RequestMethod.POST) @WSDoc("Updates an existing patient list") @ResponseBody Object updatePatientList(@PathVariable("uuid") String uuid, @RequestBody SimpleObject post,
	        HttpServletRequest request, HttpServletResponse response); @RequestMapping(method = RequestMethod.GET) @WSDoc("Get All Unretired Patient Lists in the system") @ResponseBody() String getAllPatientLists(HttpServletRequest request, HttpServletResponse response); @RequestMapping(method = RequestMethod.GET, params = "q") @WSDoc("Gets Patient Lists by name") @ResponseBody() String getPatientListsByName(@RequestParam("q") String query, HttpServletRequest request); @RequestMapping(value = "/{uuid}", method = RequestMethod.GET) @WSDoc("Gets Patient Lists for the uuid path") @ResponseBody() String getAllPatientListByUuid(@PathVariable("uuid") String uuid, HttpServletRequest request); @RequestMapping(value = "/{uuid}", method = RequestMethod.GET, params = "v") @WSDoc("Gets Full representation of Patient Lists for the uuid path") @ResponseBody() String getAllPatientListByUuidFull(@PathVariable("uuid") String uuid, @RequestParam("v") String rep,
	        HttpServletRequest request); @RequestMapping(method = RequestMethod.GET, params = "encounterType") @WSDoc("Gets Patients Without Saving the Patient list") @ResponseBody() String getPatientsInPatientList(@RequestParam Map<String, String> params, HttpServletRequest request); @RequestMapping(value = "/optimized", method = RequestMethod.GET, params = "encounterType") @WSDoc("Gets Patients Without Saving the Patient list") @ResponseBody() String getPatientsInPatientListV2(@RequestParam Map<String, String> params, HttpServletRequest request); @RequestMapping(value = "/{uuid}", method = RequestMethod.DELETE, params = "!purge") @WSDoc("Retires the Patient List") @ResponseBody Object retirePatientList(@PathVariable("uuid") String uuid,
	        @RequestParam(value = "reason", defaultValue = "web service call") String reason, HttpServletRequest request,
	        HttpServletResponse response); @RequestMapping(value = "/{uuid}", method = RequestMethod.DELETE, params = "purge") @ResponseBody Object purgePatientList(@PathVariable("uuid") String uuid, HttpServletRequest request,
	        HttpServletResponse response); }
PatientListController extends BaseRestController { @RequestMapping(method = RequestMethod.GET, params = "encounterType") @WSDoc("Gets Patients Without Saving the Patient list") @ResponseBody() public String getPatientsInPatientList(@RequestParam Map<String, String> params, HttpServletRequest request) throws ResponseException { initPatientListController(); PatientList patientList = new PatientList(); patientList.setSearchQuery("?" + Joiner.on("&").withKeyValueSeparator("=").join(params)); SimpleObject obj = new SimpleObject(); obj.add("uuid", patientList.getUuid()); obj.add("name", patientList.getName()); obj.add("description", patientList.getDescription()); obj.add("searchQuery", patientList.getSearchQuery()); ArrayList patients = new ArrayList(); List<Patient> patientsInPatientList = service.getPatientsInPatientList(patientList); for (Patient p : patientsInPatientList) { SimpleObject patient = new SimpleObject(); patient.add("uuid", p.getUuid()); patient.add("display", p.getPersonName().getFullName()); patient.add("gender", p.getGender()); patient.add("age", p.getAge()); ArrayList encounters = new ArrayList(); List<Encounter> encountersInPatientList = service.getEncountersInPatientList(patientList); for (Encounter e : encountersInPatientList) { if (e.getPatient().equals(p)) { SimpleObject encounter = new SimpleObject(); encounter.add("uuid", e.getUuid()); encounter.add("display", e.getEncounterType().getName() + " - " + e.getEncounterDatetime()); encounter.add("encounterType", e.getEncounterType().getUuid()); encounter.add("encounterDatetime", df.format(e.getEncounterDatetime())); if (e.getProvider() != null) { encounter.add("provider", e.getProvider().getUuid()); } else { encounter.add("provider", null); } ArrayList obsArray = new ArrayList(); Set<Obs> obsAll = e.getObs(); for (Obs o : obsAll) { SimpleObject obs = new SimpleObject(); obs.add("uuid", o.getUuid()); obs.add("display", o.getConcept().getName().getName() + " = " + o.getValueAsString(request.getLocale())); obs.add("obsDatetime", df.format(o.getObsDatetime())); obs.add("value", o.getValueAsString(request.getLocale())); obs.add("comment", o.getComment()); if (o.getOrder() != null) { obs.add("order", o.getOrder().getUuid()); } else { obs.add("order", null); } obsArray.add(obs); } encounter.add("obs", obsArray); encounters.add(encounter); } } patient.add("encounters", encounters); patients.add(patient); } obj.add("patients", patients); obj.add("resourceVersion", getResourceVersion()); return gson.toJson(obj); }  void initPatientListController(); @RequestMapping(method = RequestMethod.POST) @WSDoc("Save New PatientList") @ResponseBody Object createNewPatientList(@RequestBody SimpleObject post, HttpServletRequest request,
	        HttpServletResponse response); @RequestMapping(value = "/{uuid}", method = RequestMethod.POST) @WSDoc("Updates an existing patient list") @ResponseBody Object updatePatientList(@PathVariable("uuid") String uuid, @RequestBody SimpleObject post,
	        HttpServletRequest request, HttpServletResponse response); @RequestMapping(method = RequestMethod.GET) @WSDoc("Get All Unretired Patient Lists in the system") @ResponseBody() String getAllPatientLists(HttpServletRequest request, HttpServletResponse response); @RequestMapping(method = RequestMethod.GET, params = "q") @WSDoc("Gets Patient Lists by name") @ResponseBody() String getPatientListsByName(@RequestParam("q") String query, HttpServletRequest request); @RequestMapping(value = "/{uuid}", method = RequestMethod.GET) @WSDoc("Gets Patient Lists for the uuid path") @ResponseBody() String getAllPatientListByUuid(@PathVariable("uuid") String uuid, HttpServletRequest request); @RequestMapping(value = "/{uuid}", method = RequestMethod.GET, params = "v") @WSDoc("Gets Full representation of Patient Lists for the uuid path") @ResponseBody() String getAllPatientListByUuidFull(@PathVariable("uuid") String uuid, @RequestParam("v") String rep,
	        HttpServletRequest request); @RequestMapping(method = RequestMethod.GET, params = "encounterType") @WSDoc("Gets Patients Without Saving the Patient list") @ResponseBody() String getPatientsInPatientList(@RequestParam Map<String, String> params, HttpServletRequest request); @RequestMapping(value = "/optimized", method = RequestMethod.GET, params = "encounterType") @WSDoc("Gets Patients Without Saving the Patient list") @ResponseBody() String getPatientsInPatientListV2(@RequestParam Map<String, String> params, HttpServletRequest request); @RequestMapping(value = "/{uuid}", method = RequestMethod.DELETE, params = "!purge") @WSDoc("Retires the Patient List") @ResponseBody Object retirePatientList(@PathVariable("uuid") String uuid,
	        @RequestParam(value = "reason", defaultValue = "web service call") String reason, HttpServletRequest request,
	        HttpServletResponse response); @RequestMapping(value = "/{uuid}", method = RequestMethod.DELETE, params = "purge") @ResponseBody Object purgePatientList(@PathVariable("uuid") String uuid, HttpServletRequest request,
	        HttpServletResponse response);  }