Browse Source

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

xmg123 4 days ago
parent
commit
22533996f7

+ 11 - 13
controllers/his_api_controller.go View File

@@ -71,35 +71,24 @@ func HisManagerApiRegistRouters() {
71 71
 	beego.Router("/api/comparedata/get", &HisApiController{}, "get:GetCompareData")
72 72
 	beego.Router("/api/fapiao/get", &HisApiController{}, "get:GetFaPiaoData")
73 73
 	beego.Router("/api/incomestatistics/get", &HisApiController{}, "get:GetIncomeStatisticsData")
74
-
75 74
 	beego.Router("/api/postprojectinformation", &HisApiController{}, "post:PostProjectInformation")
76 75
 	beego.Router("/api/hisprescriptiontemplate/create", &HisApiController{}, "post:CreateHisPrescriptionTemplate")
77 76
 	beego.Router("/api/privateexpenses/get", &HisApiController{}, "get:GetPrivateExpensesInfo")
78 77
 	beego.Router("/api/changemedtype/post", &HisApiController{}, "post:ChangeMedType")
79
-
80 78
 	beego.Router("/api/refunddetail/post", &HisApiController{}, "post:RefudDetail")
81
-
82 79
 	beego.Router("/api/privateexpensesorder/get", &HisApiController{}, "get:GetPrivateExpensesOrder")
83
-
84 80
 	beego.Router("/api/uncharge/list", &HisApiController{}, "get:GetHisUnChargePatientList")
85
-
86 81
 	beego.Router("/api/monthcharge/info", &HisApiController{}, "get:GetHisMonthChargePatientInfo")
87 82
 	beego.Router("/api/monthhispatient/get", &HisApiController{}, "get:GetHisMonthPatientInfo")
88
-
89 83
 	beego.Router("/api/orders", &HisApiController{}, "get:GetAllOrder")
90 84
 
91 85
 	beego.Router("/api/psn/ncds/delete", &HisApiController{}, "post:DeleteNCDS")
92 86
 	beego.Router("/api/bailin/export", &PublicApiController{}, "get:GetBaiLinExportData")
93 87
 	beego.Router("/api/his/gethistdoctoradviceinfo", &HisApiController{}, "get:GetHisDoctorAdviceInfo")
94
-
95 88
 	beego.Router("/api/his/gethistdoctoradviceinfo", &HisApiController{}, "get:GetHisDoctorAdviceInfo")
96
-
97 89
 	beego.Router("/api/monthcharge/list", &HisApiController{}, "get:GetHisMonthChargePatientList")
98
-
99 90
 	beego.Router("/api/test/get", &HisApiController{}, "get:GetTestOrder")
100
-
101 91
 	beego.Router("/api/batch/settleaccount", &HisApiController{}, "get:GetBatchSettleAccounts")
102
-
103 92
 	beego.Router("/api/monthhispatient", &HisApiController{}, "get:GetMonthHisPatient")
104 93
 	beego.Router("/api/changeorderdesc", &HisApiController{}, "get:ChangeOrderDesc")
105 94
 	beego.Router("/api/getfapiaonumber", &HisApiController{}, "get:GetFaPiaoNumber")
@@ -1567,8 +1556,17 @@ func (c *HisApiController) GetHisPatientList() {
1567 1556
 	}
1568 1557
 	recordDateTime := theTime.Unix()
1569 1558
 	adminInfo := c.GetAdminUserInfo()
1570
-	patients, _ := service.GetNewHisPatientList(adminInfo.CurrentOrgId, recordDateTime, sch_type, 0)
1571
-	patients_two, _ := service.GetScheduleHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime, sch_type, 0)
1559
+	var patients []*service.PatientTwo
1560
+	var patients_two []*service.Patients
1561
+
1562
+	if c.GetAdminUserInfo().CurrentOrgId == 10768 {
1563
+		patients, _ = service.GetNewHisPatientListBySource(adminInfo.CurrentOrgId, recordDateTime, sch_type, 0)
1564
+		patients_two, _ = service.GetScheduleHisPatientListSource(adminInfo.CurrentOrgId, "", recordDateTime, sch_type, 0)
1565
+
1566
+	} else {
1567
+		patients, _ = service.GetNewHisPatientList(adminInfo.CurrentOrgId, recordDateTime, sch_type, 0)
1568
+		patients_two, _ = service.GetScheduleHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime, sch_type, 0)
1569
+	}
1572 1570
 
