Search in sources :

Example 21 with ParameterDefinition

use of org.hl7.fhir.r5.model.ParameterDefinition in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeParameterDefinition.

protected void composeParameterDefinition(Complex parent, String parentType, String name, ParameterDefinition element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeElement(t, "ParameterDefinition", name, element, index);
    if (element.hasNameElement())
        composeCode(t, "ParameterDefinition", "name", element.getNameElement(), -1);
    if (element.hasUseElement())
        composeEnum(t, "ParameterDefinition", "use", element.getUseElement(), -1);
    if (element.hasMinElement())
        composeInteger(t, "ParameterDefinition", "min", element.getMinElement(), -1);
    if (element.hasMaxElement())
        composeString(t, "ParameterDefinition", "max", element.getMaxElement(), -1);
    if (element.hasDocumentationElement())
        composeString(t, "ParameterDefinition", "documentation", element.getDocumentationElement(), -1);
    if (element.hasTypeElement())
        composeCode(t, "ParameterDefinition", "type", element.getTypeElement(), -1);
    if (element.hasProfileElement())
        composeCanonical(t, "ParameterDefinition", "profile", element.getProfileElement(), -1);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 22 with ParameterDefinition

use of org.hl7.fhir.r5.model.ParameterDefinition in project org.hl7.fhir.core by hapifhir.

the class LibraryRenderer method render.

public boolean render(XhtmlNode x, Library lib) throws FHIRFormatError, DefinitionException, IOException {
    if (lib.hasAuthor() || lib.hasEditor() || lib.hasReviewer() || lib.hasEndorser()) {
        boolean email = hasCT(lib.getAuthor(), "email") || hasCT(lib.getEditor(), "email") || hasCT(lib.getReviewer(), "email") || hasCT(lib.getEndorser(), "email");
        boolean phone = hasCT(lib.getAuthor(), "phone") || hasCT(lib.getEditor(), "phone") || hasCT(lib.getReviewer(), "phone") || hasCT(lib.getEndorser(), "phone");
        boolean url = hasCT(lib.getAuthor(), "url") || hasCT(lib.getEditor(), "url") || hasCT(lib.getReviewer(), "url") || hasCT(lib.getEndorser(), "url");
        x.h2().tx("Participants");
        XhtmlNode t = x.table("grid");
        for (ContactDetail cd : lib.getAuthor()) {
            participantRow(t, "Author", cd, email, phone, url);
        }
        for (ContactDetail cd : lib.getEditor()) {
            participantRow(t, "Editor", cd, email, phone, url);
        }
        for (ContactDetail cd : lib.getReviewer()) {
            participantRow(t, "Reviewer", cd, email, phone, url);
        }
        for (ContactDetail cd : lib.getEndorser()) {
            participantRow(t, "Endorser", cd, email, phone, url);
        }
    }
    if (lib.hasRelatedArtifact()) {
        x.h2().tx("Related Artifacts");
        XhtmlNode t = x.table("grid");
        boolean label = false;
        boolean display = false;
        boolean citation = false;
        for (RelatedArtifact ra : lib.getRelatedArtifact()) {
            label = label || ra.hasLabel();
            display = display || ra.hasDisplay();
            citation = citation || ra.hasCitation();
        }
        for (RelatedArtifact ra : lib.getRelatedArtifact()) {
            renderArtifact(t, ra, lib, label, display, citation);
        }
    }
    if (lib.hasParameter()) {
        x.h2().tx("Parameters");
        XhtmlNode t = x.table("grid");
        boolean doco = false;
        for (ParameterDefinition p : lib.getParameter()) {
            doco = doco || p.hasDocumentation();
        }
        for (ParameterDefinition p : lib.getParameter()) {
            renderParameter(t, p, doco);
        }
    }
    if (lib.hasDataRequirement()) {
        x.h2().tx("Data Requirements");
        for (DataRequirement p : lib.getDataRequirement()) {
            renderDataRequirement(x, p);
        }
    }
    if (lib.hasContent()) {
        x.h2().tx("Contents");
        boolean isCql = false;
        int counter = 0;
        for (Attachment att : lib.getContent()) {
            renderAttachment(x, att, isCql, counter, lib.getId());
            isCql = isCql || (att.hasContentType() && att.getContentType().startsWith("text/cql"));
            counter++;
        }
    }
    return false;
}
Also used : ContactDetail(org.hl7.fhir.r4b.model.ContactDetail) Attachment(org.hl7.fhir.r4b.model.Attachment) DataRequirement(org.hl7.fhir.r4b.model.DataRequirement) RelatedArtifact(org.hl7.fhir.r4b.model.RelatedArtifact) ContactPoint(org.hl7.fhir.r4b.model.ContactPoint) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) ParameterDefinition(org.hl7.fhir.r4b.model.ParameterDefinition)

