renalware-core 2.0.0.pre.beta8 → 2.0.0.pre.beta9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +19 -1
  3. data/app/assets/stylesheets/renalware/lib/_select2-foundation5-overrides.scss +2 -2
  4. data/app/controllers/renalware/directory/people_controller.rb +1 -1
  5. data/app/controllers/renalware/letters/contacts_controller.rb +1 -1
  6. data/app/controllers/renalware/letters/letters_controller.rb +1 -1
  7. data/app/controllers/renalware/patients/patients_controller.rb +3 -5
  8. data/app/controllers/renalware/patients/primary_care_physicians_controller.rb +1 -1
  9. data/app/controllers/renalware/renal/aki_alerts_controller.rb +44 -0
  10. data/app/controllers/renalware/renal/profiles_controller.rb +1 -1
  11. data/app/controllers/renalware/reporting/audits_controller.rb +9 -3
  12. data/app/documents/renalware/patient_document.rb +0 -13
  13. data/app/jobs/hl7_message_example.yml +1 -1
  14. data/app/jobs/renalware/reporting/refresh_audit_data_job.rb +7 -3
  15. data/app/models/renalware/clinical/create_allergy.rb +4 -2
  16. data/app/models/renalware/clinics/create_clinic_visit.rb +6 -2
  17. data/app/models/renalware/hd/session.rb +12 -0
  18. data/app/models/renalware/hospitals/unit.rb +4 -0
  19. data/app/models/renalware/hospitals/ward.rb +22 -0
  20. data/app/models/renalware/modalities/change_patient_modality.rb +4 -2
  21. data/app/models/renalware/patient.rb +1 -0
  22. data/app/models/renalware/patients/language.rb +1 -0
  23. data/app/models/renalware/pd/create_regime.rb +4 -2
  24. data/app/models/renalware/pd/revise_regime.rb +5 -3
  25. data/app/models/renalware/renal/aki_alert.rb +15 -0
  26. data/app/models/renalware/renal/aki_alert_action.rb +10 -0
  27. data/app/models/renalware/reporting/audit.rb +2 -3
  28. data/app/models/renalware/reporting/generate_audit_json.rb +21 -5
  29. data/app/models/renalware/system/country.rb +21 -0
  30. data/app/models/renalware/transplants/create_donor_stage.rb +4 -2
  31. data/app/policies/renalware/base_policy.rb +4 -0
  32. data/app/policies/renalware/renal/aki_alert_policy.rb +9 -0
  33. data/app/presenters/renalware/hd/patient_presenter.rb +5 -0
  34. data/app/presenters/renalware/reporting/audit_presenter.rb +1 -0
  35. data/app/presenters/renalware/transplants/patient_presenter.rb +2 -1
  36. data/app/presenters/renalware/ukrdc/patient_presenter.rb +27 -0
  37. data/app/values/renalware/address.rb +2 -13
  38. data/app/views/renalware/addresses/_form.html.slim +4 -2
  39. data/app/views/renalware/api/ukrdc/patients/_address.xml.builder +2 -2
  40. data/app/views/renalware/api/ukrdc/patients/_diagnoses.xml.builder +5 -2
  41. data/app/views/renalware/api/ukrdc/patients/_encounters.xml.builder +8 -1
  42. data/app/views/renalware/api/ukrdc/patients/_medications.xml.builder +30 -0
  43. data/app/views/renalware/api/ukrdc/patients/_patient.xml.builder +36 -4
  44. data/app/views/renalware/api/ukrdc/patients/_sending_facility.xml.builder +1 -0
  45. data/app/views/renalware/api/ukrdc/patients/diagnoses/_cause_of_death.xml.builder +10 -0
  46. data/app/views/renalware/api/ukrdc/patients/encounters/_hd_session.xml.builder +40 -0
  47. data/app/views/renalware/api/ukrdc/patients/show.xml.builder +1 -0
  48. data/app/views/renalware/directory/people/_address_form.html.slim +1 -1
  49. data/app/views/renalware/hd/sessions/_form.html.slim +43 -33
  50. data/app/views/renalware/letters/contacts/_person_form.html.slim +1 -1
  51. data/app/views/renalware/navigation/_renal.html.slim +1 -0
  52. data/app/views/renalware/patients/patients/_form.html.slim +5 -2
  53. data/app/views/renalware/patients/patients/show.html.slim +0 -5
  54. data/app/views/renalware/patients/patients/show/_patient_demographics.html.slim +3 -3
  55. data/app/views/renalware/patients/side_menu/_actions.html.slim +3 -0
  56. data/app/views/renalware/renal/aki_alerts/_filters.html.slim +0 -0
  57. data/app/views/renalware/renal/aki_alerts/edit.html.slim +17 -0
  58. data/app/views/renalware/renal/aki_alerts/index.html.slim +28 -0
  59. data/app/views/renalware/reporting/audits/edit.html.slim +1 -1
  60. data/app/views/renalware/reporting/audits/index.html.slim +11 -7
  61. data/app/views/renalware/reporting/audits/show.html.slim +2 -17
  62. data/app/views/renalware/shared/documents/_blood_pressure_input.html.slim +6 -7
  63. data/config/initializers/inflections.rb +3 -2
  64. data/config/locales/renalware/navigation/renal.en.yml +1 -0
  65. data/config/locales/renalware/renal/aki_alerts.en.yml +5 -0
  66. data/config/locales/renalware/renal/{profile.yml → profile.en.yml} +0 -0
  67. data/config/locales/renalware/reporting/audit.en.yml +1 -1
  68. data/config/routes.rb +1 -0
  69. data/db/migrate/20150312113937_create_drug_types_drugs.rb +2 -2
  70. data/db/migrate/20170925161033_add_code_to_patient_langauges.rb +6 -0
  71. data/db/migrate/20170925182738_add_rr_code_to_medication_routes.rb +5 -0
  72. data/db/migrate/20170926081426_create_countries.rb +14 -0
  73. data/db/migrate/20170926132845_add_country_of_birth_to_patients.rb +6 -0
  74. data/db/migrate/20171002175804_add_rr_columns_to_transplant_registration_status_descriptions.rb +12 -0
  75. data/db/migrate/20171003093347_create_hospital_wards.rb +17 -0
  76. data/db/migrate/20171003111228_create_aki_alert_actions.rb +10 -0
  77. data/db/migrate/20171003122425_create_renal_aki_alerts.rb +22 -0
  78. data/db/migrate/20171005081224_create_reporting_bone_audit.rb +5 -0
  79. data/db/migrate/20171005091202_reporting_audit_changes.rb +7 -0
  80. data/db/migrate/20171005130109_create_medication_current_prescriptions.rb +5 -0
  81. data/db/migrate/20171005144505_create_reporting_anaemia_audit.rb +5 -0
  82. data/db/migrate/20171009104106_add_legacy_patient_id_to_patients.rb +6 -0
  83. data/db/seeds/default/events/{event_types_required.csv → event_types.csv} +0 -0
  84. data/db/seeds/default/events/{event_types_required.rb → event_types.rb} +2 -2
  85. data/db/seeds/default/events/seeds.rb +1 -2
  86. data/db/seeds/default/medications/medication_routes.rb +23 -13
  87. data/db/seeds/default/patients/patients_languages.csv +192 -102
  88. data/db/seeds/default/patients/patients_languages.rb +1 -1
  89. data/db/seeds/default/patients/patients_religions.csv +2 -0
  90. data/db/seeds/default/reporting/audits.rb +4 -3
  91. data/db/seeds/default/reporting/audits.yml +47 -4
  92. data/db/seeds/default/system/countries.csv +250 -0
  93. data/db/seeds/default/system/countries.rb +12 -0
  94. data/db/seeds/default/system/seeds.rb +1 -0
  95. data/db/seeds/default/transplants/transplant_registration_statuses.rb +30 -19
  96. data/db/views/medication_current_prescriptions_v01.sql +28 -0
  97. data/db/views/reporting_anaemia_audit_v01.sql +41 -0
  98. data/db/views/reporting_bone_audit_v01.sql +32 -0
  99. data/lib/renalware/version.rb +1 -1
  100. data/spec/factories/deaths/cause.rb +1 -1
  101. data/spec/factories/drugs/drug.rb +6 -0
  102. data/spec/factories/drugs/drug_types.rb +5 -0
  103. data/spec/factories/hospitals/wards.rb +9 -0
  104. data/spec/factories/modalities/modality_descriptions.rb +10 -8
  105. data/spec/factories/patients/ethnicities.rb +3 -0
  106. data/spec/factories/patients/languages.rb +12 -1
  107. data/spec/factories/renal/aki_alert_actions.rb +5 -0
  108. data/spec/factories/renal/aki_alerts.rb +9 -0
  109. data/spec/factories/reporting/audits.rb +1 -1
  110. data/spec/factories/system/addresses.rb +1 -1
  111. data/spec/factories/system/countries.rb +15 -0
  112. metadata +42 -13
  113. data/app/values/renalware/country.rb +0 -19
  114. data/config/countries.csv +0 -250
  115. data/db/migrate/20170706120643_create_reporting_data_sources.rb +0 -5
  116. data/db/seeds/default/events/event_types_blt.csv +0 -109
  117. data/db/seeds/default/events/event_types_local.rb +0 -10
  118. data/db/views/reporting_data_sources_v01.sql +0 -17
