Search in sources :

Example 16 with System

use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project beneficiary-fhir-data by CMSgov.

the class CCWProcedureTest method assertMatches.

static void assertMatches(Character version, String system) {
    Optional<String> code = Optional.of("code");
    Optional<LocalDate> procDate = Optional.of(LocalDate.now());
    Optional<CCWProcedure> diagnosis = CCWProcedure.from(code, Optional.of(version), procDate);
    assertEquals(procDate.get(), diagnosis.get().getProcedureDate().get());
    assertEquals(system, diagnosis.get().getFhirSystem());
    TransformerTestUtils.assertHasCoding(system, code.get(), diagnosis.get().toCodeableConcept().getCoding());
    CodeableConcept codeableConcept = new CodeableConcept();
    Coding coding = codeableConcept.addCoding();
    coding.setSystem(system).setCode(code.get());
    assertTrue(diagnosis.get().isContainedIn(codeableConcept));
}
Also used : CCWProcedure(gov.cms.bfd.server.war.commons.CCWProcedure) Coding(org.hl7.fhir.dstu3.model.Coding) LocalDate(java.time.LocalDate) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 17 with System

use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project beneficiary-fhir-data by CMSgov.

the class CCWProcedureTest method assertDateNotPresent.

/**
 * Verifies that a procedure date isn't present even though there is a procedure code present
 */
static void assertDateNotPresent(Character version, String system) {
    Optional<String> code = Optional.of("code");
    Optional<LocalDate> procDate = Optional.empty();
    Optional<CCWProcedure> diagnosis = CCWProcedure.from(code, Optional.of(version), procDate);
    assertEquals(Optional.empty(), diagnosis.get().getProcedureDate());
    assertEquals(system, diagnosis.get().getFhirSystem());
    TransformerTestUtils.assertHasCoding(system, code.get(), diagnosis.get().toCodeableConcept().getCoding());
    CodeableConcept codeableConcept = new CodeableConcept();
    Coding coding = codeableConcept.addCoding();
    coding.setSystem(system).setCode(code.get());
    assertTrue(diagnosis.get().isContainedIn(codeableConcept));
}
Also used : CCWProcedure(gov.cms.bfd.server.war.commons.CCWProcedure) Coding(org.hl7.fhir.dstu3.model.Coding) LocalDate(java.time.LocalDate) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 18 with System

use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project beneficiary-fhir-data by CMSgov.

the class SamhsaMatcherR4FromClaimTransformerV2Test method verifySamhsaMatcherForItemWithMultiCoding.

/**
 * Verify SAMHSA matcher for item with the given system, code and if the expectation is that there
 * should be a match for this combination.
 *
 * @param system the system value of the first coding
 * @param code the code of the first coding
 * @param system2 the system value of the second coding
 * @param code2 the code of the second coding
 * @param shouldMatch if the matcher should match on this combination
 * @param explanationOfBenefit the explanation of benefit
 */
private void verifySamhsaMatcherForItemWithMultiCoding(String system, String code, String system2, String code2, boolean shouldMatch, ExplanationOfBenefit explanationOfBenefit) {
    ExplanationOfBenefit modifiedEob = explanationOfBenefit.copy();
    // Set Top level diagnosis and package code to null so we can test item logic
    for (ExplanationOfBenefit.DiagnosisComponent diagnosisComponent : modifiedEob.getDiagnosis()) {
        CodeableConcept codeableConcept = diagnosisComponent.getDiagnosisCodeableConcept();
        codeableConcept.setCoding(new ArrayList<>());
        diagnosisComponent.setPackageCode(null);
    }
    List<Coding> codings = new ArrayList<>();
    Coding coding = new Coding();
    coding.setSystem(system);
    coding.setCode(code);
    Coding coding2 = new Coding();
    coding2.setSystem(system2);
    coding2.setCode(code2);
    codings.add(coding);
    codings.add(coding2);
    modifiedEob.getItem().get(0).getProductOrService().setCoding(codings);
    assertEquals(shouldMatch, samhsaMatcherV2.test(modifiedEob));
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) ArrayList(java.util.ArrayList) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 19 with System

use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project kindling by HL7.

the class Publisher method produceSpecMap.

