Advertisement
Guest User

Untitled

a guest
Sep 10th, 2012
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.46 KB | None | 0 0
  1.     @RequestMapping(value = "module/hl7query/ORUR01", method = RequestMethod.GET)
  2.     @ResponseBody
  3.     public Object getEncounters(@RequestParam(value = "patientId", required = false) String patientId,
  4.                                 @RequestParam(value = "idTypeUuid", required = false) String idTypeUuid,
  5.                                 @RequestParam(value = "encounterUuid", required = false) String encounterUuid,
  6.                                 @RequestParam(value = "startDate", required = false) Date startDate,
  7.                                 @RequestParam(value = "endDate", required = false) Date endDate, HttpServletRequest request,
  8.                                 HttpServletResponse response) {
  9.        
  10.         boolean isPipeDelimited = false;
  11.        
  12.         String acceptHeader = request.getHeader("Accept");
  13.         if (acceptHeader == null || !acceptHeader.contains("text/xml"))
  14.                 isPipeDelimited = true;
  15.        
  16.         List<Encounter> encounters = new ArrayList<Encounter>();
  17.         EncounterService encounterService = Context.getEncounterService();
  18.         HL7QueryService hL7QueryService = Context.getService(HL7QueryService.class);
  19.         HL7Template template = null;
  20.         Patient patient = null;
  21.         if (StringUtils.isBlank(patientId) && StringUtils.isBlank(encounterUuid)){
  22.             if(isPipeDelimited){
  23.                 response.setContentType("application/json");
  24.                 return ExceptionUtils.generateJSONMessage(ErrorMessageConstants.MISSING_IDENTIFIER);
  25.             }
  26.             else{
  27.                 return ExceptionUtils.generateXmlMessage(ErrorMessageConstants.MISSING_IDENTIFIER);
  28.             }
  29.         }
  30.            
  31.         String templateNameGP = Context.getAdministrationService().getGlobalProperty(
  32.             HL7QueryConstants.HL7QUERY_GP_ORUR01_TEMPLATE);
  33.         template = hL7QueryService.getHL7TemplateByName(templateNameGP);
  34.         if (template == null){
  35.             if(isPipeDelimited){
  36.                 response.setContentType("application/json");
  37.                 return ExceptionUtils.generateJSONMessage(ErrorMessageConstants.MISSING_TEMPLATE + templateNameGP);
  38.             }
  39.             else{
  40.                 return ExceptionUtils.generateXmlMessage(ErrorMessageConstants.MISSING_TEMPLATE + templateNameGP);
  41.             }
  42.         }
  43.        
  44.         if (encounterUuid != null) {
  45.             Encounter encounter = encounterService.getEncounterByUuid(encounterUuid);
  46.             if (encounter == null){
  47.                 if(isPipeDelimited){
  48.                     response.setContentType("application/json");
  49.                     return ExceptionUtils.generateJSONMessage(ErrorMessageConstants.MISSING_ENCOUNTER + encounterUuid);
  50.                 }
  51.                 else{
  52.                     return ExceptionUtils.generateXmlMessage(ErrorMessageConstants.MISSING_ENCOUNTER + encounterUuid);
  53.                 }
  54.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement