use of org.hl7.fhir.r4b.model.SearchParameter in project org.hl7.fhir.core by hapifhir.
the class SearchParameterRenderer method render.
public boolean render(XhtmlNode x, SearchParameter spd) throws IOException, FHIRException, EOperationOutcome {
x.h2().addText(spd.getName());
XhtmlNode p = x.para();
p.tx("Parameter ");
p.code().tx(spd.getCode());
p.tx(":");
p.code().tx(spd.getType().toCode());
addMarkdown(x, spd.getDescription());
XhtmlNode tbl = x.table("grid");
XhtmlNode tr = tbl.tr();
tr.td().tx(Utilities.pluralize("Resource", spd.getBase().size()));
XhtmlNode td = tr.td();
for (CodeType t : spd.getBase()) {
StructureDefinition sd = context.getWorker().fetchTypeDefinition(t.toString());
if (sd != null && sd.hasUserData("path")) {
td.sep(", ").ah(sd.getUserString("path")).tx(t.getCode());
} else {
td.sep(", ").tx(t.getCode());
}
}
tr = tbl.tr();
tr.td().tx("Expression");
if (spd.hasExpression()) {
tr.td().code().tx(spd.getExpression());
} else {
tr.td().tx("(none)");
}
if (spd.hasXpathUsage()) {
tr = tbl.tr();
tr.td().tx("Usage");
tr.td().tx(spd.getXpathUsage().getDisplay());
}
if (spd.hasXpath()) {
tr = tbl.tr();
tr.td().tx("XPath");
tr.td().code().tx(spd.getXpath());
}
if (spd.hasTarget()) {
tr = tbl.tr();
tr.td().tx(Utilities.pluralize("Target Resources", spd.getTarget().size()));
td = tr.td();
for (CodeType t : spd.getTarget()) {
StructureDefinition sd = context.getWorker().fetchTypeDefinition(t.toString());
if (sd != null && sd.hasUserData("path")) {
td.sep(", ").ah(sd.getUserString("path")).tx(t.getCode());
} else {
td.sep(", ").tx(t.getCode());
}
}
}
tr = tbl.tr();
tr.td().tx("Multiples");
if (spd.getMultipleAnd() && spd.getMultipleOr()) {
tr.td().tx("The parameter can repeat (and) and can have repeating values (or)");
} else if (spd.getMultipleOr()) {
tr.td().tx("The parameter can repeat (and) but each repeat can only have one value");
} else if (spd.getMultipleAnd()) {
tr.td().tx("The parameter cannot repeat (and) but the single parameter can have multiple values (or)");
} else {
tr.td().tx("The parameter cannot repeat or have multiple values");
}
if (spd.hasComparator()) {
tr = tbl.tr();
tr.td().tx("Comparators");
td = tr.td().tx("Allowed: ");
for (Enumeration<SearchComparator> t : spd.getComparator()) {
td.sep(", ").tx(t.asStringValue());
}
}
if (spd.hasModifier()) {
tr = tbl.tr();
tr.td().tx("Modifiers");
td = tr.td().tx("Allowed: ");
for (Enumeration<SearchModifierCode> t : spd.getModifier()) {
td.sep(", ").tx(t.asStringValue());
}
}
if (spd.hasChain()) {
tr = tbl.tr();
tr.td().tx("Chains");
td = tr.td().tx("Allowed: ");
for (StringType t : spd.getChain()) {
td.sep(", ").tx(t.asStringValue());
}
}
if (spd.hasComponent()) {
x.para().b().tx("Components");
tbl = x.table("grid");
for (SearchParameterComponentComponent t : spd.getComponent()) {
tr = tbl.tr();
SearchParameter tsp = context.getWorker().fetchResource(SearchParameter.class, t.getDefinition());
if (tsp != null && tsp.hasUserData("path")) {
tr.td().ah(tsp.getUserString("path")).tx(tsp.present());
} else {
tr.td().tx(t.getDefinition());
}
tr.td().code().tx(t.getExpression());
}
}
return false;
}
use of org.hl7.fhir.r4b.model.SearchParameter in project hapi-fhir-jpaserver-starter by hapifhir.
the class BaseJpaRestfulServer method initialize.
@SuppressWarnings("unchecked")
@Override
protected void initialize() throws ServletException {
super.initialize();
/*
* Create a FhirContext object that uses the version of FHIR
* specified in the properties file.
*/
// Customize supported resource types
List<String> supportedResourceTypes = appProperties.getSupported_resource_types();
if (!supportedResourceTypes.isEmpty()) {
if (!supportedResourceTypes.contains("SearchParameter")) {
supportedResourceTypes.add("SearchParameter");
}
daoRegistry.setSupportedResourceTypes(supportedResourceTypes);
}
setFhirContext(fhirSystemDao.getContext());
/*
* Order matters - the MDM provider registers itself on the resourceProviderFactory - hence the loading must be done
* ahead of provider registration
*/
if (appProperties.getMdm_enabled())
mdmProviderProvider.get().loadProvider();
registerProviders(resourceProviderFactory.createProviders());
registerProvider(jpaSystemProvider);
/*
* The conformance provider exports the supported resources, search parameters, etc for
* this server. The JPA version adds resourceProviders counts to the exported statement, so it
* is a nice addition.
*
* You can also create your own subclass of the conformance provider if you need to
* provide further customization of your server's CapabilityStatement
*/
FhirVersionEnum fhirVersion = fhirSystemDao.getContext().getVersion().getVersion();
if (fhirVersion == FhirVersionEnum.DSTU2) {
JpaConformanceProviderDstu2 confProvider = new JpaConformanceProviderDstu2(this, fhirSystemDao, daoConfig);
confProvider.setImplementationDescription("HAPI FHIR DSTU2 Server");
setServerConformanceProvider(confProvider);
} else {
if (fhirVersion == FhirVersionEnum.DSTU3) {
JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, fhirSystemDao, daoConfig, searchParamRegistry);
confProvider.setImplementationDescription("HAPI FHIR DSTU3 Server");
setServerConformanceProvider(confProvider);
} else if (fhirVersion == FhirVersionEnum.R4) {
JpaCapabilityStatementProvider confProvider = new JpaCapabilityStatementProvider(this, fhirSystemDao, daoConfig, searchParamRegistry, myValidationSupport);
confProvider.setImplementationDescription("HAPI FHIR R4 Server");
setServerConformanceProvider(confProvider);
} else if (fhirVersion == FhirVersionEnum.R5) {
JpaCapabilityStatementProvider confProvider = new JpaCapabilityStatementProvider(this, fhirSystemDao, daoConfig, searchParamRegistry, myValidationSupport);
confProvider.setImplementationDescription("HAPI FHIR R5 Server");
setServerConformanceProvider(confProvider);
} else {
throw new IllegalStateException();
}
}
if (appProperties.getEtag_support_enabled() == false)
setETagSupport(ETagSupportEnum.DISABLED);
/*
* This server tries to dynamically generate narratives
*/
FhirContext ctx = getFhirContext();
INarrativeGenerator theNarrativeGenerator = appProperties.getNarrative_enabled() ? new DefaultThymeleafNarrativeGenerator() : new NullNarrativeGenerator();
ctx.setNarrativeGenerator(theNarrativeGenerator);
/*
* Default to JSON and pretty printing
*/
setDefaultPrettyPrint(appProperties.getDefault_pretty_print());
/*
* Default encoding
*/
setDefaultResponseEncoding(appProperties.getDefault_encoding());
/*
* This configures the server to page search results to and from
* the database, instead of only paging them to memory. This may mean
* a performance hit when performing searches that return lots of results,
* but makes the server much more scalable.
*/
setPagingProvider(databaseBackedPagingProvider);
/*
* This interceptor formats the output using nice colourful
* HTML output when the request is detected to come from a
* browser.
*/
ResponseHighlighterInterceptor responseHighlighterInterceptor = new ResponseHighlighterInterceptor();
this.registerInterceptor(responseHighlighterInterceptor);
if (appProperties.getFhirpath_interceptor_enabled()) {
registerInterceptor(new FhirPathFilterInterceptor());
}
/*
* Add some logging for each request
*/
LoggingInterceptor loggingInterceptor = new LoggingInterceptor();
loggingInterceptor.setLoggerName(appProperties.getLogger().getName());
loggingInterceptor.setMessageFormat(appProperties.getLogger().getFormat());
loggingInterceptor.setErrorMessageFormat(appProperties.getLogger().getError_format());
loggingInterceptor.setLogExceptions(appProperties.getLogger().getLog_exceptions());
this.registerInterceptor(loggingInterceptor);
/*
* If you are hosting this server at a specific DNS name, the server will try to
* figure out the FHIR base URL based on what the web container tells it, but
* this doesn't always work. If you are setting links in your search bundles that
* just refer to "localhost", you might want to use a server address strategy:
*/
String serverAddress = appProperties.getServer_address();
if (!Strings.isNullOrEmpty(serverAddress)) {
setServerAddressStrategy(new HardcodedServerAddressStrategy(serverAddress));
} else if (appProperties.getUse_apache_address_strategy()) {
boolean useHttps = appProperties.getUse_apache_address_strategy_https();
setServerAddressStrategy(useHttps ? ApacheProxyAddressStrategy.forHttps() : ApacheProxyAddressStrategy.forHttp());
} else {
setServerAddressStrategy(new IncomingRequestAddressStrategy());
}
/*
* If you are using DSTU3+, you may want to add a terminology uploader, which allows
* uploading of external terminologies such as Snomed CT. Note that this uploader
* does not have any security attached (any anonymous user may use it by default)
* so it is a potential security vulnerability. Consider using an AuthorizationInterceptor
* with this feature.
*/
if (ctx.getVersion().getVersion().isEqualOrNewerThan(FhirVersionEnum.DSTU3)) {
// <-- ENABLED RIGHT NOW
registerProvider(myApplicationContext.getBean(TerminologyUploaderProvider.class));
}
// manual triggering of a subscription delivery, enable this provider
if (true) {
// <-- ENABLED RIGHT NOW
registerProvider(myApplicationContext.getBean(SubscriptionTriggeringProvider.class));
}
// to your specific needs
if (appProperties.getCors() != null) {
ourLog.info("CORS is enabled on this server");
CorsConfiguration config = new CorsConfiguration();
config.addAllowedHeader(HttpHeaders.ORIGIN);
config.addAllowedHeader(HttpHeaders.ACCEPT);
config.addAllowedHeader(HttpHeaders.CONTENT_TYPE);
config.addAllowedHeader(HttpHeaders.AUTHORIZATION);
config.addAllowedHeader(HttpHeaders.CACHE_CONTROL);
config.addAllowedHeader("x-fhir-starter");
config.addAllowedHeader("X-Requested-With");
config.addAllowedHeader("Prefer");
List<String> allAllowedCORSOrigins = appProperties.getCors().getAllowed_origin();
allAllowedCORSOrigins.forEach(config::addAllowedOriginPattern);
ourLog.info("CORS allows the following origins: " + String.join(", ", allAllowedCORSOrigins));
config.addExposedHeader("Location");
config.addExposedHeader("Content-Location");
config.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH", "HEAD"));
config.setAllowCredentials(appProperties.getCors().getAllow_Credentials());
// Create the interceptor and register it
CorsInterceptor interceptor = new CorsInterceptor(config);
registerInterceptor(interceptor);
} else {
ourLog.info("CORS is disabled on this server");
}
// will activate them and match results against them
if (appProperties.getSubscription() != null) {
// Subscription debug logging
interceptorService.registerInterceptor(new SubscriptionDebugLogInterceptor());
}
if (appProperties.getAllow_cascading_deletes()) {
CascadingDeleteInterceptor cascadingDeleteInterceptor = new CascadingDeleteInterceptor(ctx, daoRegistry, interceptorBroadcaster);
getInterceptorService().registerInterceptor(cascadingDeleteInterceptor);
}
// Binary Storage
if (appProperties.getBinary_storage_enabled()) {
getInterceptorService().registerInterceptor(binaryStorageInterceptor);
}
if (validatorModule != null) {
if (appProperties.getValidation().getRequests_enabled()) {
RequestValidatingInterceptor interceptor = new RequestValidatingInterceptor();
interceptor.setFailOnSeverity(ResultSeverityEnum.ERROR);
interceptor.setValidatorModules(Collections.singletonList(validatorModule));
registerInterceptor(interceptor);
}
if (appProperties.getValidation().getResponses_enabled()) {
ResponseValidatingInterceptor interceptor = new ResponseValidatingInterceptor();
interceptor.setFailOnSeverity(ResultSeverityEnum.ERROR);
interceptor.setValidatorModules(Collections.singletonList(validatorModule));
registerInterceptor(interceptor);
}
}
// GraphQL
if (appProperties.getGraphql_enabled()) {
if (fhirVersion.isEqualOrNewerThan(FhirVersionEnum.DSTU3)) {
registerProvider(graphQLProvider.get());
}
}
if (appProperties.getAllowed_bundle_types() != null) {
daoConfig.setBundleTypesAllowedForStorage(appProperties.getAllowed_bundle_types().stream().map(BundleType::toCode).collect(Collectors.toSet()));
}
daoConfig.setDeferIndexingForCodesystemsOfSize(appProperties.getDefer_indexing_for_codesystems_of_size());
if (appProperties.getOpenapi_enabled()) {
registerInterceptor(new OpenApiInterceptor());
}
// Bulk Export
if (appProperties.getBulk_export_enabled()) {
registerProvider(bulkDataExportProvider);
}
// valueSet Operations i.e $expand
registerProvider(myValueSetOperationProvider);
// reindex Provider $reindex
registerProvider(reindexProvider);
// Partitioning
if (appProperties.getPartitioning() != null) {
registerInterceptor(new RequestTenantPartitionInterceptor());
setTenantIdentificationStrategy(new UrlBaseTenantIdentificationStrategy());
registerProviders(partitionManagementProvider);
}
if (appProperties.getClient_id_strategy() == DaoConfig.ClientIdStrategyEnum.ANY) {
daoConfig.setResourceServerIdStrategy(DaoConfig.IdStrategyEnum.UUID);
daoConfig.setResourceClientIdStrategy(appProperties.getClient_id_strategy());
}
// Parallel Batch GET execution settings
daoConfig.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_size());
daoConfig.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_max_size());
if (appProperties.getImplementationGuides() != null) {
Map<String, AppProperties.ImplementationGuide> guides = appProperties.getImplementationGuides();
for (Map.Entry<String, AppProperties.ImplementationGuide> guide : guides.entrySet()) {
PackageInstallationSpec packageInstallationSpec = new PackageInstallationSpec().setPackageUrl(guide.getValue().getUrl()).setName(guide.getValue().getName()).setVersion(guide.getValue().getVersion()).setInstallMode(PackageInstallationSpec.InstallModeEnum.STORE_AND_INSTALL);
if (appProperties.getInstall_transitive_ig_dependencies()) {
packageInstallationSpec.setFetchDependencies(true);
packageInstallationSpec.setDependencyExcludes(ImmutableList.of("hl7.fhir.r2.core", "hl7.fhir.r3.core", "hl7.fhir.r4.core", "hl7.fhir.r5.core"));
}
packageInstallerSvc.install(packageInstallationSpec);
}
}
if (factory != null) {
interceptorService.registerInterceptor(factory.buildUsingStoredStructureDefinitions());
}
if (appProperties.getLastn_enabled()) {
daoConfig.setLastNEnabled(true);
}
daoConfig.setStoreResourceInLuceneIndex(appProperties.getStore_resource_in_lucene_index_enabled());
daoConfig.getModelConfig().setNormalizedQuantitySearchLevel(appProperties.getNormalized_quantity_search_level());
daoConfig.getModelConfig().setIndexOnContainedResources(appProperties.getEnable_index_contained_resource());
}
use of org.hl7.fhir.r4b.model.SearchParameter in project kindling by HL7.
the class SpreadSheetReloader method processSearchParams.
private void processSearchParams(XSSFWorkbook excel) throws FHIRFormatError, FileNotFoundException, IOException {
Bundle bnd = (Bundle) parseXml(fnSP());
XSSFSheet src = getSheet(excel, SN_SEARCH);
List<BundleEntryComponent> oldSPs = bnd.getEntry();
bnd.setEntry(new ArrayList<>());
XSSFRow cols = src.getRow(0);
for (int i = 1; i <= src.getLastRowNum(); i++) {
XSSFRow row = src.getRow(i);
if (row != null && hasValue(row, cols, CN_NAME)) {
String c = getValue(row, cols, CN_NAME);
SearchParameter sp = getSp(oldSPs, c);
bnd.addEntry().setResource(sp);
readSearchParameter(row, cols, sp);
}
}
saveXml(fnSP(), bnd);
}
use of org.hl7.fhir.r4b.model.SearchParameter in project kindling by HL7.
the class ValueSetFinder method checkSearchParams.
private static void checkSearchParams(File f) throws Exception {
String folder = Utilities.getDirectoryForFile(f.getAbsolutePath());
System.out.println(f.getName());
try {
Set<String> s = new HashSet<>();
for (File fsp : new File(folder).listFiles()) {
if (fsp.getName().startsWith("searchparameter-")) {
SearchParameter sp = (SearchParameter) new XmlParser().parseAndClose(new FileInputStream(fsp));
s.add(sp.getId());
}
}
for (File fig : new File(folder).listFiles()) {
if (fig.getName().startsWith("implementationguide-")) {
ImplementationGuide ig = (ImplementationGuide) new XmlParser().parseAndClose(new FileInputStream(fig));
ig.getDefinition().getResource().removeIf(res -> res.getReference().getReference().startsWith("SearchParameter/") && !s.contains(res.getReference().getReference().substring(res.getReference().getReference().indexOf("/") + 1)));
if (ig.getDefinition().getResource().isEmpty()) {
fig.delete();
} else {
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(fig), ig);
}
}
}
} catch (Exception e) {
System.out.println(" " + e.getMessage());
}
}
use of org.hl7.fhir.r4b.model.SearchParameter in project kindling by HL7.
the class PageProcessor method genAllSearchParams.
private String genAllSearchParams() throws Exception {
List<SearchParameter> splist = new ArrayList<SearchParameter>();
for (ResourceDefn rd : getDefinitions().getBaseResources().values()) addSearchParams(splist, rd);
for (ResourceDefn rd : getDefinitions().getResources().values()) addSearchParams(splist, rd);
for (Profile cp : getDefinitions().getPackList()) {
addSearchParams(splist, cp);
}
StringBuilder b = new StringBuilder();
genSearchParams(b, splist, "Resource");
genSearchParams(b, splist, "DomainResource");
genCommonSearchParams(b, splist);
for (String n : definitions.sortedResourceNames()) genSearchParams(b, splist, n);
return b.toString();
}
Aggregations