新增获取就诊人详情
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"hospital-admin-api/api/dao"
|
||||
)
|
||||
|
||||
type UserService struct {
|
||||
}
|
||||
|
||||
// GetUserCardNum 获取用户身份证号
|
||||
func (r *UserService) GetUserCardNum(userId, familyId int64) (string, error) {
|
||||
var cardNum string
|
||||
|
||||
// 获取用户数据
|
||||
userDao := dao.UserDao{}
|
||||
user, err := userDao.GetUserById(userId)
|
||||
if err != nil || user == nil {
|
||||
return "", errors.New("用户错误")
|
||||
}
|
||||
|
||||
// 判断用户类型
|
||||
if user.UserType == 1 {
|
||||
// 患者
|
||||
if familyId == 0 {
|
||||
return "", errors.New("获取失败")
|
||||
}
|
||||
|
||||
patientFamilyDao := dao.PatientFamilyDao{}
|
||||
patientFamily, err := patientFamilyDao.GetPatientFamilyById(familyId)
|
||||
if err != nil || patientFamily == nil {
|
||||
return "", errors.New("获取失败")
|
||||
}
|
||||
|
||||
cardNum = patientFamily.IdNumber
|
||||
} else if user.UserType == 2 {
|
||||
// 医生
|
||||
userDoctorInfoDao := dao.UserDoctorInfoDao{}
|
||||
userDoctorInfo, err := userDoctorInfoDao.GetUserDoctorInfoByUserId(userId)
|
||||
if err != nil || userDoctorInfo == nil {
|
||||
return "", errors.New("获取失败")
|
||||
}
|
||||
|
||||
cardNum = userDoctorInfo.CardNum
|
||||
} else if user.UserType == 3 {
|
||||
// 药师
|
||||
cardNum = "暂时未做"
|
||||
}
|
||||
|
||||
return cardNum, nil
|
||||
}
|
||||
|
||||
// GetUserBankNumByDoctorId 获取银行卡号
|
||||
func (r *UserService) GetUserBankNumByDoctorId(doctorId int64) (string, error) {
|
||||
// 获取用户数据
|
||||
doctorBankCardDao := dao.DoctorBankCardDao{}
|
||||
doctorBankCard, err := doctorBankCardDao.GetDoctorBankCardByDoctorId(doctorId)
|
||||
if err != nil || doctorBankCard == nil {
|
||||
return "", errors.New("错误数据")
|
||||
}
|
||||
|
||||
return doctorBankCard.BankCardCode, nil
|
||||
}
|
||||
@@ -14,11 +14,11 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type UserService struct {
|
||||
type AdminUserService struct {
|
||||
}
|
||||
|
||||
// AddUser 新增用户
|
||||
func (r *UserService) AddUser(c *gin.Context, AddUserRequest requests.AddUser) (bool, error) {
|
||||
func (r *AdminUserService) AddUser(c *gin.Context, AddUserRequest requests.AddUser) (bool, error) {
|
||||
// 当前登陆用户id
|
||||
loginUserId := c.GetInt64("UserId")
|
||||
if loginUserId == 0 {
|
||||
@@ -127,7 +127,7 @@ func (r *UserService) AddUser(c *gin.Context, AddUserRequest requests.AddUser) (
|
||||
}
|
||||
|
||||
// DeleteUser 删除用户-批量
|
||||
func (r *UserService) DeleteUser(c *gin.Context, DeleteUserRequest requests.DeleteUser) (bool, error) {
|
||||
func (r *AdminUserService) DeleteUser(c *gin.Context, DeleteUserRequest requests.DeleteUser) (bool, error) {
|
||||
// 获取当前登陆用户数据
|
||||
userId := c.GetInt64("UserId")
|
||||
if userId == 0 {
|
||||
@@ -188,7 +188,7 @@ func (r *UserService) DeleteUser(c *gin.Context, DeleteUserRequest requests.Dele
|
||||
}
|
||||
|
||||
// PutUser 修改用户
|
||||
func (r *UserService) PutUser(c *gin.Context, requestUserId int64, putUserRequest requests.PutUser) (bool, error) {
|
||||
func (r *AdminUserService) PutUser(c *gin.Context, requestUserId int64, putUserRequest requests.PutUser) (bool, error) {
|
||||
// 获取当前登陆用户数据
|
||||
loginUserId := c.GetInt64("UserId")
|
||||
if loginUserId == 0 {
|
||||
@@ -325,7 +325,7 @@ func (r *UserService) PutUser(c *gin.Context, requestUserId int64, putUserReques
|
||||
}
|
||||
|
||||
// PutUserPassword 修改用户密码
|
||||
func (r *UserService) PutUserPassword(requestUserId int64, putUserPasswordRequest requests.PutUserPassword) (bool, error) {
|
||||
func (r *AdminUserService) PutUserPassword(requestUserId int64, putUserPasswordRequest requests.PutUserPassword) (bool, error) {
|
||||
adminUserDao := dao.AdminUserDao{}
|
||||
|
||||
// 获取需修改用户数据
|
||||
@@ -397,57 +397,3 @@ func (r *UserService) PutUserPassword(requestUserId int64, putUserPasswordReques
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// GetUserCardNum 获取用户身份证号
|
||||
func (r *UserService) GetUserCardNum(userId, familyId int64) (string, error) {
|
||||
var cardNum string
|
||||
|
||||
// 获取用户数据
|
||||
userDao := dao.UserDao{}
|
||||
user, err := userDao.GetUserById(userId)
|
||||
if err != nil || user == nil {
|
||||
return "", errors.New("用户错误")
|
||||
}
|
||||
|
||||
// 判断用户类型
|
||||
if user.UserType == 1 {
|
||||
// 患者
|
||||
if familyId == 0 {
|
||||
return "", errors.New("获取失败")
|
||||
}
|
||||
|
||||
patientFamilyDao := dao.PatientFamilyDao{}
|
||||
patientFamily, err := patientFamilyDao.GetPatientFamilyById(familyId)
|
||||
if err != nil || patientFamily == nil {
|
||||
return "", errors.New("获取失败")
|
||||
}
|
||||
|
||||
cardNum = patientFamily.IdNumber
|
||||
} else if user.UserType == 2 {
|
||||
// 医生
|
||||
userDoctorInfoDao := dao.UserDoctorInfoDao{}
|
||||
userDoctorInfo, err := userDoctorInfoDao.GetUserDoctorInfoByUserId(userId)
|
||||
if err != nil || userDoctorInfo == nil {
|
||||
return "", errors.New("获取失败")
|
||||
}
|
||||
|
||||
cardNum = userDoctorInfo.CardNum
|
||||
} else if user.UserType == 3 {
|
||||
// 药师
|
||||
cardNum = "暂时未做"
|
||||
}
|
||||
|
||||
return cardNum, nil
|
||||
}
|
||||
|
||||
// GetUserBankNumByDoctorId 获取银行卡号
|
||||
func (r *UserService) GetUserBankNumByDoctorId(doctorId int64) (string, error) {
|
||||
// 获取用户数据
|
||||
doctorBankCardDao := dao.DoctorBankCardDao{}
|
||||
doctorBankCard, err := doctorBankCardDao.GetDoctorBankCardByDoctorId(doctorId)
|
||||
if err != nil || doctorBankCard == nil {
|
||||
return "", errors.New("错误数据")
|
||||
}
|
||||
|
||||
return doctorBankCard.BankCardCode, nil
|
||||
}
|
||||
@@ -1,9 +1,13 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/responses/patientFamilyResponse"
|
||||
"hospital-admin-api/api/responses/userResponse"
|
||||
"hospital-admin-api/utils"
|
||||
)
|
||||
|
||||
type PatientFamilyService struct {
|
||||
@@ -63,3 +67,68 @@ func (r *PatientFamilyService) GetPatientFamilyListByPatientId(patientId int64)
|
||||
|
||||
return items, nil
|
||||
}
|
||||
|
||||
// GetPatientFamily 家庭成员详情
|
||||
func (r *PatientFamilyService) GetPatientFamily(familyId int64) (getPatientFamilyResponse *patientFamilyResponse.GetPatientFamily, err error) {
|
||||
patientFamilyDao := dao.PatientFamilyDao{}
|
||||
patientFamily, err := patientFamilyDao.GetPatientFamilyById(familyId)
|
||||
if err != nil || patientFamily == nil {
|
||||
return nil, errors.New("就诊人错误")
|
||||
}
|
||||
|
||||
// 获取患者数据
|
||||
userPatientDao := dao.UserPatientDao{}
|
||||
userPatient, err := userPatientDao.GetUserPatientPreloadById(patientFamily.PatientId)
|
||||
if err != nil || userPatient == nil {
|
||||
return nil, errors.New("患者错误")
|
||||
}
|
||||
|
||||
// 获取用户数据
|
||||
userDao := dao.UserDao{}
|
||||
user, err := userDao.GetUserById(userPatient.UserId)
|
||||
if err != nil || user == nil {
|
||||
return nil, errors.New("用户错误")
|
||||
}
|
||||
|
||||
var userData *userResponse.User
|
||||
if userPatient.User != nil {
|
||||
userData = userResponse.UserResponse(user)
|
||||
|
||||
// 加密患者手机号
|
||||
userData.Mobile = utils.MaskPhoneStr(userData.Mobile)
|
||||
userData.WxMobile = utils.MaskPhoneStr(userData.WxMobile)
|
||||
}
|
||||
|
||||
getPatientFamilyResponse = &patientFamilyResponse.GetPatientFamily{
|
||||
FamilyId: fmt.Sprintf("%d", patientFamily.FamilyId),
|
||||
PatientId: fmt.Sprintf("%d", patientFamily.PatientId),
|
||||
Relation: &patientFamily.Relation,
|
||||
Status: &patientFamily.Status,
|
||||
IsDefault: &patientFamily.IsDefault,
|
||||
CardName: patientFamily.CardName,
|
||||
CardNameMask: patientFamily.CardNameMask,
|
||||
MobileMask: patientFamily.MobileMask,
|
||||
Type: &patientFamily.Type,
|
||||
IdNumberMask: patientFamily.IdNumberMask,
|
||||
Sex: &patientFamily.Sex,
|
||||
Age: patientFamily.Age,
|
||||
ProvinceId: fmt.Sprintf("%d", patientFamily.ProvinceId),
|
||||
Province: patientFamily.Province,
|
||||
CityId: fmt.Sprintf("%d", patientFamily.CityId),
|
||||
City: patientFamily.City,
|
||||
CountyId: fmt.Sprintf("%d", patientFamily.CountyId),
|
||||
County: patientFamily.County,
|
||||
Height: patientFamily.Height,
|
||||
Weight: patientFamily.Weight,
|
||||
MaritalStatus: &patientFamily.MaritalStatus,
|
||||
NationId: fmt.Sprintf("%d", patientFamily.NationId),
|
||||
NationName: patientFamily.NationName,
|
||||
JobId: fmt.Sprintf("%d", patientFamily.JobId),
|
||||
JobName: patientFamily.JobName,
|
||||
User: userData,
|
||||
CreatedAt: model.LocalTime{},
|
||||
UpdatedAt: model.LocalTime{},
|
||||
}
|
||||
|
||||
return getPatientFamilyResponse, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user