Browse Source

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

28169 1 week ago
parent
commit
4b565c2998

+ 6 - 8
controllers/his_charge_api_controller.go View File

20
 func HisChargeApiRegistRouters() {
20
 func HisChargeApiRegistRouters() {
21
 	beego.Router("/api/his/chargestatistics/detail", &HisChargeApiController{}, "get:GetChargeStatisticsDetail")
21
 	beego.Router("/api/his/chargestatistics/detail", &HisChargeApiController{}, "get:GetChargeStatisticsDetail")
22
 	beego.Router("/api/his/chargestatistics/settle", &HisChargeApiController{}, "get:GetChargeStatisticsSettle")
22
 	beego.Router("/api/his/chargestatistics/settle", &HisChargeApiController{}, "get:GetChargeStatisticsSettle")
23
-
24
 	beego.Router("/api/his/prescription/detail", &HisChargeApiController{}, "get:GetPrescriptionStatisticsDetail")
23
 	beego.Router("/api/his/prescription/detail", &HisChargeApiController{}, "get:GetPrescriptionStatisticsDetail")
25
 	beego.Router("/api/his/prescription/initdata", &HisChargeApiController{}, "get:GetPrescriptionInitData")
24
 	beego.Router("/api/his/prescription/initdata", &HisChargeApiController{}, "get:GetPrescriptionInitData")
26
-
27
 	//beego.InsertFilter("/api/his/chargestatistics/detail", beego.BeforeRouter, GzipFilter)
25
 	//beego.InsertFilter("/api/his/chargestatistics/detail", beego.BeforeRouter, GzipFilter)
28
-
29
 	beego.Router("/api/his/patient", &HisChargeApiController{}, "get:GetAllPatient")
26
 	beego.Router("/api/his/patient", &HisChargeApiController{}, "get:GetAllPatient")
30
 	//beego.Router("/api/his/chargestatistics/settle", &HisChargeApiController{}, "get:GetChargeStatisticsSettle")
27
 	//beego.Router("/api/his/chargestatistics/settle", &HisChargeApiController{}, "get:GetChargeStatisticsSettle")
31
-
32
 	beego.Router("/api/his/inspectionlist/get", &HisChargeApiController{}, "get:GetHisInspectionList")
28
 	beego.Router("/api/his/inspectionlist/get", &HisChargeApiController{}, "get:GetHisInspectionList")
33
-
34
 	beego.Router("/api/his/inspectionlisttwo/get", &HisChargeApiController{}, "get:GetHisInspectionListTwo")
29
 	beego.Router("/api/his/inspectionlisttwo/get", &HisChargeApiController{}, "get:GetHisInspectionListTwo")
35
-
36
 	beego.Router("/api/his/inspectioninfo/get", &HisChargeApiController{}, "get:GetHisInspectionInfo")
30
 	beego.Router("/api/his/inspectioninfo/get", &HisChargeApiController{}, "get:GetHisInspectionInfo")
37
 
31
 
38
 	//发票
32
 	//发票
42
 	beego.Router("/api/fapiao/delete", &HisChargeApiController{}, "post:DeleteFaPiaoRecord")
36
 	beego.Router("/api/fapiao/delete", &HisChargeApiController{}, "post:DeleteFaPiaoRecord")
43
 	beego.Router("/api/fapiao", &HisChargeApiController{}, "get:GetFaPiaoRecord")
37
 	beego.Router("/api/fapiao", &HisChargeApiController{}, "get:GetFaPiaoRecord")
44
 	beego.Router("/api/fapiao/is_use", &HisChargeApiController{}, "post:UpdateFaPiaoRecordIsUse")
38
 	beego.Router("/api/fapiao/is_use", &HisChargeApiController{}, "post:UpdateFaPiaoRecordIsUse")
45
-
46
 	beego.Router("/api/his/getyidiclear", &HisChargeApiController{}, "get:GetHisYidiClearRecord")
39
 	beego.Router("/api/his/getyidiclear", &HisChargeApiController{}, "get:GetHisYidiClearRecord")
47
-
48
 	beego.Router("/api/his/getexportdata", &HisChargeApiController{}, "get:GetExportData")
40
 	beego.Router("/api/his/getexportdata", &HisChargeApiController{}, "get:GetExportData")
49
 
41
 
50
 }
42
 }
566
 
558
 
567
 	}
559
 	}
568
 	endRecordDateTime := endTime.Unix()
560
 	endRecordDateTime := endTime.Unix()
561
+
569
 	chargePatient, err := service.GetAllPatientChargeSettle(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime, keyword, item_type)
562
 	chargePatient, err := service.GetAllPatientChargeSettle(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime, keyword, item_type)
563
+	sick, _, _ := service.FindAllMZSickList(adminUser.CurrentOrgId, 1, 10000)
564
+	config, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
565
+
570
 	if err == nil {
566
 	if err == nil {
571
 		c.ServeSuccessJSON(map[string]interface{}{
567
 		c.ServeSuccessJSON(map[string]interface{}{
572
 			"patients": chargePatient,
568
 			"patients": chargePatient,
569
+			"config":   config,
570
+			"sick":     sick,
573
 		})
571
 		})
574
 		return
572
 		return
575
 	} else {
573
 	} else {

+ 8 - 6
models/his_charge_models.go View File

95
 }
95
 }
96
 
96
 
