新增获取就诊人列表-分页

This commit is contained in:
2023-09-18 16:48:22 +08:00
parent 913e1647fb
commit 9d21730305
12 changed files with 389 additions and 54 deletions
+32 -15
View File
@@ -10,7 +10,7 @@ type PatientFamilyService struct {
}
// 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{}
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 {
for i, v := range patientFamilys {
// 将原始结构体转换为新结构体
item := &patientFamilyResponse.GetUserPatient{
FamilyId: fmt.Sprintf("%d", v.FamilyId),
PatientId: fmt.Sprintf("%d", v.PatientId),
Relation: &v.Relation,
Status: &v.Status,
IsDefault: &v.IsDefault,
CardNameMask: v.CardNameMask,
MobileMask: v.MobileMask,
IdNumberMask: v.IdNumberMask,
Sex: &v.Sex,
Age: v.Age,
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
item := &patientFamilyResponse.PatientFamily{
FamilyId: fmt.Sprintf("%d", v.FamilyId),
PatientId: fmt.Sprintf("%d", v.PatientId),
Relation: &v.Relation,
Status: &v.Status,
IsDefault: &v.IsDefault,
CardName: v.CardName,
CardNameMask: v.CardNameMask,
Mobile: v.Mobile,
MobileMask: v.MobileMask,
Type: &v.Type,
IdNumber: v.IdNumber,
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,
}
// 将转换后的结构体添加到新切片中
+45
View File
@@ -4,10 +4,12 @@ import (
"errors"
"fmt"
"hospital-admin-api/api/dao"
"hospital-admin-api/api/requests"
"hospital-admin-api/api/responses/patientFamilyResponse"
"hospital-admin-api/api/responses/userPatientResponse"
"hospital-admin-api/api/responses/userResponse"
"hospital-admin-api/api/responses/userShipAddressResponse"
"hospital-admin-api/global"
"hospital-admin-api/utils"
)
@@ -56,3 +58,46 @@ func (r *UserPatientService) GetUserPatient(patientId int64) (getUserPatientResp
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
}