陈少旭 1 month ago
parent
commit
c2d7449900
3 changed files with 15 additions and 16 deletions
  1. 4 2
      controllers/sg/his_api_controller.go
  2. 7 10
      models/new_stock_models.go
  3. 4 4
      service/his_service.go

+ 4 - 2
controllers/sg/his_api_controller.go View File

3023
 	advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
3023
 	advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
3024
 	var flows []*models.DrugFlow
3024
 	var flows []*models.DrugFlow
3025
 	for _, item := range advicelist {
3025
 	for _, item := range advicelist {
3026
-		flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.ID, times, c.GetAdminUserInfo().CurrentOrgId)
3026
+		flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
3027
 		flows = append(flows, flow...)
3027
 		flows = append(flows, flow...)
3028
 	}
3028
 	}
3029
 	roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
3029
 	roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
4443
 
4443
 
4444
 	//ids := c.GetString("ids")
4444
 	//ids := c.GetString("ids")
4445
 	//id_arr := strings.Split(ids, ",")
4445
 	//id_arr := strings.Split(ids, ",")
4446
-	flows, _ := service.GetNewDrugFlowInforTen()
4446
+	now := time.Now()
4447
+	timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
4448
+	flows, _ := service.GetNewDrugFlowInforTen(timestamp)
4447
 	admin_user_id, _ := c.GetInt64("admin_user_id")
4449
 	admin_user_id, _ := c.GetInt64("admin_user_id")
4448
 	roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
4450
 	roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
4449
 	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
4451
 	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)

+ 7 - 10
models/new_stock_models.go View File

261
 	SecondWarehouseInfoId     int64  `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
261
 	SecondWarehouseInfoId     int64  `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
262
 	IsCheck                   int64  `gorm:"column:is_check" json:"is_check" form:"is_check"`
262
 	IsCheck                   int64  `gorm:"column:is_check" json:"is_check" form:"is_check"`
263
 
263
 
264
-	IsPc    int64  `gorm:"column:is_pc" json:"is_pc" form:"is_pc"`
265
-	IsBg    int64  `gorm:"column:is_bg" json:"is_bg" form:"is_bg"`
266
-	Bchno   string `gorm:"column:bchno" json:"bchno" form:"bchno"`
267
-	PcDate  int64 `gorm:"column:pc_date" json:"pc_date" form:"pc_date"`
268
-	BgBchno string `gorm:"column:bg_bchno" json:"bg_bchno" form:"bg_bchno"`
264
+	IsPc     int64  `gorm:"column:is_pc" json:"is_pc" form:"is_pc"`
265
+	IsBg     int64  `gorm:"column:is_bg" json:"is_bg" form:"is_bg"`
266
+	Bchno    string `gorm:"column:bchno" json:"bchno" form:"bchno"`
267
+	PcDate   int64  `gorm:"column:pc_date" json:"pc_date" form:"pc_date"`
268
+	BgBchno  string `gorm:"column:bg_bchno" json:"bg_bchno" form:"bg_bchno"`
269
 	DrugCode string `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
269
 	DrugCode string `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
270
-
271
 }
270
 }
272
 
271
 
