/**
  * Copy one ValueObject to another
  *
  * @param valueObjectDest to be updated
  * @param valueObjectSrc to copy values from
  */
 public static ims.generalmedical.vo.EpworthSleepAssessmentVo copy(
     ims.generalmedical.vo.EpworthSleepAssessmentVo valueObjectDest,
     ims.generalmedical.vo.EpworthSleepAssessmentVo valueObjectSrc) {
   if (null == valueObjectSrc) {
     return valueObjectSrc;
   }
   valueObjectDest.setID_EpworthSleepAssessment(valueObjectSrc.getID_EpworthSleepAssessment());
   valueObjectDest.setIsRIE(valueObjectSrc.getIsRIE());
   // ChanceOfSleep
   valueObjectDest.setChanceOfSleep(valueObjectSrc.getChanceOfSleep());
   // SleepScore
   valueObjectDest.setSleepScore(valueObjectSrc.getSleepScore());
   return valueObjectDest;
 }
  /**
   * 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.clinical.domain.objects.EpworthSleepAssessment
   */
  public static ims.generalmedical.vo.EpworthSleepAssessmentVo insert(
      DomainObjectMap map,
      ims.generalmedical.vo.EpworthSleepAssessmentVo valueObject,
      ims.core.clinical.domain.objects.EpworthSleepAssessment domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

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

    // ChanceOfSleep
    ims.domain.lookups.LookupInstance instance1 = domainObject.getChanceOfSleep();
    if (null != instance1) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance1.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance1.getImage().getImageId(), instance1.getImage().getImagePath());
      }
      color = instance1.getColor();
      if (color != null) color.getValue();

      ims.spinalinjuries.vo.lookups.SleepEpworthChanceOfSleep voLookup1 =
          new ims.spinalinjuries.vo.lookups.SleepEpworthChanceOfSleep(
              instance1.getId(), instance1.getText(), instance1.isActive(), null, img, color);
      ims.spinalinjuries.vo.lookups.SleepEpworthChanceOfSleep parentVoLookup1 = voLookup1;
      ims.domain.lookups.LookupInstance parent1 = instance1.getParent();
      while (parent1 != null) {
        if (parent1.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent1.getImage().getImageId(), parent1.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent1.getColor();
        if (color != null) color.getValue();
        parentVoLookup1.setParent(
            new ims.spinalinjuries.vo.lookups.SleepEpworthChanceOfSleep(
                parent1.getId(), parent1.getText(), parent1.isActive(), null, img, color));
        parentVoLookup1 = parentVoLookup1.getParent();
        parent1 = parent1.getParent();
      }
      valueObject.setChanceOfSleep(voLookup1);
    }
    // SleepScore
    ims.domain.lookups.LookupInstance instance2 = domainObject.getSleepScore();
    if (null != instance2) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance2.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance2.getImage().getImageId(), instance2.getImage().getImagePath());
      }
      color = instance2.getColor();
      if (color != null) color.getValue();

      ims.spinalinjuries.vo.lookups.SleepEpworthScore voLookup2 =
          new ims.spinalinjuries.vo.lookups.SleepEpworthScore(
              instance2.getId(), instance2.getText(), instance2.isActive(), null, img, color);
      ims.spinalinjuries.vo.lookups.SleepEpworthScore parentVoLookup2 = voLookup2;
      ims.domain.lookups.LookupInstance parent2 = instance2.getParent();
      while (parent2 != null) {
        if (parent2.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent2.getImage().getImageId(), parent2.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent2.getColor();
        if (color != null) color.getValue();
        parentVoLookup2.setParent(
            new ims.spinalinjuries.vo.lookups.SleepEpworthScore(
                parent2.getId(), parent2.getText(), parent2.isActive(), null, img, color));
        parentVoLookup2 = parentVoLookup2.getParent();
        parent2 = parent2.getParent();
      }
      valueObject.setSleepScore(voLookup2);
    }
    return valueObject;
  }