Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @RequestMapping(value = "module/hl7query/ORUR01", method = RequestMethod.GET)
- @ResponseBody
- public Object getEncounters(@RequestParam(value = "patientId", required = false) String patientId,
- @RequestParam(value = "idTypeUuid", required = false) String idTypeUuid,
- @RequestParam(value = "encounterUuid", required = false) String encounterUuid,
- @RequestParam(value = "startDate", required = false) Date startDate,
- @RequestParam(value = "endDate", required = false) Date endDate, HttpServletRequest request,
- HttpServletResponse response) {
- boolean isPipeDelimited = false;
- String acceptHeader = request.getHeader("Accept");
- if (acceptHeader == null || !acceptHeader.contains("text/xml"))
- isPipeDelimited = true;
- List<Encounter> encounters = new ArrayList<Encounter>();
- EncounterService encounterService = Context.getEncounterService();
- HL7QueryService hL7QueryService = Context.getService(HL7QueryService.class);
- HL7Template template = null;
- Patient patient = null;
- if (StringUtils.isBlank(patientId) && StringUtils.isBlank(encounterUuid)){
- if(isPipeDelimited){
- response.setContentType("application/json");
- return ExceptionUtils.generateJSONMessage(ErrorMessageConstants.MISSING_IDENTIFIER);
- }
- else{
- return ExceptionUtils.generateXmlMessage(ErrorMessageConstants.MISSING_IDENTIFIER);
- }
- }
- String templateNameGP = Context.getAdministrationService().getGlobalProperty(
- HL7QueryConstants.HL7QUERY_GP_ORUR01_TEMPLATE);
- template = hL7QueryService.getHL7TemplateByName(templateNameGP);
- if (template == null){
- if(isPipeDelimited){
- response.setContentType("application/json");
- return ExceptionUtils.generateJSONMessage(ErrorMessageConstants.MISSING_TEMPLATE + templateNameGP);
- }
- else{
- return ExceptionUtils.generateXmlMessage(ErrorMessageConstants.MISSING_TEMPLATE + templateNameGP);
- }
- }
- if (encounterUuid != null) {
- Encounter encounter = encounterService.getEncounterByUuid(encounterUuid);
- if (encounter == null){
- if(isPipeDelimited){
- response.setContentType("application/json");
- return ExceptionUtils.generateJSONMessage(ErrorMessageConstants.MISSING_ENCOUNTER + encounterUuid);
- }
- else{
- return ExceptionUtils.generateXmlMessage(ErrorMessageConstants.MISSING_ENCOUNTER + encounterUuid);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement