Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Adding the notes and patient history
Browse files Browse the repository at this point in the history
Merging PR #392
Closes #392
Closes #32
Closes #239
  • Loading branch information
jkleinsc committed Mar 30, 2016
1 parent 062c2db commit e182cad
Show file tree
Hide file tree
Showing 29 changed files with 745 additions and 138 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ nbproject/project.xml
*.sublime-workspace
server/config.js
.brackets.json
/app/nbproject/private/
/app/nbproject/private/
newrelic_agent.log

newrelic.js
8 changes: 8 additions & 0 deletions app/helpers/html-line-break.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Ember from 'ember';
export default Ember.Helper.helper(function([text]) {
if (text !== null && typeof text !== 'undefined') {
return new Ember.Handlebars.SafeString(text.replace(/\n/g, '<br>'));
} else {
return null;
}
});
1 change: 1 addition & 0 deletions app/initializers/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ export default {
app.inject('route', 'i18n', 'service:i18n');
app.inject('controller', 'i18n', 'service:i18n');
app.inject('mixin', 'i18n', 'service:i18n');
app.inject('model', 'i18n', 'service:i18n');
}
};
57 changes: 55 additions & 2 deletions app/locales/en/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,15 @@ export default {
}
},
labels: {
cptcode: 'CPT Code',
loading: 'Loading',
name: 'Name',
patient: 'Patient',
quantity: 'Quantity',
requested_on: 'Requested On',
date: 'Date',
date_of_birth: 'Date of Birth',
date_of_birth_short: 'DoB',
date_requested: 'Date Requested',
date_completed: 'Date Completed',
description: 'Description',
Expand All @@ -155,12 +158,18 @@ export default {
action: 'Action',
notes: 'Notes',
edit: 'Edit',
image_orders: 'Image Orders',
lab_orders: 'Lab Orders',
patient_history: 'Patient History',
imaging_type: 'Imaging Type',
result: 'Result',
results: 'Results',
visit: 'Visit',
requests: 'Requests',
completed: 'Completed',
id: 'Id',
on: 'on',
type: 'Type',
id: 'ID',
sex: 'Sex',
age: 'Age',
username: 'Username',
Expand Down Expand Up @@ -196,17 +205,24 @@ export default {
location: 'Location',
provider: 'Provider',
with: 'With',
all_day: 'All Day'
all_day: 'All Day',
physician: 'Physician',
assisting: 'Assisting',
anesthesia: 'Anesthesia',
procedures: 'Procedures'
},
messages: {
no_items_found: 'No items found.',
no_history_available: 'No history available.',
create_new_record: 'Create a new record?',
create_new_user: 'Create a new user?',
no_users_found: 'No users found.',
are_you_sure_delete: 'Are you sure you wish to delete the user {{user}}?',
user_has_been_saved: 'The user has been saved.',
user_saved: 'User Saved',
on_behalf_of: 'on behalf of',
new_patient_has_to_be_created: 'A new patient needs to be created...Please wait..',
no_notes_available: 'No additional clinical notes are available for this visit.',
sorry: 'Sorry, something went wrong...'
},
alerts: {
Expand All @@ -226,6 +242,7 @@ export default {
delete: 'Delete',
new_user: 'New User',
add_value: 'Add Value',
new_note: 'New Note',
import: 'Import',
load_file: 'Load File',
new_request: 'New Request',
Expand Down Expand Up @@ -504,6 +521,31 @@ export default {
new_button: '+ new appointment'
}
},
visits: {
edit: {
actions: 'Actions',
edit: 'Edit',
date: 'Date',
authored_by: 'Authored By',
note: 'Note',
notes: 'Notes',
new_note: 'New Note',
visit_information: 'Visit Information',
new_appointment: 'New Appointment',
add_diagnosis: 'Add Diagnosis',
diagnosis: 'Diagnosis',
delete: 'Delete',
procedure: 'Procedure',
procedures: 'Procedures',
new_procedure: 'New Procedure',
labs: 'Labs',
new_lab: 'New Lab',
imaging: 'Imaging',
new_imaging: 'New Imaging',
medication: 'Medication',
new_medication: 'New Medication'
}
},
labs: {
section_title: 'Labs',
requests_title: 'Lab Requests',
Expand All @@ -530,5 +572,16 @@ export default {
request_saved_title: 'Lab Request Saved',
request_saved_message: 'The lab request has been saved.'
}
},
common: {
actions: 'Actions'
},
patients: {
notes: {
on_behalf_of_label: 'On Behalf Of',
on_behalf_of_copy: 'on behalf of',
please_select_a_visit: 'Please select a visit',
note_label: 'Note'
}
}
};
35 changes: 35 additions & 0 deletions app/mixins/patient-notes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import Ember from 'ember';
export default Ember.Mixin.create({

canAddNote: function() {
return this.currentUserCan('add_note') && (!Ember.isEmpty(this.get('visits')) || !Ember.isEmpty(this.get('model.visits')));
},

canDeleteNote: function() {
return this.currentUserCan('delete_note');
},

_computeNoteType: function(visit) {
switch (visit.get('visitType')) {
case 'Admission':
if (Ember.isEmpty(visit.get('procedures'))) {
return 'Pre-op';
} else {
return 'Post-op';
}
break;
case 'Clinic':
case 'Followup':
return 'General';
default:
return visit.get('visitType');
}
},

_setNoteType: function() {
var model = this.get('model');
if (model.get('noteType') == null) {
model.set('noteType', this._computeNoteType(model.get('visit')));
}
}
});
14 changes: 14 additions & 0 deletions app/mixins/user-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,20 @@ export default Ember.Mixin.create({
users: [
'User Administrator',
'System Administrator'
],
add_note: [
'Doctor',
'Medical Records Officer',
'Nurse',
'Nurse Manager',
'Patient Administration',
'System Administrator'
],
delete_note: [
'Medical Records Officer',
'Nurse Manager',
'Patient Administration',
'System Administrator'
]

},
Expand Down
42 changes: 42 additions & 0 deletions app/models/patient-note.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import AbstractModel from 'hospitalrun/models/abstract';
import Ember from 'ember';
import DS from 'ember-data';
export default AbstractModel.extend({
authoredBy: function() {
if (!Ember.isEmpty(this.get('attribution'))) {
let i18n = this.get('i18n');
return this.get('createdBy') + ' ' + i18n.t('patients.notes.on_behalf_of_copy') + ' ' + this.get('attribution');
} else {
return this.get('createdBy');
}
}.property('attribution', 'createdBy'),
// if the note was written by one person but dictated / given on behalf of another, otherwise, this and createdBy are the same
attribution: DS.attr('string'),
content: DS.attr('string'),
createdBy: DS.attr('string'),
date: DS.attr('date'),
// custom list of noteTypes of mixins/patient-note-types
noteType: DS.attr(),
// who is this note about?
patient: DS.belongsTo('patient', {
async: false
}),
// if this note is related to a visit, make sure it's noted.
visit: DS.belongsTo('visit', {
async: false
}),
validations: {
patient: {
presence: true
},
visit: {
presence: true
},
noteType: {
presence: true
},
content: {
presence: true
}
}
});
2 changes: 2 additions & 0 deletions app/models/visit.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export default AbstractModel.extend({
labs: DS.hasMany('lab', { async: true }),
location: DS.attr('string'),
medication: DS.hasMany('medication', { async: true }),
// this field is being deprecated in favor of patient-note
notes: DS.attr('string'),
patientNotes: DS.hasMany('patient-note', { async: true }),
outPatient: DS.attr('boolean'),
patient: DS.belongsTo('patient', {
async: false
Expand Down
63 changes: 44 additions & 19 deletions app/patients/edit/controller.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import AbstractEditController from 'hospitalrun/controllers/abstract-edit-controller';
import BloodTypes from 'hospitalrun/mixins/blood-types';
import Ember from 'ember';
import PatientNotes from 'hospitalrun/mixins/patient-notes';
import ReturnTo from 'hospitalrun/mixins/return-to';
import SelectValues from 'hospitalrun/utils/select-values';
import UserSession from 'hospitalrun/mixins/user-session';
export default AbstractEditController.extend(BloodTypes, ReturnTo, UserSession, {
export default AbstractEditController.extend(BloodTypes, ReturnTo, UserSession, PatientNotes, {
canAddAppointment: function() {
return this.currentUserCan('add_appointment');
}.property(),
Expand Down Expand Up @@ -284,33 +285,41 @@ export default AbstractEditController.extend(BloodTypes, ReturnTo, UserSession,
},

editAppointment: function(appointment) {
appointment.set('returnToPatient', true);
appointment.set('returnTo', null);
this.transitionToRoute('appointments.edit', appointment);
if (this.get('canAddAppointment')) {
appointment.set('returnToPatient', true);
appointment.set('returnTo', null);
this.transitionToRoute('appointments.edit', appointment);
}
},

editImaging: function(imaging) {
if (imaging.get('canEdit')) {
imaging.setProperties({
'returnToPatient': true
});
this.transitionToRoute('imaging.edit', imaging);
if (this.get('canAddImaging')) {
if (imaging.get('canEdit')) {
imaging.setProperties({
'returnToPatient': true
});
this.transitionToRoute('imaging.edit', imaging);
}
}
},

editLab: function(lab) {
if (lab.get('canEdit')) {
lab.setProperties({
'returnToPatient': true
});
this.transitionToRoute('labs.edit', lab);
if (this.get('canAddLab')) {
if (lab.get('canEdit')) {
lab.setProperties({
'returnToPatient': true
});
this.transitionToRoute('labs.edit', lab);
}
}
},

editMedication: function(medication) {
if (medication.get('canEdit')) {
medication.set('returnToPatient', true);
this.transitionToRoute('medication.edit', medication);
if (this.get('canAddMedication')) {
if (medication.get('canEdit')) {
medication.set('returnToPatient', true);
this.transitionToRoute('medication.edit', medication);
}
}
},

Expand All @@ -319,11 +328,15 @@ export default AbstractEditController.extend(BloodTypes, ReturnTo, UserSession,
},

editProcedure: function(procedure) {
this.transitionToRoute('procedures.edit', procedure);
if (this.get('canAddVisit')) {
this.transitionToRoute('procedures.edit', procedure);
}
},

editVisit: function(visit) {
this.transitionToRoute('visits.edit', visit);
if (this.get('canAddVisit')) {
this.transitionToRoute('visits.edit', visit);
}
},

newAppointment: function() {
Expand Down Expand Up @@ -358,6 +371,18 @@ export default AbstractEditController.extend(BloodTypes, ReturnTo, UserSession,
});
},

showAddPatientNote: function(model) {
if (this.get('canAddNote')) {
if (Ember.isEmpty(model)) {
model = this.get('store').createRecord('patient-note', {
patient: this.get('model'),
createdBy: this.getUserName()
});
}
this.send('openModal', 'patients.notes', model);
}
},

showDeleteAppointment: function(appointment) {
appointment.set('deleteFromPatient', true);
this.send('openModal', 'appointments.delete', appointment);
Expand Down
8 changes: 7 additions & 1 deletion app/patients/edit/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route';
import Ember from 'ember';
import PatientId from 'hospitalrun/mixins/patient-id';
import PatientVisits from 'hospitalrun/mixins/patient-visits';
import PatientNotes from 'hospitalrun/mixins/patient-notes';
import PouchDbMixin from 'hospitalrun/mixins/pouchdb';
export default AbstractEditRoute.extend(PatientId, PatientVisits, PouchDbMixin, {
export default AbstractEditRoute.extend(PatientId, PatientVisits, PouchDbMixin, PatientNotes, {
editTitle: 'Edit Patient',
modelName: 'patient',
newTitle: 'New Patient',
photos: null,

actions: {
updateNote: function(note) {
note.get('visit').save().then(function() {
// noop
});
},
appointmentDeleted: function(model) {
this.controller.send('appointmentDeleted', model);
},
Expand Down
Loading

0 comments on commit e182cad

Please sign in to comment.