Search in sources :

Example 91 with Address

use of org.hl7.fhir.dstu2016may.model.Address in project org.hl7.fhir.core by hapifhir.

the class DataRenderer method displayAddress.

private String displayAddress(Address address) {
    StringBuilder s = new StringBuilder();
    if (address.hasText())
        s.append(address.getText());
    else {
        for (StringType p : address.getLine()) {
            s.append(p.getValue());
            s.append(" ");
        }
        if (address.hasCity()) {
            s.append(address.getCity());
            s.append(" ");
        }
        if (address.hasState()) {
            s.append(address.getState());
            s.append(" ");
        }
        if (address.hasPostalCode()) {
            s.append(address.getPostalCode());
            s.append(" ");
        }
        if (address.hasCountry()) {
            s.append(address.getCountry());
            s.append(" ");
        }
    }
    if (address.hasUse())
        s.append("(" + address.getUse().toString() + ")");
    return s.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) StringType(org.hl7.fhir.r4b.model.StringType)

Example 92 with Address

use of org.hl7.fhir.dstu2016may.model.Address in project org.hl7.fhir.core by hapifhir.

the class InstanceValidator method checkAddress.

private void checkAddress(List<ValidationMessage> errors, String path, Element focus, Address fixed, String fixedSource, boolean pattern) {
    checkFixedValue(errors, path + ".use", focus.getNamedChild("use"), fixed.getUseElement(), fixedSource, "use", focus, pattern);
    checkFixedValue(errors, path + ".text", focus.getNamedChild("text"), fixed.getTextElement(), fixedSource, "text", focus, pattern);
    checkFixedValue(errors, path + ".city", focus.getNamedChild("city"), fixed.getCityElement(), fixedSource, "city", focus, pattern);
    checkFixedValue(errors, path + ".state", focus.getNamedChild("state"), fixed.getStateElement(), fixedSource, "state", focus, pattern);
    checkFixedValue(errors, path + ".country", focus.getNamedChild("country"), fixed.getCountryElement(), fixedSource, "country", focus, pattern);
    checkFixedValue(errors, path + ".zip", focus.getNamedChild("zip"), fixed.getPostalCodeElement(), fixedSource, "postalCode", focus, pattern);
    List<Element> lines = new ArrayList<Element>();
    focus.getNamedChildren("line", lines);
    boolean lineSizeCheck;
    if (pattern) {
        lineSizeCheck = lines.size() >= fixed.getLine().size();
        if (rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, lineSizeCheck, I18nConstants.FIXED_TYPE_CHECKS_DT_ADDRESS_LINE, Integer.toString(fixed.getLine().size()), Integer.toString(lines.size()))) {
            for (int i = 0; i < fixed.getLine().size(); i++) {
                StringType fixedLine = fixed.getLine().get(i);
                boolean found = false;
                List<ValidationMessage> allErrorsFixed = new ArrayList<>();
                List<ValidationMessage> errorsFixed = null;
                for (int j = 0; j < lines.size() && !found; ++j) {
                    errorsFixed = new ArrayList<>();
                    checkFixedValue(errorsFixed, path + ".line", lines.get(j), fixedLine, fixedSource, "line", focus, pattern);
                    if (!hasErrors(errorsFixed)) {
                        found = true;
                    } else {
                        errorsFixed.stream().filter(t -> t.getLevel().ordinal() >= IssueSeverity.ERROR.ordinal()).forEach(t -> allErrorsFixed.add(t));
                    }
                }
                if (!found) {
                    rule(errorsFixed, IssueType.VALUE, focus.line(), focus.col(), path, false, I18nConstants.PATTERN_CHECK_STRING, fixedLine.getValue(), fixedSource, allErrorsFixed);
                }
            }
        }
    } else if (!pattern) {
        lineSizeCheck = lines.size() == fixed.getLine().size();
        if (rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, lineSizeCheck, I18nConstants.FIXED_TYPE_CHECKS_DT_ADDRESS_LINE, Integer.toString(fixed.getLine().size()), Integer.toString(lines.size()))) {
            for (int i = 0; i < lines.size(); i++) {
                checkFixedValue(errors, path + ".line", lines.get(i), fixed.getLine().get(i), fixedSource, "line", focus, pattern);
            }
        }
    }
}
Also used : TypedElementDefinition(org.hl7.fhir.r5.utils.FHIRPathEngine.TypedElementDefinition) XmlParser(org.hl7.fhir.r5.elementmodel.XmlParser) IntegerType(org.hl7.fhir.r5.model.IntegerType) VersionUtilities(org.hl7.fhir.utilities.VersionUtilities) ExtensionContextType(org.hl7.fhir.r5.model.StructureDefinition.ExtensionContextType) TimeType(org.hl7.fhir.r5.model.TimeType) TerminologyServiceErrorClass(org.hl7.fhir.r5.terminologies.ValueSetExpander.TerminologyServiceErrorClass) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) CanonicalResource(org.hl7.fhir.r5.model.CanonicalResource) ConstraintSeverity(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity) StringUtils(org.apache.commons.lang3.StringUtils) SearchParameterValidator(org.hl7.fhir.validation.instance.type.SearchParameterValidator) BigDecimal(java.math.BigDecimal) Document(org.w3c.dom.Document) Map(java.util.Map) DateTimeType(org.hl7.fhir.r5.model.DateTimeType) JsonParser(org.hl7.fhir.r5.elementmodel.JsonParser) ImplementationGuide(org.hl7.fhir.r5.model.ImplementationGuide) Resource(org.hl7.fhir.r5.model.Resource) Source(org.hl7.fhir.utilities.validation.ValidationMessage.Source) ObjectConverter(org.hl7.fhir.r5.elementmodel.ObjectConverter) ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent) FormatUtilities(org.hl7.fhir.r5.formats.FormatUtilities) VersionURLInfo(org.hl7.fhir.utilities.VersionUtilities.VersionURLInfo) XVerExtensionManager(org.hl7.fhir.r5.utils.XVerExtensionManager) IssueSeverity(org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity) Timing(org.hl7.fhir.r5.model.Timing) ValidatorHostContext(org.hl7.fhir.validation.instance.utils.ValidatorHostContext) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) Set(java.util.Set) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) TerminologyServiceException(org.hl7.fhir.exceptions.TerminologyServiceException) ResourceValidationTracker(org.hl7.fhir.validation.instance.utils.ResourceValidationTracker) StandardCharsets(java.nio.charset.StandardCharsets) TypeRefComponent(org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent) PropertyRepresentation(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation) StringUtils.isNotBlank(org.apache.commons.lang3.StringUtils.isNotBlank) Coding(org.hl7.fhir.r5.model.Coding) Utilities(org.hl7.fhir.utilities.Utilities) BooleanType(org.hl7.fhir.r5.model.BooleanType) ParserBase(org.hl7.fhir.r5.elementmodel.ParserBase) NamedElement(org.hl7.fhir.r5.elementmodel.ParserBase.NamedElement) ElementDefinitionSlicingDiscriminatorComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent) ElementDefinitionConstraintComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent) BindingStrength(org.hl7.fhir.r5.model.Enumerations.BindingStrength) StructureDefinitionContextComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionContextComponent) BaseValidator(org.hl7.fhir.validation.BaseValidator) BundleValidator(org.hl7.fhir.validation.instance.type.BundleValidator) ArrayList(java.util.ArrayList) ValidationPolicy(org.hl7.fhir.r5.elementmodel.ParserBase.ValidationPolicy) QuestionnaireValidator(org.hl7.fhir.validation.instance.type.QuestionnaireValidator) Calendar(java.util.Calendar) ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage) Decimal(org.fhir.ucum.Decimal) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) ValidationLevel(org.hl7.fhir.validation.cli.utils.ValidationLevel) DataType(org.hl7.fhir.r5.model.DataType) IOException(java.io.IOException) InstantType(org.hl7.fhir.r5.model.InstantType) File(java.io.File) Base(org.hl7.fhir.r5.model.Base) Manager(org.hl7.fhir.r5.elementmodel.Manager) ElementInfo(org.hl7.fhir.validation.instance.utils.ElementInfo) CodeableConcept(org.hl7.fhir.r5.model.CodeableConcept) FHIRException(org.hl7.fhir.exceptions.FHIRException) ExpressionNode(org.hl7.fhir.r5.model.ExpressionNode) TypeDetails(org.hl7.fhir.r5.model.TypeDetails) JsonObject(com.google.gson.JsonObject) NodeType(org.hl7.fhir.utilities.xhtml.NodeType) IndexedElement(org.hl7.fhir.validation.instance.utils.IndexedElement) FHIRPathEngine(org.hl7.fhir.r5.utils.FHIRPathEngine) StructureDefinitionKind(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind) SampledData(org.hl7.fhir.r5.model.SampledData) Range(org.hl7.fhir.r5.model.Range) QuestionnaireMode(org.hl7.fhir.validation.cli.utils.QuestionnaireMode) I18nConstants(org.hl7.fhir.utilities.i18n.I18nConstants) ByteArrayInputStream(java.io.ByteArrayInputStream) StructureDefinitionMappingComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent) Gson(com.google.gson.Gson) CanonicalType(org.hl7.fhir.r5.model.CanonicalType) Identifier(org.hl7.fhir.r5.model.Identifier) AggregationMode(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode) Period(org.hl7.fhir.r5.model.Period) ToolingExtensions(org.hl7.fhir.r5.utils.ToolingExtensions) Collection(java.util.Collection) Reference(org.hl7.fhir.r5.model.Reference) StructureDefinitionSnapshotComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionSnapshotComponent) UUID(java.util.UUID) Quantity(org.hl7.fhir.r5.model.Quantity) PrimitiveType(org.hl7.fhir.r5.model.PrimitiveType) ChildIterator(org.hl7.fhir.validation.instance.utils.ChildIterator) List(java.util.List) ValueSetExpansionContainsComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) DateType(org.hl7.fhir.r5.model.DateType) ElementDefinitionBindingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent) Enumeration(org.hl7.fhir.r5.model.Enumeration) Base64InputStream(org.apache.commons.codec.binary.Base64InputStream) DecimalStatus(org.hl7.fhir.utilities.Utilities.DecimalStatus) ValidationResult(org.hl7.fhir.r5.context.IWorkerContext.ValidationResult) ImplementationGuideGlobalComponent(org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideGlobalComponent) ResolvedReference(org.hl7.fhir.validation.instance.utils.ResolvedReference) NotImplementedException(org.apache.commons.lang3.NotImplementedException) org.hl7.fhir.r5.utils.validation.constants(org.hl7.fhir.r5.utils.validation.constants) ElementDefinitionMappingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent) ElementDefinitionSlicingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent) ValueSet(org.hl7.fhir.r5.model.ValueSet) ProfileUtilities(org.hl7.fhir.r5.conformance.ProfileUtilities) HashMap(java.util.HashMap) TypeDerivationRule(org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule) NodeStack(org.hl7.fhir.validation.instance.utils.NodeStack) DataRenderer(org.hl7.fhir.r5.renderers.DataRenderer) CodeSystemValidator(org.hl7.fhir.validation.instance.type.CodeSystemValidator) HashSet(java.util.HashSet) UriType(org.hl7.fhir.r5.model.UriType) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) StructureDefinitionValidator(org.hl7.fhir.validation.instance.type.StructureDefinitionValidator) BuildExtensions(org.hl7.fhir.r5.utils.BuildExtensions) SearchParameter(org.hl7.fhir.r5.model.SearchParameter) ValidationOptions(org.hl7.fhir.utilities.validation.ValidationOptions) DiscriminatorType(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType) MeasureValidator(org.hl7.fhir.validation.instance.type.MeasureValidator) PathEngineException(org.hl7.fhir.exceptions.PathEngineException) Ratio(org.hl7.fhir.r5.model.Ratio) IssueType(org.hl7.fhir.utilities.validation.ValidationMessage.IssueType) Attachment(org.hl7.fhir.r5.model.Attachment) IWorkerContext(org.hl7.fhir.r5.context.IWorkerContext) SpecialElement(org.hl7.fhir.r5.elementmodel.Element.SpecialElement) StringType(org.hl7.fhir.r5.model.StringType) Address(org.hl7.fhir.r5.model.Address) SIDUtilities(org.hl7.fhir.utilities.SIDUtilities) FhirFormat(org.hl7.fhir.r5.elementmodel.Manager.FhirFormat) Element(org.hl7.fhir.r5.elementmodel.Element) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) Extension(org.hl7.fhir.r5.model.Extension) UnicodeUtilities(org.hl7.fhir.utilities.UnicodeUtilities) org.hl7.fhir.r5.utils.validation(org.hl7.fhir.r5.utils.validation) IEvaluationContext(org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext) StringUtils.isBlank(org.apache.commons.lang3.StringUtils.isBlank) DecimalType(org.hl7.fhir.r5.model.DecimalType) ValueSetValidator(org.hl7.fhir.validation.instance.type.ValueSetValidator) FHIRLexerException(org.hl7.fhir.r5.utils.FHIRLexer.FHIRLexerException) InputStream(java.io.InputStream) HumanName(org.hl7.fhir.r5.model.HumanName) ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage) StringType(org.hl7.fhir.r5.model.StringType) NamedElement(org.hl7.fhir.r5.elementmodel.ParserBase.NamedElement) IndexedElement(org.hl7.fhir.validation.instance.utils.IndexedElement) SpecialElement(org.hl7.fhir.r5.elementmodel.Element.SpecialElement) Element(org.hl7.fhir.r5.elementmodel.Element) ArrayList(java.util.ArrayList) ContactPoint(org.hl7.fhir.r5.model.ContactPoint)

