Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VACCS v1.0.3 master merge #52

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions app/controllers/public_health_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def patients
# Validate tab param
tab = permitted_params.require(:tab).to_sym
if workflow == :exposure
return head :bad_request unless %i[all followup symptomatic non_reporting asymptomatic pui closed transferred_in transferred_out].include?(tab)
return head :bad_request unless %i[all followup symptomatic non_reporting asymptomatic registered pui closed transferred_in transferred_out].include?(tab)
else
return head :bad_request unless %i[all requiring_review non_reporting reporting closed transferred_in transferred_out].include?(tab)
end
Expand Down Expand Up @@ -105,7 +105,7 @@ def tab_counts
# Validate tab param
tab = params.require(:tab).to_sym
if workflow == :exposure
return head :bad_request unless %i[all followup symptomatic non_reporting asymptomatic pui closed transferred_in transferred_out].include?(tab)
return head :bad_request unless %i[all followup symptomatic non_reporting asymptomatic registered pui closed transferred_in transferred_out].include?(tab)
else
return head :bad_request unless %i[all requiring_review non_reporting reporting closed transferred_in transferred_out].include?(tab)
end
Expand All @@ -129,6 +129,7 @@ def patients_by_type(workflow, tab)
return current_user.viewable_patients.exposure_symptomatic if tab == :symptomatic
return current_user.viewable_patients.exposure_non_reporting if tab == :non_reporting
return current_user.viewable_patients.exposure_asymptomatic if tab == :asymptomatic
return current_user.viewable_patients.exposure_registered if tab == :registered
return current_user.viewable_patients.exposure_under_investigation if tab == :pui
else
return current_user.viewable_patients.isolation_requiring_review if tab == :requiring_review
Expand Down Expand Up @@ -200,11 +201,14 @@ def sort(patients, order, direction)
when 'latest_report'
patients = patients.order('CASE WHEN latest_assessment_at IS NULL THEN 1 ELSE 0 END, latest_assessment_at ' + dir)
when 'status'
# For alphabetical sorting: closed 0, followup 1, non-reporting 2, reviewed 3, symptomatic 4
# Case determination -> closed, followup, symptomatic, reviewed, non-reporting
patients = patients.order('CASE WHEN monitoring != true THEN 0 WHEN severe_symptom_onset IS NOT NULL THEN 1 WHEN symptom_onset IS NOT NULL then 4 WHEN
latest_assessment_at IS NOT NULL and latest_assessment_at >= DATE_SUB(DATE(NOW()), INTERVAL ' +
reporting_period + ' MINUTE) THEN 3 ELSE 2 END ' + dir)
# For alphabetical sorting: closed 0, followup 1, non-reporting 2, registered 3, reviewed 4, symptomatic 5
# Case determination -> closed, followup, symptomatic, registered, reviewed, non-reporting
patients = patients.select('patients.*, MAX(dosages.date_given)').joins('LEFT JOIN dosages ON patients.id = dosages.patient_id')
.group('patients.id')
.order('CASE WHEN monitoring != true THEN 0 WHEN MAX(dosages.date_given) IS NULL THEN 3 WHEN severe_symptom_onset IS NOT NULL THEN 1
WHEN symptom_onset IS NOT NULL then 5 WHEN latest_assessment_at IS NOT NULL and latest_assessment_at >= DATE_SUB(UTC_TIMESTAMP()
, INTERVAL ' + reporting_period + ' MINUTE) THEN 4 WHEN patients.created_at is NOT NULL and patients.created_at >=
DATE_SUB(UTC_TIMESTAMP(), INTERVAL ' + reporting_period + ' MINUTE) THEN 4 ELSE 2 END ' + dir)
when 'dose1_date'
patients = patients.select('patients.*, dosages.dose_number, MAX(dosages.date_given)').joins('LEFT JOIN dosages ON patients.id = dosages.patient_id')
.group('patients.id, dosages.dose_number').having('dosages.dose_number = 1 OR dosages.dose_number IS NULL')
Expand Down Expand Up @@ -282,18 +286,19 @@ def linelist(patients, workflow, tab)
end

def linelist_specific_fields(workflow, tab)
return %i[jurisdiction assigned_user expected_purge_date reason_for_closure closed_at dose1_date dose2_date dose2_app] if tab == :closed
return %i[jurisdiction expected_purge_date reason_for_closure closed_at dose1_date dose2_date dose2_app] if tab == :closed

if workflow == :isolation
return %i[jurisdiction assigned_user extended_isolation symptom_onset monitoring_plan latest_report status report_eligibility] if tab == :all
return %i[jurisdiction extended_isolation symptom_onset monitoring_plan latest_report status report_eligibility] if tab == :all
return %i[transferred_from monitoring_plan transferred_at] if tab == :transferred_in
return %i[transferred_to monitoring_plan transferred_at] if tab == :transferred_out

return %i[jurisdiction assigned_user extended_isolation symptom_onset monitoring_plan latest_report report_eligibility]
return %i[jurisdiction extended_isolation symptom_onset monitoring_plan latest_report report_eligibility]
end

return %i[jurisdiction end_of_monitoring latest_report status report_eligibility dose1_date dose2_date dose2_app] if tab == :all
return %i[jurisdiction assigned_user end_of_monitoring risk_level public_health_action latest_report report_eligibility] if tab == :pui
return %i[jurisdiction] if tab == :registered
return %i[jurisdiction end_of_monitoring risk_level public_health_action latest_report report_eligibility] if tab == :pui
return %i[transferred_from end_of_monitoring risk_level monitoring_plan transferred_at] if tab == :transferred_in
return %i[transferred_to end_of_monitoring risk_level monitoring_plan transferred_at] if tab == :transferred_out

Expand Down
1 change: 1 addition & 0 deletions app/helpers/patient_details_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def status
return :closed unless monitoring

unless isolation
return :exposure_registered if latest_dosage.nil?
return :exposure_follow_up unless severe_symptom_onset.nil?
return :exposure_under_investigation if public_health_action != 'None'
return :exposure_symptomatic unless symptom_onset.nil?
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/components/public_health/PatientsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class PatientsTable extends React.Component {
{ field: 'end_of_monitoring', label: 'End of Monitoring', isSortable: true, tooltip: null, filter: this.formatDate },
{ field: 'latest_report', label: 'Latest Report', isSortable: true, tooltip: null, filter: this.formatTimestamp },
{ field: 'status', label: 'Status', isSortable: true, tooltip: null },
// { field: 'report_eligibility', label: '', isSortable: false, tooltip: null, filter: this.createEligibilityTooltip, icon: 'far fa-comment' },
{ field: 'report_eligibility', label: '', isSortable: false, tooltip: null, filter: this.createEligibilityTooltip, icon: 'far fa-comment' },
],
displayedColData: [],
rowData: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CloseRecords extends React.Component {
apply_to_household: false,
loading: false,
monitoring: false,
monitoring_reasons: ['Both doses completed', 'Deceased', 'Duplicate', 'Person under investigation', 'Other'],
monitoring_reasons: ['Deceased', 'Duplicate', 'Person under investigation', 'Other'],
monitoring_reason: '',
reasoning: '',
};
Expand Down
2 changes: 2 additions & 0 deletions app/javascript/components/subject/CurrentStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class CurrentStatus extends React.Component {
return <span className="text-danger">needs follow up</span>;
} else if (status === 'exposure_reviewed') {
return <span className="text-success">reviewed</span>;
} else if (status === 'exposure_registered') {
return <span className="text-secondary">registered</span>;
} else if (status === 'exposure_non_reporting') {
return <span className="text-warning">non-reporting</span>;
} else if (status === 'exposure_under_investigation') {
Expand Down
8 changes: 7 additions & 1 deletion app/javascript/components/util/EligibilityTooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ class EligibilityTooltip extends React.Component {
return ts.isValid() ? ts.tz(moment.tz.guess()).format('MM/DD/YYYY HH:mm z') : '';
}

formatDate(date) {
return date ? moment(date, 'YYYY-MM-DD').format('MM/DD/YYYY') : '';
}

formatEligibility(eligibility, id) {
if (eligibility.household) {
return (
Expand Down Expand Up @@ -47,7 +51,9 @@ class EligibilityTooltip extends React.Component {
<ReactTooltip key={`re-tooltip${id}`} id={`re${id}`} multiline={true} type="dark" effect="solid" className="tooltip-container">
<div>
<p className="lead mb-0">Eligible for notifications:</p>
<span>{eligibility.messages[0].message}</span>
<span>
{eligibility.messages[0].message} {eligibility.messages[0].datetime ? ` ${this.formatDate(eligibility.messages[0].datetime)}` : ''}
</span>
</div>
</ReactTooltip>
</React.Fragment>
Expand Down
10 changes: 6 additions & 4 deletions app/javascript/components/util/InfoTooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,15 @@ const TOOLTIP_TEXT = {
// EXPOSURE WORKFLOW LINE LIST DEFINITIONS
exposure_symptomatic: (
<div>
Recipients on this list require public health follow-up to determine if disease is suspected. Follow-up should be based on current guidelines and
available resources.
Recipients on this list are experiencing symptoms following receiving the vaccine. Follow-up should be based on current guidelines and available
resources.
</div>
),

exposure_followup: (
<div>
Recipients on this list require public health follow-up to determine if disease is suspected. Follow-up should be based on current guidelines and
available resources.
Recipients on this list are experiencing severe adverse reactions following receiving the vaccine and require public health follow-up. Follow-up should be
based on current guidelines and available resources.
</div>
),

Expand All @@ -282,6 +282,8 @@ const TOOLTIP_TEXT = {

exposure_asymptomatic: <div>Recipients on this list do not require public health follow-up unless otherwise indicated.</div>,

exposure_registered: <div>Recipients on this list have not received a vaccine dosage yet.</div>,

exposure_under_investigation: (
<div>
A ‘Latest Public Health Action’ other than “None” has been documented in the recipient’s record. Recipients on this list do not receive daily reminder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const authyToken = 'Q1z4yZXLdN+tZod6dBSIlMbZ3yWAUFdY44U06QWffEP76nx1WGMHIz8rYxEU
const monitoringStatusValues = [ 'Actively Monitoring', 'Not Monitoring' ];
const monitoringReasons = [
'--',
'Both doses completed',
'Deceased',
'Duplicate',
'Person under investigation',
Expand Down
15 changes: 7 additions & 8 deletions app/mailers/patient_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# PatientMailer: mailers for monitorees
class PatientMailer < ApplicationMailer
# Inform the patient via email that they will receive notifications after vaccine.
def enrollment_email(patient)
return if patient&.email.blank?

Expand All @@ -17,15 +18,12 @@ def enrollment_email(patient)
History.welcome_message_sent(patient: patient)
end

# Inform the patient via SMS that they will receive notifications after vaccine.
def enrollment_sms_weblink(patient)
return if patient&.primary_telephone.blank?

lang = patient.select_language
url = new_patient_assessment_jurisdiction_lang_initials_url(patient.submission_token,
patient.jurisdiction.unique_identifier,
lang&.to_s || 'en',
patient&.initials_age)
contents = "#{I18n.t('assessments.sms.weblink.intro', locale: lang)} #{patient&.initials_age('-')}: #{url}"
lang = patient.select_language || 'en'
contents = "#{I18n.t('assessments.sms.enrollment.info1', locale: lang)} #{I18n.t('assessments.sms.enrollment.weblink.info2', locale: lang)}"
account_sid = ENV['TWILLIO_API_ACCOUNT']
auth_token = ENV['TWILLIO_API_KEY']
from = ENV['TWILLIO_SENDING_NUMBER']
Expand All @@ -41,11 +39,12 @@ def enrollment_sms_weblink(patient)
patient.update(last_assessment_reminder_sent: DateTime.now)
end

# Inform the user via SMS that they will receive notifications after vaccine.
def enrollment_sms_text_based(patient)
return if patient&.primary_telephone.blank?

lang = patient.select_language
contents = "#{I18n.t('assessments.sms.prompt.intro1', locale: lang)} #{patient&.initials_age('-')} #{I18n.t('assessments.sms.prompt.intro2', locale: lang)}"
lang = patient.select_language || 'en'
contents = "#{I18n.t('assessments.sms.enrollment.info1', locale: lang)} #{I18n.t('assessments.sms.enrollment.prompt.info2', locale: lang)}"
account_sid = ENV['TWILLIO_API_ACCOUNT']
auth_token = ENV['TWILLIO_API_KEY']
from = ENV['TWILLIO_SENDING_NUMBER']
Expand Down
Loading