/**
   * Update the ValueObject with the Domain Object.
   *
   * @param map DomainObjectMap of DomainObjects to already created ValueObjects.
   * @param valueObject to be updated
   * @param domainObject ims.clinical.domain.objects.PerfProcAndSignOutIntraOp
   */
  public static ims.clinical.vo.PerformedProcAndSignOutIntraOpVo insert(
      DomainObjectMap map,
      ims.clinical.vo.PerformedProcAndSignOutIntraOpVo valueObject,
      ims.clinical.domain.objects.PerfProcAndSignOutIntraOp domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

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

    // TheatreAppointment
    if (domainObject.getTheatreAppointment() != null) {
      if (domainObject.getTheatreAppointment()
          instanceof
          HibernateProxy) // If the proxy is set, there is no need to lazy load, the proxy knows the
                          // id already.
      {
        HibernateProxy p = (HibernateProxy) domainObject.getTheatreAppointment();
        int id = Integer.parseInt(p.getHibernateLazyInitializer().getIdentifier().toString());
        valueObject.setTheatreAppointment(new ims.scheduling.vo.Booking_AppointmentRefVo(id, -1));
      } else {
        valueObject.setTheatreAppointment(
            new ims.scheduling.vo.Booking_AppointmentRefVo(
                domainObject.getTheatreAppointment().getId(),
                domainObject.getTheatreAppointment().getVersion()));
      }
    }
    // Unplannedreturntotheatre
    valueObject.setUnplannedreturntotheatre(domainObject.isUnplannedreturntotheatre());
    // ConfirmedCountsComplete
    valueObject.setConfirmedCountsComplete(domainObject.isConfirmedCountsComplete());
    // AntibioticsAfterKnifeToSkin
    ims.domain.lookups.LookupInstance instance4 = domainObject.getAntibioticsAfterKnifeToSkin();
    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.YesNoNotApplicable voLookup4 =
          new ims.core.vo.lookups.YesNoNotApplicable(
              instance4.getId(), instance4.getText(), instance4.isActive(), null, img, color);
      ims.core.vo.lookups.YesNoNotApplicable 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.YesNoNotApplicable(
                parent4.getId(), parent4.getText(), parent4.isActive(), null, img, color));
        parentVoLookup4 = parentVoLookup4.getParent();
        parent4 = parent4.getParent();
      }
      valueObject.setAntibioticsAfterKnifeToSkin(voLookup4);
    }
    // TimeIntraOpAntibioticsGiven
    java.util.Date TimeIntraOpAntibioticsGiven = domainObject.getTimeIntraOpAntibioticsGiven();
    if (null != TimeIntraOpAntibioticsGiven) {
      valueObject.setTimeIntraOpAntibioticsGiven(
          new ims.framework.utils.DateTime(TimeIntraOpAntibioticsGiven));
    }
    // AdministrationRecordCompleted
    valueObject.setAdministrationRecordCompleted(domainObject.isAdministrationRecordCompleted());
    // AnySpecimensHaveBeenLabelled
    valueObject.setAnySpecimensHaveBeenLabelled(domainObject.isAnySpecimensHaveBeenLabelled());
    // AnyEquipmentProblemsAddressed
    ims.domain.lookups.LookupInstance instance8 = domainObject.getAnyEquipmentProblemsAddressed();
    if (null != instance8) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance8.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance8.getImage().getImageId(), instance8.getImage().getImagePath());
      }
      color = instance8.getColor();
      if (color != null) color.getValue();

      ims.core.vo.lookups.YesNoNotApplicable voLookup8 =
          new ims.core.vo.lookups.YesNoNotApplicable(
              instance8.getId(), instance8.getText(), instance8.isActive(), null, img, color);
      ims.core.vo.lookups.YesNoNotApplicable parentVoLookup8 = voLookup8;
      ims.domain.lookups.LookupInstance parent8 = instance8.getParent();
      while (parent8 != null) {
        if (parent8.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent8.getImage().getImageId(), parent8.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent8.getColor();
        if (color != null) color.getValue();
        parentVoLookup8.setParent(
            new ims.core.vo.lookups.YesNoNotApplicable(
                parent8.getId(), parent8.getText(), parent8.isActive(), null, img, color));
        parentVoLookup8 = parentVoLookup8.getParent();
        parent8 = parent8.getParent();
      }
      valueObject.setAnyEquipmentProblemsAddressed(voLookup8);
    }
    // KeyConcernsDocumented
    valueObject.setKeyConcernsDocumented(domainObject.isKeyConcernsDocumented());
    // SignatureByRegisteredPractitioner
    valueObject.setSignatureByRegisteredPractitioner(
        ims.core.vo.domain.HcpLiteVoAssembler.create(
            map, domainObject.getSignatureByRegisteredPractitioner()));
    return valueObject;
  }