Exemplo n.º 1
0
  public DischargeSupplementaryNotesVo getSupplementary(CareContextRefVo voCareContextRefVo) {
    if (voCareContextRefVo == null)
      throw new CodingRuntimeException("voCareContextRefVo Filter not provided for list call. ");

    if (voCareContextRefVo != null) {
      DomainFactory factory = getDomainFactory();
      StringBuffer hql = new StringBuffer(" from DischargeSupplementaryNotes ds where ");
      String andStr = " ";

      ArrayList<String> markers = new ArrayList<String>();
      ArrayList<Serializable> values = new ArrayList<Serializable>();

      hql.append(andStr + " ds.careContext.id = :careContextId");
      markers.add("careContextId");
      values.add(voCareContextRefVo.getID_CareContext());
      andStr = " and ";

      List list = factory.find(hql.toString(), markers, values);
      if (list != null && list.size() > 0) {
        DischargeSupplementaryNotesVoCollection voColl =
            DischargeSupplementaryNotesVoAssembler
                .createDischargeSupplementaryNotesVoCollectionFromDischargeSupplementaryNotes(list);
        if (voColl != null && voColl.size() > 0) return voColl.get(0);
      }
    }
    return null;
  }
Exemplo n.º 2
0
  public DischargeSupplementaryNotesVo saveSupplementaryAndDD(
      DischargeSupplementaryNotesVo voDischSupp, DischargeDetailsVo voDD)
      throws DomainInterfaceException, StaleObjectException {
    if (voDischSupp == null)
      throw new CodingRuntimeException("DischargeSupplementaryNotesVo is null");

    if (!voDischSupp.isValidated())
      throw new CodingRuntimeException(
          "DischargeSupplementaryNotesVo Value Object has not been validated");

    DomainFactory factory = getDomainFactory();
    DischargeSupplementaryNotes doDSN =
        DischargeSupplementaryNotesVoAssembler.extractDischargeSupplementaryNotes(
            factory, voDischSupp);

    // WDEV-8813
    // Workaround for the case when 2 users save in the same time a new
    // DischargeSupplementaryNotesVO
    // In this case the domain.save call doesn't throw a StaleObjectExeption, even if it is the case
    if (!voDischSupp.getID_DischargeSupplementaryNotesIsNotNull()) {
      DischargeSupplementaryNotesVo voDischargeSupp =
          getSupplementary(voDischSupp.getCareContext());
      if (voDischargeSupp != null) {
        throw new StaleObjectException(
            doDSN, "A DischargeSupplementaryNotesVo was already saved by another user");
      }
    }

    factory.save(doDSN);

    if (voDD != null) {
      DischargeDetails doDD = DischargeDetailsVoAssembler.extractDischargeDetails(factory, voDD);
      factory.save(doDD);
    }
    return DischargeSupplementaryNotesVoAssembler.create(doDSN);
  }