Class: DaVinciPDexTestKit::PDexPayerServer::MemberMatchRequestProfileValidation

Inherits:
Inferno::Test
  • Object
show all
Defined in:
lib/davinci_pdex_test_kit/pdex_payer_server/member_match_request_profile_validation.rb

Overview

Factorized test for Member Match Request Profile validation on PDex v2.0.0 and HRex v1.0.0.

hl7.org/fhir/us/davinci-hrex/STU1/StructureDefinition-hrex-parameters-member-match-in.html

Inputs

member_match_request - Optional: JSON text to validate against profile

Outputs

(none)

Required Config

(none)

Required Scratch

(none)

Notes

Skips if no input provided. This test does not validate all requirements of a Member Match Request resource.

Instance Method Summary collapse

Instance Method Details

#assert_local_patient_references(member_match_request_parameters) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/davinci_pdex_test_kit/pdex_payer_server/member_match_request_profile_validation.rb', line 36

def assert_local_patient_references(member_match_request_parameters)
  # $member-match has references requirements on its Parameters profile not coded as FHIR constraints
  # see https://hl7.org/fhir/us/davinci-hrex/STU1/OperationDefinition-member-match.html#resolving-parameter-references
  parameter_patient_id = member_match_request_parameters.parameter.find{|p| p.name== 'MemberPatient'}.resource.id
  assert member_match_request_parameters.parameter.find{|p| p.name== 'Consent'}&.resource&.patient&.reference == "Patient/#{parameter_patient_id}",
    "The reference to Patient resource in Consent parameter must be a local reference referring to MemberPatient with matching id"
  assert member_match_request_parameters.parameter.find{|p| p.name== 'CoverageToMatch'}&.resource.beneficiary.reference == "Patient/#{parameter_patient_id}",
    "The reference to Patient resource in CoverageToMatch parameter must be a local reference referring to MemberPatient with matching id"
end

#assert_member_match_request(member_match_request_json) ⇒ Object



46
47
48
49
50
51
# File 'lib/davinci_pdex_test_kit/pdex_payer_server/member_match_request_profile_validation.rb', line 46

def assert_member_match_request(member_match_request_json)
  # assert_valid_json(member_match_request_json)
  member_match_request_resource = FHIR.from_contents(member_match_request_json) # TODO: handle case if it fails to parse as FHIR, but is valid JSON
  assert_valid_resource(resource: member_match_request_resource, profile_url: 'http://hl7.org/fhir/us/davinci-hrex/StructureDefinition/hrex-parameters-member-match-in')
  assert_local_patient_references(member_match_request_resource)
end