Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Fix dates mismatch issue where dates for observation’s displayed in the Graph and Table view’s don’t match the observation’s effectiveDateTime as received by the app from service. #17

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions js/chart-pane.js
Original file line number Diff line number Diff line change
Expand Up @@ -1398,15 +1398,15 @@ ChartPane.prototype = {
html = [];
this.forEachColumn(function( col, colIndex/*, colsLen*/ ) {
$.each(annotated, function(i, entry) {
var dateString = entry.hasOwnProperty('dateString') ? entry.dateString : '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to check entry object?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We wouldnt need to check entry since its an object in the array and we are doing a $.each on the array.

html.push(
'<div class="annotation-button" style="left:',
inst.months2x(entry.agemos, colIndex),
'px" data-agemos="' + GC.Util.roundToPrecision(entry.agemos, 1) + '">',
'<div class="details">',
'<div class="header">',
'<div class="title">Annotation</div>',
new XDate(GC.App.getPatient().DOB)
.addMonths(entry.agemos)
new XDate(dateString)
.toString(GC.chartSettings.dateFormat),
'</div>',
'<div class="content">',
Expand Down
3 changes: 2 additions & 1 deletion js/gc-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,8 @@
return;
}

date = (new XDate(PATIENT.DOB)).addMonths(rec.agemos);
var dateString = rec.hasOwnProperty('dateString') ? rec.dateString : '';
date = new XDate(dateString);

age = new GC.TimeInterval(PATIENT.DOB, date);

Expand Down
7 changes: 4 additions & 3 deletions js/gc-grid-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,9 @@

$.each(model, function( index, data ) {
//debugger;
var dateString = data.hasOwnProperty('dateString') ? data.dateString : '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check data?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We wouldnt need to check data since its an object in the array and we are doing a $.each on the array.

var age = new GC.TimeInterval(patient.DOB).setMonths(data.agemos),
date = new XDate(patient.DOB.getTime()).addMonths(data.agemos),
date = new XDate(dateString),
dateText = date.toString(GC.chartSettings.dateFormat);//,
// years,
// months,
Expand Down Expand Up @@ -478,8 +479,8 @@
{
label : "Date",
get : function( entry/*, model*/ ) {
return new XDate(patient.DOB.getTime())
.addMonths(entry.agemos)
var dateString = entry.hasOwnProperty('dateString') ? entry.dateString : '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check entry?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entry here represents the model which is pulled from an array of models.
E.g : var entry = model[colIndex], v, x//,

So it should always be available.

return new XDate(dateString)
.toString(GC.chartSettings.dateFormat);
},
style : "text-align:left"
Expand Down
7 changes: 4 additions & 3 deletions js/gc-parental-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,11 @@
}, function(key, meta) {
var lastEntry = getLastEnryHaving( meta.modelProp ), ds, pct;
if (lastEntry) {
var dateString = lastEntry.hasOwnProperty('dateString') ? lastEntry.dateString : '';
ds = GC.getDataSet(src, meta.dsType, gender, 0, lastEntry.agemos);
out[key].value = lastEntry[meta.modelProp];
out[key].agemos = lastEntry.agemos;
out[key].date = new XDate(PATIENT.DOB.getTime()).addMonths(lastEntry.agemos);
out[key].date = new XDate(dateString);

if (ds) {
pct = GC.findPercentileFromX(
Expand Down Expand Up @@ -457,11 +458,11 @@
"fill-opacity" : heightChild > heightTreshold ? 0.75 : 0
});

var dateString = lastHeight.hasOwnProperty('dateString') ? lastHeight.dateString : '';
this._nodes.childDateLabel.attr({
text : lastHeight.agemos === null ?
GC.str("STR_158") :
((new XDate(PATIENT.DOB.getTime())).addMonths(lastHeight.agemos)
.toString(GC.chartSettings.dateFormat)),
((new XDate(dateString)).toString(GC.chartSettings.dateFormat)),
y : heightChild > heightTreshold ?
y + 10 :
y - 35
Expand Down
36 changes: 34 additions & 2 deletions js/gc-smart-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,25 @@ window.GC = window.GC || {};
var out = {};
out.annotation = { txt : this.note };
out.agemos = patient.DOB.diffMonths(this.date + 1);
if (this.hasOwnProperty('dateString')){
out.dateString = this.dateString;
}
return out;
};

function SmartBoneage(date, boneAgeMos) {
function SmartBoneage(date, boneAgeMos, dateString) {
this.date = new XDate(date);
this.boneAgeMos = boneAgeMos;
this.dateString = dateString;
}

SmartBoneage.prototype.toGCBoneage = function(patient) {
var out = {};
out.boneAge = this.boneAgeMos;
out.agemos = patient.DOB.diffMonths(this.date + 1);
if (this.hasOwnProperty('dateString')){
out.dateString = this.dateString;
}
return out;
};

Expand Down Expand Up @@ -278,7 +285,8 @@ window.GC = window.GC || {};
agemos: o.hasOwnProperty("agemos") ?
o.agemos :
patient.DOB.diffMonths(new XDate(o.date)),
value : o.value
value : o.value,
dateString: o.dateString
});
}

Expand Down Expand Up @@ -336,6 +344,9 @@ window.GC = window.GC || {};

if (boneAgeList && boneAgeList.length) {
$.each(boneAgeList, function(i, o) {
if (o.hasOwnProperty("boneAgeMos") && o.hasOwnProperty("date") && o.hasOwnProperty("dateString")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check o?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$.each will guarantee that o always has a value .

o = new SmartBoneage(o.date, o.boneAgeMos, o.dateString);
}
if (o instanceof SmartBoneage) {
patient.boneAge.push(o.toGCBoneage(patient));
} else {
Expand Down Expand Up @@ -475,6 +486,9 @@ window.GC = window.GC || {};
model[ o.agemos ].lengthAndStature = o.value;
} else {
model[ o.agemos ] = { "lengthAndStature" : o.value };
if (o.hasOwnProperty('dateString')) {
model[ o.agemos ]['dateString'] = o.dateString;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix the spaces

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

}
}
});

Expand All @@ -484,6 +498,9 @@ window.GC = window.GC || {};
model[ o.agemos ].weight = o.value;
} else {
model[ o.agemos ] = { "weight" : o.value };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove spaces in []

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the entire file.

if (o.hasOwnProperty('dateString')) {
model[ o.agemos ]['dateString'] = o.dateString;
}
}
});

Expand All @@ -494,6 +511,9 @@ window.GC = window.GC || {};
} else {
model[ o.agemos ] = { "headc" : o.value };
}
if (!model[o.agemos].hasOwnProperty("dateString") && o.hasOwnProperty('dateString')) {
model[ o.agemos ]['dateString'] = o.dateString;
}
});

// BMI
Expand All @@ -503,6 +523,9 @@ window.GC = window.GC || {};
} else {
model[ o.agemos ] = { "bmi" : o.value };
}
if (!model[o.agemos].hasOwnProperty("dateString") && o.hasOwnProperty('dateString')) {
model[ o.agemos ]['dateString'] = o.dateString;
}
});

