Search in sources :

Example 16 with FhirFormat

use of org.hl7.fhir.r4b.elementmodel.Manager.FhirFormat in project org.hl7.fhir.core by hapifhir.

the class FormatUtilities method loadFile.

public static Resource loadFile(String path) throws FileNotFoundException, IOException, FHIRException {
    byte[] src = TextFile.fileToBytes(path);
    FhirFormat fmt = determineFormat(src);
    ParserBase parser = makeParser(fmt);
    return parser.parse(src);
}
Also used : FhirFormat(org.hl7.fhir.r4b.elementmodel.Manager.FhirFormat)

Example 17 with FhirFormat

use of org.hl7.fhir.r4b.elementmodel.Manager.FhirFormat in project org.hl7.fhir.core by hapifhir.

the class SpecDifferenceEvaluator method saveResource.

private void saveResource(ZipGenerator zip, Resource t, FhirFormat fmt) throws IOException {
    ByteArrayOutputStream bs = new ByteArrayOutputStream();
    if (fmt == FhirFormat.JSON)
        new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(bs, t);
    else
        new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(bs, t);
    zip.addBytes(t.fhirType() + "-" + t.getId() + "." + fmt.getExtension(), bs.toByteArray(), true);
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) ByteArrayOutputStream(java.io.ByteArrayOutputStream) JsonParser(org.hl7.fhir.r5.formats.JsonParser)

Example 18 with FhirFormat

use of org.hl7.fhir.r4b.elementmodel.Manager.FhirFormat in project org.hl7.fhir.core by hapifhir.

the class FormatUtilities method loadFile.

public static Resource loadFile(InputStream source) throws FileNotFoundException, IOException, FHIRException {
    byte[] src = TextFile.streamToBytes(source);
    FhirFormat fmt = determineFormat(src);
    ParserBase parser = makeParser(fmt);
    return parser.parse(src);
}
Also used : FhirFormat(org.hl7.fhir.r4.elementmodel.Manager.FhirFormat)

Example 19 with FhirFormat

use of org.hl7.fhir.r4b.elementmodel.Manager.FhirFormat in project org.hl7.fhir.core by hapifhir.

the class FormatUtilities method loadFile.

public static Resource loadFile(String path) throws FileNotFoundException, IOException, FHIRException {
    byte[] src = TextFile.fileToBytes(path);
    FhirFormat fmt = determineFormat(src);
    ParserBase parser = makeParser(fmt);
    return parser.parse(src);
}
Also used : FhirFormat(org.hl7.fhir.r4.elementmodel.Manager.FhirFormat)

Aggregations

InstanceValidator (org.hl7.fhir.validation.instance.InstanceValidator)6 FHIRException (org.hl7.fhir.exceptions.FHIRException)5 Element (org.hl7.fhir.r5.elementmodel.Element)4 ValidationMessage (org.hl7.fhir.utilities.validation.ValidationMessage)4 IOException (java.io.IOException)3 FhirFormat (org.hl7.fhir.r5.elementmodel.Manager.FhirFormat)3 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)3 ArrayList (java.util.ArrayList)2 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)2 FhirFormat (org.hl7.fhir.r4.elementmodel.Manager.FhirFormat)2 JsonParser (org.hl7.fhir.r5.formats.JsonParser)2 XmlParser (org.hl7.fhir.r5.formats.XmlParser)2 StructureMapUtilities (org.hl7.fhir.r5.utils.structuremap.StructureMapUtilities)2 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStream (java.io.InputStream)1 MalformedURLException (java.net.MalformedURLException)1