创建不同约会中所有患者体重测量值的数组

时间:2019-05-24 19:16:26

标签: google-app-maker

场景

患者安排“预约”并前往诊所。在他们接受医生检查之前,必须采取“措施”。 这些度量是“体重”,“身高”和“头部”大小。为了完成所需的数据,他们的“年龄”也要记录在案。


我正在尝试做的事情:

我想创建一个图表,以显示患者的体重(例如)是否超出/低于限制,并且要实现这一目标,我需要创建一个包含患者先前所有度量的数组< / 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 ,例如,不返回任何内容,包括任何错误。

那么,我怎么能返回这些数组?

0 个答案:

没有答案