陈少旭 9 months ago
parent
commit
d0e65cbc5a
2 changed files with 729 additions and 708 deletions
  1. 711 679
      controllers/sg/his_api_controller.go
  2. 18 29
      service/his_service.go

File diff suppressed because it is too large
+ 711 - 679
controllers/sg/his_api_controller.go


+ 18 - 29
service/his_service.go View File

531
 	return
531
 	return
532
 }
532
 }
533
 
533
 
534
-func FindLastPatientPrescriptionInfoTwo2(org_id int64, patient_id int64,start_time string, end_time string) (info []models.HisPrescriptionInfo, err error) {
535
-	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND patient_id = ? and p_type = 1 and FROM_UNIXTIME(record_date) >= ? and FROM_UNIXTIME(record_date) <= ?", org_id, patient_id,start_time,end_time).Find(&info).Error
534
+func FindLastPatientPrescriptionInfoTwo2(org_id int64, patient_id int64, start_time string, end_time string) (info []models.HisPrescriptionInfo, err error) {
535
+	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND patient_id = ? and p_type = 1 and FROM_UNIXTIME(record_date) >= ? and FROM_UNIXTIME(record_date) <= ?", org_id, patient_id, start_time, end_time).Find(&info).Error
536
 	return
536
 	return
537
 }
537
 }
538
 
538
 
618
 	PrivatePrice            float64 `gorm:"column:private_price" json:"private_price" form:"private_price"`
618
 	PrivatePrice            float64 `gorm:"column:private_price" json:"private_price" form:"private_price"`
619
 	Creator                 int64   `gorm:"column:creator" json:"creator" form:"creator"`
619
 	Creator                 int64   `gorm:"column:creator" json:"creator" form:"creator"`
620
 	Modify                  int64   `gorm:"column:modify" json:"modify" form:"modify"`
620
 	Modify                  int64   `gorm:"column:modify" json:"modify" form:"modify"`
621
-	MedType                  int64   `gorm:"column:med_type" json:"med_type" form:"med_type"`
621
+	MedType                 int64   `gorm:"column:med_type" json:"med_type" form:"med_type"`
622
 	IsPre                   int64   `gorm:"column:is_pre" json:"is_pre" form:"is_pre"`
622
 	IsPre                   int64   `gorm:"column:is_pre" json:"is_pre" form:"is_pre"`
623
 	SzChargeInfo            string  `gorm:"column:sz_charge_info" json:"sz_charge_info" form:"sz_charge_info"`
623
 	SzChargeInfo            string  `gorm:"column:sz_charge_info" json:"sz_charge_info" form:"sz_charge_info"`
624
 	SzProjectInfo           string  `gorm:"column:sz_project_info" json:"sz_project_info" form:"sz_project_info"`
624
 	SzProjectInfo           string  `gorm:"column:sz_project_info" json:"sz_project_info" form:"sz_project_info"`
627
 	OrgSetlNumber           string  `gorm:"column:org_setl_number" json:"org_setl_number" form:"org_setl_number"`
627
 	OrgSetlNumber           string  `gorm:"column:org_setl_number" json:"org_setl_number" form:"org_setl_number"`
628
 	PayWays                 string  `gorm:"column:pay_ways" json:"pay_way" form:"pay_ways"`
628
 	PayWays                 string  `gorm:"column:pay_ways" json:"pay_way" form:"pay_ways"`
629
 	OthDesc                 string  `gorm:"column:oth_desc" json:"oth_desc" form:"oth_desc"`
629
 	OthDesc                 string  `gorm:"column:oth_desc" json:"oth_desc" form:"oth_desc"`
630
-	SetlDetail              string    `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
630
+	SetlDetail              string  `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
631
 
631
 
632
 	HisOrderInfo        models.HisOrderInfo        `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
632
 	HisOrderInfo        models.HisOrderInfo        `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
633
 	Patients            models.Patients            `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
633
 	Patients            models.Patients            `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
