|
@@ -17,6 +17,7 @@ class PatientService extends CrudService {
|
|
|
this.chatModel = this.ctx.model.Chat;
|
|
|
this.remark = this.ctx.model.Remark;
|
|
|
this.gc = this.ctx.model.Groupchat;
|
|
|
+ this.room = this.ctx.model.Room;
|
|
|
}
|
|
|
|
|
|
async query({ doctorid, ...query }, { skip, limit }) {
|
|
@@ -237,7 +238,23 @@ class PatientService extends CrudService {
|
|
|
async findByOpenid(data) {
|
|
|
return await this.model.findOne({ openid: data.openid });
|
|
|
}
|
|
|
-
|
|
|
+ // 医生移除病人
|
|
|
+ async fromDoctorDelete({ doctorid, patientid } = {}) {
|
|
|
+ console.log(doctorid, patientid);
|
|
|
+ assert(doctorid, '缺少医生信息');
|
|
|
+ assert(patientid, '缺少病人信息');
|
|
|
+ // 切断医生和病人的关系
|
|
|
+ // 删除医生群组下的这个病人
|
|
|
+ const res = await this.pGroups.find({ 'patients.patientid': patientid, doctorid }, '+patients');
|
|
|
+ for (const i of res) {
|
|
|
+ i.patients = i.patients.filter(f => f.patientid !== patientid);
|
|
|
+ await i.save();
|
|
|
+ }
|
|
|
+ // 删除医生和病人的关系,patient_doctor
|
|
|
+ await this.pDocs.deleteMany({ patientid, doctorid });
|
|
|
+ // 删除医生和病人的聊天房间
|
|
|
+ await this.room.deleteMany({ patientid, doctorid });
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|