ca.uhn.fhir.context.FhirVersionEnum Java Examples

The following examples show how to use ca.uhn.fhir.context.FhirVersionEnum. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FhirTesterConfig.java    From fhirstarters with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * This bean tells the testing webpage which servers it should configure itself
 * to communicate with. In this example we configure it to talk to the local
 * server, as well as one public server. If you are creating a project to 
 * deploy somewhere else, you might choose to only put your own server's 
 * address here.
 * 
 * Note the use of the ${serverBase} variable below. This will be replaced with
 * the base URL as reported by the server itself. Often for a simple Tomcat
 * (or other container) installation, this will end up being something
 * like "http://localhost:8080/hapi-fhir-jpaserver-example". If you are
 * deploying your server to a place with a fully qualified domain name, 
 * you might want to use that instead of using the variable.
 */
@Bean
public TesterConfig testerConfig() {
	TesterConfig retVal = new TesterConfig();
	retVal
		.addServer()
			.withId("home")
			.withFhirVersion(FhirVersionEnum.DSTU2)
			.withBaseUrl("${serverBase}/fhir")
			.withName("Local Tester")
		.addServer()
			.withId("hapi")
			.withFhirVersion(FhirVersionEnum.DSTU2)
			.withBaseUrl("http://fhirtest.uhn.ca/baseDstu2")
			.withName("Public HAPI Test Server");
	
	/*
	 * Use the method below to supply a client "factory" which can be used 
	 * if your server requires authentication
	 */
	// retVal.setClientFactory(clientFactory);
	
	return retVal;
}
 
Example #2
Source File: FhirResourceProcessorTest.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
public void dstu3SpecificationsShouldBeValid() throws Exception {
    Assertions.assertThat(FhirMetaDataExtension.getResources(FhirVersionEnum.DSTU3)).hasSize(117);

    XmlSchemaInspector inspector = new XmlSchemaInspector();
    FhirResourcesProcessor fhirResourcesProcessor = new FhirResourcesProcessor();

    List<Exception> errors = new ArrayList<>();
    for (String resource : FhirMetaDataExtension.getResources(FhirVersionEnum.DSTU3)) {
        Path file = FileSystems.getDefault().getPath("src/main/resources/META-INF/syndesis/schemas/dstu3/" + resource.toLowerCase() + ".xsd");
        String specification = fhirResourcesProcessor.buildSchema(file);
        try {
            inspector.inspect(specification);

        } catch (Exception e) {
            errors.add(new RuntimeException(resource + " specification failed validation due to " + e.getMessage(), e));
        }
    }

    Assertions.assertThat(errors).hasSize(0);
}
 
Example #3
Source File: Bundles.java    From bunsen with Apache License 2.0 6 votes vote down vote up
private void readObject(java.io.ObjectInputStream stream) throws IOException,
    ClassNotFoundException {

  this.resourceName = stream.readUTF();
  this.resourceTypeUrl = stream.readUTF();
  this.fhirVersion = (FhirVersionEnum) stream.readObject();
  this.containedResourceTypeUrls = (List<String>) stream.readObject();

  FhirContext context = FhirContexts.contextFor(fhirVersion);

  if (this.containedResourceTypeUrls.isEmpty()) {
    this.converter = SparkRowConverter.forResource(context, resourceTypeUrl);
  } else {
    this.converter = SparkRowConverter.forResource(context, resourceTypeUrl,
        containedResourceTypeUrls);
  }

  this.support = FhirConversionSupport.supportFor(fhirVersion);
}
 
Example #4
Source File: ConceptMaps.java    From bunsen with Apache License 2.0 5 votes vote down vote up
protected ConceptMaps(SparkSession spark,
    Dataset<UrlAndVersion> members,
    Dataset<ConceptMap> conceptMaps,
    Dataset<Mapping> mappings) {

  super(spark, FhirVersionEnum.R4, members, conceptMaps, mappings, CONCEPT_MAP_ENCODER);
}
 
Example #5
Source File: AbstractValueSets.java    From bunsen with Apache License 2.0 5 votes vote down vote up
protected AbstractValueSets(SparkSession spark,
    FhirVersionEnum fhirVersion,
    Dataset<UrlAndVersion> members,
    Dataset<Row> valueSets,
    Dataset<Value> values,
    SparkRowConverter valueSetRowConverter) {

  this.spark = spark;
  this.fhirVersion = fhirVersion;
  this.members = members;
  this.valueSets = valueSets;
  this.values = values;
  this.valueSetRowConverter = valueSetRowConverter;
}
 
