Search in sources :

Example 1 with Function

use of org.hl7.fhir.r4b.model.ExpressionNode.Function in project beneficiary-fhir-data by CMSgov.

the class BeneficiaryTransformerV2Test method verifyDualResourceExtension.

/**
 * helper function to verify that {@link
 * gov.cms.bfd.server.war.r4.providers.BeneficiaryTransformerV2} correctly handles patient Part D
 * attributee.
 */
private void verifyDualResourceExtension(String dualId) {
    String uri = "https://bluebutton.cms.gov/resources/variables/" + dualId;
    Extension ex = TransformerTestUtilsV2.findExtensionByUrl(uri, patient.getExtension());
    assertNotNull(ex);
    Extension compare = new Extension(uri, new Coding(uri, "**", "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)"));
    assertTrue(compare.equalsDeep(ex));
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) Coding(org.hl7.fhir.r4.model.Coding)

Example 2 with Function

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

the class Publisher method execute.

/**
 * Entry point to the publisher. This classes Java Main() calls this function
 * to actually produce the specification
 *
 * @param folder
 * @throws IOException
 */
public void execute(String folder) throws IOException {
    tester = new PublisherTestSuites();
    page.log("Publish FHIR in folder " + folder + " @ " + Config.DATE_FORMAT().format(page.getGenDate().getTime()), LogMessageType.Process);
    if (web)
        page.log("Build final copy for HL7 web site", LogMessageType.Process);
    else
        page.log("Build local copy", LogMessageType.Process);
    if (outputdir != null) {
        page.log("Create output in " + outputdir, LogMessageType.Process);
    }
    page.log("Detected Java version: " + System.getProperty("java.version") + " from " + System.getProperty("java.home") + " on " + System.getProperty("os.arch"), LogMessageType.Process);
    try {
        tester.initialTests();
        page.setFolders(new FolderManager(folder, outputdir));
        if (!initialize(folder))
            throw new Exception("Unable to publish as preconditions aren't met");
        cache = new IniFile(page.getFolders().rootDir + "temp" + File.separator + "build.cache");
        loadSuppressedMessages(page.getFolders().rootDir);
        boolean doAny = false;
        for (String n : dates.keySet()) {
            Long d = cache.getLongProperty("dates", n);
            boolean b = d == null || (dates.get(n) > d);
            cache.setLongProperty("dates", n, dates.get(n).longValue(), null);
            buildFlags.put(n.toLowerCase(), b);
            doAny = doAny || b;
        }
        cache.save();
        if (noPartialBuild || !doAny || !(new File(page.getFolders().dstDir + "qa.html").exists()))
            // nothing - build all
            buildFlags.put("all", true);
        if (singlePage != null) {
            for (String n : buildFlags.keySet()) buildFlags.put(n, false);
            buildFlags.put("page-" + singlePage.toLowerCase(), true);
        } else if (singleResource != null) {
            for (String n : buildFlags.keySet()) buildFlags.put(n, false);
            buildFlags.put(singleResource.toLowerCase(), true);
        }
        if (!buildFlags.get("all")) {
            if (!noSound) {
                AudioUtilities.tone(1000, 10);
                AudioUtilities.tone(1400, 10);
                AudioUtilities.tone(1800, 10);
                AudioUtilities.tone(1000, 10);
                AudioUtilities.tone(1400, 10);
                AudioUtilities.tone(1800, 10);
            }
            page.log("Partial Build (if you want a full build, just run the build again)", LogMessageType.Process);
            CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
            for (String n : buildFlags.keySet()) if (buildFlags.get(n))
                b.append(n);
            page.log("  Build: " + b.toString(), LogMessageType.Process);
        } else {
            if (!noSound)
                AudioUtilities.tone(1200, 30);
            page.log("Full Build", LogMessageType.Process);
        }
        if (isGenerate && page.getBuildId() == null)
            page.setBuildId(getGitBuildId());
        page.log("Version " + page.getVersion() + "-" + page.getBuildId(), LogMessageType.Hint);
        Utilities.createDirectory(page.getFolders().dstDir);
        Utilities.deleteTempFiles();
        page.getBreadCrumbManager().parse(page.getFolders().srcDir + "hierarchy.xml");
        page.loadSnomed();
        page.loadLoinc();
        page.loadUcum();
        buildFeedsAndMaps();
        prsr.setExternals(externals);
        prsr.parse(page.getGenDate(), page.getValidationErrors());
        for (String n : page.getDefinitions().sortedResourceNames()) if (!page.getBreadCrumbManager().knowsResource(n))
            page.getValidationErrors().add(new ValidationMessage(Source.Publisher, IssueType.INVALID, -1, -1, "hierarchy.xml", "Resource not found: " + n, IssueSeverity.ERROR));
        for (String n : prsr.getErrors()) page.getValidationErrors().add(new ValidationMessage(Source.Publisher, IssueType.INVALID, -1, -1, "source spreadsheets", n, IssueSeverity.ERROR));
        if (web) {
            page.log("Clear Directory", LogMessageType.Process);
            Utilities.clearDirectory(page.getFolders().dstDir);
        }
        if (web || (isGenerate && buildFlags.get("all"))) {
            Utilities.createDirectory(page.getFolders().dstDir + "html");
            Utilities.createDirectory(page.getFolders().dstDir + "examples");
        }
        for (ImplementationGuideDefn ig : page.getDefinitions().getSortedIgs()) if (!ig.isCore())
            Utilities.createDirectory(page.getFolders().dstDir + ig.getCode());
        if (buildFlags.get("all")) {
            copyStaticContent();
        }
        page.makeRenderingContext();
        loadValueSets1();
        prsr.getRegistry().commit();
        generateSCMaps();
        validate();
        processProfiles();
        checkAllOk();
        if (isGenerate) {
            produceSpecification();
            checkAllOk();
        }
        if (doValidate)
            validationProcess();
        page.saveSnomed();
        page.getWorkerContext().saveCache();
        processWarnings(false);
        if (isGenerate && buildFlags.get("all"))
            produceQA();
        if (!buildFlags.get("all")) {
            page.log("This was a Partial Build", LogMessageType.Process);
            CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
            for (String n : buildFlags.keySet()) if (buildFlags.get(n))
                b.append(n);
            page.log("  Build: " + b.toString(), LogMessageType.Process);
        } else
            page.log("This was a Full Build", LogMessageType.Process);
        if (!noSound) {
            AudioUtilities.tone(800, 10);
            AudioUtilities.tone(1000, 10);
            AudioUtilities.tone(1200, 10);
            AudioUtilities.tone(1000, 10);
            AudioUtilities.tone(800, 10);
        }
        page.log("Finished publishing FHIR @ " + Config.DATE_FORMAT().format(Calendar.getInstance().getTime()), LogMessageType.Process);
    } catch (Exception e) {
        if (!(e instanceof NullPointerException)) {
            // because NullPointerException is unexpected...
            try {
                processWarnings(e instanceof EValidationFailed);
            } catch (Exception e2) {
                page.log("  ERROR: Unable to process warnings: " + e2.getMessage(), LogMessageType.Error);
                e2.printStackTrace();
            }
        }
        if (buildFlags.containsKey("all") && !buildFlags.get("all")) {
            page.log("This was a Partial Build", LogMessageType.Process);
            CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
            for (String n : buildFlags.keySet()) if (buildFlags.get(n))
                b.append(n);
            page.log("  Build: " + b.toString(), LogMessageType.Process);
        } else
            page.log("This was a Full Build", LogMessageType.Process);
        if (!noSound) {
            AudioUtilities.tone(800, 20);
            AudioUtilities.tone(1000, 20);
            AudioUtilities.tone(1200, 20);
        }
        try {
            Thread.sleep(50);
        } catch (InterruptedException e1) {
        }
        if (!noSound) {
            AudioUtilities.tone(800, 20);
            AudioUtilities.tone(1000, 20);
            AudioUtilities.tone(1200, 20);
        }
        try {
            Thread.sleep(50);
        } catch (InterruptedException e1) {
        }
        if (!noSound) {
            AudioUtilities.tone(800, 20);
            AudioUtilities.tone(1000, 20);
            AudioUtilities.tone(1200, 20);
        }
        page.log("FHIR build failure @ " + Config.DATE_FORMAT().format(Calendar.getInstance().getTime()), LogMessageType.Process);
        System.out.println("Error: " + e.getMessage());
        e.printStackTrace();
        TextFile.stringToFile(StringUtils.defaultString(e.getMessage()), Utilities.path(folder, "publish", "simple-error.txt"));
        System.exit(1);
    }
}
Also used : ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage) IniFile(org.hl7.fhir.utilities.IniFile) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ImplementationGuideDefn(org.hl7.fhir.definitions.model.ImplementationGuideDefn) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) EValidationFailed(org.hl7.fhir.tools.publisher.ExampleInspector.EValidationFailed) IniFile(org.hl7.fhir.utilities.IniFile) File(java.io.File) CSFile(org.hl7.fhir.utilities.CSFile) TextFile(org.hl7.fhir.utilities.TextFile)