private void produceSpecMap() throws IOException {
    SpecMapManager spm = new SpecMapManager("hl7.fhir.core", page.getVersion().toCode(), page.getVersion().toCode(), page.getBuildId(), page.getGenDate(), CANONICAL_BASE);
    for (StructureDefinition sd : page.getWorkerContext().allStructures()) {
        if (sd.hasUserData("path")) {
            spm.path(sd.getUrl(), sd.getUserString("path").replace("\\", "/"));
            spm.target(sd.getUserString("path").replace("\\", "/"));
        }
    }
    for (StructureDefinition sd : page.getWorkerContext().getExtensionDefinitions()) {
        if (sd.hasUserData("path")) {
            spm.path(sd.getUrl(), sd.getUserString("path").replace("\\", "/"));
            spm.target(sd.getUserString("path").replace("\\", "/"));
        }
    }
    for (String s : page.getCodeSystems().keys()) {
        CodeSystem cs = page.getCodeSystems().get(s);
        if (cs == null && !Utilities.existsInList(s, "http://unitsofmeasure.org", "http://loinc.org", "http://fdasis.nlm.nih.gov", "http://www.nlm.nih.gov/research/umls/rxnorm", "urn:oid:1.2.36.1.2001.1005.17") && !SIDUtilities.isknownCodeSystem(s))
            System.out.println("No code system resource found for " + s);
    }
    for (CodeSystem cs : page.getCodeSystems().getList()) {
        if (cs != null && cs.hasUserData("path")) {
            spm.path(cs.getUrl(), cs.getUserString("path").replace("\\", "/"));
            spm.target(cs.getUserString("path").replace("\\", "/"));
        }
    }
    for (ValueSet vs : page.getValueSets().getList()) {
        if (vs.hasUserData("path")) {
            spm.path(vs.getUrl(), vs.getUserString("path").replace("\\", "/"));
            spm.target(vs.getUserString("path").replace("\\", "/"));
        }
    }
    for (ConceptMap cm : page.getConceptMaps().getList()) {
        if (cm.hasUserData("path")) {
            spm.path(cm.getUrl(), cm.getUserString("path").replace("\\", "/"));
            spm.target(cm.getUserString("path").replace("\\", "/"));
        }
    }
    for (String s : page.getDefinitions().getPageTitles().keySet()) {
        spm.page(s, page.getDefinitions().getPageTitles().get(s));
    }
    for (String n : page.getIni().getPropertyNames("pages")) {
        spm.target(n);
    }
    for (ResourceDefn rd : page.getDefinitions().getResources().values()) {
        spm.target(rd.getName().toLowerCase() + ".html");
        spm.target(rd.getName().toLowerCase() + "-definitions.html");
        spm.target(rd.getName().toLowerCase() + "-mappings.html");
        spm.target(rd.getName().toLowerCase() + "-examples.html");
        spm.target(rd.getName().toLowerCase() + "-profiles.html");
        if (!rd.getOperations().isEmpty())
            spm.target(rd.getName().toLowerCase() + "-operations.html");
        for (Example ex : rd.getExamples()) {
            ImplementationGuideDefn ig = ex.getIg() == null ? null : page.getDefinitions().getIgs().get(ex.getIg());
            String prefix = (ig == null || ig.isCore()) ? "" : ig.getCode() + "/";
            spm.target(prefix + ex.getTitle() + ".html");
        }
    }
    for (Profile p : page.getDefinitions().getPackList()) {
        spm.target(p.getId() + ".html");
    }
    // for (String url : page.getDefinitions().getMapTypes().keySet()) {
    // spm.map(url, page.getDefinitions().getMapTypes().get(url).getPreamble());
    // }
    scanForImages(spm, page.getFolders().dstDir, page.getFolders().dstDir);
    scanForPages(spm, page.getFolders().dstDir, page.getFolders().dstDir);
    for (String url : page.getDefinitions().getRedirectList().keySet()) {
        // http://hl7.org/fhir/ = 20 chars
        spm.target(url.substring(20));
    }
    spm.save(page.getFolders().dstDir + "spec.internals");
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) Example(org.hl7.fhir.definitions.model.Example) ConceptMap(org.hl7.fhir.r5.model.ConceptMap) ImplementationGuideDefn(org.hl7.fhir.definitions.model.ImplementationGuideDefn) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) ValueSet(org.hl7.fhir.r5.model.ValueSet) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn) Profile(org.hl7.fhir.definitions.model.Profile)

