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

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

    // AppointmentDate
    java.util.Date AppointmentDate = domainObject.getAppointmentDate();
    if (null != AppointmentDate) {
      valueObject.setAppointmentDate(new ims.framework.utils.Date(AppointmentDate));
    }
    // ApptStartTime
    String ApptStartTime = domainObject.getApptStartTime();
    if (null != ApptStartTime) {
      valueObject.setApptStartTime(new ims.framework.utils.Time(ApptStartTime));
    }
    // Session
    valueObject.setSession(
        ims.scheduling.vo.domain.SessionForClinicNameVoAssembler.create(
            map, domainObject.getSession()));
    // RTTClockImpact
    if (domainObject.getRTTClockImpact() != null) {
      if (domainObject.getRTTClockImpact()
          instanceof
          HibernateProxy) // If the proxy is set, there is no need to lazy load, the proxy knows the
                          // id already.
      {
        HibernateProxy p = (HibernateProxy) domainObject.getRTTClockImpact();
        int id = Integer.parseInt(p.getHibernateLazyInitializer().getIdentifier().toString());
        valueObject.setRTTClockImpact(new ims.pathways.vo.PathwaysRTTClockImpactRefVo(id, -1));
      } else {
        valueObject.setRTTClockImpact(
            new ims.pathways.vo.PathwaysRTTClockImpactRefVo(
                domainObject.getRTTClockImpact().getId(),
                domainObject.getRTTClockImpact().getVersion()));
      }
    }
    return valueObject;
  }
  /**
   * Create the ValueObject from the ims.scheduling.domain.objects.Booking_Appointment object.
   *
   * @param map DomainObjectMap of DomainObjects to already created ValueObjects.
   * @param domainObject
   */
  public static ims.scheduling.vo.AppointmentOutcomeDetailsVo create(
      DomainObjectMap map, ims.scheduling.domain.objects.Booking_Appointment domainObject) {
    if (null == domainObject) {
      return null;
    }
    // check if the domainObject already has a valueObject created for it
    ims.scheduling.vo.AppointmentOutcomeDetailsVo valueObject =
        (ims.scheduling.vo.AppointmentOutcomeDetailsVo)
            map.getValueObject(domainObject, ims.scheduling.vo.AppointmentOutcomeDetailsVo.class);
    if (null == valueObject) {
      valueObject =
          new ims.scheduling.vo.AppointmentOutcomeDetailsVo(
              domainObject.getId(), domainObject.getVersion());
      map.addValueObject(domainObject, valueObject);

      valueObject = insert(map, valueObject, domainObject);
    }
    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.icps.instantiation.domain.objects.PatientICP
   */
  public static ims.icp.vo.PatientICPVo insert(
      DomainObjectMap map,
      ims.icp.vo.PatientICPVo valueObject,
      ims.icps.instantiation.domain.objects.PatientICP domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

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

    // Patient
    if (domainObject.getPatient() != null) {
      if (domainObject.getPatient()
          instanceof
          HibernateProxy) // If the proxy is set, there is no need to lazy load, the proxy knows the
                          // id already.
      {
        HibernateProxy p = (HibernateProxy) domainObject.getPatient();
        int id = Integer.parseInt(p.getHibernateLazyInitializer().getIdentifier().toString());
        valueObject.setPatient(new ims.core.patient.vo.PatientRefVo(id, -1));
      } else {
        valueObject.setPatient(
            new ims.core.patient.vo.PatientRefVo(
                domainObject.getPatient().getId(), domainObject.getPatient().getVersion()));
      }
    }
    // 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()));
      }
    }
    // 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()));
      }
    }
    // PasEvent
    if (domainObject.getPasEvent() != null) {
      if (domainObject.getPasEvent()
          instanceof
          HibernateProxy) // If the proxy is set, there is no need to lazy load, the proxy knows the
                          // id already.
      {
        HibernateProxy p = (HibernateProxy) domainObject.getPasEvent();
        int id = Integer.parseInt(p.getHibernateLazyInitializer().getIdentifier().toString());
        valueObject.setPasEvent(new ims.core.admin.pas.vo.PASEventRefVo(id, -1));
      } else {
        valueObject.setPasEvent(
            new ims.core.admin.pas.vo.PASEventRefVo(
                domainObject.getPasEvent().getId(), domainObject.getPasEvent().getVersion()));
      }
    }
    // ICP
    valueObject.setICP(ims.icp.vo.domain.ICPLiteVoAssembler.create(map, domainObject.getICP()));
    // AuthoringInformation
    valueObject.setAuthoringInformation(
        ims.core.vo.domain.AuthoringInformationVoAssembler.create(
            map, domainObject.getAuthoringInformation()));
    // Stages
    valueObject.setStages(
        ims.icp.vo.domain.PatientICPStageVoAssembler
            .createPatientICPStageVoCollectionFromPatientICPStage(map, domainObject.getStages()));
    // hasOutstandingAdminActions
    valueObject.setHasOutstandingAdminActions(domainObject.isHasOutstandingAdminActions());
    // hasOutstandingNursingActions
    valueObject.setHasOutstandingNursingActions(domainObject.isHasOutstandingNursingActions());
    // hasOutstandingPhysioActions
    valueObject.setHasOutstandingPhysioActions(domainObject.isHasOutstandingPhysioActions());
    // hasOutstandingClinicalActions
    valueObject.setHasOutstandingClinicalActions(domainObject.isHasOutstandingClinicalActions());
    // Appointments
    ims.scheduling.vo.Booking_AppointmentRefVoCollection Appointments =
        new ims.scheduling.vo.Booking_AppointmentRefVoCollection();
    for (java.util.Iterator iterator = domainObject.getAppointments().iterator();
        iterator.hasNext(); ) {
      ims.scheduling.domain.objects.Booking_Appointment tmp =
          (ims.scheduling.domain.objects.Booking_Appointment) iterator.next();
      if (tmp != null)
        Appointments.add(
            new ims.scheduling.vo.Booking_AppointmentRefVo(tmp.getId(), tmp.getVersion()));
    }
    valueObject.setAppointments(Appointments);
    // CriticalEvents
    ims.icps.instantiation.vo.PatientCriticalEventsRefVoCollection CriticalEvents =
        new ims.icps.instantiation.vo.PatientCriticalEventsRefVoCollection();
    for (java.util.Iterator iterator = domainObject.getCriticalEvents().iterator();
        iterator.hasNext(); ) {
      ims.icps.instantiation.domain.objects.PatientCriticalEvents tmp =
          (ims.icps.instantiation.domain.objects.PatientCriticalEvents) iterator.next();
      if (tmp != null)
        CriticalEvents.add(
            new ims.icps.instantiation.vo.PatientCriticalEventsRefVo(
                tmp.getId(), tmp.getVersion()));
    }
    valueObject.setCriticalEvents(CriticalEvents);
    // StartedDateTime
    java.util.Date StartedDateTime = domainObject.getStartedDateTime();
    if (null != StartedDateTime) {
      valueObject.setStartedDateTime(new ims.framework.utils.DateTime(StartedDateTime));
    }
    // CompletedDateTime
    java.util.Date CompletedDateTime = domainObject.getCompletedDateTime();
    if (null != CompletedDateTime) {
      valueObject.setCompletedDateTime(new ims.framework.utils.DateTime(CompletedDateTime));
    }
    // EvaluationNotes
    ims.icps.instantiation.vo.PatientICPEvaluationNoteRefVoCollection EvaluationNotes =
        new ims.icps.instantiation.vo.PatientICPEvaluationNoteRefVoCollection();
    for (java.util.Iterator iterator = domainObject.getEvaluationNotes().iterator();
        iterator.hasNext(); ) {
      ims.icps.instantiation.domain.objects.PatientICPEvaluationNote tmp =
          (ims.icps.instantiation.domain.objects.PatientICPEvaluationNote) iterator.next();
      if (tmp != null)
        EvaluationNotes.add(
            new ims.icps.instantiation.vo.PatientICPEvaluationNoteRefVo(
                tmp.getId(), tmp.getVersion()));
    }
    valueObject.setEvaluationNotes(EvaluationNotes);
    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.scheduling.domain.objects.Booking_Appointment
   */
  public static ims.scheduling.vo.AppointmentForOutpatientClinicListManualCustomClassVo insert(
      DomainObjectMap map,
      ims.scheduling.vo.AppointmentForOutpatientClinicListManualCustomClassVo valueObject,
      ims.scheduling.domain.objects.Booking_Appointment domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

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

    // AppointmentDate
    java.util.Date AppointmentDate = domainObject.getAppointmentDate();
    if (null != AppointmentDate) {
      valueObject.setAppointmentDate(new ims.framework.utils.Date(AppointmentDate));
    }
    // ApptStartTime
    String ApptStartTime = domainObject.getApptStartTime();
    if (null != ApptStartTime) {
      valueObject.setApptStartTime(new ims.framework.utils.Time(ApptStartTime));
    }
    // isCABBooking
    valueObject.setIsCABBooking(domainObject.isIsCABBooking());
    // Patient
    valueObject.setPatient(
        ims.core.vo.domain.PatientManuallyAssembledVoAssembler.create(
            map, domainObject.getPatient()));
    // OutcomeComments
    valueObject.setOutcomeComments(domainObject.getOutcomeComments());
    // HasElectiveList
    valueObject.setHasElectiveList(domainObject.isHasElectiveList());
    // wasPrinted
    valueObject.setWasPrinted(domainObject.isWasPrinted());
    // Comments
    valueObject.setComments(domainObject.getComments());
    // ElectiveList
    if (domainObject.getElectiveList() != null) {
      if (domainObject.getElectiveList()
          instanceof
          HibernateProxy) // If the proxy is set, there is no need to lazy load, the proxy knows the
      // id already.
      {
        HibernateProxy p = (HibernateProxy) domainObject.getElectiveList();
        int id = Integer.parseInt(p.getHibernateLazyInitializer().getIdentifier().toString());
        valueObject.setElectiveList(new ims.RefMan.vo.PatientElectiveListRefVo(id, -1));
      } else {
        valueObject.setElectiveList(
            new ims.RefMan.vo.PatientElectiveListRefVo(
                domainObject.getElectiveList().getId(),
                domainObject.getElectiveList().getVersion()));
      }
    }
    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.scheduling.domain.objects.Booking_Appointment
   */
  public static ims.RefMan.vo.BookingAppointmentForClinicalNotesVo insert(
      DomainObjectMap map,
      ims.RefMan.vo.BookingAppointmentForClinicalNotesVo valueObject,
      ims.scheduling.domain.objects.Booking_Appointment domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

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

    // AppointmentDate
    java.util.Date AppointmentDate = domainObject.getAppointmentDate();
    if (null != AppointmentDate) {
      valueObject.setAppointmentDate(new ims.framework.utils.Date(AppointmentDate));
    }
    // ApptStartTime
    String ApptStartTime = domainObject.getApptStartTime();
    if (null != ApptStartTime) {
      valueObject.setApptStartTime(new ims.framework.utils.Time(ApptStartTime));
    }
    // ApptStatus
    ims.domain.lookups.LookupInstance instance3 = domainObject.getApptStatus();
    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.scheduling.vo.lookups.Status_Reason voLookup3 =
          new ims.scheduling.vo.lookups.Status_Reason(
              instance3.getId(), instance3.getText(), instance3.isActive(), null, img, color);
      ims.scheduling.vo.lookups.Status_Reason 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.scheduling.vo.lookups.Status_Reason(
                parent3.getId(), parent3.getText(), parent3.isActive(), null, img, color));
        parentVoLookup3 = parentVoLookup3.getParent();
        parent3 = parent3.getParent();
      }
      valueObject.setApptStatus(voLookup3);
    }
    // Session
    valueObject.setSession(
        ims.RefMan.vo.domain.SessionForClinicalNotesVoAssembler.create(
            map, domainObject.getSession()));
    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.core.domain.objects.TransportBooking
   */
  public static ims.RefMan.vo.TransportBookingShortVo insert(
      DomainObjectMap map,
      ims.RefMan.vo.TransportBookingShortVo valueObject,
      ims.core.domain.objects.TransportBooking domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

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

    // Appointments
    ims.scheduling.vo.Booking_AppointmentRefVoCollection Appointments =
        new ims.scheduling.vo.Booking_AppointmentRefVoCollection();
    for (java.util.Iterator iterator = domainObject.getAppointments().iterator();
        iterator.hasNext(); ) {
      ims.scheduling.domain.objects.Booking_Appointment tmp =
          (ims.scheduling.domain.objects.Booking_Appointment) iterator.next();
      if (tmp != null)
        Appointments.add(
            new ims.scheduling.vo.Booking_AppointmentRefVo(tmp.getId(), tmp.getVersion()));
    }
    valueObject.setAppointments(Appointments);
    // DateBooked
    java.util.Date DateBooked = domainObject.getDateBooked();
    if (null != DateBooked) {
      valueObject.setDateBooked(new ims.framework.utils.Date(DateBooked));
    }
    // BookingReference
    valueObject.setBookingReference(domainObject.getBookingReference());
    // SysInfo
    // set system information
    valueObject.setSysInfo(
        ims.vo.domain.SystemInformationAssembler.create(domainObject.getSystemInformation()));
    // 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()));
      }
    }
    return valueObject;
  }