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);
}
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;
}
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;
}
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);
}
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();
}
}
Aggregations