Search in sources :

Example 1 with ValueSetExpansionOutcome

use of org.hl7.fhir.dstu2.terminologies.ValueSetExpander.ValueSetExpansionOutcome in project kindling by HL7.

the class PageProcessor method expandVS.

public String expandVS(ValueSet vs, String prefix, String base) {
    try {
        ValueSetExpansionOutcome result = workerContext.expandVS(vs, true, true);
        if (result.getError() != null)
            return "<hr/>\r\n" + VS_INC_START + "<!--3-->" + processExpansionError(result.getError()) + VS_INC_END;
        if (result.getValueset() == null)
            return "<hr/>\r\n" + VS_INC_START + "<!--4-->" + processExpansionError("(no error returned)") + VS_INC_END;
        ValueSet exp = result.getValueset();
        if (exp == vs)
            throw new Exception("Expansion cannot be the same instance");
        exp.setCompose(null);
        exp.setText(null);
        exp.setDescription("Value Set Contents (Expansion) for " + vs.present() + " at " + Config.DATE_FORMAT().format(new Date()));
        int i = countContains(exp.getExpansion().getContains());
        IniFile sini = new IniFile(Utilities.path(folders.rootDir, "temp", "stats.ini"));
        sini.setIntegerProperty("valuesets", vs.getId(), i, null);
        sini.save();
        RenderingContext lrc = rc.copy().setLocalPrefix(prefix).setTooCostlyNoteEmpty(TOO_MANY_CODES_TEXT_EMPTY).setTooCostlyNoteNotEmpty(TOO_MANY_CODES_TEXT_NOT_EMPTY);
        RendererFactory.factory(exp, lrc).render(exp);
        return "<hr/>\r\n" + VS_INC_START + "" + new XhtmlComposer(XhtmlComposer.HTML).compose(exp.getText().getDiv()) + VS_INC_END;
    } catch (Exception e) {
        e.printStackTrace();
        return "<hr/>\r\n" + VS_INC_START + "<!--5-->" + processExpansionError(e instanceof NullPointerException ? "NullPointerException" : e.getMessage()) + " " + Utilities.escapeXml(stack(e)) + VS_INC_END;
    }
}
Also used : RenderingContext(org.hl7.fhir.r5.renderers.utils.RenderingContext) IniFile(org.hl7.fhir.utilities.IniFile) XhtmlComposer(org.hl7.fhir.utilities.xhtml.XhtmlComposer) ValueSetExpansionOutcome(org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome) ValueSet(org.hl7.fhir.r5.model.ValueSet) UcumException(org.fhir.ucum.UcumException) TransformerException(javax.xml.transform.TransformerException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) URISyntaxException(java.net.URISyntaxException) PathEngineException(org.hl7.fhir.exceptions.PathEngineException) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) FileNotFoundException(java.io.FileNotFoundException) NotImplementedException(org.apache.commons.lang3.NotImplementedException) Date(java.util.Date) ContactPoint(org.hl7.fhir.r5.model.ContactPoint)

Example 2 with ValueSetExpansionOutcome

use of org.hl7.fhir.dstu2.terminologies.ValueSetExpander.ValueSetExpansionOutcome in project kindling by HL7.

the class PageProcessor method expandValueSetIG.

private String expandValueSetIG(ValueSet vs, boolean heirarchy) throws Exception {
    if (!hasDynamicContent(vs))
        return "";
    try {
        ValueSetExpansionOutcome result = workerContext.expandVS(vs, true, heirarchy);
        if (result.getError() != null)
            return "<hr/>\r\n" + VS_INC_START + "<!--1-->" + processExpansionError(result.getError()) + VS_INC_END;
        ValueSet exp = result.getValueset();
        if (exp == vs)
            throw new Exception("Expansion cannot be the same instance");
        exp.setCompose(null);
        exp.setText(null);
        exp.setDescription("Value Set Contents (Expansion) for " + vs.present() + " at " + Config.DATE_FORMAT().format(new Date()));
        RenderingContext lrc = rc.copy().setTooCostlyNoteEmpty(TOO_MANY_CODES_TEXT_EMPTY).setTooCostlyNoteNotEmpty(TOO_MANY_CODES_TEXT_NOT_EMPTY);
        RendererFactory.factory(exp, lrc).render(exp);
        return "<hr/>\r\n" + VS_INC_START + "" + new XhtmlComposer(XhtmlComposer.HTML).compose(exp.getText().getDiv()) + VS_INC_END;
    } catch (Exception e) {
        return "<hr/>\r\n" + VS_INC_START + "<!--2-->" + processExpansionError(e.getMessage()) + VS_INC_END;
    }
}
Also used : RenderingContext(org.hl7.fhir.r5.renderers.utils.RenderingContext) XhtmlComposer(org.hl7.fhir.utilities.xhtml.XhtmlComposer) ValueSetExpansionOutcome(org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome) ValueSet(org.hl7.fhir.r5.model.ValueSet) UcumException(org.fhir.ucum.UcumException) TransformerException(javax.xml.transform.TransformerException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) URISyntaxException(java.net.URISyntaxException) PathEngineException(org.hl7.fhir.exceptions.PathEngineException) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) FileNotFoundException(java.io.FileNotFoundException) NotImplementedException(org.apache.commons.lang3.NotImplementedException) Date(java.util.Date)

