public static InvalidRequestException invalidRequest( OperationOutcome.IssueSeverity severity, OperationOutcome.IssueType type, String code, String diagnostics, String msg, Object... args) { return exception(InvalidRequestException::new, severity, type, code, diagnostics, msg, args); }
/** * Converts a {@link Bundle} into a map grouped by the entry resources types * * @param bundle Bundle * @return map of entries grouped by their resource type */ public static Map<ResourceType, List<Bundle.BundleEntryComponent>> getBundleEntries(Bundle bundle) { return bundle.getEntry().stream() .collect(Collectors.groupingBy(entry -> { Bundle.BundleEntryRequestComponent request = entry.getRequest(); if (request == null || request.getUrl() == null) { throw unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, null, null, "Invalid bundle entry request element %s", entry); } return entry.getResource().getResourceType(); } , LinkedHashMap::new, Collectors.toList())); }
Map<ResourceType, List<Bundle.BundleEntryComponent>> entries = FhirUtils.getBundleEntries(bundle); throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, patientReferences.add(getSubjectReference(resource, r -> ((ListResource) r).getSubject())); } else if (!(resource instanceof Binary)) { throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, if (ResourceType.DocumentReference == entry.getResource().getResourceType()) { if (!expectedReferenceFullUrls.remove(entry.getFullUrl())) { throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID,
/** * Converts a {@link Bundle} into a map grouped by the entry resources types * * @param bundle Bundle * @return map of entries grouped by their resource type */ public static Map<ResourceType, List<Bundle.BundleEntryComponent>> getBundleEntries(Bundle bundle) { return bundle.getEntry().stream() .collect(Collectors.groupingBy(entry -> { Bundle.BundleEntryRequestComponent request = entry.getRequest(); if (request == null || request.getUrl() == null) { throw unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, null, null, "Invalid bundle entry request element %s", entry); } return entry.getResource().getResourceType(); } , LinkedHashMap::new, Collectors.toList())); }
Map<ResourceType, List<Bundle.BundleEntryComponent>> entries = FhirUtils.getBundleEntries(bundle); throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, patientReferences.add(getSubjectReference(resource, r -> ((List_) r).getSubject())); } else if (!(resource instanceof Binary)) { throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, if (ResourceType.DocumentReference == entry.getResource().getResourceType()) { if (!expectedReferenceFullUrls.remove(entry.getFullUrl())) { throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID,
public static UnprocessableEntityException unprocessableEntity( OperationOutcome.IssueSeverity severity, OperationOutcome.IssueType type, String code, String diagnostics, String msg, Object... args) { return exception(UnprocessableEntityException::new, severity, type, code, diagnostics, msg, args); }
/** * Validates bundle type, meta data and consistency of contained resources * * @param bundle transaction bundle */ protected void validateTransactionBundle(Bundle bundle) { if (!Bundle.BundleType.TRANSACTION.equals(bundle.getType())) { throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, null, null, "Bundle type must be %s, but was %s", Bundle.BundleType.TRANSACTION.toCode(), bundle.getType().toCode()); } List<UriType> profiles = bundle.getMeta().getProfile(); if (profiles.isEmpty() || !Iti65Constants.ITI65_PROFILE.equals(profiles.get(0).getValue())) { throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, null, null, "Request bundle must have profile", Iti65Constants.ITI65_PROFILE); } }
Map<ResourceType, List<Bundle.BundleEntryComponent>> entries = FhirUtils.getBundleEntries(bundle); throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, patientReferences.add(getSubjectReference(resource, r -> ((ListResource) r).getSubject())); } else if (!(resource instanceof Binary)) { throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, if (ResourceType.DocumentReference == entry.getResource().getResourceType()) { if (!expectedReferenceFullUrls.remove(entry.getFullUrl())) { throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID,
public static InvalidRequestException invalidRequest( OperationOutcome.IssueSeverity severity, OperationOutcome.IssueType type, String code, String diagnostics, String msg, Object... args) { return exception(InvalidRequestException::new, severity, type, code, diagnostics, msg, args); }
/** * Validates bundle type, meta data and consistency of contained resources * * @param bundle transaction bundle */ protected void validateTransactionBundle(Bundle bundle) { if (!Bundle.BundleType.TRANSACTION.equals(bundle.getType())) { throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, null, null, "Bundle type must be %s, but was %s", Bundle.BundleType.TRANSACTION.toCode(), bundle.getType().toCode()); } List<CanonicalType> profiles = bundle.getMeta().getProfile(); if (profiles.isEmpty() || !Iti65Constants.ITI65_PROFILE.equals(profiles.get(0).getValue())) { throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, null, null, "Request bundle must have profile", Iti65Constants.ITI65_PROFILE); } }
public static InternalErrorException internalError( OperationOutcome.IssueSeverity severity, OperationOutcome.IssueType type, String code, String diagnostics, String msg, Object... args) { return exception(InternalErrorException::new, severity, type, code, diagnostics, msg, args); }
/** * Validates bundle type, meta data and consistency of contained resources * * @param bundle transaction bundle */ protected void validateTransactionBundle(Bundle bundle) { if (!Bundle.BundleType.TRANSACTION.equals(bundle.getType())) { throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, null, null, "Bundle type must be %s, but was %s", Bundle.BundleType.TRANSACTION.toCode(), bundle.getType().toCode()); } List<UriType> profiles = bundle.getMeta().getProfile(); if (profiles.isEmpty() || !Iti65Constants.ITI65_PROFILE.equals(profiles.get(0).getValue())) { throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, null, null, "Request bundle must have profile", Iti65Constants.ITI65_PROFILE); } }
public static ResourceNotFoundException resourceNotFound( OperationOutcome.IssueSeverity severity, OperationOutcome.IssueType type, String code, String diagnostics, String msg, Object... args) { return exception(ResourceNotFoundException::new, severity, type, code, diagnostics, msg, args); }
private String getSubjectReference(Resource resource, Function<Resource, Reference> f) { Reference reference = f.apply(resource); if (reference == null) { throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, ErrorCode.UNKNOWN_PATIENT_ID.getOpcode(), null, "Empty Patient reference in resource %s", resource ); } // Could be contained resources if (reference.getResource() != null) { Patient patient = (Patient) reference.getResource(); return patient.getIdentifier().get(0).getValue(); } return reference.getReference(); }
public static UnprocessableEntityException unprocessableEntity( OperationOutcome.IssueSeverity severity, OperationOutcome.IssueType type, String code, String diagnostics, String msg, Object... args) { return exception(UnprocessableEntityException::new, severity, type, code, diagnostics, msg, args); }
private String getSubjectReference(Resource resource, Function<Resource, Reference> f) { Reference reference = f.apply(resource); if (reference == null) { throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, ErrorCode.UNKNOWN_PATIENT_ID.getOpcode(), null, "Empty Patient reference in resource %s", resource ); } // Could be contained resources if (reference.getResource() != null) { Patient patient = (Patient) reference.getResource(); return patient.getIdentifier().get(0).getValue(); } return reference.getReference(); }
public static ResourceNotFoundException resourceNotFound( OperationOutcome.IssueSeverity severity, OperationOutcome.IssueType type, String code, String diagnostics, String msg, Object... args) { return exception(ResourceNotFoundException::new, severity, type, code, diagnostics, msg, args); }
private String getSubjectReference(Resource resource, Function<Resource, Reference> f) { Reference reference = f.apply(resource); if (reference == null) { throw FhirUtils.unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, ErrorCode.UNKNOWN_PATIENT_ID.getOpcode(), null, "Empty Patient reference in resource %s", resource ); } // Could be contained resources if (reference.getResource() != null) { Patient patient = (Patient) reference.getResource(); return patient.getIdentifier().get(0).getValue(); } return reference.getReference(); }
public static ForbiddenOperationException forbiddenOperation( OperationOutcome.IssueSeverity severity, OperationOutcome.IssueType type, String code, String diagnostics, String msg, Object... args) { return exception(ForbiddenOperationException::new, severity, type, code, diagnostics, msg, args); }
public static InternalErrorException internalError( OperationOutcome.IssueSeverity severity, OperationOutcome.IssueType type, String code, String diagnostics, String msg, Object... args) { return exception(InternalErrorException::new, severity, type, code, diagnostics, msg, args); }