Example #6
Source File: AbstractConceptMaps.java    From bunsen with Apache License 2.0 5 votes vote down vote up
protected AbstractConceptMaps(SparkSession spark,
    FhirVersionEnum fhirVersion,
    Dataset<UrlAndVersion> members,
    Dataset<Row> conceptMaps,
    Dataset<Mapping> mappings,
    SparkRowConverter conceptMapRowConverter) {

  this.spark = spark;
  this.fhirVersion = fhirVersion;
  this.members = members;
  this.conceptMaps = conceptMaps;
  this.mappings = mappings;
  this.conceptMapRowConverter = conceptMapRowConverter;
}
 
Example #7
Source File: AbstractConceptMaps.java    From bunsen with Apache License 2.0 5 votes vote down vote up
ToConceptMap(FhirVersionEnum fhirVersion) {
  this.fhirVersion = fhirVersion;

  xmlParser = FhirContexts.contextFor(fhirVersion).newXmlParser();
  jsonParser = FhirContexts.contextFor(fhirVersion).newJsonParser();

  converter = SparkRowConverter.forResource(FhirContexts.contextFor(fhirVersion),
      "ConceptMap");
}
 
Example #8
Source File: AbstractValueSets.java    From bunsen with Apache License 2.0 5 votes vote down vote up
ToValueSet(FhirVersionEnum fhirVersion) {
  this.fhirVersion = fhirVersion;

  xmlParser = FhirContexts.contextFor(fhirVersion).newXmlParser();
  jsonParser = FhirContexts.contextFor(fhirVersion).newJsonParser();

  converter = SparkRowConverter.forResource(FhirContexts.contextFor(fhirVersion),
      "ValueSet");
}
 
Example #9
Source File: Bundles.java    From bunsen with Apache License 2.0 5 votes vote down vote up
StringToBundle(boolean isXml, FhirVersionEnum fhirVersion) {
  this.isXml = isXml;
  this.fhirVersion = fhirVersion;

  parser = isXml
      ? FhirContexts.contextFor(fhirVersion).newXmlParser()
      : FhirContexts.contextFor(fhirVersion).newJsonParser();
}
 
Example #10
Source File: Bundles.java    From bunsen with Apache License 2.0 5 votes vote down vote up
ToResourceRow(String resourceName,
    String resourceTypeUrl,
    FhirVersionEnum fhirVersion,
    SparkRowConverter converter) {

  this.resourceName = resourceName;
  this.resourceTypeUrl = resourceTypeUrl;
  this.fhirVersion = fhirVersion;

  this.converter = converter;
  this.support = FhirConversionSupport.supportFor(fhirVersion);
  this.containedResourceTypeUrls = Collections.emptyList();
}
 
Example #11
Source File: Bundles.java    From bunsen with Apache License 2.0 5 votes vote down vote up
ToResourceRow(String resourceName,
    String resourceTypeUrl,
    FhirVersionEnum fhirVersion,
    SparkRowConverter converter,
    List<String> contained) {

  this.resourceName = resourceName;
  this.resourceTypeUrl = resourceTypeUrl;
  this.fhirVersion = fhirVersion;

  this.converter = converter;
  this.support = FhirConversionSupport.supportFor(fhirVersion);
  this.containedResourceTypeUrls = contained;
}
 
Example #12
Source File: HasSerializableConverter.java    From bunsen with Apache License 2.0 5 votes vote down vote up
protected HasSerializableConverter(String resourceTypeUrl,
    FhirVersionEnum fhirVersion) {

  this.resourceTypeUrl = resourceTypeUrl;
  this.fhirVersion = fhirVersion;

  this.converter = SparkRowConverter.forResource(FhirContexts.contextFor(fhirVersion),
      resourceTypeUrl);
}
 
Example #13
Source File: MockValueSets.java    From bunsen with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an empty MockValueSets instance for test purposes.
 */
