renalware-core 2.0.0.pre.rc9 → 2.0.0.pre.rc10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/renalware/modules/_clinics.scss +1 -1
  3. data/app/assets/stylesheets/renalware/modules/_letters.scss +7 -0
  4. data/app/assets/stylesheets/renalware/partials/_navigation.scss +1 -1
  5. data/app/controllers/renalware/api/ukrdc/patients_controller.rb +2 -1
  6. data/app/controllers/renalware/application_controller.rb +13 -0
  7. data/app/controllers/renalware/base_controller.rb +0 -2
  8. data/app/controllers/renalware/concerns/cache_busting.rb +21 -0
  9. data/app/controllers/renalware/devise/passwords_controller.rb +0 -2
  10. data/app/controllers/renalware/devise/registrations_controller.rb +0 -2
  11. data/app/controllers/renalware/devise/sessions_controller.rb +0 -2
  12. data/app/controllers/renalware/events/events_controller.rb +2 -0
  13. data/app/controllers/renalware/letters/letters_controller.rb +1 -1
  14. data/app/controllers/renalware/pd/bag_types_controller.rb +1 -1
  15. data/app/controllers/renalware/virology/dashboards_controller.rb +15 -0
  16. data/app/controllers/renalware/virology/vaccinations_controller.rb +11 -0
  17. data/app/documents/renalware/patient_document.rb +9 -0
  18. data/app/jobs/hl7_message_example.yml +12 -12
  19. data/app/models/renalware/events/event.rb +28 -3
  20. data/app/models/renalware/pathology/create_observation_requests.rb +2 -1
  21. data/app/models/renalware/pathology/observation_description.rb +2 -0
  22. data/app/models/renalware/pathology/observation_descriptions_by_code_query.rb +2 -1
  23. data/app/models/renalware/pathology/observation_requests_attributes_builder.rb +14 -1
  24. data/app/models/renalware/pd/bag_type.rb +2 -0
  25. data/app/models/renalware/pd/capd_regime.rb +5 -1
  26. data/app/models/renalware/virology.rb +13 -0
  27. data/app/models/renalware/virology/profile.rb +8 -0
  28. data/app/models/renalware/virology/vaccination.rb +24 -0
  29. data/app/policies/renalware/virology/dasboard_policy.rb +8 -0
  30. data/app/policies/renalware/virology/vaccination_policy.rb +8 -0
  31. data/app/presenters/renalware/admissions/summary_part.rb +30 -0
  32. data/app/presenters/renalware/events/summary_part.rb +31 -0
  33. data/app/presenters/renalware/letters/summary_part.rb +48 -0
  34. data/app/presenters/renalware/medications/summary_part.rb +23 -0
  35. data/app/presenters/renalware/problems/summary_part.rb +19 -0
  36. data/app/presenters/renalware/renal/clinical_summary_presenter.rb +5 -90
  37. data/app/presenters/renalware/summary_part.rb +34 -0
  38. data/app/views/renalware/admissions/_summary_part.html.slim +14 -0
  39. data/app/views/renalware/clinical/_header.html.slim +3 -3
  40. data/app/views/renalware/clinics/visits/index.html.slim +0 -1
  41. data/app/views/renalware/events/events/_event.html.slim +2 -2
  42. data/app/views/renalware/events/events/_form.html.slim +1 -2
  43. data/app/views/renalware/events/events/_summary_part.html.slim +15 -0
  44. data/app/views/renalware/events/events/new.js.erb +2 -3
  45. data/app/views/renalware/events/events/simple/_event.html.slim +1 -2
  46. data/app/views/renalware/layouts/_patient.html.slim +1 -0
  47. data/app/views/renalware/letters/_summary_part.html.slim +16 -0
  48. data/app/views/renalware/letters/letters/index.html.slim +3 -3
  49. data/app/views/renalware/mdm_patients/_table.html.slim +1 -1
  50. data/app/views/renalware/medications/_summary_part.html.slim +18 -0
  51. data/app/views/renalware/patients/clinical_summaries/show.html.slim +6 -32
  52. data/app/views/renalware/patients/patients/_form.html.slim +13 -0
  53. data/app/views/renalware/patients/patients/show.html.slim +2 -0
  54. data/app/views/renalware/patients/patients/show/_psychosocial.html.slim +15 -0
  55. data/app/views/renalware/patients/side_menu/_general.html.slim +4 -0
  56. data/app/views/renalware/problems/problems/_summary_part.html.slim +16 -0
  57. data/app/views/renalware/virology/dashboards/_actions.html.slim +10 -0
  58. data/app/views/renalware/virology/dashboards/show.html.slim +6 -0
  59. data/app/views/renalware/virology/vaccinations/_cell.html.slim +2 -0
  60. data/app/views/renalware/virology/vaccinations/_inputs.html.slim +4 -0
  61. data/app/views/renalware/virology/vaccinations/_list.html.slim +14 -0
  62. data/app/views/renalware/virology/vaccinations/_toggled_cell.html.slim +8 -0
  63. data/config/locales/en-GB.yml +1 -3
  64. data/config/locales/en.yml +0 -11
  65. data/config/locales/renalware/age.yml +0 -1
  66. data/config/locales/renalware/clinical/allergies.en.yml +0 -3
  67. data/config/locales/renalware/clinical/body_composition.yml +0 -2
  68. data/config/locales/renalware/clinical/dry_weight.en.yml +0 -2
  69. data/config/locales/renalware/clinics/visit.yml +0 -2
  70. data/config/locales/renalware/feeds/file.en.yml +0 -1
  71. data/config/locales/renalware/hd/diary_slots.en.yml +0 -1
  72. data/config/locales/renalware/hd/prescription_administration.en.yml +0 -1
  73. data/config/locales/renalware/hd/session.en.yml +0 -1
  74. data/config/locales/renalware/hospitals/unit.yml +0 -2
  75. data/config/locales/renalware/letters/contact.en.yml +0 -1
  76. data/config/locales/renalware/letters/letter.en.yml +0 -2
  77. data/config/locales/renalware/low_clearance/profile.en.yml +0 -1
  78. data/config/locales/renalware/medications/prescription.yml +0 -2
  79. data/config/locales/renalware/messaging/internal/messages.en.yml +0 -2
  80. data/config/locales/renalware/patient.yml +0 -2
  81. data/config/locales/renalware/patients/side_menu.en.yml +1 -1
  82. data/config/locales/renalware/pd/assessments.en.yml +0 -1
  83. data/config/locales/renalware/pd/bag_types.yml +0 -2
  84. data/config/locales/renalware/pd/regime.en.yml +0 -2
  85. data/config/locales/renalware/pd/training_sessions.en.yml +0 -1
  86. data/config/locales/renalware/renal/profile.en.yml +0 -1
  87. data/config/locales/renalware/renal/registry.en.yml +0 -2
  88. data/config/locales/renalware/research/study_participant.en.yml +0 -1
  89. data/config/locales/renalware/snippets/snippets.en.yml +0 -1
  90. data/config/locales/renalware/transplants/donation.yml +0 -3
  91. data/config/locales/renalware/transplants/donor_followup.yml +0 -4
  92. data/config/locales/renalware/transplants/donor_operation.yml +0 -4
  93. data/config/locales/renalware/transplants/donor_workup.yml +0 -4
  94. data/config/locales/renalware/transplants/recipient_followup.yml +0 -2
  95. data/config/locales/renalware/transplants/recipient_operation.yml +0 -4
  96. data/config/locales/renalware/transplants/recipient_workup.yml +0 -4
  97. data/config/locales/renalware/transplants/registration.yml +0 -4
  98. data/config/locales/renalware/virology/virology.en.yml +18 -0
  99. data/config/routes.rb +8 -0
  100. data/db/migrate/20180122173922_create_virology_profiles.rb +6 -0
  101. data/db/migrate/20180213171805_add_display_order_cols_to_observation_descriptions.rb +12 -0
  102. data/db/seeds/default/events/event_types.csv +1 -0
  103. data/db/seeds/default/pathology/measurement_units.csv +45 -38
  104. data/db/seeds/default/pathology/measurement_units.rb +1 -0
  105. data/lib/renalware/configuration.rb +14 -0
  106. data/lib/renalware/engine.rb +0 -4
  107. data/lib/renalware/version.rb +1 -1
  108. data/lib/sql/index_case_stmt.rb +6 -6
  109. data/spec/factories/events/events_types.rb +6 -0
  110. data/spec/factories/virology/vaccinations.rb +6 -0
  111. metadata +265 -243
  112. data/app/controllers/application_controller.rb +0 -6
  113. data/app/models/renalware/pathology/view_current_observation_results.rb.dead +0 -47
  114. data/app/presenters/renalware/pathology/current_observation_results.dead/html_table_view.rb.dead +0 -67
  115. data/app/views/renalware/layouts/application.html.slim +0 -44
  116. data/app/views/renalware/patients/clinical_summaries/_admissions.html.slim +0 -11
  117. data/app/views/renalware/patients/clinical_summaries/_events.html.slim +0 -11
  118. data/app/views/renalware/patients/clinical_summaries/_letters.html.slim +0 -12
  119. data/app/views/renalware/patients/clinical_summaries/_prescriptions.html.slim +0 -16
  120. data/app/views/renalware/patients/clinical_summaries/_problems.html.slim +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3361756d54b9a83fa22bab7f608be70508af45ecfe4b2caa6155c5a179463067
