示例#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;
   }
 }