/**
  * Copy one ValueObject to another
  *
  * @param valueObjectDest to be updated
  * @param valueObjectSrc to copy values from
  */
 public static ims.core.vo.ConsultantStayMinVo copy(
     ims.core.vo.ConsultantStayMinVo valueObjectDest,
     ims.core.vo.ConsultantStayMinVo valueObjectSrc) {
   if (null == valueObjectSrc) {
     return valueObjectSrc;
   }
   valueObjectDest.setID_ConsultantStay(valueObjectSrc.getID_ConsultantStay());
   valueObjectDest.setIsRIE(valueObjectSrc.getIsRIE());
   // transferDateTime
   valueObjectDest.setTransferDateTime(valueObjectSrc.getTransferDateTime());
   // endDateTime
   valueObjectDest.setEndDateTime(valueObjectSrc.getEndDateTime());
   // PatientStatus
   valueObjectDest.setPatientStatus(valueObjectSrc.getPatientStatus());
   return valueObjectDest;
 }
  public static ims.core.admin.pas.domain.objects.ConsultantStay extractConsultantStay(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.core.vo.ConsultantStayMinVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_ConsultantStay();
    ims.core.admin.pas.domain.objects.ConsultantStay domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.core.admin.pas.domain.objects.ConsultantStay) domMap.get(valueObject);
      }
      // ims.core.vo.ConsultantStayMinVo ID_ConsultantStay field is unknown
      domainObject = new ims.core.admin.pas.domain.objects.ConsultantStay();
      domMap.put(valueObject, domainObject);
    } else {
      String key = (valueObject.getClass().getName() + "__" + valueObject.getID_ConsultantStay());
      if (domMap.get(key) != null) {
        return (ims.core.admin.pas.domain.objects.ConsultantStay) domMap.get(key);
      }
      domainObject =
          (ims.core.admin.pas.domain.objects.ConsultantStay)
              domainFactory.getDomainObject(
                  ims.core.admin.pas.domain.objects.ConsultantStay.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_ConsultantStay());

    ims.framework.utils.DateTime dateTime1 = valueObject.getTransferDateTime();
    java.util.Date value1 = null;
    if (dateTime1 != null) {
      value1 = dateTime1.getJavaDate();
    }
    domainObject.setTransferDateTime(value1);
    ims.framework.utils.DateTime dateTime2 = valueObject.getEndDateTime();
    java.util.Date value2 = null;
    if (dateTime2 != null) {
      value2 = dateTime2.getJavaDate();
    }
    domainObject.setEndDateTime(value2);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value3 = null;
    if (null != valueObject.getPatientStatus()) {
      value3 = domainFactory.getLookupInstance(valueObject.getPatientStatus().getID());
    }
    domainObject.setPatientStatus(value3);

    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.pas.domain.objects.ConsultantStay
   */
  public static ims.core.vo.ConsultantStayMinVo insert(
      DomainObjectMap map,
      ims.core.vo.ConsultantStayMinVo valueObject,
      ims.core.admin.pas.domain.objects.ConsultantStay domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

    valueObject.setID_ConsultantStay(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;

    // transferDateTime
    java.util.Date transferDateTime = domainObject.getTransferDateTime();
    if (null != transferDateTime) {
      valueObject.setTransferDateTime(new ims.framework.utils.DateTime(transferDateTime));
    }
    // endDateTime
    java.util.Date endDateTime = domainObject.getEndDateTime();
    if (null != endDateTime) {
      valueObject.setEndDateTime(new ims.framework.utils.DateTime(endDateTime));
    }
    // PatientStatus
    ims.domain.lookups.LookupInstance instance3 = domainObject.getPatientStatus();
    if (null != instance3) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance3.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance3.getImage().getImageId(), instance3.getImage().getImagePath());
      }
      color = instance3.getColor();
      if (color != null) color.getValue();

      ims.core.vo.lookups.PatientStatus voLookup3 =
          new ims.core.vo.lookups.PatientStatus(
              instance3.getId(), instance3.getText(), instance3.isActive(), null, img, color);
      ims.core.vo.lookups.PatientStatus parentVoLookup3 = voLookup3;
      ims.domain.lookups.LookupInstance parent3 = instance3.getParent();
      while (parent3 != null) {
        if (parent3.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent3.getImage().getImageId(), parent3.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent3.getColor();
        if (color != null) color.getValue();
        parentVoLookup3.setParent(
            new ims.core.vo.lookups.PatientStatus(
                parent3.getId(), parent3.getText(), parent3.isActive(), null, img, color));
        parentVoLookup3 = parentVoLookup3.getParent();
        parent3 = parent3.getParent();
      }
      valueObject.setPatientStatus(voLookup3);
    }
    return valueObject;
  }