Example 3 with Function

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

the class PageProcessor method produceStructureDefinitionExamples.

private String produceStructureDefinitionExamples(ResourceDefn resource) throws Exception {
    StringBuilder s = new StringBuilder();
    s.append("<div id=\"tabs\">\r\n");
    s.append("<ul>\r\n");
    s.append("  <li><a href=\"#tabs-1\">Base Types</a></li>\r\n");
    s.append("  <li><a href=\"#tabs-2\">Resources</a></li>\r\n");
    s.append("  <li><a href=\"#tabs-3\">Constraints</a></li>\r\n");
    s.append("  <li><a href=\"#tabs-4\">Extensions</a></li>\r\n");
    s.append("  <li><a href=\"#tabs-5\">Examples</a></li>\r\n");
    s.append("</ul>\r\n");
    s.append("<div id=\"tabs-1\">\r\n");
    // base types
    s.append("<table class=\"list\">\r\n");
    genStructureExampleCategory(s, "Abstract Types", "3");
    genStructureExample(s, definitions.getElementLink(), "element.profile", "element", "Element");
    genStructureExample(s, definitions.getBackboneLink(), "backboneelement.profile", "backboneelement", "BackBoneElement");
    genStructureExample(s, "resource.html", "resource.profile", "resource", "Resource");
    genStructureExample(s, "domainresource.html", "domainresource.profile", "domainresource", "DomainResource");
    genStructureExampleCategory(s, "Primitive Types", "3");
    List<String> names = new ArrayList<String>();
    names.addAll(definitions.getPrimitives().keySet());
    Collections.sort(names);
    for (String n : names) {
        DefinedCode dc = definitions.getPrimitives().get(n);
        genStructureExample(s, "datatypes.html#" + dc.getCode(), dc.getCode().toLowerCase() + ".profile", dc.getCode().toLowerCase(), dc.getCode());
    }
    genStructureExampleCategory(s, "Data Types", "3");
    names.clear();
    names.addAll(definitions.getTypes().keySet());
    names.addAll(definitions.getInfrastructure().keySet());
    Collections.sort(names);
    for (String n : names) {
        org.hl7.fhir.definitions.model.TypeDefn t = definitions.getTypes().get(n);
        if (t == null)
            t = definitions.getInfrastructure().get(n);
        genStructureExample(s, getLinkFor("", t.getName()), t.getName().toLowerCase() + ".profile", t.getName().toLowerCase(), t.getName());
    }
    s.append("</table>\r\n");
    s.append("</div>\r\n");
    s.append("<div id=\"tabs-2\">\r\n");
    s.append("<table class=\"list\">\r\n");
    genStructureExampleCategory(s, "Resources", "3");
    for (String n : definitions.sortedResourceNames()) {
        ResourceDefn r = definitions.getResources().get(n);
        genStructureExample(s, r.getName().toLowerCase() + ".html", r.getName().toLowerCase() + ".profile", r.getName().toLowerCase(), r.getName());
    }
    s.append("</table>\r\n");
    s.append("</div>\r\n");
    s.append("<div id=\"tabs-3\">\r\n");
    s.append("<table class=\"list\">\r\n");
    Map<String, ConstraintStructure> constraints = new HashMap<String, ConstraintStructure>();
    for (Profile pp : definitions.getPackList()) {
        for (ConstraintStructure p : pp.getProfiles()) constraints.put(p.getId(), p);
    }
    for (String rn : definitions.sortedResourceNames()) for (Profile ap : definitions.getResourceByName(rn).getConformancePackages()) for (ConstraintStructure p : ap.getProfiles()) constraints.put(p.getId(), p);
    names.clear();
    names.addAll(constraints.keySet());
    Collections.sort(names);
    for (ImplementationGuideDefn ig : definitions.getSortedIgs()) {
        boolean started = false;
        for (String n : names) {
            ConstraintStructure p = constraints.get(n);
            if (ig == p.getUsage()) {
                if (!started) {
                    started = true;
                    genStructureExampleCategory(s, ig.getName(), "3");
                }
                String prefix = ig.isCore() ? "" : ig.getCode() + "/";
                genStructureExample(s, prefix + p.getId().toLowerCase() + ".html", prefix + p.getId().toLowerCase() + ".profile", p.getId().toLowerCase(), p.getTitle());
            }
        }
    }
    s.append("</table>\r\n");
    s.append("</div>\r\n");
    s.append("<div id=\"tabs-4\">\r\n");
    s.append("<table class=\"list\">\r\n");
    names.clear();
    for (StructureDefinition sd : workerContext.getExtensionDefinitions()) names.add(sd.getUrl());
    Collections.sort(names);
    for (ImplementationGuideDefn ig : definitions.getSortedIgs()) {
        boolean started = false;
        for (String n : names) {
            StructureDefinition ed = workerContext.fetchResource(StructureDefinition.class, n);
            if (ig.getCode().equals(ToolResourceUtilities.getUsage(ed))) {
                if (!started) {
                    started = true;
                    genStructureExampleCategory(s, ig.getName(), "3");
                }
                String prefix = ig.isCore() ? "" : ig.getCode() + "/";
                genStructureExample(s, prefix + "extension-" + ed.getId().toLowerCase() + ".html", prefix + "extension-" + ed.getId().toLowerCase(), ed.getId().toLowerCase(), ed.getUrl().startsWith("http://hl7.org/fhir/StructureDefinition/") ? ed.getUrl().substring(40) : ed.getUrl(), ed.getName());
            }
        }
    }
    s.append("</table>\r\n");
    s.append("</div>\r\n");
    s.append("<div id=\"tabs-5\">\r\n");
    s.append("<table class=\"list\">\r\n");
    for (Example e : resource.getExamples()) {
        if (e.isRegistered() && Utilities.noString(e.getIg()))
            produceExampleListEntry(s, e, null, null);
    }
    for (Profile p : resource.getConformancePackages()) {
        for (Example e : p.getExamples()) {
            produceExampleListEntry(s, e, p, null);
        }
    }
    for (Profile p : definitions.getPackList()) {
        ImplementationGuideDefn ig = definitions.getIgs().get(p.getCategory());
        for (Example e : p.getExamples()) {
            String rn = e.getResourceName();
            if (Utilities.noString(rn))
                rn = e.getXml().getDocumentElement().getNodeName();
            if (rn.equals(resource.getName()))
                produceExampleListEntry(s, e, p, ig);
        }
    }
    for (ImplementationGuideDefn ig : definitions.getSortedIgs()) {
        if (ig.getIg() != null) {
            for (ImplementationGuideDefinitionResourceComponent res : ig.getIg().getDefinition().getResource()) {
                Example e = (Example) res.getUserData(ToolResourceUtilities.NAME_RES_EXAMPLE);
                if (res.hasExample() && e != null && e.getResourceName().equals(resource.getName()))
                    produceExampleListEntry(s, res, ig);
            }
        }
    }
    s.append("</table>\r\n");
    s.append("</div>\r\n");
    s.append("</div>\r\n");
    s.append("\r\n");
    s.append("<script src=\"external/jquery/jquery.js\"> </script>\r\n");
    s.append("<script src=\"jquery-ui.min.js\"> </script>\r\n");
    s.append("<script>\r\n");
    s.append("try {\r\n");
    s.append("  var currentTabIndex = sessionStorage.getItem('fhir-sdelist-tab-index');\r\n");
    s.append("}\r\n");
    s.append("catch(exception){\r\n");
    s.append("}\r\n");
    s.append("\r\n");
    s.append("if (!currentTabIndex)\r\n");
    s.append("  currentTabIndex = '0';\r\n");
    s.append("  \r\n");
    s.append("$( '#tabs' ).tabs({\r\n");
    s.append("         active: currentTabIndex,\r\n");
    s.append("         activate: function( event, ui ) {\r\n");
    s.append("             var active = $('.selector').tabs('option', 'active');\r\n");
    s.append("             currentTabIndex = ui.newTab.index();\r\n");
    s.append("             document.activeElement.blur();\r\n");
    s.append("             try {\r\n");
    s.append("               sessionStorage.setItem('fhir-sdelist-tab-index', currentTabIndex);\r\n");
    s.append("             }\r\n");
    s.append("             catch(exception){\r\n");
    s.append("             }\r\n");
    s.append("         }\r\n");
    s.append("     });\r\n");
    s.append("</script>\r\n");
    s.append("\r\n");
    return s.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ImplementationGuideDefn(org.hl7.fhir.definitions.model.ImplementationGuideDefn) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn) Profile(org.hl7.fhir.definitions.model.Profile) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) DefinedCode(org.hl7.fhir.definitions.model.DefinedCode) Example(org.hl7.fhir.definitions.model.Example) OperationExample(org.hl7.fhir.definitions.model.Operation.OperationExample) TypeDefn(org.hl7.fhir.definitions.model.TypeDefn) ImplementationGuideDefinitionResourceComponent(org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionResourceComponent) ConstraintStructure(org.hl7.fhir.definitions.model.ConstraintStructure)

