|
@@ -594,43 +594,43 @@ func GetAllPatientChargeSettle(org_id int64, start_time int64, end_time int64, k
|
594
|
594
|
switch item_type {
|
595
|
595
|
case 0:
|
596
|
596
|
err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").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("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
|
597
|
|
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id).Order("ctime")
|
|
597
|
+ return db.Preload("OrderHisPatient", "status = 1").Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id).Order("ctime")
|
598
|
598
|
}).Where("p.status = 1 AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
|
599
|
599
|
|
600
|
600
|
break
|
601
|
601
|
case 1:
|
602
|
602
|
err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").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("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
|
603
|
|
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 1 ", start_time, end_time, org_id).Order("ctime")
|
|
603
|
+ return db.Preload("OrderHisPatient", "status = 1").Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 1 ", start_time, end_time, org_id).Order("ctime")
|
604
|
604
|
}).Where("p.status = 1 AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
|
605
|
605
|
|
606
|
606
|
break
|
607
|
607
|
case 2:
|
608
|
608
|
err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").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("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
|
609
|
|
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 0", start_time, end_time, org_id).Order("ctime")
|
|
609
|
+ return db.Preload("OrderHisPatient", "status = 1").Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 0", start_time, end_time, org_id).Order("ctime")
|
610
|
610
|
}).Where("p.status = 1 AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
|
611
|
611
|
|
612
|
612
|
break
|
613
|
613
|
case 3:
|
614
|
614
|
err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").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("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
|
615
|
|
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 14", start_time, end_time, org_id).Order("ctime")
|
|
615
|
+ return db.Preload("OrderHisPatient", "status = 1").Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 14", start_time, end_time, org_id).Order("ctime")
|
616
|
616
|
}).Where("p.status = 1 AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
|
617
|
617
|
|
618
|
618
|
break
|
619
|
619
|
case 4:
|
620
|
620
|
err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").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("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
|
621
|
|
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 11", start_time, end_time, org_id).Order("ctime")
|
|
621
|
+ return db.Preload("OrderHisPatient", "status = 1").Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 11", start_time, end_time, org_id).Order("ctime")
|
622
|
622
|
}).Where("p.status = 1 AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
|
623
|
623
|
|
624
|
624
|
break
|
625
|
625
|
case 5:
|
626
|
626
|
err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").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 AND orders.insutype = 390", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
|
627
|
|
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 ", start_time, end_time, org_id).Order("ctime")
|
|
627
|
+ return db.Preload("OrderHisPatient", "status = 1").Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 ", start_time, end_time, org_id).Order("ctime")
|
628
|
628
|
}).Where("p.status = 1 AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
|
629
|
629
|
|
630
|
630
|
break
|
631
|
631
|
case 6:
|
632
|
632
|
err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").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 AND orders.insutype = 310 ", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
|
633
|
|
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id).Order("ctime")
|
|
633
|
+ return db.Preload("OrderHisPatient", "status = 1").Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id).Order("ctime")
|
634
|
634
|
}).Where("p.status = 1 AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
|
635
|
635
|
|
636
|
636
|
break
|
|
@@ -642,31 +642,31 @@ func GetAllPatientChargeSettle(org_id int64, start_time int64, end_time int64, k
|
642
|
642
|
switch item_type {
|
643
|
643
|
case 0:
|
644
|
644
|
err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").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("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
|
645
|
|
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id).Order("ctime")
|
|
645
|
+ return db.Preload("OrderHisPatient", "status = 1").Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id).Order("ctime")
|
646
|
646
|
}).Where("p.status = 1 AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
|
647
|
647
|
|
648
|
648
|
break
|
649
|
649
|
case 1:
|
650
|
650
|
err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").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("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
|
651
|
|
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 1 ", start_time, end_time, org_id).Order("ctime")
|
|
651
|
+ return db.Preload("OrderHisPatient", "status = 1").Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 1 ", start_time, end_time, org_id).Order("ctime")
|
652
|
652
|
}).Where("p.status = 1 AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
|
653
|
653
|
|
654
|
654
|
break
|
655
|
655
|
case 2:
|
656
|
656
|
err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").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("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
|
657
|
|
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 0", start_time, end_time, org_id).Order("ctime")
|
|
657
|
+ return db.Preload("OrderHisPatient", "status = 1").Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 0", start_time, end_time, org_id).Order("ctime")
|
658
|
658
|
}).Where("p.status = 1 AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
|
659
|
659
|
|
660
|
660
|
break
|
661
|
661
|
case 3:
|
662
|
662
|
err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").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("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
|
663
|
|
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 14", start_time, end_time, org_id).Order("ctime")
|
|
663
|
+ return db.Preload("OrderHisPatient", "status = 1").Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 14", start_time, end_time, org_id).Order("ctime")
|
664
|
664
|
}).Where("p.status = 1 AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
|
665
|
665
|
|
666
|
666
|
break
|
667
|
667
|
case 4:
|
668
|
668
|
err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").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("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
|
669
|
|
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 11", start_time, end_time, org_id).Order("ctime")
|
|
669
|
+ return db.Preload("OrderHisPatient", "status = 1").Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 11", start_time, end_time, org_id).Order("ctime")
|
670
|
670
|
}).Where("p.status = 1 AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
|
671
|
671
|
|
672
|
672
|
break
|
|
@@ -1068,7 +1068,7 @@ func GetAllLisDataFor10191(org_id int64) (list []models.HisLabelPrintStatusInfo,
|
1068
|
1068
|
}
|
1069
|
1069
|
|
1070
|
1070
|
func GetHisPrescriptionDrugDetails(org_id int64, start_time_str string, end_time_str string, start_time int64, end_time int64, patient_id int64, item_type int64) (patients []*models.NewPDetail, err error) {
|
1071
|
|
- db := readDb.Table("his_doctor_advice_info as oi").Select("oo.setl_time as setl_time, drug.id as item_id,1 as p_type,oi.id as advice_id,0 as project_id,pp.id as p_id,pp.name as p_name,FROM_UNIXTIME(o.`record_date`, '%Y-%m-%d') as record_date, drug.drug_type as item_cost_type,o.med_type as med_type,oi.`prescribing_number` as cnt,oi.`price` as pric,drug.drug_name as item_name,CONCAT(drug.dose, \"\", drug.dose_unit, \"*\", drug.min_number, \"\", drug.min_unit, \"/\", drug.max_unit) as spec,o.order_status as order_status,oi.`prescribing_number_unit` as unit").
|
|
1071
|
+ db := readDb.Table("his_doctor_advice_info as oi").Select("oo.mdtrt_id as mdtrt_id,oi.advice_doctor as advice_doctor,oo.setl_time as setl_time, drug.id as item_id,1 as p_type,oi.id as advice_id,0 as project_id,pp.id as p_id,pp.name as p_name,FROM_UNIXTIME(o.`record_date`, '%Y-%m-%d') as record_date, drug.drug_type as item_cost_type,o.med_type as med_type,oi.`prescribing_number` as cnt,oi.`price` as pric,drug.drug_name as item_name,CONCAT(drug.dose, \"\", drug.dose_unit, \"*\", drug.min_number, \"\", drug.min_unit, \"/\", drug.max_unit) as spec,o.order_status as order_status,oi.`prescribing_number_unit` as unit").
|
1072
|
1072
|
Joins("JOIN xt_base_drug drug ON oi.drug_id = drug.id ")
|
1073
|
1073
|
if patient_id == 0 {
|
1074
|
1074
|
db = db.Joins("JOIN xt_patients pp on oi.patient_id = pp.id")
|
|
@@ -1094,7 +1094,7 @@ func GetHisPrescriptionDrugDetails(org_id int64, start_time_str string, end_time
|
1094
|
1094
|
}
|
1095
|
1095
|
|
1096
|
1096
|
func GetHisPrescriptionProjectDetails(org_id int64, start_time_str string, end_time_str string, start_time int64, end_time int64, patient_id int64, item_type int64) (patients []*models.NewPDetail, err error) {
|
1097
|
|
- db := readDb.Table("`his_prescription_project` AS oi").Select("oo.setl_time as setl_time,(case oi.type\n\t\t\tWHEN 2 THEN\n\t\t\tproject.id\n\t\t\tWHEN 3 THEN\n\t\t\tgood.id END) AS item_id,oi.type as p_type,oi.id as project_id,0 as advice_id,pp.id as p_id,(case oi.type\n\t\t\tWHEN 2 THEN\n\t\t\tproject.`cost_classify`\n\t\t\tWHEN 3 THEN\n\t\t\t-100 END) AS item_cost_type,\n\t o.med_type as med_type,\n\t oi.count AS cnt,\n \t oi.price AS pric,\n \t pp.name AS p_name, \n \tFROM_UNIXTIME(o.`record_date`,'%Y-%m-%d') as record_date,\n\t\t (case oi.type\n\tWHEN 2 THEN\n\tproject.project_name\n\tWHEN 3 THEN\n\tgood.good_name END) AS item_name,\n\t\t (case oi.type\n\tWHEN 2 THEN\n\t\"\"\n\tWHEN 3 THEN\n\tgood.`specification_name` END) AS spec,\n\toi.`unit` as unit,o.order_status as order_status")
|
|
1097
|
+ db := readDb.Table("`his_prescription_project` AS oi").Select("oo.mdtrt_id as mdtrt_id,oi.doctor as advice_doctor,oo.setl_time as setl_time,(case oi.type\n\t\t\tWHEN 2 THEN\n\t\t\tproject.id\n\t\t\tWHEN 3 THEN\n\t\t\tgood.id END) AS item_id,oi.type as p_type,oi.id as project_id,0 as advice_id,pp.id as p_id,(case oi.type\n\t\t\tWHEN 2 THEN\n\t\t\tproject.`cost_classify`\n\t\t\tWHEN 3 THEN\n\t\t\t-100 END) AS item_cost_type,\n\t o.med_type as med_type,\n\t oi.count AS cnt,\n \t oi.price AS pric,\n \t pp.name AS p_name, \n \tFROM_UNIXTIME(o.`record_date`,'%Y-%m-%d') as record_date,\n\t\t (case oi.type\n\tWHEN 2 THEN\n\tproject.project_name\n\tWHEN 3 THEN\n\tgood.good_name END) AS item_name,\n\t\t (case oi.type\n\tWHEN 2 THEN\n\t\"\"\n\tWHEN 3 THEN\n\tgood.`specification_name` END) AS spec,\n\toi.`unit` as unit,o.order_status as order_status")
|
1098
|
1098
|
db = db.Joins("LEFT JOIN xt_his_project project\n\tON oi.project_id = project.id").
|
1099
|
1099
|
Joins("LEFT JOIN xt_good_information good\n\tON oi.project_id = good.id\n")
|
1100
|
1100
|
//Joins("JOIN his_order ord ON o.batch_number = ord.number ")
|