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,354 @@
1
+ module Crucible
2
+ module Tests
3
+ class ConnectathonAuditEventAndProvenanceTrackTest < BaseSuite
4
+
5
+ def id
6
+ 'ConnectathonAuditEventAndProvenanceTrackTest'
7
+ end
8
+
9
+ def description
10
+ 'Connectathon AuditEvent and Provenance Track Test focuses on server-created AuditEvents and Provenance resources.'
11
+ end
12
+
13
+ def initialize(client1, client2=nil)
14
+ super(client1, client2)
15
+ @category = {id: 'connectathon', title: 'Connectathon'}
16
+ end
17
+
18
+ def setup
19
+ @resources = Crucible::Generator::Resources.new
20
+ end
21
+
22
+ def teardown
23
+ @client.destroy(FHIR::Provenance, @provenance1.xmlId) if @provenance1 && !@provenance1.xmlId.nil?
24
+ @client.destroy(FHIR::Provenance, @provenance2.xmlId) if @provenance2 && !@provenance2.xmlId.nil?
25
+ @client.destroy(FHIR::Provenance, @provenance3.xmlId) if @provenance3 && !@provenance3.xmlId.nil?
26
+ @client.destroy(FHIR::Provenance, @provenance4.xmlId) if @provenance4 && !@provenance4.xmlId.nil?
27
+ @client.destroy(FHIR::Patient, @patient.xmlId) if @patient && !@patient.xmlId.nil?
28
+ @client.destroy(FHIR::Patient, @patient1.xmlId) if @patient1 && !@patient1.xmlId.nil?
29
+ @client.destroy(FHIR::Patient, @patient2.xmlId) if @patient2 && !@patient2.xmlId.nil?
30
+ FHIR::ResourceAddress::DEFAULTS.delete('X-Provenance') # just in case
31
+ end
32
+
33
+ # Create a Patient then check for AuditEvent
34
+ test 'CAEP1','Create a Patient then check for AuditEvent' do
35
+ metadata {
36
+ links "#{REST_SPEC_LINK}#create"
37
+ links "#{BASE_SPEC_LINK}/patient.html"
38
+ links "#{REST_SPEC_LINK}#search"
39
+ links "#{BASE_SPEC_LINK}/auditevent.html"
40
+ links 'http://wiki.hl7.org/index.php?title=FHIR_Connectathon_10#Track_4_-EHR_record_lifecycle_architecture'
41
+ requires resource: 'Patient', methods: ['create']
42
+ requires resource: 'AuditEvent', methods: ['search']
43
+ validates resource: 'Patient', methods: ['create']
44
+ validates resource: 'AuditEvent', methods: ['search']
45
+ validates resource: nil, methods: ['Audit Logging', 'audit event']
46
+ }
47
+ @patient = @resources.minimal_patient
48
+ @patient.xmlId = nil # clear the identifier
49
+ reply = @client.create(@patient)
50
+ assert_response_ok(reply)
51
+ @patient.xmlId = reply.id
52
+
53
+ options = {
54
+ :search => {
55
+ :flag => false,
56
+ :compartment => nil,
57
+ :parameters => {
58
+ 'reference' => "Patient/#{@patient.xmlId}"
59
+ }
60
+ }
61
+ }
62
+ reply = @client.search(FHIR::AuditEvent, options)
63
+ assert_response_ok(reply)
64
+ assert_bundle_response(reply)
65
+ assert_equal(1, reply.resource.entry.size, 'There should only be one AuditEvent for the test Patient currently in the system.', reply.body)
66
+ assert(reply.resource.entry[0].try(:resource).try(:object).try(:reference).include?(@patient.xmlId), 'The correct AuditEvent was not returned.', reply.body)
67
+ warning { assert_equal('110110', reply.resource.entry[0].try(:resource).try(:event).try(:type).try(:code), 'Was expecting an AuditEvent.event.type.code of 110110 (Patient Record).', reply.body) }
68
+ end
69
+
70
+ # Create a Patient with Provenance as a transaction
71
+ test 'CAEP2','Create a Patient with Provenance as transaction' do
72
+ metadata {
73
+ links "#{REST_SPEC_LINK}#create"
74
+ links "#{BASE_SPEC_LINK}/patient.html"
75
+ links "#{REST_SPEC_LINK}#search"
76
+ links "#{BASE_SPEC_LINK}/provenance.html"
77
+ links "#{BASE_SPEC_LINK}/provenance.html#6.4.4.2" # submit as transaction
78
+ links 'http://wiki.hl7.org/index.php?title=FHIR_Connectathon_10#Track_4_-EHR_record_lifecycle_architecture'
79
+ requires resource: 'Patient', methods: ['create']
80
+ requires resource: 'Provenance', methods: ['search']
81
+ validates resource: 'Patient', methods: ['create']
82
+ validates resource: 'Provenance', methods: ['search']
83
+ validates resource: nil, methods: ['transaction-system', 'provenance']
84
+ }
85
+
86
+ @patient1 = @resources.minimal_patient
87
+ @patient1.xmlId = 'foo'
88
+
89
+ @provenance1 = FHIR::Provenance.new
90
+ @provenance1.target = [ FHIR::Reference.new ]
91
+ @provenance1.target[0].reference = "Patient/#{@patient1.xmlId}"
92
+ @provenance1.recorded = DateTime.now.strftime("%Y-%m-%dT%T.%LZ%z")
93
+ @provenance1.reason = [ FHIR::CodeableConcept.new ]
94
+ @provenance1.reason[0].text = 'New patient'
95
+
96
+ @client.begin_transaction
97
+ @client.add_transaction_request('POST',nil,@patient1)
98
+ @client.add_transaction_request('POST',nil,@provenance1)
99
+ reply = @client.end_transaction
100
+
101
+ # set the patient id as nil, until we know that the transaction was successful, so teardown doesn't try
102
+ # to delete something that wasn't created
103
+ @patient1.xmlId = nil
104
+
105
+ assert_response_ok(reply)
106
+ assert_bundle_response(reply)
107
+
108
+ # set the patient id back from nil to whatever the server created
109
+ @patient1.xmlId = FHIR::ResourceAddress.pull_out_id('Patient',reply.resource.entry[0].try(:response).try(:location))
110
+ @provenance1.xmlId = FHIR::ResourceAddress.pull_out_id('Provenance',reply.resource.entry[1].try(:response).try(:location))
111
+
112
+ options = {
113
+ :search => {
114
+ :flag => false,
115
+ :compartment => nil,
116
+ :parameters => {
117
+ 'target' => "Patient/#{@patient1.xmlId}"
118
+ }
119
+ }
120
+ }
121
+ reply = @client.search(FHIR::Provenance, options)
122
+ assert_response_ok(reply)
123
+ assert_bundle_response(reply)
124
+ assert_equal(1, reply.resource.entry.size, 'There should only be one Provenance for the test Patient currently in the system.', reply.body)
125
+ assert(reply.resource.entry[0].try(:resource).try(:target).try(:first).try(:reference).include?(@patient1.xmlId), 'The correct Provenance was not returned.', reply.body)
126
+ end
127
+
128
+ # Create a Patient with a Provenance header:
129
+ # Grahame says: "json format, in the X-Provenance header - I'll pick it up and store it after fixing the target reference (just leave target blank)"
130
+ test 'CAEP2X','Create a Patient with X-Provenance header' do
131
+ metadata {
132
+ links "#{REST_SPEC_LINK}#create"
133
+ links "#{BASE_SPEC_LINK}/patient.html"
134
+ links "#{REST_SPEC_LINK}#search"
135
+ links "#{BASE_SPEC_LINK}/provenance.html"
136
+ links 'http://wiki.hl7.org/index.php?title=FHIR_Connectathon_10#Track_4_-EHR_record_lifecycle_architecture'
137
+ requires resource: 'Patient', methods: ['create']
138
+ requires resource: 'Provenance', methods: ['search']
139
+ validates resource: 'Patient', methods: ['create']
140
+ validates resource: 'Provenance', methods: ['search']
141
+ }
142
+
143
+ @patient2 = @resources.minimal_patient
144
+ @patient2.xmlId = nil # clear the identifier
145
+
146
+ @provenance2 = FHIR::Provenance.new
147
+ @provenance2.target = [ FHIR::Reference.new ]
148
+ # @provenance2.target[0].reference = "Patient/#{@patient2.xmlId}"
149
+ @provenance2.recorded = DateTime.now.strftime("%Y-%m-%dT%T.%LZ%z")
150
+ @provenance2.reason = [ FHIR::CodeableConcept.new ]
151
+ @provenance2.reason[0].text = 'New patient'
152
+
153
+ FHIR::ResourceAddress::DEFAULTS['X-Provenance'] = @provenance2.to_fhir_json
154
+ reply = @client.create(@patient2)
155
+ FHIR::ResourceAddress::DEFAULTS.delete('X-Provenance')
156
+
157
+ assert_response_ok(reply)
158
+ @patient2.xmlId = reply.id
159
+
160
+ options = {
161
+ :search => {
162
+ :flag => false,
163
+ :compartment => nil,
164
+ :parameters => {
165
+ 'target' => "Patient/#{@patient2.xmlId}"
166
+ }
167
+ }
168
+ }
169
+ reply = @client.search(FHIR::Provenance, options)
170
+ assert_response_ok(reply)
171
+ assert_bundle_response(reply)
172
+ assert_equal(1, reply.resource.entry.size, 'There should only be one Provenance for the test Patient currently in the system.', reply.body)
173
+ assert(reply.resource.entry[0].try(:resource).try(:target).try(:first).try(:reference).include?(@patient2.xmlId), 'The correct Provenance was not returned.', reply.body)
174
+ @provenance2.xmlId = FHIR::ResourceAddress.pull_out_id('Provenance',reply.resource.entry[0].try(:response).try(:location))
175
+ end
176
+
177
+ # Update a Patient and check for AuditEvent
178
+ test 'CAEP3','Update a Patient then check for AuditEvent' do
179
+ metadata {
180
+ links "#{REST_SPEC_LINK}#update"
181
+ links "#{BASE_SPEC_LINK}/patient.html"
182
+ links "#{REST_SPEC_LINK}#search"
183
+ links "#{BASE_SPEC_LINK}/auditevent.html"
184
+ links 'http://wiki.hl7.org/index.php?title=FHIR_Connectathon_10#Track_4_-EHR_record_lifecycle_architecture'
185
+ requires resource: 'Patient', methods: ['create','update']
186
+ requires resource: 'AuditEvent', methods: ['search']
187
+ validates resource: 'Patient', methods: ['update']
188
+ validates resource: 'AuditEvent', methods: ['search']
189
+ }
190
+ @patient.gender = 'male'
191
+ reply = @client.update(@patient,@patient.xmlId)
192
+ assert_response_ok(reply)
193
+
194
+ options = {
195
+ :search => {
196
+ :flag => false,
197
+ :compartment => nil,
198
+ :parameters => {
199
+ 'reference' => "Patient/#{@patient.xmlId}"
200
+ }
201
+ }
202
+ }
203
+ reply = @client.search(FHIR::AuditEvent, options)
204
+ assert_response_ok(reply)
205
+ assert_bundle_response(reply)
206
+ assert_equal(2, reply.resource.entry.size, 'There should be two AuditEvents for the test Patient currently in the system.', reply.body)
207
+ reply.resource.entry.each do |entry|
208
+ assert(entry.try(:resource).try(:object).try(:reference).include?(@patient.xmlId), 'An incorrect AuditEvent was returned.', reply.body)
209
+ warning { assert_equal('110110', entry.try(:resource).try(:event).try(:type).try(:code), 'Was expecting an AuditEvent.event.type.code of 110110 (Patient Record).', reply.body) }
210
+ end
211
+ end
212
+
213
+ # Update a Patient with Provenance as a transaction
214
+ test 'CAEP4','Update a Patient with Provenance as transaction' do
215
+ metadata {
216
+ links "#{REST_SPEC_LINK}#update"
217
+ links "#{BASE_SPEC_LINK}/patient.html"
218
+ links "#{REST_SPEC_LINK}#search"
219
+ links "#{BASE_SPEC_LINK}/provenance.html"
220
+ links "#{BASE_SPEC_LINK}/provenance.html#6.4.4.2" # submit as transaction
221
+ links 'http://wiki.hl7.org/index.php?title=FHIR_Connectathon_10#Track_4_-EHR_record_lifecycle_architecture'
222
+ requires resource: 'Patient', methods: ['create','update']
223
+ requires resource: 'Provenance', methods: ['search']
224
+ validates resource: 'Patient', methods: ['update']
225
+ validates resource: 'Provenance', methods: ['search']
226
+ validates resource: nil, methods: ['transaction-system', 'provenance']
227
+ }
228
+ @patient1.gender = 'male'
229
+
230
+ @provenance3 = FHIR::Provenance.new
231
+ @provenance3.target = [ FHIR::Reference.new ]
232
+ @provenance3.target[0].reference = "Patient/#{@patient1.xmlId}"
233
+ @provenance3.recorded = DateTime.now.strftime("%Y-%m-%dT%T.%LZ%z")
234
+ @provenance3.reason = [ FHIR::CodeableConcept.new ]
235
+ @provenance3.reason[0].text = 'Update Gender'
236
+
237
+ @client.begin_transaction
238
+ @client.add_transaction_request('PUT',nil,@patient1)
239
+ @client.add_transaction_request('POST',nil,@provenance3)
240
+ reply = @client.end_transaction
241
+
242
+ assert_response_ok(reply)
243
+ assert_bundle_response(reply)
244
+
245
+ @provenance3.xmlId = FHIR::ResourceAddress.pull_out_id('Provenance',reply.resource.entry[1].try(:response).try(:location))
246
+
247
+ options = {
248
+ :search => {
249
+ :flag => false,
250
+ :compartment => nil,
251
+ :parameters => {
252
+ 'target' => "Patient/#{@patient1.xmlId}"
253
+ }
254
+ }
255
+ }
256
+ reply = @client.search(FHIR::Provenance, options)
257
+ assert_response_ok(reply)
258
+ assert_bundle_response(reply)
259
+ assert_equal(2, reply.resource.entry.size, 'There should be two Provenance resources for the test Patient currently in the system.', reply.body)
260
+ reply.resource.entry.each do |entry|
261
+ assert(entry.try(:resource).try(:target).try(:first).try(:reference).include?(@patient1.xmlId), 'An incorrect Provenance was returned.', reply.body)
262
+ end
263
+ end
264
+
265
+ # Update a Patient with a Provenance header:
266
+ # Grahame says: "json format, in the X-Provenance header - I'll pick it up and store it after fixing the target reference (just leave target blank)"
267
+ test 'CAEP4X','Update a Patient with X-Provenance header' do
268
+ metadata {
269
+ links "#{REST_SPEC_LINK}#create"
270
+ links "#{BASE_SPEC_LINK}/patient.html"
271
+ links "#{REST_SPEC_LINK}#search"
272
+ links "#{BASE_SPEC_LINK}/provenance.html"
273
+ links 'http://wiki.hl7.org/index.php?title=FHIR_Connectathon_10#Track_4_-EHR_record_lifecycle_architecture'
274
+ requires resource: 'Patient', methods: ['create']
275
+ requires resource: 'Provenance', methods: ['search']
276
+ validates resource: 'Patient', methods: ['create']
277
+ validates resource: 'Provenance', methods: ['search']
278
+ validates resource: nil, methods: ['provenance']
279
+ }
280
+
281
+ @patient2.gender = 'male'
282
+
283
+ @provenance4 = FHIR::Provenance.new
284
+ @provenance4.target = [ FHIR::Reference.new ]
285
+ @provenance4.target[0].reference = "Patient/#{@patient2.xmlId}"
286
+ @provenance4.recorded = DateTime.now.strftime("%Y-%m-%dT%T.%LZ%z")
287
+ @provenance4.reason = [ FHIR::CodeableConcept.new ]
288
+ @provenance4.reason[0].text = 'Update Gender'
289
+
290
+ FHIR::ResourceAddress::DEFAULTS['X-Provenance'] = @provenance4.to_fhir_json
291
+ reply = @client.update(@patient2,@patient2.xmlId)
292
+ FHIR::ResourceAddress::DEFAULTS.delete('X-Provenance')
293
+ assert_response_ok(reply)
294
+
295
+
296
+ options = {
297
+ :search => {
298
+ :flag => false,
299
+ :compartment => nil,
300
+ :parameters => {
301
+ 'target' => "Patient/#{@patient2.xmlId}"
302
+ }
303
+ }
304
+ }
305
+ reply = @client.search(FHIR::Provenance, options)
306
+ assert_response_ok(reply)
307
+ assert_bundle_response(reply)
308
+ assert_equal(2, reply.resource.entry.size, 'There should be two Provenance resources for the test Patient currently in the system.', reply.body)
309
+ reply.resource.entry.each do |entry|
310
+ assert(entry.try(:resource).try(:target).try(:first).try(:reference).include?(@patient2.xmlId), 'An incorrect Provenance was returned.', reply.body)
311
+ end
312
+ @provenance3.xmlId = FHIR::ResourceAddress.pull_out_id('Provenance',reply.resource.entry[0].try(:response).try(:location))
313
+ @provenance4.xmlId = FHIR::ResourceAddress.pull_out_id('Provenance',reply.resource.entry[1].try(:response).try(:location))
314
+ end
315
+
316
+ # Read a Patient and check for AuditEvent
317
+ test 'CAEP5','Read a Patient and check for AuditEvent' do
318
+ metadata {
319
+ links "#{REST_SPEC_LINK}#read"
320
+ links "#{BASE_SPEC_LINK}/patient.html"
321
+ links "#{REST_SPEC_LINK}#search"
322
+ links "#{BASE_SPEC_LINK}/auditevent.html"
323
+ links 'http://wiki.hl7.org/index.php?title=FHIR_Connectathon_10#Track_4_-EHR_record_lifecycle_architecture'
324
+ requires resource: 'Patient', methods: ['create','read']
325
+ requires resource: 'AuditEvent', methods: ['search']
326
+ validates resource: 'Patient', methods: ['read']
327
+ validates resource: 'AuditEvent', methods: ['search']
328
+ validates resource: nil, methods: ['Audit Logging', 'audit event']
329
+ }
330
+ reply = @client.read(FHIR::Patient,@patient.xmlId)
331
+ assert_response_ok(reply)
332
+
333
+ options = {
334
+ :search => {
335
+ :flag => false,
336
+ :compartment => nil,
337
+ :parameters => {
338
+ 'reference' => "Patient/#{@patient.xmlId}"
339
+ }
340
+ }
341
+ }
342
+ reply = @client.search(FHIR::AuditEvent, options)
343
+ assert_response_ok(reply)
344
+ assert_bundle_response(reply)
345
+ assert_equal(3, reply.resource.entry.size, 'There should be three AuditEvents for the test Patient currently in the system.', reply.body)
346
+ reply.resource.entry.each do |entry|
347
+ assert(entry.try(:resource).try(:object).try(:reference).include?(@patient.xmlId), 'An incorrect AuditEvent was returned.', reply.body)
348
+ warning { assert_equal('110110', entry.try(:resource).try(:event).try(:type).try(:code), 'Was expecting an AuditEvent.event.type.code of 110110 (Patient Record).', reply.body) }
349
+ end
350
+ end
351
+
352
+ end
353
+ end
354
+ end