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