csx il y a 2 ans
Parent
révision
b03932b058

+ 7 - 3
controllers/his_api_controller.go Voir le fichier

@@ -90,7 +90,6 @@ func HisManagerApiRegistRouters() {
90 90
 	beego.Router("/api/orders", &HisApiController{}, "get:GetAllOrder")
91 91
 
92 92
 	beego.Router("/api/psn/ncds/delete", &HisApiController{}, "post:DeleteNCDS")
93
-
94 93
 	beego.Router("/api/bailin/export", &PublicApiController{}, "get:GetBaiLinExportData")
95 94
 	beego.Router("/api/his/gethistdoctoradviceinfo", &HisApiController{}, "get:GetHisDoctorAdviceInfo")
96 95
 
@@ -3735,7 +3734,7 @@ func (c *HisApiController) GetHisOrderList() {
3735 3734
 
3736 3735
 	adminUser := c.GetAdminUserInfo()
3737 3736
 	org_id := adminUser.CurrentOrgId
3738
-	order, err, total := service.GetHisOrderList(org_id, page, limit, startTime, endTime, types, keywords, p_type, sort_type)
3737
+	order, err, total := service.GetHisOrderList(org_id, page, limit, startTime, endTime, types, keywords, p_type, sort_type, start_time, end_time)
3739 3738
 
3740 3739
 	for _, item := range order {
3741 3740
 		info, _ := service.GetHisPrescriptionByPatientID(item.PatientId, item.UserOrgId)
@@ -5107,6 +5106,8 @@ func (c *HisApiController) GetCompareData() {
5107 5106
 	start_time := c.GetString("start_time")
5108 5107
 	end_time := c.GetString("end_time")
5109 5108
 	insutype := c.GetString("insutype")
5109
+	clr_type := c.GetString("clr_type")
5110
+
5110 5111
 	timeLayout := "2006-01-02"
5111 5112
 	loc, _ := time.LoadLocation("Local")
5112 5113
 	var theStartTIme int64
@@ -5125,7 +5126,7 @@ func (c *HisApiController) GetCompareData() {
5125 5126
 		}
5126 5127
 		theEndtTIme = theTime.Unix()
5127 5128
 	}
5128
-	formData, err := service.GetCheckAccountFormData(theStartTIme, theEndtTIme, c.GetAdminUserInfo().CurrentOrgId, insutype)
5129
+	formData, err := service.GetCheckAccountFormData(theStartTIme, theEndtTIme, c.GetAdminUserInfo().CurrentOrgId, insutype, clr_type)
5129 5130
 	fmt.Println(err)
5130 5131
 	if err == nil {
5131 5132
 		c.ServeSuccessJSON(map[string]interface{}{
@@ -5153,6 +5154,8 @@ func (c *HisApiController) GetFaPiaoData() {
5153 5154
 
5154 5155
 	his, _ := service.GetHisPatientInfoThree(adminUser.CurrentOrgId, number)
5155 5156
 
5157
+	his_hospital_record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
5158
+
5156 5159
 	//prescriptions, _ := service.GetHisPrescriptionThree(adminUser.CurrentOrgId, patient_id, order.Number)
5157 5160
 
5158 5161
 	var bedCostTotal float64 = 0         //床位总费
@@ -5399,6 +5402,7 @@ func (c *HisApiController) GetFaPiaoData() {
5399 5402
 		"treatCostTotal":              treatCostTotal,
5400 5403
 		"treatCostSelfTotal":          treatCostSelfTotal,
5401 5404
 		"treatCostPartSelfTotal":      treatCostPartSelfTotal,
5405
+		"his_hospital_record":         his_hospital_record,
5402 5406
 	})
5403 5407
 
5404 5408
 }

+ 1 - 0
controllers/his_config_api_controller.go Voir le fichier

@@ -25,6 +25,7 @@ func HisConfigApiRegistRouters() {
25 25
 	beego.Router("/api/his/prescriptioninfotemplate/delete", &HisConfigApiController{}, "post:DeletePrescriptionInfoTemplate")
26 26
 	beego.Router("/api/his/advicetemplate/delete", &HisConfigApiController{}, "post:DeleteAdviceTemplate")
27 27
 	beego.Router("/api/his/projecttemplate/delete", &HisConfigApiController{}, "post:DeleteProjectTemplate")
28
+	//beego.Router("/api/his/responsibilitydoctor/get", &HisConfigApiController{}, "get:GetResponsibilityDoctor")
28 29
 
29 30
 }
30 31
 

+ 152 - 151
controllers/his_hospital_api_controller.go Voir le fichier

@@ -91,180 +91,181 @@ func (c *HisHospitalApiController) GetUploadInfo() {
91 91
 	for _, item := range prescriptions {
92 92
 		ids = append(ids, item.ID)
93 93
 	}
94
-	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
95
-	if config.IsOpen == 1 { //对接了医保,走医保流程
96
-
97
-		var customs []*models.NewCustom
98
-
99
-		for _, item := range prescriptions {
100
-			tm := time.Unix(item.PreTime, 0)
101
-			if item.Type == 1 { //药品
102
-				for _, subItem := range item.HisDoctorAdviceInfo {
103
-					if len(subItem.Drug.MedicalInsuranceNumber) > 0 && subItem.Drug.IsUser != 1 {
104
-						//var randNum int
105
-						//randNum = rand.Intn(10000) + 1000
94
+	//config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
95
+
96
+	var customs []*models.NewCustom
97
+
98
+	for _, item := range prescriptions {
99
+		tm := time.Unix(item.PreTime, 0)
100
+		if item.Type == 1 { //药品
101
+			for _, subItem := range item.HisDoctorAdviceInfo {
102
+				if len(subItem.Drug.MedicalInsuranceNumber) > 0 && subItem.Drug.IsUser != 1 {
103
+					//var randNum int
104
+					//randNum = rand.Intn(10000) + 1000
105
+					cus := &models.NewCustom{
106
+						DetItemFeeSumamt: subItem.Price * subItem.PrescribingNumber,
107
+						Cut:              subItem.PrescribingNumber,
108
+						FeedetlSn:        subItem.FeedetlSn,
109
+						Price:            subItem.Price,
110
+						MedListCodg:      subItem.Drug.MedicalInsuranceNumber,
111
+						HospApprFlag:     subItem.Drug.HospApprFlag,
112
+						FeeOcurTime:      tm.Format("2006-01-02 15:04:05"),
113
+					}
114
+
115
+					customs = append(customs, cus)
116
+				}
117
+			}
118
+		}
119
+
120
+		if item.Type == 2 { //项目
121
+			for _, subItem := range item.HisPrescriptionProject {
122
+				if subItem.Type == 2 {
123
+					if len(subItem.HisProject.MedicalCode) > 0 {
124
+						cnt, _ := strconv.ParseFloat(subItem.Count, 64)
106 125
 						cus := &models.NewCustom{
107
-							DetItemFeeSumamt: subItem.Price * subItem.PrescribingNumber,
108
-							Cut:              subItem.PrescribingNumber,
126
+							DetItemFeeSumamt: subItem.Price * cnt,
127
+							Cut:              cnt,
109 128
 							FeedetlSn:        subItem.FeedetlSn,
110
-							Price:            subItem.Price,
111
-							MedListCodg:      subItem.Drug.MedicalInsuranceNumber,
112
-							HospApprFlag:     subItem.Drug.HospApprFlag,
129
+							Price:            float64(subItem.Price),
130
+							MedListCodg:      subItem.HisProject.MedicalCode,
131
+							HospApprFlag:     -1,
113 132
 							FeeOcurTime:      tm.Format("2006-01-02 15:04:05"),
114 133
 						}
115
-
116 134
 						customs = append(customs, cus)
117 135
 					}
118
-				}
119
-			}
136
+				} else if subItem.Type == 3 {
137
+					if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 && subItem.GoodInfo.IsUser != 1 {
138
+						cnt, _ := strconv.ParseFloat(subItem.Count, 64)
120 139
 
121
-			if item.Type == 2 { //项目
122
-				for _, subItem := range item.HisPrescriptionProject {
123
-					if subItem.Type == 2 {
124
-						if len(subItem.HisProject.MedicalCode) > 0 {
125
-							cnt, _ := strconv.ParseFloat(subItem.Count, 64)
126
-							cus := &models.NewCustom{
127
-								DetItemFeeSumamt: subItem.Price * cnt,
128
-								Cut:              cnt,
129
-								FeedetlSn:        subItem.FeedetlSn,
130
-								Price:            float64(subItem.Price),
131
-								MedListCodg:      subItem.HisProject.MedicalCode,
132
-								HospApprFlag:     -1,
133
-								FeeOcurTime:      tm.Format("2006-01-02 15:04:05"),
134
-							}
135
-							customs = append(customs, cus)
136
-						}
137
-					} else if subItem.Type == 3 {
138
-						if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 && subItem.GoodInfo.IsUser != 1 {
139
-							cnt, _ := strconv.ParseFloat(subItem.Count, 64)
140
-
141
-							cus := &models.NewCustom{
142
-								DetItemFeeSumamt: subItem.Price * cnt,
143
-								Cut:              cnt,
144
-								FeedetlSn:        subItem.FeedetlSn,
145
-								Price:            float64(subItem.Price),
146
-								MedListCodg:      subItem.GoodInfo.MedicalInsuranceNumber,
147
-								HospApprFlag:     -1,
148
-								FeeOcurTime:      tm.Format("2006-01-02 15:04:05"),
149
-							}
150
-							customs = append(customs, cus)
140
+						cus := &models.NewCustom{
141
+							DetItemFeeSumamt: subItem.Price * cnt,
142
+							Cut:              cnt,
143
+							FeedetlSn:        subItem.FeedetlSn,
144
+							Price:            float64(subItem.Price),
145
+							MedListCodg:      subItem.GoodInfo.MedicalInsuranceNumber,
146
+							HospApprFlag:     -1,
147
+							FeeOcurTime:      tm.Format("2006-01-02 15:04:05"),
151 148
 						}
149
+						customs = append(customs, cus)
152 150
 					}
153 151
 				}
154 152
 			}
155
-
156 153
 		}
157 154
 
158
-		if settle_accounts_type == 1 {
159
-			for _, subItem := range customs {
160
-				temp := strings.Split(subItem.FeedetlSn, "-")
161
-				var advice_id int64 = 0
162
-				var project_id int64 = 0
163
-				var types int64 = 0
164
-
165
-				id, _ := strconv.ParseInt(temp[2], 10, 64)
166
-				types, _ = strconv.ParseInt(temp[1], 10, 64)
167
-
168
-				if temp[1] == "1" {
169
-					advice_id = id
170
-					project_id = 0
171
-				} else if temp[1] == "2" {
172
-					advice_id = 0
173
-					project_id = id
174
-				}
175
-				info := &models.HisOrderInfo{
176
-					OrderNumber:      record.Number,
177
-					FeedetlSn:        subItem.FeedetlSn,
178
-					UploadDate:       recordDateTime,
179
-					AdviceId:         advice_id,
180
-					DetItemFeeSumamt: subItem.DetItemFeeSumamt,
181
-					Cnt:              subItem.Cut,
182
-					Pric:             float64(subItem.Price),
183
-					PatientId:        record.PatientId,
184
-					PricUplmtAmt:     0,
185
-					SelfpayProp:      0,
186
-					FulamtOwnpayAmt:  0,
187
-					OverlmtAmt:       0,
188
-					PreselfpayAmt:    0,
189
-					Status:           1,
190
-					Mtime:            time.Now().Unix(),
191
-					Ctime:            time.Now().Unix(),
192
-					UserOrgId:        adminUser.CurrentOrgId,
193
-					HisPatientId:     record.ID,
194
-					OrderId:          0,
195
-					ProjectId:        project_id,
196
-					Type:             types,
197
-					SettleType:       settle_accounts_type,
198
-				}
199
-				service.CreateOrderInfo(info)
200
-			}
155
+	}
201 156
 
202
-			err := service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
203
-			service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
204
-			service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, record.PatientId, record.Number, recordDateTime)
205
-			if err == nil {
206
-				c.ServeSuccessJSON(map[string]interface{}{
207
-					"msg": "上传费用明细成功",
208
-				})
209
-				return
210
-			} else {
211
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
212
-				return
213
-			}
157
+	fmt.Println(settle_accounts_type)
214 158
 
215
-		} else {
159
+	if settle_accounts_type == 1 {
160
+		fmt.Println(customs)
161
+		for _, subItem := range customs {
162
+			temp := strings.Split(subItem.FeedetlSn, "-")
163
+			var advice_id int64 = 0
164
+			var project_id int64 = 0
165
+			var types int64 = 0
216 166
 
217
-			for _, subItem := range customs {
218
-				temp := strings.Split(subItem.FeedetlSn, "-")
219
-				var advice_id int64 = 0
220
-				var project_id int64 = 0
221
-				var types int64 = 0
222
-
223
-				id, _ := strconv.ParseInt(temp[2], 10, 64)
224
-				types, _ = strconv.ParseInt(temp[1], 10, 64)
225
-
226
-				if temp[1] == "1" {
227
-					advice_id = id
228
-					project_id = 0
229
-				} else if temp[1] == "2" {
230
-					advice_id = 0
231
-					project_id = id
232
-				}
233
-				info := &models.HisOrderInfo{
234
-					OrderNumber:      record.Number,
235
-					FeedetlSn:        subItem.FeedetlSn,
236
-					UploadDate:       recordDateTime,
237
-					AdviceId:         advice_id,
238
-					DetItemFeeSumamt: subItem.DetItemFeeSumamt,
239
-					Cnt:              subItem.Cut,
240
-					Pric:             float64(subItem.Price),
241
-					PatientId:        record.PatientId,
242
-					PricUplmtAmt:     0,
243
-					SelfpayProp:      0,
244
-					FulamtOwnpayAmt:  0,
245
-					OverlmtAmt:       0,
246
-					PreselfpayAmt:    0,
247
-					Status:           1,
248
-					Mtime:            time.Now().Unix(),
249
-					Ctime:            time.Now().Unix(),
250
-					UserOrgId:        adminUser.CurrentOrgId,
251
-					HisPatientId:     record.ID,
252
-					OrderId:          0,
253
-					ProjectId:        project_id,
254
-					Type:             types,
255
-					SettleType:       settle_accounts_type,
256
-				}
257
-				service.CreateOrderInfo(info)
167
+			id, _ := strconv.ParseInt(temp[2], 10, 64)
168
+			types, _ = strconv.ParseInt(temp[1], 10, 64)
169
+
170
+			if temp[1] == "1" {
171
+				advice_id = id
172
+				project_id = 0
173
+			} else if temp[1] == "2" {
174
+				advice_id = 0
175
+				project_id = id
176
+			}
177
+			info := &models.HisOrderInfo{
178
+				OrderNumber:      record.Number,
179
+				FeedetlSn:        subItem.FeedetlSn,
180
+				UploadDate:       recordDateTime,
181
+				AdviceId:         advice_id,
182
+				DetItemFeeSumamt: subItem.DetItemFeeSumamt,
183
+				Cnt:              subItem.Cut,
184
+				Pric:             float64(subItem.Price),
185
+				PatientId:        record.PatientId,
186
+				PricUplmtAmt:     0,
187
+				SelfpayProp:      0,
188
+				FulamtOwnpayAmt:  0,
189
+				OverlmtAmt:       0,
190
+				PreselfpayAmt:    0,
191
+				Status:           1,
192
+				Mtime:            time.Now().Unix(),
193
+				Ctime:            time.Now().Unix(),
194
+				UserOrgId:        adminUser.CurrentOrgId,
195
+				HisPatientId:     record.ID,
196
+				OrderId:          0,
197
+				ProjectId:        project_id,
198
+				Type:             types,
199
+				SettleType:       settle_accounts_type,
258 200
 			}
201
+			service.CreateOrderInfo(info)
202
+		}
259 203
 
260
-			service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
261
-			service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
262
-			service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, record.PatientId, record.Number, recordDateTime)
204
+		err := service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
205
+		service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
206
+		service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, record.PatientId, record.Number, recordDateTime)
207
+		if err == nil {
263 208
 			c.ServeSuccessJSON(map[string]interface{}{
264 209
 				"msg": "上传费用明细成功",
265 210
 			})
211
+			return
212
+		} else {
213
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
214
+			return
215
+		}
266 216
 
217
+	} else {
218
+
219
+		for _, subItem := range customs {
220
+			temp := strings.Split(subItem.FeedetlSn, "-")
221
+			var advice_id int64 = 0
222
+			var project_id int64 = 0
223
+			var types int64 = 0
224
+
225
+			id, _ := strconv.ParseInt(temp[2], 10, 64)
226
+			types, _ = strconv.ParseInt(temp[1], 10, 64)
227
+
228
+			if temp[1] == "1" {
229
+				advice_id = id
230
+				project_id = 0
231
+			} else if temp[1] == "2" {
232
+				advice_id = 0
233
+				project_id = id
234
+			}
235
+			info := &models.HisOrderInfo{
236
+				OrderNumber:      record.Number,
237
+				FeedetlSn:        subItem.FeedetlSn,
238
+				UploadDate:       recordDateTime,
239
+				AdviceId:         advice_id,
240
+				DetItemFeeSumamt: subItem.DetItemFeeSumamt,
241
+				Cnt:              subItem.Cut,
242
+				Pric:             float64(subItem.Price),
243
+				PatientId:        record.PatientId,
244
+				PricUplmtAmt:     0,
245
+				SelfpayProp:      0,
246
+				FulamtOwnpayAmt:  0,
247
+				OverlmtAmt:       0,
248
+				PreselfpayAmt:    0,
249
+				Status:           1,
250
+				Mtime:            time.Now().Unix(),
251
+				Ctime:            time.Now().Unix(),
252
+				UserOrgId:        adminUser.CurrentOrgId,
253
+				HisPatientId:     record.ID,
254
+				OrderId:          0,
255
+				ProjectId:        project_id,
256
+				Type:             types,
257
+				SettleType:       settle_accounts_type,
258
+			}
259
+			service.CreateOrderInfo(info)
267 260
 		}
261
+
262
+		service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
263
+		service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
264
+		service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, record.PatientId, record.Number, recordDateTime)
265
+		c.ServeSuccessJSON(map[string]interface{}{
266
+			"msg": "上传费用明细成功",
267
+		})
268
+
268 269
 	}
269 270
 }
270 271
 

+ 2 - 2
service/his_hospital_service.go Voir le fichier

@@ -444,7 +444,7 @@ func GetZHHisPrescription(org_id int64, patient_id int64, record_date int64) (pr
444 444
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
445 445
 		}).
446 446
 		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
447
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
447
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
448 448
 		}).
449 449
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
450 450
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1").Preload("GoodInfo", "status = 1")
@@ -460,7 +460,7 @@ func GetZHMonthHisPrescription(org_id int64, patient_id int64, start_time int64,
460 460
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
461 461
 		}).
462 462
 		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
463
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
463
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
464 464
 		}).
465 465
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
466 466
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1").Preload("GoodInfo", "status = 1")

+ 30 - 14
service/his_service.go Voir le fichier

@@ -854,7 +854,7 @@ func SavePatientPrescriptionInfo(info models.HisPrescriptionInfo) (err error) {
854 854
 	return
855 855
 }
856 856
 
857
-func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time int64, end_time int64, doctor_id int64, keywords string, p_type int64, sort_type int64) (order []*models.HisOrder, err error, total int64) {
857
+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) (order []*models.HisOrder, err error, total int64) {
858 858
 	offset := (page - 1) * limit
859 859
 	db := readDb.Model(&models.HisOrder{})
860 860
 
@@ -868,15 +868,23 @@ func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time int6
868 868
 
869 869
 	}
870 870
 
871
-	if start_time != 0 {
872
-		db = db.Where("his_order.settle_accounts_date>=?", start_time)
873
-	}
874
-	if end_time != 0 {
875
-		db = db.Where("his_order.settle_accounts_date<=?", end_time)
876
-	}
871
+	if sort_type == 1 {
872
+		if start_time_timestamp != 0 {
873
+			db = db.Where("his_order.settle_accounts_date>=?", start_time_timestamp)
874
+		}
875
+		if end_time_timestamp != 0 {
876
+			db = db.Where("his_order.settle_accounts_date<=?", end_time_timestamp)
877
+		}
878
+	} else {
877 879
 
880
+		if len(start_time) != 0 {
881
+			db = db.Where("his_order.setl_time>=?", start_time+" 00:00:00")
882
+		}
883
+		if len(end_time) != 0 {
884
+			db = db.Where("his_order.setl_time<=?", end_time+" 23:59:59")
885
+		}
886
+	}
878 887
 	db = db.Where("his_order.status = 1 AND his_order.user_org_id = ? AND his_order.p_type = ? AND his_order.order_status = 2", user_org_id, p_type)
879
-
880 888
 	db = db.Preload("HisOrderInfo", "status = 1 AND user_org_id = ?", user_org_id).
881 889
 		Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id).
882 890
 		Preload("HisPatient", "status = 1 AND user_org_id = ?", user_org_id).
@@ -886,18 +894,18 @@ func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time int6
886 894
 	db = db.Limit(limit).Offset(offset)
887 895
 	if user_org_id == 10215 {
888 896
 		if sort_type == 1 {
889
-			err = db.Order("settle_accounts_date asc,ctime asc").Find(&order).Error
897
+			err = db.Order("settle_accounts_date asc,ctime asc").Group("his_order.id").Find(&order).Error
890 898
 		}
891 899
 		if sort_type == 2 {
892
-			err = db.Order("setl_time asc,ctime asc").Find(&order).Error
900
+			err = db.Order("setl_time asc,ctime asc").Group("his_order.id").Find(&order).Error
893 901
 		}
894 902
 
895 903
 	} else {
896 904
 		if sort_type == 1 {
897
-			err = db.Order("settle_accounts_date desc,ctime desc").Find(&order).Error
905
+			err = db.Order("settle_accounts_date desc,ctime desc").Group("his_order.id").Find(&order).Error
898 906
 		}
899 907
 		if sort_type == 2 {
900
-			err = db.Order("setl_time desc,ctime desc").Find(&order).Error
908
+			err = db.Order("setl_time desc,ctime desc").Group("his_order.id").Find(&order).Error
901 909
 		}
902 910
 	}
903 911
 
@@ -1699,6 +1707,7 @@ type MedicalInsuranceCostCompare struct {
1699 1707
 	PsnPay    float64 `gorm:"column:psn_pay" json:"psn_pay" form:"psn_pay"`
1700 1708
 	Creator   int64   `gorm:"column:creator" json:"creator" form:"creator"`
1701 1709
 	Ctime     int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
1710
+	ClrType   string  `gorm:"column:clr_type" json:"clr_type" form:"clr_type"`
1702 1711
 }
1703 1712
 
1704 1713
 func (MedicalInsuranceCostCompare) TableName() string {
@@ -1810,6 +1819,7 @@ type CustomAccountFormData struct {
1810 1819
 	PsnCashPay         float64 `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
1811 1820
 	AcctPay            float64 `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
1812 1821
 	CashPay            float64 `gorm:"column:cash_pay" json:"cash_pay" form:"cash_pay"`
1822
+	HifpPay            float64 `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
1813 1823
 	Sumamt             float64 `gorm:"column:sumamt" json:"sumamt" form:"sumamt"`
1814 1824
 	Iinfo              string  `gorm:"column:iinfo" json:"iinfo" form:"iinfo"`
1815 1825
 	DiagnosisId        string  `gorm:"column:diagnosis_id" json:"diagnosis_id" form:"diagnosis_id"`
@@ -1823,8 +1833,14 @@ type CustomAccountFormData struct {
1823 1833
 	SetlDetail         string  `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
1824 1834
 }
1825 1835
 
1826
-func GetCheckAccountFormData(start_time int64, end_time int64, org_id int64, insutype string) (cus []*CustomAccountFormData, err error) {
1827
-	err = readDb.Raw("select o.setl_detail as setl_detail, o.maf_pay as maf_pay,  o.hifmi_pay  as hifmi_pay, o.hifob_pay as hifob_pay, o.cvlserv_pay as cvlserv_pay, o.hifes_pay as hifes_pay, o.patient_id as patient_id, p.diagnosis as diagnosis_id, p.iinfo as iinfo, o.medfee_sumamt as medfee_sumamt ,o.psn_name as psn_name ,p.id_card_no as id_card_no ,o.psn_no as psn_no, o.mdtrt_id as mdtrt_id, o.settle_accounts_date as settle_accounts_date,o.act_pay_dedc as act_pay_dedc,O.fund_pay_sumamt as fund_pay_sumamt,o.psn_cash_pay as psn_cash_pay ,o.acct_pay as acct_pay,o.psn_cash_pay as cash_pay,o.medfee_sumamt as sumamt  from his_order o  Join his_patient p On o.patient_id = p.patient_id AND o.settle_accounts_date = p.record_date where o.user_org_id = ? AND o.status = 1 AND o.order_status = 2  AND o.settle_accounts_date >= ? AND o.settle_accounts_date <= ? AND o.insutype = ? Group by o.id", org_id, start_time, end_time, insutype).Scan(&cus).Error
1836
+func GetCheckAccountFormData(start_time int64, end_time int64, org_id int64, insutype string, clr_type string) (cus []*CustomAccountFormData, err error) {
1837
+	if clr_type == "9903" {
1838
+
1839
+		err = readDb.Raw("select o.setl_detail as setl_detail, o.maf_pay as maf_pay,  o.hifmi_pay  as hifmi_pay, o.hifob_pay as hifob_pay, o.cvlserv_pay as cvlserv_pay, o.hifes_pay as hifes_pay, o.patient_id as patient_id, p.diagnosis as diagnosis_id, p.iinfo as iinfo, o.medfee_sumamt as medfee_sumamt ,o.psn_name as psn_name ,p.id_card_no as id_card_no ,o.psn_no as psn_no, o.mdtrt_id as mdtrt_id, o.settle_accounts_date as settle_accounts_date,o.act_pay_dedc as act_pay_dedc,O.fund_pay_sumamt as fund_pay_sumamt,o.psn_cash_pay as psn_cash_pay ,o.acct_pay as acct_pay,o.psn_cash_pay as cash_pay,o.medfee_sumamt as sumamt,o.hifp_pay as hifp_pay  from his_order o  Join his_patient p On o.patient_id = p.patient_id AND o.settle_accounts_date = p.record_date where o.user_org_id = ? AND o.status = 1 AND o.order_status = 2  AND o.settle_accounts_date >= ? AND o.settle_accounts_date <= ? AND o.insutype = ? AND o.clr_type = ? Group by o.id", org_id, start_time, end_time, insutype, clr_type).Scan(&cus).Error
1840
+	} else {
1841
+		err = readDb.Raw("select o.setl_detail as setl_detail, o.maf_pay as maf_pay,  o.hifmi_pay  as hifmi_pay, o.hifob_pay as hifob_pay, o.cvlserv_pay as cvlserv_pay, o.hifes_pay as hifes_pay, o.patient_id as patient_id, p.diagnosis as diagnosis_id, p.iinfo as iinfo, o.medfee_sumamt as medfee_sumamt ,o.psn_name as psn_name ,p.id_card_no as id_card_no ,o.psn_no as psn_no, o.mdtrt_id as mdtrt_id, o.settle_accounts_date as settle_accounts_date,o.act_pay_dedc as act_pay_dedc,O.fund_pay_sumamt as fund_pay_sumamt,o.psn_cash_pay as psn_cash_pay ,o.acct_pay as acct_pay,o.psn_cash_pay as cash_pay,o.medfee_sumamt as sumamt,o.hifp_pay as hifp_pay  from his_order o  Join his_patient p On o.patient_id = p.patient_id AND o.settle_accounts_date = p.record_date where o.user_org_id = ? AND o.status = 1 AND o.order_status = 2  AND o.settle_accounts_date >= ? AND o.settle_accounts_date <= ? AND o.insutype = ? AND o.clr_type <> 9903 Group by o.id", org_id, start_time, end_time, insutype).Scan(&cus).Error
1842
+
1843
+	}
1828 1844
 
1829 1845
 	for _, item := range cus {
1830 1846
 		var total int64