Search in sources :

Example 26 with FHIRFormatError

use of org.hl7.fhir.exceptions.FHIRFormatError in project org.hl7.fhir.core by hapifhir.

the class ISO21090Importer method addParentProperties.

private void addParentProperties(List<ElementDefinition> elements, String name, String parent, boolean attrMode, boolean snapshot) throws FHIRFormatError {
    DataType dt = types.get(parent);
    if (dt == null)
        throw new Error("No find " + parent);
    if (dt.getParent() != null)
        addParentProperties(elements, name, dt.getParent(), attrMode, snapshot);
    produceProperties(elements, name, dt.getProperties(), attrMode, snapshot);
}
Also used : FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError)

Example 27 with FHIRFormatError

use of org.hl7.fhir.exceptions.FHIRFormatError in project org.hl7.fhir.core by hapifhir.

the class ExamplesPackageBuilder method process.

private void process(String source) throws FHIRFormatError, FileNotFoundException, IOException {
    Set<String> set = new HashSet<>();
    for (File f : new File(source).listFiles()) {
        if (f.getName().endsWith(".json")) {
            JsonObject obj = JsonTrackingParser.parseJson(new FileInputStream(f));
            if (obj.has("resourceType") && obj.has("id")) {
                String type = obj.get("resourceType").getAsString();
                String id = obj.get("id").getAsString();
                byte[] content = TextFile.fileToBytes(f);
                if (type.equals("ConceptMap")) {
                    System.out.println("convert " + f.getName());
                    content = r5ToR4B(content);
                    TextFile.bytesToFile(content, f);
                }
            // TextFile.bytesToFile(content, Utilities.path(dest2, type+"-"+id+".json"));
            // if (!set.contains(type+"/"+id)) {
            // set.add(type+"/"+id);
            // pck.addFile(Category.RESOURCE, type+"-"+id+".json", content);
            // }
            }
        }
    }
// pck.finish();
// 
}
Also used : JsonObject(com.google.gson.JsonObject) File(java.io.File) TextFile(org.hl7.fhir.utilities.TextFile) FileInputStream(java.io.FileInputStream) HashSet(java.util.HashSet)

Example 28 with FHIRFormatError

use of org.hl7.fhir.exceptions.FHIRFormatError in project org.hl7.fhir.core by hapifhir.

the class LoincToDEConvertor method saveBundle.

private void saveBundle() throws FHIRFormatError, IOException, XmlPullParserException {
    XmlParser xml = new XmlParser();
    FileOutputStream s = new FileOutputStream(dest);
    xml.compose(s, bundle, true);
    s.close();
}
Also used : XmlParser(org.hl7.fhir.dstu2.formats.XmlParser) FileOutputStream(java.io.FileOutputStream)

Example 29 with FHIRFormatError

use of org.hl7.fhir.exceptions.FHIRFormatError in project org.hl7.fhir.core by hapifhir.

the class ValueSetExpansionCache method loadCache.

private void loadCache() throws FHIRFormatError, IOException {
    File[] files = new File(cacheFolder).listFiles();
    for (File f : files) {
        if (f.getName().endsWith(".xml")) {
            final FileInputStream is = new FileInputStream(f);
            try {
                Resource r = context.newXmlParser().setOutputStyle(OutputStyle.PRETTY).parse(is);
                if (r instanceof OperationOutcome) {
                    OperationOutcome oo = (OperationOutcome) r;
                    expansions.put(ToolingExtensions.getExtension(oo, VS_ID_EXT).getValue().toString(), new ValueSetExpansionOutcome(new XhtmlComposer(true, false).composePlainText(oo.getText().getDiv())));
                } else {
                    ValueSet vs = (ValueSet) r;
                    expansions.put(vs.getUrl(), new ValueSetExpansionOutcome(vs, null));
                }
            } finally {
                IOUtils.closeQuietly(is);
            }
        }
    }
}
Also used : OperationOutcome(org.hl7.fhir.dstu2016may.model.OperationOutcome) Resource(org.hl7.fhir.dstu2016may.model.Resource) XhtmlComposer(org.hl7.fhir.utilities.xhtml.XhtmlComposer) ValueSetExpansionOutcome(org.hl7.fhir.dstu2016may.terminologies.ValueSetExpander.ValueSetExpansionOutcome) File(java.io.File) ValueSet(org.hl7.fhir.dstu2016may.model.ValueSet) FileInputStream(java.io.FileInputStream)

Example 30 with FHIRFormatError

use of org.hl7.fhir.exceptions.FHIRFormatError in project org.hl7.fhir.core by hapifhir.

the class LoincToDEConvertor method saveBundle.

private void saveBundle() throws FHIRFormatError, IOException, XmlPullParserException {
    XmlParser xml = new XmlParser();
    FileOutputStream s = new FileOutputStream(dest);
    xml.compose(s, bundle, true);
    s.close();
}
Also used : XmlParser(org.hl7.fhir.dstu2016may.formats.XmlParser) FileOutputStream(java.io.FileOutputStream)

Aggregations

XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)85 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)61 FileInputStream (java.io.FileInputStream)43 ArrayList (java.util.ArrayList)36 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)36 FileOutputStream (java.io.FileOutputStream)29 IOException (java.io.IOException)27 FHIRException (org.hl7.fhir.exceptions.FHIRException)26 File (java.io.File)22 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)19 XhtmlParser (org.hl7.fhir.utilities.xhtml.XhtmlParser)18 StructureDefinition (org.hl7.fhir.dstu3.model.StructureDefinition)13 StructureDefinition (org.hl7.fhir.r4b.model.StructureDefinition)13 JsonElement (com.google.gson.JsonElement)12 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)12 XhtmlComposer (org.hl7.fhir.utilities.xhtml.XhtmlComposer)12 XmlParser (org.hl7.fhir.r5.formats.XmlParser)11 Resource (org.hl7.fhir.dstu3.model.Resource)9 HashMap (java.util.HashMap)8 Extension (org.hl7.fhir.r5.model.Extension)8