diff --git a/app/components/patient-typeahead.js b/app/components/patient-typeahead.js index c104ca65ab..4276a4181e 100644 --- a/app/components/patient-typeahead.js +++ b/app/components/patient-typeahead.js @@ -8,7 +8,7 @@ export default TypeAhead.extend(PatientName, { _mapPatient: function(item) { var returnObj = {}; item.doc.id = item.id.substr(8); - returnObj.name = '%@ - %@'.fmt(this.getPatientDisplayName(item.doc), item.doc.id); + returnObj.name = '%@ - %@'.fmt(this.getPatientDisplayName(item.doc), this.getPatientDisplayId(item.doc)); returnObj[this.get('selectionKey')] = item.doc; return returnObj; }, diff --git a/app/mixins/patient-name.js b/app/mixins/patient-name.js index 36295e2e59..8c2607cc7b 100644 --- a/app/mixins/patient-name.js +++ b/app/mixins/patient-name.js @@ -1,5 +1,18 @@ import Ember from "ember"; export default Ember.Mixin.create({ + getPatientDisplayId: function(patient) { + var externalPatientId = Ember.get(patient, 'externalPatientId'), + friendlyId = Ember.get(patient, 'friendlyId'), + id = Ember.get(patient, 'id'); + if (!Ember.isEmpty(friendlyId)) { + return friendlyId; + } else if (!Ember.isEmpty(externalPatientId)) { + return externalPatientId; + } else { + return id; + } + }, + getPatientDisplayName: function(patient) { var firstName = Ember.get(patient, 'firstName'), lastName = Ember.get(patient, 'lastName'), diff --git a/app/models/patient.js b/app/models/patient.js index d5fb1c8ea1..243b7b407d 100644 --- a/app/models/patient.js +++ b/app/models/patient.js @@ -70,16 +70,7 @@ export default AbstractModel.extend(DOBDays, PatientName, { }.property('firstName', 'lastName'), displayPatientId: function() { - var externalPatientId = this.get('externalPatientId'), - friendlyId = this.get('friendlyId'), - id = this.get('id'); - if (!Ember.isEmpty(friendlyId)) { - return friendlyId; - } else if (!Ember.isEmpty(externalPatientId)) { - return externalPatientId; - } else { - return id; - } + return this.getPatientDisplayId(this); }.property('id', 'externalPatientId', 'friendlyId'), validations: {