plan_executor 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (337) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +44 -0
  3. data/.simplecov +16 -0
  4. data/.travis.yml +13 -0
  5. data/Gemfile +26 -0
  6. data/Gemfile.lock +197 -0
  7. data/LICENSE +201 -0
  8. data/README.md +126 -0
  9. data/Rakefile +25 -0
  10. data/fixtures/daf/conformance-daf-query-responder.xml +1471 -0
  11. data/fixtures/diagnostic_order/do-100.xml +64 -0
  12. data/fixtures/diagnostic_order/do-200.xml +121 -0
  13. data/fixtures/diagnostic_order/do-300.xml +91 -0
  14. data/fixtures/diagnostic_order/do-400.xml +88 -0
  15. data/fixtures/diagnostic_report/dr-100.xml +96 -0
  16. data/fixtures/diagnostic_report/dr-200.xml +125 -0
  17. data/fixtures/diagnostic_report/dr-300.xml +132 -0
  18. data/fixtures/diagnostic_report/dr-400.xml +121 -0
  19. data/fixtures/financial/claim-example-average.xml +168 -0
  20. data/fixtures/financial/claim-example-simple.xml +67 -0
  21. data/fixtures/observation/obs-100.xml +58 -0
  22. data/fixtures/observation/obs-101.xml +58 -0
  23. data/fixtures/observation/obs-200.xml +125 -0
  24. data/fixtures/observation/obs-300.xml +106 -0
  25. data/fixtures/observation/obs-301.xml +106 -0
  26. data/fixtures/observation/obs-302.xml +106 -0
  27. data/fixtures/observation/obs-303.xml +106 -0
  28. data/fixtures/observation/obs-304.xml +106 -0
  29. data/fixtures/observation/obs-400.xml +87 -0
  30. data/fixtures/observation/obs-401.xml +95 -0
  31. data/fixtures/observation/obs-402.xml +95 -0
  32. data/fixtures/observation/obs-403.xml +84 -0
  33. data/fixtures/observation/obs-404.xml +84 -0
  34. data/fixtures/observation/obs-405.xml +83 -0
  35. data/fixtures/observation/obs-406.xml +83 -0
  36. data/fixtures/observation/obs-407.xml +70 -0
  37. data/fixtures/observation/obs-408.xml +84 -0
  38. data/fixtures/observation/obs-uslab-example5.xml +102 -0
  39. data/fixtures/order/order-100.xml +61 -0
  40. data/fixtures/order/order-200.xml +61 -0
  41. data/fixtures/order/order-300.xml +61 -0
  42. data/fixtures/order/order-400.xml +61 -0
  43. data/fixtures/order_response/ordresp-100.xml +79 -0
  44. data/fixtures/order_response/ordresp-110.xml +79 -0
  45. data/fixtures/order_response/ordresp-200.xml +79 -0
  46. data/fixtures/order_response/ordresp-210.xml +79 -0
  47. data/fixtures/order_response/ordresp-300.xml +79 -0
  48. data/fixtures/order_response/ordresp-310.xml +79 -0
  49. data/fixtures/order_response/ordresp-400.xml +79 -0
  50. data/fixtures/order_response/ordresp-410.xml +79 -0
  51. data/fixtures/organization/org-uslab-example3.xml +49 -0
  52. data/fixtures/patient/patient-example-updated.xml +140 -0
  53. data/fixtures/patient/patient-example-us-extensions(us01).xml +81 -0
  54. data/fixtures/patient/patient-example.xml +132 -0
  55. data/fixtures/patient/patient-format-example.xml +101 -0
  56. data/fixtures/patient/patient-minimal.xml +9 -0
  57. data/fixtures/patient/patient-uslab-example1.xml +44 -0
  58. data/fixtures/practitioner/pract-uslab-example1.xml +18 -0
  59. data/fixtures/practitioner/pract-uslab-example3.xml +36 -0
  60. data/fixtures/record/condition-example-f201-fever.xml +63 -0
  61. data/fixtures/record/condition-example-f205-infection.xml +20 -0
  62. data/fixtures/record/diagnosticreport-example-f201-brainct.xml +18 -0
  63. data/fixtures/record/encounter-example-f201-20130404.xml +17 -0
  64. data/fixtures/record/encounter-example-f202-20130128.xml +17 -0
  65. data/fixtures/record/observation-example-f202-temperature.xml +60 -0
  66. data/fixtures/record/organization-example-f201-aumc.xml +5 -0
  67. data/fixtures/record/organization-example-f203-bumc.xml +5 -0
  68. data/fixtures/record/patient-example-f201-roel.xml +16 -0
  69. data/fixtures/record/practitioner-example-f201-ab.xml +14 -0
  70. data/fixtures/record/procedure-example-f201-tpf.xml +23 -0
  71. data/fixtures/scheduling/appointment-simple.xml +24 -0
  72. data/fixtures/scheduling/appointmentresponse-patient-simple.xml +12 -0
  73. data/fixtures/scheduling/appointmentresponse-practitioner-simple.xml +12 -0
  74. data/fixtures/scheduling/practitioner-simple.xml +10 -0
  75. data/fixtures/scheduling/schedule-simple.xml +12 -0
  76. data/fixtures/scheduling/slot-simple.xml +10 -0
  77. data/fixtures/specimen/spec-100.xml +65 -0
  78. data/fixtures/specimen/spec-400.xml +70 -0
  79. data/fixtures/specimen/spec-uslab-example1.xml +82 -0
  80. data/fixtures/validation/observation.profile.xml +2045 -0
  81. data/fixtures/validation/observations/observation-example(example).xml +50 -0
  82. data/lib/FHIR_structure.json +529 -0
  83. data/lib/daf_resource_generator.rb +94 -0
  84. data/lib/data/fhir_structure.rb +8 -0
  85. data/lib/data/resources.rb +138 -0
  86. data/lib/executor.rb +56 -0
  87. data/lib/ext/client.rb +27 -0
  88. data/lib/ext/client_reply.rb +19 -0
  89. data/lib/plan_executor.rb +31 -0
  90. data/lib/resource_generator.rb +656 -0
  91. data/lib/tasks/tasks.rake +329 -0
  92. data/lib/tasks/templates/summary.html.erb +163 -0
  93. data/lib/test_result.rb +69 -0
  94. data/lib/tests/assertions.rb +261 -0
  95. data/lib/tests/base_test.rb +117 -0
  96. data/lib/tests/suites/argonaut_resprint_1_test.rb +260 -0
  97. data/lib/tests/suites/argonaut_resprint_2_test.rb +369 -0
  98. data/lib/tests/suites/argonaut_resprint_3_test.rb +309 -0
  99. data/lib/tests/suites/argonaut_sprint_1_test.rb +187 -0
  100. data/lib/tests/suites/argonaut_sprint_2_test.rb +115 -0
  101. data/lib/tests/suites/argonaut_sprint_3_test.rb +208 -0
  102. data/lib/tests/suites/argonaut_sprint_4_test.rb +335 -0
  103. data/lib/tests/suites/argonaut_sprint_5_test.rb +196 -0
  104. data/lib/tests/suites/argonaut_sprint_6_test.rb +243 -0
  105. data/lib/tests/suites/argonaut_sprint_7_test.rb +161 -0
  106. data/lib/tests/suites/base_suite.rb +116 -0
  107. data/lib/tests/suites/connectathon_audit_track.rb +354 -0
  108. data/lib/tests/suites/connectathon_fetch_patient_record.rb +443 -0
  109. data/lib/tests/suites/connectathon_financial_track.rb +380 -0
  110. data/lib/tests/suites/connectathon_lab_order_track.rb +239 -0
  111. data/lib/tests/suites/connectathon_patient_track.rb +364 -0
  112. data/lib/tests/suites/connectathon_profile_validation.rb +101 -0
  113. data/lib/tests/suites/connectathon_scheduling_track.rb +266 -0
  114. data/lib/tests/suites/connectathon_terminology_track.rb +242 -0
  115. data/lib/tests/suites/daf_profiles_test.rb +431 -0
  116. data/lib/tests/suites/format_test.rb +453 -0
  117. data/lib/tests/suites/history_test.rb +311 -0
  118. data/lib/tests/suites/read_test.rb +104 -0
  119. data/lib/tests/suites/resource_test.rb +553 -0
  120. data/lib/tests/suites/search_test.rb +219 -0
  121. data/lib/tests/suites/search_test_robust.rb +172 -0
  122. data/lib/tests/suites/sprinkler_search_test.rb +660 -0
  123. data/lib/tests/suites/suite_engine.rb +114 -0
  124. data/lib/tests/suites/transaction_test.rb +571 -0
  125. data/lib/tests/testscripts/base_testscript.rb +480 -0
  126. data/lib/tests/testscripts/testscript_engine.rb +81 -0
  127. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/Client Assigned Id/track1-patient-base-client-id-json.xml +348 -0
  128. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/Client Assigned Id/track1-patient-base-client-id-xml.xml +348 -0
  129. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/Client Assigned Id/track1-patient-bonus-client-id-json.xml +420 -0
  130. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/Client Assigned Id/track1-patient-bonus-client-id-xml.xml +420 -0
  131. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/README.html +68 -0
  132. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/Server Assigned Id/track1-patient-base-server-id-json.xml +352 -0
  133. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/Server Assigned Id/track1-patient-base-server-id-xml.xml +352 -0
  134. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/Server Assigned Id/track1-patient-bonus-server-id-json.xml +421 -0
  135. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/Server Assigned Id/track1-patient-bonus-server-id-xml.xml +421 -0
  136. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/_reference/conformance/PatientConformance.xml +34 -0
  137. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/_reference/resources/patient-create-PeterChalmers-min.json +45 -0
  138. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/_reference/resources/patient-create-PeterChalmers-min.xml +26 -0
  139. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/_reference/resources/patient-create-PeterChalmers.json +100 -0
  140. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/_reference/resources/patient-create-PeterChalmers.xml +102 -0
  141. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/_reference/resources/patient-create-bonus-PeterChalmers-min.json +53 -0
  142. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/_reference/resources/patient-create-bonus-PeterChalmers-min.xml +30 -0
  143. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/_reference/resources/patient-create-bonus-PeterChalmers.json +108 -0
  144. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/_reference/resources/patient-create-bonus-PeterChalmers.xml +108 -0
  145. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/_reference/resources/patient-update-PeterChalmers-min.json +45 -0
  146. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/_reference/resources/patient-update-PeterChalmers-min.xml +26 -0
  147. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/_reference/resources/patient-update-PeterChalmers.json +100 -0
  148. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/_reference/resources/patient-update-PeterChalmers.xml +102 -0
  149. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/_reference/resources/patient-update-bonus1-PeterChalmers-min.json +53 -0
  150. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/_reference/resources/patient-update-bonus1-PeterChalmers-min.xml +30 -0
  151. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/_reference/resources/patient-update-bonus1-PeterChalmers.json +108 -0
  152. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/_reference/resources/patient-update-bonus1-PeterChalmers.xml +107 -0
  153. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/_reference/resources/patient-update-bonus2-PeterChalmers-min.json +53 -0
  154. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/_reference/resources/patient-update-bonus2-PeterChalmers-min.xml +31 -0
  155. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/_reference/resources/patient-update-bonus2-PeterChalmers.json +108 -0
  156. data/lib/tests/testscripts/xml/Connectathon11/Track1-Patient/_reference/resources/patient-update-bonus2-PeterChalmers.xml +106 -0
  157. data/lib/tests/testscripts/xml/Connectathon11/Track11-SDC/_reference/C-CDA_R2-1_CCD-ussg.xml +3414 -0
  158. data/lib/tests/testscripts/xml/Connectathon11/Track11-SDC/_reference/resources/parameters-A1-empty-on-instance.xml +9 -0
  159. data/lib/tests/testscripts/xml/Connectathon11/Track11-SDC/_reference/resources/parameters-A2-empty-by-ref.xml +15 -0
  160. data/lib/tests/testscripts/xml/Connectathon11/Track11-SDC/_reference/resources/parameters-A3-empty-by-identifier.xml +13 -0
  161. data/lib/tests/testscripts/xml/Connectathon11/Track11-SDC/_reference/resources/parameters-A4-empty-by-contained.xml +15 -0
  162. data/lib/tests/testscripts/xml/Connectathon11/Track11-SDC/_reference/resources/parameters-B1-CCDA-on-instance.xml +15 -0
  163. data/lib/tests/testscripts/xml/Connectathon11/Track11-SDC/_reference/resources/parameters-B2-CCDA-by-ref.xml +21 -0
  164. data/lib/tests/testscripts/xml/Connectathon11/Track11-SDC/_reference/resources/parameters-B3-CCDA-by-identifier.xml +19 -0
  165. data/lib/tests/testscripts/xml/Connectathon11/Track11-SDC/_reference/resources/parameters-B4-CCDA-by-contained.xml +21 -0
  166. data/lib/tests/testscripts/xml/Connectathon11/Track11-SDC/_reference/resources/questionnaire-sdc-profile-example-ussg-fht.xml +3905 -0
  167. data/lib/tests/testscripts/xml/Connectathon11/Track11-SDC/_reference/resources/questionnaireresponse-expected-ussg-fht-CCDA.xml +190 -0
  168. data/lib/tests/testscripts/xml/Connectathon11/Track11-SDC/_reference/resources/questionnaireresponse-expected-ussg-fht-empty.xml +177 -0
  169. data/lib/tests/testscripts/xml/Connectathon11/Track11-SDC/track11-sdc-prepop-xml.xml +142 -0
  170. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/Expand/Client Assigned Id/track2-ts-suite1-expand-client-id.xml +925 -0
  171. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/Expand/Client Assigned Id/track2-ts-suite2-expand-filter-client-id.xml +930 -0
  172. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/Expand/Server Assigned Id/track2-ts-suite1-expand-server-id.xml +953 -0
  173. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/Expand/Server Assigned Id/track2-ts-suite2-expand-filter-server-id.xml +958 -0
  174. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/Lookup/track2-ts-suite5-loinc-lookup-xml.xml +224 -0
  175. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/Lookup/track2-ts-suite5-snomed-lookup-xml.xml +224 -0
  176. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/README.html +85 -0
  177. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/Translate/track2-ts-suite6-translate-xml.xml +224 -0
  178. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/Validate-code/Client Assigned Id/track2-ts-suite3-validate-code-client-id.xml +1807 -0
  179. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/Validate-code/Client Assigned Id/track2-ts-suite4-validate-code-client-id.xml +714 -0
  180. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/Validate-code/Server Assigned Id/track2-ts-suite3-validate-code-server-id.xml +1835 -0
  181. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/Validate-code/Server Assigned Id/track2-ts-suite4-validate-code-server-id.xml +742 -0
  182. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/conformance/ConceptMapSuite6Conformance.xml +11 -0
  183. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/conformance/ValueSetSuite1Conformance.xml +17 -0
  184. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/conformance/ValueSetSuite2Conformance.xml +17 -0
  185. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/conformance/ValueSetSuite3Conformance.xml +14 -0
  186. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/conformance/ValueSetSuite4Conformance.xml +14 -0
  187. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/conformance/ValueSetSuite5Conformance.xml +11 -0
  188. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/input/extensional-case-1-input-4-2-a.xml +11 -0
  189. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/input/extensional-case-1-input-4-2-b.xml +11 -0
  190. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/input/extensional-case-1-input-4-3-a.xml +13 -0
  191. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/input/extensional-case-1-input-4-3-b.xml +13 -0
  192. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/input/extensional-case-1-input-4-4-a.xml +15 -0
  193. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/input/extensional-case-1-input-4-4-b.xml +15 -0
  194. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/input/lookup-loinc-input-5-2.xml +10 -0
  195. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/input/lookup-loinc-input-5-3.xml +11 -0
  196. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/input/lookup-snomed-input-5-2.xml +10 -0
  197. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/input/lookup-snomed-input-5-3.xml +11 -0
  198. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/input/translate-conceptmap-input-6-2.xml +14 -0
  199. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/input/translate-conceptmap-input-6-3.xml +15 -0
  200. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/output/extensional-case-1-expand-min.xml +47 -0
  201. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/output/extensional-case-1-filter-min.xml +23 -0
  202. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/output/extensional-case-2-expand-min.xml +132 -0
  203. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/output/extensional-case-2-filter-min.xml +38 -0
  204. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/output/extensional-case-3-expand-min.xml +252 -0
  205. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/output/extensional-case-3-filter-min.xml +58 -0
  206. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/output/extensional-case-4-expand-min.xml +57 -0
  207. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/output/extensional-case-4-filter-min.xml +28 -0
  208. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/output/intensional-case-1-expand-min.xml +347 -0
  209. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/output/intensional-case-1-filter-min.xml +33 -0
  210. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/output/intensional-case-2-expand-min.xml +637 -0
  211. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/output/intensional-case-2-filter-min.xml +33 -0
  212. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/output/intensional-case-3-filter-min.xml +58 -0
  213. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/output/lookup-loinc-min.xml +11 -0
  214. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/output/lookup-snomed-min.xml +11 -0
  215. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/output/suite3-invalid-min.xml +10 -0
  216. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/output/suite3-valid-min.xml +7 -0
  217. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/output/suite4-invalid-min.xml +10 -0
  218. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/output/suite4-valid-min.xml +7 -0
  219. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/output/translate-conceptmap-min.xml +17 -0
  220. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/resources/extensional-case-1.xml +55 -0
  221. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/resources/extensional-case-2.xml +122 -0
  222. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/resources/extensional-case-3.xml +222 -0
  223. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/resources/extensional-case-4.xml +65 -0
  224. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/resources/intensional-case-1.xml +31 -0
  225. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/resources/intensional-case-2.xml +31 -0
  226. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/resources/intensional-case-3.xml +31 -0
  227. data/lib/tests/testscripts/xml/Connectathon11/Track2-Terminology/_reference/resources/translate-conceptmap-case-1.xml +145 -0
  228. data/lib/tests/testscripts/xml/Connectathon11/Track3-CDS-on-FHIR/_reference/conformance/DecisionSupportServiceModule-Evaluate.xml +17 -0
  229. data/lib/tests/testscripts/xml/Connectathon11/Track3-CDS-on-FHIR/_reference/resources/ecrs-fhir-cdc-immunizations-incomplete-request-payload.xml +26 -0
  230. data/lib/tests/testscripts/xml/Connectathon11/Track3-CDS-on-FHIR/_reference/resources/ecrs-fhir-cdc-immunizations-incomplete-response-min-payload.xml +7 -0
  231. data/lib/tests/testscripts/xml/Connectathon11/Track3-CDS-on-FHIR/_reference/resources/ecrs-fhir-cdc-immunizations-incomplete-response-payload.xml +332 -0
  232. data/lib/tests/testscripts/xml/Connectathon11/Track3-CDS-on-FHIR/_reference/resources/ecrs-fhir-cdc-immunizations-malformed-request-payload.xml +28 -0
  233. data/lib/tests/testscripts/xml/Connectathon11/Track3-CDS-on-FHIR/_reference/resources/ecrs-fhir-cdc-immunizations-malformed-response-min-payload.xml +7 -0
  234. data/lib/tests/testscripts/xml/Connectathon11/Track3-CDS-on-FHIR/_reference/resources/ecrs-fhir-cdc-immunizations-malformed-response-payload.xml +20 -0
  235. data/lib/tests/testscripts/xml/Connectathon11/Track3-CDS-on-FHIR/_reference/resources/ecrs-fhir-cdc-immunizations-request-payload.xml +28 -0
  236. data/lib/tests/testscripts/xml/Connectathon11/Track3-CDS-on-FHIR/_reference/resources/ecrs-fhir-cdc-immunizations-response-min-payload.xml +7 -0
  237. data/lib/tests/testscripts/xml/Connectathon11/Track3-CDS-on-FHIR/_reference/resources/ecrs-fhir-cdc-immunizations-response-payload.xml +332 -0
  238. data/lib/tests/testscripts/xml/Connectathon11/Track3-CDS-on-FHIR/_reference/resources/ecrs-fhir-cdc-immunizations-unauthorized-request-payload.xml +28 -0
  239. data/lib/tests/testscripts/xml/Connectathon11/Track3-CDS-on-FHIR/_reference/resources/ecrs-fhir-cdc-immunizations-unauthorized-response-min-payload.xml +7 -0
  240. data/lib/tests/testscripts/xml/Connectathon11/Track3-CDS-on-FHIR/_reference/resources/ecrs-fhir-cdc-immunizations-unauthorized-response-payload.xml +8 -0
  241. data/lib/tests/testscripts/xml/Connectathon11/Track3-CDS-on-FHIR/_reference/resources/gao-assessment-request-payload.xml +176 -0
  242. data/lib/tests/testscripts/xml/Connectathon11/Track3-CDS-on-FHIR/_reference/resources/gao-assessment-response-payload-min.xml +32 -0
  243. data/lib/tests/testscripts/xml/Connectathon11/Track3-CDS-on-FHIR/_reference/resources/gao-assessment-response-payload.xml +80 -0
  244. data/lib/tests/testscripts/xml/Connectathon11/Track3-CDS-on-FHIR/track3-cds-evaluate-cdc-immunization.xml +290 -0
  245. data/lib/tests/testscripts/xml/Connectathon11/Track3-CDS-on-FHIR/track3-cds-evaluate-gao-profile.xml +110 -0
  246. data/lib/tests/testscripts/xml/Connectathon11/Track6-FHIR-Genomics/Client_Assigned_Id/TestScript_FHIR-Genomics.xml +170 -0
  247. data/lib/tests/testscripts/xml/Connectathon11/Track6-FHIR-Genomics/_reference/resources/sequence-example-1.xml +31 -0
  248. data/lib/tests/testscripts/xml/Connectathon11/Track6-FHIR-Genomics/_reference/resources/sequence-example-2.xml +31 -0
  249. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/Actors.png +0 -0
  250. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/Client_Assigned_Id/track7-laborder100-xml.xml +590 -0
  251. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/Client_Assigned_Id/track7-laborder200-xml.xml +587 -0
  252. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/Client_Assigned_Id/track7-laborder300-xml.xml +612 -0
  253. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/Client_Assigned_Id/track7-laborder400-xml.xml +635 -0
  254. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/Peer-to-Peer/track7-laborder100-peer2peer-xml.xml +752 -0
  255. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/Thumbs.db +0 -0
  256. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/conformance/LabOrderLabReport-CreateDeleteReadUpdate.xml +187 -0
  257. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/conformance/html.xslt +45 -0
  258. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/DiagnosticOrder/do-100-update.xml +64 -0
  259. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/DiagnosticOrder/do-100.xml +64 -0
  260. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/DiagnosticOrder/do-200-update.xml +121 -0
  261. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/DiagnosticOrder/do-200.xml +121 -0
  262. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/DiagnosticOrder/do-300-update.xml +91 -0
  263. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/DiagnosticOrder/do-300.xml +91 -0
  264. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/DiagnosticOrder/do-400-update.xml +88 -0
  265. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/DiagnosticOrder/do-400.xml +88 -0
  266. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/DiagnosticReport/dr-100.xml +96 -0
  267. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/DiagnosticReport/dr-200.xml +125 -0
  268. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/DiagnosticReport/dr-300.xml +132 -0
  269. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/DiagnosticReport/dr-400.xml +121 -0
  270. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Observation/obs-100.xml +58 -0
  271. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Observation/obs-101.xml +58 -0
  272. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Observation/obs-200.xml +125 -0
  273. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Observation/obs-300.xml +106 -0
  274. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Observation/obs-301.xml +106 -0
  275. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Observation/obs-302.xml +106 -0
  276. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Observation/obs-303.xml +106 -0
  277. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Observation/obs-304.xml +106 -0
  278. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Observation/obs-400.xml +87 -0
  279. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Observation/obs-401.xml +95 -0
  280. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Observation/obs-402.xml +95 -0
  281. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Observation/obs-403.xml +84 -0
  282. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Observation/obs-404.xml +84 -0
  283. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Observation/obs-405.xml +83 -0
  284. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Observation/obs-406.xml +83 -0
  285. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Observation/obs-407.xml +70 -0
  286. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Observation/obs-408.xml +84 -0
  287. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Observation/obs-uslab-example5.xml +102 -0
  288. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Order/order-100.xml +61 -0
  289. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Order/order-200.xml +61 -0
  290. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Order/order-300.xml +61 -0
  291. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Order/order-400.xml +61 -0
  292. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/OrderResponse/ordresp-100.xml +79 -0
  293. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/OrderResponse/ordresp-110.xml +79 -0
  294. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/OrderResponse/ordresp-200.xml +79 -0
  295. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/OrderResponse/ordresp-210.xml +79 -0
  296. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/OrderResponse/ordresp-300.xml +79 -0
  297. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/OrderResponse/ordresp-310.xml +79 -0
  298. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/OrderResponse/ordresp-400.xml +79 -0
  299. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/OrderResponse/ordresp-410.xml +79 -0
  300. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Organization/org-uslab-example3.xml +49 -0
  301. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Patient/patient-uslab-example1.xml +44 -0
  302. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Practitioner/pract-uslab-example1.xml +18 -0
  303. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Practitioner/pract-uslab-example3.xml +36 -0
  304. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Specimen/Thumbs.db +0 -0
  305. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Specimen/spec-100.xml +65 -0
  306. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Specimen/spec-400.xml +70 -0
  307. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Specimen/spec-uslab-example1.xml +82 -0
  308. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Testscript 1 Document.txt +122 -0
  309. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Testscript 2 Document.txt +103 -0
  310. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Testscript 3 Document.txt +201 -0
  311. data/lib/tests/testscripts/xml/Connectathon11/Track7-LabOrderLabReport/_reference/resources/Testscript 4 Document.txt +310 -0
  312. data/lib/tests/testscripts/xml/Connectathon11/Track9-Patch/_reference/conformance/MedicationStatementCreate.xml +11 -0
  313. data/lib/tests/testscripts/xml/Connectathon11/Track9-Patch/_reference/conformance/PatientSearchType.xml +15 -0
  314. data/lib/tests/testscripts/xml/Connectathon11/Track9-Patch/_reference/resources/medicationstatement-create.json +39 -0
  315. data/lib/tests/testscripts/xml/Connectathon11/Track9-Patch/_reference/resources/medicationstatement-patch.json +3 -0
  316. data/lib/tests/testscripts/xml/Connectathon11/Track9-Patch/track9-patch-medicationstatement-json-if-match.xml +321 -0
  317. data/lib/tests/testscripts/xml/Connectathon11/Track9-Patch/track9-patch-medicationstatement-json.xml +303 -0
  318. data/lib/tests/testscripts/xml/Connectathon11/Track9-Patch/track9-patch-peer2peer-patient-json.xml +235 -0
  319. data/plan_executor.gemspec +14 -0
  320. data/test/fixtures/diagnostic_bundle.xml +51 -0
  321. data/test/fixtures/lab_results_bundle.xml +49 -0
  322. data/test/fixtures/observation_bundle.json +61 -0
  323. data/test/fixtures/testscript-example.xml +202 -0
  324. data/test/fixtures/testscript-history.xml +143 -0
  325. data/test/fixtures/testscript-readtest.xml +272 -0
  326. data/test/fixtures/testscript-search.xml +282 -0
  327. data/test/fixtures/testscript-update.xml +147 -0
  328. data/test/fixtures/vital_signs_bundle.xml +117 -0
  329. data/test/test_helper.rb +8 -0
  330. data/test/unit/argonaut_sprint6_test.rb +31 -0
  331. data/test/unit/argonaut_sprint7_test.rb +21 -0
  332. data/test/unit/basic_test.rb +27 -0
  333. data/test/unit/fetch_patient_record_test.rb +357 -0
  334. data/test/unit/financial_test.rb +41 -0
  335. data/test/unit/fixtures_test.rb +45 -0
  336. data/test/unit/metadata_test.rb +33 -0
  337. metadata +394 -0
