Browse Source

耗材参数

XMLWAN 4 years ago
parent
commit
d5af4ffdc5

+ 21 - 15
controllers/his_api_controller.go View File

@@ -9,7 +9,6 @@ import (
9 9
 	"encoding/json"
10 10
 	"fmt"
11 11
 	"github.com/astaxie/beego"
12
-	"github.com/jinzhu/gorm"
13 12
 	"io/ioutil"
14 13
 	"math/rand"
15 14
 	"net/http"
@@ -560,20 +559,27 @@ func (c *HisApiController) CreateHisPatientCaseHistory() {
560 559
 		Remark:                  remark,
561 560
 	}
562 561
 
563
-	//查询该患者是否有病历
564
-	_, errcode := service.GetHisPatientCaseHistoryById(his_patient_id)
565
-	if errcode == gorm.ErrRecordNotFound {
566
-		err = service.SaveHisPatientCaseHistory(caseHistory)
567
-		if err != nil {
568
-			c.ServeSuccessJSON(map[string]interface{}{
569
-				"msg": "保存成功",
570
-			})
571
-		}
572
-	} else if errcode == nil {
573
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
574
-		return
562
+	err = service.SaveHisPatientCaseHistory(caseHistory)
563
+	if err != nil {
564
+		c.ServeSuccessJSON(map[string]interface{}{
565
+			"msg": "保存成功",
566
+		})
575 567
 	}
576 568
 
569
+	//查询该患者是否有病历
570
+	//_, errcode := service.GetHisPatientCaseHistoryById(his_patient_id)
571
+	//if errcode == gorm.ErrRecordNotFound {
572
+	//	err = service.SaveHisPatientCaseHistory(caseHistory)
573
+	//	if err != nil {
574
+	//		c.ServeSuccessJSON(map[string]interface{}{
575
+	//			"msg": "保存成功",
576
+	//		})
577
+	//	}
578
+	//} else if errcode == nil {
579
+	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
580
+	//	return
581
+	//}
582
+
577 583
 }
578 584
 func (c *HisApiController) GetHisPatientCaseHistoryList() {
579 585
 	patient_id, _ := c.GetInt64("patient_id", 0)
@@ -664,10 +670,10 @@ func (c *HisApiController) GetCaseHistoryTemplate() {
664 670
 	endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
665 671
 	admin := c.GetAdminUserInfo()
666 672
 	template, _ := service.GetHisPatientCaseHistoryTemplate(admin.CurrentOrgId, startTime.Unix(), endTime.Unix(), keyword)
667
-	history, _ := service.GetHisPatientCaseHistory(admin.CurrentOrgId)
673
+	//history, _ := service.GetHisPatientCaseHistory(admin.CurrentOrgId)
668 674
 	c.ServeSuccessJSON(map[string]interface{}{
669 675
 		"template": template,
670
-		"history":  history,
676
+		//"history":  history,
671 677
 	})
672 678
 
673 679
 }

+ 16 - 0
controllers/his_project_api_controller.go View File

@@ -59,6 +59,7 @@ func HisProjectRouters() {
59 59
 	beego.Router("/api/patient/getpatientcasehistory", &HisProjectApiController{}, "Get:GetPatientcaseHistory")
60 60
 	beego.Router("/api/doctorworkstation/gettemplatedetail", &HisProjectApiController{}, "Get:GetTemplateDetail")
61 61
 	beego.Router("/api/doctorworkstation/updaterecordtemplate", &HisProjectApiController{}, "Get:UpdateRecordTemplate")
62
+	beego.Router("/api/hispatient/gehispatient", &HisProjectApiController{}, "Get:GetHisPatient")
62 63
 }
63 64
 
64 65
 func (this *HisProjectApiController) SaveProject() {
@@ -981,3 +982,18 @@ func (this *HisProjectApiController) UpdateRecordTemplate() {
981 982
 		"templateDetail": historyTemplate,
982 983
 	})
983 984
 }
985
+
986
+func (this *HisProjectApiController) GetHisPatient() {
987
+
988
+	adminUserInfo := this.GetAdminUserInfo()
989
+	orgId := adminUserInfo.CurrentOrgId
990
+	keyword := this.GetString("keyword")
991
+	patient, err := service.GetHistPatient(orgId, keyword)
992
+	if err != nil {
993
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
994
+		return
995
+	}
996
+	this.ServeSuccessJSON(map[string]interface{}{
997
+		"patient": patient,
998
+	})
999
+}

+ 1 - 1
controllers/mobile_api_controllers/mobile_api_router_register.go View File

@@ -13,7 +13,7 @@ func MobileAPIControllersRegisterRouters() {
13 13
 	beego.Router("/m/api/checkbeforedialysis", &CheckWeightApiController{}, "get:GetPatientInfoBeforeDialysis")
14 14
 	beego.Router("/m/api/getpatientlist", &CheckWeightApiController{}, "get:GetPatientList")
15 15
 	beego.Router("/m/api/getschedulepatient", &CheckWeightApiController{}, "get:GetPatientListForSchedules")
16
-	beego.Router("/m/api/getschedulepatientfind", &CheckWeightApiController{}, "get:GetPatientListForSchedulesFind")
16
+	//beego.Router("/m/api/getschedulepatientfind", &CheckWeightApiController{}, "get:GetPatientListForSchedulesFind")
17 17
 	beego.Router("/m/api/getpatientinfo", &CheckWeightApiController{}, "get:GetPatientListById")
18 18
 	beego.Router("/m/api/checkdialysis", &CheckWeightApiController{}, "get:GetPatientInfoDialysis")
19 19
 	beego.Router("/m/api/savecheckdialysis", &CheckWeightApiController{}, "Post:SavePatientInfoDialysis")

+ 2 - 1
controllers/schedule_api_controller.go View File

@@ -765,6 +765,7 @@ func (this *ScheduleApiController) SearchSchedulePatients() {
765 765
 
766 766
 func (this *ScheduleApiController) GetWeekDaySchedule() {
767 767
 	week_type, _ := this.GetInt64("week_type", -1)
768
+	week_time, _ := this.GetInt64("week_time")
768 769
 	fmt.Println(week_type)
769 770
 	thisTime := time.Now()
770 771
 	weekDay := int(thisTime.Weekday())
@@ -822,7 +823,7 @@ func (this *ScheduleApiController) GetWeekDaySchedule() {
822 823
 	}
823 824
 
824 825
 	adminUserInfo := this.GetAdminUserInfo()
825
-	list, _ := service.GetWeekDaySchedule(adminUserInfo.CurrentOrgId, targetDay.Unix(), targetDay)
826
+	list, _ := service.GetWeekDayScheduleTwo(adminUserInfo.CurrentOrgId, targetDay.Unix(), targetDay, week_time)
826 827
 
827 828
 	this.ServeSuccessJSON(map[string]interface{}{
828 829
 		"schdules": list,

+ 1 - 0
models/stock_query_models.go View File

@@ -3,6 +3,7 @@ package models
3 3
 type StockInfo struct {
4 4
 	ID                int64  `gorm:"column:id" json:"id"`
5 5
 	GoodCode          string `gorm:"column:good_code" json:"good_code"`
6
+	GoodName          string `gorm:"column:good_name" json:"good_name"`
6 7
 	SpecificationName string `gorm:"column:specification_name" json:"specification_name"`
7 8
 	GoodTypeId        int64  `gorm:"column:good_type_id" json:"good_type_id"`
8 9
 	GoodUnit          int64  `gorm:"column:good_unit" json:"good_unit"`

+ 6 - 0
service/his_project_service.go View File

@@ -366,3 +366,9 @@ func UpdateCaseHistoryTemplate(tem *models.HisCaseHistoryTemplate, id int64) err
366 366
 	err := XTWriteDB().Model(&tem).Where("id = ? ", id).Updates(map[string]interface{}{"history_of_present_illness": tem.HistoryOfPresentIllness, "past_history": tem.PastHistory, "chief_conplaint": tem.ChiefConplaint, "personal_history": tem.PersonalHistory, "family_history": tem.FamilyHistory, "diagnostic": tem.Diagnostic, "template_name": tem.TemplateName, "template_remark": tem.TemplateRemark, "modifier": tem.Modifier}).Error
367 367
 	return err
368 368
 }
369
+
370
+func GetHistPatient(orgid int64, keyword string) (hisPatient []*models.HisPatient, err error) {
371
+	likeKey := "%" + keyword + "%"
372
+	err = XTReadDB().Model(&hisPatient).Where("user_org_id = ? and name like ?", orgid, likeKey).Find(&hisPatient).Error
373
+	return hisPatient, err
374
+}

+ 95 - 0
service/schedule_service.go View File

@@ -304,6 +304,101 @@ func GetSchedualPatientsByKeywords(keywords string, org_id int64) (schedule []*m
304 304
 
305 305
 }
306 306
 
307
+func GetWeekDayScheduleTwo(orgID int64, scheduleDate int64, scheduleDates *time.Time, weektime int64) (schedules []*models.WeekSchedule, err error) {
308
+	db := readDb.Table("xt_schedule as s ").Where("s.status =1")
309
+	if orgID > 0 {
310
+		db = db.Where("s.user_org_id = ?", orgID)
311
+	}
312
+	if scheduleDate > 0 {
313
+		db = db.Where("s.schedule_date = ?", scheduleDate)
314
+
315
+	}
316
+	if weektime > 0 {
317
+		db = db.Where("s.schedule_type = ?", weektime)
318
+	}
319
+	err = db.
320
+		Preload("DeviceZone", "status = 1 ").
321
+		Preload("DeviceNumber", "status = 1 ").
322
+		Preload("DialysisPrescription", func(db *gorm.DB) *gorm.DB {
323
+			return db.Where("status = 1").Order("id asc")
324
+		}).
325
+		Joins("JOIN xt_patients as p ON p.id = s.patient_id").
326
+		Select("s.id, s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id, s.status, s.created_time, s.updated_time, p.name as patient").
327
+		Order("s.partition_id asc").
328
+		Find(&schedules).Error
329
+
330
+	for _, item := range schedules {
331
+		_, config := FindDoctorAdviceRecordByOrgId(item.UserOrgId)
332
+		if config.IsOpenRemind > 0 {
333
+			//开启推送提醒逻辑    提交长期处方的时候,弹起长期医嘱推送
334
+			var advice_three []*models.DoctorAdvice
335
+			advices, _ := GetLastLongAdviceByGroupNoOther(item.UserOrgId, item.PatientId)
336
+			advices_two, _ := GetLastLongAdviceByGroupNoThreeOther(item.UserOrgId, item.PatientId)
337
+			for _, advice := range advices {
338
+				advice.IsCheck = 1
339
+				if advice.FrequencyType == 3 {
340
+					week := int(scheduleDates.Weekday())
341
+					fmt.Println(advice.WeekDay)
342
+					switch week {
343
+					case 1:
344
+						if strings.Index(advice.WeekDay, "周一") > -1 {
345
+							advice_three = append(advice_three, advice)
346
+						}
347
+						break
348
+					case 2:
349
+						if strings.Index(advice.WeekDay, "周二") > -1 {
350
+							advice_three = append(advice_three, advice)
351
+						}
352
+						break
353
+					case 3:
354
+						if strings.Index(advice.WeekDay, "周三") > -1 {
355
+							advice_three = append(advice_three, advice)
356
+						}
357
+						break
358
+					case 4:
359
+						if strings.Index(advice.WeekDay, "周四") > -1 {
360
+							advice_three = append(advice_three, advice)
361
+						}
362
+						break
363
+					case 5:
364
+						if strings.Index(advice.WeekDay, "周五") > -1 {
365
+							advice_three = append(advice_three, advice)
366
+						}
367
+						break
368
+					case 6:
369
+						if strings.Index(advice.WeekDay, "周六") > -1 {
370
+							advice_three = append(advice_three, advice)
371
+						}
372
+						break
373
+					case 0:
374
+						if strings.Index(advice.WeekDay, "周日") > -1 {
375
+							advice_three = append(advice_three, advice)
376
+						}
377
+						break
378
+					}
379
+				} else if advice.FrequencyType == 1 {
380
+					advice_three = append(advice_three, advice)
381
+				}
382
+			}
383
+
384
+			for _, advice := range advices_two {
385
+				now := scheduleDates.Unix()
386
+				dayStr := strconv.FormatInt(advice.DayCount, 10)
387
+				dayStr2 := "-" + dayStr
388
+				count, _ := strconv.ParseInt(dayStr2, 10, 64)
389
+				oldTime := scheduleDates.AddDate(0, 0, int(count)).Unix()
390
+				advices, _ := FindAllDoctorAdviceByTimeOther(now, oldTime, item.PatientId, item.UserOrgId, advice.TemplateId)
391
+				if len(advices) == 0 {
392
+					advice_three = append(advice_three, advice)
393
+				}
394
+			}
395
+
396
+			item.DoctorAdvice = append(item.DoctorAdvice, advice_three...)
397
+		}
398
+	}
399
+	return
400
+}
401
+
307 402
 func GetWeekDaySchedule(orgID int64, scheduleDate int64, scheduleDates *time.Time) (schedules []*models.WeekSchedule, err error) {
308 403
 
309 404
 	err = readDb.