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,656 @@
1
+ module Crucible
2
+ module Tests
3
+ class ResourceGenerator
4
+
5
+ #
6
+ # Generate a FHIR resource for the given class `klass`
7
+ # If `embedded` is greater than zero, all embedded children will also
8
+ # be generated.
9
+ #
10
+ def self.generate(klass,embedded=0)
11
+ resource = klass.new
12
+ Time.zone = 'UTC'
13
+ set_fields!(resource)
14
+ if(embedded > 0)
15
+ generate_children!(resource,embedded)
16
+ end
17
+ resource.xmlId=nil if resource.respond_to?(:xmlId=)
18
+ resource.versionId=nil if resource.respond_to?(:versionId=)
19
+ resource.version=nil if resource.respond_to?(:version=)
20
+ resource.text=nil if [FHIR::Bundle,FHIR::Binary,FHIR::Parameters].include?(klass)
21
+ apply_invariants!(resource)
22
+ resource
23
+ end
24
+
25
+ #
26
+ # Set the fields of this resource to have some random values.
27
+ #
28
+ def self.set_fields!(resource)
29
+ # Organize some of the validators
30
+ validators = {}
31
+ resource.class.validators.collect{|v| v if v.class==Mongoid::Validatable::FormatValidator}.compact.each do |v|
32
+ v.attributes.each{|a| validators[a] = v.options[:with]}
33
+ end
34
+
35
+ # For now, we'll skip fields that can have multiple datatypes, such as attribute[x]
36
+ multiples = []
37
+ if resource.class.constants.include? :MULTIPLE_TYPES
38
+ multiples = resource.class::MULTIPLE_TYPES.map{|k,v| v}.flatten
39
+ end
40
+
41
+ # Get valid codes
42
+ valid_codes = {}
43
+ if resource.class.constants.include? :VALID_CODES
44
+ valid_codes = resource.class::VALID_CODES
45
+ end
46
+
47
+ # Get special codes
48
+ special_codes = {}
49
+ if resource.class.constants.include? :SPECIAL_CODES
50
+ special_codes = resource.class::SPECIAL_CODES
51
+ end
52
+
53
+ fields = resource.fields
54
+ fields.each do |key,value|
55
+ type = value.options[:type]
56
+ next if ['id','xmlId','version','versionId','implicitRules'].include? key
57
+ next if multiples.include? key
58
+ gen = nil
59
+ if type == String
60
+ gen = SecureRandom.base64
61
+ if valid_codes[key.to_sym]
62
+ valid_values = valid_codes[key.to_sym]
63
+ if !valid_values.nil?
64
+ gen = valid_values[ SecureRandom.random_number( valid_values.length ) ]
65
+ end
66
+ elsif validators[key.to_sym]
67
+ date = DateTime.now
68
+ regex = validators[key.to_sym]
69
+ if date.strftime("%Y-%m-%dT%T.%LZ").match(regex)
70
+ gen = date.strftime("%Y-%m-%dT%T.%LZ")
71
+ elsif date.strftime("%Y-%m-%d").match(regex)
72
+ gen = date.strftime("%Y-%m-%d")
73
+ elsif date.strftime("%T").match(regex)
74
+ gen = date.strftime("%T")
75
+ end
76
+ elsif special_codes[key.to_sym]
77
+ if special_codes[key.to_sym]=='MimeType'
78
+ gen = 'text/plain'
79
+ elsif special_codes[key.to_sym]=='Language'
80
+ gen = 'en-US'
81
+ end
82
+ end
83
+ elsif type == Integer
84
+ gen = (SecureRandom.random_number(100) + 1) # add one in case this is a "positiveInt" which must be > 0
85
+ elsif type == Float
86
+ gen = SecureRandom.random_number
87
+ while gen.to_s.match(/e/) # according to FHIR spec: decimals may not contain exponents
88
+ gen = SecureRandom.random_number
89
+ end
90
+ elsif type == Mongoid::Boolean
91
+ gen = (SecureRandom.random_number(100) % 2 == 0)
92
+ elsif type == BSON::Binary
93
+ # gen = SecureRandom.random_bytes
94
+ gen = SecureRandom.base64
95
+ elsif type == BSON::ObjectId or type == Array or type == Object or type == FHIR::AnyType
96
+ gen = nil # ignore
97
+ # else
98
+ # puts "Unable to generate field #{key} for #{resource.class} -- unrecognized type: #{type}"
99
+ end
100
+ gen='en-US' if(key=='language' && type==String)
101
+ resource[key] = gen if !gen.nil?
102
+ end
103
+ resource
104
+ end
105
+
106
+
107
+ #
108
+ # Generate children for this resource.
109
+ #
110
+ def self.generate_children!(resource,embedded=0)
111
+ # For now, we'll skip fields that can have multiple datatypes, such as attribute[x]
112
+ multiples = []
113
+ if resource.class.constants.include? :MULTIPLE_TYPES
114
+ multiples = resource.class::MULTIPLE_TYPES.map{|k,v| v}.flatten
115
+ end
116
+
117
+ children = resource.embedded_relations
118
+ children.each do |key,value|
119
+ # TODO: Determine if we can generate references or meta information
120
+ next if ['meta'].include? key
121
+ next if multiples.include? key
122
+
123
+ klass = resource.get_fhir_class_from_resource_type(value[:class_name])
124
+ case klass
125
+ when FHIR::Reference
126
+ child = FHIR::Reference.new
127
+ child.display = "#{key} #{SecureRandom.base64}"
128
+ when FHIR::CodeableConcept
129
+ child = FHIR::CodeableConcept.new
130
+ child.text = "#{key} #{SecureRandom.base64}"
131
+ when FHIR::Coding
132
+ child = FHIR::Coding.new
133
+ child.display = "#{key} #{SecureRandom.base64}"
134
+ when FHIR::Quantity
135
+ child = FHIR::Quantity.new
136
+ child.value = SecureRandom.random_number
137
+ while child.value.to_s.match(/e/) # according to FHIR spec: decimals may not contain exponents
138
+ child.value = SecureRandom.random_number
139
+ end
140
+ child.unit = SecureRandom.base64
141
+ else
142
+ child = generate(klass,(embedded-1)) if(!['FHIR::Extension','FHIR::PrimitiveExtension','FHIR::Signature'].include?(value[:class_name]))
143
+ end
144
+
145
+ case klass
146
+ when FHIR::Identifier
147
+ child.system = nil
148
+ when FHIR::Attachment
149
+ child.url = nil
150
+ end
151
+
152
+ if value[:relation] == Mongoid::Relations::Embedded::Many
153
+ child = ([] << child) if child
154
+ end
155
+ resource[key] = child if child
156
+ end
157
+ resource
158
+ end
159
+
160
+ def self.random_oid
161
+ oid = "urn:oid:2"
162
+ SecureRandom.random_number(12).times do |i|
163
+ oid = "#{oid}.#{SecureRandom.random_number(500)}"
164
+ end
165
+ oid
166
+ end
167
+
168
+ def self.minimal_patient(identifier='0',name='Name')
169
+ resource = FHIR::Patient.new
170
+ resource.identifier = [ minimal_identifier(identifier) ]
171
+ resource.name = [ minimal_humanname(name) ]
172
+ resource
173
+ end
174
+
175
+ # Common systems:
176
+ # SNOMED http://snomed.info/sct
177
+ # LOINC http://loinc.org
178
+ # ICD-10 http://hl7.org/fhir/sid/icd-10
179
+ # units: must be UCOM
180
+ def self.minimal_observation(system='http://loinc.org',code='8302-2',value=170,units='cm',patientId=nil)
181
+ resource = FHIR::Observation.new
182
+ resource.status = 'final'
183
+ resource.code = minimal_codeableconcept(system,code)
184
+ if patientId
185
+ ref = FHIR::Reference.new
186
+ ref.reference = "Patient/#{patientId}"
187
+ resource.subject = ref
188
+ end
189
+ resource.valueQuantity = minimal_quantity(value,units)
190
+ resource
191
+ end
192
+
193
+ # Default system/code are for SNOMED "Obese (finding)"
194
+ def self.minimal_condition(system='http://snomed.info/sct',code='414915002',patientId=nil)
195
+ resource = FHIR::Condition.new
196
+ resource.patient = FHIR::Reference.new
197
+ if patientId
198
+ resource.patient.reference = "Patient/#{patientId}"
199
+ else
200
+ resource.patient.display = 'Patient'
201
+ end
202
+ resource.code = minimal_codeableconcept(system,code)
203
+ resource.verificationStatus = 'confirmed'
204
+ resource
205
+ end
206
+
207
+ def self.minimal_identifier(identifier='0')
208
+ mid = FHIR::Identifier.new
209
+ mid.use = 'official'
210
+ mid.system = 'http://projectcrucible.org'
211
+ mid.value = identifier
212
+ mid
213
+ end
214
+
215
+ def self.minimal_humanname(name='Name')
216
+ hn = FHIR::HumanName.new
217
+ hn.use = 'official'
218
+ hn.family = [ 'Crucible' ]
219
+ hn.given = [ name ]
220
+ hn.text = "#{hn.given[0]} #{hn.family[0]}"
221
+ hn
222
+ end
223
+
224
+ def self.textonly_codeableconcept(text='text')
225
+ concept = FHIR::CodeableConcept.new
226
+ concept.text = text
227
+ concept
228
+ end
229
+
230
+ def self.textonly_reference(text='Reference')
231
+ ref = FHIR::Reference.new
232
+ ref.display = "#{text} #{SecureRandom.base64}"
233
+ ref
234
+ end
235
+
236
+ # Common systems:
237
+ # SNOMED http://snomed.info/sct
238
+ # LOINC http://loinc.org
239
+ # ICD-10 http://hl7.org/fhir/sid/icd-10
240
+ def self.minimal_codeableconcept(system='http://loinc.org',code='8302-2')
241
+ concept = FHIR::CodeableConcept.new
242
+ concept.coding = [ minimal_coding(system,code) ]
243
+ concept
244
+ end
245
+
246
+ # Common systems:
247
+ # SNOMED http://snomed.info/sct
248
+ # LOINC http://loinc.org
249
+ # ICD-10 http://hl7.org/fhir/sid/icd-10
250
+ def self.minimal_coding(system='http://loinc.org',code='8302-2')
251
+ coding = FHIR::Coding.new
252
+ coding.system = system
253
+ coding.code = code
254
+ coding
255
+ end
256
+
257
+ def self.minimal_quantity(value=170,units='cm')
258
+ quantity = FHIR::Quantity.new
259
+ quantity.value = value
260
+ quantity.unit = units
261
+ quantity.system = 'http://unitsofmeasure.org'
262
+ quantity
263
+ end
264
+
265
+ def self.minimal_animal
266
+ animal = FHIR::Patient::AnimalComponent.new
267
+ animal.species = minimal_codeableconcept('http://hl7.org/fhir/animal-species','canislf') # dog
268
+ animal.breed = minimal_codeableconcept('http://hl7.org/fhir/animal-breed','gret') # golden retriever
269
+ animal.genderStatus = minimal_codeableconcept('http://hl7.org/fhir/animal-genderstatus','intact') # intact
270
+ animal
271
+ end
272
+
273
+ def self.apply_invariants!(resource)
274
+ case resource.class
275
+ when FHIR::Appointment
276
+ resource.reason = minimal_codeableconcept('http://snomed.info/sct','219006') # drinker of alcohol
277
+ resource.participant.each{|p| p.fhirType=[ minimal_codeableconcept('http://hl7.org/fhir/participant-type','emergency') ] }
278
+ when FHIR::AppointmentResponse
279
+ resource.participantType = [ minimal_codeableconcept('http://hl7.org/fhir/participant-type','emergency') ]
280
+ when FHIR::AuditEvent
281
+ resource.object.each do |o|
282
+ o.query=nil
283
+ o.name = "name #{SecureRandom.base64}" if o.name.nil?
284
+ end
285
+ when FHIR::Bundle
286
+ resource.total = nil if !['searchset','history'].include?(resource.fhirType)
287
+ resource.entry.each {|e|e.search=nil} if resource.fhirType!='searchset'
288
+ resource.entry.each {|e|e.request=nil} if !['batch','transaction','history'].include?(resource.fhirType)
289
+ resource.entry.each {|e|e.response=nil} if !['batch-response','transaction-response'].include?(resource.fhirType)
290
+ head = resource.entry.first
291
+ if !head.nil?
292
+ if head.request.nil? && head.response.nil? && head.resource.nil?
293
+ if resource.fhirType == 'document'
294
+ head.resource = generate(FHIR::Composition,3)
295
+ elsif resource.fhirType == 'message'
296
+ head.resource = generate(FHIR::MessageHeader,3)
297
+ else
298
+ head.resource = generate(FHIR::Basic,3)
299
+ end
300
+ end
301
+ if head.resource.nil?
302
+ head.fullUrl = nil
303
+ else
304
+ rid = SecureRandom.random_number(100) + 1
305
+ head.fullUrl = "http://projectcrucible.org/fhir/#{rid}"
306
+ head.resource.xmlId = "#{rid}"
307
+ end
308
+ end
309
+ when FHIR::CarePlan
310
+ resource.activity.each {|a| a.reference = nil if a.detail }
311
+ when FHIR::Claim
312
+ resource.item.each do |item|
313
+ item.fhirType = minimal_coding('http://hl7.org/fhir/v3/ActCode','OHSINV')
314
+ item.detail.each do |detail|
315
+ detail.fhirType = minimal_coding('http://hl7.org/fhir/v3/ActCode','OHSINV')
316
+ detail.subDetail.each do |sub|
317
+ sub.fhirType = minimal_coding('http://hl7.org/fhir/v3/ActCode','OHSINV')
318
+ sub.service = minimal_coding('http://hl7.org/fhir/ex-USCLS','1205')
319
+ end
320
+ end
321
+ end
322
+ resource.missingTeeth.each do |mt|
323
+ mt.tooth = minimal_coding('http://hl7.org/fhir/ex-fdi','42')
324
+ end
325
+ when FHIR::ClaimResponse
326
+ resource.item.each do |item|
327
+ item.adjudication.each{|a|a.code = minimal_coding('http://hl7.org/fhir/adjudication','benefit')}
328
+ item.detail.each do |detail|
329
+ detail.adjudication.each{|a|a.code = minimal_coding('http://hl7.org/fhir/adjudication','benefit')}
330
+ detail.subDetail.each do |sub|
331
+ sub.adjudication.each{|a|a.code = minimal_coding('http://hl7.org/fhir/adjudication','benefit')}
332
+ end
333
+ end
334
+ end
335
+ resource.addItem.each do |addItem|
336
+ addItem.adjudication.each{|a|a.code = minimal_coding('http://hl7.org/fhir/adjudication','benefit')}
337
+ addItem.detail.each do |detail|
338
+ detail.adjudication.each{|a|a.code = minimal_coding('http://hl7.org/fhir/adjudication','benefit')}
339
+ end
340
+ end
341
+ when FHIR::Communication
342
+ resource.payload = nil
343
+ when FHIR::CommunicationRequest
344
+ resource.payload = nil
345
+ when FHIR::Composition
346
+ resource.attester.each {|a| a.mode = ['professional']}
347
+ resource.section.each do |section|
348
+ section.emptyReason = nil
349
+ section.section.each do |sub|
350
+ sub.emptyReason = nil
351
+ sub.section = nil
352
+ end
353
+ end
354
+ when FHIR::ConceptMap
355
+ if(resource.sourceUri.nil? && resource.sourceReference.nil?)
356
+ resource.sourceReference = textonly_reference('ValueSet')
357
+ end
358
+ if(resource.targetUri.nil? && resource.targetReference.nil?)
359
+ resource.targetReference = textonly_reference('ValueSet')
360
+ end
361
+ when FHIR::Conformance
362
+ resource.fhirVersion = 'DSTU2'
363
+ resource.format = ['xml','json']
364
+ if resource.kind == 'capability'
365
+ resource.implementation = nil
366
+ elsif resource.kind == 'requirements'
367
+ resource.implementation = nil
368
+ resource.software = nil
369
+ end
370
+ resource.messaging.each{|m| m.endpoint = nil} if resource.kind != 'instance'
371
+ when FHIR::Contract
372
+ resource.actor.each do |actor|
373
+ actor.entity = textonly_reference('Patient')
374
+ end
375
+ resource.term.each do |term|
376
+ term.actor.each do |actor|
377
+ actor.entity = textonly_reference('Organization')
378
+ end
379
+ term.group.each do |group|
380
+ group.actor.each do |actor|
381
+ actor.entity = textonly_reference('Organization')
382
+ end
383
+ end
384
+ end
385
+ resource.friendly.each do |f|
386
+ f.contentAttachment = nil
387
+ f.contentReference = textonly_reference('DocumentReference')
388
+ end
389
+ resource.legal.each do |f|
390
+ f.contentAttachment = nil
391
+ f.contentReference = textonly_reference('DocumentReference')
392
+ end
393
+ resource.rule.each do |f|
394
+ f.contentAttachment = nil
395
+ f.contentReference = textonly_reference('DocumentReference')
396
+ end
397
+ when FHIR::DataElement
398
+ resource.mapping.each do |m|
399
+ m.fhirIdentity = SecureRandom.base64 if m.fhirIdentity.nil?
400
+ m.fhirIdentity.gsub!(/[^0-9A-Za-z]/, '')
401
+ end
402
+ when FHIR::DeviceMetric
403
+ resource.measurementPeriod = nil
404
+ when FHIR::DiagnosticReport
405
+ date = DateTime.now
406
+ resource.effectiveDateTime = date.strftime("%Y-%m-%dT%T.%LZ")
407
+ resource.effectivePeriod = nil
408
+ when FHIR::DocumentManifest
409
+ resource.content.each do |c|
410
+ c.pAttachment = nil
411
+ c.pReference = textonly_reference('Any')
412
+ end
413
+ when FHIR::DocumentReference
414
+ resource.docStatus = minimal_codeableconcept('http://hl7.org/fhir/composition-status','preliminary')
415
+ when FHIR::ElementDefinition
416
+ keys = []
417
+ resource.constraint.each do |constraint|
418
+ constraint.key = SecureRandom.base64 if constraint.key.nil?
419
+ constraint.key.gsub!(/[^0-9A-Za-z]/, '')
420
+ keys << constraint.key
421
+ constraint.xpath = "/"
422
+ end
423
+ resource.condition = keys
424
+ resource.mapping.each do |m|
425
+ m.fhirIdentity = SecureRandom.base64 if m.fhirIdentity.nil?
426
+ m.fhirIdentity.gsub!(/[^0-9A-Za-z]/, '')
427
+ end
428
+ resource.max = "#{resource.min+1}"
429
+ # TODO remove bindings for things that can't be code, Coding, CodeableConcept
430
+ is_codeable = false
431
+ resource.fhirType.each do |f|
432
+ is_codeable = (['code','Coding','CodeableConcept'].include?(f.code))
433
+ end
434
+ resource.binding = nil unless is_codeable
435
+ when FHIR::Goal
436
+ resource.outcome.each do |outcome|
437
+ outcome.resultCodeableConcept = nil
438
+ outcome.resultReference = textonly_reference('Observation')
439
+ end
440
+ when FHIR::Group
441
+ resource.member = [] if resource.actual==false
442
+ resource.characteristic.each do |c|
443
+ c.valueCodeableConcept = nil
444
+ c.valueBoolean = true
445
+ c.valueQuantity = nil
446
+ c.valueRange = nil
447
+ end
448
+ when FHIR::ImagingObjectSelection
449
+ resource.uid = random_oid
450
+ index = SecureRandom.random_number(FHIR::ImagingObjectSelection::VALID_CODES[:title].length)
451
+ code = FHIR::ImagingObjectSelection::VALID_CODES[:title][index]
452
+ resource.title = minimal_codeableconcept('http://nema.org/dicom/dicm',code)
453
+ resource.study.each do |study|
454
+ study.uid = random_oid
455
+ study.series.each do |series|
456
+ series.uid = random_oid
457
+ series.instance.each do |instance|
458
+ instance.sopClass = random_oid
459
+ instance.uid = random_oid
460
+ end
461
+ end
462
+ end
463
+ when FHIR::ImagingStudy
464
+ resource.uid = random_oid
465
+ resource.series.each do |series|
466
+ series.uid=random_oid
467
+ series.instance.each do |instance|
468
+ instance.uid = random_oid
469
+ instance.sopClass = random_oid
470
+ end
471
+ end
472
+ when FHIR::Immunization
473
+ if resource.wasNotGiven
474
+ resource.explanation.reasonNotGiven = [ textonly_codeableconcept("reasonNotGiven #{SecureRandom.base64}") ]
475
+ resource.explanation.reason = nil
476
+ resource.reaction = nil
477
+ else
478
+ resource.explanation.reasonNotGiven = nil
479
+ resource.explanation.reason = [ textonly_codeableconcept("reason #{SecureRandom.base64}") ]
480
+ end
481
+ when FHIR::ImplementationGuide
482
+ resource.fhirVersion = "DSTU2"
483
+ resource.package.each do |package|
484
+ package.resource.each do |r|
485
+ r.sourceUri = nil
486
+ r.sourceReference = textonly_reference('Any')
487
+ end
488
+ end
489
+ when FHIR::List
490
+ resource.emptyReason = nil
491
+ resource.entry.each do |entry|
492
+ resource.mode = 'changes' if !entry.fhirDeleted.nil?
493
+ end
494
+ when FHIR::Media
495
+ if resource.fhirType == 'video'
496
+ resource.frames = nil
497
+ elsif resource.fhirType == 'photo'
498
+ resource.duration = nil
499
+ elsif resource.fhirType == 'audio'
500
+ resource.height = nil
501
+ resource.width = nil
502
+ resource.frames = nil
503
+ else
504
+ resource.height = nil
505
+ resource.width = nil
506
+ resource.frames = nil
507
+ end
508
+ when FHIR::Medication
509
+ if resource.product.try(:ingredient)
510
+ resource.product.ingredient.each {|i|i.amount = nil}
511
+ end
512
+ when FHIR::MedicationAdministration
513
+ date = DateTime.now
514
+ resource.effectiveTimeDateTime = date.strftime("%Y-%m-%dT%T.%LZ")
515
+ resource.effectiveTimePeriod = nil
516
+ if resource.wasNotGiven
517
+ resource.reasonGiven = nil
518
+ else
519
+ resource.reasonNotGiven = nil
520
+ end
521
+ resource.medicationReference = textonly_reference('Medication')
522
+ resource.medicationCodeableConcept = nil
523
+ when FHIR::MedicationDispense
524
+ resource.medicationReference = textonly_reference('Medication')
525
+ resource.medicationCodeableConcept = nil
526
+ resource.dosageInstruction.each {|d|d.timing = nil }
527
+ when FHIR::MedicationOrder
528
+ resource.medicationReference = textonly_reference('Medication')
529
+ resource.medicationCodeableConcept = nil
530
+ resource.dosageInstruction.each {|d|d.timing = nil }
531
+ when FHIR::MedicationStatement
532
+ resource.reasonNotTaken = nil if resource.wasNotTaken != true
533
+ resource.medicationReference = textonly_reference('Medication')
534
+ resource.medicationCodeableConcept = nil
535
+ resource.dosage.each{|d|d.timing=nil}
536
+ when FHIR::MessageHeader
537
+ resource.response.identifier.gsub!(/[^0-9A-Za-z]/, '') if resource.try(:response).try(:identifier)
538
+ when FHIR::NamingSystem
539
+ resource.replacedBy = nil if resource.status!='retired'
540
+ if resource.kind == 'root'
541
+ resource.uniqueId.each do |uid|
542
+ uid.fhirType='other' if ['uuid','oid'].include?(uid.fhirType)
543
+ end
544
+ end
545
+ resource.uniqueId.each do |uid|
546
+ uid.preferred = nil
547
+ end
548
+ when FHIR::NutritionOrder
549
+ resource.oralDiet.schedule = nil if resource.oralDiet
550
+ resource.supplement.each{|s|s.schedule=nil}
551
+ resource.enteralFormula.administration = nil if resource.enteralFormula
552
+ when FHIR::OperationDefinition
553
+ resource.parameter.each do |p|
554
+ p.binding = nil
555
+ p.part = nil
556
+ end
557
+ when FHIR::Order
558
+ resource.when.schedule = nil
559
+ when FHIR::Patient
560
+ resource.maritalStatus = minimal_codeableconcept('http://hl7.org/fhir/v3/MaritalStatus','S')
561
+ when FHIR::Procedure
562
+ resource.reasonNotPerformed = nil if resource.notPerformed != true
563
+ resource.focalDevice.each do |fd|
564
+ fd.action = minimal_codeableconcept('http://hl7.org/fhir/ValueSet/device-action','implanted')
565
+ end
566
+ when FHIR::Provenance
567
+ resource.entity.each do |e|
568
+ e.agent.relatedAgent = nil if e.agent
569
+ end
570
+ when FHIR::RelatedPerson
571
+ resource.relationship = minimal_codeableconcept('http://hl7.org/fhir/patient-contact-relationship','family')
572
+ when FHIR::Questionnaire
573
+ resource.group.required = true
574
+ resource.group.group = nil
575
+ resource.group.question.each {|q|q.options = nil }
576
+ when FHIR::QuestionnaireResponse
577
+ resource.group.group = nil
578
+ resource.group.question.each {|q|q.answer = nil }
579
+ when FHIR::Subscription
580
+ resource.status = 'requested' if resource.xmlId.nil?
581
+ resource.channel.payload = 'applicaton/json+fhir'
582
+ resource.end = nil
583
+ when FHIR::SupplyDelivery
584
+ resource.fhirType = minimal_codeableconcept('http://hl7.org/fhir/supply-item-type','medication')
585
+ when FHIR::SupplyRequest
586
+ resource.kind = minimal_codeableconcept('http://hl7.org/fhir/supply-kind','central')
587
+ if resource.when
588
+ resource.when.schedule = nil
589
+ resource.when.code = minimal_codeableconcept('http://snomed.info/sct','20050000') #biweekly
590
+ end
591
+ when FHIR::StructureDefinition
592
+ resource.fhirVersion = 'DSTU2'
593
+ resource.snapshot.element.first.path = resource.constrainedType if resource.snapshot && resource.snapshot.element
594
+ resource.mapping.each do |m|
595
+ m.fhirIdentity.gsub!(/[^0-9A-Za-z]/, '') if m.fhirIdentity
596
+ end
597
+ when FHIR::TestScript
598
+ resource.variable.each do |v|
599
+ v.sourceId.gsub!(/[^0-9A-Za-z]/, '') if v.sourceId
600
+ v.path = nil if v.headerField
601
+ end
602
+ if resource.setup
603
+ resource.setup.metadata = nil
604
+ resource.setup.action.each do |a|
605
+ a.assert = nil if a.operation
606
+ apply_invariants!(a.operation) if a.operation
607
+ apply_invariants!(a.assert) if a.assert
608
+ end
609
+ end
610
+ resource.test.each do |test|
611
+ test.metadata = nil
612
+ test.action.each do |a|
613
+ a.assert = nil if a.operation
614
+ apply_invariants!(a.operation) if a.operation
615
+ apply_invariants!(a.assert) if a.assert
616
+ end
617
+ end
618
+ if resource.teardown
619
+ resource.teardown.action.each do |a|
620
+ apply_invariants!(a.operation) if a.operation
621
+ end
622
+ end
623
+ when FHIR::TestScript::TestScriptSetupActionAssertComponent
624
+ # an assertion can only contain one of these...
625
+ keys = ['contentType','headerField','minimumId','navigationLinks','path','resource','responseCode','response','validateProfileId']
626
+ has_keys = []
627
+ keys.each do |key|
628
+ has_keys << key if resource.try(key.to_sym)
629
+ end
630
+ # remove all assertions except the first
631
+ has_keys[1..-1].each do |key|
632
+ resource.send("#{key}=",nil)
633
+ end
634
+ resource.sourceId.gsub!(/[^0-9A-Za-z]/, '') if resource.sourceId
635
+ resource.validateProfileId.gsub!(/[^0-9A-Za-z]/, '') if resource.validateProfileId
636
+ when FHIR::TestScript::TestScriptSetupActionOperationComponent
637
+ resource.responseId.gsub!(/[^0-9A-Za-z]/, '') if resource.responseId
638
+ resource.sourceId.gsub!(/[^0-9A-Za-z]/, '') if resource.sourceId
639
+ resource.targetId.gsub!(/[^0-9A-Za-z]/, '') if resource.targetId
640
+ when FHIR::ValueSet
641
+ if resource.compose
642
+ resource.compose.include.each do |inc|
643
+ inc.filter = nil if inc.concept
644
+ end
645
+ resource.compose.exclude.each do |exc|
646
+ exc.filter = nil if exc.concept
647
+ end
648
+ end
649
+ else
650
+ # default
651
+ end
652
+ end
653
+
654
+ end
655
+ end
656
+ end