Search in sources :

Example 76 with Bundle

use of org.hl7.fhir.r4b.model.Bundle in project kindling by HL7.

the class DSTU3ValidationConvertor method convert.

public void convert(String bundleSource, String bundleTarget) throws Exception {
    System.out.println("Convert " + bundleSource);
    try {
        source = (Bundle) new XmlParser().parse(new FileInputStream(bundleSource));
        org.hl7.fhir.dstu3.model.Bundle target = Bundle30_50.convertBundle(source);
        new org.hl7.fhir.dstu3.formats.XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(bundleTarget), target);
    } catch (Exception e) {
        throw new Exception(e);
    }
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) FileOutputStream(java.io.FileOutputStream) FileInputStream(java.io.FileInputStream)

Example 77 with Bundle

use of org.hl7.fhir.r4b.model.Bundle in project kindling by HL7.

the class SourceParser method loadCommonSearchParameters.

private void loadCommonSearchParameters() throws FHIRFormatError, FileNotFoundException, IOException {
    Bundle bnd = (Bundle) new XmlParser().parse(new CSFileInputStream(Utilities.path(srcDir, "searchparameter", "common-search-parameters.xml")));
    for (BundleEntryComponent be : bnd.getEntry()) {
        SearchParameter sp = (SearchParameter) be.getResource();
        CommonSearchParameter csp = new CommonSearchParameter();
        csp.setId(sp.getId());
        csp.setCode(sp.getCode());
        for (CodeType ct : sp.getBase()) {
            csp.getResources().add(ct.asStringValue());
            definitions.getCommonSearchParameters().put(ct.asStringValue() + "::" + sp.getCode(), csp);
        }
    }
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) XLSXmlParser(org.hl7.fhir.utilities.xls.XLSXmlParser) BundleEntryComponent(org.hl7.fhir.r5.model.Bundle.BundleEntryComponent) Bundle(org.hl7.fhir.r5.model.Bundle) CommonSearchParameter(org.hl7.fhir.definitions.model.CommonSearchParameter) CodeType(org.hl7.fhir.r5.model.CodeType) CommonSearchParameter(org.hl7.fhir.definitions.model.CommonSearchParameter) SearchParameter(org.hl7.fhir.r5.model.SearchParameter) CSFileInputStream(org.hl7.fhir.utilities.CSFileInputStream)

Example 78 with Bundle

use of org.hl7.fhir.r4b.model.Bundle in project kindling by HL7.

the class SpreadSheetCreator method addSearchParams.

private void addSearchParams(XSSFWorkbook excel) throws FHIRFormatError, FileNotFoundException, IOException {
    Bundle bnd = (Bundle) parseXml(fnSP());
    XSSFSheet sheet = excel.createSheet(SN_SEARCH);
    addSearchColumns(sheet);
    int rowCount = 0;
    for (BundleEntryComponent be : bnd.getEntry()) {
        rowCount++;
        addSearchParam(sheet, (SearchParameter) be.getResource(), rowCount);
    }
}
Also used : XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) BundleEntryComponent(org.hl7.fhir.r5.model.Bundle.BundleEntryComponent) Bundle(org.hl7.fhir.r5.model.Bundle)

Example 79 with Bundle

use of org.hl7.fhir.r4b.model.Bundle in project kindling by HL7.

the class Publisher method addToResourceFeed.

private void addToResourceFeed(CapabilityStatement cs, Bundle dest) throws Exception {
    if (cs.getId() == null)
        throw new Exception("Resource has no id");
    if (ResourceUtilities.getById(dest, ResourceType.ValueSet, cs.getId()) != null)
        throw new Exception("Attempt to add duplicate Conformance " + cs.getId());
    if (!cs.hasText() || !cs.getText().hasDiv()) {
        RendererFactory.factory(cs, page.getRc().copy()).render(cs);
    }
    if (!cs.hasText() || cs.getText().getDiv() == null)
        System.out.println("WARNING: Example CapabilityStatement " + cs.getId() + " does not have any narrative");
    // Changed this from an exception to a warning because generateConformanceStatement doesn't produce narrative if
    // "register" is 'false'
    ResourceUtilities.meta(cs).setLastUpdated(page.getGenDate().getTime());
    if (!cs.getUrl().equals("http://hl7.org/fhir/" + cs.getResourceType().toString() + "/" + cs.getId()))
        throw new Exception("URL mismatch on CapabilityStatement");
    dest.getEntry().add(new BundleEntryComponent().setResource(cs).setFullUrl("http://hl7.org/fhir/" + cs.fhirType() + "/" + cs.getId()));
}
Also used : BundleEntryComponent(org.hl7.fhir.r5.model.Bundle.BundleEntryComponent) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 80 with Bundle