Example 23 with ParameterDefinition

use of org.hl7.fhir.r5.model.ParameterDefinition in project org.hl7.fhir.core by hapifhir.

the class LibraryRenderer method render.

public boolean render(XhtmlNode x, Library lib) throws FHIRFormatError, DefinitionException, IOException {
    if (lib.hasAuthor() || lib.hasEditor() || lib.hasReviewer() || lib.hasEndorser()) {
        boolean email = hasCT(lib.getAuthor(), "email") || hasCT(lib.getEditor(), "email") || hasCT(lib.getReviewer(), "email") || hasCT(lib.getEndorser(), "email");
        boolean phone = hasCT(lib.getAuthor(), "phone") || hasCT(lib.getEditor(), "phone") || hasCT(lib.getReviewer(), "phone") || hasCT(lib.getEndorser(), "phone");
        boolean url = hasCT(lib.getAuthor(), "url") || hasCT(lib.getEditor(), "url") || hasCT(lib.getReviewer(), "url") || hasCT(lib.getEndorser(), "url");
        x.h2().tx("Participants");
        XhtmlNode t = x.table("grid");
        for (ContactDetail cd : lib.getAuthor()) {
            participantRow(t, "Author", cd, email, phone, url);
        }
        for (ContactDetail cd : lib.getEditor()) {
            participantRow(t, "Editor", cd, email, phone, url);
        }
        for (ContactDetail cd : lib.getReviewer()) {
            participantRow(t, "Reviewer", cd, email, phone, url);
        }
        for (ContactDetail cd : lib.getEndorser()) {
            participantRow(t, "Endorser", cd, email, phone, url);
        }
    }
    if (lib.hasRelatedArtifact()) {
        x.h2().tx("Related Artifacts");
        XhtmlNode t = x.table("grid");
        boolean label = false;
        boolean display = false;
        boolean citation = false;
        for (RelatedArtifact ra : lib.getRelatedArtifact()) {
            label = label || ra.hasLabel();
            display = display || ra.hasDisplay();
            citation = citation || ra.hasCitation();
        }
        for (RelatedArtifact ra : lib.getRelatedArtifact()) {
            renderArtifact(t, ra, lib, label, display, citation);
        }
    }
    if (lib.hasParameter()) {
        x.h2().tx("Parameters");
        XhtmlNode t = x.table("grid");
        boolean doco = false;
        for (ParameterDefinition p : lib.getParameter()) {
            doco = doco || p.hasDocumentation();
        }
        for (ParameterDefinition p : lib.getParameter()) {
            renderParameter(t, p, doco);
        }
    }
    if (lib.hasDataRequirement()) {
        x.h2().tx("Data Requirements");
        for (DataRequirement p : lib.getDataRequirement()) {
            renderDataRequirement(x, p);
        }
    }
    if (lib.hasContent()) {
        x.h2().tx("Contents");
        boolean isCql = false;
        int counter = 0;
        for (Attachment att : lib.getContent()) {
            renderAttachment(x, att, isCql, counter, lib.getId());
            isCql = isCql || (att.hasContentType() && att.getContentType().startsWith("text/cql"));
            counter++;
        }
    }
    return false;
}
Also used : ContactDetail(org.hl7.fhir.r5.model.ContactDetail) Attachment(org.hl7.fhir.r5.model.Attachment) DataRequirement(org.hl7.fhir.r5.model.DataRequirement) RelatedArtifact(org.hl7.fhir.r5.model.RelatedArtifact) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) ParameterDefinition(org.hl7.fhir.r5.model.ParameterDefinition)

