Module: DaVinciPASTestKit::PASNotificationVerification
- Included in:
- NotificationPASConformanceTest
- Defined in:
- lib/davinci_pas_test_kit/cross_suite/pas_notification_verification.rb
Constant Summary collapse
- PAS_RESPONSE_BUNDLE_PROFILE =
'http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-pas-response-bundle'.freeze
Instance Method Summary collapse
-
#verify_pas_notification(notification_json_str, ig_version: 'v2.2.1') ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
Instance Method Details
#verify_pas_notification(notification_json_str, ig_version: 'v2.2.1') ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/davinci_pas_test_kit/cross_suite/pas_notification_verification.rb', line 7 def verify_pas_notification(notification_json_str, ig_version: 'v2.2.1') # rubocop:disable Lint/UnusedMethodArgument assert_valid_json(notification_json_str) notification_bundle = FHIR.from_contents(notification_json_str) assert notification_bundle.present?, 'Not a FHIR resource' assert_resource_type(:bundle, resource: notification_bundle) assert notification_bundle.entry.present?, 'The notification Bundle must contain at least one entry' # First entry is the SubscriptionStatus Parameters resource subscription_status = notification_bundle.entry[0]&.resource assert subscription_status&.resourceType == 'Parameters', 'The first entry in the notification Bundle must be a Parameters ' \ "(SubscriptionStatus) resource, but found `#{subscription_status&.resourceType}`" # Extract focus references from notification-event parameters focus_references = extract_focus_references(subscription_status) assert focus_references.present?, 'The SubscriptionStatus must include at least one notification-event ' \ 'parameter with a focus reference' # Resolve each focus reference to a Bundle entry and validate PAS structure bundle_entries = notification_bundle.entry.drop(1) focus_references.each do |focus_ref| focus_entry = resolve_focus_entry(focus_ref, bundle_entries) if focus_entry.nil? ('error', %( Could not resolve focus reference `#{focus_ref}` to a Bundle entry. The notification Bundle must include the focus resource. )) next end focus_resource = focus_entry.resource if focus_resource.nil? ('error', %( The Bundle entry for focus reference `#{focus_ref}` does not contain a resource. )) next end # Check PAS-specific structural requirements only. # Profile validation is handled by the Subscription conformance tests # (9.3.3.01 and 9.3.3.02) to avoid duplicate error messages. validate_focus_as_response_bundle(focus_resource) end assert .none? { |msg| msg[:type] == 'error' }, 'The notification does not conform to PAS requirements - see messages for details.' end |