Example 3 with ValueSetExpansionOutcome

use of org.hl7.fhir.dstu2.terminologies.ValueSetExpander.ValueSetExpansionOutcome in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method countMembership.

private Integer countMembership(ValueSet vs) {
    int count = 0;
    if (vs.hasExpansion())
        count = count + conceptCount(vs.getExpansion().getContains());
    else {
        if (vs.hasCodeSystem())
            count = count + countConcepts(vs.getCodeSystem().getConcept());
        if (vs.hasCompose()) {
            if (vs.getCompose().hasExclude()) {
                try {
                    ValueSetExpansionOutcome vse = context.expandVS(vs, true);
                    count = 0;
                    count += conceptCount(vse.getValueset().getExpansion().getContains());
                    return count;
                } catch (Exception e) {
                    return null;
                }
            }
            for (ConceptSetComponent inc : vs.getCompose().getInclude()) {
                if (inc.hasFilter())
                    return null;
                if (!inc.hasConcept())
                    return null;
                count = count + inc.getConcept().size();
            }
        }
    }
    return count;
}
Also used : ConceptSetComponent(org.hl7.fhir.dstu2.model.ValueSet.ConceptSetComponent) ValueSetExpansionOutcome(org.hl7.fhir.dstu2.terminologies.ValueSetExpander.ValueSetExpansionOutcome) ContactPoint(org.hl7.fhir.dstu2.model.ContactPoint) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) NotImplementedException(org.apache.commons.lang3.NotImplementedException)

Example 4 with ValueSetExpansionOutcome

use of org.hl7.fhir.dstu2.terminologies.ValueSetExpander.ValueSetExpansionOutcome in project org.hl7.fhir.core by hapifhir.

the class BaseWorkerContext method expandVS.

@Override
public ValueSetExpansionOutcome expandVS(ValueSet vs, boolean cacheOk) {
    try {
        Map<String, String> params = new HashMap<String, String>();
        params.put("_limit", "10000");
        params.put("_incomplete", "true");
        params.put("profile", "http://www.healthintersections.com.au/fhir/expansion/no-details");
        ValueSet result = txServer.expandValueset(vs, null, params);
        return new ValueSetExpansionOutcome(result);
    } catch (Exception e) {
        return new ValueSetExpansionOutcome("Error expanding ValueSet \"" + vs.getUrl() + ": " + e.getMessage());
    }
}
Also used : HashMap(java.util.HashMap) ValueSetExpansionOutcome(org.hl7.fhir.dstu2.terminologies.ValueSetExpander.ValueSetExpansionOutcome) ValueSet(org.hl7.fhir.dstu2.model.ValueSet) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 5 with ValueSetExpansionOutcome

use of org.hl7.fhir.dstu2.terminologies.ValueSetExpander.ValueSetExpansionOutcome in project org.hl7.fhir.core by hapifhir.

the class BaseWorkerContext method expandVS.

@Override
public ValueSetExpansionComponent expandVS(ConceptSetComponent inc) {
    ValueSet vs = new ValueSet();
    vs.setCompose(new ValueSetComposeComponent());
    vs.getCompose().getInclude().add(inc);
    ValueSetExpansionOutcome vse = expandVS(vs, true);
    return vse.getValueset().getExpansion();
}
Also used : ValueSetExpansionOutcome(org.hl7.fhir.dstu2.terminologies.ValueSetExpander.ValueSetExpansionOutcome) ValueSet(org.hl7.fhir.dstu2.model.ValueSet) ValueSetComposeComponent(org.hl7.fhir.dstu2.model.ValueSet.ValueSetComposeComponent)

Aggregations

IOException (java.io.IOException)26 FHIRException (org.hl7.fhir.exceptions.FHIRException)25 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)24 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)22 FileNotFoundException (java.io.FileNotFoundException)16 ValueSet (org.hl7.fhir.r5.model.ValueSet)16 ValueSetExpansionOutcome (org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome)16 HashMap (java.util.HashMap)11 ValueSetExpansionOutcome (org.hl7.fhir.dstu3.terminologies.ValueSetExpander.ValueSetExpansionOutcome)11 NoTerminologyServiceException (org.hl7.fhir.exceptions.NoTerminologyServiceException)11 ValueSet (org.hl7.fhir.r4b.model.ValueSet)11 ValidationMessage (org.hl7.fhir.utilities.validation.ValidationMessage)11 File (java.io.File)10 ValueSetExpansionOutcome (org.hl7.fhir.r4.terminologies.ValueSetExpander.ValueSetExpansionOutcome)10 ValueSetExpansionOutcome (org.hl7.fhir.r4b.terminologies.ValueSetExpander.ValueSetExpansionOutcome)10 NotImplementedException (org.apache.commons.lang3.NotImplementedException)9 ValueSet (org.hl7.fhir.r4.model.ValueSet)9 FileInputStream (java.io.FileInputStream)8 ValueSetExpansionOutcome (org.hl7.fhir.dstu2.terminologies.ValueSetExpander.ValueSetExpansionOutcome)8 ValueSetExpansionOutcome (org.hl7.fhir.dstu2016may.terminologies.ValueSetExpander.ValueSetExpansionOutcome)8