Browse Source

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

XMLWAN 3 years ago
parent
commit
ff4606537e

+ 60 - 59
controllers/base_api_controller.go View File

@@ -2,6 +2,7 @@ package controllers
2 2
 
3 3
 import (
4 4
 	"XT_New/enums"
5
+	"XT_New/models"
5 6
 	"XT_New/service"
6 7
 	"fmt"
7 8
 	"strconv"
@@ -69,36 +70,36 @@ type BaseAuthAPIController struct {
69 70
 func (this *BaseAuthAPIController) Prepare() {
70 71
 	this.BaseAPIController.Prepare()
71 72
 	if this.GetAdminUserInfo() == nil {
72
-		//var userAdmin models.AdminUser
73
-		//userAdmin.Id = 1448
74
-		//userAdmin.Mobile = "13318599895"
75
-		//
76
-		//userAdmin.Id = 597
77
-		//userAdmin.Mobile = "19874122664"
78
-		//userAdmin.IsSuperAdmin = false
79
-		//userAdmin.Status = 1
80
-		//userAdmin.CreateTime = 1530786071
81
-		//userAdmin.ModifyTime = 1530786071
82
-		//var subscibe models.ServeSubscibe
83
-		//subscibe.ID = 1
84
-		//subscibe.OrgId = 9671
85
-		//subscibe.PeriodStart = 1538035409
86
-		//subscibe.PeriodEnd = 1569571409
87
-		//subscibe.State = 1
88
-		//subscibe.Status = 1
89
-		//subscibe.CreatedTime = 1538035409
90
-		//subscibe.UpdatedTime = 1538035409
91
-		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
92
-		//subscibes[4] = &subscibe
93
-		//var adminUserInfo service.AdminUserInfo
94
-		//adminUserInfo.CurrentOrgId = 9671
95
-		//adminUserInfo.CurrentAppId = 9671
96
-		//adminUserInfo.AdminUser = &userAdmin
97
-		//adminUserInfo.Subscibes = subscibes
98
-		//this.SetSession("admin_user_info", &adminUserInfo)
99
-
100
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
101
-		this.StopRun()
73
+		var userAdmin models.AdminUser
74
+		userAdmin.Id = 1448
75
+		userAdmin.Mobile = "13318599895"
76
+
77
+		userAdmin.Id = 597
78
+		userAdmin.Mobile = "19874122664"
79
+		userAdmin.IsSuperAdmin = false
80
+		userAdmin.Status = 1
81
+		userAdmin.CreateTime = 1530786071
82
+		userAdmin.ModifyTime = 1530786071
83
+		var subscibe models.ServeSubscibe
84
+		subscibe.ID = 1
85
+		subscibe.OrgId = 9675
86
+		subscibe.PeriodStart = 1538035409
87
+		subscibe.PeriodEnd = 1569571409
88
+		subscibe.State = 1
89
+		subscibe.Status = 1
90
+		subscibe.CreatedTime = 1538035409
91
+		subscibe.UpdatedTime = 1538035409
92
+		subscibes := make(map[int64]*models.ServeSubscibe, 0)
93
+		subscibes[4] = &subscibe
94
+		var adminUserInfo service.AdminUserInfo
95
+		adminUserInfo.CurrentOrgId = 9675
96
+		adminUserInfo.CurrentAppId = 4
97
+		adminUserInfo.AdminUser = &userAdmin
98
+		adminUserInfo.Subscibes = subscibes
99
+		this.SetSession("admin_user_info", &adminUserInfo)
100
+
101
+		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
102
+		//this.StopRun()
102 103
 
103 104
 	}
104 105
 
@@ -315,35 +316,35 @@ type BaseServeAPIController struct {
315 316
 func (this *BaseServeAPIController) Prepare() {
316 317
 	this.BaseAPIController.Prepare()
317 318
 	if this.GetAdminUserInfo() == nil {
318
-		//var userAdmin models.AdminUser
319
-		//userAdmin.Id = 1448
320
-		//userAdmin.Mobile = "13318599895"
321
-		//
322
-		//userAdmin.Id = 597
323
-		//userAdmin.Mobile = "19874122664"
324
-		//userAdmin.IsSuperAdmin = false
325
-		//userAdmin.Status = 1
326
-		//userAdmin.CreateTime = 1530786071
327
-		//userAdmin.ModifyTime = 1530786071
328
-		//var subscibe models.ServeSubscibe
329
-		//subscibe.ID = 1
330
-		//subscibe.OrgId = 9671
331
-		//subscibe.PeriodStart = 1538035409
332
-		//subscibe.PeriodEnd = 1569571409
333
-		//subscibe.State = 1
334
-		//subscibe.Status = 1
335
-		//subscibe.CreatedTime = 1538035409
336
-		//subscibe.UpdatedTime = 1538035409
337
-		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
338
-		//subscibes[4] = &subscibe
339
-		//var adminUserInfo service.AdminUserInfo
340
-		//adminUserInfo.CurrentOrgId = 9671
341
-		//adminUserInfo.CurrentAppId = 9671
342
-		//adminUserInfo.AdminUser = &userAdmin
343
-		//adminUserInfo.Subscibes = subscibes
344
-		//this.SetSession("admin_user_info", &adminUserInfo)
345
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
346
-		this.StopRun()
319
+		var userAdmin models.AdminUser
320
+		userAdmin.Id = 1448
321
+		userAdmin.Mobile = "13318599895"
322
+
323
+		userAdmin.Id = 597
324
+		userAdmin.Mobile = "19874122664"
325
+		userAdmin.IsSuperAdmin = false
326
+		userAdmin.Status = 1
327
+		userAdmin.CreateTime = 1530786071
328
+		userAdmin.ModifyTime = 1530786071
329
+		var subscibe models.ServeSubscibe
330
+		subscibe.ID = 1
331
+		subscibe.OrgId = 9675
332
+		subscibe.PeriodStart = 1538035409
333
+		subscibe.PeriodEnd = 1569571409
334
+		subscibe.State = 1
335
+		subscibe.Status = 1
336
+		subscibe.CreatedTime = 1538035409
337
+		subscibe.UpdatedTime = 1538035409
338
+		subscibes := make(map[int64]*models.ServeSubscibe, 0)
339
+		subscibes[4] = &subscibe
340
+		var adminUserInfo service.AdminUserInfo
341
+		adminUserInfo.CurrentOrgId = 9675
342
+		adminUserInfo.CurrentAppId = 4
343
+		adminUserInfo.AdminUser = &userAdmin
344
+		adminUserInfo.Subscibes = subscibes
345
+		this.SetSession("admin_user_info", &adminUserInfo)
346
+		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
347
+		//this.StopRun()
347 348
 	}
348 349
 
349 350
 	//if adminUserInfo.AppRole != nil {

+ 2 - 0
controllers/his_api_controller.go View File

@@ -396,6 +396,8 @@ func (c *HisApiController) GetHisPatientInfo() {
396 396
 	//endRecordDateTime := endTime.Unix()
397 397
 	admin := c.GetAdminUserInfo()
398 398
 	his_patient_info, _ := service.GetNewHisPatientInfoTwo(admin.CurrentOrgId, his_patient_id, recordDateTime)
399
+	//his_patient_info, _ := service.GetNewHisPatientInfoTwo(admin.CurrentOrgId, his_patient_id, recordDateTime)
400
+
399 401
 	xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
400 402
 
401 403
 	count, _ := service.GetHisPatientCount(admin.CurrentOrgId, patient_id, recordDateTime)

+ 11 - 6
controllers/his_hospital_api_controller.go View File

@@ -43,21 +43,25 @@ func (c *HisHospitalApiController) GetHisHospitalPatientList() {
43 43
 	}
44 44
 	recordDateTime := theTime.Unix()
45 45
 	adminInfo := c.GetAdminUserInfo()
46
-	var patients []*service.HospitalPatient
46
+	//var patients []*service.HospitalPatient
47 47
 	tempPatients, _ := service.GetHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime)
48
+	tempPatients_two, _ := service.GetHisHospitalSchPatientList(adminInfo.CurrentOrgId, recordDateTime)
48 49
 
50
+	//当天有登记住院的和排班同时存在的话,删除掉排班的记录
49 51
 	for _, item := range tempPatients {
50
-		if item.HisHospitalCheckRecord.ID > 0 && item.HisHospitalCheckRecord.InHospitalStatus == 1 && item.HisHospitalCheckRecord.OutHospitalStatus == 0 {
51
-			patients = append(patients, item)
52
+		for index, subItem := range tempPatients_two {
53
+			if item.ID == subItem.ID {
54
+				tempPatients_two = append(tempPatients_two[:index], tempPatients_two[index+1:]...)
52 55
 
56
+			}
53 57
 		}
54
-
55 58
 	}
59
+	tempPatients = append(tempPatients, tempPatients_two...)
56 60
 
57 61
 	var total_one int64
58 62
 	var total_two int64
59 63
 
60
-	for _, item := range patients {
64
+	for _, item := range tempPatients {
61 65
 
62 66
 		if item.VMHisPrescriptionInfo.ID == 0 {
63 67
 			total_one = total_one + 1
@@ -73,7 +77,7 @@ func (c *HisHospitalApiController) GetHisHospitalPatientList() {
73 77
 
74 78
 	if types == 0 {
75 79
 		c.ServeSuccessJSON(map[string]interface{}{
76
-			"list":       patients,
80
+			"list":       tempPatients,
77 81
 			"total_one":  total_one,
78 82
 			"total_two":  total_two,
79 83
 			"info":       adminUserInfo,
@@ -491,6 +495,7 @@ func (c *HisHospitalApiController) GetSettleInfo() {
491 495
 		SettleStartTime:    start_time,
492 496
 		SettleType:         settle_accounts_type,
493 497
 		PType:              1,
498
+		Creator:            c.GetAdminUserInfo().AdminUser.Id,
494 499
 	}
495 500
 	order.DiscountPrice = discount_price
496 501
 	order.MedicalInsurancePrice = medical_insurance_price

+ 1 - 1
routers/router.go View File

@@ -11,7 +11,7 @@ import (
11 11
 func init() {
12 12
 	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
13 13
 		// AllowAllOrigins:  true,
14
-		AllowOrigins: []string{"https://xt.kuyicloud.com", "https://xt.kuyicloud.com", "http://localhost:9528", "http://localhost:9529", "http://localhost:9531", "http://xt.test.shengws.com", "http://new_mobile.test.sgjyun.com", "https://xt.test.shengws.com", "http://xt.test.sgjyun.com", "https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com", "https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com", "http://mobile.sgjyun.com", "http://mobile.kuyicloud.com"},
14
+		AllowOrigins: []string{"https://xt.kuyicloud.com", "http://localhost:9528", "http://localhost:9529", "http://localhost:9531", "http://xt.test.shengws.com", "http://new_mobile.test.sgjyun.com", "https://xt.test.shengws.com", "http://xt.test.sgjyun.com", "https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com", "https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com", "http://mobile.sgjyun.com", "http://mobile.kuyicloud.com"},
15 15
 		//AllowOrigins:     []string{"https://xt.kuyicloud.com", "http://localhost:9528", "http://xt.test.shengws.com","https://xt.test.shengws.com", "http://xt.test.sgjyun.com","https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com","https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com","http://mobile.sgjyun.com","http://mobile.kuyicloud.com"},
16 16
 		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
17 17
 		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type", "X-XSRF-TOKEN", "Permission"},

+ 1 - 1
service/app_version.go View File

@@ -351,7 +351,7 @@ func (HisPrescriptionInfoTemplateTwo) TableName() string {
351 351
 func GetHisPrescriptionTemplateTwo() (prescription []*HisPrescriptionInfoTemplateTwo, err error) {
352 352
 	err = readDb.Model(&HisPrescriptionInfoTemplateTwo{}).
353 353
 		Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
354
-			return db.Where("status = 1").Preload("Drug", "status=1")
354
+			return db.Where("status = 1")
355 355
 		}).
356 356
 		Where("status = 1 ").
357 357
 		Find(&prescription).Error

+ 14 - 4
service/his_hospital_service.go View File

@@ -72,7 +72,17 @@ func (HisHospitalOrder) TableName() string {
72 72
 
73 73
 func GetHisHospitalPatientList(org_id int64, record_date int64) (patients []*HospitalPatient, err error) {
74 74
 	db := readDb.Model(&HospitalPatient{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
75
-	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)
75
+	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)
76
+	db = db.Preload("HisHospitalCheckRecord", func(db *gorm.DB) *gorm.DB {
77
+		return db.Where("user_org_id = ? AND status = 1  AND in_hospital_status = 1 AND out_hospital_status = 0", org_id).Order("id desc")
78
+	})
79
+	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
80
+	return
81
+}
82
+
83
+func GetHisHospitalSchPatientList(org_id int64, record_date int64) (patients []*HospitalPatient, err error) {
84
+	db := readDb.Model(&HospitalPatient{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
85
+	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)
76 86
 	db = db.Preload("HisHospitalCheckRecord", func(db *gorm.DB) *gorm.DB {
77 87
 		return db.Where("user_org_id = ? AND status = 1  AND in_hospital_status = 1 AND out_hospital_status = 0", org_id).Order("id desc")
78 88
 	})
@@ -219,7 +229,7 @@ func (VMHisHospitalPrescriptionInfo) TableName() string {
219 229
 
220 230
 func GetHisHospitalPatientPrescriptionList(org_id int64, keywords string, record_date int64, page int64, limit int64) (patients []*VMHisHospitalPrescriptionInfo, err error, total int64) {
221 231
 	offset := (page - 1) * limit
222
-	db := readDb.Model(&VMHisHospitalPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND p_type = 1 ", org_id, record_date)
232
+	db := readDb.Model(&VMHisHospitalPrescriptionInfo{}).Where("his_prescription_info.user_org_id = ? AND his_prescription_info.status = 1 AND his_prescription_info.record_date = ? AND his_prescription_info.p_type = 1 ", org_id, record_date)
223 233
 	if len(keywords) > 0 {
224 234
 		keywords = "%" + keywords + "%"
225 235
 		db = db.Joins("JOIN xt_patients as p On his_prescription_info.patient_id = p.id AND p.user_org_id = ? AND p.name like ?", org_id, keywords)
@@ -269,10 +279,10 @@ func GetHospitalMonthHisPrescription(org_id int64, patient_id int64, start_time
269 279
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
270 280
 		}).
271 281
 		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
272
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
282
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
273 283
 		}).
274 284
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
275
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
285
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
276 286
 		}).
277 287
 		Where("user_org_id = ? AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND status = 1 AND p_type = 1 ", org_id, start_time, end_time, patient_id).
278 288
 		Find(&prescription).Error

+ 5 - 0
service/his_service.go View File

@@ -314,6 +314,11 @@ func GetNewHisPatientInfoTwo(org_id int64, id int64, record_date int64) (info mo
314 314
 	return
315 315
 }
316 316
 
317
+func GetNewHisHosptialRecordTwo(org_id int64, id int64, record_date int64) (info models.HisPatient, err error) {
318
+	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND id = ?", org_id, record_date, id).First(&info).Error
319
+	return
320
+}
321
+
317 322
 func GetHisPatientCount(org_id int64, patient_id int64, record_date int64) (total int64, err error) {
318 323
 	err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).Count(&total).Error
319 324
 	return