us_core_test_kit 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (350) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +201 -0
  3. data/lib/us_core_test_kit/custom_groups/capability_statement/conformance_support_test.rb +41 -0
  4. data/lib/us_core_test_kit/custom_groups/capability_statement/fhir_version_test.rb +15 -0
  5. data/lib/us_core_test_kit/custom_groups/capability_statement/json_support_test.rb +40 -0
  6. data/lib/us_core_test_kit/custom_groups/capability_statement/profile_support_test.rb +90 -0
  7. data/lib/us_core_test_kit/custom_groups/capability_statement_group.rb +64 -0
  8. data/lib/us_core_test_kit/custom_groups/clinical_notes_guidance_group.rb +208 -0
  9. data/lib/us_core_test_kit/custom_groups/data_absent_reason_group.rb +59 -0
  10. data/lib/us_core_test_kit/date_search_validation.rb +101 -0
  11. data/lib/us_core_test_kit/ext/fhir_models.rb +59 -0
  12. data/lib/us_core_test_kit/fhir_resource_navigation.rb +63 -0
  13. data/lib/us_core_test_kit/generated/allergy_intolerance/allergy_intolerance_must_support_test.rb +40 -0
  14. data/lib/us_core_test_kit/generated/allergy_intolerance/allergy_intolerance_patient_clinical_status_search_test.rb +46 -0
  15. data/lib/us_core_test_kit/generated/allergy_intolerance/allergy_intolerance_patient_search_test.rb +60 -0
  16. data/lib/us_core_test_kit/generated/allergy_intolerance/allergy_intolerance_provenance_revinclude_search_test.rb +49 -0
  17. data/lib/us_core_test_kit/generated/allergy_intolerance/allergy_intolerance_read_test.rb +24 -0
  18. data/lib/us_core_test_kit/generated/allergy_intolerance/allergy_intolerance_reference_resolution_test.rb +28 -0
  19. data/lib/us_core_test_kit/generated/allergy_intolerance/allergy_intolerance_validation_test.rb +34 -0
  20. data/lib/us_core_test_kit/generated/allergy_intolerance_group.rb +85 -0
  21. data/lib/us_core_test_kit/generated/bodyheight/bodyheight_must_support_test.rb +49 -0
  22. data/lib/us_core_test_kit/generated/bodyheight/bodyheight_patient_category_date_search_test.rb +46 -0
  23. data/lib/us_core_test_kit/generated/bodyheight/bodyheight_patient_category_search_test.rb +45 -0
  24. data/lib/us_core_test_kit/generated/bodyheight/bodyheight_patient_category_status_search_test.rb +47 -0
  25. data/lib/us_core_test_kit/generated/bodyheight/bodyheight_patient_code_date_search_test.rb +48 -0
  26. data/lib/us_core_test_kit/generated/bodyheight/bodyheight_patient_code_search_test.rb +62 -0
  27. data/lib/us_core_test_kit/generated/bodyheight/bodyheight_provenance_revinclude_search_test.rb +51 -0
  28. data/lib/us_core_test_kit/generated/bodyheight/bodyheight_read_test.rb +24 -0
  29. data/lib/us_core_test_kit/generated/bodyheight/bodyheight_reference_resolution_test.rb +28 -0
  30. data/lib/us_core_test_kit/generated/bodyheight/bodyheight_validation_test.rb +34 -0
  31. data/lib/us_core_test_kit/generated/bodyheight_group.rb +93 -0
  32. data/lib/us_core_test_kit/generated/bodytemp/bodytemp_must_support_test.rb +49 -0
  33. data/lib/us_core_test_kit/generated/bodytemp/bodytemp_patient_category_date_search_test.rb +46 -0
  34. data/lib/us_core_test_kit/generated/bodytemp/bodytemp_patient_category_search_test.rb +45 -0
  35. data/lib/us_core_test_kit/generated/bodytemp/bodytemp_patient_category_status_search_test.rb +47 -0
  36. data/lib/us_core_test_kit/generated/bodytemp/bodytemp_patient_code_date_search_test.rb +48 -0
  37. data/lib/us_core_test_kit/generated/bodytemp/bodytemp_patient_code_search_test.rb +62 -0
  38. data/lib/us_core_test_kit/generated/bodytemp/bodytemp_provenance_revinclude_search_test.rb +51 -0
  39. data/lib/us_core_test_kit/generated/bodytemp/bodytemp_read_test.rb +24 -0
  40. data/lib/us_core_test_kit/generated/bodytemp/bodytemp_reference_resolution_test.rb +28 -0
  41. data/lib/us_core_test_kit/generated/bodytemp/bodytemp_validation_test.rb +34 -0
  42. data/lib/us_core_test_kit/generated/bodytemp_group.rb +93 -0
  43. data/lib/us_core_test_kit/generated/bodyweight/bodyweight_must_support_test.rb +49 -0
  44. data/lib/us_core_test_kit/generated/bodyweight/bodyweight_patient_category_date_search_test.rb +46 -0
  45. data/lib/us_core_test_kit/generated/bodyweight/bodyweight_patient_category_search_test.rb +45 -0
  46. data/lib/us_core_test_kit/generated/bodyweight/bodyweight_patient_category_status_search_test.rb +47 -0
  47. data/lib/us_core_test_kit/generated/bodyweight/bodyweight_patient_code_date_search_test.rb +48 -0
  48. data/lib/us_core_test_kit/generated/bodyweight/bodyweight_patient_code_search_test.rb +62 -0
  49. data/lib/us_core_test_kit/generated/bodyweight/bodyweight_provenance_revinclude_search_test.rb +51 -0
  50. data/lib/us_core_test_kit/generated/bodyweight/bodyweight_read_test.rb +24 -0
  51. data/lib/us_core_test_kit/generated/bodyweight/bodyweight_reference_resolution_test.rb +28 -0
  52. data/lib/us_core_test_kit/generated/bodyweight/bodyweight_validation_test.rb +34 -0
  53. data/lib/us_core_test_kit/generated/bodyweight_group.rb +93 -0
  54. data/lib/us_core_test_kit/generated/bp/bp_must_support_test.rb +52 -0
  55. data/lib/us_core_test_kit/generated/bp/bp_patient_category_date_search_test.rb +46 -0
  56. data/lib/us_core_test_kit/generated/bp/bp_patient_category_search_test.rb +45 -0
  57. data/lib/us_core_test_kit/generated/bp/bp_patient_category_status_search_test.rb +47 -0
  58. data/lib/us_core_test_kit/generated/bp/bp_patient_code_date_search_test.rb +48 -0
  59. data/lib/us_core_test_kit/generated/bp/bp_patient_code_search_test.rb +62 -0
  60. data/lib/us_core_test_kit/generated/bp/bp_provenance_revinclude_search_test.rb +51 -0
  61. data/lib/us_core_test_kit/generated/bp/bp_read_test.rb +24 -0
  62. data/lib/us_core_test_kit/generated/bp/bp_reference_resolution_test.rb +28 -0
  63. data/lib/us_core_test_kit/generated/bp/bp_validation_test.rb +34 -0
  64. data/lib/us_core_test_kit/generated/bp_group.rb +93 -0
  65. data/lib/us_core_test_kit/generated/care_plan/care_plan_must_support_test.rb +41 -0
  66. data/lib/us_core_test_kit/generated/care_plan/care_plan_patient_category_date_search_test.rb +48 -0
  67. data/lib/us_core_test_kit/generated/care_plan/care_plan_patient_category_search_test.rb +62 -0
  68. data/lib/us_core_test_kit/generated/care_plan/care_plan_patient_category_status_date_search_test.rb +48 -0
  69. data/lib/us_core_test_kit/generated/care_plan/care_plan_patient_category_status_search_test.rb +47 -0
  70. data/lib/us_core_test_kit/generated/care_plan/care_plan_provenance_revinclude_search_test.rb +51 -0
  71. data/lib/us_core_test_kit/generated/care_plan/care_plan_read_test.rb +24 -0
  72. data/lib/us_core_test_kit/generated/care_plan/care_plan_reference_resolution_test.rb +28 -0
  73. data/lib/us_core_test_kit/generated/care_plan/care_plan_validation_test.rb +34 -0
  74. data/lib/us_core_test_kit/generated/care_plan_group.rb +89 -0
  75. data/lib/us_core_test_kit/generated/care_team/care_team_must_support_test.rb +39 -0
  76. data/lib/us_core_test_kit/generated/care_team/care_team_patient_status_search_test.rb +62 -0
  77. data/lib/us_core_test_kit/generated/care_team/care_team_provenance_revinclude_search_test.rb +50 -0
  78. data/lib/us_core_test_kit/generated/care_team/care_team_read_test.rb +24 -0
  79. data/lib/us_core_test_kit/generated/care_team/care_team_reference_resolution_test.rb +28 -0
  80. data/lib/us_core_test_kit/generated/care_team/care_team_validation_test.rb +34 -0
  81. data/lib/us_core_test_kit/generated/care_team_group.rb +83 -0
  82. data/lib/us_core_test_kit/generated/condition/condition_must_support_test.rb +39 -0
  83. data/lib/us_core_test_kit/generated/condition/condition_patient_category_search_test.rb +47 -0
  84. data/lib/us_core_test_kit/generated/condition/condition_patient_clinical_status_search_test.rb +46 -0
  85. data/lib/us_core_test_kit/generated/condition/condition_patient_code_search_test.rb +47 -0
  86. data/lib/us_core_test_kit/generated/condition/condition_patient_onset_date_search_test.rb +47 -0
  87. data/lib/us_core_test_kit/generated/condition/condition_patient_search_test.rb +60 -0
  88. data/lib/us_core_test_kit/generated/condition/condition_provenance_revinclude_search_test.rb +49 -0
  89. data/lib/us_core_test_kit/generated/condition/condition_read_test.rb +24 -0
  90. data/lib/us_core_test_kit/generated/condition/condition_reference_resolution_test.rb +28 -0
  91. data/lib/us_core_test_kit/generated/condition/condition_validation_test.rb +34 -0
  92. data/lib/us_core_test_kit/generated/condition_group.rb +91 -0
  93. data/lib/us_core_test_kit/generated/device/device_must_support_test.rb +43 -0
  94. data/lib/us_core_test_kit/generated/device/device_patient_search_test.rb +65 -0
  95. data/lib/us_core_test_kit/generated/device/device_patient_type_search_test.rb +52 -0
  96. data/lib/us_core_test_kit/generated/device/device_provenance_revinclude_search_test.rb +49 -0
  97. data/lib/us_core_test_kit/generated/device/device_read_test.rb +24 -0
  98. data/lib/us_core_test_kit/generated/device/device_reference_resolution_test.rb +28 -0
  99. data/lib/us_core_test_kit/generated/device/device_validation_test.rb +34 -0
  100. data/lib/us_core_test_kit/generated/device_group.rb +85 -0
  101. data/lib/us_core_test_kit/generated/diagnostic_report_lab/diagnostic_report_lab_must_support_test.rb +43 -0
  102. data/lib/us_core_test_kit/generated/diagnostic_report_lab/diagnostic_report_lab_patient_category_date_search_test.rb +46 -0
  103. data/lib/us_core_test_kit/generated/diagnostic_report_lab/diagnostic_report_lab_patient_category_search_test.rb +63 -0
  104. data/lib/us_core_test_kit/generated/diagnostic_report_lab/diagnostic_report_lab_patient_code_date_search_test.rb +48 -0
  105. data/lib/us_core_test_kit/generated/diagnostic_report_lab/diagnostic_report_lab_patient_code_search_test.rb +45 -0
  106. data/lib/us_core_test_kit/generated/diagnostic_report_lab/diagnostic_report_lab_patient_search_test.rb +44 -0
  107. data/lib/us_core_test_kit/generated/diagnostic_report_lab/diagnostic_report_lab_patient_status_search_test.rb +46 -0
  108. data/lib/us_core_test_kit/generated/diagnostic_report_lab/diagnostic_report_lab_provenance_revinclude_search_test.rb +51 -0
  109. data/lib/us_core_test_kit/generated/diagnostic_report_lab/diagnostic_report_lab_read_test.rb +24 -0
  110. data/lib/us_core_test_kit/generated/diagnostic_report_lab/diagnostic_report_lab_reference_resolution_test.rb +28 -0
  111. data/lib/us_core_test_kit/generated/diagnostic_report_lab/diagnostic_report_lab_validation_test.rb +34 -0
  112. data/lib/us_core_test_kit/generated/diagnostic_report_lab_group.rb +96 -0
  113. data/lib/us_core_test_kit/generated/diagnostic_report_note/diagnostic_report_note_must_support_test.rb +43 -0
  114. data/lib/us_core_test_kit/generated/diagnostic_report_note/diagnostic_report_note_patient_category_date_search_test.rb +46 -0
  115. data/lib/us_core_test_kit/generated/diagnostic_report_note/diagnostic_report_note_patient_category_search_test.rb +63 -0
  116. data/lib/us_core_test_kit/generated/diagnostic_report_note/diagnostic_report_note_patient_code_date_search_test.rb +48 -0
  117. data/lib/us_core_test_kit/generated/diagnostic_report_note/diagnostic_report_note_patient_code_search_test.rb +45 -0
  118. data/lib/us_core_test_kit/generated/diagnostic_report_note/diagnostic_report_note_patient_search_test.rb +44 -0
  119. data/lib/us_core_test_kit/generated/diagnostic_report_note/diagnostic_report_note_patient_status_search_test.rb +46 -0
  120. data/lib/us_core_test_kit/generated/diagnostic_report_note/diagnostic_report_note_provenance_revinclude_search_test.rb +51 -0
  121. data/lib/us_core_test_kit/generated/diagnostic_report_note/diagnostic_report_note_read_test.rb +24 -0
  122. data/lib/us_core_test_kit/generated/diagnostic_report_note/diagnostic_report_note_reference_resolution_test.rb +28 -0
  123. data/lib/us_core_test_kit/generated/diagnostic_report_note/diagnostic_report_note_validation_test.rb +34 -0
  124. data/lib/us_core_test_kit/generated/diagnostic_report_note_group.rb +96 -0
  125. data/lib/us_core_test_kit/generated/document_reference/document_reference_id_search_test.rb +40 -0
  126. data/lib/us_core_test_kit/generated/document_reference/document_reference_must_support_test.rb +49 -0
  127. data/lib/us_core_test_kit/generated/document_reference/document_reference_patient_category_date_search_test.rb +46 -0
  128. data/lib/us_core_test_kit/generated/document_reference/document_reference_patient_category_search_test.rb +45 -0
  129. data/lib/us_core_test_kit/generated/document_reference/document_reference_patient_search_test.rb +61 -0
  130. data/lib/us_core_test_kit/generated/document_reference/document_reference_patient_status_search_test.rb +46 -0
  131. data/lib/us_core_test_kit/generated/document_reference/document_reference_patient_type_period_search_test.rb +48 -0
  132. data/lib/us_core_test_kit/generated/document_reference/document_reference_patient_type_search_test.rb +45 -0
  133. data/lib/us_core_test_kit/generated/document_reference/document_reference_provenance_revinclude_search_test.rb +50 -0
  134. data/lib/us_core_test_kit/generated/document_reference/document_reference_read_test.rb +24 -0
  135. data/lib/us_core_test_kit/generated/document_reference/document_reference_reference_resolution_test.rb +28 -0
  136. data/lib/us_core_test_kit/generated/document_reference/document_reference_validation_test.rb +34 -0
  137. data/lib/us_core_test_kit/generated/document_reference_group.rb +99 -0
  138. data/lib/us_core_test_kit/generated/encounter/encounter_class_patient_search_test.rb +47 -0
  139. data/lib/us_core_test_kit/generated/encounter/encounter_date_patient_search_test.rb +45 -0
  140. data/lib/us_core_test_kit/generated/encounter/encounter_id_search_test.rb +40 -0
  141. data/lib/us_core_test_kit/generated/encounter/encounter_identifier_search_test.rb +43 -0
  142. data/lib/us_core_test_kit/generated/encounter/encounter_must_support_test.rb +51 -0
  143. data/lib/us_core_test_kit/generated/encounter/encounter_patient_search_test.rb +61 -0
  144. data/lib/us_core_test_kit/generated/encounter/encounter_patient_status_search_test.rb +45 -0
  145. data/lib/us_core_test_kit/generated/encounter/encounter_patient_type_search_test.rb +47 -0
  146. data/lib/us_core_test_kit/generated/encounter/encounter_provenance_revinclude_search_test.rb +50 -0
  147. data/lib/us_core_test_kit/generated/encounter/encounter_read_test.rb +24 -0
  148. data/lib/us_core_test_kit/generated/encounter/encounter_reference_resolution_test.rb +28 -0
  149. data/lib/us_core_test_kit/generated/encounter/encounter_validation_test.rb +34 -0
  150. data/lib/us_core_test_kit/generated/encounter_group.rb +97 -0
  151. data/lib/us_core_test_kit/generated/goal/goal_must_support_test.rb +39 -0
  152. data/lib/us_core_test_kit/generated/goal/goal_patient_lifecycle_status_search_test.rb +45 -0
  153. data/lib/us_core_test_kit/generated/goal/goal_patient_search_test.rb +60 -0
  154. data/lib/us_core_test_kit/generated/goal/goal_patient_target_date_search_test.rb +47 -0
  155. data/lib/us_core_test_kit/generated/goal/goal_provenance_revinclude_search_test.rb +49 -0
  156. data/lib/us_core_test_kit/generated/goal/goal_read_test.rb +24 -0
  157. data/lib/us_core_test_kit/generated/goal/goal_reference_resolution_test.rb +28 -0
  158. data/lib/us_core_test_kit/generated/goal/goal_validation_test.rb +34 -0
  159. data/lib/us_core_test_kit/generated/goal_group.rb +87 -0
  160. data/lib/us_core_test_kit/generated/head_circumference/head_circumference_must_support_test.rb +49 -0
  161. data/lib/us_core_test_kit/generated/head_circumference/head_circumference_patient_category_date_search_test.rb +46 -0
  162. data/lib/us_core_test_kit/generated/head_circumference/head_circumference_patient_category_search_test.rb +45 -0
  163. data/lib/us_core_test_kit/generated/head_circumference/head_circumference_patient_category_status_search_test.rb +47 -0
  164. data/lib/us_core_test_kit/generated/head_circumference/head_circumference_patient_code_date_search_test.rb +48 -0
  165. data/lib/us_core_test_kit/generated/head_circumference/head_circumference_patient_code_search_test.rb +62 -0
  166. data/lib/us_core_test_kit/generated/head_circumference/head_circumference_provenance_revinclude_search_test.rb +51 -0
  167. data/lib/us_core_test_kit/generated/head_circumference/head_circumference_read_test.rb +24 -0
  168. data/lib/us_core_test_kit/generated/head_circumference/head_circumference_reference_resolution_test.rb +28 -0
  169. data/lib/us_core_test_kit/generated/head_circumference/head_circumference_validation_test.rb +34 -0
  170. data/lib/us_core_test_kit/generated/head_circumference_group.rb +93 -0
  171. data/lib/us_core_test_kit/generated/heartrate/heartrate_must_support_test.rb +49 -0
  172. data/lib/us_core_test_kit/generated/heartrate/heartrate_patient_category_date_search_test.rb +46 -0
  173. data/lib/us_core_test_kit/generated/heartrate/heartrate_patient_category_search_test.rb +45 -0
  174. data/lib/us_core_test_kit/generated/heartrate/heartrate_patient_category_status_search_test.rb +47 -0
  175. data/lib/us_core_test_kit/generated/heartrate/heartrate_patient_code_date_search_test.rb +48 -0
  176. data/lib/us_core_test_kit/generated/heartrate/heartrate_patient_code_search_test.rb +62 -0
  177. data/lib/us_core_test_kit/generated/heartrate/heartrate_provenance_revinclude_search_test.rb +51 -0
  178. data/lib/us_core_test_kit/generated/heartrate/heartrate_read_test.rb +24 -0
  179. data/lib/us_core_test_kit/generated/heartrate/heartrate_reference_resolution_test.rb +28 -0
  180. data/lib/us_core_test_kit/generated/heartrate/heartrate_validation_test.rb +34 -0
  181. data/lib/us_core_test_kit/generated/heartrate_group.rb +93 -0
  182. data/lib/us_core_test_kit/generated/immunization/immunization_must_support_test.rb +40 -0
  183. data/lib/us_core_test_kit/generated/immunization/immunization_patient_date_search_test.rb +47 -0
  184. data/lib/us_core_test_kit/generated/immunization/immunization_patient_search_test.rb +60 -0
  185. data/lib/us_core_test_kit/generated/immunization/immunization_patient_status_search_test.rb +45 -0
  186. data/lib/us_core_test_kit/generated/immunization/immunization_provenance_revinclude_search_test.rb +50 -0
  187. data/lib/us_core_test_kit/generated/immunization/immunization_read_test.rb +24 -0
  188. data/lib/us_core_test_kit/generated/immunization/immunization_reference_resolution_test.rb +28 -0
  189. data/lib/us_core_test_kit/generated/immunization/immunization_validation_test.rb +34 -0
  190. data/lib/us_core_test_kit/generated/immunization_group.rb +87 -0
  191. data/lib/us_core_test_kit/generated/medication_request/medication_request_must_support_test.rb +44 -0
  192. data/lib/us_core_test_kit/generated/medication_request/medication_request_patient_intent_authoredon_search_test.rb +53 -0
  193. data/lib/us_core_test_kit/generated/medication_request/medication_request_patient_intent_encounter_search_test.rb +52 -0
  194. data/lib/us_core_test_kit/generated/medication_request/medication_request_patient_intent_search_test.rb +68 -0
  195. data/lib/us_core_test_kit/generated/medication_request/medication_request_patient_intent_status_search_test.rb +49 -0
  196. data/lib/us_core_test_kit/generated/medication_request/medication_request_provenance_revinclude_search_test.rb +51 -0
  197. data/lib/us_core_test_kit/generated/medication_request/medication_request_read_test.rb +24 -0
  198. data/lib/us_core_test_kit/generated/medication_request/medication_request_reference_resolution_test.rb +28 -0
  199. data/lib/us_core_test_kit/generated/medication_request/medication_request_validation_test.rb +34 -0
  200. data/lib/us_core_test_kit/generated/medication_request/medication_validation_test.rb +34 -0
  201. data/lib/us_core_test_kit/generated/medication_request_group.rb +92 -0
  202. data/lib/us_core_test_kit/generated/observation_lab/observation_lab_must_support_test.rb +41 -0
  203. data/lib/us_core_test_kit/generated/observation_lab/observation_lab_patient_category_date_search_test.rb +46 -0
  204. data/lib/us_core_test_kit/generated/observation_lab/observation_lab_patient_category_search_test.rb +62 -0
  205. data/lib/us_core_test_kit/generated/observation_lab/observation_lab_patient_category_status_search_test.rb +47 -0
  206. data/lib/us_core_test_kit/generated/observation_lab/observation_lab_patient_code_date_search_test.rb +48 -0
  207. data/lib/us_core_test_kit/generated/observation_lab/observation_lab_patient_code_search_test.rb +45 -0
  208. data/lib/us_core_test_kit/generated/observation_lab/observation_lab_provenance_revinclude_search_test.rb +51 -0
  209. data/lib/us_core_test_kit/generated/observation_lab/observation_lab_read_test.rb +24 -0
  210. data/lib/us_core_test_kit/generated/observation_lab/observation_lab_reference_resolution_test.rb +28 -0
  211. data/lib/us_core_test_kit/generated/observation_lab/observation_lab_validation_test.rb +34 -0
  212. data/lib/us_core_test_kit/generated/observation_lab_group.rb +93 -0
  213. data/lib/us_core_test_kit/generated/organization/organization_address_search_test.rb +39 -0
  214. data/lib/us_core_test_kit/generated/organization/organization_must_support_test.rb +47 -0
  215. data/lib/us_core_test_kit/generated/organization/organization_name_search_test.rb +49 -0
  216. data/lib/us_core_test_kit/generated/organization/organization_read_test.rb +24 -0
  217. data/lib/us_core_test_kit/generated/organization/organization_reference_resolution_test.rb +28 -0
  218. data/lib/us_core_test_kit/generated/organization/organization_validation_test.rb +34 -0
  219. data/lib/us_core_test_kit/generated/organization_group.rb +84 -0
  220. data/lib/us_core_test_kit/generated/patient/patient_birthdate_family_search_test.rb +41 -0
  221. data/lib/us_core_test_kit/generated/patient/patient_birthdate_name_search_test.rb +39 -0
  222. data/lib/us_core_test_kit/generated/patient/patient_family_gender_search_test.rb +41 -0
  223. data/lib/us_core_test_kit/generated/patient/patient_gender_name_search_test.rb +39 -0
  224. data/lib/us_core_test_kit/generated/patient/patient_id_search_test.rb +53 -0
  225. data/lib/us_core_test_kit/generated/patient/patient_identifier_search_test.rb +40 -0
  226. data/lib/us_core_test_kit/generated/patient/patient_must_support_test.rb +57 -0
  227. data/lib/us_core_test_kit/generated/patient/patient_name_search_test.rb +39 -0
  228. data/lib/us_core_test_kit/generated/patient/patient_provenance_revinclude_search_test.rb +49 -0
  229. data/lib/us_core_test_kit/generated/patient/patient_read_test.rb +24 -0
  230. data/lib/us_core_test_kit/generated/patient/patient_reference_resolution_test.rb +28 -0
  231. data/lib/us_core_test_kit/generated/patient/patient_validation_test.rb +34 -0
  232. data/lib/us_core_test_kit/generated/patient_group.rb +99 -0
  233. data/lib/us_core_test_kit/generated/pediatric_bmi_for_age/pediatric_bmi_for_age_must_support_test.rb +49 -0
  234. data/lib/us_core_test_kit/generated/pediatric_bmi_for_age/pediatric_bmi_for_age_patient_category_date_search_test.rb +46 -0
  235. data/lib/us_core_test_kit/generated/pediatric_bmi_for_age/pediatric_bmi_for_age_patient_category_search_test.rb +45 -0
  236. data/lib/us_core_test_kit/generated/pediatric_bmi_for_age/pediatric_bmi_for_age_patient_category_status_search_test.rb +47 -0
  237. data/lib/us_core_test_kit/generated/pediatric_bmi_for_age/pediatric_bmi_for_age_patient_code_date_search_test.rb +48 -0
  238. data/lib/us_core_test_kit/generated/pediatric_bmi_for_age/pediatric_bmi_for_age_patient_code_search_test.rb +62 -0
  239. data/lib/us_core_test_kit/generated/pediatric_bmi_for_age/pediatric_bmi_for_age_provenance_revinclude_search_test.rb +51 -0
  240. data/lib/us_core_test_kit/generated/pediatric_bmi_for_age/pediatric_bmi_for_age_read_test.rb +24 -0
  241. data/lib/us_core_test_kit/generated/pediatric_bmi_for_age/pediatric_bmi_for_age_reference_resolution_test.rb +28 -0
  242. data/lib/us_core_test_kit/generated/pediatric_bmi_for_age/pediatric_bmi_for_age_validation_test.rb +34 -0
  243. data/lib/us_core_test_kit/generated/pediatric_bmi_for_age_group.rb +93 -0
  244. data/lib/us_core_test_kit/generated/pediatric_weight_for_height/pediatric_weight_for_height_must_support_test.rb +49 -0
  245. data/lib/us_core_test_kit/generated/pediatric_weight_for_height/pediatric_weight_for_height_patient_category_date_search_test.rb +46 -0
  246. data/lib/us_core_test_kit/generated/pediatric_weight_for_height/pediatric_weight_for_height_patient_category_search_test.rb +45 -0
  247. data/lib/us_core_test_kit/generated/pediatric_weight_for_height/pediatric_weight_for_height_patient_category_status_search_test.rb +47 -0
  248. data/lib/us_core_test_kit/generated/pediatric_weight_for_height/pediatric_weight_for_height_patient_code_date_search_test.rb +48 -0
  249. data/lib/us_core_test_kit/generated/pediatric_weight_for_height/pediatric_weight_for_height_patient_code_search_test.rb +62 -0
  250. data/lib/us_core_test_kit/generated/pediatric_weight_for_height/pediatric_weight_for_height_provenance_revinclude_search_test.rb +51 -0
  251. data/lib/us_core_test_kit/generated/pediatric_weight_for_height/pediatric_weight_for_height_read_test.rb +24 -0
  252. data/lib/us_core_test_kit/generated/pediatric_weight_for_height/pediatric_weight_for_height_reference_resolution_test.rb +28 -0
  253. data/lib/us_core_test_kit/generated/pediatric_weight_for_height/pediatric_weight_for_height_validation_test.rb +34 -0
  254. data/lib/us_core_test_kit/generated/pediatric_weight_for_height_group.rb +93 -0
  255. data/lib/us_core_test_kit/generated/practitioner/practitioner_identifier_search_test.rb +40 -0
  256. data/lib/us_core_test_kit/generated/practitioner/practitioner_must_support_test.rb +40 -0
  257. data/lib/us_core_test_kit/generated/practitioner/practitioner_name_search_test.rb +49 -0
  258. data/lib/us_core_test_kit/generated/practitioner/practitioner_read_test.rb +24 -0
  259. data/lib/us_core_test_kit/generated/practitioner/practitioner_reference_resolution_test.rb +28 -0
  260. data/lib/us_core_test_kit/generated/practitioner/practitioner_validation_test.rb +34 -0
  261. data/lib/us_core_test_kit/generated/practitioner_group.rb +84 -0
  262. data/lib/us_core_test_kit/generated/procedure/procedure_must_support_test.rb +38 -0
  263. data/lib/us_core_test_kit/generated/procedure/procedure_patient_code_date_search_test.rb +48 -0
  264. data/lib/us_core_test_kit/generated/procedure/procedure_patient_date_search_test.rb +45 -0
  265. data/lib/us_core_test_kit/generated/procedure/procedure_patient_search_test.rb +60 -0
  266. data/lib/us_core_test_kit/generated/procedure/procedure_patient_status_search_test.rb +46 -0
  267. data/lib/us_core_test_kit/generated/procedure/procedure_provenance_revinclude_search_test.rb +50 -0
  268. data/lib/us_core_test_kit/generated/procedure/procedure_read_test.rb +24 -0
  269. data/lib/us_core_test_kit/generated/procedure/procedure_reference_resolution_test.rb +28 -0
  270. data/lib/us_core_test_kit/generated/procedure/procedure_validation_test.rb +34 -0
  271. data/lib/us_core_test_kit/generated/procedure_group.rb +90 -0
  272. data/lib/us_core_test_kit/generated/provenance/provenance_must_support_test.rb +44 -0
  273. data/lib/us_core_test_kit/generated/provenance/provenance_read_test.rb +24 -0
  274. data/lib/us_core_test_kit/generated/provenance/provenance_reference_resolution_test.rb +28 -0
  275. data/lib/us_core_test_kit/generated/provenance/provenance_validation_test.rb +34 -0
  276. data/lib/us_core_test_kit/generated/provenance_group.rb +56 -0
  277. data/lib/us_core_test_kit/generated/pulse_oximetry/pulse_oximetry_must_support_test.rb +65 -0
  278. data/lib/us_core_test_kit/generated/pulse_oximetry/pulse_oximetry_patient_category_date_search_test.rb +46 -0
  279. data/lib/us_core_test_kit/generated/pulse_oximetry/pulse_oximetry_patient_category_search_test.rb +45 -0
  280. data/lib/us_core_test_kit/generated/pulse_oximetry/pulse_oximetry_patient_category_status_search_test.rb +47 -0
  281. data/lib/us_core_test_kit/generated/pulse_oximetry/pulse_oximetry_patient_code_date_search_test.rb +48 -0
  282. data/lib/us_core_test_kit/generated/pulse_oximetry/pulse_oximetry_patient_code_search_test.rb +62 -0
  283. data/lib/us_core_test_kit/generated/pulse_oximetry/pulse_oximetry_provenance_revinclude_search_test.rb +51 -0
  284. data/lib/us_core_test_kit/generated/pulse_oximetry/pulse_oximetry_read_test.rb +24 -0
  285. data/lib/us_core_test_kit/generated/pulse_oximetry/pulse_oximetry_reference_resolution_test.rb +28 -0
  286. data/lib/us_core_test_kit/generated/pulse_oximetry/pulse_oximetry_validation_test.rb +34 -0
  287. data/lib/us_core_test_kit/generated/pulse_oximetry_group.rb +93 -0
  288. data/lib/us_core_test_kit/generated/resource_list.rb +26 -0
  289. data/lib/us_core_test_kit/generated/resprate/resprate_must_support_test.rb +49 -0
  290. data/lib/us_core_test_kit/generated/resprate/resprate_patient_category_date_search_test.rb +46 -0
  291. data/lib/us_core_test_kit/generated/resprate/resprate_patient_category_search_test.rb +45 -0
  292. data/lib/us_core_test_kit/generated/resprate/resprate_patient_category_status_search_test.rb +47 -0
  293. data/lib/us_core_test_kit/generated/resprate/resprate_patient_code_date_search_test.rb +48 -0
  294. data/lib/us_core_test_kit/generated/resprate/resprate_patient_code_search_test.rb +62 -0
  295. data/lib/us_core_test_kit/generated/resprate/resprate_provenance_revinclude_search_test.rb +51 -0
  296. data/lib/us_core_test_kit/generated/resprate/resprate_read_test.rb +24 -0
  297. data/lib/us_core_test_kit/generated/resprate/resprate_reference_resolution_test.rb +28 -0
  298. data/lib/us_core_test_kit/generated/resprate/resprate_validation_test.rb +34 -0
  299. data/lib/us_core_test_kit/generated/resprate_group.rb +93 -0
  300. data/lib/us_core_test_kit/generated/smokingstatus/smokingstatus_must_support_test.rb +39 -0
  301. data/lib/us_core_test_kit/generated/smokingstatus/smokingstatus_patient_category_date_search_test.rb +48 -0
  302. data/lib/us_core_test_kit/generated/smokingstatus/smokingstatus_patient_category_search_test.rb +47 -0
  303. data/lib/us_core_test_kit/generated/smokingstatus/smokingstatus_patient_category_status_search_test.rb +47 -0
  304. data/lib/us_core_test_kit/generated/smokingstatus/smokingstatus_patient_code_date_search_test.rb +48 -0
  305. data/lib/us_core_test_kit/generated/smokingstatus/smokingstatus_patient_code_search_test.rb +62 -0
  306. data/lib/us_core_test_kit/generated/smokingstatus/smokingstatus_provenance_revinclude_search_test.rb +51 -0
  307. data/lib/us_core_test_kit/generated/smokingstatus/smokingstatus_read_test.rb +24 -0
  308. data/lib/us_core_test_kit/generated/smokingstatus/smokingstatus_reference_resolution_test.rb +28 -0
  309. data/lib/us_core_test_kit/generated/smokingstatus/smokingstatus_validation_test.rb +34 -0
  310. data/lib/us_core_test_kit/generated/smokingstatus_group.rb +93 -0
  311. data/lib/us_core_test_kit/generated/us_core_test_suite.rb +110 -0
  312. data/lib/us_core_test_kit/generator/group_generator.rb +171 -0
  313. data/lib/us_core_test_kit/generator/group_metadata.rb +98 -0
  314. data/lib/us_core_test_kit/generator/group_metadata_extractor.rb +281 -0
  315. data/lib/us_core_test_kit/generator/ig_loader.rb +63 -0
  316. data/lib/us_core_test_kit/generator/ig_metadata.rb +49 -0
  317. data/lib/us_core_test_kit/generator/ig_metadata_extractor.rb +56 -0
  318. data/lib/us_core_test_kit/generator/ig_resources.rb +48 -0
  319. data/lib/us_core_test_kit/generator/must_support_metadata_extractor.rb +221 -0
  320. data/lib/us_core_test_kit/generator/must_support_test_generator.rb +86 -0
  321. data/lib/us_core_test_kit/generator/naming.rb +58 -0
  322. data/lib/us_core_test_kit/generator/provenance_revinclude_search_test_generator.rb +186 -0
  323. data/lib/us_core_test_kit/generator/read_test_generator.rb +89 -0
  324. data/lib/us_core_test_kit/generator/reference_resolution_test_generator.rb +72 -0
  325. data/lib/us_core_test_kit/generator/resource_list_generator.rb +46 -0
  326. data/lib/us_core_test_kit/generator/search_definition_metadata_extractor.rb +181 -0
  327. data/lib/us_core_test_kit/generator/search_metadata_extractor.rb +74 -0
  328. data/lib/us_core_test_kit/generator/search_test_generator.rb +280 -0
  329. data/lib/us_core_test_kit/generator/special_cases.rb +17 -0
  330. data/lib/us_core_test_kit/generator/suite_generator.rb +67 -0
  331. data/lib/us_core_test_kit/generator/terminology_binding_metadata_extractor.rb +105 -0
  332. data/lib/us_core_test_kit/generator/validation_test_generator.rb +124 -0
  333. data/lib/us_core_test_kit/generator.rb +86 -0
  334. data/lib/us_core_test_kit/igs/StructureDefinition-bodyheight.json +3772 -0
  335. data/lib/us_core_test_kit/igs/StructureDefinition-bodytemp.json +3772 -0
  336. data/lib/us_core_test_kit/igs/StructureDefinition-bodyweight.json +3772 -0
  337. data/lib/us_core_test_kit/igs/StructureDefinition-bp.json +6034 -0
  338. data/lib/us_core_test_kit/igs/StructureDefinition-heartrate.json +3756 -0
  339. data/lib/us_core_test_kit/igs/StructureDefinition-resprate.json +3756 -0
  340. data/lib/us_core_test_kit/igs/package.tgz +0 -0
  341. data/lib/us_core_test_kit/must_support_test.rb +146 -0
  342. data/lib/us_core_test_kit/read_test.rb +62 -0
  343. data/lib/us_core_test_kit/reference_resolution_test.rb +111 -0
  344. data/lib/us_core_test_kit/request_logger.rb +46 -0
  345. data/lib/us_core_test_kit/search_test.rb +686 -0
  346. data/lib/us_core_test_kit/search_test_properties.rb +56 -0
  347. data/lib/us_core_test_kit/validation_test.rb +48 -0
  348. data/lib/us_core_test_kit/version.rb +3 -0
  349. data/lib/us_core_test_kit.rb +2 -0
  350. metadata +477 -0
