Ejemplo n.º 1
0
  /**
   * Adds a match against RegistryObjectIndex, i.e. the indexed fields from the blob xml. </br> Uses
   * OR for multi values and LIKE to match.
   */
  protected void addIndexMatch(
      BooleanBuilder builder,
      NumberPath<Long> registryObjectPk,
      StoredQueryParam param,
      XDSSearchIndexKey key) {

    // No match needed if param not specified
    if (param == null) return;

    QRegistryObjectIndex index = QRegistryObjectIndex.registryObjectIndex;

    // perform an OR for the list of values in QueryParam
    BooleanExpression orExpr;
    BooleanBuilder andBuilder = new BooleanBuilder();
    List<String> values;
    for (int i = 0, len = param.getNumberOfANDElements(); i < len; i++) {
      orExpr = null;
      if (param.isMultiValue()) {
        values = param.getMultiValues(i);
        for (String val : values)
          orExpr = orExpr == null ? index.value.like(val) : orExpr.or(index.value.like(val));
      } else {
        orExpr = index.value.like(param.getStringValue());
      }
      andBuilder.and(orExpr);
    }
    // add this expression as subquery
    JPASubQuery subq =
        new JPASubQuery()
            .from(index)
            .where(index.subject.pk.eq(registryObjectPk).and(index.key.eq(key)).and(andBuilder));
    builder.and(subq.exists());
  }
Ejemplo n.º 2
0
 private List<Predicate> getValuePredicate(StoredQueryParam param, StringPath valuePath) {
   List<Predicate> predicates = new ArrayList<Predicate>();
   List<String> values;
   for (int i = 0, len = param.getNumberOfANDElements(); i < len; i++) {
     values =
         param.isMultiValue() ? param.getMultiValues(i) : Arrays.asList(param.getStringValue());
     BooleanBuilder predicate = new BooleanBuilder();
     List<String> eqValues = new ArrayList<String>();
     for (String v : values) {
       if (v.indexOf('%') != -1 || v.indexOf('_') != -1) {
         predicate.or(valuePath.like(v));
       } else {
         eqValues.add(v);
       }
     }
     if (eqValues.size() > 0) {
       if (eqValues.size() > 1) {
         predicate.or(valuePath.in(eqValues));
       } else {
         predicate.or(valuePath.eq(eqValues.get(0)));
       }
     }
     predicates.add(predicate);
   }
   return predicates;
 }
Ejemplo n.º 3
0
 /**
  * Add code matches in XDS form using XDSCode entity
  *
  * @param builder BooleanBuilder to add matches for given code parameter
  * @param codeParam Stored Query Parameter with code values
  * @param codeType The classification of the codes (Classification.classificationScheme)
  * @param xdsCodes The CollectionPath for XDSCodes of parent select (to bind subselect)
  * @throws XDSException
  */
 protected void addXdsCodeMatch(
     BooleanBuilder builder,
     StoredQueryParam codeParam,
     String codeClassification,
     CollectionPath<XDSCode, QXDSCode> xdsCodes)
     throws XDSException {
   if (codeParam != null) {
     List<String> codeValues;
     String[] codeAndScheme;
     for (int i = 0, len = codeParam.getNumberOfANDElements(); i < len; i++) {
       codeValues = codeParam.getMultiValues(i);
       BooleanBuilder codesBuilder = new BooleanBuilder();
       for (int j = 0, jLen = codeValues.size(); j < jLen; j++) {
         codeAndScheme = toCodeValueAndScheme(codeValues.get(j));
         codesBuilder.or(
             ExpressionUtils.allOf(
                 QXDSCode.xDSCode.codeClassification.eq(codeClassification),
                 QXDSCode.xDSCode.codeValue.eq(codeAndScheme[0]),
                 QXDSCode.xDSCode.codingSchemeDesignator.eq(codeAndScheme[1])));
       }
       builder.and(
           new JPASubQuery()
               .from(QXDSCode.xDSCode)
               .where(QXDSCode.xDSCode.in(xdsCodes), codesBuilder)
               .exists());
     }
   }
 }
