Browse Source

库存流水展示

XMLWAN 2 years ago
parent
commit
473b21a0d3

+ 6 - 6
controllers/base_api_controller.go View File

82
 		userAdmin.ModifyTime = 1530786071
82
 		userAdmin.ModifyTime = 1530786071
83
 		var subscibe models.ServeSubscibe
83
 		var subscibe models.ServeSubscibe
84
 		subscibe.ID = 11
84
 		subscibe.ID = 11
85
-		subscibe.OrgId = 10341 //机构id
85
+		subscibe.OrgId = 9671 //机构id
86
 		subscibe.PeriodStart = 1547447814
86
 		subscibe.PeriodStart = 1547447814
87
 		subscibe.PeriodEnd = 1550039814
87
 		subscibe.PeriodEnd = 1550039814
88
 		subscibe.State = 1
88
 		subscibe.State = 1
92
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
92
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
93
 		subscibes[4] = &subscibe
93
 		subscibes[4] = &subscibe
94
 		var adminUserInfo service.AdminUserInfo
94
 		var adminUserInfo service.AdminUserInfo
95
-		adminUserInfo.CurrentOrgId = 10341 //机构id小英9675或4
96
-		adminUserInfo.CurrentAppId = 3295  //4
95
+		adminUserInfo.CurrentOrgId = 9671 //机构id小英9675或4
96
+		adminUserInfo.CurrentAppId = 3295 //4
97
 		adminUserInfo.AdminUser = &userAdmin
97
 		adminUserInfo.AdminUser = &userAdmin
98
 		adminUserInfo.Subscibes = subscibes
98
 		adminUserInfo.Subscibes = subscibes
99
 		this.SetSession("admin_user_info", &adminUserInfo)
99
 		this.SetSession("admin_user_info", &adminUserInfo)
328
 		userAdmin.ModifyTime = 1530786071
328
 		userAdmin.ModifyTime = 1530786071
329
 		var subscibe models.ServeSubscibe
329
 		var subscibe models.ServeSubscibe
330
 		subscibe.ID = 11
330
 		subscibe.ID = 11
331
-		subscibe.OrgId = 10341 //机构id小英9675或4
331
+		subscibe.OrgId = 9671 //机构id小英9675或4
332
 		subscibe.PeriodStart = 1538035409
332
 		subscibe.PeriodStart = 1538035409
333
 		subscibe.PeriodEnd = 1569571409
333
 		subscibe.PeriodEnd = 1569571409
334
 		subscibe.State = 1
334
 		subscibe.State = 1
338
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
338
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
339
 		subscibes[4] = &subscibe
339
 		subscibes[4] = &subscibe
340
 		var adminUserInfo service.AdminUserInfo
340
 		var adminUserInfo service.AdminUserInfo
341
-		adminUserInfo.CurrentOrgId = 10341 //机构id小英9675或4
342
-		adminUserInfo.CurrentAppId = 3295  //4
341
+		adminUserInfo.CurrentOrgId = 9671 //机构id小英9675或4
342
+		adminUserInfo.CurrentAppId = 3295 //4
343
 		adminUserInfo.AdminUser = &userAdmin
343
 		adminUserInfo.AdminUser = &userAdmin
344
 		adminUserInfo.Subscibes = subscibes
344
 		adminUserInfo.Subscibes = subscibes
345
 		this.SetSession("admin_user_info", &adminUserInfo)
345
 		this.SetSession("admin_user_info", &adminUserInfo)

+ 353 - 1
controllers/dialysis_api_controller.go View File

111
 	beego.Router("/api/patient/getdialysisadvicetoday", &DialysisApiController{}, "Get:GetDialysisAdviceToday")
111
 	beego.Router("/api/patient/getdialysisadvicetoday", &DialysisApiController{}, "Get:GetDialysisAdviceToday")
112
 
112
 
113
 	beego.Router("/api/schedule/getmobileschedulelist", &DialysisApiController{}, "Get:GetMobileScheduleList")
113
 	beego.Router("/api/schedule/getmobileschedulelist", &DialysisApiController{}, "Get:GetMobileScheduleList")
114
+
115
+	beego.Router("/api/patient/saveinformation", &DialysisApiController{}, "Get:SaveInformation")
114
 }
116
 }
115
 
117
 
116
 func (c *DialysisApiController) GetQueueCall() {
118
 func (c *DialysisApiController) GetQueueCall() {
602
 			prescription.AdminUserId = adminUserInfo.AdminUser.Id
604
 			prescription.AdminUserId = adminUserInfo.AdminUser.Id
603
 		}
605
 		}
604
 
606
 
607
+		// 查询信息规挡的设置天数
608
+
609
+		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
610
+		if infor.ID > 0 {
611
+
612
+			var cha_time int64
613
+
614
+			timeNowStr := time.Now().Format("2006-01-02")
615
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
616
+
617
+			//今日的日期减去设置的日期
618
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
619
+
620
+			if cha_time >= recordDate.Unix() {
621
+				//查询审核是否允许
622
+				infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
623
+				//申请状态不允许的情况 拒绝修改
624
+				if infor.ApplicationStatus != 1 {
625
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
626
+					return
627
+				}
628
+
629
+			}
630
+		}
631
+
605
 		err := service.AddSigleRecord(&prescription)
632
 		err := service.AddSigleRecord(&prescription)
606
 
633
 
634
+		//创建步骤表
635
+		finish := models.XtDialysisFinish{
636
+			IsFinish:   1,
637
+			UserOrgId:  adminUserInfo.CurrentOrgId,
638
+			Status:     1,
639
+			Ctime:      time.Now().Unix(),
640
+			Mtime:      0,
641
+			Module:     1,
642
+			RecordDate: recordDate.Unix(),
643
+			Sourse:     1,
644
+		}
645
+
646
+		dialysisFinish, err := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, recordDate.Unix(), 1)
647
+		if dialysisFinish.ID == 0 {
648
+			service.CreateDialysisFinish(finish)
649
+		}
650
+
607
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
651
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
608
 		redis := service.RedisClient()
652
 		redis := service.RedisClient()
609
 		//清空key 值
653
 		//清空key 值
1431
 		NeedleBatchNumber:          needle_batch_number,
1475
 		NeedleBatchNumber:          needle_batch_number,
1432
 	}
1476
 	}
1433
 
1477
 
1478
+	// 查询信息规挡的设置天数
1479
+
1480
+	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
1481
+	if infor.ID > 0 {
1482
+
1483
+		var cha_time int64
1484
+
1485
+		timeNowStr := time.Now().Format("2006-01-02")
1486
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
1487
+
1488
+		//今日的日期减去设置的日期
1489
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
1490
+
1491
+		if cha_time >= recordDate.Unix() {
1492
+			//查询审核是否允许
1493
+			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId)
1494
+			//申请状态不允许的情况 拒绝修改
1495
+			if infor.ApplicationStatus != 1 {
1496
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1497
+				return
1498
+			}
1499
+
1500
+		}
1501
+	}
1502
+
1434
 	_, check := service.FindDoubleCheckByReordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId)
1503
 	_, check := service.FindDoubleCheckByReordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId)
1435
 	if check.ID == 0 { //新增
1504
 	if check.ID == 0 { //新增
1436
 		doubleCheck.FirstCheckTime = firstCheckTimeDate
1505
 		doubleCheck.FirstCheckTime = firstCheckTimeDate
1439
 		doubleCheck.Modifier = modifier
1508
 		doubleCheck.Modifier = modifier
1440
 
1509
 
1441
 		err := service.AddSigleDoubleCheck(&doubleCheck)
1510
 		err := service.AddSigleDoubleCheck(&doubleCheck)
1511
+		//创建步骤表
1512
+		finish := models.XtDialysisFinish{
1513
+			IsFinish:   1,
1514
+			UserOrgId:  adminUserInfo.CurrentOrgId,
1515
+			Status:     1,
1516
+			Ctime:      time.Now().Unix(),
1517
+			Mtime:      0,
1518
+			Module:     5,
1519
+			RecordDate: recordDate.Unix(),
1520
+			Sourse:     1,
1521
+		}
1522
+
1523
+		dialysisFinish, err := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, recordDate.Unix(), 5)
1524
+		if dialysisFinish.ID == 0 {
1525
+			service.CreateDialysisFinish(finish)
1526
+		}
1527
+
1528
+		// 查询信息规挡的设置天数
1529
+
1530
+		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
1531
+		if infor.ID > 0 {
1532
+
1533
+			var cha_time int64
1534
+
1535
+			timeNowStr := time.Now().Format("2006-01-02")
1536
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
1537
+
1538
+			//今日的日期减去设置的日期
1539
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
1540
+
1541
+			if cha_time >= recordDate.Unix() {
1542
+				//查询审核是否允许
1543
+				infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId)
1544
+				//申请状态不允许的情况 拒绝修改
1545
+				if infor.ApplicationStatus != 1 {
1546
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1547
+					return
1548
+				}
1549
+
1550
+			}
1551
+		}
1442
 		redis := service.RedisClient()
1552
 		redis := service.RedisClient()
1443
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":double_check"
1553
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":double_check"
1444
 
1554
 
1570
 		Diacrisis:                    diacrisis,
1680
 		Diacrisis:                    diacrisis,
1571
 	}
1681
 	}
1572
 
1682
 
1683
+	// 查询信息规挡的设置天数
1684
+
1685
+	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
1686
+	if infor.ID > 0 {
1687
+
1688
+		var cha_time int64
1689
+
1690
+		timeNowStr := time.Now().Format("2006-01-02")
1691
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
1692
+
1693
+		//今日的日期减去设置的日期
1694
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
1695
+
1696
+		if cha_time >= recordDate.Unix() {
1697
+			//查询审核是否允许
1698
+			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId)
1699
+			//申请状态不允许的情况 拒绝修改
1700
+			if infor.ApplicationStatus != 1 {
1701
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1702
+				return
1703
+			}
1704
+
1705
+		}
1706
+	}
1707
+
1573
 	if receiveTreatment.ID == 0 { //新增
1708
 	if receiveTreatment.ID == 0 { //新增
1574
 		receiveTreatmentAsses.Creater = adminUserInfo.AdminUser.Id
1709
 		receiveTreatmentAsses.Creater = adminUserInfo.AdminUser.Id
1575
 		err := service.AddSigleReceiveTreatmentAssesRecord(&receiveTreatmentAsses)
1710
 		err := service.AddSigleReceiveTreatmentAssesRecord(&receiveTreatmentAsses)
1711
+		//创建步骤表
1712
+		finish := models.XtDialysisFinish{
1713
+			IsFinish:   1,
1714
+			UserOrgId:  adminUserInfo.CurrentOrgId,
1715
+			Status:     1,
1716
+			Ctime:      time.Now().Unix(),
1717
+			Mtime:      0,
1718
+			Module:     2,
1719
+			RecordDate: recordDate.Unix(),
1720
+			Sourse:     1,
1721
+		}
1722
+
1723
+		dialysisFinish, err := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, recordDate.Unix(), 2)
1724
+		if dialysisFinish.ID == 0 {
1725
+			service.CreateDialysisFinish(finish)
1726
+		}
1576
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":receive_treatment_asses"
1727
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":receive_treatment_asses"
1577
 		redis := service.RedisClient()
1728
 		redis := service.RedisClient()
1578
 		//清空key 值
1729
 		//清空key 值
1752
 		}
1903
 		}
1753
 
1904
 
1754
 		assessment.UpdatedTime = time.Now().Unix()
1905
 		assessment.UpdatedTime = time.Now().Unix()
1906
+
1907
+		// 查询信息规挡的设置天数
1908
+
1909
+		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
1910
+		if infor.ID > 0 {
1911
+
1912
+			var cha_time int64
1913
+
1914
+			timeNowStr := time.Now().Format("2006-01-02")
1915
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
1916
+
1917
+			//今日的日期减去设置的日期
1918
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
1919
+
1920
+			if cha_time >= recordDate.Unix() {
1921
+				//查询审核是否允许
1922
+				infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
1923
+				//申请状态不允许的情况 拒绝修改
1924
+				if infor.ApplicationStatus != 1 {
1925
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1926
+					return
1927
+				}
1928
+
1929
+			}
1930
+		}
1755
 		err = service.UpdateAssessmentAfterDislysisRecord(&assessment)
1931
 		err = service.UpdateAssessmentAfterDislysisRecord(&assessment)
1932
+		finish := models.XtDialysisFinish{
1933
+			IsFinish:   1,
1934
+			UserOrgId:  adminUserInfo.CurrentOrgId,
1935
+			Status:     1,
1936
+			Ctime:      time.Now().Unix(),
1937
+			Mtime:      0,
1938
+			Module:     9,
1939
+			RecordDate: recordDate.Unix(),
1940
+			Sourse:     1,
1941
+		}
1942
+
1943
+		dialysisFinish, _ := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, recordDate.Unix(), 1)
1944
+		if dialysisFinish.ID == 0 {
1945
+			service.CreateDialysisFinish(finish)
1946
+		}
1756
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis"
1947
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis"
1757
 		redis := service.RedisClient()
1948
 		redis := service.RedisClient()
1758
 		//清空key 值
1949
 		//清空key 值
1984
 
2175
 
1985
 		}
2176
 		}
1986
 
2177
 
