Search in sources :

Example 1 with SEARCHSET

use of org.hl7.fhir.r4.model.Bundle.BundleType.SEARCHSET in project kindling by HL7.

the class PageProcessor method renderExample.

private void renderExample(StringBuilder b, OperationExample ex, String type) throws Exception {
    if (Utilities.noString(ex.getComment()))
        b.append("<p>" + type + ":</p>\r\n");
    else
        b.append("<p>" + processMarkdown("op-example", type + ": " + Utilities.capitalize(ex.getComment()), "") + "</p>\r\n");
    b.append("<pre>\r\n");
    String[] lines = ex.getContent().split("\\r\\n");
    for (String l : lines) {
        if (l.startsWith("$bundle ")) {
            b.append(Utilities.escapeXml("<Bundle xml=\"http://hl7.org/fhir\">\r\n"));
            b.append(Utilities.escapeXml("  <id value=\"" + UUID.randomUUID().toString().toLowerCase() + "\"/>\r\n"));
            b.append(Utilities.escapeXml("  <type value=\"searchset\"/>\r\n"));
            Example e = getExampleByRef(l.substring(8));
            addExample(b, e);
            for (Example x : e.getInbounds()) {
                addExample(b, x);
            }
            b.append(Utilities.escapeXml("</Bundle>\r\n"));
        } else {
            b.append(l);
            b.append("\r\n");
        }
    }
    b.append("</pre>\r\n");
}
Also used : Example(org.hl7.fhir.definitions.model.Example) OperationExample(org.hl7.fhir.definitions.model.Operation.OperationExample)

Example 2 with SEARCHSET

use of org.hl7.fhir.r4.model.Bundle.BundleType.SEARCHSET in project summary-care-record-api by NHSDigital.

the class GetScrService method buildBundle.

private Bundle buildBundle() {
    Bundle bundle = new Bundle();
    bundle.setType(SEARCHSET);
    bundle.setId(randomUUID());
    return bundle;
}
Also used : Bundle(org.hl7.fhir.r4.model.Bundle)

Example 3 with SEARCHSET

use of org.hl7.fhir.r4.model.Bundle.BundleType.SEARCHSET in project summary-care-record-api by NHSDigital.

the class InteractionMapper method buildBundle.

private Bundle buildBundle() {
    Bundle bundle = new Bundle();
    bundle.setType(SEARCHSET);
    bundle.setId(randomUUID());
    return bundle;
}
Also used : Bundle(org.hl7.fhir.r4.model.Bundle)

Example 4 with SEARCHSET

use of org.hl7.fhir.r4.model.Bundle.BundleType.SEARCHSET in project gpconnect-demonstrator by nhsconnect.

the class PostProcessor method outgoingResponse.

@Override
public boolean outgoingResponse(RequestDetails theRequestDetails, IBaseResource theResponseDetails, javax.servlet.http.HttpServletRequest theServletRequest, javax.servlet.http.HttpServletResponse theServletResponse) throws AuthenticationException {
    if (theResponseDetails instanceof Bundle) {
        Bundle bundle = (Bundle) theResponseDetails;
        // #299 remove total and link from searchset result bundles
        if (bundle.getType() == SEARCHSET) {
            bundle.setTotalElement(null);
            bundle.setLink(null);
        }
        for (Bundle.BundleEntryComponent entry : bundle.getEntry()) {
            if (entry.hasFullUrl()) {
                // #215 don't populate Bundle.entry.fullurl
                entry.setFullUrl("");
            }
        }
    }
    return true;
}
Also used : Bundle(org.hl7.fhir.dstu3.model.Bundle)

Example 5 with SEARCHSET

use of org.hl7.fhir.r4.model.Bundle.BundleType.SEARCHSET in project org.hl7.fhir.core by hapifhir.

the class BundleValidator method validateBundle.

