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

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

    // StatusHistory
    valueObject.setStatusHistory(
        ims.clinical.vo.domain.PatientDiagnosisStatusVoAssembler
            .createPatientDiagnosisStatusVoCollectionFromPatientDiagnosisStatus(
                map, domainObject.getStatusHistory()));
    // DiagnosisDescription
    valueObject.setDiagnosisDescription(domainObject.getDiagnosisDescription());
    // DiagnosedDate
    Integer DiagnosedDate = domainObject.getDiagnosedDate();
    if (null != DiagnosedDate) {
      valueObject.setDiagnosedDate(new ims.framework.utils.PartialDate(DiagnosedDate));
    }
    // Diagnosis
    valueObject.setDiagnosis(
        ims.core.vo.domain.DiagLiteVoAssembler.create(map, domainObject.getDiagnosis()));
    // SourceofInformation
    ims.domain.lookups.LookupInstance instance5 = domainObject.getSourceofInformation();
    if (null != instance5) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance5.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance5.getImage().getImageId(), instance5.getImage().getImagePath());
      }
      color = instance5.getColor();
      if (color != null) color.getValue();

      ims.core.vo.lookups.SourceofInformation voLookup5 =
          new ims.core.vo.lookups.SourceofInformation(
              instance5.getId(), instance5.getText(), instance5.isActive(), null, img, color);
      ims.core.vo.lookups.SourceofInformation parentVoLookup5 = voLookup5;
      ims.domain.lookups.LookupInstance parent5 = instance5.getParent();
      while (parent5 != null) {
        if (parent5.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent5.getImage().getImageId(), parent5.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent5.getColor();
        if (color != null) color.getValue();
        parentVoLookup5.setParent(
            new ims.core.vo.lookups.SourceofInformation(
                parent5.getId(), parent5.getText(), parent5.isActive(), null, img, color));
        parentVoLookup5 = parentVoLookup5.getParent();
        parent5 = parent5.getParent();
      }
      valueObject.setSourceofInformation(voLookup5);
    }
    // isComplication
    valueObject.setIsComplication(domainObject.isIsComplication());
    // isComorbidity
    valueObject.setIsComorbidity(domainObject.isIsComorbidity());
    // DateResolved
    java.util.Date DateResolved = domainObject.getDateResolved();
    if (null != DateResolved) {
      valueObject.setDateResolved(new ims.framework.utils.Date(DateResolved));
    }
    // CareContext
    valueObject.setCareContext(
        ims.core.vo.domain.CareContextForEdischargeDiagnosisVoAssembler.create(
            map, domainObject.getCareContext()));
    // DiagLaterality
    ims.domain.lookups.LookupInstance instance10 = domainObject.getDiagLaterality();
    if (null != instance10) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance10.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance10.getImage().getImageId(), instance10.getImage().getImagePath());
      }
      color = instance10.getColor();
      if (color != null) color.getValue();

      ims.core.vo.lookups.LateralityLRB voLookup10 =
          new ims.core.vo.lookups.LateralityLRB(
              instance10.getId(), instance10.getText(), instance10.isActive(), null, img, color);
      ims.core.vo.lookups.LateralityLRB parentVoLookup10 = voLookup10;
      ims.domain.lookups.LookupInstance parent10 = instance10.getParent();
      while (parent10 != null) {
        if (parent10.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent10.getImage().getImageId(), parent10.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent10.getColor();
        if (color != null) color.getValue();
        parentVoLookup10.setParent(
            new ims.core.vo.lookups.LateralityLRB(
                parent10.getId(), parent10.getText(), parent10.isActive(), null, img, color));
        parentVoLookup10 = parentVoLookup10.getParent();
        parent10 = parent10.getParent();
      }
      valueObject.setDiagLaterality(voLookup10);
    }
    // SiteText
    valueObject.setSiteText(domainObject.getSiteText());
    // AuthoringInfo
    valueObject.setAuthoringInfo(
        ims.core.vo.domain.AuthoringInformationVoAssembler.create(
            map, domainObject.getAuthoringInfo()));
    // IncludeDiagnosisInDiscReports
    valueObject.setIncludeDiagnosisInDiscReports(
        ims.core.vo.domain.IncludeDiagnosisInDischargeReportVoAssembler
            .createIncludeDiagnosisInDischargeReportVoCollectionFromIncludeDiagnosisInDischargeReport(
                map, domainObject.getIncludeDiagnosisInDiscReports()));
    // isPrevRelevantDiagnosis
    valueObject.setIsPrevRelevantDiagnosis(domainObject.isIsPrevRelevantDiagnosis());
    // SysInfo
    // set system information
    valueObject.setSysInfo(
        ims.vo.domain.SystemInformationAssembler.create(domainObject.getSystemInformation()));
    // DateOnset
    java.util.Date DateOnset = domainObject.getDateOnset();
    if (null != DateOnset) {
      valueObject.setDateOnset(new ims.framework.utils.Date(DateOnset));
    }
    // ClinicalContact
    if (domainObject.getClinicalContact() != null) {
      if (domainObject.getClinicalContact()
          instanceof
          HibernateProxy) // If the proxy is set, there is no need to lazy load, the proxy knows the
      // id already.
      {
        HibernateProxy p = (HibernateProxy) domainObject.getClinicalContact();
        int id = Integer.parseInt(p.getHibernateLazyInitializer().getIdentifier().toString());
        valueObject.setClinicalContact(new ims.core.admin.vo.ClinicalContactRefVo(id, -1));
      } else {
        valueObject.setClinicalContact(
            new ims.core.admin.vo.ClinicalContactRefVo(
                domainObject.getClinicalContact().getId(),
                domainObject.getClinicalContact().getVersion()));
      }
    }
    // PrimaryForCareSpells
    valueObject.setPrimaryForCareSpells(
        ims.core.vo.domain.CSPrimaryDiagnosisVoAssembler
            .createCSPrimaryDiagnosisVoCollectionFromCsPrimaryDiagnosis(
                map, domainObject.getPrimaryForCareSpells()));
    // CoMorbidityForEpisodeOfCares
    valueObject.setCoMorbidityForEpisodeOfCares(
        ims.core.vo.domain.EpisodeOfCareCoMorbidityVoAssembler
            .createEpisodeOfCareCoMorbidityVoCollectionFromEpisodeOfCareCoMorbidity(
                map, domainObject.getCoMorbidityForEpisodeOfCares()));
    // EpisodeOfCare
    if (domainObject.getEpisodeOfCare() != null) {
      if (domainObject.getEpisodeOfCare()
          instanceof
          HibernateProxy) // If the proxy is set, there is no need to lazy load, the proxy knows the
      // id already.
      {
        HibernateProxy p = (HibernateProxy) domainObject.getEpisodeOfCare();
        int id = Integer.parseInt(p.getHibernateLazyInitializer().getIdentifier().toString());
        valueObject.setEpisodeOfCare(new ims.core.admin.vo.EpisodeOfCareRefVo(id, -1));
      } else {
        valueObject.setEpisodeOfCare(
            new ims.core.admin.vo.EpisodeOfCareRefVo(
                domainObject.getEpisodeOfCare().getId(),
                domainObject.getEpisodeOfCare().getVersion()));
      }
    }
    // diagnosedOnAdmission
    valueObject.setDiagnosedOnAdmission(domainObject.isDiagnosedOnAdmission());
    return valueObject;
  }
  /**
   * Update the ValueObject with the Domain Object.
   *
   * @param map DomainObjectMap of DomainObjects to already created ValueObjects.
   * @param valueObject to be updated
   * @param domainObject ims.coe.assessment.domain.objects.CommunicationHearing
   */
  public static ims.coe.vo.CommunicationHearingVo insert(
      DomainObjectMap map,
      ims.coe.vo.CommunicationHearingVo valueObject,
      ims.coe.assessment.domain.objects.CommunicationHearing domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

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

    // HearingImpairment
    ims.domain.lookups.LookupInstance instance1 = domainObject.getHearingImpairment();
    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.core.vo.lookups.YesNoUnknown voLookup1 =
          new ims.core.vo.lookups.YesNoUnknown(
              instance1.getId(), instance1.getText(), instance1.isActive(), null, img, color);
      ims.core.vo.lookups.YesNoUnknown 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.core.vo.lookups.YesNoUnknown(
                parent1.getId(), parent1.getText(), parent1.isActive(), null, img, color));
        parentVoLookup1 = parentVoLookup1.getParent();
        parent1 = parent1.getParent();
      }
      valueObject.setHearingImpairment(voLookup1);
    }
    // EffectedEars
    ims.domain.lookups.LookupInstance instance2 = domainObject.getEffectedEars();
    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.core.vo.lookups.LateralityLRB voLookup2 =
          new ims.core.vo.lookups.LateralityLRB(
              instance2.getId(), instance2.getText(), instance2.isActive(), null, img, color);
      ims.core.vo.lookups.LateralityLRB 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.core.vo.lookups.LateralityLRB(
                parent2.getId(), parent2.getText(), parent2.isActive(), null, img, color));
        parentVoLookup2 = parentVoLookup2.getParent();
        parent2 = parent2.getParent();
      }
      valueObject.setEffectedEars(voLookup2);
    }
    // HearingAid
    ims.domain.lookups.LookupInstance instance3 = domainObject.getHearingAid();
    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.YesNoUnknown voLookup3 =
          new ims.core.vo.lookups.YesNoUnknown(
              instance3.getId(), instance3.getText(), instance3.isActive(), null, img, color);
      ims.core.vo.lookups.YesNoUnknown 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.YesNoUnknown(
                parent3.getId(), parent3.getText(), parent3.isActive(), null, img, color));
        parentVoLookup3 = parentVoLookup3.getParent();
        parent3 = parent3.getParent();
      }
      valueObject.setHearingAid(voLookup3);
    }
    // HearingAidWithPatientOnAdmission
    ims.domain.lookups.LookupInstance instance4 =
        domainObject.getHearingAidWithPatientOnAdmission();
    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.core.vo.lookups.YesNoUnknown voLookup4 =
          new ims.core.vo.lookups.YesNoUnknown(
              instance4.getId(), instance4.getText(), instance4.isActive(), null, img, color);
      ims.core.vo.lookups.YesNoUnknown 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.core.vo.lookups.YesNoUnknown(
                parent4.getId(), parent4.getText(), parent4.isActive(), null, img, color));
        parentVoLookup4 = parentVoLookup4.getParent();
        parent4 = parent4.getParent();
      }
      valueObject.setHearingAidWithPatientOnAdmission(voLookup4);
    }
    // BatteriesInOrder
    ims.domain.lookups.LookupInstance instance5 = domainObject.getBatteriesInOrder();
    if (null != instance5) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance5.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance5.getImage().getImageId(), instance5.getImage().getImagePath());
      }
      color = instance5.getColor();
      if (color != null) color.getValue();

      ims.core.vo.lookups.YesNoUnknown voLookup5 =
          new ims.core.vo.lookups.YesNoUnknown(
              instance5.getId(), instance5.getText(), instance5.isActive(), null, img, color);
      ims.core.vo.lookups.YesNoUnknown parentVoLookup5 = voLookup5;
      ims.domain.lookups.LookupInstance parent5 = instance5.getParent();
      while (parent5 != null) {
        if (parent5.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent5.getImage().getImageId(), parent5.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent5.getColor();
        if (color != null) color.getValue();
        parentVoLookup5.setParent(
            new ims.core.vo.lookups.YesNoUnknown(
                parent5.getId(), parent5.getText(), parent5.isActive(), null, img, color));
        parentVoLookup5 = parentVoLookup5.getParent();
        parent5 = parent5.getParent();
      }
      valueObject.setBatteriesInOrder(voLookup5);
    }
    // YearLastHearingTest
    valueObject.setYearLastHearingTest(domainObject.getYearLastHearingTest());
    return valueObject;
  }