1987
-		err := service.AddSigleAssessmentBeforeDislysisRecord(&assessmentBeforeDislysis)
2178
+		// 查询信息规挡的设置天数
2179
+
2180
+		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
2181
+		if infor.ID > 0 {
2182
+
2183
+			var cha_time int64
1988
 
2184
 
2185
+			timeNowStr := time.Now().Format("2006-01-02")
2186
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
2187
+
2188
+			//今日的日期减去设置的日期
2189
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
2190
+
2191
+			if cha_time >= recordDate.Unix() {
2192
+				//查询审核是否允许
2193
+				infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
2194
+				//申请状态不允许的情况 拒绝修改
2195
+				if infor.ApplicationStatus != 1 {
2196
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
2197
+					return
2198
+				}
2199
+
2200
+			}
2201
+		}
2202
+
2203
+		err := service.AddSigleAssessmentBeforeDislysisRecord(&assessmentBeforeDislysis)
2204
+		//创建步骤表
2205
+		finish := models.XtDialysisFinish{
2206
+			IsFinish:   1,
2207
+			UserOrgId:  adminUserInfo.CurrentOrgId,
2208
+			Status:     1,
2209
+			Ctime:      time.Now().Unix(),
2210
+			Mtime:      0,
2211
+			Module:     3,
2212
+			RecordDate: recordDate.Unix(),
2213
+			Sourse:     1,
2214
+		}
2215
+
2216
+		dialysisFinish, err := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, recordDate.Unix(), 3)
2217
+		if dialysisFinish.ID == 0 {
2218
+			service.CreateDialysisFinish(finish)
2219
+		}
1989
 		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 10469 {
2220
 		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 10469 {
1990
 			var dewater_amount float64
2221
 			var dewater_amount float64
1991
 			dewater_amount = 0
2222
 			dewater_amount = 0
2514
 	_, tempTreatmentSummary := service.FindTreatmentSummaryByReordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
2745
 	_, tempTreatmentSummary := service.FindTreatmentSummaryByReordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
2515
 	if tempTreatmentSummary.ID == 0 { //新增
2746
 	if tempTreatmentSummary.ID == 0 { //新增
2516
 		treatmentSummary.Creater = adminUserInfo.AdminUser.Id
2747
 		treatmentSummary.Creater = adminUserInfo.AdminUser.Id
2748
+
2749
+		// 查询信息规挡的设置天数
2750
+
2751
+		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
2752
+		if infor.ID > 0 {
2753
+
2754
+			var cha_time int64
2755
+
2756
+			timeNowStr := time.Now().Format("2006-01-02")
2757
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
2758
+
2759
+			//今日的日期减去设置的日期
2760
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
2761
+
2762
+			if cha_time >= recordDate.Unix() {
2763
+				//查询审核是否允许
2764
+				infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
2765
+				//申请状态不允许的情况 拒绝修改
2766
+				if infor.ApplicationStatus != 1 {
2767
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
2768
+					return
2769
+				}
2770
+
2771
+			}
2772
+		}
2517
 		err := service.AddSigleSummaryRecord(&treatmentSummary)
2773
 		err := service.AddSigleSummaryRecord(&treatmentSummary)
2774
+		finish := models.XtDialysisFinish{
2775
+			IsFinish:   1,
2776
+			UserOrgId:  adminUserInfo.CurrentOrgId,
2777
+			Status:     1,
2778
+			Ctime:      time.Now().Unix(),
2779
+			Mtime:      0,
2780
+			Module:     10,
2781
+			RecordDate: recordDate.Unix(),
2782
+			Sourse:     1,
2783
+		}
2784
+
2785
+		dialysisFinish, err := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, recordDate.Unix(), 10)
2786
+		if dialysisFinish.ID == 0 {
2787
+			service.CreateDialysisFinish(finish)
2788
+		}
2518
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summary"
2789
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summary"
2519
 		redis := service.RedisClient()
2790
 		redis := service.RedisClient()
2520
 		keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summarys_list_all"
2791
 		keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summarys_list_all"
3046
 	//}
3317
 	//}
3047
 
3318
 
3048
 	err := service.DisableMonitor(adminInfo.CurrentOrgId, patientID, recordID, adminInfo.AdminUser.Id)
3319
 	err := service.DisableMonitor(adminInfo.CurrentOrgId, patientID, recordID, adminInfo.AdminUser.Id)
3320
+
3321
+	// 查询信息规挡的设置天数
3322
+
3323
+	infor, _ := service.GetDialysisInformationSetting(adminInfo.CurrentOrgId)
3324
+	if infor.ID > 0 {
3325
+
3326
+		var cha_time int64
3327
+
3328
+		timeNowStr := time.Now().Format("2006-01-02")
3329
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
3330
+
3331
+		//今日的日期减去设置的日期
3332
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
3333
+
3334
+		if cha_time >= monitor.MonitoringDate {
3335
+			//查询审核是否允许
3336
+			infor, _ := service.GetDialysisInformationByRecordDate(patientID, monitor.MonitoringDate, adminInfo.CurrentOrgId)
3337
+			//申请状态不允许的情况 拒绝修改
3338
+			if infor.ApplicationStatus != 1 {
3339
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
3340
+				return
3341
+			}
3342
+
3343
+		}
3344
+	}
3345
+
3049
 	key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(monitor.MonitoringDate, 10) + ":monitor_records"
3346
 	key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(monitor.MonitoringDate, 10) + ":monitor_records"
3050
 	redis := service.RedisClient()
3347
 	redis := service.RedisClient()
3051
 	//清空key 值
3348
 	//清空key 值
6096
 	return
6393
 	return
6097
 
6394
 
6098
 }
6395
 }
6396
+
6397
+func (this *DialysisApiController) SaveInformation() {
6398
+
6399
+	patient_id, _ := this.GetInt64("patient_id")
6400
+	record_date, _ := this.GetInt64("record_date")
6401
+	adviceDate := this.GetString("selected_date")
6402
+	timeLayout2 := "2006-01-02"
6403
+	loc2, _ := time.LoadLocation("Local")
6404
+	theTime, _ := time.ParseInLocation(timeLayout2, adviceDate, loc2)
6405
+	AdviceDate := theTime.Unix()
6406
+
6407
+	module, _ := this.GetInt64("module")
6408
+
6409
+	remark := this.GetString("remark")
6410
+
6411
+	orgId := this.GetAdminUserInfo().CurrentOrgId
6412
+	creater := this.GetAdminUserInfo().AdminUser.Id
6413
+
6414
+	information := models.XtDialysisInformation{
6415
+		Module:            module,
6416
+		PatientId:         patient_id,
6417
+		RecordDate:        record_date,
6418
+		ApplicationDate:   AdviceDate,
6419
+		Creater:           creater,
6420
+		ApplicationStatus: 2,
6421
+		Checker:           0,
6422
+		CheckTime:         0,
6423
+		Remark:            remark,
6424
+		UserOrgId:         orgId,
6425
+		Ctime:             time.Now().Unix(),
6426
+		Status:            1,
6427
+		Mtime:             0,
6428
+	}
6429
+
6430
+	infor, _ := service.GetDialysisInoformationById(patient_id, record_date, orgId, module)
6431
+	if infor.ID == 0 {
6432
+		err := service.CreatedDialysisInformation(information)
6433
+		if err == nil {
6434
+			this.ServeSuccessJSON(map[string]interface{}{
6435
+				"information": information,
6436
+			})
6437
+			return
6438
+		}
6439
+	}
6440
+	if infor.ID > 0 {
6441
+		err := service.UpdateDialysisInformationById(patient_id, record_date, orgId, module, AdviceDate, remark)
6442
+		if err == nil {
6443
+			this.ServeSuccessJSON(map[string]interface{}{
6444
+				"information": information,
6445
+			})
6446
+			return
6447
+		}
6448
+	}
6449
+
6450
+}

+ 121 - 0
controllers/dialysis_record_api_controller.go View File

633
 		orderID = dialysisOrder.ID
633
 		orderID = dialysisOrder.ID
634
 	}
634
 	}
635
 
635
 
636
+	// 查询信息规挡的设置天数
637
+
638
+	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
639
+	if infor.ID > 0 {
640
+
641
+		var cha_time int64
642
+
643
+		timeNowStr := time.Now().Format("2006-01-02")
644
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
645
+
646
+		//今日的日期减去设置的日期
647
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
648
+
649
+		if cha_time >= scheduleDate {
650
+			//查询审核是否允许
651
+			infor, _ := service.GetDialysisInformationByRecordDate(patientID, scheduleDate, adminUserInfo.CurrentOrgId)
652
+			//申请状态不允许的情况 拒绝修改
653
+			if infor.ApplicationStatus != 1 {
654
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
655
+				return
656
+			}
657
+
658
+		}
659
+	}
660
+
636
 	if monitorParam.ID <= 0 { // 新建记录
661
 	if monitorParam.ID <= 0 { // 新建记录
637
 		monitor := models.MonitoringRecord{
662
 		monitor := models.MonitoringRecord{
638
 			UserOrgId:       adminUserInfo.CurrentOrgId,
663
 			UserOrgId:       adminUserInfo.CurrentOrgId,
689
 			FilterPressure:              monitorParam.FilterPressure,
714
 			FilterPressure:              monitorParam.FilterPressure,
690
 		}
715
 		}
691
 		createErr := service.CreateMonitor(&monitor)
716
 		createErr := service.CreateMonitor(&monitor)
717
+		finish := models.XtDialysisFinish{
718
+			IsFinish:   1,
719
+			UserOrgId:  adminUserInfo.CurrentOrgId,
720
+			Status:     1,
721
+			Ctime:      time.Now().Unix(),
722
+			Mtime:      0,
723
+			Module:     7,
724
+			RecordDate: monitorParam.MonitoringDate,
725
+			Sourse:     1,
726
+		}
727
+
728
+		dialysisFinish, _ := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, monitorParam.MonitoringDate, 1)
729
+		if dialysisFinish.ID == 0 {
730
+			service.CreateDialysisFinish(finish)
731
+		}
692
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":monitor_records"
732
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":monitor_records"
693
 		redis := service.RedisClient()
733
 		redis := service.RedisClient()
694
 		//清空key 值
734
 		//清空key 值
1038
 	}
1078
 	}
1039
 
1079
 
1040
 	createErr := service.MobileCreateDialysisOrder(adminUserInfo.CurrentOrgId, patientID, dialysisRecord)
1080
 	createErr := service.MobileCreateDialysisOrder(adminUserInfo.CurrentOrgId, patientID, dialysisRecord)
1081
+
1082
+	finish := models.XtDialysisFinish{
1083
+		IsFinish:   1,
1084
+		UserOrgId:  adminUserInfo.CurrentOrgId,
1085
+		Status:     1,
1086
+		Ctime:      time.Now().Unix(),
1087
+		Mtime:      0,
1088
+		Module:     6,
1089
+		RecordDate: recordDate.Unix(),
1090
+		Sourse:     1,
1091
+	}
1092
+
1093
+	dialysisFinish, err := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, recordDate.Unix(), 1)
1094
+	if dialysisFinish.ID == 0 {
1095
+		service.CreateDialysisFinish(finish)
1096
+	}
1041
 	//更新患者表排班备注
1097
 	//更新患者表排班备注
1042
 	service.UpdateMobilePatient(adminUserInfo.CurrentOrgId, patientID, schedule_remark)
1098
 	service.UpdateMobilePatient(adminUserInfo.CurrentOrgId, patientID, schedule_remark)
1043
 
1099
 
1566
 		http.PostForm(api, values)
1622
 		http.PostForm(api, values)
1567
 	}()
1623
 	}()
1568
 
1624
 
1625
+	// 查询信息规挡的设置天数
1626
+
1627
+	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
1628
+	if infor.ID > 0 {
1629
+
1630
+		var cha_time int64
1631
+
1632
+		timeNowStr := time.Now().Format("2006-01-02")
1633
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
1634
+
1635
+		//今日的日期减去设置的日期
1636
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
1637
+
1638
+		if cha_time >= recordDate.Unix() {
1639
+			//查询审核是否允许
1640
+			infor, _ := service.GetDialysisInformationByRecordDate(patientID, recordDate.Unix(), adminUserInfo.CurrentOrgId)
1641
+			//申请状态不允许的情况 拒绝修改
1642
+			if infor.ApplicationStatus != 1 {
1643
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1644
+				return
1645
+			}
1646
+
1647
+		}
1648
+	}
1649
+
1569
 	//执行下机
1650
 	//执行下机
1570
 	updateErr := service.ModifyDialysisRecord(dialysisRecord.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id, puncture_point_haematoma, internal_fistula, catheter, cruor, mission)
1651
 	updateErr := service.ModifyDialysisRecord(dialysisRecord.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id, puncture_point_haematoma, internal_fistula, catheter, cruor, mission)
1652
+	finish := models.XtDialysisFinish{
1653
+		IsFinish:   1,
1654
+		UserOrgId:  adminUserInfo.CurrentOrgId,
1655
+		Status:     1,
1656
+		Ctime:      time.Now().Unix(),
1657
+		Mtime:      0,
1658
+		Module:     8,
1659
+		RecordDate: recordDate.Unix(),
1660
+		Sourse:     1,
1661
+	}
1662
+
1663
+	dialysisFinish, err := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, recordDate.Unix(), 8)
1664
+	if dialysisFinish.ID == 0 {
1665
+		service.CreateDialysisFinish(finish)
1666
+	}
1571
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
1667
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
1572
 	redis := service.RedisClient()
1668
 	redis := service.RedisClient()
1573
 	defer redis.Close()
1669
 	defer redis.Close()
1920
 	}
2016
 	}
1921
 
2017
 
1922
 	updateErr := service.ModifyFinishDialysisOrder(dialysisRecord)
2018
 	updateErr := service.ModifyFinishDialysisOrder(dialysisRecord)
2019
+
2020
+	// 查询信息规挡的设置天数
2021
+
2022
+	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
2023
+	if infor.ID > 0 {
2024
+
2025
+		var cha_time int64
2026
+
2027
+		timeNowStr := time.Now().Format("2006-01-02")
2028
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
2029
+
2030
+		//今日的日期减去设置的日期
2031
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
2032
+
2033
+		if cha_time >= tempDialysisRecords.DialysisDate {
2034
+			//查询审核是否允许
2035
+			infor, _ := service.GetDialysisInformationByRecordDate(tempDialysisRecords.PatientId, tempDialysisRecords.DialysisDate, adminUserInfo.CurrentOrgId)
2036
+			//申请状态不允许的情况 拒绝修改
2037
+			if infor.ApplicationStatus != 1 {
2038
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
2039
+				return
2040
+			}
2041
+
2042
+		}
2043
+	}
1923
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(tempDialysisRecords.PatientId, 10) + ":" + strconv.FormatInt(tempDialysisRecords.DialysisDate, 10) + ":dialysis_order"
2044
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(tempDialysisRecords.PatientId, 10) + ":" + strconv.FormatInt(tempDialysisRecords.DialysisDate, 10) + ":dialysis_order"
1924
 	redis := service.RedisClient()
2045
 	redis := service.RedisClient()
1925
 	defer redis.Close()
2046
 	defer redis.Close()

+ 637 - 6
controllers/mobile_api_controllers/dialysis_api_controller.go View File

686
 		NursingRecord:   nursingRecord,
686
 		NursingRecord:   nursingRecord,
687
 		SpecialRecord:   specialRecord,
687
 		SpecialRecord:   specialRecord,
688
 	}
688
 	}
689
+
690
+	// 查询信息规挡的设置天数
691
+
692
+	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
693
+	if infor.ID > 0 {
694
+
695
+		var cha_time int64
696
+
697
+		timeNowStr := time.Now().Format("2006-01-02")
698
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
699
+
700
+		//今日的日期减去设置的日期
701
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
702
+
703
+		if cha_time >= recordDate.Unix() {
704
+			//查询审核是否允许
705
+			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
706
+			//申请状态不允许的情况 拒绝修改
707
+			if infor.ApplicationStatus != 1 {
708
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
709
+				return
710
+			}
711
+
712
+		}
713
+	}
689
 	_, treatmentSummary := service.FindTreatmentSummaryByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
714
 	_, treatmentSummary := service.FindTreatmentSummaryByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
690
 	if treatmentSummary.ID == 0 { //新增
715
 	if treatmentSummary.ID == 0 { //新增
691
 		summary.Creater = adminUserInfo.AdminUser.Id
716
 		summary.Creater = adminUserInfo.AdminUser.Id
692
 		service.AddSigleSummaryRecord(&summary)
717
 		service.AddSigleSummaryRecord(&summary)
718
+		finish := models.XtDialysisFinish{
719
+			IsFinish:   1,
720
+			UserOrgId:  adminUserInfo.Org.Id,
721
+			Status:     1,
722
+			Ctime:      time.Now().Unix(),
723
+			Mtime:      0,
724
+			Module:     10,
725
+			RecordDate: recordDate.Unix(),
726
+			Sourse:     1,
727
+		}
728
+
729
+		dialysisFinish, _ := service.GetDialysisFinish(adminUserInfo.Org.Id, recordDate.Unix(), 10)
730
+		if dialysisFinish.ID == 0 {
731
+			service.CreateDialysisFinish(finish)
732
+		}
693
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summary"
733
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summary"
694
 		redis := service.RedisClient()
734
 		redis := service.RedisClient()
695
 		//清空key 值
735
 		//清空key 值
856
 				}
896
 				}
857
 			}
897
 			}
858
 		}
898
 		}
899
+
900
+		// 查询信息规挡的设置天数
901
+
902
+		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
903
+		if infor.ID > 0 {
904
+
905
+			var cha_time int64
906
+
907
+			timeNowStr := time.Now().Format("2006-01-02")
908
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
909
+
910
+			//今日的日期减去设置的日期
911
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
912
+
913
+			fmt.Println(" recordDate.Unix()-----------", recordDate.Unix())
914
+			fmt.Println("cha_time-------------", cha_time)
915
+			if cha_time >= recordDate.Unix() {
916
+				//查询审核是否允许
917
+				infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
918
+				//申请状态不允许的情况 拒绝修改
919
+				if infor.ApplicationStatus != 1 {
920
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
921
+					return
922
+				}
923
+
924
+			}
925
+		}
859
 		err := service.AddSigleDoubleCheck(&doubleCheck)
926
 		err := service.AddSigleDoubleCheck(&doubleCheck)
927
+		finish := models.XtDialysisFinish{
928
+			IsFinish:   1,
929
+			UserOrgId:  adminUserInfo.Org.Id,
930
+			Status:     1,
931
+			Ctime:      time.Now().Unix(),
932
+			Mtime:      0,
933
+			Module:     5,
934
+			RecordDate: recordDate.Unix(),
935
+			Sourse:     1,
936
+		}
937
+
938
+		dialysisFinish, err := service.GetDialysisFinish(adminUserInfo.Org.Id, recordDate.Unix(), 5)
939
+		if dialysisFinish.ID == 0 {
940
+			service.CreateDialysisFinish(finish)
941
+		}
860
 
942
 
861
 		//针对长沙南雅
943
 		//针对长沙南雅
862
 		if adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 3877 {
944
 		if adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 3877 {
894
 			})
