Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Romulus10 committed Oct 15, 2021
2 parents ac717b2 + bbdaff8 commit 8b2d292
Show file tree
Hide file tree
Showing 31 changed files with 155 additions and 54 deletions.
3 changes: 2 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ Vagrant.configure("2") do |config|
apt-get clean
rm -rf /var/lib/apt/lists/*
apt-get update
apt-get install -y unzip apache2 python3 python3-pip mysql-server libmysqlclient-dev python3-dev libssl-dev python3-sphinx libpq-dev virtualenv
apt-get install -y unzip apache2 python3 python3-pip mysql-server libmysqlclient-dev \
python3-dev libssl-dev python3-sphinx libpq-dev virtualenv
apt-get upgrade -y
pip3 install -r /home/vagrant/femr_onchain/requirements.txt
curl -sL https://deb.nodesource.com/setup_14.x | bash -
Expand Down
2 changes: 1 addition & 1 deletion appMR
2 changes: 1 addition & 1 deletion femr_onchain/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
'session_security',
'django_user_agents',
'background_task',
'rest_framework_swagger',
'drf_yasg',
]

AUTHENTICATION_BACKENDS = [
Expand Down
3 changes: 3 additions & 0 deletions femr_onchain/urls.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Main URL configurations for fEMR-OnChain-Core. This redirects to the other apps in this project.
"""
from django.conf.urls import url
from django.contrib import admin
from django.contrib.auth import views as auth_views
Expand Down
6 changes: 6 additions & 0 deletions main/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@


class TreatmentAdmin(admin.ModelAdmin):
"""
Register a TreatmentForm as accessible in the Admin site.
"""
form = TreatmentForm


class PatientEncounterAdmin(admin.ModelAdmin):
"""
Register a PatientEncounterForm as accessible in the Admin site.
"""
form = PatientEncounterForm


Expand Down
9 changes: 8 additions & 1 deletion main/background_tasks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Non-view functions used to carry out background processes.
"""
from datetime import timedelta

from django.utils import timezone
Expand Down Expand Up @@ -26,7 +29,11 @@ def run_encounter_close():
e.save_no_timestamp()


def reset_sessions():
def reset_sessions() -> None:
"""
Empty out sessions older than 1 minute.
:return:
"""
now = timezone.now()
d = now - timedelta(minutes=1)
for x in UserSession.objects.all():
Expand Down
18 changes: 18 additions & 0 deletions main/csvio/added_inventory.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
AddedInventoryHandler and required imports.
"""
import csv

import requests
Expand All @@ -7,13 +10,28 @@


class AddedInventoryHandler(CSVHandler):
"""
Implements CSVHandler and adds inventory to supplies that already existed in the formulary.
"""
def __init__(self) -> None:
super().__init__()

def read(self, upload, campaign):
"""
Given an upload file and a campaign to upload to, execute a CSV import.
:param upload:
:param campaign:
:return:
"""
return self.__import(upload, campaign)

def write(self, response, formulary):
"""
Given an HTTPResponse and a formulary object, write out the formulary as a CSV file.
:param response:
:param formulary:
:return:
"""
return self.__export(response, formulary)

def __export(self, response, formulary):
Expand Down
8 changes: 8 additions & 0 deletions main/delete_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ def patient_delete_view(request, id=None):


def delete_chief_complaint(request, id=None, patient_id=None, encounter_id=None):
"""
Delete a selected Chief Complaint and redirect back.
:param request:
:param id:
:param patient_id:
:param encounter_id:
:return:
"""
if request.user.is_authenticated:
p = get_object_or_404(ChiefComplaint, pk=id)
p.active = False
Expand Down
1 change: 1 addition & 0 deletions main/edit_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ def upload_photo_view(request, patient_id=None, encounter_id=None):
ph.save()
m.photos.add(ph)
m.save()
aux_form = PhotoForm()
DatabaseChangeLog.objects.create(action="Edit", model="PatientEncounter", instance=str(m),
ip=get_client_ip(request), username=request.user.username,
campaign=Campaign.objects.get(name=request.session['campaign']))
Expand Down
4 changes: 2 additions & 2 deletions main/form_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def patient_form_view(request):
'match_list': match,
'form': form,
'page_name': 'New Patient',
'page_tip': "Complete form with patient demographics as instructed. Any box with an asterix (*) is required. Shared contact information would be if two patients have a household phone or email that they share, for example."})
'page_tip': "Complete form with patient demographics as instructed. Any box with an asterisk (*) is required. Shared contact information would be if two patients have a household phone or email that they share, for example."})
else:
return redirect('/not_logged_in')

Expand Down Expand Up @@ -194,7 +194,7 @@ def patient_encounter_form_view(request, id=None):
'page_name': 'New Encounter for {} {} {}'.format(p.first_name, p.last_name, suffix),
'birth_sex': p.sex_assigned_at_birth, 'patient_id': id, 'units': units, 'telehealth': telehealth,
'encounter_open': encounter_open,
'page_tip': "Complete form with patient vitals as instructed. Any box with an asterix (*) is required. For max efficiency, use 'tab' to navigate through this page."})
'page_tip': "Complete form with patient vitals as instructed. Any box with an asterisk (*) is required. For max efficiency, use 'tab' to navigate through this page."})
else:
return redirect('/not_logged_in')

Expand Down
2 changes: 1 addition & 1 deletion main/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def save(self, commit=True):
m.body_height_secondary = (
((tmp * 12) + m.body_height_secondary) * 2.54) % 100
if m.body_weight is not None:
m.body_weight = m.body_weight / 2.2046
m.body_weight /= 2.2046
if commit:
m.save()
return m
Expand Down
11 changes: 4 additions & 7 deletions main/formulary_management.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from main.csvio.added_inventory import AddedInventoryHandler
from django.db.models.query_utils import Q
from django.http.response import HttpResponse
from django.shortcuts import redirect, render
Expand Down Expand Up @@ -55,9 +54,8 @@ def edit_add_supply_view(request, id=None):
elif request.method == "POST":
form = AddSupplyForm(request.POST)
if form.is_valid():
inventory_entry.initial_quantity = inventory_entry.initial_quantity + \
int(request.POST['quantity'])
inventory_entry.quantity = inventory_entry.quantity + int(request.POST['quantity'])
inventory_entry.initial_quantity += int(request.POST['quantity'])
inventory_entry.quantity += int(request.POST['quantity'])
inventory_entry.save()
return redirect('main:formulary_home_view')
else:
Expand All @@ -84,9 +82,8 @@ def edit_sub_supply_view(request, id=None):
if form.is_valid():
if inventory_entry.initial_quantity > int(
request.POST['quantity']) and inventory_entry.quantity > int(request.POST['quantity']):
inventory_entry.initial_quantity = inventory_entry.initial_quantity - \
int(request.POST['quantity'])
inventory_entry.quantity = inventory_entry.quantity - int(request.POST['quantity'])
inventory_entry.initial_quantity -= int(request.POST['quantity'])
inventory_entry.quantity -= int(request.POST['quantity'])
else:
inventory_entry.initial_quantity = 0
inventory_entry.quantity = 0
Expand Down
6 changes: 3 additions & 3 deletions main/list_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def patient_csv_export_view(request):
'Body Temperature (F)', 'Height', 'Weight (lbs)', 'BMI', 'Oxygen Concentration',
'Glucose Level', 'History of Tobacco Use',
'History of Diabetes', 'History of Hypertension', 'History of High Cholesterol',
'History of Alchol Abuse/Substance Abuse', 'Community Health Worker Notes',
'History of Alcohol Abuse/Substance Abuse', 'Community Health Worker Notes',
'Procedure/Counseling', 'Pharmacy Notes',
'Medical/Surgical History', 'Social History', 'Current Medications', 'Family History']
else:
Expand All @@ -80,9 +80,9 @@ def patient_csv_export_view(request):
'Glucose Level',
'History of Tobacco Use', 'History of Diabetes', 'History of Hypertension',
'History of High Cholesterol',
'History of Alchol Abuse/Substance Abuse', 'Community Health Worker Notes',
'History of Alcohol Abuse/Substance Abuse', 'Community Health Worker Notes',
'Procedure/Counseling', 'Pharmacy Notes',
'Medical/Surgical History', 'Socil History', 'Current Medications', 'Family History']
'Medical/Surgical History', 'Social History', 'Current Medications', 'Family History']
try:
data = Patient.objects.filter(
campaign=Campaign.objects.get(name=request.session['campaign'])).exclude(
Expand Down
3 changes: 1 addition & 2 deletions main/middleware.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import pytz
from django.contrib.auth import logout
from django.contrib.auth.models import AnonymousUser
from django.contrib.sessions.exceptions import SessionInterrupted
from django.shortcuts import redirect, render
from django.shortcuts import render
from django.utils import timezone

from clinic_messages.models import Message
Expand Down
2 changes: 1 addition & 1 deletion main/static/main/js/bmi_calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function get_input_and_calc() {
}

function set_final_value() {
console.log("Imperial BMI compuation.");
console.log("Imperial BMI computation.");
$("#id_form-body_mass_index").val(get_input_and_calc);
}

Expand Down
2 changes: 1 addition & 1 deletion main/static/main/js/bmi_calc_metric.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function get_input_and_calc() {
}

function set_final_value() {
console.log("Metric BMI compuation.");
console.log("Metric BMI computation.");
$("#id_form-body_mass_index").val(get_input_and_calc);
}

Expand Down
2 changes: 1 addition & 1 deletion main/static/main/js/bmi_edit_calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function get_input_and_calc() {
}

function set_final_value() {
console.log("Imperial BMI compuation.");
console.log("Imperial BMI computation.");
$("#id_body_mass_index").val(get_input_and_calc);
}

Expand Down
2 changes: 1 addition & 1 deletion main/static/main/js/bmi_edit_calc_metric.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function get_input_and_calc() {
}

function set_final_value() {
console.log("Metric BMI compuation.");
console.log("Metric BMI computation.");
$("#id_form-body_mass_index").val(get_input_and_calc);
}

Expand Down
12 changes: 6 additions & 6 deletions main/templates/admin/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<h3>Campaign Management</h3>
<div>
<a href="{% url 'main:list_users_view' %}">User Management</a>
<a data-content="Click here to create new users or edit existing users." data-toggle="popover" data-trigger="hover"
href="#"><i
<a data-content="Click here to create new users or edit existing users."
data-toggle="popover" data-trigger="hover" href="#"><i
class="fa fa-question-circle"></i></a>
</div>
<!-- <div>
Expand All @@ -18,14 +18,14 @@ <h3>Campaign Management</h3>
</div> -->
<div>
<a href="{% url 'main:get_audit_logs_view' %}">Access Audit Log Management</a>
<a data-content="Cick here to see who has logged in and out of fEMR On-Chain." data-toggle="popover" data-trigger="hover"
href="#"><i
<a data-content="Click here to see who has logged in and out of fEMR On-Chain." data-toggle="popover"
data-trigger="hover" href="#"><i
class="fa fa-question-circle"></i></a>
</div>
<div>
<a href="{% url 'main:get_database_logs_view' %}">Database Access Log Management</a>
<a data-content="Click here to see who edited or accessed patient records." data-toggle="popover" data-trigger="hover"
href="#"><i
<a data-content="Click here to see who edited or accessed patient records." data-toggle="popover"
data-trigger="hover" href="#"><i
class="fa fa-question-circle"></i></a>
</div>
<div>
Expand Down
13 changes: 7 additions & 6 deletions main/templates/data/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
<meta content="width=device-width, initial-scale=1" name="viewport">
<title>fEMR On-Chain</title>
<script src="{% static 'admin/js/vendor/jquery/jquery.js' %}" type="text/javascript"></script>
<!-- <script crossorigin="anonymous" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script> -->
<script crossorigin="anonymous" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="{% static 'main/js/node_modules/inputmask/dist/jquery.inputmask.min.js' %}"></script>
Expand All @@ -35,7 +33,10 @@
<img alt=""
src="https://demo.teamfemr.org/assets/img/52749c927045848ae798e9df58dcc0dd-logo_color_sm.png" width="60">
</a>
<a data-content="Make sure you are using Google Chrome. Make sure Campaign is set to the correct clinic location or program. It is easiest to tab through each screen. For help contact [email protected]." data-toggle="popover" data-trigger="hover" href="#"
<a data-content="Make sure you are using Google Chrome.
Make sure Campaign is set to the correct clinic location or program.
It is easiest to tab through each screen. For help contact [email protected]."
data-toggle="popover" data-trigger="hover" href="#"
id="main_popover"><i
class="fa fa-question-circle"></i></a>

Expand Down Expand Up @@ -63,8 +64,8 @@
</li>
{% if request.message_number > 0 %}
<li class="nav-item" style="background-color: red;">
<a class="nav-link" href="{% url 'clinic_messages:index' %}" style="color: black;">Messages ({{
request.message_number }})</a>
<a class="nav-link" href="{% url 'clinic_messages:index' %}" style="color: black;">
Messages ({{ request.message_number }})</a>
</li>
{% else %}
<li class="nav-item">
Expand Down Expand Up @@ -142,7 +143,7 @@ <h1>{{ page_name }}</h1>
Find a bug or problem? <a href="{% url 'appMR:index' %}">Let us know.</a>
</div>
<div class="col-sm-12 col-md-4 text-center">
v1.4.2.10132021
v1.4.3.10142021
</div>
<div class="col-sm-12 col-md-4">
<a href="https://github.com/FEMR/fEMR-OnChain-Core/wiki" target="_blank">fEMR On-Chain Wiki</a>
Expand Down
2 changes: 1 addition & 1 deletion main/templates/data/base_login.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<div class="col-sm-12 col-md-4">
</div>
<div class="col-sm-12 col-md-4 text-center">
v1.4.2.10132021
v1.4.3.10142021
</div>
<div class="col-sm-12 col-md-4">
</div>
Expand Down
2 changes: 1 addition & 1 deletion main/templates/data/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</div>
{% endif %}
<div>
Welcome to fEMR On-Chain v1.4.2.10132021, {{ user.first_name }} {{ user.last_name }}!
Welcome to fEMR On-Chain v1.4.3.10142021, {{ user.first_name }} {{ user.last_name }}!
</div>
<div>
Please select a tab at the top, search below, or select a campaign below to get started!
Expand Down
2 changes: 1 addition & 1 deletion main/templates/data/patient_deleted_success.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "data/base.html" %}
{% block content %}
<div>
<div>Paitent record successfully deleted.</div>
<div>Patient record successfully deleted.</div>
</div>
{% endblock %}
3 changes: 2 additions & 1 deletion main/templates/forms/edit_encounter.html
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ <h3>Treatments</h3>
<div class="row">
<div class="form-group col-md-12">
{{ form.chief_complaint|as_crispy_field }}
<a class="btn btn-primary" href="{% url 'main:chief_complaint_list_view' patient.id encounter_id %}"
<a class="btn btn-primary"
href="{% url 'main:chief_complaint_list_view' patient.id encounter_id %}"
target="_blank">Manage</a>
</div>
</div>
Expand Down
5 changes: 3 additions & 2 deletions main/templates/forms/encounter.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,9 @@ <h5 class="modal-title">Patient Already Has an Open Encounter</h5>
<div class="col-md-4">
<input class="btn btn-primary ml-auto" id="submit_refer" name="submit_refer" type="submit"
value="Save and Refer"/>
<a data-content="Click this button if another campaign or location should have access to this patient record." data-toggle="popover" data-trigger="hover"
href="#"><i
<a data-content="Click this button if another campaign or
location should have access to this patient record."
data-toggle="popover" data-trigger="hover" href="#"><i
class="fa fa-question-circle"></i></a>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion main/templates/list/patient.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
<tr>
<td>{{ o.campaign_key }}</td>
<td>{{ o|open_encounters }}</td>
<td><a href="{% url 'main:patient_edit_form_view' id=o.id %}">{{ o.first_name }} {{ o|has_middle_name }} {{ o.last_name }} {{ o|has_suffix }}</a></td>
<td><a href="{% url 'main:patient_edit_form_view' id=o.id %}">{{ o.first_name }}
{{ o|has_middle_name }} {{ o.last_name }} {{ o|has_suffix }}</a></td>
<td>{{ o|last_timestamp }}</td>
<td>{{ o|get_campaign_info }}</td>
<td><a href="{% url 'main:patient_medical' id=o.id %}">Medical</a></td>
Expand Down
13 changes: 12 additions & 1 deletion main/templatetags/campaign_tags.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
"""
TemplateTags used to carry out more complex display actions on Campaigns.
"""
from django import template

from main.models import Campaign

register = template.Library()


@register.filter('is_selected')
def is_selected(campaign, selected):
def is_selected(campaign: Campaign, selected: str) -> bool:
"""
Given a campaign and a campaign name, check if they match.
:param campaign:
:param selected:
:return:
"""
return True if campaign.name == selected else False
Loading

0 comments on commit 8b2d292

Please sign in to comment.