/**
  * Copy one ValueObject to another
  *
  * @param valueObjectDest to be updated
  * @param valueObjectSrc to copy values from
  */
 public static ims.clinicaladmin.vo.PathologyDetailsVo copy(
     ims.clinicaladmin.vo.PathologyDetailsVo valueObjectDest,
     ims.clinicaladmin.vo.PathologyDetailsVo valueObjectSrc) {
   if (null == valueObjectSrc) {
     return valueObjectSrc;
   }
   valueObjectDest.setID_PathologyDetails(valueObjectSrc.getID_PathologyDetails());
   valueObjectDest.setIsRIE(valueObjectSrc.getIsRIE());
   // InvasiveLesionSize
   valueObjectDest.setInvasiveLesionSize(valueObjectSrc.getInvasiveLesionSize());
   // SynchronousTumourIndicator
   valueObjectDest.setSynchronousTumourIndicator(valueObjectSrc.getSynchronousTumourIndicator());
   // Histology
   valueObjectDest.setHistology(valueObjectSrc.getHistology());
   // VascularLymphInvasion
   valueObjectDest.setVascularLymphInvasion(valueObjectSrc.getVascularLymphInvasion());
   // ExcisionMargin
   valueObjectDest.setExcisionMargin(valueObjectSrc.getExcisionMargin());
   // NumberNodesExamined
   valueObjectDest.setNumberNodesExamined(valueObjectSrc.getNumberNodesExamined());
   // NodesPositiveNumber
   valueObjectDest.setNodesPositiveNumber(valueObjectSrc.getNodesPositiveNumber());
   // PathologicalTVal
   valueObjectDest.setPathologicalTVal(valueObjectSrc.getPathologicalTVal());
   // PathologicalNVal
   valueObjectDest.setPathologicalNVal(valueObjectSrc.getPathologicalNVal());
   // PathologicalMVal
   valueObjectDest.setPathologicalMVal(valueObjectSrc.getPathologicalMVal());
   // PathologicalOverall
   valueObjectDest.setPathologicalOverall(valueObjectSrc.getPathologicalOverall());
   // ServiceReportId
   valueObjectDest.setServiceReportId(valueObjectSrc.getServiceReportId());
   // ServiceReportStatus
   valueObjectDest.setServiceReportStatus(valueObjectSrc.getServiceReportStatus());
   // SpecimenNature
   valueObjectDest.setSpecimenNature(valueObjectSrc.getSpecimenNature());
   // OrgaCodeRequester
   valueObjectDest.setOrgaCodeRequester(valueObjectSrc.getOrgaCodeRequester());
   // CareProfCodeRequester
   valueObjectDest.setCareProfCodeRequester(valueObjectSrc.getCareProfCodeRequester());
   // TCategoryExtended
   valueObjectDest.setTCategoryExtended(valueObjectSrc.getTCategoryExtended());
   // MCategoryExtended
   valueObjectDest.setMCategoryExtended(valueObjectSrc.getMCategoryExtended());
   // Status
   valueObjectDest.setStatus(valueObjectSrc.getStatus());
   // AuthoringInformation
   valueObjectDest.setAuthoringInformation(valueObjectSrc.getAuthoringInformation());
   // AssociatedQuestions
   valueObjectDest.setAssociatedQuestions(valueObjectSrc.getAssociatedQuestions());
   // AssociatiatedTumourDetails
   valueObjectDest.setAssociatiatedTumourDetails(valueObjectSrc.getAssociatiatedTumourDetails());
   // GradeOfDifferentation
   valueObjectDest.setGradeOfDifferentation(valueObjectSrc.getGradeOfDifferentation());
   // InvestigationType
   valueObjectDest.setInvestigationType(valueObjectSrc.getInvestigationType());
   // SampleReceiptDate
   valueObjectDest.setSampleReceiptDate(valueObjectSrc.getSampleReceiptDate());
   // InvestigationResultDate
   valueObjectDest.setInvestigationResultDate(valueObjectSrc.getInvestigationResultDate());
   // ReportingConsultantCode
   valueObjectDest.setReportingConsultantCode(valueObjectSrc.getReportingConsultantCode());
   // ReportingOrganisation
   valueObjectDest.setReportingOrganisation(valueObjectSrc.getReportingOrganisation());
   // CareContext
   valueObjectDest.setCareContext(valueObjectSrc.getCareContext());
   // PreviousVersion
   valueObjectDest.setPreviousVersion(valueObjectSrc.getPreviousVersion());
   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.oncology.domain.objects.PathologyDetails
   */
  public static ims.clinicaladmin.vo.PathologyDetailsVo insert(
      DomainObjectMap map,
      ims.clinicaladmin.vo.PathologyDetailsVo valueObject,
      ims.oncology.domain.objects.PathologyDetails domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

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

    // InvasiveLesionSize
    valueObject.setInvasiveLesionSize(domainObject.getInvasiveLesionSize());
    // SynchronousTumourIndicator
    ims.domain.lookups.LookupInstance instance2 = domainObject.getSynchronousTumourIndicator();
    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.oncology.vo.lookups.SynchronousTumourIndicator voLookup2 =
          new ims.oncology.vo.lookups.SynchronousTumourIndicator(
              instance2.getId(), instance2.getText(), instance2.isActive(), null, img, color);
      ims.oncology.vo.lookups.SynchronousTumourIndicator 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.oncology.vo.lookups.SynchronousTumourIndicator(
                parent2.getId(), parent2.getText(), parent2.isActive(), null, img, color));
        parentVoLookup2 = parentVoLookup2.getParent();
        parent2 = parent2.getParent();
      }
      valueObject.setSynchronousTumourIndicator(voLookup2);
    }
    // Histology
    valueObject.setHistology(
        ims.clinicaladmin.vo.domain.TumourHistologyLiteVoAssembler
            .createTumourHistologyLiteVoCollectionFromTumourHistology(
                map, domainObject.getHistology()));
    // VascularLymphInvasion
    ims.domain.lookups.LookupInstance instance4 = domainObject.getVascularLymphInvasion();
    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.oncology.vo.lookups.VascularLymphInvasion voLookup4 =
          new ims.oncology.vo.lookups.VascularLymphInvasion(
              instance4.getId(), instance4.getText(), instance4.isActive(), null, img, color);
      ims.oncology.vo.lookups.VascularLymphInvasion 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.oncology.vo.lookups.VascularLymphInvasion(
                parent4.getId(), parent4.getText(), parent4.isActive(), null, img, color));
        parentVoLookup4 = parentVoLookup4.getParent();
        parent4 = parent4.getParent();
      }
      valueObject.setVascularLymphInvasion(voLookup4);
    }
    // ExcisionMargin
    ims.domain.lookups.LookupInstance instance5 = domainObject.getExcisionMargin();
    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.oncology.vo.lookups.ExcisionMargin voLookup5 =
          new ims.oncology.vo.lookups.ExcisionMargin(
              instance5.getId(), instance5.getText(), instance5.isActive(), null, img, color);
      ims.oncology.vo.lookups.ExcisionMargin 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.oncology.vo.lookups.ExcisionMargin(
                parent5.getId(), parent5.getText(), parent5.isActive(), null, img, color));
        parentVoLookup5 = parentVoLookup5.getParent();
        parent5 = parent5.getParent();
      }
      valueObject.setExcisionMargin(voLookup5);
    }
    // NumberNodesExamined
    valueObject.setNumberNodesExamined(domainObject.getNumberNodesExamined());
    // NodesPositiveNumber
    valueObject.setNodesPositiveNumber(domainObject.getNodesPositiveNumber());
    // PathologicalTVal
    valueObject.setPathologicalTVal(
        ims.clinicaladmin.vo.domain.TumourGroupSiteTNMValueVoAssembler.create(
            map, domainObject.getPathologicalTVal()));
    // PathologicalNVal
    valueObject.setPathologicalNVal(
        ims.clinicaladmin.vo.domain.TumourGroupSiteTNMValueVoAssembler.create(
            map, domainObject.getPathologicalNVal()));
    // PathologicalMVal
    valueObject.setPathologicalMVal(
        ims.clinicaladmin.vo.domain.TumourGroupSiteTNMValueVoAssembler.create(
            map, domainObject.getPathologicalMVal()));
    // PathologicalOverall
    valueObject.setPathologicalOverall(
        ims.clinicaladmin.vo.domain.TumourGroupSiteOverallStagingVoAssembler.create(
            map, domainObject.getPathologicalOverall()));
    // ServiceReportId
    valueObject.setServiceReportId(domainObject.getServiceReportId());
    // ServiceReportStatus
    ims.domain.lookups.LookupInstance instance13 = domainObject.getServiceReportStatus();
    if (null != instance13) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance13.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance13.getImage().getImageId(), instance13.getImage().getImagePath());
      }
      color = instance13.getColor();
      if (color != null) color.getValue();

      ims.oncology.vo.lookups.ServiceReportStatus voLookup13 =
          new ims.oncology.vo.lookups.ServiceReportStatus(
              instance13.getId(), instance13.getText(), instance13.isActive(), null, img, color);
      ims.oncology.vo.lookups.ServiceReportStatus parentVoLookup13 = voLookup13;
      ims.domain.lookups.LookupInstance parent13 = instance13.getParent();
      while (parent13 != null) {
        if (parent13.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent13.getImage().getImageId(), parent13.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent13.getColor();
        if (color != null) color.getValue();
        parentVoLookup13.setParent(
            new ims.oncology.vo.lookups.ServiceReportStatus(
                parent13.getId(), parent13.getText(), parent13.isActive(), null, img, color));
        parentVoLookup13 = parentVoLookup13.getParent();
        parent13 = parent13.getParent();
      }
      valueObject.setServiceReportStatus(voLookup13);
    }
    // SpecimenNature
    ims.domain.lookups.LookupInstance instance14 = domainObject.getSpecimenNature();
    if (null != instance14) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance14.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance14.getImage().getImageId(), instance14.getImage().getImagePath());
      }
      color = instance14.getColor();
      if (color != null) color.getValue();

      ims.oncology.vo.lookups.SpecimenNature voLookup14 =
          new ims.oncology.vo.lookups.SpecimenNature(
              instance14.getId(), instance14.getText(), instance14.isActive(), null, img, color);
      ims.oncology.vo.lookups.SpecimenNature parentVoLookup14 = voLookup14;
      ims.domain.lookups.LookupInstance parent14 = instance14.getParent();
      while (parent14 != null) {
        if (parent14.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent14.getImage().getImageId(), parent14.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent14.getColor();
        if (color != null) color.getValue();
        parentVoLookup14.setParent(
            new ims.oncology.vo.lookups.SpecimenNature(
                parent14.getId(), parent14.getText(), parent14.isActive(), null, img, color));
        parentVoLookup14 = parentVoLookup14.getParent();
        parent14 = parent14.getParent();
      }
      valueObject.setSpecimenNature(voLookup14);
    }
    // OrgaCodeRequester
    valueObject.setOrgaCodeRequester(
        ims.core.vo.domain.OrgLiteVoAssembler.create(map, domainObject.getOrgaCodeRequester()));
    // CareProfCodeRequester
    valueObject.setCareProfCodeRequester(
        (ims.core.vo.HcpLiteVo)
            ims.core.vo.domain.HcpLiteVoAssembler.create(
                map, domainObject.getCareProfCodeRequester()));
    // TCategoryExtended
    valueObject.setTCategoryExtended(
        ims.clinicaladmin.vo.domain.TumourGroupSiteTNMValueVoAssembler
            .createTumourGroupSiteTNMValueVoCollectionFromTumourGroupSiteTNMValue(
                map, domainObject.getTCategoryExtended()));
    // MCategoryExtended
    valueObject.setMCategoryExtended(
        ims.clinicaladmin.vo.domain.TumourGroupSiteTNMValueVoAssembler
            .createTumourGroupSiteTNMValueVoCollectionFromTumourGroupSiteTNMValue(
                map, domainObject.getMCategoryExtended()));
    // Status
    ims.domain.lookups.LookupInstance instance19 = domainObject.getStatus();
    if (null != instance19) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance19.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance19.getImage().getImageId(), instance19.getImage().getImagePath());
      }
      color = instance19.getColor();
      if (color != null) color.getValue();

      ims.oncology.vo.lookups.HistopathologyReportStatus voLookup19 =
          new ims.oncology.vo.lookups.HistopathologyReportStatus(
              instance19.getId(), instance19.getText(), instance19.isActive(), null, img, color);
      ims.oncology.vo.lookups.HistopathologyReportStatus parentVoLookup19 = voLookup19;
      ims.domain.lookups.LookupInstance parent19 = instance19.getParent();
      while (parent19 != null) {
        if (parent19.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent19.getImage().getImageId(), parent19.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent19.getColor();
        if (color != null) color.getValue();
        parentVoLookup19.setParent(
            new ims.oncology.vo.lookups.HistopathologyReportStatus(
                parent19.getId(), parent19.getText(), parent19.isActive(), null, img, color));
        parentVoLookup19 = parentVoLookup19.getParent();
        parent19 = parent19.getParent();
      }
      valueObject.setStatus(voLookup19);
    }
    // AuthoringInformation
    valueObject.setAuthoringInformation(
        ims.core.vo.domain.AuthoringInformationVoAssembler.create(
            map, domainObject.getAuthoringInformation()));
    // AssociatedQuestions
    valueObject.setAssociatedQuestions(
        ims.assessment.vo.domain.PatientAssessmentVoAssembler.create(
            map, domainObject.getAssociatedQuestions()));
    // AssociatiatedTumourDetails
    valueObject.setAssociatiatedTumourDetails(
        ims.oncology.vo.domain.PrimaryTumourDetailsShortVoAssembler.create(
            map, domainObject.getAssociatiatedTumourDetails()));
    // GradeOfDifferentation
    valueObject.setGradeOfDifferentation(
        ims.clinicaladmin.vo.domain.TumourGroupHistopathologyGradeVoAssembler.create(
            map, domainObject.getGradeOfDifferentation()));
    // InvestigationType
    ims.domain.lookups.LookupInstance instance24 = domainObject.getInvestigationType();
    if (null != instance24) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance24.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance24.getImage().getImageId(), instance24.getImage().getImagePath());
      }
      color = instance24.getColor();
      if (color != null) color.getValue();

      ims.oncology.vo.lookups.InvestigationType voLookup24 =
          new ims.oncology.vo.lookups.InvestigationType(
              instance24.getId(), instance24.getText(), instance24.isActive(), null, img, color);
      ims.oncology.vo.lookups.InvestigationType parentVoLookup24 = voLookup24;
      ims.domain.lookups.LookupInstance parent24 = instance24.getParent();
      while (parent24 != null) {
        if (parent24.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent24.getImage().getImageId(), parent24.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent24.getColor();
        if (color != null) color.getValue();
        parentVoLookup24.setParent(
            new ims.oncology.vo.lookups.InvestigationType(
                parent24.getId(), parent24.getText(), parent24.isActive(), null, img, color));
        parentVoLookup24 = parentVoLookup24.getParent();
        parent24 = parent24.getParent();
      }
      valueObject.setInvestigationType(voLookup24);
    }
    // SampleReceiptDate
    java.util.Date SampleReceiptDate = domainObject.getSampleReceiptDate();
    if (null != SampleReceiptDate) {
      valueObject.setSampleReceiptDate(new ims.framework.utils.Date(SampleReceiptDate));
    }
    // InvestigationResultDate
    java.util.Date InvestigationResultDate = domainObject.getInvestigationResultDate();
    if (null != InvestigationResultDate) {
      valueObject.setInvestigationResultDate(new ims.framework.utils.Date(InvestigationResultDate));
    }
    // ReportingConsultantCode
    valueObject.setReportingConsultantCode(
        (ims.core.vo.HcpLiteVo)
            ims.core.vo.domain.HcpLiteVoAssembler.create(
                map, domainObject.getReportingConsultantCode()));
    // ReportingOrganisation
    valueObject.setReportingOrganisation(
        ims.core.vo.domain.OrgLiteVoAssembler.create(map, domainObject.getReportingOrganisation()));
    // 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()));
      }
    }
    // PreviousVersion
    if (domainObject.getPreviousVersion() != null) {
      if (domainObject.getPreviousVersion()
          instanceof
          HibernateProxy) // If the proxy is set, there is no need to lazy load, the proxy knows the
                          // id already.
      {
        HibernateProxy p = (HibernateProxy) domainObject.getPreviousVersion();
        int id = Integer.parseInt(p.getHibernateLazyInitializer().getIdentifier().toString());
        valueObject.setPreviousVersion(new ims.oncology.vo.PathologyDetailsRefVo(id, -1));
      } else {
        valueObject.setPreviousVersion(
            new ims.oncology.vo.PathologyDetailsRefVo(
                domainObject.getPreviousVersion().getId(),
                domainObject.getPreviousVersion().getVersion()));
      }
    }
    return valueObject;
  }