use of org.hl7.fhir.r4b.model.Bundle in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7EncounterFHIRConversionTest method test_encounter_PV1_serviceProvider.

// Test for serviceProvider reference in messages with both PV1 and PV2 segments
// Part 2: Field PV2.23 is provided but no PV2.23.8; serviceProvider id should use backup field PV1.3.4.1
@ParameterizedTest
@ValueSource(strings = { "ADT^A01", /* "ADT^A02", "ADT^A03", "ADT^A04", */
"ADT^A08", // MDM messages are not tested here because they do not have PV2 segments
"OMP^O09", "ORU^R01", "RDE^O11", "RDE^O25", "VXU^V04" })
void test_encounter_PV1_serviceProvider(String message) {
    String hl7message = "MSH|^~\\&|TestSystem||TestTransformationAgent||20150502090000||" + message + "|controlID|P|2.6\r" + "EVN||20210330144208||ADT_EVENT|007|20210309140700\r" + "PID|1||0a8a1752-e336-43e1-bf7f-0c8f6f437ca3^^^MRN||Patient^Load^Generator||19690720|M|Patient^Alias^Generator|AA|9999^^CITY^STATE^ZIP^CAN|COUNTY|(866)845-0900||ENGLISH^ENGLISH|SIN|NONE|Account_0a8a1752-e336-43e1-bf7f-0c8f6f437ca3|123-456-7890|||N|BIRTH PLACE|N||||||N\r" + "PV1||I|^^^Toronto^^5642 Hilly Av||||2905^Doctor^Attending^M^IV^^M.D|5755^Doctor^Referring^^Sr|770542^Doctor^Consulting^Jr||||||||59367^Doctor^Admitting||Visit_0a3be81e-144b-4885-9b4e-c5cd33c8f038|||||||||||||||||||||||||20210407191342\r" + "PV2||TEL||||X-5546||20210330144208|20210309||||||||||||n|N|South Shore Hosptial Weymouth|||||||||N||||||\r";
    String json = ftv.convert(hl7message, OPTIONS);
    assertThat(json).isNotBlank();
    LOGGER.debug("FHIR json result:\n" + json);
    IBaseResource bundleResource = context.getParser().parseResource(json);
    assertThat(bundleResource).isNotNull();
    Bundle b = (Bundle) bundleResource;
    List<BundleEntryComponent> e = b.getEntry();
    List<Resource> encounterResource = ResourceUtils.getResourceList(e, ResourceType.Encounter);
    assertThat(encounterResource).hasSize(1);
    Encounter encounter = ResourceUtils.getResourceEncounter(encounterResource.get(0), context);
    Reference serviceProvider = encounter.getServiceProvider();
    assertThat(serviceProvider).isNotNull();
    String providerString = serviceProvider.getReference();
    assertThat(providerString).isEqualTo("Organization/toronto");
    List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
    assertThat(organizations).hasSize(1);
    Organization orgResource = ResourceUtils.getResourceOrganization(organizations.get(0), context);
    assertThat(orgResource.getId()).isEqualTo(providerString);
    assertThat(orgResource.getName()).isEqualTo("South Shore Hosptial Weymouth");
    assertThat(orgResource.getIdentifier()).hasSize(1);
    // PV1.3.4.1
    assertThat(orgResource.getIdentifierFirstRep().getValue()).hasToString("Toronto");
    // Because ID is name based
    assertThat(orgResource.getIdentifierFirstRep().getSystem()).hasToString("urn:id:extID");
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Organization(org.hl7.fhir.r4.model.Organization) Bundle(org.hl7.fhir.r4.model.Bundle) Reference(org.hl7.fhir.r4.model.Reference) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.r4.model.Resource) Encounter(org.hl7.fhir.r4.model.Encounter) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Bundle (org.hl7.fhir.r4.model.Bundle)603 Bundle (org.hl7.fhir.dstu3.model.Bundle)357 Test (org.junit.Test)343 Test (org.junit.jupiter.api.Test)316 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)306 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)192 IBaseBundle (org.hl7.fhir.instance.model.api.IBaseBundle)167 Date (java.util.Date)159 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)151 ArrayList (java.util.ArrayList)147 List (java.util.List)143 Resource (org.hl7.fhir.r4.model.Resource)128 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)116 HashMap (java.util.HashMap)113 Collectors (java.util.stream.Collectors)108 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)106 Patient (org.hl7.fhir.r4.model.Patient)93 Beneficiary (gov.cms.bfd.model.rif.Beneficiary)85 Observation (org.hl7.fhir.r4.model.Observation)79 IOException (java.io.IOException)77