273
 func (NewDrugWarehouseInfo) TableName() string {
272
 func (NewDrugWarehouseInfo) TableName() string {
424
 	LastStockMaxNumber        int64                `gorm:"column:last_stock_max_number" json:"last_stock_max_number" form:"last_stock_max_number"`
423
 	LastStockMaxNumber        int64                `gorm:"column:last_stock_max_number" json:"last_stock_max_number" form:"last_stock_max_number"`
425
 	LastStockMinNumber        int64                `gorm:"column:last_stock_min_number" json:"last_stock_min_number" form:"last_stock_min_number"`
424
 	LastStockMinNumber        int64                `gorm:"column:last_stock_min_number" json:"last_stock_min_number" form:"last_stock_min_number"`
426
 	AdviceId                  int64                `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
425
 	AdviceId                  int64                `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
427
-	HisDoctorAdviceInfo       HisDoctorAdviceInfo  `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"advice"`
426
+	HisDoctorAdviceInfo       HisDoctorAdviceInfo  `gorm:"ForeignKey:PatientID,RecordDate;AssociationForeignKey,DrugId:PatientID,SystemTime,DrugId" json:"advice"`
428
 	SupplyWarehouseId         int64                `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
427
 	SupplyWarehouseId         int64                `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
429
 	SupplyCancelOutId         int64                `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
428
 	SupplyCancelOutId         int64                `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
430
 	SupplyWarehouseDetailInfo int64                `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
429
 	SupplyWarehouseDetailInfo int64                `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
445
 	Bchno                     string               `gorm:"column:bchno" json:"bchno" form:"bchno"`
444
 	Bchno                     string               `gorm:"column:bchno" json:"bchno" form:"bchno"`
446
 	SaleDate                  string               `gorm:"column:sale_date" json:"sale_date" form:"sale_date"`
445
 	SaleDate                  string               `gorm:"column:sale_date" json:"sale_date" form:"sale_date"`
447
 	BgBchno                   string               `gorm:"column:bg_bchno" json:"bg_bchno" form:"bg_bchno"`
446
 	BgBchno                   string               `gorm:"column:bg_bchno" json:"bg_bchno" form:"bg_bchno"`
448
-	DrugCode 	string `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
449
-
450
-
447
+	DrugCode                  string               `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
451
 }
448
 }
452
 
449
 
453
 func (DrugFlow) TableName() string {
450
 func (DrugFlow) TableName() string {

+ 4 - 4
service/his_service.go View File

1739
 	return
1739
 	return
1740
 }
1740
 }
1741
 
1741
 
1742
-func GetNewDrugFlowInfoByPatient(patient_id int64, advice_id int64, time int64, org_id int64) (flows []*models.DrugFlow, err error) {
1743
-	err = readDb.Model(&models.DrugFlow{}).Where("user_org_id = ? and status = 1 and id in (?) and patinet_id = ? and advice_id = ? and system_time = ?", org_id, patient_id, advice_id, time).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1742
+func GetNewDrugFlowInfoByPatient(patient_id int64, advdrug_idice_id int64, time int64, org_id int64) (flows []*models.DrugFlow, err error) {
1743
+	err = readDb.Model(&models.DrugFlow{}).Where("user_org_id = ? and status = 1 and id in (?) and patinet_id = ? and drug_id = ? and system_time = ?", org_id, patient_id, drug_id, time).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1744
 		return db.Where("status = 1").Preload("BaseDrugLib", "status=1")
1744
 		return db.Where("status = 1").Preload("BaseDrugLib", "status=1")
1745
 	}).Preload("NewDrugWarehouseInfo", "status = 1").Find(&flows).Error
1745
 	}).Preload("NewDrugWarehouseInfo", "status = 1").Find(&flows).Error
1746
 	return
1746
 	return
1767
 	return
1767
 	return
1768
 }
1768
 }
1769
 
1769
 
1770
-func GetNewDrugFlowInforTen() (flows []*models.DrugFlow, err error) {
1771
-	err = readDb.Model(&models.DrugFlow{}).Where("user_org_id = 10318 and status = 1 and drug_code != '' and consumable_type = 3 and is_sale = 0").Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1770
+func GetNewDrugFlowInforTen(system_time int64) (flows []*models.DrugFlow, err error) {
1771
+	err = readDb.Model(&models.DrugFlow{}).Joins("join his_doctor_advice_info info on info.patient_id = xt_drug_flow.patient_id and info.drug_id = xt_drug_flow.drug_id and info.record_date = xt_drug_flow.system_time").Where("user_org_id = 10318 and status = 1 and consumable_type = 3 and is_sale = 0 and system_time = ?", system_time).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1772
 		return db.Where("status = 1").Preload("BaseDrugLib", "status=1")
1772
 		return db.Where("status = 1").Preload("BaseDrugLib", "status=1")
1773
 	}).Preload("NewDrugWarehouseInfo", "status = 1").Find(&flows).Error
1773
 	}).Preload("NewDrugWarehouseInfo", "status = 1").Find(&flows).Error
1774
 	return
1774
 	return