Browse Source

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

28169 9 months ago
parent
commit
7aa1b35d57
1 changed files with 20 additions and 28 deletions
  1. 20 28
      service/his_charge_service.go

+ 20 - 28
service/his_charge_service.go View File

@@ -157,19 +157,19 @@ func GetNewAllPatientDrugChargeDetails(org_id int64, start_time_str string, end_
157 157
 		switch item_type {
158 158
 		case 0:
159 159
 			err = readDb.Table("his_order_info as oi").Select("oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
160
-				Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN  ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
160
+				Joins("JOIN his_order o ON oi.order_number = o.number  and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
161 161
 				Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
162 162
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
163 163
 				Joins(" JOIN  xt_base_drug drug on  a.drug_id = drug.id").
164
-				Where("oi.advice_id > 0 and oi.user_org_id = ? and oi.`upload_date` >= ?  and oi.`upload_date` <= ?   and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
164
+				Where("oi.advice_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ?   and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
165 165
 			break
166 166
 		case 1:
167 167
 			err = readDb.Table("his_order_info as oi").Select("oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
168
-				Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN  ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
168
+				Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
169 169
 				Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
170 170
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
171 171
 				Joins(" JOIN  xt_base_drug drug on  a.drug_id = drug.id").
172
-				Where("oi.advice_id > 0 and oi.user_org_id = ? and oi.`upload_date` >= ?  and oi.`upload_date` <= ?   and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
172
+				Where("oi.advice_id > 0 and oi.user_org_id = ? and  o.settle_accounts_date >= ?  and o.settle_accounts_date <= ?    and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
173 173
 			break
174 174
 
175 175
 		}
@@ -179,20 +179,20 @@ func GetNewAllPatientDrugChargeDetails(org_id int64, start_time_str string, end_
179 179
 		switch item_type {
180 180
 		case 0:
181 181
 			err = readDb.Table("his_order_info as oi").Select("oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
182
-				Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN  ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
182
+				Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
183 183
 				Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
184 184
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
185 185
 				Joins(" JOIN  xt_base_drug drug on  a.drug_id = drug.id").
186
-				Where("oi.advice_id > 0 and oi.user_org_id = ? and oi.`upload_date` >= ?  and oi.`upload_date` <= ?   and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
186
+				Where("oi.advice_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ?  and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
187 187
 
188 188
 			break
189 189
 		case 1:
190 190
 			err = readDb.Table("his_order_info as oi").Select("oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
191
-				Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN  ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
191
+				Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
192 192
 				Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
193 193
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
194 194
 				Joins(" JOIN  xt_base_drug drug on  a.drug_id = drug.id").
195
-				Where("oi.advice_id > 0 and oi.user_org_id = ? and oi.`upload_date` >= ?  and oi.`upload_date` <= ?   and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
195
+				Where("oi.advice_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ? and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
196 196
 
197 197
 			break
198 198
 
@@ -207,12 +207,12 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
207 207
 		switch item_type {
208 208
 		case 0:
209 209
 			err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
210
-				Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN  ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
210
+				Joins("JOIN his_order o ON oi.order_number = o.number  and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
211 211
 				Joins(" JOIN his_prescription_project p ON oi.project_id = p.id ").
212 212
 				Joins(" left join xt_his_project project on  p.project_id = project.id").
213 213
 				Joins(" left join  xt_good_information good on  p.project_id = good.id").
214 214
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
215
-				Where("oi.project_id > 0 and oi.user_org_id = ? and oi.`upload_date` >= ?  and oi.`upload_date` <= ?   and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
215
+				Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ? and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
216 216
 
217 217
 			//err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
218 218
 			//	return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
@@ -233,66 +233,58 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
233 233
 			break
234 234
 		case 2:
235 235
 			err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
236
-				Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN  ? AND ?  and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
236
+				Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
237 237
 				Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
238 238
 				Joins("left join xt_his_project project on  p.project_id = project.id").
239 239
 				Joins("left join  xt_good_information good on  p.project_id = good.id").
240 240
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
241
-				Where("oi.project_id > 0 and oi.user_org_id = ? and oi.`upload_date` >= ?  and oi.`upload_date` <= ?   and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
242
-
241
+				Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ?  and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
243 242
 			break
244 243
 		case 3:
245 244
 			err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
246
-				Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN  ? AND ?  and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
245
+				Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
247 246
 				Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 3").
248 247
 				Joins("left join xt_his_project project on  p.project_id = project.id").
249 248
 				Joins("left join  xt_good_information good on  p.project_id = good.id").
250 249
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
251
-				Where("oi.project_id > 0 and oi.user_org_id = ? and oi.`upload_date` >= ?  and oi.`upload_date` <= ?   and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
252
-
250
+				Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ? and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
253 251
 			break
254
-
255 252
 		}
256
-
257 253
 	} else {
258 254
 		keyword := "%" + keyword + "%"
259 255
 		switch item_type {
260 256
 		case 0:
261 257
 			err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
262
-				Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN  ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
258
+				Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
263 259
 				Joins(" JOIN his_prescription_project p ON oi.project_id = p.id ").
264 260
 				Joins("left join xt_his_project project on  p.project_id = project.id").
265 261
 				Joins("left join  xt_good_information good on  p.project_id = good.id").
266 262
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
267
-				Where("oi.project_id > 0 and oi.user_org_id = ? and oi.`upload_date` >= ?  and oi.`upload_date` <= ?   and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
263
+				Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ? and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
268 264
 
269 265
 			break
270 266
 
271 267
 		case 2:
272 268
 			err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
273
-				Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN  ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
269
+				Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
274 270
 				Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
275 271
 				Joins("left join xt_his_project project on  p.project_id = project.id").
276 272
 				Joins("left join  xt_good_information good on  p.project_id = good.id").
277 273
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
278
-				Where("oi.project_id > 0 and oi.user_org_id = ? and oi.`upload_date` >= ?  and oi.`upload_date` <= ?   and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
274
+				Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ? and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
279 275
 
280 276
 			break
281 277
 		case 3:
282 278
 			err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
283
-				Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN  ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
279
+				Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
284 280
 				Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 3").
285 281
 				Joins("left join xt_his_project project on  p.project_id = project.id").
286 282
 				Joins("left join  xt_good_information good on  p.project_id = good.id").
287 283
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
288
-				Where("oi.project_id > 0 and oi.user_org_id = ? and oi.`upload_date` >= ?  and oi.`upload_date` <= ?   and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
289
-
284
+				Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ? and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
290 285
 			break
291
-
292 286
 		}
293
-
294 287
 	}
295
-
296 288
 	return
297 289
 }
298 290