// Bone Age
Expand All @@ -512,6 +535,9 @@ window.GC = window.GC || {};
} else {
model[ o.agemos ] = { "boneAge" : o.boneAge };
}
if (!model[o.agemos].hasOwnProperty("dateString") && o.hasOwnProperty('dateString')) {
model[ o.agemos ]['dateString'] = o.dateString;
}
});

// Annotations
Expand All @@ -521,12 +547,18 @@ window.GC = window.GC || {};
} else {
model[ o.agemos ] = { "annotation" : o.annotation };
}
if (!model[o.agemos].hasOwnProperty("dateString") && o.hasOwnProperty('dateString')) {
model[ o.agemos ]['dateString'] = o.dateString;
}
});

// Override with custom scratchpad data if available
if (GC._isPatientDataEditable && GC.scratchpadData && GC.scratchpadData.patientData) {
$.each(GC.scratchpadData.patientData, function(i, o) {
model[ o.agemos ] = o;
if (!model[o.agemos].hasOwnProperty("dateString") && o.hasOwnProperty('dateString')) {
model[ o.agemos ]['dateString'] = o.dateString;
}
});
}

Expand Down
4 changes: 3 additions & 1 deletion load-fhir-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ GC.get_data = function() {
if (isValidObservationObj(v)) {
arr.push({
date: v.effectiveDateTime,
dateString: v.effectiveDateTime,
boneAgeMos: units.any(v.valueQuantity)
})
}
Expand Down Expand Up @@ -107,7 +108,8 @@ GC.get_data = function() {
if (isValidObservationObj(v)) {
arr.push({
agemos: months(v.effectiveDateTime, patient.birthDate),
value: toUnit(v.valueQuantity)
value: toUnit(v.valueQuantity),
dateString: v.effectiveDateTime
})
}
});
Expand Down