public MockValueSets(SparkSession spark, SparkRowConverter valuesetRowConverter) {
  super(spark,
      FhirVersionEnum.DSTU3,
      spark.emptyDataset(AbstractValueSets.getUrlAndVersionEncoder()),
      valuesetRowConverter.emptyDataFrame(spark),
      spark.emptyDataset(AbstractValueSets.getValueEncoder()),
      valuesetRowConverter);
}
 
Example #14
Source File: MockValueSets.java    From bunsen with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a MockValueSets instance with the given data.
 */
public MockValueSets(SparkSession spark,
    Dataset<UrlAndVersion> members,
    Dataset<Row> valueSets,
    Dataset<Value> values,
    SparkRowConverter valueSetRowConverter) {

  super(spark, FhirVersionEnum.DSTU3, members, valueSets, values, valueSetRowConverter);
}
 
Example #15
Source File: HapiProperties.java    From careconnect-reference-implementation with Apache License 2.0 5 votes vote down vote up
public static FhirVersionEnum getFhirVersion() {
    String fhirVersionString = HapiProperties.getProperty(FHIR_VERSION);

    if (fhirVersionString != null && fhirVersionString.length() > 0) {
        return FhirVersionEnum.valueOf(fhirVersionString);
    }

    return FhirVersionEnum.DSTU3;
}
 
Example #16
Source File: Dstu2FhirModelResolver.java    From cql_engine with Apache License 2.0 5 votes vote down vote up
private Dstu2FhirModelResolver(FhirContext fhirContext) {
    super(fhirContext);

    this.setPackageName("org.hl7.fhir.dstu2.model");
    
    if (fhirContext.getVersion().getVersion() != FhirVersionEnum.DSTU2) {
        throw new IllegalArgumentException("The supplied context is not configured for DSTU2");
    }
}
 
Example #17
Source File: Dstu3FhirModelResolver.java    From cql_engine with Apache License 2.0 5 votes vote down vote up
private Dstu3FhirModelResolver(FhirContext fhirContext) {
    super(fhirContext);
    this.setPackageName("org.hl7.fhir.dstu3.model");
    if (fhirContext.getVersion().getVersion() != FhirVersionEnum.DSTU3) {
        throw new IllegalArgumentException("The supplied context is not configured for DSTU3");
    }
}
 
Example #18
Source File: R4FhirModelResolver.java    From cql_engine with Apache License 2.0 5 votes vote down vote up
private R4FhirModelResolver(FhirContext fhirContext) {
    super(fhirContext);
    this.setPackageName("org.hl7.fhir.r4.model");
    if (fhirContext.getVersion().getVersion() != FhirVersionEnum.R4) {
        throw new IllegalArgumentException("The supplied context is not configured for R4");
    }
}
 
Example #19
Source File: HapiProperties.java    From cqf-ruler with Apache License 2.0 5 votes vote down vote up
public static FhirVersionEnum getFhirVersion() {
    String fhirVersionString = HapiProperties.getProperty(FHIR_VERSION);

    if (fhirVersionString != null && fhirVersionString.length() > 0) {
        return FhirVersionEnum.valueOf(fhirVersionString);
    }

    return FhirVersionEnum.R4;
}
 
Example #20
Source File: ValueSets.java    From bunsen with Apache License 2.0 5 votes vote down vote up
private ValueSets(SparkSession spark,
    Dataset<UrlAndVersion> members,
    Dataset<ValueSet> valueSets,
    Dataset<Value> values) {

  super(spark, FhirVersionEnum.R4, members, valueSets,values, VALUE_SET_ENCODER);
}
 
Example #21
Source File: ConceptMaps.java    From bunsen with Apache License 2.0 5 votes vote down vote up
protected ConceptMaps(SparkSession spark,
    Dataset<UrlAndVersion> members,
    Dataset<Row> conceptMaps,
    Dataset<Mapping> mappings) {

  super(spark, FhirVersionEnum.DSTU3, members, conceptMaps, mappings, conceptMapConverter);
}
 