Ejemplo n.º 4
0
 protected void addStatusMatch(
     BooleanBuilder builder, StringPath status, StoredQueryParam statusParam) {
   List<String> stati = statusParam.getMultiValues(0);
   if (stati == null) {
     builder.and(status.eq(statusParam.getStringValue()));
   } else if (stati.size() == 1) {
     builder.and(status.eq(stati.get(0)));
   } else if (stati.size() > 1) {
     builder.and(status.in(stati));
   }
 }
Ejemplo n.º 5
0
 public StoredQuery(AdhocQueryRequest req, XDSRegistryBean session) throws XDSException {
   this.req = req;
   this.session = session;
   queryParam = StoredQueryParam.getQueryParams(req);
   log.info(
       "AdhocQueryRequest " + req.getAdhocQuery().getId() + ": params:" + queryParam.values());
   checkRequiredParameter();
 }
Ejemplo n.º 6
0
 protected XDSDocumentEntry getDocumentEntry() throws XDSException {
   StoredQueryParam param;
   XDSDocumentEntry doc;
   if ((param = getQueryParam(XDSConstants.QRY_DOCUMENT_UNIQUE_ID)) != null) {
     if (getQueryParam(XDSConstants.QRY_DOCUMENT_ENTRY_UUID) != null) {
       throw new XDSException(
           XDSException.XDS_ERR_REGISTRY_ERROR,
           "Both $XDSDocumentEntryUUID and $XDSDocumentEntryUniqueId are specified!",
           null);
     }
     doc = getSession().getDocumentEntryByUniqueId(param.getStringValue());
   } else {
     param = getQueryParam(XDSConstants.QRY_DOCUMENT_ENTRY_UUID);
     doc = getSession().getDocumentEntryByUUID(param.getStringValue());
   }
   log.debug("#### Found Document:" + doc);
   return doc;
 }
Ejemplo n.º 7
0
 protected void addFromToMatch(
     BooleanBuilder builder,
     StoredQueryParam fromParam,
     StoredQueryParam toParam,
     NumberPath<Long> subselectJoinPk,
     String slotName) {
   String from =
       fromParam == null ? null : XDSUtil.normalizeDTM(fromParam.getStringValue(), false);
   String to = toParam == null ? null : XDSUtil.normalizeDTM(toParam.getStringValue(), true);
   if (from != null || to != null) {
     Predicate fromTo =
         from == null
             ? QSlot.slot.value.loe(to)
             : to != null
                 ? ExpressionUtils.allOf(QSlot.slot.value.goe(from), QSlot.slot.value.loe(to))
                 : QSlot.slot.value.goe(from);
     builder.and(
         new JPASubQuery()
             .from(QSlot.slot)
             .where(QSlot.slot.parent.pk.eq(subselectJoinPk), QSlot.slot.name.eq(slotName), fromTo)
             .exists());
   }
 }
Ejemplo n.º 8
0
 protected void addPatientIdMatch(BooleanBuilder builder, StoredQueryParam pid)
     throws XDSException {
   if (pid.isMultiValue())
     throw new XDSException(
         XDSException.XDS_ERR_STORED_QUERY_PARAM_NUMBER,
         this.getClass().getSimpleName()
             + " - "
             + pid.getName()
             + " only accepts a single value but is coded with multiple values!",
         null);
   try {
     XADPatient qryPat = new XADPatient(pid.getStringValue());
     patID = qryPat.getCXPatientID();
     builder.and(QXADPatient.xADPatient.patientID.eq(qryPat.getPatientID()));
     builder.and(
         QXADIssuer.xADIssuer.universalID.eq(qryPat.getIssuerOfPatientID().getUniversalID()));
     builder.and(QXADPatient.xADPatient.linkedPatient.isNull());
   } catch (Exception x) {
     throw new XDSException(
         XDSException.XDS_ERR_PATID_DOESNOT_MATCH,
         "PatientID is not correct! " + x.getMessage(),
         null);
   }
 }