976
 			})
895
 		}
977
 		}
896
 	} else { //修改
978
 	} else { //修改
979
+		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
980
+		if infor.ID > 0 {
981
+
982
+			var cha_time int64
983
+
984
+			timeNowStr := time.Now().Format("2006-01-02")
985
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
986
+
987
+			//今日的日期减去设置的日期
988
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
989
+
990
+			if cha_time >= recordDate.Unix() {
991
+				//查询审核是否允许
992
+				infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
993
+				//申请状态不允许的情况 拒绝修改
994
+				if infor.ApplicationStatus != 1 {
995
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
996
+					return
997
+				}
897
 
998
 
999
+			}
1000
+		}
898
 		doubleCheck.FirstCheckTime = firstCheckDate
1001
 		doubleCheck.FirstCheckTime = firstCheckDate
899
 		doubleCheck.CheckTime = checkDate
1002
 		doubleCheck.CheckTime = checkDate
900
 		doubleCheck.Creater = creater
1003
 		doubleCheck.Creater = creater
1011
 		return
1114
 		return
1012
 	}
1115
 	}
1013
 
1116
 
1117
+	// 查询信息规挡的设置天数
1118
+
1119
+	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
1120
+	if infor.ID > 0 {
1121
+
1122
+		var cha_time int64
1123
+
1124
+		timeNowStr := time.Now().Format("2006-01-02")
1125
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
1126
+
1127
+		//今日的日期减去设置的日期
1128
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
1129
+
1130
+		if cha_time >= recordDate.Unix() {
1131
+			//查询审核是否允许
1132
+			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1133
+			//申请状态不允许的情况 拒绝修改
1134
+			if infor.ApplicationStatus != 1 {
1135
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1136
+				return
1137
+			}
1138
+
1139
+		}
1140
+	}
1141
+
1014
 	_, receiveTreatment := service.FindReceiveTreatmentAssesByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1142
 	_, receiveTreatment := service.FindReceiveTreatmentAssesByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1015
 	receiveTreatmentAsses := models.ReceiveTreatmentAsses{
1143
 	receiveTreatmentAsses := models.ReceiveTreatmentAsses{
1016
 		UserOrgId:                    adminUserInfo.Org.Id,
1144
 		UserOrgId:                    adminUserInfo.Org.Id,
1045
 	if receiveTreatment.ID == 0 { //新增
1173
 	if receiveTreatment.ID == 0 { //新增
1046
 		receiveTreatmentAsses.Creater = adminUserInfo.AdminUser.Id
1174
 		receiveTreatmentAsses.Creater = adminUserInfo.AdminUser.Id
1047
 		err := service.AddSigleReceiveTreatmentAssesRecord(&receiveTreatmentAsses)
1175
 		err := service.AddSigleReceiveTreatmentAssesRecord(&receiveTreatmentAsses)
1176
+		finish := models.XtDialysisFinish{
1177
+			IsFinish:   1,
1178
+			UserOrgId:  adminUserInfo.Org.Id,
1179
+			Status:     1,
1180
+			Ctime:      time.Now().Unix(),
1181
+			Mtime:      0,
1182
+			Module:     2,
1183
+			RecordDate: recordDate.Unix(),
1184
+			Sourse:     1,
1185
+		}
1186
+
1187
+		dialysisFinish, err := service.GetDialysisFinish(adminUserInfo.Org.Id, recordDate.Unix(), 2)
1188
+		if dialysisFinish.ID == 0 {
1189
+			service.CreateDialysisFinish(finish)
1190
+		}
1191
+
1048
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":receive_treatment_asses"
1192
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":receive_treatment_asses"
1049
 		redis := service.RedisClient()
1193
 		redis := service.RedisClient()
1050
 		defer redis.Close()
1194
 		defer redis.Close()
1121
 	//dialysateVolume, _ := c.GetInt64("dialysis_intakes", 0)
1265
 	//dialysateVolume, _ := c.GetInt64("dialysis_intakes", 0)
1122
 	dialysis_intakes := c.GetString("dialysis_intakes")
1266
 	dialysis_intakes := c.GetString("dialysis_intakes")
1123
 	dialysateVolume, _ := strconv.ParseFloat(dialysis_intakes, 64)
1267
 	dialysateVolume, _ := strconv.ParseFloat(dialysis_intakes, 64)
1124
-	fmt.Println("dialysateVolumewode 23323233223232wode", dialysateVolume)
1268
+
1125
 	dialysis_intakes_unit, _ := c.GetInt64("dialysis_intakes_unit", 0)
1269
 	dialysis_intakes_unit, _ := c.GetInt64("dialysis_intakes_unit", 0)
1126
 
1270
 
1127
 	blood_access_part_id, _ := c.GetInt64("blood_access_part_id", 0)
1271
 	blood_access_part_id, _ := c.GetInt64("blood_access_part_id", 0)
1299
 
1443
 
1300
 		}
1444
 		}
1301
 
1445
 
1446
+		// 查询信息规挡的设置天数
1447
+
1448
+		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
1449
+		if infor.ID > 0 {
1450
+
1451
+			var cha_time int64
1452
+
1453
+			timeNowStr := time.Now().Format("2006-01-02")
1454
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
1455
+
1456
+			//今日的日期减去设置的日期
1457
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
1458
+
1459
+			if cha_time >= recordDate.Unix() {
1460
+				//查询审核是否允许
1461
+				infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1462
+				//申请状态不允许的情况 拒绝修改
1463
+				if infor.ApplicationStatus != 1 {
1464
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1465
+					return
1466
+				}
1467
+
1468
+			}
1469
+		}
1302
 		err := service.AddSigleAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
1470
 		err := service.AddSigleAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
1471
+		finish := models.XtDialysisFinish{
1472
+			IsFinish:   1,
1473
+			UserOrgId:  adminUserInfo.Org.Id,
1474
+			Status:     1,
1475
+			Ctime:      time.Now().Unix(),
1476
+			Mtime:      0,
1477
+			Module:     9,
1478
+			RecordDate: recordDate.Unix(),
1479
+			Sourse:     1,
1480
+		}
1481
+
1482
+		dialysisFinish, err := service.GetDialysisFinish(adminUserInfo.Org.Id, recordDate.Unix(), 9)
1483
+		if dialysisFinish.ID == 0 {
1484
+			service.CreateDialysisFinish(finish)
1485
+		}
1303
 		redis := service.RedisClient()
1486
 		redis := service.RedisClient()
1304
 		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1487
 		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1305
 		redis.Set(keyTwo, "", time.Second)
1488
 		redis.Set(keyTwo, "", time.Second)
1354
 
1537
 
1355
 func (c *DialysisAPIController) PostDialysisPrescription() {
1538
 func (c *DialysisAPIController) PostDialysisPrescription() {
1356
 	id, _ := c.GetInt64("patient", 0)
1539
 	id, _ := c.GetInt64("patient", 0)
1357
-
1358
 	recordDateStr := c.GetString("record_date")
1540
 	recordDateStr := c.GetString("record_date")
1359
 
1541
 
1360
 	if id <= 0 {
1542
 	if id <= 0 {
1364
 
1546
 
1365
 	adminUserInfo := c.GetMobileAdminUserInfo()
1547
 	adminUserInfo := c.GetMobileAdminUserInfo()
1366
 	patient, _ := service.FindPatientById(adminUserInfo.Org.Id, id)
1548
 	patient, _ := service.FindPatientById(adminUserInfo.Org.Id, id)
1549
+
1367
 	if patient.ID == 0 {
1550
 	if patient.ID == 0 {
1368
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
1551
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
1369
 		return
1552
 		return
1438
 	safe_package, _ := c.GetInt64("package", 0)
1621
 	safe_package, _ := c.GetInt64("package", 0)
1439
 	a_liquid, _ := c.GetInt64("a_liquid", 0)
1622
 	a_liquid, _ := c.GetInt64("a_liquid", 0)
1440
 	pre_impulse, parseDateErr := c.GetFloat("pre_impulse", 0)
1623
 	pre_impulse, parseDateErr := c.GetFloat("pre_impulse", 0)
1441
-	fmt.Println("预冲量", pre_impulse)
1624
+
1442
 	anticoagulant_stop_time_hour, _ := c.GetInt64("anticoagulant_stop_time_hour", 0)
1625
 	anticoagulant_stop_time_hour, _ := c.GetInt64("anticoagulant_stop_time_hour", 0)
1443
 	anticoagulant_stop_time_min, _ := c.GetInt64("anticoagulant_stop_time_min", 0)
1626
 	anticoagulant_stop_time_min, _ := c.GetInt64("anticoagulant_stop_time_min", 0)
1444
 	blood := c.GetString("blood")
1627
 	blood := c.GetString("blood")
1516
 	//	}
1699
 	//	}
1517
 	//}
1700
 	//}
1518
 
1701
 
1702
+	// 查询信息规挡的设置天数
1703
+
1704
+	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
1705
+	if infor.ID > 0 {
1706
+
1707
+		var cha_time int64
1708
+
1709
+		timeNowStr := time.Now().Format("2006-01-02")
1710
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
1711
+
1712
+		//今日的日期减去设置的日期
1713
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
1714
+
1715
+		if cha_time >= recordDate.Unix() {
1716
+			//查询审核是否允许
1717
+			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1718
+			//申请状态不允许的情况 拒绝修改
1719
+			if infor.ApplicationStatus != 1 {
1720
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1721
+				return
1722
+			}
1723
+
1724
+		}
1725
+	}
1726
+
1519
 	if mode_id > 0 {
1727
 	if mode_id > 0 {
1520
 		var str string
1728
 		var str string
1521
 		//查找该机构用的是什么透析器
1729
 		//查找该机构用的是什么透析器
1722
 			prescription.AdminUserId = adminUserInfo.AdminUser.Id
1930
 			prescription.AdminUserId = adminUserInfo.AdminUser.Id
1723
 		}
1931
 		}
1724
 		err := service.AddSigleRecord(&prescription)
1932
 		err := service.AddSigleRecord(&prescription)
1933
+		finish := models.XtDialysisFinish{
1934
+			IsFinish:   1,
1935
+			UserOrgId:  adminUserInfo.Org.Id,
1936
+			Status:     1,
1937
+			Ctime:      time.Now().Unix(),
1938
+			Mtime:      0,
1939
+			Module:     1,
1940
+			RecordDate: recordDate.Unix(),
1941
+			Sourse:     1,
1942
+		}
1725
 
1943
 
1944
+		dialysisFinish, err := service.GetDialysisFinish(adminUserInfo.Org.Id, recordDate.Unix(), 1)
1945
+		if dialysisFinish.ID == 0 {
1946
+			service.CreateDialysisFinish(finish)
1947
+		}
1726
 		//长沙南雅医院,自动生成抗凝剂的临时处方
1948
 		//长沙南雅医院,自动生成抗凝剂的临时处方
1727
 		if adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 10340 {
1949
 		if adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 10340 {
1728
 
1950
 
2041
 		return
2263
 		return
2042
 	}
2264
 	}
2043
 
2265
 
2266
+	// 查询信息规挡的设置天数
2267
+
2268
+	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
2269
+	if infor.ID > 0 {
2270
+
2271
+		var cha_time int64
2272
+
2273
+		timeNowStr := time.Now().Format("2006-01-02")
2274
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
2275
+
2276
+		//今日的日期减去设置的日期
2277
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
2278
+
2279
+		if cha_time >= recordDate.Unix() {
2280
+			//查询审核是否允许
2281
+			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
2282
+			//申请状态不允许的情况 拒绝修改
2283
+			if infor.ApplicationStatus != 1 {
2284
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
2285
+				return
2286
+			}
2287
+
2288
+		}
2289
+	}
2290
+
2044
 	//now := time.Now()
2291
 	//now := time.Now()
2045
 	//year, month, day := now.Date()
2292
 	//year, month, day := now.Date()
2046
 	//today_time := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
2293
 	//today_time := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
2339
 
2586
 
2340
 	if dialysisOrder.Stage == 1 {
2587
 	if dialysisOrder.Stage == 1 {
2341
 		err := service.ModifyDialysisRecord(dialysisOrder.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id, puncture_point_haematoma, internal_fistula, catheter, cruor, mission)
2588
 		err := service.ModifyDialysisRecord(dialysisOrder.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id, puncture_point_haematoma, internal_fistula, catheter, cruor, mission)
2589
+		finish := models.XtDialysisFinish{
2590
+			IsFinish:   1,
2591
+			UserOrgId:  adminUserInfo.Org.Id,
2592
+			Status:     1,
2593
+			Ctime:      time.Now().Unix(),
2594
+			Mtime:      0,
2595
+			Module:     8,
2596
+			RecordDate: recordDate.Unix(),
2597
+			Sourse:     1,
2598
+		}
2342
 
2599
 
2600
+		dialysisFinish, err := service.GetDialysisFinish(adminUserInfo.Org.Id, recordDate.Unix(), 8)
2601
+		if dialysisFinish.ID == 0 {
2602
+			service.CreateDialysisFinish(finish)
2603
+		}
2343
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
2604
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
2344
 		redis := service.RedisClient()
2605
 		redis := service.RedisClient()
2345
 		defer redis.Close()
2606
 		defer redis.Close()
2728
 	if errorscode == gorm.ErrRecordNotFound {
2989
 	if errorscode == gorm.ErrRecordNotFound {
2729
 
2990
 
2730
 		createErr := service.MobileCreateDialysisOrder(adminUserInfo.Org.Id, patientID, dialysisRecord)
2991
 		createErr := service.MobileCreateDialysisOrder(adminUserInfo.Org.Id, patientID, dialysisRecord)
2992
+		finish := models.XtDialysisFinish{
2993
+			IsFinish:   1,
2994
+			UserOrgId:  adminUserInfo.Org.Id,
2995
+			Status:     1,
2996
+			Ctime:      time.Now().Unix(),
2997
+			Mtime:      0,
2998
+			Module:     6,
2999
+			RecordDate: recordDate.Unix(),
3000
+			Sourse:     1,
3001
+		}
3002
+
3003
+		dialysisFinish, _ := service.GetDialysisFinish(adminUserInfo.Org.Id, recordDate.Unix(), 6)
3004
+		if dialysisFinish.ID == 0 {
3005
+			service.CreateDialysisFinish(finish)
3006
+		}
2731
 		service.UpdateMobilePatient(adminUserInfo.Org.Id, patientID, schedule_remark)
3007
 		service.UpdateMobilePatient(adminUserInfo.Org.Id, patientID, schedule_remark)
2732
 
3008
 
2733
 		if adminUserInfo.Org.Id != 10101 && adminUserInfo.Org.Id != 10445 && adminUserInfo.Org.Id != 3877 && adminUserInfo.Org.Id != 10345 {
3009
 		if adminUserInfo.Org.Id != 10101 && adminUserInfo.Org.Id != 10445 && adminUserInfo.Org.Id != 3877 && adminUserInfo.Org.Id != 10345 {
2902
 			record.PulseFrequency = 80
3178
 			record.PulseFrequency = 80
2903
 			record.Temperature = 36.5
3179
 			record.Temperature = 36.5
2904
 		}
3180
 		}
3181
+
3182
+		// 查询信息规挡的设置天数
3183
+
3184
+		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
3185
+		if infor.ID > 0 {
3186
+
3187
+			var cha_time int64
3188
+
3189
+			timeNowStr := time.Now().Format("2006-01-02")
3190
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
3191
+
3192
+			//今日的日期减去设置的日期
3193
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
3194
+
3195
+			if cha_time >= recordDate.Unix() {
3196
+				//查询审核是否允许
3197
+				infor, _ := service.GetDialysisInformationByRecordDate(patientID, recordDate.Unix(), adminUserInfo.Org.Id)
3198
+				//申请状态不允许的情况 拒绝修改
3199
+				if infor.ApplicationStatus != 1 {
3200
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
3201
+					return
3202
+				}
3203
+
3204
+			}
3205
+		}
2905
 		err := service.CreateMonitor(&record)
3206
 		err := service.CreateMonitor(&record)
3207
+		finish := models.XtDialysisFinish{
3208
+			IsFinish:   1,
3209
+			UserOrgId:  adminUserInfo.Org.Id,
3210
+			Status:     1,
3211
+			Ctime:      time.Now().Unix(),
3212
+			Mtime:      0,
3213
+			Module:     7,
3214
+			RecordDate: recordDate.Unix(),
3215
+			Sourse:     1,
3216
+		}
2906
 
3217
 
3218
+		dialysisFinish, _ := service.GetDialysisFinish(adminUserInfo.Org.Id, recordDate.Unix(), 7)
3219
+		if dialysisFinish.ID == 0 {
3220
+			service.CreateDialysisFinish(finish)
3221
+		}
2907
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":monitor_records"
3222
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":monitor_records"
2908
 
3223
 
2909
 		redis := service.RedisClient()
3224
 		redis := service.RedisClient()
3105
 	//	}
3420
 	//	}
3106
 	//}
3421
 	//}
3107
 
3422
 
3423
+	// 查询信息规挡的设置天数
3424
+
3425
+	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
3426
+	if infor.ID > 0 {
3427
+
3428
+		var cha_time int64
3429
+
3430
+		timeNowStr := time.Now().Format("2006-01-02")
3431
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
3432
+
3433
+		//今日的日期减去设置的日期
3434
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
3435
+
3436
+		if cha_time >= recordDate.Unix() {
3437
+			//查询审核是否允许
3438
+			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
3439
+			//申请状态不允许的情况 拒绝修改
3440
+			if infor.ApplicationStatus != 1 {
3441
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
3442
+				return
3443
+			}
3444
+
3445
+		}
3446
+	}
3447
+
3108
 	prescription := models.DialysisPrescription{
3448
 	prescription := models.DialysisPrescription{
3109
 
3449
 
3110
 		UserOrgId:          adminUserInfo.Org.Id,
3450
 		UserOrgId:          adminUserInfo.Org.Id,
3366
 	}
3706
 	}
3367
 
3707
 
3368
 	service.SavePrescriptionAndCreateSolution(&solution, &prescription)
3708
 	service.SavePrescriptionAndCreateSolution(&solution, &prescription)
3709
+	finish := models.XtDialysisFinish{
3710
+		IsFinish:   1,
3711
+		UserOrgId:  adminUserInfo.Org.Id,
3712
+		Status:     1,
3713
+		Ctime:      time.Now().Unix(),
3714
+		Mtime:      0,
3715
+		Module:     1,
3716
+		RecordDate: recordDate.Unix(),
3717
+		Sourse:     1,
3718
+	}
3719
+
3720
+	dialysisFinish, _ := service.GetDialysisFinish(adminUserInfo.Org.Id, recordDate.Unix(), 1)
3721
+	if dialysisFinish.ID == 0 {
3722
+		service.CreateDialysisFinish(finish)
3723
+	}
3369
 	//获取最新1条
3724
 	//获取最新1条
3370
 	dialysisSolution, _ := service.GetLastPatientDialysisSolution(id, adminUserInfo.Org.Id)
3725
 	dialysisSolution, _ := service.GetLastPatientDialysisSolution(id, adminUserInfo.Org.Id)
3371
 	//更新状态
3726
 	//更新状态
3976
 		defer redis.Close()
4331
 		defer redis.Close()
3977
 
4332
 
3978
 	}
4333
 	}
4334
+	// 查询信息规挡的设置天数
4335
+
4336
+	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
4337
+	if infor.ID > 0 {
4338
+
4339
+		var cha_time int64
4340
+
4341
+		timeNowStr := time.Now().Format("2006-01-02")
4342
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
4343
+
4344
+		//今日的日期减去设置的日期
4345
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
3979
 
4346
 
4347
+		if cha_time >= record_date {
4348
+			//查询审核是否允许
4349
+			infor, _ := service.GetDialysisInformationByRecordDate(tempDialysisRecord.PatientId, record_date, adminUserInfo.Org.Id)
4350
+			//申请状态不允许的情况 拒绝修改
4351
+			if infor.ApplicationStatus != 1 {
4352
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
4353
+				return
4354
+			}
4355
+
4356
+		}
4357
+	}
3980
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
4358
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
3981
 	order, _ := service.GetLastPatientOrder(record_id)
4359
 	order, _ := service.GetLastPatientOrder(record_id)
3982
 	service.UpdateMobilePatient(adminUserInfo.Org.Id, order.PatientId, schedule_remark)
4360
 	service.UpdateMobilePatient(adminUserInfo.Org.Id, order.PatientId, schedule_remark)
4093
 	//	}
4471
 	//	}
4094
 	//}
4472
 	//}
4095
 
4473
 
4474
+	// 查询信息规挡的设置天数
4475
+
4476
+	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
4477
+	if infor.ID > 0 {
4478
+
4479
+		var cha_time int64
4480
+
4481
+		timeNowStr := time.Now().Format("2006-01-02")
4482
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
4483
+
4484
+		//今日的日期减去设置的日期
4485
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
4486
+
4487
+		if cha_time >= tempDialysisRecords.DialysisDate {
4488
+			//查询审核是否允许
4489
+			infor, _ := service.GetDialysisInformationByRecordDate(tempDialysisRecords.PatientId, tempDialysisRecords.DialysisDate, adminUserInfo.Org.Id)
4490
+			//申请状态不允许的情况 拒绝修改
4491
+			if infor.ApplicationStatus != 1 {
4492
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
4493
+				return
4494
+			}
4495
+
4496
+		}
4497
+	}
4096
 	dialysisRecord := &models.DialysisOrder{
4498
 	dialysisRecord := &models.DialysisOrder{
4097
 		ID:                         record_id,
4499
 		ID:                         record_id,
4098
 		UserOrgId:                  adminUserInfo.Org.Id,
4500
 		UserOrgId:                  adminUserInfo.Org.Id,
4909
 	theRecordTime, _ := time.ParseInLocation(timeLayout, record_date, loc)
5311
 	theRecordTime, _ := time.ParseInLocation(timeLayout, record_date, loc)
4910
 	record_time := theRecordTime.Unix()
5312
 	record_time := theRecordTime.Unix()
4911
 
5313
 
5314
+	// 查询信息规挡的设置天数
5315
+	orgid := c.GetMobileAdminUserInfo().Org.Id
5316
+	infor, _ := service.GetDialysisInformationSetting(adminUser.Org.Id)
5317
+	if infor.ID > 0 {
5318
+
5319
+		var cha_time int64
5320
+
5321
+		timeNowStr := time.Now().Format("2006-01-02")
5322
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
5323
+
5324
+		//今日的日期减去设置的日期
5325
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
5326
+
5327
+		if cha_time >= record_time {
5328
+			//查询审核是否允许
5329
+			infor, _ := service.GetDialysisInformationByRecordDate(patient_id, record_time, orgid)
5330
+			//申请状态不允许的情况 拒绝修改
5331
+			if infor.ApplicationStatus != 1 {
5332
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
5333
+				return
5334
+			}
5335
+
5336
+		}
5337
+	}
4912
 	dataBody := make(map[string]interface{}, 0)
5338
 	dataBody := make(map[string]interface{}, 0)
4913
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
5339
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
4914
 	if err != nil {
5340
 	if err != nil {
5260
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
5686
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
5261
 		return
5687
 		return
5262
 	}
5688
 	}
5263
-
5264
 	adminInfo := c.GetMobileAdminUserInfo()
5689
 	adminInfo := c.GetMobileAdminUserInfo()
5690
+
5265
 	creator := c.GetMobileAdminUserInfo().AdminUser.Id
5691
 	creator := c.GetMobileAdminUserInfo().AdminUser.Id
5266
 	timeLayout := "2006-01-02"
5692
 	timeLayout := "2006-01-02"
5267
 	loc, _ := time.LoadLocation("Local")
5693
 	loc, _ := time.LoadLocation("Local")
5268
 	theRecordTime, _ := time.ParseInLocation(timeLayout, record_date, loc)
5694
 	theRecordTime, _ := time.ParseInLocation(timeLayout, record_date, loc)
5269
 	record_time := theRecordTime.Unix()
5695
 	record_time := theRecordTime.Unix()
5270
 
5696
 
5697
+	// 查询信息规挡的设置天数
5698
+
5699
+	infor, _ := service.GetDialysisInformationSetting(adminInfo.Org.Id)
5700
+	if infor.ID > 0 {
5701
+
5702
+		var cha_time int64
5703
+
5704
+		timeNowStr := time.Now().Format("2006-01-02")
5705
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
5706
+
5707
+		//今日的日期减去设置的日期
5708
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
5709
+
5710
+		if cha_time >= record_time {
5711
+			//查询审核是否允许
5712
+			infor, _ := service.GetDialysisInformationByRecordDate(patient_id, record_time, adminInfo.Org.Id)
5713
+			//申请状态不允许的情况 拒绝修改
5714
+			if infor.ApplicationStatus != 1 {
5715
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
5716
+				return
5717
+			}
5718
+
5719
+		}
5720
+	}
5271
 	consumables, _ := service.FindConsumablesByDate(adminInfo.Org.Id, patient_id, record_time)
5721
 	consumables, _ := service.FindConsumablesByDate(adminInfo.Org.Id, patient_id, record_time)
5272
 
5722
 
5273
 	_, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
5723
 	_, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
5360
 					err := service.ConsumablesGoodDelivery(item.UserOrgId, patient_id, record_time, item, &warehouseOut, item.Count)
5810
 					err := service.ConsumablesGoodDelivery(item.UserOrgId, patient_id, record_time, item, &warehouseOut, item.Count)
5361
 
5811
 
5362
 					//err := service.ConsumableMobileDelivery(item.UserOrgId, patient_id, record_time, item, &warehouseOut, adminInfo.AdminUser.Id, item.Count)
5812
 					//err := service.ConsumableMobileDelivery(item.UserOrgId, patient_id, record_time, item, &warehouseOut, adminInfo.AdminUser.Id, item.Count)
5363
-					//fmt.Println("item----------------------------------count", item.Count)
5364
 
5813
 
5365
 					if err == nil {
5814
 					if err == nil {
5366
 						goodErrcode := models.XtGoodErrcode{
5815
 						goodErrcode := models.XtGoodErrcode{
5513
 				//出库
5962
 				//出库
5514
 				err := service.ConsumablesGoodDelivery(item.UserOrgId, patient_id, record_time, item, &out, item.Count)
5963
 				err := service.ConsumablesGoodDelivery(item.UserOrgId, patient_id, record_time, item, &out, item.Count)
5515
 				//err := service.ConsumableMobileDelivery(item.UserOrgId, patient_id, record_time, item, &out, adminInfo.AdminUser.Id, item.Count)
5964
 				//err := service.ConsumableMobileDelivery(item.UserOrgId, patient_id, record_time, item, &out, adminInfo.AdminUser.Id, item.Count)
5516
-				//fmt.Println("item----------------------------------count", item.Count)
5517
 				if err != nil {
5965
 				if err != nil {
5518
 					goodErrcode := models.XtGoodErrcode{
5966
 					goodErrcode := models.XtGoodErrcode{
5519
 						UserOrgId:      adminInfo.Org.Id,
5967
 						UserOrgId:      adminInfo.Org.Id,
5689
 	theRecordTime, _ := time.ParseInLocation(timeLayout, record_date, loc)
6137
 	theRecordTime, _ := time.ParseInLocation(timeLayout, record_date, loc)
5690
 	record_time := theRecordTime.Unix()
6138
 	record_time := theRecordTime.Unix()
5691
 
6139
 
6140
+	// 查询信息规挡的设置天数
6141
+
6142
+	infor, _ := service.GetDialysisInformationSetting(adminInfo.Org.Id)
6143
+	if infor.ID > 0 {
6144
+
6145
+		var cha_time int64
6146
+
6147
+		timeNowStr := time.Now().Format("2006-01-02")
6148
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
6149
+
6150
+		//今日的日期减去设置的日期
6151
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
6152
+
6153
+		if cha_time >= record_time {
6154
+			//查询审核是否允许
6155
+			infor, _ := service.GetDialysisInformationByRecordDate(patient_id, record_time, adminInfo.Org.Id)
6156
+			//申请状态不允许的情况 拒绝修改
6157
+			if infor.ApplicationStatus != 1 {
6158
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
6159
+				return
6160
+			}
6161
+
6162
+		}
6163
+	}
5692
 	dataBody := make(map[string]interface{}, 0)
6164
 	dataBody := make(map[string]interface{}, 0)
5693
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
6165
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
5694
 	if err != nil {
6166
 	if err != nil {
6544
 
7016
 
6545
 	}
7017
 	}
6546
 
7018
 
7019
+	// 查询信息规挡的设置天数
7020
+
7021
+	infor, _ := service.GetDialysisInformationSetting(adminInfo.Org.Id)
7022
+	if infor.ID > 0 {
7023
+
7024
+		var cha_time int64
7025
+
7026
+		timeNowStr := time.Now().Format("2006-01-02")
7027
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
7028
+
7029
+		//今日的日期减去设置的日期
7030
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
7031
+
7032
+		if cha_time >= record_time {
7033
+			//查询审核是否允许
7034
+			infor, _ := service.GetDialysisInformationByRecordDate(patient_id, record_time, adminInfo.Org.Id)
7035
+			//申请状态不允许的情况 拒绝修改
7036
+			if infor.ApplicationStatus != 1 {
7037
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
7038
+				return
7039
+			}
7040
+
7041
+		}
7042
+	}
7043
+
6547
 	//出库逻辑
7044
 	//出库逻辑
6548
 	err = service.ConsumablesDeliveryTotal(adminInfo.Org.Id, patient_id, record_time, beforePrepares, newBeforePrepares, adminInfo.AdminUser.Id)
7045
 	err = service.ConsumablesDeliveryTotal(adminInfo.Org.Id, patient_id, record_time, beforePrepares, newBeforePrepares, adminInfo.AdminUser.Id)
6549
 
7046
 
6553
 		return
7050
 		return
6554
 
7051
 
6555
 	}
7052
 	}
7053
+
7054
+	finish := models.XtDialysisFinish{
7055
+		IsFinish:   1,
7056
+		UserOrgId:  adminInfo.Org.Id,
7057
+		Status:     1,
7058
+		Ctime:      time.Now().Unix(),
7059
+		Mtime:      0,
7060
+		Module:     11,
7061
+		RecordDate: record_time,
7062
+		Sourse:     1,
7063
+	}
7064
+
7065
+	dialysisFinish, err := service.GetDialysisFinish(adminInfo.Org.Id, record_time, 11)
7066
+	if dialysisFinish.ID == 0 {
7067
+		service.CreateDialysisFinish(finish)
7068
+	}
7069
+
6556
 	//查询当天出库的数据
7070
 	//查询当天出库的数据
6557
 	list, _ := service.GetAutoReduceRecordInfoByPatientId(adminInfo.Org.Id, patient_id, record_time)
7071
 	list, _ := service.GetAutoReduceRecordInfoByPatientId(adminInfo.Org.Id, patient_id, record_time)
6558
 
7072
 
8429
 		return
8943
 		return
8430
 	}
8944
 	}
8431
 }
8945
 }
8946
+
8947
+func (this *DialysisAPIController) SaveMobileInformation() {
8948
+
8949
+	patient_id, _ := this.GetInt64("patient_id")
8950
+	record_date, _ := this.GetInt64("record_date")
8951
+	startTime := this.GetString("start_time")
8952
+	module, _ := this.GetInt64("module")
8953
+	remark := this.GetString("remark")
8954
+	timeLayout := "2006-01-02 15:04"
8955
+	loc, _ := time.LoadLocation("Local")
8956
+
8957
+	if len(startTime) == 0 {
8958
+		utils.ErrorLog("len(start_time) == 0")
8959
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8960
+		return
8961
+	}
8962
+	theTime, err := time.ParseInLocation(timeLayout, startTime, loc)
8963
+	if err != nil {
8964
+		utils.ErrorLog(err.Error())
8965
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8966
+		return
8967
+	}
8968
+	StartTime := theTime.Unix()
8969
+	fmt.Println("startime-------------", StartTime)
8970
+	creater := this.GetMobileAdminUserInfo().AdminUser.Id
8971
+
8972
+	user_org_id := this.GetMobileAdminUserInfo().Org.Id
8973
+
8974
+	information := models.XtDialysisInformation{
8975
+		Module:            module,
8976
+		PatientId:         patient_id,
8977
+		RecordDate:        record_date,
8978
+		ApplicationDate:   StartTime,
8979
+		Creater:           creater,
8980
+		ApplicationStatus: 2,
8981
+		Checker:           0,
8982
+		CheckTime:         0,
8983
+		Remark:            remark,
8984
+		UserOrgId:         user_org_id,
8985
+		Ctime:             time.Now().Unix(),
8986
+		Status:            1,
8987
+		Mtime:             0,
8988
+	}
8989
+
8990
+	infor, _ := service.GetDialysisInformationByRecordDate(patient_id, record_date, user_org_id)
8991
+	if infor.ID == 0 {
8992
+		service.SaveDialysisInformation(information)
8993
+	}
8994
+	if infor.ID > 0 {
8995
+		service.UpdateInformationByRecordDate(patient_id, record_date, user_org_id, StartTime, remark)
8996
+	}
8997
+
8998
+	this.ServeSuccessJSON(map[string]interface{}{
8999
+		"information": information,
9000
+	})
9001
+	return
9002
+}
9003
+
9004
+func (this *DialysisAPIController) GetMobileInformation() {
9005
+
9006
+	limit, _ := this.GetInt64("limit")
9007
+
9008
+	page, _ := this.GetInt64("page")
9009
+
9010
+	orgid := this.GetMobileAdminUserInfo().Org.Id
9011
+	information, total, _ := service.GetMobileInformation(limit, page, 2, orgid)
9012
+	appid := this.GetMobileAdminUserInfo().App.Id
9013
+	doclist, _ := service.GetAllDoctorSix(orgid, appid)
9014
+	patients, _ := service.GetAllpatientThirty(orgid)
9015
+	this.ServeSuccessJSON(map[string]interface{}{
9016
+		"information": information,
9017
+		"total":       total,
9018
+		"doclist":     doclist,
9019
+		"patients":    patients,
9020
+	})
9021
+	return
9022
+
9023
+}
9024
+
9025
+func (this *DialysisAPIController) GetMobileInformationOne() {
9026
+
9027
+	limit, _ := this.GetInt64("limit")
9028
+
9029
+	page, _ := this.GetInt64("page")
9030
+
9031
+	orgid := this.GetMobileAdminUserInfo().Org.Id
9032
+	information, total, _ := service.GetMobileInformationOne(limit, page, orgid)
9033
+	appid := this.GetMobileAdminUserInfo().App.Id
9034
+	doclist, _ := service.GetAllDoctorSix(orgid, appid)
9035
+	patients, _ := service.GetAllpatientThirty(orgid)
9036
+	this.ServeSuccessJSON(map[string]interface{}{
9037
+		"information": information,
9038
+		"total":       total,
9039
+		"doclist":     doclist,
9040
+		"patients":    patients,
9041
+	})
9042
+	return
9043
+}
9044
+
9045
+func (this *DialysisAPIController) CheckMobileInformation() {
9046
+
9047
+	id, _ := this.GetInt64("id")
9048
+
9049
+	application_status, _ := this.GetInt64("application_status")
9050
+
9051
+	checker := this.GetMobileAdminUserInfo().AdminUser.Id
9052
+	checktime := time.Now().Unix()
9053
+	err := service.CheckMobileInformation(id, application_status, checker, checktime)
9054
+
9055
+	if err == nil {
9056
+		this.ServeSuccessJSON(map[string]interface{}{
9057
+			"msg": "ok",
9058
+		})
9059
+		return
9060
+	}
9061
+
9062
+}

+ 89 - 1
controllers/mobile_api_controllers/dialysis_api_controller_extend.go View File

117
 		return
117
 		return
118
 	}
118
 	}
119
 
119
 
120
+	// 查询信息规挡的设置天数
121
+
122
+	infor, _ := service.GetDialysisInformationSetting(adminInfo.Org.Id)
123
+	if infor.ID > 0 {
124
+
125
+		var cha_time int64
126
+
127
+		timeNowStr := time.Now().Format("2006-01-02")
128
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
129
+
130
+		//今日的日期减去设置的日期
131
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
132
+
133
+		if cha_time >= date {
134
+			//查询审核是否允许
135
+			infor, _ := service.GetDialysisInformationByRecordDate(patientID, date, adminInfo.Org.Id)
136
+			//申请状态不允许的情况 拒绝修改
137
+			if infor.ApplicationStatus != 1 {
138
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
139
+				return
140
+			}
141
+
142
+		}
143
+	}
120
 	record := models.MonitoringRecord{
144
 	record := models.MonitoringRecord{
121
 		UserOrgId:       adminInfo.Org.Id,
145
 		UserOrgId:       adminInfo.Org.Id,
122
 		PatientId:       patientID,
146
 		PatientId:       patientID,
175
 	}
199
 	}
176
 
200
 
177
 	err := service.CreateMonitor(&record)
201
 	err := service.CreateMonitor(&record)
202
+	finish := models.XtDialysisFinish{
203
+		IsFinish:   1,
204
+		UserOrgId:  record.UserOrgId,
205
+		Status:     1,
206
+		Ctime:      time.Now().Unix(),
207
+		Mtime:      0,
208
+		Module:     7,
209
+		RecordDate: record.MonitoringDate,
210
+		Sourse:     1,
211
+	}
212
+
213
+	dialysisFinish, err := service.GetDialysisFinish(record.UserOrgId, record.MonitoringDate, 7)
214
+	if dialysisFinish.ID == 0 {
215
+		service.CreateDialysisFinish(finish)
216
+	}
178
 	key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(date, 10) + ":monitor_records"
217
 	key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(date, 10) + ":monitor_records"
179
 	redis := service.RedisClient()
218
 	redis := service.RedisClient()
180
 	//清空key 值
219
 	//清空key 值
345
 	monitor.HeparinAmount = heparin_amount
384
 	monitor.HeparinAmount = heparin_amount
346
 	monitor.Dehydration = dehydration
385
 	monitor.Dehydration = dehydration
347
 	monitor.FilterPressure = filter_pressure
386
 	monitor.FilterPressure = filter_pressure
387
+
388
+	// 查询信息规挡的设置天数
389
+
390
+	infor, _ := service.GetDialysisInformationSetting(monitor.MonitoringDate)
391
+	if infor.ID > 0 {
392
+
393
+		var cha_time int64
394
+
395
+		timeNowStr := time.Now().Format("2006-01-02")
396
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
397
+
398
+		//今日的日期减去设置的日期
399
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
400
+
401
+		if cha_time >= monitor.MonitoringDate {
402
+			//查询审核是否允许
403
+			infor, _ := service.GetDialysisInformationByRecordDate(id, monitor.MonitoringDate, monitor.UserOrgId)
404
+			//申请状态不允许的情况 拒绝修改
405
+			if infor.ApplicationStatus != 1 {
406
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
407
+				return
408
+			}
409
+
410
+		}
411
+	}
348
 	err = service.UpdateMonitor(monitor)
412
 	err = service.UpdateMonitor(monitor)
349
 	key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(date, 10) + ":monitor_records"
413
 	key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(date, 10) + ":monitor_records"
350
 	redis := service.RedisClient()
414
 	redis := service.RedisClient()
391
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
455
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
392
 		return
456
 		return
393
 	}
457
 	}
458
+
459
+	// 查询信息规挡的设置天数
460
+
461
+	infor, _ := service.GetDialysisInformationSetting(adminInfo.Org.Id)
462
+	if infor.ID > 0 {
463
+
464
+		var cha_time int64
465
+
466
+		timeNowStr := time.Now().Format("2006-01-02")
467
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
468
+
469
+		//今日的日期减去设置的日期
470
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
471
+
472
+		if cha_time >= monitor.MonitoringDate {
473
+			//查询审核是否允许
474
+			infor, _ := service.GetDialysisInformationByRecordDate(monitor.PatientId, monitor.MonitoringDate, monitor.UserOrgId)
475
+			//申请状态不允许的情况 拒绝修改
476
+			if infor.ApplicationStatus != 1 {
477
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
478
+				return
479
+			}
480
+
481
+		}
482
+	}
394
 	err := service.DisableMonitor(adminInfo.Org.Id, patientID, recordID, adminInfo.AdminUser.Id)
483
 	err := service.DisableMonitor(adminInfo.Org.Id, patientID, recordID, adminInfo.AdminUser.Id)
395
 	orgid := this.GetMobileAdminUserInfo().Org.Id
484
 	orgid := this.GetMobileAdminUserInfo().Org.Id
396
 	redis := service.RedisClient()
485
 	redis := service.RedisClient()
398
 	redis.Set(key, "", time.Second)
487
 	redis.Set(key, "", time.Second)
399
 	keyOne := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(monitor.MonitoringDate, 10) + ":monitor_records"
488
 	keyOne := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(monitor.MonitoringDate, 10) + ":monitor_records"
400
 	redis.Set(keyOne, "", time.Second)
489
 	redis.Set(keyOne, "", time.Second)
401
-	fmt.Println("keyo呢32332322332332232332", keyOne)
402
 	redis.Close()
490
 	redis.Close()
403
 
491
 
404
 	if err != nil {
492
 	if err != nil {

+ 9 - 0
controllers/mobile_api_controllers/mobile_api_router_register.go View File

190
 	beego.Router("/m/api/checkmobileadvice", &DialysisAPIController{}, "Get:GetCheckMobileAdvice")
190
 	beego.Router("/m/api/checkmobileadvice", &DialysisAPIController{}, "Get:GetCheckMobileAdvice")
191
 
191
 
192
 	beego.Router("/m/api/getnewdoctorlisttoday", &DialysisAPIController{}, "Get:GetNewDoctorListToday")
192
 	beego.Router("/m/api/getnewdoctorlisttoday", &DialysisAPIController{}, "Get:GetNewDoctorListToday")
193
+
194
+	beego.Router("/m/api/savemobileinformation", &DialysisAPIController{}, "Get:SaveMobileInformation")
195
+
196
+	beego.Router("/m/api/getmobileinformation", &DialysisAPIController{}, "Get:GetMobileInformation")
197
+
198
+	beego.Router("/m/api/getmobileinformationone", &DialysisAPIController{}, "Get:GetMobileInformationOne")
199
+
200
+	beego.Router("/m/api/checkmobileinformation", &DialysisAPIController{}, "Get:CheckMobileInformation")
201
+
193
 }
202
 }

+ 577 - 0
controllers/mobile_api_controllers/patient_api_controller.go View File

310
 		adviceSlice, _ := service.FindAdviceByGoroupNo(adminUserInfo.Org.Id, advice.GroupNo)
310
 		adviceSlice, _ := service.FindAdviceByGoroupNo(adminUserInfo.Org.Id, advice.GroupNo)
311
 		sourceAdvice, _ := service.FindOldDoctorAdvice(adminUserInfo.Org.Id, advice.ID)
311
 		sourceAdvice, _ := service.FindOldDoctorAdvice(adminUserInfo.Org.Id, advice.ID)
312
 		if len(adviceSlice) == 1 {
312
 		if len(adviceSlice) == 1 {
313
+
314
+			// 查询信息规挡的设置天数
315
+
316
+			infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
317
+			if infor.ID > 0 {
318
+
319
+				var cha_time int64
320
+
321
+				timeNowStr := time.Now().Format("2006-01-02")
322
+				timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
323
+
324
+				//今日的日期减去设置的日期
325
+				cha_time = timeNewDate.Unix() - infor.WeekDay*86400
326
+
327
+				if cha_time >= sourceAdvice.AdviceDate {
328
+					//查询审核是否允许
329
+					infor, _ := service.GetDialysisInformationByRecordDate(id, sourceAdvice.AdviceDate, adminUserInfo.Org.Id)
330
+					//申请状态不允许的情况 拒绝修改
331
+					if infor.ApplicationStatus != 1 {
332
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
333
+						return
334
+					}
335
+
336
+				}
337
+			}
313
 			//判断前端上传上来的开始时间和数据库中想要修改的那条医嘱的开始时间是否相同,如果不同,需要修改子医嘱的开始时间,如果相同直接修改,不需要修改子医嘱的开始时间
338
 			//判断前端上传上来的开始时间和数据库中想要修改的那条医嘱的开始时间是否相同,如果不同,需要修改子医嘱的开始时间,如果相同直接修改,不需要修改子医嘱的开始时间
314
 			if advice.StartTime == sourceAdvice.StartTime {
339
 			if advice.StartTime == sourceAdvice.StartTime {
315
 				err = service.UpdateDoctorAdvice(&advice)
340
 				err = service.UpdateDoctorAdvice(&advice)
331
 				redis.Set(keyOne, "", time.Second)
356
 				redis.Set(keyOne, "", time.Second)
332
 			}
357
 			}
333
 		} else if len(adviceSlice) > 1 {
358
 		} else if len(adviceSlice) > 1 {
359
+			infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
360
+			if infor.ID > 0 {
361
+
362
+				var cha_time int64
363
+
364
+				timeNowStr := time.Now().Format("2006-01-02")
365
+				timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
366
+
367
+				//今日的日期减去设置的日期
368
+				cha_time = timeNewDate.Unix() - infor.WeekDay*86400
369
+
370
+				if cha_time >= sourceAdvice.AdviceDate {
371
+					//查询审核是否允许
372
+					infor, _ := service.GetDialysisInformationByRecordDate(id, sourceAdvice.AdviceDate, adminUserInfo.Org.Id)
373
+					//申请状态不允许的情况 拒绝修改
374
+					if infor.ApplicationStatus != 1 {
375
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
376
+						return
377
+					}
334
 
378
 
379
+				}
380
+			}
335
 			//判断前端上传上来的开始时间和数据库中想要修改的那条医嘱的开始时间是否相同,如果不同,需要重新分配组,如果相同直接修改,不需要分配组
381
 			//判断前端上传上来的开始时间和数据库中想要修改的那条医嘱的开始时间是否相同,如果不同,需要重新分配组,如果相同直接修改,不需要分配组
336
 			if advice.StartTime == sourceAdvice.StartTime {
382
 			if advice.StartTime == sourceAdvice.StartTime {
337
 				err = service.UpdateDoctorAdvice(&advice)
383
 				err = service.UpdateDoctorAdvice(&advice)
359
 			}
405
 			}
360
 		}
406
 		}
361
 	} else {
407
 	} else {
408
+		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
409
+		if infor.ID > 0 {
410
+
411
+			var cha_time int64
412
+
413
+			timeNowStr := time.Now().Format("2006-01-02")
414
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
415
+
416
+			//今日的日期减去设置的日期
417
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
418
+
419
+			if cha_time >= advice.AdviceDate {
420
+				//查询审核是否允许
421
+				infor, _ := service.GetDialysisInformationByRecordDate(id, advice.AdviceDate, adminUserInfo.Org.Id)
422
+				//申请状态不允许的情况 拒绝修改
423
+				if infor.ApplicationStatus != 1 {
424
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
425
+					return
426
+				}
427
+
428
+			}
429
+		}
362
 		isChangeGroup = false
430
 		isChangeGroup = false
363
 		err = service.UpdateDoctorAdvice(&advice)
431
 		err = service.UpdateDoctorAdvice(&advice)
364
 		redis := service.RedisClient()
432
 		redis := service.RedisClient()
382
 		})
450
 		})
383
 
451
 
384
 	} else {
452
 	} else {
453
+
385
 		newGroupAdvice, err := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, advice.GroupNo)
454
 		newGroupAdvice, err := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, advice.GroupNo)
386
 		if err != nil {
455
 		if err != nil {
387
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
456
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
620
 		}
689
 		}
621
 		var err error
690
 		var err error
622
 		if groupno > 0 {
691
 		if groupno > 0 {
692
+
693
+			// 查询信息规挡的设置天数
694
+
695
+			infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
696
+			if infor.ID > 0 {
697
+
698
+				var cha_time int64
699
+
700
+				timeNowStr := time.Now().Format("2006-01-02")
701
+				timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
702
+
703
+				//今日的日期减去设置的日期
704
+				cha_time = timeNewDate.Unix() - infor.WeekDay*86400
705
+
706
+				if cha_time >= advices.AdviceDate {
707
+					//查询审核是否允许
708
+					infor, _ := service.GetDialysisInformationByRecordDate(advices.PatientId, advices.AdviceDate, adminUserInfo.Org.Id)
709
+					//申请状态不允许的情况 拒绝修改
710
+					if infor.ApplicationStatus != 1 {
711
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
712
+						return
713
+					}
714
+
715
+				}
716
+			}
623
 			err = service.ExceDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
717
 			err = service.ExceDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
624
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
718
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
625
 			redis := service.RedisClient()
719
 			redis := service.RedisClient()
642
 
736
 
643
 			defer redis.Close()
737
 			defer redis.Close()
644
 		} else {
738
 		} else {
739
+			// 查询信息规挡的设置天数
740
+
741
+			infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
742
+			if infor.ID > 0 {
743
+
744
+				var cha_time int64
645
 
745
 
746
+				timeNowStr := time.Now().Format("2006-01-02")
747
+				timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
748
+
749
+				//今日的日期减去设置的日期
750
+				cha_time = timeNewDate.Unix() - infor.WeekDay*86400
751
+
752
+				if cha_time >= advices.AdviceDate {
753
+					//查询审核是否允许
754
+					infor, _ := service.GetDialysisInformationByRecordDate(advices.PatientId, advices.AdviceDate, adminUserInfo.Org.Id)
755
+					//申请状态不允许的情况 拒绝修改
756
+					if infor.ApplicationStatus != 1 {
757
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
758
+						return
759
+					}
760
+
761
+				}
762
+			}
646
 			err = service.BatchExceOldDoctorAdvice(&advices, ids)
763
 			err = service.BatchExceOldDoctorAdvice(&advices, ids)
647
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
764
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
648
 			redis := service.RedisClient()
765
 			redis := service.RedisClient()
1076
 			item.ExecutionStaff = adminInfo.AdminUser.Id
1193
 			item.ExecutionStaff = adminInfo.AdminUser.Id
1077
 			item.ExecutionTime = theTime.Unix()
1194
 			item.ExecutionTime = theTime.Unix()
1078
 			item.IsMobile = 1
1195
 			item.IsMobile = 1
1196
+
1197
+			// 查询信息规挡的设置天数
1198
+
1199
+			infor, _ := service.GetDialysisInformationSetting(item.UserOrgId)
1200
+			if infor.ID > 0 {
1201
+
1202
+				var cha_time int64
1203
+
1204
+				timeNowStr := time.Now().Format("2006-01-02")
1205
+				timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
1206
+
1207
+				//今日的日期减去设置的日期
1208
+				cha_time = timeNewDate.Unix() - infor.WeekDay*86400
1209
+
1210
+				if cha_time >= item.AdviceDate {
1211
+					//查询审核是否允许
1212
+					infor, _ := service.GetDialysisInformationByRecordDate(item.PatientId, item.AdviceDate, item.UserOrgId)
1213
+					//申请状态不允许的情况 拒绝修改
1214
+					if infor.ApplicationStatus != 1 {
1215
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1216
+						return
1217
+					}
1218
+
1219
+				}
1220
+			}
1079
 			err = service.SaveHisDoctorAdvice(item)
1221
 			err = service.SaveHisDoctorAdvice(item)
1080
 			key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
1222
 			key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
1081
 			redis := service.RedisClient()
1223
 			redis := service.RedisClient()
1483
 	var err error
1625
 	var err error
1484
 	if groupno > 0 {
1626
 	if groupno > 0 {
1485
 
1627
 
1628
+		// 查询信息规挡的设置天数
1629
+
1630
+		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
1631
+		if infor.ID > 0 {
1632
+
1633
+			var cha_time int64
1634
+
1635
+			timeNowStr := time.Now().Format("2006-01-02")
1636
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
1637
+
1638
+			//今日的日期减去设置的日期
1639
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
1640
+
1641
+			if cha_time >= advices.AdviceDate {
1642
+				//查询审核是否允许
1643
+				infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advices.AdviceDate, adminUserInfo.Org.Id)
1644
+				//申请状态不允许的情况 拒绝修改
1645
+				if infor.ApplicationStatus != 1 {
1646
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1647
+					return
1648
+				}
1649
+
1650
+			}
1651
+		}
1486
 		err = service.ModifyExceDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
1652
 		err = service.ModifyExceDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
1487
 		redis := service.RedisClient()
1653
 		redis := service.RedisClient()
1488
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1654
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1494
 		defer redis.Close()
1660
 		defer redis.Close()
1495
 
1661
 
1496
 	} else {
1662
 	} else {
1663
+		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
1664
+		if infor.ID > 0 {
1665
+
1666
+			var cha_time int64
1667
+
1668
+			timeNowStr := time.Now().Format("2006-01-02")
1669
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
1670
+
1671
+			//今日的日期减去设置的日期
1672
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
1673
+
1674
+			if cha_time >= advices.AdviceDate {
1675
+				//查询审核是否允许
1676
+				infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advices.AdviceDate, adminUserInfo.Org.Id)
1677
+				//申请状态不允许的情况 拒绝修改
1678
+				if infor.ApplicationStatus != 1 {
1679
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1680
+					return
1681
+				}
1682
+
1683
+			}
1684
+		}
1497
 		err = service.BatchModifyExceOldDoctorAdvice(&advices, ids)
1685
 		err = service.BatchModifyExceOldDoctorAdvice(&advices, ids)
1498
 
1686
 
1499
 		err = service.ModifyExceDoctorAdviceByGroupNoOne(&advices, ids)
1687
 		err = service.ModifyExceDoctorAdviceByGroupNoOne(&advices, ids)
1634
 		}
1822
 		}
1635
 		var err error
1823
 		var err error
1636
 		if groupno > 0 {
1824
 		if groupno > 0 {
1825
+
1826
+			// 查询信息规挡的设置天数
1827
+
1828
+			infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
1829
+			if infor.ID > 0 {
1830
+
1831
+				var cha_time int64
1832
+
1833
+				timeNowStr := time.Now().Format("2006-01-02")
1834
+				timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
1835
+
1836
+				//今日的日期减去设置的日期
1837
+				cha_time = timeNewDate.Unix() - infor.WeekDay*86400
1838
+
1839
+				if cha_time >= advices.AdviceDate {
1840
+					//查询审核是否允许
1841
+					infor, _ := service.GetDialysisInformationByRecordDate(advices.PatientId, advices.AdviceDate, adminUserInfo.Org.Id)
1842
+					//申请状态不允许的情况 拒绝修改
1843
+					if infor.ApplicationStatus != 1 {
1844
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1845
+						return
1846
+					}
1847
+
1848
+				}
1849
+			}
1637
 			err = service.CheckDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
1850
 			err = service.CheckDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
1638
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1851
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1639
 			redis := service.RedisClient()
1852
 			redis := service.RedisClient()
1660
 				//timeLayout2 := "2006-01-02"
1873
 				//timeLayout2 := "2006-01-02"
1661
 				//loc, _ := time.LoadLocation("Local")
1874
 				//loc, _ := time.LoadLocation("Local")
1662
 				//theTime, _ := time.ParseInLocation(timeLayout2, t, loc)
1875
 				//theTime, _ := time.ParseInLocation(timeLayout2, t, loc)
1876
+				// 查询信息规挡的设置天数
1877
+
1878
+				infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
1879
+				if infor.ID > 0 {
1880
+
1881
+					var cha_time int64
1882
+
1883
+					timeNowStr := time.Now().Format("2006-01-02")
1884
+					timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
1885
+
1886
+					//今日的日期减去设置的日期
1887
+					cha_time = timeNewDate.Unix() - infor.WeekDay*86400
1888
+
1889
+					if cha_time >= advices.AdviceDate {
1890
+						//查询审核是否允许
1891
+						infor, _ := service.GetDialysisInformationByRecordDate(advices.PatientId, advices.AdviceDate, adminUserInfo.Org.Id)
1892
+						//申请状态不允许的情况 拒绝修改
1893
+						if infor.ApplicationStatus != 1 {
1894
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1895
+							return
1896
+						}
1897
+
1898
+					}
1899
+				}
1663
 				err = service.BatchCheckOldDoctorAdvice(&advices, ids, adminUserInfo.Org.Id, advice.AdviceDate)
1900
 				err = service.BatchCheckOldDoctorAdvice(&advices, ids, adminUserInfo.Org.Id, advice.AdviceDate)
1664
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1901
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1665
 				redis := service.RedisClient()
1902
 				redis := service.RedisClient()
1710
 			item.Checker = adminInfo.AdminUser.Id
1947
 			item.Checker = adminInfo.AdminUser.Id
1711
 			item.CheckTime = time.Now().Unix()
1948
 			item.CheckTime = time.Now().Unix()
1712
 			item.CheckState = 1
1949
 			item.CheckState = 1
1950
+			// 查询信息规挡的设置天数
1951
+
1952
+			infor, _ := service.GetDialysisInformationSetting(adminInfo.Org.Id)
1953
+			if infor.ID > 0 {
1954
+
1955
+				var cha_time int64
1956
+
1957
+				timeNowStr := time.Now().Format("2006-01-02")
1958
+				timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
1959
+
1960
+				//今日的日期减去设置的日期
1961
+				cha_time = timeNewDate.Unix() - infor.WeekDay*86400
1962
+
1963
+				if cha_time >= item.AdviceDate {
1964
+					//查询审核是否允许
1965
+					infor, _ := service.GetDialysisInformationByRecordDate(item.PatientId, item.AdviceDate, adminInfo.Org.Id)
1966
+					//申请状态不允许的情况 拒绝修改
1967
+					if infor.ApplicationStatus != 1 {
1968
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1969
+						return
1970
+					}
1971
+
1972
+				}
1973
+			}
1713
 			err = service.SaveHisDoctorAdvice(item)
1974
 			err = service.SaveHisDoctorAdvice(item)
1714
 			redis := service.RedisClient()
1975
 			redis := service.RedisClient()
1715
 			key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
1976
 			key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
2311
 	// 	}
2572
 	// 	}
2312
 	// }
2573
 	// }
2313
 
2574
 
2575
+	// 查询信息规挡的设置天数
2576
+
2577
+	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
2578
+	if infor.ID > 0 {
2579
+
2580
+		var cha_time int64
2581
+
2582
+		timeNowStr := time.Now().Format("2006-01-02")
2583
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
2584
+
2585
+		//今日的日期减去设置的日期
2586
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
2587
+
2588
+		if cha_time >= evaluation.AssessmentDate {
2589
+			//查询审核是否允许
2590
+			infor, _ := service.GetDialysisInformationByRecordDate(id, evaluation.AssessmentDate, adminUserInfo.Org.Id)
2591
+			//申请状态不允许的情况 拒绝修改
2592
+			if infor.ApplicationStatus != 1 {
2593
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
2594
+				return
2595
+			}
2596
+
2597
+		}
2598
+	}
2599
+
2314
 	err = service.UpadatePredialysisEvaluation(&evaluation)
2600
 	err = service.UpadatePredialysisEvaluation(&evaluation)
2601
+	finish := models.XtDialysisFinish{
2602
+		IsFinish:   1,
2603
+		UserOrgId:  adminUserInfo.Org.Id,
2604
+		Status:     1,
2605
+		Ctime:      time.Now().Unix(),
2606
+		Mtime:      0,
2607
+		Module:     3,
2608
+		RecordDate: evaluation.AssessmentDate,
2609
+		Sourse:     1,
2610
+	}
2315
 
2611
 
2612
+	dialysisFinish, err := service.GetDialysisFinish(adminUserInfo.Org.Id, evaluation.AssessmentDate, 3)
2613
+	if dialysisFinish.ID == 0 {
2614
+		service.CreateDialysisFinish(finish)
2615
+	}
2316
 	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_before_dislysis"
2616
 	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_before_dislysis"
2317
 	redis := service.RedisClient()
2617
 	redis := service.RedisClient()
2318
 	defer redis.Close()
2618
 	defer redis.Close()
3845
 			Remark = remark
4145
 			Remark = remark
3846
 		}
4146
 		}
3847
 
4147
 
4148
+		Startdate := int64(dataBody["record_date"].(float64))
4149
+
3848
 		var advices []*models.GroupAdvice
4150
 		var advices []*models.GroupAdvice
3849
 		// utils.TraceLog("%+v", dataBody["adviceNames"])
4151
 		// utils.TraceLog("%+v", dataBody["adviceNames"])
3850
 		if dataBody["adviceNames"] == nil || reflect.TypeOf(dataBody["adviceNames"]).String() != "[]interface {}" {
4152
 		if dataBody["adviceNames"] == nil || reflect.TypeOf(dataBody["adviceNames"]).String() != "[]interface {}" {
3931
 			advices = append(advices, &advice)
4233
 			advices = append(advices, &advice)
3932
 		}
4234
 		}
3933
 
4235
 
4236
+		// 查询信息规挡的设置天数
4237
+
4238
+		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
4239
+		if infor.ID > 0 {
4240
+
4241
+			var cha_time int64
4242
+
4243
+			timeNowStr := time.Now().Format("2006-01-02")
4244
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
4245
+
4246
+			//今日的日期减去设置的日期
4247
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
4248
+			fmt.Println("RecordDate------------------", Startdate)
4249
+			if cha_time >= Startdate {
4250
+				//查询审核是否允许
4251
+				infor, _ := service.GetDialysisInformationByRecordDate(patient, Startdate, adminUserInfo.Org.Id)
4252
+				//申请状态不允许的情况 拒绝修改
4253
+				if infor.ApplicationStatus != 1 {
4254
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
4255
+					return
4256
+				}
4257
+
4258
+			}
4259
+		}
4260
+
3934
 		newAdvices, createErr := service.CreateMGroupAdvice(adminUserInfo.Org.Id, advices, group_no)
4261
 		newAdvices, createErr := service.CreateMGroupAdvice(adminUserInfo.Org.Id, advices, group_no)
4262
+		finish := models.XtDialysisFinish{
4263
+			IsFinish:   1,
4264
+			UserOrgId:  adminUserInfo.Org.Id,
4265
+			Status:     1,
4266
+			Ctime:      time.Now().Unix(),
4267
+			Mtime:      0,
4268
+			Module:     4,
4269
+			RecordDate: advicedateunix,
4270
+			Sourse:     1,
4271
+		}
4272
+
4273
+		dialysisFinish, err := service.GetDialysisFinish(adminUserInfo.Org.Id, advicedateunix, 4)
4274
+		if dialysisFinish.ID == 0 {
4275
+			service.CreateDialysisFinish(finish)
4276
+		}
3935
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":doctor_advices"
4277
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":doctor_advices"
3936
 		redis := service.RedisClient()
4278
 		redis := service.RedisClient()
3937
 		//清空key 值
4279
 		//清空key 值
4018
 				advice.CheckTime = time.Now().Unix()
4360
 				advice.CheckTime = time.Now().Unix()
4019
 			}
4361
 			}
4020
 		}
4362
 		}