Example 20 with System

use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project kindling by HL7.

the class Publisher method generateCodeSystemRegistry.

private void generateCodeSystemRegistry() throws FileNotFoundException, IOException, Exception {
    XmlParser xml = new XmlParser();
    xml.setOutputStyle(OutputStyle.PRETTY);
    Bundle bnd = (Bundle) xml.parse(new CSFileInputStream(Utilities.path(page.getFolders().srcDir, "namingsystem", "namingsystem-terminologies.xml")));
    for (BundleEntryComponent entry : bnd.getEntry()) {
        NamingSystem ns = (NamingSystem) entry.getResource();
        entry.setFullUrl("http://hl7.org/fhir/NamingSystem/" + ns.getId());
        String url = null;
        for (NamingSystemUniqueIdComponent t : ns.getUniqueId()) {
            if (t.getType() == NamingSystemIdentifierType.URI)
                url = t.getValue();
        }
        if (url != null) {
            if (url.startsWith("http://hl7.org/fhir"))
                page.getDefinitions().addNs(url, "System " + ns.getName(), "terminologies-systems.html#" + url);
            page.getDefinitions().addNs(entry.getFullUrl(), ns.getId(), "terminologies-systems.html#" + url);
        }
    }
    List<String> names = new ArrayList<String>();
    Set<String> urls = new HashSet<>();
    names.addAll(page.getCodeSystems().keys());
    Collections.sort(names);
    for (String n : names) {
        CodeSystem cs = page.getCodeSystems().get(n);
        if (cs != null && !urls.contains(cs.getUrl()) && cs.hasUrl() && !cs.getUrl().startsWith("http://terminology.hl7.org")) {
            urls.add(cs.getUrl());
            if (cs.hasName()) {
                NamingSystem ns = new NamingSystem();
                ns.setId(cs.getId());
                ns.setName(cs.getName());
                ns.setStatus(cs.getStatus());
                if (!ns.hasStatus())
                    ns.setStatus(PublicationStatus.DRAFT);
                ns.setKind(NamingSystemType.CODESYSTEM);
                ns.setPublisher(cs.getPublisher());
                for (ContactDetail c : cs.getContact()) {
                    ContactDetail nc = ns.addContact();
                    nc.setName(c.getName());
                    for (ContactPoint cc : c.getTelecom()) {
                        nc.getTelecom().add(cc);
                    }
                }
                ns.setDate(cs.getDate());
                if (!ns.hasDate())
                    ns.setDate(page.getGenDate().getTime());
                ns.setDescription(cs.getDescription());
                ns.addUniqueId().setType(NamingSystemIdentifierType.URI).setValue(cs.getUrl()).setPreferred(true);
                String oid = CodeSystemUtilities.getOID(cs);
                if (oid != null) {
                    if (oid.startsWith("urn:oid:"))
                        oid = oid.substring(8);
                    ns.addUniqueId().setType(NamingSystemIdentifierType.OID).setValue(oid).setPreferred(false);
                }
                ns.setUserData("path", cs.getUserData("path"));
                bnd.addEntry().setResource(ns).setFullUrl("http://hl7.org/fhir/" + ns.fhirType() + "/" + ns.getId());
            }
        }
    }
    xml.compose(new FileOutputStream(Utilities.path(page.getFolders().dstDir, "namingsystem-terminologies.xml")), bnd);
    cloneToXhtml("namingsystem-terminologies", "Terminology Registry", false, "resource-instance:NamingSystem", "Terminology Registry", null, wg("vocab"));
    xml.setOutputStyle(OutputStyle.CANONICAL);
    xml.compose(new FileOutputStream(Utilities.path(page.getFolders().dstDir, "namingsystem-terminologies.canonical.xml")), bnd);
    JsonParser json = new JsonParser();
    json.setOutputStyle(OutputStyle.PRETTY);
    json.compose(new FileOutputStream(Utilities.path(page.getFolders().dstDir, "namingsystem-terminologies.json")), bnd);
    jsonToXhtml("namingsystem-terminologies", "Terminology Registry", TextFile.fileToString(Utilities.path(page.getFolders().dstDir, "namingsystem-terminologies.json")), "resource-instance:NamingSystem", "Terminology Registry", null, wg("vocab"));
    json.setOutputStyle(OutputStyle.CANONICAL);
    json.compose(new FileOutputStream(Utilities.path(page.getFolders().dstDir, "namingsystem-terminologies.canonical.json")), bnd);
    RdfParser rdf = new RdfParser();
    rdf.setOutputStyle(OutputStyle.PRETTY);
    rdf.compose(new FileOutputStream(Utilities.path(page.getFolders().dstDir, "namingsystem-terminologies.ttl")), bnd);
    ttlToXhtml("namingsystem-terminologies", "Terminology Registry", TextFile.fileToString(Utilities.path(page.getFolders().dstDir, "namingsystem-terminologies.ttl")), "resource-instance:NamingSystem", "Terminology Registry", null, wg("vocab"));
    StringBuilder b = new StringBuilder();
    b.append("<table class=\"grid\">\r\n");
    b.append(" <tr>");
    b.append("<td><b>Name</b></td>");
    b.append("<td><b>Uri</b></td>");
    b.append("<td><b>OID</b></td>");
    b.append("</tr>\r\n");
    for (BundleEntryComponent entry : bnd.getEntry()) {
        NamingSystem ns = (NamingSystem) entry.getResource();
        String uri = "";
        String oid = "";
        for (NamingSystemUniqueIdComponent id : ns.getUniqueId()) {
            if (id.getType() == NamingSystemIdentifierType.URI)
                uri = id.getValue();
            if (id.getType() == NamingSystemIdentifierType.OID)
                oid = id.getValue();
        }
        String link = "terminologies-systems.html#" + uri;
        if (ns.getUserData("path") != null)
            link = ns.getUserString("path");
        b.append(" <tr>");
        b.append("<td><a href=\"" + link + "\">" + Utilities.escapeXml(ns.getName()) + "</a></td>");
        b.append("<td>" + Utilities.escapeXml(uri) + "</td>");
        b.append("<td>" + Utilities.escapeXml(oid) + "</td>");
        b.append("</tr>\r\n");
    }
    b.append("</table>\r\n");
    String html = TextFile.fileToString(page.getFolders().templateDir + "template-example.html").replace("<%example%>", b.toString()).replace("<%example-usage%>", "");
    html = page.processPageIncludes("namingsystem-terminologies.html", html, "resource-instance:NamingSystem", null, bnd, null, "Example", null, null, page.getDefinitions().getWorkgroups().get("fhir"));
    TextFile.stringToFile(html, page.getFolders().dstDir + "namingsystem-terminologies.html");
    cachePage("namingsystem-terminologies.html", html, "Registered Code Systems", false);
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) NamingSystemUniqueIdComponent(org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) Bundle(org.hl7.fhir.r5.model.Bundle) ArrayList(java.util.ArrayList) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) ContactDetail(org.hl7.fhir.r5.model.ContactDetail) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) BundleEntryComponent(org.hl7.fhir.r5.model.Bundle.BundleEntryComponent) NamingSystem(org.hl7.fhir.r5.model.NamingSystem) FileOutputStream(java.io.FileOutputStream) CSFileInputStream(org.hl7.fhir.utilities.CSFileInputStream) HashSet(java.util.HashSet) JsonParser(org.hl7.fhir.r5.formats.JsonParser) RdfParser(org.hl7.fhir.r5.formats.RdfParser)

Aggregations

Test (org.junit.jupiter.api.Test)92 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)75 ArrayList (java.util.ArrayList)70 Coding (org.hl7.fhir.r4.model.Coding)70 Identifier (org.hl7.fhir.r4.model.Identifier)62 FHIRException (org.hl7.fhir.exceptions.FHIRException)45 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)45 Resource (org.hl7.fhir.r4.model.Resource)45 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)38 Test (org.junit.Test)37 Coding (org.hl7.fhir.dstu3.model.Coding)32 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)32 HashMap (java.util.HashMap)30 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)28 List (java.util.List)27 IOException (java.io.IOException)26 Bundle (org.hl7.fhir.r4.model.Bundle)26 Patient (org.hl7.fhir.r4.model.Patient)25 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)24 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)21