use of org.hl7.fhir.r4b.model.Questionnaire in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireBuilder method processMetadata.
private void processMetadata() {
// todo: can we derive a more informative identifier from the questionnaire if we have a profile
if (prebuiltQuestionnaire == null) {
questionnaire.addIdentifier().setSystem("urn:ietf:rfc:3986").setValue(questionnaireId);
questionnaire.setVersion(profile.getVersion());
questionnaire.setStatus(profile.getStatus());
questionnaire.setDate(profile.getDate());
questionnaire.setPublisher(profile.getPublisher());
Questionnaire.QuestionnaireItemComponent item = new Questionnaire.QuestionnaireItemComponent();
questionnaire.addItem(item);
item.getCode().addAll(profile.getKeyword());
questionnaire.setId(nextId("qs"));
}
if (response != null) {
// no identifier - this is transient
response.setQuestionnaire(factory.makeReference("#" + questionnaire.getId()));
response.getContained().add(questionnaire);
response.setStatus(QuestionnaireResponseStatus.INPROGRESS);
QuestionnaireResponse.QuestionnaireResponseItemComponent item = new QuestionnaireResponse.QuestionnaireResponseItemComponent();
response.addItem(item);
item.setUserData("object", resource);
}
}
use of org.hl7.fhir.r4b.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.hasEnableBehaviorElement())
composeEnum(t, "Questionnaire", "enableBehavior", element.getEnableBehaviorElement(), -1);
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.hasAnswerValueSetElement())
composeCanonical(t, "Questionnaire", "answerValueSet", element.getAnswerValueSetElement(), -1);
for (int i = 0; i < element.getAnswerOption().size(); i++) composeQuestionnaireQuestionnaireItemAnswerOptionComponent(t, "Questionnaire", "answerOption", element.getAnswerOption().get(i), i);
for (int i = 0; i < element.getInitial().size(); i++) composeQuestionnaireQuestionnaireItemInitialComponent(t, "Questionnaire", "initial", element.getInitial().get(i), i);
for (int i = 0; i < element.getItem().size(); i++) composeQuestionnaireQuestionnaireItemComponent(t, "Questionnaire", "item", element.getItem().get(i), i);
}
use of org.hl7.fhir.r4b.model.Questionnaire in project org.hl7.fhir.core by hapifhir.
the class SimpleWorkerContext method loadFromPackageInt.
public int loadFromPackageInt(NpmPackage pi, IContextResourceLoader loader, String... types) throws FileNotFoundException, IOException, FHIRException {
int t = 0;
if (progress) {
System.out.println("Load Package " + pi.name() + "#" + pi.version());
}
if (loadedPackages.contains(pi.id() + "#" + pi.version())) {
return 0;
}
loadedPackages.add(pi.id() + "#" + pi.version());
if ((types == null || types.length == 0) && loader != null) {
types = loader.getTypes();
}
if (VersionUtilities.isR2Ver(pi.fhirVersion()) || !pi.canLazyLoad()) {
// can't lazy load R2 because of valueset/codesystem implementation
if (types.length == 0) {
types = new String[] { "StructureDefinition", "ValueSet", "SearchParameter", "OperationDefinition", "Questionnaire", "ConceptMap", "StructureMap", "NamingSystem" };
}
for (String s : pi.listResources(types)) {
try {
loadDefinitionItem(s, pi.load("package", s), loader, null, new PackageVersion(pi.id(), pi.version()));
t++;
} catch (Exception e) {
throw new FHIRException(formatMessage(I18nConstants.ERROR_READING__FROM_PACKAGE__, s, pi.name(), pi.version(), e.getMessage()), e);
}
}
} else {
if (types.length == 0) {
types = new String[] { "StructureDefinition", "ValueSet", "CodeSystem", "SearchParameter", "OperationDefinition", "Questionnaire", "ConceptMap", "StructureMap", "NamingSystem", "Measures" };
}
for (PackageResourceInformation pri : pi.listIndexedResources(types)) {
try {
registerResourceFromPackage(new PackageResourceLoader(pri, loader), new PackageVersion(pi.id(), pi.version()));
t++;
} catch (FHIRException e) {
throw new FHIRException(formatMessage(I18nConstants.ERROR_READING__FROM_PACKAGE__, pri.getFilename(), pi.name(), pi.version(), e.getMessage()), e);
}
}
}
for (String s : pi.list("other")) {
binaries.put(s, TextFile.streamToBytes(pi.load("other", s)));
}
if (version == null) {
version = pi.version();
}
return t;
}
use of org.hl7.fhir.r4b.model.Questionnaire in project org.hl7.fhir.core by hapifhir.
the class BaseWorkerContext method fetchResourceWithException.
@SuppressWarnings("unchecked")
public <T extends Resource> T fetchResourceWithException(String cls, String uri, CanonicalResource source) throws FHIRException {
if (uri == null) {
return null;
}
if ("StructureDefinition".equals(cls)) {
uri = ProfileUtilities.sdNs(uri, getOverrideVersionNs());
}
synchronized (lock) {
String version = null;
if (uri.contains("|")) {
version = uri.substring(uri.lastIndexOf("|") + 1);
uri = uri.substring(0, uri.lastIndexOf("|"));
}
if (uri.contains("#")) {
uri = uri.substring(0, uri.indexOf("#"));
}
if (cls == null || "Resource".equals(cls)) {
if (structures.has(uri)) {
return (T) structures.get(uri, version);
}
if (guides.has(uri)) {
return (T) guides.get(uri, version);
}
if (capstmts.has(uri)) {
return (T) capstmts.get(uri, version);
}
if (measures.has(uri)) {
return (T) measures.get(uri, version);
}
if (libraries.has(uri)) {
return (T) libraries.get(uri, version);
}
if (valueSets.has(uri)) {
return (T) valueSets.get(uri, version);
}
if (codeSystems.has(uri)) {
return (T) codeSystems.get(uri, version);
}
if (operations.has(uri)) {
return (T) operations.get(uri, version);
}
if (searchParameters.has(uri)) {
return (T) searchParameters.get(uri, version);
}
if (plans.has(uri)) {
return (T) plans.get(uri, version);
}
if (maps.has(uri)) {
return (T) maps.get(uri, version);
}
if (transforms.has(uri)) {
return (T) transforms.get(uri, version);
}
if (questionnaires.has(uri)) {
return (T) questionnaires.get(uri, version);
}
for (Map<String, ResourceProxy> rt : allResourcesById.values()) {
for (ResourceProxy r : rt.values()) {
if (uri.equals(r.getUrl())) {
return (T) r.getResource();
}
}
}
} else if ("ImplementationGuide".equals(cls)) {
return (T) guides.get(uri, version);
} else if ("CapabilityStatement".equals(cls)) {
return (T) capstmts.get(uri, version);
} else if ("Measure".equals(cls)) {
return (T) measures.get(uri, version);
} else if ("Library".equals(cls)) {
return (T) libraries.get(uri, version);
} else if ("StructureDefinition".equals(cls)) {
return (T) structures.get(uri, version);
} else if ("StructureMap".equals(cls)) {
return (T) transforms.get(uri, version);
} else if ("ValueSet".equals(cls)) {
return (T) valueSets.get(uri, version);
} else if ("CodeSystem".equals(cls)) {
return (T) codeSystems.get(uri, version);
} else if ("ConceptMap".equals(cls)) {
return (T) maps.get(uri, version);
} else if ("PlanDefinition".equals(cls)) {
return (T) plans.get(uri, version);
} else if ("OperationDefinition".equals(cls)) {
OperationDefinition od = operations.get(uri, version);
return (T) od;
} else if ("Questionnaire.class".equals(cls)) {
return (T) questionnaires.get(uri, version);
} else if ("SearchParameter.class".equals(cls)) {
SearchParameter res = searchParameters.get(uri, version);
return (T) res;
}
if ("CodeSystem".equals(cls) && codeSystems.has(uri)) {
return (T) codeSystems.get(uri, version);
}
if ("ValueSet".equals(cls) && valueSets.has(uri)) {
return (T) valueSets.get(uri, version);
}
if ("Questionnaire".equals(cls)) {
return (T) questionnaires.get(uri, version);
}
if (cls == null) {
if (uri.matches(Constants.URI_REGEX) && !uri.contains("ValueSet")) {
return null;
}
// it might be a special URL.
if (Utilities.isAbsoluteUrl(uri) || uri.startsWith("ValueSet/")) {
// findTxValueSet(uri);
Resource res = null;
if (res != null) {
return (T) res;
}
}
return null;
}
if (supportedCodeSystems.contains(uri)) {
return null;
}
throw new FHIRException(formatMessage(I18nConstants.NOT_DONE_YET_CANT_FETCH_, uri));
}
}
use of org.hl7.fhir.r4b.model.Questionnaire in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireBuilder method processMetadata.
private void processMetadata() {
// todo: can we derive a more informative identifier from the questionnaire if we have a profile
if (prebuiltQuestionnaire == null) {
questionnaire.addIdentifier().setSystem("urn:ietf:rfc:3986").setValue(questionnaireId);
questionnaire.setVersion(profile.getVersion());
questionnaire.setStatus(profile.getStatus());
questionnaire.setDate(profile.getDate());
questionnaire.setPublisher(profile.getPublisher());
Questionnaire.QuestionnaireItemComponent item = new Questionnaire.QuestionnaireItemComponent();
questionnaire.addItem(item);
item.setLinkId("meta");
item.getCode().addAll(profile.getKeyword());
questionnaire.setId(nextId("qs"));
}
if (response != null) {
// no identifier - this is transient
response.setQuestionnaire("#" + questionnaire.getId());
response.getContained().add(questionnaire);
response.setStatus(QuestionnaireResponseStatus.INPROGRESS);
QuestionnaireResponse.QuestionnaireResponseItemComponent item = new QuestionnaireResponse.QuestionnaireResponseItemComponent();
response.addItem(item);
item.setLinkId("meta");
item.setUserData("object", resource);
}
}
Aggregations