4363
+
4364
+		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
4365
+		if infor.ID > 0 {
4366
+
4367
+			var cha_time int64
4368
+
4369
+			timeNowStr := time.Now().Format("2006-01-02")
4370
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
4371
+
4372
+			//今日的日期减去设置的日期
4373
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
4374
+
4375
+			if cha_time >= advice.RecordDate {
4376
+				//查询审核是否允许
4377
+				infor, _ := service.GetDialysisInformationByRecordDate(patient, advice.RecordDate, adminUserInfo.Org.Id)
4378
+				//申请状态不允许的情况 拒绝修改
4379
+				if infor.ApplicationStatus != 1 {
4380
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
4381
+					return
4382
+				}
4383
+
4384
+			}
4385
+		}
4021
 		err := service.CreateDoctorAdvice(&advice)
4386
 		err := service.CreateDoctorAdvice(&advice)
4022
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
4387
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
4023
 		redis := service.RedisClient()
4388
 		redis := service.RedisClient()
4156
 		advice.UpdatedTime = time.Now().Unix()
4521
 		advice.UpdatedTime = time.Now().Unix()
4157
 		advice.Modifier = adminUserInfo.AdminUser.Id
4522
 		advice.Modifier = adminUserInfo.AdminUser.Id
4158
 
4523
 
