Browse Source

Merge branch '20230223_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20230223_xt_api_new_branch

28169 1 year ago
parent
commit
32359c8d72
2 changed files with 62 additions and 12 deletions
  1. 31 6
      controllers/his_api_controller.go
  2. 31 6
      service/his_service.go

+ 31 - 6
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
 
@@ -6201,6 +6203,7 @@ func (c *HisApiController) GetHisOrderList() {
6201 6203
 	charge_type, _ := c.GetInt64("charge_type", 0)
6202 6204
 	sch_type, _ := c.GetInt64("sch_type", 0)
6203 6205
 	zone_type, _ := c.GetInt64("zone_type", 0)
6206
+	med_type, _ := c.GetInt64("med_type", 0)
6204 6207
 
6205 6208
 	timeLayout := "2006-01-02"
6206 6209
 	loc, _ := time.LoadLocation("Local")
@@ -6227,7 +6230,7 @@ func (c *HisApiController) GetHisOrderList() {
6227 6230
 
6228 6231
 	adminUser := c.GetAdminUserInfo()
6229 6232
 	org_id := adminUser.CurrentOrgId
6230
-	order, err, total := service.GetHisOrderList(org_id, page, limit, startTime, endTime, types, keywords, p_type, sort_type, start_time, end_time, charge_type, sch_type, zone_type)
6233
+	order, err, total := service.GetHisOrderList(org_id, page, limit, startTime, endTime, types, keywords, p_type, sort_type, start_time, end_time, charge_type, sch_type, zone_type, med_type)
6231 6234
 
6232 6235
 	for _, item := range order {
6233 6236
 		info, _ := service.GetHisPrescriptionByPatientID(item.PatientId, item.UserOrgId)
@@ -6797,6 +6800,26 @@ func (c *HisApiController) GetUploadInfo() {
6797 6800
 
6798 6801
 	dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
6799 6802
 	tmp_decimal := c.GetString("tmp_decimal")
6803
+
6804
+	//last_order, _ := service.GetLastHisOrderThree(c.GetAdminUserInfo().CurrentOrgId)
6805
+	max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
6806
+	count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
6807
+	fmt.Println(count)
6808
+	var zero string
6809
+	number := count + 1
6810
+	if number >= 1000 {
6811
+		zero = "0000" + strconv.FormatInt(number, 10)
6812
+	} else if number >= 10000 {
6813
+		zero = "000" + strconv.FormatInt(number, 10)
6814
+	} else if number >= 100000 {
6815
+		zero = "00" + strconv.FormatInt(number, 10)
6816
+	} else if number >= 1000000 {
6817
+		zero = "0" + strconv.FormatInt(number, 10)
6818
+	} else {
6819
+		zero = strconv.FormatInt(number, 10)
6820
+	}
6821
+	fapiao_number = zero
6822
+
6800 6823
 	var decimal float64 //本次使用的押金
6801 6824
 	var errmsg error
6802 6825
 	tx := service.XTWriteDB().Begin() //开了事务
@@ -7690,6 +7713,7 @@ func (this *HisApiController) GetHisDayPrescription() {
7690 7713
 func (c *HisApiController) GetHisChargePatientList() {
7691 7714
 	record_date := c.GetString("record_date")
7692 7715
 	order_status, _ := c.GetInt64("type")
7716
+	sch_type, _ := c.GetInt64("sch_type")
7693 7717
 
7694 7718
 	timeLayout := "2006-01-02"
7695 7719
 	loc, _ := time.LoadLocation("Local")
@@ -7703,9 +7727,9 @@ func (c *HisApiController) GetHisChargePatientList() {
7703 7727
 	var tempPatients []*service.NewTempPatients
7704 7728
 	//tempPatients, _ := service.GetAllChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
7705 7729
 	if order_status != 2 {
7706
-		tempPatients, _ = service.GetNewAllUnChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
7730
+		tempPatients, _ = service.GetNewAllUnChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime, sch_type)
7707 7731
 	} else {
7708
-		tempPatients, _ = service.GetNewAllChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
7732
+		tempPatients, _ = service.GetNewAllChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime, sch_type)
7709 7733
 	}
7710 7734
 
7711 7735
 	var patients []*service.NewTempPatients
@@ -8867,8 +8891,9 @@ func (c *HisApiController) GetFaPiaoData() {
8867 8891
 	admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
8868 8892
 
8869 8893
 	c.ServeSuccessJSON(map[string]interface{}{
8870
-		"order_number":                        order.Number,             //业务流水号
8871
-		"id_card_no":                          his.IdCardNo,             //社会保障号
8894
+		"order_number":                        order.Number, //业务流水号
8895
+		"id_card_no":                          his.IdCardNo, //社会保障号
8896
+		"patient":                             patient,
8872 8897
 		"department_name":                     department.Name,          //科室
8873 8898
 		"number":                              his.Number,               //门诊号
8874 8899
 		"date":                                order.SettleAccountsDate, //结算日期

+ 31 - 6
service/his_service.go View File

@@ -975,7 +975,7 @@ func SavePatientPrescriptionInfo(info models.HisPrescriptionInfo) (err error) {
975 975
 	return
976 976
 }
977 977
 
978
-func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time_timestamp int64, end_time_timestamp int64, doctor_id int64, keywords string, p_type int64, sort_type int64, start_time string, end_time string, charge_type int64, sch_type int64, zone_type int64) (order []*models.HisOrder, err error, total int64) {
978
+func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time_timestamp int64, end_time_timestamp int64, doctor_id int64, keywords string, p_type int64, sort_type int64, start_time string, end_time string, charge_type int64, sch_type int64, zone_type int64, med_type int64) (order []*models.HisOrder, err error, total int64) {
979 979
 	offset := (page - 1) * limit
980 980
 	db := readDb.Model(&models.HisOrder{})
981 981
 
@@ -998,6 +998,10 @@ func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time_time
998 998
 		db = db.Joins("join xt_schedule sch on sch.schedule_date = his_order.settle_accounts_date AND sch.patient_id = his_order.patient_id  AND sch.schedule_date >= ? AND sch.schedule_date <= ? AND sch.partition_id = ? AND sch.status = 1", start_time_timestamp, end_time_timestamp, zone_type)
999 999
 	}
1000 1000
 
1001
+	if med_type > 0 {
1002
+		db = db.Where("his_order.med_type = ?", med_type)
1003
+	}
1004
+
1001 1005
 	//if zone_type > 0 {
1002 1006
 	//	db = db.Joins("join xt_schedule sch_two on sch_two.schedule_date = his_order.settle_accounts_date AND sch_two.patient_id = his_order.patient_id AND sch_two.partition_id = ?", zone_type)
1003 1007
 	//}
@@ -2116,8 +2120,13 @@ func (NewTempPatients) TableName() string {
2116 2120
 
2117 2121
 //"VMHisOrder", "user_org_id = ? AND status = 1 AND settle_accounts_date = ?", org_id, record_date
2118 2122
 
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)
2123
+func GetNewAllUnChargeHisPatientList(org_id int64, keywords string, record_date int64, sch_type int64) (patients []*NewTempPatients, err error) {
2124
+	db := readDb.Model(&NewTempPatients{})
2125
+	//if sch_type > 0 {
2126
+	//	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)
2127
+	//}
2128
+	db = db.Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
2129
+	db = db.Preload("Schedule", "status = 1")
2121 2130
 	db = db.Preload("HisPatient", func(db *gorm.DB) *gorm.DB {
2122 2131
 		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 2132
 	})
@@ -2136,13 +2145,19 @@ func GetNewAllUnChargeHisPatientList(org_id int64, keywords string, record_date
2136 2145
 	return
2137 2146
 }
2138 2147
 
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)
2148
+func GetNewAllChargeHisPatientList(org_id int64, keywords string, record_date int64, sch_type int64) (patients []*NewTempPatients, err error) {
2149
+	db := readDb.Model(&NewTempPatients{})
2150
+
2151
+	//if sch_type > 0 {
2152
+	//	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)
2153
+	//}
2154
+	db = db.Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
2155
+	db = db.Preload("Schedule", "status = 1")
2141 2156
 	db = db.Preload("HisPatient", func(db *gorm.DB) *gorm.DB {
2142 2157
 		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 2158
 	})
2144 2159
 	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
2160
+	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 2161
 
2147 2162
 	for _, item := range patients {
2148 2163
 		for _, sumItem := range item.HisPatient {
@@ -2840,3 +2855,13 @@ func GetHisPrescriptionByBatchNumber(org_id int64, number string) (prescription
2840 2855
 		Find(&prescription).Error
2841 2856
 	return
2842 2857
 }
2858
+
2859
+func GetLastHisOrderThree(org_id int64) (err error, o models.HisOrder) {
2860
+	err = readDb.Model(&models.HisOrder{}).Where("user_org_id = ? and status = 1 and order_status = 2", org_id).First(&o).Error
2861
+	return
2862
+}
2863
+
2864
+func GetLastHisOrderTwo(org_id int64) (his models.HisOrder, err error) {
2865
+	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
2866
+	return
2867
+}