Search in sources :

Example 1 with IParser

use of org.hl7.fhir.r5.formats.IParser in project gpconnect-demonstrator by nhsconnect.

the class ValueSetValidator method findValueSet.

private ValueSet findValueSet(String systemUrl) {
    int valueSetNamePos = systemUrl.lastIndexOf("/") + 1;
    String valueSetFilename = String.format("%s.xml", systemUrl.substring(valueSetNamePos));
    ValueSet valSet = null;
    String xmlContent = null;
    if (fhirValueSetsCheckWebFirst == true) {
        xmlContent = readValueSetFromWeb(valueSetFilename);
    }
    if (xmlContent == null) {
        xmlContent = readValueSetFromDisk(valueSetFilename);
    }
    if (fhirValueSetsCheckWebFirst == false && xmlContent == null) {
        xmlContent = readValueSetFromWeb(valueSetFilename);
    }
    if (xmlContent != null) {
        try {
            FhirContext fhirCtx = FhirContext.forDstu3();
            IParser parser = fhirCtx.newXmlParser();
            valSet = parser.parseResource(ValueSet.class, xmlContent);
        } catch (DataFormatException ex) {
            LOG.error(String.format("Error parsing valueSetFilename: %s", valueSetFilename));
        }
    }
    if (valSet == null) {
        throw OperationOutcomeFactory.buildOperationOutcomeException(new UnprocessableEntityException(String.format("Could not find or parse Value Set [SystemUrl: %s] at: %s. See system log for details.", systemUrl, valueSetFilename)), SystemCode.REFERENCE_NOT_FOUND, IssueType.NOTFOUND);
    }
    return valSet;
}
Also used : UnprocessableEntityException(ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException) FhirContext(ca.uhn.fhir.context.FhirContext) DataFormatException(ca.uhn.fhir.parser.DataFormatException) ValueSet(org.hl7.fhir.dstu3.model.ValueSet) IParser(ca.uhn.fhir.parser.IParser)

Example 2 with IParser

use of org.hl7.fhir.r5.formats.IParser in project beneficiary-fhir-data by CMSgov.

the class DMEClaimTransformerV2Test method before.

@BeforeEach
public void before() {
    claim = generateClaim();
    ExplanationOfBenefit genEob = DMEClaimTransformerV2.transform(new MetricRegistry(), claim, Optional.empty());
    IParser parser = fhirContext.newJsonParser();
    String json = parser.encodeResourceToString(genEob);
    eob = parser.parseResource(ExplanationOfBenefit.class, json);
}
Also used : MetricRegistry(com.codahale.metrics.MetricRegistry) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit) IParser(ca.uhn.fhir.parser.IParser) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with IParser

use of org.hl7.fhir.r5.formats.IParser in project beneficiary-fhir-data by CMSgov.

the class CarrierClaimTransformerV2Test method before.

@BeforeEach
public void before() {
    claim = generateClaim();
    ExplanationOfBenefit genEob = CarrierClaimTransformerV2.transform(new MetricRegistry(), claim, Optional.empty());
    IParser parser = fhirContext.newJsonParser();
    String json = parser.encodeResourceToString(genEob);
    eob = parser.parseResource(ExplanationOfBenefit.class, json);
}
Also used : MetricRegistry(com.codahale.metrics.MetricRegistry) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit) IParser(ca.uhn.fhir.parser.IParser) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with IParser

use of org.hl7.fhir.r5.formats.IParser in project beneficiary-fhir-data by CMSgov.

the class HospiceClaimTransformerV2Test method createEOB.

private void createEOB(Optional<Boolean> includeTaxNumber) {
    ExplanationOfBenefit genEob = HospiceClaimTransformerV2.transform(new MetricRegistry(), claim, includeTaxNumber);
    IParser parser = fhirContext.newJsonParser();
    String json = parser.encodeResourceToString(genEob);
    eob = parser.parseResource(ExplanationOfBenefit.class, json);
}
Also used : MetricRegistry(com.codahale.metrics.MetricRegistry) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit) IParser(ca.uhn.fhir.parser.IParser)

Example 5 with IParser

use of org.hl7.fhir.r5.formats.IParser in project beneficiary-fhir-data by CMSgov.

the class InpatientClaimTransformerV2Test method before.

@BeforeEach
public void before() {
    claim = generateClaim();
    ExplanationOfBenefit genEob = InpatientClaimTransformerV2.transform(new MetricRegistry(), claim, Optional.empty());
    IParser parser = fhirContext.newJsonParser();
    String json = parser.encodeResourceToString(genEob);
    eob = parser.parseResource(ExplanationOfBenefit.class, json);
}
Also used : MetricRegistry(com.codahale.metrics.MetricRegistry) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit) IParser(ca.uhn.fhir.parser.IParser) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

IParser (ca.uhn.fhir.parser.IParser)68 FhirContext (ca.uhn.fhir.context.FhirContext)33 ByteArrayOutputStream (java.io.ByteArrayOutputStream)30 IOException (java.io.IOException)25 Test (org.junit.Test)24 IParser (org.hl7.fhir.r5.formats.IParser)19 JsonParser (org.hl7.fhir.r5.formats.JsonParser)18 FHIRException (org.hl7.fhir.exceptions.FHIRException)17 ByteArrayInputStream (java.io.ByteArrayInputStream)16 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)15 File (java.io.File)15 FileInputStream (java.io.FileInputStream)15 Bundle (org.hl7.fhir.r4.model.Bundle)14 FileOutputStream (java.io.FileOutputStream)12 XmlParser (org.hl7.fhir.r5.formats.XmlParser)12 InputStream (java.io.InputStream)11 ArrayList (java.util.ArrayList)11 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)11 Patient (org.hl7.fhir.r4.model.Patient)11 PatientListMeasureEvaluation (com.ibm.cohort.engine.api.service.model.PatientListMeasureEvaluation)10