示例#1
0
  protected void onSearchClick() throws PresentationLogicException {
    form.PatientsGrid().getRows().clear();
    form.AppointmentsGrid().getRows().clear();
    form.LeftDate().setEnabled(false);
    form.RightDate().setEnabled(false);
    form.DateSelected().setValue(form.Date().getValue());

    ClearArrivalControls();
    EnableButtons(false);
    EnableArrivalControls(false);

    PatientShortCollection voPatients = null;

    String surname = form.Surname().getValue();
    String forname = form.Name().getValue();
    String hospNum = form.HospitalNumber().getValue();

    Date dob = form.DOB().getValue();
    if ((surname == null || surname.length() == 0)
        && (forname == null || forname.length() == 0)
        && (hospNum == null || hospNum.length() == 0)
        && (dob == null)) {
      engine.showMessage(
          "Please enter a partial Surname, Name, \nHospital number OR a Date of birth and Search again.");
      return;
    }

    // 08/04/2003 - Do a Get when Hospital Number provided - ignore the rest
    if (hospNum != null && hospNum.length() > 0) {
      // Clear the Patient name, surname, dob
      form.Surname().setValue("");
      form.Name().setValue("");
      form.DOB().setValue(null);
    }

    try {
      PatientFilter voFilter = new PatientFilter();

      voFilter.setSurname(surname != null ? surname.toUpperCase() : null);
      voFilter.setForename(forname != null ? forname.toUpperCase() : null);
      voFilter.setDob(dob != null ? new PartialDate(dob.toString(DateFormat.ISO)) : null);

      PatientId pid = new PatientId();
      pid.setType(PatIdType.HOSPNUM);
      pid.setValue(form.HospitalNumber().getValue());
      voFilter.setPersId(pid);

      voPatients = domain.listPatients(voFilter);
    } catch (DomainInterfaceException e) {
      engine.showMessage(e.getMessage());
      return;
    }

    if (voPatients.size() == 0) {
      engine.showMessage("There is no patient matching this search criteria.");
      return;
    }

    for (int i = 0; i < voPatients.size(); ++i) addPatientRow(voPatients.get(i));
  }
示例#2
0
  private String[] validateSearchCriteria() {
    ArrayList<String> listOfErrors = new ArrayList<String>();
    SurgicalOPNotesFilterVo sonf = populateSearchDataFromScreen();

    if (sonf.countFieldsWithValue() == 0) {
      listOfErrors.add("Please fill in at least one search field");
    } else {
      Date today = new Date();
      if (today.isLessThan(sonf.getDateFrom())) {
        listOfErrors.add("'Date From' cannot be set to a date in the future."); // WDEV-18762
      }
      if (today.isLessThan(sonf.getDateTo())) {
        listOfErrors.add("'Date To' cannot be set to a date in the future."); // WDEV-18762
      }
      if (sonf.getDateToIsNotNull()
          && sonf.getDateFromIsNotNull()
          && sonf.getDateFrom().isGreaterThan(sonf.getDateTo())) {

        listOfErrors.add("'Date From' cannot be later than 'Date To'."); // WDEV-18762
      }
    }
    if (listOfErrors.size() == 0) return null;
    String[] errors = new String[listOfErrors.size()];
    errors = listOfErrors.toArray(errors);
    return errors;
  }
  public static ims.nursing.careplans.domain.objects.CarePlanTemplate extractCarePlanTemplate(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.nursing.vo.CarePlanTemplateTitle valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_CarePlanTemplate();
    ims.nursing.careplans.domain.objects.CarePlanTemplate domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.nursing.careplans.domain.objects.CarePlanTemplate) domMap.get(valueObject);
      }
      // ims.nursing.vo.CarePlanTemplateTitle ID_CarePlanTemplate field is unknown
      domainObject = new ims.nursing.careplans.domain.objects.CarePlanTemplate();
      domMap.put(valueObject, domainObject);
    } else {
      String key = (valueObject.getClass().getName() + "__" + valueObject.getID_CarePlanTemplate());
      if (domMap.get(key) != null) {
        return (ims.nursing.careplans.domain.objects.CarePlanTemplate) domMap.get(key);
      }
      domainObject =
          (ims.nursing.careplans.domain.objects.CarePlanTemplate)
              domainFactory.getDomainObject(
                  ims.nursing.careplans.domain.objects.CarePlanTemplate.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_CarePlanTemplate());

    java.util.Date value1 = null;
    ims.framework.utils.Date date1 = valueObject.getCreationDate();
    if (date1 != null) {
      value1 = date1.getDate();
    }
    domainObject.setCreationDate(value1);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value2 = null;
    if (null != valueObject.getAssessmentComponent()) {
      value2 = domainFactory.getLookupInstance(valueObject.getAssessmentComponent().getID());
    }
    domainObject.setAssessmentComponent(value2);
    // 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.getTitle() != null && valueObject.getTitle().equals("")) {
      valueObject.setTitle(null);
    }
    domainObject.setTitle(valueObject.getTitle());
    domainObject.setActive(valueObject.getActive());

    return domainObject;
  }
  public static ims.core.admin.domain.objects.Referral extractReferral(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.core.vo.ReferralListVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_Referral();
    ims.core.admin.domain.objects.Referral domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.core.admin.domain.objects.Referral) domMap.get(valueObject);
      }
      // ims.core.vo.ReferralListVo ID_Referral field is unknown
      domainObject = new ims.core.admin.domain.objects.Referral();
      domMap.put(valueObject, domainObject);
    } else {
      String key = (valueObject.getClass().getName() + "__" + valueObject.getID_Referral());
      if (domMap.get(key) != null) {
        return (ims.core.admin.domain.objects.Referral) domMap.get(key);
      }
      domainObject =
          (ims.core.admin.domain.objects.Referral)
              domainFactory.getDomainObject(ims.core.admin.domain.objects.Referral.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_Referral());

    ims.framework.utils.DateTime dateTime1 = valueObject.getAuthoringDateTime();
    java.util.Date value1 = null;
    if (dateTime1 != null) {
      value1 = dateTime1.getJavaDate();
    }
    domainObject.setAuthoringDateTime(value1);
    java.util.Date value2 = null;
    ims.framework.utils.Date date2 = valueObject.getReferralReceivedDate();
    if (date2 != null) {
      value2 = date2.getDate();
    }
    domainObject.setReferralReceivedDate(value2);
    java.util.Date value3 = null;
    ims.framework.utils.Date date3 = valueObject.getOriginalReferralDate();
    if (date3 != null) {
      value3 = date3.getDate();
    }
    domainObject.setOriginalReferralDate(value3);

    return domainObject;
  }
  public MiniNutritionalAssessmentCollection listAssessments(
      Date dateFrom, Date dateTo, CareContextLiteVo careContextref)
      throws DomainInterfaceException {
    DomainFactory factory = getDomainFactory();

    String filter = " from MiniNutritionalAssessment mna ";
    StringBuffer filterString = new StringBuffer();

    boolean conditionFound = false;

    ArrayList markerNames = new ArrayList();
    ArrayList markerValues = new ArrayList();

    if (dateFrom != null && dateTo != null) {
      filterString.append(
          " mna.dateTimeInitiated > :fromDate and mna.dateTimeInitiated < :toDate ");
      conditionFound = true;
      markerNames.add("fromDate");
      markerNames.add("toDate");
      markerValues.add(dateFrom.addDay(-1).getDate());
      markerValues.add(dateTo.addDay(1).getDate());
    } else if (dateFrom != null) {
      filterString.append(" mna.dateTimeInitiated > :fromDate ");
      conditionFound = true;
      markerNames.add("fromDate");

      markerValues.add(dateFrom.addDay(-1).getDate());
    }

    if (careContextref != null) {
      if (conditionFound) filterString.append(" and ");

      filterString.append(" mna.careContext.id = :careContext ");
      markerNames.add("careContext");
      markerValues.add(careContextref.getID_CareContext());
    }

    String[] names = new String[markerNames.size()];
    markerNames.toArray(names);
    filter += " where ";

    filter += filterString.toString();

    List procs = factory.find(filter, markerNames, markerValues);

    return MiniNutritionalAssessmentAssembler
        .createMiniNutritionalAssessmentCollectionFromMiniNutritionalAssessment(procs)
        .sort();
  }
  // wdev-18936
  public PatientElectiveListForWardViewVoCollection listPatientElectiveListForWardViewVo(
      LocationRefVo ward, Date tcidate) {
    StringBuilder query = new StringBuilder();
    ArrayList<String> paramNames = new ArrayList<String>();
    ArrayList<Object> paramValues = new ArrayList<Object>();

    query.append("SELECT pel FROM PatientElectiveList AS pel ");
    query.append(
        "LEFT JOIN pel.electiveListStatus AS els LEFT JOIN els.electiveListStatus AS elStatus ");
    query.append("LEFT JOIN pel.tCIDetails AS tci LEFT JOIN tci.tCIWard AS ward ");
    query.append("LEFT JOIN pel.patient AS patient ");

    query.append(
        "WHERE ward.id = :WARD AND elStatus.id = :TCI_GIVEN AND tci.isActive = 1 AND tci.currentOutcome is null ");
    paramNames.add("WARD");
    paramValues.add(ward.getID_Location());
    paramNames.add("TCI_GIVEN");
    paramValues.add(WaitingListStatus.TCI_GIVEN.getId());
    if (tcidate != null) // wdev-19115
    {
      query.append(" AND tci.tCIDate = :CURRENT_DATE");
      paramNames.add("CURRENT_DATE");
      paramValues.add(tcidate.getDate());
    }

    query.append(" ORDER BY patient.name.surname, patient.name.forename");

    return PatientElectiveListForWardViewVoAssembler
        .createPatientElectiveListForWardViewVoCollectionFromPatientElectiveList(
            getDomainFactory().find(query.toString(), paramNames, paramValues));
  }
  /** Saves the default schedule for current date to a provided client ClientImmunisationSchedule */
  public ClientImmunisationScheduleVo saveDefaultScheduleToClient(
      PatientRefVo clientRef, MemberOfStaffLiteVo mos)
      throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException,
          UniqueKeyViolationException {
    if (clientRef == null)
      throw new DomainInterfaceException(
          "A client must be selected before a schedule can be added");

    // Look for a client in the database
    DomainFactory factory = getDomainFactory();
    ClientLiteVo clientLiteVo =
        ClientLiteVoAssembler.create(
            (Patient) factory.getDomainObject(Patient.class, clientRef.getID_Patient()));

    if (clientLiteVo == null) throw new DomainInterfaceException("Desired client does not exist");

    Date dateOfBirth = new Date();
    dateOfBirth.setDay(
        clientLiteVo.getDob().getDay() == null ? new Integer(1) : clientLiteVo.getDob().getDay());
    dateOfBirth.setMonth(
        clientLiteVo.getDob().getMonth() == null
            ? new Integer(1)
            : clientLiteVo.getDob().getMonth());
    dateOfBirth.setYear(
        clientLiteVo.getDob().getYear() == null
            ? new Integer(new Date().getYear())
            : clientLiteVo.getDob().getYear());

    ScheduleConfigurationLiteVo defaultScheduleConfiguration =
        getDefaultScheduleConfiguration(dateOfBirth);

    if (defaultScheduleConfiguration == null)
      throw new DomainInterfaceException(
          "There is no default schedule for the current date. Please define a default schedule for this date or select a schedule");

    ClientImmunisationScheduleVo clientSchedule =
        addScheduleToClient(clientRef, defaultScheduleConfiguration, mos);

    String[] errors = clientSchedule.validate();

    if (errors != null && errors.length != 0) {
      throw new DomainInterfaceException(
          "Can not add a default schedule to client. Errors present");
    }

    return saveClientImmunisationSchedule(clientSchedule);
  }
