Beispiel #1
0
  private FhirContext(
      FhirVersionEnum theVersion, Collection<Class<? extends IBaseResource>> theResourceTypes) {
    VersionUtil.getVersion();

    if (theVersion != null) {
      if (!theVersion.isPresentOnClasspath()) {
        throw new IllegalStateException(
            getLocalizer()
                .getMessage(
                    FhirContext.class, "noStructuresForSpecifiedVersion", theVersion.name()));
      }
      myVersion = theVersion.getVersionImplementation();
    } else if (FhirVersionEnum.DSTU1.isPresentOnClasspath()) {
      myVersion = FhirVersionEnum.DSTU1.getVersionImplementation();
    } else if (FhirVersionEnum.DSTU2.isPresentOnClasspath()) {
      myVersion = FhirVersionEnum.DSTU2.getVersionImplementation();
    } else if (FhirVersionEnum.DSTU2_HL7ORG.isPresentOnClasspath()) {
      myVersion = FhirVersionEnum.DSTU2_HL7ORG.getVersionImplementation();
    } else {
      throw new IllegalStateException(getLocalizer().getMessage(FhirContext.class, "noStructures"));
    }

    if (theVersion == null) {
      ourLog.info(
          "Creating new FhirContext with auto-detected version [{}]. It is recommended to explicitly select a version for future compatibility by invoking FhirContext.forDstuX()",
          myVersion.getVersion().name());
    } else {
      ourLog.info("Creating new FHIR context for FHIR version [{}]", myVersion.getVersion().name());
    }

    myResourceTypesToScan = theResourceTypes;
  }