@@ -4,7 +4,7 @@ module Renalware
4
4
  file_path = File.join(File.dirname(__FILE__), "patients_languages.csv")
5
5
 
6
6
  CSV.foreach(file_path, headers: true) do |row|
7
- Patients::Language.find_or_create_by!(name: row["name"])
7
+ Patients::Language.find_or_create_by!(code: row["code"], name: row["name"])
8
8
  end
9
9
  end
10
10
  end
@@ -22,3 +22,5 @@
22
22
  "Scientology"
23
23
  "Pantheism"
24
24
  "Heathenism"
25
+ "Other"
26
+ "Unknown"
@@ -1,15 +1,16 @@
1
1
  module Renalware
2
- #log "Adding default audits" do
2
+ log "Adding default audits" do
3
3
  file_path = File.join(File.dirname(__FILE__), "audits.yml")
4
4
  yml_audits = YAML.load_file(file_path)
5
5
  yml_audits.each do |yml_audit|
6
6
  yml_audit.symbolize_keys!
7
7
  Reporting::Audit.find_or_create_by!(name: yml_audit[:name]) do |audit|
8
8
  audit.description = yml_audit[:description]
9
- audit.materialized_view_name = yml_audit[:materialized_view_name]
9
+ audit.view_name = yml_audit[:view_name]
10
+ audit.materialized = yml_audit[:materialized]
10
11
  audit.refresh_schedule = yml_audit[:refresh_schedule]
