Explorar el Código

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

XMLWAN hace 3 años
padre
commit
ff4606537e

+ 60 - 59
controllers/base_api_controller.go Ver fichero

2
 
2
 
3
 import (
3
 import (
4
 	"XT_New/enums"
4
 	"XT_New/enums"
5
+	"XT_New/models"
5
 	"XT_New/service"
6
 	"XT_New/service"
6
 	"fmt"
7
 	"fmt"
7
 	"strconv"
8
 	"strconv"
69
 func (this *BaseAuthAPIController) Prepare() {
70
 func (this *BaseAuthAPIController) Prepare() {
70
 	this.BaseAPIController.Prepare()
71
 	this.BaseAPIController.Prepare()
71
 	if this.GetAdminUserInfo() == nil {
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
 func (this *BaseServeAPIController) Prepare() {
316
 func (this *BaseServeAPIController) Prepare() {
316
 	this.BaseAPIController.Prepare()
317
 	this.BaseAPIController.Prepare()
317
 	if this.GetAdminUserInfo() == nil {
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
 	//if adminUserInfo.AppRole != nil {
350
 	//if adminUserInfo.AppRole != nil {

+ 2 - 0
controllers/his_api_controller.go Ver fichero

396
 	//endRecordDateTime := endTime.Unix()
396
 	//endRecordDateTime := endTime.Unix()
397
 	admin := c.GetAdminUserInfo()
397
 	admin := c.GetAdminUserInfo()
398
 	his_patient_info, _ := service.GetNewHisPatientInfoTwo(admin.CurrentOrgId, his_patient_id, recordDateTime)
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
 	xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
401
 	xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
400
 
402
 
401
 	count, _ := service.GetHisPatientCount(admin.CurrentOrgId, patient_id, recordDateTime)
403
 	count, _ := service.GetHisPatientCount(admin.CurrentOrgId, patient_id, recordDateTime)

+ 11 - 6
controllers/his_hospital_api_controller.go Ver fichero

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

+ 1 - 1
routers/router.go Ver fichero

11
 func init() {
11
 func init() {
12
 	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
12
 	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
13
 		// AllowAllOrigins:  true,
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
 		//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"},
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
 		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
16
 		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
17
 		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type", "X-XSRF-TOKEN", "Permission"},
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 Ver fichero

351
 func GetHisPrescriptionTemplateTwo() (prescription []*HisPrescriptionInfoTemplateTwo, err error) {
351
 func GetHisPrescriptionTemplateTwo() (prescription []*HisPrescriptionInfoTemplateTwo, err error) {
352
 	err = readDb.Model(&HisPrescriptionInfoTemplateTwo{}).
352
 	err = readDb.Model(&HisPrescriptionInfoTemplateTwo{}).
353
 		Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
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
 		Where("status = 1 ").
356
 		Where("status = 1 ").
357
 		Find(&prescription).Error
357
 		Find(&prescription).Error

+ 14 - 4
service/his_hospital_service.go Ver fichero

72
 
72
 
73
 func GetHisHospitalPatientList(org_id int64, record_date int64) (patients []*HospitalPatient, err error) {
73
 func GetHisHospitalPatientList(org_id int64, record_date int64) (patients []*HospitalPatient, err error) {
74
 	db := readDb.Model(&HospitalPatient{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
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
 	db = db.Preload("HisHospitalCheckRecord", func(db *gorm.DB) *gorm.DB {
86
 	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")
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
 
229
 
220
 func GetHisHospitalPatientPrescriptionList(org_id int64, keywords string, record_date int64, page int64, limit int64) (patients []*VMHisHospitalPrescriptionInfo, err error, total int64) {
230
 func GetHisHospitalPatientPrescriptionList(org_id int64, keywords string, record_date int64, page int64, limit int64) (patients []*VMHisHospitalPrescriptionInfo, err error, total int64) {
221
 	offset := (page - 1) * limit
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
 	if len(keywords) > 0 {
233
 	if len(keywords) > 0 {
224
 		keywords = "%" + keywords + "%"
234
 		keywords = "%" + keywords + "%"
225
 		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)
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
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
279
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
270
 		}).
280
 		}).
271
 		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
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
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
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
 		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).
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
 		Find(&prescription).Error
288
 		Find(&prescription).Error

+ 5 - 0
service/his_service.go Ver fichero

314
 	return
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
 func GetHisPatientCount(org_id int64, patient_id int64, record_date int64) (total int64, err error) {
322
 func GetHisPatientCount(org_id int64, patient_id int64, record_date int64) (total int64, err error) {
318
 	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
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
 	return
324
 	return