public static ims.oncology.domain.objects.PathologyDetails extractPathologyDetails(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.clinicaladmin.vo.PathologyDetailsVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_PathologyDetails();
    ims.oncology.domain.objects.PathologyDetails domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.oncology.domain.objects.PathologyDetails) domMap.get(valueObject);
      }
      // ims.clinicaladmin.vo.PathologyDetailsVo ID_PathologyDetails field is unknown
      domainObject = new ims.oncology.domain.objects.PathologyDetails();
      domMap.put(valueObject, domainObject);
    } else {
      String key = (valueObject.getClass().getName() + "__" + valueObject.getID_PathologyDetails());
      if (domMap.get(key) != null) {
        return (ims.oncology.domain.objects.PathologyDetails) domMap.get(key);
      }
      domainObject =
          (ims.oncology.domain.objects.PathologyDetails)
              domainFactory.getDomainObject(ims.oncology.domain.objects.PathologyDetails.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_PathologyDetails());

    domainObject.setInvasiveLesionSize(valueObject.getInvasiveLesionSize());
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value2 = null;
    if (null != valueObject.getSynchronousTumourIndicator()) {
      value2 = domainFactory.getLookupInstance(valueObject.getSynchronousTumourIndicator().getID());
    }
    domainObject.setSynchronousTumourIndicator(value2);
    domainObject.setHistology(
        ims.clinicaladmin.vo.domain.TumourHistologyLiteVoAssembler.extractTumourHistologySet(
            domainFactory, valueObject.getHistology(), domainObject.getHistology(), domMap));
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value4 = null;
    if (null != valueObject.getVascularLymphInvasion()) {
      value4 = domainFactory.getLookupInstance(valueObject.getVascularLymphInvasion().getID());
    }
    domainObject.setVascularLymphInvasion(value4);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value5 = null;
    if (null != valueObject.getExcisionMargin()) {
      value5 = domainFactory.getLookupInstance(valueObject.getExcisionMargin().getID());
    }
    domainObject.setExcisionMargin(value5);
    domainObject.setNumberNodesExamined(valueObject.getNumberNodesExamined());
    domainObject.setNodesPositiveNumber(valueObject.getNodesPositiveNumber());
    domainObject.setPathologicalTVal(
        ims.clinicaladmin.vo.domain.TumourGroupSiteTNMValueVoAssembler
            .extractTumourGroupSiteTNMValue(
                domainFactory, valueObject.getPathologicalTVal(), domMap));
    domainObject.setPathologicalNVal(
        ims.clinicaladmin.vo.domain.TumourGroupSiteTNMValueVoAssembler
            .extractTumourGroupSiteTNMValue(
                domainFactory, valueObject.getPathologicalNVal(), domMap));
    domainObject.setPathologicalMVal(
        ims.clinicaladmin.vo.domain.TumourGroupSiteTNMValueVoAssembler
            .extractTumourGroupSiteTNMValue(
                domainFactory, valueObject.getPathologicalMVal(), domMap));
    domainObject.setPathologicalOverall(
        ims.clinicaladmin.vo.domain.TumourGroupSiteOverallStagingVoAssembler
            .extractTumourGroupSiteOverallStaging(
                domainFactory, valueObject.getPathologicalOverall(), domMap));
    // 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.getServiceReportId() != null && valueObject.getServiceReportId().equals("")) {
      valueObject.setServiceReportId(null);
    }
    domainObject.setServiceReportId(valueObject.getServiceReportId());
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value13 = null;
    if (null != valueObject.getServiceReportStatus()) {
      value13 = domainFactory.getLookupInstance(valueObject.getServiceReportStatus().getID());
    }
    domainObject.setServiceReportStatus(value13);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value14 = null;
    if (null != valueObject.getSpecimenNature()) {
      value14 = domainFactory.getLookupInstance(valueObject.getSpecimenNature().getID());
    }
    domainObject.setSpecimenNature(value14);
    domainObject.setOrgaCodeRequester(
        ims.core.vo.domain.OrgLiteVoAssembler.extractOrganisation(
            domainFactory, valueObject.getOrgaCodeRequester(), domMap));
    domainObject.setCareProfCodeRequester(
        ims.core.vo.domain.HcpLiteVoAssembler.extractHcp(
            domainFactory, (ims.core.vo.HcpLiteVo) valueObject.getCareProfCodeRequester(), domMap));
    domainObject.setTCategoryExtended(
        ims.clinicaladmin.vo.domain.TumourGroupSiteTNMValueVoAssembler
            .extractTumourGroupSiteTNMValueSet(
                domainFactory,
                valueObject.getTCategoryExtended(),
                domainObject.getTCategoryExtended(),
                domMap));
    domainObject.setMCategoryExtended(
        ims.clinicaladmin.vo.domain.TumourGroupSiteTNMValueVoAssembler
            .extractTumourGroupSiteTNMValueSet(
                domainFactory,
                valueObject.getMCategoryExtended(),
                domainObject.getMCategoryExtended(),
                domMap));
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value19 = null;
    if (null != valueObject.getStatus()) {
      value19 = domainFactory.getLookupInstance(valueObject.getStatus().getID());
    }
    domainObject.setStatus(value19);
    domainObject.setAuthoringInformation(
        ims.core.vo.domain.AuthoringInformationVoAssembler.extractAuthoringInformation(
            domainFactory, valueObject.getAuthoringInformation(), domMap));
    domainObject.setAssociatedQuestions(
        ims.assessment.vo.domain.PatientAssessmentVoAssembler.extractPatientAssessment(
            domainFactory, valueObject.getAssociatedQuestions(), domMap));
    domainObject.setAssociatiatedTumourDetails(
        ims.oncology.vo.domain.PrimaryTumourDetailsShortVoAssembler.extractPrimaryTumourDetails(
            domainFactory, valueObject.getAssociatiatedTumourDetails(), domMap));
    domainObject.setGradeOfDifferentation(
        ims.clinicaladmin.vo.domain.TumourGroupHistopathologyGradeVoAssembler
            .extractTumourGroupHistopathologicGrade(
                domainFactory, valueObject.getGradeOfDifferentation(), domMap));
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value24 = null;
    if (null != valueObject.getInvestigationType()) {
      value24 = domainFactory.getLookupInstance(valueObject.getInvestigationType().getID());
    }
    domainObject.setInvestigationType(value24);
    java.util.Date value25 = null;
    ims.framework.utils.Date date25 = valueObject.getSampleReceiptDate();
    if (date25 != null) {
      value25 = date25.getDate();
    }
    domainObject.setSampleReceiptDate(value25);
    java.util.Date value26 = null;
    ims.framework.utils.Date date26 = valueObject.getInvestigationResultDate();
    if (date26 != null) {
      value26 = date26.getDate();
    }
    domainObject.setInvestigationResultDate(value26);
    domainObject.setReportingConsultantCode(
        ims.core.vo.domain.HcpLiteVoAssembler.extractHcp(
            domainFactory,
            (ims.core.vo.HcpLiteVo) valueObject.getReportingConsultantCode(),
            domMap));
    domainObject.setReportingOrganisation(
        ims.core.vo.domain.OrgLiteVoAssembler.extractOrganisation(
            domainFactory, valueObject.getReportingOrganisation(), domMap));
    ims.core.admin.domain.objects.CareContext value29 = null;
    if (null != valueObject.getCareContext()) {
      if (valueObject.getCareContext().getBoId() == null) {
        if (domMap.get(valueObject.getCareContext()) != null) {
          value29 =
              (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
      {
        value29 = domainObject.getCareContext();
      } else {
        value29 =
            (ims.core.admin.domain.objects.CareContext)
                domainFactory.getDomainObject(
                    ims.core.admin.domain.objects.CareContext.class,
                    valueObject.getCareContext().getBoId());
      }
    }
    domainObject.setCareContext(value29);
    ims.oncology.domain.objects.PathologyDetails value30 = null;
    if (null != valueObject.getPreviousVersion()) {
      if (valueObject.getPreviousVersion().getBoId() == null) {
        if (domMap.get(valueObject.getPreviousVersion()) != null) {
          value30 =
              (ims.oncology.domain.objects.PathologyDetails)
                  domMap.get(valueObject.getPreviousVersion());
        }
      } else if (valueObject.getBoVersion()
          == -1) // RefVo was not modified since obtained from the Assembler, no need to update the
                 // BO field
      {
        value30 = domainObject.getPreviousVersion();
      } else {
        value30 =
            (ims.oncology.domain.objects.PathologyDetails)
                domainFactory.getDomainObject(
                    ims.oncology.domain.objects.PathologyDetails.class,
                    valueObject.getPreviousVersion().getBoId());
      }
    }
    domainObject.setPreviousVersion(value30);

    return domainObject;
  }
 /**
  * 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;
 }