|
@@ -249,63 +249,120 @@ func GetManyUsers(tmp []int64) (list []*models.TmpPatient, err error) {
|
249
|
249
|
func GetPatientMedication(orgid, patient_id, stime, etime, is_medicine int64) (pp []*models.PharmacyContent, err error) {
|
250
|
250
|
InitDrugidIsNil(orgid, stime, etime)
|
251
|
251
|
var tmp []*models.HisDoctorAdviceInfoL
|
252
|
|
- if is_medicine == 0 {
|
|
252
|
+ if orgid == 10375 {
|
253
|
253
|
err = XTReadDB().Model(&models.HisDoctorAdviceInfoL{}).Where(
|
254
|
|
- "status = 1 and advice_date >= ? and advice_date <= ? and user_org_id = ? and patient_id = ? and is_medicine = ? and drug_id in (select id from xt_base_drug where org_id = ? and is_pharmacy = 1)", stime, etime, orgid, patient_id, is_medicine, orgid).Find(&tmp).Error
|
|
254
|
+ "status = 1 and advice_date >= ? and advice_date <= ? and user_org_id = ? and patient_id = ? and drug_id in (select id from xt_base_drug where org_id = ?)", stime, etime, orgid, patient_id, orgid).Find(&tmp).Error
|
255
|
255
|
if err != nil {
|
256
|
256
|
return pp, err
|
257
|
257
|
}
|
258
|
|
- } else {
|
259
|
|
- err = XTReadDB().Model(&models.HisDoctorAdviceInfoL{}).Where(
|
260
|
|
- "status = 1 and advice_date >= ? and advice_date <= ? and user_org_id = ? and patient_id = ? and is_medicine = ? and drug_id in (select id from xt_base_drug where org_id = ? and status = 1)", stime, etime, orgid, patient_id, is_medicine, orgid).Find(&tmp).Error
|
261
|
|
- if err != nil {
|
262
|
|
- return pp, err
|
|
258
|
+
|
|
259
|
+ for _, v := range tmp {
|
|
260
|
+ pp = append(pp, &models.PharmacyContent{
|
|
261
|
+ Name: v.AdviceName,
|
|
262
|
+ SingleDosage: config.ToString(v.SingleDose) + v.SingleDoseUnit,
|
|
263
|
+ Usage: v.DeliveryWay,
|
|
264
|
+ Frequency: v.ExecutionFrequency,
|
|
265
|
+ Days: config.ToString(v.Day) + "天",
|
|
266
|
+ Total: config.ToString(v.PrescribingNumber) + v.PrescribingNumberUnit,
|
|
267
|
+ Doctor: GetAdminUserName(v.AdviceDoctor, orgid),
|
|
268
|
+ DataSources: "his处方",
|
|
269
|
+ Remarks: v.Remark,
|
|
270
|
+ DrugId: v.DrugId,
|
|
271
|
+ })
|
263
|
272
|
}
|
264
|
|
- }
|
265
|
273
|
|
266
|
|
- for _, v := range tmp {
|
267
|
|
- pp = append(pp, &models.PharmacyContent{
|
268
|
|
- Name: v.AdviceName,
|
269
|
|
- SingleDosage: config.ToString(v.SingleDose) + v.SingleDoseUnit,
|
270
|
|
- Usage: v.DeliveryWay,
|
271
|
|
- Frequency: v.ExecutionFrequency,
|
272
|
|
- Days: config.ToString(v.Day) + "天",
|
273
|
|
- Total: config.ToString(v.PrescribingNumber) + v.PrescribingNumberUnit,
|
274
|
|
- Doctor: GetAdminUserName(v.AdviceDoctor, orgid),
|
275
|
|
- DataSources: "his处方",
|
276
|
|
- Remarks: v.Remark,
|
277
|
|
- DrugId: v.DrugId,
|
278
|
|
- })
|
|
274
|
+ var tmp_advice []*models.XtDoctorAdviceL
|
|
275
|
+ if is_medicine == 0 {
|
|
276
|
+ err = XTReadDB().Model(&models.XtDoctorAdviceL{}).Where(
|
|
277
|
+ "status = 1 and (advice_type = 2 or advice_type = 3) and advice_date >= ? and advice_date <= ? and user_org_id = ? and patient_id = ? and is_medicine = ? and drug_id in (select id from xt_base_drug where org_id = ? and is_pharmacy = 1)", stime, etime, orgid, patient_id, is_medicine, orgid).Find(&tmp_advice).Error
|
|
278
|
+ if err != nil {
|
|
279
|
+ return pp, err
|
|
280
|
+ }
|
|
281
|
+ } else {
|
|
282
|
+ err = XTReadDB().Model(&models.XtDoctorAdviceL{}).Where(
|
|
283
|
+ "status = 1 and (advice_type = 2 or advice_type = 3) and advice_date >= ? and advice_date <= ? and user_org_id = ? and patient_id = ? and is_medicine = ? and drug_id in (select id from xt_base_drug where org_id = ? and status = 1)", stime, etime, orgid, patient_id, is_medicine, orgid).Find(&tmp_advice).Error
|
|
284
|
+ if err != nil {
|
|
285
|
+ return pp, err
|
|
286
|
+ }
|
|
287
|
+ }
|
|
288
|
+
|
|
289
|
+ for _, v := range tmp_advice {
|
|
290
|
+ pp = append(pp, &models.PharmacyContent{
|
|
291
|
+ Name: v.AdviceName,
|
|
292
|
+ SingleDosage: config.ToString(v.SingleDose) + v.SingleDoseUnit,
|
|
293
|
+ Usage: v.DeliveryWay,
|
|
294
|
+ Frequency: v.ExecutionFrequency,
|
|
295
|
+ Days: "-",
|
|
296
|
+ Total: config.ToString(v.PrescribingNumber) + v.PrescribingNumberUnit,
|
|
297
|
+ Doctor: GetAdminUserName(v.AdviceDoctor, orgid),
|
|
298
|
+ DataSources: "临时医嘱",
|
|
299
|
+ Remarks: v.Remark,
|
|
300
|
+ DrugId: v.DrugId,
|
|
301
|
+ })
|
|
302
|
+ }
|
|
303
|
+ return
|
279
|
304
|
}
|
280
|
305
|
|
281
|
|
- var tmp_advice []*models.XtDoctorAdviceL
|
282
|
|
- if is_medicine == 0 {
|
283
|
|
- err = XTReadDB().Model(&models.XtDoctorAdviceL{}).Where(
|
284
|
|
- "status = 1 and (advice_type = 2 or advice_type = 3) and advice_date >= ? and advice_date <= ? and user_org_id = ? and patient_id = ? and is_medicine = ? and drug_id in (select id from xt_base_drug where org_id = ? and is_pharmacy = 1)", stime, etime, orgid, patient_id, is_medicine, orgid).Find(&tmp_advice).Error
|
285
|
|
- if err != nil {
|
286
|
|
- return pp, err
|
|
306
|
+ if orgid != 10375 {
|
|
307
|
+ if is_medicine == 0 {
|
|
308
|
+ err = XTReadDB().Model(&models.HisDoctorAdviceInfoL{}).Where(
|
|
309
|
+ "status = 1 and advice_date >= ? and advice_date <= ? and user_org_id = ? and patient_id = ? and is_medicine = ? and drug_id in (select id from xt_base_drug where org_id = ? and is_pharmacy = 1)", stime, etime, orgid, patient_id, is_medicine, orgid).Find(&tmp).Error
|
|
310
|
+ if err != nil {
|
|
311
|
+ return pp, err
|
|
312
|
+ }
|
|
313
|
+ } else {
|
|
314
|
+ err = XTReadDB().Model(&models.HisDoctorAdviceInfoL{}).Where(
|
|
315
|
+ "status = 1 and advice_date >= ? and advice_date <= ? and user_org_id = ? and patient_id = ? and is_medicine = ? and drug_id in (select id from xt_base_drug where org_id = ? and status = 1)", stime, etime, orgid, patient_id, is_medicine, orgid).Find(&tmp).Error
|
|
316
|
+ if err != nil {
|
|
317
|
+ return pp, err
|
|
318
|
+ }
|
287
|
319
|
}
|
288
|
|
- } else {
|
289
|
|
- err = XTReadDB().Model(&models.XtDoctorAdviceL{}).Where(
|
290
|
|
- "status = 1 and (advice_type = 2 or advice_type = 3) and advice_date >= ? and advice_date <= ? and user_org_id = ? and patient_id = ? and is_medicine = ? and drug_id in (select id from xt_base_drug where org_id = ? and status = 1)", stime, etime, orgid, patient_id, is_medicine, orgid).Find(&tmp_advice).Error
|
291
|
|
- if err != nil {
|
292
|
|
- return pp, err
|
|
320
|
+
|
|
321
|
+ for _, v := range tmp {
|
|
322
|
+ pp = append(pp, &models.PharmacyContent{
|
|
323
|
+ Name: v.AdviceName,
|
|
324
|
+ SingleDosage: config.ToString(v.SingleDose) + v.SingleDoseUnit,
|
|
325
|
+ Usage: v.DeliveryWay,
|
|
326
|
+ Frequency: v.ExecutionFrequency,
|
|
327
|
+ Days: config.ToString(v.Day) + "天",
|
|
328
|
+ Total: config.ToString(v.PrescribingNumber) + v.PrescribingNumberUnit,
|
|
329
|
+ Doctor: GetAdminUserName(v.AdviceDoctor, orgid),
|
|
330
|
+ DataSources: "his处方",
|
|
331
|
+ Remarks: v.Remark,
|
|
332
|
+ DrugId: v.DrugId,
|
|
333
|
+ })
|
293
|
334
|
}
|
294
|
|
- }
|
295
|
335
|
|
296
|
|
- for _, v := range tmp_advice {
|
297
|
|
- pp = append(pp, &models.PharmacyContent{
|
298
|
|
- Name: v.AdviceName,
|
299
|
|
- SingleDosage: config.ToString(v.SingleDose) + v.SingleDoseUnit,
|
300
|
|
- Usage: v.DeliveryWay,
|
301
|
|
- Frequency: v.ExecutionFrequency,
|
302
|
|
- Days: "-",
|
303
|
|
- Total: config.ToString(v.PrescribingNumber) + v.PrescribingNumberUnit,
|
304
|
|
- Doctor: GetAdminUserName(v.AdviceDoctor, orgid),
|
305
|
|
- DataSources: "临时医嘱",
|
306
|
|
- Remarks: v.Remark,
|
307
|
|
- DrugId: v.DrugId,
|
308
|
|
- })
|
|
336
|
+ var tmp_advice []*models.XtDoctorAdviceL
|
|
337
|
+ if is_medicine == 0 {
|
|
338
|
+ err = XTReadDB().Model(&models.XtDoctorAdviceL{}).Where(
|
|
339
|
+ "status = 1 and (advice_type = 2 or advice_type = 3) and advice_date >= ? and advice_date <= ? and user_org_id = ? and patient_id = ? and is_medicine = ? and drug_id in (select id from xt_base_drug where org_id = ? and is_pharmacy = 1)", stime, etime, orgid, patient_id, is_medicine, orgid).Find(&tmp_advice).Error
|
|
340
|
+ if err != nil {
|
|
341
|
+ return pp, err
|
|
342
|
+ }
|
|
343
|
+ } else {
|
|
344
|
+ err = XTReadDB().Model(&models.XtDoctorAdviceL{}).Where(
|
|
345
|
+ "status = 1 and (advice_type = 2 or advice_type = 3) and advice_date >= ? and advice_date <= ? and user_org_id = ? and patient_id = ? and is_medicine = ? and drug_id in (select id from xt_base_drug where org_id = ? and status = 1)", stime, etime, orgid, patient_id, is_medicine, orgid).Find(&tmp_advice).Error
|
|
346
|
+ if err != nil {
|
|
347
|
+ return pp, err
|
|
348
|
+ }
|
|
349
|
+ }
|
|
350
|
+
|
|
351
|
+ for _, v := range tmp_advice {
|
|
352
|
+ pp = append(pp, &models.PharmacyContent{
|
|
353
|
+ Name: v.AdviceName,
|
|
354
|
+ SingleDosage: config.ToString(v.SingleDose) + v.SingleDoseUnit,
|
|
355
|
+ Usage: v.DeliveryWay,
|
|
356
|
+ Frequency: v.ExecutionFrequency,
|
|
357
|
+ Days: "-",
|
|
358
|
+ Total: config.ToString(v.PrescribingNumber) + v.PrescribingNumberUnit,
|
|
359
|
+ Doctor: GetAdminUserName(v.AdviceDoctor, orgid),
|
|
360
|
+ DataSources: "临时医嘱",
|
|
361
|
+ Remarks: v.Remark,
|
|
362
|
+ DrugId: v.DrugId,
|
|
363
|
+ })
|
|
364
|
+ }
|
|
365
|
+ return
|
309
|
366
|
}
|
310
|
367
|
return
|
311
|
368
|
}
|