carin_for_blue_button_test_kit 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (278) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +201 -0
  3. data/lib/carin_for_blue_button_test_kit/capability_statement/capability_statement_group.rb +45 -0
  4. data/lib/carin_for_blue_button_test_kit/capability_statement/tests/conformance_support_test.rb +41 -0
  5. data/lib/carin_for_blue_button_test_kit/capability_statement/tests/fhir_version_test.rb +15 -0
  6. data/lib/carin_for_blue_button_test_kit/capability_statement/tests/instantiates_test.rb +32 -0
  7. data/lib/carin_for_blue_button_test_kit/capability_statement/tests/json_support_test.rb +39 -0
  8. data/lib/carin_for_blue_button_test_kit/capability_statement/tests/profile_support_test.rb +32 -0
  9. data/lib/carin_for_blue_button_test_kit/carin_search_test.rb +227 -0
  10. data/lib/carin_for_blue_button_test_kit/date_search_validator.rb +109 -0
  11. data/lib/carin_for_blue_button_test_kit/fhir_resource_navigation.rb +73 -0
  12. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/c4bb_test_suite.rb +106 -0
  13. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/coverage/coverage_must_support_test.rb +53 -0
  14. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/coverage/coverage_read_test.rb +39 -0
  15. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/coverage/coverage_validation_test.rb +43 -0
  16. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/coverage_group.rb +58 -0
  17. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit/explanation_of_benefit_explanation_of_benefit_all_search_test.rb +38 -0
  18. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit/explanation_of_benefit_explanation_of_benefit_careteam_search_test.rb +38 -0
  19. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit/explanation_of_benefit_explanation_of_benefit_coverage_search_test.rb +38 -0
  20. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit/explanation_of_benefit_explanation_of_benefit_insurer_search_test.rb +38 -0
  21. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit/explanation_of_benefit_explanation_of_benefit_patient_search_test.rb +38 -0
  22. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit/explanation_of_benefit_explanation_of_benefit_provider_search_test.rb +38 -0
  23. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit/explanation_of_benefit_id_search_test.rb +59 -0
  24. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit/explanation_of_benefit_identifier_search_test.rb +49 -0
  25. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit/explanation_of_benefit_lastupdated_search_test.rb +48 -0
  26. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit/explanation_of_benefit_must_support_test.rb +72 -0
  27. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit/explanation_of_benefit_patient_search_test.rb +48 -0
  28. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit/explanation_of_benefit_read_test.rb +39 -0
  29. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit/explanation_of_benefit_service_date_search_test.rb +48 -0
  30. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit/explanation_of_benefit_type_search_test.rb +49 -0
  31. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit/explanation_of_benefit_validation_test.rb +43 -0
  32. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_group.rb +110 -0
  33. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_explanation_of_benefit_all_search_test.rb +38 -0
  34. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_explanation_of_benefit_careteam_search_test.rb +38 -0
  35. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_explanation_of_benefit_coverage_search_test.rb +38 -0
  36. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_explanation_of_benefit_insurer_search_test.rb +38 -0
  37. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_explanation_of_benefit_patient_search_test.rb +38 -0
  38. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_explanation_of_benefit_provider_search_test.rb +38 -0
  39. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_id_search_test.rb +59 -0
  40. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_identifier_search_test.rb +49 -0
  41. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_lastupdated_search_test.rb +48 -0
  42. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_must_support_test.rb +120 -0
  43. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_patient_search_test.rb +48 -0
  44. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_read_test.rb +39 -0
  45. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_service_date_search_test.rb +48 -0
  46. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_type_search_test.rb +49 -0
  47. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_validation_test.rb +43 -0
  48. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_inpatient_institutional_group.rb +58 -0
  49. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_explanation_of_benefit_all_search_test.rb +38 -0
  50. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_explanation_of_benefit_careteam_search_test.rb +38 -0
  51. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_explanation_of_benefit_coverage_search_test.rb +38 -0
  52. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_explanation_of_benefit_insurer_search_test.rb +38 -0
  53. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_explanation_of_benefit_patient_search_test.rb +38 -0
  54. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_explanation_of_benefit_provider_search_test.rb +38 -0
  55. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_id_search_test.rb +59 -0
  56. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_identifier_search_test.rb +49 -0
  57. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_lastupdated_search_test.rb +48 -0
  58. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_must_support_test.rb +112 -0
  59. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_patient_search_test.rb +48 -0
  60. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_read_test.rb +39 -0
  61. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_service_date_search_test.rb +48 -0
  62. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_type_search_test.rb +49 -0
  63. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_validation_test.rb +43 -0
  64. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_outpatient_institutional_group.rb +58 -0
  65. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_explanation_of_benefit_all_search_test.rb +38 -0
  66. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_explanation_of_benefit_careteam_search_test.rb +38 -0
  67. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_explanation_of_benefit_coverage_search_test.rb +38 -0
  68. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_explanation_of_benefit_insurer_search_test.rb +38 -0
  69. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_explanation_of_benefit_patient_search_test.rb +38 -0
  70. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_explanation_of_benefit_provider_search_test.rb +38 -0
  71. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_id_search_test.rb +59 -0
  72. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_identifier_search_test.rb +49 -0
  73. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_lastupdated_search_test.rb +48 -0
  74. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_must_support_test.rb +103 -0
  75. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_patient_search_test.rb +48 -0
  76. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_read_test.rb +39 -0
  77. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_service_date_search_test.rb +48 -0
  78. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_type_search_test.rb +49 -0
  79. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_validation_test.rb +43 -0
  80. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_pharmacy_group.rb +58 -0
  81. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_explanation_of_benefit_all_search_test.rb +38 -0
  82. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_explanation_of_benefit_careteam_search_test.rb +38 -0
  83. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_explanation_of_benefit_coverage_search_test.rb +38 -0
  84. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_explanation_of_benefit_insurer_search_test.rb +38 -0
  85. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_explanation_of_benefit_patient_search_test.rb +38 -0
  86. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_explanation_of_benefit_provider_search_test.rb +38 -0
  87. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_id_search_test.rb +59 -0
  88. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_identifier_search_test.rb +49 -0
  89. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_lastupdated_search_test.rb +48 -0
  90. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_must_support_test.rb +97 -0
  91. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_patient_search_test.rb +48 -0
  92. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_read_test.rb +39 -0
  93. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_service_date_search_test.rb +48 -0
  94. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_type_search_test.rb +49 -0
  95. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_validation_test.rb +43 -0
  96. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/explanation_of_benefit_professional_non_clinician_group.rb +58 -0
  97. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/organization/organization_must_support_test.rb +55 -0
  98. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/organization/organization_read_test.rb +39 -0
  99. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/organization/organization_validation_test.rb +43 -0
  100. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/organization_group.rb +58 -0
  101. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/patient/patient_must_support_test.rb +69 -0
  102. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/patient/patient_read_test.rb +39 -0
  103. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/patient/patient_validation_test.rb +43 -0
  104. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/patient_group.rb +58 -0
  105. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/practitioner/practitioner_must_support_test.rb +46 -0
  106. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/practitioner/practitioner_read_test.rb +39 -0
  107. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/practitioner/practitioner_validation_test.rb +43 -0
  108. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/practitioner_group.rb +58 -0
  109. data/lib/carin_for_blue_button_test_kit/generated/v1.1.0/resource_list.rb +17 -0
  110. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/c4bb_test_suite.rb +110 -0
  111. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/coverage/coverage_coverage_payor_search_test.rb +38 -0
  112. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/coverage/coverage_id_search_test.rb +59 -0
  113. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/coverage/coverage_lastupdated_search_test.rb +48 -0
  114. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/coverage/coverage_must_support_test.rb +53 -0
  115. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/coverage/coverage_read_test.rb +39 -0
  116. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/coverage/coverage_validation_test.rb +43 -0
  117. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/coverage_group.rb +87 -0
  118. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit/explanation_of_benefit_billable_period_start_search_test.rb +48 -0
  119. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit/explanation_of_benefit_explanation_of_benefit_all_search_test.rb +38 -0
  120. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit/explanation_of_benefit_explanation_of_benefit_careteam_search_test.rb +38 -0
  121. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit/explanation_of_benefit_explanation_of_benefit_coverage_search_test.rb +38 -0
  122. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit/explanation_of_benefit_explanation_of_benefit_insurer_search_test.rb +38 -0
  123. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit/explanation_of_benefit_explanation_of_benefit_patient_search_test.rb +38 -0
  124. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit/explanation_of_benefit_explanation_of_benefit_payee_search_test.rb +38 -0
  125. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit/explanation_of_benefit_explanation_of_benefit_provider_search_test.rb +38 -0
  126. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit/explanation_of_benefit_id_search_test.rb +59 -0
  127. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit/explanation_of_benefit_identifier_search_test.rb +49 -0
  128. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit/explanation_of_benefit_lastupdated_search_test.rb +48 -0
  129. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit/explanation_of_benefit_must_support_test.rb +73 -0
  130. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit/explanation_of_benefit_patient_search_test.rb +48 -0
  131. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit/explanation_of_benefit_read_test.rb +39 -0
  132. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit/explanation_of_benefit_service_date_search_test.rb +48 -0
  133. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit/explanation_of_benefit_service_start_date_search_test.rb +48 -0
  134. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit/explanation_of_benefit_type_search_test.rb +49 -0
  135. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit/explanation_of_benefit_validation_test.rb +43 -0
  136. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_group.rb +118 -0
  137. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_billable_period_start_search_test.rb +48 -0
  138. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_explanation_of_benefit_all_search_test.rb +38 -0
  139. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_explanation_of_benefit_careteam_search_test.rb +38 -0
  140. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_explanation_of_benefit_coverage_search_test.rb +38 -0
  141. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_explanation_of_benefit_insurer_search_test.rb +38 -0
  142. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_explanation_of_benefit_patient_search_test.rb +38 -0
  143. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_explanation_of_benefit_payee_search_test.rb +38 -0
  144. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_explanation_of_benefit_provider_search_test.rb +38 -0
  145. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_id_search_test.rb +59 -0
  146. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_identifier_search_test.rb +49 -0
  147. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_lastupdated_search_test.rb +48 -0
  148. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_must_support_test.rb +121 -0
  149. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_patient_search_test.rb +48 -0
  150. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_read_test.rb +39 -0
  151. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_service_date_search_test.rb +48 -0
  152. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_service_start_date_search_test.rb +48 -0
  153. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_type_search_test.rb +49 -0
  154. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_inpatient_institutional/explanation_of_benefit_inpatient_institutional_validation_test.rb +43 -0
  155. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_inpatient_institutional_group.rb +58 -0
  156. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_oral/explanation_of_benefit_oral_billable_period_start_search_test.rb +48 -0
  157. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_oral/explanation_of_benefit_oral_explanation_of_benefit_all_search_test.rb +38 -0
  158. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_oral/explanation_of_benefit_oral_explanation_of_benefit_careteam_search_test.rb +38 -0
  159. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_oral/explanation_of_benefit_oral_explanation_of_benefit_coverage_search_test.rb +38 -0
  160. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_oral/explanation_of_benefit_oral_explanation_of_benefit_insurer_search_test.rb +38 -0
  161. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_oral/explanation_of_benefit_oral_explanation_of_benefit_patient_search_test.rb +38 -0
  162. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_oral/explanation_of_benefit_oral_explanation_of_benefit_payee_search_test.rb +38 -0
  163. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_oral/explanation_of_benefit_oral_explanation_of_benefit_provider_search_test.rb +38 -0
  164. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_oral/explanation_of_benefit_oral_id_search_test.rb +59 -0
  165. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_oral/explanation_of_benefit_oral_identifier_search_test.rb +49 -0
  166. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_oral/explanation_of_benefit_oral_lastupdated_search_test.rb +48 -0
  167. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_oral/explanation_of_benefit_oral_must_support_test.rb +112 -0
  168. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_oral/explanation_of_benefit_oral_patient_search_test.rb +48 -0
  169. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_oral/explanation_of_benefit_oral_read_test.rb +39 -0
  170. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_oral/explanation_of_benefit_oral_service_date_search_test.rb +48 -0
  171. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_oral/explanation_of_benefit_oral_service_start_date_search_test.rb +48 -0
  172. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_oral/explanation_of_benefit_oral_type_search_test.rb +49 -0
  173. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_oral/explanation_of_benefit_oral_validation_test.rb +43 -0
  174. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_oral_group.rb +58 -0
  175. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_billable_period_start_search_test.rb +48 -0
  176. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_explanation_of_benefit_all_search_test.rb +38 -0
  177. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_explanation_of_benefit_careteam_search_test.rb +38 -0
  178. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_explanation_of_benefit_coverage_search_test.rb +38 -0
  179. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_explanation_of_benefit_insurer_search_test.rb +38 -0
  180. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_explanation_of_benefit_patient_search_test.rb +38 -0
  181. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_explanation_of_benefit_payee_search_test.rb +38 -0
  182. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_explanation_of_benefit_provider_search_test.rb +38 -0
  183. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_id_search_test.rb +59 -0
  184. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_identifier_search_test.rb +49 -0
  185. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_lastupdated_search_test.rb +48 -0
  186. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_must_support_test.rb +114 -0
  187. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_patient_search_test.rb +48 -0
  188. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_read_test.rb +39 -0
  189. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_service_date_search_test.rb +48 -0
  190. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_service_start_date_search_test.rb +48 -0
  191. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_type_search_test.rb +49 -0
  192. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_outpatient_institutional/explanation_of_benefit_outpatient_institutional_validation_test.rb +43 -0
  193. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_outpatient_institutional_group.rb +58 -0
  194. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_billable_period_start_search_test.rb +48 -0
  195. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_explanation_of_benefit_all_search_test.rb +38 -0
  196. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_explanation_of_benefit_careteam_search_test.rb +38 -0
  197. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_explanation_of_benefit_coverage_search_test.rb +38 -0
  198. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_explanation_of_benefit_insurer_search_test.rb +38 -0
  199. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_explanation_of_benefit_patient_search_test.rb +38 -0
  200. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_explanation_of_benefit_payee_search_test.rb +38 -0
  201. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_explanation_of_benefit_provider_search_test.rb +38 -0
  202. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_id_search_test.rb +59 -0
  203. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_identifier_search_test.rb +49 -0
  204. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_lastupdated_search_test.rb +48 -0
  205. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_must_support_test.rb +109 -0
  206. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_patient_search_test.rb +48 -0
  207. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_read_test.rb +39 -0
  208. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_service_date_search_test.rb +48 -0
  209. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_service_start_date_search_test.rb +48 -0
  210. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_type_search_test.rb +49 -0
  211. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_pharmacy/explanation_of_benefit_pharmacy_validation_test.rb +43 -0
  212. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_pharmacy_group.rb +58 -0
  213. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_billable_period_start_search_test.rb +48 -0
  214. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_explanation_of_benefit_all_search_test.rb +38 -0
  215. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_explanation_of_benefit_careteam_search_test.rb +38 -0
  216. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_explanation_of_benefit_coverage_search_test.rb +38 -0
  217. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_explanation_of_benefit_insurer_search_test.rb +38 -0
  218. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_explanation_of_benefit_patient_search_test.rb +38 -0
  219. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_explanation_of_benefit_payee_search_test.rb +38 -0
  220. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_explanation_of_benefit_provider_search_test.rb +38 -0
  221. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_id_search_test.rb +59 -0
  222. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_identifier_search_test.rb +49 -0
  223. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_lastupdated_search_test.rb +48 -0
  224. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_must_support_test.rb +108 -0
  225. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_patient_search_test.rb +48 -0
  226. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_read_test.rb +39 -0
  227. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_service_date_search_test.rb +48 -0
  228. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_service_start_date_search_test.rb +48 -0
  229. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_type_search_test.rb +49 -0
  230. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_professional_non_clinician/explanation_of_benefit_professional_non_clinician_validation_test.rb +43 -0
  231. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/explanation_of_benefit_professional_non_clinician_group.rb +58 -0
  232. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/organization/organization_must_support_test.rb +55 -0
  233. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/organization/organization_read_test.rb +39 -0
  234. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/organization/organization_validation_test.rb +43 -0
  235. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/organization_group.rb +81 -0
  236. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/patient/patient_must_support_test.rb +68 -0
  237. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/patient/patient_read_test.rb +39 -0
  238. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/patient/patient_validation_test.rb +43 -0
  239. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/patient_group.rb +81 -0
  240. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/practitioner/practitioner_must_support_test.rb +46 -0
  241. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/practitioner/practitioner_read_test.rb +39 -0
  242. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/practitioner/practitioner_validation_test.rb +43 -0
  243. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/practitioner_group.rb +81 -0
  244. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/related_person/related_person_must_support_test.rb +47 -0
  245. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/related_person/related_person_read_test.rb +39 -0
  246. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/related_person/related_person_validation_test.rb +43 -0
  247. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/related_person_group.rb +81 -0
  248. data/lib/carin_for_blue_button_test_kit/generated/v2.0.0/resource_list.rb +19 -0
  249. data/lib/carin_for_blue_button_test_kit/generator/group_generator.rb +210 -0
  250. data/lib/carin_for_blue_button_test_kit/generator/group_metadata.rb +87 -0
  251. data/lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb +240 -0
  252. data/lib/carin_for_blue_button_test_kit/generator/ig_loader.rb +76 -0
  253. data/lib/carin_for_blue_button_test_kit/generator/ig_metadata.rb +50 -0
  254. data/lib/carin_for_blue_button_test_kit/generator/ig_metadata_extractor.rb +40 -0
  255. data/lib/carin_for_blue_button_test_kit/generator/ig_resources.rb +50 -0
  256. data/lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb +105 -0
  257. data/lib/carin_for_blue_button_test_kit/generator/must_support_metadata_extractor.rb +326 -0
  258. data/lib/carin_for_blue_button_test_kit/generator/must_support_test_generator.rb +131 -0
  259. data/lib/carin_for_blue_button_test_kit/generator/naming.rb +36 -0
  260. data/lib/carin_for_blue_button_test_kit/generator/read_test_generator.rb +109 -0
  261. data/lib/carin_for_blue_button_test_kit/generator/resource_list_generator.rb +43 -0
  262. data/lib/carin_for_blue_button_test_kit/generator/search_definition_metadata_extractor.rb +207 -0
  263. data/lib/carin_for_blue_button_test_kit/generator/search_metadata_extractor.rb +74 -0
  264. data/lib/carin_for_blue_button_test_kit/generator/search_test_generator.rb +299 -0
  265. data/lib/carin_for_blue_button_test_kit/generator/special_cases.rb +21 -0
  266. data/lib/carin_for_blue_button_test_kit/generator/suite_generator.rb +94 -0
  267. data/lib/carin_for_blue_button_test_kit/generator/terminology_binding_metadata_extractor.rb +109 -0
  268. data/lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb +137 -0
  269. data/lib/carin_for_blue_button_test_kit/generator/value_extractor.rb +50 -0
  270. data/lib/carin_for_blue_button_test_kit/generator.rb +90 -0
  271. data/lib/carin_for_blue_button_test_kit/must_support_test.rb +211 -0
  272. data/lib/carin_for_blue_button_test_kit/read_test.rb +51 -0
  273. data/lib/carin_for_blue_button_test_kit/search_test.rb +781 -0
  274. data/lib/carin_for_blue_button_test_kit/search_test_properties.rb +57 -0
  275. data/lib/carin_for_blue_button_test_kit/validation_test.rb +57 -0
  276. data/lib/carin_for_blue_button_test_kit/version.rb +5 -0
  277. data/lib/carin_for_blue_button_test_kit.rb +2 -0
  278. metadata +405 -0
