|
@@ -0,0 +1,177 @@
|
|
1
|
+package new_mobile_api_controllers
|
|
2
|
+
|
|
3
|
+import (
|
|
4
|
+ "XT_New/controllers/mobile_api_controllers"
|
|
5
|
+ "XT_New/enums"
|
|
6
|
+ "XT_New/models"
|
|
7
|
+ "XT_New/service"
|
|
8
|
+ "XT_New/utils"
|
|
9
|
+ "fmt"
|
|
10
|
+ "github.com/jinzhu/gorm"
|
|
11
|
+ "strconv"
|
|
12
|
+ "time"
|
|
13
|
+)
|
|
14
|
+
|
|
15
|
+type NewManageApiController struct {
|
|
16
|
+ mobile_api_controllers.MobileBaseAPIAuthController
|
|
17
|
+}
|
|
18
|
+
|
|
19
|
+func (this *NewManageApiController) GetEquitAutoInfo() {
|
|
20
|
+
|
|
21
|
+ adminUser := this.GetMobileAdminUserInfo()
|
|
22
|
+ orgid := adminUser.Org.Id
|
|
23
|
+ remander, err := service.GetRemanderData(orgid)
|
|
24
|
+ if err != nil {
|
|
25
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
26
|
+ return
|
|
27
|
+ }
|
|
28
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
29
|
+ "remander": remander,
|
|
30
|
+ })
|
|
31
|
+}
|
|
32
|
+
|
|
33
|
+func (this *NewManageApiController) GetDisInfectionTime() {
|
|
34
|
+ adminUser := this.GetMobileAdminUserInfo()
|
|
35
|
+ orgid := adminUser.Org.Id
|
|
36
|
+ bedid, _ := this.GetInt64("bed_id")
|
|
37
|
+ scheduletype, _ := this.GetInt64("schedule_type")
|
|
38
|
+ scheduleweek, _ := this.GetInt64("schedule_week")
|
|
39
|
+ fmt.Println(scheduleweek)
|
|
40
|
+ //查询改设备是否有消毒计划
|
|
41
|
+ plan, err := service.GetDisInfectionTime(orgid, bedid, scheduletype, scheduleweek)
|
|
42
|
+ if err == gorm.ErrRecordNotFound {
|
|
43
|
+ //去查询使用登记最后一条数据
|
|
44
|
+ infomation, err := service.GetLaseDeviceInfomation(orgid, bedid)
|
|
45
|
+ if err != nil {
|
|
46
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
47
|
+ return
|
|
48
|
+ }
|
|
49
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
50
|
+ "plan": infomation.LongTime,
|
|
51
|
+ })
|
|
52
|
+ } else if err == nil {
|
|
53
|
+ if err != nil {
|
|
54
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
55
|
+ return
|
|
56
|
+ }
|
|
57
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
58
|
+ "plan": plan.DisinfecTime,
|
|
59
|
+ })
|
|
60
|
+ } else {
|
|
61
|
+
|
|
62
|
+ }
|
|
63
|
+
|
|
64
|
+}
|
|
65
|
+
|
|
66
|
+func (this *NewManageApiController) SaveDisInfectionInfo() {
|
|
67
|
+ adminUser := this.GetMobileAdminUserInfo()
|
|
68
|
+ orgid := adminUser.Org.Id
|
|
69
|
+ bedid, _ := this.GetInt64("bed_id")
|
|
70
|
+ start_time := this.GetString("start_time")
|
|
71
|
+ startdate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", start_time)
|
|
72
|
+ startdateunix := startdate.Unix()
|
|
73
|
+ disinfectime, _ := this.GetInt64("disinfec_time")
|
|
74
|
+ endtime := this.GetString("end_time")
|
|
75
|
+ enddate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", endtime)
|
|
76
|
+ enddateunix := enddate.Unix()
|
|
77
|
+ scheduledate, _ := this.GetInt64("schedule_date")
|
|
78
|
+ zoneid, _ := this.GetInt64("zone_id")
|
|
79
|
+ patientid, _ := this.GetInt64("patient_id")
|
|
80
|
+ modeid, _ := this.GetInt64("mode_id")
|
|
81
|
+ scheduletype, _ := this.GetInt64("schedule_type")
|
|
82
|
+
|
|
83
|
+ //查询病人信息
|
|
84
|
+ patients, _ := service.GetPatientInfoMation(patientid)
|
|
85
|
+ var con = ""
|
|
86
|
+ if patients.IsInfectious == 0 {
|
|
87
|
+ con = ""
|
|
88
|
+ }
|
|
89
|
+ if patients.IsInfectious == 1 {
|
|
90
|
+ con = "无"
|
|
91
|
+ }
|
|
92
|
+ if patients.IsInfectious == 2 {
|
|
93
|
+ con = "有"
|
|
94
|
+ }
|
|
95
|
+ //查询病人上机信息
|
|
96
|
+ order, _ := service.GetPatientOrderInfo(scheduledate, patientid, orgid)
|
|
97
|
+ //查询病人今日透后评估数据
|
|
98
|
+ dislysis, _ := service.GetAssessmentAfterDissDataTwo(patientid, orgid, scheduledate)
|
|
99
|
+ fmt.Println("透析减少", dislysis.WeightLoss)
|
|
100
|
+ // //根据床位号获取设备id
|
|
101
|
+ addmacher, _ := service.GetEquimentIDTwo(bedid, orgid)
|
|
102
|
+ unitype, _ := strconv.ParseInt(addmacher.UnitType, 10, 64)
|
|
103
|
+ fmt.Println(unitype)
|
|
104
|
+ plan, errplan := service.GetDisinfectionTwo(unitype, scheduletype, orgid)
|
|
105
|
+ //counts, errplan := service.GetUserTotalCount(orgid, bedid)
|
|
106
|
+ //var usertoal int64
|
|
107
|
+ //fmt.Println(usertoal)
|
|
108
|
+ //for index, count := range counts {
|
|
109
|
+ // if(index == 0){
|
|
110
|
+ // usertoal = count.Total
|
|
111
|
+ // }
|
|
112
|
+ //}
|
|
113
|
+ //usertotalint, errplan := strconv.ParseInt(addmacher.UserTotal, 10, 64)
|
|
114
|
+ //var total = usertoal + usertotalint
|
|
115
|
+ //totals := strconv.FormatInt(total, 10)
|
|
116
|
+ if errplan == gorm.ErrRecordNotFound {
|
|
117
|
+ returnData := make(map[string]interface{}, 0)
|
|
118
|
+ returnData["msstatus"] = "2"
|
|
119
|
+ this.ServeSuccessJSON(returnData)
|
|
120
|
+ return
|
|
121
|
+ } else {
|
|
122
|
+ _, errcode := service.GetInforTwo(patientid, scheduledate, orgid, scheduletype)
|
|
123
|
+ if errcode == gorm.ErrRecordNotFound {
|
|
124
|
+ information := models.DeviceInformation{
|
|
125
|
+ Date: scheduledate,
|
|
126
|
+ Zone: zoneid,
|
|
127
|
+ Class: scheduletype,
|
|
128
|
+ BedNumber: bedid,
|
|
129
|
+ PatientId: patientid,
|
|
130
|
+ DialysisMode: modeid,
|
|
131
|
+ LongTime: strconv.FormatInt(disinfectime, 10),
|
|
132
|
+ Disinfection: 1,
|
|
133
|
+ DialysisConcentration: 1,
|
|
134
|
+ DisinfectionStatus: 1,
|
|
135
|
+ Move: 1,
|
|
136
|
+ UserOrgId: orgid,
|
|
137
|
+ DisinfectType: plan.Way,
|
|
138
|
+ DisinfectantType: plan.MachineDisinfectant,
|
|
139
|
+ FluidPath: plan.DisinfectanWay, //液路消毒方式
|
|
140
|
+ Disinfectant: plan.Disinfectant,
|
|
141
|
+ Ctime: time.Now().Unix(),
|
|
142
|
+ Status: 1,
|
|
143
|
+ SignName: order.FinishNurse,
|
|
144
|
+ EquimentId: addmacher.ID,
|
|
145
|
+ DisinfectionResidue: 2,
|
|
146
|
+ Bed: addmacher.BedNumber,
|
|
147
|
+ StartTime: order.StartTime,
|
|
148
|
+ EndTime: order.EndTime,
|
|
149
|
+ Contagion: con,
|
|
150
|
+ WeightLoss: dislysis.WeightLoss,
|
|
151
|
+ Hyperfiltratio: dislysis.ActualUltrafiltration,
|
|
152
|
+ DialysisHour: strconv.FormatInt(dislysis.ActualTreatmentHour, 10),
|
|
153
|
+ MachineRun: 1,
|
|
154
|
+ DisinfecStartime: startdateunix,
|
|
155
|
+ DisinfecEndtime: enddateunix,
|
|
156
|
+ }
|
|
157
|
+ err := service.CreateInformationTwo(&information)
|
|
158
|
+ fmt.Println("报错", err)
|
|
159
|
+ if err != nil {
|
|
160
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
161
|
+ return
|
|
162
|
+ }
|
|
163
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
164
|
+ "information": information,
|
|
165
|
+ })
|
|
166
|
+ } else if errcode == nil {
|
|
167
|
+
|
|
168
|
+ returnData := make(map[string]interface{}, 0)
|
|
169
|
+ returnData["msstatus"] = "1"
|
|
170
|
+ this.ServeSuccessJSON(returnData)
|
|
171
|
+ return
|
|
172
|
+ } else {
|
|
173
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
174
|
+ return
|
|
175
|
+ }
|
|
176
|
+ }
|
|
177
|
+}
|