新增问诊病例接口查询,修改问诊订单详情问诊病例返回数据
This commit is contained in:
parent
744fb8d067
commit
a0b7726115
65
api/dao/inquiryCaseProduct.go
Normal file
65
api/dao/inquiryCaseProduct.go
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"hospital-admin-api/api/model"
|
||||||
|
"hospital-admin-api/global"
|
||||||
|
)
|
||||||
|
|
||||||
|
type InquiryCaseProductDao struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *InquiryCaseProductDao) DeleteInquiryCaseProduct(tx *gorm.DB, maps interface{}) error {
|
||||||
|
err := tx.Where(maps).Delete(&model.InquiryCaseProduct{}).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *InquiryCaseProductDao) GetInquiryCaseProductListByInquiryCaseId(inquiryCaseId int64) (m []*model.InquiryCaseProduct, err error) {
|
||||||
|
err = global.Db.Where("inquiry_case_id = ?", inquiryCaseId).Find(&m).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *InquiryCaseProductDao) EditInquiryCaseProduct(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||||
|
err := tx.Model(&model.InquiryCaseProduct{}).Where(maps).Updates(data).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *InquiryCaseProductDao) EditInquiryCaseProductById(tx *gorm.DB, caseProductId int64, data interface{}) error {
|
||||||
|
err := tx.Model(&model.InquiryCaseProduct{}).Where("case_product_id = ?", caseProductId).Updates(data).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *InquiryCaseProductDao) GetInquiryCaseProductList(maps interface{}) (m []*model.InquiryCaseProduct, err error) {
|
||||||
|
err = global.Db.Where(maps).Find(&m).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *InquiryCaseProductDao) AddInquiryCaseProduct(tx *gorm.DB, model *model.InquiryCaseProduct) (*model.InquiryCaseProduct, error) {
|
||||||
|
if err := tx.Create(model).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return model, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *InquiryCaseProductDao) AddInquiryCaseProductByMap(tx *gorm.DB, data map[string]interface{}) (*model.InquiryCaseProduct, error) {
|
||||||
|
userDoctorInfo := &model.InquiryCaseProduct{}
|
||||||
|
if err := tx.Model(&model.InquiryCaseProduct{}).Create(data).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return userDoctorInfo, nil
|
||||||
|
}
|
||||||
@ -198,6 +198,10 @@ func (r *UserDoctorDao) GetUserDoctorPageSearch(getUserDoctorPage requests.GetUs
|
|||||||
query = query.Where("is_platform_deep_cooperation = ?", getUserDoctorPage.IsPlatformDeepCooperation)
|
query = query.Where("is_platform_deep_cooperation = ?", getUserDoctorPage.IsPlatformDeepCooperation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if getUserDoctorPage.IsSysDiagnoCooperation != nil {
|
||||||
|
query = query.Where("is_sys_diagno_cooperation = ?", getUserDoctorPage.IsSysDiagnoCooperation)
|
||||||
|
}
|
||||||
|
|
||||||
// 查询总数量
|
// 查询总数量
|
||||||
if err := query.Count(&totalRecords).Error; err != nil {
|
if err := query.Count(&totalRecords).Error; err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
|
|||||||
34
api/model/inquiryCaseProduct.go
Normal file
34
api/model/inquiryCaseProduct.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"hospital-admin-api/global"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// InquiryCaseProduct 问诊病例-用药意向表
|
||||||
|
type InquiryCaseProduct struct {
|
||||||
|
CaseProductId int64 `gorm:"column:case_product_id;type:bigint(19);primary_key;comment:主键id" json:"case_product_id"`
|
||||||
|
InquiryCaseId int64 `gorm:"column:inquiry_case_id;type:bigint(19);comment:病例id" json:"inquiry_case_id"`
|
||||||
|
ProductId int64 `gorm:"column:product_id;type:bigint(19);comment:商品id" json:"product_id"`
|
||||||
|
CaseProductNum int `gorm:"column:case_product_num;type:int(11);default:1;comment:药品数量" json:"case_product_num"`
|
||||||
|
Model
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *InquiryCaseProduct) TableName() string {
|
||||||
|
return "gdxz_inquiry_case_product"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *InquiryCaseProduct) BeforeCreate(tx *gorm.DB) error {
|
||||||
|
if m.CaseProductId == 0 {
|
||||||
|
m.CaseProductId = global.Snowflake.Generate().Int64()
|
||||||
|
}
|
||||||
|
|
||||||
|
m.CreatedAt = LocalTime(time.Now())
|
||||||
|
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
||||||
|
|
||||||
|
m.UpdatedAt = LocalTime(time.Now())
|
||||||
|
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@ -22,7 +22,7 @@ type OrderInquiryCase struct {
|
|||||||
DiseaseClassName string `json:"disease_class_name"` // 疾病名称-系统
|
DiseaseClassName string `json:"disease_class_name"` // 疾病名称-系统
|
||||||
DiagnosisDate model.LocalTime `json:"diagnosis_date"` // 确诊日期
|
DiagnosisDate model.LocalTime `json:"diagnosis_date"` // 确诊日期
|
||||||
DiseaseDesc string `json:"disease_desc"` // 病情描述(主诉)
|
DiseaseDesc string `json:"disease_desc"` // 病情描述(主诉)
|
||||||
DiagnoseImages string `json:"diagnose_images"` // 复诊凭证(多个使用逗号分隔)
|
DiagnoseImages []*string `json:"diagnose_images"` // 复诊凭证(多个使用逗号分隔)
|
||||||
IsAllergyHistory *int `json:"is_allergy_history"` // 是否存在过敏史(0:否 1:是)
|
IsAllergyHistory *int `json:"is_allergy_history"` // 是否存在过敏史(0:否 1:是)
|
||||||
AllergyHistory string `json:"allergy_history"` // 过敏史描述
|
AllergyHistory string `json:"allergy_history"` // 过敏史描述
|
||||||
IsFamilyHistory *int `json:"is_family_history"` // 是否存在家族病史(0:否 1:是)
|
IsFamilyHistory *int `json:"is_family_history"` // 是否存在家族病史(0:否 1:是)
|
||||||
@ -39,6 +39,7 @@ type OrderInquiryCase struct {
|
|||||||
ChemicalCompoundDescribe string `json:"chemical_compound_describe"` // 化合物描述
|
ChemicalCompoundDescribe string `json:"chemical_compound_describe"` // 化合物描述
|
||||||
IsOperation *int `json:"is_operation"` // 是否存在手术(0:否 1:是)
|
IsOperation *int `json:"is_operation"` // 是否存在手术(0:否 1:是)
|
||||||
Operation string `json:"operation"` // 手术描述
|
Operation string `json:"operation"` // 手术描述
|
||||||
|
Product []*string `json:"product"` // 用药意向
|
||||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,9 +2,12 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"hospital-admin-api/api/dao"
|
"hospital-admin-api/api/dao"
|
||||||
"hospital-admin-api/api/responses/orderInquiryCaseResponse"
|
"hospital-admin-api/api/responses/orderInquiryCaseResponse"
|
||||||
|
"hospital-admin-api/utils"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CaseService 病例
|
// CaseService 病例
|
||||||
@ -27,6 +30,10 @@ func (r *CaseService) GetOrderInquiryCaseByInquiryCaseId(inquiryCaseId int64) (u
|
|||||||
patientFamilyPersonalDao := dao.PatientFamilyPersonalDao{}
|
patientFamilyPersonalDao := dao.PatientFamilyPersonalDao{}
|
||||||
patientFamilyPersonal, err := patientFamilyPersonalDao.GetPatientFamilyPersonalByFamilyId(orderInquiryCase.FamilyId)
|
patientFamilyPersonal, err := patientFamilyPersonalDao.GetPatientFamilyPersonalByFamilyId(orderInquiryCase.FamilyId)
|
||||||
|
|
||||||
|
// 获取用药意向
|
||||||
|
inquiryCaseProductDao := dao.InquiryCaseProductDao{}
|
||||||
|
inquiryCaseProducts, err := inquiryCaseProductDao.GetInquiryCaseProductListByInquiryCaseId(orderInquiryCase.InquiryCaseId)
|
||||||
|
|
||||||
// 处理返回数据
|
// 处理返回数据
|
||||||
u = &orderInquiryCaseResponse.OrderInquiryCase{
|
u = &orderInquiryCaseResponse.OrderInquiryCase{
|
||||||
InquiryCaseId: strconv.FormatInt(orderInquiryCase.InquiryCaseId, 10),
|
InquiryCaseId: strconv.FormatInt(orderInquiryCase.InquiryCaseId, 10),
|
||||||
@ -45,7 +52,6 @@ func (r *CaseService) GetOrderInquiryCaseByInquiryCaseId(inquiryCaseId int64) (u
|
|||||||
DiseaseClassName: orderInquiryCase.DiseaseClassName,
|
DiseaseClassName: orderInquiryCase.DiseaseClassName,
|
||||||
DiagnosisDate: orderInquiryCase.DiagnosisDate,
|
DiagnosisDate: orderInquiryCase.DiagnosisDate,
|
||||||
DiseaseDesc: orderInquiryCase.DiseaseDesc,
|
DiseaseDesc: orderInquiryCase.DiseaseDesc,
|
||||||
DiagnoseImages: orderInquiryCase.DiagnoseImages,
|
|
||||||
IsAllergyHistory: orderInquiryCase.IsAllergyHistory,
|
IsAllergyHistory: orderInquiryCase.IsAllergyHistory,
|
||||||
AllergyHistory: orderInquiryCase.AllergyHistory,
|
AllergyHistory: orderInquiryCase.AllergyHistory,
|
||||||
IsFamilyHistory: orderInquiryCase.IsFamilyHistory,
|
IsFamilyHistory: orderInquiryCase.IsFamilyHistory,
|
||||||
@ -71,5 +77,38 @@ func (r *CaseService) GetOrderInquiryCaseByInquiryCaseId(inquiryCaseId int64) (u
|
|||||||
u.IsOperation = patientFamilyPersonal.IsOperation
|
u.IsOperation = patientFamilyPersonal.IsOperation
|
||||||
u.Operation = patientFamilyPersonal.Operation
|
u.Operation = patientFamilyPersonal.Operation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理复诊凭证
|
||||||
|
var diagnoseImages []*string
|
||||||
|
if orderInquiryCase.DiagnoseImages != "" {
|
||||||
|
diagnoseImages := strings.Split(orderInquiryCase.DiagnoseImages, ",")
|
||||||
|
|
||||||
|
for i, image := range diagnoseImages {
|
||||||
|
diagnoseImages[i] = utils.AddOssDomain(image)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
u.DiagnoseImages = diagnoseImages
|
||||||
|
|
||||||
|
// 处理用药意向
|
||||||
|
var product []*string
|
||||||
|
if inquiryCaseProducts != nil {
|
||||||
|
for i, inquiryCaseProduct := range inquiryCaseProducts {
|
||||||
|
// 获取商品数据
|
||||||
|
productDao := dao.ProductDao{}
|
||||||
|
productData, err := productDao.GetProductById(inquiryCaseProduct.CaseProductId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.New("数据错误")
|
||||||
|
}
|
||||||
|
|
||||||
|
caseProductNum := fmt.Sprintf("%d", inquiryCaseProduct.CaseProductNum)
|
||||||
|
productName := productData.ProductName + productData.ProductSpec + "(" + caseProductNum + productData.PackagingUnit + ")"
|
||||||
|
|
||||||
|
product[i] = &productName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
u.Product = product
|
||||||
|
|
||||||
return u, nil
|
return u, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,27 +24,11 @@ func (r *OrderInquiryCaseService) GetOrderInquiryCaseByOrderInquiryId(orderInqui
|
|||||||
PatientId: strconv.FormatInt(orderInquiryCase.PatientId, 10),
|
PatientId: strconv.FormatInt(orderInquiryCase.PatientId, 10),
|
||||||
OrderInquiryId: strconv.FormatInt(orderInquiryCase.OrderInquiryId, 10),
|
OrderInquiryId: strconv.FormatInt(orderInquiryCase.OrderInquiryId, 10),
|
||||||
FamilyId: strconv.FormatInt(orderInquiryCase.FamilyId, 10),
|
FamilyId: strconv.FormatInt(orderInquiryCase.FamilyId, 10),
|
||||||
Relation: orderInquiryCase.Relation,
|
|
||||||
Status: orderInquiryCase.Status,
|
|
||||||
Name: orderInquiryCase.Name,
|
Name: orderInquiryCase.Name,
|
||||||
Sex: orderInquiryCase.Sex,
|
Sex: orderInquiryCase.Sex,
|
||||||
Age: orderInquiryCase.Age,
|
Age: orderInquiryCase.Age,
|
||||||
Height: orderInquiryCase.Height,
|
|
||||||
Weight: orderInquiryCase.Weight,
|
|
||||||
DiseaseClassId: strconv.FormatInt(orderInquiryCase.DiseaseClassId, 10),
|
|
||||||
DiseaseClassName: orderInquiryCase.DiseaseClassName,
|
DiseaseClassName: orderInquiryCase.DiseaseClassName,
|
||||||
DiagnosisDate: orderInquiryCase.DiagnosisDate,
|
|
||||||
DiseaseDesc: orderInquiryCase.DiseaseDesc,
|
DiseaseDesc: orderInquiryCase.DiseaseDesc,
|
||||||
DiagnoseImages: orderInquiryCase.DiagnoseImages,
|
|
||||||
IsAllergyHistory: orderInquiryCase.IsAllergyHistory,
|
|
||||||
AllergyHistory: orderInquiryCase.AllergyHistory,
|
|
||||||
IsFamilyHistory: orderInquiryCase.IsFamilyHistory,
|
|
||||||
FamilyHistory: orderInquiryCase.FamilyHistory,
|
|
||||||
IsPregnant: orderInquiryCase.IsPregnant,
|
|
||||||
Pregnant: orderInquiryCase.Pregnant,
|
|
||||||
IsTaboo: orderInquiryCase.IsTaboo,
|
|
||||||
CreatedAt: orderInquiryCase.CreatedAt,
|
|
||||||
UpdatedAt: orderInquiryCase.UpdatedAt,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return u, nil
|
return u, nil
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user