public ArrayList<Specialty> listSpecialties(Specialty filterLookup)
      throws DomainInterfaceException {
    if (filterLookup == null)
      throw new DomainInterfaceException("Can not search on null speciality filter");

    ArrayList<Specialty> specialtiesList = new ArrayList<Specialty>();

    ArrayList<String> searchWords = new ArrayList<String>();

    filterLookup.setText(filterLookup.getText().replaceAll(" ", "%"));
    String[] split = filterLookup.getText().split("%");

    for (int i = split.length - 1; i >= 0; i--) {
      if (!(split[i].equalsIgnoreCase(""))) searchWords.add(split[i]);
    }

    LookupService lookup = this.getLookupService();
    SpecialtyCollection collection =
        (SpecialtyCollection)
            lookup.getLookupCollection(
                Specialty.TYPE_ID, SpecialtyCollection.class, Specialty.class);

    for (int i = 0; i < collection.size(); i++) {
      Specialty specialty = collection.get(i);

      if (containsText(specialty, searchWords)) specialtiesList.add(specialty);
    }

    return specialtiesList;
  }
  protected final void oncmbSpecialtyValueSet(Object value) {
    java.util.ArrayList listOfValues =
        this.form.lyrMappings().tabExternal().cmbSpecialty().getValues();

    if (value == null) {
      if (listOfValues != null && listOfValues.size() > 0) {
        for (int x = 0; x < listOfValues.size(); x++) {
          ims.core.vo.lookups.Specialty existingInstance =
              (ims.core.vo.lookups.Specialty) listOfValues.get(x);
          if (!existingInstance.isActive()) {
            bindcmbSpecialtyLookup();
            return;
          }
        }
      }
    } else if (value instanceof ims.core.vo.lookups.Specialty) {
      ims.core.vo.lookups.Specialty instance = (ims.core.vo.lookups.Specialty) value;

      if (listOfValues != null) {
        if (listOfValues.size() == 0) bindcmbSpecialtyLookup();

        for (int x = 0; x < listOfValues.size(); x++) {
          ims.core.vo.lookups.Specialty existingInstance =
              (ims.core.vo.lookups.Specialty) listOfValues.get(x);
          if (existingInstance.equals(instance)) return;
        }
      }

      this.form
          .lyrMappings()
          .tabExternal()
          .cmbSpecialty()
          .newRow(instance, instance.getText(), instance.getImage(), instance.getTextColor());
    }
  }
 public void populate(
     ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.PasEventShortAdmitVoBean bean) {
   this.id = bean.getId();
   this.version = bean.getVersion();
   this.patient = bean.getPatient() == null ? null : bean.getPatient().buildVo(map);
   this.paseventid = bean.getPasEventId();
   this.eventdatetime =
       bean.getEventDateTime() == null ? null : bean.getEventDateTime().buildDateTime();
   this.location =
       bean.getLocation() == null
           ? null
           : new ims.core.resource.place.vo.LocationRefVo(
               new Integer(bean.getLocation().getId()), bean.getLocation().getVersion());
   this.consultant =
       bean.getConsultant() == null
           ? null
           : new ims.core.resource.people.vo.MedicRefVo(
               new Integer(bean.getConsultant().getId()), bean.getConsultant().getVersion());
   this.specialty =
       bean.getSpecialty() == null
           ? null
           : ims.core.vo.lookups.Specialty.buildLookup(bean.getSpecialty());
   this.passpecialty =
       bean.getPASSpecialty() == null
           ? null
           : ims.core.vo.lookups.PASSpecialty.buildLookup(bean.getPASSpecialty());
   this.sourceofreferral =
       bean.getSourceOfReferral() == null
           ? null
           : ims.core.vo.lookups.SourceOfReferral.buildLookup(bean.getSourceOfReferral());
   this.eventtype =
       bean.getEventType() == null
           ? null
           : ims.core.vo.lookups.PasEventType.buildLookup(bean.getEventType());
 }
  private boolean containsText(Specialty specialty, ArrayList<String> searchWords) {
    for (int i = 0; i < searchWords.size(); i++)
      if (specialty.getText().toUpperCase().indexOf(searchWords.get(i).toUpperCase()) == -1)
        return false;

    return true;
  }
 public ifPartialAdmissionVo(ims.emergency.vo.beans.ifPartialAdmissionVoBean bean) {
   this.id = bean.getId();
   this.version = bean.getVersion();
   this.specialty =
       bean.getSpecialty() == null
           ? null
           : ims.core.vo.lookups.Specialty.buildLookup(bean.getSpecialty());
   this.allocatedstatus =
       bean.getAllocatedStatus() == null
           ? null
           : ims.emergency.vo.lookups.AllocationStatus.buildLookup(bean.getAllocatedStatus());
   this.allocatedward = bean.getAllocatedWard() == null ? null : bean.getAllocatedWard().buildVo();
 }
  /**
   * Update the ValueObject with the Domain Object.
   *
   * @param map DomainObjectMap of DomainObjects to already created ValueObjects.
   * @param valueObject to be updated
   * @param domainObject ims.core.clinical.domain.objects.Service
   */
  public static ims.core.vo.ServiceShortVo insert(
      DomainObjectMap map,
      ims.core.vo.ServiceShortVo valueObject,
      ims.core.clinical.domain.objects.Service domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

    valueObject.setID_Service(domainObject.getId());
    valueObject.setIsRIE(domainObject.getIsRIE());

    // If this is a recordedInError record, and the domainObject
    // value isIncludeRecord has not been set, then we return null and
    // not the value object
    if (valueObject.getIsRIE() != null
        && valueObject.getIsRIE().booleanValue() == true
        && !domainObject.isIncludeRecord()) return null;

    // If this is not a recordedInError record, and the domainObject
    // value isIncludeRecord has been set, then we return null and
    // not the value object
    if ((valueObject.getIsRIE() == null || valueObject.getIsRIE().booleanValue() == false)
        && domainObject.isIncludeRecord()) return null;

    // ServiceDescription
    valueObject.setServiceDescription(domainObject.getServiceDescription());
    // isActive
    valueObject.setIsActive(domainObject.isIsActive());
    // AlternateServiceCode
    valueObject.setAlternateServiceCode(domainObject.getAlternateServiceCode());
    // ServiceName
    valueObject.setServiceName(domainObject.getServiceName());
    // ServiceCategory
    ims.domain.lookups.LookupInstance instance5 = domainObject.getServiceCategory();
    if (null != instance5) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance5.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance5.getImage().getImageId(), instance5.getImage().getImagePath());
      }
      color = instance5.getColor();
      if (color != null) color.getValue();

      ims.core.vo.lookups.ServiceCategory voLookup5 =
          new ims.core.vo.lookups.ServiceCategory(
              instance5.getId(), instance5.getText(), instance5.isActive(), null, img, color);
      ims.core.vo.lookups.ServiceCategory parentVoLookup5 = voLookup5;
      ims.domain.lookups.LookupInstance parent5 = instance5.getParent();
      while (parent5 != null) {
        if (parent5.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent5.getImage().getImageId(), parent5.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent5.getColor();
        if (color != null) color.getValue();
        parentVoLookup5.setParent(
            new ims.core.vo.lookups.ServiceCategory(
                parent5.getId(), parent5.getText(), parent5.isActive(), null, img, color));
        parentVoLookup5 = parentVoLookup5.getParent();
        parent5 = parent5.getParent();
      }
      valueObject.setServiceCategory(voLookup5);
    }
    // CanBeScheduled
    valueObject.setCanBeScheduled(domainObject.isCanBeScheduled());
    // Specialty
    ims.domain.lookups.LookupInstance instance7 = domainObject.getSpecialty();
    if (null != instance7) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance7.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance7.getImage().getImageId(), instance7.getImage().getImagePath());
      }
      color = instance7.getColor();
      if (color != null) color.getValue();

      ims.core.vo.lookups.Specialty voLookup7 =
          new ims.core.vo.lookups.Specialty(
              instance7.getId(), instance7.getText(), instance7.isActive(), null, img, color);
      ims.core.vo.lookups.Specialty parentVoLookup7 = voLookup7;
      ims.domain.lookups.LookupInstance parent7 = instance7.getParent();
      while (parent7 != null) {
        if (parent7.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent7.getImage().getImageId(), parent7.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent7.getColor();
        if (color != null) color.getValue();
        parentVoLookup7.setParent(
            new ims.core.vo.lookups.Specialty(
                parent7.getId(), parent7.getText(), parent7.isActive(), null, img, color));
        parentVoLookup7 = parentVoLookup7.getParent();
        parent7 = parent7.getParent();
      }
      valueObject.setSpecialty(voLookup7);
    }
    // ExpectedTurnaround
    valueObject.setExpectedTurnaround(domainObject.getExpectedTurnaround());
    // TurnaroundMeasure
    ims.domain.lookups.LookupInstance instance9 = domainObject.getTurnaroundMeasure();
    if (null != instance9) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance9.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance9.getImage().getImageId(), instance9.getImage().getImagePath());
      }
      color = instance9.getColor();
      if (color != null) color.getValue();

      ims.ocrr.vo.lookups.MinReorderPeriod voLookup9 =
          new ims.ocrr.vo.lookups.MinReorderPeriod(
              instance9.getId(), instance9.getText(), instance9.isActive(), null, img, color);
      ims.ocrr.vo.lookups.MinReorderPeriod parentVoLookup9 = voLookup9;
      ims.domain.lookups.LookupInstance parent9 = instance9.getParent();
      while (parent9 != null) {
        if (parent9.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent9.getImage().getImageId(), parent9.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent9.getColor();
        if (color != null) color.getValue();
        parentVoLookup9.setParent(
            new ims.ocrr.vo.lookups.MinReorderPeriod(
                parent9.getId(), parent9.getText(), parent9.isActive(), null, img, color));
        parentVoLookup9 = parentVoLookup9.getParent();
        parent9 = parent9.getParent();
      }
      valueObject.setTurnaroundMeasure(voLookup9);
    }
    // MaternityIndicator
    valueObject.setMaternityIndicator(domainObject.isMaternityIndicator());
    return valueObject;
  }
  /**
   * Update the ValueObject with the Domain Object.
   *
   * @param map DomainObjectMap of DomainObjects to already created ValueObjects.
   * @param valueObject to be updated
   * @param domainObject ims.core.clinical.domain.objects.Service
   */
  public static ims.admin.vo.ServiceForElectiveListConfigVo insert(
      DomainObjectMap map,
      ims.admin.vo.ServiceForElectiveListConfigVo valueObject,
      ims.core.clinical.domain.objects.Service domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

    valueObject.setID_Service(domainObject.getId());
    valueObject.setIsRIE(domainObject.getIsRIE());

    // If this is a recordedInError record, and the domainObject
    // value isIncludeRecord has not been set, then we return null and
    // not the value object
    if (valueObject.getIsRIE() != null
        && valueObject.getIsRIE().booleanValue() == true
        && !domainObject.isIncludeRecord()) return null;

    // If this is not a recordedInError record, and the domainObject
    // value isIncludeRecord has been set, then we return null and
    // not the value object
    if ((valueObject.getIsRIE() == null || valueObject.getIsRIE().booleanValue() == false)
        && domainObject.isIncludeRecord()) return null;

    // ServiceName
    valueObject.setServiceName(domainObject.getServiceName());
    // ServiceDescription
    valueObject.setServiceDescription(domainObject.getServiceDescription());
    // ServiceCategory
    ims.domain.lookups.LookupInstance instance3 = domainObject.getServiceCategory();
    if (null != instance3) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance3.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance3.getImage().getImageId(), instance3.getImage().getImagePath());
      }
      color = instance3.getColor();
      if (color != null) color.getValue();

      ims.core.vo.lookups.ServiceCategory voLookup3 =
          new ims.core.vo.lookups.ServiceCategory(
              instance3.getId(), instance3.getText(), instance3.isActive(), null, img, color);
      ims.core.vo.lookups.ServiceCategory parentVoLookup3 = voLookup3;
      ims.domain.lookups.LookupInstance parent3 = instance3.getParent();
      while (parent3 != null) {
        if (parent3.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent3.getImage().getImageId(), parent3.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent3.getColor();
        if (color != null) color.getValue();
        parentVoLookup3.setParent(
            new ims.core.vo.lookups.ServiceCategory(
                parent3.getId(), parent3.getText(), parent3.isActive(), null, img, color));
        parentVoLookup3 = parentVoLookup3.getParent();
        parent3 = parent3.getParent();
      }
      valueObject.setServiceCategory(voLookup3);
    }
    // Specialty
    ims.domain.lookups.LookupInstance instance4 = domainObject.getSpecialty();
    if (null != instance4) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance4.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance4.getImage().getImageId(), instance4.getImage().getImagePath());
      }
      color = instance4.getColor();
      if (color != null) color.getValue();

      ims.core.vo.lookups.Specialty voLookup4 =
          new ims.core.vo.lookups.Specialty(
              instance4.getId(), instance4.getText(), instance4.isActive(), null, img, color);
      ims.core.vo.lookups.Specialty parentVoLookup4 = voLookup4;
      ims.domain.lookups.LookupInstance parent4 = instance4.getParent();
      while (parent4 != null) {
        if (parent4.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent4.getImage().getImageId(), parent4.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent4.getColor();
        if (color != null) color.getValue();
        parentVoLookup4.setParent(
            new ims.core.vo.lookups.Specialty(
                parent4.getId(), parent4.getText(), parent4.isActive(), null, img, color));
        parentVoLookup4 = parentVoLookup4.getParent();
        parent4 = parent4.getParent();
      }
      valueObject.setSpecialty(voLookup4);
    }
    // isActive
    valueObject.setIsActive(domainObject.isIsActive());
    // UpperName
    valueObject.setUpperName(domainObject.getUpperName());
    return valueObject;
  }