|
@@ -10,6 +10,7 @@ func GetAllPatientChargeDetails(org_id int64, start_time int64, end_time int64,
|
10
|
10
|
if len(keyword) == 0 {
|
11
|
11
|
switch item_type {
|
12
|
12
|
case 0:
|
|
13
|
+
|
13
|
14
|
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 {
|
14
|
15
|
return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
|
15
|
16
|
Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
|
|
@@ -152,24 +153,50 @@ func GetAllPatientChargeDetails(org_id int64, start_time int64, end_time int64,
|
152
|
153
|
return
|
153
|
154
|
}
|
154
|
155
|
|
155
|
|
-func GetNewAllPatientDrugChargeDetails(org_id int64, start_time_str string, end_time_str string, start_time int64, end_time int64, keyword string, item_type int64) (patients []*models.NewChargeDetail, err error) {
|
|
156
|
+func GetNewAllPatientDrugChargeDetails(org_id int64, start_time_str string, end_time_str string, start_time int64, end_time int64, keyword string, item_type int64, time_type string) (patients []*models.NewChargeDetail, err error) {
|
156
|
157
|
if len(keyword) == 0 {
|
157
|
158
|
switch item_type {
|
158
|
159
|
case 0:
|
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 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
|
|
- Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
|
162
|
|
- Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
|
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 o.settle_accounts_date >= ? and o.settle_accounts_date <= ? and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
|
|
160
|
+ if time_type == "0" {
|
|
161
|
+ 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").
|
|
162
|
+ Joins("JOIN his_order o ON oi.order_number = o.number and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
|
|
163
|
+ Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
|
|
164
|
+ Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
|
|
165
|
+ Joins(" JOIN xt_base_drug drug on a.drug_id = drug.id").
|
|
166
|
+ 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
|
|
167
|
+
|
|
168
|
+ } else {
|
|
169
|
+
|
|
170
|
+ 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").
|
|
171
|
+ 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).
|
|
172
|
+ Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
|
|
173
|
+ Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
|
|
174
|
+ Joins(" JOIN xt_base_drug drug on a.drug_id = drug.id").
|
|
175
|
+ 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
|
|
176
|
+
|
|
177
|
+ }
|
|
178
|
+
|
165
|
179
|
break
|
166
|
180
|
case 1:
|
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 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
|
|
- Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
|
170
|
|
- Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
|
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 o.settle_accounts_date >= ? and o.settle_accounts_date <= ? and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
|
|
181
|
+ if time_type == "0" {
|
|
182
|
+
|
|
183
|
+ 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").
|
|
184
|
+ Joins("JOIN his_order o ON oi.order_number = o.number and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
|
|
185
|
+ Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
|
|
186
|
+ Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
|
|
187
|
+ Joins(" JOIN xt_base_drug drug on a.drug_id = drug.id").
|
|
188
|
+ 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
|
|
189
|
+
|
|
190
|
+ } else {
|
|
191
|
+ 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").
|
|
192
|
+ 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).
|
|
193
|
+ Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
|
|
194
|
+ Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
|
|
195
|
+ Joins(" JOIN xt_base_drug drug on a.drug_id = drug.id").
|
|
196
|
+ 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
|
|
197
|
+
|
|
198
|
+ }
|
|
199
|
+
|
173
|
200
|
break
|
174
|
201
|
|
175
|
202
|
}
|
|
@@ -178,21 +205,46 @@ func GetNewAllPatientDrugChargeDetails(org_id int64, start_time_str string, end_
|
178
|
205
|
keyword := "%" + keyword + "%"
|
179
|
206
|
switch item_type {
|
180
|
207
|
case 0:
|
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 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
|
|
- Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
|
184
|
|
- Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
|
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 o.settle_accounts_date >= ? and o.settle_accounts_date <= ? and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
|
|
208
|
+ if time_type == "0" {
|
|
209
|
+
|
|
210
|
+ 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").
|
|
211
|
+ Joins("JOIN his_order o ON oi.order_number = o.number and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
|
|
212
|
+ Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
|
|
213
|
+ Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
|
|
214
|
+ Joins(" JOIN xt_base_drug drug on a.drug_id = drug.id").
|
|
215
|
+ 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
|
|
216
|
+
|
|
217
|
+ } else {
|
|
218
|
+
|
|
219
|
+ 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").
|
|
220
|
+ 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).
|
|
221
|
+ Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
|
|
222
|
+ Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
|
|
223
|
+ Joins(" JOIN xt_base_drug drug on a.drug_id = drug.id").
|
|
224
|
+ 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
|
|
225
|
+
|
|
226
|
+ }
|
187
|
227
|
|
188
|
228
|
break
|
189
|
229
|
case 1:
|
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 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
|
|
- Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
|
193
|
|
- Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
|
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 o.settle_accounts_date >= ? and o.settle_accounts_date <= ? and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
|
|
230
|
+ if time_type == "0" {
|
|
231
|
+ 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").
|
|
232
|
+ Joins("JOIN his_order o ON oi.order_number = o.number and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
|
|
233
|
+ Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
|
|
234
|
+ Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
|
|
235
|
+ Joins(" JOIN xt_base_drug drug on a.drug_id = drug.id").
|
|
236
|
+ 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
|
|
237
|
+
|
|
238
|
+ } else {
|
|
239
|
+
|
|
240
|
+ 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").
|
|
241
|
+ 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).
|
|
242
|
+ Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
|
|
243
|
+ Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
|
|
244
|
+ Joins(" JOIN xt_base_drug drug on a.drug_id = drug.id").
|
|
245
|
+ 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
|
|
246
|
+
|
|
247
|
+ }
|
196
|
248
|
|
197
|
249
|
break
|
198
|
250
|
|
|
@@ -202,17 +254,30 @@ func GetNewAllPatientDrugChargeDetails(org_id int64, start_time_str string, end_
|
202
|
254
|
|
203
|
255
|
return
|
204
|
256
|
}
|
205
|
|
-func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str string, end_time_str string, start_time int64, end_time int64, keyword string, item_type int64) (patients []*models.NewChargeDetail, err error) {
|
|
257
|
+func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str string, end_time_str string, start_time int64, end_time int64, keyword string, item_type int64, time_type string) (patients []*models.NewChargeDetail, err error) {
|
206
|
258
|
if len(keyword) == 0 {
|
207
|
259
|
switch item_type {
|
208
|
260
|
case 0:
|
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 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
|
|
- Joins(" JOIN his_prescription_project p ON oi.project_id = p.id ").
|
212
|
|
- Joins(" left join xt_his_project project on p.project_id = project.id").
|
213
|
|
- Joins(" left join xt_good_information good on p.project_id = good.id").
|
214
|
|
- Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
|
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
|
|
261
|
+ if time_type == "0" {
|
|
262
|
+ 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").
|
|
263
|
+ Joins("JOIN his_order o ON oi.order_number = o.number and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
|
|
264
|
+ Joins(" JOIN his_prescription_project p ON oi.project_id = p.id ").
|
|
265
|
+ Joins(" left join xt_his_project project on p.project_id = project.id").
|
|
266
|
+ Joins(" left join xt_good_information good on p.project_id = good.id").
|
|
267
|
+ Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
|
|
268
|
+ 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
|
|
269
|
+
|
|
270
|
+ } else {
|
|
271
|
+
|
|
272
|
+ 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).
|
|
274
|
+ Joins(" JOIN his_prescription_project p ON oi.project_id = p.id ").
|
|
275
|
+ Joins(" left join xt_his_project project on p.project_id = project.id").
|
|
276
|
+ Joins(" left join xt_good_information good on p.project_id = good.id").
|
|
277
|
+ Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
|
|
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
|
|
279
|
+
|
|
280
|
+ }
|
216
|
281
|
|
217
|
282
|
//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
|
283
|
// return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
|
|
@@ -232,56 +297,123 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
|
232
|
297
|
|
233
|
298
|
break
|
234
|
299
|
case 2:
|
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 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
|
|
- Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
|
238
|
|
- Joins("left join xt_his_project project on p.project_id = project.id").
|
239
|
|
- Joins("left join xt_good_information good on p.project_id = good.id").
|
240
|
|
- Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
|
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
|
|
300
|
+ if time_type == "0" {
|
|
301
|
+ 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").
|
|
302
|
+ Joins("JOIN his_order o ON oi.order_number = o.number and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
|
|
303
|
+ Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
|
|
304
|
+ Joins("left join xt_his_project project on p.project_id = project.id").
|
|
305
|
+ Joins("left join xt_good_information good on p.project_id = good.id").
|
|
306
|
+ Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
|
|
307
|
+ 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
|
|
308
|
+
|
|
309
|
+ } else {
|
|
310
|
+ 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").
|
|
311
|
+ 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).
|
|
312
|
+ Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
|
|
313
|
+ Joins("left join xt_his_project project on p.project_id = project.id").
|
|
314
|
+ Joins("left join xt_good_information good on p.project_id = good.id").
|
|
315
|
+ Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
|
|
316
|
+ 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
|
|
317
|
+
|
|
318
|
+ }
|
|
319
|
+
|
242
|
320
|
break
|
243
|
321
|
case 3:
|
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").
|
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).
|
246
|
|
- Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 3").
|
247
|
|
- Joins("left join xt_his_project project on p.project_id = project.id").
|
248
|
|
- Joins("left join xt_good_information good on p.project_id = good.id").
|
249
|
|
- Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
|
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
|
|
322
|
+ if time_type == "0" {
|
|
323
|
+ 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").
|
|
324
|
+ Joins("JOIN his_order o ON oi.order_number = o.number and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
|
|
325
|
+ Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 3").
|
|
326
|
+ Joins("left join xt_his_project project on p.project_id = project.id").
|
|
327
|
+ Joins("left join xt_good_information good on p.project_id = good.id").
|
|
328
|
+ Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
|
|
329
|
+ 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
|
|
330
|
+
|
|
331
|
+ } else {
|
|
332
|
+ 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").
|
|
333
|
+ 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).
|
|
334
|
+ Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 3").
|
|
335
|
+ Joins("left join xt_his_project project on p.project_id = project.id").
|
|
336
|
+ Joins("left join xt_good_information good on p.project_id = good.id").
|
|
337
|
+ Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
|
|
338
|
+ 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
|
|
339
|
+
|
|
340
|
+ }
|
|
341
|
+
|
251
|
342
|
break
|
252
|
343
|
}
|
253
|
344
|
} else {
|
254
|
345
|
keyword := "%" + keyword + "%"
|
255
|
346
|
switch item_type {
|
256
|
347
|
case 0:
|
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").
|
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).
|
259
|
|
- Joins(" JOIN his_prescription_project p ON oi.project_id = p.id ").
|
260
|
|
- Joins("left join xt_his_project project on p.project_id = project.id").
|
261
|
|
- Joins("left join xt_good_information good on p.project_id = good.id").
|
262
|
|
- Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
|
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
|
|
348
|
+ if time_type == "0" {
|
|
349
|
+ 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").
|
|
350
|
+ Joins("JOIN his_order o ON oi.order_number = o.number and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
|
|
351
|
+ Joins(" JOIN his_prescription_project p ON oi.project_id = p.id ").
|
|
352
|
+ Joins("left join xt_his_project project on p.project_id = project.id").
|
|
353
|
+ Joins("left join xt_good_information good on p.project_id = good.id").
|
|
354
|
+ Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
|
|
355
|
+ 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
|
|
356
|
+
|
|
357
|
+ } else {
|
|
358
|
+
|
|
359
|
+ 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").
|
|
360
|
+ 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).
|
|
361
|
+ Joins(" JOIN his_prescription_project p ON oi.project_id = p.id ").
|
|
362
|
+ Joins("left join xt_his_project project on p.project_id = project.id").
|
|
363
|
+ Joins("left join xt_good_information good on p.project_id = good.id").
|
|
364
|
+ Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
|
|
365
|
+ 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
|
|
366
|
+
|
|
367
|
+ }
|
264
|
368
|
|
265
|
369
|
break
|
266
|
370
|
|
267
|
371
|
case 2:
|
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").
|
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).
|
270
|
|
- Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
|
271
|
|
- Joins("left join xt_his_project project on p.project_id = project.id").
|
272
|
|
- Joins("left join xt_good_information good on p.project_id = good.id").
|
273
|
|
- Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
|
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
|
|
372
|
+ if time_type == "0" {
|
|
373
|
+
|
|
374
|
+ 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").
|
|
375
|
+ Joins("JOIN his_order o ON oi.order_number = o.number and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
|
|
376
|
+ Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
|
|
377
|
+ Joins("left join xt_his_project project on p.project_id = project.id").
|
|
378
|
+ Joins("left join xt_good_information good on p.project_id = good.id").
|
|
379
|
+ Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
|
|
380
|
+ 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
|
|
381
|
+
|
|
382
|
+ } else {
|
|
383
|
+ 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").
|
|
384
|
+ 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).
|
|
385
|
+ Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
|
|
386
|
+ Joins("left join xt_his_project project on p.project_id = project.id").
|
|
387
|
+ Joins("left join xt_good_information good on p.project_id = good.id").
|
|
388
|
+ Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
|
|
389
|
+ 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
|
|
390
|
+
|
|
391
|
+ }
|
275
|
392
|
|
276
|
393
|
break
|
277
|
394
|
case 3:
|
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").
|
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).
|
280
|
|
- Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 3").
|
281
|
|
- Joins("left join xt_his_project project on p.project_id = project.id").
|
282
|
|
- Joins("left join xt_good_information good on p.project_id = good.id").
|
283
|
|
- Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
|
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
|
|
395
|
+ if time_type == "0" {
|
|
396
|
+
|
|
397
|
+ 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").
|
|
398
|
+ Joins("JOIN his_order o ON oi.order_number = o.number and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
|
|
399
|
+ Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 3").
|
|
400
|
+ Joins("left join xt_his_project project on p.project_id = project.id").
|
|
401
|
+ Joins("left join xt_good_information good on p.project_id = good.id").
|
|
402
|
+ Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
|
|
403
|
+ 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
|
|
404
|
+
|
|
405
|
+ } else {
|
|
406
|
+
|
|
407
|
+ 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").
|
|
408
|
+ 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).
|
|
409
|
+ Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 3").
|
|
410
|
+ Joins("left join xt_his_project project on p.project_id = project.id").
|
|
411
|
+ Joins("left join xt_good_information good on p.project_id = good.id").
|
|
412
|
+ Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
|
|
413
|
+ 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
|
|
414
|
+
|
|
415
|
+ }
|
|
416
|
+
|
285
|
417
|
break
|
286
|
418
|
}
|
287
|
419
|
}
|