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

Modified patient model, using ember style guides #911

Merged
merged 6 commits into from
Jan 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/models/allergy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import AbstractModel from 'hospitalrun/models/abstract';
import DS from 'ember-data';

export default AbstractModel.extend({
patient: DS.belongsTo('patient'),
// Attributes
name: DS.attr('string'),
icd9CMCode: DS.attr('string'),
icd10Code: DS.attr('string')
icd10Code: DS.attr('string'),
// Associations
patient: DS.belongsTo('patient')
});
1 change: 1 addition & 0 deletions app/models/diagnosis.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import AbstractModel from 'hospitalrun/models/abstract';
import DS from 'ember-data';

export default AbstractModel.extend({
// Attributes
active: DS.attr('boolean', { defaultValue: true }),
date: DS.attr('date'),
diagnosis: DS.attr('string'),
Expand Down
38 changes: 22 additions & 16 deletions app/models/patient-note.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
import AbstractModel from 'hospitalrun/models/abstract';
import Ember from 'ember';
import DS from 'ember-data';

const { computed } = Ember;

export default AbstractModel.extend({
authoredBy: function() {
// Attributes
/*
* if the note was written by one person but dictated or
* 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 }),

authoredBy: computed('attribution', 'createdBy', function() {
if (!Ember.isEmpty(this.get('attribution'))) {
let i18n = this.get('i18n');
return `${this.get('createdBy')} ${i18n.t('patients.notes.onBehalfOfCopy')} ${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
Expand Down
45 changes: 19 additions & 26 deletions app/models/patient.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,22 @@ import Ember from 'ember';
import DS from 'ember-data';
import PatientName from 'hospitalrun/mixins/patient-name';

const { computed } = Ember;
const { computed, get } = Ember;

export default AbstractModel.extend(DOBDays, PatientName, {
// Attributes
admitted: DS.attr('boolean', { defaultValue: false }),
additionalContacts: DS.attr(),
address: DS.attr('string'),
address2: DS.attr('string'),
address3: DS.attr('string'),
address4: DS.attr('string'),
allergies: DS.hasMany('allergy', {
async: true
}),
bloodType: DS.attr('string'),
clinic: DS.attr('string'),
country: DS.attr('string'),
checkedIn: DS.attr('boolean', { defaultValue: false }),
customForms: DS.attr('custom-forms'),
dateOfBirth: DS.attr('date'),
diagnoses: DS.hasMany('diagnosis', {
async: false
}),
economicClassification: DS.attr('string'),
email: DS.attr('string'),
expenses: DS.attr(),
Expand All @@ -47,14 +42,8 @@ export default AbstractModel.extend(DOBDays, PatientName, {
middleName: DS.attr('string'),
notes: DS.attr('string'),
otherIncome: DS.attr('string'),
payments: DS.hasMany('payment', {
async: true
}),
patientType: DS.attr('string'),
parent: DS.attr('string'),
paymentProfile: DS.belongsTo('price-profile', {
async: false
}),
phone: DS.attr('string'),
placeOfBirth: DS.attr('string'),
referredDate: DS.attr('date'),
Expand All @@ -63,13 +52,18 @@ export default AbstractModel.extend(DOBDays, PatientName, {
socialActionTaken: DS.attr('string'),
socialRecommendation: DS.attr('string'),
status: DS.attr('string'),
// Associations
allergies: DS.hasMany('allergy', { async: true }),
diagnoses: DS.hasMany('diagnosis', { async: false }),
payments: DS.hasMany('payment', { async: true }),
paymentProfile: DS.belongsTo('price-profile', { async: false }),

age: function() {
let dob = this.get('dateOfBirth');
age: computed('dateOfBirth', function() {
let dob = get(this, 'dateOfBirth');
return this.convertDOBToText(dob);
}.property('dateOfBirth'),
}),

displayAddress: function() {
displayAddress: computed('address', 'address2', 'address3', 'address4', function() {
let addressFields = this.getProperties('address', 'address2', 'address3', 'address4');
let displayAddress = '';
for (let prop in addressFields) {
Expand All @@ -81,20 +75,20 @@ export default AbstractModel.extend(DOBDays, PatientName, {
}
}
return displayAddress;
}.property('address', 'address2', 'address3', 'address4'),
}),

displayName: function() {
displayName: computed('firstName', 'lastName', 'middleName', function() {
return this.getPatientDisplayName(this);
}.property('firstName', 'lastName', 'middleName'),
}),

displayPatientId: function() {
displayPatientId: computed('id', 'externalPatientId', 'friendlyId', function() {
return this.getPatientDisplayId(this);
}.property('id', 'externalPatientId', 'friendlyId'),
}),

shortAge: function() {
let dob = this.get('dateOfBirth');
shortAge: computed('dateOfBirth', function() {
let dob = get(this, 'dateOfBirth');
return this.convertDOBToText(dob, true);
}.property('dateOfBirth'),
}),

shortDisplayName: computed('firstName', 'lastName', function() {
return this.getPatientDisplayName(this, true);
Expand All @@ -118,5 +112,4 @@ export default AbstractModel.extend(DOBDays, PatientName, {
presence: true
}
}

});