/** * Default is DSTU2. Use {@link AbstractJaxRsProvider#AbstractJaxRsProvider(FhirContext)} to specify a DSTU3 context. */ protected AbstractJaxRsProvider() { CTX = FhirContext.forDstu2(); }
public VersionedApiConverterInterceptor() { myVersionConvertor_30_40 = new VersionConvertor_30_40(); VersionConvertorAdvisor40 advisor40 = new NullVersionConverterAdvisor40(); myVersionConvertor_10_40 = new VersionConvertor_10_40(advisor40); VersionConvertorAdvisor30 advisor30 = new NullVersionConverterAdvisor30(); myVersionConvertor_10_30 = new VersionConvertor_10_30(advisor30); myCtxDstu2 = FhirContext.forDstu2(); myCtxDstu2Hl7Org = FhirContext.forDstu2Hl7Org(); }
@Bean(name = "myFhirContextDstu2") @Lazy public FhirContext fhirContextDstu2() { if (ourFhirContextDstu2 == null) { ourFhirContextDstu2 = FhirContext.forDstu2(); } return ourFhirContextDstu2; }
public void upgrade() { // START SNIPPET: client FhirContext ctxDstu2 = FhirContext.forDstu2(); IGenericClient clientDstu2 = ctxDstu2.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu2"); // END SNIPPET: client }
@SuppressWarnings("unused") public static void creatingContext() { // START SNIPPET: creatingContext // Create a context for DSTU2 FhirContext ctxDstu2 = FhirContext.forDstu2(); // Alternately, create a context for R4 FhirContext ctxR4 = FhirContext.forR4(); // END SNIPPET: creatingContext }
public BaseStructureParser(String theVersion, String theBaseDir) { myVersion = theVersion; myBaseDir = theBaseDir; myIsRi = myVersion.equals("dstu3"); if (myVersion.equals("r4")) { myCtx = FhirContext.forR4(); } else if (myVersion.equals("dstu3")) { myCtx = FhirContext.forDstu3(); } else if (myVersion.equals("dstu2")) { myCtx = FhirContext.forDstu2(); } }
@SuppressWarnings("unused") public void getResourceTags() { // START SNIPPET: context // Create a DSTU2 context, which will use DSTU2 semantics FhirContext ctx = FhirContext.forDstu2(); // This parser supports DSTU2 IParser parser = ctx.newJsonParser(); // This client supports DSTU2 IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu2"); // END SNIPPET: context }
public static void deferModelScanning() { // START SNIPPET: deferModelScanning // Create a context and configure it for deferred child scanning FhirContext ctx = FhirContext.forDstu2(); ctx.setPerformanceOptions(PerformanceOptionsEnum.DEFERRED_MODEL_SCANNING); // Now create a client and use it String serverBase = "http://fhirtest.uhn.ca/baseDstu2"; IGenericClient client = ctx.newRestfulGenericClient(serverBase); // END SNIPPET: deferModelScanning }
public void testGenerator() throws IOException { //START SNIPPET: gen String propFile = "classpath:/com/foo/customnarrative.properties"; CustomThymeleafNarrativeGenerator gen = new CustomThymeleafNarrativeGenerator(propFile); FhirContext ctx = FhirContext.forDstu2(); ctx.setNarrativeGenerator(gen); //END SNIPPET: gen } }
@Override protected void initialize() throws ServletException { // In your initialize method, assign a DSTU2 FhirContext. This // is all that is required in order to put the server // into DSTU2 mode setFhirContext(FhirContext.forDstu2()); // Then set resource providers as normal, and do any other // configuration you need to do. setResourceProviders(resourceProviderList); }
public static void main(String[] args) { //START SNIPPET: createClient // Create a client FhirContext ctx = FhirContext.forDstu2(); // Create an instance of the JAX RS client factory and // set it on the context JaxRsRestfulClientFactory clientFactory = new JaxRsRestfulClientFactory(ctx); ctx.setRestfulClientFactory(clientFactory); // This client uses JAX-RS! IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu2"); //END SNIPPET: createClient }
public static void performance() { // START SNIPPET: dontValidate // Create a context FhirContext ctx = FhirContext.forDstu2(); // Disable server validation (don't pull the server's metadata first) ctx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); // Now create a client and use it String serverBase = "http://fhirtest.uhn.ca/baseDstu2"; IGenericClient client = ctx.newRestfulGenericClient(serverBase); // END SNIPPET: dontValidate }
public void bbbbb() throws DataFormatException, IOException { //START SNIPPET: metadataClientUsage FhirContext ctx = FhirContext.forDstu2(); MetadataClient client = ctx.newRestfulClient(MetadataClient.class, "http://spark.furore.com/fhir"); CapabilityStatement metadata = client.getServerMetadata(); System.out.println(ctx.newXmlParser().encodeResourceToString(metadata)); //END SNIPPET: metadataClientUsage }
public static void main(String[] args) { FhirContext ctx = FhirContext.forDstu2(); String serverBase = "http://foo.com/fhirServerBase"; // Create the client IRestfulClient client = ctx.newRestfulClient(IRestfulClient.class, serverBase); // Try the client out! This method will invoke the server List<Patient> patients = client.getPatient(new StringDt("SMITH")); } //END SNIPPET: client
@SuppressWarnings("unused") public void gzip() { // START SNIPPET: gzip // Create a context and get the client factory so it can be configured FhirContext ctx = FhirContext.forDstu2(); IRestfulClientFactory clientFactory = ctx.getRestfulClientFactory(); // Register the interceptor with your client (either style) IPatientClient annotationClient = ctx.newRestfulClient(IPatientClient.class, "http://localhost:9999/fhir"); annotationClient.registerInterceptor(new GZipContentInterceptor()); // END SNIPPET: gzip }
public static void main(String[] args) throws Exception { FhirContext ctx = FhirContext.forDstu2(); String serverBase = "http://fhirtest.uhn.ca/baseDstu2"; IGenericClient client = ctx.newRestfulGenericClient(serverBase); // use RelatedPerson because there aren't that many on the server Bundle bundle = client.search().forResource(RelatedPerson.class).returnBundle(Bundle.class).execute(); BundleFetcher.fetchRestOfBundle(client, bundle); if (bundle.getTotal() != bundle.getEntry().size()) { System.out.println("Counts didn't match! Expected " + bundle.getTotal() + " but bundle only had " + bundle.getEntry().size() + " entries!"); } // IParser parser = ctx.newXmlParser().setPrettyPrint(true); // System.out.println(parser.encodeResourceToString(bundle)); } }
@SuppressWarnings("unused") public void createTimeouts() { // START SNIPPET: timeouts FhirContext ctx = FhirContext.forDstu2(); // Set how long to try and establish the initial TCP connection (in ms) ctx.getRestfulClientFactory().setConnectTimeout(20 * 1000); // Set how long to block for individual read/write operations (in ms) ctx.getRestfulClientFactory().setSocketTimeout(20 * 1000); // Create the client IGenericClient genericClient = ctx.newRestfulGenericClient("http://localhost:9999/fhir"); // END SNIPPET: timeouts }
@SuppressWarnings("unused") public void createProxy() { // START SNIPPET: proxy FhirContext ctx = FhirContext.forDstu2(); // Set connections to access the network via the HTTP proxy at // example.com : 8888 ctx.getRestfulClientFactory().setProxy("example.com", 8888); // If the proxy requires authentication, use the following as well ctx.getRestfulClientFactory().setProxyCredentials("theUsername", "thePassword"); // Create the client IGenericClient genericClient = ctx.newRestfulGenericClient("http://localhost:9999/fhir"); // END SNIPPET: proxy }
private static void testSearchForPatients() { List<IBaseResource> resources = new IncludesExamples().searchForPatients(); // Create a bundle with both FhirContext ctx = FhirContext.forDstu2(); Dstu2BundleFactory bf = new Dstu2BundleFactory(ctx); bf.initializeBundleFromResourceList(null, resources, "http://example.com/base", "http://example.com/base/Patient", 1, BundleTypeEnum.SEARCHSET); IBaseResource b = bf.getResourceBundle(); // Encode the bundle String encoded = ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(b); System.out.println(encoded); }
@SuppressWarnings("unused") public static void main(String[] args) throws DataFormatException, IOException { Patient patient = new Patient(); patient.addIdentifier().setUse(IdentifierUseEnum.OFFICIAL).setSystem("urn:fake:mrns").setValue("7000135"); patient.addIdentifier().setUse(IdentifierUseEnum.SECONDARY).setSystem("urn:fake:otherids").setValue("3287486"); patient.addName().addFamily("Smith").addGiven("John").addGiven("Q").addSuffix("Junior"); patient.setGender(AdministrativeGenderEnum.MALE); FhirContext ctx = FhirContext.forDstu2(); String xmlEncoded = ctx.newXmlParser().encodeResourceToString(patient); String jsonEncoded = ctx.newJsonParser().encodeResourceToString(patient); MyClientInterface client = ctx.newRestfulClient(MyClientInterface.class, "http://foo/fhir"); IdentifierDt searchParam = new IdentifierDt("urn:someidentifiers", "7000135"); List<Patient> clients = client.findPatientsByIdentifier(searchParam); }