public static ims.core.clinical.domain.objects.IntraOperativeCareRecord
      extractIntraOperativeCareRecord(
          ims.domain.ILightweightDomainFactory domainFactory,
          ims.clinical.vo.IntraOperativeCareRecordShortVo valueObject,
          HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_IntraOperativeCareRecord();
    ims.core.clinical.domain.objects.IntraOperativeCareRecord domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.core.clinical.domain.objects.IntraOperativeCareRecord) domMap.get(valueObject);
      }
      // ims.clinical.vo.IntraOperativeCareRecordShortVo ID_IntraOperativeCareRecord field is
      // unknown
      domainObject = new ims.core.clinical.domain.objects.IntraOperativeCareRecord();
      domMap.put(valueObject, domainObject);
    } else {
      String key =
          (valueObject.getClass().getName() + "__" + valueObject.getID_IntraOperativeCareRecord());
      if (domMap.get(key) != null) {
        return (ims.core.clinical.domain.objects.IntraOperativeCareRecord) domMap.get(key);
      }
      domainObject =
          (ims.core.clinical.domain.objects.IntraOperativeCareRecord)
              domainFactory.getDomainObject(
                  ims.core.clinical.domain.objects.IntraOperativeCareRecord.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_IntraOperativeCareRecord());

    // SaveAsRefVO - treated as a refVo in extract methods
    ims.core.clinical.domain.objects.IntraOperativeDetails value1 = null;
    if (null != valueObject.getIntraOperativeDetails()) {
      if (valueObject.getIntraOperativeDetails().getBoId() == null) {
        if (domMap.get(valueObject.getIntraOperativeDetails()) != null) {
          value1 =
              (ims.core.clinical.domain.objects.IntraOperativeDetails)
                  domMap.get(valueObject.getIntraOperativeDetails());
        }
      } else {
        value1 =
            (ims.core.clinical.domain.objects.IntraOperativeDetails)
                domainFactory.getDomainObject(
                    ims.core.clinical.domain.objects.IntraOperativeDetails.class,
                    valueObject.getIntraOperativeDetails().getBoId());
      }
    }
    domainObject.setIntraOperativeDetails(value1);
    ims.core.admin.domain.objects.CareContext value2 = null;
    if (null != valueObject.getCareContext()) {
      if (valueObject.getCareContext().getBoId() == null) {
        if (domMap.get(valueObject.getCareContext()) != null) {
          value2 =
              (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
      {
        value2 = domainObject.getCareContext();
      } else {
        value2 =
            (ims.core.admin.domain.objects.CareContext)
                domainFactory.getDomainObject(
                    ims.core.admin.domain.objects.CareContext.class,
                    valueObject.getCareContext().getBoId());
      }
    }
    domainObject.setCareContext(value2);
    // SaveAsRefVO - treated as a refVo in extract methods
    ims.core.clinical.domain.objects.PatientProcedure value3 = null;
    if (null != valueObject.getActualProcedure()) {
      if (valueObject.getActualProcedure().getBoId() == null) {
        if (domMap.get(valueObject.getActualProcedure()) != null) {
          value3 =
              (ims.core.clinical.domain.objects.PatientProcedure)
                  domMap.get(valueObject.getActualProcedure());
        }
      } else {
        value3 =
            (ims.core.clinical.domain.objects.PatientProcedure)
                domainFactory.getDomainObject(
                    ims.core.clinical.domain.objects.PatientProcedure.class,
                    valueObject.getActualProcedure().getBoId());
      }
    }
    domainObject.setActualProcedure(value3);
    java.util.Date value4 = null;
    ims.framework.utils.Date date4 = valueObject.getProcedureDate();
    if (date4 != null) {
      value4 = date4.getDate();
    }
    domainObject.setProcedureDate(value4);
    // SaveAsRefVO - treated as a refVo in extract methods
    ims.core.resource.place.domain.objects.Location value5 = null;
    if (null != valueObject.getTheatre()) {
      if (valueObject.getTheatre().getBoId() == null) {
        if (domMap.get(valueObject.getTheatre()) != null) {
          value5 =
              (ims.core.resource.place.domain.objects.Location)
                  domMap.get(valueObject.getTheatre());
        }
      } else {
        value5 =
            (ims.core.resource.place.domain.objects.Location)
                domainFactory.getDomainObject(
                    ims.core.resource.place.domain.objects.Location.class,
                    valueObject.getTheatre().getBoId());
      }
    }
    domainObject.setTheatre(value5);
    // SaveAsRefVO - treated as a refVo in extract methods
    ims.core.resource.people.domain.objects.Hcp value6 = null;
    if (null != valueObject.getSurgeon()) {
      if (valueObject.getSurgeon().getBoId() == null) {
        if (domMap.get(valueObject.getSurgeon()) != null) {
          value6 =
              (ims.core.resource.people.domain.objects.Hcp) domMap.get(valueObject.getSurgeon());
        }
      } else {
        value6 =
            (ims.core.resource.people.domain.objects.Hcp)
                domainFactory.getDomainObject(
                    ims.core.resource.people.domain.objects.Hcp.class,
                    valueObject.getSurgeon().getBoId());
      }
    }
    domainObject.setSurgeon(value6);

    return domainObject;
  }
 /**
  * Copy one ValueObject to another
  *
  * @param valueObjectDest to be updated
  * @param valueObjectSrc to copy values from
  */
 public static ims.clinical.vo.IntraOperativeCareRecordShortVo copy(
     ims.clinical.vo.IntraOperativeCareRecordShortVo valueObjectDest,
     ims.clinical.vo.IntraOperativeCareRecordShortVo valueObjectSrc) {
   if (null == valueObjectSrc) {
     return valueObjectSrc;
   }
   valueObjectDest.setID_IntraOperativeCareRecord(valueObjectSrc.getID_IntraOperativeCareRecord());
   valueObjectDest.setIsRIE(valueObjectSrc.getIsRIE());
   // IntraOperativeDetails
   valueObjectDest.setIntraOperativeDetails(valueObjectSrc.getIntraOperativeDetails());
   // CareContext
   valueObjectDest.setCareContext(valueObjectSrc.getCareContext());
   // ActualProcedure
   valueObjectDest.setActualProcedure(valueObjectSrc.getActualProcedure());
   // ProcedureDate
   valueObjectDest.setProcedureDate(valueObjectSrc.getProcedureDate());
   // Theatre
   valueObjectDest.setTheatre(valueObjectSrc.getTheatre());
   // Surgeon
   valueObjectDest.setSurgeon(valueObjectSrc.getSurgeon());
   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.IntraOperativeCareRecord
   */
  public static ims.clinical.vo.IntraOperativeCareRecordShortVo insert(
      DomainObjectMap map,
      ims.clinical.vo.IntraOperativeCareRecordShortVo valueObject,
      ims.core.clinical.domain.objects.IntraOperativeCareRecord domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

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

    // IntraOperativeDetails
    valueObject.setIntraOperativeDetails(
        ims.clinical.vo.domain.IntraOperativeDetailsLiteVoAssembler.create(
            map, domainObject.getIntraOperativeDetails()));
    // 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()));
      }
    }
    // ActualProcedure
    valueObject.setActualProcedure(
        ims.core.vo.domain.PatientProcedureForSurgicalOperationNotesVoAssembler.create(
            map, domainObject.getActualProcedure()));
    // ProcedureDate
    java.util.Date ProcedureDate = domainObject.getProcedureDate();
    if (null != ProcedureDate) {
      valueObject.setProcedureDate(new ims.framework.utils.Date(ProcedureDate));
    }
    // Theatre
    valueObject.setTheatre(
        ims.core.vo.domain.LocationLiteVoAssembler.create(map, domainObject.getTheatre()));
    // Surgeon
    valueObject.setSurgeon(
        ims.core.vo.domain.HcpLiteVoAssembler.create(map, domainObject.getSurgeon()));
    return valueObject;
  }