Example 4 with Function

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

the class Hl7DocumentReferenceFHIRConversionTest method doc_ref_content_test.

@ParameterizedTest
@ValueSource(strings = { "MDM^T02", "MDM^T06" })
void doc_ref_content_test(String segment) {
    String documentReferenceMessage = "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|" + segment + "^MDM_T02|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6|56789^NID^UID|MCM||||\n" + "PID|1||000054321^^^MRN|||||||||||||M|CAT|||||N\n" + "PV1|1|I||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|NW|||PGN001|SC|D|1|||MS|MS|||||\n" + "OBR|1||||||20170825010500|||||||||||||002|||||F||||||||\n" + "TXA|1||TEXT||||201801180346||<PHYSID1>||||||||||AV|||<PHYSID2>||\n" + // Next three lines create an attachment
    "OBX|1|TX|||ECHOCARDIOGRAPHIC REPORT||||||F|||202101010000|||\n" + "OBX|2|TX|||NORMAL LV CHAMBER SIZE WITH MILD CONCENTRIC LVH||||||F|||202101010000|||\n" + "OBX|3|TX|||HYPERDYNAMIC LV SYSTOLIC FUNCTION, VISUAL EF 80%||||||F|||202101010000|||\n";
    DocumentReference report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    DocumentReference.DocumentReferenceContentComponent content = report.getContentFirstRep();
    // Future TXA.3, currently always defaults to text/plain
    assertThat(content.getAttachment().getContentType()).isEqualTo("text/plain");
    // TXA.7 date
    assertThat(content.getAttachment().getCreationElement().toString()).containsPattern("2018-01-18T03:46:00");
    assertThat(content.getAttachment().hasData()).isTrue();
    String decodedData = new String(Base64.getDecoder().decode(content.getAttachment().getDataElement().getValueAsString()));
    assertThat(decodedData).isEqualTo("ECHOCARDIOGRAPHIC REPORT\nNORMAL LV CHAMBER SIZE WITH MILD CONCENTRIC LVH\nHYPERDYNAMIC LV SYSTOLIC FUNCTION, VISUAL EF 80%");
    // TODO: Determine if we need to look at anything other than OBX.2 when it is TX
    // Leave this test in place as a reminder
    documentReferenceMessage = "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|" + segment + "^MDM_T02|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6|56789^NID^UID|MCM||||\n" + "PID|1||000054321^^^MRN|||||||||||||M|CAT|||||N\n" + "PV1|1|I||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|NW|||PGN001|SC|D|1|||MS|MS|||||\n" + "OBR|1||||||20170825010500|||||||||||||002|||||F||||||||\n" + "TXA|1||||||201801180346||<PHYSID1>||||||||||AV|||<PHYSID2>||\n" + // TODO: find better code for this test which is to see that OBX.2 is the fallback.
    "OBX|1|SN|||||||||F";
    report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    content = report.getContentFirstRep();
    // Because the OBX is not TX, the content is put in an Observation
    // FHIR requires a Content element, so only a minimal one is created.
    // Future OBX.2 is the backup for content type, but currently always defaults to text/plain
    assertThat(content.getAttachment().hasContentType()).isTrue();
    // Currently always defaults to text/plain
    assertThat(content.getAttachment().getContentType()).isEqualTo("text/plain");
    // TXA.7 date
    assertThat(content.getAttachment().getCreationElement().toString()).containsPattern("2018-01-18T03:46:00");
    assertThat(content.getAttachment().hasData()).isFalse();
    // Test that content is created even if TXA.7 is empty
    documentReferenceMessage = "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|" + segment + "^MDM_T02|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6|56789^NID^UID|MCM||||\n" + "PID|1||000054321^^^MRN|||||||||||||M|CAT|||||N\n" + "PV1|1|I||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|NW|||PGN001|SC|D|1|||MS|MS|||||\n" + "OBR|1||||||20170825010500|||||||||||||002|||||F||||||||\n" + // Ensure that empty TXA.7 still works
    "TXA|1||||||||<PHYSID1>||||||||||AV|||<PHYSID2>||\n" + "OBX|1|SN|||||||||F";
    report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    content = report.getContentFirstRep();
    // Because the OBX is not TX, the content is put in an Observation
    // FHIR requires a Content element, so only a minimal one is created.
    // Currently always defaults to text/plain
    assertThat(content.getAttachment().hasContentType()).isTrue();
    // Currently always defaults to text/plain, even if not data for content
    assertThat(content.getAttachment().getContentType()).isEqualTo("text/plain");
    // No TXA.7 date
    assertThat(content.getAttachment().hasCreationElement()).isFalse();
    assertThat(content.getAttachment().hasData()).isFalse();
}
Also used : DocumentReference(org.hl7.fhir.r4.model.DocumentReference) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with Function

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

