Browse Source

历史排班

28169 1 year ago
parent
commit
74b045ecfd

+ 5 - 1
controllers/common_api_controller.go View File

@@ -735,8 +735,11 @@ func (this *CommonApiController) GetDialysislist() {
735 735
 	dialysislist, total, err := service.GetDialysisList(statime, entime, page, limit, orgId)
736 736
 	prescriptionList, _ := service.GetAllDialysisList(statime, entime, orgId)
737 737
 	list, totallist, _ := service.GetDialysisPatientList(statime, entime, page, limit, orgId)
738
-	//获取每个病人每个透析模式的数据
738
+	//获取每个病人每个透析模式的数据(按透析记录)
739 739
 	modeIdCount, parseDateErr := service.GetModeIdCount(statime, entime, orgId, page, 1000)
740
+
741
+	//按排班
742
+	scheduleCount, _ := service.GetScheduleModeIdCount(statime, entime, orgId, page, 1000)
740 743
 	if err != nil {
741 744
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
742 745
 		return
@@ -749,6 +752,7 @@ func (this *CommonApiController) GetDialysislist() {
749 752
 		"prescriptionList": prescriptionList,
750 753
 		"count":            count,
751 754
 		"modeIdCount":      modeIdCount,
755
+		"scheduleCount":    scheduleCount,
752 756
 	})
753 757
 }
754 758
 

+ 223 - 16
controllers/dialysis_api_controller.go View File

