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,553 @@
1
+ module Crucible
2
+ module Tests
3
+ class ResourceTest < BaseSuite
4
+
5
+ attr_accessor :resource_class
6
+ attr_accessor :bundle
7
+ attr_accessor :history_bundle
8
+
9
+ attr_accessor :temp_resource
10
+ attr_accessor :temp_id
11
+ attr_accessor :temp_version
12
+
13
+ attr_accessor :preexisting_id
14
+ attr_accessor :preexisting_version
15
+ attr_accessor :preexisting
16
+
17
+ def execute(resource_class=nil)
18
+ if resource_class
19
+ @resource_class = resource_class
20
+ {"ResourceTest_#{@resource_class.name.demodulize}" => execute_test_methods}
21
+ else
22
+ results = {}
23
+ fhir_resources.each do | klass |
24
+ @resource_class = klass
25
+ results.merge!({"ResourceTest_#{@resource_class.name.demodulize}" => execute_test_methods})
26
+ end
27
+ results
28
+ end
29
+ end
30
+
31
+ def id
32
+ suffix = resource_class
33
+ suffix = resource_class.name.demodulize if !resource_class.nil?
34
+ "ResourceTest_#{suffix}"
35
+ end
36
+
37
+ def description
38
+ "Basic operations for FHIR #{resource_class.name.demodulize} resource (CREATE, READ, VREAD, UPDATE, DELETE, HISTORY, SEARCH, VALIDATE)"
39
+ end
40
+
41
+ def category
42
+ resource = @resource_class.nil? ? "Uncategorized" : resource_category(@resource_class.name.demodulize)
43
+ {id: "resources_#{resource.parameterize}", title: "#{resource} Resources"}
44
+ end
45
+
46
+ def initialize(client1, client2=nil)
47
+ super(client1, client2)
48
+ end
49
+
50
+ # this allows results to have unique ids for resource based tests
51
+ def result_id_suffix
52
+ resource_class.name.demodulize
53
+ end
54
+
55
+ def supplement_test_description(desc)
56
+ "#{resource_class.name.demodulize}: #{desc}"
57
+ end
58
+
59
+ #
60
+ # Get and read all the resources of this type. Result is an XML ATOM bundle.
61
+ #
62
+ test 'X000', 'Read Type' do
63
+ metadata {
64
+ define_metadata('read')
65
+ }
66
+
67
+ reply = @client.read_feed(@resource_class)
68
+ @bundle = reply.resource
69
+ assert_bundle_response reply
70
+ assert !@bundle.nil?, 'Service did not respond with bundle.'
71
+ end
72
+
73
+ #
74
+ # Test if we can create a new resource and post it to the server.
75
+ #
76
+ test 'X010', 'Create New' do
77
+ metadata {
78
+ define_metadata('create')
79
+ }
80
+
81
+ result = TestResult.new('X010',"Create new #{resource_class.name.demodulize}", nil, nil, nil)
82
+ @temp_resource = ResourceGenerator.generate(@resource_class,3)
83
+ reply = @client.create @temp_resource
84
+ @temp_id = reply.id
85
+ @temp_resource.xmlId = (reply.resource.try(:xmlId) || reply.id)
86
+ @temp_version = reply.version
87
+
88
+ if reply.code==201
89
+ result.update(STATUS[:pass], "New #{resource_class.name.demodulize} was created.", reply.body)
90
+ else
91
+ outcome = (self.parse_operation_outcome(reply.body) rescue nil)
92
+ if outcome.nil?
93
+ message = "Response code #{reply.code} with no OperationOutcome provided."
94
+ else
95
+ message = self.build_messages(outcome)
96
+ end
97
+ result.update(STATUS[:fail], message, reply.body)
98
+ @temp_resource = nil
99
+ end
100
+
101
+ result
102
+ end
103
+
104
+ #
105
+ # Test if we can read a preexisting resource
106
+ #
107
+ test 'X020', 'Read Existing' do
108
+ metadata {
109
+ define_metadata('read')
110
+ }
111
+
112
+ result = TestResult.new('X020',"Read existing #{resource_class.name.demodulize} by ID", nil, nil, nil)
113
+ if !@bundle.nil? && @bundle.total && @bundle.total>0 && @bundle.entry && !@bundle.entry[0].nil? && !@bundle.entry[0].resource.nil?
114
+ @preexisting_id = @bundle.entry[0].resource.xmlId
115
+ elsif !@temp_resource.nil?
116
+ @preexisting_id = @temp_id
117
+ else
118
+ raise AssertionException.new("Preexisting #{resource_class.name.demodulize} unknown.", nil)
119
+ end
120
+
121
+ reply = @client.read(@resource_class, @preexisting_id)
122
+ @preexisting = reply.resource
123
+
124
+ if @preexisting.nil?
125
+ raise AssertionException.new("Failed to read preexisting #{resource_class.name.demodulize}: #{@preexisting_id}", reply.body)
126
+ else
127
+ begin
128
+ @preexisting.to_xml
129
+ rescue Exception
130
+ @preexisting = nil
131
+ raise AssertionException.new("Read preexisting #{resource_class.name.demodulize}, but it appears invalid.", reply.response)
132
+ end
133
+ end
134
+
135
+ @preexisting_version = reply.version
136
+
137
+ result.update(STATUS[:pass], "Successfully read preexisting #{resource_class.name.demodulize}.", reply.response)
138
+ result
139
+ end
140
+
141
+ #
142
+ # Test if we can update a preexisting resource.
143
+ #
144
+ test 'X030', 'Update Existing' do
145
+ metadata {
146
+ define_metadata('update')
147
+ }
148
+
149
+ result = TestResult.new('X030',"Update existing #{resource_class.name.demodulize} by ID", nil, nil, nil)
150
+
151
+ if !@temp_resource.nil?
152
+ @preexisting_id = @temp_id
153
+ @preexisting = @temp_resource
154
+ elsif !@bundle.nil? && @bundle.total && @bundle.total>0 && @bundle.entry && !@bundle.entry[0].nil? && !@bundle.entry[0].resource.nil?
155
+ @preexisting_id = @bundle.entry[0].resource.xmlId
156
+ @preexisting = @bundle.entry[0].resource
157
+ end
158
+
159
+ if !@preexisting.nil?
160
+ begin
161
+ @preexisting.to_xml
162
+ rescue Exception
163
+ @preexisting = nil
164
+ end
165
+ end
166
+
167
+ if @preexisting.nil?
168
+ result.update(STATUS[:skip], "Unable to update -- existing #{resource_class.name.demodulize} is not available or was not valid.", nil)
169
+ else
170
+ ResourceGenerator.set_fields!(@preexisting)
171
+ ResourceGenerator.apply_invariants!(@preexisting)
172
+
173
+ reply = @client.update @preexisting, @preexisting_id
174
+
175
+ if reply.code==200
176
+ result.update(STATUS[:pass], "Updated existing #{resource_class.name.demodulize}.", reply.body)
177
+ elsif reply.code==201
178
+ # check created id -- see if it matches the one we used, or is new
179
+ resulting_id = reply.id
180
+
181
+ if(@preexisting_id != resulting_id)
182
+ result.update(STATUS[:fail], "Server created (201) new #{resource_class.name.demodulize} rather than update (200). A new ID (#{resulting_id}) was also created (was #{@preexisting_id}).", reply.body)
183
+ else
184
+ result.update(STATUS[:fail], "The #{resource_class.name.demodulize} was successfully updated, but the server responded with the wrong code (201, but should have been 200).", reply.body)
185
+ end
186
+
187
+ resulting_version = reply.version
188
+ if(@preexisting_version == resulting_version)
189
+ result.update(STATUS[:fail], "The #{resource_class.name.demodulize} was successfully updated, but the server did not update the resource version number.", reply.body)
190
+ end
191
+ else
192
+ outcome = self.parse_operation_outcome(reply.body) rescue nil
193
+ if outcome.nil?
194
+ message = "Response code #{reply.code} with no OperationOutcome provided."
195
+ else
196
+ message = self.build_messages(outcome)
197
+ end
198
+ result.update(STATUS[:fail], message, reply.body)
199
+ end
200
+ end
201
+
202
+ result
203
+ end
204
+
205
+ #
206
+ # Test if we can retrieve the history of a preexisting resource.
207
+ #
208
+ test 'X040', 'Read History of existing' do
209
+ metadata {
210
+ define_metadata('history')
211
+ }
212
+
213
+ result = TestResult.new('X040',"Read history of existing #{resource_class.name.demodulize} by ID", nil, nil, nil)
214
+
215
+ if @preexisting_id.nil?
216
+ result.update(STATUS[:skip], "Preexisting #{resource_class.name.demodulize} unknown.", nil)
217
+ else
218
+ reply = @client.resource_instance_history(@resource_class, @preexisting_id)
219
+ @history_bundle = reply.resource
220
+ if @history_bundle.nil?
221
+ raise AssertionException.new('Service did not respond with bundle.', nil)
222
+ end
223
+ result.update(STATUS[:pass], 'Service responded with bundle.', reply.body)
224
+ end
225
+ result
226
+ end
227
+
228
+ #
229
+ # Test if we can read a specific version of a preexisting resource.
230
+ #
231
+ test 'X050', 'Version read existing' do
232
+ metadata {
233
+ define_metadata('vread')
234
+ }
235
+
236
+ result = TestResult.new('X050',"Version read existing #{resource_class.name.demodulize} by ID", nil, nil, nil)
237
+
238
+ if !@history_bundle.nil? && @history_bundle.total && @history_bundle.total>0 && @history_bundle.entry && !@history_bundle.entry[0].nil? && !@history_bundle.entry[0].resource.nil?
239
+ @preexisting = @history_bundle.entry[0].resource
240
+ @preexisting_id = @preexisting.xmlId
241
+ @preexisting_version = nil
242
+ @preexisting_version = @preexisting.meta.versionId if !@preexisting.meta.nil?
243
+ elsif !@temp_resource.nil?
244
+ @preexisting_id = @temp_id
245
+ @preexisting_version = @temp_version
246
+ @preexisting = @temp_resource
247
+ end
248
+
249
+ if @preexisting.nil?
250
+ result.update(STATUS[:skip], "Preexisting #{resource_class.name.demodulize} unknown.", nil)
251
+ else
252
+ reply = @client.vread(@resource_class, @preexisting_id, @preexisting_version)
253
+ if reply.resource.nil?
254
+ raise AssertionException.new("Server failed to return preexisting #{resource_class.name.demodulize}.", reply.body)
255
+ elsif reply.code != 200
256
+ raise AssertionException.new("Server returned preexisting #{resource_class.name.demodulize}, but responded with HTTP#{reply.code}.", nil)
257
+ elsif (reply.id != @preexisting_id) and (reply.version != @preexisting_version)
258
+ raise AssertionException.new("Server did not respond with correct information in the content-location header.", nil)
259
+ end
260
+ result.update(STATUS[:pass], "Read current version of preexisting #{resource_class.name.demodulize}.", reply.body)
261
+ end
262
+ result
263
+ end
264
+
265
+ #
266
+ # Test if we can read a specific version of a preexisting resource.
267
+ #
268
+ test 'X055', 'Previous version read existing' do
269
+ metadata {
270
+ define_metadata('vread')
271
+ }
272
+
273
+ result = TestResult.new('X055',"Previous version read existing #{resource_class.name.demodulize} by ID", nil, nil, nil)
274
+
275
+ if !@history_bundle.nil? && @history_bundle.total && @history_bundle.total>0 && @history_bundle.entry && !@history_bundle.entry[0].nil? && !@history_bundle.entry[0].resource.nil?
276
+ @preexisting = @history_bundle.entry[0].resource
277
+ @preexisting_id = @preexisting.xmlId
278
+ @preexisting_version = nil
279
+ @preexisting_version = @preexisting.meta.versionId if !@preexisting.meta.nil?
280
+ end
281
+
282
+ if @preexisting.nil?
283
+ result.update(STATUS[:skip],"Previous version of #{resource_class.name.demodulize} unavailable.", nil)
284
+ else
285
+ reply = @client.vread(@resource_class, @preexisting_id, @preexisting_version)
286
+ if reply.resource.nil?
287
+ raise AssertionException.new("Server failed to return preexisting #{resource_class.name.demodulize}.", reply.body)
288
+ elsif reply.code != 200
289
+ raise AssertionException.new("Server returned preexisting #{resource_class.name.demodulize}, but responded with HTTP#{reply.code}.", nil)
290
+ elsif (reply.id != @preexisting_id) and (reply.version != @preexisting_version)
291
+ raise AssertionException.new("Server did not respond with correct information in the content-location header.", nil)
292
+ end
293
+ result.update(STATUS[:pass], "Read previous version of preexisting #{resource_class.name.demodulize}.", reply.body)
294
+ end
295
+ result
296
+ end
297
+
298
+
299
+ #
300
+ # Validate the representation of a given resource.
301
+ #
302
+ # Interestingly, this functionality is deprecated in the latest "Continuous Integration" branch.
303
+ #
304
+ test 'X060', 'Validate' do
305
+ metadata {
306
+ define_metadata('$validate')
307
+ validates profiles: ['validate-profile']
308
+ }
309
+
310
+ result = TestResult.new('X060',"Validate #{resource_class.name.demodulize}", nil, nil, nil)
311
+
312
+ @temp_resource = ResourceGenerator.generate(@resource_class,3)
313
+ reply = @client.validate @temp_resource
314
+ if reply.code==200
315
+ result.update(STATUS[:pass], "#{resource_class.name.demodulize} was validated.", reply.body)
316
+ elsif reply.code==201
317
+ result.update(STATUS[:fail], "Server created a #{resource_class.name.demodulize} with the ID `_validate` rather than validate the resource.", reply.body)
318
+ else
319
+ outcome = self.parse_operation_outcome(reply.body) rescue nil
320
+ if outcome.nil?
321
+ message = "Response code #{reply.code} with no OperationOutcome provided."
322
+ else
323
+ message = self.build_messages(outcome)
324
+ end
325
+ result.update(STATUS[:fail], message, reply.body)
326
+ end
327
+
328
+ result
329
+ end
330
+
331
+ #
332
+ # Validate the representation of an existing resource.
333
+ #
334
+ # Interestingly, this functionality is deprecated in the latest "Continuous Integration" branch.
335
+ #
336
+ test 'X065', 'Validate Existing' do
337
+ metadata {
338
+ define_metadata('$validate')
339
+ validates profiles: ['validate-profile']
340
+ }
341
+
342
+ result = TestResult.new('X065',"Validate existing #{resource_class.name.demodulize}", nil, nil, nil)
343
+
344
+ if !@bundle.nil? && @bundle.total && @bundle.total>0 && @bundle.entry && !@bundle.entry[0].nil? && !@bundle.entry[0].resource.nil?
345
+ @preexisting_id = @bundle.entry[0].resource.xmlId
346
+ @preexisting = @bundle.entry[0].resource
347
+ elsif !@temp_resource.nil?
348
+ @preexisting_id = @temp_id
349
+ @preexisting = @temp_resource
350
+ end
351
+
352
+ if !@preexisting.nil?
353
+ begin
354
+ @preexisting.to_xml
355
+ rescue Exception
356
+ @preexisting = nil
357
+ end
358
+ end
359
+
360
+ if @preexisting.nil?
361
+ result.update(STATUS[:skip], "Unable to validate -- existing #{resource_class.name.demodulize} is not available or was not valid.", nil)
362
+ else
363
+ # ResourceGenerator.set_fields!(@preexisting)
364
+ # ResourceGenerator.apply_invariants!(@preexisting)
365
+
366
+ reply = @client.validate_existing(@preexisting, @preexisting_id)
367
+
368
+ if reply.code==200
369
+ result.update(STATUS[:pass], "Existing #{resource_class.name.demodulize} was validated.", reply.body)
370
+ elsif reply.code==201
371
+ result.update(STATUS[:fail], "Server created a #{resource_class.name.demodulize} with the ID `_validate` rather than validate the resource.", reply.body)
372
+ elsif reply.code==400
373
+ outcome = self.parse_operation_outcome(reply.body) rescue nil
374
+
375
+ if outcome.nil?
376
+ message = "Response code #{reply.code} with no OperationOutcome provided."
377
+ result.update(STATUS[:fail], message, reply.body)
378
+ else
379
+ message = self.build_messages(outcome)
380
+ invalid_codes = ['invalid','structure','required','value','invariant']
381
+ security_codes = ['security','login','unknown','expired','forbidden','suppressed']
382
+ processing_codes = ['processing','not-supported','duplicate','not-found','too-long','code-invalid','extension','too-costly','business-rule','conflict','incomplete']
383
+ transient_codes = ['transient','lock-error','no-store','exception','timeout','throttled']
384
+
385
+ status = :pass
386
+ outcome.issue.each do |issue|
387
+ if ['fatal','error'].include?(issue.severity)
388
+ status = :fail if security_codes.include?(issue.code) || transient_codes.include?(issue.code)
389
+ end
390
+ end
391
+ result.update(STATUS[status], message, reply.body)
392
+ end
393
+ else
394
+ outcome = self.parse_operation_outcome(reply.body) rescue nil
395
+ if outcome.nil?
396
+ message = "Response code #{reply.code} with no OperationOutcome provided."
397
+ else
398
+ message = self.build_messages(outcome)
399
+ end
400
+ result.update(STATUS[:fail], message, reply.body)
401
+ end
402
+ end
403
+
404
+ result
405
+ end
406
+
407
+ #
408
+ # Validate the representation of a resource against a given profile.
409
+ #
410
+ # The client can ask the server to validate against a particular resource by attaching a profile tag to the resource.
411
+ # This is an assertion that the resource conforms to the specified profile(s), and the server can check this.
412
+ #
413
+ # Profile Tag has an HTTP header named "Category" with three parts:
414
+ # scheme: [uri] "http://hl7.org/fhir/tag/profile"
415
+ # term: [uri] In a profile tag, the term is a URL that references a profile resource.
416
+ # label: [string] (optional) A human-readable label for the tag for use when displaying in end-user applications
417
+ #
418
+ # Category: [Tag Term]; scheme="[Tag Scheme]"; label="[Tag label]"(, ...)
419
+ #
420
+ # Interestingly, this functionality is deprecated in the latest "Continuous Integration" branch.
421
+ #
422
+ test 'X067', 'Validate against a profile' do
423
+ metadata {
424
+ define_metadata('$validate')
425
+ validates profiles: ['validate-profile']
426
+ }
427
+
428
+ profile_uri = "http://hl7.org/fhir/StructureDefinition/#{resource_class.name.demodulize}" # the profile to validate with
429
+
430
+ result = TestResult.new('X067',"Validate #{resource_class.name.demodulize} against a profile", nil, nil, nil)
431
+
432
+ @temp_resource = ResourceGenerator.generate(@resource_class,3)
433
+ reply = @client.validate(@temp_resource,{profile_uri: profile_uri})
434
+ if reply.code==200
435
+ result.update(STATUS[:pass], "#{resource_class.name.demodulize} was validated.", reply.body)
436
+ elsif reply.code==201
437
+ result.update(STATUS[:fail], "Server created a #{resource_class.name.demodulize} with the ID `_validate` rather than validate the resource.", reply.body)
438
+ else
439
+ outcome = self.parse_operation_outcome(reply.body) rescue nil
440
+ if outcome.nil?
441
+ message = "Response code #{reply.code} with no OperationOutcome provided."
442
+ else
443
+ message = self.build_messages(outcome)
444
+ end
445
+ result.update(STATUS[:fail], message, reply.body)
446
+ end
447
+
448
+ result
449
+ end
450
+
451
+ #
452
+ # Test if we can delete a preexisting resource.
453
+ #
454
+ # 204 == deleted
455
+ # 405 == not allowed
456
+ # 404 == not found
457
+ # 409 == conflict, cannot be deleted (e.g. referential integrity won't allow it)
458
+ #
459
+ test 'X070', 'Delete Existing' do
460
+ metadata {
461
+ define_metadata('delete')
462
+ }
463
+
464
+ @x070_success = false
465
+ result = TestResult.new('X070',"Delete existing #{resource_class.name.demodulize}", nil, nil, nil)
466
+
467
+ if !@temp_resource.nil?
468
+ @preexisting_id = @temp_id
469
+ @preexisting = @temp_resource
470
+ end
471
+ if @preexisting_id.nil? &&!@bundle.nil? && @bundle.total && @bundle.total>0 && @bundle.entry && !@bundle.entry[0].nil? && !@bundle.entry[0].resource.nil?
472
+ @preexisting_id = @bundle.entry[0].resource.xmlId
473
+ @preexisting = @bundle.entry[0].resource
474
+ end
475
+
476
+ if @preexisting_id.nil?
477
+ result.update(STATUS[:skip],"Preexisting #{resource_class.name.demodulize} unknown.", nil)
478
+ else
479
+ reply = @client.destroy(@resource_class,@preexisting_id)
480
+ if reply.code==204
481
+ @x070_success = true
482
+ result.update(STATUS[:pass], "Existing #{resource_class.name.demodulize} was deleted.", reply.body)
483
+ elsif reply.code==405
484
+ outcome = self.parse_operation_outcome(reply.body) rescue nil
485
+ message = self.build_messages(outcome)
486
+ message.unshift "Server does not allow deletion of #{resource_class.name.demodulize}"
487
+ result.update(STATUS[:fail], message, reply.body)
488
+ elsif reply.code==404
489
+ outcome = self.parse_operation_outcome(reply.body) rescue nil
490
+ message = self.build_messages(outcome)
491
+ message.unshift "Server was unable to find (404 not found) the #{resource_class.name.demodulize} with the ID `#{preexisting_id}`"
492
+ result.update(STATUS[:fail], message, reply.body)
493
+ elsif reply.code==409
494
+ outcome = self.parse_operation_outcome(reply.body) rescue nil
495
+ message = self.build_messages(outcome)
496
+ message.unshift "Server had a conflict try to delete the #{resource_class.name.demodulize} with the ID `#{preexisting_id}"
497
+ result.update(STATUS[:fail], message, reply.body)
498
+ else
499
+ outcome = self.parse_operation_outcome(reply.body) rescue nil
500
+ message = self.build_messages(outcome)
501
+ result.update(STATUS[:fail], message, reply.body)
502
+ end
503
+ end
504
+
505
+ result
506
+ end
507
+
508
+ test 'X075', 'Get Deleted Resource' do
509
+ metadata {
510
+ define_metadata('delete')
511
+ }
512
+ skip unless @x070_success
513
+
514
+ result = TestResult.new('X075',"Get Deleted #{resource_class.name.demodulize}", nil, nil, nil)
515
+
516
+ if !@temp_resource.nil?
517
+ @preexisting_id = @temp_id
518
+ @preexisting = @temp_resource
519
+ end
520
+ if @preexisting_id.nil? &&!@bundle.nil? && @bundle.total && @bundle.total>0 && @bundle.entry && !@bundle.entry[0].nil? && !@bundle.entry[0].resource.nil?
521
+ @preexisting_id = @bundle.entry[0].resource.xmlId
522
+ @preexisting = @bundle.entry[0].resource
523
+ end
524
+
525
+ if @preexisting_id.nil?
526
+ result.update(STATUS[:skip],"Preexisting #{resource_class.name.demodulize} unknown.", nil)
527
+ else
528
+ reply = @client.read(@resource_class,@preexisting_id)
529
+ if reply.code==410
530
+ result.update(STATUS[:pass], "Deleted #{resource_class.name.demodulize} was correctly reported as gone.", reply.body)
531
+ elsif reply.code==404
532
+ message = "Deleted #{resource_class.name.demodulize} was reported as unknown (404). If the system tracks deleted resources, it should respond with 410."
533
+ result.update(STATUS[:pass], message , reply.body)
534
+ result.warnings = [ message ]
535
+ else
536
+ outcome = self.parse_operation_outcome(reply.body) rescue nil
537
+ message = self.build_messages(outcome)
538
+ result.update(STATUS[:fail], message, reply.body)
539
+ end
540
+ end
541
+
542
+ result
543
+ end
544
+
545
+ def define_metadata(method)
546
+ links "#{REST_SPEC_LINK}##{method}"
547
+ links "#{BASE_SPEC_LINK}/#{resource_class.name.demodulize.downcase}.html"
548
+ validates resource: resource_class.name.demodulize, methods: [method]
549
+ end
550
+
551
+ end
552
+ end
553
+ end