use of org.hl7.fhir.r4.model.CapabilityStatement in project org.hl7.fhir.core by hapifhir.
the class TerminologyCacheTests method testCachePersistence.
@Test
public void testCachePersistence() throws IOException, URISyntaxException {
Object lock = new Object();
Path tempCacheDirectory = createTempCacheDirectory();
ValueSet valueSet = new ValueSet();
valueSet.setUrl("dummyValueSetURL");
TerminologyCapabilities terminologyCapabilities = new TerminologyCapabilities();
terminologyCapabilities.getExpansion().setParameter(Arrays.asList());
CapabilityStatement.CapabilityStatementSoftwareComponent software = new CapabilityStatement.CapabilityStatementSoftwareComponent();
software.setVersion("dummyVersion");
CapabilityStatement capabilityStatement = new CapabilityStatement();
capabilityStatement.setSoftware(software);
Coding coding = new Coding();
coding.setCode("dummyCode");
CodeableConcept concept = new CodeableConcept();
concept.addCoding(new Coding().setCode("dummyCode"));
ValueSet ccvalueSet = new ValueSet();
// Add dummy results to the cache
TerminologyCache terminologyCacheA = new TerminologyCache(lock, tempCacheDirectory.toString());
terminologyCacheA.cacheTerminologyCapabilities(terminologyCapabilities);
terminologyCacheA.cacheCapabilityStatement(capabilityStatement);
IWorkerContext.ValidationResult codingResultA = new IWorkerContext.ValidationResult(ValidationMessage.IssueSeverity.INFORMATION, "dummyInfo");
TerminologyCache.CacheToken codingTokenA = terminologyCacheA.generateValidationToken(CacheTestUtils.validationOptions, coding, valueSet);
terminologyCacheA.cacheValidation(codingTokenA, codingResultA, true);
IWorkerContext.ValidationResult codeableConceptResultA = new IWorkerContext.ValidationResult(ValidationMessage.IssueSeverity.INFORMATION, "dummyInfo");
TerminologyCache.CacheToken codeableConceptTokenA = terminologyCacheA.generateValidationToken(CacheTestUtils.validationOptions, concept, valueSet);
terminologyCacheA.cacheValidation(codeableConceptTokenA, codeableConceptResultA, true);
TerminologyCache.CacheToken expansionTokenA = terminologyCacheA.generateExpandToken(valueSet, true);
ValueSetExpander.ValueSetExpansionOutcome expansionOutcomeA = new ValueSetExpander.ValueSetExpansionOutcome(valueSet);
terminologyCacheA.cacheExpansion(expansionTokenA, expansionOutcomeA, true);
// Check that the in-memory cache is returning what we put in
{
assertEquals(terminologyCapabilities, terminologyCacheA.getTerminologyCapabilities());
assertEquals(capabilityStatement, terminologyCacheA.getCapabilityStatement());
assertValidationResultEquals(codingResultA, terminologyCacheA.getValidation(codingTokenA));
assertValidationResultEquals(codeableConceptResultA, terminologyCacheA.getValidation(codeableConceptTokenA));
assertExpansionOutcomeEquals(expansionOutcomeA, terminologyCacheA.getExpansion(expansionTokenA));
}
// Create another cache using the same directory, and check that it gives the same results.
{
TerminologyCache terminologyCacheB = new TerminologyCache(lock, tempCacheDirectory.toString());
assertCanonicalResourceEquals(terminologyCapabilities, terminologyCacheB.getTerminologyCapabilities());
assertCanonicalResourceEquals(capabilityStatement, terminologyCacheB.getCapabilityStatement());
assertValidationResultEquals(codingResultA, terminologyCacheB.getValidation(terminologyCacheA.generateValidationToken(CacheTestUtils.validationOptions, coding, valueSet)));
assertValidationResultEquals(codeableConceptResultA, terminologyCacheB.getValidation(terminologyCacheA.generateValidationToken(CacheTestUtils.validationOptions, concept, valueSet)));
assertExpansionOutcomeEquals(expansionOutcomeA, terminologyCacheB.getExpansion(terminologyCacheA.generateExpandToken(valueSet, true)));
}
deleteTempCacheDirectory(tempCacheDirectory);
}
use of org.hl7.fhir.r4.model.CapabilityStatement in project pathling by aehrc.
the class ConformanceProvider method getServerConformance.
@Override
@Metadata(cacheMillis = 0)
public CapabilityStatement getServerConformance(@Nullable final HttpServletRequest httpServletRequest, @Nullable final RequestDetails requestDetails) {
log.debug("Received request for server capabilities");
final CapabilityStatement capabilityStatement = new CapabilityStatement();
capabilityStatement.setUrl(getCapabilityUri());
capabilityStatement.setVersion(version.getBuildVersion().orElse(UNKNOWN_VERSION));
capabilityStatement.setTitle("Pathling FHIR API");
capabilityStatement.setName("pathling-fhir-api");
capabilityStatement.setStatus(PublicationStatus.ACTIVE);
capabilityStatement.setExperimental(true);
capabilityStatement.setPublisher("Australian e-Health Research Centre, CSIRO");
capabilityStatement.setCopyright("Dedicated to the public domain via CC0: https://creativecommons.org/publicdomain/zero/1.0/");
capabilityStatement.setKind(CapabilityStatementKind.INSTANCE);
final CapabilityStatementSoftwareComponent software = new CapabilityStatementSoftwareComponent(new StringType("Pathling"));
software.setVersion(version.getDescriptiveVersion().orElse(UNKNOWN_VERSION));
capabilityStatement.setSoftware(software);
final CapabilityStatementImplementationComponent implementation = new CapabilityStatementImplementationComponent(new StringType(configuration.getImplementationDescription()));
final Optional<String> serverBase = getServerBase(Optional.ofNullable(httpServletRequest));
serverBase.ifPresent(implementation::setUrl);
capabilityStatement.setImplementation(implementation);
capabilityStatement.setFhirVersion(FHIRVersion._4_0_1);
capabilityStatement.setFormat(Arrays.asList(new CodeType("json"), new CodeType("xml")));
capabilityStatement.setRest(buildRestComponent());
return capabilityStatement;
}
use of org.hl7.fhir.r4.model.CapabilityStatement in project gpconnect-demonstrator by nhsconnect.
the class GpConnectServerCapabilityStatementProvider method getServerConformance.
@Override
public CapabilityStatement getServerConformance(HttpServletRequest theRequest) {
final boolean FROM_JSON = true;
CapabilityStatement capabilityStatement = null;
if (!FROM_JSON) {
// Get the automatically generated statement
capabilityStatement = super.getServerConformance(theRequest);
// added at 1.2.2 force overwrite the default entries which are not correct
for (CapabilityStatement.CapabilityStatementRestComponent st : capabilityStatement.getRest()) {
for (CapabilityStatement.CapabilityStatementRestOperationComponent operation : st.getOperation()) {
String opPlusDollar = "$" + operation.getName();
switch(opPlusDollar) {
case REGISTER_PATIENT_OPERATION_NAME:
operation.getDefinition().setReference(OD_GPC_REGISTER_PATIENT);
break;
case GET_STRUCTURED_RECORD_OPERATION_NAME:
operation.getDefinition().setReference(OD_GPC_GET_STRUCTURED_RECORD);
break;
}
}
}
} else {
try {
// 1.2.6 #316
String interactionId = theRequest.getHeader(SSP_INTERACTIONID);
String capabilityFile = null;
switch(interactionId) {
case REST_READ_STRUCTURED_METADATA:
capabilityFile = "structured_capability.json";
break;
default:
capabilityFile = "capability.json";
}
// read a json capability file
String capabilityJson = new String(Files.readAllBytes(Paths.get(FhirRequestGenericIntercepter.getConfigPath() + "/" + capabilityFile)));
FhirContext ctx = FhirContext.forDstu3();
capabilityStatement = (CapabilityStatement) ctx.newJsonParser().parseResource(capabilityJson);
} catch (IOException ex) {
return null;
}
}
// And add additional required information
capabilityStatement.setVersion(SystemVariable.VERSION);
capabilityStatement.setDescription("This server implements the GP Connect API version " + SystemVariable.VERSION);
capabilityStatement.setName("GP Connect");
capabilityStatement.setCopyright("Copyright NHS Digital 2018");
capabilityStatement.getSoftware().setReleaseDate(Date.valueOf(LocalDate.parse("2017-09-27")));
return capabilityStatement;
}
use of org.hl7.fhir.r4.model.CapabilityStatement in project clinical_quality_language by cqframework.
the class ElmDataRequirement method applyJoinRequirementTo.
private void applyJoinRequirementTo(ElmJoinRequirement joinRequirement, Retrieve retrieve, ElmRequirementsContext context, ElmQueryRequirement queryRequirements) {
ElmDataRequirement leftRequirement = queryRequirements.getDataRequirement(joinRequirement.getLeftProperty().getSource());
ElmDataRequirement rightRequirement = queryRequirements.getDataRequirement(joinRequirement.getRightProperty().getSource());
if (leftRequirement != null && rightRequirement != null) {
Retrieve leftRetrieve = leftRequirement.getRetrieve();
Retrieve rightRetrieve = rightRequirement.getRetrieve();
// Only report include possibility if the retrieves can both be tied to the data model
if (leftRetrieve.getDataType() != null && rightRetrieve.getDataType() != null) {
ClassType leftRetrieveType = getRetrieveType(context, leftRetrieve);
ClassType rightRetrieveType = getRetrieveType(context, rightRetrieve);
if (leftRetrieveType != null && rightRetrieveType != null) {
SearchType leftSearch;
SearchType rightSearch;
for (SearchType search : leftRetrieveType.getSearches()) {
if (joinRequirement.getLeftProperty().getProperty().getPath().startsWith(search.getPath())) {
if (search.getType().isCompatibleWith(rightRetrieveType)) {
leftSearch = search;
break;
}
}
}
for (SearchType search : rightRetrieveType.getSearches()) {
if (joinRequirement.getRightProperty().getProperty().getPath().startsWith(search.getPath())) {
if (search.getType().isCompatibleWith(leftRetrieveType)) {
rightSearch = search;
break;
}
}
}
// Search from the model info should be used to inform the selection, but will in general resolve to multiple choices
// May be a choice better left to the capabilityStatement-informed planning phase anyway
}
// In the absence of search information, either of these formulations is correct, favor primary query sources over withs
if (leftRetrieve.getLocalId() == null) {
leftRetrieve.setLocalId(context.generateLocalId());
}
if (rightRetrieve.getLocalId() == null) {
rightRetrieve.setLocalId(context.generateLocalId());
}
if (rightRequirement.getQuerySource() instanceof With) {
leftRetrieve.getInclude().add(new IncludeElement().withIncludeFrom(rightRetrieve.getLocalId()).withRelatedDataType(rightRetrieve.getDataType()).withRelatedProperty(joinRequirement.getLeftProperty().getProperty().getPath()).withIsReverse(false));
rightRetrieve.setIncludedIn(leftRetrieve.getLocalId());
} else {
rightRetrieve.getInclude().add(new IncludeElement().withIncludeFrom(leftRetrieve.getLocalId()).withRelatedDataType(leftRetrieve.getDataType()).withRelatedProperty(joinRequirement.getRightProperty().getProperty().getPath()).withIsReverse(false));
leftRetrieve.setIncludedIn(rightRetrieve.getLocalId());
}
}
}
}
use of org.hl7.fhir.r4.model.CapabilityStatement in project dpc-app by CMSgov.
the class Capabilities method buildCapabilities.
private static CapabilityStatement buildCapabilities(String baseURL) {
final PropertiesProvider pp = new PropertiesProvider();
DateTimeType releaseDate = DateTimeType.parseV3(pp.getBuildTimestamp().format(FHIRFormatters.DATE_TIME_FORMATTER));
logger.debug("Reading {} from resources", CAP_STATEMENT);
try (InputStream resource = Capabilities.class.getClassLoader().getResourceAsStream(CAP_STATEMENT)) {
if (resource == null) {
throw new MissingResourceException("Cannot find Capability Statement", Capabilities.class.getName(), CAP_STATEMENT);
}
final CapabilityStatement capabilityStatement = FhirContext.forDstu3().newJsonParser().parseResource(CapabilityStatement.class, resource);
return capabilityStatement.setVersion(pp.getApplicationVersion()).setImplementation(generateImplementationComponent(baseURL)).setSoftware(generateSoftwareComponent(releaseDate, pp.getApplicationVersion()));
} catch (IOException e) {
throw new IllegalStateException("Unable to read capability statement", e);
}
}
Aggregations