|
@@ -5,6 +5,7 @@ const assert = require('assert');
|
|
|
const _ = require('lodash');
|
|
|
const { CrudService } = require('naf-framework-mongoose/lib/service');
|
|
|
const { BusinessError, ErrorCode } = require('naf-core').Error;
|
|
|
+const { ObjectId } = require('mongoose').Types;
|
|
|
|
|
|
class PatientService extends CrudService {
|
|
|
constructor(ctx) {
|
|
@@ -14,6 +15,7 @@ class PatientService extends CrudService {
|
|
|
this.pGroups = this.ctx.model.Group;
|
|
|
this.pDoctor = this.ctx.model.Doctor;
|
|
|
this.chatModel = this.ctx.model.Chat;
|
|
|
+ this.remark = this.ctx.model.Remark;
|
|
|
}
|
|
|
|
|
|
async query({ doctorid, ...query }, { skip, limit }) {
|
|
@@ -78,6 +80,7 @@ class PatientService extends CrudService {
|
|
|
assert(id, '患者id不能为空');
|
|
|
const doctors = await this.pDocs.find({ patientid: id });
|
|
|
const data = [];
|
|
|
+ const remarks = await this.remark.find({ remarkid: id });
|
|
|
for (const elm of doctors) {
|
|
|
|
|
|
let contenttype = '';
|
|
@@ -90,7 +93,13 @@ class PatientService extends CrudService {
|
|
|
content = chats[0].content;
|
|
|
sendtime = chats[0].sendtime;
|
|
|
}
|
|
|
- const newdata = { patientid: elm.patientid, patientname: elm.patientname, doctorid: elm.doctorid, doctorname: elm.doctorname, contenttype, content, sendtime };
|
|
|
+ let { patientid, patientname, doctorid, doctorname } = elm;
|
|
|
+ const s_r = remarks.find(f => ObjectId(f.benoteid).equals(patientid));
|
|
|
+ if (s_r) patientname = s_r.name;
|
|
|
+ const r_r = remarks.find(f => ObjectId(f.benoteid).equals(doctorid));
|
|
|
+ if (r_r) doctorname = r_r.name;
|
|
|
+ const newdata = { patientid: elm.patientid, patientname, doctorid: elm.doctorid, doctorname, contenttype, content, sendtime };
|
|
|
+
|
|
|
data.push(newdata);
|
|
|
}
|
|
|
return data;
|