Example 93 with Address

use of org.hl7.fhir.dstu2016may.model.Address in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method displayAddress.

private String displayAddress(Address address) {
    StringBuilder s = new StringBuilder();
    if (address.hasText())
        s.append(address.getText());
    else {
        for (StringType p : address.getLine()) {
            s.append(p.getValue());
            s.append(" ");
        }
        if (address.hasCity()) {
            s.append(address.getCity());
            s.append(" ");
        }
        if (address.hasState()) {
            s.append(address.getState());
            s.append(" ");
        }
        if (address.hasPostalCode()) {
            s.append(address.getPostalCode());
            s.append(" ");
        }
        if (address.hasCountry()) {
            s.append(address.getCountry());
            s.append(" ");
        }
    }
    if (address.hasUse())
        s.append("(" + address.getUse().toString() + ")");
    return s.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) StringType(org.hl7.fhir.dstu3.model.StringType)

Example 94 with Address

use of org.hl7.fhir.dstu2016may.model.Address in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method renderLeaf.

private void renderLeaf(ResourceWrapper res, BaseWrapper ew, ElementDefinition defn, XhtmlNode x, boolean title, boolean showCodeDetails, Map<String, String> displayHints, String path) throws FHIRException, UnsupportedEncodingException, IOException {
    if (ew == null)
        return;
    Base e = ew.getBase();
    if (e instanceof StringType)
        x.addText(((StringType) e).getValue());
    else if (e instanceof CodeType)
        x.addText(((CodeType) e).getValue());
    else if (e instanceof IdType)
        x.addText(((IdType) e).getValue());
    else if (e instanceof Extension)
        return;
    else if (e instanceof InstantType)
        x.addText(((InstantType) e).toHumanDisplay());
    else if (e instanceof DateTimeType)
        x.addText(((DateTimeType) e).toHumanDisplay());
    else if (e instanceof Base64BinaryType)
        x.addText(new Base64().encodeAsString(((Base64BinaryType) e).getValue()));
    else if (e instanceof org.hl7.fhir.dstu3.model.DateType)
        x.addText(((org.hl7.fhir.dstu3.model.DateType) e).toHumanDisplay());
    else if (e instanceof Enumeration) {
        Object ev = ((Enumeration<?>) e).getValue();
        // todo: look up a display name if there is one
        x.addText(ev == null ? "" : ev.toString());
    } else if (e instanceof BooleanType)
        x.addText(((BooleanType) e).getValue().toString());
    else if (e instanceof CodeableConcept) {
        renderCodeableConcept((CodeableConcept) e, x, showCodeDetails);
    } else if (e instanceof Coding) {
        renderCoding((Coding) e, x, showCodeDetails);
    } else if (e instanceof Annotation) {
        renderAnnotation((Annotation) e, x);
    } else if (e instanceof Identifier) {
        renderIdentifier((Identifier) e, x);
    } else if (e instanceof org.hl7.fhir.dstu3.model.IntegerType) {
        x.addText(Integer.toString(((org.hl7.fhir.dstu3.model.IntegerType) e).getValue()));
    } else if (e instanceof org.hl7.fhir.dstu3.model.DecimalType) {
        x.addText(((org.hl7.fhir.dstu3.model.DecimalType) e).getValue().toString());
    } else if (e instanceof HumanName) {
        renderHumanName((HumanName) e, x);
    } else if (e instanceof SampledData) {
        renderSampledData((SampledData) e, x);
    } else if (e instanceof Address) {
        renderAddress((Address) e, x);
    } else if (e instanceof ContactPoint) {
        renderContactPoint((ContactPoint) e, x);
    } else if (e instanceof UriType) {
        renderUri((UriType) e, x);
    } else if (e instanceof Timing) {
        renderTiming((Timing) e, x);
    } else if (e instanceof Range) {
        renderRange((Range) e, x);
    } else if (e instanceof Quantity) {
        renderQuantity((Quantity) e, x, showCodeDetails);
    } else if (e instanceof Ratio) {
        renderQuantity(((Ratio) e).getNumerator(), x, showCodeDetails);
        x.tx("/");
        renderQuantity(((Ratio) e).getDenominator(), x, showCodeDetails);
    } else if (e instanceof Period) {
        Period p = (Period) e;
        x.addText(!p.hasStart() ? "??" : p.getStartElement().toHumanDisplay());
        x.tx(" --> ");
        x.addText(!p.hasEnd() ? "(ongoing)" : p.getEndElement().toHumanDisplay());
    } else if (e instanceof Reference) {
        Reference r = (Reference) e;
        XhtmlNode c = x;
        ResourceWithReference tr = null;
        if (r.hasReferenceElement()) {
            tr = resolveReference(res, r.getReference());
            if (!r.getReference().startsWith("#")) {
                if (tr != null && tr.getReference() != null)
                    c = x.ah(tr.getReference());
                else
                    c = x.ah(r.getReference());
            }
        }
        // what to display: if text is provided, then that. if the reference was resolved, then show the generated narrative
        if (r.hasDisplayElement()) {
            c.addText(r.getDisplay());
            if (tr != null && tr.getResource() != null) {
                c.tx(". Generated Summary: ");
                generateResourceSummary(c, tr.getResource(), true, r.getReference().startsWith("#"));
            }
        } else if (tr != null && tr.getResource() != null) {
            generateResourceSummary(c, tr.getResource(), r.getReference().startsWith("#"), r.getReference().startsWith("#"));
        } else {
            c.addText(r.getReference());
        }
    } else if (e instanceof Resource) {
        return;
    } else if (e instanceof ElementDefinition) {
        x.tx("todo-bundle");
    } else if (e != null && !(e instanceof Attachment) && !(e instanceof Narrative) && !(e instanceof Meta)) {
        StructureDefinition sd = context.fetchTypeDefinition(e.fhirType());
        if (sd == null)
            throw new NotImplementedException("type " + e.getClass().getName() + " not handled yet, and no structure found");
        else
            generateByProfile(res, sd, ew, sd.getSnapshot().getElement(), sd.getSnapshot().getElementFirstRep(), getChildrenForPath(sd.getSnapshot().getElement(), sd.getSnapshot().getElementFirstRep().getPath()), x, path, showCodeDetails);
    }
}
Also used : Meta(org.hl7.fhir.dstu3.model.Meta) Base64(org.apache.commons.codec.binary.Base64) Address(org.hl7.fhir.dstu3.model.Address) StringType(org.hl7.fhir.dstu3.model.StringType) NotImplementedException(org.apache.commons.lang3.NotImplementedException) Attachment(org.hl7.fhir.dstu3.model.Attachment) UriType(org.hl7.fhir.dstu3.model.UriType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) HumanName(org.hl7.fhir.dstu3.model.HumanName) ContactPoint(org.hl7.fhir.dstu3.model.ContactPoint) StructureDefinition(org.hl7.fhir.dstu3.model.StructureDefinition) Identifier(org.hl7.fhir.dstu3.model.Identifier) Coding(org.hl7.fhir.dstu3.model.Coding) Narrative(org.hl7.fhir.dstu3.model.Narrative) SampledData(org.hl7.fhir.dstu3.model.SampledData) Ratio(org.hl7.fhir.dstu3.model.Ratio) ElementDefinition(org.hl7.fhir.dstu3.model.ElementDefinition) InstantType(org.hl7.fhir.dstu3.model.InstantType) Enumeration(org.hl7.fhir.dstu3.model.Enumeration) Reference(org.hl7.fhir.dstu3.model.Reference) BooleanType(org.hl7.fhir.dstu3.model.BooleanType) DomainResource(org.hl7.fhir.dstu3.model.DomainResource) MetadataResource(org.hl7.fhir.dstu3.model.MetadataResource) Resource(org.hl7.fhir.dstu3.model.Resource) Quantity(org.hl7.fhir.dstu3.model.Quantity) Period(org.hl7.fhir.dstu3.model.Period) Range(org.hl7.fhir.dstu3.model.Range) Base(org.hl7.fhir.dstu3.model.Base) Annotation(org.hl7.fhir.dstu3.model.Annotation) IdType(org.hl7.fhir.dstu3.model.IdType) Extension(org.hl7.fhir.dstu3.model.Extension) DateTimeType(org.hl7.fhir.dstu3.model.DateTimeType) CodeType(org.hl7.fhir.dstu3.model.CodeType) EventTiming(org.hl7.fhir.dstu3.model.Timing.EventTiming) Timing(org.hl7.fhir.dstu3.model.Timing) Base64BinaryType(org.hl7.fhir.dstu3.model.Base64BinaryType) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 95 with Address

