|
@@ -125,8 +125,17 @@ class PatientService extends CrudService {
|
|
|
}
|
|
|
|
|
|
async delete({ id }) {
|
|
|
- await this.model.findByIdAndDelete(id);
|
|
|
+ // 删除病人和医生的关联
|
|
|
await this.pDocs.deleteMany({ patientid: id });
|
|
|
+ // 删除群组中的病人
|
|
|
+ const res = await this.pGroups.find({ 'patients.patientid': id }, '+patients');
|
|
|
+ for (const i of res) {
|
|
|
+ i.patients = i.patients.filter(f => f.patientid !== id);
|
|
|
+ await i.save();
|
|
|
+ }
|
|
|
+ // 删除该病人
|
|
|
+ await this.model.findByIdAndDelete(id);
|
|
|
+
|
|
|
return 'deleted';
|
|
|
}
|
|
|
|