Skip to content

Commit

Permalink
Fix date display (#410)
Browse files Browse the repository at this point in the history
* fix homepage age

* fix misspelling

* remove log
  • Loading branch information
crosskayla committed Feb 10, 2024
1 parent c85e829 commit 4f986e9
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,17 @@ export class PatientVitalsWidgetComponent extends DashboardWidgetComponent imple
return
}

//process Patient objecst
//process Patient objects
let sortedPatients = _.sortBy(queryResults?.[1], ['birthDate'])
for(let patient of sortedPatients){
if(!this.name && _.get(patient, 'name[0].family') && _.get(patient, 'name[0].given[0]')){
this.name = `${_.get(patient, 'name[0].given[0]')} ${_.get(patient, 'name[0].family')}`
}
if(!this.age && _.get(patient, 'birthDate')){
this.age = `${moment().diff(moment(_.get(patient, 'birthDate')), 'years')} years`
const birthDate = _.get(patient, 'birthDate');
if(!this.age && birthDate){
const birthDateString = Array.isArray(birthDate) ? birthDate[0] : birthDate;
const birthDateMoment = moment(birthDateString);
this.age = `${moment().diff(birthDateMoment, 'years')} years`; // moment.diff rounds down
}
if(!this.gender && _.get(patient, 'gender[0]')){
this.gender = _.get(patient, 'gender[0]')
Expand Down

0 comments on commit 4f986e9

Please sign in to comment.