public static String createUserAgentString(FhirContext theContext, String theClientType) { StringBuilder b = new StringBuilder(); b.append("HAPI-FHIR/"); b.append(VersionUtil.getVersion()); b.append(" (FHIR Client; FHIR "); b.append(theContext.getVersion().getVersion().getFhirVersionString()); b.append('/'); b.append(theContext.getVersion().getVersion().name()); b.append("; "); b.append(theClientType); b.append(")"); return b.toString(); }
@Override public void run(CommandLine theCommandLine) throws ParseException { parseFhirContext(theCommandLine); String targetServer = theCommandLine.getOptionValue("t"); if (isBlank(targetServer)) { throw new ParseException("No target server (-t) specified"); } else if (targetServer.startsWith("http") == false) { throw new ParseException("Invalid target server specified, must begin with 'http'"); } FhirContext ctx = getFhirContext(); String exclude = theCommandLine.getOptionValue("e"); if (isNotBlank(exclude)) { for (String next : exclude.split(",")) { if (isNotBlank(next)) { IIdType id = ctx.getVersion().newIdType(); id.setValue(next); myExcludes.add(id); } } } if (ctx.getVersion().getVersion() == FhirVersionEnum.DSTU2) { uploadDefinitionsDstu2(theCommandLine, ctx); } else if (ctx.getVersion().getVersion() == FhirVersionEnum.DSTU3) { uploadDefinitionsDstu3(theCommandLine, ctx); } else if (ctx.getVersion().getVersion() == FhirVersionEnum.R4) { uploadDefinitionsR4(theCommandLine, ctx); } }
private Source loadXml(String theSystemId, String theSchemaName) { String pathToBase = myCtx.getVersion().getPathToSchemaDefinitions() + '/' + theSchemaName; ourLog.debug("Going to load resource: {}", pathToBase); InputStream baseIs = FhirValidator.class.getResourceAsStream(pathToBase); if (baseIs == null) { throw new InternalErrorException("Schema not found. " + RESOURCES_JAR_NOTE); } baseIs = new BOMInputStream(baseIs, false); InputStreamReader baseReader = new InputStreamReader(baseIs, Charset.forName("UTF-8")); Source baseSource = new StreamSource(baseReader, theSystemId); //FIXME resource leak return baseSource; }
ourLog.info("No resource names supplied, going to use all resources from version: {}", fhirContext.getVersion().getVersion()); p.load(fhirContext.getVersion().getFhirVersionPropertiesFile()); } catch (IOException e) { throw new IllegalArgumentException("Failed to load version property file", e); if (fhirContext.getVersion().getVersion() == FhirVersionEnum.DSTU3) { resourceNames.remove("conformance");
public IIdType getIdElement(FhirContext theContext) { IIdType retVal = null; if (isNotBlank(myIdElement)) { retVal = theContext.getVersion().newIdType().setValue(myIdElement); } return retVal; }
ourLog.info("Initializing HAPI FHIR restful server running in " + getFhirContext().getVersion().getVersion().name() + " mode"); IFhirVersionServer versionServer = (IFhirVersionServer) getFhirContext().getVersion().getServerVersion(); confProvider = versionServer.createServerConformanceProvider(this);
/** * Returns an unmodifiable set containing all resource names known to this * context */ public Set<String> getResourceNames() { Set<String> resourceNames = new HashSet<>(); if (myNameToResourceDefinition.isEmpty()) { Properties props = new Properties(); try { props.load(myVersion.getFhirVersionPropertiesFile()); } catch (IOException theE) { throw new ConfigurationException("Failed to load version properties file"); } Enumeration<?> propNames = props.propertyNames(); while (propNames.hasMoreElements()) { String next = (String) propNames.nextElement(); if (next.startsWith("resource.")) { resourceNames.add(next.substring("resource.".length()).trim()); } } } for (RuntimeResourceDefinition next : myNameToResourceDefinition.values()) { resourceNames.add(next.getName()); } return Collections.unmodifiableSet(resourceNames); }
baseResourceNames = new ArrayList<String>(); ourLog.info("No resource names supplied, going to use all resources from version: {}",fhirContext.getVersion().getVersion()); p.load(fhirContext.getVersion().getFhirVersionPropertiesFile()); } catch (IOException e) { throw new MojoFailureException("Failed to load version property file", e); if (fhirContext.getVersion().getVersion() == FhirVersionEnum.DSTU3) { baseResourceNames.remove("conformance");
public IIdType getPayloadId(FhirContext theCtx) { IIdType retVal = null; if (myPayloadId != null) { retVal = theCtx.getVersion().newIdType().setValue(myPayloadId); } return retVal; }
static Set<Class<? extends IBase>> scanVersionPropertyFile(Set<Class<? extends IBase>> theDatatypes, Map<String, Class<? extends IBaseResource>> theResourceTypes, FhirVersionEnum theVersion, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theExistingElementDefinitions) { Set<Class<? extends IBase>> retVal = new HashSet<Class<? extends IBase>>(); try (InputStream str = theVersion.getVersionImplementation().getFhirVersionPropertiesFile()) { Properties prop = new Properties(); prop.load(str);
private static FhirContext getContextForVersion(FhirContext theContext, FhirVersionEnum theForVersion) { FhirContext context = theContext; if (context.getVersion().getVersion() != theForVersion) { context = myFhirContextMap.get(theForVersion); if (context == null) { context = theForVersion.newContext(); myFhirContextMap.put(theForVersion, context); } } return context; }
private IIdType store(@ResourceParam T theResource, String theIdPart, Long theVersionIdPart) { IIdType id = myFhirContext.getVersion().newIdType(); String versionIdPart = Long.toString(theVersionIdPart); id.setParts(null, myResourceName, theIdPart, versionIdPart); if (myFhirContext.getVersion().getVersion() == FhirVersionEnum.DSTU2) { ResourceMetadataKeyEnum.VERSION.put((IResource) theResource, versionIdPart); } else {
includeResources = new ArrayList<String>(); logInfo("No resource names supplied, going to use all resources from version: "+fhirContext.getVersion().getVersion()); p.load(fhirContext.getVersion().getFhirVersionPropertiesFile()); } catch (IOException e) { throw new FailureException("Failed to load version property file", e); if (fhirContext.getVersion().getVersion() == FhirVersionEnum.DSTU3) { includeResources.remove("conformance");
public IIdType getId(FhirContext theCtx) { IIdType retVal = null; if (myId != null) { retVal = theCtx.getVersion().newIdType().setValue(myId); } return retVal; }
Map<String, ValueSet> defaultValueSets = myDefaultValueSets; if (defaultValueSets == null) { String path = theContext.getVersion().getPathToSchemaDefinitions().replace("/schema", "/valueset") + "/valuesets.xml"; InputStream valuesetText = DefaultProfileValidationSupport.class.getResourceAsStream(path); if (valuesetText == null) {
/** * Returns an unmodifiable set containing all resource names known to this * context */ public Set<String> getResourceNames() { Set<String> resourceNames = new HashSet<>(); if (myNameToResourceDefinition.isEmpty()) { Properties props = new Properties(); try { props.load(myVersion.getFhirVersionPropertiesFile()); } catch (IOException theE) { throw new ConfigurationException("Failed to load version properties file"); } Enumeration<?> propNames = props.propertyNames(); while (propNames.hasMoreElements()) { String next = (String) propNames.nextElement(); if (next.startsWith("resource.")) { resourceNames.add(next.substring("resource.".length()).trim()); } } } for (RuntimeResourceDefinition next : myNameToResourceDefinition.values()) { resourceNames.add(next.getName()); } return Collections.unmodifiableSet(resourceNames); }
public BaseIgPackParser(FhirContext theCtx) { FhirVersionEnum expectedVersion = provideExpectedVersion(); Validate.isTrue(theCtx.getVersion().getVersion() == expectedVersion, "theCtx is not for the correct version, expecting " + expectedVersion); myCtx = theCtx; }
private DaoMethodOutcome toMethodOutcome(@Nonnull final ResourceTable theEntity, @Nonnull IBaseResource theResource) { DaoMethodOutcome outcome = new DaoMethodOutcome(); IIdType id = null; if (theResource.getIdElement().getValue() != null) { id = theResource.getIdElement(); } if (id == null) { id = theEntity.getIdDt(); if (getContext().getVersion().getVersion().isRi()) { id = getContext().getVersion().newIdType().setValue(id.getValue()); } } outcome.setId(id); outcome.setResource(theResource); outcome.setEntity(theEntity); return outcome; }
private IIdType newIdType(String theValue) { return myContext.getVersion().newIdType().setValue(theValue); }
@Override public LSInput resolveResource(String theType, String theNamespaceURI, String thePublicId, String theSystemId, String theBaseURI) { if (theSystemId != null && SCHEMA_NAMES.contains(theSystemId)) { LSInputImpl input = new LSInputImpl(); input.setPublicId(thePublicId); input.setSystemId(theSystemId); input.setBaseURI(theBaseURI); // String pathToBase = "ca/uhn/fhir/model/" + myVersion + "/schema/" + theSystemId; String pathToBase = myCtx.getVersion().getPathToSchemaDefinitions() + '/' + theSystemId; ourLog.debug("Loading referenced schema file: " + pathToBase); InputStream baseIs = FhirValidator.class.getResourceAsStream(pathToBase); if (baseIs == null) { throw new InternalErrorException("Schema file not found: " + pathToBase); } input.setByteStream(baseIs); //FIXME resource leak return input; } throw new ConfigurationException("Unknown schema: " + theSystemId); } }