Patient risk indicators - aavedula/how-to-notes GitHub Wiki
Background
A patient is considered to be at risk if he/she meets certain criteria. The first criterion to be implemented is whether or not the patient has been to an emergency department more than four times in the past year.
The patient's timeline page should contain a section to the right of the other patient info that should indicate whether or not a patient is at risk.
If the patient is at risk, there should be a red alert icon; a header in red text; a message describing the type of risk; and a box with a red background and border containing the icon, header, and message.
If the patient is not at risk, there should be an alert icon and header in the standard font colour and a message in italics and the standard font colour. There should be no box.
The feature involves both front end and back end changes. The following describe the major components of the feature.
Implementation
Overall architecture
Backend
The following sections list some of the major changes that were made. It is not a complete list of all files that changed.
Data models
-
PatientRisks
A new model that contains methods to calculate a patient's risk indicators.
-
PatientHistory
Instantiates the new PatientRisks method to access risks.
Presenters
-
PatientRisksPresenter
A model that converts that PatientRisks data to a JSON format suitable to pass to the front end.
-
PatientHistoryPresenter
Calls the PatientRisksPresenter#as_json to return the risks data.
Specs
New specs were written for changes in the models and presenters.
Frontend
Control
-
Control/Timeline.elm
This file contains all the methods required to display the block. The methods are prefixed by riskSummary and are similar to the methods prefixed with patientInfo. Although a few new css classes were introduced, most of these methods use the existing patient-info- classes.
-
Control/Timeline/Translation.elm
This contains text strings to be translated, including the header, the risk message, and message indicating the lack of risk indicators.
Decoders
-
Data/PatientRisks.elm
New decoder for the JSON data returned by the PatientRisksPresenter.
-
Data/PatientHistory.elm
Calls the PatientRisks Decoder to decode risks.
Assets
-
app/assets/stylesheets/views/_timeline.scss
New classes to control the appearance of the alert icon, header, message, and box.
-
app/assets/elm/Icon.elm
A new icon font was added for the alert icon. (Refer to the rails_common README for instructions.)
Specs
-
spec/system/patient_history_spec.rb
Checks were added for the risk summary section.