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

Commit

Permalink
Show friendlyid in patient typeahead
Browse files Browse the repository at this point in the history
Resolves #63
  • Loading branch information
jkleinsc committed Apr 24, 2015
1 parent b039f26 commit ef4825e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/components/patient-typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
Expand Down
13 changes: 13 additions & 0 deletions app/mixins/patient-name.js
Original file line number Diff line number Diff line change
@@ -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'),
Expand Down
11 changes: 1 addition & 10 deletions app/models/patient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit ef4825e

Please sign in to comment.