From efde711eaa1aa8bb824c429fbf90439058022f10 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Tue, 19 Sep 2023 17:49:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=8F=96=E5=A4=84?= =?UTF-8?q?=E6=96=B9=E5=88=97=E8=A1=A8-=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/controller/base.go | 22 ++- api/controller/orderPrescription.go | 79 +++++++++ api/dao/orderPrescription.go | 161 ++++++++++++++++++ api/model/orderPrescription.go | 54 +++--- api/model/patientFamily.go | 2 +- api/requests/orderPrescription.go | 22 +++ .../orderPrescription.go | 101 +++++++++++ .../patientFamilyResponse/patientFamily.go | 5 +- api/router/router.go | 10 ++ api/service/orderPrescription.go | 1 - api/service/patientFamily.go | 4 +- 11 files changed, 422 insertions(+), 39 deletions(-) create mode 100644 api/controller/orderPrescription.go create mode 100644 api/requests/orderPrescription.go diff --git a/api/controller/base.go b/api/controller/base.go index ef444af..18adc42 100644 --- a/api/controller/base.go +++ b/api/controller/base.go @@ -2,14 +2,15 @@ package controller // Api api接口 type Api struct { - sysSetting // 系统设置 - userDoctorManage // 医生管理 - Admin // 公共方法-验证权限 - Public // 公共方法-不验证权限 - basic // 基础数据 - order // 订单管理 - userPatientManage // 患者管理 - caseManage // 病例管理 + sysSetting // 系统设置 + userDoctorManage // 医生管理 + Admin // 公共方法-验证权限 + Public // 公共方法-不验证权限 + basic // 基础数据 + order // 订单管理 + userPatientManage // 患者管理 + caseManage // 病例管理 + orderPrescriptionManage // 处方管理 } // SysSetting 系统设置 @@ -53,3 +54,8 @@ type userPatientManage struct { type caseManage struct { Case // 患者列表 } + +// 处方管理 +type orderPrescriptionManage struct { + OrderPrescription // 处方列表 +} diff --git a/api/controller/orderPrescription.go b/api/controller/orderPrescription.go new file mode 100644 index 0000000..5cddb0a --- /dev/null +++ b/api/controller/orderPrescription.go @@ -0,0 +1,79 @@ +package controller + +import ( + "github.com/gin-gonic/gin" + "hospital-admin-api/api/dao" + "hospital-admin-api/api/requests" + "hospital-admin-api/api/responses" + "hospital-admin-api/api/responses/orderPrescriptionResponse" + "hospital-admin-api/global" + "hospital-admin-api/utils" +) + +type OrderPrescription struct{} + +// GetOrderPrescriptionPage 获取处方列表-分页 +func (r *OrderPrescription) GetOrderPrescriptionPage(c *gin.Context) { + req := requests.OrderPrescriptionRequest{} + if err := c.ShouldBind(&req.GetOrderPrescriptionPage); err != nil { + responses.FailWithMessage(err.Error(), c) + return + } + + // 参数验证 + if err := global.Validate.Struct(req.GetOrderPrescriptionPage); err != nil { + responses.FailWithMessage(utils.Translate(err), c) + return + } + + if req.GetOrderPrescriptionPage.Page == 0 { + req.GetOrderPrescriptionPage.Page = 1 + } + + if req.GetOrderPrescriptionPage.PageSize == 0 { + req.GetOrderPrescriptionPage.PageSize = 20 + } + + orderPrescriptionDao := dao.OrderPrescriptionDao{} + orderPrescription, total, err := orderPrescriptionDao.GetOrderPrescriptionPageSearch(req.GetOrderPrescriptionPage, req.GetOrderPrescriptionPage.Page, req.GetOrderPrescriptionPage.PageSize) + if err != nil { + responses.FailWithMessage(err.Error(), c) + return + } + + // 处理返回值 + GetOrderPrescriptionPage := orderPrescriptionResponse.GetOrderPrescriptionPageResponse(orderPrescription) + + result := make(map[string]interface{}) + result["page"] = req.GetOrderPrescriptionPage.Page + result["page_size"] = req.GetOrderPrescriptionPage.PageSize + result["total"] = total + result["data"] = GetOrderPrescriptionPage + responses.OkWithData(result, c) +} + +// // GetOrderPrescription 处方详情 +// func (r *OrderPrescription) GetOrderPrescription(c *gin.Context) { +// id := c.Param("family_id") +// if id == "" { +// responses.FailWithMessage("缺少参数", c) +// return +// } +// +// // 将 id 转换为 int64 类型 +// familyId, err := strconv.ParseInt(id, 10, 64) +// if err != nil { +// responses.Fail(c) +// return +// } +// +// // 业务处理 +// patientFamilyService := service.PrescriptionService{} +// getPrescriptionResponse, err := patientFamilyService.GetPrescription(familyId) +// if err != nil { +// responses.FailWithMessage(err.Error(), c) +// return +// } +// +// responses.OkWithData(getPrescriptionResponse, c) +// } diff --git a/api/dao/orderPrescription.go b/api/dao/orderPrescription.go index 087f9d6..6354444 100644 --- a/api/dao/orderPrescription.go +++ b/api/dao/orderPrescription.go @@ -3,7 +3,10 @@ package dao import ( "gorm.io/gorm" "hospital-admin-api/api/model" + "hospital-admin-api/api/requests" "hospital-admin-api/global" + "strings" + "time" ) type OrderPrescriptionDao struct { @@ -70,3 +73,161 @@ func (r *OrderPrescriptionDao) AddByMap(tx *gorm.DB, data map[string]interface{} } return orderPrescription, nil } + +// GetOrderPrescriptionPageSearch 获取处方列表-分页 +func (r *OrderPrescriptionDao) GetOrderPrescriptionPageSearch(req requests.GetOrderPrescriptionPage, page, pageSize int) (m []*model.OrderPrescription, total int64, err error) { + var totalRecords int64 + + // 构建查询条件 + query := global.Db.Model(&model.OrderPrescription{}) + + // 患者表 + query = query.Preload("UserPatient", func(db *gorm.DB) *gorm.DB { + return db.Omit("open_id", "union_id", "wx_session_key") + }) + + // 用户表 + query = query.Preload("UserPatient.User", func(db *gorm.DB) *gorm.DB { + return db.Omit("user_password", "salt") + }) + + // 药师表 + query = query.Preload("UserPharmacist", func(db *gorm.DB) *gorm.DB { + return db.Omit("open_id", "union_id", "wx_session_key") + }) + + // 处方关联疾病表 + query = query.Preload("OrderPrescriptionIcd") + + // 患者家庭成员表 + query = query.Preload("PatientFamily") + + // 处方编号 + if req.PrescriptionCode != "" { + query = query.Where("prescription_code = ?", req.PrescriptionCode) + } + + // 医生名称 + if req.DoctorName != "" { + query = query.Where("doctor_name LIKE ?", "%"+req.DoctorName+"%") + } + + // 患者姓名-就诊人 + if req.PatientName != "" { + query = query.Where("patient_name LIKE ?", "%"+req.PatientName+"%") + } + + // 手机号-医生/患者/就诊人 + if req.Mobile != "" { + // 就诊人 + patientFamilySubQuery := global.Db.Model(&model.PatientFamily{}). + Select("family_id"). + Where("mobile = ?", req.Mobile) + + // 患者 + patientUserSubQuery := global.Db.Model(&model.User{}). + Select("user_id"). + Where("mobile = ?", req.Mobile) + + patientSubQuery := global.Db.Model(&model.UserPatient{}). + Select("patient_id"). + Where(gorm.Expr("user_id IN (?)", patientUserSubQuery)) + + // 医生 + doctorUserSubQuery := global.Db.Model(&model.User{}). + Select("user_id"). + Where("mobile = ?", req.Mobile) + + doctorSubQuery := global.Db.Model(&model.UserDoctor{}). + Select("doctor_id"). + Where(gorm.Expr("user_id IN (?)", doctorUserSubQuery)) + + query = query.Where("patient_id IN (?)", patientSubQuery).Or("doctor_id IN (?)", doctorSubQuery).Or("family_id IN (?)", patientFamilySubQuery) + } + + // 处方状态 + if req.PrescriptionStatus != nil { + query = query.Where("prescription_status = ?", req.PrescriptionStatus) + } + + // 药师审核状态 + if req.PharmacistAuditStatus != nil { + query = query.Where("pharmacist_audit_status = ?", req.PharmacistAuditStatus) + } + + // 问诊订单编号 + if req.InquiryNo != "" { + subQuery := global.Db.Model(&model.OrderInquiry{}). + Select("order_inquiry_id"). + Where("inquiry_no = ?", req.InquiryNo) + query = query.Where("order_inquiry_id IN (?)", subQuery) + } + + // 药品订单编号 + if req.OrderProductNo != "" { + subQuery := global.Db.Model(&model.OrderInquiry{}). + Select("order_prescription_id"). + Where("order_product_no = ?", req.OrderProductNo) + query = query.Where("order_prescription_id IN (?)", subQuery) + } + + // 药师审核时间 + if req.PharmacistVerifyTime != "" { + pharmacistVerifyTime := strings.Split(req.PharmacistVerifyTime, "&") + if len(pharmacistVerifyTime) == 2 { + startTime, _ := time.Parse("2006-01-02", pharmacistVerifyTime[0]) + endTime, _ := time.Parse("2006-01-02", pharmacistVerifyTime[1]) + + if startTime == endTime { + endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second) + } + + query = query.Where("pharmacist_verify_time BETWEEN ? AND ?", startTime, endTime) + } + } + + // 医生开具处方时间 + if req.DoctorCreatedTime != "" { + doctorCreatedTime := strings.Split(req.DoctorCreatedTime, "&") + if len(doctorCreatedTime) == 2 { + startTime, _ := time.Parse("2006-01-02", doctorCreatedTime[0]) + endTime, _ := time.Parse("2006-01-02", doctorCreatedTime[1]) + + if startTime == endTime { + endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second) + } + + query = query.Where("doctor_created_time BETWEEN ? AND ?", startTime, endTime) + } + } + + // 处方过期时间 + if req.ExpiredTime != "" { + expiredTime := strings.Split(req.ExpiredTime, "&") + if len(expiredTime) == 2 { + startTime, _ := time.Parse("2006-01-02", expiredTime[0]) + endTime, _ := time.Parse("2006-01-02", expiredTime[1]) + + if startTime == endTime { + endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second) + } + + query = query.Where("expired_time BETWEEN ? AND ?", startTime, endTime) + } + } + + // 排序 + query = query.Order("created_at desc") + + // 查询总数量 + if err := query.Count(&totalRecords).Error; err != nil { + return nil, 0, err + } + + err = query.Scopes(model.Paginate(page, pageSize)).Find(&m).Error + if err != nil { + return nil, 0, err + } + + return m, totalRecords, nil +} diff --git a/api/model/orderPrescription.go b/api/model/orderPrescription.go index 7d86530..578696f 100644 --- a/api/model/orderPrescription.go +++ b/api/model/orderPrescription.go @@ -8,30 +8,36 @@ import ( // OrderPrescription 订单-处方表 type OrderPrescription struct { - OrderPrescriptionId int64 `gorm:"column:order_prescription_id;type:bigint(19);primary_key;comment:主键id" json:"order_prescription_id"` - OrderInquiryId int64 `gorm:"column:order_inquiry_id;type:bigint(19);comment:订单-问诊id;NOT NULL" json:"order_inquiry_id"` - DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id;NOT NULL" json:"doctor_id"` - PatientId int64 `gorm:"column:patient_id;type:bigint(19);comment:患者id" json:"patient_id"` - FamilyId int64 `gorm:"column:family_id;type:bigint(19);comment:家庭成员id(就诊用户)" json:"family_id"` - PharmacistId int64 `gorm:"column:pharmacist_id;type:bigint(19);comment:药师id" json:"pharmacist_id"` - PrescriptionStatus int `gorm:"column:prescription_status;type:tinyint(1);comment:处方状态(1:待审核 2:待使用 3:已失效 4:已使用)" json:"prescription_status"` - PharmacistAuditStatus int `gorm:"column:pharmacist_audit_status;type:tinyint(1);default:0;comment:药师审核状态(0:审核中 1:审核成功 2:审核驳回)" json:"pharmacist_audit_status"` - PharmacistVerifyTime LocalTime `gorm:"column:pharmacist_verify_time;type:datetime;comment:药师审核时间" json:"pharmacist_verify_time"` - PharmacistFailReason string `gorm:"column:pharmacist_fail_reason;type:varchar(255);comment:药师审核驳回原因" json:"pharmacist_fail_reason"` - PlatformAuditStatus int `gorm:"column:platform_audit_status;type:tinyint(1);default:0;comment:处方平台审核状态(0:审核中 1:审核成功 2:审核驳回)" json:"platform_audit_status"` - PlatformFailTime LocalTime `gorm:"column:platform_fail_time;type:datetime;comment:平台审核失败时间" json:"platform_fail_time"` - PlatformFailReason string `gorm:"column:platform_fail_reason;type:varchar(255);comment:处方平台驳回原因" json:"platform_fail_reason"` - IsAutoPharVerify int `gorm:"column:is_auto_phar_verify;type:tinyint(1);default:0;comment:是否药师自动审核(0:否 1:是)" json:"is_auto_phar_verify"` - DoctorCreatedTime LocalTime `gorm:"column:doctor_created_time;type:datetime;comment:医生开具处方时间" json:"doctor_created_time"` - ExpiredTime LocalTime `gorm:"column:expired_time;type:datetime;comment:处方过期时间" json:"expired_time"` - VoidTime LocalTime `gorm:"column:void_time;type:datetime;comment:处方作废时间" json:"void_time"` - IsDelete int `gorm:"column:is_delete;type:tinyint(1);default:0;comment:是否删除(0:否 1:是)" json:"is_delete"` - PrescriptionCode string `gorm:"column:prescription_code;type:varchar(255);comment:处方编号" json:"prescription_code"` - DoctorName string `gorm:"column:doctor_name;type:varchar(100);comment:医生名称" json:"doctor_name"` - PatientName string `gorm:"column:patient_name;type:varchar(100);comment:患者姓名-就诊人" json:"patient_name"` - PatientSex int `gorm:"column:patient_sex;type:tinyint(1);comment:患者性别-就诊人(1:男 2:女)" json:"patient_sex"` - PatientAge int `gorm:"column:patient_age;type:int(11);comment:患者年龄-就诊人" json:"patient_age"` - DoctorAdvice string `gorm:"column:doctor_advice;type:varchar(255);comment:医嘱" json:"doctor_advice"` + OrderPrescriptionId int64 `gorm:"column:order_prescription_id;type:bigint(19);primary_key;comment:主键id" json:"order_prescription_id"` + OrderInquiryId int64 `gorm:"column:order_inquiry_id;type:bigint(19);comment:订单-问诊id;NOT NULL" json:"order_inquiry_id"` + DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id;NOT NULL" json:"doctor_id"` + PatientId int64 `gorm:"column:patient_id;type:bigint(19);comment:患者id" json:"patient_id"` + FamilyId int64 `gorm:"column:family_id;type:bigint(19);comment:家庭成员id(就诊用户)" json:"family_id"` + PharmacistId int64 `gorm:"column:pharmacist_id;type:bigint(19);comment:药师id" json:"pharmacist_id"` + PrescriptionStatus int `gorm:"column:prescription_status;type:tinyint(1);comment:处方状态(1:待审核 2:待使用 3:已失效 4:已使用)" json:"prescription_status"` + PharmacistAuditStatus int `gorm:"column:pharmacist_audit_status;type:tinyint(1);default:0;comment:药师审核状态(0:审核中 1:审核成功 2:审核驳回)" json:"pharmacist_audit_status"` + PharmacistVerifyTime LocalTime `gorm:"column:pharmacist_verify_time;type:datetime;comment:药师审核时间" json:"pharmacist_verify_time"` + PharmacistFailReason string `gorm:"column:pharmacist_fail_reason;type:varchar(255);comment:药师审核驳回原因" json:"pharmacist_fail_reason"` + PlatformAuditStatus int `gorm:"column:platform_audit_status;type:tinyint(1);default:0;comment:处方平台审核状态(0:审核中 1:审核成功 2:审核驳回)" json:"platform_audit_status"` + PlatformFailTime LocalTime `gorm:"column:platform_fail_time;type:datetime;comment:平台审核失败时间" json:"platform_fail_time"` + PlatformFailReason string `gorm:"column:platform_fail_reason;type:varchar(255);comment:处方平台驳回原因" json:"platform_fail_reason"` + IsAutoPharVerify int `gorm:"column:is_auto_phar_verify;type:tinyint(1);default:0;comment:是否药师自动审核(0:否 1:是)" json:"is_auto_phar_verify"` + DoctorCreatedTime LocalTime `gorm:"column:doctor_created_time;type:datetime;comment:医生开具处方时间" json:"doctor_created_time"` + ExpiredTime LocalTime `gorm:"column:expired_time;type:datetime;comment:处方过期时间" json:"expired_time"` + VoidTime LocalTime `gorm:"column:void_time;type:datetime;comment:处方作废时间" json:"void_time"` + IsDelete int `gorm:"column:is_delete;type:tinyint(1);default:0;comment:是否删除(0:否 1:是)" json:"is_delete"` + PrescriptionCode string `gorm:"column:prescription_code;type:varchar(255);comment:处方编号" json:"prescription_code"` + DoctorName string `gorm:"column:doctor_name;type:varchar(100);comment:医生名称" json:"doctor_name"` + PatientName string `gorm:"column:patient_name;type:varchar(100);comment:患者姓名-就诊人" json:"patient_name"` + PatientSex int `gorm:"column:patient_sex;type:tinyint(1);comment:患者性别-就诊人(1:男 2:女)" json:"patient_sex"` + PatientAge int `gorm:"column:patient_age;type:int(11);comment:患者年龄-就诊人" json:"patient_age"` + DoctorAdvice string `gorm:"column:doctor_advice;type:varchar(255);comment:医嘱" json:"doctor_advice"` + OrderInquiry *OrderInquiry `gorm:"foreignKey:OrderInquiryId;references:order_inquiry_id" json:"order_inquiry"` // 问诊订单 + UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"` // 医生 + UserPharmacist *UserPharmacist `gorm:"foreignKey:PharmacistId;references:pharmacist_id" json:"user_pharmacist"` // 药师 + UserPatient *UserPatient `gorm:"foreignKey:PatientId;references:patient_id" json:"user_patient"` // 患者 + OrderPrescriptionIcd []*OrderPrescriptionIcd `gorm:"foreignKey:OrderPrescriptionId;references:order_prescription_id" json:"order_prescription_icd"` // 处方疾病 + PatientFamily *PatientFamily `gorm:"foreignKey:FamilyId;references:family_id" json:"patient_family"` // 家庭成员 Model } diff --git a/api/model/patientFamily.go b/api/model/patientFamily.go index 5d251a9..36b44b0 100644 --- a/api/model/patientFamily.go +++ b/api/model/patientFamily.go @@ -10,7 +10,7 @@ import ( type PatientFamily struct { FamilyId int64 `gorm:"column:family_id;type:bigint(19);primary_key;comment:主键id" json:"family_id"` PatientId int64 `gorm:"column:patient_id;type:bigint(19);comment:患者id" json:"patient_id"` - Relation int `gorm:"column:relation;type:tinyint(1);comment:与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他 )" json:"relation"` + Relation *int `gorm:"column:relation;type:tinyint(1);comment:与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他 )" json:"relation"` Status int `gorm:"column:status;type:tinyint(1);default:1;comment:状态(1:正常 2:删除)" json:"status"` IsDefault int `gorm:"column:is_default;type:tinyint(1);default:0;comment:是否默认(0:否 1:是)" json:"is_default"` CardName string `gorm:"column:card_name;type:varchar(50);comment:姓名" json:"card_name"` diff --git a/api/requests/orderPrescription.go b/api/requests/orderPrescription.go new file mode 100644 index 0000000..bcc47ba --- /dev/null +++ b/api/requests/orderPrescription.go @@ -0,0 +1,22 @@ +package requests + +type OrderPrescriptionRequest struct { + GetOrderPrescriptionPage // 获取处方列表-分页 +} + +// GetOrderPrescriptionPage 获取处方列表-分页 +type GetOrderPrescriptionPage struct { + Page int `json:"page" form:"page" label:"页码"` + PageSize int `json:"page_size" form:"page_size" label:"每页个数"` + PrescriptionCode string `json:"prescription_code" form:"prescription_code" label:"处方编号"` + DoctorName string `json:"doctor_name" form:"doctor_name" label:"医生名称"` + PatientName string `json:"patient_name" form:"patient_name" label:"患者姓名-就诊人"` + Mobile string `json:"mobile" form:"mobile" label:"手机号-医生/患者/就诊人"` + PrescriptionStatus *int `json:"prescription_status" form:"prescription_status" label:"处方状态"` // (1:待审核 2:待使用 3:已失效 4:已使用) + PharmacistAuditStatus *int `json:"pharmacist_audit_status" form:"pharmacist_audit_status" label:"药师审核状态"` // (0:审核中 1:审核成功 2:审核驳回) + PharmacistVerifyTime string `json:"pharmacist_verify_time" form:"pharmacist_verify_time" label:"药师审核时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间 + DoctorCreatedTime string `json:"doctor_created_time" form:"doctor_created_time" label:"医生开具处方时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间 + ExpiredTime string `json:"expired_time" form:"expired_time" label:"处方过期时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间 + InquiryNo string `json:"inquiry_no" form:"inquiry_no" label:"问诊订单编号"` + OrderProductNo string `json:"order_product_no" form:"order_product_no" label:"药品订单编号"` +} diff --git a/api/responses/orderPrescriptionResponse/orderPrescription.go b/api/responses/orderPrescriptionResponse/orderPrescription.go index 68d98bb..49deef6 100644 --- a/api/responses/orderPrescriptionResponse/orderPrescription.go +++ b/api/responses/orderPrescriptionResponse/orderPrescription.go @@ -1,7 +1,10 @@ package orderPrescriptionResponse import ( + "fmt" "hospital-admin-api/api/model" + "hospital-admin-api/utils" + "strings" ) type OrderPrescription struct { @@ -32,3 +35,101 @@ type OrderPrescription struct { CreatedAt model.LocalTime `json:"created_at"` // 创建时间 UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 } + +type getOrderPrescriptionPage struct { + OrderPrescriptionId string `json:"order_prescription_id"` // 主键id + OrderInquiryId string `json:"order_inquiry_id"` // 订单-问诊id;NOT NULL + DoctorId string `json:"doctor_id"` // 医生id;NOT NULL + PatientId string `json:"patient_id"` // 患者id + FamilyId string `json:"family_id"` // 家庭成员id(就诊用户) + PharmacistId string `json:"pharmacist_id"` // 药师id + PrescriptionStatus int `json:"prescription_status"` // 处方状态(1:待审核 2:待使用 3:已失效 4:已使用) + PharmacistAuditStatus int `json:"pharmacist_audit_status"` // 药师审核状态(0:审核中 1:审核成功 2:审核驳回) + PharmacistVerifyTime model.LocalTime `json:"pharmacist_verify_time"` // 药师审核时间 + PharmacistFailReason string `json:"pharmacist_fail_reason"` // 药师审核驳回原因 + PlatformAuditStatus int `json:"platform_audit_status"` // 处方平台审核状态(0:审核中 1:审核成功 2:审核驳回) + PlatformFailTime model.LocalTime `json:"platform_fail_time"` // 平台审核失败时间 + PlatformFailReason string `json:"platform_fail_reason"` // 处方平台驳回原因 + IsAutoPharVerify int `json:"is_auto_phar_verify"` // 是否药师自动审核(0:否 1:是) + DoctorCreatedTime model.LocalTime `json:"doctor_created_time"` // 医生开具处方时间 + ExpiredTime model.LocalTime `json:"expired_time"` // 处方过期时间 + IsDelete int `json:"is_delete"` // 是否删除(0:否 1:是) + PrescriptionCode string `json:"prescription_code"` // 处方编号 + DoctorName string `json:"doctor_name"` // 医生名称 + PatientName string `json:"patient_name"` // 患者姓名-就诊人 + PatientSex int `json:"patient_sex"` // 患者性别-就诊人(1:男 2:女) + PatientAge int `json:"patient_age"` // 患者年龄-就诊人 + DoctorAdvice string `json:"doctor_advice"` // 医嘱 + PharmacistName string `json:"pharmacist_name"` // 药师姓名 + Mobile string `json:"mobile"` // 手机号 + OrderPrescriptionIcd string `json:"order_prescription_icd"` // 处方诊断疾病 + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 +} + +// GetOrderPrescriptionPageResponse 获取处方列表-分页 +func GetOrderPrescriptionPageResponse(orderPrescription []*model.OrderPrescription) []getOrderPrescriptionPage { + // 处理返回值 + orderPrescriptionResponses := make([]getOrderPrescriptionPage, len(orderPrescription)) + + if len(orderPrescription) > 0 { + for i, v := range orderPrescription { + // 将原始结构体转换为新结构体 + u := getOrderPrescriptionPage{ + OrderPrescriptionId: fmt.Sprintf("%d", v.OrderPrescriptionId), + OrderInquiryId: fmt.Sprintf("%d", v.OrderInquiryId), + DoctorId: fmt.Sprintf("%d", v.DoctorId), + PatientId: fmt.Sprintf("%d", v.PatientId), + FamilyId: fmt.Sprintf("%d", v.FamilyId), + PharmacistId: fmt.Sprintf("%d", v.PharmacistId), + PrescriptionStatus: v.PrescriptionStatus, + PharmacistAuditStatus: v.PharmacistAuditStatus, + PharmacistVerifyTime: v.PharmacistVerifyTime, + PharmacistFailReason: v.PharmacistFailReason, + PlatformAuditStatus: v.PlatformAuditStatus, + PlatformFailTime: v.PlatformFailTime, + PlatformFailReason: v.PlatformFailReason, + IsAutoPharVerify: v.IsAutoPharVerify, + DoctorCreatedTime: v.DoctorCreatedTime, + ExpiredTime: v.ExpiredTime, + IsDelete: v.IsDelete, + PrescriptionCode: v.PrescriptionCode, + DoctorName: v.DoctorName, + PatientName: v.PatientName, + PatientSex: v.PatientSex, + PatientAge: v.PatientAge, + DoctorAdvice: v.DoctorAdvice, + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 药师姓名 + if v.UserPharmacist != nil { + u.PharmacistName = v.UserPharmacist.UserName + } + + // 手机号 + if v.PatientFamily != nil { + u.Mobile = v.PatientFamily.MobileMask + } + + if u.Mobile == "" && v.UserPatient.User != nil { + u.Mobile = utils.MaskPhoneStr(v.UserPatient.User.Mobile) + } + + // 处方诊断疾病 + if len(v.OrderPrescriptionIcd) > 0 { + var orderPrescriptionIcd []string + for _, icd := range v.OrderPrescriptionIcd { + orderPrescriptionIcd = append(orderPrescriptionIcd, icd.IcdName) + } + + u.OrderPrescriptionIcd = strings.Join(orderPrescriptionIcd, "、") + } + + // 将转换后的结构体添加到新切片中 + orderPrescriptionResponses[i] = u + } + } + return orderPrescriptionResponses +} diff --git a/api/responses/patientFamilyResponse/patientFamily.go b/api/responses/patientFamilyResponse/patientFamily.go index 84b8581..e43a6db 100644 --- a/api/responses/patientFamilyResponse/patientFamily.go +++ b/api/responses/patientFamilyResponse/patientFamily.go @@ -111,7 +111,7 @@ func GetUserPatientResponse(patientFamilys []*model.PatientFamily) []*GetUserPat item := &GetUserPatient{ FamilyId: fmt.Sprintf("%d", v.FamilyId), PatientId: fmt.Sprintf("%d", v.PatientId), - Relation: &v.Relation, + Relation: v.Relation, Status: &v.Status, IsDefault: &v.IsDefault, CardNameMask: v.CardNameMask, @@ -137,12 +137,11 @@ func GetPatientFamilyPageResponse(patientFamily []*model.PatientFamily) []getPat if len(patientFamily) > 0 { for i, v := range patientFamily { - // 将原始结构体转换为新结构体 // 将原始结构体转换为新结构体 patientFamilyResponse := getPatientFamilyPage{ FamilyId: fmt.Sprintf("%d", v.FamilyId), PatientId: fmt.Sprintf("%d", v.PatientId), - Relation: &v.Relation, + Relation: v.Relation, Status: &v.Status, CardName: v.CardName, MobileMask: utils.MaskPhoneStr(v.UserPatient.User.Mobile), diff --git a/api/router/router.go b/api/router/router.go index 9125553..d40d7a6 100644 --- a/api/router/router.go +++ b/api/router/router.go @@ -438,4 +438,14 @@ func privateRouter(r *gin.Engine, api controller.Api) { } } + + // 处方管理 + prescriptionGroup := adminGroup.Group("/prescription") + { + // 获取处方列表-分页 + prescriptionGroup.GET("", api.OrderPrescription.GetOrderPrescriptionPage) + + // 处方详情 + prescriptionGroup.GET("/:patient_id", api.OrderPrescription.GetOrderPrescriptionPage) + } } diff --git a/api/service/orderPrescription.go b/api/service/orderPrescription.go index 2c5916e..c3194d9 100644 --- a/api/service/orderPrescription.go +++ b/api/service/orderPrescription.go @@ -35,7 +35,6 @@ func (r *OrderPrescriptionService) GetOrderPrescriptionById(OrderPrescriptionId IsAutoPharVerify: orderPrescription.IsAutoPharVerify, DoctorCreatedTime: orderPrescription.DoctorCreatedTime, ExpiredTime: orderPrescription.ExpiredTime, - VoidTime: orderPrescription.VoidTime, IsDelete: orderPrescription.IsDelete, PrescriptionCode: orderPrescription.PrescriptionCode, DoctorName: orderPrescription.DoctorName, diff --git a/api/service/patientFamily.go b/api/service/patientFamily.go index 4245533..e51af04 100644 --- a/api/service/patientFamily.go +++ b/api/service/patientFamily.go @@ -31,7 +31,7 @@ func (r *PatientFamilyService) GetPatientFamilyListByPatientId(patientId int64) item := &patientFamilyResponse.PatientFamily{ FamilyId: fmt.Sprintf("%d", v.FamilyId), PatientId: fmt.Sprintf("%d", v.PatientId), - Relation: &v.Relation, + Relation: v.Relation, Status: &v.Status, IsDefault: &v.IsDefault, CardName: v.CardName, @@ -102,7 +102,7 @@ func (r *PatientFamilyService) GetPatientFamily(familyId int64) (getPatientFamil getPatientFamilyResponse = &patientFamilyResponse.GetPatientFamily{ FamilyId: fmt.Sprintf("%d", patientFamily.FamilyId), PatientId: fmt.Sprintf("%d", patientFamily.PatientId), - Relation: &patientFamily.Relation, + Relation: patientFamily.Relation, Status: &patientFamily.Status, IsDefault: &patientFamily.IsDefault, CardName: patientFamily.CardName,