1011
 	}
1011
 	}
1012
 	if len(clr_type) > 0 {
1012
 	if len(clr_type) > 0 {
1013
 		if mdtrtareaAdmvs == "150499" {
1013
 		if mdtrtareaAdmvs == "150499" {
1014
-			if clr_type == "11"  {
1014
+			if clr_type == "11" {
1015
 				db = db.Where("clr_type = ?", clr_type)
1015
 				db = db.Where("clr_type = ?", clr_type)
1016
 			}
1016
 			}
1017
 
1017
 
1020
 			db = db.Where("clr_type = ?", clr_type)
1020
 			db = db.Where("clr_type = ?", clr_type)
1021
 		}
1021
 		}
1022
 	} else {
1022
 	} else {
1023
-		if len(clr_type) == 0{
1023
+		if len(clr_type) == 0 {
1024
 			db = db.Where("clr_type = ?", "")
1024
 			db = db.Where("clr_type = ?", "")
1025
 
1025
 
1026
-		}else{
1026
+		} else {
1027
 			db = db.Where("clr_type = ?", "9903")
1027
 			db = db.Where("clr_type = ?", "9903")
1028
 
1028
 
1029
 		}
1029
 		}
1061
 	return
1061
 	return
1062
 }
1062
 }
1063
 
1063
 
1064
-
1065
 func GetOrderByTime11222(start_time int64, end_time int64, org_id int64) (orders []*models.HisOrder, err error) {
1064
 func GetOrderByTime11222(start_time int64, end_time int64, org_id int64) (orders []*models.HisOrder, err error) {
1066
 	db := readDb.Model(&models.HisOrder{})
1065
 	db := readDb.Model(&models.HisOrder{})
1067
 	db = db.Where("user_org_id = ? AND status = 1 AND order_status = 2 AND is_medicine_insurance = 1 AND UNIX_TIMESTAMP(setl_time)  <= ? AND UNIX_TIMESTAMP(setl_time) >= ?", org_id, end_time, start_time)
1066
 	db = db.Where("user_org_id = ? AND status = 1 AND order_status = 2 AND is_medicine_insurance = 1 AND UNIX_TIMESTAMP(setl_time)  <= ? AND UNIX_TIMESTAMP(setl_time) >= ?", org_id, end_time, start_time)
1071
 
1070
 
1072
 func GetOrderByTimeFourfor11(start_time int64, end_time int64, org_id int64) (orders []*models.HisOrder, err error) {
1071
 func GetOrderByTimeFourfor11(start_time int64, end_time int64, org_id int64) (orders []*models.HisOrder, err error) {
1073
 	db := readDb.Model(&models.HisOrder{})
1072
 	db := readDb.Model(&models.HisOrder{})
1074
-db = db.Where("user_org_id = ? AND status = 1 AND order_status = 2 AND is_medicine_insurance = 1 AND UNIX_TIMESTAMP(setl_time)  <= ? AND UNIX_TIMESTAMP(setl_time) >= ? and med_type = 11", org_id, end_time, start_time)
1073
+	db = db.Where("user_org_id = ? AND status = 1 AND order_status = 2 AND is_medicine_insurance = 1 AND UNIX_TIMESTAMP(setl_time)  <= ? AND UNIX_TIMESTAMP(setl_time) >= ? and med_type = 11", org_id, end_time, start_time)
1075
 	err = db.Find(&orders).Error
1074
 	err = db.Find(&orders).Error
1076
 	return
1075
 	return
1077
 }
1076
 }
1078
 
1077
 
1079
-
1080
 func GetOrderByTimeThree(start_time int64, end_time int64, org_id int64, insutype string, clr_type string) (orders []*models.HisOrder, err error) {
1078
 func GetOrderByTimeThree(start_time int64, end_time int64, org_id int64, insutype string, clr_type string) (orders []*models.HisOrder, err error) {
1081
 	err = readDb.Model(&models.HisOrder{}).Where("user_org_id = ? AND status = 1  AND is_medicine_insurance = 1 AND UNIX_TIMESTAMP(setl_time) <= ? AND UNIX_TIMESTAMP(setl_time) >= ? AND insutype = ?", org_id, end_time, start_time, insutype).Find(&orders).Error
1079
 	err = readDb.Model(&models.HisOrder{}).Where("user_org_id = ? AND status = 1  AND is_medicine_insurance = 1 AND UNIX_TIMESTAMP(setl_time) <= ? AND UNIX_TIMESTAMP(setl_time) >= ? AND insutype = ?", org_id, end_time, start_time, insutype).Find(&orders).Error
1082
 	return
1080
 	return
1334
 
1332
 
1335
 	err = db.Where("status = 1 and user_org_id = ?", org_id).Find(&project).Error
1333
 	err = db.Where("status = 1 and user_org_id = ?", org_id).Find(&project).Error
1336
 
1334
 
1337
-
1338
 	return project, err
1335
 	return project, err
1339
 }
1336
 }
1340
 func GetBatchDoctorList(idss []int64) (role []*models.SgjUserAdminRole, err error) {
1337
 func GetBatchDoctorList(idss []int64) (role []*models.SgjUserAdminRole, err error) {
1374
 	return
1371
 	return
1375
 }
1372
 }
1376
 
1373
 
1377
-
1378
 func GetHisPatientInfoList(org_id int64, patient_id int64, record_date int64) (info []*models.HisPatient, err error) {
1374
 func GetHisPatientInfoList(org_id int64, patient_id int64, record_date int64) (info []*models.HisPatient, err error) {
1379
 	err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).Find(&info).Error
1375
 	err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).Find(&info).Error
1380
 	return
1376
 	return
1558
 	return
1554
 	return
1559
 }
1555
 }
