Browse Source

提交代码

陈少旭 1 year ago
parent
commit
d1b6d40804
2 changed files with 55 additions and 10 deletions
  1. 29 5
      controllers/his_api_controller.go
  2. 26 5
      service/his_service.go

+ 29 - 5
controllers/his_api_controller.go View File

@@ -797,6 +797,8 @@ func (c *PublicApiController) GetBaiLinExportData() {
797 797
 
798 798
 func (c *HisApiController) GetHisUnChargePatientList() {
799 799
 	record_date := c.GetString("record_date")
800
+	sch_type, _ := c.GetInt64("sch_type")
801
+
800 802
 	timeLayout := "2006-01-02"
801 803
 	loc, _ := time.LoadLocation("Local")
802 804
 	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
@@ -808,7 +810,7 @@ func (c *HisApiController) GetHisUnChargePatientList() {
808 810
 	adminInfo := c.GetAdminUserInfo()
809 811
 	var tempPatients []*service.NewTempPatients
810 812
 	//tempPatients, _ := service.GetAllChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
811
-	tempPatients, _ = service.GetNewAllUnChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
813
+	tempPatients, _ = service.GetNewAllUnChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime, sch_type)
812 814
 	var patients []*service.NewTempPatients
813 815
 	var patients_two []*service.NewTempPatients
814 816
 
@@ -6806,6 +6808,26 @@ func (c *HisApiController) GetUploadInfo() {
6806 6808
 
6807 6809
 	dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
6808 6810
 	tmp_decimal := c.GetString("tmp_decimal")
6811
+
6812
+	//last_order, _ := service.GetLastHisOrderThree(c.GetAdminUserInfo().CurrentOrgId)
6813
+	max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
6814
+	count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
6815
+	fmt.Println(count)
6816
+	var zero string
6817
+	number := count + 1
6818
+	if number >= 1000 {
6819
+		zero = "0000" + strconv.FormatInt(number, 10)
6820
+	} else if number >= 10000 {
6821
+		zero = "000" + strconv.FormatInt(number, 10)
6822
+	} else if number >= 100000 {
6823
+		zero = "00" + strconv.FormatInt(number, 10)
6824
+	} else if number >= 1000000 {
6825
+		zero = "0" + strconv.FormatInt(number, 10)
6826
+	} else {
6827
+		zero = strconv.FormatInt(number, 10)
6828
+	}
6829
+	fapiao_number = zero
6830
+
6809 6831
 	var decimal float64 //本次使用的押金
6810 6832
 	var errmsg error
6811 6833
 	tx := service.XTWriteDB().Begin() //开了事务
@@ -7699,6 +7721,7 @@ func (this *HisApiController) GetHisDayPrescription() {
7699 7721
 func (c *HisApiController) GetHisChargePatientList() {
7700 7722
 	record_date := c.GetString("record_date")
7701 7723
 	order_status, _ := c.GetInt64("type")
7724
+	sch_type, _ := c.GetInt64("sch_type")
7702 7725
 
7703 7726
 	timeLayout := "2006-01-02"
7704 7727
 	loc, _ := time.LoadLocation("Local")
@@ -7712,9 +7735,9 @@ func (c *HisApiController) GetHisChargePatientList() {
7712 7735
 	var tempPatients []*service.NewTempPatients
7713 7736
 	//tempPatients, _ := service.GetAllChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
7714 7737
 	if order_status != 2 {
7715
-		tempPatients, _ = service.GetNewAllUnChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
7738
+		tempPatients, _ = service.GetNewAllUnChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime, sch_type)
7716 7739
 	} else {
7717
-		tempPatients, _ = service.GetNewAllChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
7740
+		tempPatients, _ = service.GetNewAllChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime, sch_type)
7718 7741
 	}
7719 7742
 
7720 7743
 	var patients []*service.NewTempPatients
@@ -8876,8 +8899,9 @@ func (c *HisApiController) GetFaPiaoData() {
8876 8899
 	admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
8877 8900
 
8878 8901
 	c.ServeSuccessJSON(map[string]interface{}{
8879
-		"order_number":                        order.Number,             //业务流水号
8880
-		"id_card_no":                          his.IdCardNo,             //社会保障号
8902
+		"order_number":                        order.Number, //业务流水号
8903
+		"id_card_no":                          his.IdCardNo, //社会保障号
8904
+		"patient":                             patient,
8881 8905
 		"department_name":                     department.Name,          //科室
8882 8906
 		"number":                              his.Number,               //门诊号
8883 8907
 		"date":                                order.SettleAccountsDate, //结算日期

+ 26 - 5
service/his_service.go View File

@@ -2116,8 +2116,13 @@ func (NewTempPatients) TableName() string {
2116 2116
 
2117 2117
 //"VMHisOrder", "user_org_id = ? AND status = 1 AND settle_accounts_date = ?", org_id, record_date
2118 2118
 
2119
-func GetNewAllUnChargeHisPatientList(org_id int64, keywords string, record_date int64) (patients []*NewTempPatients, err error) {
2120
-	db := readDb.Model(&NewTempPatients{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
2119
+func GetNewAllUnChargeHisPatientList(org_id int64, keywords string, record_date int64, sch_type int64) (patients []*NewTempPatients, err error) {
2120
+	db := readDb.Model(&NewTempPatients{})
2121
+	//if sch_type > 0 {
2122
+	//	db = db.Joins("join xt_schedule as sch on sch.patient_id = xt_patients.id and sch.schedule_date = ? and sch.schedule_type = ?", record_date, sch_type)
2123
+	//}
2124
+	db = db.Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
2125
+	db = db.Preload("Schedule", "status = 1")
2121 2126
 	db = db.Preload("HisPatient", func(db *gorm.DB) *gorm.DB {
2122 2127
 		return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", org_id, record_date).Preload("VMHisOrders", "user_org_id = ? AND status = 1 AND settle_accounts_date = ?", org_id, record_date)
2123 2128
 	})
@@ -2136,13 +2141,19 @@ func GetNewAllUnChargeHisPatientList(org_id int64, keywords string, record_date
2136 2141
 	return
2137 2142
 }
2138 2143
 
2139
-func GetNewAllChargeHisPatientList(org_id int64, keywords string, record_date int64) (patients []*NewTempPatients, err error) {
2140
-	db := readDb.Model(&NewTempPatients{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
2144
+func GetNewAllChargeHisPatientList(org_id int64, keywords string, record_date int64, sch_type int64) (patients []*NewTempPatients, err error) {
2145
+	db := readDb.Model(&NewTempPatients{})
2146
+
2147
+	//if sch_type > 0 {
2148
+	//	db = db.Joins("join xt_schedule as sch on sch.patient_id = xt_patients.id and sch.schedule_date = ? and sch.schedule_type = ?", record_date, sch_type)
2149
+	//}
2150
+	db = db.Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
2151
+	db = db.Preload("Schedule", "status = 1")
2141 2152
 	db = db.Preload("HisPatient", func(db *gorm.DB) *gorm.DB {
2142 2153
 		return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", org_id, record_date).Preload("VMHisOrders", "user_org_id = ? AND status = 1 AND settle_accounts_date = ? ", org_id, record_date)
2143 2154
 	})
2144 2155
 	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1 AND order_status = 2", org_id, record_date)
2145
-	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1", org_id, record_date).Find(&patients).Error
2156
+	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1", org_id, record_date).Find(&patients).Group("xt_patients.id").Error
2146 2157
 
2147 2158
 	for _, item := range patients {
2148 2159
 		for _, sumItem := range item.HisPatient {
@@ -2840,3 +2851,13 @@ func GetHisPrescriptionByBatchNumber(org_id int64, number string) (prescription
2840 2851
 		Find(&prescription).Error
2841 2852
 	return
2842 2853
 }
2854
+
2855
+func GetLastHisOrderThree(org_id int64) (err error, o models.HisOrder) {
2856
+	err = readDb.Model(&models.HisOrder{}).Where("user_org_id = ? and status = 1 and order_status = 2", org_id).First(&o).Error
2857
+	return
2858
+}
2859
+
2860
+func GetLastHisOrderTwo(org_id int64) (his models.HisOrder, err error) {
2861
+	err = readDb.Model(&models.HisOrder{}).Select("max(convert(fa_piao_number,signed)) as fa_piao_number").Where("user_org_id = ? AND status = 1 AND order_status = 2 ", org_id).Find(&his).Error
2862
+	return
2863
+}