11
12
  audit.display_configuration = yml_audit[:display_configuration]
12
13
  end
13
14
  end
14
- #end
15
+ end
15
16
  end
@@ -1,7 +1,8 @@
1
1
  -
2
2
  name: Main Authors
3
3
  description: A list of authors with their letter statistics.
4
- materialized_view_name: reporting_main_authors_audit
4
+ view_name: reporting_main_authors_audit
5
+ materialized: true
5
6
  refresh_schedule: "1 0 * * *"
6
7
  display_configuration: >
7
8
  { "columnDefs": [
@@ -14,7 +15,8 @@
14
15
  -
15
16
  name: HD Blood Pressures
16
17
  description:
17
- materialized_view_name: reporting_hd_blood_pressures_audit
18
+ view_name: reporting_hd_blood_pressures_audit
19
+ materialized: true
18
20
  refresh_schedule: "1 0 * * *"
19
21
  display_configuration: >
20
22
  {
@@ -28,16 +30,57 @@
28
30
  -
29
31
  name: HD Overall
30
32
  description: An overview of HD activity in the current month across all HD units.
31
- materialized_view_name: reporting_hd_overall_audit
33
+ view_name: reporting_hd_overall_audit
34
+ materialized: true
32
35
  refresh_schedule: "1 0 * * *"
33
36
  display_configuration: >
34
37
  { "columnDefs": [
35
38
  { "title": "Unit", "targets": 0, width: "300" },
36
39
  { "title": "No. patients", "targets": 1, width: "120" },
37
- { "title": "% HB > 100", "targets": 2, width: "120" },
40
+ { "title": "% HGB > 100", "targets": 2, width: "120" },
38
41
  { "title": "% URR > 65", "targets": 3, width: "120" },
39
42
  { "title": "% Phosphate < 1.8", "targets": 4, width: "200" },
40
43
  { "title": "% w/fistula or graft", "targets": 5, width: "200" },
41
44
  { "title": "Avg. missed HD time", "targets": 6, width: "200" }
42
45
  { "title": "% missing >5% HD time", "targets": 7, width: "200" }
43
46
  ]}
47
+ -
48
+ name: Bone
49
+ description: Bone audit
50
+ view_name: reporting_bone_audit
51
+ materialized: false
52
+ refresh_schedule:
53
+ display_configuration: >
54
+ { "columnDefs": [
55
+ { "title": "Modality", "targets": 0, width: "200" },
56
+ { "title": "No. patients", "targets": 1, width: "100" },
57
+ { "title": "Avg CCA", "targets": 2, width: "100" },
58
+ { "title": "% CCA 2.1-2.4", "targets": 4, width: "110" },
59
+ { "title": "% PTH > 300", "targets": 5, width: "100" },
60
+ { "title": "% PTH > 800", "targets": 6, width: "100" },
61
+ { "title": "Avg PHOS", "targets": 7, width: "100" },
62
+ { "title": "Max PHOS", "targets": 8, width: "100" },
63
+ { "title": "% PHOS < 1.8", "targets": 8, width: "110" }
64
+ ]}
65
+ -
66
+ name: Anaemia
67
+ description: ESD/EPO audit
68
+ view_name: reporting_anaemia_audit
69
+ materialized: false
70
+ refresh_schedule:
71
+ display_configuration: >
72
+ { "columnDefs": [
73
+ { "title": "Modality", "targets": 0, width: "160" },
74
+ { "title": "Patients", "targets": 1, width: "80" },
75
+ { "title": "Avg HGB", "targets": 2, width: "90" },
76
+ { "title": "% HGB ≥ 10", "targets": 4, width: "100" },
77
+ { "title": "% HGB ≥ 11", "targets": 5, width: "100" },
78
+ { "title": "% HGB ≥ 13", "targets": 6, width: "100" },
79
+ { "title": "Avg FER", "targets": 7, width: "80" },
80
+ { "title": "% FER ≥ 150", "targets": 8, width: "100" },
81
+ { "title": "No on EPO", "targets": 9, width: "90" },
82
+ { "title": "Count Mircer*", "targets": 9, width: "100" },
83
+ { "title": "Count Neo*", "targets": 9, width: "90" },
84
+ { "title": "Count Ara*", "targets": 9, width: "90" }
85
+ ]}
86
+
@@ -0,0 +1,250 @@
1
+ name,alpha2,alpha3
2
+ United Kingdom,GB,GBR
3
+ Afghanistan,AF,AFG
4
+ Albania,AL,ALB
5
+ Algeria,DZ,DZA
6
+ American Samoa,AS,ASM
7
+ Andorra,AD,AND
8
+ Angola,AO,AGO
9
+ Anguilla,AI,AIA
10
+ Antarctica,AQ,ATA
11
+ Antigua & Barbuda,AG,ATG
12
+ Argentina,AR,ARG
13
+ Armenia,AM,ARM
14
+ Aruba,AW,ABW
15
+ Australia,AU,AUS
16
+ Austria,AT,AUT
17
+ Azerbaijan,AZ,AZE
18
+ Bahamas,BS,BHS
19
+ Bahrain,BH,BHR
20
+ Bangladesh,BD,BGD
21
+ Barbados,BB,BRB
22
+ Belarus,BY,BLR
23
+ Belgium,BE,BEL
24
+ Belize,BZ,BLZ
25
+ Benin,BJ,BEN
26
+ Bermuda,BM,BMU
27
+ Bhutan,BT,BTN
28
+ Bolivia,BO,BOL
29
+ Bosnia,BA,BIH
30
+ Botswana,BW,BWA
31
+ Bouvet Island,BV,BVT
32
+ Brazil,BR,BRA
33
+ British Indian Ocean Territory,IO,IOT
34
+ British Virgin Islands,VG,VGB
35
+ Brunei,BN,BRN
36
+ Bulgaria,BG,BGR
37
+ Burkina Faso,BF,BFA
38
+ Burundi,BI,BDI
39
+ Cambodia,KH,KHM
40
+ Cameroon,CM,CMR
41
+ Canada,CA,CAN
42
+ Cape Verde,CV,CPV
43
+ Caribbean Netherlands,BQ,BES
44
+ Cayman Islands,KY,CYM
45
+ Central African Republic,CF,CAF
46
+ Chad,TD,TCD
47
+ Chile,CL,CHL
48
+ China,CN,CHN
49
+ Christmas Island,CX,CXR
50
+ Cocos (Keeling) Islands,CC,CCK
51
+ Colombia,CO,COL
52
+ Comoros,KM,COM
53
+ Congo - Brazzaville,CG,COG
54
+ Congo - Kinshasa,CD,COD
55
+ Cook Islands,CK,COK
56
+ Costa Rica,CR,CRI
57
+ Croatia,HR,HRV
58
+ Cuba,CU,CUB
59
+ Cura̤ao,CW,CUW
60
+ Cyprus,CY,CYP
61
+ Czech Republic,CZ,CZE
62
+ Côte d'Ivoire,CI,CIV
63
+ Denmark,DK,DNK
64
+ Djibouti,DJ,DJI
65
+ Dominica,DM,DMA
66
+ Dominican Republic,DO,DOM
67
+ Ecuador,EC,ECU
68
+ Egypt,EG,EGY
69
+ El Salvador,SV,SLV
70
+ Equatorial Guinea,GQ,GNQ
71
+ Eritrea,ER,ERI
72
+ Estonia,EE,EST
73
+ Ethiopia,ET,ETH
74
+ Falkland Islands,FK,FLK
75
+ Faroe Islands,FO,FRO
76
+ Fiji,FJ,FJI
77
+ Finland,FI,FIN
78
+ France,FR,FRA
79
+ French Guiana,GF,GUF
80
+ French Polynesia,PF,PYF
81
+ French Southern Territories,TF,ATF
82
+ Gabon,GA,GAB
83
+ Gambia,GM,GMB
84
+ Georgia,GE,GEO
85
+ Germany,DE,DEU
86
+ Ghana,GH,GHA
87
+ Gibraltar,GI,GIB
88
+ Greece,GR,GRC
89
+ Greenland,GL,GRL
90
+ Grenada,GD,GRD
91
+ Guadeloupe,GP,GLP
92
+ Guam,GU,GUM
93
+ Guatemala,GT,GTM
94
+ Guernsey,GG,GGY
95
+ Guinea,GN,GIN
96
+ Guinea-Bissau,GW,GNB
97
+ Guyana,GY,GUY
98
+ Haiti,HT,HTI
99
+ Heard & McDonald Islands,HM,HMD
100
+ Honduras,HN,HND
101
+ Hong Kong,HK,HKG
102
+ Hungary,HU,HUN
103
+ Iceland,IS,ISL
104
+ India,IN,IND
105
+ Indonesia,ID,IDN
106
+ Iran,IR,IRN
107
+ Iraq,IQ,IRQ
108
+ Ireland,IE,IRL
109
+ Isle of Man,IM,IMN
110
+ Israel,IL,ISR
111
+ Italy,IT,ITA
112
+ Jamaica,JM,JAM
113
+ Japan,JP,JPN
114
+ Jersey,JE,JEY
115
+ Jordan,JO,JOR
116
+ Kazakhstan,KZ,KAZ
117
+ Kenya,KE,KEN
118
+ Kiribati,KI,KIR
119
+ Kuwait,KW,KWT
120
+ Kyrgyzstan,KG,KGZ
121
+ Laos,LA,LAO
122
+ Latvia,LV,LVA
123
+ Lebanon,LB,LBN
124
+ Lesotho,LS,LSO
125
+ Liberia,LR,LBR
126
+ Libya,LY,LBY
127
+ Liechtenstein,LI,LIE
128
+ Lithuania,LT,LTU
129
+ Luxembourg,LU,LUX
130
+ Macau,MO,MAC
131
+ Macedonia,MK,MKD
132
+ Madagascar,MG,MDG
133
+ Malawi,MW,MWI
134
+ Malaysia,MY,MYS
135
+ Maldives,MV,MDV
136
+ Mali,ML,MLI
137
+ Malta,MT,MLT
138
+ Marshall Islands,MH,MHL
139
+ Martinique,MQ,MTQ
140
+ Mauritania,MR,MRT
141
+ Mauritius,MU,MUS
142
+ Mayotte,YT,MYT
143
+ Mexico,MX,MEX
144
+ Micronesia,FM,FSM
145
+ Moldova,MD,MDA
146
+ Monaco,MC,MCO
147
+ Mongolia,MN,MNG
148
+ Montenegro,ME,MNE
149
+ Montserrat,MS,MSR
150
+ Morocco,MA,MAR
151
+ Mozambique,MZ,MOZ
152
+ Myanmar,MM,MMR
153
+ Namibia,NA,NAM
154
+ Nauru,NR,NRU
155
+ Nepal,NP,NPL
156
+ Netherlands,NL,NLD
157
+ New Caledonia,NC,NCL
158
+ New Zealand,NZ,NZL
159
+ Nicaragua,NI,NIC
160
+ Niger,NE,NER
161
+ Nigeria,NG,NGA
162
+ Niue,NU,NIU
163
+ Norfolk Island,NF,NFK
164
+ North Korea,KP,PRK
165
+ Northern Mariana Islands,MP,MNP
166
+ Norway,NO,NOR
167
+ Oman,OM,OMN
168
+ Pakistan,PK,PAK
169
+ Palau,PW,PLW
170
+ Palestine,PS,PSE
171
+ Panama,PA,PAN
172
+ Papua New Guinea,PG,PNG
173
+ Paraguay,PY,PRY
174
+ Peru,PE,PER
175
+ Philippines,PH,PHL
176
+ Pitcairn Islands,PN,PCN
177
+ Poland,PL,POL
178
+ Portugal,PT,PRT
179
+ Puerto Rico,PR,PRI
180
+ Qatar,QA,QAT
181
+ Romania,RO,ROU
182
+ Russia,RU,RUS
183
+ Rwanda,RW,RWA
184
+ R̩union,RE,REU
185
+ Samoa,WS,WSM
186
+ San Marino,SM,SMR
187
+ Sao Tome and Principe,ST,STP
188
+ Saudi Arabia,SA,SAU
189
+ Senegal,SN,SEN
190
+ Serbia,RS,SRB
191
+ Seychelles,SC,SYC
192
+ Sierra Leone,SL,SLE
193
+ Singapore,SG,SGP
194
+ Sint Maarten,SX,SXM
195
+ Slovakia,SK,SVK
196
+ Slovenia,SI,SVN
197
+ Solomon Islands,SB,SLB
198
+ Somalia,SO,SOM
199
+ South Africa,ZA,ZAF
200
+ South Georgia & South Sandwich Islands,GS,SGS
201
+ South Korea,KR,KOR
202
+ South Sudan,SS,SSD
203
+ Spain,ES,ESP
204
+ Sri Lanka,LK,LKA
205
+ St. Barth̩lemy,BL,BLM
206
+ St. Helena,SH,SHN
207
+ St. Kitts & Nevis,KN,KNA
208
+ St. Lucia,LC,LCA
209
+ St. Martin,MF,MAF
210
+ St. Pierre & Miquelon,PM,SPM
211
+ St. Vincent & Grenadines,VC,VCT
212
+ Sudan,SD,SDN
213
+ Suriname,SR,SUR
214
+ Svalbard & Jan Mayen,SJ,SJM
215
+ Swaziland,SZ,SWZ
216
+ Sweden,SE,SWE
217
+ Switzerland,CH,CHE
218
+ Syria,SY,SYR
219
+ Taiwan,TW,TWN
220
+ Tajikistan,TJ,TJK
221
+ Tanzania,TZ,TZA
222
+ Thailand,TH,THA
223
+ Timor-Leste,TL,TLS
224
+ Togo,TG,TGO
225
+ Tokelau,TK,TKL
226
+ Tonga,TO,TON
227
+ Trinidad & Tobago,TT,TTO
228
+ Tunisia,TN,TUN
229
+ Turkey,TR,TUR
230
+ Turkmenistan,TM,TKM
231
+ Turks & Caicos Islands,TC,TCA
232
+ Tuvalu,TV,TUV
233
+ U.S. Outlying Islands,UM,UMI
234
+ U.S. Virgin Islands,VI,VIR
235
+ Uganda,UG,UGA
236
+ Ukraine,UA,UKR
237
+ United Arab Emirates,AE,ARE
238
+ Uruguay,UY,URY
239
+ US,US,USA
240
+ Uzbekistan,UZ,UZB
241
+ Vanuatu,VU,VUT
242
+ Vatican City,VA,VAT
243
+ Venezuela,VE,VEN
244
+ Vietnam,VN,VNM
245
+ Wallis & Futuna,WF,WLF
246
+ Western Sahara,EH,ESH
247
+ Yemen,YE,YEM
248
+ Zambia,ZM,ZMB
249
+ Zimbabwe,ZW,ZWE
250
+ Åland Islands,AX,ALA
@@ -0,0 +1,12 @@
1
+ module Renalware
2
+ log "Adding Countries" do
3
+ file_path = File.join(File.dirname(__FILE__), "countries.csv")
4
+ CSV.foreach(file_path, headers: true) do |row, index|
5
+ System::Country.find_or_create_by!(
6
+ name: row["name"],
7
+ alpha2: row["alpha2"],
8
+ alpha3: row["alpha3"]
9
+ ).tap{ |country| country.position = index }
10
+ end
11
+ end
12
+ end
@@ -1,2 +1,3 @@
1
+ require_relative "./countries"
1
2
  require_relative "./roles"
2
3
  require_relative "./users"
@@ -1,29 +1,40 @@
1
1
  module Renalware
2
2
  log "Adding Transplant Registration Statuses" do
3
3
 
4
+ # HC on #1664: The only difficulty is for patients who receive a pre-emptive transplant so
5
+ # their ESRF date is the date of their transplant. The RR list does not
6
+ # accommodate that but I would put them as On Transplant List (3)
7
+ #
8
+ # RR ESR61 codes:
9
+ # 1 Unsuitable
10
+ # 2 Working Up or under discussion
11
+ # 3 On Transplant List
12
+ # 4 Suspended on Transplant List
13
+ # 5 Not Assessed by Start of Dialysis
4
14
  statuses = [
5
- [:active, "Active"],
6
- [:suspended, "Suspended"],
7
- [:transplanted, "Transplanted"],
8
- [:live_transplanted, "Live transplanted"],
9
- [:off_by_patient, "Off by patient request"],
10
- [:not_eligible, "Not eligible for NHS Tx"],
11
- [:unfit_reconsider, "Unfit (not listed -- reconsider)"],
12
- [:unfit_permanent, "Unfit (not listed -- permanent)"],
13
- [:working_up, "X - working up"],
14
- [:working_up_lrf, "X - working up LRF"],
15
- [:not_for_work_up, "Not for work up - eGFR too high"],
16
- [:workup_complete, "Workup complete - low creat"],
17
- [:transfer_out, "Transfer Out"],
18
- [:died, "Died"]
15
+ [:active, "Active", 3, "ESRF61: On Transplant List"],
16
+ [:suspended, "Suspended", 4, "ESRF61: Suspended on Transplant List"],
17
+ [:transplanted, "Transplanted", nil, "Not relevant for ESRF61"],
18
+ [:live_transplanted, "Live transplanted", nil, "Not relevant for ESRF61"],
19
+ [:off_by_patient, "Off by patient request", 1, "ERF61: Unsuitable"],
20
+ [:not_eligible, "Not eligible for NHS Tx", 1, "ERF61: Unsuitable"],
21
+ [:unfit_reconsider, "Unfit (not listed -- reconsider)", 1, "ERF61: Unsuitable"],
22
+ [:unfit_permanent, "Unfit (not listed -- permanent)", 1, "ERF61: Unsuitable"],
23
+ [:working_up, "X - working up", 2, "ERF61: Working Up or under discussion"],
24
+ [:working_up_lrf, "X - working up LRF", 2, "ERF61: Working Up or under discussion"],
25
+ [:not_for_work_up, "Not for work up - eGFR too high", 1, "ERF61: Unsuitable"],
26
+ [:workup_complete, "Workup complete - low creat", 2, "ERF61: Working Up or under discussion"],
27
+ [:transfer_out, "Transfer Out", nil, "Not relevant for ESRF61"],
28
+ [:died, "Died", nil, "Not relevant for ESRF61"]
19
29
  ]
20
30
 
21
31
  statuses.each_with_index do |status, index|
22
- Transplants::RegistrationStatusDescription.create!(
23
- code: status[0],
24
- name: status[1],
25
- position: index * 10
26
- )
32
+ Transplants::RegistrationStatusDescription.find_or_create_by(code: status[0]) do |desc|
33
+ desc.name = status[1]
34
+ desc.rr_code = status[2]
35
+ desc.rr_comment = status[3]
36
+ desc.position = index * 10
37
+ end
27
38
  end
28
39
  end
29
40
  end
@@ -0,0 +1,28 @@
1
+ SELECT mp.id,
2
+ mp.patient_id,
3
+ mp.drug_id,
4
+ mp.treatable_type,
5
+ mp.treatable_id,
6
+ mp.dose_amount,
7
+ mp.dose_unit,
8
+ mp.medication_route_id,
9
+ mp.route_description,
10
+ mp.frequency,
11
+ mp.notes,
12
+ mp.prescribed_on,
13
+ mp.provider,
14
+ mp.created_at,
15
+ mp.updated_at,
16
+ mp.created_by_id,
17
+ mp.updated_by_id,
18
+ mp.administer_on_hd,
19
+ mp.last_delivery_date,
20
+ drugs.name as drug_name,
21
+ drug_types.code AS drug_type_code,
22
+ drug_types.name AS drug_type_name
23
+ FROM medication_prescriptions mp
24
+ FULL JOIN medication_prescription_terminations mpt ON mpt.prescription_id = mp.id
25
+ JOIN drugs ON drugs.id = mp.drug_id
26
+ FULL JOIN drug_types_drugs ON drug_types_drugs.drug_id = drugs.id
27
+ FULL JOIN drug_types ON drug_types_drugs.drug_type_id = drug_types.id
28
+ AND (mpt.terminated_on IS NULL OR mpt.terminated_on > now());