1234567891011121314151617181920212223242526272829303132333435363738394041 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- // 病历信息
- const Emrinfo = new Schema({
- indate: { type: String, required: false, maxLength: 20 }, // 入院时间
- outdate: { type: String, required: false, maxLength: 20 }, // 出院时间
- doctorid: { type: String, required: false }, // 医生ID
- doctorname: { type: String, required: false, maxLength: 200 }, // 医生名称
- title: { type: String, required: false }, // 标题
- content: { type: String, required: false }, // 病历内容
- img: { type: String }, // 病例图片
- });
- Emrinfo.index({ mobile: 1 });
- // 患者信息表
- const PatientSchema = {
- name: { type: String, required: false, maxLength: 200 }, // 名称
- icon: { type: String, required: false, maxLength: 500 }, // 头像
- cardno: { type: String, required: false, maxLength: 200 }, // 就诊卡号
- gender: { type: String, required: false, maxLength: 200 }, // 性别
- birthday: { type: String, required: false }, // 生日
- address: { type: String, required: false, maxLength: 500 }, // 地址
- tel: { type: String, required: false, maxLength: 200 }, // 电话
- urgentname: { type: String, required: false, maxLength: 200 }, // 紧急联系人
- urgenttel: { type: String, required: false, maxLength: 200 }, // 紧急联系电话
- content: { type: String, required: false }, // 简介
- openid: { type: String, required: false }, // 微信openid
- emrs: { type: [ Emrinfo ], select: true }, // 病人病历信息
- };
- const schema = new Schema(PatientSchema, { toJSON: { virtuals: true } });
- schema.index({ openid: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Patient', schema, 'patient');
- };
|