4524
+		// 查询信息规挡的设置天数
4525
+
4526
+		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
4527
+		if infor.ID > 0 {
4528
+
4529
+			var cha_time int64
4530
+
4531
+			timeNowStr := time.Now().Format("2006-01-02")
4532
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
4533
+
4534
+			//今日的日期减去设置的日期
4535
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
4536
+
4537
+			if cha_time >= advice.AdviceDate {
4538
+				//查询审核是否允许
4539
+				infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advice.AdviceDate, adminUserInfo.Org.Id)
4540
+				//申请状态不允许的情况 拒绝修改
4541
+				if infor.ApplicationStatus != 1 {
4542
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
4543
+					return
4544
+				}
4545
+
4546
+			}
4547
+		}
4159
 		err := service.DeleteDoctorAdvice(&advice)
4548
 		err := service.DeleteDoctorAdvice(&advice)
4160
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
4549
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
4161
 
4550
 
4218
 
4607
 
4219
 		var err error
4608
 		var err error
4220
 		if groupno > 0 {
4609
 		if groupno > 0 {
4610
+			// 查询信息规挡的设置天数
4611
+
4612
+			infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
4613
+			if infor.ID > 0 {
4614
+
4615
+				var cha_time int64
4616
+
4617
+				timeNowStr := time.Now().Format("2006-01-02")
4618
+				timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
4619
+
4620
+				//今日的日期减去设置的日期
4621
+				cha_time = timeNewDate.Unix() - infor.WeekDay*86400
4221
 
4622
 
4623
+				if cha_time >= advice.AdviceDate {
4624
+					//查询审核是否允许
4625
+					infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advice.AdviceDate, adminUserInfo.Org.Id)
4626
+					//申请状态不允许的情况 拒绝修改
4627
+					if infor.ApplicationStatus != 1 {
4628
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
4629
+						return
4630
+					}
4631
+
4632
+				}
4633
+			}
4222
 			err = service.DeleteDoctorAdviceByGroupNo(&advice)
4634
 			err = service.DeleteDoctorAdviceByGroupNo(&advice)
4223
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
4635
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
4224
 
4636
 
4230
 			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":his_doctor_advice"
4642
 			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":his_doctor_advice"
4231
 			redis.Set(keyThree, "", time.Second)
4643
 			redis.Set(keyThree, "", time.Second)
4232
 		} else {
4644
 		} else {
4645
+			// 查询信息规挡的设置天数
4646
+
4647
+			infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
4648
+			if infor.ID > 0 {
4649
+
4650
+				var cha_time int64
4233
 
4651
 
4652
+				timeNowStr := time.Now().Format("2006-01-02")
4653
+				timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
4654
+
4655
+				//今日的日期减去设置的日期
4656
+				cha_time = timeNewDate.Unix() - infor.WeekDay*86400
4657
+
4658
+				if cha_time >= advice.AdviceDate {
4659
+					//查询审核是否允许
4660
+					infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advice.AdviceDate, adminUserInfo.Org.Id)
4661
+					//申请状态不允许的情况 拒绝修改
4662
+					if infor.ApplicationStatus != 1 {
4663
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
4664
+						return
4665
+					}
4666
+
4667
+				}
4668
+			}
4234
 			err = service.BatchDeleteDoctorAdvice(ids, adminUserInfo.AdminUser.Id)