public void validateBundle(List<ValidationMessage> errors, Element bundle, NodeStack stack, boolean checkSpecials, ValidatorHostContext hostContext) {
    List<Element> entries = new ArrayList<Element>();
    bundle.getNamedChildren(ENTRY, entries);
    String type = bundle.getNamedChildValue(TYPE);
    type = StringUtils.defaultString(type);
    if (entries.size() == 0) {
        rule(errors, IssueType.INVALID, stack.getLiteralPath(), !(type.equals(DOCUMENT) || type.equals(MESSAGE)), I18nConstants.BUNDLE_BUNDLE_ENTRY_NOFIRST);
    } else {
        // Get the first entry, the MessageHeader
        Element firstEntry = entries.get(0);
        // Get the stack of the first entry
        NodeStack firstStack = stack.push(firstEntry, 1, null, null);
        String fullUrl = firstEntry.getNamedChildValue(FULL_URL);
        if (type.equals(DOCUMENT)) {
            Element resource = firstEntry.getNamedChild(RESOURCE);
            if (rule(errors, IssueType.INVALID, firstEntry.line(), firstEntry.col(), stack.addToLiteralPath(ENTRY, PATH_ARG), resource != null, I18nConstants.BUNDLE_BUNDLE_ENTRY_NOFIRSTRESOURCE)) {
                String id = resource.getNamedChildValue(ID);
                validateDocument(errors, entries, resource, firstStack.push(resource, -1, null, null), fullUrl, id);
            }
            if (!VersionUtilities.isThisOrLater(FHIRVersion._4_0_1.getDisplay(), bundle.getProperty().getStructure().getFhirVersion().getDisplay())) {
                handleSpecialCaseForLastUpdated(bundle, errors, stack);
            }
            checkAllInterlinked(errors, entries, stack, bundle, true);
        }
        if (type.equals(MESSAGE)) {
            Element resource = firstEntry.getNamedChild(RESOURCE);
            String id = resource.getNamedChildValue(ID);
            if (rule(errors, IssueType.INVALID, firstEntry.line(), firstEntry.col(), stack.addToLiteralPath(ENTRY, PATH_ARG), resource != null, I18nConstants.BUNDLE_BUNDLE_ENTRY_NOFIRSTRESOURCE)) {
                validateMessage(errors, entries, resource, firstStack.push(resource, -1, null, null), fullUrl, id);
            }
            checkAllInterlinked(errors, entries, stack, bundle, VersionUtilities.isR5Ver(context.getVersion()));
        }
        if (type.equals(SEARCHSET)) {
            checkSearchSet(errors, bundle, entries, stack);
        }
    // We do not yet have rules requiring that the id and fullUrl match when dealing with messaging Bundles
    // validateResourceIds(errors, entries, stack);
    }
    int count = 0;
    Map<String, Integer> counter = new HashMap<>();
    boolean fullUrlOptional = Utilities.existsInList(type, "transaction", "transaction-response", "batch", "batch-response");
    for (Element entry : entries) {
        NodeStack estack = stack.push(entry, count, null, null);
        String fullUrl = entry.getNamedChildValue(FULL_URL);
        String url = getCanonicalURLForEntry(entry);
        String id = getIdForEntry(entry);
        if (url != null) {
            if (!(!url.equals(fullUrl) || (url.matches(uriRegexForVersion()) && url.endsWith("/" + id))) && !isV3orV2Url(url))
                rule(errors, IssueType.INVALID, entry.line(), entry.col(), stack.addToLiteralPath(ENTRY, PATH_ARG), false, I18nConstants.BUNDLE_BUNDLE_ENTRY_MISMATCHIDURL, url, fullUrl, id);
            rule(errors, IssueType.INVALID, entry.line(), entry.col(), stack.addToLiteralPath(ENTRY, PATH_ARG), !url.equals(fullUrl) || serverBase == null || (url.equals(Utilities.pathURL(serverBase, entry.getNamedChild(RESOURCE).fhirType(), id))), I18nConstants.BUNDLE_BUNDLE_ENTRY_CANONICAL, url, fullUrl);
        }
        if (!VersionUtilities.isR2Ver(context.getVersion())) {
            rule(errors, IssueType.INVALID, entry.line(), entry.col(), estack.getLiteralPath(), fullUrlOptional || fullUrl != null, I18nConstants.BUNDLE_BUNDLE_ENTRY_FULLURL_REQUIRED);
        }
        // check bundle profile requests
        if (entry.hasChild(RESOURCE)) {
            String rtype = entry.getNamedChild(RESOURCE).fhirType();
            int rcount = counter.containsKey(rtype) ? counter.get(rtype) + 1 : 0;
            counter.put(rtype, rcount);
            for (BundleValidationRule bvr : validator.getBundleValidationRules()) {
                if (meetsRule(bvr, rtype, rcount, count)) {
                    StructureDefinition defn = validator.getContext().fetchResource(StructureDefinition.class, bvr.getProfile());
                    if (defn == null) {
                        throw new Error(validator.getContext().formatMessage(I18nConstants.BUNDLE_RULE_PROFILE_UNKNOWN, bvr.getRule(), bvr.getProfile()));
                    } else {
                        Element res = entry.getNamedChild(RESOURCE);
                        NodeStack rstack = estack.push(res, -1, null, null);
                        if (validator.isCrumbTrails()) {
                            res.addMessage(signpost(errors, IssueType.INFORMATIONAL, res.line(), res.col(), stack.getLiteralPath(), I18nConstants.VALIDATION_VAL_PROFILE_SIGNPOST_BUNDLE_PARAM, defn.getUrl()));
                        }
                        stack.resetIds();
                        validator.startInner(hostContext, errors, res, res, defn, rstack, false);
                    }
                }
            }
        }
        // todo: check specials
        count++;
    }
}
Also used : BundleValidationRule(org.hl7.fhir.r5.utils.validation.BundleValidationRule) HashMap(java.util.HashMap) IndexedElement(org.hl7.fhir.validation.instance.utils.IndexedElement) Element(org.hl7.fhir.r5.elementmodel.Element) ArrayList(java.util.ArrayList) NodeStack(org.hl7.fhir.validation.instance.utils.NodeStack) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition)

Aggregations

Bundle (org.hl7.fhir.r4.model.Bundle)3 HashMap (java.util.HashMap)2 CloseOutEicrAction (com.drajer.eca.model.CloseOutEicrAction)1 CreateEicrAction (com.drajer.eca.model.CreateEicrAction)1 CreateEicrAfterRecheckAction (com.drajer.eca.model.CreateEicrAfterRecheckAction)1 EcrActionTypes (com.drajer.eca.model.EventTypes.EcrActionTypes)1 MatchTriggerAction (com.drajer.eca.model.MatchTriggerAction)1 PeriodicUpdateEicrAction (com.drajer.eca.model.PeriodicUpdateEicrAction)1 SubmitEicrAction (com.drajer.eca.model.SubmitEicrAction)1 ValidateEicrAction (com.drajer.eca.model.ValidateEicrAction)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Example (org.hl7.fhir.definitions.model.Example)1 OperationExample (org.hl7.fhir.definitions.model.Operation.OperationExample)1 Bundle (org.hl7.fhir.dstu3.model.Bundle)1 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)1 Library (org.hl7.fhir.r4.model.Library)1 PlanDefinition (org.hl7.fhir.r4.model.PlanDefinition)1 PlanDefinitionActionComponent (org.hl7.fhir.r4.model.PlanDefinition.PlanDefinitionActionComponent)1