use of org.hl7.fhir.r5.model.Questionnaire in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeQuestionnaireQuestionnaireItemComponent.
protected void composeQuestionnaireQuestionnaireItemComponent(Complex parent, String parentType, String name, Questionnaire.QuestionnaireItemComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "item", name, element, index);
if (element.hasLinkIdElement())
composeString(t, "Questionnaire", "linkId", element.getLinkIdElement(), -1);
if (element.hasDefinitionElement())
composeUri(t, "Questionnaire", "definition", element.getDefinitionElement(), -1);
for (int i = 0; i < element.getCode().size(); i++) composeCoding(t, "Questionnaire", "code", element.getCode().get(i), i);
if (element.hasPrefixElement())
composeString(t, "Questionnaire", "prefix", element.getPrefixElement(), -1);
if (element.hasTextElement())
composeString(t, "Questionnaire", "text", element.getTextElement(), -1);
if (element.hasTypeElement())
composeEnum(t, "Questionnaire", "type", element.getTypeElement(), -1);
for (int i = 0; i < element.getEnableWhen().size(); i++) composeQuestionnaireQuestionnaireItemEnableWhenComponent(t, "Questionnaire", "enableWhen", element.getEnableWhen().get(i), i);
if (element.hasRequiredElement())
composeBoolean(t, "Questionnaire", "required", element.getRequiredElement(), -1);
if (element.hasRepeatsElement())
composeBoolean(t, "Questionnaire", "repeats", element.getRepeatsElement(), -1);
if (element.hasReadOnlyElement())
composeBoolean(t, "Questionnaire", "readOnly", element.getReadOnlyElement(), -1);
if (element.hasMaxLengthElement())
composeInteger(t, "Questionnaire", "maxLength", element.getMaxLengthElement(), -1);
if (element.hasOptions())
composeReference(t, "Questionnaire", "options", element.getOptions(), -1);
for (int i = 0; i < element.getOption().size(); i++) composeQuestionnaireQuestionnaireItemOptionComponent(t, "Questionnaire", "option", element.getOption().get(i), i);
if (element.hasInitial())
composeType(t, "Questionnaire", "initial", element.getInitial(), -1);
for (int i = 0; i < element.getItem().size(); i++) composeQuestionnaireQuestionnaireItemComponent(t, "Questionnaire", "item", element.getItem().get(i), i);
}
use of org.hl7.fhir.r5.model.Questionnaire in project org.hl7.fhir.core by hapifhir.
the class BaseWorkerContext method cacheResource.
public void cacheResource(Resource r) throws FHIRException {
synchronized (lock) {
Map<String, Resource> map = allResourcesById.get(r.fhirType());
if (map == null) {
map = new HashMap<String, Resource>();
allResourcesById.put(r.fhirType(), map);
}
map.put(r.getId(), r);
if (r instanceof MetadataResource) {
MetadataResource m = (MetadataResource) r;
String url = m.getUrl();
if (!allowLoadingDuplicates && hasResource(r.getClass(), url))
throw new DefinitionException("Duplicate Resource " + url);
if (r instanceof StructureDefinition)
seeMetadataResource((StructureDefinition) m, structures, false);
else if (r instanceof ValueSet)
seeMetadataResource((ValueSet) m, valueSets, false);
else if (r instanceof CodeSystem)
seeMetadataResource((CodeSystem) m, codeSystems, false);
else if (r instanceof ImplementationGuide)
seeMetadataResource((ImplementationGuide) m, guides, false);
else if (r instanceof CapabilityStatement)
seeMetadataResource((CapabilityStatement) m, capstmts, false);
else if (r instanceof SearchParameter)
seeMetadataResource((SearchParameter) m, searchParameters, false);
else if (r instanceof PlanDefinition)
seeMetadataResource((PlanDefinition) m, plans, false);
else if (r instanceof OperationDefinition)
seeMetadataResource((OperationDefinition) m, operations, false);
else if (r instanceof Questionnaire)
seeMetadataResource((Questionnaire) m, questionnaires, true);
else if (r instanceof ConceptMap)
seeMetadataResource((ConceptMap) m, maps, false);
else if (r instanceof StructureMap)
seeMetadataResource((StructureMap) m, transforms, false);
else if (r instanceof NamingSystem)
systems.add((NamingSystem) r);
}
}
}
use of org.hl7.fhir.r5.model.Questionnaire in project org.hl7.fhir.core by hapifhir.
the class EnableWhenEvaluator method isQuestionEnabled.
/**
* the stack contains a set of QR items that represent the tree of the QR being validated, each tagged with the definition of the item from the Q for the QR being validated
* <p>
* the itembeing validated is in the context of the stack. For root items, the stack is empty.
* <p>
* The context Questionnaire and QuestionnaireResponse are always available
*/
public boolean isQuestionEnabled(ValidatorHostContext hostContext, QuestionnaireItemComponent qitem, QStack qstack, FHIRPathEngine engine) {
if (hasExpressionExtension(qitem)) {
String expr = getExpression(qitem);
ExpressionNode node = engine.parse(expr);
return engine.evaluateToBoolean(hostContext, qstack.a, qstack.a, qstack.a, node);
}
if (!qitem.hasEnableWhen()) {
return true;
}
List<EnableWhenResult> evaluationResults = new ArrayList<>();
for (QuestionnaireItemEnableWhenComponent enableCondition : qitem.getEnableWhen()) {
evaluationResults.add(evaluateCondition(enableCondition, qitem, qstack));
}
return checkConditionResults(evaluationResults, qitem);
}
use of org.hl7.fhir.r5.model.Questionnaire in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeQuestionnaireQuestionnaireItemOptionComponent.
protected void composeQuestionnaireQuestionnaireItemOptionComponent(Complex parent, String parentType, String name, Questionnaire.QuestionnaireItemOptionComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "option", name, element, index);
if (element.hasValue())
composeType(t, "Questionnaire", "value", element.getValue(), -1);
}
use of org.hl7.fhir.r5.model.Questionnaire in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeQuestionnaireResponse.
protected void composeQuestionnaireResponse(Complex parent, String parentType, String name, QuestionnaireResponse element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "QuestionnaireResponse", name, element, index);
if (element.hasIdentifier())
composeIdentifier(t, "QuestionnaireResponse", "identifier", element.getIdentifier(), -1);
for (int i = 0; i < element.getBasedOn().size(); i++) composeReference(t, "QuestionnaireResponse", "basedOn", element.getBasedOn().get(i), i);
for (int i = 0; i < element.getParent().size(); i++) composeReference(t, "QuestionnaireResponse", "parent", element.getParent().get(i), i);
if (element.hasQuestionnaire())
composeReference(t, "QuestionnaireResponse", "questionnaire", element.getQuestionnaire(), -1);
if (element.hasStatusElement())
composeEnum(t, "QuestionnaireResponse", "status", element.getStatusElement(), -1);
if (element.hasSubject())
composeReference(t, "QuestionnaireResponse", "subject", element.getSubject(), -1);
if (element.hasContext())
composeReference(t, "QuestionnaireResponse", "context", element.getContext(), -1);
if (element.hasAuthoredElement())
composeDateTime(t, "QuestionnaireResponse", "authored", element.getAuthoredElement(), -1);
if (element.hasAuthor())
composeReference(t, "QuestionnaireResponse", "author", element.getAuthor(), -1);
if (element.hasSource())
composeReference(t, "QuestionnaireResponse", "source", element.getSource(), -1);
for (int i = 0; i < element.getItem().size(); i++) composeQuestionnaireResponseQuestionnaireResponseItemComponent(t, "QuestionnaireResponse", "item", element.getItem().get(i), i);
}
Aggregations