@@ -0,0 +1,781 @@
1
+ require_relative 'date_search_validator'
2
+ require_relative 'fhir_resource_navigation'
3
+ require_relative 'search_test_properties'
4
+
5
+ module CarinForBlueButtonTestKit
6
+ module SearchTest
7
+ extend Forwardable
8
+ include DateSearchValidation
9
+ include FHIRResourceNavigation
10
+
11
+ def_delegators 'self.class', :metadata, :provenance_metadata, :properties
12
+ def_delegators 'properties',
13
+ :resource_type,
14
+ :search_param_names,
15
+ :saves_delayed_references?,
16
+ :first_search?,
17
+ :fixed_value_search?,
18
+ :possible_status_search?,
19
+ :test_medication_inclusion?,
20
+ :test_post_search?,
21
+ :token_search_params,
22
+ :test_reference_variants?,
23
+ :params_with_comparators,
24
+ :multiple_or_search_params
25
+
26
+ def all_search_params
27
+ @all_search_params ||=
28
+ patient_id_list.each_with_object({}) do |patient_id, params|
29
+ params[patient_id] ||= []
30
+ new_params =
31
+ if fixed_value_search?
32
+ fixed_value_search_param_values.map { |value| fixed_value_search_params(value, patient_id) }
33
+ else
34
+ [search_params_with_values(search_param_names, patient_id)]
35
+ end
36
+ new_params.reject! do |params|
37
+ params.any? { |_key, value| value.blank? }
38
+ end
39
+
40
+ params[patient_id].concat(new_params)
41
+ end
42
+ end
43
+
44
+ def all_provenance_revinclude_search_params
45
+ @all_provenance_revinclude_search_params ||=
46
+ all_search_params.transform_values! do |params_list|
47
+ params_list.map { |params| params.merge(_revinclude: 'Provenance:target') }
48
+ end
49
+ end
50
+
51
+ def any_valid_search_params?(search_params)
52
+ search_params.any? { |_patient_id, params| params.present? }
53
+ end
54
+
55
+ def run_provenance_revinclude_search_test
56
+ # TODO: skip if not supported?
57
+ skip_if !any_valid_search_params?(all_provenance_revinclude_search_params), unable_to_resolve_params_message
58
+
59
+ provenance_resources =
60
+ all_provenance_revinclude_search_params.flat_map do |_patient_id, params_list|
61
+ params_list.flat_map do |params|
62
+ fhir_search resource_type, params: params
63
+
64
+ perform_search_with_status(params, patient_id) if response[:status] == 400 && possible_status_search?
65
+
66
+ check_search_response
67
+
68
+ fetch_all_bundled_resources(additional_resource_types: ['Provenance'])
69
+ .select { |resource| resource.resourceType == 'Provenance' }
70
+ end
71
+ end
72
+
73
+ scratch_provenance_resources[:all] ||= []
74
+ scratch_provenance_resources[:all].concat(provenance_resources)
75
+
76
+ save_delayed_references(provenance_resources, 'Provenance')
77
+
78
+ skip_if provenance_resources.empty?, no_resources_skip_message('Provenance')
79
+ end
80
+
81
+ def run_search_test
82
+ # TODO: skip if not supported?
83
+ skip_if !any_valid_search_params?(all_search_params), unable_to_resolve_params_message
84
+
85
+ resources_returned =
86
+ all_search_params.flat_map do |patient_id, params_list|
87
+ params_list.flat_map { |params| perform_search(params, patient_id) }
88
+ end
89
+
90
+ skip_if resources_returned.empty?, no_resources_skip_message
91
+
92
+ perform_multiple_or_search_test if multiple_or_search_params.present?
93
+ end
94
+
95
+ def perform_search(params, patient_id)
96
+ fhir_search resource_type, params: params
97
+
98
+ perform_search_with_status(params, patient_id) if response[:status] == 400 && possible_status_search?
99
+
100
+ check_search_response
101
+
102
+ resources_returned =
103
+ fetch_all_bundled_resources.select { |resource| resource.resourceType == resource_type }
104
+
105
+ return [] if resources_returned.blank?
106
+
107
+ perform_comparator_searches(params, patient_id) if params_with_comparators.present?
108
+
109
+ filter_conditions(resources_returned) if resource_type == 'Condition' && metadata.version == 'v5.0.1'
110
+ filter_devices(resources_returned) if resource_type == 'Device'
111
+
112
+ if first_search?
113
+ all_scratch_resources.concat(resources_returned).uniq!
114
+ scratch_resources_for_patient(patient_id).concat(resources_returned).uniq!
115
+ end
116
+
117
+ resources_returned.each do |resource|
118
+ check_resource_against_params(resource, params)
119
+ end
120
+
121
+ save_delayed_references(resources_returned) if saves_delayed_references?
122
+
123
+ return resources_returned if all_search_variants_tested?
124
+
125
+ perform_post_search(resources_returned, params) if test_post_search?
126
+ test_medication_inclusion(resources_returned, params, patient_id) if test_medication_inclusion?
127
+ perform_reference_with_type_search(params, resources_returned.count) if test_reference_variants?
128
+ perform_search_with_system(params, patient_id) if token_search_params.present?
129
+
130
+ resources_returned
131
+ end
132
+
133
+ def perform_post_search(get_search_resources, params)
134
+ fhir_search resource_type, params: params, search_method: :post
135
+
136
+ check_search_response
137
+
138
+ post_search_resources = fetch_all_bundled_resources.select { |resource| resource.resourceType == resource_type }
139
+
140
+ filter_conditions(post_search_resources) if resource_type == 'Condition' && metadata.version == 'v5.0.1'
141
+ filter_devices(post_search_resources) if resource_type == 'Device'
142
+
143
+ get_resource_count = get_search_resources.length
144
+ post_resource_count = post_search_resources.length
145
+
146
+ search_variant_test_records[:post_variant] = true
147
+
148
+ assert get_resource_count == post_resource_count,
149
+ "Expected search by POST to return the same results as search by GET, " \
150
+ "but GET search returned #{get_resource_count} resources, and POST search " \
151
+ "returned #{post_resource_count} resources."
152
+ end
153
+
154
+ def filter_devices(resources)
155
+ codes_to_include = implantable_device_codes&.split(',')&.map(&:strip)
156
+ return resources if codes_to_include.blank?
157
+
158
+ resources.select! do |resource|
159
+ resource&.type&.coding&.any? { |coding| codes_to_include.include?(coding.code) }
160
+ end
161
+ end
162
+
163
+ def filter_conditions(resources)
164
+ # HL7 JIRA FHIR-37917. US Core v5.0.1 does not required patient+category.
165
+ # In order to distinguish which resources matches the current profile, Inferno has to manually filter
166
+ # the result of first search, which is searching by patient.
167
+ resources.select! do |resource|
168
+ resource.category.any? do |category|
169
+ category.coding.any? do |coding|
170
+ metadata.search_definitions[:category][:values].include? coding.code
171
+ end
172
+ end
173
+ end
174
+ end
175
+
176
+ def search_and_check_response(params, resource_type = self.resource_type)
177
+ fhir_search resource_type, params: params
178
+
179
+ check_search_response
180
+ end
181
+
182
+ def check_search_response
183
+ assert_response_status(200)
184
+ assert_resource_type(:bundle)
185
+ # NOTE: how do we want to handle validating Bundles?
186
+ end
187
+
188
+ def search_variant_test_records
189
+ @search_variant_test_records ||= initial_search_variant_test_records
190
+ end
191
+
192
+ def initial_search_variant_test_records
193
+ {}.tap do |records|
194
+ records[:post_variant] = false if test_post_search?
195
+ records[:medication_inclusion] = false if test_medication_inclusion?
196
+ records[:reference_variants] = false if test_reference_variants?
197
+ records[:token_variants] = false if token_search_params.present?
198
+ records[:comparator_searches] = Set.new if params_with_comparators.present?
199
+ end
200
+ end
201
+
202
+ def all_search_variants_tested?
203
+ search_variant_test_records.all? { |_variant, tested| tested.present? } &&
204
+ all_comparator_searches_tested?
205
+ end
206
+
207
+ def all_comparator_searches_tested?
208
+ return true if params_with_comparators.blank?
209
+
210
+ Set.new(params_with_comparators) == search_variant_test_records[:comparator_searches]
211
+ end
212
+
213
+ def date_comparator_value(comparator, date)
214
+ date = date.start || date.end if date.is_a? FHIR::Period
215
+ case comparator
216
+ when 'lt', 'le'
217
+ comparator + (DateTime.xmlschema(date) + 1).xmlschema
218
+ when 'gt', 'ge'
219
+ comparator + (DateTime.xmlschema(date) - 1).xmlschema
220
+ else
221
+ # ''
222
+ raise "Unsupported comparator '#{comparator}'"
223
+ end
224
+ end
225
+
226
+ def required_comparators(name)
227
+ metadata
228
+ .search_definitions
229
+ .dig(name.to_sym, :comparators)
230
+ .select { |_comparator, expectation| expectation == 'SHALL' }
231
+ .keys
232
+ .map(&:to_s)
233
+ end
234
+
235
+ def perform_comparator_searches(params, patient_id)
236
+ params_with_comparators.each do |name|
237
+ next if search_variant_test_records[:comparator_searches].include? name
238
+
239
+ required_comparators(name).each do |comparator|
240
+ paths = search_param_paths(name).first
241
+ date_element = find_a_value_at(scratch_resources_for_patient(patient_id), paths)
242
+ params_with_comparator = params.merge(name => date_comparator_value(comparator, date_element))
243
+
244
+ search_and_check_response(params_with_comparator)
245
+
246
+ fetch_all_bundled_resources.each do |resource|
247
+ check_resource_against_params(resource, params_with_comparator) if resource.resourceType == resource_type
248
+ end
249
+ end
250
+
251
+ search_variant_test_records[:comparator_searches] << name
252
+ end
253
+ end
254
+
255
+ def perform_reference_with_type_search(params, resource_count)
256
+ return if resource_count == 0
257
+ return if search_variant_test_records[:reference_variants]
258
+
259
+ new_search_params = params.merge('patient' => "Patient/#{params['patient']}")
260
+ search_and_check_response(new_search_params)
261
+
262
+ reference_with_type_resources = fetch_all_bundled_resources.select { |resource| resource.resourceType == resource_type }
263
+
264
+ filter_conditions(reference_with_type_resources) if resource_type == 'Condition' && metadata.version == 'v5.0.1'
265
+ filter_devices(reference_with_type_resources) if resource_type == 'Device'
266
+
267
+ new_resource_count = reference_with_type_resources.count
268
+
269
+ assert new_resource_count == resource_count,
270
+ "Expected search by `#{params['patient']}` to to return the same results as searching " \
271
+ "by `#{new_search_params['patient']}`, but found #{resource_count} resources with " \
272
+ "`#{params['patient']}` and #{new_resource_count} with `#{new_search_params['patient']}`"
273
+
274
+ search_variant_test_records[:reference_variants] = true
275
+ end
276
+
277
+ def perform_search_with_system(params, patient_id)
278
+ return if search_variant_test_records[:token_variants]
279
+
280
+ new_search_params = search_params_with_values(token_search_params, patient_id, include_system: true)
281
+ return if new_search_params.any? { |_name, value| value.blank? }
282
+
283
+ search_params = params.merge(new_search_params)
284
+ search_and_check_response(search_params)
285
+
286
+ resources_returned =
287
+ fetch_all_bundled_resources
288
+ .select { |resource| resource.resourceType == resource_type }
289
+
290
+ assert resources_returned.present?, "No resources were returned when searching by `system|code`"
291
+
292
+ search_variant_test_records[:token_variants] = true
293
+ end
294
+
295
+ def perform_search_with_status(
296
+ original_params,
297
+ patient_id,
298
+ status_search_values: self.status_search_values,
299
+ resource_type: self.resource_type
300
+ )
301
+ assert resource.is_a?(FHIR::OperationOutcome), "Server returned a status of 400 without an OperationOutcome"
302
+ # TODO: warn about documenting status requirements
303
+ status_search_values.flat_map do |status_value|
304
+ search_params = original_params.merge("#{status_search_param_name}": status_value)
305
+
306
+ search_and_check_response(search_params)
307
+
308
+ entries = resource.entry.select { |entry| entry.resource.resourceType == resource_type }
309
+
310
+ if entries.present?
311
+ original_params.merge!("#{status_search_param_name}": status_value)
312
+ break
313
+ end
314
+ end
315
+ end
316
+
317
+ def status_search_param_name
318
+ @status_search_param_name ||=
319
+ metadata.search_definitions.keys.find { |key| key.to_s.include? 'status' }
320
+ end
321
+
322
+ def status_search_values
323
+ default_search_values(status_search_param_name)
324
+ end
325
+
326
+ def default_search_values(param_name)
327
+ definition = metadata.search_definitions[param_name]
328
+ return [] if definition.blank?
329
+
330
+ definition[:multiple_or] == 'SHALL' ? [definition[:values].join(',')] : Array.wrap(definition[:values])
331
+ end
332
+
333
+
334
+ def perform_multiple_or_search_test
335
+ resolved_one = false
336
+
337
+ all_search_params.each do |patient_id, params_list|
338
+ next unless params_list.present?
339
+
340
+ search_params = params_list.first
341
+ existing_values = {}
342
+ missing_values = {}
343
+
344
+ multiple_or_search_params.each do |param_name|
345
+ search_value = default_search_values(param_name.to_sym)
346
+ search_params = search_params.merge("#{param_name}" => search_value)
347
+ existing_values[param_name.to_sym] = scratch_resources_for_patient(patient_id).map(&param_name.to_sym).compact.uniq
348
+ end
349
+
350
+ # skip patient without multiple-or values
351
+ next if existing_values.values.any?(&:empty?)
352
+
353
+ resolved_one = true
354
+
355
+ search_and_check_response(search_params)
356
+
357
+ resources_returned =
358
+ fetch_all_bundled_resources
359
+ .select { |resource| resource.resourceType == resource_type }
360
+
361
+ multiple_or_search_params.each do |param_name|
362
+ missing_values[param_name.to_sym] = existing_values[param_name.to_sym] - resources_returned.map(&param_name.to_sym)
363
+ end
364
+
365
+ missing_value_message = missing_values
366
+ .reject { |_param_name, missing_value| missing_value.empty? }
367
+ .map { |param_name, missing_value| "#{missing_value.join(',')} values from #{param_name}" }
368
+ .join(' and ')
369
+
370
+ assert missing_value_message.blank?, "Could not find #{missing_value_message} in any of the resources returned for Patient/#{patient_id}"
371
+
372
+ break if resolved_one
373
+ end
374
+ end
375
+
376
+ def test_medication_inclusion(medication_requests, params, patient_id)
377
+ return if search_variant_test_records[:medication_inclusion]
378
+
379
+ scratch[:medication_resources] ||= {}
380
+ scratch[:medication_resources][:all] ||= []
381
+ scratch[:medication_resources][patient_id] ||= []
382
+ scratch[:medication_resources][:contained] ||= []
383
+
384
+ requests_with_external_references =
385
+ medication_requests
386
+ .select { |request| request&.medicationReference&.present? }
387
+ .reject { |request| request&.medicationReference&.reference&.start_with? '#' }
388
+
389
+ contained_medications =
390
+ medication_requests
391
+ .select { |request| request&.medicationReference&.reference&.start_with? '#' }
392
+ .flat_map(&:contained)
393
+ .select { |resource| resource.resourceType == 'Medication' }
394
+
395
+ scratch[:medication_resources][:all] += contained_medications
396
+ scratch[:medication_resources][patient_id] += contained_medications
397
+ scratch[:medication_resources][:contained] += contained_medications
398
+
399
+ return if requests_with_external_references.blank?
400
+
401
+ search_params = params.merge(_include: 'MedicationRequest:medication')
402
+
403
+ search_and_check_response(search_params)
404
+
405
+ medications = fetch_all_bundled_resources.select { |resource| resource.resourceType == 'Medication' }
406
+ assert medications.present?, 'No Medications were included in the search results'
407
+
408
+ medications.uniq!(&:id)
409
+
410
+ scratch[:medication_resources][:all] += medications
411
+ scratch[:medication_resources][patient_id] += medications
412
+
413
+ search_variant_test_records[:medication_inclusion] = true
414
+ end
415
+
416
+ def all_scratch_resources
417
+ scratch_resources[:all] ||= []
418
+ end
419
+
420
+ def scratch_resources_for_patient(patient_id)
421
+ return all_scratch_resources if patient_id.nil?
422
+
423
+ scratch_resources[patient_id] ||= []
424
+ end
425
+
426
+ def references_to_save(resource_type = nil)
427
+ reference_metadata = resource_type == 'Provenance' ? provenance_metadata : metadata
428
+ reference_metadata.delayed_references
429
+ end
430
+
431
+ def fixed_value_search_param_name
432
+ (search_param_names - ['patient']).first
433
+ end
434
+
435
+ def fixed_value_search_param_values
436
+ metadata.search_definitions[fixed_value_search_param_name.to_sym][:values]
437
+ end
438
+
439
+ def fixed_value_search_params(value, patient_id)
440
+ search_param_names.each_with_object({}) do |name, params|
441
+ patient_id_param?(name) ? params[name] = patient_id : params[name] = value
442
+ end
443
+ end
444
+
445
+ def search_params_with_values(search_param_names, patient_id, include_system: false)
446
+ resources = scratch_resources_for_patient(patient_id)
447
+
448
+ #if resources.empty?
449
+ #return search_param_names.each_with_object({}) do |name, params|
450
+ #value = patient_id_param?(name) ? patient_id : nil
451
+ #params[name] = value
452
+ # end
453
+ #end
454
+
455
+ params_with_partial_value = resources.each_with_object({}) do |resource, outer_params|
456
+ results_from_one_resource = search_param_names.each_with_object({}) do |name, params|
457
+ value = patient_id_param?(name) ? patient_id : search_param_value(name, resource, include_system: include_system)
458
+ params[name] = value
459
+ end
460
+
461
+ outer_params.merge!(results_from_one_resource)
462
+
463
+ # stop if all parameter values are found
464
+ return outer_params if outer_params.all? { |_key, value| value.present? }
465
+ end
466
+
467
+ params_with_partial_value
468
+ end
469
+
470
+ def patient_id_list
471
+ return [nil] unless respond_to? :patient_ids
472
+
473
+ patient_ids.split(',').map(&:strip)
474
+ end
475
+
476
+ def patient_search?
477
+ search_param_names.any? { |name| patient_id_param? name }
478
+ end
479
+
480
+ def patient_id_param?(name)
481
+ name == 'patient' || (name == '_id' && resource_type == 'Patient')
482
+ end
483
+
484
+ def search_param_paths(name)
485
+ paths = metadata.search_definitions[name.to_sym][:paths]
486
+ if paths.first =='class'
487
+ paths[0] = 'local_class'
488
+ end
489
+
490
+ paths
491
+ end
492
+
493
+ def all_search_params_present?(params)
494
+ params.all? { |_name, value| value.present? }
495
+ end
496
+
497
+ def array_of_codes(array)
498
+ array.map { |name| "`#{name}`" }.join(', ')
499
+ end
500
+
501
+ def unable_to_resolve_params_message
502
+ "Could not find values for all search params #{array_of_codes(search_param_names)}"
503
+ end
504
+
505
+ def empty_search_params_message(empty_search_params)
506
+ "Could not find values for the search parameters #{array_of_codes(empty_search_params.keys)}"
507
+ end
508
+
509
+ def no_resources_skip_message(resource_type = self.resource_type)
510
+ msg = "No #{resource_type} resources appear to be available"
511
+
512
+ if (resource_type == 'Device' && implantable_device_codes.present?)
513
+ msg.concat(" with the following Device Type Code filter: #{implantable_device_codes}")
514
+ end
515
+
516
+ msg + ". Please use patients with more information"
517
+ end
518
+
519
+ def fetch_all_bundled_resources(
520
+ reply_handler: nil,
521
+ max_pages: 20,
522
+ additional_resource_types: [],
523
+ resource_type: self.resource_type
524
+ )
525
+ page_count = 1
526
+ resources = []
527
+ bundle = resource
528
+
529
+ until bundle.nil? || page_count == max_pages
530
+ resources += bundle&.entry&.map { |entry| entry&.resource }
531
+ next_bundle_link = bundle&.link&.find { |link| link.relation == 'next' }&.url
532
+ reply_handler&.call(response)
533
+
534
+ break if next_bundle_link.blank?
535
+
536
+ reply = fhir_client.raw_read_url(next_bundle_link)
537
+
538
+ store_request('outgoing') { reply }
539
+ error_message = cant_resolve_next_bundle_message(next_bundle_link)
540
+
541
+ assert_response_status(200)
542
+ assert_valid_json(reply.body, error_message)
543
+
544
+ bundle = fhir_client.parse_reply(FHIR::Bundle, fhir_client.default_format, reply)
545
+
546
+ page_count += 1
547
+ end
548
+
549
+ valid_resource_types = [resource_type, 'OperationOutcome'].concat(additional_resource_types)
550
+ valid_resource_types << 'Medication' if resource_type == 'MedicationRequest'
551
+
552
+ invalid_resource_types =
553
+ resources.reject { |entry| valid_resource_types.include? entry.resourceType }
554
+ .map(&:resourceType)
555
+ .uniq
556
+
557
+ if invalid_resource_types.any?
558
+ info "Received resource type(s) #{invalid_resource_types.join(', ')} in search bundle, " \
559
+ "but only expected resource types #{valid_resource_types.join(', ')}. " + \
560
+ "This is unusual but allowed if the server believes additional resource types are relevant."
561
+ end
562
+
563
+ resources
564
+ end
565
+
566
+ def cant_resolve_next_bundle_message(link)
567
+ "Could not resolve next bundle: #{link}"
568
+ end
569
+
570
+ def search_param_value(name, resource, include_system: false)
571
+ paths = search_param_paths(name)
572
+ search_value = nil
573
+ paths.each do |path|
574
+ element = find_a_value_at(resource, path) { |element| element_has_valid_value?(element, include_system) }
575
+
576
+ search_value =
577
+ case element
578
+ when FHIR::Period
579
+ if element.start.present?
580
+ 'gt' + (DateTime.xmlschema(element.start) - 1).xmlschema
581
+ else
582
+ end_datetime = get_fhir_datetime_range(element.end)[:end]
583
+ 'lt' + (end_datetime + 1).xmlschema
584
+ end
585
+ when FHIR::Reference
586
+ element.reference
587
+ when FHIR::CodeableConcept
588
+ if include_system
589
+ coding =
590
+ find_a_value_at(element, 'coding') { |coding| coding.code.present? && coding.system.present? }
591
+ "#{coding.system}|#{coding.code}"
592
+ else
593
+ find_a_value_at(element, 'coding.code')
594
+ end
595
+ when FHIR::Identifier
596
+ include_system ? "#{element.system}|#{element.value}" : element.value
597
+ when FHIR::Coding
598
+ include_system ? "#{element.system}|#{element.code}" : element.code
599
+ when FHIR::HumanName
600
+ element.family || element.given&.first || element.text
601
+ when FHIR::Address
602
+ element.text || element.city || element.state || element.postalCode || element.country
603
+ else
604
+ if metadata.version != 'v3.1.1' &&
605
+ metadata.search_definitions[name.to_sym][:type] == 'date' &&
606
+ params_with_comparators&.include?(name)
607
+ # convert date search to greath-than comparator search with correct precision
608
+ # For all date search parameters:
609
+ # Patient.birthDate does not mandate comparators so cannot be converted
610
+ # Goal.target-date has day precision
611
+ # All others have second + time offset precision
612
+ if /^\d{4}(-\d{2})?$/.match?(element) || # YYYY or YYYY-MM
613
+ (/^\d{4}-\d{2}-\d{2}$/.match?(element) && resource_type != "Goal") # YYY-MM-DD AND Resource is NOT Goal
614
+ "gt#{(DateTime.xmlschema(element)-1).xmlschema}"
615
+ else
616
+ element
617
+ end
618
+ else
619
+ element
620
+ end
621
+ end
622
+
623
+ break if search_value.present?
624
+ end
625
+
626
+ escaped_value = search_value&.gsub(',', '\\,')
627
+ escaped_value
628
+ end
629
+
630
+ def element_has_valid_value?(element, include_system)
631
+ case element
632
+ when FHIR::Reference
633
+ element.reference.present?
634
+ when FHIR::CodeableConcept
635
+ if include_system
636
+ coding =
637
+ find_a_value_at(element, 'coding') { |coding| coding.code.present? && coding.system.present? }
638
+ coding.present?
639
+ else
640
+ find_a_value_at(element, 'coding.code').present?
641
+ end
642
+ when FHIR::Identifier
643
+ include_system ? element.value.present? && element.system.present? : element.value.present?
644
+ when FHIR::Coding
645
+ include_system ? element.code.present? && element.system.present? : element.code.present?
646
+ when FHIR::HumanName
647
+ (element.family || element.given&.first || element.text).present?
648
+ when FHIR::Address
649
+ (element.text || element.city || element.state || element.postalCode || element.country).present?
650
+ else
651
+ true
652
+ end
653
+ end
654
+
655
+ def save_resource_reference(resource_type, reference)
656
+ scratch[:references] ||= {}
657
+ scratch[:references][resource_type] ||= Set.new
658
+ scratch[:references][resource_type] << reference
659
+ end
660
+
661
+ def save_delayed_references(resources, containing_resource_type = self.resource_type)
662
+ resources.each do |resource|
663
+ references_to_save(containing_resource_type).each do |reference_to_save|
664
+ resolve_path(resource, reference_to_save[:path])
665
+ .select { |reference| reference.is_a?(FHIR::Reference) && !reference.contained? }
666
+ .each do |reference|
667
+ resource_type = reference.resource_class.name.demodulize
668
+ need_to_save = reference_to_save[:resources].include?(resource_type)
669
+ next unless need_to_save
670
+
671
+ save_resource_reference(resource_type, reference)
672
+ end
673
+ end
674
+ end
675
+ end
676
+
677
+ #### RESULT CHECKING ####
678
+
679
+ def check_resource_against_params(resource, params)
680
+ params.each do |name, escaped_search_value|
681
+ #unescape search value
682
+ search_value = escaped_search_value&.gsub('\\,', ',')
683
+ paths = search_param_paths(name)
684
+
685
+ match_found = false
686
+ values_found = []
687
+
688
+ paths.each do |path|
689
+ type = metadata.search_definitions[name.to_sym][:type]
690
+ values_found =
691
+ resolve_path(resource, path)
692
+ .map do |value|
693
+ if value.is_a? FHIR::Reference
694
+ value.reference
695
+ else
696
+ value
697
+ end
698
+ end
699
+
700
+ match_found =
701
+ case type
702
+ when 'Period', 'date', 'instant', 'dateTime'
703
+ values_found.any? { |date| validate_date_search(search_value, date) }
704
+ when 'HumanName'
705
+ # When a string search parameter refers to the types HumanName and Address,
706
+ # the search covers the elements of type string, and does not cover elements such as use and period
707
+ # https://www.hl7.org/fhir/search.html#string
708
+ search_value_downcase = search_value.downcase
709
+ values_found.any? do |name|
710
+ name&.text&.downcase&.start_with?(search_value_downcase) ||
711
+ name&.family&.downcase&.start_with?(search_value_downcase) ||
712
+ name&.given&.any? { |given| given.downcase.start_with?(search_value_downcase) } ||
713
+ name&.prefix&.any? { |prefix| prefix.downcase.start_with?(search_value_downcase) } ||
714
+ name&.suffix&.any? { |suffix| suffix.downcase.start_with?(search_value_downcase) }
715
+ end
716
+ when 'Address'
717
+ search_value_downcase = search_value.downcase
718
+ values_found.any? do |address|
719
+ address&.text&.downcase&.start_with?(search_value_downcase) ||
720
+ address&.city&.downcase&.start_with?(search_value_downcase) ||
721
+ address&.state&.downcase&.start_with?(search_value_downcase) ||
722
+ address&.postalCode&.downcase&.start_with?(search_value_downcase) ||
723
+ address&.country&.downcase&.start_with?(search_value_downcase)
724
+ end
725
+ when 'CodeableConcept'
726
+ # FHIR token search (https://www.hl7.org/fhir/search.html#token): "When in doubt, servers SHOULD
727
+ # treat tokens in a case-insensitive manner, on the grounds that including undesired data has
728
+ # less safety implications than excluding desired behavior".
729
+ codings = values_found.flat_map(&:coding)
730
+ if search_value.include? '|'
731
+ system = search_value.split('|').first
732
+ code = search_value.split('|').last
733
+ codings&.any? { |coding| coding.system == system && coding.code&.casecmp?(code) }
734
+ else
735
+ codings&.any? { |coding| coding.code&.casecmp?(search_value) }
736
+ end
737
+ when 'Coding'
738
+ if search_value.include? '|'
739
+ system = search_value.split('|').first
740
+ code = search_value.split('|').last
741
+ values_found.any? { |coding| coding.system == system && coding.code&.casecmp?(code) }
742
+ else
743
+ values_found.any? { |coding| coding.code&.casecmp?(search_value) }
744
+ end
745
+ when 'Identifier'
746
+ if search_value.include? '|'
747
+ values_found.any? { |identifier| "#{identifier.system}|#{identifier.value}" == search_value }
748
+ else
749
+ values_found.any? { |identifier| identifier.value == search_value }
750
+ end
751
+ when 'string'
752
+ searched_values = search_value.downcase.split(/(?<!\\\\),/).map{ |string| string.gsub('\\,', ',') }
753
+ values_found.any? do |value_found|
754
+ searched_values.any? { |searched_value| value_found.downcase.starts_with? searched_value }
755
+ end
756
+ else
757
+ # searching by patient requires special case because we are searching by a resource identifier
758
+ # references can also be URLs, so we may need to resolve those URLs
759
+ if ['subject', 'patient'].include? name.to_s
760
+ id = search_value.split('Patient/').last
761
+ possible_values = [id, "Patient/#{id}", "#{url}/Patient/#{id}"]
762
+ values_found.any? do |reference|
763
+ possible_values.include? reference
764
+ end
765
+ else
766
+ search_values = search_value.split(/(?<!\\\\),/).map { |string| string.gsub('\\,', ',') }
767
+ values_found.any? { |value_found| search_values.include? value_found }
768
+ end
769
+ end
770
+
771
+ break if match_found
772
+ end
773
+
774
+ assert match_found,
775
+ "#{resource_type}/#{resource.id} did not match the search parameters:\n" \
776
+ "* Expected: #{search_value}\n" \
777
+ "* Found: #{values_found.map(&:inspect).join(', ')}"
778
+ end
779
+ end
780
+ end
781
+ end