示例#8
0
  protected void onRightDateClick() throws PresentationLogicException {
    if (form.Date().getValue() != null) {
      Date date = null;
      try {
        date = new Date(form.getLocalContext().getPatientArrivalDate(), DateFormat.ISO);
      } catch (ParseException e) {
        engine.showMessage(e.getMessage());
        return;
      }
      date.addDay(1);
      EnableButtons(false);
      getAppointments(date);

      form.DateSelected().setValue(date);
      form.getLocalContext().setPatientArrivalDate(date.toString(DateFormat.ISO));
    }
  }
示例#9
0
  private void getAppointments(Date date) throws PresentationLogicException {
    form.AppointmentsGrid().getRows().clear();
    EnableArrivalControls(false);
    // Clear the arrival controls
    ClearArrivalControls();

    if (date == null) return;

    String pkey = getPkey();

    Sd_appt_dts appDetails;
    try {
      appDetails = domain.listAppointmentDetails(pkey, date.toString(DateFormat.ISO));
    } catch (DomainInterfaceException e) {
      engine.showMessage(e.getMessage());
      return;
    }

    Result result = appDetails.list();
    if (result != null) {
      engine.showMessage(result.getMessage());
      return;
    }

    for (int i = 0; i < appDetails.DataCollection.count(); ++i) {
      GenForm.AppointmentsGridRow row = form.AppointmentsGrid().getRows().newRow();

      if (appDetails.DataCollection.get(i).First_appt_id
          == appDetails.DataCollection.get(i).Appt_id)
        row.setBooking(form.getImages().CcoSched.First);
      else if (appDetails.DataCollection.get(i).Last_appt_id
          == appDetails.DataCollection.get(i).Appt_id)
        row.setBooking(form.getImages().CcoSched.Last);
      Time dt = getTimeFromString(appDetails.DataCollection.get(i).Stm);
      row.setAppointmentTime(dt == null ? "" : dt.toString());
      row.setClinicName(appDetails.DataCollection.get(i).Prfile_sess_idtxt);
      row.setConsultant(appDetails.DataCollection.get(i).Act_consulttxt);
      row.setStatus(appDetails.DataCollection.get(i).Appt_stattxt);

      row.setValue(appDetails.DataCollection.get(i));
    }

    int nCount = form.AppointmentsGrid().getRows().size();
    if (nCount == 0) engine.showMessage("No records.");

    // 05/06/2003 - Kevin's improvement - select the first record (or the previous selected one)
    if (nCount > 0) {
      form.AppointmentsGrid()
          .setValue(form.AppointmentsGrid().getRows().get(GetPrevSelIndex()).getValue());

      if (form.AppointmentsGrid().getSelectedRowIndex() >= 0) onAppointmentsGridSelectionChanged();

      // If only one record - disable
      if (nCount == 1) form.AllAppointments().setEnabled(false);
    }
  }
示例#10
0
  protected void onLeftDateClick() throws PresentationLogicException {
    if (form.Date().getValue() != null) {
      Date date = null;
      if (form.getLocalContext().getPatientArrivalDateIsNotNull()
          && form.getLocalContext().getPatientArrivalDate().equals("") == false) {
        try {
          date = new Date(form.getLocalContext().getPatientArrivalDate(), DateFormat.ISO);
        } catch (ParseException e) {
          e.printStackTrace();
        }
      }
      date.addDay(-1);
      EnableButtons(false);
      getAppointments(date);

      form.DateSelected().setValue(date);
      form.getLocalContext().setPatientArrivalDate(date.toString(DateFormat.ISO));
    }
  }