use of org.hl7.fhir.dstu2016may.model.Address in project org.hl7.fhir.core by hapifhir.

the class QuestionnaireBuilder method processDataType.

private void processDataType(StructureDefinition profile, QuestionnaireItemComponent group, ElementDefinition element, String path, TypeRefComponent t, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> answerGroups, List<ElementDefinition> parents) throws FHIRException {
    String tc = t.getWorkingCode();
    if (tc.equals("code"))
        addCodeQuestions(group, element, path, answerGroups);
    else if (Utilities.existsInList(tc, "string", "id", "oid", "uuid", "markdown"))
        addStringQuestions(group, element, path, answerGroups);
    else if (Utilities.existsInList(tc, "uri", "url", "canonical"))
        addUriQuestions(group, element, path, answerGroups);
    else if (tc.equals("boolean"))
        addBooleanQuestions(group, element, path, answerGroups);
    else if (tc.equals("decimal"))
        addDecimalQuestions(group, element, path, answerGroups);
    else if (tc.equals("dateTime") || tc.equals("date"))
        addDateTimeQuestions(group, element, path, answerGroups);
    else if (tc.equals("instant"))
        addInstantQuestions(group, element, path, answerGroups);
    else if (tc.equals("time"))
        addTimeQuestions(group, element, path, answerGroups);
    else if (tc.equals("CodeableConcept"))
        addCodeableConceptQuestions(group, element, path, answerGroups);
    else if (tc.equals("Period"))
        addPeriodQuestions(group, element, path, answerGroups);
    else if (tc.equals("Ratio"))
        addRatioQuestions(group, element, path, answerGroups);
    else if (tc.equals("HumanName"))
        addHumanNameQuestions(group, element, path, answerGroups);
    else if (tc.equals("Address"))
        addAddressQuestions(group, element, path, answerGroups);
    else if (tc.equals("ContactPoint"))
        addContactPointQuestions(group, element, path, answerGroups);
    else if (tc.equals("Identifier"))
        addIdentifierQuestions(group, element, path, answerGroups);
    else if (tc.equals("integer") || tc.equals("positiveInt") || tc.equals("unsignedInt"))
        addIntegerQuestions(group, element, path, answerGroups);
    else if (tc.equals("Coding"))
        addCodingQuestions(group, element, path, answerGroups);
    else if (Utilities.existsInList(tc, "Quantity", "Count", "Age", "Duration", "Distance", "Money"))
        addQuantityQuestions(group, element, path, answerGroups);
    else if (tc.equals("Money"))
        addMoneyQuestions(group, element, path, answerGroups);
    else if (tc.equals("Reference"))
        addReferenceQuestions(group, element, path, t.getTargetProfile(), answerGroups);
    else if (tc.equals("Duration"))
        addDurationQuestions(group, element, path, answerGroups);
    else if (tc.equals("base64Binary"))
        addBinaryQuestions(group, element, path, answerGroups);
    else if (tc.equals("Attachment"))
        addAttachmentQuestions(group, element, path, answerGroups);
    else if (tc.equals("Age"))
        addAgeQuestions(group, element, path, answerGroups);
    else if (tc.equals("Range"))
        addRangeQuestions(group, element, path, answerGroups);
    else if (tc.equals("Timing"))
        addTimingQuestions(group, element, path, answerGroups);
    else if (tc.equals("Annotation"))
        addAnnotationQuestions(group, element, path, answerGroups);
    else if (tc.equals("SampledData"))
        addSampledDataQuestions(group, element, path, answerGroups);
    else if (tc.equals("Extension")) {
        if (t.hasProfile())
            addExtensionQuestions(profile, group, element, path, t.getProfile().get(0).getValue(), answerGroups, parents);
    } else if (tc.equals("SampledData"))
        addSampledDataQuestions(group, element, path, answerGroups);
    else if (!tc.equals("Narrative") && !tc.equals("Resource") && !tc.equals("Meta") && !tc.equals("Signature")) {
        StructureDefinition sd = context.fetchTypeDefinition(tc);
        if (sd == null)
            throw new NotImplementedException("Unhandled Data Type: " + tc + " on element " + element.getPath());
        buildGroup(group, sd, sd.getSnapshot().getElementFirstRep(), parents, answerGroups);
    }
}
Also used : StructureDefinition(org.hl7.fhir.r4.model.StructureDefinition) NotImplementedException(org.apache.commons.lang3.NotImplementedException)

Aggregations

Address (org.hl7.fhir.r4.model.Address)75 Test (org.junit.Test)47 Patient (org.hl7.fhir.r4.model.Patient)30 Test (org.junit.jupiter.api.Test)30 PersonAddress (org.openmrs.PersonAddress)27 HumanName (org.hl7.fhir.r4.model.HumanName)24 Identifier (org.hl7.fhir.r4.model.Identifier)23 ArrayList (java.util.ArrayList)22 Address (org.hl7.fhir.dstu3.model.Address)22 Path (javax.ws.rs.Path)20 Produces (javax.ws.rs.Produces)20 NotImplementedException (org.apache.commons.lang3.NotImplementedException)19 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)19 Location (org.hl7.fhir.r4.model.Location)13 Organization (org.hl7.fhir.r4.model.Organization)13 InputStream (java.io.InputStream)12 IdType (org.hl7.fhir.dstu3.model.IdType)12 Patient (org.hl7.fhir.dstu3.model.Patient)12 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)12 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)12