/**
   * Create the ValueObject collection to hold the set of DomainObjects.
   *
   * @param map - maps DomainObjects to created ValueObjects
   * @param domainObjectSet - Set of ims.scheduling.domain.objects.Booking_Appointment objects.
   */
  public static ims.scheduling.vo.AppointmentOutcomeDetailsVoCollection
      createAppointmentOutcomeDetailsVoCollectionFromBooking_Appointment(
          DomainObjectMap map, java.util.Set domainObjectSet) {
    ims.scheduling.vo.AppointmentOutcomeDetailsVoCollection voList =
        new ims.scheduling.vo.AppointmentOutcomeDetailsVoCollection();
    if (null == domainObjectSet) {
      return voList;
    }
    int rieCount = 0;
    int activeCount = 0;
    java.util.Iterator iterator = domainObjectSet.iterator();
    while (iterator.hasNext()) {
      ims.scheduling.domain.objects.Booking_Appointment domainObject =
          (ims.scheduling.domain.objects.Booking_Appointment) iterator.next();
      ims.scheduling.vo.AppointmentOutcomeDetailsVo vo = create(map, domainObject);

      if (vo != null) voList.add(vo);

      if (domainObject != null) {
        if (domainObject.getIsRIE() != null && domainObject.getIsRIE().booleanValue() == true)
          rieCount++;
        else activeCount++;
      }
    }
    voList.setRieCount(rieCount);
    voList.setActiveCount(activeCount);
    return voList;
  }
  /**
   * Create the ValueObject collection to hold the list of DomainObjects.
   *
   * @param map - maps DomainObjects to created ValueObjects
   * @param domainObjectList - List of ims.scheduling.domain.objects.Booking_Appointment objects.
   */
  public static ims.scheduling.vo.AppointmentOutcomeDetailsVoCollection
      createAppointmentOutcomeDetailsVoCollectionFromBooking_Appointment(
          DomainObjectMap map, java.util.List domainObjectList) {
    ims.scheduling.vo.AppointmentOutcomeDetailsVoCollection voList =
        new ims.scheduling.vo.AppointmentOutcomeDetailsVoCollection();
    if (null == domainObjectList) {
      return voList;
    }
    int rieCount = 0;
    int activeCount = 0;
    for (int i = 0; i < domainObjectList.size(); i++) {
      ims.scheduling.domain.objects.Booking_Appointment domainObject =
          (ims.scheduling.domain.objects.Booking_Appointment) domainObjectList.get(i);
      ims.scheduling.vo.AppointmentOutcomeDetailsVo vo = create(map, domainObject);

      if (vo != null) voList.add(vo);

      if (domainObject != null) {
        if (domainObject.getIsRIE() != null && domainObject.getIsRIE().booleanValue() == true)
          rieCount++;
        else activeCount++;
      }
    }

    voList.setRieCount(rieCount);
    voList.setActiveCount(activeCount);
    return voList;
  }
  /**
   * 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;
  }
  /**
   * 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;
  }