1573 1571
 	if patient_type == 2 && c.GetAdminUserInfo().CurrentOrgId == 10721 {
1574 1572
 		patients_three, _ := service.GetFuTouHisPatientList(adminInfo.CurrentOrgId, recordDateTime)

+ 19 - 8
controllers/his_hospital_api_controller.go View File

@@ -442,12 +442,24 @@ func (c *HisHospitalApiController) GetHisHospitalPatientList() {
442 442
 	recordDateTime := theTime.Unix()
443 443
 	adminInfo := c.GetAdminUserInfo()
444 444
 	//var patients []*service.HospitalPatient
445
+
445 446
 	var all_tempPatients []*service.HospitalPatient
446
-	tempPatients, _ := service.GetHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime, sch_type)
447
-	tempPatients_two, _ := service.GetHisHospitalSchPatientList(adminInfo.CurrentOrgId, recordDateTime, sch_type)
447
+	var tempPatients []*service.HospitalPatient
448
+	var tempPatients_two []*service.HospitalPatient
448 449
 
450
+	if adminInfo.CurrentOrgId == 10768 {
451
+		tempPatients, _ = service.GetHisHospitalPatientListBySource(adminInfo.CurrentOrgId, recordDateTime, sch_type)
452
+		tempPatients_two, _ = service.GetHisHospitalSchPatientListBySource(adminInfo.CurrentOrgId, recordDateTime, sch_type)
453
+	} else {
454
+		tempPatients, _ = service.GetHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime, sch_type)
455
+		tempPatients_two, _ = service.GetHisHospitalSchPatientList(adminInfo.CurrentOrgId, recordDateTime, sch_type)
456
+	}
449 457
 	if types == 0 {
450
-		all_tempPatients, _ = service.GetAllHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime, sch_type)
458
+		if adminInfo.CurrentOrgId == 10768 {
459
+			all_tempPatients, _ = service.GetAllHisHospitalPatientListBySource(adminInfo.CurrentOrgId, recordDateTime, sch_type)
460
+		} else {
461
+			all_tempPatients, _ = service.GetAllHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime, sch_type)
462
+		}
451 463
 		for _, item := range all_tempPatients {
452 464
 			for index, subItem := range tempPatients_two {
453 465
 				if item.ID == subItem.ID {
@@ -476,10 +488,10 @@ func (c *HisHospitalApiController) GetHisHospitalPatientList() {
476 488
 
477 489
 	for _, item := range tempPatients {
478 490
 
479
-		if item.VMHisPrescriptionInfo.ID == 0 {
491
+		if len(item.HisPrescription) == 0 {
480 492
 			total_one = total_one + 1
481 493
 		}
482
-		if item.VMHisPrescriptionInfo.ID > 0 {
494
+		if len(item.HisPrescription) > 0 {
483 495
 			total_two = total_two + 1
484 496
 		}
485 497
 	}
@@ -501,7 +513,7 @@ func (c *HisHospitalApiController) GetHisHospitalPatientList() {
501 513
 	} else if types == 1 { //未就诊
502 514
 		var patientsOne []*service.HospitalPatient
503 515
 		for _, item := range tempPatients {
504
-			if item.VMHisPrescriptionInfo.ID == 0 {
516
+			if len(item.HisPrescription) == 0 {
505 517
 				patientsOne = append(patientsOne, item)
506 518
 			}
507 519
 		}
@@ -517,8 +529,7 @@ func (c *HisHospitalApiController) GetHisHospitalPatientList() {
517 529
 	} else if types == 2 { //已就诊
518 530
 		var patientsTwo []*service.HospitalPatient
519 531
 		for _, item := range tempPatients {
520
-
521
-			if item.VMHisPrescriptionInfo.ID > 0 {
532
+			if len(item.HisPrescription) > 0 {
522 533
 				patientsTwo = append(patientsTwo, item)
523 534
 			}
524 535
 		}

+ 2 - 2
controllers/patient_api_controller.go View File

@@ -5768,7 +5768,8 @@ func patientFormData(patient *models.Patients, data []byte, method string) (cont
5768 5768
 	}
5769 5769
 	patient.IdCardNo = idCardNo
5770 5770
 
5771
-	patient.PatientType = 1
5771
+	insuplc_admdvs, _ := patientBody["insuplc_admdvs"].(string)
5772
+	patient.InsuplcAdmdvs = insuplc_admdvs
5772 5773
 
5773 5774
 	if patientBody["dialysisNo"] == nil || reflect.TypeOf(patientBody["dialysisNo"]).String() != "string" {
5774 5775
 		utils.ErrorLog("dialysisNo")
@@ -5782,7 +5783,6 @@ func patientFormData(patient *models.Patients, data []byte, method string) (cont
5782 5783
 		return
5783 5784
 	}
5784 5785
 	patient.DialysisNo = dialysisNo
5785
-	// }
5786 5786
 
5787 5787
 	if patientBody["lapseto"] == nil || reflect.TypeOf(patientBody["lapseto"]).String() != "float64" {
5788 5788
 		utils.ErrorLog("lapseto")

+ 26 - 8
controllers/pharmacy_controller.go View File

@@ -275,14 +275,15 @@ func (this *PharmacyController) WaitingDrug() {
275 275
 	stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
276 276
 	stime = stmp.Unix()
277 277
 
278
+	var patients []*models.PharmacyPatients
278 279
 	is_medicine := 0
279 280
 	w_his_advice_patient, _ := service.GetWaitPharmacyHISAdvicePatient(partition, shift, stime, orgid, keyword, is_medicine)
280
-	w_xt_advice_patient, _ := service.GetWaitPharmacyXTPatient(partition, shift, stime, orgid, keyword, is_medicine)
281
+	if orgid != 10217 {
282
+		w_xt_advice_patient, _ := service.GetWaitPharmacyXTPatient(partition, shift, stime, orgid, keyword, is_medicine)
283
+		patients = append(patients, w_xt_advice_patient...)
284
+	}
281 285
 
282
-	var patients []*models.PharmacyPatients
283 286
 	patients = append(patients, w_his_advice_patient...)
284
-	patients = append(patients, w_xt_advice_patient...)
285
-
286 287
 	good_info, _ := service.GetGoodCodeOpen(orgid)
287 288
 	if good_info.IsOpen == 1 {
288 289
 		w_his_goods_patient, _ := service.GetWaitPharmacyHISGoodsPatient(partition, shift, stime, orgid, keyword, is_medicine)
@@ -323,8 +324,12 @@ func (this *PharmacyController) GetPharmacyContent() {
323 324
 	}
324 325
 	var list []*models.PharmacyContent
325 326
 	list, err = service.GetPatientMedication(orgid, patient_id, stime, etime, is_medicine)
326
-	list_p, err := service.GetPatientProject(orgid, patient_id, stime, etime, is_medicine)
327
-	list = append(list, list_p...)
327
+
328
+	good_info, _ := service.GetGoodCodeOpen(orgid)
329
+	if good_info.IsOpen == 1 {
330
+		list_p, _ := service.GetPatientProject(orgid, patient_id, stime, etime, is_medicine)
331
+		list = append(list, list_p...)
332
+	}
328 333
 	baseList, _ := service.GetAllBaseDrugListTwo(orgid)
329 334
 	patients, _ := service.GetPatientByIDOne(orgid, patient_id)
330 335
 	//zoneList, _ := service.GetAllZoneByList(orgid)
@@ -504,7 +509,13 @@ func (this *PharmacyController) DispensingMedicine() {
504 509
 		//发药
505 510
 		err = service.DispensingMedicine(orgid, patient_id, stime, etime, creater)
506 511
 
507
-		err = service.DispensingGoods(orgid, patient_id, stime, etime, creater)
512
+		good_info, _ := service.GetGoodCodeOpen(orgid)
513
+		if good_info.IsOpen == 1 {
514
+			//list_p, _ := service.GetPatientProject(orgid, patient_id, stime, etime, is_medicine)
515
+			//list = append(list, list_p...)
516
+			err = service.DispensingGoods(orgid, patient_id, stime, etime, creater)
517
+
518
+		}
508 519
 
509 520
 		if err != nil {
510 521
 			utils.ErrorLog(err.Error())
@@ -522,7 +533,14 @@ func (this *PharmacyController) DispensingMedicine() {
522 533
 		//发药逻辑
523 534
 
524 535
 		service.DispensingMedicineOne(orgid, patient_id, stime, etime, creater)
525
-		err = service.DispensingGoods(orgid, patient_id, stime, etime, creater)
536
+		//err = service.DispensingGoods(orgid, patient_id, stime, etime, creater)
537
+		good_info, _ := service.GetGoodCodeOpen(orgid)
538
+		if good_info.IsOpen == 1 {
539
+			//list_p, _ := service.GetPatientProject(orgid, patient_id, stime, etime, is_medicine)
540
+			//list = append(list, list_p...)
541
+			err = service.DispensingGoods(orgid, patient_id, stime, etime, creater)
542
+
543
+		}
526 544
 
527 545
 		//针对桑植盛康
528 546
 		if orgid == 10387 || orgid == 3877 {

+ 25 - 17
models/patient_models.go View File

@@ -28,6 +28,7 @@ type MSchedualPatientList struct {
28 28
 	FirstLetter        string `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
29 29
 	IsInfectious       int64  `gorm:"column:is_infectious" json:"is_infectious" form:"is_infectious"`
30 30
 	Height             int64  `gorm:"column:height" json:"height" form:"height"`
31
+	InsuplcAdmdvs      string `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
31 32
 }
32 33
 
33 34
 func (MSchedualPatientList) TableName() string {
@@ -113,17 +114,18 @@ func (VMDoctorAdviceForList) TableName() string {
113 114
 }
114 115
 
115 116
 type PatientListForFace struct {
116
-	ID          int64  `gorm:"column:id" json:"id" form:"id"`
117
-	UserOrgId   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
118
-	Name        string `gorm:"column:name" json:"name" form:"name"`
119
-	Avatar      string `gorm:"column:avatar" json:"avatar" form:"avatar"`
120
-	DialysisNo  string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
121
-	IdCardNo    string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
122
-	Birthday    int64  `gorm:"column:birthday" json:"birthday" form:"birthday"`
123
-	Phone       string `gorm:"column:phone" json:"phone" form:"phone"`
124
-	Age         int64  `gorm:"column:age" json:"age"`
125
-	CreatedTime int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
126
-	UpdatedTime int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
117
+	ID            int64  `gorm:"column:id" json:"id" form:"id"`
118
+	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
119
+	Name          string `gorm:"column:name" json:"name" form:"name"`
120
+	Avatar        string `gorm:"column:avatar" json:"avatar" form:"avatar"`
121
+	DialysisNo    string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
122
+	IdCardNo      string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
123
+	Birthday      int64  `gorm:"column:birthday" json:"birthday" form:"birthday"`
124
+	Phone         string `gorm:"column:phone" json:"phone" form:"phone"`
125
+	Age           int64  `gorm:"column:age" json:"age"`
126
+	CreatedTime   int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
127
+	UpdatedTime   int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
128
+	InsuplcAdmdvs string `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
127 129
 }
128 130
 
129 131
 func (PatientListForFace) TableName() string {
@@ -952,6 +954,7 @@ type CdmPatients struct {
952 954
 	UpdatedTime        int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
953 955
 	UserSysBeforeCount int64  `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
954 956
 	SchRemark          string `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
957
+	InsuplcAdmdvs      string `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
955 958
 }
956 959
 
957 960
 func (CdmPatients) TableName() string {
@@ -1171,12 +1174,13 @@ type VmInspection struct {
1171 1174
 }
1172 1175
 
1173 1176
 type BloodXtPatients struct {
1174
-	ID          int64  `gorm:"column:id" json:"id" form:"id"`
1175
-	UserOrgId   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1176
-	DialysisNo  string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
1177
-	Name        string `gorm:"column:name" json:"name" form:"name"`
1178
-	IdCardNo    string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
1179
-	PatientType int64  `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
1177
+	ID            int64  `gorm:"column:id" json:"id" form:"id"`
1178
+	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1179
+	DialysisNo    string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
1180
+	Name          string `gorm:"column:name" json:"name" form:"name"`
1181
+	IdCardNo      string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
1182
+	PatientType   int64  `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
1183
+	InsuplcAdmdvs string `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
1180 1184
 }
1181 1185
 
1182 1186
 func (BloodXtPatients) TableName() string {
@@ -1271,6 +1275,7 @@ type XtPatients struct {
1271 1275
 	Url                          string  `gorm:"column:url" json:"url" form:"url"`
1272 1276
 	FirstLetter                  string  `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
1273 1277
 	InsuplcAdmdvsName            string  `gorm:"column:insuplc_admdvs_name" json:"insuplc_admdvs_name" form:"insuplc_admdvs_name"`
1278
+	InsuplcAdmdvs                string  `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
1274 1279
 }
1275 1280
 
1276 1281
 func (XtPatients) TableName() string {
@@ -1506,6 +1511,7 @@ type VmPatients struct {
1506 1511
 	SchRemark                    string  `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
1507 1512
 	OutReason                    string  `gorm:"column:out_reason" json:"out_reason" form:"out_reason"`
1508 1513
 	DeathTime                    int64   `gorm:"column:death_time" json:"death_time" form:"death_time"`
1514
+	InsuplcAdmdvs                string  `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
1509 1515
 }
1510 1516
 
1511 1517
 func (VmPatients) TableName() string {
@@ -1774,6 +1780,7 @@ type PatientsThirty struct {
1774 1780
 	Name          string `gorm:"column:name" json:"name" form:"name"`
1775 1781
 	TotalDialysis int64  `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
1776 1782
 	Lapseto       int64  `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
1783
+	InsuplcAdmdvs string `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
1777 1784
 }
1778 1785
 
1779 1786
 func (PatientsThirty) TableName() string {
@@ -1795,6 +1802,7 @@ type XtNewPatients struct {
1795 1802
 	SchRemark          string `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
1796 1803
 	ScheduleRemark     string `gorm:"column:schedule_remark" json:"schedule_remark" form:"schedule_remark"`
1797 1804
 	Status             int64  `gorm:"column:status" json:"status" form:"status"`
1805
+	InsuplcAdmdvs      string `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
1798 1806
 }
1799 1807
 
1800 1808
 func (XtNewPatients) TableName() string {

+ 56 - 0
service/his_hospital_service.go View File

@@ -16,6 +16,7 @@ type HospitalPatient struct {
16 16
 	Schedule               Schedule                      `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"schedule"`
17 17
 	HisHospitalCheckRecord models.HisHospitalCheckRecord `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"his_patient"`
18 18
 	VMHisPrescriptionInfo  VMHisPrescriptionInfo         `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"info"`
19
+	HisPrescription        []models.HisPrescription      `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"ps"`
19 20
 	HisHospitalOrder       models.HisHospitalOrder       `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"order"`
20 21
 	FirstLetter            string                        `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
21 22
 }
@@ -81,6 +82,20 @@ func GetAllHisHospitalPatientList(org_id int64, record_date int64, sch_type int6
81 82
 	db = db.Preload("HisHospitalCheckRecord", func(db *gorm.DB) *gorm.DB {
82 83
 		return db.Where("user_org_id = ? AND status = 1  AND in_hospital_status = 1 AND out_hospital_status = 0", org_id).Order("id desc")
83 84
 	})
85
+	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type = 1", org_id, record_date)
86
+	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1  AND p_type = 1", org_id, record_date).Group("id").Find(&patients).Error
87
+	return
88
+}
89
+
90
+func GetAllHisHospitalPatientListBySource(org_id int64, record_date int64, sch_type int64) (patients []*HospitalPatient, err error) {
91
+	db := readDb.Model(&HospitalPatient{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1 and xt_patients.source = 2", org_id)
92
+	db = db.Joins("join his_hospital_check_record as record ON record.patient_id = xt_patients.id AND record.status = 1 AND record.user_org_id = ? AND record.in_hospital_status = 1", org_id)
93
+	//db = db.Joins("join xt_schedule as sch ON sch.patient_id = xt_patients.id AND sch.status = 1 AND sch.user_org_id = ? AND sch.schedule_date = ? AND sch.schedule_type = ? ", org_id, record_date, sch_type)
94
+	db = db.Preload("HisHospitalCheckRecord", func(db *gorm.DB) *gorm.DB {
95
+		return db.Where("user_org_id = ? AND status = 1  AND in_hospital_status = 1 AND out_hospital_status = 0", org_id).Order("id desc")
96
+	})
97
+	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type = 1", org_id, record_date)
98
+
84 99
 	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1  AND p_type = 1", org_id, record_date).Group("id").Find(&patients).Error
85 100
 	return
86 101
 }
@@ -92,6 +107,8 @@ func GetHisHospitalPatientList(org_id int64, record_date int64, sch_type int64)
92 107
 	db = db.Preload("HisHospitalCheckRecord", func(db *gorm.DB) *gorm.DB {
93 108
 		return db.Where("user_org_id = ? AND status = 1  AND in_hospital_status = 1 AND out_hospital_status = 0", org_id).Order("id desc")
94 109
 	})
110
+	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type = 1", org_id, record_date)
111
+
95 112
 	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type = 1", org_id, record_date).Group("id").Find(&patients).Error
96 113
 	return
97 114
 }
@@ -103,6 +120,7 @@ func GetHisHospitalSchPatientList(org_id int64, record_date int64, sch_type int6
103 120
 		db = db.Preload("HisHospitalCheckRecord", func(db *gorm.DB) *gorm.DB {
104 121
 			return db.Where("user_org_id = ? AND status = 1  AND in_hospital_status = 1 AND out_hospital_status = 0", org_id).Order("id desc")
105 122
 		})
123
+		db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type = 1", org_id, record_date)
106 124
 		err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type = 1", org_id, record_date).Group("id").Find(&patients).Error
107 125
 		return
108 126
 
@@ -112,6 +130,44 @@ func GetHisHospitalSchPatientList(org_id int64, record_date int64, sch_type int6
112 130
 		db = db.Preload("HisHospitalCheckRecord", func(db *gorm.DB) *gorm.DB {
113 131
 			return db.Where("user_org_id = ? AND status = 1  AND in_hospital_status = 1 AND out_hospital_status = 0", org_id).Order("id desc")
114 132
 		})
133
+		db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type = 1", org_id, record_date)
134
+		err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type = 1", org_id, record_date).Group("id").Find(&patients).Error
135
+		return
136
+
137
+	}
138
+
139
+}
140
+
141
+func GetHisHospitalPatientListBySource(org_id int64, record_date int64, sch_type int64) (patients []*HospitalPatient, err error) {
142
+	db := readDb.Model(&HospitalPatient{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1 and xt_patients.source = 2", org_id)
143
+	db = db.Joins("join his_hospital_check_record as record ON record.patient_id = xt_patients.id AND record.status = 1 AND record.user_org_id = ? AND record.in_hospital_status = 1 AND record.record_date = ? ", org_id, record_date)
144
+	db = db.Joins("join xt_schedule as sch ON sch.patient_id = xt_patients.id AND sch.status = 1 AND sch.user_org_id = ? AND sch.schedule_date = ? AND sch.schedule_type = ? ", org_id, record_date, sch_type)
145
+	db = db.Preload("HisHospitalCheckRecord", func(db *gorm.DB) *gorm.DB {
146
+		return db.Where("user_org_id = ? AND status = 1  AND in_hospital_status = 1 AND out_hospital_status = 0", org_id).Order("id desc")
147
+	})
148
+	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type = 1", org_id, record_date)
149
+	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type = 1", org_id, record_date).Group("id").Find(&patients).Error
150
+	return
151
+}
152
+
153
+func GetHisHospitalSchPatientListBySource(org_id int64, record_date int64, sch_type int64) (patients []*HospitalPatient, err error) {
154
+	if sch_type > 0 {
155
+		db := readDb.Model(&HospitalPatient{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1 and xt_patients.source = 2", org_id)
156
+		db = db.Joins("join xt_schedule as sch ON sch.patient_id = xt_patients.id AND sch.status = 1 AND sch.user_org_id = ? AND sch.schedule_date = ? AND sch.schedule_type = ? ", org_id, record_date, sch_type)
157
+		db = db.Preload("HisHospitalCheckRecord", func(db *gorm.DB) *gorm.DB {
158
+			return db.Where("user_org_id = ? AND status = 1  AND in_hospital_status = 1 AND out_hospital_status = 0", org_id).Order("id desc")
159
+		})
160
+		db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type = 1", org_id, record_date)
161
+		err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type = 1", org_id, record_date).Group("id").Find(&patients).Error
162
+		return
163
+
164
+	} else {
165
+		db := readDb.Model(&HospitalPatient{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1 and xt_patients.source = 2", org_id)
166
+		db = db.Joins("join xt_schedule as sch ON sch.patient_id = xt_patients.id AND sch.status = 1 AND sch.user_org_id = ? AND sch.schedule_date = ?  ", org_id, record_date)
167
+		db = db.Preload("HisHospitalCheckRecord", func(db *gorm.DB) *gorm.DB {
168
+			return db.Where("user_org_id = ? AND status = 1  AND in_hospital_status = 1 AND out_hospital_status = 0", org_id).Order("id desc")
169
+		})
170
+		db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type = 1", org_id, record_date)
115 171
 		err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type = 1", org_id, record_date).Group("id").Find(&patients).Error
116 172
 		return
117 173
 

+ 28 - 0
service/his_service.go View File

@@ -161,6 +161,21 @@ func GetScheduleHisPatientList(org_id int64, keywords string, record_date int64,
161 161
 	return
162 162
 }
163 163
 
164
+func GetScheduleHisPatientListSource(org_id int64, keywords string, record_date int64, sch_type int64, patient_type int64) (patients []*Patients, err error) {
165
+	db := readDb.Model(&Patients{}).Select("xt_patients.id,xt_patients.user_org_id,xt_patients.name,xt_patients.status,xt_patients.id_card_no,xt_patients.first_letter,xt_patients.patient_type,sch.schedule_type as sch_type").Where("xt_patients.user_org_id = ? AND xt_patients.status = 1 and xt_patients.patient_type <> 4 and xt_patients.source = 1", org_id)
166
+
167
+	if sch_type != 0 {
168
+		db = db.Joins("join xt_schedule as sch ON sch.patient_id = xt_patients.id AND sch.schedule_date = ? AND sch.status = 1 AND sch.user_org_id = ? AND sch.schedule_type = ?", record_date, org_id, sch_type)
169
+	} else {
170
+		db = db.Joins("join xt_schedule as sch ON sch.patient_id = xt_patients.id AND sch.schedule_date = ? AND sch.status = 1 AND sch.user_org_id = ? ", record_date, org_id)
171
+	}
172
+
173
+	db = db.Preload("HisPatient", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
174
+	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1", org_id, record_date)
175
+	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1", org_id, record_date).Group("xt_patients.id").Find(&patients).Error
176
+	return
177
+}
178
+
164 179
 func GetScheduleHisPatientListTwo(org_id int64, record_date int64) (patients []*Patients, err error) {
165 180
 	db := readDb.Model(&Patients{}).Select("xt_patients.id,xt_patients.user_org_id,xt_patients.name,xt_patients.status,xt_patients.id_card_no,xt_patients.first_letter,xt_patients.patient_type").Where("xt_patients.user_org_id = ? AND xt_patients.status = 1 and xt_patients.patient_type = 4", org_id)
166 181
 
@@ -301,6 +316,19 @@ func GetNewHisPatientList(org_id int64, record_date int64, sch_type int64, patie
301 316
 	return
302 317
 }
303 318
 
319
+func GetNewHisPatientListBySource(org_id int64, record_date int64, sch_type int64, patient_type int64) (patients []*PatientTwo, err error) {
320
+	db := readDb.Model(&PatientTwo{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1 and xt_patients.patient_type <> 4 and xt_patients.source = 1", org_id).
321
+		Joins("join his_patient as hp ON hp.patient_id = xt_patients.id AND hp.record_date = ? AND hp.status = 1 AND hp.user_org_id = ?", record_date, org_id)
322
+	if sch_type > 0 {
323
+		db = db.Joins("join xt_schedule as sch ON sch.patient_id = xt_patients.id AND sch.schedule_date = ? AND sch.status = 1 AND sch.user_org_id = ? AND schedule_type = ?", record_date, org_id, sch_type)
324
+	}
325
+	db = db.Preload("HisPatient", func(db *gorm.DB) *gorm.DB {
326
+		return db.Preload("HisPrescriptionTwo", "status = 1 AND user_org_id = ?  AND record_date = ?", org_id, record_date).Where("user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
327
+	})
328
+	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date).Group("id").Find(&patients).Error
329
+	return
330
+}
331
+
304 332
 func GetNewHisPatientListTwo(org_id int64, record_date int64, sch_type int64) (patients []*PatientThree, err error) {
305 333
 	db := readDb.Model(&PatientThree{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
306 334
 	//if sch_type > 0 {