Example 24 with ParameterDefinition

use of org.hl7.fhir.r5.model.ParameterDefinition in project clinical_quality_language by cqframework.

the class DataRequirementsProcessor method toOutputParameterDefinition.

private ParameterDefinition toOutputParameterDefinition(VersionedIdentifier libraryIdentifier, ExpressionDef def) {
    AtomicBoolean isList = new AtomicBoolean(false);
    Enumerations.FHIRAllTypes typeCode = null;
    try {
        typeCode = Enumerations.FHIRAllTypes.fromCode(toFHIRResultTypeCode(def.getResultType(), def.getName(), isList));
    } catch (org.hl7.fhir.exceptions.FHIRException fhirException) {
        validationMessages.add(new ValidationMessage(ValidationMessage.Source.Publisher, ValidationMessage.IssueType.NOTSUPPORTED, "CQL Library Packaging", String.format("Result type %s of library %s is not supported; implementations may not be able to use the result of this expression", def.getResultType().toLabel(), libraryIdentifier.getId()), ValidationMessage.IssueSeverity.WARNING));
    }
    return new ParameterDefinition().setName(def.getName()).setUse(Enumerations.OperationParameterUse.OUT).setMin(0).setMax(isList.get() ? "*" : "1").setType(typeCode);
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage)

Example 25 with ParameterDefinition

use of org.hl7.fhir.r5.model.ParameterDefinition in project clinical_quality_language by cqframework.

the class DataRequirementsProcessorTest method TestDataRequirementsProcessorWithExpressions.