1560
 
1556
 
1561
-
1562
 func GetAllHisOrder10265() (his []*models.HisOrder, err error) {
1557
 func GetAllHisOrder10265() (his []*models.HisOrder, err error) {
1563
 	err = readDb.Model(&models.HisOrder{}).Where(" user_org_id = 10265  AND status = 1  AND  order_status = 2 AND setl_id <> ''  AND setl_time >= '2023-09-01 00:00:00'").Order("setl_time asc").Find(&his).Error
1558
 	err = readDb.Model(&models.HisOrder{}).Where(" user_org_id = 10265  AND status = 1  AND  order_status = 2 AND setl_id <> ''  AND setl_time >= '2023-09-01 00:00:00'").Order("setl_time asc").Find(&his).Error
1564
 	fmt.Println(err)
1559
 	fmt.Println(err)
1565
 	return
1560
 	return
1566
 }
1561
 }
1567
 
1562
 
1568
-
1569
 //	func GetAllHisOrder2(org_id int64) (his []models.HisOrder, err error) {
1563
 //	func GetAllHisOrder2(org_id int64) (his []models.HisOrder, err error) {
1570
 //		err = readDb.Model(&models.HisOrder{}).Where("id = 180753").Order("setl_time asc").First(&his).Error
1564
 //		err = readDb.Model(&models.HisOrder{}).Where("id = 180753").Order("setl_time asc").First(&his).Error
1571
 //		return
1565
 //		return
1667
 	return
1661
 	return
1668
 }
1662
 }
1669
 
1663
 
1670
-//
1671
-func Saveflow(flow models.HisPrescriptionFlow){
1664
+func Saveflow(flow models.HisPrescriptionFlow) {
1672
 	writeDb.Save(&flow)
1665
 	writeDb.Save(&flow)
1673
 }
1666
 }
1674
 
1667
 
1668
+func Createflow(flow models.HisPrescriptionFlow) {
1669
+	writeDb.Create(&flow)
1670
+}
1675
 
1671
 
