Search in sources :

Example 41 with Package

use of org.hl7.fhir.utilities.graphql.Package in project beneficiary-fhir-data by CMSgov.

the class SamhsaMatcherFromClaimTransformerTest method verifySamhsaMatcherForItemWithSingleCoding.

/**
 * 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
 * @param code the code
 * @param shouldMatch if the matcher should match on this combination
 * @param explanationOfBenefit the explanation of benefit
 */
private void verifySamhsaMatcherForItemWithSingleCoding(String system, String code, 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();
        if (codeableConcept != null) {
            codeableConcept.setCoding(new ArrayList<>());
            diagnosisComponent.setPackageCode(null);
        }
    }
    List<Coding> codings = new ArrayList<>();
    Coding coding = new Coding();
    coding.setSystem(system);
    coding.setCode(code);
    codings.add(coding);
    modifiedEob.getItem().get(0).getService().setCoding(codings);
    assertEquals(shouldMatch, samhsaMatcher.test(modifiedEob));
}
Also used : Coding(org.hl7.fhir.dstu3.model.Coding) ArrayList(java.util.ArrayList) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 42 with Package

use of org.hl7.fhir.utilities.graphql.Package in project beneficiary-fhir-data by CMSgov.

the class SamhsaMatcherFromClaimTransformerTest method verifyNoItemCodingsTriggersSamhsaFiltering.

/**
 * Verifies that a claim with no samhsa diagnosis, procedure, or item-level HCPCS codes does
 * trigger filtering because the code array is empty and therefore does not contain known systems.
 *
 * @param expectMatch if the test is expecting a filtering match
 * @param explanationOfBenefit the loaded benefit to use for the test
 */
private void verifyNoItemCodingsTriggersSamhsaFiltering(ExplanationOfBenefit explanationOfBenefit, boolean expectMatch) {
    ExplanationOfBenefit modifiedEob = explanationOfBenefit.copy();
    // Set Top level diagnosis and package code to null and coding to empty
    for (ExplanationOfBenefit.DiagnosisComponent diagnosisComponent : modifiedEob.getDiagnosis()) {
        if (diagnosisComponent != null && diagnosisComponent.getDiagnosisCodeableConcept() != null) {
            diagnosisComponent.getDiagnosisCodeableConcept().setCoding(new ArrayList<>());
            diagnosisComponent.setPackageCode(null);
        }
    }
    // Set procedure to empty
    modifiedEob.setProcedure(new ArrayList<>());
    // Set item level codings to non-SAMHSA
    modifiedEob.getItem().get(0).setService(null);
    // When
    boolean isMatch = samhsaMatcher.test(modifiedEob);
    // Then
    assertEquals(expectMatch, isMatch);
}
Also used : ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit)

Example 43 with Package

use of org.hl7.fhir.utilities.graphql.Package in project kindling by HL7.

the class SpecNPMPackageGenerator method generate.

