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

Commit

Permalink
Changed Visit Types to be editable list.
Browse files Browse the repository at this point in the history
Resolves #46
  • Loading branch information
jkleinsc committed May 6, 2015
1 parent 21dc442 commit 7fdc9d3
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 14 deletions.
64 changes: 54 additions & 10 deletions app/admin/lookup/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import LabPricingTypes from 'hospitalrun/mixins/lab-pricing-types';
import ModalHelper from 'hospitalrun/mixins/modal-helper';
import ImagingPricingTypes from 'hospitalrun/mixins/imaging-pricing-types';
import InventoryTypeList from 'hospitalrun/mixins/inventory-type-list';
import VisitTypes from 'hospitalrun/mixins/visit-types';
export default Ember.ArrayController.extend(BillingCategories, LabPricingTypes,
ModalHelper, ImagingPricingTypes, InventoryTypeList, {
ModalHelper, ImagingPricingTypes, InventoryTypeList, VisitTypes, {
lookupType: null,
lookupTypes: [{
name: 'Anesthesia Types',
Expand Down Expand Up @@ -157,6 +158,13 @@ export default Ember.ArrayController.extend(BillingCategories, LabPricingTypes,
appointment: 'location',
visit: 'location',
}
}, {
defaultValues: 'defaultVisitTypes',
name: 'Visit Types',
value: 'visit_types',
models: {
visit: 'visitType',
}
}, {
name: 'Ward Pricing Types',
value: 'ward_pricing_types',
Expand Down Expand Up @@ -218,6 +226,49 @@ export default Ember.ArrayController.extend(BillingCategories, LabPricingTypes,

userCanAdd: Ember.computed.alias('lookupTypeList.userCanAdd'),

_canDeleteValue: function(value) {
var lookupType = this.get('lookupType');
switch (lookupType) {
case 'inventory_types': {
if (value === 'Medication') {
this.displayAlert('Cannot Delete Medication', 'The Medication inventory type cannot be deleted because it is needed for the Medication module.');
return false;
}
break;
}
case 'lab_pricing_types': {
if (value === 'Lab Procedure') {
this.displayAlert('Cannot Delete Lab Pricing Type', 'The Lab Procedure pricing type cannot be deleted because it is needed for the Labs module.');
return false;
}
break;
}
case 'imaging_pricing_types': {
if (value === 'Imaging Procedure') {
this.displayAlert('Cannot Delete Imaging Pricing Type', 'The Imaging Procedure pricing type cannot be deleted because it is needed for the Imaging module.');
return false;
}
break;
}
case 'visit_types': {
if (value === 'Admission') {
this.displayAlert('Cannot Delete Admmission Visit Type', 'The Admission Visit type cannot be deleted because it is needed for the Visits module.');
return false;
} else if (value === 'Imaging') {
this.displayAlert('Cannot Delete Imaging Visit Type', 'The Imaging Visit type cannot be deleted because it is needed for the Imaging module.');
return false;
} else if (value === 'Lab') {
this.displayAlert('Cannot Delete Lab Visit Type', 'The Lab Visit type cannot be deleted because it is needed for the Lab module.');
return false;
} else if (value === 'Pharmacy') {
this.displayAlert('Cannot Delete Pharmacy Visit Type', 'The Lab Visit type cannot be deleted because it is needed for the Medication module.');
return false;
}
}
}
return true;
},

_sortValues: function(a, b) {
return Ember.compare(a.toLowerCase(), b.toLowerCase());
},
Expand All @@ -229,16 +280,9 @@ export default Ember.ArrayController.extend(BillingCategories, LabPricingTypes,
}));
},
deleteValue: function(value) {
var lookupType = this.get('lookupType'),
lookupTypeList = this.get('lookupTypeList'),
var lookupTypeList = this.get('lookupTypeList'),
lookupTypeValues = lookupTypeList.get('value');
if (lookupType === 'inventory_types' && value === 'Medication') {
this.displayAlert('Cannot Delete Medication', 'The Medication inventory type cannot be deleted because it is needed for the Medication module.');
} else if (lookupType === 'lab_pricing_types' && value === 'Lab Procedure') {
this.displayAlert('Cannot Delete Lab Pricing Type', 'The Lab Procedure pricing type cannot be deleted because it is needed for the Labs module.');
} else if (lookupType === 'imaging_pricing_types' && value === 'Imaging Procedure') {
this.displayAlert('Cannot Delete Imaging Pricing Type', 'The Imaging Procedure pricing type cannot be deleted because it is needed for the Imaging module.');
} else {
if (this._canDeleteValue(value)) {
lookupTypeValues.removeObject(value.toString());
lookupTypeList.save();
}
Expand Down
1 change: 1 addition & 0 deletions app/appointments/edit/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default AbstractEditController.extend(PatientSubmodule, ReturnTo, VisitTy

physicianList: Ember.computed.alias('controllers.appointments.physicianList'),
showTime: true,
visitTypesList: Ember.computed.alias('controllers.appointments.visitTypeList'),

cancelAction: function() {
var returnTo = this.get('returnTo');
Expand Down
3 changes: 3 additions & 0 deletions app/appointments/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export default AbstractModuleRoute.extend(UserSession,{
}, {
name: 'locationList',
findArgs: ['lookup','visit_location_list']
}, {
name: 'visitTypesList',
findArgs: ['lookup','visit_types']
}],

subActions: [{
Expand Down
18 changes: 14 additions & 4 deletions app/mixins/visit-types.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import Ember from "ember";
export default Ember.Mixin.create({
visitTypes: [
defaultVisitTypes: [
'Admission',
'Clinic',
'Followup',
'Imaging',
'Lab',
'Pharmacy',
'Surgery'
]
'Pharmacy'
],

visitTypes: function() {
var defaultVisitTypes = this.get('defaultVisitTypes'),
visitTypesList = this.get('visitTypesList');
if (Ember.isEmpty(visitTypesList)) {
return defaultVisitTypes;
} else {
return visitTypesList.get('value');
}
}.property('visitTypesList', 'defaultVisitTypes'),
});
1 change: 1 addition & 0 deletions app/patients/reports/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default AbstractReportController.extend(VisitTypes, {
clinicList: Ember.computed.alias('controllers.patients.clinicList'),
physicianList: Ember.computed.alias('controllers.patients.physicianList'),
locationList: Ember.computed.alias('controllers.patients.locationList'),
visitTypesList: Ember.computed.alias('controllers.patients.visitTypeList'),

admissionReportColumns: {
gender: {
Expand Down
3 changes: 3 additions & 0 deletions app/patients/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export default AbstractModuleRoute.extend(PatientId, {
}, {
name: 'statusList',
findArgs: ['lookup','patient_status_list']
}, {
name: 'visitTypesList',
findArgs: ['lookup','visit_types']
}],
moduleName: 'patients',
newButtonText: '+ new patient',
Expand Down
3 changes: 3 additions & 0 deletions app/visits/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export default AbstractModuleRoute.extend({
}, {
name: 'procedurePricingTypes',
findArgs: ['lookup','procedure_pricing_types']
}, {
name: 'visitTypesList',
findArgs: ['lookup','visit_types']
}, {
name: 'wardPricingTypes',
findArgs: ['lookup','ward_pricing_types']
Expand Down

0 comments on commit 7fdc9d3

Please sign in to comment.