public ims.clinicaladmin.vo.TreatmentInterventionLiteVoCollection listTreatmentsInterventions(
      String criteria, String listOfTreatmentsInterventionsAllreadyAdded) {
    if (criteria == null || criteria.length() == 0)
      throw new CodingRuntimeException("Cannot search on null TreatmentIntervention name.");

    DomainFactory factory = getDomainFactory();
    StringBuilder query =
        new StringBuilder(
            "select ti from TreatmentIntervention as ti left join ti.keywords as kw where ti.isActive = 1 and ti.id not in (select tisec.id from TreatmentInterventionHotlist as th left join th.hotListItem as titem left join titem.treatmentIntervention as tisec left join th.specialty as sp where sp.id = :Emergency) and (ti.treatmentInterventionName like :TreatmentName or kw.keyword like :TreatmentName) ");

    if (listOfTreatmentsInterventionsAllreadyAdded != null
        && listOfTreatmentsInterventionsAllreadyAdded.length() > 0) {
      query.append(" and ti.id not in (" + listOfTreatmentsInterventionsAllreadyAdded + ") ");
    }

    query.append(" order by UPPER(ti.treatmentInterventionName) asc");

    List<?> tiList =
        factory.find(
            query.toString(),
            new String[] {"Emergency", "TreatmentName"},
            new Object[] {Specialty.EMERGENCY.getID(), criteria + "%"});

    return TreatmentInterventionLiteVoAssembler
        .createTreatmentInterventionLiteVoCollectionFromTreatmentIntervention(tiList);
  }
  public ims.clinicaladmin.vo.TreatmentInterventionLiteVoCollection
      listTreatmentsInterventionsFromHotlist(
          String listOfTreatmentsInterventionsAllreadyAdded, TreatmentInterventionType type) {
    DomainFactory factory = getDomainFactory();
    StringBuilder query =
        new StringBuilder(
            "select ti from TreatmentInterventionHotlist as th left join th.hotListItem as titem left join titem.treatmentIntervention as ti left join th.specialty as sp left join ti.treatmentInterventionType as tType where sp.id = :Emergency and ti.isActive = 1 ");

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

    markers.add("Emergency");
    values.add(Specialty.EMERGENCY.getID());

    if (listOfTreatmentsInterventionsAllreadyAdded != null
        && listOfTreatmentsInterventionsAllreadyAdded.length() > 0) {
      query.append(" and ti.id not in (" + listOfTreatmentsInterventionsAllreadyAdded + ") ");
    }

    if (type != null) {
      query.append(" and tType.id = :TType ");
      markers.add("TType");
      values.add(type.getID());
    }

    query.append(" order by UPPER(tType.text) asc, UPPER(ti.treatmentInterventionName) asc");

    List<?> tiList = factory.find(query.toString(), markers, values);

    return TreatmentInterventionLiteVoAssembler
        .createTreatmentInterventionLiteVoCollectionFromTreatmentIntervention(tiList);
  }