@@ -0,0 +1,480 @@
1
+ module Crucible
2
+ module Tests
3
+ class BaseTestScript < BaseTest
4
+
5
+ FORMAT_MAP = {
6
+ 'json' => FHIR::Formats::ResourceFormat::RESOURCE_JSON,
7
+ 'xml' => FHIR::Formats::ResourceFormat::RESOURCE_XML
8
+ }
9
+
10
+ CODE_MAP = {
11
+ 'okay' => 200,
12
+ 'created' => 201,
13
+ 'noContent' => 204,
14
+ 'notModified' => 304,
15
+ 'bad' => 400,
16
+ 'forbidden' => 403,
17
+ 'notFound' => 404,
18
+ 'methodNotAllowed' => 405,
19
+ 'conflict' => 409,
20
+ 'gone' => 410,
21
+ 'preconditionFailed' => 412,
22
+ 'unprocessable' => 422
23
+ }
24
+
25
+ OPERATOR_MAP = {
26
+ 'equals' => :equals,
27
+ 'notEquals' => :notEquals,
28
+ 'in' => :in,
29
+ 'notIn' => :notIn,
30
+ 'greaterThan' => :greaterThan,
31
+ 'lessThan' => :lessThan,
32
+ 'empty' => :empty,
33
+ 'notEmpty' => :notEmpty,
34
+ 'contains' => :contains,
35
+ 'notContains' => :notContains,
36
+ }
37
+
38
+ def initialize(testscript, client, client2=nil)
39
+ super(client, client2)
40
+ @category = {id: 'testscript', title: 'TestScript'}
41
+ @id_map = {}
42
+ @response_map = {}
43
+ @warnings = []
44
+ @autocreate = []
45
+ @autodelete = []
46
+ @testscript = testscript
47
+ @preprocessed_vars = {}
48
+ define_tests
49
+ load_fixtures
50
+ end
51
+
52
+ def author
53
+ @testscript.name
54
+ end
55
+
56
+ def description
57
+ @testscript.description
58
+ end
59
+
60
+ def id
61
+ @testscript.xmlId
62
+ end
63
+
64
+ def title
65
+ "TS-#{id}"
66
+ end
67
+
68
+ def tests
69
+ @testscript.test.map { |test| "#{test.xmlId} #{test.name} test".downcase.tr(' ', '_').to_sym }
70
+ end
71
+
72
+ def debug_prefix
73
+ "[TESTSCRIPT]:\t"
74
+ end
75
+
76
+ def log(message)
77
+ puts "#{debug_prefix}#{message}"
78
+ end
79
+
80
+ def define_tests
81
+ @testscript.test.each do |test|
82
+ test_method = "#{test.xmlId} #{test.name} test".downcase.tr(' ', '_').to_sym
83
+ define_singleton_method test_method, -> { process_test(test) }
84
+ end
85
+ end
86
+
87
+ def load_fixtures
88
+ @fixtures = {}
89
+ @testscript.fixture.each do |fixture|
90
+ @fixtures[fixture.xmlId] = get_reference(fixture.resource.reference)
91
+ @fixtures[fixture.xmlId].xmlId = nil unless @fixtures[fixture.xmlId].nil? #fixture resources cannot have an ID
92
+ @autocreate << fixture.xmlId if fixture.autocreate
93
+ @autodelete << fixture.xmlId if fixture.autodelete
94
+ end
95
+ end
96
+
97
+ def collect_metadata(methods_only=false)
98
+ @metadata_only = true
99
+ result = execute
100
+ result = result.values.first if methods_only
101
+ @metadata_only = false
102
+ result
103
+ end
104
+
105
+ def process_test(test)
106
+ result = TestResult.new("TS_#{test.xmlId}", test.name, STATUS[:pass], '','')
107
+ @last_response = nil # clear out any responses from previous tests
108
+ @warnings = [] # clear out any previous warnings
109
+ begin
110
+ test.action.each do |action|
111
+ perform_action action
112
+ end unless @setup_failed || @metadata_only
113
+ rescue AssertionException => e
114
+ result.update(STATUS[:fail], e.message, e.data)
115
+ rescue => e
116
+ result.update(STATUS[:error], "Fatal Error: #{e.message}", e.backtrace.join("\n"))
117
+ end
118
+ result.update(STATUS[:skip], "Skipped because setup failed.", "-") if @setup_failed
119
+ result.warnings = @warnings unless @warnings.empty?
120
+ result.requires = []
121
+ result.validates = []
122
+ unless test.metadata.nil?
123
+ test.metadata.capability.each do |capability|
124
+ conf = get_reference(capability.conformance.reference)
125
+ conf.rest.each do |rest|
126
+ interactions = rest.resource.map{|resource| { resource: resource.fhirType, methods: resource.interaction.map(&:code)}}
127
+ result.requires.concat(interactions) if capability.required
128
+ result.validates.concat(interactions) if capability.fhirValidated
129
+ end
130
+ end
131
+ result.links = test.metadata.capability.map(&:link).flatten.uniq
132
+ end
133
+ result
134
+ end
135
+
136
+ def setup
137
+ return if @testscript.setup.blank? && @autocreate.empty?
138
+ @setup_failed = false
139
+ begin
140
+ @autocreate.each do |fixture_id|
141
+ @last_response = @client.create @fixtures[fixture_id]
142
+ @id_map[fixture_id] = @last_response.id
143
+ end unless @client.nil?
144
+ @testscript.setup.action.each do |action|
145
+ perform_action action
146
+ end unless @testscript.setup.blank?
147
+ rescue AssertionException
148
+ @setup_failed = true
149
+ end
150
+ end
151
+
152
+ def teardown
153
+ return if @testscript.teardown.blank? && @autodelete.empty?
154
+ @testscript.teardown.action.each do |action|
155
+ execute_operation action.operation unless action.operation.nil?
156
+ end unless @testscript.teardown.blank?
157
+ @autodelete.each do |fixture_id|
158
+ @last_response = @client.destroy @fixtures[fixture_id].class, @id_map[fixture_id]
159
+ @id_map.delete(fixture_id)
160
+ end unless @client.nil?
161
+ end
162
+
163
+ def perform_action(action)
164
+ execute_operation action.operation unless action.operation.nil?
165
+ handle_assertion action.assert unless action.assert.nil?
166
+ end
167
+
168
+ def execute_operation(operation)
169
+ return if @client.nil?
170
+ requestHeaders = Hash[operation.requestHeader.all.map{|u| [u.field, u.value]}] #Client needs upgrade to support
171
+ format = FHIR::Formats::ResourceFormat::RESOURCE_XML
172
+ format = FORMAT_MAP[operation.contentType] unless operation.contentType.nil?
173
+ format = FORMAT_MAP[operation.accept] unless operation.accept.nil?
174
+
175
+ operationCode = 'empty'
176
+ operationCode = operation.fhirType.code unless operation.fhirType.nil?
177
+
178
+ case operationCode
179
+ when 'read'
180
+ if !operation.targetId.nil?
181
+ @last_response = @client.read @fixtures[operation.targetId].class, @id_map[operation.targetId]
182
+ else
183
+ resource_type = replace_variables(operation.resource)
184
+ resource_id = replace_variables(operation.params)
185
+ @last_response = @client.read "FHIR::#{resource_type}".constantize, id_from_path(resource_id)
186
+ end
187
+ when 'vread'
188
+ raise 'vread not implemented'
189
+ when 'search'
190
+ if operation.url.nil?
191
+ params = extract_operation_parameters(operation)
192
+ @last_response = @client.search "FHIR::#{operation.resource}".constantize, {search: {parameters: params}}, format
193
+ else
194
+ url = replace_variables(operation.url)
195
+ @last_response = @client.search "FHIR::#{operation.resource}".constantize, url: url #todo implement URL
196
+ end
197
+ when 'history'
198
+ target_id = @id_map[operation.targetId]
199
+ fixture = @fixtures[operation.targetId]
200
+ @last_response = @client.resource_instance_history(fixture.class,target_id)
201
+ when 'create'
202
+ @last_response = @client.base_create(@fixtures[operation.sourceId], requestHeaders, format)
203
+ @id_map[operation.sourceId] = @last_response.id
204
+ when 'update'
205
+ target_id = nil
206
+
207
+ if !operation.targetId.nil?
208
+ target_id = @id_map[operation.targetId]
209
+ elsif !operation.params.nil?
210
+ target_id = id_from_path(replace_variables(operation.params))
211
+ end
212
+
213
+ raise "No target specified for update" if target_id.nil?
214
+
215
+ fixture = @fixtures[operation.sourceId]
216
+ fixture.xmlId = replace_variables(target_id) if fixture.xmlId.nil?
217
+ @last_response = @client.update fixture, replace_variables(target_id), format
218
+ when 'transaction'
219
+ raise 'transaction not implemented'
220
+ when 'conformance'
221
+ raise 'conformance not implemented'
222
+ when 'delete'
223
+ if operation.targetId.nil?
224
+ params = replace_variables(operation.params)
225
+ @last_response = @client.destroy "FHIR::#{operation.resource}".constantize, nil, params: params
226
+ else
227
+ @last_response = @client.destroy @fixtures[operation.targetId].class, @id_map[operation.targetId]
228
+ @id_map.delete(operation.targetId)
229
+ end
230
+ when '$expand'
231
+ raise '$expand not supported'
232
+ # @last_response = @client.value_set_expansion( extract_operation_parameters(operation) )
233
+ when '$validate'
234
+ raise '$validate not supported'
235
+ # @last_response = @client.value_set_code_validation( extract_operation_parameters(operation) )
236
+ when '$validate-code'
237
+ raise 'could not find params for $validate-code' unless operation.params
238
+
239
+ params = nil
240
+ # TODO: need to figure this out
241
+ # if operation.params =~ URI::regexp
242
+ # params = CGI.parse(URI.parse(operation.params).query)
243
+ # end
244
+
245
+ raise 'could not find any parameters for $validate-code' unless params
246
+ raise 'could not find system for $validate-code' unless params['system']
247
+ raise 'could not find code for $validate-code' unless params['code']
248
+
249
+ options = {
250
+ :operation => {
251
+ :method => 'GET',
252
+ :parameters => {
253
+ 'code' => { type: 'Code', value: params['code'] },
254
+ 'identifier' => { type: 'Uri', value: params['system'] }
255
+ }
256
+ }
257
+ }
258
+ @last_response = @client.value_set_code_validation(options)
259
+
260
+ when 'empty'
261
+
262
+ if !operation.params.nil? && !operation.resource.nil?
263
+ resource = "FHIR::#{operation.resource}".constantize
264
+ @last_response = @client.read resource, nil, FORMAT_MAP[operation.accept], nil, params: replace_variables(operation.params)
265
+ end
266
+
267
+ else
268
+ raise "Undefined operation for #{@testscript.name}-#{title}: #{operation.fhirType}"
269
+ end
270
+ handle_response(operation)
271
+ end
272
+
273
+ def handle_assertion(assertion)
274
+
275
+ operator = :equals
276
+ operator = OPERATOR_MAP[assertion.operator] unless assertion.operator.nil?
277
+
278
+ warningOnly = false
279
+ warningOnly = assertion.warningOnly unless assertion.warningOnly.nil?
280
+
281
+ case
282
+ when !assertion.contentType.nil?
283
+ call_assertion(:assert_resource_content_type, warningOnly, @last_response, assertion.contentType)
284
+
285
+ when !assertion.headerField.nil?
286
+ call_assertion(:assert_operator, warningOnly, operator, replace_variables(assertion.value), @last_response.response[:headers][assertion.headerField.downcase], "Header field #{assertion.headerField}")
287
+
288
+ when !assertion.minimumId.nil?
289
+ call_assertion(:assert_minimum, warningOnly, @last_response, @fixtures[assertion.minimumId])
290
+
291
+ when !assertion.navigationLinks.nil?
292
+ call_assertion(:assert_navigation_links, warningOnly, @last_response.resource)
293
+
294
+ when !assertion.path.nil?
295
+ actual_value = nil
296
+
297
+ resource_xml = nil
298
+ if assertion.sourceId.nil?
299
+ resource_xml = @last_response.try(:resource).try(:to_xml) || @last_response.body
300
+ else
301
+ resource_xml = @fixtures[assertion.sourceId].try(:to_xml)
302
+ resource_xml = @response_map[assertion.sourceId].try(:resource).try(:to_xml) || @response_map[assertion.soureId].body if resource_xml.nil?
303
+ end
304
+
305
+ actual_value = extract_xpath_value(resource_xml, assertion.path)
306
+
307
+ expected_value = replace_variables(assertion.value)
308
+ unless assertion.compareToSourceId.nil?
309
+ resource_xml = @fixtures[assertion.compareToSourceId].try(:to_xml)
310
+ resource_xml = @response_map[assertion.compareToSourceId].try(:resource).try(:to_xml) || @response_map[assertion.compareToSourceId].body if resource_xml.nil?
311
+
312
+ expected_value = extract_xpath_value(resource_xml, assertion.path)
313
+ end
314
+
315
+ call_assertion(:assert_operator, warningOnly, operator, expected_value, actual_value)
316
+
317
+ when !assertion.resource.nil?
318
+ call_assertion(:assert_resource_type, warningOnly, @last_response, "FHIR::#{assertion.resource}".constantize)
319
+
320
+ when !assertion.responseCode.nil?
321
+ call_assertion(:assert_operator, warningOnly, operator, assertion.responseCode, @last_response.response[:code], "Response Code #{assertion.responseCode}")
322
+
323
+ # call_assertion(:assert_response_code, warningOnly, @last_response, assertion.responseCode)
324
+
325
+ when !assertion.response.nil?
326
+ call_assertion(:assert_response_code, warningOnly, @last_response, CODE_MAP[assertion.response])
327
+
328
+ when !assertion.validateProfileId.nil?
329
+ profile_uri = @testscript.profile.first{|p| p.xmlId = assertion.validateProfileId}.reference
330
+ reply = @client.validate(@last_response.resource,{profile_uri: profile_uri})
331
+ call_assertion(:assert_valid_profile, warningOnly, reply.response, @last_response.resource.class)
332
+
333
+ else
334
+ raise "Unknown Assertion"
335
+
336
+ end
337
+
338
+ end
339
+
340
+ def call_assertion(method, warned, *params)
341
+ if warned
342
+ warning { self.method(method).call(*params) }
343
+ else
344
+ self.method(method).call(*params)
345
+ end
346
+ end
347
+
348
+ def replace_variables(input)
349
+ return nil if input.nil?
350
+
351
+ @testscript.variable.each do |var|
352
+ if !var.headerField.nil?
353
+ variable_source_response = @response_map[var.sourceId]
354
+ variable_value = variable_source_response.response[:headers][var.headerField]
355
+ input.gsub!("${" + var.name + "}", variable_value)
356
+ elsif !var.path.nil?
357
+
358
+ resource_xml = nil
359
+
360
+ variable_source_response = @response_map[var.sourceId]
361
+ unless variable_source_response.nil?
362
+ resource_xml = variable_source_response.try(:resource).try(:to_xml) || variable_source_response.body
363
+ else
364
+ resource_xml = @fixtures[var.sourceId].to_xml
365
+ end
366
+
367
+ extracted_value = extract_xpath_value(resource_xml, var.path)
368
+
369
+ input.gsub!("${" + var.name + "}", extracted_value) unless extracted_value.nil?
370
+
371
+ end if input.include? "${" + var.name + "}"
372
+ end
373
+
374
+ if input.include? '${'
375
+ puts "An unknown variable was unable to be replaced: #{input}!"
376
+ warning { assert !input.include?('${'), "An unknown variable was unable to be substituted: #{input}" }
377
+ end
378
+
379
+ input
380
+ end
381
+
382
+ def extract_operation_parameters(operation)
383
+ parameters = {}
384
+ return parameters if operation.params.nil?
385
+ params = operation.params
386
+ params = operation.params[1..-1] if operation.params.length > 0 && operation.params[0] == "?"
387
+ params.split("&").each do |param|
388
+ key, value = param.split("=")
389
+ parameters[key.to_sym] = replace_variables(value)
390
+ end unless operation.params.blank?
391
+ parameters
392
+ end
393
+
394
+ def handle_response(operation)
395
+ if !operation.responseId.blank? && operation.fhirType.code != 'delete'
396
+ log "Overwriting response #{operation.responseId}..." if @response_map.keys.include?(operation.responseId)
397
+ log "Storing response #{operation.responseId}..."
398
+ @response_map[operation.responseId] = @last_response
399
+ end
400
+ end
401
+
402
+ def extract_xpath_value(resource_xml, resource_xpath)
403
+
404
+ # Massage the xpath if it doesn't have fhir: namespace or if doesn't end in @value
405
+ # Also make it look in the entire xml document instead of just starting at the root
406
+ resource_xpath = resource_xpath.split("/").map{|s| if s.starts_with?("fhir:") || s.length == 0 then s else "fhir:#{s}" end}.join("/")
407
+ resource_xpath = "#{resource_xpath}/@value" unless resource_xpath.ends_with? "/@value"
408
+ resource_xpath = "//#{resource_xpath}"
409
+
410
+ resource_doc = Nokogiri::XML(resource_xml)
411
+ resource_doc.root.add_namespace_definition('fhir', 'http://hl7.org/fhir')
412
+ resource_element = resource_doc.xpath(resource_xpath)
413
+
414
+ # This doesn't work on warningOnly; consider putting back in place
415
+ # raise AssertionException.new("[#{resource_xpath}] resolved to multiple values instead of a single value", resource_element.to_s) if resource_element.length>1
416
+ resource_element.first.try(:value)
417
+ end
418
+
419
+ def id_from_path(path)
420
+ path[1..-1]
421
+ end
422
+
423
+ def get_reference(reference)
424
+ resource = nil
425
+ if reference.start_with?('#')
426
+ contained_id = reference[1..-1]
427
+ resource = @testscript.contained.select{|r| r.xmlId == contained_id}.first
428
+ else
429
+ root = File.expand_path '.', File.dirname(File.absolute_path(__FILE__))
430
+ return nil unless File.exist? "#{root}/xml#{reference}"
431
+ file = File.open("#{root}/xml#{reference}", "r:UTF-8", &:read)
432
+ file.encode!('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
433
+ file = preprocess(file) if file.include?('${')
434
+ if reference.split('.').last == "json"
435
+ resourceType = JSON.parse(file)["resourceType"]
436
+ resource = "FHIR::#{resourceType}".constantize.from_fhir_json(file)
437
+ else
438
+ resourceType = Nokogiri::XML(file).children.find{|x| x.class == Nokogiri::XML::Element}.name
439
+ fhirType = "FHIR::#{resourceType}".constantize
440
+ if fhirType.respond_to? :from_xml
441
+ resource = fhirType.from_xml(file)
442
+ else
443
+ puts "Unable to load reference: Method from_xml undefined on FHIR::#{resourceType}"
444
+ end
445
+
446
+ end
447
+ end
448
+
449
+ resource
450
+ end
451
+
452
+ def preprocess(input)
453
+ # ${C4}: generates a 4 character string
454
+ # ${D5}: generates a 5 digit number
455
+ # ${CD6}: generates a 6 character string with digits and characters
456
+ output = input;
457
+ input.scan(/\${(\w+)}/).each do |match|
458
+ if @preprocessed_vars.key?(match[0])
459
+ output.sub!("${#{match[0]}}", @preprocessed_vars[match[0]])
460
+ else
461
+ code_matches = /^([a-zA-Z]+)(\d+)$/.match(match[0])
462
+ continue unless code_matches.size == 3
463
+ mock_data = generate_mock_data(code_matches[1], code_matches[2].to_i)
464
+ output.sub!("${#{match[0]}}", mock_data)
465
+ @preprocessed_vars[match[0]] = mock_data
466
+ end
467
+ end
468
+
469
+ output
470
+ end
471
+
472
+ def generate_mock_data(type, length)
473
+ choices = []
474
+ choices << ('a'..'z') << ('A'..'Z') if type.downcase.include?('c') #add uppercase and lowercase characters as a choice
475
+ choices << (0..9) if type.downcase.include?('d') #add digits as a choice
476
+ (choices * length).map(&:to_a).flatten.shuffle[0,length].join #generate a random string based on all the choices
477
+ end
478
+ end
479
+ end
480
+ end
@@ -0,0 +1,81 @@
1
+ module Crucible
2
+ module Tests
3
+ class TestScriptEngine
4
+
5
+ @@models = []
6
+
7
+ def initialize(client=nil, client2=nil)
8
+ @client = client
9
+ @client2 = client2
10
+ @scripts = []
11
+ load_testscripts
12
+ end
13
+
14
+ def tests
15
+ @scripts
16
+ end
17
+
18
+ def find_test(key)
19
+ @scripts.find{|s| s.id == key || s.title == key} || []
20
+ end
21
+
22
+ def execute_all
23
+ results = {}
24
+ self.tests.each do |test|
25
+ # TODO: Do we want to separate out multiserver tests?
26
+ next if test.multiserver
27
+ results.merge! test.execute
28
+ end
29
+ results
30
+ end
31
+
32
+ def self.list_all(metadata=false)
33
+ list = {}
34
+ # TODO: Determine if we need resource-based testscript listing support
35
+ TestScriptEngine.new.tests.each do |test|
36
+ list[test.title] = {}
37
+ BaseTest::JSON_FIELDS.each {|field| list[test.title][field] = test.send(field)}
38
+ if metadata
39
+ test_metadata = test.collect_metadata(true)
40
+ BaseTest::METADATA_FIELDS.each do |field|
41
+ field_hash = {}
42
+ test_metadata.each { |tm| field_hash[tm[:test_method]] = tm[field] }
43
+ list[test.title][field] = field_hash
44
+ end
45
+ end
46
+ end
47
+ list
48
+ end
49
+
50
+ def load_testscripts
51
+ return unless @scripts.empty?
52
+ @@models.each do |model|
53
+ @scripts << BaseTestScript.new(model, @client, @client2)
54
+ end
55
+ end
56
+
57
+ def self.parse_testscript_xml
58
+ return unless @@models.empty?
59
+ # get all TestScript's in testscripts/xml
60
+ root = File.expand_path '.', File.dirname(File.absolute_path(__FILE__))
61
+ files = File.join(root, 'xml', '**/*.xml')
62
+ Dir.glob(files).each do |f|
63
+ next if f.include? "/_reference/" # to support connectathon11 fixtures; review if there is a better way
64
+ next if f.include? "Track11-SDC" # uses STU3 models
65
+ next if f.include? "Track3-CDS-on-FHIR" # uses STU3 models
66
+ next if f.include? "Track9-Patch" # uses Patch
67
+ next if f.include? "Track6-FHIR-Genomics" # uses STU3 models
68
+
69
+ #TODO: these can be finished with DSTU2
70
+ next if f.include? "Track2-Terminology"
71
+ next if f.include? "Track7-LabOrderLabReport"
72
+
73
+ @@models << FHIR::TestScript.from_xml( File.read(f) )
74
+ end
75
+ end
76
+
77
+ end
78
+
79
+ end
80
+ end
81
+ Crucible::Tests::TestScriptEngine.parse_testscript_xml