// 
// public static void main(String[] args) throws Exception {
// //    generateForVersion("F:\\fhir\\web\\DSTU2", "http://hl7.org/fhir/DSTU2");
// generateForVersion("E:\\fhir\\web\\2016May", "http://hl7.org/fhir/2016May", new Date());
// //    generateForVersion("F:\\fhir\\web\\STU3", "http://hl7.org/fhir/2016STU3");
// System.out.println("Done");
// }
// private static void generateForVersion(String folder, String url, Date genDate) throws Exception {
// SpecNPMPackageGenerator self = new SpecNPMPackageGenerator();
// self.generate(folder, url, false, genDate);
// }
// 
public void generate(String folder, String url, boolean forWeb, Date genDate, String pidRoot) throws Exception {
    System.out.println("Generate Package for " + folder);
    Map<String, byte[]> files = loadZip(new FileInputStream(Utilities.path(folder, "igpack.zip")));
    FHIRVersion version = determineVersion(files);
    System.out.println(" .. Loading v" + version);
    SpecMapManager spm = new SpecMapManager(files.get("spec.internals"), version.toCode());
    System.out.println(" .. Conformance Resources");
    List<ResourceEntry> reslist = makeResourceList(files, version.toCode());
    System.out.println(" .. Other Resources");
    addToResList(folder, reslist, version.toCode());
    System.out.println(" .. building IG");
    ImplementationGuide ig = new ImplementationGuide();
    ig.setId("fhir");
    ig.setUrl("http://hl7.org/fhir/ImplementationGuide/fhir");
    ig.setVersion(version.toCode());
    ig.addFhirVersion(version);
    ig.setLicense(SPDXLicense.CC01_0);
    ig.setTitle("FHIR Core package");
    ig.setDescription("FHIR Core package - the NPM package that contains all the definitions for the base FHIR specification");
    ig.setPublisher("HL7 Inc");
    ig.getContactFirstRep().getTelecomFirstRep().setSystem(ContactPointSystem.URL).setValue("http://hl7.org/fhir");
    ig.setPackageId(pidRoot + ".core");
    ig.getManifest().setRendering(url);
    for (ResourceEntry e : reslist) {
        ManifestResourceComponent r = ig.getManifest().addResource();
        r.setReference(new Reference(e.type + "/" + e.id));
        if (e.conf)
            r.setExample(new BooleanType(true));
        r.setRelativePath(spm.getPath(e.canonical, null));
    }
    for (String k : files.keySet()) {
        if (k.endsWith(".png") || k.endsWith(".gif"))
            ig.getManifest().addImage(k);
        else if (k.endsWith(".css"))
            ig.getManifest().addOther(k);
    }
    Map<String, ManifestPageComponent> map = new HashMap<String, ManifestPageComponent>();
    for (String k : spm.getPages()) {
        ManifestPageComponent pp = ig.getManifest().addPage();
        pp.setName(k).setTitle(spm.getPage(k));
        map.put(pp.getName(), pp);
    }
    for (String k : spm.getTargets()) {
        String n = null;
        String f = null;
        if (k.contains("#")) {
            n = k.substring(0, k.indexOf("#"));
            f = k.substring(k.indexOf("#") + 1);
        } else
            n = k;
        ManifestPageComponent p = map.get(n);
        if (p == null) {
            p = ig.getManifest().addPage();
            p.setName(n);
            map.put(p.getName(), p);
        }
        if (f != null)
            p.addAnchor(f);
    }
    // ok ig is full loaded...
    System.out.println(" .. Building NPM Package");
    NPMPackageGenerator npm = new NPMPackageGenerator(Utilities.path(folder, pidRoot + ".core.tgz"), "http://hl7.org/fhir", url, PackageType.CORE, ig, genDate, true);
    ByteArrayOutputStream bs = new ByteArrayOutputStream();
    new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.NORMAL).compose(bs, ig);
    // npm.addFile(Category.RESOURCE, "ig-r4.json", bs.toByteArray());
    addConvertedIg(npm, ig, version.toCode());
    for (ResourceEntry e : reslist) {
        npm.addFile(Category.RESOURCE, e.type + "-" + e.id + ".json", e.json);
    }
    for (String k : files.keySet()) {
        if (k.endsWith(".png") || k.endsWith(".css") || k.endsWith(".template") || k.endsWith(".zip") || k.endsWith(".gif") || k.equals("spec.internals") || k.equals("mappingSpaces.details"))
            npm.addFile(Category.OTHER, k, files.get(k));
    }
    for (String fn : new File(folder).list()) {
        if (fn.endsWith(".schema.json") || fn.endsWith(".openapi.json")) {
            byte[] b = TextFile.fileToBytes(Utilities.path(folder, fn));
            npm.addFile(Category.OPENAPI, fn, b);
        }
        if (fn.endsWith(".xsd") || fn.endsWith(".sch")) {
            byte[] b = TextFile.fileToBytes(Utilities.path(folder, fn));
            npm.addFile(Category.SCHEMATRON, fn, b);
        }
    }
    npm.finish();
    System.out.println(" .. Built");
    System.out.println(" .. Building NPM Package (xml)");
    ig.setId("fhir-xml");
    ig.setUrl("http://hl7.org/fhir/ImplementationGuide/fhir-xml");
    ig.setTitle("FHIR Core package (XML Conformance files)");
    ig.setDescription("FHIR Core package - the NPM package that contains all the definitions for the base FHIR specification (XML)");
    ig.setPackageId(pidRoot + ".corexml");
    npm = new NPMPackageGenerator(Utilities.path(folder, pidRoot + ".corexml.tgz"), "http://hl7.org/fhir", url, PackageType.CORE, ig, genDate, true);
    bs = new ByteArrayOutputStream();
    new org.hl7.fhir.r5.formats.XmlParser().setOutputStyle(OutputStyle.NORMAL).compose(bs, ig);
    npm.addFile(Category.RESOURCE, "ig-r4.json", bs.toByteArray());
    addConvertedIgX(npm, ig, version.toCode());
    for (ResourceEntry e : reslist) {
        if (e.xml != null)
            npm.addFile(Category.RESOURCE, e.type + "-" + e.id + ".xml", e.xml);
    }
    npm.finish();
    System.out.println(" .. Built");
}
Also used : SpecMapManager(org.hl7.fhir.tools.publisher.SpecMapManager) XmlParser(org.hl7.fhir.r5.formats.XmlParser) ImplementationGuide(org.hl7.fhir.r5.model.ImplementationGuide) HashMap(java.util.HashMap) Reference(org.hl7.fhir.r5.model.Reference) BooleanType(org.hl7.fhir.r5.model.BooleanType) NPMPackageGenerator(org.hl7.fhir.r5.utils.NPMPackageGenerator) ByteArrayOutputStream(java.io.ByteArrayOutputStream) FileInputStream(java.io.FileInputStream) FHIRVersion(org.hl7.fhir.r5.model.Enumerations.FHIRVersion) ManifestResourceComponent(org.hl7.fhir.r5.model.ImplementationGuide.ManifestResourceComponent) ManifestPageComponent(org.hl7.fhir.r5.model.ImplementationGuide.ManifestPageComponent) File(java.io.File) IniFile(org.hl7.fhir.utilities.IniFile) TextFile(org.hl7.fhir.utilities.TextFile) JsonParser(org.hl7.fhir.r5.formats.JsonParser)

