Ver código fonte

库存流水展示

XMLWAN 2 anos atrás
pai
commit
473b21a0d3

+ 6 - 6
controllers/base_api_controller.go Ver arquivo

@@ -82,7 +82,7 @@ func (this *BaseAuthAPIController) Prepare() {
82 82
 		userAdmin.ModifyTime = 1530786071
83 83
 		var subscibe models.ServeSubscibe
84 84
 		subscibe.ID = 11
85
-		subscibe.OrgId = 10341 //机构id
85
+		subscibe.OrgId = 9671 //机构id
86 86
 		subscibe.PeriodStart = 1547447814
87 87
 		subscibe.PeriodEnd = 1550039814
88 88
 		subscibe.State = 1
@@ -92,8 +92,8 @@ func (this *BaseAuthAPIController) Prepare() {
92 92
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
93 93
 		subscibes[4] = &subscibe
94 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 97
 		adminUserInfo.AdminUser = &userAdmin
98 98
 		adminUserInfo.Subscibes = subscibes
99 99
 		this.SetSession("admin_user_info", &adminUserInfo)
@@ -328,7 +328,7 @@ func (this *BaseServeAPIController) Prepare() {
328 328
 		userAdmin.ModifyTime = 1530786071
329 329
 		var subscibe models.ServeSubscibe
330 330
 		subscibe.ID = 11
331
-		subscibe.OrgId = 10341 //机构id小英9675或4
331
+		subscibe.OrgId = 9671 //机构id小英9675或4
332 332
 		subscibe.PeriodStart = 1538035409
333 333
 		subscibe.PeriodEnd = 1569571409
334 334
 		subscibe.State = 1
@@ -338,8 +338,8 @@ func (this *BaseServeAPIController) Prepare() {
338 338
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
339 339
 		subscibes[4] = &subscibe
340 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 343
 		adminUserInfo.AdminUser = &userAdmin
344 344
 		adminUserInfo.Subscibes = subscibes
345 345
 		this.SetSession("admin_user_info", &adminUserInfo)

+ 353 - 1
controllers/dialysis_api_controller.go Ver arquivo

@@ -111,6 +111,8 @@ func DialysisApiRegistRouters() {
111 111
 	beego.Router("/api/patient/getdialysisadvicetoday", &DialysisApiController{}, "Get:GetDialysisAdviceToday")
112 112
 
113 113
 	beego.Router("/api/schedule/getmobileschedulelist", &DialysisApiController{}, "Get:GetMobileScheduleList")
114
+
115
+	beego.Router("/api/patient/saveinformation", &DialysisApiController{}, "Get:SaveInformation")
114 116
 }
115 117
 
116 118
 func (c *DialysisApiController) GetQueueCall() {
@@ -602,8 +604,50 @@ func (c *DialysisApiController) PostPrescription() {
602 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 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 651
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
608 652
 		redis := service.RedisClient()
609 653
 		//清空key 值
@@ -1431,6 +1475,31 @@ func (c *DialysisApiController) PostDouleCheck() {
1431 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 1503
 	_, check := service.FindDoubleCheckByReordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId)
1435 1504
 	if check.ID == 0 { //新增
1436 1505
 		doubleCheck.FirstCheckTime = firstCheckTimeDate
@@ -1439,6 +1508,47 @@ func (c *DialysisApiController) PostDouleCheck() {
1439 1508
 		doubleCheck.Modifier = modifier
1440 1509
 
1441 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 1552
 		redis := service.RedisClient()
1443 1553
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":double_check"
1444 1554
 
@@ -1570,9 +1680,50 @@ func (c *DialysisApiController) PostReceiveTreatmentAsses() {
1570 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 1708
 	if receiveTreatment.ID == 0 { //新增
1574 1709
 		receiveTreatmentAsses.Creater = adminUserInfo.AdminUser.Id
1575 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 1727
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":receive_treatment_asses"
1577 1728
 		redis := service.RedisClient()
1578 1729
 		//清空key 值
@@ -1752,7 +1903,47 @@ func (c *DialysisApiController) PostAssessmentAfterDislysis() {
1752 1903
 		}
1753 1904
 
1754 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 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 1947
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis"
1757 1948
 		redis := service.RedisClient()
1758 1949
 		//清空key 值
@@ -1984,8 +2175,48 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
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 2220
 		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 10469 {
1990 2221
 			var dewater_amount float64
1991 2222
 			dewater_amount = 0
@@ -2514,7 +2745,47 @@ func (c *DialysisApiController) PostTreatmentSummary() {
2514 2745
 	_, tempTreatmentSummary := service.FindTreatmentSummaryByReordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
2515 2746
 	if tempTreatmentSummary.ID == 0 { //新增
2516 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 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 2789
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summary"
2519 2790
 		redis := service.RedisClient()
2520 2791
 		keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summarys_list_all"
@@ -3046,6 +3317,32 @@ func (this *DialysisApiController) DelMonitor() {
3046 3317
 	//}
3047 3318
 
3048 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 3346
 	key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(monitor.MonitoringDate, 10) + ":monitor_records"
3050 3347
 	redis := service.RedisClient()
3051 3348
 	//清空key 值
@@ -6096,3 +6393,58 @@ func (this *DialysisApiController) GetMobileScheduleList() {
6096 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 Ver arquivo

@@ -633,6 +633,31 @@ func (this *DialysisRecordAPIController) EditMonitor() {
633 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 661
 	if monitorParam.ID <= 0 { // 新建记录
637 662
 		monitor := models.MonitoringRecord{
638 663
 			UserOrgId:       adminUserInfo.CurrentOrgId,
@@ -689,6 +714,21 @@ func (this *DialysisRecordAPIController) EditMonitor() {
689 714
 			FilterPressure:              monitorParam.FilterPressure,
690 715
 		}
691 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 732
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":monitor_records"
693 733
 		redis := service.RedisClient()
694 734
 		//清空key 值
@@ -1038,6 +1078,22 @@ func (this *DialysisRecordAPIController) StartDialysis() {
1038 1078
 	}
1039 1079
 
1040 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 1098
 	service.UpdateMobilePatient(adminUserInfo.CurrentOrgId, patientID, schedule_remark)
1043 1099
 
@@ -1566,8 +1622,48 @@ func (this *DialysisRecordAPIController) FinishDialysis() {
1566 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 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 1667
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
1572 1668
 	redis := service.RedisClient()
1573 1669
 	defer redis.Close()
@@ -1920,6 +2016,31 @@ func (c *DialysisRecordAPIController) ModifyFinishDialysis() {
1920 2016
 	}
1921 2017
 
1922 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 2044
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(tempDialysisRecords.PatientId, 10) + ":" + strconv.FormatInt(tempDialysisRecords.DialysisDate, 10) + ":dialysis_order"
1924 2045
 	redis := service.RedisClient()
1925 2046
 	defer redis.Close()

+ 637 - 6
controllers/mobile_api_controllers/dialysis_api_controller.go Ver arquivo

@@ -686,10 +686,50 @@ func (c *DialysisAPIController) PostAtreatmentInfo() {
686 686
 		NursingRecord:   nursingRecord,
687 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 714
 	_, treatmentSummary := service.FindTreatmentSummaryByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
690 715
 	if treatmentSummary.ID == 0 { //新增
691 716
 		summary.Creater = adminUserInfo.AdminUser.Id
692 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 733
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summary"
694 734
 		redis := service.RedisClient()
695 735
 		//清空key 值
@@ -856,7 +896,49 @@ func (c *DialysisAPIController) PostDoubleCheck() {
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 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 944
 		if adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 3877 {
@@ -894,7 +976,28 @@ func (c *DialysisAPIController) PostDoubleCheck() {
894 976
 			})
895 977
 		}
896 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 1001
 		doubleCheck.FirstCheckTime = firstCheckDate
899 1002
 		doubleCheck.CheckTime = checkDate
900 1003
 		doubleCheck.Creater = creater
@@ -1011,6 +1114,31 @@ func (c *DialysisAPIController) PostAcceptsAssessment() {
1011 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 1142
 	_, receiveTreatment := service.FindReceiveTreatmentAssesByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1015 1143
 	receiveTreatmentAsses := models.ReceiveTreatmentAsses{
1016 1144
 		UserOrgId:                    adminUserInfo.Org.Id,
@@ -1045,6 +1173,22 @@ func (c *DialysisAPIController) PostAcceptsAssessment() {
1045 1173
 	if receiveTreatment.ID == 0 { //新增
1046 1174
 		receiveTreatmentAsses.Creater = adminUserInfo.AdminUser.Id
1047 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 1192
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":receive_treatment_asses"
1049 1193
 		redis := service.RedisClient()
1050 1194
 		defer redis.Close()
@@ -1121,7 +1265,7 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1121 1265
 	//dialysateVolume, _ := c.GetInt64("dialysis_intakes", 0)
1122 1266
 	dialysis_intakes := c.GetString("dialysis_intakes")
1123 1267
 	dialysateVolume, _ := strconv.ParseFloat(dialysis_intakes, 64)
1124
-	fmt.Println("dialysateVolumewode 23323233223232wode", dialysateVolume)
1268
+
1125 1269
 	dialysis_intakes_unit, _ := c.GetInt64("dialysis_intakes_unit", 0)
1126 1270
 
1127 1271
 	blood_access_part_id, _ := c.GetInt64("blood_access_part_id", 0)
@@ -1299,7 +1443,46 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
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 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 1486
 		redis := service.RedisClient()
1304 1487
 		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1305 1488
 		redis.Set(keyTwo, "", time.Second)
@@ -1354,7 +1537,6 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1354 1537
 
1355 1538
 func (c *DialysisAPIController) PostDialysisPrescription() {
1356 1539
 	id, _ := c.GetInt64("patient", 0)
1357
-
1358 1540
 	recordDateStr := c.GetString("record_date")
1359 1541
 
1360 1542
 	if id <= 0 {
@@ -1364,6 +1546,7 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1364 1546
 
1365 1547
 	adminUserInfo := c.GetMobileAdminUserInfo()
1366 1548
 	patient, _ := service.FindPatientById(adminUserInfo.Org.Id, id)
1549
+
1367 1550
 	if patient.ID == 0 {
1368 1551
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
1369 1552
 		return
@@ -1438,7 +1621,7 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1438 1621
 	safe_package, _ := c.GetInt64("package", 0)
1439 1622
 	a_liquid, _ := c.GetInt64("a_liquid", 0)
1440 1623
 	pre_impulse, parseDateErr := c.GetFloat("pre_impulse", 0)
1441
-	fmt.Println("预冲量", pre_impulse)
1624
+
1442 1625
 	anticoagulant_stop_time_hour, _ := c.GetInt64("anticoagulant_stop_time_hour", 0)
1443 1626
 	anticoagulant_stop_time_min, _ := c.GetInt64("anticoagulant_stop_time_min", 0)
1444 1627
 	blood := c.GetString("blood")
@@ -1516,6 +1699,31 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
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 1727
 	if mode_id > 0 {
1520 1728
 		var str string
1521 1729
 		//查找该机构用的是什么透析器
@@ -1722,7 +1930,21 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1722 1930
 			prescription.AdminUserId = adminUserInfo.AdminUser.Id
1723 1931
 		}
1724 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 1949
 		if adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 10340 {
1728 1950
 
@@ -2041,6 +2263,31 @@ func (c *DialysisAPIController) Finish() {
2041 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 2291
 	//now := time.Now()
2045 2292
 	//year, month, day := now.Date()
2046 2293
 	//today_time := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
@@ -2339,7 +2586,21 @@ func (c *DialysisAPIController) Finish() {
2339 2586
 
2340 2587
 	if dialysisOrder.Stage == 1 {
2341 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 2604
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
2344 2605
 		redis := service.RedisClient()
2345 2606
 		defer redis.Close()
@@ -2728,6 +2989,21 @@ func (this *DialysisAPIController) StartDialysis() {
2728 2989
 	if errorscode == gorm.ErrRecordNotFound {
2729 2990
 
2730 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 3007
 		service.UpdateMobilePatient(adminUserInfo.Org.Id, patientID, schedule_remark)
2732 3008
 
2733 3009
 		if adminUserInfo.Org.Id != 10101 && adminUserInfo.Org.Id != 10445 && adminUserInfo.Org.Id != 3877 && adminUserInfo.Org.Id != 10345 {
@@ -2902,8 +3178,47 @@ func (this *DialysisAPIController) StartDialysis() {
2902 3178
 			record.PulseFrequency = 80
2903 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 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 3222
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":monitor_records"
2908 3223
 
2909 3224
 		redis := service.RedisClient()
@@ -3105,6 +3420,31 @@ func (c *DialysisAPIController) PostSolution() {
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 3448
 	prescription := models.DialysisPrescription{
3109 3449
 
3110 3450
 		UserOrgId:          adminUserInfo.Org.Id,
@@ -3366,6 +3706,21 @@ func (c *DialysisAPIController) PostSolution() {
3366 3706
 	}
3367 3707
 
3368 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 3724
 	//获取最新1条
3370 3725
 	dialysisSolution, _ := service.GetLastPatientDialysisSolution(id, adminUserInfo.Org.Id)
3371 3726
 	//更新状态
@@ -3976,7 +4331,30 @@ func (this *DialysisAPIController) ModifyStartDialysisOrder() {
3976 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 4358
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
3981 4359
 	order, _ := service.GetLastPatientOrder(record_id)
3982 4360
 	service.UpdateMobilePatient(adminUserInfo.Org.Id, order.PatientId, schedule_remark)
@@ -4093,6 +4471,30 @@ func (c *DialysisAPIController) ModifyFinishDialysisOrder() {
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 4498
 	dialysisRecord := &models.DialysisOrder{
4097 4499
 		ID:                         record_id,
4098 4500
 		UserOrgId:                  adminUserInfo.Org.Id,
@@ -4909,6 +5311,30 @@ func (c *DialysisAPIController) CreateConsumables() {
4909 5311
 	theRecordTime, _ := time.ParseInLocation(timeLayout, record_date, loc)
4910 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 5338
 	dataBody := make(map[string]interface{}, 0)
4913 5339
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
4914 5340
 	if err != nil {
@@ -5260,14 +5686,38 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
5260 5686
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
5261 5687
 		return
5262 5688
 	}
5263
-
5264 5689
 	adminInfo := c.GetMobileAdminUserInfo()
5690
+
5265 5691
 	creator := c.GetMobileAdminUserInfo().AdminUser.Id
5266 5692
 	timeLayout := "2006-01-02"
5267 5693
 	loc, _ := time.LoadLocation("Local")
5268 5694
 	theRecordTime, _ := time.ParseInLocation(timeLayout, record_date, loc)
5269 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 5721
 	consumables, _ := service.FindConsumablesByDate(adminInfo.Org.Id, patient_id, record_time)
5272 5722
 
5273 5723
 	_, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
@@ -5360,7 +5810,6 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
5360 5810
 					err := service.ConsumablesGoodDelivery(item.UserOrgId, patient_id, record_time, item, &warehouseOut, item.Count)
5361 5811
 
5362 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 5814
 					if err == nil {
5366 5815
 						goodErrcode := models.XtGoodErrcode{
@@ -5513,7 +5962,6 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
5513 5962
 				//出库
5514 5963
 				err := service.ConsumablesGoodDelivery(item.UserOrgId, patient_id, record_time, item, &out, item.Count)
5515 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 5965
 				if err != nil {
5518 5966
 					goodErrcode := models.XtGoodErrcode{
5519 5967
 						UserOrgId:      adminInfo.Org.Id,
@@ -5689,6 +6137,30 @@ func (c *DialysisAPIController) EditConsumables() {
5689 6137
 	theRecordTime, _ := time.ParseInLocation(timeLayout, record_date, loc)
5690 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 6164
 	dataBody := make(map[string]interface{}, 0)
5693 6165
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
5694 6166
 	if err != nil {
@@ -6544,6 +7016,31 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
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 7045
 	err = service.ConsumablesDeliveryTotal(adminInfo.Org.Id, patient_id, record_time, beforePrepares, newBeforePrepares, adminInfo.AdminUser.Id)
6549 7046
 
@@ -6553,6 +7050,23 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
6553 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 7071
 	list, _ := service.GetAutoReduceRecordInfoByPatientId(adminInfo.Org.Id, patient_id, record_time)
6558 7072
 
@@ -8429,3 +8943,120 @@ func (this *DialysisAPIController) GetNewDoctorListToday() {
8429 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 Ver arquivo

@@ -117,6 +117,30 @@ func (this *DialysisAPIController) AddMonitorRecord() {
117 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 144
 	record := models.MonitoringRecord{
121 145
 		UserOrgId:       adminInfo.Org.Id,
122 146
 		PatientId:       patientID,
@@ -175,6 +199,21 @@ func (this *DialysisAPIController) AddMonitorRecord() {
175 199
 	}
176 200
 
177 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 217
 	key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(date, 10) + ":monitor_records"
179 218
 	redis := service.RedisClient()
180 219
 	//清空key 值
@@ -345,6 +384,31 @@ func (this *DialysisAPIController) EditMonitorRecord() {
345 384
 	monitor.HeparinAmount = heparin_amount
346 385
 	monitor.Dehydration = dehydration
347 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 412
 	err = service.UpdateMonitor(monitor)
349 413
 	key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(date, 10) + ":monitor_records"
350 414
 	redis := service.RedisClient()
@@ -391,6 +455,31 @@ func (this *DialysisAPIController) DeleteMonitor() {
391 455
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
392 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 483
 	err := service.DisableMonitor(adminInfo.Org.Id, patientID, recordID, adminInfo.AdminUser.Id)
395 484
 	orgid := this.GetMobileAdminUserInfo().Org.Id
396 485
 	redis := service.RedisClient()
@@ -398,7 +487,6 @@ func (this *DialysisAPIController) DeleteMonitor() {
398 487
 	redis.Set(key, "", time.Second)
399 488
 	keyOne := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(monitor.MonitoringDate, 10) + ":monitor_records"
400 489
 	redis.Set(keyOne, "", time.Second)
401
-	fmt.Println("keyo呢32332322332332232332", keyOne)
402 490
 	redis.Close()
403 491
 
404 492
 	if err != nil {

+ 9 - 0
controllers/mobile_api_controllers/mobile_api_router_register.go Ver arquivo

@@ -190,4 +190,13 @@ func MobileAPIControllersRegisterRouters() {
190 190
 	beego.Router("/m/api/checkmobileadvice", &DialysisAPIController{}, "Get:GetCheckMobileAdvice")
191 191
 
192 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 Ver arquivo

@@ -310,6 +310,31 @@ func (c *PatientApiController) EditDoctorAdvice() {
310 310
 		adviceSlice, _ := service.FindAdviceByGoroupNo(adminUserInfo.Org.Id, advice.GroupNo)
311 311
 		sourceAdvice, _ := service.FindOldDoctorAdvice(adminUserInfo.Org.Id, advice.ID)
312 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 339
 			if advice.StartTime == sourceAdvice.StartTime {
315 340
 				err = service.UpdateDoctorAdvice(&advice)
@@ -331,7 +356,28 @@ func (c *PatientApiController) EditDoctorAdvice() {
331 356
 				redis.Set(keyOne, "", time.Second)
332 357
 			}
333 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 382
 			if advice.StartTime == sourceAdvice.StartTime {
337 383
 				err = service.UpdateDoctorAdvice(&advice)
@@ -359,6 +405,28 @@ func (c *PatientApiController) EditDoctorAdvice() {
359 405
 			}
360 406
 		}
361 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 430
 		isChangeGroup = false
363 431
 		err = service.UpdateDoctorAdvice(&advice)
364 432
 		redis := service.RedisClient()
@@ -382,6 +450,7 @@ func (c *PatientApiController) EditDoctorAdvice() {
382 450
 		})
383 451
 
384 452
 	} else {
453
+
385 454
 		newGroupAdvice, err := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, advice.GroupNo)
386 455
 		if err != nil {
387 456
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -620,6 +689,31 @@ func (c *PatientApiController) ExecDoctorAdvice() {
620 689
 		}
621 690
 		var err error
622 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 717
 			err = service.ExceDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
624 718
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
625 719
 			redis := service.RedisClient()
@@ -642,7 +736,30 @@ func (c *PatientApiController) ExecDoctorAdvice() {
642 736
 
643 737
 			defer redis.Close()
644 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 763
 			err = service.BatchExceOldDoctorAdvice(&advices, ids)
647 764
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
648 765
 			redis := service.RedisClient()
@@ -1076,6 +1193,31 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1076 1193
 			item.ExecutionStaff = adminInfo.AdminUser.Id
1077 1194
 			item.ExecutionTime = theTime.Unix()
1078 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 1221
 			err = service.SaveHisDoctorAdvice(item)
1080 1222
 			key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
1081 1223
 			redis := service.RedisClient()
@@ -1483,6 +1625,30 @@ func (c *PatientApiController) ModifyExecDoctorAdvice() {
1483 1625
 	var err error
1484 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 1652
 		err = service.ModifyExceDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
1487 1653
 		redis := service.RedisClient()
1488 1654
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
@@ -1494,6 +1660,28 @@ func (c *PatientApiController) ModifyExecDoctorAdvice() {
1494 1660
 		defer redis.Close()
1495 1661
 
1496 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 1685
 		err = service.BatchModifyExceOldDoctorAdvice(&advices, ids)
1498 1686
 
1499 1687
 		err = service.ModifyExceDoctorAdviceByGroupNoOne(&advices, ids)
@@ -1634,6 +1822,31 @@ func (c *PatientApiController) CheckDoctorAdvice() {
1634 1822
 		}
1635 1823
 		var err error
1636 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 1850
 			err = service.CheckDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
1638 1851
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1639 1852
 			redis := service.RedisClient()
@@ -1660,6 +1873,30 @@ func (c *PatientApiController) CheckDoctorAdvice() {
1660 1873
 				//timeLayout2 := "2006-01-02"
1661 1874
 				//loc, _ := time.LoadLocation("Local")
1662 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 1900
 				err = service.BatchCheckOldDoctorAdvice(&advices, ids, adminUserInfo.Org.Id, advice.AdviceDate)
1664 1901
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1665 1902
 				redis := service.RedisClient()
@@ -1710,6 +1947,30 @@ func (c *PatientApiController) CheckDoctorAdvice() {
1710 1947
 			item.Checker = adminInfo.AdminUser.Id
1711 1948
 			item.CheckTime = time.Now().Unix()
1712 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 1974
 			err = service.SaveHisDoctorAdvice(item)
1714 1975
 			redis := service.RedisClient()
1715 1976
 			key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
@@ -2311,8 +2572,47 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
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 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 2616
 	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_before_dislysis"
2317 2617
 	redis := service.RedisClient()
2318 2618
 	defer redis.Close()
@@ -3845,6 +4145,8 @@ func (c *PatientApiController) CreateGroupAdvice() {
3845 4145
 			Remark = remark
3846 4146
 		}
3847 4147
 
4148
+		Startdate := int64(dataBody["record_date"].(float64))
4149
+
3848 4150
 		var advices []*models.GroupAdvice
3849 4151
 		// utils.TraceLog("%+v", dataBody["adviceNames"])
3850 4152
 		if dataBody["adviceNames"] == nil || reflect.TypeOf(dataBody["adviceNames"]).String() != "[]interface {}" {
@@ -3931,7 +4233,47 @@ func (c *PatientApiController) CreateGroupAdvice() {
3931 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 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 4277
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":doctor_advices"
3936 4278
 		redis := service.RedisClient()
3937 4279
 		//清空key 值
@@ -4018,6 +4360,29 @@ func (c *PatientApiController) CreateGroupAdvice() {
4018 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 4386
 		err := service.CreateDoctorAdvice(&advice)
4022 4387
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
4023 4388
 		redis := service.RedisClient()
@@ -4156,6 +4521,30 @@ func (c *PatientApiController) DelDoctorAdvice() {
4156 4521
 		advice.UpdatedTime = time.Now().Unix()
4157 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 4548
 		err := service.DeleteDoctorAdvice(&advice)
4160 4549
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
4161 4550
 
@@ -4218,7 +4607,30 @@ func (c *PatientApiController) DelDoctorAdvice() {
4218 4607
 
4219 4608
 		var err error
4220 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 4634
 			err = service.DeleteDoctorAdviceByGroupNo(&advice)
4223 4635
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
4224 4636
 
@@ -4230,7 +4642,30 @@ func (c *PatientApiController) DelDoctorAdvice() {
4230 4642
 			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":his_doctor_advice"
4231 4643
 			redis.Set(keyThree, "", time.Second)
4232 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 4669
 			err = service.BatchDeleteDoctorAdvice(ids, adminUserInfo.AdminUser.Id)
4235 4670
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
4236 4671
 
@@ -4432,7 +4867,30 @@ func (c *PatientApiController) ExecProject() {
4432 4867
 	project.ExecutionStaff = adminInfo.AdminUser.Id
4433 4868
 	project.ExecutionTime = theTime.Unix()
4434 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 4894
 		err := service.SaveHisProject(&project)
4437 4895
 		if err == nil {
4438 4896
 			c.ServeSuccessJSON(map[string]interface{}{
@@ -4445,7 +4903,30 @@ func (c *PatientApiController) ExecProject() {
4445 4903
 		}
4446 4904
 	} else {
4447 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 4930
 			err := service.SaveHisProject(&project)
4450 4931
 			if err == nil {
4451 4932
 				c.ServeSuccessJSON(map[string]interface{}{
@@ -4457,6 +4938,30 @@ func (c *PatientApiController) ExecProject() {
4457 4938
 
4458 4939
 			}
4459 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 4965
 			ps, _ := service.GetCheckTeamProject(team_id, project.PatientId, project.RecordDate, project.UserOrgId)
4461 4966
 			var ids []int64
4462 4967
 			for _, items := range ps {
@@ -4498,6 +5003,30 @@ func (c *PatientApiController) CheckProject() {
4498 5003
 	project.CheckTime = time.Now().Unix()
4499 5004
 	project.CheckState = 1
4500 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 5030
 		err := service.SaveHisProject(&project)
4502 5031
 		if err == nil {
4503 5032
 			c.ServeSuccessJSON(map[string]interface{}{
@@ -4513,6 +5042,30 @@ func (c *PatientApiController) CheckProject() {
4513 5042
 
4514 5043
 	} else {
4515 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 5069
 			err := service.SaveHisProject(&project)
4517 5070
 			if err == nil {
4518 5071
 				c.ServeSuccessJSON(map[string]interface{}{
@@ -4527,6 +5080,30 @@ func (c *PatientApiController) CheckProject() {
4527 5080
 			}
4528 5081
 
4529 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 5107
 			ps, _ := service.GetCheckTeamProject(team_id, project.PatientId, project.RecordDate, project.UserOrgId)
4531 5108
 			var ids []int64
4532 5109
 			for _, items := range ps {

+ 191 - 0
controllers/patient_api_controller.go Ver arquivo

@@ -1300,6 +1300,7 @@ func (c *PatientApiController) CreateGroupAdvice() {
1300 1300
 	}
1301 1301
 	adviceNames := dataBody["adviceNames"].([]interface{})
1302 1302
 	for _, adviceNameMap := range adviceNames {
1303
+
1303 1304
 		adviceNameM := adviceNameMap.(map[string]interface{})
1304 1305
 		var advice models.GroupAdvice
1305 1306
 		advice.Remark = Remark
@@ -1317,6 +1318,32 @@ func (c *PatientApiController) CreateGroupAdvice() {
1317 1318
 		advice.PatientId = patientInfo.ID
1318 1319
 		advice.AdviceDoctor = adminUserInfo.AdminUser.Id
1319 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 1347
 		if adviceNameM["advice_name"] == nil || reflect.TypeOf(adviceNameM["advice_name"]).String() != "string" {
1321 1348
 			utils.ErrorLog("advice_name")
1322 1349
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -1666,7 +1693,48 @@ func (c *PatientApiController) CreateDoctorAdvice() {
1666 1693
 	advice.PatientId = patient
1667 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 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 1738
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1671 1739
 	redis := service.RedisClient()
1672 1740
 	defer redis.Close()
@@ -1939,6 +2007,31 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1939 2007
 			ExecutionTime:  theTime.Unix(),
1940 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 2035
 		if advice.ParentId > 0 {
1943 2036
 			err = service.ExceDoctorAdviceById(&exceAdvice, advice.ParentId, patient)
1944 2037
 			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
@@ -2675,6 +2768,30 @@ func (c *PatientApiController) CheckDoctorAdvice() {
2675 2768
 			UpdatedTime: time.Now().Unix(),
2676 2769
 		}
2677 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 2795
 		if advice.ParentId > 0 {
2679 2796
 			err = service.CheckDoctorAdviceById(&exceAdvice, advice.ParentId, patient)
2680 2797
 			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
@@ -2866,6 +2983,31 @@ func (c *PatientApiController) UpdateDoctorAdvice() {
2866 2983
 	advice.UpdatedTime = time.Now().Unix()
2867 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 3011
 	err := service.UpdateDoctorAdvice(&advice)
2870 3012
 	redis := service.RedisClient()
2871 3013
 
@@ -3078,6 +3220,30 @@ func (c *PatientApiController) DeleteDoctorAdvice() {
3078 3220
 	advice.Status = 0
3079 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 3247
 	err := service.DeleteDoctorAdvice(&advice)
3082 3248
 	redis := service.RedisClient()
3083 3249
 	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
@@ -3125,6 +3291,31 @@ func (c *PatientApiController) DeleteGroupAdvice() {
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 3319
 	err := service.DeleteGroupAdvice(adminUserInfo.CurrentOrgId, groupNo, adminUserInfo.AdminUser.Id)
3129 3320
 
3130 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 Ver arquivo

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

+ 22 - 0
models/device_models.go Ver arquivo

@@ -1443,3 +1443,25 @@ func (XtNewObjectDisinfect) TableName() string {
1443 1443
 
1444 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 Ver arquivo

@@ -1826,3 +1826,33 @@ type XtPatientFirstDisease struct {
1826 1826
 func (XtPatientFirstDisease) TableName() string {
1827 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 Ver arquivo

@@ -2090,3 +2090,50 @@ func UpdateLastMonitorRecordToday(accumulated_blood_volume float64, id int64) er
2090 2090
 	err := XTWriteDB().Model(&models.MonitoringRecord{}).Where(" id = ? and status= 1", id).Update(map[string]interface{}{"accumulated_blood_volume": accumulated_blood_volume}).Error
2091 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 Ver arquivo

@@ -1061,3 +1061,61 @@ func GetLastAfter(patient_id int64, schedule_date int64, user_org_id int64) (mod
1061 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 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
+}