Skip to content

Commit

Permalink
Merge fefcbd3 into cfc4ee2
Browse files Browse the repository at this point in the history
  • Loading branch information
fredkingham committed Jan 19, 2023
2 parents cfc4ee2 + fefcbd3 commit f1f9196
Show file tree
Hide file tree
Showing 11 changed files with 379 additions and 2 deletions.
12 changes: 11 additions & 1 deletion elcid/assets/js/elcid/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,17 @@ app.config(

.when('/lab-sync-performance/', static_template_route('/templates/monitoring/lab_timings.html'))
.when('/system-stats/', static_template_route('/templates/monitoring/system_stats.html'))

// Although there is only one tb opal patient list route.params.slug is what is
// used by the patient list move tag modal, so we can't hard code it.
.when('/tb/lists/:slug/', {
controller: 'PatientListCtrl',
resolve: {
episodedata : function(patientListLoader) { return patientListLoader(); },
metadata : function(Metadata){ return Metadata.load(); },
profile : function(UserProfile){ return UserProfile.load(); }
},
templateUrl: "/templates/tb_patient_review_list.html"
})
.when('/tb/clinic-list/', static_template_route('/templates/tb/clinic_list/'))
.when('/tb/clinic-list/:date_stamp', param_template_route('/templates/tb/clinic_list/', 'date_stamp'))
.when('/tb/last-30-days/', static_template_route('/templates/tb/last_30_days.html'))
Expand Down
2 changes: 2 additions & 0 deletions elcid/patient_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
class RfhPatientList(AbstractBase):
comparator_service = "EpisodeAddedComparator"
order = 50
# This attribute means it shows up in the main patient list navigation
show_in_main_patient_list = True

def to_dict(self, user):
qs = super(RfhPatientList, self).get_queryset()
Expand Down
2 changes: 1 addition & 1 deletion elcid/templates/episode_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ <h3>
</h3>
<ul class="patientlist-list">
{% for list in lists|dictsort:'display_name' %}
{% if list.get_slug != list_slug %}
{% if list.get_slug != list_slug and list.show_in_main_patient_list %}
<li>
<a href="#/list/{{ list.get_slug }}">
{{ list.display_name }}
Expand Down
61 changes: 61 additions & 0 deletions plugins/tb/patient_lists.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from opal.core.patient_lists import TaggedPatientList
from elcid import models as elcid_models
from opal import models as opal_models
from plugins.tb import models as tb_models


class TBPatientReview(TaggedPatientList):
display_name = "Patient Review"

direct_add = False
tag = "tb_patient_review"

# template name is not actually used
template_name = "tb_patient_review_list.html"

# schema is not used
schema = []

def to_dict(self, user):
tagging = opal_models.Tagging.objects.filter(
archived=False,
value=self.tag
)
episode_qs = opal_models.Episode.objects.filter(
tagging__in=tagging
).prefetch_related(
'patient__bedstatus'
).prefetch_related(
'patient__demographics_set'
)
episode_dicts = []
for episode in episode_qs:
episode_id = episode.id
episode_dict = {"id": episode_id}
demographics = episode.patient.demographics_set.all()
episode_dict['demographics'] = [d.to_dict(user) for d in demographics]
statuses = episode.patient.bedstatus.all()
episode_dict["bed_status"] = [s.to_dict() for s in statuses]
primary_diagnosis = elcid_models.Diagnosis.objects.filter(
episode_id=episode_id
).filter(category=elcid_models.Diagnosis.PRIMARY)
episode_dict[elcid_models.Diagnosis.get_api_name()] = [
pd.to_dict(user) for pd in primary_diagnosis
]
patient_consultation_qs = tb_models.PatientConsultation.objects.filter(
episode_id=episode_id
)
recent_patient_consultation = patient_consultation_qs.order_by(
"-when"
).first()
episode_dict["recent_patient_consultation"] = None
if recent_patient_consultation:
episode_dict[
"recent_patient_consultation"
] = recent_patient_consultation.to_dict(user)
# this is required to remove the episode tag
episode_dict["tagging"] = {
self.tag: True
}
episode_dicts.append(episode_dict)
return episode_dicts
1 change: 1 addition & 0 deletions plugins/tb/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class TbPlugin(plugins.OpalPlugin):
# 'js/tb/app.js',
'js/tb/filters.js',
'js/tb/controllers/tb_symptom_complex.js',
'js/tb/controllers/add_remove_tag_modal.js',
'js/tb/controllers/patient_consultation.js',
'js/tb/controllers/new_subrecord_step.js',
'js/tb/controllers/tb_diagnosis.js',
Expand Down
52 changes: 52 additions & 0 deletions plugins/tb/static/js/tb/controllers/add_remove_tag_modal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
angular
.module("opal.controllers")
.controller(
"AddRemoveTagCtrl",
function (
$scope,
ngProgressLite,
$modalInstance,
episode,
tagName,
tagDisplayName,
addTag
) {
"use strict";
$scope.episode = episode;
$scope.tagName = tagName;
$scope.tagDisplayName = tagDisplayName;
$scope.demographics = $scope.episode.demographics[0];
$scope.editingName = $scope.demographics.first_name + " " + $scope.demographics.surname;
$scope.addTag = addTag;

var tagging = {};
if (episode.tagging.length) {
tagging = episode.tagging[0].makeCopy();
}

$scope.cancel = function(){
$modalInstance.close();
}

$scope.save = function () {
ngProgressLite.set(0);
ngProgressLite.start();
if ($scope.addTag) {
tagging[tagName] = true;
} else {
tagging[tagName] = false;
}

episode.tagging[0].save(tagging).then(
function () {
ngProgressLite.done();
$modalInstance.close();
},
function () {
ngProgressLite.done();
$modalInstance.close();
}
);
};
}
);
46 changes: 46 additions & 0 deletions plugins/tb/templates/modals/add_remove_tag.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{% extends "base_templates/form_modal_base.html" %}
{% block title %}
<span ng-show="addTag">Add ([[ editingName ]])</span>
<span ng-hide="addTag">Remove ([[ editingName ]])</span>
{% endblock %}

{% block modal_body%}
{# Add the patient to the list #}
<div ng-show="addTag">
<div class="row">
<div class="col-md-8 col-md-offset-2 text-center">
<p class="lead">
Add [[ editingName ]] to the <strong>[[ tagDisplayName ]]</strong>
</p>
</div>
</div>
<div class="row">
<div class="col-md-6 col-md-offset-3 text-center">
<button class="btn btn-primary btn-save" one-click-only ng-click="save()">
<i class="fa fa-plus"></i> Add to list
</button>
</div>
</div>
</div>


{# Remove the patient from the list #}
<div ng-hide="addTag">
<div class="row">
<div class="col-md-8 col-md-offset-2 text-center">
<p class="lead">
Remove [[ editingName ]] from the <strong>[[ tagDisplayName ]]</strong>
</p>
</div>
</div>
<div class="row">
<div class="col-md-6 col-md-offset-3 text-center">
<button class="btn btn-primary btn-save" one-click-only ng-click="save()">
<i class="fa fa-sign-out"></i> Remove from list
</button>
</div>
</div>
</div>
{% endblock %}

{% block modal_save %}{% endblock %}
19 changes: 19 additions & 0 deletions plugins/tb/templates/partials/tb_appointments.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,24 @@ <h3><i class="fa fa-calendar"></i> TB Appointments</h3>
</div>
</span>
</div>
<div class="row">
<div class="col-md-12">
<a
href=""
ng-hide="episode.tagging[0].tb_patient_review"
ng-click="open_modal('AddRemoveTagCtrl', '/templates/modals/add_remove_tag.html', {episode: episode, tagName: 'tb_patient_review', tagDisplayName: 'patient review list', addTag: true})"
>
Add to patient review <a href="/#/tb/lists/tb_patient_review/">
</a>
<a
href=""
ng-show="episode.tagging[0].tb_patient_review"
ng-click="open_modal('AddRemoveTagCtrl', '/templates/modals/add_remove_tag.html', {episode: episode, tagName: 'tb_patient_review', tagDisplayName: 'patient review list', addTag: false})"
>
Patient under review
</a>
<a href="/#/tb/lists/tb_patient_review/"><i class="fa fa-external-link"></i></a>
</div>
</div>
</div>
</div>
5 changes: 5 additions & 0 deletions plugins/tb/templates/tb/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ <h3>
MDT History
</a>
</li>
<li>
<a href="/#/tb/lists/tb_patient_review/">
Patient Review
</a>
</li>
</ul>
</div>

Expand Down
130 changes: 130 additions & 0 deletions plugins/tb/templates/tb_patient_review_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{% extends "tb/base.html" %} {% load forms %} {% load elcid_panels %}
{% block tb_content %}
<div class="panel panel-default tb-clinic-list">
<div class="panel-heading">
<div class="row">
<div class="col-md-6">
<h1>TB Patient Review List</h1>
</div>
</div>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-11">
<div
ng-repeat="row in rows"
class="panel panel-default patient-row"
ng-class="{'collapsed': isCardCollapsed}"
>
<a
class="panel-link"
href="[[ '/#/patient/' + row.demographics[0].patient_id + '/' + row.id ]]"
>
<div class="panel-heading">
<div class="row">
<div class="col-md-10">
<h3>
<i class="fa fa-user"></i>
[[ row.demographics[0].first_name ]] [[
row.demographics[0].surname ]] [[
row.demographics[0].hospital_number ]]
<small>
[[ row.demographics[0].date_of_birth|displayDate ]]
<span ng-show="row.bed_statuses.length">
&nbsp; [[row.bed_statuses[0].hospital]]
[[row.bed_statuses[0].ward]]
[[row.bed_statuses[0].room]] [[row.bed_statuses[0].bed]]
</span>
</small>
</h3>
</div>
<div class="col-md-2 text-right">
<button
class="btn btn-primary"
pathway-episode="row"
open-pathway="remove"
pathway-callback="removeFromList(row.id)"
>
{% icon 'fa-sign-out' %} Remove
</button>
</div>
</div>
</div>
<div uib-collapse="isCardCollapsed" class="panel-body">
<div class="col-md-5">
<h4>
<strong>
{% icon models.Diagnosis.get_icon %} Primary Diagnosis
</strong>
</h4>
<div ng-repeat="item in row.diagnosis">
<span ng-show="item.condition">
<p><b>Condition:</b> [[ item.condition ]]</p>
<p><b>Date:</b> [[ item.date_of_diagnosis | displayDate ]]</p>
<p>[[ item.details ]]</p>
</span>
</div>
</div>
<div class="col-md-7 overflow-x-auto">
<h4>
<strong
>{% icon 'fa fa-comments' %} Most Recent Clinical
Note</strong
>
</h4>
<div ng-if="row.recent_patient_consultation">
<p>
<span
ng-show="row.recent_patient_consultation.initials && row.recent_patient_consultation.initials.trim().length"
>
<p>
<b>By: </b> [[row.recent_patient_consultation.initials]]
</p>
</span>
<span
ng-show="row.recent_patient_consultation.reason_for_interaction"
>
<p>
<b>Reason For Interaction: </b
>[[row.recent_patient_consultation.reason_for_interaction]]
</p>
</span>
<span
ng-show="row.recent_patient_consultation.examination_findings"
>
<b>Examination Findings: </b>
<div markdown="examination_findings"></div>
</span>
<span ng-show="row.recent_patient_consultation.discussion">
<b>Discussion: </b>
<div markdown="discussion"></div>
</span>
<span ng-show="row.recent_patient_consultation.progress">
<b>Progress: </b>
<div markdown="progress"></div>
</span>
<span
ng-show="row.recent_patient_consultation.infection_control"
>
<b>Infection Control: </b>
<div markdown="infection_control"></div>
</span>
<span ng-show="row.recent_patient_consultation.plan">
<b>Plan: </b>
<div markdown="plan"></div>
</span>
<span class="bg-success" ng-show="row.recent_patient_consultation.sent_upstream">
<br>
Note written to EPR
</span>
</p>
</div>
</div>
</div>
</a>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
Loading

0 comments on commit f1f9196

Please sign in to comment.