Ejemplo n.º 1
0
 /**
  * Get available timeslots based on passed parameters
  *
  * @param fromDate
  * @param toDate
  * @param appointmentType
  * @param location
  * @param provider
  * @param limit
  * @return
  */
 public List<TimeSlot> getTimeSlots(
     Date fromDate,
     Date toDate,
     String appointmentType,
     String location,
     String provider,
     String limit) {
   String charset = "UTF-8";
   ObjectMapper m = new ObjectMapper();
   List<TimeSlot> timeSlots = new ArrayList<TimeSlot>();
   TimeSlot timeSlot;
   try {
     DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
     String query =
         String.format(
             "appointmentscheduling/timeslot?fromDate=%s"
                 + "&toDate=%s&appointmentType=%s"
                 + "&location=%s&provider=%s"
                 + "&limit=%s&v=full",
             URLEncoder.encode(df.format(fromDate), charset),
             URLEncoder.encode(df.format(toDate), charset),
             URLEncoder.encode(appointmentType, charset),
             URLEncoder.encode(location, charset),
             URLEncoder.encode(provider, charset),
             URLEncoder.encode(limit, charset));
     logger.debug(query);
     JsonNode rootNode = m.readTree(RestCall.getRequestGet(query));
     JsonNode results = rootNode.get("results");
     for (JsonNode result : results) {
       String uuid = result.path("uuid").textValue();
       Date startDate = ISO8601DateParser.parse(result.path("startDate").textValue());
       Date endDate = ISO8601DateParser.parse(result.path("endDate").textValue());
       String appBlockUuid = result.path("appointmentBlock").path("uuid").textValue();
       AppointmentBlock appointmentBlock = new AppointmentBlock();
       appointmentBlock.setUuid(appBlockUuid);
       timeSlot = new TimeSlot(appointmentBlock, startDate, endDate);
       timeSlot.setUuid(uuid);
       timeSlots.add(timeSlot);
       System.out.println(startDate.toString() + " " + endDate.toString());
     }
     return timeSlots;
   } catch (Exception ex) {
     logger.info("Some Error occured while getting timeSlots");
     logger.error("\n ERROR Caused by\n", ex);
     ex.printStackTrace();
     return timeSlots;
   }
 }
Ejemplo n.º 2
0
 /**
  * Get appointments for a given patient and appointment status
  *
  * @param patient
  * @param status
  * @param limit
  * @return
  */
 public List<Appointment> getAppointments(
     String patient, AppointmentStatusType status, String limit) {
   String query =
       "appointmentscheduling/appointment?patient="
           + patient
           + "&status="
           + status.toString()
           + "&limit="
           + limit
           + "&v=full";
   ObjectMapper m = new ObjectMapper();
   Appointment appointment;
   TimeSlot timeSlot;
   AppointmentType appointmentType;
   List<Appointment> appointments = new ArrayList<Appointment>();
   try {
     JsonNode rootNode = m.readTree(RestCall.getRequestGet(query));
     JsonNode results = rootNode.get("results");
     System.out.println(results.size());
     for (JsonNode result : results) {
       String uuid = result.path("uuid").textValue();
       Date startDate =
           ISO8601DateParser.parse(result.path("timeSlot").path("startDate").textValue());
       Date endDate = ISO8601DateParser.parse(result.path("timeSlot").path("endDate").textValue());
       appointmentType = new AppointmentType();
       appointmentType.setName(result.path("appointmentType").path("name").textValue());
       timeSlot = new TimeSlot();
       timeSlot.setStartDate(startDate);
       timeSlot.setEndDate(endDate);
       appointment = new Appointment();
       appointment.setUuid(uuid);
       appointment.setTimeSlot(timeSlot);
       appointment.setAppointmentType(appointmentType);
       appointments.add(appointment);
     }
     return appointments;
   } catch (Exception ex) {
     logger.info("Some Error occured. Returning null appointments for patient " + patient);
     logger.error("\n ERROR Caused by\n", ex);
     ex.printStackTrace();
     return appointments;
   }
 }