patient.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 病历信息
  5. const Emrinfo = new Schema({
  6. indate: { type: String, required: false, maxLength: 20 }, // 入院时间
  7. outdate: { type: String, required: false, maxLength: 20 }, // 出院时间
  8. doctorid: { type: String, required: false }, // 医生ID
  9. doctorname: { type: String, required: false, maxLength: 200 }, // 医生名称
  10. title: { type: String, required: false }, // 标题
  11. content: { type: String, required: false }, // 病历内容
  12. img: { type: String }, // 病例图片
  13. });
  14. Emrinfo.index({ mobile: 1 });
  15. // 患者信息表
  16. const PatientSchema = {
  17. name: { type: String, required: false, maxLength: 200 }, // 名称
  18. icon: { type: String, required: false, maxLength: 500 }, // 头像
  19. cardno: { type: String, required: false, maxLength: 200 }, // 就诊卡号
  20. gender: { type: String, required: false, maxLength: 200 }, // 性别
  21. birthday: { type: String, required: false }, // 生日
  22. address: { type: String, required: false, maxLength: 500 }, // 地址
  23. tel: { type: String, required: false, maxLength: 200 }, // 电话
  24. urgentname: { type: String, required: false, maxLength: 200 }, // 紧急联系人
  25. urgenttel: { type: String, required: false, maxLength: 200 }, // 紧急联系电话
  26. content: { type: String, required: false }, // 简介
  27. openid: { type: String, required: false }, // 微信openid
  28. emrs: { type: [ Emrinfo ], select: true }, // 病人病历信息
  29. };
  30. const schema = new Schema(PatientSchema, { toJSON: { virtuals: true } });
  31. schema.index({ openid: 1 });
  32. schema.index({ 'meta.createdAt': 1 });
  33. schema.plugin(metaPlugin);
  34. module.exports = app => {
  35. const { mongoose } = app;
  36. return mongoose.model('Patient', schema, 'patient');
  37. };