@Test
public void TestDataRequirementsProcessorWithExpressions() {
    CqlTranslatorOptions cqlTranslatorOptions = new CqlTranslatorOptions();
    cqlTranslatorOptions.getFormats().add(CqlTranslator.Format.JSON);
    try {
        Set<String> expressions = new HashSet<>();
        // TODO - add expressions to expressions
        // Active Ambulatory Opioid Rx");
        expressions.add("Conditions Indicating End of Life or With Limited Life Expectancy");
        CqlTranslator translator = createTranslator("OpioidCDS/cql/OpioidCDSCommon.cql", cqlTranslatorOptions);
        translator.toELM();
        assertTrue(translator.getErrors().isEmpty());
        libraryManager.cacheLibrary(translator.getTranslatedLibrary());
        DataRequirementsProcessor dqReqTrans = new DataRequirementsProcessor();
        org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = dqReqTrans.gatherDataRequirements(libraryManager, translator.getTranslatedLibrary(), cqlTranslatorOptions, expressions, false);
        assertTrue(moduleDefinitionLibrary.getType().getCode("http://terminology.hl7.org/CodeSystem/library-type").equalsIgnoreCase("module-definition"));
        List<Extension> directReferenceCodes = moduleDefinitionLibrary.getExtensionsByUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-directReferenceCode");
        assertTrue(directReferenceCodes.size() == 4);
        Extension directReferenceCode = directReferenceCodes.get(0);
        Coding coding = directReferenceCode.getValueCoding();
        assertEquals("http://hl7.org/fhir/condition-category", coding.getSystem());
        assertEquals("encounter-diagnosis", coding.getCode());
        assertEquals("Encounter Diagnosis", coding.getDisplay());
        assertTrue(moduleDefinitionLibrary.getRelatedArtifact().size() == 6);
        RelatedArtifact conditionCategoryCodes = null;
        for (RelatedArtifact relatedArtifact : moduleDefinitionLibrary.getRelatedArtifact()) {
            if (relatedArtifact.getType() == RelatedArtifact.RelatedArtifactType.DEPENDSON && relatedArtifact.getResource() != null && relatedArtifact.getResource().equals("http://hl7.org/fhir/condition-category")) {
                conditionCategoryCodes = relatedArtifact;
                break;
            }
        }
        assertTrue(conditionCategoryCodes != null);
        assertTrue(moduleDefinitionLibrary.getParameter().size() == 1);
        ParameterDefinition conditionsIndicatingEndOfLife = null;
        for (ParameterDefinition parameter : moduleDefinitionLibrary.getParameter()) {
            if (parameter.getName().equals("Conditions Indicating End of Life or With Limited Life Expectancy")) {
                conditionsIndicatingEndOfLife = parameter;
                break;
            }
        }
        assertTrue(conditionsIndicatingEndOfLife != null);
        assertTrue(moduleDefinitionLibrary.getDataRequirement().size() == 3);
        DataRequirement diagnosisRequirement = null;
        for (DataRequirement requirement : moduleDefinitionLibrary.getDataRequirement()) {
            if (requirement.getType() == Enumerations.FHIRAllTypes.CONDITION && requirement.getCodeFilter().size() == 1) {
                DataRequirement.DataRequirementCodeFilterComponent cfc = requirement.getCodeFilterFirstRep();
                if (cfc.hasPath() && cfc.getPath().equals("category") && cfc.getCode().size() == 1 && cfc.getCodeFirstRep().hasCode() && cfc.getCodeFirstRep().getCode().equals("encounter-diagnosis")) {
                    diagnosisRequirement = requirement;
                    break;
                }
            }
        }
        assertTrue(diagnosisRequirement != null);
        FhirContext context = getFhirContext();
        IParser parser = context.newJsonParser();
        String moduleDefString = parser.setPrettyPrint(true).encodeResourceToString(moduleDefinitionLibrary);
        logger.debug(moduleDefString);
    } catch (IOException ioException) {
        ioException.printStackTrace();
    }
}
Also used : FhirContext(ca.uhn.fhir.context.FhirContext) IOException(java.io.IOException) org.hl7.fhir.r5.model(org.hl7.fhir.r5.model) IParser(ca.uhn.fhir.parser.IParser) Test(org.testng.annotations.Test)

Aggregations

ParameterDefinition (org.hl7.fhir.r4.model.ParameterDefinition)32 Test (org.junit.Test)26 Extension (org.hl7.fhir.r4.model.Extension)14 DatetimeParameter (com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter)9 ArrayList (java.util.ArrayList)9 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)9 QuantityParameter (com.ibm.cohort.cql.evaluation.parameters.QuantityParameter)8 StringParameter (com.ibm.cohort.cql.evaluation.parameters.StringParameter)8 Quantity (org.hl7.fhir.r4.model.Quantity)8 Range (org.hl7.fhir.r4.model.Range)8 CodeParameter (com.ibm.cohort.cql.evaluation.parameters.CodeParameter)7 IntervalParameter (com.ibm.cohort.cql.evaluation.parameters.IntervalParameter)7 Period (org.hl7.fhir.r4.model.Period)7 BooleanParameter (com.ibm.cohort.cql.evaluation.parameters.BooleanParameter)6 ConceptParameter (com.ibm.cohort.cql.evaluation.parameters.ConceptParameter)6 DateParameter (com.ibm.cohort.cql.evaluation.parameters.DateParameter)6 DecimalParameter (com.ibm.cohort.cql.evaluation.parameters.DecimalParameter)6 IntegerParameter (com.ibm.cohort.cql.evaluation.parameters.IntegerParameter)6 RatioParameter (com.ibm.cohort.cql.evaluation.parameters.RatioParameter)6 TimeParameter (com.ibm.cohort.cql.evaluation.parameters.TimeParameter)6