Package org.sis.ancmessaging.json

Examples of org.sis.ancmessaging.json.CustomMotherResponse


 
  @RequestMapping(value = "getmothers", method = RequestMethod.GET)
  public @ResponseBody CustomMotherResponse fetchMothers(@RequestParam("postId") int postId,
      @RequestParam("workerId") int workerId, @RequestParam("status") String status,
      @RequestParam("time") String time, @RequestParam("rows") int rows, @RequestParam("page") int page) {
    CustomMotherResponse response = new CustomMotherResponse();
    //StringBuilder sb = new StringBuilder();
        Map<String, String> sb = new HashMap<String, String> ();
    List<Mother> mothers = motherService.getMothersByCriteria(postId, workerId, status, time, rows, page, sb);
   
    List<MotherDTO> motherDTOs = new ArrayList<MotherDTO>();
    for (Mother mother : mothers) {
            if (!motherService.motherExistsInList(motherDTOs, mother)) {
                MotherDTO mDTO = new MotherDTO();
                mDTO.setSeqId(mother.getSeqId());
                mDTO.setMotherId(mother.getMotherId());
                mDTO.setFullName(mother.getFullName());
                mDTO.setAge(mother.getAge());
                mDTO.setGott(mother.getGott());

                DateTime edd = new DateTime(mother.getEdd()).withChronology(EthiopicChronology.getInstance());
                mDTO.setEdd(edd.getDayOfMonth() + "/" + edd.getMonthOfYear() + "/" + edd.getYear());

                mDTO.setPassed(edd.isBeforeNow());

                mDTO.setGott(mother.getGott());
                HealthExtensionWorker worker = mother.getHealthWorker();
                if (worker != null) {
                    mDTO.setWorkerName(worker.getFullName());
                    mDTO.setWorkerPhone(worker.getPhoneNumber());
                    mDTO.setHealthPost(worker.getHealthPost().getPostName());
                }
                String outcome = mother.getOutcome();
                //Delivery delivery = motherService.getRecentDelivery(mother);

                if (outcome != null) {
                    mDTO.setDeliveryStatus(outcome);
                } else {
                    mDTO.setDeliveryStatus("Not Delivered");
                }

                List<Reminder> reminders = mother.getReminders();
                for(Reminder reminder : reminders) {
                    String reminderType = reminder.getReminderType();
                    String reminderStatus = reminder.getStatus();
                   
                    if (reminderType.equalsIgnoreCase("MONTHLY")) {
                        mDTO.setFirstReminder(true);
                        mDTO.setFirstConfirmation(reminderStatus);
                    } else if (reminderType.equalsIgnoreCase("WEEKLY")) {
                        mDTO.setSecondReminder(true);
                        mDTO.setSecondConfirmation(reminderStatus);
                    }
                }
                motherDTOs.add(mDTO);
            }
    }
    response.setPage(String.valueOf(page));
    response.setRows(motherDTOs);
    response.setTotal(sb.get("totalPages").toString());
    response.setRecords(sb.get("records").toString());
    return response;
  }
View Full Code Here

TOP

Related Classes of org.sis.ancmessaging.json.CustomMotherResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.