4
- data.tar.gz: 82ae6e70d84354b6764a549e1eb8c624b2b9706b3109af3f40f739d90fdb4ca4
3
+ metadata.gz: 020dc0513f4623aebbe15a14363cd05525eaed0405a8deacb057dcd585e39114
4
+ data.tar.gz: 89f150581ec3fb071333af4682c971c0564cf71f0c6284d20941e2a0839c14e3
5
5
  SHA512:
6
- metadata.gz: 2e516676b956cc6abf3189e4b270400c13282e774530051637b9c39e914c4c55d1109274b53541ec811f93f160d5aee9193dd4a3ce11943e046b46188d0e3c9b
7
- data.tar.gz: 5c45e168decc8c91857411ff6d1736939e206030f3e75749d125798c0d12bfcfc84fe9ab04e881c4e05c74ce315bc4bb546fc37f0dc5dd57068f560a4a782fbf
6
+ metadata.gz: 92079d58e50dcc7a2475ee28850baaaf804e129b15accef98d542fcca39bb5da6691135f307f4098636ca134ad8673c6c139aad6cb656eb90451dced4f4cacdc
7
+ data.tar.gz: 994ec364d3c9bed98075d17742390327685c5b46465ab016531c25db804e4500709fc4a6907b8e99eb45857785884db3638097a54dae9e0c88836595b369ec3c
@@ -1,4 +1,4 @@
1
- .page--cinic-visits {
1
+ .page--visits {
2
2
 
3
3
  .filters__output {
4
4
  display: none;
@@ -1,3 +1,10 @@
1
+ // When the letter summary part is included in the clinical summary, make it 12 cols wide.
2
+ .page--clinical_summaries {
3
+ .summary-part--letters {
4
+ @include grid-column(12);
5
+ }
6
+ }
7
+
1
8
  table.contacts tbody td{
2
9
  vertical-align: top;
3
10
  }
@@ -78,7 +78,7 @@ dd.patient-name {
78
78
  }
79
79
 
80
80
  ul.side-nav {
81
- margin: .1rem 0 0 0;
81
+ margin: 0;
82
82
  padding: 0;
83
83
 
84
84
  li {
@@ -1,7 +1,7 @@
1
1
  module Renalware
2
2
  module API
3
3
  module UKRDC
4
- class PatientsController < ApplicationController
4
+ class PatientsController < BaseController
5
5
  respond_to :xml
6
6
 
7
7
  def show
@@ -18,6 +18,7 @@ module Renalware
18
18
 
19
19
  def patient_presenter
20
20
  patient = Renalware::Patient.find_by!(secure_id: params[:id])
21
+ authorize patient
21
22
  Renalware::UKRDC::PatientPresenter.new(patient)
22
23
  end
23
24
  end
@@ -0,0 +1,13 @@
1
+ require_dependency "renalware"
2
+
3
+ module Renalware
4
+ # Note that we inherit from ::ApplicationController which is defined in the host application.
5
+ # This allows application to
6
+ # - define the default layout
7
+ # - intercept requests with before_action etc.
8
+ class ApplicationController < ::ApplicationController
9
+ # Prevent CSRF attacks by raising an exception.
10
+ # For APIs, you may want to use :null_session instead.
11
+ protect_from_forgery with: :exception
12
+ end
13
+ end
@@ -10,8 +10,6 @@ module Renalware
10
10
 
11
11
  rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
12
12
 
13
- layout "renalware/layouts/application"
14
-
15
13
  # Expose a few attributes for use in the patient layout and its partials.
16
14
  # As a rule, we should be passing variables explicitly to all view using `locals`;
17
15
  # however, while not a fan of `helper_method`, exposing e.g. current_patient this (akin to
@@ -0,0 +1,21 @@
1
+ require "active_support/concern"
2
+
3
+ # The host Rails application's ApplicationController could choose to mix-in this concern in order to
4
+ # prevent the browser from being able navigate Back to logged-in pages once the user has logged out.
5
+ module Renalware
6
+ module Concerns::CacheBusting
7
+ extend ActiveSupport::Concern
8
+
9
+ included do
10
+ class_eval do
11
+ before_action :bust_cache
12
+ end
13
+ end
14
+
15
+ def bust_cache
16
+ response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
17
+ response.headers["Pragma"] = "no-cache"
18
+ response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
19
+ end
20
+ end
21
+ end
@@ -1,6 +1,4 @@
1
1
  class Renalware::Devise::PasswordsController < ::Devise::PasswordsController
2
2
  helper Renalware::ApplicationHelper
3
3
  include Renalware::Concerns::DeviseControllerMethods
4
-
5
- layout "renalware/layouts/application"
6
4
  end
@@ -1,6 +1,4 @@
1
1
  class Renalware::Devise::RegistrationsController < ::Devise::RegistrationsController
2
2
  helper Renalware::ApplicationHelper
3
3
  include Renalware::Concerns::DeviseControllerMethods
4
-
5
- layout "renalware/layouts/application"
6
4
  end
@@ -2,8 +2,6 @@ module Renalware
2
2
  class Devise::SessionsController < ::Devise::SessionsController
3
3
  include Concerns::DeviseControllerMethods
4
4
 
5
- layout "renalware/layouts/application"
6
-
7
5
  # Define the path to go to after logging in:
8
6
  # - if the user has never before logged-in, devise will take them to the root path (dashboard)
9
7
  # - if the user's session timed-out less that 30 minutes ago, we take them back to the
@@ -6,6 +6,8 @@ module Renalware
6
6
  class EventsController < BaseController
7
7
  include Renalware::Concerns::Pageable
8
8
 
9
+ # HTML GET when rendering the new form
10
+ # JS GET after user selects event type, prompting us to return event-specific form fields
9
11
  def new
10
12
  save_path_to_return_to
11
13
  render locals: {
@@ -8,7 +8,7 @@ module Renalware
8
8
  before_action :load_patient, except: [:author]
9
9
 
10
10
  def index
11
- render :index, locals: { letters: present_letters(find_letters) }
11
+ render :index, locals: { letters: present_letters(find_letters), patient: patient }
12
12
  end
13
13
 
14
14
  def author
@@ -23,7 +23,7 @@ module Renalware
23
23
  end
24
24
 
25
25
  def index
26
- bag_types = BagType.all
26
+ bag_types = BagType.ordered
27
27
  authorize bag_types
28
28
  render locals: { bag_types: bag_types }
29
29
  end
@@ -0,0 +1,15 @@
1
+ require_dependency "renalware/virology"
2
+
3
+ module Renalware
4
+ module Virology
5
+ class DashboardsController < BaseController
6
+ def show
7
+ authorize patient
8
+ render locals: {
9
+ patient: patient,
10
+ vaccinations: Vaccination.for_patient(patient)
11
+ }
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ require_dependency "renalware/events"
2
+ require_dependency "renalware/virology"
3
+
4
+ # This controller is mostly empty - we are using it for mainly routing and to let us
5
+ # override the events 'new' and 'edit' templates. See the base class for most functionality.
6
+ module Renalware
7
+ module Virology
8
+ class VaccinationsController < Events::EventsController
9
+ end
10
+ end
11
+ end
@@ -23,6 +23,15 @@ module Renalware
23
23
  end
24
24
  attribute :referral, Referral
25
25
 
26
+ class Psychosocial < Document::Embedded
27
+ attribute :housing, String
28
+ attribute :social_network, String
29
+ attribute :care_package, String
30
+ attribute :other, String
31
+ attribute :updated_at, Date
32
+ end
33
+ attribute :psychosocial, Psychosocial
34
+
26
35
  class History < Document::Embedded
27
36
  attribute :alcohol, Document::Enum, enums: %i(never rarely social heavy)
28
37
  attribute :smoking, Document::Enum, enums: %i(no ex yes) # RRSMOKING %i(never former current)
@@ -5,18 +5,18 @@ raw_message: |
5
5
  PV1||Inpatient|NIBC^^^^^^^^|||||MID^KINGS MIDWIVES||||||||||NHS|HXF888888^^^Visit Number|||||||||
6
6
  ORC|RE|^PCS|09B0099478^LA||CM||||200911111841|||MID^KINGS MIDWIVES|||||||
7
7
  OBR|1|^PCS|09B0099478^LA|FBC^FULL BLOOD COUNT^MB||200911111841|200911111841|||||||200911111841|B^Blood|MID^KINGS MIDWIVES||09B0099478||||200911121646||HM|F||||||||||||||||||
8
- OBX|1|TX|WBC^WBC^MB||6.09||||||F|||200911112026||BBKA^Kenneth AMENYAH|
9
- OBX|2|TX|RBC^RBC^MB||4.00||||||F|||200911112026||BBKA^Kenneth AMENYAH|
10
- OBX|3|TX|HGB^Hb^MB||11.8||||||F|||200911112026||BBKA^Kenneth AMENYAH|
11
- OBX|4|TX|PCV^PCV^MB||0.344||||||F|||200911112026||BBKA^Kenneth AMENYAH|
12
- OBX|5|TX|MCV^MCV^MB||85.9||||||F|||200911112026||BBKA^Kenneth AMENYAH|
13
- OBX|6|TX|MCH^MCH^MB||29.5||||||F|||200911112026||BBKA^Kenneth AMENYAH|
14
- OBX|7|TX|MCHC^MCHC^MB||34.4||||||F|||200911112026||BBKA^Kenneth AMENYAH|
15
- OBX|8|TX|RDW^RDW^MB||13.3||||||F|||200911112026||BBKA^Kenneth AMENYAH|
16
- OBX|9|TX|PLT^PLT^MB||259||||||F|||200911112026||BBKA^Kenneth AMENYAH|
17
- OBX|10|TX|MPV^Mean Platelet Volume^MB||8.3||||||F|||200911112026||BBKA^Kenneth AMENYAH|
18
- OBX|11|TX|NRBC^Machine NRBC^MB||<0.2%||||||F|||200911112026||BBKA^Kenneth AMENYAH|
19
- OBX|12|TX|HYPO^% HYPO^MB||0.2||||||F|||200911112026||BBKA^Kenneth AMENYAH|
8
+ OBX|1|TX|WBC^WBC^MB||6.09||||||F|||200911112026||BBKA^Donald DUCK|
9
+ OBX|2|TX|RBC^RBC^MB||4.00||||||F|||200911112026||BBKA^Donald DUCK|
10
+ OBX|3|TX|HGB^Hb^MB||11.8||||||F|||200911112026||BBKA^Donald DUCK|
11
+ OBX|4|TX|PCV^PCV^MB||0.344||||||F|||200911112026||BBKA^Donald DUCK|
12
+ OBX|5|TX|MCV^MCV^MB||85.9||||||F|||200911112026||BBKA^Donald DUCK|
13
+ OBX|6|TX|MCH^MCH^MB||29.5||||||F|||200911112026||BBKA^Donald DUCK|
14
+ OBX|7|TX|MCHC^MCHC^MB||34.4||||||F|||200911112026||BBKA^Donald DUCK|
15
+ OBX|8|TX|RDW^RDW^MB||13.3||||||F|||200911112026||BBKA^Donald DUCK|
16
+ OBX|9|TX|PLT^PLT^MB||259||||||F|||200911112026||BBKA^Donald DUCK|
17
+ OBX|10|TX|MPV^Mean Platelet Volume^MB||8.3||||||F|||200911112026||BBKA^Donald DUCK|
18
+ OBX|11|TX|NRBC^Machine NRBC^MB||<0.2%||||||F|||200911112026||BBKA^Donald DUCK|
19
+ OBX|12|TX|HYPO^% HYPO^MB||0.2||||||F|||200911112026||BBKA^Donald DUCK|
20
20
  OBX|13|TX|NEUT^Neutrophil Count^MB|| 3.16||||||F|||200911121646||BHISVC01^BHI Authchecker|
21
21
  OBX|14|TX|LYM^Lymphocyte Count^MB|| 2.32||||||F|||200911121646||BHISVC01^BHI Authchecker|
22
22
  OBX|15|TX|MON^Monocyte Count^MB|| 0.44||||||F|||200911121646||BHISVC01^BHI Authchecker|
@@ -29,12 +29,37 @@ module Renalware
29
29
  NullObject.instance
30
30
  end
31
31
 
32
+ def to_s
33
+ description
34
+ end
35
+
36
+ # As Events are a cross domain model, a subclass can choose to override to_partial_path etc
37
+ # in order to use events from another namespace for instance.
32
38
  def to_partial_path
33
- self.class.name.demodulize.underscore
39
+ partial_for "inputs"
34
40
  end
41
+ alias :to_input_partial_path :to_partial_path
35
42
 
36
- def to_s
37
- description
43
+ def to_cell_partial_path
44
+ partial_for "cell"
45
+ end
46
+
47
+ def to_toggled_cell_partial_path
48
+ partial_for "toggled_cell"
49
+ end
50
+
51
+ def partial_for(partial_type)
52
+ File.join(
53
+ "renalware/events/events",
54
+ partial_type,
55
+ self.class.name.demodulize.underscore
56
+ )
57
+ end
58
+
59
+ private
60
+
61
+ def our_class_name
62
+ self.class.name.demodulize.underscore
38
63
  end
39
64
  end
40
65
  end
@@ -2,7 +2,8 @@ require_dependency "renalware/pathology"
2
2
 
3
3
  #
4
4
  # Create pathology observations requests and their child observations for an existing
5
- # patient from HL7 message content.
5
+ # patient from HL7 message content previously parsed into an array of hashes (there can be > 1 OBR
6
+ # in each message).
6
7
  #
7
8
  module Renalware
8
9
  module Pathology
@@ -4,6 +4,8 @@ module Renalware
4
4
  module Pathology
5
5
  class ObservationDescription < ApplicationRecord
6
6
  belongs_to :measurement_unit
7
+ validates :display_order, uniqueness: { allow_nil: true }
8
+ validates :display_order_letters, uniqueness: { allow_nil: true }
7
9
 
8
10
  def self.for(codes)
9
11
  ObservationDescriptionsByCodeQuery.new(codes: codes).call
@@ -6,7 +6,7 @@ module Renalware
6
6
  class ObservationDescriptionsByCodeQuery
7
7
  def initialize(relation: ObservationDescription, codes:)
8
8
  @relation = relation
9
- @codes = codes
9
+ @codes = Array(codes)
10
10
  end
11
11
 
12
12
  # Executes SQL that looks like this:
@@ -37,6 +37,7 @@ module Renalware
37
37
  def verify_all_records_found(records)
38
38
  found_codes = records.map(&:code)
39
39
 
40
+ # TODO: Bug? Shouldn't this be @codes - found_codes?
40
41
  missing_records = found_codes - @codes
41
42
  if missing_records.present?
42
43
  raise ActiveRecord::RecordNotFound, "Missing records for #{missing_records}"
@@ -71,13 +71,14 @@ module Renalware
71
71
  def build_observations_params(request)
72
72
  request.observations.map do |observation|
73
73
  observation_description = find_observation_description(observation.identifier)
74
+ next unless validate_observation(observation, observation_description)
74
75
  {
75
76
  description_id: observation_description.id,
76
77
  observed_at: parse_time(observation.date_time),
77
78
  result: observation.value,
78
79
  comment: observation.comment
79
80
  }
80
- end
81
+ end.compact
81
82
  end
82
83
 
83
84
  def find_request_description(code)
@@ -88,6 +89,18 @@ module Renalware
88
89
  ObservationDescription.find_by!(code: code)
89
90
  end
90
91
 
92
+ def validate_observation(observation, observation_description)
93
+ if observation.date_time.blank?
94
+ logger.warn(
95
+ "Skipped observation with blank `observed_at` (date_time) "\
96
+ "in OBX with code #{observation_description.code}"
97
+ )
98
+ false
99
+ else
100
+ true
101
+ end
102
+ end
103
+
91
104
  # TODO: Support searching by other local patient ids?
92
105
  def find_patient(local_patient_id)
93
106
  Patient.find_by!(local_patient_id: local_patient_id)
@@ -6,6 +6,8 @@ module Renalware
6
6
  acts_as_paranoid
7
7
  extend Enumerize
8
8
 
9
+ scope :ordered, ->{ order(manufacturer: :asc, description: :asc) }
10
+
9
11
  enumerize :glucose_strength, in: { not_applicable: 0, low: 1, medium: 2, high: 3 }
10
12
 
11
13
  has_many :bags, class_name: "Renalware::PD::RegimeBag"
@@ -6,7 +6,9 @@ module Renalware
6
6
  include OrderedScope
7
7
  include PatientScope
8
8
 
9
- BAG_VOLUMES = [1000, 1200, 1500, 1800, 2000, 2200, 2500].freeze
9
+ BAG_VOLUMES = [
10
+ 500, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2200, 2500
11
+ ].freeze
10
12
 
11
13
  before_save :set_glucose_volume_low_strength
12
14
  before_save :set_glucose_volume_medium_strength
@@ -18,6 +20,7 @@ module Renalware
18
20
 
19
21
  private
20
22
 
23
+ # rubocop:disable Metrics/MethodLength
21
24
  def match_bag_type
22
25
  @match_bag_type ||= begin
23
26
  glucose_types = [[], [], []]
@@ -34,6 +37,7 @@ module Renalware
34
37
  glucose_types
35
38
  end
36
39
  end
40
+ # rubocop:enable Metrics/MethodLength
37
41
 
38
42
  def set_glucose_volume_low_strength
39
43
  if match_bag_type[0].empty?
@@ -0,0 +1,13 @@
1
+ require_dependency "renalware"
2
+
3
+ module Renalware
4
+ module Virology
5
+ def self.table_name_prefix
6
+ "virology_"
7
+ end
8
+
9
+ def self.cast_patient(patient)
10
+ ActiveType.cast(patient, ::Renalware::Virology::Patient)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ require_dependency "renalware/virology"
2
+
3
+ module Renalware
4
+ module Virology
5
+ class Profile < ApplicationRecord
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,24 @@
1
+ require_dependency "renalware/virology"
2
+ require_dependency "renalware/events"
3
+ require "document/base"
4
+ require "document/embedded"
5
+ require "document/enum"
6
+
7
+ module Renalware
8
+ module Virology
9
+ class Vaccination < Events::Event
10
+ include Document::Base
11
+
12
+ # Return e.g. "renalware/virology/vaccinations/toggled_cell
13
+ def partial_for(partial_type)
14
+ File.join("renalware/virology/vaccinations", partial_type)
15
+ end
16
+
17
+ class Document < Document::Embedded
18
+ attribute :type, ::Document::Enum # See i18n for options
19
+ validates :type, presence: true
20
+ end
21
+ has_document
22
+ end
23
+ end
24
+ end