コード例 #1
0
ファイル: AppointmentRestCall.java プロジェクト: Raxa/voice
 /**
  * Get appointment types
  *
  * @param limit
  * @return
  */
 public List<AppointmentType> getAppointmentTypes(String limit) {
   String query = "appointmentscheduling/appointmenttype?v=full&limit=" + limit;
   ObjectMapper m = new ObjectMapper();
   List<AppointmentType> appointmentTypes = new ArrayList<AppointmentType>();
   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();
       String name = result.path("display").textValue();
       String desc = result.path("description").textValue();
       Integer duration = result.path("duration").asInt();
       AppointmentType appType = new AppointmentType(name, desc, duration);
       appType.setUuid(uuid);
       appointmentTypes.add(appType);
     }
     return appointmentTypes;
   } catch (Exception ex) {
     logger.info("Some Error occured.Retruning null for phone number:");
     logger.error("\n ERROR Caused by\n", ex);
     ex.printStackTrace();
     return appointmentTypes;
   }
 }
コード例 #2
0
ファイル: AppointmentRestCall.java プロジェクト: Raxa/voice
 /**
  * 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;
   }
 }