4669
 			err = service.BatchDeleteDoctorAdvice(ids, adminUserInfo.AdminUser.Id)
4235
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
4670
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
4236
 
4671
 
4432
 	project.ExecutionStaff = adminInfo.AdminUser.Id
4867
 	project.ExecutionStaff = adminInfo.AdminUser.Id
4433
 	project.ExecutionTime = theTime.Unix()
4868
 	project.ExecutionTime = theTime.Unix()
4434
 	if team_id == 0 {
4869
 	if team_id == 0 {
4870
+		// 查询信息规挡的设置天数
4435
 
4871
 
4872
+		infor, _ := service.GetDialysisInformationSetting(project.RecordDate)
4873
+		if infor.ID > 0 {
4874
+
4875
+			var cha_time int64
4876
+
4877
+			timeNowStr := time.Now().Format("2006-01-02")
4878
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
4879
+
4880
+			//今日的日期减去设置的日期
4881
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
4882
+
4883
+			if cha_time >= project.RecordDate {
4884
+				//查询审核是否允许
4885
+				infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId)
4886
+				//申请状态不允许的情况 拒绝修改
4887
+				if infor.ApplicationStatus != 1 {
4888
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
4889
+					return
4890
+				}
4891
+
4892
+			}
4893
+		}
4436
 		err := service.SaveHisProject(&project)
4894
 		err := service.SaveHisProject(&project)
4437
 		if err == nil {
4895
 		if err == nil {
4438
 			c.ServeSuccessJSON(map[string]interface{}{
4896
 			c.ServeSuccessJSON(map[string]interface{}{
4445
 		}
4903
 		}
4446
 	} else {
4904
 	} else {
4447
 		if is_check_team == 2 { //虽然是组套数据,但不是检验项目
4905
 		if is_check_team == 2 { //虽然是组套数据,但不是检验项目
4906
+			// 查询信息规挡的设置天数
4907
+
4908
+			infor, _ := service.GetDialysisInformationSetting(project.RecordDate)
4909
+			if infor.ID > 0 {
4910
+
4911
+				var cha_time int64
4912
+
4913
+				timeNowStr := time.Now().Format("2006-01-02")
4914
+				timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
4448
 
4915
 
4916
+				//今日的日期减去设置的日期
4917
+				cha_time = timeNewDate.Unix() - infor.WeekDay*86400
4918
+
4919
+				if cha_time >= project.RecordDate {
4920
+					//查询审核是否允许
4921
+					infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId)
4922
+					//申请状态不允许的情况 拒绝修改
4923
+					if infor.ApplicationStatus != 1 {
4924
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
4925
+						return
4926
+					}
4927
+
4928
+				}
4929
+			}
4449
 			err := service.SaveHisProject(&project)
4930
 			err := service.SaveHisProject(&project)
4450
 			if err == nil {
4931
 			if err == nil {
4451
 				c.ServeSuccessJSON(map[string]interface{}{
4932
 				c.ServeSuccessJSON(map[string]interface{}{
4457
 
4938
 
4458
 			}
4939
 			}
4459
 		} else {
4940
 		} else {
4941
+			// 查询信息规挡的设置天数
4942
+
4943
+			infor, _ := service.GetDialysisInformationSetting(project.RecordDate)
4944
+			if infor.ID > 0 {
4945
+
4946
+				var cha_time int64
4947
+
4948
+				timeNowStr := time.Now().Format("2006-01-02")
4949
+				timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
4950
+
4951
+				//今日的日期减去设置的日期
4952
+				cha_time = timeNewDate.Unix() - infor.WeekDay*86400
4953
+
4954
+				if cha_time >= project.RecordDate {
4955
+					//查询审核是否允许
4956
+					infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId)
4957
+					//申请状态不允许的情况 拒绝修改
4958
+					if infor.ApplicationStatus != 1 {
4959
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
4960
+						return
4961
+					}
4962
+
4963
+				}
4964
+			}
4460
 			ps, _ := service.GetCheckTeamProject(team_id, project.PatientId, project.RecordDate, project.UserOrgId)
4965
 			ps, _ := service.GetCheckTeamProject(team_id, project.PatientId, project.RecordDate, project.UserOrgId)
4461
 			var ids []int64
4966
 			var ids []int64
4462
 			for _, items := range ps {
4967
 			for _, items := range ps {
4498
 	project.CheckTime = time.Now().Unix()
5003
 	project.CheckTime = time.Now().Unix()
4499
 	project.CheckState = 1
5004
 	project.CheckState = 1
4500
 	if team_id == 0 {
5005
 	if team_id == 0 {
5006
+		// 查询信息规挡的设置天数
5007
+
5008
+		infor, _ := service.GetDialysisInformationSetting(project.RecordDate)
5009
+		if infor.ID > 0 {
5010
+
5011
+			var cha_time int64
5012
+
5013
+			timeNowStr := time.Now().Format("2006-01-02")
5014
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
5015
+
5016
+			//今日的日期减去设置的日期
5017
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
5018
+
5019
+			if cha_time >= project.RecordDate {
5020
+				//查询审核是否允许
5021
+				infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId)
5022
+				//申请状态不允许的情况 拒绝修改
5023
+				if infor.ApplicationStatus != 1 {
5024
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
5025
+					return
5026
+				}
5027
+
5028
+			}
5029
+		}
4501
 		err := service.SaveHisProject(&project)
5030
 		err := service.SaveHisProject(&project)
4502
 		if err == nil {
5031
 		if err == nil {
4503
 			c.ServeSuccessJSON(map[string]interface{}{
5032
 			c.ServeSuccessJSON(map[string]interface{}{
4513
 
5042
 
4514
 	} else {
5043
 	} else {
4515
 		if is_check_team == 2 { //虽然是组套数据,但不是检验项目
5044
 		if is_check_team == 2 { //虽然是组套数据,但不是检验项目
5045
+			// 查询信息规挡的设置天数
5046
+
5047
+			infor, _ := service.GetDialysisInformationSetting(project.RecordDate)
5048
+			if infor.ID > 0 {
5049
+
5050
+				var cha_time int64
5051
+
5052
+				timeNowStr := time.Now().Format("2006-01-02")
5053
+				timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
5054
+
5055
+				//今日的日期减去设置的日期
5056
+				cha_time = timeNewDate.Unix() - infor.WeekDay*86400
5057
+
5058
+				if cha_time >= project.RecordDate {
5059
+					//查询审核是否允许
5060
+					infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId)
5061
+					//申请状态不允许的情况 拒绝修改
5062
+					if infor.ApplicationStatus != 1 {
5063
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
5064
+						return
5065
+					}
5066
+
5067
+				}
5068
+			}
4516
 			err := service.SaveHisProject(&project)
5069
 			err := service.SaveHisProject(&project)
4517
 			if err == nil {
5070
 			if err == nil {
4518
 				c.ServeSuccessJSON(map[string]interface{}{
5071
 				c.ServeSuccessJSON(map[string]interface{}{
4527
 			}
5080
 			}
4528
 
5081
 
4529
 		} else {
5082
 		} else {
5083
+			// 查询信息规挡的设置天数
5084
+
5085
+			infor, _ := service.GetDialysisInformationSetting(project.RecordDate)
5086
+			if infor.ID > 0 {
5087
+
5088
+				var cha_time int64
5089
+
5090
+				timeNowStr := time.Now().Format("2006-01-02")
5091
+				timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
5092
+
5093
+				//今日的日期减去设置的日期
5094
+				cha_time = timeNewDate.Unix() - infor.WeekDay*86400
5095
+
5096
+				if cha_time >= project.RecordDate {
5097
+					//查询审核是否允许
5098
+					infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId)
5099
+					//申请状态不允许的情况 拒绝修改
5100
+					if infor.ApplicationStatus != 1 {
5101
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
5102
+						return
5103
+					}
5104
+
5105
+				}
5106
+			}
4530
 			ps, _ := service.GetCheckTeamProject(team_id, project.PatientId, project.RecordDate, project.UserOrgId)
5107
 			ps, _ := service.GetCheckTeamProject(team_id, project.PatientId, project.RecordDate, project.UserOrgId)
4531
 			var ids []int64
5108
 			var ids []int64
4532
 			for _, items := range ps {
5109
 			for _, items := range ps {

+ 191 - 0
controllers/patient_api_controller.go View File

1300
 	}
1300
 	}
1301
 	adviceNames := dataBody["adviceNames"].([]interface{})
1301
 	adviceNames := dataBody["adviceNames"].([]interface{})
1302
 	for _, adviceNameMap := range adviceNames {
1302
 	for _, adviceNameMap := range adviceNames {
1303
+
1303
 		adviceNameM := adviceNameMap.(map[string]interface{})
1304
 		adviceNameM := adviceNameMap.(map[string]interface{})
1304
 		var advice models.GroupAdvice
1305
 		var advice models.GroupAdvice
1305
 		advice.Remark = Remark
1306
 		advice.Remark = Remark
1317
 		advice.PatientId = patientInfo.ID
1318
 		advice.PatientId = patientInfo.ID
1318
 		advice.AdviceDoctor = adminUserInfo.AdminUser.Id
1319
 		advice.AdviceDoctor = adminUserInfo.AdminUser.Id
1319
 		advice.IsSettle = 2
1320
 		advice.IsSettle = 2
1321
+
1322
+		// 查询信息规挡的设置天数
1323
+
1324
+		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
1325
+		if infor.ID > 0 {
1326
+
1327
+			var cha_time int64
1328
+
1329
+			timeNowStr := time.Now().Format("2006-01-02")
1330
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
1331
+
1332
+			//今日的日期减去设置的日期
1333
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
1334
+
1335
+			if cha_time >= advice.AdviceDate {
1336
+				//查询审核是否允许
1337
+				infor, _ := service.GetDialysisInformationByRecordDate(patient, advice.AdviceDate, adminUserInfo.CurrentOrgId)
1338
+				//申请状态不允许的情况 拒绝修改
1339
+				if infor.ApplicationStatus != 1 {
1340
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1341
+					return
1342
+				}
1343
+
1344
+			}
1345
+		}
1346
+
1320
 		if adviceNameM["advice_name"] == nil || reflect.TypeOf(adviceNameM["advice_name"]).String() != "string" {
1347
 		if adviceNameM["advice_name"] == nil || reflect.TypeOf(adviceNameM["advice_name"]).String() != "string" {
1321
 			utils.ErrorLog("advice_name")
1348
 			utils.ErrorLog("advice_name")
1322
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1349
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1666
 	advice.PatientId = patient
1693
 	advice.PatientId = patient
1667
 	advice.AdviceDoctor = adminUserInfo.AdminUser.Id
1694
 	advice.AdviceDoctor = adminUserInfo.AdminUser.Id
1668
 
1695
 
1696
+	// 查询信息规挡的设置天数
1697
+
1698
+	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
1699
+	if infor.ID > 0 {
1700
+
1701
+		var cha_time int64
1702
+
1703
+		timeNowStr := time.Now().Format("2006-01-02")
1704
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
1705
+
1706
+		//今日的日期减去设置的日期
1707
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
1708
+
1709
+		if cha_time >= advice.AdviceDate {
1710
+			//查询审核是否允许
1711
+			infor, _ := service.GetDialysisInformationByRecordDate(patient, advice.AdviceDate, adminUserInfo.CurrentOrgId)
1712
+			//申请状态不允许的情况 拒绝修改
1713
+			if infor.ApplicationStatus != 1 {
1714
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1715
+				return
1716
+			}
1717
+
1718
+		}
1719
+	}
1720
+
1669
 	err := service.CreateDoctorAdvice(&advice)
1721
 	err := service.CreateDoctorAdvice(&advice)
1722
+	//创建步骤表
1723
+	finish := models.XtDialysisFinish{
1724
+		IsFinish:   1,
1725
+		UserOrgId:  adminUserInfo.CurrentOrgId,
1726
+		Status:     1,
1727
+		Ctime:      time.Now().Unix(),
1728
+		Mtime:      0,
1729
+		Module:     4,
1730
+		RecordDate: advice.AdviceDate,
1731
+		Sourse:     1,
1732
+	}
1733
+
1734
+	dialysisFinish, err := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, advice.AdviceDate, 1)
1735
+	if dialysisFinish.ID == 0 {
1736
+		service.CreateDialysisFinish(finish)
1737
+	}
1670
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1738
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1671
 	redis := service.RedisClient()
1739
 	redis := service.RedisClient()
1672
 	defer redis.Close()
1740
 	defer redis.Close()
1939
 			ExecutionTime:  theTime.Unix(),
2007
 			ExecutionTime:  theTime.Unix(),
1940
 			UpdatedTime:    time.Now().Unix(),
2008
 			UpdatedTime:    time.Now().Unix(),
1941
 		}
2009
 		}
2010
+
2011
+		// 查询信息规挡的设置天数
2012
+
2013
+		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
2014
+		if infor.ID > 0 {
2015
+
2016
+			var cha_time int64
2017
+
2018
+			timeNowStr := time.Now().Format("2006-01-02")
2019
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
2020
+
2021
+			//今日的日期减去设置的日期
2022
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
2023
+
2024
+			if cha_time >= advice.AdviceDate {
2025
+				//查询审核是否允许
2026
+				infor, _ := service.GetDialysisInformationByRecordDate(patient, advice.AdviceDate, adminUserInfo.CurrentOrgId)
2027
+				//申请状态不允许的情况 拒绝修改
2028
+				if infor.ApplicationStatus != 1 {
2029
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
2030
+					return
2031
+				}
2032
+
2033
+			}
2034
+		}
1942
 		if advice.ParentId > 0 {
2035
 		if advice.ParentId > 0 {
1943
 			err = service.ExceDoctorAdviceById(&exceAdvice, advice.ParentId, patient)
2036
 			err = service.ExceDoctorAdviceById(&exceAdvice, advice.ParentId, patient)
1944
 			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
2037
 			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
2675
 			UpdatedTime: time.Now().Unix(),
2768
 			UpdatedTime: time.Now().Unix(),
2676
 		}
2769
 		}
2677
 		var err error
2770
 		var err error
2771
+		// 查询信息规挡的设置天数
2772
+
2773
+		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
2774
+		if infor.ID > 0 {
2775
+
2776
+			var cha_time int64
2777
+
2778
+			timeNowStr := time.Now().Format("2006-01-02")
2779
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
2780
+
2781
+			//今日的日期减去设置的日期
2782
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
2783
+
2784
+			if cha_time >= advice.AdviceDate {
2785
+				//查询审核是否允许
2786
+				infor, _ := service.GetDialysisInformationByRecordDate(patient, advice.AdviceDate, adminUserInfo.CurrentOrgId)
2787
+				//申请状态不允许的情况 拒绝修改
2788
+				if infor.ApplicationStatus != 1 {
2789
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
2790
+					return
2791
+				}
2792
+
2793
+			}
2794
+		}
2678
 		if advice.ParentId > 0 {
2795
 		if advice.ParentId > 0 {
2679
 			err = service.CheckDoctorAdviceById(&exceAdvice, advice.ParentId, patient)
2796
 			err = service.CheckDoctorAdviceById(&exceAdvice, advice.ParentId, patient)
2680
 			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
2797
 			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
2866
 	advice.UpdatedTime = time.Now().Unix()
2983
 	advice.UpdatedTime = time.Now().Unix()
2867
 	advice.Modifier = adminUserInfo.AdminUser.Id
2984
 	advice.Modifier = adminUserInfo.AdminUser.Id
2868
 
2985
 
2986
+	// 查询信息规挡的设置天数
2987
+
2988
+	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
2989
+	if infor.ID > 0 {
2990
+
2991
+		var cha_time int64
2992
+
2993
+		timeNowStr := time.Now().Format("2006-01-02")
2994
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
2995
+
2996
+		//今日的日期减去设置的日期
2997
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
2998
+
2999
+		if cha_time >= advice.AdviceDate {
3000
+			//查询审核是否允许
3001
+			infor, _ := service.GetDialysisInformationByRecordDate(patient, advice.AdviceDate, adminUserInfo.CurrentOrgId)
3002
+			//申请状态不允许的情况 拒绝修改
3003
+			if infor.ApplicationStatus != 1 {
3004
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
3005
+				return
3006
+			}
3007
+
3008
+		}
3009
+	}
3010
+
2869
 	err := service.UpdateDoctorAdvice(&advice)
3011
 	err := service.UpdateDoctorAdvice(&advice)
2870
 	redis := service.RedisClient()
3012
 	redis := service.RedisClient()
2871
 
3013
 
3078
 	advice.Status = 0
3220
 	advice.Status = 0
3079
 	advice.Modifier = adminUserInfo.AdminUser.Id
3221
 	advice.Modifier = adminUserInfo.AdminUser.Id
3080
 
3222
 
3223
+	// 查询信息规挡的设置天数
3224
+
3225
+	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
3226
+	if infor.ID > 0 {
3227
+
3228
+		var cha_time int64
3229
+
3230
+		timeNowStr := time.Now().Format("2006-01-02")
3231
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
3232
+
3233
+		//今日的日期减去设置的日期
3234
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
3235
+
3236
+		if cha_time >= advice.AdviceDate {
3237
+			//查询审核是否允许
3238
+			infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advice.AdviceDate, adminUserInfo.CurrentOrgId)
3239
+			//申请状态不允许的情况 拒绝修改
3240
+			if infor.ApplicationStatus != 1 {
3241
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
3242
+				return
3243
+			}
3244
+
3245
+		}
3246
+	}
3081
 	err := service.DeleteDoctorAdvice(&advice)
3247
 	err := service.DeleteDoctorAdvice(&advice)
3082
 	redis := service.RedisClient()
3248
 	redis := service.RedisClient()
3083
 	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
3249
 	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
3125
 	//	}
3291
 	//	}
3126
 	//}
3292
 	//}
3127
 
3293
 
3294
+	// 查询信息规挡的设置天数
3295
+
3296
+	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
3297
+	if infor.ID > 0 {
3298
+
3299
+		var cha_time int64
3300
+
3301
+		timeNowStr := time.Now().Format("2006-01-02")
3302
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
3303
+
3304
+		//今日的日期减去设置的日期
3305
+		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
3306
+
3307
+		if cha_time >= advice.AdviceDate {
3308
+			//查询审核是否允许
3309
+			infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advice.AdviceDate, adminUserInfo.CurrentOrgId)
3310
+			//申请状态不允许的情况 拒绝修改
3311
+			if infor.ApplicationStatus != 1 {
3312
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
3313
+				return
3314
+			}
3315
+
3316
+		}
3317
+	}
3318
+
3128
 	err := service.DeleteGroupAdvice(adminUserInfo.CurrentOrgId, groupNo, adminUserInfo.AdminUser.Id)
3319
 	err := service.DeleteGroupAdvice(adminUserInfo.CurrentOrgId, groupNo, adminUserInfo.AdminUser.Id)
3129
 
3320
 
3130
 	key := strconv.FormatInt(advice.UserOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
3321
 	key := strconv.FormatInt(advice.UserOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"

+ 4 - 0
enums/error_code.go View File

277
 	ErrorCodeSyncWrong = 60000006
277
 	ErrorCodeSyncWrong = 60000006
278
 
278
 
279
 	AdviceCodeParamWrong = 600000007
279
 	AdviceCodeParamWrong = 600000007
280
+
281
+	ErrorCodeInformationExist = 600000008
280
 )
282
 )
281
 
283
 
282
 var ErrCodeMsgs = map[int]string{
284
 var ErrCodeMsgs = map[int]string{
536
 	ErrorCodePatientScheduleRepeat:        "一天只能存在一次排班",
538
 	ErrorCodePatientScheduleRepeat:        "一天只能存在一次排班",
537
 	ErrorCodeDelScheduleFailByDialysisTwo: "已经上机透析,不能操作排班",
539
 	ErrorCodeDelScheduleFailByDialysisTwo: "已经上机透析,不能操作排班",
538
 	AdviceCodeParamWrong:                  "医嘱核对人和执行人不能为同一人,请更换第二核对人!",
540
 	AdviceCodeParamWrong:                  "医嘱核对人和执行人不能为同一人,请更换第二核对人!",
541
+
542
+	ErrorCodeInformationExist: "已经超过归档天数,不予编辑",
539
 }
543
 }
540
 
544
 
541
 type SGJError struct {
545
 type SGJError struct {

+ 22 - 0
models/device_models.go View File

1443
 
1443
 
1444
 	return "xt_new_object_disinfect"
1444
 	return "xt_new_object_disinfect"
1445
 }
1445
 }
1446
+
1447
+type XtDialysisInformation struct {
1448
+	ID                int64  `gorm:"column:id" json:"id" form:"id"`
1449
+	Module            int64  `gorm:"column:module" json:"module" form:"module"`
1450
+	PatientId         int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1451
+	RecordDate        int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
1452
+	ApplicationDate   int64  `gorm:"column:application_date" json:"application_date" form:"application_date"`
1453
+	Creater           int64  `gorm:"column:creater" json:"creater" form:"creater"`
1454
+	ApplicationStatus int64  `gorm:"column:application_status" json:"application_status" form:"application_status"`
1455
+	Checker           int64  `gorm:"column:checker" json:"checker" form:"checker"`
1456
+	CheckTime         int64  `gorm:"column:check_time" json:"check_time" form:"check_time"`
1457
+	Remark            string `gorm:"column:remark" json:"remark" form:"remark"`
1458
+	UserOrgId         int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1459
+	Ctime             int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
1460
+	Status            int64  `gorm:"column:status" json:"status" form:"status"`
1461
+	Mtime             int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
1462
+}
1463
+
1464
+func (XtDialysisInformation) TableName() string {
1465
+
1466
+	return "xt_dialysis_information"
1467
+}

+ 30 - 0
models/patient_models.go View File

1826
 func (XtPatientFirstDisease) TableName() string {
1826
 func (XtPatientFirstDisease) TableName() string {
1827
 	return "xt_patient_first_disease"
1827
 	return "xt_patient_first_disease"
1828
 }
1828
 }
1829
+
1830
+type XtDialysisFinish struct {
1831
+	ID         int64 `gorm:"column:id" json:"id" form:"id"`
1832
+	IsFinish   int64 `gorm:"column:is_finish" json:"is_finish" form:"is_finish"`
1833
+	UserOrgId  int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1834
+	Status     int64 `gorm:"column:status" json:"status" form:"status"`
1835
+	Ctime      int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
1836
+	Mtime      int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
1837
+	Module     int64 `gorm:"column:module" json:"module" form:"module"`
1838
+	RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
1839
+	Sourse     int64 `gorm:"column:sourse" json:"sourse" form:"sourse"`
1840
+	PatientId  int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1841
+}
1842
+
1843
+func (XtDialysisFinish) TableName() string {
1844
+	return "xt_dialysis_finish"
1845
+}
1846
+
1847
+type XtDialysisInformaitonSetting struct {
1848
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
1849
+	WeekDay   int64 `gorm:"column:week_day" json:"week_day" form:"week_day"`
1850
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1851
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
1852
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
1853
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
1854
+}
1855
+
1856
+func (XtDialysisInformaitonSetting) TableName() string {
1857
+	return "xt_dialysis_informaiton_setting"
1858
+}

+ 47 - 0
service/dialysis_service.go View File

2090
 	err := XTWriteDB().Model(&models.MonitoringRecord{}).Where(" id = ? and status= 1", id).Update(map[string]interface{}{"accumulated_blood_volume": accumulated_blood_volume}).Error
2090
 	err := XTWriteDB().Model(&models.MonitoringRecord{}).Where(" id = ? and status= 1", id).Update(map[string]interface{}{"accumulated_blood_volume": accumulated_blood_volume}).Error
2091
 	return err
2091
 	return err
2092
 }
2092
 }
2093
+
2094
+func GetDialysisFinish(user_org_id int64, record_date int64, module int64) (models.XtDialysisFinish, error) {
2095
+
2096
+	finish := models.XtDialysisFinish{}
2097
+
2098
+	err := XTReadDB().Where("user_org_id = ? and record_date = ? and status =1 and module = ?", user_org_id, record_date, module).Find(&finish).Error
2099
+	return finish, err
2100
+}
2101
+
2102
+func CreateDialysisFinish(finish models.XtDialysisFinish) error {
2103
+
2104
+	err := XTWriteDB().Create(&finish).Error
2105
+
2106
+	return err
2107
+}
2108
+
2109
+func GetDialysisInformationSetting(user_org_id int64) (models.XtDialysisInformaitonSetting, error) {
2110
+
2111
+	setting := models.XtDialysisInformaitonSetting{}
2112
+
2113
+	err := XTReadDB().Where("user_org_id =? and status = 1", user_org_id).Find(&setting).Error
2114
+
2115
+	return setting, err
2116
+
2117
+}
2118
+
2119
+func CreatedDialysisInformation(information models.XtDialysisInformation) error {
2120
+
2121
+	err := XTWriteDB().Create(&information).Error
2122
+
2123
+	return err
2124
+}
2125
+
2126
+func GetDialysisInoformationById(patient_id int64, record_date int64, user_org_id int64, module int64) (models.XtDialysisInformation, error) {
2127
+
2128
+	information := models.XtDialysisInformation{}
2129
+	err := XTReadDB().Where("patient_id = ? and record_date = ? and user_org_id = ? and module = ? and status = 1", patient_id, record_date, user_org_id, module).Find(&information).Error
2130
+	return information, err
2131
+}
2132
+
2133
+func UpdateDialysisInformationById(patient_id int64, record_date int64, user_org_id int64, module int64, advice_date int64, remark string) error {
2134
+
2135
+	information := models.XtDialysisInformation{}
2136
+
2137
+	err := XTWriteDB().Model(&information).Where("patient_id = ? and record_date = ? and user_org_id  =? and module = ? and status=1", patient_id, record_date, user_org_id, module).Update(map[string]interface{}{"application_date": advice_date, "remark": remark}).Error
2138
+	return err
2139
+}

+ 58 - 0
service/gobal_config_service.go View File

1061
 	err := XTReadDB().Where("patient_id = ? and assessment_date = ? and user_org_id =? and status= 1", patient_id, schedule_date, user_org_id).Find(&dislysis).Error
1061
 	err := XTReadDB().Where("patient_id = ? and assessment_date = ? and user_org_id =? and status= 1", patient_id, schedule_date, user_org_id).Find(&dislysis).Error
1062
 	return dislysis, err
1062
 	return dislysis, err
1063
 }
1063
 }
1064
+
1065
+func GetDialysisInformationByRecordDate(patient_id int64, record_date int64, user_org_id int64) (models.XtDialysisInformation, error) {
1066
+
1067
+	information := models.XtDialysisInformation{}
1068
+	err := XTReadDB().Where("patient_id = ? and record_date = ? and user_org_id = ? and status=1", patient_id, record_date, user_org_id).Find(&information).Error
1069
+	return information, err
1070
+}
1071
+
1072
+func SaveDialysisInformation(information models.XtDialysisInformation) error {
1073
+
1074
+	err := XTWriteDB().Create(&information).Error
1075
+
1076
+	return err
1077
+}
1078
+
1079
+func UpdateInformationByRecordDate(patient_id int64, record_date int64, user_org_id int64, application_date int64, remark string) error {
1080
+
1081
+	err := XTWriteDB().Model(&models.XtDialysisInformation{}).Where("patient_id = ? and record_date = ? and user_org_id = ? and status = 1", patient_id, record_date, user_org_id).Update(map[string]interface{}{"application_status": 2, "application_date": application_date, "remark": remark}).Error
1082
+	return err
1083
+}
1084
+
1085
+func GetMobileInformation(limit int64, page int64, application_status int64, orgid int64) (infor []*models.XtDialysisInformation, total int64, err error) {
1086
+
1087
+	db := XTReadDB().Model(&infor).Where("status=1")
1088
+
1089
+	if orgid > 0 {
1090
+		db = db.Where("user_org_id = ?", orgid)
1091
+	}
1092
+
1093
+	if application_status > 0 {
1094
+		db = db.Where("application_status = ?", application_status)
1095
+	}
1096
+
1097
+	err = db.Count(&total).Offset(limit * (page - 1)).Limit(limit).Order("ctime desc").Find(&infor).Error
1098
+
1099
+	return infor, total, err
1100
+
1101
+}
1102
+
1103
+func GetMobileInformationOne(limit int64, page int64, orgid int64) (infor []*models.XtDialysisInformation, total int64, err error) {
1104
+
1105
+	db := XTReadDB().Model(&infor).Where("status=1")
1106
+
1107
+	if orgid > 0 {
1108
+		db = db.Where("user_org_id = ?", orgid)
1109
+	}
1110
+
1111
+	err = db.Count(&total).Offset(limit * (page - 1)).Limit(limit).Order("ctime desc").Find(&infor).Error
1112
+
1113
+	return infor, total, err
1114
+
1115
+}
1116
+
1117
+func CheckMobileInformation(id int64, application_status int64, checker int64, checker_time int64) error {
1118
+
1119
+	err := XTWriteDB().Model(&models.XtDialysisInformation{}).Where("id = ? and status= 1", id).Update(map[string]interface{}{"application_status": application_status, "checker": checker, "check_time": checker_time}).Error
1120
+	return err
1121
+}