/**
  * Copy one ValueObject to another
  *
  * @param valueObjectDest to be updated
  * @param valueObjectSrc to copy values from
  */
 public static ims.emergency.vo.EmergencyAttendanceForTriageLiteVo copy(
     ims.emergency.vo.EmergencyAttendanceForTriageLiteVo valueObjectDest,
     ims.emergency.vo.EmergencyAttendanceForTriageLiteVo valueObjectSrc) {
   if (null == valueObjectSrc) {
     return valueObjectSrc;
   }
   valueObjectDest.setID_EmergencyAttendance(valueObjectSrc.getID_EmergencyAttendance());
   valueObjectDest.setIsRIE(valueObjectSrc.getIsRIE());
   // ArrivalDateTime
   valueObjectDest.setArrivalDateTime(valueObjectSrc.getArrivalDateTime());
   // DischargeDateTime
   valueObjectDest.setDischargeDateTime(valueObjectSrc.getDischargeDateTime());
   // CareContext
   valueObjectDest.setCareContext(valueObjectSrc.getCareContext());
   // UrgencyLevel
   valueObjectDest.setUrgencyLevel(valueObjectSrc.getUrgencyLevel());
   // ConclusionDateTime
   valueObjectDest.setConclusionDateTime(valueObjectSrc.getConclusionDateTime());
   // BedTypeRequested
   valueObjectDest.setBedTypeRequested(valueObjectSrc.getBedTypeRequested());
   // MC
   valueObjectDest.setMC(valueObjectSrc.getMC());
   // COTA
   valueObjectDest.setCOTA(valueObjectSrc.getCOTA());
   // PCG1
   valueObjectDest.setPCG1(valueObjectSrc.getPCG1());
   // PCG2
   valueObjectDest.setPCG2(valueObjectSrc.getPCG2());
   // HAR
   valueObjectDest.setHAR(valueObjectSrc.getHAR());
   // Purchaser
   valueObjectDest.setPurchaser(valueObjectSrc.getPurchaser());
   // SequenceNumber
   valueObjectDest.setSequenceNumber(valueObjectSrc.getSequenceNumber());
   // customID
   valueObjectDest.setCustomID(valueObjectSrc.getCustomID());
   // EndOfRegistrationDateTime
   valueObjectDest.setEndOfRegistrationDateTime(valueObjectSrc.getEndOfRegistrationDateTime());
   // ModeOfArrival
   valueObjectDest.setModeOfArrival(valueObjectSrc.getModeOfArrival());
   // RegistrationDateTime
   valueObjectDest.setRegistrationDateTime(valueObjectSrc.getRegistrationDateTime());
   // AgeAtAttendance
   valueObjectDest.setAgeAtAttendance(valueObjectSrc.getAgeAtAttendance());
   return valueObjectDest;
 }
  public static ims.core.admin.domain.objects.EmergencyAttendance extractEmergencyAttendance(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.emergency.vo.EmergencyAttendanceForTriageLiteVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_EmergencyAttendance();
    ims.core.admin.domain.objects.EmergencyAttendance domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.core.admin.domain.objects.EmergencyAttendance) domMap.get(valueObject);
      }
      // ims.emergency.vo.EmergencyAttendanceForTriageLiteVo ID_EmergencyAttendance field is unknown
      domainObject = new ims.core.admin.domain.objects.EmergencyAttendance();
      domMap.put(valueObject, domainObject);
    } else {
      String key =
          (valueObject.getClass().getName() + "__" + valueObject.getID_EmergencyAttendance());
      if (domMap.get(key) != null) {
        return (ims.core.admin.domain.objects.EmergencyAttendance) domMap.get(key);
      }
      domainObject =
          (ims.core.admin.domain.objects.EmergencyAttendance)
              domainFactory.getDomainObject(
                  ims.core.admin.domain.objects.EmergencyAttendance.class, id);

      // TODO: Not sure how this should be handled. Effectively it must be a staleobject exception,
      // but maybe should be handled as that further up.
      if (domainObject == null) return null;

      domMap.put(key, domainObject);
    }
    domainObject.setVersion(valueObject.getVersion_EmergencyAttendance());

    ims.framework.utils.DateTime dateTime1 = valueObject.getArrivalDateTime();
    java.util.Date value1 = null;
    if (dateTime1 != null) {
      value1 = dateTime1.getJavaDate();
    }
    domainObject.setArrivalDateTime(value1);
    ims.framework.utils.DateTime dateTime2 = valueObject.getDischargeDateTime();
    java.util.Date value2 = null;
    if (dateTime2 != null) {
      value2 = dateTime2.getJavaDate();
    }
    domainObject.setDischargeDateTime(value2);
    ims.core.admin.domain.objects.CareContext value3 = null;
    if (null != valueObject.getCareContext()) {
      if (valueObject.getCareContext().getBoId() == null) {
        if (domMap.get(valueObject.getCareContext()) != null) {
          value3 =
              (ims.core.admin.domain.objects.CareContext) domMap.get(valueObject.getCareContext());
        }
      } else if (valueObject.getBoVersion()
          == -1) // RefVo was not modified since obtained from the Assembler, no need to update the
                 // BO field
      {
        value3 = domainObject.getCareContext();
      } else {
        value3 =
            (ims.core.admin.domain.objects.CareContext)
                domainFactory.getDomainObject(
                    ims.core.admin.domain.objects.CareContext.class,
                    valueObject.getCareContext().getBoId());
      }
    }
    domainObject.setCareContext(value3);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value4 = null;
    if (null != valueObject.getUrgencyLevel()) {
      value4 = domainFactory.getLookupInstance(valueObject.getUrgencyLevel().getID());
    }
    domainObject.setUrgencyLevel(value4);
    ims.framework.utils.DateTime dateTime5 = valueObject.getConclusionDateTime();
    java.util.Date value5 = null;
    if (dateTime5 != null) {
      value5 = dateTime5.getJavaDate();
    }
    domainObject.setConclusionDateTime(value5);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value6 = null;
    if (null != valueObject.getBedTypeRequested()) {
      value6 = domainFactory.getLookupInstance(valueObject.getBedTypeRequested().getID());
    }
    domainObject.setBedTypeRequested(value6);
    // This is to overcome a bug in both Sybase and Oracle which prevents them from storing an empty
    // string correctly
    // Sybase stores it as a single space, Oracle stores it as NULL. This fix will make them
    // consistent at least.
    if (valueObject.getMC() != null && valueObject.getMC().equals("")) {
      valueObject.setMC(null);
    }
    domainObject.setMC(valueObject.getMC());
    // This is to overcome a bug in both Sybase and Oracle which prevents them from storing an empty
    // string correctly
    // Sybase stores it as a single space, Oracle stores it as NULL. This fix will make them
    // consistent at least.
    if (valueObject.getCOTA() != null && valueObject.getCOTA().equals("")) {
      valueObject.setCOTA(null);
    }
    domainObject.setCOTA(valueObject.getCOTA());
    // This is to overcome a bug in both Sybase and Oracle which prevents them from storing an empty
    // string correctly
    // Sybase stores it as a single space, Oracle stores it as NULL. This fix will make them
    // consistent at least.
    if (valueObject.getPCG1() != null && valueObject.getPCG1().equals("")) {
      valueObject.setPCG1(null);
    }
    domainObject.setPCG1(valueObject.getPCG1());
    // This is to overcome a bug in both Sybase and Oracle which prevents them from storing an empty
    // string correctly
    // Sybase stores it as a single space, Oracle stores it as NULL. This fix will make them
    // consistent at least.
    if (valueObject.getPCG2() != null && valueObject.getPCG2().equals("")) {
      valueObject.setPCG2(null);
    }
    domainObject.setPCG2(valueObject.getPCG2());
    // This is to overcome a bug in both Sybase and Oracle which prevents them from storing an empty
    // string correctly
    // Sybase stores it as a single space, Oracle stores it as NULL. This fix will make them
    // consistent at least.
    if (valueObject.getHAR() != null && valueObject.getHAR().equals("")) {
      valueObject.setHAR(null);
    }
    domainObject.setHAR(valueObject.getHAR());
    // This is to overcome a bug in both Sybase and Oracle which prevents them from storing an empty
    // string correctly
    // Sybase stores it as a single space, Oracle stores it as NULL. This fix will make them
    // consistent at least.
    if (valueObject.getPurchaser() != null && valueObject.getPurchaser().equals("")) {
      valueObject.setPurchaser(null);
    }
    domainObject.setPurchaser(valueObject.getPurchaser());
    // This is to overcome a bug in both Sybase and Oracle which prevents them from storing an empty
    // string correctly
    // Sybase stores it as a single space, Oracle stores it as NULL. This fix will make them
    // consistent at least.
    if (valueObject.getSequenceNumber() != null && valueObject.getSequenceNumber().equals("")) {
      valueObject.setSequenceNumber(null);
    }
    domainObject.setSequenceNumber(valueObject.getSequenceNumber());
    // This is to overcome a bug in both Sybase and Oracle which prevents them from storing an empty
    // string correctly
    // Sybase stores it as a single space, Oracle stores it as NULL. This fix will make them
    // consistent at least.
    if (valueObject.getCustomID() != null && valueObject.getCustomID().equals("")) {
      valueObject.setCustomID(null);
    }
    domainObject.setCustomID(valueObject.getCustomID());
    ims.framework.utils.DateTime dateTime15 = valueObject.getEndOfRegistrationDateTime();
    java.util.Date value15 = null;
    if (dateTime15 != null) {
      value15 = dateTime15.getJavaDate();
    }
    domainObject.setEndOfRegistrationDateTime(value15);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value16 = null;
    if (null != valueObject.getModeOfArrival()) {
      value16 = domainFactory.getLookupInstance(valueObject.getModeOfArrival().getID());
    }
    domainObject.setModeOfArrival(value16);
    ims.framework.utils.DateTime dateTime17 = valueObject.getRegistrationDateTime();
    java.util.Date value17 = null;
    if (dateTime17 != null) {
      value17 = dateTime17.getJavaDate();
    }
    domainObject.setRegistrationDateTime(value17);
    domainObject.setAgeAtAttendance(valueObject.getAgeAtAttendance());

    return domainObject;
  }
  /**
   * Update the ValueObject with the Domain Object.
   *
   * @param map DomainObjectMap of DomainObjects to already created ValueObjects.
   * @param valueObject to be updated
   * @param domainObject ims.core.admin.domain.objects.EmergencyAttendance
   */
  public static ims.emergency.vo.EmergencyAttendanceForTriageLiteVo insert(
      DomainObjectMap map,
      ims.emergency.vo.EmergencyAttendanceForTriageLiteVo valueObject,
      ims.core.admin.domain.objects.EmergencyAttendance domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

    valueObject.setID_EmergencyAttendance(domainObject.getId());
    valueObject.setIsRIE(domainObject.getIsRIE());

    // If this is a recordedInError record, and the domainObject
    // value isIncludeRecord has not been set, then we return null and
    // not the value object
    if (valueObject.getIsRIE() != null
        && valueObject.getIsRIE().booleanValue() == true
        && !domainObject.isIncludeRecord()) return null;

    // If this is not a recordedInError record, and the domainObject
    // value isIncludeRecord has been set, then we return null and
    // not the value object
    if ((valueObject.getIsRIE() == null || valueObject.getIsRIE().booleanValue() == false)
        && domainObject.isIncludeRecord()) return null;

    // ArrivalDateTime
    java.util.Date ArrivalDateTime = domainObject.getArrivalDateTime();
    if (null != ArrivalDateTime) {
      valueObject.setArrivalDateTime(new ims.framework.utils.DateTime(ArrivalDateTime));
    }
    // DischargeDateTime
    java.util.Date DischargeDateTime = domainObject.getDischargeDateTime();
    if (null != DischargeDateTime) {
      valueObject.setDischargeDateTime(new ims.framework.utils.DateTime(DischargeDateTime));
    }
    // CareContext
    if (domainObject.getCareContext() != null) {
      if (domainObject.getCareContext()
          instanceof
          HibernateProxy) // If the proxy is set, there is no need to lazy load, the proxy knows the
                          // id already.
      {
        HibernateProxy p = (HibernateProxy) domainObject.getCareContext();
        int id = Integer.parseInt(p.getHibernateLazyInitializer().getIdentifier().toString());
        valueObject.setCareContext(new ims.core.admin.vo.CareContextRefVo(id, -1));
      } else {
        valueObject.setCareContext(
            new ims.core.admin.vo.CareContextRefVo(
                domainObject.getCareContext().getId(), domainObject.getCareContext().getVersion()));
      }
    }
    // UrgencyLevel
    ims.domain.lookups.LookupInstance instance4 = domainObject.getUrgencyLevel();
    if (null != instance4) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance4.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance4.getImage().getImageId(), instance4.getImage().getImagePath());
      }
      color = instance4.getColor();
      if (color != null) color.getValue();

      ims.emergency.vo.lookups.UrgencyLevel voLookup4 =
          new ims.emergency.vo.lookups.UrgencyLevel(
              instance4.getId(), instance4.getText(), instance4.isActive(), null, img, color);
      ims.emergency.vo.lookups.UrgencyLevel parentVoLookup4 = voLookup4;
      ims.domain.lookups.LookupInstance parent4 = instance4.getParent();
      while (parent4 != null) {
        if (parent4.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent4.getImage().getImageId(), parent4.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent4.getColor();
        if (color != null) color.getValue();
        parentVoLookup4.setParent(
            new ims.emergency.vo.lookups.UrgencyLevel(
                parent4.getId(), parent4.getText(), parent4.isActive(), null, img, color));
        parentVoLookup4 = parentVoLookup4.getParent();
        parent4 = parent4.getParent();
      }
      valueObject.setUrgencyLevel(voLookup4);
    }
    // ConclusionDateTime
    java.util.Date ConclusionDateTime = domainObject.getConclusionDateTime();
    if (null != ConclusionDateTime) {
      valueObject.setConclusionDateTime(new ims.framework.utils.DateTime(ConclusionDateTime));
    }
    // BedTypeRequested
    ims.domain.lookups.LookupInstance instance6 = domainObject.getBedTypeRequested();
    if (null != instance6) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance6.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance6.getImage().getImageId(), instance6.getImage().getImagePath());
      }
      color = instance6.getColor();
      if (color != null) color.getValue();

      ims.core.vo.lookups.BedTypeRequested voLookup6 =
          new ims.core.vo.lookups.BedTypeRequested(
              instance6.getId(), instance6.getText(), instance6.isActive(), null, img, color);
      ims.core.vo.lookups.BedTypeRequested parentVoLookup6 = voLookup6;
      ims.domain.lookups.LookupInstance parent6 = instance6.getParent();
      while (parent6 != null) {
        if (parent6.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent6.getImage().getImageId(), parent6.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent6.getColor();
        if (color != null) color.getValue();
        parentVoLookup6.setParent(
            new ims.core.vo.lookups.BedTypeRequested(
                parent6.getId(), parent6.getText(), parent6.isActive(), null, img, color));
        parentVoLookup6 = parentVoLookup6.getParent();
        parent6 = parent6.getParent();
      }
      valueObject.setBedTypeRequested(voLookup6);
    }
    // MC
    valueObject.setMC(domainObject.getMC());
    // COTA
    valueObject.setCOTA(domainObject.getCOTA());
    // PCG1
    valueObject.setPCG1(domainObject.getPCG1());
    // PCG2
    valueObject.setPCG2(domainObject.getPCG2());
    // HAR
    valueObject.setHAR(domainObject.getHAR());
    // Purchaser
    valueObject.setPurchaser(domainObject.getPurchaser());
    // SequenceNumber
    valueObject.setSequenceNumber(domainObject.getSequenceNumber());
    // customID
    valueObject.setCustomID(domainObject.getCustomID());
    // EndOfRegistrationDateTime
    java.util.Date EndOfRegistrationDateTime = domainObject.getEndOfRegistrationDateTime();
    if (null != EndOfRegistrationDateTime) {
      valueObject.setEndOfRegistrationDateTime(
          new ims.framework.utils.DateTime(EndOfRegistrationDateTime));
    }
    // ModeOfArrival
    ims.domain.lookups.LookupInstance instance16 = domainObject.getModeOfArrival();
    if (null != instance16) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance16.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance16.getImage().getImageId(), instance16.getImage().getImagePath());
      }
      color = instance16.getColor();
      if (color != null) color.getValue();

      ims.emergency.vo.lookups.ModeOfArrival voLookup16 =
          new ims.emergency.vo.lookups.ModeOfArrival(
              instance16.getId(), instance16.getText(), instance16.isActive(), null, img, color);
      ims.emergency.vo.lookups.ModeOfArrival parentVoLookup16 = voLookup16;
      ims.domain.lookups.LookupInstance parent16 = instance16.getParent();
      while (parent16 != null) {
        if (parent16.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent16.getImage().getImageId(), parent16.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent16.getColor();
        if (color != null) color.getValue();
        parentVoLookup16.setParent(
            new ims.emergency.vo.lookups.ModeOfArrival(
                parent16.getId(), parent16.getText(), parent16.isActive(), null, img, color));
        parentVoLookup16 = parentVoLookup16.getParent();
        parent16 = parent16.getParent();
      }
      valueObject.setModeOfArrival(voLookup16);
    }
    // RegistrationDateTime
    java.util.Date RegistrationDateTime = domainObject.getRegistrationDateTime();
    if (null != RegistrationDateTime) {
      valueObject.setRegistrationDateTime(new ims.framework.utils.DateTime(RegistrationDateTime));
    }
    // AgeAtAttendance
    valueObject.setAgeAtAttendance(domainObject.getAgeAtAttendance());
    return valueObject;
  }