@GET @Path("/programList") @Produces("application/json") public AbstractSearchResponse<ProgramTo1> getProgramList() throws Exception { AbstractSearchResponse<ProgramTo1> response = new AbstractSearchResponse<ProgramTo1>(); List<ProgramProvider> programProviders = programManager.getProgramDomain( getLoggedInInfo(), getLoggedInInfo().getLoggedInProviderNo()); if (programProviders != null) { List<ProgramTo1> listProgramTo1 = new ArrayList<ProgramTo1>(); ProgramConverter converter = new ProgramConverter(); for (ProgramProvider pp : programProviders) { Program program = programManager.getProgram(getLoggedInInfo(), pp.getProgramId().intValue()); if (program.getType().equals(Program.BED_TYPE)) { listProgramTo1.add(converter.getAsTransferObject(getLoggedInInfo(), program)); } } response.setContent(listProgramTo1); response.setTotal(listProgramTo1.size()); } return response; }
@GET @Path("/patientList") @Produces("application/json") public AbstractSearchResponse<AdmissionTo1> getPatientList( @QueryParam("programNo") String programNo, @QueryParam("day") String day, @QueryParam("startIndex") Integer startIndex, @QueryParam("numToReturn") Integer numToReturn) throws Exception { AbstractSearchResponse<AdmissionTo1> response = new AbstractSearchResponse<AdmissionTo1>(); if (day == null) { day = DateFormatUtils.format(Calendar.getInstance(), DateUtils.ISO8601_DATE_PATTERN); } Date d = new SimpleDateFormat(DateUtils.ISO8601_DATE_PATTERN).parse(day); if (programNo == null) { // get default ProgramProvider current = null; ProgramProvider pp = programManager.getCurrentProgramInDomain( getLoggedInInfo(), getLoggedInInfo().getLoggedInProviderNo()); if (pp != null) { current = pp; } else { List<ProgramProvider> ppList = programManager.getProgramDomain( getLoggedInInfo(), getLoggedInInfo().getLoggedInProviderNo()); if (ppList.size() > 0) { current = ppList.get(0); } } if (current != null) { programNo = String.valueOf(current.getProgramId()); } } if (programNo == null) { throw new Exception("Can't get a program for this provider to use as default"); } List<AdmissionTo1> transfers = new AdmissionConverter() .includeDemographic(true) .getAllAsTransferObjects( getLoggedInInfo(), admissionManager.findAdmissionsByProgramAndDate( getLoggedInInfo(), Integer.parseInt(programNo), d, startIndex, numToReturn)); response.setContent(transfers); response.setTotal( admissionManager.findAdmissionsByProgramAndDateAsCount( getLoggedInInfo(), Integer.parseInt(programNo), d)); return response; }