the class Hl7ObservationFHIRConversionTest method testObservationSTMultiplePartsResult.

@Test
void testObservationSTMultiplePartsResult() throws IOException {
    String hl7message = baseMessage + "OBX|1|ST|^Type of protein feed^L||HYPERDYNAMIC LV SYSTOLIC FUNCTION, VISUAL EF 80%~Fifth line, as part of a repeated field||||||F||";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> obsResource = ResourceUtils.getResourceList(e, ResourceType.Observation);
    assertThat(obsResource).hasSize(1);
    Observation obs = (Observation) obsResource.get(0);
    assertThat(obs.getValueStringType()).isNotNull();
    StringType q = obs.getValueStringType();
    assertThat(q.asStringValue()).isEqualTo("HYPERDYNAMIC LV SYSTOLIC FUNCTION, VISUAL EF 80%. Fifth line, as part of a repeated field.");
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) StringType(org.hl7.fhir.r4.model.StringType) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.r4.model.Resource) Observation(org.hl7.fhir.r4.model.Observation) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Test (org.junit.jupiter.api.Test)17 List (java.util.List)8 FhirPath (au.csiro.pathling.fhirpath.FhirPath)7 Reference (org.hl7.fhir.r4.model.Reference)7 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)7 ParserContext (au.csiro.pathling.fhirpath.parser.ParserContext)6 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)6 URI (java.net.URI)6 Row (org.apache.spark.sql.Row)6 Session (org.eclipse.jetty.websocket.api.Session)6 ClientUpgradeRequest (org.eclipse.jetty.websocket.client.ClientUpgradeRequest)6 WebSocketClient (org.eclipse.jetty.websocket.client.WebSocketClient)6 IIdType (org.hl7.fhir.instance.model.api.IIdType)6 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)6 FhirReference (org.openmrs.module.fhir2.model.FhirReference)6 FhirTask (org.openmrs.module.fhir2.model.FhirTask)6 DatasetBuilder (au.csiro.pathling.test.builders.DatasetBuilder)5 ElementPathBuilder (au.csiro.pathling.test.builders.ElementPathBuilder)5 ParserContextBuilder (au.csiro.pathling.test.builders.ParserContextBuilder)5 ArrayList (java.util.ArrayList)5