@@ -637,7 +637,7 @@ func (c *DialysisApiController) PostPrescription() {
637 637
 
638 638
 			if cha_time >= recordDate.Unix() {
639 639
 				//查询审核是否允许
640
-				infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
640
+				infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, 1)
641 641
 				//申请状态不允许的情况 拒绝修改
642 642
 				if infor.ApplicationStatus != 1 {
643 643
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -649,6 +649,22 @@ func (c *DialysisApiController) PostPrescription() {
649 649
 
650 650
 		err := service.AddSigleRecord(&prescription)
651 651
 
652
+		//记录日志
653
+		byterequest, _ := json.Marshal(prescription)
654
+		dialysisPrescriptionLog := models.XtDialysisPrescriptionLog{
655
+
656
+			UserOrgId:   adminUserInfo.CurrentOrgId,
657
+			Ctime:       time.Now().Unix(),
658
+			Mtime:       0,
659
+			ErrLog:      string(byterequest),
660
+			AdminUserId: adminUserInfo.AdminUser.Id,
661
+			RecordDate:  prescription.RecordDate,
662
+			PatientId:   prescription.PatientId,
663
+			Source:      "电脑端新建处方",
664
+			Status:      1,
665
+		}
666
+		service.CreatePrescriptionLog(dialysisPrescriptionLog)
667
+
652 668
 		//创建步骤表
653 669
 		finish := models.XtDialysisFinish{
654 670
 			IsFinish:   1,
@@ -759,7 +775,7 @@ func (c *DialysisApiController) PostPrescription() {
759 775
 
760 776
 			if cha_time >= recordDate.Unix() {
761 777
 				//查询审核是否允许
762
-				infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
778
+				infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, 1)
763 779
 				//申请状态不允许的情况 拒绝修改
764 780
 				if infor.ApplicationStatus != 1 {
765 781
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -771,6 +787,22 @@ func (c *DialysisApiController) PostPrescription() {
771 787
 
772 788
 		updateErr := service.UpDateDialysisPrescription(&prescription)
773 789
 
790
+		//记录日志
791
+		byterequest, _ := json.Marshal(prescription)
792
+		dialysisPrescriptionLog := models.XtDialysisPrescriptionLog{
793
+
794
+			UserOrgId:   adminUserInfo.CurrentOrgId,
795
+			Ctime:       time.Now().Unix(),
796
+			Mtime:       0,
797
+			ErrLog:      string(byterequest),
798
+			AdminUserId: adminUserInfo.AdminUser.Id,
799
+			RecordDate:  prescription.RecordDate,
800
+			PatientId:   prescription.PatientId,
801
+			Source:      "电脑端修改处方",
802
+			Status:      1,
803
+		}
804
+		service.CreatePrescriptionLog(dialysisPrescriptionLog)
805
+
774 806
 		//创建步骤表
775 807
 		finish := models.XtDialysisFinish{
776 808
 			IsFinish:   1,
@@ -1013,7 +1045,7 @@ func (c *DialysisApiController) PostSoulution() {
1013 1045
 
1014 1046
 		if cha_time >= recordDate.Unix() {
1015 1047
 			//查询审核是否允许
1016
-			infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
1048
+			infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, 1)
1017 1049
 			//申请状态不允许的情况 拒绝修改
1018 1050
 			if infor.ApplicationStatus != 1 {
1019 1051
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -1357,6 +1389,22 @@ func (c *DialysisApiController) PostSoulution() {
1357 1389
 
1358 1390
 	err := service.SavePrescriptionAndCreateSolution(&solution, &prescription)
1359 1391
 
1392
+	//记录日志
1393
+	byterequest, _ := json.Marshal(prescription)
1394
+	dialysisPrescriptionLog := models.XtDialysisPrescriptionLog{
1395
+
1396
+		UserOrgId:   adminUserInfo.CurrentOrgId,
1397
+		Ctime:       time.Now().Unix(),
1398
+		Mtime:       0,
1399
+		ErrLog:      string(byterequest),
1400
+		AdminUserId: adminUserInfo.AdminUser.Id,
1401
+		RecordDate:  prescription.RecordDate,
1402
+		PatientId:   prescription.PatientId,
1403
+		Source:      "电脑端新增长期处方",
1404
+		Status:      1,
1405
+	}
1406
+	service.CreatePrescriptionLog(dialysisPrescriptionLog)
1407
+
1360 1408
 	//创建步骤表
1361 1409
 	finishOne := models.XtDialysisFinish{
1362 1410
 		IsFinish:   1,
@@ -1630,7 +1678,7 @@ func (c *DialysisApiController) PostDouleCheck() {
1630 1678
 
1631 1679
 		if cha_time >= recordDate.Unix() {
1632 1680
 			//查询审核是否允许
1633
-			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId)
1681
+			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId, 5)
1634 1682
 			//申请状态不允许的情况 拒绝修改
1635 1683
 			if infor.ApplicationStatus != 1 {
1636 1684
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -1681,7 +1729,7 @@ func (c *DialysisApiController) PostDouleCheck() {
1681 1729
 
1682 1730
 			if cha_time >= recordDate.Unix() {
1683 1731
 				//查询审核是否允许
1684
-				infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId)
1732
+				infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId, 5)
1685 1733
 				//申请状态不允许的情况 拒绝修改
1686 1734
 				if infor.ApplicationStatus != 1 {
1687 1735
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -1836,7 +1884,7 @@ func (c *DialysisApiController) PostReceiveTreatmentAsses() {
1836 1884
 
1837 1885
 		if cha_time >= recordDate.Unix() {
1838 1886
 			//查询审核是否允许
1839
-			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId)
1887
+			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId, 2)
1840 1888
 			//申请状态不允许的情况 拒绝修改
1841 1889
 			if infor.ApplicationStatus != 1 {
1842 1890
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -1906,7 +1954,7 @@ func (c *DialysisApiController) PostReceiveTreatmentAsses() {
1906 1954
 
1907 1955
 			if cha_time >= recordDate.Unix() {
1908 1956
 				//查询审核是否允许
1909
-				infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId)
1957
+				infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId, 2)
1910 1958
 				//申请状态不允许的情况 拒绝修改
1911 1959
 				if infor.ApplicationStatus != 1 {
1912 1960
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -2084,7 +2132,7 @@ func (c *DialysisApiController) PostAssessmentAfterDislysis() {
2084 2132
 
2085 2133
 			if cha_time >= recordDate.Unix() {
2086 2134
 				//查询审核是否允许
2087
-				infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
2135
+				infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, 9)
2088 2136
 				//申请状态不允许的情况 拒绝修改
2089 2137
 				if infor.ApplicationStatus != 1 {
2090 2138
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -2094,7 +2142,20 @@ func (c *DialysisApiController) PostAssessmentAfterDislysis() {
2094 2142
 			}
2095 2143
 		}
2096 2144
 		err = service.UpdateAssessmentAfterDislysisRecord(&assessment)
2097
-
2145
+		//记录日志
2146
+		byterequest, _ := json.Marshal(assessment)
2147
+		afterDialysisLog := models.XtAssessmentAfterDialysisLog{
2148
+			UserOrgId:   assessment.UserOrgId,
2149
+			PatientId:   assessment.PatientId,
2150
+			RecordDate:  assessment.AssessmentDate,
2151
+			Status:      1,
2152
+			ErrLog:      string(byterequest),
2153
+			AdminUserId: adminUserInfo.AdminUser.Id,
2154
+			Ctime:       time.Now().Unix(),
2155
+			Mtime:       0,
2156
+			Source:      "电脑端保存透后评估",
2157
+		}
2158
+		service.CreateAfterDialysisLog(afterDialysisLog)
2098 2159
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis"
2099 2160
 		redis := service.RedisClient()
2100 2161
 		//清空key 值
@@ -2118,6 +2179,20 @@ func (c *DialysisApiController) PostAssessmentAfterDislysis() {
2118 2179
 		assessment.AssessmentDate = recordDate.Unix()
2119 2180
 
2120 2181
 		err = service.AddSigleAssessmentAfterDislysisRecord(&assessment)
2182
+		//记录日志
2183
+		byterequest, _ := json.Marshal(assessment)
2184
+		afterDialysisLog := models.XtAssessmentAfterDialysisLog{
2185
+			UserOrgId:   assessment.UserOrgId,
2186
+			PatientId:   assessment.PatientId,
2187
+			RecordDate:  assessment.AssessmentDate,
2188
+			Status:      1,
2189
+			ErrLog:      string(byterequest),
2190
+			AdminUserId: adminUserInfo.AdminUser.Id,
2191
+			Ctime:       time.Now().Unix(),
2192
+			Mtime:       0,
2193
+			Source:      "电脑端修改保存透后评估",
2194
+		}
2195
+		service.CreateAfterDialysisLog(afterDialysisLog)
2121 2196
 		finish := models.XtDialysisFinish{
2122 2197
 			IsFinish:   1,
2123 2198
 			UserOrgId:  adminUserInfo.CurrentOrgId,
@@ -2380,7 +2455,7 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
2380 2455
 
2381 2456
 			if cha_time >= recordDate.Unix() {
2382 2457
 				//查询审核是否允许
2383
-				infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
2458
+				infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, 3)
2384 2459
 				//申请状态不允许的情况 拒绝修改
2385 2460
 				if infor.ApplicationStatus != 1 {
2386 2461
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -2391,6 +2466,20 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
2391 2466
 		}
2392 2467
 
2393 2468
 		err := service.AddSigleAssessmentBeforeDislysisRecord(&assessmentBeforeDislysis)
2469
+		//记录日志
2470
+		byterequest, _ := json.Marshal(assessmentBeforeDislysis)
2471
+		beforeDislysisLog := models.XtAssessmentBeforeDislysisLog{
2472
+			UserOrgId:   assessmentBeforeDislysis.UserOrgId,
2473
+			AdminUserId: adminUserInfo.AdminUser.Id,
2474
+			ErrLog:      string(byterequest),
2475
+			PatientId:   assessmentBeforeDislysis.PatientId,
2476
+			RecordDate:  assessmentBeforeDislysis.AssessmentDate,
2477
+			Ctime:       time.Now().Unix(),
2478
+			Mtime:       0,
2479
+			Status:      1,
2480
+			Source:      "电脑端保存透前评估",
2481
+		}
2482
+		service.CreateBeforLog(beforeDislysisLog)
2394 2483
 		//创建步骤表
2395 2484
 		finish := models.XtDialysisFinish{
2396 2485
 			IsFinish:   1,
@@ -2506,6 +2595,21 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
2506 2595
 				newprescribe.Status = 1
2507 2596
 
2508 2597
 				err := service.AddSigleRecord(&newprescribe)
2598
+
2599
+				//记录日志
2600
+				byterequest, _ := json.Marshal(newprescribe)
2601
+				prescriptionLog := models.XtDialysisPrescriptionLog{
2602
+					UserOrgId:   newprescribe.UserOrgId,
2603
+					Ctime:       time.Now().Unix(),
2604
+					Mtime:       0,
2605
+					ErrLog:      string(byterequest),
2606
+					AdminUserId: adminUserInfo.AdminUser.Id,
2607
+					RecordDate:  newprescribe.RecordDate,
2608
+					PatientId:   newprescribe.PatientId,
2609
+					Source:      "电脑端透前评估保存",
2610
+					Status:      1,
2611
+				}
2612
+				service.CreatePrescriptionLog(prescriptionLog)
2509 2613
 				if err != nil {
2510 2614
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
2511 2615
 				}
@@ -2564,6 +2668,20 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
2564 2668
 					newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
2565 2669
 
2566 2670
 					err := service.AddSigleRecord(&newprescribe)
2671
+					//记录日志
2672
+					byterequest, _ := json.Marshal(newprescribe)
2673
+					prescriptionLog := models.XtDialysisPrescriptionLog{
2674
+						UserOrgId:   newprescribe.UserOrgId,
2675
+						Ctime:       time.Now().Unix(),
2676
+						Mtime:       0,
2677
+						ErrLog:      string(byterequest),
2678
+						AdminUserId: adminUserInfo.AdminUser.Id,
2679
+						RecordDate:  newprescribe.RecordDate,
2680
+						PatientId:   newprescribe.PatientId,
2681
+						Source:      "电脑端透前评估保存",
2682
+						Status:      1,
2683
+					}
2684
+					service.CreatePrescriptionLog(prescriptionLog)
2567 2685
 					key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
2568 2686
 					redis := service.RedisClient()
2569 2687
 					defer redis.Close()
@@ -2593,6 +2711,20 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
2593 2711
 					newprescribe.Modifier = adminUserInfo.AdminUser.Id
2594 2712
 
2595 2713
 					err := service.AddSigleRecord(&newprescribe)
2714
+					//记录日志
2715
+					byterequest, _ := json.Marshal(newprescribe)
2716
+					prescriptionLog := models.XtDialysisPrescriptionLog{
2717
+						UserOrgId:   newprescribe.UserOrgId,
2718
+						Ctime:       time.Now().Unix(),
2719
+						Mtime:       0,
2720
+						ErrLog:      string(byterequest),
2721
+						AdminUserId: adminUserInfo.AdminUser.Id,
2722
+						RecordDate:  newprescribe.RecordDate,
2723
+						PatientId:   newprescribe.PatientId,
2724
+						Source:      "电脑端透前评估保存",
2725
+						Status:      1,
2726
+					}
2727
+					service.CreatePrescriptionLog(prescriptionLog)
2596 2728
 					key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
2597 2729
 					redis := service.RedisClient()
2598 2730
 					defer redis.Close()
@@ -2763,6 +2895,20 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
2763 2895
 			newprescribe.Status = 1
2764 2896
 
2765 2897
 			err := service.AddSigleRecord(&newprescribe)
2898
+			//记录日志
2899
+			byterequest, _ := json.Marshal(newprescribe)
2900
+			prescriptionLog := models.XtDialysisPrescriptionLog{
2901
+				UserOrgId:   newprescribe.UserOrgId,
2902
+				Ctime:       time.Now().Unix(),
2903
+				Mtime:       0,
2904
+				ErrLog:      string(byterequest),
2905
+				AdminUserId: adminUserInfo.AdminUser.Id,
2906
+				RecordDate:  newprescribe.RecordDate,
2907
+				PatientId:   newprescribe.PatientId,
2908
+				Source:      "电脑端透前评估保存",
2909
+				Status:      1,
2910
+			}
2911
+			service.CreatePrescriptionLog(prescriptionLog)
2766 2912
 			if err != nil {
2767 2913
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
2768 2914
 			}
@@ -2819,7 +2965,20 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
2819 2965
 				newprescribe.Status = 1
2820 2966
 
2821 2967
 				err := service.AddSigleRecord(&newprescribe)
2822
-
2968
+				//记录日志
2969
+				byterequest, _ := json.Marshal(newprescribe)
2970
+				prescriptionLog := models.XtDialysisPrescriptionLog{
2971
+					UserOrgId:   newprescribe.UserOrgId,
2972
+					Ctime:       time.Now().Unix(),
2973
+					Mtime:       0,
2974
+					ErrLog:      string(byterequest),
2975
+					AdminUserId: adminUserInfo.AdminUser.Id,
2976
+					RecordDate:  newprescribe.RecordDate,
2977
+					PatientId:   newprescribe.PatientId,
2978
+					Source:      "电脑端透前评估保存",
2979
+					Status:      1,
2980
+				}
2981
+				service.CreatePrescriptionLog(prescriptionLog)
2823 2982
 				key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
2824 2983
 				redis := service.RedisClient()
2825 2984
 				defer redis.Close()
@@ -2846,6 +3005,20 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
2846 3005
 				newprescribe.Status = 1
2847 3006
 
2848 3007
 				err := service.AddSigleRecord(&newprescribe)
3008
+				//记录日志
3009
+				byterequest, _ := json.Marshal(newprescribe)
3010
+				prescriptionLog := models.XtDialysisPrescriptionLog{
3011
+					UserOrgId:   newprescribe.UserOrgId,
3012
+					Ctime:       time.Now().Unix(),
3013
+					Mtime:       0,
3014
+					ErrLog:      string(byterequest),
3015
+					AdminUserId: adminUserInfo.AdminUser.Id,
3016
+					RecordDate:  newprescribe.RecordDate,
3017
+					PatientId:   newprescribe.PatientId,
3018
+					Source:      "电脑端透前评估保存",
3019
+					Status:      1,
3020
+				}
3021
+				service.CreatePrescriptionLog(prescriptionLog)
2849 3022
 				key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
2850 3023
 				redis := service.RedisClient()
2851 3024
 				defer redis.Close()
@@ -2877,7 +3050,7 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
2877 3050
 
2878 3051
 			if cha_time >= recordDate.Unix() {
2879 3052
 				//查询审核是否允许
2880
-				infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
3053
+				infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, 3)
2881 3054
 				//申请状态不允许的情况 拒绝修改
2882 3055
 				if infor.ApplicationStatus != 1 {
2883 3056
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -2999,7 +3172,7 @@ func (c *DialysisApiController) PostTreatmentSummary() {
2999 3172
 
3000 3173
 			if cha_time >= recordDate.Unix() {
3001 3174
 				//查询审核是否允许
3002
-				infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
3175
+				infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, 10)
3003 3176
 				//申请状态不允许的情况 拒绝修改
3004 3177
 				if infor.ApplicationStatus != 1 {
3005 3178
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -3069,7 +3242,7 @@ func (c *DialysisApiController) PostTreatmentSummary() {
3069 3242
 
3070 3243
 			if cha_time >= recordDate.Unix() {
3071 3244
 				//查询审核是否允许
3072
-				infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
3245
+				infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, 10)
3073 3246
 				//申请状态不允许的情况 拒绝修改
3074 3247
 				if infor.ApplicationStatus != 1 {
3075 3248
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -3617,7 +3790,7 @@ func (this *DialysisApiController) DelMonitor() {
3617 3790
 
3618 3791
 		if cha_time >= monitor.MonitoringDate {
3619 3792
 			//查询审核是否允许
3620
-			infor, _ := service.GetDialysisInformationByRecordDate(patientID, monitor.MonitoringDate, adminInfo.CurrentOrgId)
3793
+			infor, _ := service.GetDialysisInformationByRecordDate(patientID, monitor.MonitoringDate, adminInfo.CurrentOrgId, 7)
3621 3794
 			//申请状态不允许的情况 拒绝修改
3622 3795
 			if infor.ApplicationStatus != 1 {
3623 3796
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -3629,6 +3802,22 @@ func (this *DialysisApiController) DelMonitor() {
3629 3802
 
3630 3803
 	err := service.DisableMonitor(adminInfo.CurrentOrgId, patientID, recordID, adminInfo.AdminUser.Id)
3631 3804
 
3805
+	//记录日志
3806
+	byterequest, _ := json.Marshal(monitor)
3807
+	monitorRecordLog := models.XtMonitorRecordLog{
3808
+		RecordDate:  monitor.MonitoringDate,
3809
+		PatientId:   monitor.PatientId,
3810
+		Module:      3,
3811
+		AdminUserId: adminInfo.AdminUser.Id,
3812
+		Ctime:       time.Now().Unix(),
3813
+		Mtime:       0,
3814
+		Status:      1,
3815
+		UserOrgId:   monitor.UserOrgId,
3816
+		ErrLog:      string(byterequest),
3817
+		Source:      "电脑端删除监测",
3818
+	}
3819
+	service.CreateMonitorRecordLog(monitorRecordLog)
3820
+
3632 3821
 	key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(monitor.MonitoringDate, 10) + ":monitor_records"
3633 3822
 	redis := service.RedisClient()
3634 3823
 	//清空key 值
@@ -3764,7 +3953,7 @@ func (c *DialysisApiController) CreateMonitor() {
3764 3953
 
3765 3954
 		if cha_time >= monitoring_date {
3766 3955
 			//查询审核是否允许
3767
-			infor, _ := service.GetDialysisInformationByRecordDate(patient, monitoring_date, adminUserInfo.CurrentOrgId)
3956
+			infor, _ := service.GetDialysisInformationByRecordDate(patient, monitoring_date, adminUserInfo.CurrentOrgId, 7)
3768 3957
 			//申请状态不允许的情况 拒绝修改
3769 3958
 			if infor.ApplicationStatus != 1 {
3770 3959
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -4903,6 +5092,24 @@ func (c *DialysisApiController) CreateRemindDoctorAdvice() {
4903 5092
 
4904 5093
 	list, err := service.CreateMGroupAdvice(adminUserInfo.CurrentOrgId, advices, groupNo)
4905 5094
 
5095
+	for _, item := range advices {
5096
+		//记录日志
5097
+		byterequest, _ := json.Marshal(item)
5098
+		adviceLog := models.XtDoctorAdviceLog{
5099
+			UserOrgId:   item.UserOrgId,
5100
+			PatientId:   item.PatientId,
5101
+			AdminUserId: adminUserInfo.AdminUser.Id,
5102
+			Module:      1,
5103
+			ErrLog:      string(byterequest),
5104
+			Status:      1,
5105
+			Ctime:       time.Now().Unix(),
5106
+			Mtime:       0,
5107
+			Source:      "电脑端医嘱推送",
5108
+			RecordDate:  item.AdviceDate,
5109
+		}
5110
+		service.CreateDoctorAdviceLog(adviceLog)
5111
+	}
5112
+
4906 5113
 	//创建步骤表
4907 5114
 	finish := models.XtDialysisFinish{
4908 5115
 		IsFinish:   1,

+ 52 - 5
controllers/dialysis_record_api_controller.go View File

@@ -649,7 +649,7 @@ func (this *DialysisRecordAPIController) EditMonitor() {
649 649
 		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
650 650
 		if cha_time >= scheduleDate && infor.WeekDay != 0 {
651 651
 			//查询审核是否允许
652
-			infor, _ := service.GetDialysisInformationByRecordDate(patientID, scheduleDate, adminUserInfo.CurrentOrgId)
652
+			infor, _ := service.GetDialysisInformationByRecordDate(patientID, scheduleDate, adminUserInfo.CurrentOrgId, 7)
653 653
 			//申请状态不允许的情况 拒绝修改
654 654
 			if infor.ApplicationStatus != 1 {
655 655
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -717,6 +717,22 @@ func (this *DialysisRecordAPIController) EditMonitor() {
717 717
 			Dicarbonate:                 monitorParam.Dicarbonate,
718 718
 		}
719 719
 		createErr := service.CreateMonitor(&monitor)
720
+
721
+		//记录日志
722
+		byterequest, _ := json.Marshal(monitor)
723
+		monitorRecordLog := models.XtMonitorRecordLog{
724
+			RecordDate:  monitor.MonitoringDate,
725
+			PatientId:   monitor.PatientId,
726
+			Module:      1,
727
+			AdminUserId: adminUserInfo.AdminUser.Id,
728
+			Ctime:       time.Now().Unix(),
729
+			Mtime:       0,
730
+			Status:      1,
731
+			UserOrgId:   monitor.UserOrgId,
732
+			ErrLog:      string(byterequest),
733
+			Source:      "电脑端新增监测",
734
+		}
735
+		service.CreateMonitorRecordLog(monitorRecordLog)
720 736
 		finish := models.XtDialysisFinish{
721 737
 			IsFinish:   1,
722 738
 			UserOrgId:  adminUserInfo.CurrentOrgId,
@@ -819,6 +835,21 @@ func (this *DialysisRecordAPIController) EditMonitor() {
819 835
 		monitor.ReplacementSpeed = monitorParam.ReplacementSpeed
820 836
 		monitor.Dicarbonate = monitorParam.Dicarbonate
821 837
 		updateErr := service.UpdateMonitor(monitor)
838
+		//记录日志
839
+		byterequest, _ := json.Marshal(monitor)
840
+		monitorRecordLog := models.XtMonitorRecordLog{
841
+			RecordDate:  monitor.MonitoringDate,
842
+			PatientId:   monitor.PatientId,
843
+			Module:      1,
844
+			AdminUserId: adminUserInfo.AdminUser.Id,
845
+			Ctime:       time.Now().Unix(),
846
+			Mtime:       0,
847
+			Status:      1,
848
+			UserOrgId:   monitor.UserOrgId,
849
+			ErrLog:      string(byterequest),
850
+			Source:      "电脑端修改监测",
851
+		}
852
+		service.CreateMonitorRecordLog(monitorRecordLog)
822 853
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":monitor_records"
823 854
 		redis := service.RedisClient()
824 855
 		defer redis.Close()
@@ -1066,7 +1097,7 @@ func (this *DialysisRecordAPIController) StartDialysis() {
1066 1097
 
1067 1098
 		if cha_time >= recordDate.Unix() {
1068 1099
 			//查询审核是否允许
1069
-			infor, _ := service.GetDialysisInformationByRecordDate(patientID, recordDate.Unix(), adminUserInfo.CurrentOrgId)
1100
+			infor, _ := service.GetDialysisInformationByRecordDate(patientID, recordDate.Unix(), adminUserInfo.CurrentOrgId, 6)
1070 1101
 			//申请状态不允许的情况 拒绝修改
1071 1102
 			if infor.ApplicationStatus != 1 {
1072 1103
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -1310,6 +1341,22 @@ func (this *DialysisRecordAPIController) StartDialysis() {
1310 1341
 
1311 1342
 			err := service.CreateMonitor(&record)
1312 1343
 
1344
+			//记录日志
1345
+			byterequest, _ := json.Marshal(record)
1346
+			monitorRecordLog := models.XtMonitorRecordLog{
1347
+				RecordDate:  record.MonitoringDate,
1348
+				PatientId:   record.PatientId,
1349
+				Module:      1,
1350
+				AdminUserId: adminUserInfo.AdminUser.Id,
1351
+				Ctime:       time.Now().Unix(),
1352
+				Mtime:       0,
1353
+				Status:      1,
1354
+				UserOrgId:   record.UserOrgId,
1355
+				ErrLog:      string(byterequest),
1356
+				Source:      "电脑端执行上机新建监测",
1357
+			}
1358
+			service.CreateMonitorRecordLog(monitorRecordLog)
1359
+
1313 1360
 			finish := models.XtDialysisFinish{
1314 1361
 				IsFinish:   1,
1315 1362
 				UserOrgId:  adminUserInfo.CurrentOrgId,
@@ -1717,7 +1764,7 @@ func (this *DialysisRecordAPIController) FinishDialysis() {
1717 1764
 
1718 1765
 		if cha_time >= recordDate.Unix() {
1719 1766
 			//查询审核是否允许
1720
-			infor, _ := service.GetDialysisInformationByRecordDate(patientID, recordDate.Unix(), adminUserInfo.CurrentOrgId)
1767
+			infor, _ := service.GetDialysisInformationByRecordDate(patientID, recordDate.Unix(), adminUserInfo.CurrentOrgId, 8)
1721 1768
 			//申请状态不允许的情况 拒绝修改
1722 1769
 			if infor.ApplicationStatus != 1 {
1723 1770
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -1978,7 +2025,7 @@ func (this *DialysisRecordAPIController) ModifyStartDialysis() {
1978 2025
 
1979 2026
 		if cha_time >= tempDialysisRecord.DialysisDate {
1980 2027
 			//查询审核是否允许
1981
-			infor, _ := service.GetDialysisInformationByRecordDate(tempDialysisRecord.PatientId, tempDialysisRecord.DialysisDate, adminUserInfo.CurrentOrgId)
2028
+			infor, _ := service.GetDialysisInformationByRecordDate(tempDialysisRecord.PatientId, tempDialysisRecord.DialysisDate, adminUserInfo.CurrentOrgId, 6)
1982 2029
 			//申请状态不允许的情况 拒绝修改
1983 2030
 			if infor.ApplicationStatus != 1 {
1984 2031
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -2136,7 +2183,7 @@ func (c *DialysisRecordAPIController) ModifyFinishDialysis() {
2136 2183
 
2137 2184
 		if cha_time >= tempDialysisRecords.DialysisDate {
2138 2185
 			//查询审核是否允许
2139
-			infor, _ := service.GetDialysisInformationByRecordDate(tempDialysisRecords.PatientId, tempDialysisRecords.DialysisDate, adminUserInfo.CurrentOrgId)
2186
+			infor, _ := service.GetDialysisInformationByRecordDate(tempDialysisRecords.PatientId, tempDialysisRecords.DialysisDate, adminUserInfo.CurrentOrgId, 6)
2140 2187
 			//申请状态不允许的情况 拒绝修改
2141 2188
 			if infor.ApplicationStatus != 1 {
2142 2189
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)

+ 63 - 2
controllers/his_api_controller.go View File

@@ -2204,8 +2204,7 @@ func (c *HisApiController) CreateHisPrescription() {
2204 2204
 
2205 2205
 											}
2206 2206
 											pharmacyConfig, _ := service.FindPharmacyConfig(adminInfo.CurrentOrgId)
2207
-											fmt.Println("device_number2333233232323222323232323323322332", device_number)
2208
-											fmt.Println("number_count99999999999999999999999999999999999", number_count)
2207
+
2209 2208
 											if pharmacyConfig.IsOpen != 1 {
2210 2209
 												if device_number != number_count {
2211 2210
 
@@ -2987,6 +2986,22 @@ func (c *HisApiController) CreateHisPrescription() {
2987 2986
 
2988 2987
 							service.CreateHisDoctorAdvice(&s)
2989 2988
 
2989
+							//记录日志
2990
+							byterequest, _ := json.Marshal(s)
2991
+							adviceLog := models.XtDoctorAdviceLog{
2992
+								UserOrgId:   s.UserOrgId,
2993
+								PatientId:   s.PatientId,
2994
+								AdminUserId: adminInfo.AdminUser.Id,
2995
+								Module:      1,
2996
+								ErrLog:      string(byterequest),
2997
+								Status:      1,
2998
+								Ctime:       time.Now().Unix(),
2999
+								Mtime:       0,
3000
+								Source:      "电脑端新建his医嘱",
3001
+								RecordDate:  s.AdviceDate,
3002
+							}
3003
+							service.CreateDoctorAdviceLog(adviceLog)
3004
+
2990 3005
 							//存储切片中
2991 3006
 							adviceList = append(adviceList, s)
2992 3007
 
@@ -3058,6 +3073,22 @@ func (c *HisApiController) CreateHisPrescription() {
3058 3073
 							}
3059 3074
 
3060 3075
 							service.CreateHisProjectTwo(&p)
3076
+							//记录日志
3077
+							byterequest, _ := json.Marshal(p)
3078
+							adviceLog := models.XtDoctorAdviceLog{
3079
+								UserOrgId:   p.UserOrgId,
3080
+								PatientId:   p.PatientId,
3081
+								AdminUserId: adminInfo.AdminUser.Id,
3082
+								Module:      1,
3083
+								ErrLog:      string(byterequest),
3084
+								Status:      1,
3085
+								Ctime:       time.Now().Unix(),
3086
+								Mtime:       0,
3087
+								Source:      "电脑端新建his项目",
3088
+								RecordDate:  p.RecordDate,
3089
+							}
3090
+							service.CreateDoctorAdviceLog(adviceLog)
3091
+
3061 3092
 							projectList = append(projectList, p)
3062 3093
 							var randNum int
3063 3094
 							randNum = rand.Intn(10000) + 1000
@@ -3629,6 +3660,21 @@ func (c *HisApiController) EditHisPrescription() {
3629 3660
 								return
3630 3661
 							}
3631 3662
 							service.CreateHisDoctorAdvice(&s)
3663
+							//记录日志
3664
+							byterequest, _ := json.Marshal(s)
3665
+							adviceLog := models.XtDoctorAdviceLog{
3666
+								UserOrgId:   s.UserOrgId,
3667
+								PatientId:   s.PatientId,
3668
+								AdminUserId: adminInfo.AdminUser.Id,
3669
+								Module:      1,
3670
+								ErrLog:      string(byterequest),
3671
+								Status:      1,
3672
+								Ctime:       time.Now().Unix(),
3673
+								Mtime:       0,
3674
+								Source:      "电脑端his医嘱修改",
3675
+								RecordDate:  s.AdviceDate,
3676
+							}
3677
+							service.CreateDoctorAdviceLog(adviceLog)
3632 3678
 							redis := service.RedisClient()
3633 3679
 							key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
3634 3680
 							redis.Set(key, "", time.Second)
@@ -3662,6 +3708,21 @@ func (c *HisApiController) EditHisPrescription() {
3662 3708
 							}
3663 3709
 							service.CreateHisProjectTwo(&p)
3664 3710
 
3711
+							//记录日志
3712
+							byterequest, _ := json.Marshal(p)
3713
+							adviceLog := models.XtDoctorAdviceLog{
3714
+								UserOrgId:   p.UserOrgId,
3715
+								PatientId:   p.PatientId,
3716
+								AdminUserId: adminInfo.AdminUser.Id,
3717
+								Module:      1,
3718
+								ErrLog:      string(byterequest),
3719
+								Status:      1,
3720
+								Ctime:       time.Now().Unix(),
3721
+								Mtime:       0,
3722
+								Source:      "电脑端his项目修改",
3723
+								RecordDate:  p.RecordDate,
3724
+							}
3725
+							service.CreateDoctorAdviceLog(adviceLog)
3665 3726
 						}
3666 3727
 					}
3667 3728
 				}

+ 147 - 0
controllers/mobile_api_controllers/check_weight_api_controller.go View File

@@ -5,6 +5,7 @@ import (
5 5
 	"XT_New/models"
6 6
 	"XT_New/service"
7 7
 	_ "XT_New/utils"
8
+	"encoding/json"
8 9
 	_ "encoding/json"
9 10
 	"fmt"
10 11
 	"github.com/astaxie/beego"
@@ -132,6 +133,21 @@ func (c *CheckWeightApiController) SaveBloodPressure() {
132 133
 		evaluation.AssessmentTime = time.Now().Unix()
133 134
 
134 135
 		err := service.UpadatePredialysisEvaluation(&evaluation)
136
+		//记录日志
137
+		byterequest, _ := json.Marshal(evaluation)
138
+		assessmentBeforeDislysisLog := models.XtAssessmentBeforeDislysisLog{
139
+			UserOrgId:   adminUserInfo.Org.Id,
140
+			AdminUserId: adminUserInfo.AdminUser.Id,
141
+			ErrLog:      string(byterequest),
142
+			PatientId:   evaluation.PatientId,
143
+			RecordDate:  evaluation.AssessmentDate,
144
+			Ctime:       time.Now().Unix(),
145
+			Mtime:       0,
146
+			Status:      1,
147
+			Source:      "物联网上传透前血压",
148
+		}
149
+
150
+		service.CreateBeforLog(assessmentBeforeDislysisLog)
135 151
 
136 152
 		assessdateDateStart := thisTime.Format("2006-01-02")
137 153
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_before_dislysis"
@@ -193,6 +209,23 @@ func (c *CheckWeightApiController) SaveBloodPressure() {
193 209
 		}
194 210
 
195 211
 		err := service.UpdateAssessmentAfterDislysisRecord(&afterevaluation)
212
+
213
+		//记录日志
214
+		byterequest, _ := json.Marshal(afterevaluation)
215
+		afterLog := models.XtAssessmentAfterDialysisLog{
216
+			UserOrgId:   adminUserInfo.Org.Id,
217
+			AdminUserId: adminUserInfo.AdminUser.Id,
218
+			ErrLog:      string(byterequest),
219
+			PatientId:   afterevaluation.PatientId,
220
+			RecordDate:  afterevaluation.AssessmentDate,
221
+			Ctime:       time.Now().Unix(),
222
+			Mtime:       0,
223
+			Status:      1,
224
+			Source:      "物联网上传透后血压",
225
+		}
226
+
227
+		service.CreateAfterDialysisLog(afterLog)
228
+
196 229
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_after_dislysis"
197 230
 		redis := service.RedisClient()
198 231
 		//清空key 值
@@ -406,6 +439,23 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
406 439
 			}
407 440
 			//插入透析处方
408 441
 			err := service.AddSigleRecord(&newprescribe)
442
+
443
+			//记录日志
444
+			byterequest, _ := json.Marshal(newprescribe)
445
+			prescriptionLog := models.XtDialysisPrescriptionLog{
446
+				UserOrgId:   newprescribe.UserOrgId,
447
+				Ctime:       time.Now().Unix(),
448
+				Mtime:       0,
449
+				ErrLog:      string(byterequest),
450
+				AdminUserId: adminUserInfo.AdminUser.Id,
451
+				RecordDate:  newprescribe.RecordDate,
452
+				PatientId:   newprescribe.PatientId,
453
+				Source:      "物联网上传",
454
+				Status:      1,
455
+			}
456
+
457
+			service.CreatePrescriptionLog(prescriptionLog)
458
+
409 459
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
410 460
 			redis := service.RedisClient()
411 461
 			//清空key 值
@@ -489,6 +539,23 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
489 539
 					newprescribe.BloodAccess = dialysisSolution.BloodAccess
490 540
 				}
491 541
 				err := service.AddSigleRecord(&newprescribe)
542
+
543
+				//记录日志
544
+				byterequest, _ := json.Marshal(newprescribe)
545
+				prescriptionLog := models.XtDialysisPrescriptionLog{
546
+					UserOrgId:   newprescribe.UserOrgId,
547
+					Ctime:       time.Now().Unix(),
548
+					Mtime:       0,
549
+					ErrLog:      string(byterequest),
550
+					AdminUserId: adminUserInfo.AdminUser.Id,
551
+					RecordDate:  newprescribe.RecordDate,
552
+					PatientId:   newprescribe.PatientId,
553
+					Source:      "物联网上传",
554
+					Status:      1,
555
+				}
556
+
557
+				service.CreatePrescriptionLog(prescriptionLog)
558
+
492 559
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
493 560
 				redis := service.RedisClient()
494 561
 				//清空key 值
@@ -563,6 +630,22 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
563 630
 					newprescribe.BloodAccess = dialysisSolution.BloodAccess
564 631
 				}
565 632
 				err := service.AddSigleRecord(&newprescribe)
633
+
634
+				//记录日志
635
+				byterequest, _ := json.Marshal(newprescribe)
636
+				prescriptionLog := models.XtDialysisPrescriptionLog{
637
+					UserOrgId:   newprescribe.UserOrgId,
638
+					Ctime:       time.Now().Unix(),
639
+					Mtime:       0,
640
+					ErrLog:      string(byterequest),
641
+					AdminUserId: adminUserInfo.AdminUser.Id,
642
+					RecordDate:  newprescribe.RecordDate,
643
+					PatientId:   newprescribe.PatientId,
644
+					Source:      "物联网上传",
645
+					Status:      1,
646
+				}
647
+
648
+				service.CreatePrescriptionLog(prescriptionLog)
566 649
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
567 650
 				redis := service.RedisClient()
568 651
 				//清空key 值
@@ -590,6 +673,21 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
590 673
 				newprescribe.Status = 1
591 674
 
592 675
 				err := service.AddSigleRecord(&newprescribe)
676
+				//记录日志
677
+				byterequest, _ := json.Marshal(newprescribe)
678
+				prescriptionLog := models.XtDialysisPrescriptionLog{
679
+					UserOrgId:   newprescribe.UserOrgId,
680
+					Ctime:       time.Now().Unix(),
681
+					Mtime:       0,
682
+					ErrLog:      string(byterequest),
683
+					AdminUserId: adminUserInfo.AdminUser.Id,
684
+					RecordDate:  newprescribe.RecordDate,
685
+					PatientId:   newprescribe.PatientId,
686
+					Source:      "物联网上传",
687
+					Status:      1,
688
+				}
689
+
690
+				service.CreatePrescriptionLog(prescriptionLog)
593 691
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
594 692
 				redis := service.RedisClient()
595 693
 				//清空key 值
@@ -616,6 +714,21 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
616 714
 				dialysisPrescribe.TargetUltrafiltration = 0
617 715
 			}
618 716
 			updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
717
+			//记录日志
718
+			byterequest, _ := json.Marshal(dialysisPrescribe)
719
+			prescriptionLog := models.XtDialysisPrescriptionLog{
720
+				UserOrgId:   dialysisPrescribe.UserOrgId,
721
+				Ctime:       time.Now().Unix(),
722
+				Mtime:       0,
723
+				ErrLog:      string(byterequest),
724
+				AdminUserId: adminUserInfo.AdminUser.Id,
725
+				RecordDate:  dialysisPrescribe.RecordDate,
726
+				PatientId:   dialysisPrescribe.PatientId,
727
+				Source:      "物联网上传",
728
+				Status:      1,
729
+			}
730
+
731
+			service.CreatePrescriptionLog(prescriptionLog)
619 732
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
620 733
 			redis := service.RedisClient()
621 734
 			//清空key 值
@@ -732,6 +845,23 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
732 845
 		evaluation.AssessmentTime = time.Now().Unix()
733 846
 
734 847
 		err := service.UpadatePredialysisEvaluation(&evaluation)
848
+
849
+		//记录日志
850
+		byterequest, _ := json.Marshal(evaluation)
851
+		beforLog := models.XtAssessmentBeforeDislysisLog{
852
+			UserOrgId:   evaluation.UserOrgId,
853
+			Ctime:       time.Now().Unix(),
854
+			Mtime:       0,
855
+			ErrLog:      string(byterequest),
856
+			AdminUserId: adminUserInfo.AdminUser.Id,
857
+			RecordDate:  evaluation.AssessmentDate,
858
+			PatientId:   evaluation.PatientId,
859
+			Source:      "物联网上传",
860
+			Status:      1,
861
+		}
862
+
863
+		service.CreateBeforLog(beforLog)
864
+
735 865
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_before_dislysis"
736 866
 		redis := service.RedisClient()
737 867
 		//清空key 值
@@ -804,6 +934,23 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
804 934
 		}
805 935
 
806 936
 		err := service.UpdateAssessmentAfterDislysisRecord(&afterevaluation)
937
+
938
+		//记录日志
939
+		byterequest, _ := json.Marshal(afterevaluation)
940
+		afterDialysisLog := models.XtAssessmentAfterDialysisLog{
941
+			UserOrgId:   afterevaluation.UserOrgId,
942
+			PatientId:   afterevaluation.PatientId,
943
+			RecordDate:  afterevaluation.AssessmentDate,
944
+			Status:      1,
945
+			ErrLog:      string(byterequest),
946
+			AdminUserId: adminUserInfo.AdminUser.Id,
947
+			Ctime:       time.Now().Unix(),
948
+			Mtime:       0,
949
+			Source:      "物联网称重",
950
+		}
951
+
952
+		service.CreateAfterDialysisLog(afterDialysisLog)
953
+
807 954
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_after_dislysis"
808 955
 		redis := service.RedisClient()
809 956
 		//清空key 值

+ 136 - 20
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -729,7 +729,7 @@ func (c *DialysisAPIController) PostAtreatmentInfo() {
729 729
 
730 730
 		if cha_time >= recordDate.Unix() {
731 731
 			//查询审核是否允许
732
-			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
732
+			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id, 10)
733 733
 			//申请状态不允许的情况 拒绝修改
734 734
 			if infor.ApplicationStatus != 1 {
735 735
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -940,7 +940,7 @@ func (c *DialysisAPIController) PostDoubleCheck() {
940 940
 
941 941
 			if cha_time >= recordDate.Unix() {
942 942
 				//查询审核是否允许
943
-				infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
943
+				infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id, 5)
944 944
 				//申请状态不允许的情况 拒绝修改
945 945
 				if infor.ApplicationStatus != 1 {
946 946
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -1019,7 +1019,7 @@ func (c *DialysisAPIController) PostDoubleCheck() {
1019 1019
 
1020 1020
 			if cha_time >= recordDate.Unix() {
1021 1021
 				//查询审核是否允许
1022
-				infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1022
+				infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id, 5)
1023 1023
 				//申请状态不允许的情况 拒绝修改
1024 1024
 				if infor.ApplicationStatus != 1 {
1025 1025
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -1165,7 +1165,7 @@ func (c *DialysisAPIController) PostAcceptsAssessment() {
1165 1165
 
1166 1166
 		if cha_time >= recordDate.Unix() {
1167 1167
 			//查询审核是否允许
1168
-			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1168
+			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id, 2)
1169 1169
 			//申请状态不允许的情况 拒绝修改
1170 1170
 			if infor.ApplicationStatus != 1 {
1171 1171
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -1267,7 +1267,7 @@ func (c *DialysisAPIController) PostAcceptsAssessment() {
1267 1267
 
1268 1268
 			if cha_time >= recordDate.Unix() {
1269 1269
 				//查询审核是否允许
1270
-				infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1270
+				infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id, 2)
1271 1271
 				//申请状态不允许的情况 拒绝修改
1272 1272
 				if infor.ApplicationStatus != 1 {
1273 1273
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -1514,7 +1514,7 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1514 1514
 		fmt.Println("recordDate.Unix()", recordDate.Unix())
1515 1515
 		if cha_time >= recordDate.Unix() {
1516 1516
 			//查询审核是否允许
1517
-			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1517
+			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id, 9)
1518 1518
 			//申请状态不允许的情况 拒绝修改
1519 1519
 			if infor.ApplicationStatus != 1 {
1520 1520
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -1535,6 +1535,22 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1535 1535
 		}
1536 1536
 
1537 1537
 		err := service.AddSigleAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
1538
+
1539
+		//记录日志
1540
+		byterequest, _ := json.Marshal(assessmentAfterDislysis)
1541
+		afterDialysisLog := models.XtAssessmentAfterDialysisLog{
1542
+			UserOrgId:   assessmentAfterDislysis.UserOrgId,
1543
+			PatientId:   assessmentAfterDislysis.PatientId,
1544
+			RecordDate:  assessmentAfterDislysis.AssessmentDate,
1545
+			Status:      1,
1546
+			ErrLog:      string(byterequest),
1547
+			AdminUserId: adminUserInfo.AdminUser.Id,
1548
+			Ctime:       0,
1549
+			Mtime:       0,
1550
+			Source:      "手机端保存透后评估",
1551
+		}
1552
+		service.CreateAfterDialysisLog(afterDialysisLog)
1553
+
1538 1554
 		finish := models.XtDialysisFinish{
1539 1555
 			IsFinish:   1,
1540 1556
 			UserOrgId:  adminUserInfo.Org.Id,
@@ -1582,7 +1598,7 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1582 1598
 			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
1583 1599
 			if cha_time >= recordDate.Unix() {
1584 1600
 				//查询审核是否允许
1585
-				infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1601
+				infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id, 9)
1586 1602
 				//申请状态不允许的情况 拒绝修改
1587 1603
 				if infor.ApplicationStatus != 1 {
1588 1604
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -1605,7 +1621,22 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1605 1621
 		assessmentAfterDislysis.ID = assessmentAfter.ID
1606 1622
 
1607 1623
 		err := service.UpdateAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
1608
-		fmt.Println("werwewweoweoweoweoewoewoew", err)
1624
+
1625
+		//记录日志
1626
+		byterequest, _ := json.Marshal(assessmentAfterDislysis)
1627
+		afterDialysisLog := models.XtAssessmentAfterDialysisLog{
1628
+			UserOrgId:   assessmentAfterDislysis.UserOrgId,
1629
+			PatientId:   assessmentAfterDislysis.PatientId,
1630
+			RecordDate:  assessmentAfterDislysis.AssessmentDate,
1631
+			Status:      1,
1632
+			ErrLog:      string(byterequest),
1633
+			AdminUserId: adminUserInfo.AdminUser.Id,
1634
+			Ctime:       0,
1635
+			Mtime:       0,
1636
+			Source:      "手机端修改保存透后评估",
1637
+		}
1638
+		service.CreateAfterDialysisLog(afterDialysisLog)
1639
+
1609 1640
 		redis := service.RedisClient()
1610 1641
 		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1611 1642
 
@@ -1809,7 +1840,7 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1809 1840
 
1810 1841
 		if cha_time >= recordDate.Unix() {
1811 1842
 			//查询审核是否允许
1812
-			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1843
+			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id, 1)
1813 1844
 			//申请状态不允许的情况 拒绝修改
1814 1845
 			if infor.ApplicationStatus != 1 {
1815 1846
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -2026,6 +2057,23 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
2026 2057
 			prescription.AdminUserId = adminUserInfo.AdminUser.Id
2027 2058
 		}
2028 2059
 		err := service.AddSigleRecord(&prescription)
2060
+
2061
+		//记录日志
2062
+		byterequest, _ := json.Marshal(prescription)
2063
+		prescriptionLog := models.XtDialysisPrescriptionLog{
2064
+			UserOrgId:   prescription.UserOrgId,
2065
+			Ctime:       time.Now().Unix(),
2066
+			Mtime:       0,
2067
+			ErrLog:      string(byterequest),
2068
+			AdminUserId: adminUserInfo.AdminUser.Id,
2069
+			RecordDate:  prescription.RecordDate,
2070
+			PatientId:   prescription.PatientId,
2071
+			Source:      "手机端新增保存处方",
2072
+			Status:      1,
2073
+		}
2074
+
2075
+		service.CreatePrescriptionLog(prescriptionLog)
2076
+
2029 2077
 		finish := models.XtDialysisFinish{
2030 2078
 			IsFinish:   1,
2031 2079
 			UserOrgId:  adminUserInfo.Org.Id,
@@ -2263,6 +2311,22 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
2263 2311
 
2264 2312
 		err := service.UpDateDialysisPrescription(&prescription)
2265 2313
 
2314
+		//记录日志
2315
+		byterequest, _ := json.Marshal(prescription)
2316
+		prescriptionLog := models.XtDialysisPrescriptionLog{
2317
+			UserOrgId:   prescription.UserOrgId,
2318
+			Ctime:       time.Now().Unix(),
2319
+			Mtime:       0,
2320
+			ErrLog:      string(byterequest),
2321
+			AdminUserId: adminUserInfo.AdminUser.Id,
2322
+			RecordDate:  prescription.RecordDate,
2323
+			PatientId:   prescription.PatientId,
2324
+			Source:      "手机端修改处方",
2325
+			Status:      1,
2326
+		}
2327
+
2328
+		service.CreatePrescriptionLog(prescriptionLog)
2329
+
2266 2330
 		finish := models.XtDialysisFinish{
2267 2331
 			IsFinish:   1,
2268 2332
 			UserOrgId:  adminUserInfo.Org.Id,
@@ -2399,7 +2463,7 @@ func (c *DialysisAPIController) Finish() {
2399 2463
 
2400 2464
 		if cha_time >= recordDate.Unix() {
2401 2465
 			//查询审核是否允许
2402
-			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
2466
+			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id, 8)
2403 2467
 			//申请状态不允许的情况 拒绝修改
2404 2468
 			if infor.ApplicationStatus != 1 {
2405 2469
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -3159,7 +3223,7 @@ func (this *DialysisAPIController) StartDialysis() {
3159 3223
 
3160 3224
 		if cha_time >= recordDate.Unix() {
3161 3225
 			//查询审核是否允许
3162
-			infor, _ := service.GetDialysisInformationByRecordDate(patientID, recordDate.Unix(), adminUserInfo.Org.Id)
3226
+			infor, _ := service.GetDialysisInformationByRecordDate(patientID, recordDate.Unix(), adminUserInfo.Org.Id, 6)
3163 3227
 			//申请状态不允许的情况 拒绝修改
3164 3228
 			if infor.ApplicationStatus != 1 {
3165 3229
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -3409,6 +3473,23 @@ func (this *DialysisAPIController) StartDialysis() {
3409 3473
 		}
3410 3474
 
3411 3475
 		err := service.CreateMonitor(&record)
3476
+
3477
+		//记录日志
3478
+		byterequest, _ := json.Marshal(record)
3479
+		monitorRecordLog := models.XtMonitorRecordLog{
3480
+			RecordDate:  record.MonitoringDate,
3481
+			PatientId:   record.PatientId,
3482
+			Module:      1,
3483
+			AdminUserId: adminUserInfo.AdminUser.Id,
3484
+			Ctime:       time.Now().Unix(),
3485
+			Mtime:       0,
3486
+			Status:      1,
3487
+			UserOrgId:   record.UserOrgId,
3488
+			ErrLog:      string(byterequest),
3489
+			Source:      "执行上机时新增监测",
3490
+		}
3491
+		service.CreateMonitorRecordLog(monitorRecordLog)
3492
+
3412 3493
 		finish := models.XtDialysisFinish{
3413 3494
 			IsFinish:   1,
3414 3495
 			UserOrgId:  adminUserInfo.Org.Id,
@@ -3642,7 +3723,7 @@ func (c *DialysisAPIController) PostSolution() {
3642 3723
 
3643 3724
 		if cha_time >= recordDate.Unix() {
3644 3725
 			//查询审核是否允许
3645
-			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
3726
+			infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id, 1)
3646 3727
 			//申请状态不允许的情况 拒绝修改
3647 3728
 			if infor.ApplicationStatus != 1 {
3648 3729
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -3761,7 +3842,7 @@ func (c *DialysisAPIController) PostSolution() {
3761 3842
 
3762 3843
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
3763 3844
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
3764
-	fmt.Println("appRole0000000000000", appRole.UserType)
3845
+
3765 3846
 	//
3766 3847
 	if appRole.UserType == 2 || appRole.UserType == 1 {
3767 3848
 		prescription_doctor = adminUserInfo.AdminUser.Id
@@ -3924,6 +4005,22 @@ func (c *DialysisAPIController) PostSolution() {
3924 4005
 	}
3925 4006
 
3926 4007
 	service.SavePrescriptionAndCreateSolution(&solution, &prescription)
4008
+	//记录日志
4009
+	byterequest, _ := json.Marshal(prescription)
4010
+	prescriptionLog := models.XtDialysisPrescriptionLog{
4011
+		UserOrgId:   prescription.UserOrgId,
4012
+		Ctime:       time.Now().Unix(),
4013
+		Mtime:       0,
4014
+		ErrLog:      string(byterequest),
4015
+		AdminUserId: adminUserInfo.AdminUser.Id,
4016
+		RecordDate:  prescription.RecordDate,
4017
+		PatientId:   prescription.PatientId,
4018
+		Source:      "手机端新增处方",
4019
+		Status:      1,
4020
+	}
4021
+
4022
+	service.CreatePrescriptionLog(prescriptionLog)
4023
+
3927 4024
 	finish := models.XtDialysisFinish{
3928 4025
 		IsFinish:   1,
3929 4026
 		UserOrgId:  adminUserInfo.Org.Id,
@@ -4594,7 +4691,7 @@ func (this *DialysisAPIController) ModifyStartDialysisOrder() {
4594 4691
 
4595 4692
 		if cha_time >= record_date {
4596 4693
 			//查询审核是否允许
4597
-			infor, _ := service.GetDialysisInformationByRecordDate(tempDialysisRecord.PatientId, record_date, adminUserInfo.Org.Id)
4694
+			infor, _ := service.GetDialysisInformationByRecordDate(tempDialysisRecord.PatientId, record_date, adminUserInfo.Org.Id, 1)
4598 4695
 			//申请状态不允许的情况 拒绝修改
4599 4696
 			if infor.ApplicationStatus != 1 {
4600 4697
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -4734,7 +4831,7 @@ func (c *DialysisAPIController) ModifyFinishDialysisOrder() {
4734 4831
 
4735 4832
 		if cha_time >= tempDialysisRecords.DialysisDate {
4736 4833
 			//查询审核是否允许
4737
-			infor, _ := service.GetDialysisInformationByRecordDate(tempDialysisRecords.PatientId, tempDialysisRecords.DialysisDate, adminUserInfo.Org.Id)
4834
+			infor, _ := service.GetDialysisInformationByRecordDate(tempDialysisRecords.PatientId, tempDialysisRecords.DialysisDate, adminUserInfo.Org.Id, 6)
4738 4835
 			//申请状态不允许的情况 拒绝修改
4739 4836
 			if infor.ApplicationStatus != 1 {
4740 4837
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -5342,6 +5439,25 @@ func (c *DialysisAPIController) CreateRemindDoctorAdvice() {
5342 5439
 		}
5343 5440
 
5344 5441
 		list, err := service.CreateMGroupAdvice(adminUserInfo.Org.Id, advices, groupNo)
5442
+
5443
+		for _, item := range advices {
5444
+			byterequest, _ := json.Marshal(item)
5445
+			adviceLog := models.XtDoctorAdviceLog{
5446
+				UserOrgId:   adminUserInfo.Org.Id,
5447
+				PatientId:   patient,
5448
+				AdminUserId: adminUserInfo.AdminUser.Id,
5449
+				Module:      1,
5450
+				ErrLog:      string(byterequest),
5451
+				Status:      1,
5452
+				Ctime:       time.Now().Unix(),
5453
+				Mtime:       0,
5454
+				Source:      "手机端医嘱推送",
5455
+				RecordDate:  item.AdviceDate,
5456
+			}
5457
+
5458
+			service.CreateDoctorAdviceLog(adviceLog)
5459
+		}
5460
+
5345 5461
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(RecordDate, 10) + ":doctor_advices"
5346 5462
 		redis := service.RedisClient()
5347 5463
 		//清空key 值
@@ -5591,7 +5707,7 @@ func (c *DialysisAPIController) CreateConsumables() {
5591 5707
 
5592 5708
 		if cha_time >= record_time {
5593 5709
 			//查询审核是否允许
5594
-			infor, _ := service.GetDialysisInformationByRecordDate(patient_id, record_time, orgid)
5710
+			infor, _ := service.GetDialysisInformationByRecordDate(patient_id, record_time, orgid, 11)
5595 5711
 			//申请状态不允许的情况 拒绝修改
5596 5712
 			if infor.ApplicationStatus != 1 {
5597 5713
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -5974,7 +6090,7 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
5974 6090
 
5975 6091
 		if cha_time >= record_time {
5976 6092
 			//查询审核是否允许
5977
-			infor, _ := service.GetDialysisInformationByRecordDate(patient_id, record_time, adminInfo.Org.Id)
6093
+			infor, _ := service.GetDialysisInformationByRecordDate(patient_id, record_time, adminInfo.Org.Id, 11)
5978 6094
 			//申请状态不允许的情况 拒绝修改
5979 6095
 			if infor.ApplicationStatus != 1 {
5980 6096
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -6435,7 +6551,7 @@ func (c *DialysisAPIController) EditConsumables() {
6435 6551
 
6436 6552
 		if cha_time >= record_time {
6437 6553
 			//查询审核是否允许
6438
-			infor, _ := service.GetDialysisInformationByRecordDate(patient_id, record_time, adminInfo.Org.Id)
6554
+			infor, _ := service.GetDialysisInformationByRecordDate(patient_id, record_time, adminInfo.Org.Id, 11)
6439 6555
 			//申请状态不允许的情况 拒绝修改
6440 6556
 			if infor.ApplicationStatus != 1 {
6441 6557
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -7314,7 +7430,7 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
7314 7430
 
7315 7431
 		if cha_time >= record_time {
7316 7432
 			//查询审核是否允许
7317
-			infor, _ := service.GetDialysisInformationByRecordDate(patient_id, record_time, adminInfo.Org.Id)
7433
+			infor, _ := service.GetDialysisInformationByRecordDate(patient_id, record_time, adminInfo.Org.Id, 11)
7318 7434
 			//申请状态不允许的情况 拒绝修改
7319 7435
 			if infor.ApplicationStatus != 1 {
7320 7436
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -9334,7 +9450,7 @@ func (this *DialysisAPIController) SaveMobileInformation() {
9334 9450
 		Mtime:             0,
9335 9451
 	}
9336 9452
 
9337
-	infor, _ := service.GetDialysisInformationByRecordDate(patient_id, record_date, user_org_id)
9453
+	infor, _ := service.GetDialysisInformationByRecordDateOne(patient_id, record_date, user_org_id)
9338 9454
 	if infor.ID == 0 {
9339 9455
 		service.SaveDialysisInformation(information)
9340 9456
 	}

+ 54 - 3
controllers/mobile_api_controllers/dialysis_api_controller_extend.go View File

@@ -5,6 +5,7 @@ import (
5 5
 	"XT_New/models"
6 6
 	"XT_New/service"
7 7
 	"XT_New/utils"
8
+	"encoding/json"
8 9
 	"fmt"
9 10
 	"github.com/jinzhu/gorm"
10 11
 	"strconv"
@@ -134,7 +135,7 @@ func (this *DialysisAPIController) AddMonitorRecord() {
134 135
 
135 136
 		if cha_time >= date {
136 137
 			//查询审核是否允许
137
-			infor, _ := service.GetDialysisInformationByRecordDate(patientID, date, adminInfo.Org.Id)
138
+			infor, _ := service.GetDialysisInformationByRecordDate(patientID, date, adminInfo.Org.Id, 7)
138 139
 			//申请状态不允许的情况 拒绝修改
139 140
 			if infor.ApplicationStatus != 1 {
140 141
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -203,6 +204,23 @@ func (this *DialysisAPIController) AddMonitorRecord() {
203 204
 	}
204 205
 
205 206
 	err := service.CreateMonitor(&record)
207
+	//记录日志
208
+	byterequest, _ := json.Marshal(record)
209
+	monitorRecordLog := models.XtMonitorRecordLog{
210
+		RecordDate:  record.MonitoringDate,
211
+		PatientId:   record.PatientId,
212
+		Module:      1,
213
+		AdminUserId: adminInfo.AdminUser.Id,
214
+		Ctime:       0,
215
+		Mtime:       0,
216
+		Status:      1,
217
+		UserOrgId:   record.UserOrgId,
218
+		ErrLog:      string(byterequest),
219
+		Source:      "手机端新增血压",
220
+	}
221
+
222
+	service.CreateMonitorRecordLog(monitorRecordLog)
223
+
206 224
 	finish := models.XtDialysisFinish{
207 225
 		IsFinish:   1,
208 226
 		UserOrgId:  record.UserOrgId,
@@ -407,7 +425,7 @@ func (this *DialysisAPIController) EditMonitorRecord() {
407 425
 
408 426
 		if cha_time >= monitor.MonitoringDate {
409 427
 			//查询审核是否允许
410
-			infor, _ := service.GetDialysisInformationByRecordDate(id, monitor.MonitoringDate, monitor.UserOrgId)
428
+			infor, _ := service.GetDialysisInformationByRecordDate(id, monitor.MonitoringDate, monitor.UserOrgId, 7)
411 429
 			//申请状态不允许的情况 拒绝修改
412 430
 			if infor.ApplicationStatus != 1 {
413 431
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -419,6 +437,22 @@ func (this *DialysisAPIController) EditMonitorRecord() {
419 437
 	monitor.ReplacementSpeed = replacement_speed
420 438
 	monitor.Dicarbonate = dicarbonate
421 439
 	err = service.UpdateMonitor(monitor)
440
+	//记录日志
441
+	byterequest, _ := json.Marshal(monitor)
442
+	monitorRecordLog := models.XtMonitorRecordLog{
443
+		RecordDate:  monitor.MonitoringDate,
444
+		PatientId:   monitor.PatientId,
445
+		Module:      3,
446
+		AdminUserId: adminInfo.AdminUser.Id,
447
+		Ctime:       time.Now().Unix(),
448
+		Mtime:       0,
449
+		Status:      1,
450
+		UserOrgId:   monitor.UserOrgId,
451
+		ErrLog:      string(byterequest),
452
+		Source:      "手机端修改监测",
453
+	}
454
+	service.CreateMonitorRecordLog(monitorRecordLog)
455
+
422 456
 	key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(date, 10) + ":monitor_records"
423 457
 	redis := service.RedisClient()
424 458
 	//清空key 值
@@ -480,7 +514,7 @@ func (this *DialysisAPIController) DeleteMonitor() {
480 514
 
481 515
 		if cha_time >= monitor.MonitoringDate {
482 516
 			//查询审核是否允许
483
-			infor, _ := service.GetDialysisInformationByRecordDate(monitor.PatientId, monitor.MonitoringDate, monitor.UserOrgId)
517
+			infor, _ := service.GetDialysisInformationByRecordDate(monitor.PatientId, monitor.MonitoringDate, monitor.UserOrgId, 7)
484 518
 			//申请状态不允许的情况 拒绝修改
485 519
 			if infor.ApplicationStatus != 1 {
486 520
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -490,6 +524,23 @@ func (this *DialysisAPIController) DeleteMonitor() {
490 524
 		}
491 525
 	}
492 526
 	err := service.DisableMonitor(adminInfo.Org.Id, patientID, recordID, adminInfo.AdminUser.Id)
527
+
528
+	//记录日志
529
+	byterequest, _ := json.Marshal(monitor)
530
+	recordLog := models.XtMonitorRecordLog{
531
+		RecordDate:  monitor.MonitoringDate,
532
+		PatientId:   monitor.PatientId,
533
+		Module:      4,
534
+		AdminUserId: adminInfo.AdminUser.Id,
535
+		Ctime:       time.Now().Unix(),
536
+		Mtime:       0,
537
+		Status:      1,
538
+		UserOrgId:   monitor.UserOrgId,
539
+		ErrLog:      string(byterequest),
540
+		Source:      "手机端删除监测",
541
+	}
542
+	service.CreateMonitorRecordLog(recordLog)
543
+
493 544
 	orgid := this.GetMobileAdminUserInfo().Org.Id
494 545
 	redis := service.RedisClient()
495 546
 	key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(monitor.MonitoringDate, 10) + ":monitor_record_list_all"

+ 402 - 25
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -326,7 +326,7 @@ func (c *PatientApiController) EditDoctorAdvice() {
326 326
 
327 327
 				if cha_time >= sourceAdvice.AdviceDate {
328 328
 					//查询审核是否允许
329
-					infor, _ := service.GetDialysisInformationByRecordDate(id, sourceAdvice.AdviceDate, adminUserInfo.Org.Id)
329
+					infor, _ := service.GetDialysisInformationByRecordDate(id, sourceAdvice.AdviceDate, adminUserInfo.Org.Id, 4)
330 330
 					//申请状态不允许的情况 拒绝修改
331 331
 					if infor.ApplicationStatus != 1 {
332 332
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -369,7 +369,7 @@ func (c *PatientApiController) EditDoctorAdvice() {
369 369
 
370 370
 				if cha_time >= sourceAdvice.AdviceDate {
371 371
 					//查询审核是否允许
372
-					infor, _ := service.GetDialysisInformationByRecordDate(id, sourceAdvice.AdviceDate, adminUserInfo.Org.Id)
372
+					infor, _ := service.GetDialysisInformationByRecordDate(id, sourceAdvice.AdviceDate, adminUserInfo.Org.Id, 4)
373 373
 					//申请状态不允许的情况 拒绝修改
374 374
 					if infor.ApplicationStatus != 1 {
375 375
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -418,7 +418,7 @@ func (c *PatientApiController) EditDoctorAdvice() {
418 418
 
419 419
 			if cha_time >= advice.AdviceDate {
420 420
 				//查询审核是否允许
421
-				infor, _ := service.GetDialysisInformationByRecordDate(id, advice.AdviceDate, adminUserInfo.Org.Id)
421
+				infor, _ := service.GetDialysisInformationByRecordDate(id, advice.AdviceDate, adminUserInfo.Org.Id, 4)
422 422
 				//申请状态不允许的情况 拒绝修改
423 423
 				if infor.ApplicationStatus != 1 {
424 424
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -727,7 +727,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
727 727
 
728 728
 				if cha_time >= record_date {
729 729
 					//查询审核是否允许
730
-					infor, _ := service.GetDialysisInformationByRecordDate(advices.PatientId, advices.AdviceDate, adminUserInfo.Org.Id)
730
+					infor, _ := service.GetDialysisInformationByRecordDate(advices.PatientId, advices.AdviceDate, adminUserInfo.Org.Id, 4)
731 731
 					//申请状态不允许的情况 拒绝修改
732 732
 					if infor.ApplicationStatus != 1 {
733 733
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -737,6 +737,23 @@ func (c *PatientApiController) ExecDoctorAdvice() {
737 737
 				}
738 738
 			}
739 739
 			err = service.ExceDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
740
+			//记录日志
741
+			byterequest, _ := json.Marshal(advices)
742
+			adviceLog := models.XtDoctorAdviceLog{
743
+				UserOrgId:   advices.UserOrgId,
744
+				PatientId:   advices.PatientId,
745
+				AdminUserId: advices.ExecutionStaff,
746
+				Module:      2,
747
+				ErrLog:      string(byterequest),
748
+				Status:      1,
749
+				Ctime:       time.Now().Unix(),
750
+				Mtime:       0,
751
+				Source:      "手机端执行医嘱",
752
+				RecordDate:  advices.RecordDate,
753
+			}
754
+
755
+			service.CreateDoctorAdviceLog(adviceLog)
756
+
740 757
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
741 758
 			redis := service.RedisClient()
742 759
 			//清空key 值
@@ -773,7 +790,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
773 790
 
774 791
 				if cha_time >= record_date {
775 792
 					//查询审核是否允许
776
-					infor, _ := service.GetDialysisInformationByRecordDate(advices.PatientId, advices.AdviceDate, adminUserInfo.Org.Id)
793
+					infor, _ := service.GetDialysisInformationByRecordDate(advices.PatientId, advices.AdviceDate, adminUserInfo.Org.Id, 4)
777 794
 					//申请状态不允许的情况 拒绝修改
778 795
 					if infor.ApplicationStatus != 1 {
779 796
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -783,6 +800,23 @@ func (c *PatientApiController) ExecDoctorAdvice() {
783 800
 				}
784 801
 			}
785 802
 			err = service.BatchExceOldDoctorAdvice(&advices, ids)
803
+
804
+			//记录日志
805
+			byterequest, _ := json.Marshal(advices)
806
+			adviceLog := models.XtDoctorAdviceLog{
807
+				UserOrgId:   advices.UserOrgId,
808
+				PatientId:   advices.PatientId,
809
+				AdminUserId: advices.ExecutionStaff,
810
+				Module:      2,
811
+				ErrLog:      string(byterequest),
812
+				Status:      1,
813
+				Ctime:       time.Now().Unix(),
814
+				Mtime:       0,
815
+				Source:      "手机端执行医嘱",
816
+				RecordDate:  advices.RecordDate,
817
+			}
818
+
819
+			service.CreateDoctorAdviceLog(adviceLog)
786 820
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
787 821
 			redis := service.RedisClient()
788 822
 			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
@@ -1287,7 +1321,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1287 1321
 
1288 1322
 				if cha_time >= item.AdviceDate {
1289 1323
 					//查询审核是否允许
1290
-					infor, _ := service.GetDialysisInformationByRecordDate(item.PatientId, item.AdviceDate, item.UserOrgId)
1324
+					infor, _ := service.GetDialysisInformationByRecordDate(item.PatientId, item.AdviceDate, item.UserOrgId, 4)
1291 1325
 					//申请状态不允许的情况 拒绝修改
1292 1326
 					if infor.ApplicationStatus != 1 {
1293 1327
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -1297,6 +1331,23 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1297 1331
 				}
1298 1332
 			}
1299 1333
 			err = service.SaveHisDoctorAdvice(item)
1334
+
1335
+			//记录日志
1336
+			byterequest, _ := json.Marshal(item)
1337
+			adviceLog := models.XtDoctorAdviceLog{
1338
+				UserOrgId:   item.UserOrgId,
1339
+				PatientId:   item.PatientId,
1340
+				AdminUserId: item.ExecutionStaff,
1341
+				Module:      2,
1342
+				ErrLog:      string(byterequest),
1343
+				Status:      1,
1344
+				Ctime:       time.Now().Unix(),
1345
+				Mtime:       0,
1346
+				Source:      "手机端执行his医嘱",
1347
+				RecordDate:  item.AdviceDate,
1348
+			}
1349
+			service.CreateDoctorAdviceLog(adviceLog)
1350
+
1300 1351
 			if err == nil {
1301 1352
 				drugError := models.XtDrugError{
1302 1353
 					UserOrgId:             adminInfo.Org.Id,
@@ -1735,7 +1786,7 @@ func (c *PatientApiController) ModifyExecDoctorAdvice() {
1735 1786
 
1736 1787
 			if cha_time >= advices.AdviceDate {
1737 1788
 				//查询审核是否允许
1738
-				infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advices.AdviceDate, adminUserInfo.Org.Id)
1789
+				infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advices.AdviceDate, adminUserInfo.Org.Id, 4)
1739 1790
 				//申请状态不允许的情况 拒绝修改
1740 1791
 				if infor.ApplicationStatus != 1 {
1741 1792
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -1745,6 +1796,23 @@ func (c *PatientApiController) ModifyExecDoctorAdvice() {
1745 1796
 			}
1746 1797
 		}
1747 1798
 		err = service.ModifyExceDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
1799
+		//记录日志
1800
+		byterequest, _ := json.Marshal(advices)
1801
+		adviceLog := models.XtDoctorAdviceLog{
1802
+			UserOrgId:   adminUserInfo.Org.Id,
1803
+			PatientId:   advices.PatientId,
1804
+			AdminUserId: adminUserInfo.AdminUser.Id,
1805
+			Module:      1,
1806
+			ErrLog:      string(byterequest),
1807
+			Status:      1,
1808
+			Ctime:       time.Now().Unix(),
1809
+			Mtime:       0,
1810
+			Source:      "手机端编辑医嘱",
1811
+			RecordDate:  advices.AdviceDate,
1812
+		}
1813
+
1814
+		service.CreateDoctorAdviceLog(adviceLog)
1815
+
1748 1816
 		redis := service.RedisClient()
1749 1817
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1750 1818
 
@@ -1768,7 +1836,7 @@ func (c *PatientApiController) ModifyExecDoctorAdvice() {
1768 1836
 
1769 1837
 			if cha_time >= advices.AdviceDate {
1770 1838
 				//查询审核是否允许
1771
-				infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advices.AdviceDate, adminUserInfo.Org.Id)
1839
+				infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advices.AdviceDate, adminUserInfo.Org.Id, 4)
1772 1840
 				//申请状态不允许的情况 拒绝修改
1773 1841
 				if infor.ApplicationStatus != 1 {
1774 1842
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -1778,8 +1846,24 @@ func (c *PatientApiController) ModifyExecDoctorAdvice() {
1778 1846
 			}
1779 1847
 		}
1780 1848
 		err = service.BatchModifyExceOldDoctorAdvice(&advices, ids)
1781
-
1782 1849
 		err = service.ModifyExceDoctorAdviceByGroupNoOne(&advices, ids)
1850
+
1851
+		//记录日志
1852
+		byterequest, _ := json.Marshal(advices)
1853
+		adviceLog := models.XtDoctorAdviceLog{
1854
+			UserOrgId:   adminUserInfo.Org.Id,
1855
+			PatientId:   advices.PatientId,
1856
+			AdminUserId: adminUserInfo.AdminUser.Id,
1857
+			Module:      1,
1858
+			ErrLog:      string(byterequest),
1859
+			Status:      1,
1860
+			Ctime:       time.Now().Unix(),
1861
+			Mtime:       0,
1862
+			Source:      "手机端编辑执行医嘱",
1863
+			RecordDate:  advices.AdviceDate,
1864
+		}
1865
+
1866
+		service.CreateDoctorAdviceLog(adviceLog)
1783 1867
 		redis := service.RedisClient()
1784 1868
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1785 1869
 
@@ -1800,6 +1884,22 @@ func (c *PatientApiController) ModifyExecDoctorAdvice() {
1800 1884
 		}
1801 1885
 		var advicehis models.HisDoctorAdviceInfo
1802 1886
 		service.ModifyExceDoctorAdviceById(&advicesinfo, ids)
1887
+		//记录日志
1888
+		byterequest, _ := json.Marshal(advicesinfo)
1889
+		adviceLog := models.XtDoctorAdviceLog{
1890
+			UserOrgId:   adminUserInfo.Org.Id,
1891
+			PatientId:   advices.PatientId,
1892
+			AdminUserId: adminUserInfo.AdminUser.Id,
1893
+			Module:      1,
1894
+			ErrLog:      string(byterequest),
1895
+			Status:      1,
1896
+			Ctime:       time.Now().Unix(),
1897
+			Mtime:       0,
1898
+			Source:      "手机端his编辑医嘱",
1899
+			RecordDate:  advices.AdviceDate,
1900
+		}
1901
+
1902
+		service.CreateDoctorAdviceLog(adviceLog)
1803 1903
 		his_advices, _ := service.FindHisDoctorAdviceByIdOne(adminUserInfo.Org.Id, ids)
1804 1904
 		for _, item := range his_advices {
1805 1905
 			if item.ExecutionState == 1 {
@@ -1821,7 +1921,21 @@ func (c *PatientApiController) ModifyExecDoctorAdvice() {
1821 1921
 			Mtime:         time.Now().Unix(),
1822 1922
 		}
1823 1923
 		service.ModifyHisPrescriptionProject(&project, ids)
1824
-
1924
+		//记录日志
1925
+		projectquerst, _ := json.Marshal(project)
1926
+		projectLog := models.XtDoctorAdviceLog{
1927
+			UserOrgId:   adminUserInfo.Org.Id,
1928
+			PatientId:   advices.PatientId,
1929
+			AdminUserId: adminUserInfo.AdminUser.Id,
1930
+			Module:      1,
1931
+			ErrLog:      string(projectquerst),
1932
+			Status:      1,
1933
+			Ctime:       time.Now().Unix(),
1934
+			Mtime:       0,
1935
+			Source:      "手机端his编辑项目医嘱",
1936
+			RecordDate:  advices.AdviceDate,
1937
+		}
1938
+		service.CreateDoctorAdviceLog(projectLog)
1825 1939
 		keyEnd := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advicesinfo.PatientId, 10) + ":" + strconv.FormatInt(advicesinfo.AdviceDate, 10) + ":his_doctor_advice"
1826 1940
 		redis.Set(keyEnd, "", time.Second)
1827 1941
 		keyFours := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
@@ -1934,7 +2048,7 @@ func (c *PatientApiController) CheckDoctorAdvice() {
1934 2048
 
1935 2049
 				if cha_time >= record_date {
1936 2050
 					//查询审核是否允许
1937
-					infor, _ := service.GetDialysisInformationByRecordDate(patient_id, record_date, adminUserInfo.Org.Id)
2051
+					infor, _ := service.GetDialysisInformationByRecordDate(patient_id, record_date, adminUserInfo.Org.Id, 4)
1938 2052
 					//申请状态不允许的情况 拒绝修改
1939 2053
 					if infor.ApplicationStatus != 1 {
1940 2054
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -1944,6 +2058,23 @@ func (c *PatientApiController) CheckDoctorAdvice() {
1944 2058
 				}
1945 2059
 			}
1946 2060
 			err = service.CheckDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
2061
+
2062
+			//记录日志
2063
+			byterequest, _ := json.Marshal(advices)
2064
+			adviceLog := models.XtDoctorAdviceLog{
2065
+				UserOrgId:   adminUserInfo.Org.Id,
2066
+				PatientId:   advices.PatientId,
2067
+				AdminUserId: advices.Checker,
2068
+				Module:      3,
2069
+				ErrLog:      string(byterequest),
2070
+				Status:      1,
2071
+				Ctime:       time.Now().Unix(),
2072
+				Mtime:       0,
2073
+				Source:      "手机端核对医嘱",
2074
+				RecordDate:  advices.AdviceDate,
2075
+			}
2076
+			service.CreateDoctorAdviceLog(adviceLog)
2077
+
1947 2078
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1948 2079
 			redis := service.RedisClient()
1949 2080
 			//清空key 值
@@ -1984,7 +2115,7 @@ func (c *PatientApiController) CheckDoctorAdvice() {
1984 2115
 
1985 2116
 					if cha_time >= advices.AdviceDate {
1986 2117
 						//查询审核是否允许
1987
-						infor, _ := service.GetDialysisInformationByRecordDate(advices.PatientId, advices.AdviceDate, adminUserInfo.Org.Id)
2118
+						infor, _ := service.GetDialysisInformationByRecordDate(advices.PatientId, advices.AdviceDate, adminUserInfo.Org.Id, 4)
1988 2119
 						//申请状态不允许的情况 拒绝修改
1989 2120
 						if infor.ApplicationStatus != 1 {
1990 2121
 							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -1994,6 +2125,21 @@ func (c *PatientApiController) CheckDoctorAdvice() {
1994 2125
 					}
1995 2126
 				}
1996 2127
 				err = service.BatchCheckOldDoctorAdvice(&advices, ids, adminUserInfo.Org.Id, advice.AdviceDate)
2128
+				//记录日志
2129
+				byterequest, _ := json.Marshal(advices)
2130
+				adviceLog := models.XtDoctorAdviceLog{
2131
+					UserOrgId:   adminUserInfo.Org.Id,
2132
+					PatientId:   advices.PatientId,
2133
+					AdminUserId: advices.Checker,
2134
+					Module:      3,
2135
+					ErrLog:      string(byterequest),
2136
+					Status:      1,
2137
+					Ctime:       time.Now().Unix(),
2138
+					Mtime:       0,
2139
+					Source:      "手机端核对医嘱",
2140
+					RecordDate:  advices.AdviceDate,
2141
+				}
2142
+				service.CreateDoctorAdviceLog(adviceLog)
1997 2143
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1998 2144
 				redis := service.RedisClient()
1999 2145
 				//清空key 值
@@ -2058,7 +2204,7 @@ func (c *PatientApiController) CheckDoctorAdvice() {
2058 2204
 
2059 2205
 				if cha_time >= record_date {
2060 2206
 					//查询审核是否允许
2061
-					infor, _ := service.GetDialysisInformationByRecordDate(patient_id, record_date, adminInfo.Org.Id)
2207
+					infor, _ := service.GetDialysisInformationByRecordDate(patient_id, record_date, adminInfo.Org.Id, 4)
2062 2208
 					//申请状态不允许的情况 拒绝修改
2063 2209
 					if infor.ApplicationStatus != 1 {
2064 2210
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -2068,6 +2214,21 @@ func (c *PatientApiController) CheckDoctorAdvice() {
2068 2214
 				}
2069 2215
 			}
2070 2216
 			err = service.SaveHisDoctorAdvice(item)
2217
+			//记录日志
2218
+			byterequest, _ := json.Marshal(advices)
2219
+			adviceLog := models.XtDoctorAdviceLog{
2220
+				UserOrgId:   adminInfo.Org.Id,
2221
+				PatientId:   item.PatientId,
2222
+				AdminUserId: item.Checker,
2223
+				Module:      3,
2224
+				ErrLog:      string(byterequest),
2225
+				Status:      1,
2226
+				Ctime:       time.Now().Unix(),
2227
+				Mtime:       0,
2228
+				Source:      "手机端核对His医嘱",
2229
+				RecordDate:  item.AdviceDate,
2230
+			}
2231
+			service.CreateDoctorAdviceLog(adviceLog)
2071 2232
 			redis := service.RedisClient()
2072 2233
 			key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
2073 2234
 			//清空key 值
@@ -2287,6 +2448,22 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
2287 2448
 
2288 2449
 			}
2289 2450
 			err := service.AddSigleRecord(&newprescribe)
2451
+			//记录日志
2452
+			byterequest, _ := json.Marshal(newprescribe)
2453
+			prescriptionLog := models.XtDialysisPrescriptionLog{
2454
+				UserOrgId:   newprescribe.UserOrgId,
2455
+				Ctime:       time.Now().Unix(),
2456
+				Mtime:       0,
2457
+				ErrLog:      string(byterequest),
2458
+				AdminUserId: adminUserInfo.AdminUser.Id,
2459
+				RecordDate:  newprescribe.RecordDate,
2460
+				PatientId:   newprescribe.PatientId,
2461
+				Source:      "手机端新增透前评估插入处方",
2462
+				Status:      1,
2463
+			}
2464
+
2465
+			service.CreatePrescriptionLog(prescriptionLog)
2466
+
2290 2467
 			//获取key,清空redis
2291 2468
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
2292 2469
 			redis := service.RedisClient()
@@ -2325,6 +2502,22 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
2325 2502
 				}
2326 2503
 			}
2327 2504
 			err := service.UpDateDialysisPrescription(&newprescribe)
2505
+
2506
+			//记录日志
2507
+			byterequest, _ := json.Marshal(newprescribe)
2508
+			prescriptionLog := models.XtDialysisPrescriptionLog{
2509
+				UserOrgId:   newprescribe.UserOrgId,
2510
+				Ctime:       time.Now().Unix(),
2511
+				Mtime:       0,
2512
+				ErrLog:      string(byterequest),
2513
+				AdminUserId: adminUserInfo.AdminUser.Id,
2514
+				RecordDate:  newprescribe.RecordDate,
2515
+				PatientId:   newprescribe.PatientId,
2516
+				Source:      "手机端新增透前评估插入处方",
2517
+				Status:      1,
2518
+			}
2519
+
2520
+			service.CreatePrescriptionLog(prescriptionLog)
2328 2521
 			//获取key,清空redis
2329 2522
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
2330 2523
 			redis := service.RedisClient()
@@ -2413,6 +2606,22 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
2413 2606
 					newprescribe.DialysateFlow = 500
2414 2607
 				}
2415 2608
 				err := service.AddSigleRecord(&newprescribe)
2609
+
2610
+				//记录日志
2611
+				byterequest, _ := json.Marshal(newprescribe)
2612
+				prescriptionLog := models.XtDialysisPrescriptionLog{
2613
+					UserOrgId:   newprescribe.UserOrgId,
2614
+					Ctime:       time.Now().Unix(),
2615
+					Mtime:       0,
2616
+					ErrLog:      string(byterequest),
2617
+					AdminUserId: adminUserInfo.AdminUser.Id,
2618
+					RecordDate:  newprescribe.RecordDate,
2619
+					PatientId:   newprescribe.PatientId,
2620
+					Source:      "手机端新增透前评估插入处方",
2621
+					Status:      1,
2622
+				}
2623
+
2624
+				service.CreatePrescriptionLog(prescriptionLog)
2416 2625
 				//获取key,清空redis
2417 2626
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
2418 2627
 				redis := service.RedisClient()
@@ -2447,6 +2656,22 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
2447 2656
 					}
2448 2657
 				}
2449 2658
 				err := service.UpDateDialysisPrescription(&newprescribe)
2659
+
2660
+				//记录日志
2661
+				byterequest, _ := json.Marshal(newprescribe)
2662
+				prescriptionLog := models.XtDialysisPrescriptionLog{
2663
+					UserOrgId:   newprescribe.UserOrgId,
2664
+					Ctime:       time.Now().Unix(),
2665
+					Mtime:       0,
2666
+					ErrLog:      string(byterequest),
2667
+					AdminUserId: adminUserInfo.AdminUser.Id,
2668
+					RecordDate:  newprescribe.RecordDate,
2669
+					PatientId:   newprescribe.PatientId,
2670
+					Source:      "手机端新增透前评估插入处方",
2671
+					Status:      1,
2672
+				}
2673
+
2674
+				service.CreatePrescriptionLog(prescriptionLog)
2450 2675
 				//获取key,清空redis
2451 2676
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
2452 2677
 				redis := service.RedisClient()
@@ -2535,7 +2760,21 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
2535 2760
 					newprescribe.DialysateFlow = 500
2536 2761
 				}
2537 2762
 				err := service.AddSigleRecord(&newprescribe)
2763
+				//记录日志
2764
+				byterequest, _ := json.Marshal(newprescribe)
2765
+				prescriptionLog := models.XtDialysisPrescriptionLog{
2766
+					UserOrgId:   newprescribe.UserOrgId,
2767
+					Ctime:       time.Now().Unix(),
2768
+					Mtime:       0,
2769
+					ErrLog:      string(byterequest),
2770
+					AdminUserId: adminUserInfo.AdminUser.Id,
2771
+					RecordDate:  newprescribe.RecordDate,
2772
+					PatientId:   newprescribe.PatientId,
2773
+					Source:      "手机端新增透前评估插入处方",
2774
+					Status:      1,
2775
+				}
2538 2776
 
2777
+				service.CreatePrescriptionLog(prescriptionLog)
2539 2778
 				//获取key,清空redis
2540 2779
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
2541 2780
 				redis := service.RedisClient()
@@ -2574,6 +2813,21 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
2574 2813
 					}
2575 2814
 				}
2576 2815
 				err := service.UpDateDialysisPrescription(&newprescribe)
2816
+				//记录日志
2817
+				byterequest, _ := json.Marshal(newprescribe)
2818
+				prescriptionLog := models.XtDialysisPrescriptionLog{
2819
+					UserOrgId:   newprescribe.UserOrgId,
2820
+					Ctime:       time.Now().Unix(),
2821
+					Mtime:       0,
2822
+					ErrLog:      string(byterequest),
2823
+					AdminUserId: adminUserInfo.AdminUser.Id,
2824
+					RecordDate:  newprescribe.RecordDate,
2825
+					PatientId:   newprescribe.PatientId,
2826
+					Source:      "手机端新增透前评估插入处方",
2827
+					Status:      1,
2828
+				}
2829
+
2830
+				service.CreatePrescriptionLog(prescriptionLog)
2577 2831
 				//获取key,清空redis
2578 2832
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
2579 2833
 				redis := service.RedisClient()
@@ -2662,6 +2916,22 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
2662 2916
 					}
2663 2917
 				}
2664 2918
 				err := service.UpDateDialysisPrescription(&newprescribe)
2919
+
2920
+				//记录日志
2921
+				byterequest, _ := json.Marshal(newprescribe)
2922
+				prescriptionLog := models.XtDialysisPrescriptionLog{
2923
+					UserOrgId:   newprescribe.UserOrgId,
2924
+					Ctime:       time.Now().Unix(),
2925
+					Mtime:       0,
2926
+					ErrLog:      string(byterequest),
2927
+					AdminUserId: adminUserInfo.AdminUser.Id,
2928
+					RecordDate:  newprescribe.RecordDate,
2929
+					PatientId:   newprescribe.PatientId,
2930
+					Source:      "手机端新增透前评估插入处方",
2931
+					Status:      1,
2932
+				}
2933
+
2934
+				service.CreatePrescriptionLog(prescriptionLog)
2665 2935
 				//获取key,清空redis
2666 2936
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
2667 2937
 				redis := service.RedisClient()
@@ -2720,7 +2990,7 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
2720 2990
 
2721 2991
 		if cha_time >= evaluation.AssessmentDate {
2722 2992
 			//查询审核是否允许
2723
-			infor, _ := service.GetDialysisInformationByRecordDate(id, evaluation.AssessmentDate, adminUserInfo.Org.Id)
2993
+			infor, _ := service.GetDialysisInformationByRecordDate(id, evaluation.AssessmentDate, adminUserInfo.Org.Id, 3)
2724 2994
 			//申请状态不允许的情况 拒绝修改
2725 2995
 			if infor.ApplicationStatus != 1 {
2726 2996
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -2731,6 +3001,23 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
2731 3001
 	}
2732 3002
 
2733 3003
 	err = service.UpadatePredialysisEvaluation(&evaluation)
3004
+
3005
+	//记录日志
3006
+	byterequest, _ := json.Marshal(evaluation)
3007
+	beforeDislysisLog := models.XtAssessmentBeforeDislysisLog{
3008
+
3009
+		UserOrgId:   evaluation.UserOrgId,
3010
+		AdminUserId: adminUserInfo.AdminUser.Id,
3011
+		ErrLog:      string(byterequest),
3012
+		PatientId:   evaluation.PatientId,
3013
+		RecordDate:  evaluation.AssessmentDate,
3014
+		Ctime:       time.Now().Unix(),
3015
+		Mtime:       0,
3016
+		Status:      1,
3017
+		Source:      "手机端保存透前评估",
3018
+	}
3019
+	service.CreateBeforLog(beforeDislysisLog)
3020
+
2734 3021
 	finish := models.XtDialysisFinish{
2735 3022
 		IsFinish:   1,
2736 3023
 		UserOrgId:  adminUserInfo.Org.Id,
@@ -4429,7 +4716,7 @@ func (c *PatientApiController) CreateGroupAdvice() {
4429 4716
 
4430 4717
 			if cha_time >= Startdate {
4431 4718
 				//查询审核是否允许
4432
-				infor, _ := service.GetDialysisInformationByRecordDate(patient, Startdate, adminUserInfo.Org.Id)
4719
+				infor, _ := service.GetDialysisInformationByRecordDate(patient, Startdate, adminUserInfo.Org.Id, 5)
4433 4720
 				//申请状态不允许的情况 拒绝修改
4434 4721
 				if infor.ApplicationStatus != 1 {
4435 4722
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -4440,6 +4727,25 @@ func (c *PatientApiController) CreateGroupAdvice() {
4440 4727
 		}
4441 4728
 
4442 4729
 		newAdvices, createErr := service.CreateMGroupAdvice(adminUserInfo.Org.Id, advices, group_no)
4730
+
4731
+		for _, item := range advices {
4732
+			//记录日志
4733
+			byterequest, _ := json.Marshal(item)
4734
+			adviceLog := models.XtDoctorAdviceLog{
4735
+				UserOrgId:   item.UserOrgId,
4736
+				PatientId:   item.PatientId,
4737
+				AdminUserId: adminUserInfo.AdminUser.Id,
4738
+				Module:      1,
4739
+				ErrLog:      string(byterequest),
4740
+				Status:      1,
4741
+				Ctime:       time.Now().Unix(),
4742
+				Mtime:       0,
4743
+				Source:      "手机端新增医嘱",
4744
+				RecordDate:  item.AdviceDate,
4745
+			}
4746
+			service.CreateDoctorAdviceLog(adviceLog)
4747
+		}
4748
+
4443 4749
 		finish := models.XtDialysisFinish{
4444 4750
 			IsFinish:   1,
4445 4751
 			UserOrgId:  adminUserInfo.Org.Id,
@@ -4556,7 +4862,7 @@ func (c *PatientApiController) CreateGroupAdvice() {
4556 4862
 
4557 4863
 			if cha_time >= advice.RecordDate {
4558 4864
 				//查询审核是否允许
4559
-				infor, _ := service.GetDialysisInformationByRecordDate(patient, advice.RecordDate, adminUserInfo.Org.Id)
4865
+				infor, _ := service.GetDialysisInformationByRecordDate(patient, advice.RecordDate, adminUserInfo.Org.Id, 4)
4560 4866
 				//申请状态不允许的情况 拒绝修改
4561 4867
 				if infor.ApplicationStatus != 1 {
4562 4868
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -4566,6 +4872,24 @@ func (c *PatientApiController) CreateGroupAdvice() {
4566 4872
 			}
4567 4873
 		}
4568 4874
 		err := service.CreateDoctorAdvice(&advice)
4875
+
4876
+		//记录日志
4877
+		byterequest, _ := json.Marshal(advice)
4878
+		adviceLog := models.XtDoctorAdviceLog{
4879
+			UserOrgId:   advice.UserOrgId,
4880
+			PatientId:   advice.PatientId,
4881
+			AdminUserId: adminUserInfo.Org.Id,
4882
+			Module:      1,
4883
+			ErrLog:      string(byterequest),
4884
+			Status:      1,
4885
+			Ctime:       time.Now().Unix(),
4886
+			Mtime:       0,
4887
+			Source:      "手机端新增医嘱",
4888
+			RecordDate:  advice.AdviceDate,
4889
+		}
4890
+
4891
+		service.CreateDoctorAdviceLog(adviceLog)
4892
+
4569 4893
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
4570 4894
 		redis := service.RedisClient()
4571 4895
 		//清空key 值
@@ -4718,7 +5042,7 @@ func (c *PatientApiController) DelDoctorAdvice() {
4718 5042
 
4719 5043
 			if cha_time >= advice.AdviceDate {
4720 5044
 				//查询审核是否允许
4721
-				infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advice.AdviceDate, adminUserInfo.Org.Id)
5045
+				infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advice.AdviceDate, adminUserInfo.Org.Id, 4)
4722 5046
 				//申请状态不允许的情况 拒绝修改
4723 5047
 				if infor.ApplicationStatus != 1 {
4724 5048
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -4728,6 +5052,22 @@ func (c *PatientApiController) DelDoctorAdvice() {
4728 5052
 			}
4729 5053
 		}
4730 5054
 		err := service.DeleteDoctorAdvice(&advice)
5055
+		//记录日志
5056
+		byterequest, _ := json.Marshal(advice)
5057
+		adviceLog := models.XtDoctorAdviceLog{
5058
+			UserOrgId:   advice.UserOrgId,
5059
+			PatientId:   advice.PatientId,
5060
+			AdminUserId: adminUserInfo.AdminUser.Id,
5061
+			Module:      4,
5062
+			ErrLog:      string(byterequest),
5063
+			Status:      1,
5064
+			Ctime:       time.Now().Unix(),
5065
+			Mtime:       0,
5066
+			Source:      "手机端删除医嘱",
5067
+			RecordDate:  advice.RecordDate,
5068
+		}
5069
+		service.CreateDoctorAdviceLog(adviceLog)
5070
+
4731 5071
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
4732 5072
 
4733 5073
 		redis.Set(key, "", time.Second)
@@ -4804,7 +5144,7 @@ func (c *PatientApiController) DelDoctorAdvice() {
4804 5144
 
4805 5145
 				if cha_time >= advice.AdviceDate {
4806 5146
 					//查询审核是否允许
4807
-					infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advice.AdviceDate, adminUserInfo.Org.Id)
5147
+					infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advice.AdviceDate, adminUserInfo.Org.Id, 4)
4808 5148
 					//申请状态不允许的情况 拒绝修改
4809 5149
 					if infor.ApplicationStatus != 1 {
4810 5150
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -4814,6 +5154,22 @@ func (c *PatientApiController) DelDoctorAdvice() {
4814 5154
 				}
4815 5155
 			}
4816 5156
 			err = service.DeleteDoctorAdviceByGroupNo(&advice)
5157
+			//记录日志
5158
+			byterequest, _ := json.Marshal(advice)
5159
+			adviceLog := models.XtDoctorAdviceLog{
5160
+				UserOrgId:   advice.UserOrgId,
5161
+				PatientId:   advice.PatientId,
5162
+				AdminUserId: adminUserInfo.AdminUser.Id,
5163
+				Module:      4,
5164
+				ErrLog:      string(byterequest),
5165
+				Status:      1,
5166
+				Ctime:       time.Now().Unix(),
5167
+				Mtime:       0,
5168
+				Source:      "手机端删除医嘱",
5169
+				RecordDate:  advice.RecordDate,
5170
+			}
5171
+			service.CreateDoctorAdviceLog(adviceLog)
5172
+
4817 5173
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
4818 5174
 
4819 5175
 			redis.Set(key, "", time.Second)
@@ -4839,7 +5195,7 @@ func (c *PatientApiController) DelDoctorAdvice() {
4839 5195
 
4840 5196
 				if cha_time >= advice.AdviceDate {
4841 5197
 					//查询审核是否允许
4842
-					infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advice.AdviceDate, adminUserInfo.Org.Id)
5198
+					infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advice.AdviceDate, adminUserInfo.Org.Id, 4)
4843 5199
 					//申请状态不允许的情况 拒绝修改
4844 5200
 					if infor.ApplicationStatus != 1 {
4845 5201
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -4849,6 +5205,27 @@ func (c *PatientApiController) DelDoctorAdvice() {
4849 5205
 				}
4850 5206
 			}
4851 5207
 			err = service.BatchDeleteDoctorAdvice(ids, adminUserInfo.AdminUser.Id)
5208
+
5209
+			advicelist, _ := service.GetBatchDoctorAdviceList(ids, adminUserInfo.Org.Id)
5210
+
5211
+			for _, item := range advicelist {
5212
+				//记录日志
5213
+				byterequest, _ := json.Marshal(item)
5214
+				adviceLog := models.XtDoctorAdviceLog{
5215
+					UserOrgId:   item.UserOrgId,
5216
+					PatientId:   item.PatientId,
5217
+					AdminUserId: adminUserInfo.AdminUser.Id,
5218
+					Module:      4,
5219
+					ErrLog:      string(byterequest),
5220
+					Status:      1,
5221
+					Ctime:       time.Now().Unix(),
5222
+					Mtime:       0,
5223
+					Source:      "手机端批量删除医嘱",
5224
+					RecordDate:  item.RecordDate,
5225
+				}
5226
+				service.CreateDoctorAdviceLog(adviceLog)
5227
+			}
5228
+
4852 5229
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
4853 5230
 
4854 5231
 			redis.Set(key, "", time.Second)
@@ -5064,7 +5441,7 @@ func (c *PatientApiController) ExecProject() {
5064 5441
 
5065 5442
 			if cha_time >= project.RecordDate {
5066 5443
 				//查询审核是否允许
5067
-				infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId)
5444
+				infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId, 4)
5068 5445
 				//申请状态不允许的情况 拒绝修改
5069 5446
 				if infor.ApplicationStatus != 1 {
5070 5447
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -5100,7 +5477,7 @@ func (c *PatientApiController) ExecProject() {
5100 5477
 
5101 5478
 				if cha_time >= project.RecordDate {
5102 5479
 					//查询审核是否允许
5103
-					infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId)
5480
+					infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId, 4)
5104 5481
 					//申请状态不允许的情况 拒绝修改
5105 5482
 					if infor.ApplicationStatus != 1 {
5106 5483
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -5135,7 +5512,7 @@ func (c *PatientApiController) ExecProject() {
5135 5512
 
5136 5513
 				if cha_time >= project.RecordDate {
5137 5514
 					//查询审核是否允许
5138
-					infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId)
5515
+					infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId, 4)
5139 5516
 					//申请状态不允许的情况 拒绝修改
5140 5517
 					if infor.ApplicationStatus != 1 {
5141 5518
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -5200,7 +5577,7 @@ func (c *PatientApiController) CheckProject() {
5200 5577
 
5201 5578
 			if cha_time >= project.RecordDate {
5202 5579
 				//查询审核是否允许
5203
-				infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId)
5580
+				infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId, 4)
5204 5581
 				//申请状态不允许的情况 拒绝修改
5205 5582
 				if infor.ApplicationStatus != 1 {
5206 5583
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -5239,7 +5616,7 @@ func (c *PatientApiController) CheckProject() {
5239 5616
 
5240 5617
 				if cha_time >= project.RecordDate {
5241 5618
 					//查询审核是否允许
5242
-					infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId)
5619
+					infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId, 4)
5243 5620
 					//申请状态不允许的情况 拒绝修改
5244 5621
 					if infor.ApplicationStatus != 1 {
5245 5622
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -5277,7 +5654,7 @@ func (c *PatientApiController) CheckProject() {
5277 5654
 
5278 5655
 				if cha_time >= project.RecordDate {
5279 5656
 					//查询审核是否允许
5280
-					infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId)
5657
+					infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId, 4)
5281 5658
 					//申请状态不允许的情况 拒绝修改
5282 5659
 					if infor.ApplicationStatus != 1 {
5283 5660
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)

+ 185 - 9
controllers/patient_api_controller.go View File

@@ -1398,7 +1398,7 @@ func (c *PatientApiController) CreateGroupAdvice() {
1398 1398
 
1399 1399
 			if cha_time >= advice.AdviceDate {
1400 1400
 				//查询审核是否允许
1401
-				infor, _ := service.GetDialysisInformationByRecordDate(patient, advice.AdviceDate, adminUserInfo.CurrentOrgId)
1401
+				infor, _ := service.GetDialysisInformationByRecordDate(patient, advice.AdviceDate, adminUserInfo.CurrentOrgId, 4)
1402 1402
 				//申请状态不允许的情况 拒绝修改
1403 1403
 				if infor.ApplicationStatus != 1 {
1404 1404
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -1669,6 +1669,25 @@ func (c *PatientApiController) CreateGroupAdvice() {
1669 1669
 	}
1670 1670
 
1671 1671
 	list, err := service.CreateMGroupAdvice(adminUserInfo.CurrentOrgId, advices, groupNo)
1672
+
1673
+	for _, item := range advices {
1674
+		//记录日志
1675
+		byterequest, _ := json.Marshal(item)
1676
+		adviceLog := models.XtDoctorAdviceLog{
1677
+			UserOrgId:   item.UserOrgId,
1678
+			PatientId:   item.PatientId,
1679
+			AdminUserId: adminUserInfo.AdminUser.Id,
1680
+			Module:      1,
1681
+			ErrLog:      string(byterequest),
1682
+			Status:      1,
1683
+			Ctime:       time.Now().Unix(),
1684
+			Mtime:       0,
1685
+			Source:      "电导端批量插入医嘱",
1686
+			RecordDate:  item.AdviceDate,
1687
+		}
1688
+		service.CreateDoctorAdviceLog(adviceLog)
1689
+	}
1690
+
1672 1691
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":doctor_advices"
1673 1692
 
1674 1693
 	redis := service.RedisClient()
@@ -1772,7 +1791,7 @@ func (c *PatientApiController) CreateDoctorAdvice() {
1772 1791
 
1773 1792
 		if cha_time >= advice.AdviceDate {
1774 1793
 			//查询审核是否允许
1775
-			infor, _ := service.GetDialysisInformationByRecordDate(patient, advice.AdviceDate, adminUserInfo.CurrentOrgId)
1794
+			infor, _ := service.GetDialysisInformationByRecordDate(patient, advice.AdviceDate, adminUserInfo.CurrentOrgId, 4)
1776 1795
 			//申请状态不允许的情况 拒绝修改
1777 1796
 			if infor.ApplicationStatus != 1 {
1778 1797
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -1796,6 +1815,24 @@ func (c *PatientApiController) CreateDoctorAdvice() {
1796 1815
 		}
1797 1816
 	}
1798 1817
 	err := service.CreateDoctorAdvice(&advice)
1818
+
1819
+	//记录日志
1820
+	byterequest, _ := json.Marshal(advice)
1821
+	adviceLog := models.XtDoctorAdviceLog{
1822
+		UserOrgId:   advice.UserOrgId,
1823
+		PatientId:   advice.PatientId,
1824
+		AdminUserId: adminUserInfo.AdminUser.Id,
1825
+		Module:      1,
1826
+		ErrLog:      string(byterequest),
1827
+		Status:      1,
1828
+		Ctime:       time.Now().Unix(),
1829
+		Mtime:       0,
1830
+		Source:      "电脑新增医嘱",
1831
+		RecordDate:  advice.RecordDate,
1832
+	}
1833
+
1834
+	service.CreateDoctorAdviceLog(adviceLog)
1835
+
1799 1836
 	//创建步骤表
1800 1837
 	finish := models.XtDialysisFinish{
1801 1838
 		IsFinish:   1,
@@ -2108,7 +2145,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2108 2145
 
2109 2146
 			if cha_time >= advice.AdviceDate {
2110 2147
 				//查询审核是否允许
2111
-				infor, _ := service.GetDialysisInformationByRecordDate(patient, advice.AdviceDate, adminUserInfo.CurrentOrgId)
2148
+				infor, _ := service.GetDialysisInformationByRecordDate(patient, advice.AdviceDate, adminUserInfo.CurrentOrgId, 4)
2112 2149
 				//申请状态不允许的情况 拒绝修改
2113 2150
 				if infor.ApplicationStatus != 1 {
2114 2151
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -2119,6 +2156,21 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2119 2156
 		}
2120 2157
 		if advice.ParentId > 0 {
2121 2158
 			err = service.ExceDoctorAdviceById(&exceAdvice, advice.ParentId, patient)
2159
+			//记录日志
2160
+			byterequest, _ := json.Marshal(exceAdvice)
2161
+			doctorAdviceLog := models.XtDoctorAdviceLog{
2162
+				UserOrgId:   exceAdvice.UserOrgId,
2163
+				PatientId:   exceAdvice.PatientId,
2164
+				AdminUserId: adminUserInfo.AdminUser.Id,
2165
+				Module:      2,
2166
+				ErrLog:      string(byterequest),
2167
+				Status:      1,
2168
+				Ctime:       time.Now().Unix(),
2169
+				Mtime:       0,
2170
+				Source:      "电脑端执行医嘱",
2171
+				RecordDate:  exceAdvice.RecordDate,
2172
+			}
2173
+			service.CreateDoctorAdviceLog(doctorAdviceLog)
2122 2174
 			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
2123 2175
 			redis := service.RedisClient()
2124 2176
 			//清空key 值
@@ -2140,6 +2192,21 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2140 2192
 			defer redis.Close()
2141 2193
 		} else {
2142 2194
 			err = service.ExceDoctorAdviceById(&exceAdvice, id, patient)
2195
+			//记录日志
2196
+			byterequest, _ := json.Marshal(exceAdvice)
2197
+			doctorAdviceLog := models.XtDoctorAdviceLog{
2198
+				UserOrgId:   exceAdvice.UserOrgId,
2199
+				PatientId:   exceAdvice.PatientId,
2200
+				AdminUserId: adminUserInfo.AdminUser.Id,
2201
+				Module:      2,
2202
+				ErrLog:      string(byterequest),
2203
+				Status:      1,
2204
+				Ctime:       time.Now().Unix(),
2205
+				Mtime:       0,
2206
+				Source:      "电脑端执行医嘱",
2207
+				RecordDate:  exceAdvice.RecordDate,
2208
+			}
2209
+			service.CreateDoctorAdviceLog(doctorAdviceLog)
2143 2210
 			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
2144 2211
 			redis := service.RedisClient()
2145 2212
 			//清空key 值
@@ -2462,6 +2529,21 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2462 2529
 		}
2463 2530
 		if advice.ParentId > 0 {
2464 2531
 			err = service.ExceHidDoctorAdviceById(&exceAdvice, advice.ParentId, patient)
2532
+			//记录日志
2533
+			byterequest, _ := json.Marshal(exceAdvice)
2534
+			doctorAdviceLog := models.XtDoctorAdviceLog{
2535
+				UserOrgId:   exceAdvice.UserOrgId,
2536
+				PatientId:   exceAdvice.PatientId,
2537
+				AdminUserId: adminUserInfo.AdminUser.Id,
2538
+				Module:      2,
2539
+				ErrLog:      string(byterequest),
2540
+				Status:      1,
2541
+				Ctime:       time.Now().Unix(),
2542
+				Mtime:       0,
2543
+				Source:      "电脑端执行His医嘱",
2544
+				RecordDate:  exceAdvice.RecordDate,
2545
+			}
2546
+			service.CreateDoctorAdviceLog(doctorAdviceLog)
2465 2547
 			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
2466 2548
 			redis := service.RedisClient()
2467 2549
 			//清空key 值
@@ -2482,6 +2564,21 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2482 2564
 			defer redis.Close()
2483 2565
 		} else {
2484 2566
 			err = service.ExceHidDoctorAdviceById(&exceAdvice, id, patient)
2567
+			//记录日志
2568
+			byterequest, _ := json.Marshal(exceAdvice)
2569
+			doctorAdviceLog := models.XtDoctorAdviceLog{
2570
+				UserOrgId:   exceAdvice.UserOrgId,
2571
+				PatientId:   exceAdvice.PatientId,
2572
+				AdminUserId: adminUserInfo.AdminUser.Id,
2573
+				Module:      2,
2574
+				ErrLog:      string(byterequest),
2575
+				Status:      1,
2576
+				Ctime:       time.Now().Unix(),
2577
+				Mtime:       0,
2578
+				Source:      "电脑端执行His医嘱",
2579
+				RecordDate:  exceAdvice.RecordDate,
2580
+			}
2581
+			service.CreateDoctorAdviceLog(doctorAdviceLog)
2485 2582
 			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
2486 2583
 			redis := service.RedisClient()
2487 2584
 			//清空key 值
@@ -2898,7 +2995,7 @@ func (c *PatientApiController) CheckDoctorAdvice() {
2898 2995
 
2899 2996
 			if cha_time >= advice.AdviceDate {
2900 2997
 				//查询审核是否允许
2901
-				infor, _ := service.GetDialysisInformationByRecordDate(patient, advice.AdviceDate, adminUserInfo.CurrentOrgId)
2998
+				infor, _ := service.GetDialysisInformationByRecordDate(patient, advice.AdviceDate, adminUserInfo.CurrentOrgId, 4)
2902 2999
 				//申请状态不允许的情况 拒绝修改
2903 3000
 				if infor.ApplicationStatus != 1 {
2904 3001
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -2909,6 +3006,23 @@ func (c *PatientApiController) CheckDoctorAdvice() {
2909 3006
 		}
2910 3007
 		if advice.ParentId > 0 {
2911 3008
 			err = service.CheckDoctorAdviceById(&exceAdvice, advice.ParentId, patient)
3009
+			//记录日志
3010
+			byterequest, _ := json.Marshal(exceAdvice)
3011
+			adviceLog := models.XtDoctorAdviceLog{
3012
+				UserOrgId:   exceAdvice.UserOrgId,
3013
+				PatientId:   exceAdvice.PatientId,
3014
+				AdminUserId: adminUserInfo.AdminUser.Id,
3015
+				Module:      3,
3016
+				ErrLog:      string(byterequest),
3017
+				Status:      1,
3018
+				Ctime:       time.Now().Unix(),
3019
+				Mtime:       0,
3020
+				Source:      "核对医嘱",
3021
+				RecordDate:  exceAdvice.AdviceDate,
3022
+			}
3023
+
3024
+			service.CreateDoctorAdviceLog(adviceLog)
3025
+
2912 3026
 			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
2913 3027
 			redis := service.RedisClient()
2914 3028
 			//清空key 值
@@ -2925,6 +3039,22 @@ func (c *PatientApiController) CheckDoctorAdvice() {
2925 3039
 			redis.Set(keyFive, "", time.Second)
2926 3040
 		} else {
2927 3041
 			err = service.CheckDoctorAdviceById(&exceAdvice, id, patient)
3042
+			//记录日志
3043
+			byterequest, _ := json.Marshal(exceAdvice)
3044
+			adviceLog := models.XtDoctorAdviceLog{
3045
+				UserOrgId:   exceAdvice.UserOrgId,
3046
+				PatientId:   exceAdvice.PatientId,
3047
+				AdminUserId: adminUserInfo.AdminUser.Id,
3048
+				Module:      3,
3049
+				ErrLog:      string(byterequest),
3050
+				Status:      1,
3051
+				Ctime:       time.Now().Unix(),
3052
+				Mtime:       0,
3053
+				Source:      "核对医嘱",
3054
+				RecordDate:  exceAdvice.AdviceDate,
3055
+			}
3056
+
3057
+			service.CreateDoctorAdviceLog(adviceLog)
2928 3058
 			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
2929 3059
 			redis := service.RedisClient()
2930 3060
 			//清空key 值
@@ -3113,7 +3243,7 @@ func (c *PatientApiController) UpdateDoctorAdvice() {
3113 3243
 
3114 3244
 		if cha_time >= advice.AdviceDate {
3115 3245
 			//查询审核是否允许
3116
-			infor, _ := service.GetDialysisInformationByRecordDate(patient, advice.AdviceDate, adminUserInfo.CurrentOrgId)
3246
+			infor, _ := service.GetDialysisInformationByRecordDate(patient, advice.AdviceDate, adminUserInfo.CurrentOrgId, 4)
3117 3247
 			//申请状态不允许的情况 拒绝修改
3118 3248
 			if infor.ApplicationStatus != 1 {
3119 3249
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -3124,15 +3254,30 @@ func (c *PatientApiController) UpdateDoctorAdvice() {
3124 3254
 	}
3125 3255
 
3126 3256
 	err := service.UpdateDoctorAdvice(&advice)
3257
+
3258
+	//记录日志
3259
+	byterequest, _ := json.Marshal(advice)
3260
+	doctorAdviceLog := models.XtDoctorAdviceLog{
3261
+		UserOrgId:   advice.UserOrgId,
3262
+		PatientId:   advice.PatientId,
3263
+		AdminUserId: adminUserInfo.AdminUser.Id,
3264
+		Module:      1,
3265
+		ErrLog:      string(byterequest),
3266
+		Status:      1,
3267
+		Ctime:       time.Now().Unix(),
3268
+		Mtime:       0,
3269
+		Source:      "电脑端修改医嘱",
3270
+		RecordDate:  advice.AdviceDate,
3271
+	}
3272
+	service.CreateDoctorAdviceLog(doctorAdviceLog)
3127 3273
 	redis := service.RedisClient()
3128 3274
 
3129 3275
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
3130 3276
 
3131 3277
 	redis.Set(key, "", time.Second)
3132
-	fmt.Println("key2332233232322332", key)
3278
+
3133 3279
 	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
3134 3280
 	redis.Set(keyOne, "", time.Second)
3135
-	fmt.Println("key3333333333333333", keyOne)
3136 3281
 	defer redis.Close()
3137 3282
 	if err != nil {
3138 3283
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
@@ -3350,7 +3495,7 @@ func (c *PatientApiController) DeleteDoctorAdvice() {
3350 3495
 
3351 3496
 		if cha_time >= advice.AdviceDate {
3352 3497
 			//查询审核是否允许
3353
-			infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advice.AdviceDate, adminUserInfo.CurrentOrgId)
3498
+			infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advice.AdviceDate, adminUserInfo.CurrentOrgId, 4)
3354 3499
 			//申请状态不允许的情况 拒绝修改
3355 3500
 			if infor.ApplicationStatus != 1 {
3356 3501
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -3360,6 +3505,22 @@ func (c *PatientApiController) DeleteDoctorAdvice() {
3360 3505
 		}
3361 3506
 	}
3362 3507
 	err := service.DeleteDoctorAdvice(&advice)
3508
+
3509
+	//记录日志
3510
+	byterequest, _ := json.Marshal(advice)
3511
+	doctorAdviceLog := models.XtDoctorAdviceLog{
3512
+		UserOrgId:   advice.UserOrgId,
3513
+		PatientId:   advice.PatientId,
3514
+		AdminUserId: adminUserInfo.AdminUser.Id,
3515
+		Module:      4,
3516
+		ErrLog:      string(byterequest),
3517
+		Status:      1,
3518
+		Ctime:       time.Now().Unix(),
3519
+		Mtime:       0,
3520
+		Source:      "电脑端删除医嘱",
3521
+		RecordDate:  advice.RecordDate,
3522
+	}
3523
+	service.CreateDoctorAdviceLog(doctorAdviceLog)
3363 3524
 	redis := service.RedisClient()
3364 3525
 	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
3365 3526
 
@@ -3421,7 +3582,7 @@ func (c *PatientApiController) DeleteGroupAdvice() {
3421 3582
 
3422 3583
 		if cha_time >= advice.AdviceDate {
3423 3584
 			//查询审核是否允许
3424
-			infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advice.AdviceDate, adminUserInfo.CurrentOrgId)
3585
+			infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advice.AdviceDate, adminUserInfo.CurrentOrgId, 4)
3425 3586
 			//申请状态不允许的情况 拒绝修改
3426 3587
 			if infor.ApplicationStatus != 1 {
3427 3588
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
@@ -3433,6 +3594,21 @@ func (c *PatientApiController) DeleteGroupAdvice() {
3433 3594
 
3434 3595
 	err := service.DeleteGroupAdvice(adminUserInfo.CurrentOrgId, groupNo, adminUserInfo.AdminUser.Id)
3435 3596
 
3597
+	byterequest, _ := json.Marshal(advice)
3598
+	doctorAdviceLog := models.XtDoctorAdviceLog{
3599
+		UserOrgId:   advice.UserOrgId,
3600
+		PatientId:   advice.PatientId,
3601
+		AdminUserId: adminUserInfo.AdminUser.Id,
3602
+		Module:      4,
3603
+		ErrLog:      string(byterequest),
3604
+		Status:      1,
3605
+		Ctime:       time.Now().Unix(),
3606
+		Mtime:       0,
3607
+		Source:      "电脑端批量删除医嘱",
3608
+		RecordDate:  advice.RecordDate,
3609
+	}
3610
+	service.CreateDoctorAdviceLog(doctorAdviceLog)
3611
+
3436 3612
 	key := strconv.FormatInt(advice.UserOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
3437 3613
 	redis := service.RedisClient()
3438 3614
 

+ 313 - 47
controllers/sign_api_controller.go View File

@@ -6,6 +6,8 @@ import (
6 6
 	"encoding/json"
7 7
 	"fmt"
8 8
 	"github.com/astaxie/beego"
9
+	"github.com/jung-kurt/gofpdf"
10
+	"time"
9 11
 )
10 12
 
11 13
 type SignApiController struct {
@@ -41,11 +43,35 @@ func SignApiRegistRouters() {
41 43
 	//后台签署(返回签署文件)
42 44
 	beego.Router("/api/sign/createbackstagesign", &SignApiController{}, "Get:CreateBackStageSign")
43 45
 
44
-	//创建企业印章并添加授权用户
46
+	//署意愿认证-短信验证
45 47
 	beego.Router("/api/sign/totestelment", &SignApiController{}, "Get:CreateEnterprise")
46 48
 
47 49
 	//测试PDF
48 50
 	beego.Router("/api/sign/totestthrityment", &SignApiController{}, "Get:GetTestThrityMent")
51
+
52
+	//CA企业认证
53
+	beego.Router("/api/sign/saveenerprise", &SignApiController{}, "Post:SaveEnerprise")
54
+
55
+	//
56
+	beego.Router("/api/sign/getenerprisebyid", &SignApiController{}, "Get:GetEnerPriseById")
57
+
58
+	beego.Router("/api/sign/getmobilecode", &SignApiController{}, "Get:GetMobileCode")
59
+
60
+	beego.Router("/api/sign/getpersionenterprise", &SignApiController{}, "Post:GetPersionEnterPrise")
61
+
62
+	beego.Router("/api/sign/getpersenterprisebyid", &SignApiController{}, "Get:GetPerseEnterPriseById")
63
+
64
+	beego.Router("/api/device/sign/creterpersionseal", &SignApiController{}, "Get:CreateNewPersionSeal")
65
+
66
+	beego.Router("/api/device/sign/createnewenterprise", &SignApiController{}, "Get:CreateNewEnterPrise")
67
+
68
+	beego.Router("/api/device/contractid", &SignApiController{}, "Get:GetContractId")
69
+
70
+	beego.Router("/api/device/endenterprise", &SignApiController{}, "Get:EndEnterPrise")
71
+
72
+	beego.Router("/api/device/getenterprisedetail", &SignApiController{}, "Get:GetEnterPriseDetail")
73
+
74
+	beego.Router("/api/device/uploadprintorder", &SignApiController{}, "Post:UploadPrintOrder")
49 75
 }
50 76
 
51 77
 // 短信服务接口
@@ -236,54 +262,9 @@ func (this *SignApiController) CreateBackStageSign() {
236 262
 
237 263
 	signers := this.GetString("signers")
238 264
 	sign := service.CreateBackStageSign(contractId, signers)
239
-	sealTimestampFiles := make(map[string]interface{})
240
-	inputDataArr := make([]map[string]interface{}, 0)
241
-	signFiles := make(map[string]interface{})
242
-
243
-	keywordSignControls := make(map[string]interface{})
244
-	keywordSignControls["controlsKey"] = "2"
245
-	keywordSignControls["pattern"] = 1
246
-	keywordSignControls["color"] = "#FF0000"
247
-	inputDataArr = append(inputDataArr, keywordSignControls)
248
-
249
-	sealTimestampFiles["allAddTimestamp"] = false
250
-	sealTimestampFiles["someTimestampStyle"] = inputDataArr
251
-
252
-	inputDataArrOne := make([]map[string]interface{}, 0)
253
-
254
-	keySignControls := make(map[string]interface{})
255
-	keySignControls["controlsKey"] = "1"
256
-	keySignControls["fontType"] = 1
257
-	keySignControls["fontSize"] = 8.5
258
-	keySignControls["fontColor"] = "#56600F"
259
-	keySignControls["alignment"] = 1
260
-	inputDataArrOne = append(inputDataArrOne, keySignControls)
261
-
262
-	signFiles["fonts"] = inputDataArrOne
263
-	signFiles["showTimestamp"] = false
264
-	signFiles["sealTimestamp"] = sealTimestampFiles
265
-	signControl := make(map[string]interface{})
266
-	signControl["1"] = "123456"
267
-	signFiles["signControl"] = signControl
268
-	signFiles["docId"] = "156190809375377646"
269
-	inputDataArrThree := make([]map[string]interface{}, 0)
270
-	inputDataArrThree = append(inputDataArrThree, signFiles)
271
-
272
-	signer := make(map[string]interface{})
273
-
274
-	signer["signerId"] = "156002269974758623"
275
-	signer["isUserWishes"] = true
276
-	signer["userWishesWay"] = 1
277
-	signer["codeNumber"] = "msg202308111444501897422"
278
-	signer["verifyCode"] = "978176"
279
-	signer["signFiles"] = inputDataArrThree
280
-	maprequest := make(map[string]interface{})
281
-	maprequest["contractId"] = "156190809375377645"
282
-	maprequest["signer"] = signer
283 265
 
284 266
 	this.ServeSuccessJSON(map[string]interface{}{
285
-		"sign":       sign,
286
-		"maprequest": maprequest,
267
+		"sign": sign,
287 268
 	})
288 269
 	return
289 270
 }
@@ -305,3 +286,288 @@ func (this *SignApiController) CreateEnterprise() {
305 286
 	})
306 287
 	return
307 288
 }
289
+
290
+func (this *SignApiController) GetTestThrityMent() {
291
+
292
+	pdf := gofpdf.New("P", "mm", "A4", "")
293
+	pdf.AddPage()
294
+	pdf.SetFont("Arial", "B", 16)
295
+	pdf.Cell(40, 10, "Hello, World!")
296
+	pdf.OutputFileAndClose("output.pdf")
297
+
298
+	this.ServeSuccessJSON(map[string]interface{}{
299
+		"sign": "msg",
300
+	})
301
+	return
302
+}
303
+
304
+func loremList() []string {
305
+	return []string{
306
+		"我爱你中国" +
307
+			"tempor incididunt ut labore et dolore magna aliqua.",
308
+		"Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " +
309
+			"aliquip ex ea commodo consequat.",
310
+		"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum " +
311
+			"dolore eu fugiat nulla pariatur.",
312
+		"Excepteur sint occaecat cupidatat non proident, sunt in culpa qui " +
313
+			"officia deserunt mollit anim id est laborum.",
314
+	}
315
+}
316
+
317
+func (this *SignApiController) SaveEnerprise() {
318
+
319
+	orgId := this.GetAdminUserInfo().CurrentOrgId
320
+
321
+	creater := this.GetAdminUserInfo().AdminUser.Id
322
+	dataBody := make(map[string]interface{}, 0)
323
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
324
+	fmt.Println("err", err)
325
+
326
+	id := int64(dataBody["id"].(float64))
327
+	org_type := int64(dataBody["org_type"].(float64))
328
+
329
+	enterprise_name := dataBody["enterprise_name"].(string)
330
+
331
+	code := dataBody["code"].(string)
332
+
333
+	org_code := dataBody["org_code"].(string)
334
+
335
+	legal_person_name := dataBody["legal_person_name"].(string)
336
+
337
+	legal_id_card_num := dataBody["legal_id_card_num"].(string)
338
+
339
+	legal_phone := dataBody["legal_phone"].(string)
340
+
341
+	enterprise := models.XtDeviceEnterprise{
342
+		ID:              id,
343
+		UserOrgId:       orgId,
344
+		OrgType:         org_type,
345
+		EnterpriseName:  enterprise_name,
346
+		Code:            code,
347
+		OrgCode:         org_code,
348
+		LegalPersonName: legal_person_name,
349
+		LegalIdCardNum:  legal_id_card_num,
350
+		LegalPhone:      legal_phone,
351
+		Creater:         creater,
352
+		Ctime:           time.Now().Unix(),
353
+		Mtime:           0,
354
+		Enterpriseid:    "",
355
+		Status:          1,
356
+	}
357
+	service.SaveEnerPrise(enterprise)
358
+
359
+	//查找该机构有没有认证信息
360
+	lastenterprise, _ := service.GetEnterPriseByUserOrgId(orgId)
361
+
362
+	//调用企业认证接口
363
+	if lastenterprise.ID > 0 {
364
+		enterPrise, enterpriseid := service.CreateNewEnterPriseRealName(lastenterprise)
365
+		fmt.Println("enterprise2ooo2oo2o2o2o", enterPrise)
366
+		updateEnterprise := models.XtDeviceEnterprise{
367
+			ID:              enterprise.ID,
368
+			UserOrgId:       orgId,
369
+			OrgType:         org_type,
370
+			EnterpriseName:  enterprise_name,
371
+			Code:            code,
372
+			OrgCode:         org_code,
373
+			LegalPersonName: legal_person_name,
374
+			LegalIdCardNum:  legal_id_card_num,
375
+			LegalPhone:      legal_phone,
376
+			Creater:         creater,
377
+			Ctime:           time.Now().Unix(),
378
+			Mtime:           0,
379
+			Enterpriseid:    enterpriseid,
380
+			Status:          1,
381
+		}
382
+		service.SaveEnerPrise(updateEnterprise)
383
+		this.ServeSuccessJSON(map[string]interface{}{
384
+			"enterPrise": enterPrise,
385
+		})
386
+		return
387
+	}
388
+}
389
+
390
+func (this *SignApiController) GetEnerPriseById() {
391
+
392
+	orgId := this.GetAdminUserInfo().CurrentOrgId
393
+
394
+	enterPrise, _ := service.GetEnterPriseByUserOrgId(orgId)
395
+
396
+	this.ServeSuccessJSON(map[string]interface{}{
397
+		"enterPrise": enterPrise,
398
+	})
399
+	return
400
+}
401
+
402
+func (this *SignApiController) GetMobileCode() {
403
+
404
+	phone := this.GetString("phone")
405
+
406
+	sign, orderNumber := service.GetNewSignNameByPhone(phone)
407
+
408
+	this.ServeSuccessJSON(map[string]interface{}{
409
+		"sign":        sign,
410
+		"orderNumber": orderNumber,
411
+	})
412
+	return
413
+}
414
+
415
+func (this *SignApiController) GetPersionEnterPrise() {
416
+
417
+	orgId := this.GetAdminUserInfo().CurrentOrgId
418
+
419
+	creater := this.GetAdminUserInfo().AdminUser.Id
420
+	dataBody := make(map[string]interface{}, 0)
421
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
422
+	fmt.Println("err", err)
423
+
424
+	id := int64(dataBody["id"].(float64))
425
+	admin_user_id := int64(dataBody["admin_user_id"].(float64))
426
+
427
+	code := dataBody["code"].(string)
428
+
429
+	display_name := dataBody["display_name"].(string)
430
+
431
+	id_card_num := dataBody["id_card_num"].(string)
432
+
433
+	phone := dataBody["phone"].(string)
434
+
435
+	enterprise := models.XtDevicePersonEnterprise{
436
+		ID:          id,
437
+		AdminUserId: admin_user_id,
438
+		DisplayName: display_name,
439
+		Phone:       phone,
440
+		IdCardNum:   id_card_num,
441
+		UserOrgId:   orgId,
442
+		Status:      1,
443
+		Creater:     creater,
444
+		Ctime:       time.Now().Unix(),
445
+		Mtime:       0,
446
+		UserId:      "",
447
+	}
448
+
449
+	service.SavePersonEnterPrise(enterprise)
450
+
451
+	lastEnterPrise, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId)
452
+
453
+	_, orderNumber := service.GetNewSignNameByPhone(phone)
454
+
455
+	personEnterPrse, UserId := service.CreateNewUserName(lastEnterPrise.Phone, lastEnterPrise.DisplayName, code, orderNumber, lastEnterPrise.IdCardNum)
456
+
457
+	firstenterprise := models.XtDevicePersonEnterprise{
458
+		ID:          id,
459
+		AdminUserId: admin_user_id,
460
+		DisplayName: display_name,
461
+		Phone:       phone,
462
+		IdCardNum:   id_card_num,
463
+		UserOrgId:   orgId,
464
+		Status:      1,
465
+		Creater:     creater,
466
+		Ctime:       time.Now().Unix(),
467
+		Mtime:       0,
468
+		UserId:      UserId,
469
+	}
470
+
471
+	service.SavePersonEnterPrise(firstenterprise)
472
+
473
+	this.ServeSuccessJSON(map[string]interface{}{
474
+		"personEnterPrse": personEnterPrse,
475
+	})
476
+	return
477
+}
478
+
479
+func (this *SignApiController) GetPerseEnterPriseById() {
480
+
481
+	orgId := this.GetAdminUserInfo().CurrentOrgId
482
+
483
+	admin_user_id, _ := this.GetInt64("admin_user_id")
484
+
485
+	lastPerson, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId)
486
+
487
+	this.ServeSuccessJSON(map[string]interface{}{
488
+		"lastPerson": lastPerson,
489
+	})
490
+	return
491
+}
492
+
493
+func (this *SignApiController) CreateNewPersionSeal() {
494
+
495
+	orgId := this.GetAdminUserInfo().CurrentOrgId
496
+
497
+	admin_user_id, _ := this.GetInt64("admin_user_id")
498
+
499
+	lastPerson, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId)
500
+
501
+	personSeal, personSealId := service.CreateNewPersionSeal(lastPerson.UserId)
502
+
503
+	service.UpdatePerseEnterPriseById(lastPerson.ID, personSealId)
504
+	this.ServeSuccessJSON(map[string]interface{}{
505
+		"personSeal": personSeal,
506
+	})
507
+	return
508
+
509
+}
510
+
511
+func (this *SignApiController) CreateNewEnterPrise() {
512
+
513
+	orgId := this.GetAdminUserInfo().CurrentOrgId
514
+
515
+	admin_user_id, _ := this.GetInt64("admin_user_id")
516
+
517
+	enterPrise, _ := service.GetEnterPriseByUserOrgId(orgId)
518
+	fmt.Println("地址日活", enterPrise.Enterpriseid)
519
+	lastPerson, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId)
520
+
521
+	newEnterPrise, sealId := service.CreateNewEnterPrise(enterPrise.Enterpriseid, lastPerson.UserId)
522
+
523
+	service.UpdatePersonEnterPrise(lastPerson.ID, sealId)
524
+
525
+	this.ServeSuccessJSON(map[string]interface{}{
526
+		"newEnterPrise": newEnterPrise,
527
+	})
528
+	return
529
+
530
+}
531
+
532
+func (this *SignApiController) GetContractId() {
533
+
534
+	sign := service.GetContractId()
535
+	this.ServeSuccessJSON(map[string]interface{}{
536
+		"sign": sign,
537
+	})
538
+	return
539
+}
540
+
541
+func (this *SignApiController) EndEnterPrise() {
542
+
543
+	sign := service.EndEnterPrise()
544
+
545
+	this.ServeSuccessJSON(map[string]interface{}{
546
+		"sign": sign,
547
+	})
548
+	return
549
+}
550
+
551
+func (this *SignApiController) GetEnterPriseDetail() {
552
+
553
+	sign, url := service.GetEnterPriseDetail()
554
+	this.ServeSuccessJSON(map[string]interface{}{
555
+		"sign": sign,
556
+		"url":  url,
557
+	})
558
+	return
559
+}
560
+
561
+func (this *SignApiController) UploadPrintOrder() {
562
+
563
+	dataBody := make(map[string]interface{}, 0)
564
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
565
+	fmt.Println("err", err)
566
+	name := dataBody["name"].(string)
567
+
568
+	sign := service.CreateNewUploadPact(name)
569
+	this.ServeSuccessJSON(map[string]interface{}{
570
+		"sign": sign,
571
+	})
572
+
573
+}

+ 4 - 0
go.mod View File

@@ -15,9 +15,11 @@ require (
15 15
 	github.com/beorn7/perks v1.0.1 // indirect
16 16
 	github.com/cespare/xxhash/v2 v2.1.1 // indirect
17 17
 	github.com/go-sql-driver/mysql v1.7.0 // indirect
18
+	github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
18 19
 	github.com/golang/protobuf v1.5.0 // indirect
19 20
 	github.com/hashicorp/golang-lru v0.5.4 // indirect
20 21
 	github.com/jinzhu/inflection v1.0.0 // indirect
22
+	github.com/jung-kurt/gofpdf v1.16.2 // indirect
21 23
 	github.com/kr/text v0.2.0 // indirect
22 24
 	github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
23 25
 	github.com/prometheus/client_golang v1.7.0 // indirect
@@ -26,7 +28,9 @@ require (
26 28
 	github.com/prometheus/procfs v0.1.3 // indirect
27 29
 	github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
28 30
 	github.com/stretchr/testify v1.8.2 // indirect
31
+	github.com/wcharczuk/go-chart v2.0.1+incompatible // indirect
29 32
 	golang.org/x/crypto v0.9.0 // indirect
33
+	golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a // indirect
30 34
 	golang.org/x/net v0.10.0 // indirect
31 35
 	golang.org/x/sys v0.8.0 // indirect
32 36
 	golang.org/x/text v0.9.0 // indirect

+ 12 - 0
go.sum View File

@@ -16,6 +16,7 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
16 16
 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
17 17
 github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
18 18
 github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
19
+github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
19 20
 github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60=
20 21
 github.com/casbin/casbin v1.7.0/go.mod h1:c67qKN6Oum3UF5Q1+BByfFxkwKvhwW57ITjqwtzR1KE=
21 22
 github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
@@ -53,6 +54,8 @@ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me
53 54
 github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
54 55
 github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
55 56
 github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
57
+github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
58
+github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
56 59
 github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
57 60
 github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
58 61
 github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@@ -86,6 +89,9 @@ github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/
86 89
 github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
87 90
 github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
88 91
 github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
92
+github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
93
+github.com/jung-kurt/gofpdf v1.16.2 h1:jgbatWHfRlPYiK85qgevsZTHviWXKwB1TTiKdz5PtRc=
94
+github.com/jung-kurt/gofpdf v1.16.2/go.mod h1:1hl7y57EsiPAkLbOwzpzqgx1A30nQCk/YmFV8S2vmK0=
89 95
 github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
90 96
 github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
91 97
 github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
@@ -117,6 +123,7 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J
117 123
 github.com/pelletier/go-toml v1.0.1/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
118 124
 github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
119 125
 github.com/peterh/liner v1.0.1-0.20171122030339-3681c2a91233/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc=
126
+github.com/phpdave11/gofpdi v1.0.7/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI=
120 127
 github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
121 128
 github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
122 129
 github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
@@ -139,6 +146,7 @@ github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFB
139 146
 github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
140 147
 github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ=
141 148
 github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
149
+github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w=
142 150
 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo=
143 151
 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
144 152
 github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
@@ -163,6 +171,8 @@ github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
163 171
 github.com/syndtr/goleveldb v0.0.0-20160425020131-cfa635847112/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
164 172
 github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
165 173
 github.com/ugorji/go v0.0.0-20171122102828-84cb69a8af83/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
174
+github.com/wcharczuk/go-chart v2.0.1+incompatible h1:0pz39ZAycJFF7ju/1mepnk26RLVLBCWz1STcD3doU0A=
175
+github.com/wcharczuk/go-chart v2.0.1+incompatible/go.mod h1:PF5tmL4EIx/7Wf+hEkpCqYi5He4u90sw+0+6FhrryuE=
166 176
 github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc=
167 177
 github.com/yuin/gopher-lua v0.0.0-20171031051903-609c9cd26973/go.mod h1:aEV29XrmTYFr3CiRxZeGHpkvbwq+prZduBqMaascyCU=
168 178
 golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
@@ -172,6 +182,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
172 182
 golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
173 183
 golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
174 184
 golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
185
+golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a h1:gHevYm0pO4QUbwy8Dmdr01R5r1BuKtfYqRqF0h/Cbh0=
186
+golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
175 187
 golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
176 188
 golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
177 189
 golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=

+ 87 - 0
models/patient_models.go View File

@@ -2020,3 +2020,90 @@ type VmDoubleCheck struct {
2020 2020
 func (VmDoubleCheck) TableName() string {
2021 2021
 	return "xt_double_check"
2022 2022
 }
2023
+
2024
+type XtDialysisPrescriptionLog struct {
2025
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
2026
+	UserOrgId   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2027
+	Ctime       int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2028
+	Mtime       int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2029
+	ErrLog      string `gorm:"column:err_log" json:"err_log" form:"err_log"`
2030
+	AdminUserId int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
2031
+	RecordDate  int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
2032
+	PatientId   int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2033
+	Source      string `gorm:"column:source" json:"source" form:"source"`
2034
+	Status      int64  `gorm:"column:status" json:"status" form:"status"`
2035
+}
2036
+
2037
+func (XtDialysisPrescriptionLog) TableName() string {
2038
+	return "xt_dialysis_prescription_log"
2039
+}
2040
+
2041
+type XtAssessmentBeforeDislysisLog struct {
2042
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
2043
+	UserOrgId   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2044
+	AdminUserId int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
2045
+	ErrLog      string `gorm:"column:err_log" json:"err_log" form:"err_log"`
2046
+	PatientId   int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2047
+	RecordDate  int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
2048
+	Ctime       int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2049
+	Mtime       int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2050
+	Status      int64  `gorm:"column:status" json:"status" form:"status"`
2051
+	Source      string `gorm:"column:source" json:"source" form:"source"`
2052
+}
2053
+
2054
+func (XtAssessmentBeforeDislysisLog) TableName() string {
2055
+	return "xt_assessment_before_dislysis_log"
2056
+}
2057
+
2058
+type XtAssessmentAfterDialysisLog struct {
2059
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
2060
+	UserOrgId   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2061
+	PatientId   int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2062
+	RecordDate  int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
2063
+	Status      int64  `gorm:"column:status" json:"status" form:"status"`
2064
+	ErrLog      string `gorm:"column:err_log" json:"err_log" form:"err_log"`
2065
+	AdminUserId int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
2066
+	Ctime       int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2067
+	Mtime       int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2068
+	Source      string `gorm:"column:source" json:"source" form:"source"`
2069
+}
2070
+
2071
+func (XtAssessmentAfterDialysisLog) TableName() string {
2072
+	return "xt_assessment_after_dialysis_log"
2073
+}
2074
+
2075
+type XtDoctorAdviceLog struct {
2076
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
2077
+	UserOrgId   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2078
+	PatientId   int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2079
+	AdminUserId int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
2080
+	Module      int64  `gorm:"column:module" json:"module" form:"module"`
2081
+	ErrLog      string `gorm:"column:err_log" json:"err_log" form:"err_log"`
2082
+	Status      int64  `gorm:"column:status" json:"status" form:"status"`
2083
+	Ctime       int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2084
+	Mtime       int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2085
+	Source      string `gorm:"column:source" json:"source" form:"source"`
2086
+	RecordDate  int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
2087
+}
2088
+
2089
+func (XtDoctorAdviceLog) TableName() string {
2090
+	return "xt_doctor_advice_log"
2091
+}
2092
+
2093
+type XtMonitorRecordLog struct {
2094
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
2095
+	RecordDate  int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
2096
+	PatientId   int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2097
+	Module      int64  `gorm:"column:module" json:"module" form:"module"`
2098
+	AdminUserId int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
2099
+	Ctime       int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2100
+	Mtime       int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2101
+	Status      int64  `gorm:"column:status" json:"status" form:"status"`
2102
+	UserOrgId   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2103
+	ErrLog      string `gorm:"column:err_log" json:"err_log" form:"err_log"`
2104
+	Source      string `gorm:"column:source" json:"source" form:"source"`
2105
+}
2106
+
2107
+func (XtMonitorRecordLog) TableName() string {
2108
+	return "xt_monitor_record_log"
2109
+}

+ 41 - 0
models/sign.models.go View File

@@ -88,3 +88,44 @@ type Signers struct {
88 88
 		} `json:"keywordSignControls"`
89 89
 	} `json:"signFiles"`
90 90
 }
91
+
92
+type XtDeviceEnterprise struct {
93
+	ID              int64  `gorm:"column:id" json:"id" form:"id"`
94
+	UserOrgId       int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
95
+	OrgType         int64  `gorm:"column:org_type" json:"org_type" form:"org_type"`
96
+	EnterpriseName  string `gorm:"column:enterprise_name" json:"enterprise_name" form:"enterprise_name"`
97
+	Code            string `gorm:"column:code" json:"code" form:"code"`
98
+	OrgCode         string `gorm:"column:org_code" json:"org_code" form:"org_code"`
99
+	LegalPersonName string `gorm:"column:legal_person_name" json:"legal_person_name" form:"legal_person_name"`
100
+	LegalIdCardNum  string `gorm:"column:legal_id_card_num" json:"legal_id_card_num" form:"legal_id_card_num"`
101
+	LegalPhone      string `gorm:"column:legal_phone" json:"legal_phone" form:"legal_phone"`
102
+	Creater         int64  `gorm:"column:creater" json:"creater" form:"creater"`
103
+	Ctime           int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
104
+	Mtime           int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
105
+	Enterpriseid    string `gorm:"column:enterprise_id" json:"enterprise_id" form:"enterprise_id"`
106
+	Status          int64  `gorm:"column:status" json:"status" form:"status"`
107
+}
108
+
109
+func (XtDeviceEnterprise) TableName() string {
110
+	return "xt_device_enterprise"
111
+}
112
+
113
+type XtDevicePersonEnterprise struct {
114
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
115
+	AdminUserId  int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
116
+	DisplayName  string `gorm:"column:display_name" json:"display_name" form:"display_name"`
117
+	Phone        string `gorm:"column:phone" json:"phone" form:"phone"`
118
+	IdCardNum    string `gorm:"column:id_card_num" json:"id_card_num" form:"id_card_num"`
119
+	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
120
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
121
+	Creater      int64  `gorm:"column:creater" json:"creater" form:"creater"`
122
+	Ctime        int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
123
+	Mtime        int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
124
+	UserId       string `gorm:"column:user_id" json:"user_id" form:"user_id"`
125
+	Personsealid string `gorm:"column:person_seal_id" json:"person_seal_id" form:"person_seal_id"`
126
+	Sealid       string `gorm:"column:seal_id" json:"seal_id" form:"seal_id"`
127
+}
128
+
129
+func (XtDevicePersonEnterprise) TableName() string {
130
+	return "xt_device_person_enterprise"
131
+}

+ 16 - 0
service/common_service.go View File

@@ -3486,6 +3486,22 @@ func GetModeIdCount(startime int64, endtime int64, orgid int64, page int64, limi
3486 3486
 	return order, err
3487 3487
 }
3488 3488
 
3489
+func GetScheduleModeIdCount(startime int64, endtime int64, orgid int64, page int64, limit int64) (order []*models.BloodDialysisModeIdCount, err error) {
3490
+
3491
+	db := XTReadDB().Table("xt_schedule as s")
3492
+	if orgid > 0 {
3493
+		db = db.Where("s.user_org_id = ?", orgid)
3494
+	}
3495
+	if startime > 0 {
3496
+		db = db.Where("s.schedule_date>=?", startime)
3497
+	}
3498
+	if endtime > 0 {
3499
+		db = db.Where("s.schedule_date<=?", endtime)
3500
+	}
3501
+	err = db.Group(" s.patient_id,s.mode_id").Select("s.mode_id,s.patient_id,count(s.id) as count").Scan(&order).Error
3502
+	return order, err
3503
+}
3504
+
3489 3505
 func GetTreatModeList(startime int64, endtime int64, orgid int64) (order []*models.BloodDialysisModeIdCount, err error) {
3490 3506
 
3491 3507
 	table := XTReadDB().Table("xt_schedule as s")

+ 62 - 0
service/dialysis_service.go View File

@@ -2362,3 +2362,65 @@ func UpdateDoctorAdviceNoExecution(id int64, creator int64, end_time int64) erro
2362 2362
 
2363 2363
 	return err
2364 2364
 }
2365
+
2366
+func CreatePrescriptionLog(log models.XtDialysisPrescriptionLog) error {
2367
+
2368
+	ut := writeDb.Begin()
2369
+	err := ut.Create(&log).Error
2370
+
2371
+	if err != nil {
2372
+		ut.Rollback()
2373
+		return err
2374
+	}
2375
+	ut.Commit()
2376
+	return err
2377
+}
2378
+
2379
+func CreateBeforLog(log models.XtAssessmentBeforeDislysisLog) error {
2380
+
2381
+	ut := writeDb.Begin()
2382
+	err := XTWriteDB().Create(&log).Error
2383
+
2384
+	if err != nil {
2385
+		ut.Rollback()
2386
+		return err
2387
+	}
2388
+	ut.Commit()
2389
+	return err
2390
+}
2391
+
2392
+func CreateAfterDialysisLog(log models.XtAssessmentAfterDialysisLog) error {
2393
+
2394
+	ut := writeDb.Begin()
2395
+	err := XTWriteDB().Create(&log).Error
2396
+	if err != nil {
2397
+		ut.Rollback()
2398
+		return err
2399
+	}
2400
+	ut.Commit()
2401
+	return err
2402
+}
2403
+
2404
+func CreateDoctorAdviceLog(log models.XtDoctorAdviceLog) error {
2405
+
2406
+	ut := writeDb.Begin()
2407
+	err := XTWriteDB().Create(&log).Error
2408
+	if err != nil {
2409
+		ut.Rollback()
2410
+		return err
2411
+	}
2412
+	ut.Commit()
2413
+	return err
2414
+}
2415
+
2416
+func CreateMonitorRecordLog(log models.XtMonitorRecordLog) error {
2417
+
2418
+	ut := writeDb.Begin()
2419
+	err := XTWriteDB().Create(&log).Error
2420
+	if err != nil {
2421
+		ut.Rollback()
2422
+		return err
2423
+	}
2424
+	ut.Commit()
2425
+	return err
2426
+}

+ 8 - 1
service/gobal_config_service.go View File

@@ -1082,7 +1082,14 @@ func GetLastAfter(patient_id int64, schedule_date int64, user_org_id int64) (mod
1082 1082
 	return dislysis, err
1083 1083
 }
1084 1084
 
1085
-func GetDialysisInformationByRecordDate(patient_id int64, record_date int64, user_org_id int64) (models.XtDialysisInformation, error) {
1085
+func GetDialysisInformationByRecordDate(patient_id int64, record_date int64, user_org_id int64, module int64) (models.XtDialysisInformation, error) {
1086
+
1087
+	information := models.XtDialysisInformation{}
1088
+	err := XTReadDB().Where("patient_id = ? and record_date = ? and user_org_id = ? and status=1 and module = ?", patient_id, record_date, user_org_id, module).Find(&information).Error
1089
+	return information, err
1090
+}
1091
+
1092
+func GetDialysisInformationByRecordDateOne(patient_id int64, record_date int64, user_org_id int64) (models.XtDialysisInformation, error) {
1086 1093
 
1087 1094
 	information := models.XtDialysisInformation{}
1088 1095
 	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

+ 17 - 12
service/his_charge_service.go View File

@@ -157,43 +157,43 @@ func GetAllPatientChargeSettle(org_id int64, start_time int64, end_time int64, k
157 157
 		switch item_type {
158 158
 		case 0:
159 159
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
160
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
160
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id).Order("ctime")
161 161
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
162 162
 
163 163
 			break
164 164
 		case 1:
165 165
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
166
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 1 ", start_time, end_time, org_id)
166
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 1 ", start_time, end_time, org_id).Order("ctime")
167 167
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
168 168
 
169 169
 			break
170 170
 		case 2:
171 171
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
172
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 0", start_time, end_time, org_id)
172
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 0", start_time, end_time, org_id).Order("ctime")
173 173
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
174 174
 
175 175
 			break
176 176
 		case 3:
177 177
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
178
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 14", start_time, end_time, org_id)
178
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 14", start_time, end_time, org_id).Order("ctime")
179 179
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
180 180
 
181 181
 			break
182 182
 		case 4:
183 183
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
184
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 11", start_time, end_time, org_id)
184
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 11", start_time, end_time, org_id).Order("ctime")
185 185
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
186 186
 
187 187
 			break
188 188
 		case 5:
189 189
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 AND orders.insutype = 390", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
190
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 ", start_time, end_time, org_id)
190
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 ", start_time, end_time, org_id).Order("ctime")
191 191
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
192 192
 
193 193
 			break
194 194
 		case 6:
195 195
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 AND orders.insutype = 310 ", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
196
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
196
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id).Order("ctime")
197 197
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
198 198
 
199 199
 			break
@@ -205,31 +205,31 @@ func GetAllPatientChargeSettle(org_id int64, start_time int64, end_time int64, k
205 205
 		switch item_type {
206 206
 		case 0:
207 207
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
208
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
208
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id).Order("ctime")
209 209
 			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
210 210
 
211 211
 			break
212 212
 		case 1:
213 213
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
214
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 1 ", start_time, end_time, org_id)
214
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 1 ", start_time, end_time, org_id).Order("ctime")
215 215
 			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
216 216
 
217 217
 			break
218 218
 		case 2:
219 219
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
220
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 0", start_time, end_time, org_id)
220
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 0", start_time, end_time, org_id).Order("ctime")
221 221
 			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
222 222
 
223 223
 			break
224 224
 		case 3:
225 225
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
226
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 14", start_time, end_time, org_id)
226
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 14", start_time, end_time, org_id).Order("ctime")
227 227
 			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
228 228
 
229 229
 			break
230 230
 		case 4:
231 231
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
232
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 11", start_time, end_time, org_id)
232
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 11", start_time, end_time, org_id).Order("ctime")
233 233
 			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
234 234
 
235 235
 			break
@@ -624,3 +624,8 @@ func GetAllChargeDetailsTwo(org_id int64, start_time int64, end_time int64) (pat
624 624
 
625 625
 	return
626 626
 }
627
+
628
+func GetAllLisDataFor10191(org_id int64) (list []models.HisLabelPrintStatusInfo, err error) {
629
+	err = readDb.Model(&models.HisLabelPrintStatusInfo{}).Preload("Patient", "status = 1").Where("user_org_id = ? AND status = 1  and apply_code = ''", org_id).Find(&list).Error
630
+	return
631
+}

+ 1 - 1
service/his_project_service.go View File

@@ -300,7 +300,7 @@ func GetAllProjectTeam(orgid int64) (project []*models.XtHisProjectTeam, err err
300 300
 }
301 301
 
302 302
 func GetProjectListById(orgid int64, ids []string) (project []*models.XtHisProjectList, err error) {
303
-	err = XTReadDB().Model(&project).Preload("XtHisProject", "status = 1").Preload("GoodInfo", "status=1").Where("user_org_id = ? and id in (?)", orgid, ids).Find(&project).Error
303
+	err = XTReadDB().Model(&project).Preload("XtHisProject", "status = 1").Preload("GoodInfo", "status=1").Where("user_org_id = ? and id in (?) and status = 1", orgid, ids).Find(&project).Error
304 304
 	return project, err
305 305
 }
306 306
 

+ 8 - 0
service/mobile_dialysis_service.go View File

@@ -1303,6 +1303,14 @@ func DisableMonitor(orgID int64, patientID int64, recordID int64, admin_user_id
1303 1303
 	tx.Commit()
1304 1304
 	return nil
1305 1305
 }
1306
+
1307
+func GetMonitorById(id int64, orgId int64) (models.MonitoringRecord, error) {
1308
+
1309
+	record := models.MonitoringRecord{}
1310
+	err := XTReadDB().Where("id = ? and user_org_id =?", id, orgId).Find(&record).Error
1311
+	return record, err
1312
+}
1313
+
1306 1314
 func GetMonitor(orgID int64, patientID int64, id int64) (*models.MonitoringRecord, error) {
1307 1315
 	var monitor models.MonitoringRecord
1308 1316
 	var err error

+ 25 - 0
service/new_warehouse_service.go View File

@@ -50,6 +50,11 @@ func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, g
50 50
 		if errThree != nil {
51 51
 			return errThree
52 52
 		}
53
+
54
+		if orgID == 10265 {
55
+			UpdateGoodInfoByPrice(warehouse.GoodId, orgID, warehouse.Price, warehouse.PackingPrice)
56
+		}
57
+
53 58
 		//更新his_prescripton_project出库状态值
54 59
 		UpdateHisPrescriptionProjectStatus(goods.GoodId, record_time, orgID, patient_id)
55 60
 
@@ -1326,6 +1331,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1326 1331
 	// 如果没有对应的库存,则报错
1327 1332
 	storeConfig, _ := GetAllStoreHouseConfig(advice.UserOrgId)
1328 1333
 	lastWarehouse, _ := FindLastDrugWarehousingInfoByID(advice.DrugId, storeConfig.DrugStorehouseOut)
1334
+
1329 1335
 	if lastWarehouse.MaxUnit != lastWarehouse.MinUnit && drup.MaxUnit != drup.MinUnit && lastWarehouse.MinUnit != "" {
1330 1336
 		if lastWarehouse.StockMinNumber >= drup.MinNumber {
1331 1337
 			var stockMax int64
@@ -1495,6 +1501,12 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1495 1501
 			return errThree
1496 1502
 		}
1497 1503
 
1504
+		//更改字典里面的价格
1505
+		if advice.UserOrgId == 10265 || advice.UserOrgId == 10215 {
1506
+
1507
+			UpdateBasePrice(lastWarehouse.DrugId, lastWarehouse.RetailPrice)
1508
+		}
1509
+
1498 1510
 		//查询剩余库存
1499 1511
 		stockInfo, _ := GetDrugAllStockInfo(storeConfig.DrugStorehouseOut, orgID, advice.DrugId)
1500 1512
 		var sum_count int64
@@ -4538,3 +4550,16 @@ func UpdateDrugWarehouseOutInfoTen(patient_id int64, sys_record_time int64, advi
4538 4550
 	err := XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("patient_id = ? and sys_record_time  = ? and status=1 and advice_id = ?", patient_id, sys_record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
4539 4551
 	return err
4540 4552
 }
4553
+
4554
+func UpdateBasePrice(id int64, min_price float64) error {
4555
+
4556
+	err := XTWriteDB().Model(models.XtBaseDrug{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"min_price": min_price}).Error
4557
+
4558
+	return err
4559
+}
4560
+
4561
+func UpdateGoodInfoByPrice(id int64, org_id int64, price float64, packingprice float64) error {
4562
+
4563
+	err := XTWriteDB().Model(&models.GoodInfo{}).Where("id=? and org_id = ? and status =1", id, org_id).Updates(map[string]interface{}{"buy_price": price, "packing_price": packingprice}).Error
4564
+	return err
4565
+}

+ 7 - 0
service/patient_service.go View File

@@ -1675,6 +1675,13 @@ func FindDoctorAdviceByIdsTwety(orgID int64, ids []string) (advice []models.Doct
1675 1675
 	return
1676 1676
 }
1677 1677
 
1678
+func GetBatchDoctorAdviceList(ids []string, user_org_id int64) (advice []*models.DoctorAdvice, err error) {
1679
+
1680
+	err = XTReadDB().Where("id in(?) and user_org_id = ? and status =1", ids, user_org_id).Find(&advice).Error
1681
+
1682
+	return advice, err
1683
+}
1684
+
1678 1685
 func BatchDeleteDoctorAdvice(ids []string, user_id int64) (err error) {
1679 1686
 	ut := writeDb.Begin()
1680 1687
 	err = ut.Model(&models.DoctorAdvice{}).Where("status = 1   AND id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix(), "modifier": user_id}).Error

+ 650 - 18
service/sign_service.go View File

@@ -210,7 +210,7 @@ func CreatePersionSeal(user_id string, person_seal_type int64, person_seal_name
210 210
 
211 211
 	maprequest["personSealType"] = 1
212 212
 
213
-	maprequest["personSealName"] = "马云朋友的印章"
213
+	maprequest["personSealName"] = "朋友的印章"
214 214
 
215 215
 	var url string
216 216
 
@@ -279,9 +279,10 @@ func CreateUploadPact(contractcode string, contractname string, signcount int64,
279 279
 
280 280
 	maprequest["signCount"] = 10
281 281
 
282
-	maprequest["docName"] = "电脑员工保密协议"
282
+	maprequest["docName"] = "日本员工保密协议"
283 283
 
284 284
 	file := "C:/Users/28169/Desktop/打印单.pdf"
285
+
285 286
 	fileBytes, err := ioutil.ReadFile(file) // 读取file
286 287
 
287 288
 	contractBase64 := base64.StdEncoding.EncodeToString(fileBytes) // 加密成base64字符串
@@ -479,7 +480,8 @@ func AddContractSignatory(contractId string, signers string, contract models.New
479 480
 
480 481
 	signFiles := make(map[string]interface{})
481 482
 
482
-	signFiles["docId"] = "156190809375377646"
483
+	//创建合同返回
484
+	signFiles["docId"] = "157595002862567873"
483 485
 
484 486
 	inputDataArr := make([]map[string]interface{}, 0)
485 487
 
@@ -489,20 +491,21 @@ func AddContractSignatory(contractId string, signers string, contract models.New
489 491
 		xySignControls["key"] = "1"
490 492
 		xySignControls["type"] = "autograph"
491 493
 		xySignControls["pageNum"] = 1
492
-		xySignControls["positionX"] = 100
493
-		xySignControls["positionY"] = 100
494
+		xySignControls["positionX"] = "100F"
495
+		xySignControls["positionY"] = "100F"
494 496
 		inputDataArr = append(inputDataArr, xySignControls)
497
+
495 498
 	}
496 499
 	inputDataArrTwo := make([]map[string]interface{}, 0)
497 500
 	for _, item := range signFiles {
498 501
 		fmt.Println(item)
499 502
 		keywordSignControls := make(map[string]interface{})
500 503
 		keywordSignControls["key"] = "2"
501
-		keywordSignControls["type"] = "autograph"
504
+		keywordSignControls["type"] = "date"
502 505
 		keywordSignControls["pageNum"] = 1
503
-		keywordSignControls["keyword"] = "盖章"
504
-		keywordSignControls["offsetX"] = 100
505
-		keywordSignControls["offsetY"] = 100
506
+		keywordSignControls["keyword"] = "医生签名"
507
+		keywordSignControls["offsetX"] = "100F"
508
+		keywordSignControls["offsetY"] = "100F"
506 509
 		inputDataArrTwo = append(inputDataArrTwo, keywordSignControls)
507 510
 	}
508 511
 	signFiles["xySignControls"] = inputDataArr
@@ -517,6 +520,7 @@ func AddContractSignatory(contractId string, signers string, contract models.New
517 520
 	signersFiles["enterpriseId"] = "BRWAABXW3RUD4PGCYEQWRRK8"
518 521
 	signersFiles["sequence"] = "8"
519 522
 	signersFiles["sendMsg"] = false
523
+	signersFiles["setting"] = true
520 524
 	signersFiles["signFiles"] = inputDataArrThree
521 525
 
522 526
 	inputDataArrFour := make([]map[string]interface{}, 0)
@@ -524,7 +528,7 @@ func AddContractSignatory(contractId string, signers string, contract models.New
524 528
 	inputDataArrFour = append(inputDataArrFour, signersFiles)
525 529
 
526 530
 	maprequest := make(map[string]interface{})
527
-	maprequest["contractId"] = "156190809375377645"
531
+	maprequest["contractId"] = "157595002862567872"
528 532
 	maprequest["signers"] = inputDataArrFour
529 533
 
530 534
 	byterequest, _ := json.Marshal(maprequest)
@@ -596,22 +600,26 @@ func CreateBackStageSign(contractId string, signers string) string {
596 600
 	signFiles["showTimestamp"] = false
597 601
 	signFiles["sealTimestamp"] = sealTimestampFiles
598 602
 	signControl := make(map[string]interface{})
599
-	signControl["1"] = "autograph"
603
+	signControl["1"] = "{sealId:157474548357267755}"
604
+	signControl["2"] = "姓名"
605
+
606
+	fmt.Println("signContorlwqowowo", signControl)
600 607
 	signFiles["signControl"] = signControl
601
-	signFiles["docId"] = "156190809375377646"
608
+	signFiles["docId"] = "157595002862567873"
602 609
 	inputDataArrThree := make([]map[string]interface{}, 0)
603 610
 	inputDataArrThree = append(inputDataArrThree, signFiles)
604 611
 
605 612
 	signer := make(map[string]interface{})
606 613
 
607
-	signer["signerId"] = "156190965067942129"
614
+	//添加合同签署人接口返回
615
+	signer["signerId"] = "157595142449004996"
608 616
 	signer["isUserWishes"] = true
609 617
 	signer["userWishesWay"] = 1
610
-	signer["codeNumber"] = "msg202308111745462623789"
611
-	signer["verifyCode"] = "930788"
618
+	signer["codeNumber"] = "msg202308261800395745892"
619
+	signer["verifyCode"] = "452399"
612 620
 	signer["signFiles"] = inputDataArrThree
613 621
 	maprequest := make(map[string]interface{})
614
-	maprequest["contractId"] = "156190809375377645"
622
+	maprequest["contractId"] = "157595002862567872"
615 623
 	maprequest["signer"] = signer
616 624
 
617 625
 	byterequest, _ := json.Marshal(maprequest)
@@ -657,7 +665,7 @@ func GetVerificationCode() string {
657 665
 	serviceCode := beego.AppConfig.String("serviceCode")
658 666
 
659 667
 	maprequest := make(map[string]interface{})
660
-	maprequest["contractId"] = "156190809375377645"
668
+	maprequest["contractId"] = "157595002862567872"
661 669
 	maprequest["userId"] = "PBRLMBFVIRR3BV8JGGOX9C7N"
662 670
 
663 671
 	byterequest, _ := json.Marshal(maprequest)
@@ -703,7 +711,7 @@ func CreateEnterprise() string {
703 711
 	serviceCode := beego.AppConfig.String("serviceCode")
704 712
 
705 713
 	maprequest := make(map[string]interface{})
706
-	maprequest["contractId"] = "156190809375377645"
714
+	maprequest["contractId"] = "157413765980094742"
707 715
 	maprequest["userId"] = "PBRLMBFVIRR3BV8JGGOX9C7N"
708 716
 	maprequest["sealType"] = 1
709 717
 	maprequest["sealName"] = "测试用章"
@@ -742,3 +750,627 @@ func CreateEnterprise() string {
742 750
 
743 751
 	return str
744 752
 }
753
+
754
+func GetTestThrityMent(org_id int64) (base []*models.XtBaseDrug, err error) {
755
+
756
+	err = XTReadDB().Where("org_id = ? and status=1", org_id).Find(&base).Error
757
+
758
+	return base, err
759
+}
760
+
761
+func UpdateDrugWarehouseInfoByDrugId(drug_id int64, min_price float64) error {
762
+
763
+	err := XTWriteDB().Model(&models.XtDrugWarehouseInfo{}).Where("drug_id = ? and (stock_max_number>0 or stock_min_number>0) and status= 1 and is_check=1 and org_id =10375", drug_id).Updates(map[string]interface{}{"retail_price": min_price}).Error
764
+
765
+	return err
766
+}
767
+
768
+func GetEnterPriseByUserOrgId(user_org_id int64) (models.XtDeviceEnterprise, error) {
769
+
770
+	enterprise := models.XtDeviceEnterprise{}
771
+
772
+	err := XTReadDB().Where("user_org_id = ? and status =1", user_org_id).Find(&enterprise).Error
773
+
774
+	return enterprise, err
775
+}
776
+
777
+func CreateEnterPrise(enterprise models.XtDeviceEnterprise) error {
778
+
779
+	err := XTWriteDB().Create(&enterprise).Error
780
+
781
+	return err
782
+}
783
+
784
+func SaveEnerPrise(enterprise models.XtDeviceEnterprise) error {
785
+
786
+	err := XTWriteDB().Save(&enterprise).Error
787
+
788
+	return err
789
+}
790
+
791
+func CreateNewEnterPriseRealName(enterprise models.XtDeviceEnterprise) (string, string) {
792
+
793
+	var url string
794
+
795
+	url = "http://demo.itruscloud.com/apigate/contractpaasapi/enterprise/createEnterpriseRealName"
796
+	appId := beego.AppConfig.String("sign_appid")
797
+
798
+	serviceKye := beego.AppConfig.String("serviceKye")
799
+
800
+	serviceCode := beego.AppConfig.String("serviceCode")
801
+
802
+	maprequest := make(map[string]interface{})
803
+
804
+	customerReq := make(map[string]interface{})
805
+	customerReq["idCardType"] = "N"
806
+	customerReq["idCardNum"] = "430526199408156511"
807
+
808
+	maprequest["enterpriseName"] = enterprise.EnterpriseName
809
+	maprequest["authentication"] = true
810
+	maprequest["customerAuthReq"] = customerReq
811
+
812
+	fmt.Println("maprequest", maprequest)
813
+	byterequest, _ := json.Marshal(maprequest)
814
+
815
+	reader := bytes.NewReader(byterequest)
816
+
817
+	signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
818
+
819
+	request, err := http.NewRequest("POST", url, reader)
820
+	if err != nil {
821
+		fmt.Println(err.Error())
822
+	}
823
+
824
+	request.Header.Set("appId", appId)
825
+	request.Header.Set("serviceCode", serviceCode)
826
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
827
+	request.Header.Set("Content-Signature", signatureStr)
828
+	client := http.Client{}
829
+
830
+	resp, err := client.Do(request)
831
+	if err != nil {
832
+		fmt.Println(err.Error())
833
+
834
+	}
835
+	respBytes, err := ioutil.ReadAll(resp.Body)
836
+	if err != nil {
837
+		fmt.Println(err.Error())
838
+
839
+	}
840
+	str := string(respBytes)
841
+
842
+	var respJSON map[string]interface{}
843
+	if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
844
+		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
845
+	}
846
+	var enterpriseId string
847
+	enterpriseId = respJSON["data"].(map[string]interface{})["enterpriseId"].(string)
848
+	fmt.Println("enterpriseId", enterpriseId)
849
+	return str, enterpriseId
850
+}
851
+
852
+func GetNewSignNameByPhone(phone string) (string, string) {
853
+
854
+	var url string
855
+	url = "http://demo-open.itruscloud.com/apigate/smsService/sendingSms"
856
+	var content string
857
+	content = "123456"
858
+	var autograph string
859
+	autograph = "【天威诚信】"
860
+
861
+	maprequest := make(map[string]interface{})
862
+
863
+	maprequest["phone"] = phone
864
+	maprequest["content"] = content
865
+	maprequest["autograph"] = autograph
866
+
867
+	byterequest, _ := json.Marshal(maprequest)
868
+
869
+	appId := beego.AppConfig.String("sign_appid")
870
+
871
+	serviceKye := beego.AppConfig.String("serviceKye")
872
+
873
+	serviceCode := beego.AppConfig.String("serviceCode")
874
+
875
+	reader := bytes.NewReader(byterequest)
876
+
877
+	signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
878
+
879
+	fmt.Println(signatureStr)
880
+
881
+	request, err := http.NewRequest("POST", url, reader)
882
+	if err != nil {
883
+		fmt.Println(err.Error())
884
+	}
885
+
886
+	request.Header.Set("appId", appId)
887
+	request.Header.Set("serviceCode", serviceCode)
888
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
889
+	request.Header.Set("Content-Signature", signatureStr)
890
+	client := http.Client{}
891
+
892
+	resp, err := client.Do(request)
893
+	if err != nil {
894
+		fmt.Println(err.Error())
895
+
896
+	}
897
+	respBytes, err := ioutil.ReadAll(resp.Body)
898
+	if err != nil {
899
+		fmt.Println(err.Error())
900
+
901
+	}
902
+	str := string(respBytes)
903
+
904
+	var respJSON map[string]interface{}
905
+
906
+	if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
907
+		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
908
+	}
909
+	var orderNumber string
910
+	orderNumber = respJSON["orderNumber"].(string)
911
+	fmt.Println("orderNumberWOWOWOWOWO", orderNumber)
912
+	return str, orderNumber
913
+}
914
+
915
+func SavePersonEnterPrise(enterprise models.XtDevicePersonEnterprise) error {
916
+
917
+	err := XTWriteDB().Save(&enterprise).Error
918
+
919
+	return err
920
+}
921
+
922
+func GetLastPersonEnterPrise(admin_user_id int64, orgId int64) (models.XtDevicePersonEnterprise, error) {
923
+
924
+	enterprise := models.XtDevicePersonEnterprise{}
925
+
926
+	err := XTReadDB().Where("admin_user_id = ? and user_org_id = ? and status = 1", admin_user_id, orgId).Find(&enterprise).Error
927
+
928
+	return enterprise, err
929
+}
930
+
931
+func CreateNewUserName(phone string, disPlayName string, code string, orderNumber string, id_card_number string) (string, string) {
932
+
933
+	var url string
934
+
935
+	url = "http://demo.itruscloud.com/apigate/contractpaasapi/user/createUserRealName"
936
+
937
+	var authentication string
938
+	//测试环境用true
939
+	authentication = "true"
940
+
941
+	maprequest := make(map[string]interface{})
942
+
943
+	twAuthReq := make(map[string]interface{})
944
+
945
+	apiAuthReq := make(map[string]interface{})
946
+
947
+	customerReq := make(map[string]interface{})
948
+
949
+	fmt.Println("身份证id_card_number", id_card_number)
950
+	customerReq["idCardType"] = "0"
951
+	customerReq["idCardNum"] = id_card_number
952
+
953
+	apiAuthReq["realNameType"] = 3
954
+	apiAuthReq["idCardType"] = "0"
955
+	apiAuthReq["idCardNum"] = id_card_number
956
+	apiAuthReq["bankCard"] = "6225551675364804"
957
+	//验证码流水号
958
+	apiAuthReq["codeNumber"] = orderNumber
959
+	//验证码
960
+	apiAuthReq["verifyCode"] = code
961
+
962
+	twAuthReq["oneLineAuth"] = "false"
963
+
964
+	twAuthReq["apiAuthReq"] = apiAuthReq
965
+
966
+	maprequest["phone"] = phone
967
+	maprequest["displayName"] = disPlayName
968
+	maprequest["authentication"] = authentication
969
+
970
+	maprequest["twAuthReq"] = twAuthReq
971
+	maprequest["customerAuthReq"] = customerReq
972
+
973
+	byterequest, _ := json.Marshal(maprequest)
974
+
975
+	appId := beego.AppConfig.String("sign_appid")
976
+
977
+	serviceKye := beego.AppConfig.String("serviceKye")
978
+
979
+	serviceCode := beego.AppConfig.String("serviceCode")
980
+
981
+	reader := bytes.NewReader(byterequest)
982
+
983
+	signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
984
+
985
+	fmt.Println(signatureStr)
986
+
987
+	request, err := http.NewRequest("POST", url, reader)
988
+	if err != nil {
989
+		fmt.Println(err.Error())
990
+	}
991
+	fmt.Println("请求参数", request)
992
+	fmt.Println("Content-Signature", signatureStr)
993
+	fmt.Println("appID", appId)
994
+	fmt.Println("serviceCode", serviceCode)
995
+	request.Header.Set("appId", appId)
996
+	request.Header.Set("serviceCode", serviceCode)
997
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
998
+	request.Header.Set("Content-Signature", signatureStr)
999
+	client := http.Client{}
1000
+
1001
+	resp, err := client.Do(request)
1002
+	if err != nil {
1003
+		fmt.Println(err.Error())
1004
+
1005
+	}
1006
+	respBytes, err := ioutil.ReadAll(resp.Body)
1007
+	if err != nil {
1008
+		fmt.Println(err.Error())
1009
+
1010
+	}
1011
+	str := string(respBytes)
1012
+
1013
+	var respJSON map[string]interface{}
1014
+	if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
1015
+		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
1016
+	}
1017
+	var UserId string
1018
+	UserId = respJSON["data"].(map[string]interface{})["userId"].(string)
1019
+	fmt.Println("str", UserId)
1020
+	return str, UserId
1021
+
1022
+}
1023
+
1024
+func CreateNewPersionSeal(userId string) (string, string) {
1025
+
1026
+	maprequest := make(map[string]interface{})
1027
+
1028
+	maprequest["userId"] = userId
1029
+
1030
+	maprequest["personSealType"] = 1
1031
+
1032
+	maprequest["personSealName"] = "小马印章"
1033
+
1034
+	var url string
1035
+
1036
+	url = "http://demo.itruscloud.com/apigate/contractpaasapi/user/createPersonSeal"
1037
+	appId := beego.AppConfig.String("sign_appid")
1038
+
1039
+	serviceKye := beego.AppConfig.String("serviceKye")
1040
+
1041
+	serviceCode := beego.AppConfig.String("serviceCode")
1042
+	byterequest, _ := json.Marshal(maprequest)
1043
+	reader := bytes.NewReader(byterequest)
1044
+
1045
+	signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
1046
+
1047
+	fmt.Println(signatureStr)
1048
+
1049
+	request, err := http.NewRequest("POST", url, reader)
1050
+	if err != nil {
1051
+		fmt.Println(err.Error())
1052
+	}
1053
+
1054
+	request.Header.Set("appId", appId)
1055
+	request.Header.Set("serviceCode", serviceCode)
1056
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1057
+	request.Header.Set("Content-Signature", signatureStr)
1058
+	client := http.Client{}
1059
+
1060
+	resp, err := client.Do(request)
1061
+	if err != nil {
1062
+		fmt.Println(err.Error())
1063
+
1064
+	}
1065
+	respBytes, err := ioutil.ReadAll(resp.Body)
1066
+	if err != nil {
1067
+		fmt.Println(err.Error())
1068
+
1069
+	}
1070
+	str := string(respBytes)
1071
+
1072
+	var respJSON map[string]interface{}
1073
+	if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
1074
+		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
1075
+	}
1076
+	var personSealId string
1077
+	personSealId = respJSON["data"].(map[string]interface{})["personSealId"].(string)
1078
+	fmt.Println("str", personSealId)
1079
+	return str, personSealId
1080
+}
1081
+
1082
+func UpdatePerseEnterPriseById(id int64, personSealId string) error {
1083
+
1084
+	err := XTWriteDB().Model(models.XtDevicePersonEnterprise{}).Where("id= ? and status =1", id).Updates(map[string]interface{}{"person_seal_id": personSealId}).Error
1085
+
1086
+	return err
1087
+}
1088
+
1089
+func CreateNewEnterPrise(enterpriseId string, userId string) (string, string) {
1090
+
1091
+	var url string
1092
+
1093
+	url = "http://demo.itruscloud.com/apigate/contractpaasapi/enterprise/createSeal"
1094
+	appId := beego.AppConfig.String("sign_appid")
1095
+
1096
+	serviceKye := beego.AppConfig.String("serviceKye")
1097
+
1098
+	serviceCode := beego.AppConfig.String("serviceCode")
1099
+
1100
+	fmt.Println("enterpriseId", enterpriseId)
1101
+	fmt.Println("userId", userId)
1102
+	maprequest := make(map[string]interface{})
1103
+	maprequest["enterpriseId"] = enterpriseId
1104
+	maprequest["userId"] = userId
1105
+	maprequest["sealType"] = 1
1106
+	maprequest["sealName"] = "测试用章"
1107
+
1108
+	fmt.Println("request23222222222222222", maprequest)
1109
+	byterequest, _ := json.Marshal(maprequest)
1110
+	reader := bytes.NewReader(byterequest)
1111
+
1112
+	signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
1113
+
1114
+	request, err := http.NewRequest("POST", url, reader)
1115
+
1116
+	fmt.Println("request23222222222222222", request)
1117
+	if err != nil {
1118
+		fmt.Println(err.Error())
1119
+	}
1120
+
1121
+	request.Header.Set("appId", appId)
1122
+	request.Header.Set("serviceCode", serviceCode)
1123
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1124
+	request.Header.Set("Content-Signature", signatureStr)
1125
+	client := http.Client{}
1126
+
1127
+	resp, err := client.Do(request)
1128
+	if err != nil {
1129
+		fmt.Println(err.Error())
1130
+
1131
+	}
1132
+	respBytes, err := ioutil.ReadAll(resp.Body)
1133
+	if err != nil {
1134
+		fmt.Println(err.Error())
1135
+
1136
+	}
1137
+	str := string(respBytes)
1138
+	fmt.Println("strwowowowowo", str)
1139
+
1140
+	var respJSON map[string]interface{}
1141
+	if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
1142
+		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
1143
+	}
1144
+	var sealId string
1145
+	sealId = respJSON["data"].(map[string]interface{})["sealId"].(string)
1146
+	fmt.Println("sealId", sealId)
1147
+	return str, sealId
1148
+}
1149
+
1150
+func UpdatePersonEnterPrise(id int64, sealId string) error {
1151
+
1152
+	err := XTWriteDB().Model(models.XtDevicePersonEnterprise{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"seal_id": sealId}).Error
1153
+	return err
1154
+}
1155
+
1156
+func GetContractId() string {
1157
+
1158
+	var url string
1159
+
1160
+	url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/search"
1161
+	appId := beego.AppConfig.String("sign_appid")
1162
+
1163
+	serviceKye := beego.AppConfig.String("serviceKye")
1164
+
1165
+	serviceCode := beego.AppConfig.String("serviceCode")
1166
+
1167
+	maprequest := make(map[string]interface{})
1168
+	maprequest["contractId"] = "157475501840007476"
1169
+	maprequest["responseContractFile"] = true
1170
+
1171
+	fmt.Println("request23222222222222222", maprequest)
1172
+	byterequest, _ := json.Marshal(maprequest)
1173
+	reader := bytes.NewReader(byterequest)
1174
+
1175
+	signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
1176
+
1177
+	request, err := http.NewRequest("POST", url, reader)
1178
+
1179
+	fmt.Println("request23222222222222222", request)
1180
+	if err != nil {
1181
+		fmt.Println(err.Error())
1182
+	}
1183
+
1184
+	request.Header.Set("appId", appId)
1185
+	request.Header.Set("serviceCode", serviceCode)
1186
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1187
+	request.Header.Set("Content-Signature", signatureStr)
1188
+	client := http.Client{}
1189
+
1190
+	resp, err := client.Do(request)
1191
+	if err != nil {
1192
+		fmt.Println(err.Error())
1193
+
1194
+	}
1195
+	respBytes, err := ioutil.ReadAll(resp.Body)
1196
+	if err != nil {
1197
+		fmt.Println(err.Error())
1198
+
1199
+	}
1200
+	str := string(respBytes)
1201
+	fmt.Println("strwowowowowo", str)
1202
+
1203
+	return str
1204
+}
1205
+
1206
+func EndEnterPrise() string {
1207
+	var url string
1208
+
1209
+	url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/finished"
1210
+	appId := beego.AppConfig.String("sign_appid")
1211
+
1212
+	serviceKye := beego.AppConfig.String("serviceKye")
1213
+
1214
+	serviceCode := beego.AppConfig.String("serviceCode")
1215
+
1216
+	maprequest := make(map[string]interface{})
1217
+	maprequest["contractId"] = "157475501840007476"
1218
+
1219
+	byterequest, _ := json.Marshal(maprequest)
1220
+	reader := bytes.NewReader(byterequest)
1221
+
1222
+	signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
1223
+
1224
+	request, err := http.NewRequest("POST", url, reader)
1225
+
1226
+	if err != nil {
1227
+		fmt.Println(err.Error())
1228
+	}
1229
+
1230
+	request.Header.Set("appId", appId)
1231
+	request.Header.Set("serviceCode", serviceCode)
1232
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1233
+	request.Header.Set("Content-Signature", signatureStr)
1234
+	client := http.Client{}
1235
+
1236
+	resp, err := client.Do(request)
1237
+	if err != nil {
1238
+		fmt.Println(err.Error())
1239
+
1240
+	}
1241
+	respBytes, err := ioutil.ReadAll(resp.Body)
1242
+	if err != nil {
1243
+		fmt.Println(err.Error())
1244
+
1245
+	}
1246
+	str := string(respBytes)
1247
+	fmt.Println("strwowowowowo", str)
1248
+
1249
+	return str
1250
+}
1251
+
1252
+func GetEnterPriseDetail() (string, string) {
1253
+
1254
+	var url string
1255
+
1256
+	url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/preview"
1257
+	appId := beego.AppConfig.String("sign_appid")
1258
+
1259
+	serviceKye := beego.AppConfig.String("serviceKye")
1260
+
1261
+	serviceCode := beego.AppConfig.String("serviceCode")
1262
+
1263
+	maprequest := make(map[string]interface{})
1264
+	maprequest["contractId"] = "157594023610024377"
1265
+
1266
+	byterequest, _ := json.Marshal(maprequest)
1267
+	reader := bytes.NewReader(byterequest)
1268
+
1269
+	signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
1270
+
1271
+	request, err := http.NewRequest("POST", url, reader)
1272
+
1273
+	if err != nil {
1274
+		fmt.Println(err.Error())
1275
+	}
1276
+
1277
+	request.Header.Set("appId", appId)
1278
+	request.Header.Set("serviceCode", serviceCode)
1279
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1280
+	request.Header.Set("Content-Signature", signatureStr)
1281
+	client := http.Client{}
1282
+
1283
+	resp, err := client.Do(request)
1284
+	if err != nil {
1285
+		fmt.Println(err.Error())
1286
+
1287
+	}
1288
+	respBytes, err := ioutil.ReadAll(resp.Body)
1289
+	if err != nil {
1290
+		fmt.Println(err.Error())
1291
+
1292
+	}
1293
+	str := string(respBytes)
1294
+	fmt.Println("strwowowowowo", str)
1295
+	var respJSON map[string]interface{}
1296
+	if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
1297
+		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
1298
+	}
1299
+	var urlOne string
1300
+	urlOne = respJSON["data"].(map[string]interface{})["url"].(string)
1301
+	fmt.Println("url", urlOne)
1302
+	return str, urlOne
1303
+}
1304
+
1305
+func CreateNewUploadPact(name string) string {
1306
+
1307
+	var url string
1308
+
1309
+	url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/createByFile"
1310
+	appId := beego.AppConfig.String("sign_appid")
1311
+
1312
+	serviceKye := beego.AppConfig.String("serviceKye")
1313
+
1314
+	serviceCode := beego.AppConfig.String("serviceCode")
1315
+
1316
+	maprequest := make(map[string]interface{})
1317
+
1318
+	//maprequest["contractCode"] = "102020620701056856"
1319
+
1320
+	maprequest["contractName"] = "手机购买交易合同"
1321
+
1322
+	maprequest["signCount"] = 10
1323
+
1324
+	maprequest["docName"] = "美国员工保密协议"
1325
+
1326
+	//file := "C:/Users/28169/Desktop/打印单.pdf"
1327
+	//
1328
+	//fileBytes, err := ioutil.ReadFile(file) // 读取file
1329
+	//
1330
+	//contractBase64 := base64.StdEncoding.EncodeToString(fileBytes) // 加密成base64字符串
1331
+
1332
+	//fmt.Println(contractBase64)
1333
+	maprequest["contractBase64"] = name
1334
+
1335
+	//添加企业成员 里面的USERID
1336
+	maprequest["creator"] = "PBRLMBFVIRR3BV8JGGOX9C7N"
1337
+
1338
+	maprequest["enterpriseId"] = "BRWAABXW3RUD4PGCYEQWRRK8"
1339
+
1340
+	maprequest["signValidDays"] = 90
1341
+
1342
+	maprequest["sysnUrl"] = "https://kuyi.shengws.com/chenxuemin1.png"
1343
+
1344
+	maprequest["asyncUrl"] = "https://kuyi.shengws.com/chenxuemin1.png"
1345
+
1346
+	byterequest, _ := json.Marshal(maprequest)
1347
+	reader := bytes.NewReader(byterequest)
1348
+
1349
+	signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
1350
+
1351
+	request, err := http.NewRequest("POST", url, reader)
1352
+	if err != nil {
1353
+		fmt.Println(err.Error())
1354
+	}
1355
+
1356
+	request.Header.Set("appId", appId)
1357
+	request.Header.Set("serviceCode", serviceCode)
1358
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1359
+	request.Header.Set("Content-Signature", signatureStr)
1360
+	client := http.Client{}
1361
+
1362
+	resp, err := client.Do(request)
1363
+	if err != nil {
1364
+		fmt.Println(err.Error())
1365
+
1366
+	}
1367
+	respBytes, err := ioutil.ReadAll(resp.Body)
1368
+	if err != nil {
1369
+		fmt.Println(err.Error())
1370
+
1371
+	}
1372
+	str := string(respBytes)
1373
+
1374
+	fmt.Println("strwwoowowow", str)
1375
+	return str
1376
+}