org.hl7.fhir.dstu3.model.Bundle Java Examples
The following examples show how to use
org.hl7.fhir.dstu3.model.Bundle.
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: Example08_ClientSearch.java From fhirstarters with BSD 3-Clause "New" or "Revised" License | 7 votes |
public static void main(String[] theArgs) { FhirContext ctx = FhirContext.forDstu3(); IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu3"); // Build a search and execute it Bundle response = client.search() .forResource(Patient.class) .where(Patient.NAME.matches().value("Test")) .and(Patient.BIRTHDATE.before().day("2014-01-01")) .count(100) .returnBundle(Bundle.class) .execute(); // How many resources did we find? System.out.println("Responses: " + response.getTotal()); // Print the ID of the first one System.out.println("First response ID: " + response.getEntry().get(0).getResource().getId()); }
Example #2
Source File: ObservationStatsBuilder.java From org.hl7.fhir.core with Apache License 2.0 | 7 votes |
private static void addAge(Bundle b, int y, int m, String v) throws FHIRException { Observation obs = new Observation(); obs.setId("obs-example-age-weight-"+Integer.toString(y)+"-"+Integer.toString(m)); obs.setSubject(new Reference().setReference("Patient/123")); obs.setStatus(ObservationStatus.FINAL); Calendar when = Calendar.getInstance(); when.add(Calendar.YEAR, -y); when.add(Calendar.MONTH, m); obs.setEffective(new DateTimeType(when)); obs.getCode().addCoding().setCode("29463-7").setSystem("http://loinc.org"); obs.setValue(new Quantity()); obs.getValueQuantity().setCode("kg"); obs.getValueQuantity().setSystem("http://unitsofmeasure.org"); obs.getValueQuantity().setUnit("kg"); obs.getValueQuantity().setValue(new BigDecimal(v)); b.addEntry().setFullUrl("http://hl7.org/fhir/Observation/"+obs.getId()).setResource(obs); }
Example #3
Source File: LoincToDEConvertor.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
public Bundle process(String sourceFile) throws FileNotFoundException, SAXException, IOException, ParserConfigurationException { this.definitions = sourceFile; log("Begin. Produce Loinc CDEs in "+dest+" from "+definitions); loadLoinc(); log("LOINC loaded"); now = DateTimeType.now(); bundle = new Bundle(); bundle.setType(BundleType.COLLECTION); bundle.setId("http://hl7.org/fhir/commondataelement/loinc"); bundle.setMeta(new Meta().setLastUpdatedElement(InstantType.now())); processLoincCodes(); return bundle; }
Example #4
Source File: Test.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
public static void main(String[] args) { try { CCDAConverter c = new CCDAConverter(new UcumEssenceService(UCUM_PATH), SimpleWorkerContext.fromPack(Utilities.path(SRC_PATH, "validation.zip"))); Bundle a = c.convert(new FileInputStream(DEF_PATH + "ccda.xml")); String fx = DEF_PATH + "output.xml"; IParser x = new XmlParser().setOutputStyle(OutputStyle.PRETTY); x.compose(new FileOutputStream(fx), a); String fj = DEF_PATH + "output.json"; IParser j = new JsonParser().setOutputStyle(OutputStyle.PRETTY); j.compose(new FileOutputStream(fj), a); System.out.println("done. save as "+fx+" and "+fj); } catch (Exception e) { e.printStackTrace(); } }
Example #5
Source File: FhirSearchCustomizer.java From syndesis with Apache License 2.0 | 6 votes |
@Override public void afterProducer(Exchange exchange) { Message in = exchange.getIn(); Bundle bundle = in.getBody(Bundle.class); if (bundle == null) { return; } List<String> results = new ArrayList<>(); for (Bundle.BundleEntryComponent entry: bundle.getEntry()) { String resource = fhirContext.newXmlParser().encodeResourceToString(entry.getResource()); results.add(resource); } in.setBody(results); }
Example #6
Source File: LoincToDEConvertor.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
public void process() throws FHIRFormatError, IOException, XmlPullParserException, SAXException, ParserConfigurationException { log("Begin. Produce Loinc CDEs in "+dest+" from "+definitions); loadLoinc(); log("LOINC loaded"); now = DateTimeType.now(); bundle = new Bundle(); bundle.setId("http://hl7.org/fhir/commondataelement/loinc"); bundle.setMeta(new Meta().setLastUpdatedElement(InstantType.now())); processLoincCodes(); if (dest != null) { log("Saving..."); saveBundle(); } log("Done"); }
Example #7
Source File: FHIRToolingClient.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
public <T extends Resource> T getCanonical(Class<T> resourceClass, String canonicalURL) { ResourceRequest<T> result = null; try { result = utils.issueGetResourceRequest(resourceAddress.resolveGetUriFromResourceClassAndCanonical(resourceClass, canonicalURL), getPreferredResourceFormat()); result.addErrorStatus(410);//gone result.addErrorStatus(404);//unknown result.addErrorStatus(405);//unknown result.addSuccessStatus(200);//Only one for now if(result.isUnsuccessfulRequest()) { throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); } } catch (Exception e) { handleException("An error has occurred while trying to read this version of the resource", e); } Bundle bnd = (Bundle) result.getPayload(); if (bnd.getEntry().size() == 0) throw new EFhirClientException("No matching resource found for canonical URL '"+canonicalURL+"'"); if (bnd.getEntry().size() > 1) throw new EFhirClientException("Multiple matching resources found for canonical URL '"+canonicalURL+"'"); return (T) bnd.getEntry().get(0).getResource(); }
Example #8
Source File: NarrativeGenerator.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
public XhtmlNode generateDocumentNarrative(Bundle feed) { /* When the document is presented for human consumption, applications must present the collated narrative portions of the following resources in order: * The Composition resource * The Subject resource * Resources referenced in the section.content */ XhtmlNode root = new XhtmlNode(NodeType.Element, "div"); Composition comp = (Composition) feed.getEntry().get(0).getResource(); root.getChildNodes().add(comp.getText().getDiv()); Resource subject = ResourceUtilities.getById(feed, null, comp.getSubject().getReference()); if (subject != null && subject instanceof DomainResource) { root.hr(); root.getChildNodes().add(((DomainResource)subject).getText().getDiv()); } List<SectionComponent> sections = comp.getSection(); renderSections(feed, root, sections, 1); return root; }
Example #9
Source File: NarrativeGenerator.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
private void renderSections(Bundle feed, XhtmlNode node, List<SectionComponent> sections, int level) { for (SectionComponent section : sections) { node.hr(); if (section.hasTitleElement()) node.addTag("h"+Integer.toString(level)).addText(section.getTitle()); // else if (section.hasCode()) // node.addTag("h"+Integer.toString(level)).addText(displayCodeableConcept(section.getCode())); // if (section.hasText()) { // node.getChildNodes().add(section.getText().getDiv()); // } // // if (!section.getSection().isEmpty()) { // renderSections(feed, node.addTag("blockquote"), section.getSection(), level+1); // } } }
Example #10
Source File: ObservationStatsBuilder.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
private static void buildVitalSignsSet() throws FileNotFoundException, IOException, FHIRFormatError { Calendar base = Calendar.getInstance(); base.add(Calendar.DAY_OF_MONTH, -1); Bundle b = new Bundle(); b.setType(BundleType.COLLECTION); b.setId(UUID.randomUUID().toString().toLowerCase()); vitals(b, base, 0, 80, 120, 95, 37.1); vitals(b, base, 35, 85, 140, 98, 36.9); vitals(b, base, 53, 75, 110, 96, 36.2); vitals(b, base, 59, 65, 100, 94, 35.5); vitals(b, base, 104, 60, 90, 90, 35.9); vitals(b, base, 109, 65, 100, 92, 36.5); vitals(b, base, 114, 70, 130, 94, 37.5); vitals(b, base, 120, 90, 150, 97, 37.3); vitals(b, base, 130, 95, 133, 97, 37.2); vitals(b, base, 150, 85, 125, 98, 37.1); new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream("c:\\temp\\vitals.xml"), b); }
Example #11
Source File: FhirSearchTest.java From syndesis with Apache License 2.0 | 6 votes |
@Test public void searchTest() { Patient one = new Patient(); one.setId("one"); one.setGender(Enumerations.AdministrativeGender.UNKNOWN); Patient two = new Patient(); two.setId("two"); two.setGender(Enumerations.AdministrativeGender.UNKNOWN); Bundle bundle = new Bundle(); bundle.getEntry().add(new Bundle.BundleEntryComponent().setResource(one)); bundle.getEntry().add(new Bundle.BundleEntryComponent().setResource(two)); stubFhirRequest(get(urlEqualTo("/Patient?gender=unknown&_format=xml")).willReturn(okXml(toXml(bundle)))); FhirResourceQuery query = new FhirResourceQuery(); query.setQuery("gender=unknown"); String result = template.requestBody("direct:start", query, String.class); Assertions.assertThat(result).isEqualTo( "[<Patient xmlns=\"http://hl7.org/fhir\"><id value=\"one\"/><gender value=\"unknown\"/></Patient>, " + "<Patient xmlns=\"http://hl7.org/fhir\"><id value=\"two\"/><gender value=\"unknown\"/></Patient>]"); }
Example #12
Source File: FhirTransactionTest.java From syndesis with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("JdkObsolete") public void transactionTest() { Bundle bundle = new Bundle(); bundle.addEntry(new Bundle.BundleEntryComponent().setResource(new Account().setId("1").setMeta(new Meta().setLastUpdated(new Date())))); bundle.addEntry(new Bundle.BundleEntryComponent().setResource(new Patient().setId("2").setMeta(new Meta().setLastUpdated(new Date())))); stubFhirRequest(post(urlEqualTo("/?_format=xml")).withRequestBody(containing( "<type value=\"transaction\"/><total value=\"2\"/><link><relation value=\"fhir-base\"/></link>" + "<link><relation value=\"self\"/></link>" + "<entry><resource><Account xmlns=\"http://hl7.org/fhir\"><name value=\"Joe\"/></Account></resource>" + "<request><method value=\"POST\"/></request></entry><entry><resource>" + "<Patient xmlns=\"http://hl7.org/fhir\"><name><family value=\"Jackson\"/></name></Patient></resource>" + "<request><method value=\"POST\"/></request></entry>")).willReturn(okXml(toXml(bundle)))); template.requestBody("direct:start", "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + "<tns:Transaction xmlns:tns=\"http://hl7.org/fhir\">" + "<tns:Account><tns:name value=\"Joe\"/></tns:Account>" + "<tns:Patient><name><tns:family value=\"Jackson\"/></name></tns:Patient></tns:Transaction>"); }
Example #13
Source File: MessageTest.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
@Test public void test() throws FHIRException, IOException { // Create new Atom Feed Bundle feed = new Bundle(); // Serialize Atom Feed IParser comp = new JsonParser(); ByteArrayOutputStream os = new ByteArrayOutputStream(); comp.compose(os, feed); os.close(); String json = os.toString(); // Deserialize Atom Feed JsonParser parser = new JsonParser(); InputStream is = new ByteArrayInputStream(json.getBytes("UTF-8")); Resource result = parser.parse(is); if (result == null) throw new FHIRException("Bundle was null"); }
Example #14
Source File: FhirStu3.java From synthea with Apache License 2.0 | 6 votes |
/** * Helper function to create an Entry for the given Resource within the given Bundle. * Sets the entry's fullURL to resourceID, and adds the entry to the bundle. * * @param bundle The Bundle to add the Entry to * @param resource Resource the new Entry should contain * @param resourceID The Resource ID to assign * @return the created Entry */ private static BundleEntryComponent newEntry(Bundle bundle, Resource resource, String resourceID) { BundleEntryComponent entry = bundle.addEntry(); resource.setId(resourceID); if (Boolean.parseBoolean(Config.get("exporter.fhir.bulk_data"))) { entry.setFullUrl(resource.fhirType() + "/" + resourceID); } else { entry.setFullUrl("urn:uuid:" + resourceID); } entry.setResource(resource); if (TRANSACTION_BUNDLE) { BundleEntryRequestComponent request = entry.getRequest(); request.setMethod(HTTPVerb.POST); request.setUrl(resource.getResourceType().name()); entry.setRequest(request); } return entry; }
Example #15
Source File: MeasureOperationsProvider.java From cqf-ruler with Apache License 2.0 | 6 votes |
private void addEvaluatedResourcesToParameters(Bundle contained, Parameters parameters) { Map<String, Resource> resourceMap = new HashMap<>(); if (contained.hasEntry()) { for (Bundle.BundleEntryComponent entry : contained.getEntry()) { if (entry.hasResource() && !(entry.getResource() instanceof ListResource)) { if (!resourceMap.containsKey(entry.getResource().getIdElement().getValue())) { parameters.addParameter(new Parameters.ParametersParameterComponent().setName("resource") .setResource(entry.getResource())); resourceMap.put(entry.getResource().getIdElement().getValue(), entry.getResource()); resolveReferences(entry.getResource(), parameters, resourceMap); } } } } }
Example #16
Source File: MeasureOperationsProvider.java From cqf-ruler with Apache License 2.0 | 6 votes |
private Bundle createTransactionBundle(Bundle bundle) { Bundle transactionBundle; if (bundle != null) { if (bundle.hasType() && bundle.getType() == Bundle.BundleType.TRANSACTION) { transactionBundle = bundle; } else { transactionBundle = new Bundle().setType(Bundle.BundleType.TRANSACTION); if (bundle.hasEntry()) { for (Bundle.BundleEntryComponent entry : bundle.getEntry()) { if (entry.hasResource()) { transactionBundle.addEntry(createTransactionEntry(entry.getResource())); } } } } } else { transactionBundle = new Bundle().setType(Bundle.BundleType.TRANSACTION).setEntry(new ArrayList<>()); } return transactionBundle; }
Example #17
Source File: BundlesTest.java From bunsen with Apache License 2.0 | 5 votes |
@Test public void testRetrieveBundle() { BundleContainer container = bundlesRdd.first(); Bundle bundle = (Bundle) container.getBundle(); Assert.assertNotNull(bundle); Assert.assertTrue(bundle.getEntry().size() > 0); }
Example #18
Source File: FhirStu3.java From synthea with Apache License 2.0 | 5 votes |
/** * Map the clinician into a FHIR Practitioner resource, and add it to the given Bundle. * @param bundle The Bundle to add to * @param clinician The clinician * @return The added Entry */ protected static BundleEntryComponent practitioner(Bundle bundle, Clinician clinician) { Practitioner practitionerResource = new Practitioner(); practitionerResource.addIdentifier().setSystem("http://hl7.org/fhir/sid/us-npi") .setValue("" + clinician.identifier); practitionerResource.setActive(true); practitionerResource.addName().setFamily( (String) clinician.attributes.get(Clinician.LAST_NAME)) .addGiven((String) clinician.attributes.get(Clinician.FIRST_NAME)) .addPrefix((String) clinician.attributes.get(Clinician.NAME_PREFIX)); Address address = new Address() .addLine((String) clinician.attributes.get(Clinician.ADDRESS)) .setCity((String) clinician.attributes.get(Clinician.CITY)) .setPostalCode((String) clinician.attributes.get(Clinician.ZIP)) .setState((String) clinician.attributes.get(Clinician.STATE)); if (COUNTRY_CODE != null) { address.setCountry(COUNTRY_CODE); } practitionerResource.addAddress(address); if (clinician.attributes.get(Person.GENDER).equals("M")) { practitionerResource.setGender(AdministrativeGender.MALE); } else if (clinician.attributes.get(Person.GENDER).equals("F")) { practitionerResource.setGender(AdministrativeGender.FEMALE); } return newEntry(bundle, practitionerResource, clinician.getResourceID()); }
Example #19
Source File: HospitalExporterStu3.java From synthea with Apache License 2.0 | 5 votes |
/** * Export the hospital in FHIR STU3 format. */ public static void export(long stop) { if (Boolean.parseBoolean(Config.get("exporter.hospital.fhir_stu3.export"))) { Bundle bundle = new Bundle(); if (Boolean.parseBoolean(Config.get("exporter.fhir.transaction_bundle"))) { bundle.setType(BundleType.TRANSACTION); } else { bundle.setType(BundleType.COLLECTION); } for (Provider h : Provider.getProviderList()) { // filter - exports only those hospitals in use Table<Integer, String, AtomicInteger> utilization = h.getUtilization(); int totalEncounters = utilization.column(Provider.ENCOUNTERS).values().stream() .mapToInt(ai -> ai.get()).sum(); if (totalEncounters > 0) { BundleEntryComponent entry = FhirStu3.provider(bundle, h); addHospitalExtensions(h, (Organization) entry.getResource()); } } String bundleJson = FHIR_CTX.newJsonParser().setPrettyPrint(true) .encodeResourceToString(bundle); // get output folder List<String> folders = new ArrayList<>(); folders.add("fhir_stu3"); String baseDirectory = Config.get("exporter.baseDirectory"); File f = Paths.get(baseDirectory, folders.toArray(new String[0])).toFile(); f.mkdirs(); Path outFilePath = f.toPath().resolve("hospitalInformation" + stop + ".json"); try { Files.write(outFilePath, Collections.singleton(bundleJson), StandardOpenOption.CREATE_NEW); } catch (IOException e) { e.printStackTrace(); } } }
Example #20
Source File: ObservationStatsBuilder.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private static Observation baseVitals(Bundle b, Calendar when, int min, String name, String lCode, String text) throws FHIRFormatError { Observation obs = new Observation(); obs.setId("obs-vitals-"+name+"-"+Integer.toString(min)); obs.setSubject(new Reference().setReference("Patient/123")); obs.setStatus(ObservationStatus.FINAL); obs.setEffective(new DateTimeType(when)); obs.addCategory().setText("Vital Signs").addCoding().setSystem("http://hl7.org/fhir/observation-category").setCode("vital-signs").setDisplay("Vital Signs"); obs.getCode().setText(text).addCoding().setCode(lCode).setSystem("http://loinc.org"); b.addEntry().setFullUrl("http://hl7.org/fhir/Observation/"+obs.getId()).setResource(obs); return obs; }
Example #21
Source File: MeasureOperationsProvider.java From cqf-ruler with Apache License 2.0 | 5 votes |
private Bundle.BundleEntryComponent createTransactionEntry(Resource resource) { Bundle.BundleEntryComponent transactionEntry = new Bundle.BundleEntryComponent().setResource(resource); if (resource.hasId()) { transactionEntry.setRequest( new Bundle.BundleEntryRequestComponent().setMethod(Bundle.HTTPVerb.PUT).setUrl(resource.getId())); } else { transactionEntry.setRequest(new Bundle.BundleEntryRequestComponent().setMethod(Bundle.HTTPVerb.POST) .setUrl(resource.fhirType())); } return transactionEntry; }
Example #22
Source File: ObservationStatsBuilder.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private static void vitals(Bundle b, Calendar base, int minutes, int diastolic, int systolic, int sat, double temp) throws FHIRFormatError { Calendar when = (Calendar) base.clone(); when.add(Calendar.MINUTE, minutes); baseVitals(b, when, minutes, "sat", "59408-5", "O2 Saturation").setValue(makeQty(sat, "%", "%")); baseVitals(b, when, minutes, "temp", "8310-5", "Body temperature").setValue(makeQty(temp, "\u00b0C", "Cel")); Observation obs = baseVitals(b, when, minutes, "bp", "85354-9", "Blood pressure"); component(obs, "8480-6", "Systolic").setValue(makeQty(systolic, "mmhg", "mm[Hg]")); component(obs, "8462-4", "Diastolic").setValue(makeQty(diastolic, "mmhg", "mm[Hg]")); }
Example #23
Source File: MeasureOperationsProvider.java From cqf-ruler with Apache License 2.0 | 5 votes |
@Operation(name = "$submit-data", idempotent = true, type = Measure.class) public Resource submitData(RequestDetails details, @IdParam IdType theId, @OperationParam(name = "measure-report", min = 1, max = 1, type = MeasureReport.class) MeasureReport report, @OperationParam(name = "resource") List<IAnyResource> resources) { Bundle transactionBundle = new Bundle().setType(Bundle.BundleType.TRANSACTION); /* * TODO - resource validation using $data-requirements operation (params are the * provided id and the measurement period from the MeasureReport) * * TODO - profile validation ... not sure how that would work ... (get * StructureDefinition from URL or must it be stored in Ruler?) */ transactionBundle.addEntry(createTransactionEntry(report)); for (IAnyResource resource : resources) { Resource res = (Resource) resource; if (res instanceof Bundle) { for (Bundle.BundleEntryComponent entry : createTransactionBundle((Bundle) res).getEntry()) { transactionBundle.addEntry(entry); } } else { // Build transaction bundle transactionBundle.addEntry(createTransactionEntry(res)); } } return (Resource) this.registry.getSystemDao().transaction(details, transactionBundle); }
Example #24
Source File: FhirStu3.java From synthea with Apache License 2.0 | 5 votes |
/** * Map the given Media element to a FHIR Media resource, and add it to the given Bundle. * * @param personEntry The Entry for the Person * @param bundle Bundle to add the Media to * @param encounterEntry Current Encounter entry * @param obs The Observation to map to FHIR and add to the bundle * @return The added Entry */ private static BundleEntryComponent media(BundleEntryComponent personEntry, Bundle bundle, BundleEntryComponent encounterEntry, Observation obs) { org.hl7.fhir.dstu3.model.Media mediaResource = new org.hl7.fhir.dstu3.model.Media(); if (obs.codes != null && obs.codes.size() > 0) { List<CodeableConcept> reasonList = obs.codes.stream() .map(code -> mapCodeToCodeableConcept(code, SNOMED_URI)).collect(Collectors.toList()); mediaResource.setReasonCode(reasonList); } // Hard code as an image mediaResource.setType(DigitalMediaType.PHOTO); mediaResource.setSubject(new Reference(personEntry.getFullUrl())); Attachment content = (Attachment) obs.value; org.hl7.fhir.dstu3.model.Attachment contentResource = new org.hl7.fhir.dstu3.model.Attachment(); contentResource.setContentType(content.contentType); contentResource.setLanguage(content.language); if (content.data != null) { contentResource.setDataElement(new org.hl7.fhir.dstu3.model.Base64BinaryType(content.data)); } contentResource.setUrl(content.url); contentResource.setSize(content.size); contentResource.setTitle(content.title); if (content.hash != null) { contentResource.setHashElement(new org.hl7.fhir.dstu3.model.Base64BinaryType(content.hash)); } mediaResource.setWidth(content.width); mediaResource.setHeight(content.height); mediaResource.setContent(contentResource); return newEntry(bundle, mediaResource); }
Example #25
Source File: FhirStu3.java From synthea with Apache License 2.0 | 5 votes |
/** * Create an entry for the given Claim, which references a Medication. * * @param personEntry Entry for the person * @param bundle The Bundle to add to * @param encounterEntry The current Encounter * @param claim the Claim object * @param medicationEntry The Entry for the Medication object, previously created * @return the added Entry */ private static BundleEntryComponent medicationClaim(BundleEntryComponent personEntry, Bundle bundle, BundleEntryComponent encounterEntry, Claim claim, BundleEntryComponent medicationEntry) { org.hl7.fhir.dstu3.model.Claim claimResource = new org.hl7.fhir.dstu3.model.Claim(); org.hl7.fhir.dstu3.model.Encounter encounterResource = (org.hl7.fhir.dstu3.model.Encounter) encounterEntry.getResource(); claimResource.setStatus(ClaimStatus.ACTIVE); claimResource.setUse(org.hl7.fhir.dstu3.model.Claim.Use.COMPLETE); // duration of encounter claimResource.setBillablePeriod(encounterResource.getPeriod()); claimResource.setPatient(new Reference(personEntry.getFullUrl())); claimResource.setOrganization(encounterResource.getServiceProvider()); // add item for encounter claimResource.addItem(new org.hl7.fhir.dstu3.model.Claim.ItemComponent(new PositiveIntType(1)) .addEncounter(new Reference(encounterEntry.getFullUrl()))); // add prescription. claimResource.setPrescription(new Reference(medicationEntry.getFullUrl())); Money moneyResource = new Money(); moneyResource.setValue(claim.getTotalClaimCost()); moneyResource.setCode("USD"); moneyResource.setSystem("urn:iso:std:iso:4217"); claimResource.setTotal(moneyResource); return newEntry(bundle, claimResource); }
Example #26
Source File: FhirStu3.java From synthea with Apache License 2.0 | 5 votes |
/** * Find the Practitioner entry in this bundle, and return the associated "fullUrl" * attribute. * @param clinician A given clinician. * @param bundle The current bundle being generated. * @return Practitioner.fullUrl if found, otherwise null. */ private static String findPractitioner(Clinician clinician, Bundle bundle) { for (BundleEntryComponent entry : bundle.getEntry()) { if (entry.getResource().fhirType().equals("Practitioner")) { Practitioner doc = (Practitioner) entry.getResource(); if (doc.getIdentifierFirstRep().getValue().equals("" + clinician.identifier)) { return entry.getFullUrl(); } } } return null; }
Example #27
Source File: FhirStu3.java From synthea with Apache License 2.0 | 5 votes |
/** * Find the provider entry in this bundle, and return the associated "fullUrl" attribute. * @param provider A given provider. * @param bundle The current bundle being generated. * @return Provider.fullUrl if found, otherwise null. */ private static String findProviderUrl(Provider provider, Bundle bundle) { for (BundleEntryComponent entry : bundle.getEntry()) { if (entry.getResource().fhirType().equals("Organization")) { Organization org = (Organization) entry.getResource(); if (org.getIdentifierFirstRep().getValue().equals(provider.getResourceID())) { return entry.getFullUrl(); } } } return null; }
Example #28
Source File: ResourceUtilities.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
public static String representDataElementCollection(IWorkerContext context, Bundle bundle, boolean profileLink, String linkBase) { StringBuilder b = new StringBuilder(); DataElement common = showDECHeader(b, bundle); b.append("<table class=\"grid\">\r\n"); List<String> cols = chooseColumns(bundle, common, b, profileLink); for (BundleEntryComponent e : bundle.getEntry()) { DataElement de = (DataElement) e.getResource(); renderDE(de, cols, b, profileLink, linkBase); } b.append("</table>\r\n"); return b.toString(); }
Example #29
Source File: Stu3FhirConversionSupport.java From bunsen with Apache License 2.0 | 5 votes |
@Override public List<IBaseResource> extractEntryFromBundle(IBaseBundle bundle, String resourceName) { Bundle stu3Bundle = (Bundle) bundle; List<IBaseResource> items = stu3Bundle.getEntry().stream() .map(BundleEntryComponent::getResource) .filter(resource -> resource != null && resourceName.equalsIgnoreCase(resource.getResourceType().name())) .collect(Collectors.toList()); return items; }
Example #30
Source File: FhirStu3.java From synthea with Apache License 2.0 | 5 votes |
/** * Map the JsonObject for a Supply into a FHIR SupplyDelivery and add it to the Bundle. * * @param personEntry The Person entry. * @param bundle Bundle to add to. * @param supply The supplied object to add. * @param encounter The encounter during which the supplies were delivered * @return The added Entry. */ private static BundleEntryComponent supplyDelivery(BundleEntryComponent personEntry, Bundle bundle, HealthRecord.Supply supply, Encounter encounter) { SupplyDelivery supplyResource = new SupplyDelivery(); supplyResource.setStatus(SupplyDeliveryStatus.COMPLETED); supplyResource.setPatient(new Reference(personEntry.getFullUrl())); CodeableConcept type = new CodeableConcept(); type.addCoding() .setCode("device") .setDisplay("Device") .setSystem("http://hl7.org/fhir/supply-item-type"); supplyResource.setType(type); SupplyDeliverySuppliedItemComponent suppliedItem = new SupplyDeliverySuppliedItemComponent(); suppliedItem.setItem(mapCodeToCodeableConcept(supply.codes.get(0), SNOMED_URI)); SimpleQuantity quantity = new SimpleQuantity(); quantity.setValue(supply.quantity); suppliedItem.setQuantity(quantity); supplyResource.setSuppliedItem(suppliedItem); supplyResource.setOccurrence(convertFhirDateTime(supply.start, true)); return newEntry(bundle, supplyResource); }