public static ims.scheduling.domain.objects.Booking_Appointment extractBooking_Appointment(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.scheduling.vo.AppointmentForOutpatientClinicListManualCustomClassVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_Booking_Appointment();
    ims.scheduling.domain.objects.Booking_Appointment domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.scheduling.domain.objects.Booking_Appointment) domMap.get(valueObject);
      }
      // ims.scheduling.vo.AppointmentForOutpatientClinicListManualCustomClassVo
      // ID_Booking_Appointment field is unknown
      domainObject = new ims.scheduling.domain.objects.Booking_Appointment();
      domMap.put(valueObject, domainObject);
    } else {
      String key =
          (valueObject.getClass().getName() + "__" + valueObject.getID_Booking_Appointment());
      if (domMap.get(key) != null) {
        return (ims.scheduling.domain.objects.Booking_Appointment) domMap.get(key);
      }
      domainObject =
          (ims.scheduling.domain.objects.Booking_Appointment)
              domainFactory.getDomainObject(
                  ims.scheduling.domain.objects.Booking_Appointment.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_Booking_Appointment());

    java.util.Date value1 = null;
    ims.framework.utils.Date date1 = valueObject.getAppointmentDate();
    if (date1 != null) {
      value1 = date1.getDate();
    }
    domainObject.setAppointmentDate(value1);
    ims.framework.utils.Time time2 = valueObject.getApptStartTime();
    String value2 = null;
    if (time2 != null) {
      value2 = time2.toString();
    }
    domainObject.setApptStartTime(value2);
    domainObject.setIsCABBooking(valueObject.getIsCABBooking());
    // SaveAsRefVO - treated as a refVo in extract methods
    ims.core.patient.domain.objects.Patient value4 = null;
    if (null != valueObject.getPatient()) {
      if (valueObject.getPatient().getBoId() == null) {
        if (domMap.get(valueObject.getPatient()) != null) {
          value4 = (ims.core.patient.domain.objects.Patient) domMap.get(valueObject.getPatient());
        }
      } else {
        value4 =
            (ims.core.patient.domain.objects.Patient)
                domainFactory.getDomainObject(
                    ims.core.patient.domain.objects.Patient.class,
                    valueObject.getPatient().getBoId());
      }
    }
    domainObject.setPatient(value4);
    // 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.getOutcomeComments() != null && valueObject.getOutcomeComments().equals("")) {
      valueObject.setOutcomeComments(null);
    }
    domainObject.setOutcomeComments(valueObject.getOutcomeComments());
    domainObject.setHasElectiveList(valueObject.getHasElectiveList());
    domainObject.setWasPrinted(valueObject.getWasPrinted());
    // 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.getComments() != null && valueObject.getComments().equals("")) {
      valueObject.setComments(null);
    }
    domainObject.setComments(valueObject.getComments());
    ims.RefMan.domain.objects.PatientElectiveList value9 = null;
    if (null != valueObject.getElectiveList()) {
      if (valueObject.getElectiveList().getBoId() == null) {
        if (domMap.get(valueObject.getElectiveList()) != null) {
          value9 =
              (ims.RefMan.domain.objects.PatientElectiveList)
                  domMap.get(valueObject.getElectiveList());
        }
      } else if (valueObject.getBoVersion()
          == -1) // RefVo was not modified since obtained from the Assembler, no need to update the
      // BO field
      {
        value9 = domainObject.getElectiveList();
      } else {
        value9 =
            (ims.RefMan.domain.objects.PatientElectiveList)
                domainFactory.getDomainObject(
                    ims.RefMan.domain.objects.PatientElectiveList.class,
                    valueObject.getElectiveList().getBoId());
      }
    }
    domainObject.setElectiveList(value9);

    return domainObject;
  }
  public static ims.scheduling.domain.objects.Booking_Appointment extractBooking_Appointment(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.scheduling.vo.AppointmentOutcomeDetailsVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_Booking_Appointment();
    ims.scheduling.domain.objects.Booking_Appointment domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.scheduling.domain.objects.Booking_Appointment) domMap.get(valueObject);
      }
      // ims.scheduling.vo.AppointmentOutcomeDetailsVo ID_Booking_Appointment field is unknown
      domainObject = new ims.scheduling.domain.objects.Booking_Appointment();
      domMap.put(valueObject, domainObject);
    } else {
      String key =
          (valueObject.getClass().getName() + "__" + valueObject.getID_Booking_Appointment());
      if (domMap.get(key) != null) {
        return (ims.scheduling.domain.objects.Booking_Appointment) domMap.get(key);
      }
      domainObject =
          (ims.scheduling.domain.objects.Booking_Appointment)
              domainFactory.getDomainObject(
                  ims.scheduling.domain.objects.Booking_Appointment.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_Booking_Appointment());

    java.util.Date value1 = null;
    ims.framework.utils.Date date1 = valueObject.getAppointmentDate();
    if (date1 != null) {
      value1 = date1.getDate();
    }
    domainObject.setAppointmentDate(value1);
    ims.framework.utils.Time time2 = valueObject.getApptStartTime();
    String value2 = null;
    if (time2 != null) {
      value2 = time2.toString();
    }
    domainObject.setApptStartTime(value2);
    // SaveAsRefVO - treated as a refVo in extract methods
    ims.scheduling.domain.objects.Sch_Session value3 = null;
    if (null != valueObject.getSession()) {
      if (valueObject.getSession().getBoId() == null) {
        if (domMap.get(valueObject.getSession()) != null) {
          value3 = (ims.scheduling.domain.objects.Sch_Session) domMap.get(valueObject.getSession());
        }
      } else {
        value3 =
            (ims.scheduling.domain.objects.Sch_Session)
                domainFactory.getDomainObject(
                    ims.scheduling.domain.objects.Sch_Session.class,
                    valueObject.getSession().getBoId());
      }
    }
    domainObject.setSession(value3);
    ims.pathways.domain.objects.PathwaysRTTClockImpact value4 = null;
    if (null != valueObject.getRTTClockImpact()) {
      if (valueObject.getRTTClockImpact().getBoId() == null) {
        if (domMap.get(valueObject.getRTTClockImpact()) != null) {
          value4 =
              (ims.pathways.domain.objects.PathwaysRTTClockImpact)
                  domMap.get(valueObject.getRTTClockImpact());
        }
      } else if (valueObject.getBoVersion()
          == -1) // RefVo was not modified since obtained from the Assembler, no need to update the
                 // BO field
      {
        value4 = domainObject.getRTTClockImpact();
      } else {
        value4 =
            (ims.pathways.domain.objects.PathwaysRTTClockImpact)
                domainFactory.getDomainObject(
                    ims.pathways.domain.objects.PathwaysRTTClockImpact.class,
                    valueObject.getRTTClockImpact().getBoId());
      }
    }
    domainObject.setRTTClockImpact(value4);

    return domainObject;
  }
  public static ims.scheduling.domain.objects.Booking_Appointment extractBooking_Appointment(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.RefMan.vo.BookingAppointmentForClinicalNotesVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_Booking_Appointment();
    ims.scheduling.domain.objects.Booking_Appointment domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.scheduling.domain.objects.Booking_Appointment) domMap.get(valueObject);
      }
      // ims.RefMan.vo.BookingAppointmentForClinicalNotesVo ID_Booking_Appointment field is unknown
      domainObject = new ims.scheduling.domain.objects.Booking_Appointment();
      domMap.put(valueObject, domainObject);
    } else {
      String key =
          (valueObject.getClass().getName() + "__" + valueObject.getID_Booking_Appointment());
      if (domMap.get(key) != null) {
        return (ims.scheduling.domain.objects.Booking_Appointment) domMap.get(key);
      }
      domainObject =
          (ims.scheduling.domain.objects.Booking_Appointment)
              domainFactory.getDomainObject(
                  ims.scheduling.domain.objects.Booking_Appointment.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_Booking_Appointment());

    java.util.Date value1 = null;
    ims.framework.utils.Date date1 = valueObject.getAppointmentDate();
    if (date1 != null) {
      value1 = date1.getDate();
    }
    domainObject.setAppointmentDate(value1);
    ims.framework.utils.Time time2 = valueObject.getApptStartTime();
    String value2 = null;
    if (time2 != null) {
      value2 = time2.toString();
    }
    domainObject.setApptStartTime(value2);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value3 = null;
    if (null != valueObject.getApptStatus()) {
      value3 = domainFactory.getLookupInstance(valueObject.getApptStatus().getID());
    }
    domainObject.setApptStatus(value3);
    // SaveAsRefVO - treated as a refVo in extract methods
    ims.scheduling.domain.objects.Sch_Session value4 = null;
    if (null != valueObject.getSession()) {
      if (valueObject.getSession().getBoId() == null) {
        if (domMap.get(valueObject.getSession()) != null) {
          value4 = (ims.scheduling.domain.objects.Sch_Session) domMap.get(valueObject.getSession());
        }
      } else {
        value4 =
            (ims.scheduling.domain.objects.Sch_Session)
                domainFactory.getDomainObject(
                    ims.scheduling.domain.objects.Sch_Session.class,
                    valueObject.getSession().getBoId());
      }
    }
    domainObject.setSession(value4);

    return domainObject;
  }