Example 44 with Package

use of org.hl7.fhir.utilities.graphql.Package in project kindling by HL7.

the class UMLWriter method toText.

public static String toText(UMLModel model) {
    StringBuilder b = new StringBuilder();
    if (model.hasDocumentation()) {
        writeDoco(b, model, 0);
        b.append("\r\n\r\n");
    }
    for (UMLPackage p : model.getPackages()) {
        writeEntity(b, "package", p);
        writePackage(b, p);
        b.append("end-package\r\n");
    }
    return b.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder)

Example 45 with Package

use of org.hl7.fhir.utilities.graphql.Package in project kindling by HL7.

the class PageProcessor method getNormativeNote.

private String getNormativeNote(String genlevel, String pack, String type, String title, String filename) throws Exception {
    if (pack == null)
        throw new Error("Normative package not known for " + filename);
    if (!filename.contains("-definitions")) {
        Map<String, PageInfo> map = normativePackages.get(pack);
        if (map == null) {
            normativePages.add(filename);
            return ansiNote("This page has", pack, genlevel);
        }
        map.put(filename, new PageInfo(PageInfoType.fromCode(type), filename, title));
    }
    return ansiNote("This page has", pack, genlevel);
// "<p style=\"border: 1px black solid; background-color: #e6ffe6; padding: 5px\">\r\n" +
// "ANSI <a href=\""+genlevel+"ansi-"+pack+".html\">"+Utilities.capitalize(pack)+" </a>.\r\n" +
// "</p>\r\n" +
// "";
}
Also used : FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError) TransformerFactoryConfigurationError(javax.xml.transform.TransformerFactoryConfigurationError)

Aggregations

File (java.io.File)25 FHIRException (org.hl7.fhir.exceptions.FHIRException)22 TextFile (org.hl7.fhir.utilities.TextFile)22 IOException (java.io.IOException)19 ArrayList (java.util.ArrayList)15 JsonObject (com.google.gson.JsonObject)12 FileNotFoundException (java.io.FileNotFoundException)11 FileInputStream (java.io.FileInputStream)9 IniFile (org.hl7.fhir.utilities.IniFile)9 FilesystemPackageCacheManager (org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager)9 ParseException (java.text.ParseException)8 HashMap (java.util.HashMap)7 Gson (com.google.gson.Gson)6 GsonBuilder (com.google.gson.GsonBuilder)6 TarArchiveEntry (org.apache.commons.compress.archivers.tar.TarArchiveEntry)6 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)6 JsonElement (com.google.gson.JsonElement)5 FileOutputStream (java.io.FileOutputStream)5 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)5 CSFile (org.hl7.fhir.utilities.CSFile)5