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

Commit

Permalink
Implemented Operation Report
Browse files Browse the repository at this point in the history
Resolves #792
  • Loading branch information
jkleinsc committed Jan 13, 2017
1 parent 5d05bfc commit 9ce696b
Show file tree
Hide file tree
Showing 21 changed files with 376 additions and 173 deletions.
1 change: 1 addition & 0 deletions app/admin/roles/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default AbstractEditController.extend(UserRoles, UserSession, {
'addDiagnosis',
'addNote',
'addOperativePlan',
'addOperationReport',
'addPhoto',
'addPatient',
'addProcedure',
Expand Down
42 changes: 22 additions & 20 deletions app/components/patient-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,34 @@ import UserSession from 'hospitalrun/mixins/user-session';
const {
computed,
get,
isEmpty
isEmpty,
set
} = Ember;

const DIAGNOSIS_KEYS = [
'diganosisContainer',
'diagnosisContainer',
'hideInActiveDiagnoses',
'[email protected]',
'[email protected]',
'[email protected]'
'[email protected]',
'[email protected]'
];

export default Ember.Component.extend(PatientDiagnosis, UserSession, {
allowAddAllergy: false,
allowAddDiagnosis: false,
allowAddOperativePlan: false,
classNames: ['patient-summary'],
disablePatientLink: false,
diagnosisContainer: null,
diagnosisList: null,
disablePatientLink: false,
editDiagnosisAction: 'editDiagnosis',
editOperativePlanAction: 'editOperativePlan',
editOperationReportAction: 'editOperationReport',
editProcedureAction: 'editProcedure',
hideInActiveDiagnoses: true,
patient: null,
patientProcedures: null,
showAddDiagnosisAction: 'showAddDiagnosis',
showPatientAction: 'showPatient',
visit: null,

canAddAllergy: computed('allowAddAllergy', {
get() {
Expand Down Expand Up @@ -61,15 +62,6 @@ export default Ember.Component.extend(PatientDiagnosis, UserSession, {
}
}),

diagnosisContainer: computed('patient', 'visit', function() {
// Pull diagnoses from visit if it is defined; otherwise pull from patient.
let diagnosisContainer = this.get('visit');
if (isEmpty(diagnosisContainer)) {
diagnosisContainer = this.get('patient');
}
return diagnosisContainer;
}),

havePrimaryDiagnoses: computed('primaryDiagnoses.length', function() {
let primaryDiagnosesLength = this.get('primaryDiagnoses.length');
return (primaryDiagnosesLength > 0);
Expand Down Expand Up @@ -107,6 +99,14 @@ export default Ember.Component.extend(PatientDiagnosis, UserSession, {
return this.get('canAddDiagnosis') || this.get('havePrimaryDiagnoses');
}),

didReceiveAttrs() {
this._super(...arguments);
let diagnosisContainer = get(this, 'diagnosisContainer');
if (isEmpty(diagnosisContainer)) {
set(this, 'diagnosisContainer', get(this, 'patient'));
}
},

actions: {
addOperativePlan() {
this.sendAction('editOperativePlanAction');
Expand All @@ -133,10 +133,12 @@ export default Ember.Component.extend(PatientDiagnosis, UserSession, {
},

editProcedure(procedure) {
procedure.set('returnToVisit');
procedure.set('returnToPatient', this.get('patient.id'));
procedure.set('patient', this.get('patient'));
this.sendAction('editProcedureAction', procedure);
let report = get(procedure, 'report');
if (isEmpty(report)) {
this.sendAction('editProcedureAction', procedure);
} else {
this.sendAction('editOperationReportAction', report);
}
},

showAddDiagnosis() {
Expand Down
38 changes: 33 additions & 5 deletions app/locales/en/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ export default {
addSocialwork: 'Add Social Work',
deleteNote: 'Delete Note',
addOperativePlan: 'Add Operative Plan',
addAllergy: 'Add Allergy'
addAllergy: 'Add Allergy',
addOperationReport: 'Add Operation Report'
},
messages: {
roleSaved: 'The {{roleName}} role has been saved.'
Expand Down Expand Up @@ -1129,6 +1130,17 @@ export default {
},
priceList: {
charges: '{{pricingType}} charges'
},
operativeProcedures: {
buttons: {
addProcedure: 'Add Procedure'
},
labels: {
procedure: 'Procedure'
},
titles: {
procedures: 'Procedures'
}
}
},
customForms: {
Expand Down Expand Up @@ -1169,7 +1181,6 @@ export default {
},
operativePlan: {
buttons: {
addProcedure: 'Add Procedure',
completePlan: 'Complete Plan'
},
labels: {
Expand All @@ -1180,7 +1191,6 @@ export default {
droppedStatus: 'Dropped',
operationDescription: 'Operation Description',
plannedStatus: 'Planned',
procedure: 'Procedure',
status: 'Status',
surgeon: 'Surgeon',
surgeryDate: 'Surgery Date'
Expand All @@ -1191,8 +1201,26 @@ export default {
titles: {
editTitle: 'Edit Operative Plan',
newTitle: 'New Operative Plan',
planSaved: 'Plan Saved',
procedures: 'Procedures'
planSaved: 'Plan Saved'
}
},
operationReport: {
labels: {
additionalNotes: 'Additional Notes',
assistant: 'Assistant',
caseComplexity: 'Case Complexity',
complications: 'Complications',
operationDescription: 'Operation Description',
surgeon: 'Surgeon',
surgeryDate: 'Surgery Date'
},
messages: {
planSaved: 'The operation report has been saved.'
},
titles: {
editTitle: 'Edit Operation Report',
newTitle: 'New Operation Report',
reportSaved: 'Report Saved'
}
}
};
55 changes: 55 additions & 0 deletions app/mixins/patient-submodule.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,28 @@ export default Ember.Mixin.create(PatientVisits, {
}.bind(this));
},

addDiagnosisToModelAndPatient(newDiagnosis) {
let diagnoses = this.get('model.diagnoses');
diagnoses.addObject(newDiagnosis);
let patientDiagnoses = this.get('model.patient.diagnoses');
let diagnosisExists = patientDiagnoses.any((diagnosis) => {
return diagnosis.get('active') === true
&& diagnosis.get('diagnosis') === newDiagnosis.get('diagnosis')
&& diagnosis.get('secondaryDiagnosis') === newDiagnosis.get('secondaryDiagnosis');
});
if (!diagnosisExists) {
patientDiagnoses.addObject(newDiagnosis);
let patient = this.get('model.patient');
patient.save().then(() => {
this.send('update', true);
this.send('closeModal');
});
} else {
this.send('update', true);
this.send('closeModal');
}
},

_finishAddChildToVisit(objectToAdd, childName, visit, resolve, reject) {
visit.get(childName).then(function(visitChildren) {
visitChildren.addObject(objectToAdd);
Expand Down Expand Up @@ -125,6 +147,26 @@ export default Ember.Mixin.create(PatientVisits, {
});
},

getPatientDiagnoses(patient) {
let diagnoses = patient.get('diagnoses');
let visitDiagnoses;
if (!isEmpty(diagnoses)) {
visitDiagnoses = diagnoses.filterBy('active', true).map((diagnosis) => {
let description = diagnosis.get('diagnosis');
let newDiagnosisProperties = diagnosis.getProperties('active', 'date', 'diagnosis', 'secondaryDiagnosis');
newDiagnosisProperties.diagnosis = description;
return this.store.createRecord('diagnosis',
newDiagnosisProperties
);
});
}
let currentDiagnoses = this.get('model.diagnoses');
currentDiagnoses.clear();
if (!isEmpty(visitDiagnoses)) {
currentDiagnoses.addObjects(visitDiagnoses);
}
},

patientId: Ember.computed.alias('model.patient.id'),

patientSelected(/* patient */) {},
Expand Down Expand Up @@ -191,6 +233,19 @@ export default Ember.Mixin.create(PatientVisits, {
return promises;
},

saveNewDiagnoses() {
let diagnoses = this.get('model.diagnoses');
diagnoses = diagnoses.filterBy('isNew', true);
if (!isEmpty(diagnoses)) {
let savePromises = diagnoses.map((diagnoses) => {
return diagnoses.save();
});
return Ember.RSVP.all(savePromises);
} else {
return Ember.RSVP.resolve();
}
},

/**
* If visit needs to saved, save it and then display an alert message; otherwise
* just display the alert message.
Expand Down
8 changes: 8 additions & 0 deletions app/mixins/user-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ export default Ember.Mixin.create({
'Patient Administration',
'System Administrator'
],
add_operation_report: [
'Data Entry',
'Doctor',
'Hospital Administrator',
'Medical Records Officer',
'Patient Administration',
'System Administrator'
],
add_photo: [
'Data Entry',
'Hospital Administrator',
Expand Down
45 changes: 45 additions & 0 deletions app/models/operation-report.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import AbstractModel from 'hospitalrun/models/abstract';
import DS from 'ember-data';
import Ember from 'ember';

const {
get,
isEmpty
} = Ember;

function defaultProcedures() {
return [];
}

export default AbstractModel.extend({
// Attributes
additionalNotes: DS.attr('string'),
caseComplexity: DS.attr('number'),
complications: DS.attr('string'),
customForms: DS.attr('custom-forms'),
procedures: DS.attr('operative-procedures', { defaultValue: defaultProcedures }),
operationDescription: DS.attr('string'),
surgeon: DS.attr('string'),
surgeryDate: DS.attr('date'),

// Associations
preOpDiagnoses: DS.hasMany('diagnosis'),
diagnoses: DS.hasMany('diagnosis'), // Post op diagnosis
patient: DS.belongsTo('patient', { async: false }),

validations: {
caseComplexity: {
numericality: {
allowBlank: true,
onlyInteger: true
}
},
procedureDescription: {
presence: {
if(object) {
return isEmpty(get(object, 'procedures'));
}
}
}
}
});
10 changes: 9 additions & 1 deletion app/models/operative-plan.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default AbstractModel.extend({
// Attributes
additionalNotes: DS.attr('string'),
admissionInstructions: DS.attr('string'),
caseComplexity: DS.attr('string'),
caseComplexity: DS.attr('number'),
customForms: DS.attr('custom-forms'),
operationDescription: DS.attr('string'),
procedures: DS.attr('operative-procedures', { defaultValue: defaultProcedures }),
Expand All @@ -26,6 +26,7 @@ export default AbstractModel.extend({
surgeryDate: DS.attr('date'),

// Associations
diagnoses: DS.hasMany('diagnosis'),
patient: DS.belongsTo('patient', { async: false }),

isPlanned: computed('status', {
Expand All @@ -36,6 +37,13 @@ export default AbstractModel.extend({
}),

validations: {
caseComplexity: {
numericality: {
allowBlank: true,
onlyInteger: true
}
},

procedureDescription: {
presence: {
if(object) {
Expand Down
1 change: 1 addition & 0 deletions app/models/patient.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default AbstractModel.extend(DOBDays, PatientName, {
// Associations
allergies: DS.hasMany('allergy', { async: true }),
diagnoses: DS.hasMany('diagnosis', { async: false }),
operationReports: DS.hasMany('operation-report', { async: true }),
operativePlans: DS.hasMany('operative-plan', { async: true }),
payments: DS.hasMany('payment', { async: true }),
paymentProfile: DS.belongsTo('price-profile', { async: false }),
Expand Down
Loading

0 comments on commit 9ce696b

Please sign in to comment.