97
 type OrderHisPatient struct {
97
 type OrderHisPatient struct {
98
-	ID        int64  `gorm:"column:id" json:"id" form:"id"`
99
-	PatientId int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
100
-	Number    string `gorm:"column:number" json:"number" form:"number"`
101
-	SickType  int64  `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
98
+	ID            int64  `gorm:"column:id" json:"id" form:"id"`
99
+	PatientId     int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
100
+	Number        string `gorm:"column:number" json:"number" form:"number"`
101
+	SickType      int64  `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
102
+	InsuplcAdmdvs string `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
102
 }
103
 }
103
 
104
 
104
 func (OrderHisPatient) TableName() string {
105
 func (OrderHisPatient) TableName() string {
212
 	SickName string `gorm:"sick_name" json:"sick_name" form:"sick_name"`
213
 	SickName string `gorm:"sick_name" json:"sick_name" form:"sick_name"`
213
 	CardDesc string `gorm:"card_desc" json:"card_desc" form:"card_desc"`
214
 	CardDesc string `gorm:"card_desc" json:"card_desc" form:"card_desc"`
214
 
215
 
215
-	//OrderHisPatient OrderHisPatient `gorm:"ForeignKey:Number;AssociationForeignKey:MdtrtId" json:"his"`
216
+	OrderHisPatient OrderHisPatient `gorm:"ForeignKey:Number;AssociationForeignKey:MdtrtId" json:"his"`
216
 }
217
 }
217
 
218
 
218
 func (HisChargeSettleOrder) TableName() string {
219
 func (HisChargeSettleOrder) TableName() string {
505
 	AdviceId     string  `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
506
 	AdviceId     string  `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
506
 	ProjectId    string  `gorm:"column:project_id" json:"project_id" form:"project_id"`
507
 	ProjectId    string  `gorm:"column:project_id" json:"project_id" form:"project_id"`
507
 	ItemId       string  `gorm:"column:item_id" json:"item_id" form:"item_id"`
508
 	ItemId       string  `gorm:"column:item_id" json:"item_id" form:"item_id"`
508
-	//SetlTime     string  `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
509
+	MdtrtId      string  `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
510
+	AdviceDoctor int64   `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
509
 }
511
 }

+ 14 - 14
service/his_charge_service.go View File

594
 		switch item_type {
594
 		switch item_type {
595
 		case 0:
595
 		case 0:
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 {
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
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
598
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
599
 
599
 
600
 			break
600
 			break
601
 		case 1:
601
 		case 1:
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 {
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
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
604
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
605
 
605
 
606
 			break
606
 			break
607
 		case 2:
607
 		case 2:
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 {
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
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
610
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
611
 
611
 
612
 			break
612
 			break
613
 		case 3:
613
 		case 3:
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 {
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
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
616
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
617
 
617
 
618
 			break
618
 			break
619
 		case 4:
619
 		case 4:
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 {
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
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
622
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
623
 
623
 
624
 			break
624
 			break
625
 		case 5:
625
 		case 5:
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 {
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
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
628
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
629
 
629
 
630
 			break
630
 			break
631
 		case 6:
631
 		case 6:
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 {
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
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
634
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
635
 
635
 
636
 			break
636
 			break
642
 		switch item_type {
642
 		switch item_type {
643
 		case 0:
643
 		case 0:
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 {
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
 			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
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
 			break
648
 			break
649
 		case 1:
649
 		case 1:
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 {
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
 			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
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
 			break
654
 			break
655
 		case 2:
655
 		case 2:
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 {
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
 			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
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
 			break
660
 			break
661
 		case 3:
661
 		case 3:
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 {
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
 			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
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
 			break
666
 			break
667
 		case 4:
667
 		case 4:
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 {
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
 			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
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
 			break
672
 			break
1068
 }
1068
 }
1069
 
1069
 
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) {
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
 		Joins("JOIN xt_base_drug drug ON oi.drug_id = drug.id ")
1072
 		Joins("JOIN xt_base_drug drug ON oi.drug_id = drug.id ")
1073
 	if patient_id == 0 {
1073
 	if patient_id == 0 {
1074
 		db = db.Joins("JOIN xt_patients pp on oi.patient_id = pp.id")
1074
 		db = db.Joins("JOIN xt_patients pp on oi.patient_id = pp.id")
1094
 }
1094
 }
1095
 
1095
 
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) {
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
 	db = db.Joins("LEFT JOIN xt_his_project project\n\tON oi.project_id = project.id").
1098
 	db = db.Joins("LEFT JOIN xt_his_project project\n\tON oi.project_id = project.id").
1099
 		Joins("LEFT JOIN xt_good_information good\n\tON oi.project_id = good.id\n")
1099
 		Joins("LEFT JOIN xt_good_information good\n\tON oi.project_id = good.id\n")
1100
 	//Joins("JOIN his_order ord ON o.batch_number = ord.number ")
1100
 	//Joins("JOIN his_order ord ON o.batch_number = ord.number ")

+ 1 - 1
service/user_service.go View File

143
 
143
 
144
 func GetAllDoctor(orgid int64, appid int64) (appRole []*models.App_Role, err error) {
144
 func GetAllDoctor(orgid int64, appid int64) (appRole []*models.App_Role, err error) {
145
 
145
 
146
-	err = UserReadDB().Where("org_id = ? AND app_id = ? AND status = ? AND  (user_type = ? OR user_type = ?) ", orgid, appid, 1, 2, 1).Find(&appRole).Error
146
+	err = UserReadDB().Where("org_id = ? AND status = ? AND  (user_type = ? OR user_type = ?) ", orgid, 1, 2, 1).Find(&appRole).Error
147
 	return appRole, err
147
 	return appRole, err
148
 }
148
 }
149
 
149