新增获取就诊人列表-分页
This commit is contained in:
parent
913e1647fb
commit
9d21730305
@ -44,7 +44,8 @@ type order struct {
|
|||||||
|
|
||||||
// 患者管理
|
// 患者管理
|
||||||
type userPatientManage struct {
|
type userPatientManage struct {
|
||||||
UserPatient // 患者列表
|
UserPatient // 患者列表
|
||||||
|
PatientFamily // 家庭成员管理
|
||||||
}
|
}
|
||||||
|
|
||||||
// 病例管理
|
// 病例管理
|
||||||
|
|||||||
81
api/controller/patientFamily.go
Normal file
81
api/controller/patientFamily.go
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
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/patientFamilyResponse"
|
||||||
|
"hospital-admin-api/api/service"
|
||||||
|
"hospital-admin-api/global"
|
||||||
|
"hospital-admin-api/utils"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PatientFamily struct{}
|
||||||
|
|
||||||
|
// GetPatientFamilyPage 获取就诊人列表-分页
|
||||||
|
func (r *PatientFamily) GetPatientFamilyPage(c *gin.Context) {
|
||||||
|
req := requests.PatientFamilyRequest{}
|
||||||
|
if err := c.ShouldBind(&req.GetPatientFamilyPage); err != nil {
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 参数验证
|
||||||
|
if err := global.Validate.Struct(req.GetPatientFamilyPage); err != nil {
|
||||||
|
responses.FailWithMessage(utils.Translate(err), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.GetPatientFamilyPage.Page == 0 {
|
||||||
|
req.GetPatientFamilyPage.Page = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.GetPatientFamilyPage.PageSize == 0 {
|
||||||
|
req.GetPatientFamilyPage.PageSize = 20
|
||||||
|
}
|
||||||
|
|
||||||
|
patientFamilyDao := dao.PatientFamilyDao{}
|
||||||
|
patientFamily, total, err := patientFamilyDao.GetPatientFamilyPageSearch(req.GetPatientFamilyPage, req.GetPatientFamilyPage.Page, req.GetPatientFamilyPage.PageSize)
|
||||||
|
if err != nil {
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理返回值
|
||||||
|
GetPatientFamilyPage := patientFamilyResponse.GetPatientFamilyPageResponse(patientFamily)
|
||||||
|
|
||||||
|
result := make(map[string]interface{})
|
||||||
|
result["page"] = req.GetPatientFamilyPage.Page
|
||||||
|
result["page_size"] = req.GetPatientFamilyPage.PageSize
|
||||||
|
result["total"] = total
|
||||||
|
result["data"] = GetPatientFamilyPage
|
||||||
|
responses.OkWithData(result, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserPatient 患者详情
|
||||||
|
func (r *PatientFamily) GetUserPatient(c *gin.Context) {
|
||||||
|
id := c.Param("patient_id")
|
||||||
|
if id == "" {
|
||||||
|
responses.FailWithMessage("缺少参数", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将 id 转换为 int64 类型
|
||||||
|
patientId, err := strconv.ParseInt(id, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
responses.Fail(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 业务处理
|
||||||
|
userPatientService := service.UserPatientService{}
|
||||||
|
getUserPatientResponses, err := userPatientService.GetUserPatient(patientId)
|
||||||
|
if err != nil {
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
responses.OkWithData(getUserPatientResponses, c)
|
||||||
|
}
|
||||||
@ -80,3 +80,41 @@ func (r *UserPatient) GetUserPatient(c *gin.Context) {
|
|||||||
|
|
||||||
responses.OkWithData(getUserPatientResponses, c)
|
responses.OkWithData(getUserPatientResponses, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PutUserDoctorStatus 修改患者状态
|
||||||
|
func (r *UserPatient) PutUserDoctorStatus(c *gin.Context) {
|
||||||
|
userPatientRequest := requests.UserPatientRequest{}
|
||||||
|
if err := c.ShouldBind(&userPatientRequest.PutUserDoctorStatus); err != nil {
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 参数验证
|
||||||
|
if err := global.Validate.Struct(userPatientRequest.PutUserDoctorStatus); err != nil {
|
||||||
|
responses.FailWithMessage(utils.Translate(err), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
id := c.Param("patient_id")
|
||||||
|
if id == "" {
|
||||||
|
responses.FailWithMessage("缺少参数", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将 id 转换为 int64 类型
|
||||||
|
patientId, err := strconv.ParseInt(id, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
responses.Fail(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 业务处理
|
||||||
|
userPatientService := service.UserPatientService{}
|
||||||
|
_, err = userPatientService.PutUserDoctorStatus(patientId, userPatientRequest.PutUserDoctorStatus)
|
||||||
|
if err != nil {
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
responses.Ok(c)
|
||||||
|
}
|
||||||
|
|||||||
@ -3,7 +3,10 @@ package dao
|
|||||||
import (
|
import (
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"hospital-admin-api/api/model"
|
"hospital-admin-api/api/model"
|
||||||
|
"hospital-admin-api/api/requests"
|
||||||
"hospital-admin-api/global"
|
"hospital-admin-api/global"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PatientFamilyDao struct {
|
type PatientFamilyDao struct {
|
||||||
@ -79,3 +82,77 @@ func (r *PatientFamilyDao) AddPatientFamilyByMap(tx *gorm.DB, data map[string]in
|
|||||||
}
|
}
|
||||||
return userDoctorInfo, nil
|
return userDoctorInfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetPatientFamilyPageSearch 获取家庭成员列表-分页
|
||||||
|
func (r *PatientFamilyDao) GetPatientFamilyPageSearch(req requests.GetPatientFamilyPage, page, pageSize int) (m []*model.PatientFamily, total int64, err error) {
|
||||||
|
var totalRecords int64
|
||||||
|
|
||||||
|
// 构建查询条件
|
||||||
|
query := global.Db.Model(&model.PatientFamily{}).Select("family_id", "patient_id", "relation", "status", "card_name", "mobile_mask", "created_at")
|
||||||
|
|
||||||
|
// 患者表
|
||||||
|
query = query.Preload("UserPatient", func(db *gorm.DB) *gorm.DB {
|
||||||
|
return db.Omit("open_id", "union_id", "wx_session_key")
|
||||||
|
})
|
||||||
|
|
||||||
|
// 状态
|
||||||
|
if req.Status != nil {
|
||||||
|
query = query.Where("status = ?", req.Status)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 手机号
|
||||||
|
if req.Mobile != "" {
|
||||||
|
userSubQuery := global.Db.Model(&model.User{}).
|
||||||
|
Select("user_id").
|
||||||
|
Where("mobile = ?", req.Mobile)
|
||||||
|
|
||||||
|
userPatientSubQuery := global.Db.Model(&model.UserPatient{}).
|
||||||
|
Select("patient_id").
|
||||||
|
Where(gorm.Expr("user_id IN (?)", userSubQuery))
|
||||||
|
|
||||||
|
query = query.Where(gorm.Expr("patient_id IN (?)", userPatientSubQuery))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 用户名称-用户-就诊人
|
||||||
|
if req.UserName != "" {
|
||||||
|
// 用户
|
||||||
|
patientFamilySubQuery := global.Db.Model(&model.UserPatient{}).
|
||||||
|
Select("patient_id").
|
||||||
|
Where("user_name LIKE ?", "%"+req.UserName+"%")
|
||||||
|
|
||||||
|
// 就诊人
|
||||||
|
query = query.Where("card_name LIKE ?", "%"+req.UserName+"%")
|
||||||
|
|
||||||
|
query = query.Or("patient_id IN (?)", patientFamilySubQuery).Or(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 注册时间
|
||||||
|
if req.CreatedAt != "" {
|
||||||
|
cancelTime := strings.Split(req.CreatedAt, "&")
|
||||||
|
if len(cancelTime) == 2 {
|
||||||
|
startTime, _ := time.Parse("2006-01-02", cancelTime[0])
|
||||||
|
endTime, _ := time.Parse("2006-01-02", cancelTime[1])
|
||||||
|
|
||||||
|
if startTime == endTime {
|
||||||
|
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
|
query = query.Where("created_at 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
|
||||||
|
}
|
||||||
|
|||||||
@ -6,6 +6,8 @@ import (
|
|||||||
"hospital-admin-api/api/model"
|
"hospital-admin-api/api/model"
|
||||||
"hospital-admin-api/api/requests"
|
"hospital-admin-api/api/requests"
|
||||||
"hospital-admin-api/global"
|
"hospital-admin-api/global"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserPatientDao struct {
|
type UserPatientDao struct {
|
||||||
@ -92,7 +94,7 @@ func (r *UserPatientDao) GetUserPatientPageSearch(req requests.GetUserPatientPag
|
|||||||
if req.Mobile != "" {
|
if req.Mobile != "" {
|
||||||
subQuery := global.Db.Model(&model.User{}).
|
subQuery := global.Db.Model(&model.User{}).
|
||||||
Select("user_id").
|
Select("user_id").
|
||||||
Where("mobile LIKE ?", "%"+req.Mobile+"%")
|
Where("mobile = ?", req.Mobile)
|
||||||
|
|
||||||
query = query.Where(gorm.Expr("user_id IN (?)", subQuery))
|
query = query.Where(gorm.Expr("user_id IN (?)", subQuery))
|
||||||
}
|
}
|
||||||
@ -115,6 +117,21 @@ func (r *UserPatientDao) GetUserPatientPageSearch(req requests.GetUserPatientPag
|
|||||||
query = query.Where("status = ?", req.Status)
|
query = query.Where("status = ?", req.Status)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 注册时间
|
||||||
|
if req.CreatedAt != "" {
|
||||||
|
cancelTime := strings.Split(req.CreatedAt, "&")
|
||||||
|
if len(cancelTime) == 2 {
|
||||||
|
startTime, _ := time.Parse("2006-01-02", cancelTime[0])
|
||||||
|
endTime, _ := time.Parse("2006-01-02", cancelTime[1])
|
||||||
|
|
||||||
|
if startTime == endTime {
|
||||||
|
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
|
query = query.Where("created_at BETWEEN ? AND ?", startTime, endTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 排序
|
// 排序
|
||||||
query = query.Order("created_at desc")
|
query = query.Order("created_at desc")
|
||||||
|
|
||||||
|
|||||||
@ -8,33 +8,34 @@ import (
|
|||||||
|
|
||||||
// PatientFamily 患者家庭成员信息表-基本信息
|
// PatientFamily 患者家庭成员信息表-基本信息
|
||||||
type PatientFamily struct {
|
type PatientFamily struct {
|
||||||
FamilyId int64 `gorm:"column:family_id;type:bigint(19);primary_key;comment:主键id" json:"family_id"`
|
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"`
|
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"`
|
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"`
|
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"`
|
CardName string `gorm:"column:card_name;type:varchar(50);comment:姓名" json:"card_name"`
|
||||||
CardNameMask string `gorm:"column:card_name_mask;type:varchar(50);comment:姓名(掩码)" json:"card_name_mask"`
|
CardNameMask string `gorm:"column:card_name_mask;type:varchar(50);comment:姓名(掩码)" json:"card_name_mask"`
|
||||||
Mobile string `gorm:"column:mobile;type:varchar(20);comment:电话" json:"mobile"`
|
Mobile string `gorm:"column:mobile;type:varchar(20);comment:电话" json:"mobile"`
|
||||||
MobileMask string `gorm:"column:mobile_mask;type:varchar(20);comment:电话(掩码)" json:"mobile_mask"`
|
MobileMask string `gorm:"column:mobile_mask;type:varchar(20);comment:电话(掩码)" json:"mobile_mask"`
|
||||||
Type int `gorm:"column:type;type:tinyint(1);default:1;comment:身份类型(1:身份证 2:护照 3:港澳通行证 4:台胞证)" json:"type"`
|
Type int `gorm:"column:type;type:tinyint(1);default:1;comment:身份类型(1:身份证 2:护照 3:港澳通行证 4:台胞证)" json:"type"`
|
||||||
IdNumber string `gorm:"column:id_number;type:varchar(30);comment:证件号码" json:"id_number"`
|
IdNumber string `gorm:"column:id_number;type:varchar(30);comment:证件号码" json:"id_number"`
|
||||||
IdNumberMask string `gorm:"column:id_number_mask;type:varchar(30);comment:证件号码(掩码)" json:"id_number_mask"`
|
IdNumberMask string `gorm:"column:id_number_mask;type:varchar(30);comment:证件号码(掩码)" json:"id_number_mask"`
|
||||||
Sex int `gorm:"column:sex;type:tinyint(1);default:0;comment:性别(0:未知 1:男 2:女)" json:"sex"`
|
Sex int `gorm:"column:sex;type:tinyint(1);default:0;comment:性别(0:未知 1:男 2:女)" json:"sex"`
|
||||||
Age int `gorm:"column:age;type:int(11);comment:年龄" json:"age"`
|
Age int `gorm:"column:age;type:int(11);comment:年龄" json:"age"`
|
||||||
ProvinceId int `gorm:"column:province_id;type:int(11);comment:省份id" json:"province_id"`
|
ProvinceId int `gorm:"column:province_id;type:int(11);comment:省份id" json:"province_id"`
|
||||||
Province string `gorm:"column:province;type:varchar(50);comment:省份" json:"province"`
|
Province string `gorm:"column:province;type:varchar(50);comment:省份" json:"province"`
|
||||||
CityId int `gorm:"column:city_id;type:int(11);comment:城市id" json:"city_id"`
|
CityId int `gorm:"column:city_id;type:int(11);comment:城市id" json:"city_id"`
|
||||||
City string `gorm:"column:city;type:varchar(50);comment:城市" json:"city"`
|
City string `gorm:"column:city;type:varchar(50);comment:城市" json:"city"`
|
||||||
CountyId int `gorm:"column:county_id;type:int(11);comment:区县id" json:"county_id"`
|
CountyId int `gorm:"column:county_id;type:int(11);comment:区县id" json:"county_id"`
|
||||||
County string `gorm:"column:county;type:varchar(255);comment:区县" json:"county"`
|
County string `gorm:"column:county;type:varchar(255);comment:区县" json:"county"`
|
||||||
Height string `gorm:"column:height;type:varchar(100);comment:身高(cm)" json:"height"`
|
Height string `gorm:"column:height;type:varchar(100);comment:身高(cm)" json:"height"`
|
||||||
Weight string `gorm:"column:weight;type:varchar(100);comment:体重(kg)" json:"weight"`
|
Weight string `gorm:"column:weight;type:varchar(100);comment:体重(kg)" json:"weight"`
|
||||||
MaritalStatus int `gorm:"column:marital_status;type:tinyint(1);comment:婚姻状况(0:未婚 1:已婚 2:离异)" json:"marital_status"`
|
MaritalStatus int `gorm:"column:marital_status;type:tinyint(1);comment:婚姻状况(0:未婚 1:已婚 2:离异)" json:"marital_status"`
|
||||||
NationId int64 `gorm:"column:nation_id;type:bigint(19);comment:民族" json:"nation_id"`
|
NationId int64 `gorm:"column:nation_id;type:bigint(19);comment:民族" json:"nation_id"`
|
||||||
NationName string `gorm:"column:nation_name;type:varchar(50);comment:民族名称" json:"nation_name"`
|
NationName string `gorm:"column:nation_name;type:varchar(50);comment:民族名称" json:"nation_name"`
|
||||||
JobId int64 `gorm:"column:job_id;type:bigint(19);comment:职业" json:"job_id"`
|
JobId int64 `gorm:"column:job_id;type:bigint(19);comment:职业" json:"job_id"`
|
||||||
JobName string `gorm:"column:job_name;type:varchar(50);comment:职业名称" json:"job_name"`
|
JobName string `gorm:"column:job_name;type:varchar(50);comment:职业名称" json:"job_name"`
|
||||||
|
UserPatient *UserPatient `gorm:"foreignKey:PatientId;references:patient_id" json:"user_patient"` // 患者
|
||||||
Model
|
Model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
15
api/requests/patientFamily.go
Normal file
15
api/requests/patientFamily.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package requests
|
||||||
|
|
||||||
|
type PatientFamilyRequest struct {
|
||||||
|
GetPatientFamilyPage // 获取就诊人列表-分页
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPatientFamilyPage 获取就诊人列表-分页
|
||||||
|
type GetPatientFamilyPage struct {
|
||||||
|
Page int `json:"page" form:"page" label:"页码"`
|
||||||
|
PageSize int `json:"page_size" form:"page_size" label:"每页个数"`
|
||||||
|
UserName string `json:"user_name" form:"user_name" label:"用户名称"`
|
||||||
|
Status *int `json:"status" form:"status" label:"状态"` // (0:禁用 1:正常 2:删除)
|
||||||
|
Mobile string `json:"mobile" form:"mobile" label:"手机号"`
|
||||||
|
CreatedAt string `json:"created_at" form:"created_at" label:"添加时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||||
|
}
|
||||||
@ -1,7 +1,8 @@
|
|||||||
package requests
|
package requests
|
||||||
|
|
||||||
type UserPatientRequest struct {
|
type UserPatientRequest struct {
|
||||||
GetUserPatientPage // 获取患者列表-分页
|
GetUserPatientPage // 获取患者列表-分页
|
||||||
|
PutUserDoctorStatus // 修改患者状态
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUserPatientPage 获取患者列表-分页
|
// GetUserPatientPage 获取患者列表-分页
|
||||||
@ -11,5 +12,11 @@ type GetUserPatientPage struct {
|
|||||||
UserName string `json:"user_name" form:"user_name" label:"用户名称"`
|
UserName string `json:"user_name" form:"user_name" label:"用户名称"`
|
||||||
Status *int `json:"status" form:"status" label:"状态"` // (0:禁用 1:正常 2:删除)
|
Status *int `json:"status" form:"status" label:"状态"` // (0:禁用 1:正常 2:删除)
|
||||||
Mobile string `json:"mobile" form:"mobile" label:"手机号"`
|
Mobile string `json:"mobile" form:"mobile" label:"手机号"`
|
||||||
CreatedAt string `json:"created_at" form:"created_at" label:"订单创建时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
CreatedAt string `json:"created_at" form:"created_at" label:"注册时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// PutUserDoctorStatus 修改患者状态
|
||||||
|
type PutUserDoctorStatus struct {
|
||||||
|
Status int `json:"status" form:"status" validate:"oneof=0 1 2" label:"状态"` // (0:禁用 1:正常 2:删除)
|
||||||
|
DisableReason string `json:"disable_reason" form:"disable_reason" label:"禁用理由"`
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,6 +53,19 @@ type GetUserPatient struct {
|
|||||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取就诊人列表-分页
|
||||||
|
type getPatientFamilyPage struct {
|
||||||
|
FamilyId string `json:"family_id"` // 主键id
|
||||||
|
PatientId string `json:"patient_id"` // 患者id
|
||||||
|
Relation *int `json:"relation"` // 与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他)
|
||||||
|
Status *int `json:"status"` // 状态(1:正常 2:删除)
|
||||||
|
CardName string `json:"card_name"` // 姓名
|
||||||
|
MobileMask string `json:"mobile_mask"` // 电话(掩码)
|
||||||
|
UserName string `json:"user_name"` // 账号名称
|
||||||
|
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||||
|
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
// GetUserPatientResponse 获取患者详情
|
// GetUserPatientResponse 获取患者详情
|
||||||
func GetUserPatientResponse(patientFamilys []*model.PatientFamily) []*GetUserPatient {
|
func GetUserPatientResponse(patientFamilys []*model.PatientFamily) []*GetUserPatient {
|
||||||
// 处理返回值
|
// 处理返回值
|
||||||
@ -82,3 +95,31 @@ func GetUserPatientResponse(patientFamilys []*model.PatientFamily) []*GetUserPat
|
|||||||
|
|
||||||
return items
|
return items
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetPatientFamilyPageResponse 获取用户列表-分页
|
||||||
|
func GetPatientFamilyPageResponse(patientFamily []*model.PatientFamily) []getPatientFamilyPage {
|
||||||
|
// 处理返回值
|
||||||
|
patientFamilyResponses := make([]getPatientFamilyPage, len(patientFamily))
|
||||||
|
|
||||||
|
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,
|
||||||
|
Status: &v.Status,
|
||||||
|
CardName: v.CardName,
|
||||||
|
MobileMask: v.MobileMask,
|
||||||
|
UserName: v.UserPatient.UserName,
|
||||||
|
CreatedAt: v.CreatedAt,
|
||||||
|
UpdatedAt: v.UpdatedAt,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将转换后的结构体添加到新切片中
|
||||||
|
patientFamilyResponses[i] = patientFamilyResponse
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return patientFamilyResponses
|
||||||
|
}
|
||||||
|
|||||||
@ -422,22 +422,17 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
|||||||
patientGroup.GET("/:patient_id", api.UserPatient.GetUserPatient)
|
patientGroup.GET("/:patient_id", api.UserPatient.GetUserPatient)
|
||||||
|
|
||||||
// 修改患者状态
|
// 修改患者状态
|
||||||
patientGroup.PUT("/status/:patient_id", api.UserDoctor.GetUserDoctor)
|
patientGroup.PUT("/status/:patient_id", api.UserPatient.PutUserDoctorStatus)
|
||||||
|
|
||||||
// 就诊人管理
|
// 就诊人管理
|
||||||
patientFamilyGroup := doctorGroup.Group("/family")
|
patientFamilyGroup := patientGroup.Group("/family")
|
||||||
{
|
{
|
||||||
// 获取就诊人列表-分页
|
// 获取就诊人列表-分页
|
||||||
patientFamilyGroup.GET("", api.UserDoctor.GetUserDoctorPendingPage)
|
patientFamilyGroup.GET("", api.PatientFamily.GetPatientFamilyPage)
|
||||||
|
|
||||||
// 就诊人详情
|
// 就诊人详情
|
||||||
patientFamilyGroup.GET("/:family_id", api.UserDoctor.GetUserDoctorPending)
|
patientFamilyGroup.GET("/:family_id", api.UserDoctor.GetUserDoctorPending)
|
||||||
|
|
||||||
// 删除就诊人
|
|
||||||
patientFamilyGroup.DELETE("/:family_id", api.UserDoctor.PutUserDoctorPending)
|
|
||||||
|
|
||||||
// 修改就诊人状态
|
|
||||||
patientFamilyGroup.DELETE("/status/:family_id", api.UserDoctor.PutUserDoctorPending)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ type PatientFamilyService struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetPatientFamilyListByPatientId 获取患者家庭成员-患者id
|
// GetPatientFamilyListByPatientId 获取患者家庭成员-患者id
|
||||||
func (r *PatientFamilyService) GetPatientFamilyListByPatientId(patientId int64) (u []*patientFamilyResponse.GetUserPatient, err error) {
|
func (r *PatientFamilyService) GetPatientFamilyListByPatientId(patientId int64) (u []*patientFamilyResponse.PatientFamily, err error) {
|
||||||
patientFamilyDao := dao.PatientFamilyDao{}
|
patientFamilyDao := dao.PatientFamilyDao{}
|
||||||
patientFamilys, err := patientFamilyDao.GetPatientFamilyListByPatientId(patientId)
|
patientFamilys, err := patientFamilyDao.GetPatientFamilyListByPatientId(patientId)
|
||||||
|
|
||||||
@ -19,24 +19,41 @@ func (r *PatientFamilyService) GetPatientFamilyListByPatientId(patientId int64)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 处理返回值
|
// 处理返回值
|
||||||
items := make([]*patientFamilyResponse.GetUserPatient, len(patientFamilys))
|
items := make([]*patientFamilyResponse.PatientFamily, len(patientFamilys))
|
||||||
|
|
||||||
if len(patientFamilys) > 0 {
|
if len(patientFamilys) > 0 {
|
||||||
for i, v := range patientFamilys {
|
for i, v := range patientFamilys {
|
||||||
// 将原始结构体转换为新结构体
|
// 将原始结构体转换为新结构体
|
||||||
item := &patientFamilyResponse.GetUserPatient{
|
item := &patientFamilyResponse.PatientFamily{
|
||||||
FamilyId: fmt.Sprintf("%d", v.FamilyId),
|
FamilyId: fmt.Sprintf("%d", v.FamilyId),
|
||||||
PatientId: fmt.Sprintf("%d", v.PatientId),
|
PatientId: fmt.Sprintf("%d", v.PatientId),
|
||||||
Relation: &v.Relation,
|
Relation: &v.Relation,
|
||||||
Status: &v.Status,
|
Status: &v.Status,
|
||||||
IsDefault: &v.IsDefault,
|
IsDefault: &v.IsDefault,
|
||||||
CardNameMask: v.CardNameMask,
|
CardName: v.CardName,
|
||||||
MobileMask: v.MobileMask,
|
CardNameMask: v.CardNameMask,
|
||||||
IdNumberMask: v.IdNumberMask,
|
Mobile: v.Mobile,
|
||||||
Sex: &v.Sex,
|
MobileMask: v.MobileMask,
|
||||||
Age: v.Age,
|
Type: &v.Type,
|
||||||
CreatedAt: v.CreatedAt,
|
IdNumber: v.IdNumber,
|
||||||
UpdatedAt: v.UpdatedAt,
|
IdNumberMask: v.IdNumberMask,
|
||||||
|
Sex: &v.Sex,
|
||||||
|
Age: v.Age,
|
||||||
|
ProvinceId: fmt.Sprintf("%d", v.ProvinceId),
|
||||||
|
Province: v.Province,
|
||||||
|
CityId: fmt.Sprintf("%d", v.CityId),
|
||||||
|
City: v.City,
|
||||||
|
CountyId: fmt.Sprintf("%d", v.CountyId),
|
||||||
|
County: v.County,
|
||||||
|
Height: v.Height,
|
||||||
|
Weight: v.Weight,
|
||||||
|
MaritalStatus: &v.MaritalStatus,
|
||||||
|
NationId: fmt.Sprintf("%d", v.NationId),
|
||||||
|
NationName: v.NationName,
|
||||||
|
JobId: fmt.Sprintf("%d", v.JobId),
|
||||||
|
JobName: v.JobName,
|
||||||
|
CreatedAt: v.CreatedAt,
|
||||||
|
UpdatedAt: v.UpdatedAt,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 将转换后的结构体添加到新切片中
|
// 将转换后的结构体添加到新切片中
|
||||||
|
|||||||
@ -4,10 +4,12 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"hospital-admin-api/api/dao"
|
"hospital-admin-api/api/dao"
|
||||||
|
"hospital-admin-api/api/requests"
|
||||||
"hospital-admin-api/api/responses/patientFamilyResponse"
|
"hospital-admin-api/api/responses/patientFamilyResponse"
|
||||||
"hospital-admin-api/api/responses/userPatientResponse"
|
"hospital-admin-api/api/responses/userPatientResponse"
|
||||||
"hospital-admin-api/api/responses/userResponse"
|
"hospital-admin-api/api/responses/userResponse"
|
||||||
"hospital-admin-api/api/responses/userShipAddressResponse"
|
"hospital-admin-api/api/responses/userShipAddressResponse"
|
||||||
|
"hospital-admin-api/global"
|
||||||
"hospital-admin-api/utils"
|
"hospital-admin-api/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -56,3 +58,46 @@ func (r *UserPatientService) GetUserPatient(patientId int64) (getUserPatientResp
|
|||||||
|
|
||||||
return getUserPatientResponse, nil
|
return getUserPatientResponse, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PutUserDoctorStatus 修改患者状态
|
||||||
|
func (r *UserPatientService) PutUserDoctorStatus(patientId int64, req requests.PutUserDoctorStatus) (res bool, err error) {
|
||||||
|
// 获取患者数据
|
||||||
|
userPatientDao := dao.UserPatientDao{}
|
||||||
|
userPatient, err := userPatientDao.GetUserPatientPreloadById(patientId)
|
||||||
|
if err != nil || userPatient == nil {
|
||||||
|
return false, errors.New("患者错误")
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.Status == userPatient.Status {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.Status == 0 {
|
||||||
|
if req.DisableReason == "" {
|
||||||
|
return false, errors.New("请填写禁用理由")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 开始事务
|
||||||
|
tx := global.Db.Begin()
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// 修改部门
|
||||||
|
data := make(map[string]interface{})
|
||||||
|
data["status"] = req.Status
|
||||||
|
data["disable_reason"] = req.DisableReason
|
||||||
|
|
||||||
|
err = userPatientDao.EditUserPatientById(tx, patientId, data)
|
||||||
|
if err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New("修改失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
tx.Commit()
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user