// wdev-13733
 public ContractConfigShortVo getContractConfig(Integer contractConfigId) {
   if (contractConfigId == null) {
     throw new DomainRuntimeException("Invalid contract ref provided");
   }
   return ContractConfigShortVoAssembler.create(
       (ContractConfig)
           getDomainFactory().getDomainObject(ContractConfig.class, contractConfigId));
 }
  public ContractConfigShortVoCollection listContracts(
      String name,
      OrganisationRefVo organisation,
      ReferralManagementContractType contractType,
      String contractId,
      PreActiveActiveInactiveStatus status,
      Boolean diagnostic,
      Boolean nonDiagnostic) {
    if ((name == null || name.length() == 0)
        && (organisation == null || !organisation.getID_OrganisationIsNotNull())
        && (contractId == null || contractId.length() == 0)
        && status == null
        && Boolean.FALSE.equals(diagnostic)
        && Boolean.FALSE.equals(nonDiagnostic)
        && contractType == null) // wdev-12676
    {
      throw new DomainRuntimeException("No search criteria specified");
    }

    StringBuilder hqlBuilder = new StringBuilder("from ContractConfig as cc where ( ");
    ArrayList<String> paramNames = new ArrayList<String>();
    ArrayList<Object> paramValues = new ArrayList<Object>();
    Boolean flagOpenParenthesiz = Boolean.FALSE;
    String and = "";
    if (contractId != null && contractId.length() > 0) {
      hqlBuilder.append("cc.contractId like :cID ");
      and = "and ";
      paramNames.add("cID");
      paramValues.add("%" + contractId + "%");
    }

    if (organisation != null && organisation.getID_OrganisationIsNotNull()) {
      hqlBuilder.append(and);
      hqlBuilder.append(" cc.contractOrganisation.id = :cOrg ");
      and = "and ";
      paramNames.add("cOrg");
      paramValues.add(organisation.getID_Organisation());
    }

    if (contractType != null) {
      hqlBuilder.append(and);
      hqlBuilder.append(" cc.contractType.id = :cType ");
      and = "and ";
      paramNames.add("cType");
      paramValues.add(contractType.getID());
    }

    if (name != null && name.length() > 0) {
      hqlBuilder.append(and);
      hqlBuilder.append(" cc.contractName like :cName ");
      and = "and ";
      paramNames.add("cName");
      paramValues.add("%" + name + "%");
    }
    if (status != null) {
      hqlBuilder.append(and);
      hqlBuilder.append(" cc.status.id = :status ");
      and = "and ";
      paramNames.add("status");
      paramValues.add(status.getID());
    }
    // wdev-12676

    if (diagnostic != null && diagnostic.equals(Boolean.TRUE)) {
      hqlBuilder.append(and);
      hqlBuilder.append("(");
      flagOpenParenthesiz = Boolean.TRUE;
      hqlBuilder.append(" cc.contractType.id = :diagnostic ");
      and = "or ";
      paramNames.add("diagnostic");
      paramValues.add(ReferralManagementContractType.DIAGNOSTIC.getID());
    }
    // wdev-12676
    if (nonDiagnostic != null && nonDiagnostic.equals(Boolean.TRUE)) {
      hqlBuilder.append(and);
      if (flagOpenParenthesiz.equals(Boolean.FALSE)) {
        hqlBuilder.append("(");
        flagOpenParenthesiz = Boolean.TRUE;
      }

      hqlBuilder.append(" cc.contractType.id = :nondiagnostic ");

      paramNames.add("nondiagnostic");
      paramValues.add(ReferralManagementContractType.NONDIAGNOSTIC.getID());
    }
    if (flagOpenParenthesiz.equals(Boolean.TRUE)) // wdev-12676
    hqlBuilder.append(" )");

    hqlBuilder.append(") order by upper(cc.contractId)");

    List<?> dos = getDomainFactory().find(hqlBuilder.toString(), paramNames, paramValues);

    if (dos == null || dos.size() == 0) return null;

    return ContractConfigShortVoAssembler.createContractConfigShortVoCollectionFromContractConfig(
        dos);
  }