예제 #1
0
  @Override
  public Tickler getAsDomainObject(LoggedInInfo loggedInInfo, TicklerTo1 t)
      throws ConversionException {
    Tickler d = new Tickler();
    d.setCreator(t.getCreator());
    d.setDemographicNo(t.getDemographicNo());
    d.setId(t.getId());
    d.setMessage(t.getMessage());
    d.setPriority(t.getPriority());
    d.setProgramId(t.getProgramId());
    d.setServiceDate(t.getServiceDate());
    d.setStatus(t.getStatus());
    d.setTaskAssignedTo(t.getTaskAssignedTo());
    d.setUpdateDate(t.getUpdateDate());

    return d;
  }
예제 #2
0
  @Override
  public TicklerTo1 getAsTransferObject(LoggedInInfo loggedInInfo, Tickler t)
      throws ConversionException {
    ProviderDao providerDao = SpringUtils.getBean(ProviderDao.class);
    DemographicDao demographicDao = SpringUtils.getBean(DemographicDao.class);
    TicklerLinkDao ticklerLinkDao = SpringUtils.getBean(TicklerLinkDao.class);
    ProgramDao programDao = SpringUtils.getBean(ProgramDao.class);

    TicklerTo1 d = new TicklerTo1();

    d.setCreator(t.getCreator());
    d.setDemographicNo(t.getDemographicNo());
    d.setId(t.getId());
    d.setMessage(t.getMessage());
    d.setPriority(t.getPriority());
    d.setProgramId(t.getProgramId());
    d.setServiceDate(t.getServiceDate());
    d.setStatus(t.getStatus());
    d.setTaskAssignedTo(t.getTaskAssignedTo());
    d.setUpdateDate(t.getUpdateDate());

    // want responses to include patient name - be nice to have this configurable by a parameter
    // map.

    d.setDemographicName(
        demographicDao.getDemographicById(t.getDemographicNo()).getFormattedName());

    d.setTaskAssignedToName(providerDao.getProviderName(t.getTaskAssignedTo()));
    d.setCreatorName(providerDao.getProviderName(t.getCreator()));

    if (d.getStatus() == STATUS.A) {
      d.setStatusName("Active");
    }
    if (d.getStatus() == STATUS.C) {
      d.setStatusName("Completed");
    }
    if (d.getStatus() == STATUS.D) {
      d.setStatusName("Deleted");
    }

    if (includeLinks) {
      List<TicklerLink> links = ticklerLinkDao.getLinkByTickler(d.getId());
      TicklerLinkConverter tlc = new TicklerLinkConverter();
      d.setTicklerLinks(tlc.getAllAsTransferObjects(loggedInInfo, links));
    }

    if (includeComments) {
      for (TicklerComment tc : t.getComments()) {
        TicklerCommentTo1 tct = new TicklerCommentTo1();
        tct.setMessage(tc.getMessage());
        tct.setProviderNo(tc.getProviderNo());
        tct.setUpdateDate(tc.getUpdateDate());
        tct.setProviderName(tc.getProvider() != null ? tc.getProvider().getFormattedName() : "N/A");
        d.getTicklerComments().add(tct);
      }
    }

    if (includeUpdates) {
      for (TicklerUpdate tu : t.getUpdates()) {
        TicklerUpdateTo1 tut = new TicklerUpdateTo1();
        BeanUtils.copyProperties(tu, tut, new String[] {"id", "provider"});
        tut.setProviderName(tu.getProvider() != null ? tu.getProvider().getFormattedName() : "N/A");

        d.getTicklerUpdates().add(tut);
      }
    }

    if (includeProgram && t.getProgramId() != null) {
      // TODO: this should go through the manager, but I have no LoggedInInfo. Going to have to
      // change the interface and update all the implementors
      Program p = programDao.getProgram(t.getProgramId());
      if (p != null) {
        d.setProgram(new ProgramConverter().getAsTransferObject(loggedInInfo, p));
      }
    }

    return d;
  }