@Search() public List<Observation> searchByObservationNames( @RequiredParam(name=Observation.SP_CODE) TokenOrListParam theCodings ) { // The list here will contain 0..* codings, and any observations which match any of the // given codings should be returned List<TokenParam> wantedCodings = theCodings.getValuesAsQueryTokens(); List<Observation> retVal = new ArrayList<Observation>(); // ...populate... return retVal; } //END SNIPPET: searchMultiple
@Override TokenOrListParam newInstance() { return new TokenOrListParam(); }
/** * Create a new token "OR list" with a single token, or multiple tokens which have the same system value * * @param theSystem * The system to use for the one token to pre-populate in this list * @param theValues * The values to use for the one token to pre-populate in this list */ public TokenOrListParam(String theSystem, String... theValues) { for (String next : theValues) { add(theSystem, next); } }
private int doSyncSubscriptions() { synchronized (mySyncSubscriptionsLock) { ourLog.debug("Starting sync subscriptions"); SearchParameterMap map = new SearchParameterMap(); map.add(Subscription.SP_STATUS, new TokenOrListParam() // TODO KHS perhaps we should only be requesting ACTIVE subscriptions here?... .addOr(new TokenParam(null, Subscription.SubscriptionStatus.REQUESTED.toCode())) .addOr(new TokenParam(null, Subscription.SubscriptionStatus.ACTIVE.toCode()))); map.setLoadSynchronousUpTo(SubscriptionConstants.MAX_SUBSCRIPTION_RESULTS); IBundleProvider subscriptionBundleList = mySubscriptionProvidor.search(map); if (subscriptionBundleList.size() >= SubscriptionConstants.MAX_SUBSCRIPTION_RESULTS) { ourLog.error("Currently over " + SubscriptionConstants.MAX_SUBSCRIPTION_RESULTS + " subscriptions. Some subscriptions have not been loaded."); } List<IBaseResource> resourceList = subscriptionBundleList.getResources(0, subscriptionBundleList.size()); Set<String> allIds = new HashSet<>(); int changesCount = 0; for (IBaseResource resource : resourceList) { String nextId = resource.getIdElement().getIdPart(); allIds.add(nextId); boolean changed = mySubscriptionProvidor.loadSubscription(resource); if (changed) { changesCount++; } } mySubscriptionRegistry.unregisterAllSubscriptionsNotInCollection(allIds); ourLog.debug("Finished sync subscriptions - found {}", resourceList.size()); return changesCount; } }
public boolean doesCodingListMatch(List<? extends BaseCodingDt> theCodings) { List<BaseCodingDt> paramCodings = getListAsCodings(); for (BaseCodingDt coding : theCodings) { for (BaseCodingDt paramCoding : paramCodings) { if (coding.matchesToken(paramCoding)) { return true; } } } return false; }
public boolean doesCodingListMatch(List<? extends BaseCodingDt> theCodings) { List<BaseCodingDt> paramCodings = getListAsCodings(); for (BaseCodingDt coding : theCodings) { for (BaseCodingDt paramCoding : paramCodings) { if (coding.matchesToken(paramCoding)) { return true; } } } return false; }
public List<BaseCodingDt> getListAsCodings() { ArrayList<BaseCodingDt> retVal = new ArrayList<BaseCodingDt>(); for (TokenParam next : getValuesAsQueryTokens()) { InternalCodingDt nextCoding = next.getValueAsCoding(); if (!nextCoding.isEmpty()) { retVal.add(nextCoding); } } return retVal; }
/** * Add a new token to this list * @param theSystem * The system to use for the one token to pre-populate in this list */ public TokenOrListParam add(String theSystem, String theValue) { add(new TokenParam(theSystem, theValue)); return this; }
@Override TokenOrListParam newInstance() { return new TokenOrListParam(); }
@Search public List<IBaseResource> searchById( @RequiredParam(name = "_id") TokenAndListParam theIds) { List<IBaseResource> retVal = new ArrayList<>(); for (TreeMap<Long, T> next : myIdToVersionToResourceMap.values()) { if (next.isEmpty() == false) { T nextResource = next.lastEntry().getValue(); boolean matches = true; if (theIds != null && theIds.getValuesAsQueryTokens().size() > 0) { for (TokenOrListParam nextIdAnd : theIds.getValuesAsQueryTokens()) { matches = false; for (TokenParam nextOr : nextIdAnd.getValuesAsQueryTokens()) { if (nextOr.getValue().equals(nextResource.getIdElement().getIdPart())) { matches = true; } } if (!matches) { break; } } } if (!matches) { continue; } retVal.add(nextResource); } } mySearchCount.incrementAndGet(); return retVal; }
@CoverageIgnore @Override public TokenOrListParam addOr(TokenParam theParameter) { add(theParameter); return this; }
@Override public List<TokenParam> getPatientIdParam() { if (_id != null) return Collections.singletonList(_id); if (identifiers != null) return identifiers.getValuesAsQueryTokens().stream() .flatMap(tol -> tol.getValuesAsQueryTokens().stream()) .collect(Collectors.toList()); return Collections.emptyList(); } }
/** * Convenience method which adds a token to this OR list using the system and code from a coding */ public void add(BaseCodingDt theCodingDt) { add(new TokenParam(theCodingDt)); }
@Override public List<TokenParam> getPatientIdParam() { if (_id != null) return Collections.singletonList(_id); if (identifiers != null) return identifiers.getValuesAsQueryTokens().stream() .flatMap(tol -> tol.getValuesAsQueryTokens().stream()) .collect(Collectors.toList()); return Collections.emptyList(); } }
/** * Convenience method which adds a token to this OR list using the system and value from an identifier */ public void add(BaseIdentifierDt theIdentifierDt) { add(new TokenParam(theIdentifierDt)); }
public List<BaseCodingDt> getListAsCodings() { ArrayList<BaseCodingDt> retVal = new ArrayList<BaseCodingDt>(); for (TokenParam next : getValuesAsQueryTokens()) { InternalCodingDt nextCoding = next.getValueAsCoding(); if (!nextCoding.isEmpty()) { retVal.add(nextCoding); } } return retVal; }
/** * Create a new token "OR list" with a single token, or multiple tokens which have the same system value * * @param theSystem * The system to use for the one token to pre-populate in this list * @param theValues * The values to use for the one token to pre-populate in this list */ public TokenOrListParam(String theSystem, String... theValues) { for (String next : theValues) { add(theSystem, next); } }
@Search public List<IBaseResource> searchById( @RequiredParam(name = "_id") TokenAndListParam theIds) { List<IBaseResource> retVal = new ArrayList<>(); for (TreeMap<Long, T> next : myIdToVersionToResourceMap.values()) { if (next.isEmpty() == false) { T nextResource = next.lastEntry().getValue(); boolean matches = true; if (theIds != null && theIds.getValuesAsQueryTokens().size() > 0) { for (TokenOrListParam nextIdAnd : theIds.getValuesAsQueryTokens()) { matches = false; for (TokenParam nextOr : nextIdAnd.getValuesAsQueryTokens()) { if (nextOr.getValue().equals(nextResource.getIdElement().getIdPart())) { matches = true; } } if (!matches) { break; } } } if (!matches) { continue; } retVal.add(nextResource); } } mySearchCount.incrementAndGet(); return retVal; }
/** * Convenience method which adds a token to this OR list using the system and code from a coding */ public void add(BaseCodingDt theCodingDt) { add(new TokenParam(theCodingDt)); }
/** * Convenience method which adds a token to this OR list using the system and value from an identifier */ public void add(BaseIdentifierDt theIdentifierDt) { add(new TokenParam(theIdentifierDt)); }