lrf402788946 4 years ago
parent
commit
f35e51611f
1 changed files with 6 additions and 1 deletions
  1. 6 1
      app/service/room.js

+ 6 - 1
app/service/room.js

@@ -12,6 +12,7 @@ class RoomService extends CrudService {
     this.model = this.ctx.model.Room;
     this.model = this.ctx.model.Room;
     this.pmodel = this.ctx.model.Patient;
     this.pmodel = this.ctx.model.Patient;
     this.chatModel = this.ctx.model.Chat;
     this.chatModel = this.ctx.model.Chat;
+    this.remark = this.ctx.model.Remark;
   }
   }
 
 
   async query(data) {
   async query(data) {
@@ -22,6 +23,7 @@ class RoomService extends CrudService {
     }
     }
     if (doctorid) {
     if (doctorid) {
       const res_ = await this.model.find({ doctorid });
       const res_ = await this.model.find({ doctorid });
+      const remarks = await this.remark.find({ remarkid: doctorid });
       const data = [];
       const data = [];
       for (const elm of res_) {
       for (const elm of res_) {
         const patient = await this.pmodel.findById(elm.patientid);
         const patient = await this.pmodel.findById(elm.patientid);
@@ -39,7 +41,10 @@ class RoomService extends CrudService {
           content = chats[0].content;
           content = chats[0].content;
           sendtime = chats[0].sendtime;
           sendtime = chats[0].sendtime;
         }
         }
-        const newdata = { patientid: elm.patientid, patientname: elm.patientname, icon, contenttype, content, sendtime, doctorid: elm.doctorid, doctorname: elm.doctorname };
+        let { patientid, patientname } = elm;
+        const s_r = remarks.find(f => ObjectId(f.benoteid).equals(patientid));
+        if (s_r) patientname = s_r.name;
+        const newdata = { patientid: elm.patientid, patientname, icon, contenttype, content, sendtime, doctorid: elm.doctorid, doctorname: elm.doctorname };
         data.push(newdata);
         data.push(newdata);
       }
       }
       res = data;
       res = data;