熟练的JSON结构,用于患者和医生之间的评论部分?

时间:2018-02-14 18:45:29

标签: javascript json relation

我目前正在开发一种具有患者和医生之间认证功能的医疗应用程序。

现在用于患者的当前JSON结构&医生如下:

的患者

"Patients": {
  "w14FKo72BieZwbxwUouTpN7UQm02": {
    "name": "Naseebullah Ahmadi",
    "profession": "Student",
    "gender": "Male",
    "type": "Patient",
    "doctors": ["Ernest"],
    "age": "20",
    "DOB": "02/06/1997",
    "address": "122 Atherstone Court",
    "contactNumber": "07473693312",
    "profilePicture": "../Images/profile.jpg",
    "history": {
      "age": "22",
      "weight": "53",
      "height": "172",
      "bmi": "20.4",
      "thermometer": "36.7",
      "calories": "537",
      "bpm": "87",
      "fat": "11",
      "allergies": ["Peanuts", "Penicilin"]
    },
    "appointments": [{
      "date": "25th Jul",
      "time": "13:00",
      "type": "Doctor",
      "name": "Ernest Kamavuako"
    }],
    "ecg": [""],
    "heartSound": [""]
  },

每位患者的身份标识为“例如:w14FKo72BieZwbxwUouTpN7UQm02

医生

"Doctors": {
  "VoxHFgUEIwRFWg7JTKNXSSoFoMV2": {
    "name": "Ernest Kamavuako",
    "gender": "Male",
    "type": "Doctor",
    "Patients": ["Naseebullah"],
    "age": "30",
    "dob": "20/12/1970",
    "address": "122 Harrow Street",
    "contactNumber": "07473033312",
    "profilePicture": "../Images/profile.jpg"
  }
}

现在的问题是:每位医生都能够阅读患者留给他们的评论,同样每位患者都能阅读每位医生留下的评论。

这两条原则最多可以有50条评论。

目前,我不确定如何表示“评论”对象及其应如何布局。

这个问题纯粹是为了理解正在演奏的演员之间的关系。

1 个答案:

答案 0 :(得分:0)

你可以有像这样的评论的json对象

"Comments": {
  "<doctorsId>:<patientsId>": {
    "doctorsComments" : '["comment1", "comment2"]',
    "patientsComments": '["comment1", "comment2"]'
  }
}

此处如果您有医生和患者ID,您可以直接访问评论对象。