Example #22
Source File: ApplicationContext.java    From hapi-fhir-jpaserver-starter with Apache License 2.0 5 votes vote down vote up
public ApplicationContext() {
  FhirVersionEnum fhirVersion = HapiProperties.getFhirVersion();
  if (fhirVersion == FhirVersionEnum.DSTU2) {
    register(FhirServerConfigDstu2.class, FhirServerConfigCommon.class);
  } else if (fhirVersion == FhirVersionEnum.DSTU3) {
    register(FhirServerConfigDstu3.class, FhirServerConfigCommon.class);
  } else if (fhirVersion == FhirVersionEnum.R4) {
    register(FhirServerConfigR4.class, FhirServerConfigCommon.class);
  } else if (fhirVersion == FhirVersionEnum.R5) {
    register(FhirServerConfigR5.class, FhirServerConfigCommon.class);
  } else {
    throw new IllegalStateException();
  }

  if (HapiProperties.getSubscriptionWebsocketEnabled()) {
    register(WebsocketDispatcherConfig.class);
  }

  if (HapiProperties.getSubscriptionEmailEnabled()
  || HapiProperties.getSubscriptionRestHookEnabled()
  || HapiProperties.getSubscriptionWebsocketEnabled()) {
    register(SubscriptionSubmitterConfig.class);
    register(SubscriptionProcessorConfig.class);
    register(SubscriptionChannelConfig.class);
  }

}
 
Example #23
Source File: HapiProperties.java    From hapi-fhir-jpaserver-starter with Apache License 2.0 5 votes vote down vote up
public static FhirVersionEnum getFhirVersion() {
  String fhirVersionString = HapiProperties.getProperty(FHIR_VERSION);

  if (fhirVersionString != null && fhirVersionString.length() > 0) {
    return FhirVersionEnum.valueOf(fhirVersionString);
  }

  return FhirVersionEnum.DSTU3;
}
 
Example #24
Source File: FhirVerifierExtension.java    From syndesis with Apache License 2.0 5 votes vote down vote up
private static void verifyFhirVersion(ResultBuilder builder, Map<String, Object> parameters) {
    try {
        final FhirVersionEnum fhirVersionEnum = ConnectorOptions.extractOptionAndMap(
            parameters, FHIR_VERSION, FhirVersionEnum::valueOf);
        parameters.put(FHIR_VERSION, fhirVersionEnum);
    } catch (Exception e) {
        builder.error(
            ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.ILLEGAL_PARAMETER_VALUE, "Invalid FHIR version")
                .parameterKey(FHIR_VERSION)
                .build());
    }
}
 
Example #25
Source File: ValueSets.java    From bunsen with Apache License 2.0 5 votes vote down vote up
private ValueSets(SparkSession spark,
    Dataset<UrlAndVersion> members,
    Dataset<Row> valueSets,
    Dataset<Value> values) {

  super(spark, FhirVersionEnum.DSTU3, members, valueSets,values, valuesetRowConverter);
}
 
Example #26
Source File: FhirMetaDataExtension.java    From syndesis with Apache License 2.0 5 votes vote down vote up
public static Set<String> getResources(FhirVersionEnum fhirVersion) {
    if (FhirVersionEnum.DSTU3.equals(fhirVersion)) {
        return toSet(org.hl7.fhir.dstu3.model.ResourceType.values());
    }

    throw new IllegalArgumentException(fhirVersion + " is not among supported FHIR versions: DSTU3");
}
 
Example #27
Source File: FhirMetaDataExtension.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Override
public Optional<MetaData> meta(Map<String, Object> parameters) {
    FhirVersionEnum fhirVersionEnum = ConnectorOptions.extractOptionAndMap(
        parameters, "fhirVersion",
        FhirVersionEnum::valueOf, FhirVersionEnum.DSTU3);

    Set<String> resources = getResources(fhirVersionEnum);

    return Optional
                .of(MetaDataBuilder.on(getCamelContext()).withAttribute(MetaData.CONTENT_TYPE, "text/plain")
                    .withAttribute(MetaData.JAVA_TYPE, String.class).withPayload(resources).build());
}
 
Example #28
Source File: BaseResource.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
@Override
public FhirVersionEnum getStructureFhirVersionEnum() {
	return FhirVersionEnum.R4;
}
 
Example #29
Source File: BaseResource.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
@Override
public FhirVersionEnum getStructureFhirVersionEnum() {
  return FhirVersionEnum.DSTU2_HL7ORG;
}
 
Example #30
Source File: BaseResource.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
@Override
public FhirVersionEnum getStructureFhirVersionEnum() {
	return FhirVersionEnum.DSTU3;
}