@@ -0,0 +1,280 @@
1
+ require_relative 'naming'
2
+ require_relative 'special_cases'
3
+
4
+ module USCoreTestKit
5
+ class Generator
6
+ class SearchTestGenerator
7
+ class << self
8
+ def generate(ig_metadata)
9
+ ig_metadata.groups
10
+ .reject { |group| SpecialCases.exclude_resource? group.resource }
11
+ .select { |group| group.searches.present? }
12
+ .each do |group|
13
+ group.searches.each { |search| new(group, search).generate }
14
+ end
15
+ end
16
+ end
17
+
18
+ attr_accessor :group_metadata, :search_metadata
19
+
20
+ def initialize(group_metadata, search_metadata)
21
+ self.group_metadata = group_metadata
22
+ self.search_metadata = search_metadata
23
+ end
24
+
25
+ def template
26
+ @template ||= File.read(File.join(__dir__, 'templates', 'search.rb.erb'))
27
+ end
28
+
29
+ def output
30
+ @output ||= ERB.new(template).result(binding)
31
+ end
32
+
33
+ def base_output_file_name
34
+ "#{class_name.underscore}.rb"
35
+ end
36
+
37
+ def output_file_directory
38
+ File.join(__dir__, '..', 'generated', profile_identifier)
39
+ end
40
+
41
+ def output_file_name
42
+ File.join(output_file_directory, base_output_file_name)
43
+ end
44
+
45
+ def profile_identifier
46
+ Naming.snake_case_for_profile(group_metadata)
47
+ end
48
+
49
+ def test_id
50
+ "us_core_311_#{profile_identifier}_#{search_identifier}_search_test"
51
+ end
52
+
53
+ def search_identifier
54
+ search_metadata[:names].join('_').tr('-', '_')
55
+ end
56
+
57
+ def search_title
58
+ search_identifier.camelize
59
+ end
60
+
61
+ def class_name
62
+ "#{Naming.upper_camel_case_for_profile(group_metadata)}#{search_title}SearchTest"
63
+ end
64
+
65
+ def resource_type
66
+ group_metadata.resource
67
+ end
68
+
69
+ def conformance_expectation
70
+ search_metadata[:expectation]
71
+ end
72
+
73
+ def search_params
74
+ @search_params ||=
75
+ search_metadata[:names].map do |name|
76
+ {
77
+ name: name,
78
+ path: search_definition(name)[:path]
79
+ }
80
+ end
81
+ end
82
+
83
+ def first_search?
84
+ group_metadata.searches.first == search_metadata
85
+ end
86
+
87
+ def fixed_value_search?
88
+ first_search? && search_metadata[:names] != ['patient'] &&
89
+ !group_metadata.delayed? && resource_type != 'Patient'
90
+ end
91
+
92
+ def fixed_value_search_param_name
93
+ (search_metadata[:names] - [:patient]).first
94
+ end
95
+
96
+ def search_param_name_string
97
+ search_metadata[:names].join(' + ')
98
+ end
99
+
100
+ def needs_patient_id?
101
+ search_metadata[:names].include?('patient') ||
102
+ (resource_type == 'Patient' && search_metadata[:names].include?('_id'))
103
+ end
104
+
105
+ def search_param_names
106
+ search_params.map { |param| param[:name] }
107
+ end
108
+
109
+ def search_param_names_array
110
+ array_of_strings(search_param_names)
111
+ end
112
+
113
+ def path_for_value(path)
114
+ path == 'class' ? 'local_class' : path
115
+ end
116
+
117
+ def required_comparators_for_param(name)
118
+ search_definition(name)[:comparators].select { |_comparator, expectation| expectation == 'SHALL' }
119
+ end
120
+
121
+ def required_comparators
122
+ @required_comparators ||=
123
+ search_param_names.each_with_object({}) do |name, comparators|
124
+ required_comparators = required_comparators_for_param(name)
125
+ comparators[name] = required_comparators if required_comparators.present?
126
+ end
127
+ end
128
+
129
+ def optional?
130
+ conformance_expectation != 'SHALL' || !search_metadata[:must_support_or_mandatory]
131
+ end
132
+
133
+ def search_definition(name)
134
+ group_metadata.search_definitions[name.to_sym]
135
+ end
136
+
137
+ def saves_delayed_references?
138
+ first_search? && group_metadata.delayed_references.present?
139
+ end
140
+
141
+ def possible_status_search?
142
+ !search_metadata[:names].any? { |name| name.include? 'status' } &&
143
+ group_metadata.search_definitions.keys.any? { |key| key.to_s.include? 'status' }
144
+ end
145
+
146
+ def token_search_params
147
+ @token_search_params ||=
148
+ search_param_names.select do |name|
149
+ ['Identifier', 'CodeableConcept', 'Coding'].include? group_metadata.search_definitions[name.to_sym][:type]
150
+ end
151
+ end
152
+
153
+ def token_search_params_string
154
+ array_of_strings(token_search_params)
155
+ end
156
+
157
+ def required_multiple_or_search_params
158
+ @multiple_or_search_params ||=
159
+ search_param_names.select do |name|
160
+ search_definition(name)[:multiple_or] == 'SHALL'
161
+ end
162
+ end
163
+
164
+ def required_multiple_or_search_params_string
165
+ array_of_strings(required_multiple_or_search_params)
166
+ end
167
+
168
+ def required_comparators_string
169
+ array_of_strings(required_comparators.keys)
170
+ end
171
+
172
+ def array_of_strings(array)
173
+ quoted_strings = array.map { |element| "'#{element}'" }
174
+ "[#{quoted_strings.join(', ')}]"
175
+ end
176
+
177
+ def test_reference_variants?
178
+ first_search? && search_param_names.include?('patient')
179
+ end
180
+
181
+ def test_medication_inclusion?
182
+ resource_type == 'MedicationRequest'
183
+ end
184
+
185
+ def test_post_search?
186
+ first_search?
187
+ end
188
+
189
+ def search_properties
190
+ {}.tap do |properties|
191
+ properties[:first_search] = 'true' if first_search?
192
+ properties[:fixed_value_search] = 'true' if fixed_value_search?
193
+ properties[:resource_type] = "'#{resource_type}'"
194
+ properties[:search_param_names] = search_param_names_array
195
+ properties[:saves_delayed_references] = 'true' if saves_delayed_references?
196
+ properties[:possible_status_search] = 'true' if possible_status_search?
197
+ properties[:test_medication_inclusion] = 'true' if test_medication_inclusion?
198
+ properties[:token_search_params] = token_search_params_string if token_search_params.present?
199
+ properties[:test_reference_variants] = 'true' if test_reference_variants?
200
+ properties[:params_with_comparators] = required_comparators_string if required_comparators.present?
201
+ properties[:multiple_or_search_params] = required_multiple_or_search_params_string if required_multiple_or_search_params.present?
202
+ properties[:test_post_search] = 'true' if first_search?
203
+ end
204
+ end
205
+
206
+ def search_test_properties_string
207
+ search_properties
208
+ .map { |key, value| "#{' ' * 8}#{key}: #{value}" }
209
+ .join(",\n")
210
+ end
211
+
212
+ def generate
213
+ FileUtils.mkdir_p(output_file_directory)
214
+ File.open(output_file_name, 'w') { |f| f.write(output) }
215
+
216
+ group_metadata.add_test(
217
+ id: test_id,
218
+ file_name: base_output_file_name
219
+ )
220
+ end
221
+
222
+ def reference_search_description
223
+ return '' unless test_reference_variants?
224
+
225
+ <<~REFERENCE_SEARCH_DESCRIPTION
226
+ This test verifies that the server supports searching by reference using
227
+ the form `patient=[id]` as well as `patient=Patient/[id]`. The two
228
+ different forms are expected to return the same number of results. US
229
+ Core requires that both forms are supported by US Core responders.
230
+ REFERENCE_SEARCH_DESCRIPTION
231
+ end
232
+
233
+ def first_search_description
234
+ return '' unless first_search?
235
+
236
+ <<~FIRST_SEARCH_DESCRIPTION
237
+ Because this is the first search of the sequence, resources in the
238
+ response will be used for subsequent tests.
239
+ FIRST_SEARCH_DESCRIPTION
240
+ end
241
+
242
+ def medication_inclusion_description
243
+ return '' unless test_medication_inclusion?
244
+
245
+ <<~MEDICATION_INCLUSION_DESCRIPTION
246
+ If any MedicationRequest resources use external references to
247
+ Medications, the search will be repeated with
248
+ `_include=MedicationRequest:medication`.
249
+ MEDICATION_INCLUSION_DESCRIPTION
250
+ end
251
+
252
+ def post_search_description
253
+ return '' unless test_post_search?
254
+
255
+ <<~POST_SEARCH_DESCRIPTION
256
+ Additionally, this test will check that GET and POST search methods
257
+ return the same number of results. Search by POST is required by the
258
+ FHIR R4 specification, and these tests interpret search by GET as a
259
+ requirement of US Core v3.1.1.
260
+ POST_SEARCH_DESCRIPTION
261
+ end
262
+
263
+ def description
264
+ <<~DESCRIPTION.gsub(/\n{3,}/, "\n\n")
265
+ A server #{conformance_expectation} support searching by
266
+ #{search_param_name_string} on the #{resource_type} resource. This test
267
+ will pass if resources are returned and match the search criteria. If
268
+ none are returned, the test is skipped.
269
+
270
+ #{medication_inclusion_description}
271
+ #{reference_search_description}
272
+ #{first_search_description}
273
+ #{post_search_description}
274
+
275
+ [US Core Server CapabilityStatement](http://hl7.org/fhir/us/core/STU3.1.1/CapabilityStatement-us-core-server.html)
276
+ DESCRIPTION
277
+ end
278
+ end
279
+ end
280
+ end
@@ -0,0 +1,17 @@
1
+ module USCoreTestKit
2
+ class Generator
3
+ module SpecialCases
4
+ RESOURCES_TO_EXCLUDE = [
5
+ 'Location',
6
+ 'Medication',
7
+ 'PractitionerRole'
8
+ ].freeze
9
+
10
+ class << self
11
+ def exclude_resource?(resource)
12
+ RESOURCES_TO_EXCLUDE.include? resource
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,67 @@
1
+ require_relative 'naming'
2
+ require_relative 'special_cases'
3
+
4
+ module USCoreTestKit
5
+ class Generator
6
+ class SuiteGenerator
7
+ class << self
8
+ def generate(ig_metadata)
9
+ new(ig_metadata).generate
10
+ end
11
+ end
12
+
13
+ attr_accessor :ig_metadata
14
+
15
+ def initialize(ig_metadata)
16
+ self.ig_metadata = ig_metadata
17
+ end
18
+
19
+ def template
20
+ @template ||= File.read(File.join(__dir__, 'templates', 'suite.rb.erb'))
21
+ end
22
+
23
+ def output
24
+ @output ||= ERB.new(template).result(binding)
25
+ end
26
+
27
+ def base_output_file_name
28
+ "us_core_test_suite.rb"
29
+ end
30
+
31
+ def class_name
32
+ "USCoreTestSuite"
33
+ end
34
+
35
+ def output_file_name
36
+ File.join(__dir__, '..', 'generated', base_output_file_name)
37
+ end
38
+
39
+ def suite_id
40
+ 'us_core_311'
41
+ end
42
+
43
+ def title
44
+ 'US Core 3.1.1'
45
+ end
46
+
47
+ def generate
48
+ File.open(output_file_name, 'w') { |f| f.write(output) }
49
+ end
50
+
51
+ def groups
52
+ ig_metadata.ordered_groups
53
+ .reject { |group| SpecialCases.exclude_resource? group.resource }
54
+ end
55
+
56
+ def group_id_list
57
+ @group_id_list ||=
58
+ groups.map(&:id)
59
+ end
60
+
61
+ def group_file_list
62
+ @group_file_list ||=
63
+ groups.map { |group| group.file_name.delete_suffix('.rb') }
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,105 @@
1
+ module USCoreTestKit
2
+ class Generator
3
+ class TerminologyBindingMetadataExtractor
4
+ attr_accessor :profile_elements, :ig_resources, :resource
5
+
6
+ def initialize(profile_elements, ig_resources, resource)
7
+ self.profile_elements = profile_elements
8
+ self.ig_resources = ig_resources
9
+ self.resource = resource
10
+ end
11
+
12
+ def terminology_bindings
13
+ (element_terminology_bindings + extension_terminology_bindings).compact
14
+ # add_terminology_bindings_from_extensions
15
+ # profile_elements.select { |element| element.type&.first&.code == 'Extension' }
16
+ # .each { |extension| add_terminology_bindings_from_extension(extension) }
17
+ end
18
+
19
+ def element_has_fixed_value?(element)
20
+ case element.type.first.code
21
+ when 'Quantity'
22
+ code = profile_elements.find { |e| e.path == "#{element.path}.code" }
23
+ system = profile_elements.find { |e| e.path == "#{element.path}.system" }
24
+ code&.fixedCode || system&.fixedUri
25
+ when 'code'
26
+ element.fixedCode.present?
27
+ end
28
+ end
29
+
30
+ def profile_elements_with_bindings
31
+ profile_elements
32
+ .select { |element| element.binding.present? }
33
+ .reject { |element| element_has_fixed_value? element }
34
+ end
35
+
36
+ def element_terminology_bindings
37
+ profile_elements_with_bindings.map do |element|
38
+ {
39
+ type: element.type.first.code,
40
+ strength: element.binding.strength,
41
+ # Goal.target.detail has an unbound binding
42
+ system: element.binding.valueSet&.split('|')&.first,
43
+ path: element.path.gsub('[x]', '').gsub("#{resource}.", '')
44
+ }
45
+ end
46
+ end
47
+
48
+ def extension_profile_elements
49
+ profile_elements
50
+ .select { |element| element.type&.first&.code == 'Extension' }
51
+ .select { |element| extension_profile_url(element).present? }
52
+ end
53
+
54
+ def extension_profile_url(extension)
55
+ extension.type.first.profile&.first
56
+ end
57
+
58
+ def extension_terminology_bindings
59
+ extension_profile_elements
60
+ .flat_map do |extension_profile_element|
61
+ url = extension_profile_url(extension_profile_element)
62
+ extension = ig_resources.profile_by_url(url)
63
+
64
+ elements = extension.snapshot.element
65
+ elements_with_bindings = elements.select do |element|
66
+ element.binding.present? && !element.id.include?('Extension.extension')
67
+ end
68
+
69
+ elements_with_bindings.map do |element|
70
+ {
71
+ type: element.type.first.code,
72
+ strength: element.binding.strength,
73
+ system: element.binding.valueSet&.split('|')&.first,
74
+ path: element.path.gsub('[x]', '').gsub('Extension.', ''),
75
+ extensions: [url]
76
+ }
77
+ end + nested_extension_terminology_bindings(elements, url)
78
+ end
79
+ end
80
+
81
+ def nested_extension_terminology_bindings(elements, extension_url)
82
+ nested_extensions = elements.select { |element| element.path == 'Extension.extension' }
83
+ nested_extensions.flat_map do |nested_extension|
84
+ nested_extension_element = elements.find { |element| element.id == "#{nested_extension.id}.url" }
85
+ next unless nested_extension_element.present?
86
+
87
+ nested_extension_url = nested_extension_element.fixedUri
88
+ nested_elements_with_bindings = elements.select do |element|
89
+ element.id.include?(nested_extension.id) && element.binding.present?
90
+ end
91
+
92
+ nested_elements_with_bindings.map do |element|
93
+ {
94
+ type: element.type.first.code,
95
+ strength: element.binding.strength,
96
+ system: element.binding.valueSet&.split('|')&.first,
97
+ path: element.path.gsub('[x]', '').gsub('Extension.extension.', ''),
98
+ extensions: [extension_url, nested_extension_url]
99
+ }
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,124 @@
1
+ require_relative 'naming'
2
+ require_relative 'special_cases'
3
+
4
+ module USCoreTestKit
5
+ class Generator
6
+ class ValidationTestGenerator
7
+ class << self
8
+ def generate(ig_metadata)
9
+ ig_metadata.groups
10
+ .reject { |group| SpecialCases.exclude_resource? group.resource }
11
+ .each do |group|
12
+ new(group).generate
13
+ next unless group.resource == 'MedicationRequest'
14
+
15
+ # The Medication validation test lives in the MedicationRequest
16
+ # group, so we need to pass in that group's metadata
17
+ medication_group_metadata = ig_metadata.groups.find { |group| group.resource == 'Medication' }
18
+ new(medication_group_metadata, group).generate
19
+ end
20
+ end
21
+ end
22
+
23
+ attr_accessor :group_metadata, :medication_request_metadata
24
+
25
+ def initialize(group_metadata, medication_request_metadata = nil)
26
+ self.group_metadata = group_metadata
27
+ self.medication_request_metadata = medication_request_metadata
28
+ end
29
+
30
+ def template
31
+ @template ||= File.read(File.join(__dir__, 'templates', 'validation.rb.erb'))
32
+ end
33
+
34
+ def output
35
+ @output ||= ERB.new(template).result(binding)
36
+ end
37
+
38
+ def base_output_file_name
39
+ "#{class_name.underscore}.rb"
40
+ end
41
+
42
+ def output_file_directory
43
+ File.join(__dir__, '..', 'generated', directory_name)
44
+ end
45
+
46
+ def output_file_name
47
+ File.join(output_file_directory, base_output_file_name)
48
+ end
49
+
50
+ def directory_name
51
+ Naming.snake_case_for_profile(medication_request_metadata || group_metadata)
52
+ end
53
+
54
+ def profile_identifier
55
+ Naming.snake_case_for_profile(group_metadata)
56
+ end
57
+
58
+ def profile_url
59
+ group_metadata.profile_url
60
+ end
61
+
62
+ def profile_name
63
+ group_metadata.profile_name
64
+ end
65
+
66
+ def test_id
67
+ "us_core_311_#{profile_identifier}_validation_test"
68
+ end
69
+
70
+ def class_name
71
+ "#{Naming.upper_camel_case_for_profile(group_metadata)}ValidationTest"
72
+ end
73
+
74
+ def resource_type
75
+ group_metadata.resource
76
+ end
77
+
78
+ def conformance_expectation
79
+ read_interaction[:expectation]
80
+ end
81
+
82
+ def generate
83
+ FileUtils.mkdir_p(output_file_directory)
84
+ File.open(output_file_name, 'w') { |f| f.write(output) }
85
+
86
+ test_metadata = {
87
+ id: test_id,
88
+ file_name: base_output_file_name
89
+ }
90
+
91
+ if resource_type == 'Medication'
92
+ medication_request_metadata.add_test(test_metadata)
93
+ else
94
+ group_metadata.add_test(test_metadata)
95
+ end
96
+ end
97
+
98
+ def description
99
+ <<~DESCRIPTION
100
+ #{description_intro}
101
+ It verifies the presence of mandatory elements and that elements with
102
+ required bindings contain appropriate values. CodeableConcept element
103
+ bindings will fail if none of their codings have a code/system belonging
104
+ to the bound ValueSet. Quantity, Coding, and code element bindings will
105
+ fail if their code/system are not found in the valueset.
106
+ DESCRIPTION
107
+ end
108
+
109
+ def description_intro
110
+ if resource_type == 'Medication'
111
+ <<~MEDICATION_INTRO
112
+ This test verifies resources returned from previous tests conform to
113
+ the [#{profile_name}](#{profile_url}).
114
+ MEDICATION_INTRO
115
+ else
116
+ <<~GENERIC_INTRO
117
+ This test verifies resources returned from the first search conform to
118
+ the [#{profile_name}](#{profile_url}).
119
+ GENERIC_INTRO
120
+ end
121
+ end
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,86 @@
1
+ require 'fhir_models'
2
+
3
+ require_relative 'ext/fhir_models'
4
+ require_relative 'generator/ig_loader'
5
+ require_relative 'generator/ig_metadata_extractor'
6
+ require_relative 'generator/group_generator'
7
+ require_relative 'generator/must_support_test_generator'
8
+ require_relative 'generator/provenance_revinclude_search_test_generator'
9
+ require_relative 'generator/read_test_generator'
10
+ require_relative 'generator/reference_resolution_test_generator'
11
+ require_relative 'generator/resource_list_generator'
12
+ require_relative 'generator/search_test_generator'
13
+ require_relative 'generator/suite_generator'
14
+ require_relative 'generator/validation_test_generator'
15
+
16
+ module USCoreTestKit
17
+ class Generator
18
+ attr_accessor :ig_resources, :ig_metadata
19
+
20
+ def generate
21
+ load_ig_package
22
+ extract_metadata
23
+ generate_resource_list
24
+ generate_search_tests
25
+ generate_read_tests
26
+ # TODO: generate_vread_tests
27
+ # TODO: generate_history_tests
28
+ generate_provenance_revinclude_search_tests
29
+ generate_validation_tests
30
+ generate_must_support_tests
31
+ generate_reference_resolution_tests
32
+
33
+ generate_groups
34
+
35
+ generate_suites
36
+ end
37
+
38
+ def extract_metadata
39
+ self.ig_metadata = IGMetadataExtractor.new(ig_resources).extract
40
+ File.open(File.join(__dir__, 'generated', 'metadata.yml'), 'w') do |file|
41
+ file.write(YAML.dump(ig_metadata.to_hash))
42
+ end
43
+ end
44
+
45
+ def load_ig_package
46
+ FHIR.logger = Logger.new('/dev/null')
47
+ self.ig_resources = IGLoader.new.load
48
+ end
49
+
50
+ def generate_resource_list
51
+ ResourceListGenerator.generate(ig_metadata)
52
+ end
53
+
54
+ def generate_reference_resolution_tests
55
+ ReferenceResolutionTestGenerator.generate(ig_metadata)
56
+ end
57
+
58
+ def generate_must_support_tests
59
+ MustSupportTestGenerator.generate(ig_metadata)
60
+ end
61
+
62
+ def generate_validation_tests
63
+ ValidationTestGenerator.generate(ig_metadata)
64
+ end
65
+
66
+ def generate_read_tests
67
+ ReadTestGenerator.generate(ig_metadata)
68
+ end
69
+
70
+ def generate_search_tests
71
+ SearchTestGenerator.generate(ig_metadata)
72
+ end
73
+
74
+ def generate_provenance_revinclude_search_tests
75
+ ProvenanceRevincludeSearchTestGenerator.generate(ig_metadata)
76
+ end
77
+
78
+ def generate_groups
79
+ GroupGenerator.generate(ig_metadata)
80
+ end
81
+
82
+ def generate_suites
83
+ SuiteGenerator.generate(ig_metadata)
84
+ end
85
+ end
86
+ end