患者安排“预约”并前往诊所。在他们接受医生检查之前,必须采取“措施”。 这些度量是“体重”,“身高”和“头部”大小。为了完成所需的数据,他们的“年龄”也要记录在案。
我想创建一个图表,以显示患者的体重(例如)是否超出/低于限制,并且要实现这一目标,我需要创建一个包含患者先前所有度量的数组< / strong>。
- John (id:12) comes to appointment#1 (id:55) on jan,1 2019; he have 1 month age; his Measures (id:47): Weight=30kg, Height=120cm, Head=[not taken];
- John (id:12) comes to appointment#2 (id:67) on feb,3 2019; he have 2 month age; his Measures (id:72): Weight=35kg, Height=127cm, Head=[not taken];
- John (id:12) comes to appointment#3 (id:89) on mar,9 2019; he have 3 month age; and none of his Measures are taken;
- John (id:12) comes to appointment#4 (id:99) on apr,5 2019; he have 4 month age; his Measures (id:93): Weight=42kg, Height=135cm, Head=[not taken];
weightArray = {"30","35",,"42"}
heightArray = {"120","127",,"135"}
headArray = {,,,}
传说:
数组名称 = {一个月测量一次,两个测量一次-月龄,测量三个月龄,等 ...}
app.datasources.Patients.item.idPatient
.Name
app.datasources.Appointments.item.idAppointment
.Date
.Time
.relations.Measures.item.idMeasure (one to one)
.Weight
.Height
.Head
.Age
.relations.Patients (many to one)
function getHistoryPatient (patientId){
var weightArr = [], heightArr = [], headArr = [], ageArr = [];
var dataSource = app.datasources.Appointments;
dataSource.query.filters.Patients.idPatient._equals = patientId;
dataSource.load(function (){
var appointmentItems = dataSource.items.forEach(function (appointment){
var data = appointment.Measures;
weightArr.push(data.Weight);
heightArr.push(data.Height);
headArr.push(data.Head);
ageArr.push(data.Age);
});
});
return {Age: ageArr, Weight: weightArr, Height: heightArr, Head: headArr};
}
实际上,调用: getHistoryPatient(PatientId).Weight ,例如,不返回任何内容,包括任何错误。
那么,我怎么能返回这些数组?