Fix date display (#410)

* fix homepage age

* fix misspelling

* remove log
This commit is contained in:
Kayla Cross 2024-02-09 22:44:46 -05:00 committed by GitHub
parent c85e829c46
commit 4f986e9c2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 3 deletions

View File

@ -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]')