示例#11
0
    public int compare(Object ob1, Object ob2) {
      Date rez1 = null;
      Date rez2 = null;

      if (ob1 instanceof SurgicalOperationNotesListVo) {
        SurgicalOperationNotesListVo ps1 = (SurgicalOperationNotesListVo) ob1;
        rez1 = ps1.getSignOffDateTime() != null ? ps1.getSignOffDateTime().getDate() : null;
      }
      if (ob2 instanceof SurgicalOperationNotesListVo) {
        SurgicalOperationNotesListVo ps2 = (SurgicalOperationNotesListVo) ob2;
        rez2 = ps2.getSignOffDateTime() != null ? ps2.getSignOffDateTime().getDate() : null;
      }

      if (rez1 != null && rez2 != null) return rez1.compareTo(rez2) * direction;

      if (rez1 != null && rez2 == null) return direction;

      if (rez2 != null && rez1 == null) return (-1) * direction;

      return 0;
    }
  private ClientImmunisationScheduleVo addScheduleToClient(
      PatientRefVo clientRef, ScheduleConfigurationRefVo scheduleRef, MemberOfStaffLiteVo mos)
      throws DomainInterfaceException {
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //	PRELIMINARY CHECKS
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    // Check for a client
    if (clientRef == null)
      throw new DomainInterfaceException("Can not add schedule. Client was not found in records");

    // Look for a client in the database
    DomainFactory factory = getDomainFactory();
    ClientLiteVo clientLiteVo =
        ClientLiteVoAssembler.create(
            (Patient) factory.getDomainObject(Patient.class, clientRef.getID_Patient()));

    if (clientLiteVo == null) throw new DomainInterfaceException("Desired client does not exist");

    Date dateOfBirth = new Date();
    dateOfBirth.setDay(
        clientLiteVo.getDob().getDay() == null ? new Integer(1) : clientLiteVo.getDob().getDay());
    dateOfBirth.setMonth(
        clientLiteVo.getDob().getMonth() == null
            ? new Integer(1)
            : clientLiteVo.getDob().getMonth());
    dateOfBirth.setYear(
        clientLiteVo.getDob().getYear() == null
            ? new Integer(new Date().getYear())
            : clientLiteVo.getDob().getYear());

    // Check for a member of staff
    if (mos == null)
      throw new DomainInterfaceException(
          "An immunisation schedule for a client can be added only by a member of staff");

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //	RETRIVE - ClientImmunisationScheduleVo, ScheduleConfigurationVo
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    // Get the client schedule
    ClientImmunisationScheduleVo clientSchedule = getClientImmunisationSchedule(clientRef);

    // Get the schedule configuration to add (return the client schedule as it is - null if there is
    // none - if the schedule configuration is null)
    ScheduleConfigurationVo schedule;
    if (scheduleRef == null) return clientSchedule;
    else {
      // Get the schedule configuration
      schedule =
          ScheduleConfigurationVoAssembler.create(
              (ScheduleConfiguration)
                  factory.getDomainObject(
                      ScheduleConfiguration.class, scheduleRef.getID_ScheduleConfiguration()));

      if (schedule == null) return clientSchedule;
    }

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //	START BUILDING ClientImmunisationSchedule (create a new one if needed)
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    // At this point if there was no schedule configuration create a new one
    if (clientSchedule == null) {
      clientSchedule = new ClientImmunisationScheduleVo();
    }

    // Set the client (if not already set)
    if (clientSchedule.getClient() == null) {
      clientSchedule.setClient(clientLiteVo);
    }

    try {
      clientSchedule.addSchedule(schedule, mos, new DateTime());
    } catch (IllegalArgumentException e) {
      //			throw new DomainInterfaceException("Can not add default schedule configuration to client
      // immunisation schedule as it conflicts withs existing schedule.");
      throw new DomainInterfaceException(e.getMessage());
    }

    return clientSchedule;
  }
  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;
  }
  public static ims.oncology.domain.objects.ChemotherapyDetails extractChemotherapyDetails(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.ocrr.vo.ChemotherapyDetailsLiteVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_ChemotherapyDetails();
    ims.oncology.domain.objects.ChemotherapyDetails domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.oncology.domain.objects.ChemotherapyDetails) domMap.get(valueObject);
      }
      // ims.ocrr.vo.ChemotherapyDetailsLiteVo ID_ChemotherapyDetails field is unknown
      domainObject = new ims.oncology.domain.objects.ChemotherapyDetails();
      domMap.put(valueObject, domainObject);
    } else {
      String key =
          (valueObject.getClass().getName() + "__" + valueObject.getID_ChemotherapyDetails());
      if (domMap.get(key) != null) {
        return (ims.oncology.domain.objects.ChemotherapyDetails) domMap.get(key);
      }
      domainObject =
          (ims.oncology.domain.objects.ChemotherapyDetails)
              domainFactory.getDomainObject(
                  ims.oncology.domain.objects.ChemotherapyDetails.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_ChemotherapyDetails());

    ims.core.admin.domain.objects.EpisodeOfCare value1 = null;
    if (null != valueObject.getEpisodeOfCare()) {
      if (valueObject.getEpisodeOfCare().getBoId() == null) {
        if (domMap.get(valueObject.getEpisodeOfCare()) != null) {
          value1 =
              (ims.core.admin.domain.objects.EpisodeOfCare)
                  domMap.get(valueObject.getEpisodeOfCare());
        }
      } else if (valueObject.getBoVersion()
          == -1) // RefVo was not modified since obtained from the Assembler, no need to update the
                 // BO field
      {
        value1 = domainObject.getEpisodeOfCare();
      } else {
        value1 =
            (ims.core.admin.domain.objects.EpisodeOfCare)
                domainFactory.getDomainObject(
                    ims.core.admin.domain.objects.EpisodeOfCare.class,
                    valueObject.getEpisodeOfCare().getBoId());
      }
    }
    domainObject.setEpisodeOfCare(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);
    java.util.Date value3 = null;
    ims.framework.utils.Date date3 = valueObject.getStartDate();
    if (date3 != null) {
      value3 = date3.getDate();
    }
    domainObject.setStartDate(value3);
    java.util.Date value4 = null;
    ims.framework.utils.Date date4 = valueObject.getDateDecisionToTreat();
    if (date4 != null) {
      value4 = date4.getDate();
    }
    domainObject.setDateDecisionToTreat(value4);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value5 = null;
    if (null != valueObject.getDrugTherapyType()) {
      value5 = domainFactory.getLookupInstance(valueObject.getDrugTherapyType().getID());
    }
    domainObject.setDrugTherapyType(value5);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value6 = null;
    if (null != valueObject.getRegimenAcronym()) {
      value6 = domainFactory.getLookupInstance(valueObject.getRegimenAcronym().getID());
    }
    domainObject.setRegimenAcronym(value6);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value7 = null;
    if (null != valueObject.getCancerTreatementIntent()) {
      value7 = domainFactory.getLookupInstance(valueObject.getCancerTreatementIntent().getID());
    }
    domainObject.setCancerTreatementIntent(value7);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value8 = null;
    if (null != valueObject.getTreatmentResponse()) {
      value8 = domainFactory.getLookupInstance(valueObject.getTreatmentResponse().getID());
    }
    domainObject.setTreatmentResponse(value8);

    return domainObject;
  }
  public static ims.core.configuration.domain.objects.ElectiveListConfiguration
      extractElectiveListConfiguration(
          ims.domain.ILightweightDomainFactory domainFactory,
          ims.admin.vo.ElectiveListConfigForElectiveListDetailsVo valueObject,
          HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_ElectiveListConfiguration();
    ims.core.configuration.domain.objects.ElectiveListConfiguration domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.core.configuration.domain.objects.ElectiveListConfiguration)
            domMap.get(valueObject);
      }
      // ims.admin.vo.ElectiveListConfigForElectiveListDetailsVo ID_ElectiveListConfiguration field
      // is unknown
      domainObject = new ims.core.configuration.domain.objects.ElectiveListConfiguration();
      domMap.put(valueObject, domainObject);
    } else {
      String key =
          (valueObject.getClass().getName() + "__" + valueObject.getID_ElectiveListConfiguration());
      if (domMap.get(key) != null) {
        return (ims.core.configuration.domain.objects.ElectiveListConfiguration) domMap.get(key);
      }
      domainObject =
          (ims.core.configuration.domain.objects.ElectiveListConfiguration)
              domainFactory.getDomainObject(
                  ims.core.configuration.domain.objects.ElectiveListConfiguration.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_ElectiveListConfiguration());

    // SaveAsRefVO treated as RefValueObject
    ims.core.configuration.vo.ElectiveListHospitalConfigurationRefVoCollection refCollection1 =
        new ims.core.configuration.vo.ElectiveListHospitalConfigurationRefVoCollection();
    if (valueObject.getListLocations() != null) {
      for (int i1 = 0; i1 < valueObject.getListLocations().size(); i1++) {
        ims.core.configuration.vo.ElectiveListHospitalConfigurationRefVo ref1 =
            (ims.core.configuration.vo.ElectiveListHospitalConfigurationRefVo)
                valueObject.getListLocations().get(i1);
        refCollection1.add(ref1);
      }
    }
    int size1 = (null == refCollection1) ? 0 : refCollection1.size();
    java.util.List domainListLocations1 = domainObject.getListLocations();
    if (domainListLocations1 == null) {
      domainListLocations1 = new java.util.ArrayList();
    }
    for (int i = 0; i < size1; i++) {
      ims.core.configuration.vo.ElectiveListHospitalConfigurationRefVo vo = refCollection1.get(i);
      ims.core.configuration.domain.objects.ElectiveListHospitalConfiguration dom = null;
      if (null != vo) {
        if (vo.getBoId() == null) {
          if (domMap.get(vo) != null) {
            dom =
                (ims.core.configuration.domain.objects.ElectiveListHospitalConfiguration)
                    domMap.get(vo);
          }
        } else {
          dom =
              (ims.core.configuration.domain.objects.ElectiveListHospitalConfiguration)
                  domainFactory.getDomainObject(
                      ims.core.configuration.domain.objects.ElectiveListHospitalConfiguration.class,
                      vo.getBoId());
        }
      }

      int domIdx = domainListLocations1.indexOf(dom);
      if (domIdx == -1) {
        domainListLocations1.add(i, dom);
      } else if (i != domIdx && i < domainListLocations1.size()) {
        Object tmp = domainListLocations1.get(i);
        domainListLocations1.set(i, domainListLocations1.get(domIdx));
        domainListLocations1.set(domIdx, tmp);
      }
    }

    // Remove all ones in domList where index > voCollection.size() as these should
    // now represent the ones removed from the VO collection. No longer referenced.
    int i1 = domainListLocations1.size();
    while (i1 > size1) {
      domainListLocations1.remove(i1 - 1);
      i1 = domainListLocations1.size();
    }

    domainObject.setListLocations(domainListLocations1);
    // 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.getWaitingListName() != null && valueObject.getWaitingListName().equals("")) {
      valueObject.setWaitingListName(null);
    }
    domainObject.setWaitingListName(valueObject.getWaitingListName());
    java.util.Date value3 = null;
    ims.framework.utils.Date date3 = valueObject.getStartDate();
    if (date3 != null) {
      value3 = date3.getDate();
    }
    domainObject.setStartDate(value3);
    java.util.Date value4 = null;
    ims.framework.utils.Date date4 = valueObject.getEndDate();
    if (date4 != null) {
      value4 = date4.getDate();
    }
    domainObject.setEndDate(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.getWaitingListCode() != null && valueObject.getWaitingListCode().equals("")) {
      valueObject.setWaitingListCode(null);
    }
    domainObject.setWaitingListCode(valueObject.getWaitingListCode());
    domainObject.setIsActive(valueObject.getIsActive());

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

    // 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.getName() != null && valueObject.getName().equals("")) {
      valueObject.setName(null);
    }
    domainObject.setName(valueObject.getName());
    java.util.Date value2 = null;
    ims.framework.utils.Date date2 = valueObject.getSessionDate();
    if (date2 != null) {
      value2 = date2.getDate();
    }
    domainObject.setSessionDate(value2);
    ims.framework.utils.Time time3 = valueObject.getStartTm();
    String value3 = null;
    if (time3 != null) {
      value3 = time3.toString();
    }
    domainObject.setStartTm(value3);
    ims.framework.utils.Time time4 = valueObject.getEndTm();
    String value4 = null;
    if (time4 != null) {
      value4 = time4.toString();
    }
    domainObject.setEndTm(value4);
    // SaveAsRefVO - treated as a refVo in extract methods
    ims.core.clinical.domain.objects.Service value5 = null;
    if (null != valueObject.getService()) {
      if (valueObject.getService().getBoId() == null) {
        if (domMap.get(valueObject.getService()) != null) {
          value5 = (ims.core.clinical.domain.objects.Service) domMap.get(valueObject.getService());
        }
      } else {
        value5 =
            (ims.core.clinical.domain.objects.Service)
                domainFactory.getDomainObject(
                    ims.core.clinical.domain.objects.Service.class,
                    valueObject.getService().getBoId());
      }
    }
    domainObject.setService(value5);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value6 = null;
    if (null != valueObject.getSessionStatus()) {
      value6 = domainFactory.getLookupInstance(valueObject.getSessionStatus().getID());
    }
    domainObject.setSessionStatus(value6);
    domainObject.setRemainingSlots(valueObject.getRemainingSlots());
    domainObject.setTotalSlots(valueObject.getTotalSlots());
    domainObject.setRemainingTime(valueObject.getRemainingTime());
    // SaveAsRefVO - treated as a refVo in extract methods
    ims.core.resource.place.domain.objects.Location value10 = null;
    if (null != valueObject.getSchLocation()) {
      if (valueObject.getSchLocation().getBoId() == null) {
        if (domMap.get(valueObject.getSchLocation()) != null) {
          value10 =
              (ims.core.resource.place.domain.objects.Location)
                  domMap.get(valueObject.getSchLocation());
        }
      } else {
        value10 =
            (ims.core.resource.place.domain.objects.Location)
                domainFactory.getDomainObject(
                    ims.core.resource.place.domain.objects.Location.class,
                    valueObject.getSchLocation().getBoId());
      }
    }
    domainObject.setSchLocation(value10);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value11 = null;
    if (null != valueObject.getSessionType()) {
      value11 = domainFactory.getLookupInstance(valueObject.getSessionType().getID());
    }
    domainObject.setSessionType(value11);

    // SaveAsRefVO treated as RefValueObject
    ims.scheduling.vo.Session_ListOwnerRefVoCollection refCollection12 =
        new ims.scheduling.vo.Session_ListOwnerRefVoCollection();
    if (valueObject.getListOwners() != null) {
      for (int i12 = 0; i12 < valueObject.getListOwners().size(); i12++) {
        ims.scheduling.vo.Session_ListOwnerRefVo ref12 =
            (ims.scheduling.vo.Session_ListOwnerRefVo) valueObject.getListOwners().get(i12);
        refCollection12.add(ref12);
      }
    }
    int size12 = (null == refCollection12) ? 0 : refCollection12.size();
    java.util.Set domainListOwners12 = domainObject.getListOwners();
    if (domainListOwners12 == null) {
      domainListOwners12 = new java.util.HashSet();
    }
    java.util.Set newSet12 = new java.util.HashSet();
    for (int i = 0; i < size12; i++) {
      ims.scheduling.vo.Session_ListOwnerRefVo vo = refCollection12.get(i);
      ims.scheduling.domain.objects.Session_ListOwner dom = null;
      if (null != vo) {
        if (vo.getBoId() == null) {
          if (domMap.get(vo) != null) {
            dom = (ims.scheduling.domain.objects.Session_ListOwner) domMap.get(vo);
          }
        } else {
          dom =
              (ims.scheduling.domain.objects.Session_ListOwner)
                  domainFactory.getDomainObject(
                      ims.scheduling.domain.objects.Session_ListOwner.class, vo.getBoId());
        }
      }

      // Trying to avoid the hibernate collection being marked as dirty via its public interface
      // methods. (like add)
      if (!domainListOwners12.contains(dom)) {
        domainListOwners12.add(dom);
      }
      newSet12.add(dom);
    }
    java.util.Set removedSet12 = new java.util.HashSet();
    java.util.Iterator iter12 = domainListOwners12.iterator();
    // Find out which objects need to be removed
    while (iter12.hasNext()) {
      ims.domain.DomainObject o = (ims.domain.DomainObject) iter12.next();
      if ((o == null || o.getIsRIE() == null || !o.getIsRIE().booleanValue())
          && !newSet12.contains(o)) {
        removedSet12.add(o);
      }
    }
    iter12 = removedSet12.iterator();
    // Remove the unwanted objects
    while (iter12.hasNext()) {
      domainListOwners12.remove(iter12.next());
    }

    domainObject.setListOwners(domainListOwners12);

    // SaveAsRefVO treated as RefValueObject
    ims.scheduling.vo.DirectoryofServiceRefVoCollection refCollection13 =
        new ims.scheduling.vo.DirectoryofServiceRefVoCollection();
    if (valueObject.getDirectoryofServices() != null) {
      for (int i13 = 0; i13 < valueObject.getDirectoryofServices().size(); i13++) {
        ims.scheduling.vo.DirectoryofServiceRefVo ref13 =
            (ims.scheduling.vo.DirectoryofServiceRefVo)
                valueObject.getDirectoryofServices().get(i13);
        refCollection13.add(ref13);
      }
    }
    int size13 = (null == refCollection13) ? 0 : refCollection13.size();
    java.util.Set domainDirectoryofServices13 = domainObject.getDirectoryofServices();
    if (domainDirectoryofServices13 == null) {
      domainDirectoryofServices13 = new java.util.HashSet();
    }
    java.util.Set newSet13 = new java.util.HashSet();
    for (int i = 0; i < size13; i++) {
      ims.scheduling.vo.DirectoryofServiceRefVo vo = refCollection13.get(i);
      ims.scheduling.domain.objects.DirectoryofService dom = null;
      if (null != vo) {
        if (vo.getBoId() == null) {
          if (domMap.get(vo) != null) {
            dom = (ims.scheduling.domain.objects.DirectoryofService) domMap.get(vo);
          }
        } else {
          dom =
              (ims.scheduling.domain.objects.DirectoryofService)
                  domainFactory.getDomainObject(
                      ims.scheduling.domain.objects.DirectoryofService.class, vo.getBoId());
        }
      }

      // Trying to avoid the hibernate collection being marked as dirty via its public interface
      // methods. (like add)
      if (!domainDirectoryofServices13.contains(dom)) {
        domainDirectoryofServices13.add(dom);
      }
      newSet13.add(dom);
    }
    java.util.Set removedSet13 = new java.util.HashSet();
    java.util.Iterator iter13 = domainDirectoryofServices13.iterator();
    // Find out which objects need to be removed
    while (iter13.hasNext()) {
      ims.domain.DomainObject o = (ims.domain.DomainObject) iter13.next();
      if ((o == null || o.getIsRIE() == null || !o.getIsRIE().booleanValue())
          && !newSet13.contains(o)) {
        removedSet13.add(o);
      }
    }
    iter13 = removedSet13.iterator();
    // Remove the unwanted objects
    while (iter13.hasNext()) {
      domainDirectoryofServices13.remove(iter13.next());
    }

    domainObject.setDirectoryofServices(domainDirectoryofServices13);
    domainObject.setIsTheatreSession(valueObject.getIsTheatreSession());

    return domainObject;
  }
  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;
  }
  @SuppressWarnings("unchecked")
  public IUINotification[] getNotifications(
      int userId,
      Date dateFrom,
      Date dateTo,
      String message,
      String source,
      NotificationPriority priority,
      boolean seen) {
    DomainFactory factory = getDomainFactory();

    String hql = "from Notifications n";
    StringBuffer condStr = new StringBuffer();
    String andStr = "";

    ArrayList<String> markers = new ArrayList<String>();
    ArrayList<Serializable> values = new ArrayList<Serializable>();

    List userNotificationsList = null;

    condStr.append(andStr + " n.user.id = :userIden");
    markers.add("userIden");
    values.add(userId);
    andStr = " and";

    if (dateFrom != null) {
      condStr.append(andStr + " n.dateTime >= :from");
      markers.add("from");
      values.add(dateFrom.getDate());
      dateFrom.getDate().toString();
      andStr = " and";
    }

    if (dateTo != null) {
      Date dateToClone = ((Date) dateTo.clone()).addDay(1);
      condStr.append(andStr + " n.dateTime < :to");
      markers.add("to");
      values.add(dateToClone.getDate());
      andStr = " and";
    }

    if (message != null) {
      condStr.append(andStr + " n.message like :mess");
      markers.add("mess");
      values.add("%" + message + "%");
      andStr = " and";
    }

    if (source != null) {
      condStr.append(andStr + " n.source like :src");
      markers.add("src");
      values.add("%" + source + "%");
      andStr = " and";
    }

    if (priority != null) {
      condStr.append(andStr + " n.priority = :pri");
      markers.add("pri");
      values.add(priority.getId());
      andStr = " and";
    }

    condStr.append(andStr + " n.seen = :isSeen");
    markers.add("isSeen");
    values.add(seen);
    andStr = " and";

    hql += " where";
    hql += condStr.toString();

    hql += " order by n.priority asc, n.dateTime desc";

    userNotificationsList = factory.find(hql, markers, values);

    return NotificationVoAssembler.createNotificationVoCollectionFromNotifications(
            userNotificationsList)
        .toIUINotificationArray();
  }
  public static ims.core.patient.domain.objects.PDSBatchTraceParams extractPDSBatchTraceParams(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.core.vo.PDSBatchTraceItemsVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_PDSBatchTraceParams();
    ims.core.patient.domain.objects.PDSBatchTraceParams domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.core.patient.domain.objects.PDSBatchTraceParams) domMap.get(valueObject);
      }
      // ims.core.vo.PDSBatchTraceItemsVo ID_PDSBatchTraceParams field is unknown
      domainObject = new ims.core.patient.domain.objects.PDSBatchTraceParams();
      domMap.put(valueObject, domainObject);
    } else {
      String key =
          (valueObject.getClass().getName() + "__" + valueObject.getID_PDSBatchTraceParams());
      if (domMap.get(key) != null) {
        return (ims.core.patient.domain.objects.PDSBatchTraceParams) domMap.get(key);
      }
      domainObject =
          (ims.core.patient.domain.objects.PDSBatchTraceParams)
              domainFactory.getDomainObject(
                  ims.core.patient.domain.objects.PDSBatchTraceParams.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_PDSBatchTraceParams());

    // 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.getNHSNumber() != null && valueObject.getNHSNumber().equals("")) {
      valueObject.setNHSNumber(null);
    }
    domainObject.setNHSNumber(valueObject.getNHSNumber());
    // 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.getSurname() != null && valueObject.getSurname().equals("")) {
      valueObject.setSurname(null);
    }
    domainObject.setSurname(valueObject.getSurname());
    // 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.getForename() != null && valueObject.getForename().equals("")) {
      valueObject.setForename(null);
    }
    domainObject.setForename(valueObject.getForename());
    java.util.Date value4 = null;
    ims.framework.utils.Date date4 = valueObject.getDateOfBirth();
    if (date4 != null) {
      value4 = date4.getDate();
    }
    domainObject.setDateOfBirth(value4);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value5 = null;
    if (null != valueObject.getGender()) {
      value5 = domainFactory.getLookupInstance(valueObject.getGender().getID());
    }
    domainObject.setGender(value5);
    java.util.Date value6 = null;
    ims.framework.utils.Date date6 = valueObject.getDateOfDeathFrom();
    if (date6 != null) {
      value6 = date6.getDate();
    }
    domainObject.setDateOfDeathFrom(value6);
    java.util.Date value7 = null;
    ims.framework.utils.Date date7 = valueObject.getDateOfDeathTo();
    if (date7 != null) {
      value7 = date7.getDate();
    }
    domainObject.setDateOfDeathTo(value7);
    // 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.getPostCode() != null && valueObject.getPostCode().equals("")) {
      valueObject.setPostCode(null);
    }
    domainObject.setPostCode(valueObject.getPostCode());
    // 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.getPafKey() != null && valueObject.getPafKey().equals("")) {
      valueObject.setPafKey(null);
    }
    domainObject.setPafKey(valueObject.getPafKey());
    ims.core.patient.domain.objects.PDSAddr value10 = null;
    if (null != valueObject.getAddressLines()) {
      if (valueObject.getAddressLines().getBoId() == null) {
        if (domMap.get(valueObject.getAddressLines()) != null) {
          value10 =
              (ims.core.patient.domain.objects.PDSAddr) domMap.get(valueObject.getAddressLines());
        }
      } else if (valueObject.getBoVersion()
          == -1) // RefVo was not modified since obtained from the Assembler, no need to update the
                 // BO field
      {
        value10 = domainObject.getAddressLines();
      } else {
        value10 =
            (ims.core.patient.domain.objects.PDSAddr)
                domainFactory.getDomainObject(
                    ims.core.patient.domain.objects.PDSAddr.class,
                    valueObject.getAddressLines().getBoId());
      }
    }
    domainObject.setAddressLines(value10);
    // 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.getGpPracticeCode() != null && valueObject.getGpPracticeCode().equals("")) {
      valueObject.setGpPracticeCode(null);
    }
    domainObject.setGpPracticeCode(valueObject.getGpPracticeCode());
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value12 = null;
    if (null != valueObject.getStatus()) {
      value12 = domainFactory.getLookupInstance(valueObject.getStatus().getID());
    }
    domainObject.setStatus(value12);
    // 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.getErrorReason() != null && valueObject.getErrorReason().equals("")) {
      valueObject.setErrorReason(null);
    }
    domainObject.setErrorReason(valueObject.getErrorReason());

    return domainObject;
  }
  public static ims.core.domain.objects.TransportBooking extractTransportBooking(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.RefMan.vo.TransportBookingShortVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_TransportBooking();
    ims.core.domain.objects.TransportBooking domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.core.domain.objects.TransportBooking) domMap.get(valueObject);
      }
      // ims.RefMan.vo.TransportBookingShortVo ID_TransportBooking field is unknown
      domainObject = new ims.core.domain.objects.TransportBooking();
      domMap.put(valueObject, domainObject);
    } else {
      String key = (valueObject.getClass().getName() + "__" + valueObject.getID_TransportBooking());
      if (domMap.get(key) != null) {
        return (ims.core.domain.objects.TransportBooking) domMap.get(key);
      }
      domainObject =
          (ims.core.domain.objects.TransportBooking)
              domainFactory.getDomainObject(ims.core.domain.objects.TransportBooking.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_TransportBooking());

    ims.scheduling.vo.Booking_AppointmentRefVoCollection refCollection1 =
        valueObject.getAppointments();
    int size1 = (null == refCollection1) ? 0 : refCollection1.size();
    java.util.Set domainAppointments1 = domainObject.getAppointments();
    if (domainAppointments1 == null) {
      domainAppointments1 = new java.util.HashSet();
    }
    java.util.Set newSet1 = new java.util.HashSet();
    for (int i = 0; i < size1; i++) {
      ims.scheduling.vo.Booking_AppointmentRefVo vo = refCollection1.get(i);
      ims.scheduling.domain.objects.Booking_Appointment dom = null;
      if (null != vo) {
        if (vo.getBoId() == null) {
          if (domMap.get(vo) != null) {
            dom = (ims.scheduling.domain.objects.Booking_Appointment) domMap.get(vo);
          }
        } else {
          dom =
              (ims.scheduling.domain.objects.Booking_Appointment)
                  domainFactory.getDomainObject(
                      ims.scheduling.domain.objects.Booking_Appointment.class, vo.getBoId());
        }
      }

      // Trying to avoid the hibernate collection being marked as dirty via its public interface
      // methods. (like add)
      if (!domainAppointments1.contains(dom)) {
        domainAppointments1.add(dom);
      }
      newSet1.add(dom);
    }
    java.util.Set removedSet1 = new java.util.HashSet();
    java.util.Iterator iter1 = domainAppointments1.iterator();
    // Find out which objects need to be removed
    while (iter1.hasNext()) {
      ims.domain.DomainObject o = (ims.domain.DomainObject) iter1.next();
      if ((o == null || o.getIsRIE() == null || !o.getIsRIE().booleanValue())
          && !newSet1.contains(o)) {
        removedSet1.add(o);
      }
    }
    iter1 = removedSet1.iterator();
    // Remove the unwanted objects
    while (iter1.hasNext()) {
      domainAppointments1.remove(iter1.next());
    }

    domainObject.setAppointments(domainAppointments1);
    java.util.Date value2 = null;
    ims.framework.utils.Date date2 = valueObject.getDateBooked();
    if (date2 != null) {
      value2 = date2.getDate();
    }
    domainObject.setDateBooked(value2);
    // 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.getBookingReference() != null && valueObject.getBookingReference().equals("")) {
      valueObject.setBookingReference(null);
    }
    domainObject.setBookingReference(valueObject.getBookingReference());
    ims.core.admin.domain.objects.CareContext value5 = null;
    if (null != valueObject.getCareContext()) {
      if (valueObject.getCareContext().getBoId() == null) {
        if (domMap.get(valueObject.getCareContext()) != null) {
          value5 =
              (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
      {
        value5 = domainObject.getCareContext();
      } else {
        value5 =
            (ims.core.admin.domain.objects.CareContext)
                domainFactory.getDomainObject(
                    ims.core.admin.domain.objects.CareContext.class,
                    valueObject.getCareContext().getBoId());
      }
    }
    domainObject.setCareContext(value5);

    return domainObject;
  }
  public static ims.core.admin.domain.objects.Referral extractReferral(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.core.vo.PASReferralVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_Referral();
    ims.core.admin.domain.objects.Referral domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.core.admin.domain.objects.Referral) domMap.get(valueObject);
      }
      // ims.core.vo.PASReferralVo ID_Referral field is unknown
      domainObject = new ims.core.admin.domain.objects.Referral();
      domMap.put(valueObject, domainObject);
    } else {
      String key = (valueObject.getClass().getName() + "__" + valueObject.getID_Referral());
      if (domMap.get(key) != null) {
        return (ims.core.admin.domain.objects.Referral) domMap.get(key);
      }
      domainObject =
          (ims.core.admin.domain.objects.Referral)
              domainFactory.getDomainObject(ims.core.admin.domain.objects.Referral.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_Referral());

    // 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.getDetails() != null && valueObject.getDetails().equals("")) {
      valueObject.setDetails(null);
    }
    domainObject.setDetails(valueObject.getDetails());
    java.util.Date value2 = null;
    ims.framework.utils.Date date2 = valueObject.getReferralReceivedDate();
    if (date2 != null) {
      value2 = date2.getDate();
    }
    domainObject.setReferralReceivedDate(value2);
    java.util.Date value3 = null;
    ims.framework.utils.Date date3 = valueObject.getOriginalReferralDate();
    if (date3 != null) {
      value3 = date3.getDate();
    }
    domainObject.setOriginalReferralDate(value3);
    ims.framework.utils.DateTime dateTime4 = valueObject.getFirstApptDate();
    java.util.Date value4 = null;
    if (dateTime4 != null) {
      value4 = dateTime4.getJavaDate();
    }
    domainObject.setFirstApptDate(value4);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value5 = null;
    if (null != valueObject.getSourceOfReferral()) {
      value5 = domainFactory.getLookupInstance(valueObject.getSourceOfReferral().getID());
    }
    domainObject.setSourceOfReferral(value5);
    // SaveAsRefVO - treated as a refVo in extract methods
    ims.core.resource.people.domain.objects.Gp value6 = null;
    if (null != valueObject.getReferringGP()) {
      if (valueObject.getReferringGP().getBoId() == null) {
        if (domMap.get(valueObject.getReferringGP()) != null) {
          value6 =
              (ims.core.resource.people.domain.objects.Gp) domMap.get(valueObject.getReferringGP());
        }
      } else {
        value6 =
            (ims.core.resource.people.domain.objects.Gp)
                domainFactory.getDomainObject(
                    ims.core.resource.people.domain.objects.Gp.class,
                    valueObject.getReferringGP().getBoId());
      }
    }
    domainObject.setReferringGP(value6);
    // SaveAsRefVO - treated as a refVo in extract methods
    ims.core.resource.people.domain.objects.Hcp value7 = null;
    if (null != valueObject.getReferringClinician()) {
      if (valueObject.getReferringClinician().getBoId() == null) {
        if (domMap.get(valueObject.getReferringClinician()) != null) {
          value7 =
              (ims.core.resource.people.domain.objects.Hcp)
                  domMap.get(valueObject.getReferringClinician());
        }
      } else {
        value7 =
            (ims.core.resource.people.domain.objects.Hcp)
                domainFactory.getDomainObject(
                    ims.core.resource.people.domain.objects.Hcp.class,
                    valueObject.getReferringClinician().getBoId());
      }
    }
    domainObject.setReferringClinician(value7);
    // SaveAsRefVO - treated as a refVo in extract methods
    ims.core.resource.people.domain.objects.Hcp value8 = null;
    if (null != valueObject.getReferredTo()) {
      if (valueObject.getReferredTo().getBoId() == null) {
        if (domMap.get(valueObject.getReferredTo()) != null) {
          value8 =
              (ims.core.resource.people.domain.objects.Hcp) domMap.get(valueObject.getReferredTo());
        }
      } else {
        value8 =
            (ims.core.resource.people.domain.objects.Hcp)
                domainFactory.getDomainObject(
                    ims.core.resource.people.domain.objects.Hcp.class,
                    valueObject.getReferredTo().getBoId());
      }
    }
    domainObject.setReferredTo(value8);
    // 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.getReferralDetails() != null && valueObject.getReferralDetails().equals("")) {
      valueObject.setReferralDetails(null);
    }
    domainObject.setReferralDetails(valueObject.getReferralDetails());
    java.util.Date value10 = null;
    ims.framework.utils.Date date10 = valueObject.getDateOfReferral();
    if (date10 != null) {
      value10 = date10.getDate();
    }
    domainObject.setDateOfReferral(value10);
    // 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.getReferralLocation() != null && valueObject.getReferralLocation().equals("")) {
      valueObject.setReferralLocation(null);
    }
    domainObject.setReferralLocation(valueObject.getReferralLocation());
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value12 = null;
    if (null != valueObject.getReferralType()) {
      value12 = domainFactory.getLookupInstance(valueObject.getReferralType().getID());
    }
    domainObject.setReferralType(value12);

    return domainObject;
  }
  public static ims.ocrr.orderingresults.domain.objects.SpecimenWorkListItem
      extractSpecimenWorkListItem(
          ims.domain.ILightweightDomainFactory domainFactory,
          ims.ocrr.vo.SpecimenWorkListItemListVo valueObject,
          HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_SpecimenWorkListItem();
    ims.ocrr.orderingresults.domain.objects.SpecimenWorkListItem domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.ocrr.orderingresults.domain.objects.SpecimenWorkListItem)
            domMap.get(valueObject);
      }
      // ims.ocrr.vo.SpecimenWorkListItemListVo ID_SpecimenWorkListItem field is unknown
      domainObject = new ims.ocrr.orderingresults.domain.objects.SpecimenWorkListItem();
      domMap.put(valueObject, domainObject);
    } else {
      String key =
          (valueObject.getClass().getName() + "__" + valueObject.getID_SpecimenWorkListItem());
      if (domMap.get(key) != null) {
        return (ims.ocrr.orderingresults.domain.objects.SpecimenWorkListItem) domMap.get(key);
      }
      domainObject =
          (ims.ocrr.orderingresults.domain.objects.SpecimenWorkListItem)
              domainFactory.getDomainObject(
                  ims.ocrr.orderingresults.domain.objects.SpecimenWorkListItem.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_SpecimenWorkListItem());

    domainObject.setSpecimen(
        ims.ocrr.vo.domain.OrderSpecimenListVoAssembler.extractOrderSpecimen(
            domainFactory, valueObject.getSpecimen(), domMap));
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value2 = null;
    if (null != valueObject.getListType()) {
      value2 = domainFactory.getLookupInstance(valueObject.getListType().getID());
    }
    domainObject.setListType(value2);
    java.util.Date value3 = null;
    ims.framework.utils.Date date3 = valueObject.getDateToCollect();
    if (date3 != null) {
      value3 = date3.getDate();
    }
    domainObject.setDateToCollect(value3);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value4 = null;
    if (null != valueObject.getRoundToCollect()) {
      value4 = domainFactory.getLookupInstance(valueObject.getRoundToCollect().getID());
    }
    domainObject.setRoundToCollect(value4);
    ims.framework.utils.Time time5 = valueObject.getTimeToCollect();
    String value5 = null;
    if (time5 != null) {
      value5 = time5.toString();
    }
    domainObject.setTimeToCollect(value5);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value6 = null;
    if (null != valueObject.getCollectionStatus()) {
      value6 = domainFactory.getLookupInstance(valueObject.getCollectionStatus().getID());
    }
    domainObject.setCollectionStatus(value6);
    domainObject.setPrinted(valueObject.getPrinted());
    // SaveAsRefVO - treated as a refVo in extract methods
    ims.ocrr.orderingresults.domain.objects.OrderInvestigation value8 = null;
    if (null != valueObject.getDFTOrderInvestigation()) {
      if (valueObject.getDFTOrderInvestigation().getBoId() == null) {
        if (domMap.get(valueObject.getDFTOrderInvestigation()) != null) {
          value8 =
              (ims.ocrr.orderingresults.domain.objects.OrderInvestigation)
                  domMap.get(valueObject.getDFTOrderInvestigation());
        }
      } else {
        value8 =
            (ims.ocrr.orderingresults.domain.objects.OrderInvestigation)
                domainFactory.getDomainObject(
                    ims.ocrr.orderingresults.domain.objects.OrderInvestigation.class,
                    valueObject.getDFTOrderInvestigation().getBoId());
      }
    }
    domainObject.setDFTOrderInvestigation(value8);
    ims.core.resource.place.domain.objects.Location value9 = null;
    if (null != valueObject.getWard()) {
      if (valueObject.getWard().getBoId() == null) {
        if (domMap.get(valueObject.getWard()) != null) {
          value9 =
              (ims.core.resource.place.domain.objects.Location) domMap.get(valueObject.getWard());
        }
      } else if (valueObject.getBoVersion()
          == -1) // RefVo was not modified since obtained from the Assembler, no need to update the
                 // BO field
      {
        value9 = domainObject.getWard();
      } else {
        value9 =
            (ims.core.resource.place.domain.objects.Location)
                domainFactory.getDomainObject(
                    ims.core.resource.place.domain.objects.Location.class,
                    valueObject.getWard().getBoId());
      }
    }
    domainObject.setWard(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.oncology.domain.objects.PathologyDetails extractPathologyDetails(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.clinicaladmin.vo.PathologyDetailsVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_PathologyDetails();
    ims.oncology.domain.objects.PathologyDetails domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.oncology.domain.objects.PathologyDetails) domMap.get(valueObject);
      }
      // ims.clinicaladmin.vo.PathologyDetailsVo ID_PathologyDetails field is unknown
      domainObject = new ims.oncology.domain.objects.PathologyDetails();
      domMap.put(valueObject, domainObject);
    } else {
      String key = (valueObject.getClass().getName() + "__" + valueObject.getID_PathologyDetails());
      if (domMap.get(key) != null) {
        return (ims.oncology.domain.objects.PathologyDetails) domMap.get(key);
      }
      domainObject =
          (ims.oncology.domain.objects.PathologyDetails)
              domainFactory.getDomainObject(ims.oncology.domain.objects.PathologyDetails.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_PathologyDetails());

    domainObject.setInvasiveLesionSize(valueObject.getInvasiveLesionSize());
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value2 = null;
    if (null != valueObject.getSynchronousTumourIndicator()) {
      value2 = domainFactory.getLookupInstance(valueObject.getSynchronousTumourIndicator().getID());
    }
    domainObject.setSynchronousTumourIndicator(value2);
    domainObject.setHistology(
        ims.clinicaladmin.vo.domain.TumourHistologyLiteVoAssembler.extractTumourHistologySet(
            domainFactory, valueObject.getHistology(), domainObject.getHistology(), domMap));
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value4 = null;
    if (null != valueObject.getVascularLymphInvasion()) {
      value4 = domainFactory.getLookupInstance(valueObject.getVascularLymphInvasion().getID());
    }
    domainObject.setVascularLymphInvasion(value4);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value5 = null;
    if (null != valueObject.getExcisionMargin()) {
      value5 = domainFactory.getLookupInstance(valueObject.getExcisionMargin().getID());
    }
    domainObject.setExcisionMargin(value5);
    domainObject.setNumberNodesExamined(valueObject.getNumberNodesExamined());
    domainObject.setNodesPositiveNumber(valueObject.getNodesPositiveNumber());
    domainObject.setPathologicalTVal(
        ims.clinicaladmin.vo.domain.TumourGroupSiteTNMValueVoAssembler
            .extractTumourGroupSiteTNMValue(
                domainFactory, valueObject.getPathologicalTVal(), domMap));
    domainObject.setPathologicalNVal(
        ims.clinicaladmin.vo.domain.TumourGroupSiteTNMValueVoAssembler
            .extractTumourGroupSiteTNMValue(
                domainFactory, valueObject.getPathologicalNVal(), domMap));
    domainObject.setPathologicalMVal(
        ims.clinicaladmin.vo.domain.TumourGroupSiteTNMValueVoAssembler
            .extractTumourGroupSiteTNMValue(
                domainFactory, valueObject.getPathologicalMVal(), domMap));
    domainObject.setPathologicalOverall(
        ims.clinicaladmin.vo.domain.TumourGroupSiteOverallStagingVoAssembler
            .extractTumourGroupSiteOverallStaging(
                domainFactory, valueObject.getPathologicalOverall(), domMap));
    // 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.getServiceReportId() != null && valueObject.getServiceReportId().equals("")) {
      valueObject.setServiceReportId(null);
    }
    domainObject.setServiceReportId(valueObject.getServiceReportId());
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value13 = null;
    if (null != valueObject.getServiceReportStatus()) {
      value13 = domainFactory.getLookupInstance(valueObject.getServiceReportStatus().getID());
    }
    domainObject.setServiceReportStatus(value13);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value14 = null;
    if (null != valueObject.getSpecimenNature()) {
      value14 = domainFactory.getLookupInstance(valueObject.getSpecimenNature().getID());
    }
    domainObject.setSpecimenNature(value14);
    domainObject.setOrgaCodeRequester(
        ims.core.vo.domain.OrgLiteVoAssembler.extractOrganisation(
            domainFactory, valueObject.getOrgaCodeRequester(), domMap));
    domainObject.setCareProfCodeRequester(
        ims.core.vo.domain.HcpLiteVoAssembler.extractHcp(
            domainFactory, (ims.core.vo.HcpLiteVo) valueObject.getCareProfCodeRequester(), domMap));
    domainObject.setTCategoryExtended(
        ims.clinicaladmin.vo.domain.TumourGroupSiteTNMValueVoAssembler
            .extractTumourGroupSiteTNMValueSet(
                domainFactory,
                valueObject.getTCategoryExtended(),
                domainObject.getTCategoryExtended(),
                domMap));
    domainObject.setMCategoryExtended(
        ims.clinicaladmin.vo.domain.TumourGroupSiteTNMValueVoAssembler
            .extractTumourGroupSiteTNMValueSet(
                domainFactory,
                valueObject.getMCategoryExtended(),
                domainObject.getMCategoryExtended(),
                domMap));
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value19 = null;
    if (null != valueObject.getStatus()) {
      value19 = domainFactory.getLookupInstance(valueObject.getStatus().getID());
    }
    domainObject.setStatus(value19);
    domainObject.setAuthoringInformation(
        ims.core.vo.domain.AuthoringInformationVoAssembler.extractAuthoringInformation(
            domainFactory, valueObject.getAuthoringInformation(), domMap));
    domainObject.setAssociatedQuestions(
        ims.assessment.vo.domain.PatientAssessmentVoAssembler.extractPatientAssessment(
            domainFactory, valueObject.getAssociatedQuestions(), domMap));
    domainObject.setAssociatiatedTumourDetails(
        ims.oncology.vo.domain.PrimaryTumourDetailsShortVoAssembler.extractPrimaryTumourDetails(
            domainFactory, valueObject.getAssociatiatedTumourDetails(), domMap));
    domainObject.setGradeOfDifferentation(
        ims.clinicaladmin.vo.domain.TumourGroupHistopathologyGradeVoAssembler
            .extractTumourGroupHistopathologicGrade(
                domainFactory, valueObject.getGradeOfDifferentation(), domMap));
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value24 = null;
    if (null != valueObject.getInvestigationType()) {
      value24 = domainFactory.getLookupInstance(valueObject.getInvestigationType().getID());
    }
    domainObject.setInvestigationType(value24);
    java.util.Date value25 = null;
    ims.framework.utils.Date date25 = valueObject.getSampleReceiptDate();
    if (date25 != null) {
      value25 = date25.getDate();
    }
    domainObject.setSampleReceiptDate(value25);
    java.util.Date value26 = null;
    ims.framework.utils.Date date26 = valueObject.getInvestigationResultDate();
    if (date26 != null) {
      value26 = date26.getDate();
    }
    domainObject.setInvestigationResultDate(value26);
    domainObject.setReportingConsultantCode(
        ims.core.vo.domain.HcpLiteVoAssembler.extractHcp(
            domainFactory,
            (ims.core.vo.HcpLiteVo) valueObject.getReportingConsultantCode(),
            domMap));
    domainObject.setReportingOrganisation(
        ims.core.vo.domain.OrgLiteVoAssembler.extractOrganisation(
            domainFactory, valueObject.getReportingOrganisation(), domMap));
    ims.core.admin.domain.objects.CareContext value29 = null;
    if (null != valueObject.getCareContext()) {
      if (valueObject.getCareContext().getBoId() == null) {
        if (domMap.get(valueObject.getCareContext()) != null) {
          value29 =
              (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
      {
        value29 = domainObject.getCareContext();
      } else {
        value29 =
            (ims.core.admin.domain.objects.CareContext)
                domainFactory.getDomainObject(
                    ims.core.admin.domain.objects.CareContext.class,
                    valueObject.getCareContext().getBoId());
      }
    }
    domainObject.setCareContext(value29);
    ims.oncology.domain.objects.PathologyDetails value30 = null;
    if (null != valueObject.getPreviousVersion()) {
      if (valueObject.getPreviousVersion().getBoId() == null) {
        if (domMap.get(valueObject.getPreviousVersion()) != null) {
          value30 =
              (ims.oncology.domain.objects.PathologyDetails)
                  domMap.get(valueObject.getPreviousVersion());
        }
      } else if (valueObject.getBoVersion()
          == -1) // RefVo was not modified since obtained from the Assembler, no need to update the
                 // BO field
      {
        value30 = domainObject.getPreviousVersion();
      } else {
        value30 =
            (ims.oncology.domain.objects.PathologyDetails)
                domainFactory.getDomainObject(
                    ims.oncology.domain.objects.PathologyDetails.class,
                    valueObject.getPreviousVersion().getBoId());
      }
    }
    domainObject.setPreviousVersion(value30);

    return domainObject;
  }
  public static ims.correspondence.domain.objects.CorrespondenceDetails
      extractCorrespondenceDetails(
          ims.domain.ILightweightDomainFactory domainFactory,
          ims.correspondence.vo.CorrespondenceDetailsVo valueObject,
          HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_CorrespondenceDetails();
    ims.correspondence.domain.objects.CorrespondenceDetails domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.correspondence.domain.objects.CorrespondenceDetails) domMap.get(valueObject);
      }
      // ims.correspondence.vo.CorrespondenceDetailsVo ID_CorrespondenceDetails field is unknown
      domainObject = new ims.correspondence.domain.objects.CorrespondenceDetails();
      domMap.put(valueObject, domainObject);
    } else {
      String key =
          (valueObject.getClass().getName() + "__" + valueObject.getID_CorrespondenceDetails());
      if (domMap.get(key) != null) {
        return (ims.correspondence.domain.objects.CorrespondenceDetails) domMap.get(key);
      }
      domainObject =
          (ims.correspondence.domain.objects.CorrespondenceDetails)
              domainFactory.getDomainObject(
                  ims.correspondence.domain.objects.CorrespondenceDetails.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_CorrespondenceDetails());

    ims.core.admin.pas.domain.objects.PASEvent value1 = null;
    if (null != valueObject.getPasEvent()) {
      if (valueObject.getPasEvent().getBoId() == null) {
        if (domMap.get(valueObject.getPasEvent()) != null) {
          value1 =
              (ims.core.admin.pas.domain.objects.PASEvent) domMap.get(valueObject.getPasEvent());
        }
      } else if (valueObject.getBoVersion()
          == -1) // RefVo was not modified since obtained from the Assembler, no need to update the
                 // BO field
      {
        value1 = domainObject.getPasEvent();
      } else {
        value1 =
            (ims.core.admin.pas.domain.objects.PASEvent)
                domainFactory.getDomainObject(
                    ims.core.admin.pas.domain.objects.PASEvent.class,
                    valueObject.getPasEvent().getBoId());
      }
    }
    domainObject.setPasEvent(value1);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value2 = null;
    if (null != valueObject.getCurrentStatus()) {
      value2 = domainFactory.getLookupInstance(valueObject.getCurrentStatus().getID());
    }
    domainObject.setCurrentStatus(value2);
    domainObject.setCspStatusHistory(
        ims.correspondence.vo.domain.CorrespondenceStatusHistoryVoAssembler
            .extractCorrespondenceStatusHistorySet(
                domainFactory,
                valueObject.getCspStatusHistory(),
                domainObject.getCspStatusHistory(),
                domMap));
    domainObject.setCategories(
        ims.correspondence.vo.domain.CategoryNotesVoAssembler.extractCategoryNotesList(
            domainFactory, valueObject.getCategories(), domainObject.getCategories(), domMap));
    domainObject.setRecipients(
        ims.correspondence.vo.domain.RecipientVoAssembler.extractRecipientList(
            domainFactory, valueObject.getRecipients(), domainObject.getRecipients(), domMap));
    domainObject.setCurrentDocument(
        ims.core.vo.domain.DocumentVoAssembler.extractDocument(
            domainFactory, valueObject.getCurrentDocument(), domMap));
    domainObject.setSignedBy(
        ims.core.vo.domain.MedicLiteVoAssembler.extractMedic(
            domainFactory, valueObject.getSignedBy(), domMap));
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value8 = null;
    if (null != valueObject.getSpecialInterest()) {
      value8 = domainFactory.getLookupInstance(valueObject.getSpecialInterest().getID());
    }
    domainObject.setSpecialInterest(value8);
    java.util.Date value9 = null;
    ims.framework.utils.Date date9 = valueObject.getDateOfClinic();
    if (date9 != null) {
      value9 = date9.getDate();
    }
    domainObject.setDateOfClinic(value9);
    java.util.Date value10 = null;
    ims.framework.utils.Date date10 = valueObject.getAdmissionDate();
    if (date10 != null) {
      value10 = date10.getDate();
    }
    domainObject.setAdmissionDate(value10);
    java.util.Date value11 = null;
    ims.framework.utils.Date date11 = valueObject.getDischargeDate();
    if (date11 != null) {
      value11 = date11.getDate();
    }
    domainObject.setDischargeDate(value11);
    domainObject.setDictatedBy(
        ims.core.vo.domain.MemberOfStaffLiteVoAssembler.extractMemberOfStaff(
            domainFactory, valueObject.getDictatedBy(), domMap));
    // 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.getDictatedByInitials() != null
        && valueObject.getDictatedByInitials().equals("")) {
      valueObject.setDictatedByInitials(null);
    }
    domainObject.setDictatedByInitials(valueObject.getDictatedByInitials());
    domainObject.setTypedBy(
        ims.core.vo.domain.MemberOfStaffLiteVoAssembler.extractMemberOfStaff(
            domainFactory, valueObject.getTypedBy(), domMap));
    // 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.getTypedByInitials() != null && valueObject.getTypedByInitials().equals("")) {
      valueObject.setTypedByInitials(null);
    }
    domainObject.setTypedByInitials(valueObject.getTypedByInitials());
    domainObject.setEnquiriesTo(
        ims.core.vo.domain.MemberOfStaffLiteVoAssembler.extractMemberOfStaff(
            domainFactory, valueObject.getEnquiriesTo(), domMap));
    domainObject.setWasTypedWithoutCaseNotes(valueObject.getWasTypedWithoutCaseNotes());

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

    domainObject.setStatusHistory(
        ims.clinical.vo.domain.PatientDiagnosisStatusVoAssembler.extractPatientDiagnosisStatusSet(
            domainFactory,
            valueObject.getStatusHistory(),
            domainObject.getStatusHistory(),
            domMap));
    // 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.getDiagnosisDescription() != null
        && valueObject.getDiagnosisDescription().equals("")) {
      valueObject.setDiagnosisDescription(null);
    }
    domainObject.setDiagnosisDescription(valueObject.getDiagnosisDescription());
    ims.framework.utils.PartialDate DiagnosedDate = valueObject.getDiagnosedDate();
    Integer value3 = null;
    if (null != DiagnosedDate) {
      value3 = DiagnosedDate.toInteger();
    }
    domainObject.setDiagnosedDate(value3);
    // SaveAsRefVO - treated as a refVo in extract methods
    ims.core.clinical.domain.objects.Diagnosis value4 = null;
    if (null != valueObject.getDiagnosis()) {
      if (valueObject.getDiagnosis().getBoId() == null) {
        if (domMap.get(valueObject.getDiagnosis()) != null) {
          value4 =
              (ims.core.clinical.domain.objects.Diagnosis) domMap.get(valueObject.getDiagnosis());
        }
      } else {
        value4 =
            (ims.core.clinical.domain.objects.Diagnosis)
                domainFactory.getDomainObject(
                    ims.core.clinical.domain.objects.Diagnosis.class,
                    valueObject.getDiagnosis().getBoId());
      }
    }
    domainObject.setDiagnosis(value4);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value5 = null;
    if (null != valueObject.getSourceofInformation()) {
      value5 = domainFactory.getLookupInstance(valueObject.getSourceofInformation().getID());
    }
    domainObject.setSourceofInformation(value5);
    domainObject.setIsComplication(valueObject.getIsComplication());
    domainObject.setIsComorbidity(valueObject.getIsComorbidity());
    java.util.Date value8 = null;
    ims.framework.utils.Date date8 = valueObject.getDateResolved();
    if (date8 != null) {
      value8 = date8.getDate();
    }
    domainObject.setDateResolved(value8);
    // SaveAsRefVO - treated as a refVo in extract methods
    ims.core.admin.domain.objects.CareContext value9 = null;
    if (null != valueObject.getCareContext()) {
      if (valueObject.getCareContext().getBoId() == null) {
        if (domMap.get(valueObject.getCareContext()) != null) {
          value9 =
              (ims.core.admin.domain.objects.CareContext) domMap.get(valueObject.getCareContext());
        }
      } else {
        value9 =
            (ims.core.admin.domain.objects.CareContext)
                domainFactory.getDomainObject(
                    ims.core.admin.domain.objects.CareContext.class,
                    valueObject.getCareContext().getBoId());
      }
    }
    domainObject.setCareContext(value9);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value10 = null;
    if (null != valueObject.getDiagLaterality()) {
      value10 = domainFactory.getLookupInstance(valueObject.getDiagLaterality().getID());
    }
    domainObject.setDiagLaterality(value10);
    // 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.getSiteText() != null && valueObject.getSiteText().equals("")) {
      valueObject.setSiteText(null);
    }
    domainObject.setSiteText(valueObject.getSiteText());
    domainObject.setAuthoringInfo(
        ims.core.vo.domain.AuthoringInformationVoAssembler.extractAuthoringInformation(
            domainFactory, valueObject.getAuthoringInfo(), domMap));
    domainObject.setIncludeDiagnosisInDiscReports(
        ims.core.vo.domain.IncludeDiagnosisInDischargeReportVoAssembler
            .extractIncludeDiagnosisInDischargeReportSet(
                domainFactory,
                valueObject.getIncludeDiagnosisInDiscReports(),
                domainObject.getIncludeDiagnosisInDiscReports(),
                domMap));
    domainObject.setIsPrevRelevantDiagnosis(valueObject.getIsPrevRelevantDiagnosis());
    java.util.Date value16 = null;
    ims.framework.utils.Date date16 = valueObject.getDateOnset();
    if (date16 != null) {
      value16 = date16.getDate();
    }
    domainObject.setDateOnset(value16);
    ims.core.admin.domain.objects.ClinicalContact value17 = null;
    if (null != valueObject.getClinicalContact()) {
      if (valueObject.getClinicalContact().getBoId() == null) {
        if (domMap.get(valueObject.getClinicalContact()) != null) {
          value17 =
              (ims.core.admin.domain.objects.ClinicalContact)
                  domMap.get(valueObject.getClinicalContact());
        }
      } else if (valueObject.getBoVersion()
          == -1) // RefVo was not modified since obtained from the Assembler, no need to update the
      // BO field
      {
        value17 = domainObject.getClinicalContact();
      } else {
        value17 =
            (ims.core.admin.domain.objects.ClinicalContact)
                domainFactory.getDomainObject(
                    ims.core.admin.domain.objects.ClinicalContact.class,
                    valueObject.getClinicalContact().getBoId());
      }
    }
    domainObject.setClinicalContact(value17);
    domainObject.setPrimaryForCareSpells(
        ims.core.vo.domain.CSPrimaryDiagnosisVoAssembler.extractCsPrimaryDiagnosisSet(
            domainFactory,
            valueObject.getPrimaryForCareSpells(),
            domainObject.getPrimaryForCareSpells(),
            domMap));
    domainObject.setCoMorbidityForEpisodeOfCares(
        ims.core.vo.domain.EpisodeOfCareCoMorbidityVoAssembler.extractEpisodeOfCareCoMorbiditySet(
            domainFactory,
            valueObject.getCoMorbidityForEpisodeOfCares(),
            domainObject.getCoMorbidityForEpisodeOfCares(),
            domMap));
    ims.core.admin.domain.objects.EpisodeOfCare value20 = null;
    if (null != valueObject.getEpisodeOfCare()) {
      if (valueObject.getEpisodeOfCare().getBoId() == null) {
        if (domMap.get(valueObject.getEpisodeOfCare()) != null) {
          value20 =
              (ims.core.admin.domain.objects.EpisodeOfCare)
                  domMap.get(valueObject.getEpisodeOfCare());
        }
      } else if (valueObject.getBoVersion()
          == -1) // RefVo was not modified since obtained from the Assembler, no need to update the
      // BO field
      {
        value20 = domainObject.getEpisodeOfCare();
      } else {
        value20 =
            (ims.core.admin.domain.objects.EpisodeOfCare)
                domainFactory.getDomainObject(
                    ims.core.admin.domain.objects.EpisodeOfCare.class,
                    valueObject.getEpisodeOfCare().getBoId());
      }
    }
    domainObject.setEpisodeOfCare(value20);
    domainObject.setDiagnosedOnAdmission(valueObject.getDiagnosedOnAdmission());

    return domainObject;
  }
  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;
  }