1676
-
1677
-func GetNewHisPrescriptionTenone(org_id int64,number string) (prescription []*models.HisPrescriptionTen, err error) {
1672
+func GetNewHisPrescriptionTenone(org_id int64, number string) (prescription []*models.HisPrescriptionTen, err error) {
1678
 	err = readDb.Model(&models.HisPrescriptionTen{}).
1673
 	err = readDb.Model(&models.HisPrescriptionTen{}).
1679
 		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1674
 		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1680
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("BaseDrugLib", "status=1")
1675
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("BaseDrugLib", "status=1")
1688
 }
1683
 }
1689
 
1684
 
1690
 func GetHisOrderByIDThree(start_time string) (his []*models.HisOrder, err error) {
1685
 func GetHisOrderByIDThree(start_time string) (his []*models.HisOrder, err error) {
1691
-	err = readDb.Model(&models.HisOrder{}).Where(" user_org_id = 10265  AND status = 1  AND  order_status = 2 AND setl_id <> ''  AND setl_time >= ?",start_time).Order("setl_time asc").Find(&his).Error
1686
+	err = readDb.Model(&models.HisOrder{}).Where(" user_org_id = 10265  AND status = 1  AND  order_status = 2 AND setl_id <> ''  AND setl_time >= ?", start_time).Order("setl_time asc").Find(&his).Error
1692
 	fmt.Println(err)
1687
 	fmt.Println(err)
1693
 	return
1688
 	return
1694
 }
1689
 }
1695
 
1690
 
1696
-
1697
-
1698
-func UpDatePrescriptionNumber111(user_org_id int64, start_time int64, end_time int64, number string,patient_id int64) (err error) {
1699
-	err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND status = 1 AND record_date >= ? and record_date <= ? and patient_id = ? and order_status = 1", user_org_id, start_time,end_time,patient_id).Updates(map[string]interface{}{"batch_number": number, "mtime": time.Now().Unix()}).Error
1691
+func UpDatePrescriptionNumber111(user_org_id int64, start_time int64, end_time int64, number string, patient_id int64) (err error) {
1692
+	err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND status = 1 AND record_date >= ? and record_date <= ? and patient_id = ? and order_status = 1", user_org_id, start_time, end_time, patient_id).Updates(map[string]interface{}{"batch_number": number, "mtime": time.Now().Unix()}).Error
1700
 	return
1693
 	return
1701
 }
1694
 }
1702
-func UpDatePrescriptionNumber222(user_org_id int64,id int64, number string,patient_id int64) (err error) {
1703
-	err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND status = 1 AND id = ? and patient_id = ?", user_org_id, id,patient_id).Updates(map[string]interface{}{"batch_number": number, "mtime": time.Now().Unix()}).Error
1695
+func UpDatePrescriptionNumber222(user_org_id int64, id int64, number string, patient_id int64) (err error) {
1696
+	err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND status = 1 AND id = ? and patient_id = ?", user_org_id, id, patient_id).Updates(map[string]interface{}{"batch_number": number, "mtime": time.Now().Unix()}).Error
1704
 	return
1697
 	return
1705
 }
1698
 }
1706
 
1699
 
1707
-
1708
-
1709
-
1710
-
1711
 func GetAllHisOrderTwo10485() (his []*models.HisOrder, err error) {
1700
 func GetAllHisOrderTwo10485() (his []*models.HisOrder, err error) {
1712
 	err = readDb.Model(&models.HisOrder{}).Where("user_org_id = 10485  AND status = 1  AND  order_status = 2 AND setl_id <> '' AND  setl_time >= '2024-01-01 00:00:00' ").Order("setl_time asc").Find(&his).Error
1701
 	err = readDb.Model(&models.HisOrder{}).Where("user_org_id = 10485  AND status = 1  AND  order_status = 2 AND setl_id <> '' AND  setl_time >= '2024-01-01 00:00:00' ").Order("setl_time asc").Find(&his).Error
1713
 	fmt.Println(err)
1702
 	fmt.Println(err)