use of ca.uhn.fhir.rest.param.StringParam in project cqf-ruler by DBCG.
the class Searches method byName.
public static SearchParameterMap byName(String theName, String theVersion) {
checkNotNull(theName);
checkNotNull(theVersion);
return byName(theName).add(VERSION_SP, new StringParam(theVersion));
}
use of ca.uhn.fhir.rest.param.StringParam in project cqf-ruler by DBCG.
the class Searches method byUrl.
public static SearchParameterMap byUrl(String theUrl, String theVersion) {
checkNotNull(theUrl);
checkNotNull(theVersion);
return byParam(URL_SP, new UriParam(theUrl)).add(VERSION_SP, new StringParam(theVersion));
}
use of ca.uhn.fhir.rest.param.StringParam in project cqf-ruler by DBCG.
the class CacheValueSetsProvider method cacheValuesets.
/**
* Using basic authentication this {@link Operation Operation} will update
* any {@link ValueSet Valueset} listed given the {@link Endpoint Endpoint}
* provided.
* Any Valuesets that require expansion will be expanded.
*
* @param details the {@link RequestDetails RequestDetails}
* @param endpointId the {@link Endpoint Endpoint} id
* @param valuesets the {@link StringAndListParam list} of {@link ValueSet
* Valueset} ids
* @param userName the userName
* @param password the password
* @return the {@link OperationOutcome OperationOutcome} or the resulting
* {@link Bundle Bundle}
*/
@Description(shortDefinition = "$cache-valuesets", value = "Using basic authentication this Operation will update any Valueset listed given the Endpoint provided. Any Valuesets that require expansion will be expanded.", example = "Endpoint/example-id/$cache-valuesets?valuesets=valuesetId1&valuesets=valuesetId2&user=user&password=password")
@Operation(name = "$cache-valuesets", idempotent = true, type = Endpoint.class)
public Resource cacheValuesets(RequestDetails details, @IdParam IdType endpointId, @OperationParam(name = "valuesets") StringAndListParam valuesets, @OperationParam(name = "user") String userName, @OperationParam(name = "pass") String password) {
Endpoint endpoint = null;
try {
endpoint = this.endpointDao.read(endpointId);
if (endpoint == null) {
return createErrorOutcome("Could not find Endpoint/" + endpointId);
}
} catch (Exception e) {
return createErrorOutcome("Could not find Endpoint/" + endpointId + "\n" + e);
}
IGenericClient client = Clients.forEndpoint(ourCtx, endpoint);
if (userName != null || password != null) {
if (userName == null) {
return createErrorOutcome("Password was provided, but not a user name.");
} else if (password == null) {
return createErrorOutcome("User name was provided, but not a password.");
}
BasicAuthInterceptor basicAuth = new BasicAuthInterceptor(userName, password);
client.registerInterceptor(basicAuth);
// TODO - more advanced security like bearer tokens, etc...
}
try {
Bundle bundleToPost = new Bundle();
for (StringOrListParam params : valuesets.getValuesAsQueryTokens()) {
for (StringParam valuesetId : params.getValuesAsQueryTokens()) {
bundleToPost.addEntry().setRequest(new Bundle.BundleEntryRequestComponent().setMethod(Bundle.HTTPVerb.PUT).setUrl("ValueSet/" + valuesetId.getValue())).setResource(resolveValueSet(client, valuesetId.getValue()));
}
}
return (Resource) systemDao.transaction(details, bundleToPost);
} catch (Exception e) {
return createErrorOutcome(e.getMessage());
}
}
use of ca.uhn.fhir.rest.param.StringParam in project cqf-ruler by DBCG.
the class CacheValueSetsProvider method cacheValuesets.
/**
* Using basic authentication this {@link Operation Operation} will update
* any {@link ValueSet Valueset} listed given the {@link Endpoint Endpoint}
* provided.
* Any Valuesets that require expansion will be expanded.
*
* @param details the {@link RequestDetails RequestDetails}
* @param endpointId the {@link Endpoint Endpoint} id
* @param valuesets the {@link StringAndListParam list} of {@link ValueSet
* Valueset} ids
* @param userName the userName
* @param password the password
* @return the {@link OperationOutcome OperationOutcome} or the resulting
* {@link Bundle Bundle}
*/
@Description(shortDefinition = "$cache-valuesets", value = "Using basic authentication this Operation will update any Valueset listed given the Endpoint provided. Any Valuesets that require expansion will be expanded.", example = "Endpoint/example-id/$cache-valuesets?valuesets=valuesetId1&valuesets=valuesetId2&user=user&password=password")
@Operation(name = "cache-valuesets", idempotent = true, type = Endpoint.class)
public Resource cacheValuesets(RequestDetails details, @IdParam IdType endpointId, @OperationParam(name = "valuesets") StringAndListParam valuesets, @OperationParam(name = "user") String userName, @OperationParam(name = "pass") String password) {
Endpoint endpoint = null;
try {
endpoint = this.endpointDao.read(endpointId);
if (endpoint == null) {
return createErrorOutcome("Could not find Endpoint/" + endpointId);
}
} catch (Exception e) {
return createErrorOutcome("Could not find Endpoint/" + endpointId + "\n" + e);
}
IGenericClient client = Clients.forEndpoint(ourCtx, endpoint);
if (userName != null || password != null) {
if (userName == null) {
return createErrorOutcome("Password was provided, but not a user name.");
} else if (password == null) {
return createErrorOutcome("User name was provided, but not a password.");
}
BasicAuthInterceptor basicAuth = new BasicAuthInterceptor(userName, password);
client.registerInterceptor(basicAuth);
// TODO - more advanced security like bearer tokens, etc...
}
try {
Bundle bundleToPost = new Bundle();
for (StringOrListParam params : valuesets.getValuesAsQueryTokens()) {
for (StringParam valuesetId : params.getValuesAsQueryTokens()) {
bundleToPost.addEntry().setRequest(new Bundle.BundleEntryRequestComponent().setMethod(Bundle.HTTPVerb.PUT).setUrl("ValueSet/" + valuesetId.getValue())).setResource(resolveValueSet(client, valuesetId.getValue()));
}
}
return (Resource) systemDao.transaction(details, bundleToPost);
} catch (Exception e) {
return createErrorOutcome(e.getMessage());
}
}
use of ca.uhn.fhir.rest.param.StringParam in project MobileAccessGateway by i4mi.
the class Iti67RequestConverter method searchParameterIti67ToFindDocumentsQuery.
/**
* convert ITI-67 request to ITI-18 request
* @param searchParameter
* @return
*/
public QueryRegistry searchParameterIti67ToFindDocumentsQuery(@Body Iti67SearchParameters searchParameter) {
boolean getLeafClass = true;
Query searchQuery = null;
if (searchParameter.get_id() != null || searchParameter.getIdentifier() != null) {
GetDocumentsQuery query = new GetDocumentsQuery();
if (searchParameter.getIdentifier() != null) {
String val = searchParameter.getIdentifier().getValue();
if (val.startsWith("urn:oid:")) {
query.setUniqueIds(Collections.singletonList(val.substring("urn:oid:".length())));
} else if (val.startsWith("urn:uuid:")) {
query.setUuids(Collections.singletonList(val.substring("urn:uuid:".length())));
}
} else {
query.setUuids(Collections.singletonList(searchParameter.get_id().getValue()));
}
searchQuery = query;
} else {
FindDocumentsQuery query;
// TODO related Note 4 --> $XDSDocumentEntryReferenceIdList
TokenOrListParam related = searchParameter.getRelated();
if (related != null) {
FindDocumentsByReferenceIdQuery referenceIdQuery = new FindDocumentsByReferenceIdQuery();
;
QueryList<ReferenceId> outerReferences = new QueryList<ReferenceId>();
List<ReferenceId> references = new ArrayList<ReferenceId>();
for (TokenParam token : related.getValuesAsQueryTokens()) {
references.add(new ReferenceId(token.getValue(), null, getScheme(token.getSystem())));
}
outerReferences.getOuterList().add(references);
referenceIdQuery.setTypedReferenceIds(outerReferences);
query = referenceIdQuery;
} else
query = new FindDocumentsQuery();
// query.setMetadataLevel(metadataLevel);
// status --> $XDSDocumentEntryStatus
TokenOrListParam status = searchParameter.getStatus();
if (status != null) {
List<AvailabilityStatus> availabilites = new ArrayList<AvailabilityStatus>();
for (TokenParam statusToken : status.getValuesAsQueryTokens()) {
String tokenValue = statusToken.getValue();
if (tokenValue.equals("current"))
availabilites.add(AvailabilityStatus.APPROVED);
else if (tokenValue.equals("superseded"))
availabilites.add(AvailabilityStatus.DEPRECATED);
}
query.setStatus(availabilites);
}
// patient or patient.identifier --> $XDSDocumentEntryPatientId
TokenParam tokenIdentifier = searchParameter.getPatientIdentifier();
if (tokenIdentifier != null) {
String system = getScheme(tokenIdentifier.getSystem());
if (system == null)
throw new InvalidRequestException("Missing OID for patient");
query.setPatientId(new Identifiable(tokenIdentifier.getValue(), new AssigningAuthority(system)));
}
ReferenceParam patientRef = searchParameter.getPatientReference();
if (patientRef != null) {
Identifiable id = transformReference(patientRef.getValue());
query.setPatientId(id);
}
// date Note 1 Note 5 --> $DSDocumentEntryCreationTimeFrom
// date Note 2 Note 5 --> $XDSDocumentEntryCreationTimeTo
DateRangeParam dateRange = searchParameter.getDate();
if (dateRange != null) {
DateParam creationTimeFrom = dateRange.getLowerBound();
DateParam creationTimeTo = dateRange.getUpperBound();
query.getCreationTime().setFrom(timestampFromDateParam(creationTimeFrom));
query.getCreationTime().setTo(timestampFromDateParam(creationTimeTo));
}
// period Note 1 --> $XDSDocumentEntryServiceStartTimeFrom
// period Note 2 --> $XDSDocumentEntryServiceStartTimeTo
// period Note 1 --> $XDSDocumentEntryServiceStopTimeFrom
// period Note 2 --> $XDSDocumentEntryServiceStopTimeTo
DateRangeParam periodRange = searchParameter.getPeriod();
if (periodRange != null) {
DateParam periodFrom = periodRange.getLowerBound();
DateParam periodTo = periodRange.getUpperBound();
query.getServiceStopTime().setFrom(timestampFromDateParam(periodFrom));
query.getServiceStartTime().setTo(timestampFromDateParam(periodTo));
}
// category --> $XDSDocumentEntryClassCode
TokenOrListParam categories = searchParameter.getCategory();
query.setClassCodes(codesFromTokens(categories));
// type --> $XDSDocumentEntryTypeCode
TokenOrListParam types = searchParameter.getType();
query.setTypeCodes(codesFromTokens(types));
// setting --> $XDSDocumentEntryPracticeSettingCode
TokenOrListParam settings = searchParameter.getSetting();
query.setPracticeSettingCodes(codesFromTokens(settings));
// facility --> $XDSDocumentEntryHealthcareFacilityTypeCode
TokenOrListParam facilities = searchParameter.getFacility();
query.setHealthcareFacilityTypeCodes(codesFromTokens(facilities));
// event --> $XDSDocumentEntryEventCodeList
TokenOrListParam events = searchParameter.getEvent();
if (events != null) {
QueryList<Code> eventCodeList = new QueryList<Code>();
eventCodeList.getOuterList().add(codesFromTokens(events));
query.setEventCodes(eventCodeList);
}
// security-label --> $XDSDocumentEntryConfidentialityCode
TokenOrListParam securityLabels = searchParameter.getSecurityLabel();
if (securityLabels != null) {
QueryList<Code> confidentialityCodes = new QueryList<Code>();
confidentialityCodes.getOuterList().add(codesFromTokens(securityLabels));
query.setConfidentialityCodes(confidentialityCodes);
}
// format --> $XDSDocumentEntryFormatCode
TokenOrListParam formats = searchParameter.getFormat();
query.setFormatCodes(codesFromTokens(formats));
// TODO author.given / author.family --> $XDSDocumentEntryAuthorPerson
StringParam authorGivenName = searchParameter.getAuthorGivenName();
StringParam authorFamilyName = searchParameter.getAuthorFamilyName();
if (authorGivenName != null || authorFamilyName != null) {
Person person = new Person();
XcnName name = new XcnName();
if (authorFamilyName != null)
name.setFamilyName(authorFamilyName.getValue());
if (authorGivenName != null)
name.setGivenName(authorGivenName.getValue());
person.setName(name);
// String author = (authorGivenName != null ? authorGivenName.getValue() : "%")+" "+(authorFamilyName != null ? authorFamilyName.getValue() : "%");
List<Person> authorPersons = Collections.singletonList(person);
query.setTypedAuthorPersons(authorPersons);
}
searchQuery = query;
}
final QueryRegistry queryRegistry = new QueryRegistry(searchQuery);
queryRegistry.setReturnType((getLeafClass) ? QueryReturnType.LEAF_CLASS : QueryReturnType.OBJECT_REF);
return queryRegistry;
}
Aggregations