陈少旭 hace 1 año
padre
commit
acfe899630

+ 35 - 0
controllers/gobal_config_api_controller.go Ver fichero

@@ -124,10 +124,45 @@ func GobalConfigRegistRouters() {
124 124
 
125 125
 	beego.Router("/api/schedule/config/commit", &GobalConfigApiController{}, "post:PostScheduleConfig")
126 126
 	beego.Router("/api/schedule/config/get", &GobalConfigApiController{}, "get:GetScheduleConfig")
127
+
128
+	beego.Router("/api/checkremind/config/commit", &GobalConfigApiController{}, "post:PostCheckRemindConfig")
129
+	beego.Router("/api/checkremind/config/get", &GobalConfigApiController{}, "get:GetCheckRemindConfig")
127 130
 }
128 131
 
129 132
 //provinces, _ := service.GetDistrictsByUpid(0)21
130 133
 
134
+func (c *GobalConfigApiController) PostCheckRemindConfig() {
135
+	is_open, _ := c.GetInt64("is_open", 0)
136
+	id, _ := c.GetInt64("id", 0)
137
+
138
+	config, _ := service.GetCheckRemindConfigByIdTwo(id)
139
+	var err error
140
+	if config.ID == 0 {
141
+		config.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
142
+		config.Ctime = time.Now().Unix()
143
+		config.Mtime = time.Now().Unix()
144
+		config.Status = 1
145
+		config.IsOpen = is_open
146
+		err = service.CreateCheckRemindConfig(&config)
147
+	} else {
148
+		config.IsOpen = is_open
149
+		config.Mtime = time.Now().Unix()
150
+		err = service.SaveCheckRemindConfig(&config)
151
+	}
152
+	if err == nil {
153
+		c.ServeSuccessJSON(map[string]interface{}{
154
+			"config": config,
155
+		})
156
+	}
157
+}
158
+
159
+func (c *GobalConfigApiController) GetCheckRemindConfig() {
160
+	config, _ := service.GetCheckRemindConfigById(c.GetAdminUserInfo().CurrentOrgId)
161
+	c.ServeSuccessJSON(map[string]interface{}{
162
+		"config": config,
163
+	})
164
+}
165
+
131 166
 func (c *GobalConfigApiController) PostScheduleConfig() {
132 167
 	is_show_mode, _ := c.GetInt64("is_show_mode", 0)
133 168
 	is_show_machine, _ := c.GetInt64("is_show_machine", 0)

+ 1 - 1
controllers/his_api_controller.go Ver fichero

@@ -6972,7 +6972,7 @@ func (c *HisApiController) GetUploadInfo() {
6972 6972
 			//扣押金
6973 6973
 			errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
6974 6974
 			order.Decimal = decimal
6975
-			service.UpDateOrderTwo(order)
6975
+			service.UpDateOrderTwo(order, tx)
6976 6976
 			if errmsg != nil {
6977 6977
 				c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
6978 6978
 				//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)

+ 41 - 0
controllers/his_charge_api_controller.go Ver fichero

@@ -21,6 +21,9 @@ func HisChargeApiRegistRouters() {
21 21
 	//beego.Router("/api/his/chargestatistics/settle", &HisChargeApiController{}, "get:GetChargeStatisticsSettle")
22 22
 
23 23
 	beego.Router("/api/his/inspectionlist/get", &HisChargeApiController{}, "get:GetHisInspectionList")
24
+
25
+	beego.Router("/api/his/inspectionlisttwo/get", &HisChargeApiController{}, "get:GetHisInspectionListTwo")
26
+
24 27
 	beego.Router("/api/his/inspectioninfo/get", &HisChargeApiController{}, "get:GetHisInspectionInfo")
25 28
 
26 29
 	//发票
@@ -341,6 +344,44 @@ func (c *HisChargeApiController) GetHisInspectionList() {
341 344
 	}
342 345
 
343 346
 }
347
+
348
+func (c *HisChargeApiController) GetHisInspectionListTwo() {
349
+	record_date := c.GetString("record_date")
350
+	keyword := c.GetString("keyword")
351
+	is_print, _ := c.GetInt64("is_print")
352
+	tube_color, _ := c.GetInt64("tube_color")
353
+	adminUser := c.GetAdminUserInfo()
354
+
355
+	timeLayout := "2006-01-02"
356
+	loc, _ := time.LoadLocation("Local")
357
+	startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
358
+	if err != nil {
359
+
360
+	}
361
+	record_time := startTime.Unix()
362
+	var labels []*models.HisLabelPrintInfo
363
+	//var labels_two []*models.HisLabelPrintInfo
364
+
365
+	//var total int64
366
+	//var total_two int64
367
+
368
+	labels, _, err = service.GetLabelPrintListThree(adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
369
+	//labels_two, total_two, err = service.GetLabelPrintListFour(adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
370
+	//total = total + total_two
371
+	//labels = append(labels, labels_two...)
372
+	if err == nil {
373
+		c.ServeSuccessJSON(map[string]interface{}{
374
+			"labels": labels,
375
+			//"total":  total,
376
+		})
377
+		return
378
+	} else {
379
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
380
+		return
381
+	}
382
+
383
+}
384
+
344 385
 func (c *HisChargeApiController) GetHisInspectionInfo() {
345 386
 	id, _ := c.GetInt64("id")
346 387
 	label, err := service.GetLabelPrintInfo(id)

+ 68 - 39
controllers/his_hospital_api_controller.go Ver fichero

@@ -40,6 +40,35 @@ func HisHospitalManagerApiRegistRouters() {
40 40
 
41 41
 	beego.Router("/api/exportuncharge/get", &HisHospitalApiController{}, "get:GetExportHisHospitalUnChargeData")
42 42
 
43
+	beego.Router("/api/hospital/inhopitalcheck/list", &HisHospitalApiController{}, "get:GetZHInHospitalCheckList")
44
+
45
+}
46
+func (this *HisHospitalApiController) GetZHInHospitalCheckList() {
47
+	timeLayout := "2006-01-02"
48
+	loc, _ := time.LoadLocation("Local")
49
+	keyword := this.GetString("keyword")
50
+	start_time := this.GetString("start_time")
51
+	end_time := this.GetString("end_time")
52
+	limit, _ := this.GetInt64("limit")
53
+	page, _ := this.GetInt64("page")
54
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+":00", loc)
55
+	endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+":59", loc)
56
+	adminUserInfo := this.GetAdminUserInfo()
57
+	orgId := adminUserInfo.CurrentOrgId
58
+	history, total, err := service.GetHisInHospitalHistory(keyword, startTime.Unix(), endTime.Unix(), limit, page, orgId)
59
+	department, err := service.GetAllDepartMent(orgId)
60
+	appId := adminUserInfo.CurrentAppId
61
+	doctor, err := service.GetAllDoctor(orgId, appId)
62
+	if err != nil {
63
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
64
+		return
65
+	}
66
+	this.ServeSuccessJSON(map[string]interface{}{
67
+		"history":    history,
68
+		"total":      total,
69
+		"department": department,
70
+		"doctor":     doctor,
71
+	})
43 72
 }
44 73
 func (c *HisHospitalApiController) RefundDetail() {
45 74
 	patient_id, _ := c.GetInt64("patient_id")
@@ -153,56 +182,56 @@ func (c *HisHospitalApiController) GetUploadInfo() {
153 182
 		tm := time.Unix(item.PreTime, 0)
154 183
 		if item.Type == 1 { //药品
155 184
 			for _, subItem := range item.HisDoctorAdviceInfo {
156
-				if len(subItem.Drug.MedicalInsuranceNumber) > 0 && subItem.Drug.IsUser != 1 {
157
-					//var randNum int
158
-					//randNum = rand.Intn(10000) + 1000
159
-					cus := &models.NewCustom{
160
-						DetItemFeeSumamt: subItem.Price * subItem.PrescribingNumber,
161
-						Cut:              subItem.PrescribingNumber,
162
-						FeedetlSn:        subItem.FeedetlSn,
163
-						Price:            subItem.Price,
164
-						MedListCodg:      subItem.Drug.MedicalInsuranceNumber,
165
-						HospApprFlag:     subItem.Drug.HospApprFlag,
166
-						FeeOcurTime:      tm.Format("2006-01-02 15:04:05"),
167
-					}
168
-
169
-					customs = append(customs, cus)
185
+				//if subItem.Drug.IsUser != 1 {
186
+				//var randNum int
187
+				//randNum = rand.Intn(10000) + 1000
188
+				cus := &models.NewCustom{
189
+					DetItemFeeSumamt: subItem.Price * subItem.PrescribingNumber,
190
+					Cut:              subItem.PrescribingNumber,
191
+					FeedetlSn:        subItem.FeedetlSn,
192
+					Price:            subItem.Price,
193
+					MedListCodg:      subItem.Drug.MedicalInsuranceNumber,
194
+					HospApprFlag:     subItem.Drug.HospApprFlag,
195
+					FeeOcurTime:      tm.Format("2006-01-02 15:04:05"),
170 196
 				}
197
+
198
+				customs = append(customs, cus)
199
+				//}
171 200
 			}
172 201
 		}
173 202
 
174 203
 		if item.Type == 2 { //项目
175 204
 			for _, subItem := range item.HisPrescriptionProject {
176 205
 				if subItem.Type == 2 {
177
-					if len(subItem.HisProject.MedicalCode) > 0 {
178
-						cnt, _ := strconv.ParseFloat(subItem.Count, 64)
179
-						cus := &models.NewCustom{
180
-							DetItemFeeSumamt: subItem.Price * cnt,
181
-							Cut:              cnt,
182
-							FeedetlSn:        subItem.FeedetlSn,
183
-							Price:            float64(subItem.Price),
184
-							MedListCodg:      subItem.HisProject.MedicalCode,
185
-							HospApprFlag:     -1,
186
-							FeeOcurTime:      tm.Format("2006-01-02 15:04:05"),
187
-						}
188
-						customs = append(customs, cus)
206
+					//if len(subItem.HisProject.MedicalCode) > 0 {
207
+					cnt, _ := strconv.ParseFloat(subItem.Count, 64)
208
+					cus := &models.NewCustom{
209
+						DetItemFeeSumamt: subItem.Price * cnt,
210
+						Cut:              cnt,
211
+						FeedetlSn:        subItem.FeedetlSn,
212
+						Price:            float64(subItem.Price),
213
+						MedListCodg:      subItem.HisProject.MedicalCode,
214
+						HospApprFlag:     -1,
215
+						FeeOcurTime:      tm.Format("2006-01-02 15:04:05"),
189 216
 					}
217
+					customs = append(customs, cus)
218
+					//}/* *//**/
190 219
 				} else if subItem.Type == 3 {
191
-					if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 && subItem.GoodInfo.IsUser != 1 {
192
-						cnt, _ := strconv.ParseFloat(subItem.Count, 64)
193
-
194
-						cus := &models.NewCustom{
195
-							DetItemFeeSumamt: subItem.Price * cnt,
196
-							Cut:              cnt,
197
-							FeedetlSn:        subItem.FeedetlSn,
198
-							Price:            float64(subItem.Price),
199
-							MedListCodg:      subItem.GoodInfo.MedicalInsuranceNumber,
200
-							HospApprFlag:     -1,
201
-							FeeOcurTime:      tm.Format("2006-01-02 15:04:05"),
202
-						}
203
-						customs = append(customs, cus)
220
+					//if subItem.GoodInfo.IsUser != 1 {
221
+					cnt, _ := strconv.ParseFloat(subItem.Count, 64)
222
+
223
+					cus := &models.NewCustom{
224
+						DetItemFeeSumamt: subItem.Price * cnt,
225
+						Cut:              cnt,
226
+						FeedetlSn:        subItem.FeedetlSn,
227
+						Price:            float64(subItem.Price),
228
+						MedListCodg:      subItem.GoodInfo.MedicalInsuranceNumber,
229
+						HospApprFlag:     -1,
230
+						FeeOcurTime:      tm.Format("2006-01-02 15:04:05"),
204 231
 					}
232
+					customs = append(customs, cus)
205 233
 				}
234
+				//}
206 235
 			}
207 236
 		}
208 237
 

+ 101 - 0
controllers/his_print_api_controller.go Ver fichero

@@ -15,8 +15,109 @@ type HisPrintApiController struct {
15 15
 
16 16
 func HisPrintApiRegistRouters() {
17 17
 	beego.Router("/api/his/prescription/print", &HisPrintApiController{}, "get:GetBatchHisPrescriptionData")
18
+	beego.Router("/api/his/prescription/list", &HisPrintApiController{}, "get:GetUnChargePrescriptionList")
19
+	beego.Router("/api/his/prescription/summary", &HisPrintApiController{}, "get:GetUnChargePrescriptionSummary")
20
+	beego.Router("/api/his/label/create", &HisPrintApiController{}, "get:CreateLablePrint")
21
+	beego.Router("/api/his/label/get", &HisPrintApiController{}, "get:GetLablePrint")
22
+
23
+}
24
+
25
+func (c *HisPrintApiController) GetLablePrint() {
26
+	patient_id, _ := c.GetInt64("patient_id")
27
+	ids := c.GetString("ids")
28
+	record_date := c.GetString("record_date")
29
+	labels, _ := service.GetLabelPrint(ids, c.GetAdminUserInfo().CurrentOrgId, record_date, patient_id)
30
+	c.ServeSuccessJSON(map[string]interface{}{
31
+		"labels": labels,
32
+	})
33
+	return
18 34
 }
19 35
 
36
+func (c *HisPrintApiController) CreateLablePrint() {
37
+	patient_id, _ := c.GetInt64("patient_id")
38
+	isCombinationPrint, _ := c.GetBool("is_combination_print")
39
+	team_ids := c.GetString("team_ids")
40
+	ids := c.GetString("ids")
41
+	record_date := c.GetString("record_date")
42
+	doctor_id, _ := c.GetInt64("doctor_id")
43
+	project_ids := c.GetString("project_ids")
44
+	is_team, _ := c.GetInt64("is_team")
45
+
46
+	var hlpsi models.HisLabelPrintStatusInfo
47
+	hlpsi.Status = 1
48
+	hlpsi.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
49
+	hlpsi.PatientId = patient_id
50
+	hlpsi.RecordDate = record_date
51
+	hlpsi.Mtime = time.Now().Unix()
52
+	hlpsi.Ctime = time.Now().Unix()
53
+	hlpsi.ItemIds = team_ids
54
+	hlpsi.ProjectIds = project_ids
55
+	hlpsi.Ids = ids
56
+	hlpsi.DoctorId = doctor_id
57
+	hlpsi.IsTeam = is_team
58
+	hlpsi.IsPrint = 1
59
+	if isCombinationPrint == true {
60
+		hlpsi.IsCombinationPrint = 1
61
+	} else {
62
+		hlpsi.IsCombinationPrint = 0
63
+	}
64
+	service.CreateLabelPrint(&hlpsi)
65
+	c.ServeSuccessJSON(map[string]interface{}{
66
+		"msg":   "保存成功",
67
+		"hlpsi": hlpsi,
68
+	})
69
+	return
70
+}
71
+
72
+func (c *HisPrintApiController) GetUnChargePrescriptionList() {
73
+	patient_id, _ := c.GetInt64("patient_id")
74
+	recordDateTime, _ := c.GetInt64("record_date")
75
+	admin_user_id, _ := c.GetInt64("admin_user_id")
76
+	p_type, _ := c.GetInt64("p_type", 0)
77
+	admin := c.GetAdminUserInfo()
78
+	xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
79
+	record, _ := service.GetLastInHospitalRecord(patient_id, c.GetAdminUserInfo().CurrentOrgId)
80
+	var prescriptions []*models.HisPrescription
81
+	prescriptions, _ = service.GetUnChargeHisPrescriptionTen(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
82
+	admin_info, _ := service.GetAdminUserRole(admin_user_id, c.GetAdminUserInfo().CurrentOrgId)
83
+	//获取所有科室信息
84
+	c.ServeSuccessJSON(map[string]interface{}{
85
+		"xt_info":      xt_patient_info,
86
+		"prescription": prescriptions,
87
+		"record":       record,
88
+		"admin_info":   admin_info,
89
+	})
90
+	return
91
+}
92
+func (c *HisPrintApiController) GetUnChargePrescriptionSummary() {
93
+	patient_id, _ := c.GetInt64("patient_id")
94
+	record_date, _ := c.GetInt64("record_date")
95
+	admin_user_id, _ := c.GetInt64("admin_user_id")
96
+	p_type, _ := c.GetInt64("p_type", 0)
97
+	//timeLayout := "2006-01-02"
98
+	//loc, _ := time.LoadLocation("Local")
99
+	//theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
100
+	//if err != nil {
101
+	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
102
+	//	return
103
+	//}
104
+	//recordDateTime := theTime.Unix()
105
+	admin := c.GetAdminUserInfo()
106
+	xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
107
+	record, _ := service.GetLastInHospitalRecord(patient_id, c.GetAdminUserInfo().CurrentOrgId)
108
+	var prescriptions []*models.HisPrescription
109
+	prescriptions, _ = service.GetUnChargeHisPrescriptionTen(admin.CurrentOrgId, patient_id, record_date, p_type)
110
+	//doctors, _ := service.GetHisAdminUserDoctors(admin.CurrentOrgId)
111
+	service.GetAdminUserRole(admin_user_id, c.GetAdminUserInfo().CurrentOrgId)
112
+	//获取所有科室信息
113
+	c.ServeSuccessJSON(map[string]interface{}{
114
+		"xt_info":      xt_patient_info,
115
+		"prescription": prescriptions,
116
+		"record":       record,
117
+		"admin_info":   admin_user_id,
118
+	})
119
+	return
120
+}
20 121
 func (c *HisPrintApiController) GetBatchHisPrescriptionData() {
21 122
 	record_date := c.GetString("record_date")
22 123
 	patient_ids := c.GetString("patient_ids")

+ 304 - 63
controllers/inspection_api_controller.go Ver fichero

@@ -30,6 +30,92 @@ func InspectionApiRegistRouters() {
30 30
 	beego.Router("/api/patient/pic_inspection/create", &InspectionApiController{}, "Post:CreatePatientPicInspection")
31 31
 	beego.Router("/api/patient/pic_inspection/edit", &InspectionApiController{}, "Post:EditPatientPicInspection")
32 32
 
33
+	beego.Router("/api/patient/inspection_remind/get", &InspectionApiController{}, "Get:GetInspectionRemind")
34
+
35
+	beego.Router("/api/patient/inspection_remind/set", &InspectionApiController{}, "Get:SetInspectionRemind")
36
+
37
+}
38
+func (c *InspectionApiController) SetInspectionRemind() {
39
+	remind_cycle, _ := c.GetInt64("remind_cycle", 0)
40
+	patient, _ := c.GetInt64("patient", 0)
41
+	project_id, _ := c.GetInt64("project_id", 0)
42
+	is_open, _ := c.GetInt64("is_open", 0)
43
+
44
+	if remind_cycle > 0 {
45
+		infectiousRecord, _ := service.FindLastRecordDate(c.GetAdminUserInfo().CurrentOrgId, patient, project_id)
46
+		fmt.Println(infectiousRecord.InspectDate)
47
+		var record_time int64
48
+		switch remind_cycle {
49
+		case 1: //1个月
50
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
51
+			record_time = ts.AddDate(0, 1, 0).Unix()
52
+			fmt.Println(record_time)
53
+			break
54
+		case 2: //2个月
55
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
56
+			record_time = ts.AddDate(0, 2, 0).Unix()
57
+			fmt.Println(record_time)
58
+
59
+			break
60
+		case 3: //3个月
61
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
62
+			record_time = ts.AddDate(0, 3, 0).Unix()
63
+			fmt.Println(record_time)
64
+
65
+			break
66
+		case 4: //6个月
67
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
68
+			record_time = ts.AddDate(0, 6, 0).Unix()
69
+			fmt.Println(record_time)
70
+
71
+			break
72
+		case 5: //12个月
73
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
74
+			record_time = ts.AddDate(0, 12, 0).Unix()
75
+			fmt.Println(record_time)
76
+
77
+			break
78
+		}
79
+		var errs error
80
+
81
+		if infectiousRecord.ID == 0 {
82
+			record_time = 0
83
+		}
84
+		//根据project_id查找是否存在提醒记录,没有的话新建,有的话更新提醒时间
85
+		reminds, _ := service.GetCheckRemindRecordTime(c.GetAdminUserInfo().CurrentOrgId, patient, project_id)
86
+		if reminds.ID == 0 {
87
+			remind := models.XtCheckRemind{
88
+				ProjectId:      project_id,
89
+				UserOrgId:      c.GetAdminUserInfo().CurrentOrgId,
90
+				Status:         1,
91
+				LastRemindDate: record_time,
92
+				PatientId:      patient,
93
+				RemindCycle:    remind_cycle,
94
+				IsOpen:         is_open,
95
+			}
96
+			errs = service.CreateRemind(remind)
97
+		} else {
98
+			errs = service.UpDateCheckRemindRecordTime(c.GetAdminUserInfo().CurrentOrgId, patient, record_time, project_id, remind_cycle)
99
+		}
100
+		fmt.Println(errs)
101
+		c.ServeSuccessJSON(map[string]interface{}{
102
+			"remind_cycle": remind_cycle,
103
+		})
104
+	} else {
105
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
106
+		return
107
+
108
+	}
109
+
110
+}
111
+
112
+func (c *InspectionApiController) GetInspectionRemind() {
113
+	patient, _ := c.GetInt64("patient")
114
+	project_id, _ := c.GetInt64("project_id")
115
+	remind, _ := service.GetCheckRemindRecordTime(c.GetAdminUserInfo().CurrentOrgId, patient, project_id)
116
+	c.ServeSuccessJSON(map[string]interface{}{
117
+		"remind": remind,
118
+	})
33 119
 }
34 120
 
35 121
 // PatientInspectionReference 请求检验检查大小项目
@@ -182,53 +268,101 @@ func (c *InspectionApiController) CreatePatientInspection() {
182 268
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionAddFail)
183 269
 		return
184 270
 	}
185
-
186
-	if remind_cycle > 0 {
187
-		infectiousRecord, _ := service.FindLastRecordDate(adminUserInfo.CurrentOrgId, patient, 14)
188
-		fmt.Println(infectiousRecord.InspectDate)
189
-		var record_time int64
190
-		switch remind_cycle {
191
-		case 1: //1个月
192
-			ts := time.Unix(infectiousRecord.InspectDate, 0)
193
-			record_time = ts.AddDate(0, 1, 0).Unix()
194
-			fmt.Println(record_time)
195
-			break
196
-		case 2: //2个月
197
-			ts := time.Unix(infectiousRecord.InspectDate, 0)
198
-			record_time = ts.AddDate(0, 2, 0).Unix()
199
-			fmt.Println(record_time)
200
-
201
-			break
202
-		case 3: //3个月
203
-			ts := time.Unix(infectiousRecord.InspectDate, 0)
204
-			record_time = ts.AddDate(0, 3, 0).Unix()
205
-			fmt.Println(record_time)
206
-
207
-			break
208
-		case 4: //6个月
209
-			ts := time.Unix(infectiousRecord.InspectDate, 0)
210
-			record_time = ts.AddDate(0, 6, 0).Unix()
211
-			fmt.Println(record_time)
212
-
213
-			break
214
-		case 5: //12个月
215
-			ts := time.Unix(infectiousRecord.InspectDate, 0)
216
-			record_time = ts.AddDate(0, 12, 0).Unix()
217
-			fmt.Println(record_time)
218
-
219
-			break
271
+	if inspections[0].ProjectId == 14 {
272
+		if remind_cycle > 0 {
273
+			infectiousRecord, _ := service.FindLastRecordDate(adminUserInfo.CurrentOrgId, patient, inspections[0].ProjectId)
274
+			fmt.Println(infectiousRecord.InspectDate)
275
+			var record_time int64
276
+			switch remind_cycle {
277
+			case 1: //1个月
278
+				ts := time.Unix(infectiousRecord.InspectDate, 0)
279
+				record_time = ts.AddDate(0, 1, 0).Unix()
280
+				fmt.Println(record_time)
281
+				break
282
+			case 2: //2个月
283
+				ts := time.Unix(infectiousRecord.InspectDate, 0)
284
+				record_time = ts.AddDate(0, 2, 0).Unix()
285
+				fmt.Println(record_time)
286
+
287
+				break
288
+			case 3: //3个月
289
+				ts := time.Unix(infectiousRecord.InspectDate, 0)
290
+				record_time = ts.AddDate(0, 3, 0).Unix()
291
+				fmt.Println(record_time)
292
+
293
+				break
294
+			case 4: //6个月
295
+				ts := time.Unix(infectiousRecord.InspectDate, 0)
296
+				record_time = ts.AddDate(0, 6, 0).Unix()
297
+				fmt.Println(record_time)
298
+
299
+				break
300
+			case 5: //12个月
301
+				ts := time.Unix(infectiousRecord.InspectDate, 0)
302
+				record_time = ts.AddDate(0, 12, 0).Unix()
303
+				fmt.Println(record_time)
304
+
305
+				break
306
+			}
307
+			var errs error
308
+			if inspections[0].ProjectId == 14 {
309
+				errs = service.UpDateInfectiousRecordTime(adminUserInfo.CurrentOrgId, patient, record_time, remind_cycle)
310
+			}
311
+			if errs != nil {
312
+				utils.ErrorLog("更新日期出错:%v", errs)
313
+			}
220 314
 		}
221
-
222
-		errs := service.UpDateInfectiousRecordTime(adminUserInfo.CurrentOrgId, patient, record_time, remind_cycle)
223
-		if errs != nil {
224
-			utils.ErrorLog("更新日期出错:%v", errs)
315
+		c.ServeSuccessJSON(map[string]interface{}{
316
+			"inspections":  inspections,
317
+			"remind_cycle": remind_cycle,
318
+		})
319
+	} else {
320
+		//更新提醒时间
321
+		reminds, _ := service.GetCheckRemindRecordTime(adminUserInfo.CurrentOrgId, patient, inspections[0].ProjectId)
322
+		if reminds.ID > 0 {
323
+			infectiousRecord, _ := service.FindLastRecordDate(adminUserInfo.CurrentOrgId, patient, inspections[0].ProjectId)
324
+			var record_time int64
325
+			switch reminds.RemindCycle {
326
+			case 1: //1个月
327
+				ts := time.Unix(infectiousRecord.InspectDate, 0)
328
+				record_time = ts.AddDate(0, 1, 0).Unix()
329
+				fmt.Println(record_time)
330
+				break
331
+			case 2: //2个月
332
+				ts := time.Unix(infectiousRecord.InspectDate, 0)
333
+				record_time = ts.AddDate(0, 2, 0).Unix()
334
+				fmt.Println(record_time)
335
+
336
+				break
337
+			case 3: //3个月
338
+				ts := time.Unix(infectiousRecord.InspectDate, 0)
339
+				record_time = ts.AddDate(0, 3, 0).Unix()
340
+				fmt.Println(record_time)
341
+
342
+				break
343
+			case 4: //6个月
344
+				ts := time.Unix(infectiousRecord.InspectDate, 0)
345
+				record_time = ts.AddDate(0, 6, 0).Unix()
346
+				fmt.Println(record_time)
347
+
348
+				break
349
+			case 5: //12个月
350
+				ts := time.Unix(infectiousRecord.InspectDate, 0)
351
+				record_time = ts.AddDate(0, 12, 0).Unix()
352
+				fmt.Println(record_time)
353
+
354
+				break
355
+			}
356
+			errs := service.UpDateCheckRemindRecordTimeTwo(adminUserInfo.CurrentOrgId, patient, record_time, inspections[0].ProjectId)
357
+			if errs != nil {
358
+				utils.ErrorLog("更新日期出错:%v", errs)
359
+			}
225 360
 		}
361
+		c.ServeSuccessJSON(map[string]interface{}{
362
+			"inspections": inspections,
363
+		})
226 364
 	}
227 365
 
228
-	c.ServeSuccessJSON(map[string]interface{}{
229
-		"inspections":  inspections,
230
-		"remind_cycle": remind_cycle,
231
-	})
232 366
 	return
233 367
 }
234 368
 func (c *InspectionApiController) CreatePatientPicInspection() {
@@ -305,6 +439,52 @@ func (c *InspectionApiController) CreatePatientPicInspection() {
305 439
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionAddFail)
306 440
 		return
307 441
 	}
442
+
443
+	if inspections[0].ProjectId != 14 {
444
+		//更新提醒时间
445
+		reminds, _ := service.GetCheckRemindRecordTime(adminUserInfo.CurrentOrgId, patient, inspections[0].ProjectId)
446
+		if reminds.ID > 0 {
447
+			infectiousRecord, _ := service.FindLastRecordDate(adminUserInfo.CurrentOrgId, patient, inspections[0].ProjectId)
448
+			var record_time int64
449
+			switch reminds.RemindCycle {
450
+			case 1: //1个月
451
+				ts := time.Unix(infectiousRecord.InspectDate, 0)
452
+				record_time = ts.AddDate(0, 1, 0).Unix()
453
+				fmt.Println(record_time)
454
+				break
455
+			case 2: //2个月
456
+				ts := time.Unix(infectiousRecord.InspectDate, 0)
457
+				record_time = ts.AddDate(0, 2, 0).Unix()
458
+				fmt.Println(record_time)
459
+
460
+				break
461
+			case 3: //3个月
462
+				ts := time.Unix(infectiousRecord.InspectDate, 0)
463
+				record_time = ts.AddDate(0, 3, 0).Unix()
464
+				fmt.Println(record_time)
465
+
466
+				break
467
+			case 4: //6个月
468
+				ts := time.Unix(infectiousRecord.InspectDate, 0)
469
+				record_time = ts.AddDate(0, 6, 0).Unix()
470
+				fmt.Println(record_time)
471
+
472
+				break
473
+			case 5: //12个月
474
+				ts := time.Unix(infectiousRecord.InspectDate, 0)
475
+				record_time = ts.AddDate(0, 12, 0).Unix()
476
+				fmt.Println(record_time)
477
+
478
+				break
479
+			}
480
+			errs := service.UpDateCheckRemindRecordTimeTwo(adminUserInfo.CurrentOrgId, patient, record_time, inspections[0].ProjectId)
481
+			if errs != nil {
482
+				utils.ErrorLog("更新日期出错:%v", errs)
483
+			}
484
+		}
485
+
486
+	}
487
+
308 488
 	c.ServeSuccessJSON(map[string]interface{}{
309 489
 		"inspections": inspections,
310 490
 	})
@@ -595,6 +775,56 @@ func (c *InspectionApiController) DeletePatientInspection() {
595 775
 		return
596 776
 	}
597 777
 
778
+	//更新提醒时间
779
+	reminds, _ := service.GetCheckRemindRecordTime(adminUserInfo.CurrentOrgId, patient, ProjectId)
780
+	if reminds.ID > 0 {
781
+		infectiousRecord, _ := service.FindLastRecordDate(adminUserInfo.CurrentOrgId, patient, ProjectId)
782
+		fmt.Println(infectiousRecord)
783
+		if infectiousRecord.ID > 0 {
784
+			var record_time int64
785
+			switch reminds.RemindCycle {
786
+			case 1: //1个月
787
+				ts := time.Unix(infectiousRecord.InspectDate, 0)
788
+				record_time = ts.AddDate(0, 1, 0).Unix()
789
+				fmt.Println(record_time)
790
+				break
791
+			case 2: //2个月
792
+				ts := time.Unix(infectiousRecord.InspectDate, 0)
793
+				record_time = ts.AddDate(0, 2, 0).Unix()
794
+				fmt.Println(record_time)
795
+
796
+				break
797
+			case 3: //3个月
798
+				ts := time.Unix(infectiousRecord.InspectDate, 0)
799
+				record_time = ts.AddDate(0, 3, 0).Unix()
800
+				fmt.Println(record_time)
801
+
802
+				break
803
+			case 4: //6个月
804
+				ts := time.Unix(infectiousRecord.InspectDate, 0)
805
+				record_time = ts.AddDate(0, 6, 0).Unix()
806
+				fmt.Println(record_time)
807
+
808
+				break
809
+			case 5: //12个月
810
+				ts := time.Unix(infectiousRecord.InspectDate, 0)
811
+				record_time = ts.AddDate(0, 12, 0).Unix()
812
+				fmt.Println(record_time)
813
+
814
+				break
815
+			}
816
+			errs := service.UpDateCheckRemindRecordTimeTwo(adminUserInfo.CurrentOrgId, patient, record_time, ProjectId)
817
+			if errs != nil {
818
+				utils.ErrorLog("更新日期出错:%v", errs)
819
+			}
820
+		} else {
821
+			errs := service.UpDateCheckRemindRecordTimeTwo(adminUserInfo.CurrentOrgId, patient, 0, ProjectId)
822
+			if errs != nil {
823
+				utils.ErrorLog("更新日期出错:%v", errs)
824
+			}
825
+		}
826
+
827
+	}
598 828
 	c.ServeSuccessJSON(map[string]interface{}{
599 829
 		"msg": "ok",
600 830
 	})
@@ -625,10 +855,17 @@ func (c *InspectionApiController) GetPatientInspections() {
625 855
 		date = time.Unix(dateTime, 0).Format("2006-01-02 15:04")
626 856
 	}
627 857
 
858
+	remind, _ := service.GetCheckRemindRecordTime(c.GetAdminUserInfo().CurrentOrgId, patient, projectId)
859
+
860
+	//remind, _ := service.GetCheckRemindRecordTime(c.GetAdminUserInfo().CurrentOrgId, patient, projectId)
861
+	config, _ := service.GetCheckRemindConfigById(c.GetAdminUserInfo().CurrentOrgId)
862
+
628 863
 	c.ServeSuccessJSON(map[string]interface{}{
629 864
 		"inspections": inspections,
630 865
 		"total":       total,
631 866
 		"date":        date,
867
+		"remind":      remind,
868
+		"config":      config,
632 869
 	})
633 870
 	return
634 871
 
@@ -661,11 +898,12 @@ func (c *InspectionApiController) GetAllPatientInspection() {
661 898
 		for _, item := range ids {
662 899
 			id, _ := strconv.ParseInt(item, 10, 64)
663 900
 			inspection, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id, start_time, end_time)
664
-			//fmt.Println(err)
665
-			//if err != nil {
666
-			//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
667
-			//	return
668
-			//}
901
+			// fmt.Println(err)
902
+			//
903
+			//	if err != nil {
904
+			//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
905
+			//		return
906
+			//	}
669 907
 			for _, inspection_item := range inspection {
670 908
 				inspections = append(inspections, inspection_item)
671 909
 			}
@@ -699,11 +937,12 @@ func (c *InspectionApiController) GetAllPatientInspection() {
699 937
 		for _, item := range ids {
700 938
 			id, _ := strconv.ParseInt(item, 10, 64)
701 939
 			inspection, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id, start_time, end_time)
702
-			//fmt.Println(err)
703
-			//if err != nil {
704
-			//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
705
-			//	return
706
-			//}
940
+			// fmt.Println(err)
941
+			//
942
+			//	if err != nil {
943
+			//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
944
+			//		return
945
+			//	}
707 946
 			for _, inspection_item := range inspection {
708 947
 				inspections = append(inspections, inspection_item)
709 948
 			}
@@ -757,11 +996,12 @@ func (c *InspectionApiController) GetAllPatientInspection() {
757 996
 		for _, item := range ids {
758 997
 			id, _ := strconv.ParseInt(item, 10, 64)
759 998
 			inspection, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id, start_time, end_time)
760
-			//fmt.Println(err)
761
-			//if err != nil {
762
-			//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
763
-			//	return
764
-			//}
999
+			// fmt.Println(err)
1000
+			//
1001
+			//	if err != nil {
1002
+			//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1003
+			//		return
1004
+			//	}
765 1005
 			for _, inspection_item := range inspection {
766 1006
 				inspections = append(inspections, inspection_item)
767 1007
 			}
@@ -779,11 +1019,12 @@ func (c *InspectionApiController) GetAllPatientInspection() {
779 1019
 		for _, item := range ids {
780 1020
 			id, _ := strconv.ParseInt(item, 10, 64)
781 1021
 			inspection, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id, start_time, end_time)
782
-			//fmt.Println(err)
783
-			//if err != nil {
784
-			//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
785
-			//	return
786
-			//}
1022
+			// fmt.Println(err)
1023
+			//
1024
+			//	if err != nil {
1025
+			//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1026
+			//		return
1027
+			//	}
787 1028
 			for _, inspection_item := range inspection {
788 1029
 				inspections = append(inspections, inspection_item)
789 1030
 			}

+ 7 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go Ver fichero

@@ -575,6 +575,11 @@ func (this *DialysisAPIController) DialysisRecord() {
575 575
 	}
576 576
 
577 577
 	lastOrder, _ := service.GetLastDilysisOrder(adminInfo.Org.Id, patientID, date.Unix())
578
+	remind_config, _ := service.GetCheckRemindConfigById(adminInfo.Org.Id)
579
+	var remind_lists []models.XtCheckRemind
580
+	if remind_config.ID > 0 && remind_config.IsOpen == 1 {
581
+		remind_lists, _ = service.GetAllInspectionRemind(adminInfo.Org.Id, patientID)
582
+	}
578 583
 	returnData := map[string]interface{}{
579 584
 		"patient":                        patient,
580 585
 		"schedual":                       schedual,
@@ -608,7 +613,9 @@ func (this *DialysisAPIController) DialysisRecord() {
608 613
 		"is_advice_open":                 is_advice_open,
609 614
 		"prescription_open":              prescriptionConfig.IsOpen,
610 615
 		"lastOrder":                      lastOrder,
616
+		"remind_lists":                   remind_lists,
611 617
 	}
618
+
612 619
 	this.ServeSuccessJSON(returnData)
613 620
 }
614 621
 

+ 16 - 0
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go Ver fichero

@@ -2895,3 +2895,19 @@ func (this *NewDialysisApiController) CommitDialysisOrder() {
2895 2895
 	}
2896 2896
 
2897 2897
 }
2898
+
2899
+func (this *NewDialysisApiController) GetAllInspectionReminds() {
2900
+	org_id := this.GetMobileAdminUserInfo().Org.Id
2901
+	patient_id, _ := this.GetInt64("patient_id")
2902
+	reminds, err := service.GetAllInspectionRemind(org_id, patient_id)
2903
+	if err == nil {
2904
+		this.ServeSuccessJSON(map[string]interface{}{
2905
+			"reminds": reminds,
2906
+		})
2907
+		return
2908
+	} else {
2909
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2910
+		return
2911
+	}
2912
+
2913
+}

+ 2 - 0
controllers/new_mobile_api_controllers/new_mobile_api_router_register.go Ver fichero

@@ -183,4 +183,6 @@ func NewMobileAPIControllersRegisterRouters() {
183 183
 	beego.Router("/m/api/patient/getpatientplan", &MobileHisApiController{}, "Get:GetPatientPlan")
184 184
 	beego.Router("/m/api/patient/togetpatient", &MobileHisApiController{}, "Get:ToGetPatient")
185 185
 
186
+	beego.Router("m/api/patient/inspection_reminds", &NewDialysisApiController{}, "Get:GetAllInspectionReminds")
187
+
186 188
 }

+ 171 - 2
controllers/statistics_api_controller.go Ver fichero

@@ -1,8 +1,12 @@
1 1
 package controllers
2 2
 
3 3
 import (
4
+	"XT_New/enums"
4 5
 	"XT_New/service"
6
+	"XT_New/utils"
7
+	"fmt"
5 8
 	"github.com/astaxie/beego"
9
+	"strconv"
6 10
 	"time"
7 11
 )
8 12
 
@@ -13,7 +17,174 @@ type StatisticsApiController struct {
13 17
 func StatisticsApiRegistRouters() {
14 18
 
15 19
 	beego.Router("/api/statistisc/index", &StatisticsApiController{}, "get:GetStatistics")
20
+	beego.Router("/api/qc/statistiscall/get", &StatisticsApiController{}, "get:GetAllInspectionStatistisc")
21
+	beego.Router("/api/qc/statistiscperson/get", &StatisticsApiController{}, "get:GetPersonInspectionStatistisc")
16 22
 
23
+	beego.Router("/api/qc/patientstatistiscall/get", &StatisticsApiController{}, "get:GetPatientInspectionStatistisc")
24
+
25
+	//beego.Router("/api/qc/statistiscperson/export", &StatisticsApiController{}, "get:ExportPersonInspectionStatistisc")
26
+
27
+}
28
+func (c *StatisticsApiController) GetPatientInspectionStatistisc() {
29
+	start_date := c.GetString("start_date")
30
+	end_date := c.GetString("end_date")
31
+	project_id, _ := c.GetInt64("project_id")
32
+	item_id, _ := c.GetInt64("item_id")
33
+	item_type, _ := c.GetInt64("item_type")
34
+	order_type, _ := c.GetInt64("order_type")
35
+	keyword := c.GetString("key_word")
36
+
37
+	timeLayout := "2006-01-02"
38
+	loc, _ := time.LoadLocation("Local")
39
+	var startTime int64
40
+	if len(start_date) > 0 {
41
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_date+" 00:00:00", loc)
42
+		fmt.Println("err-----------", err)
43
+		if err != nil {
44
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
45
+			return
46
+		}
47
+		startTime = theTime.Unix()
48
+	}
49
+	var endTime int64
50
+	if len(end_date) > 0 {
51
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_date+" 23:59:59", loc)
52
+		if err != nil {
53
+			utils.ErrorLog(err.Error())
54
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
55
+			return
56
+		}
57
+		endTime = theTime.Unix()
58
+	}
59
+
60
+	//获取配置
61
+	reference, _ := service.GetInspectionReferenceThree(project_id, item_id)
62
+	//获取数值在正常范围内的总数
63
+
64
+	max, _ := strconv.ParseFloat(reference.RangeMax, 64)
65
+	min, _ := strconv.ParseFloat(reference.RangeMin, 64)
66
+
67
+	switch item_type {
68
+	case 0:
69
+
70
+		break
71
+	case 1:
72
+		list, _ := service.GetUnusualInspectionPatientList(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.SystemProjectId, reference.ID, max, min, order_type, keyword)
73
+		c.ServeSuccessJSON(map[string]interface{}{
74
+			"list":      list,
75
+			"reference": reference,
76
+		})
77
+		break
78
+	case 2:
79
+		list, _ := service.GetPatientNotInspectionPatientList(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.SystemProjectId, reference.ID, keyword)
80
+		c.ServeSuccessJSON(map[string]interface{}{
81
+			"list":      list,
82
+			"reference": reference,
83
+		})
84
+		break
85
+	case 3:
86
+		list, _ := service.GetNormalInspectionPatientList(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.SystemProjectId, reference.ID, max, min, order_type, keyword)
87
+		c.ServeSuccessJSON(map[string]interface{}{
88
+			"list":      list,
89
+			"reference": reference,
90
+		})
91
+		break
92
+	}
93
+}
94
+
95
+func (c *StatisticsApiController) GetAllInspectionStatistisc() {
96
+	start_date := c.GetString("start_date")
97
+	end_date := c.GetString("end_date")
98
+	project_id, _ := c.GetInt64("project_id")
99
+	item_id, _ := c.GetInt64("item_id")
100
+
101
+	timeLayout := "2006-01-02"
102
+	loc, _ := time.LoadLocation("Local")
103
+	var startTime int64
104
+	if len(start_date) > 0 {
105
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_date+" 00:00:00", loc)
106
+		fmt.Println("err-----------", err)
107
+		if err != nil {
108
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
109
+			return
110
+		}
111
+		startTime = theTime.Unix()
112
+	}
113
+	var endTime int64
114
+	if len(end_date) > 0 {
115
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_date+" 23:59:59", loc)
116
+		if err != nil {
117
+			utils.ErrorLog(err.Error())
118
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
119
+			return
120
+		}
121
+		endTime = theTime.Unix()
122
+	}
123
+
124
+	//患者总数
125
+	patientCount := service.GetPatientCount(c.GetAdminUserInfo().CurrentOrgId)
126
+	//获取配置
127
+	reference, _ := service.GetInspectionReferenceThree(project_id, item_id)
128
+	//获取数值在正常范围内的总数
129
+
130
+	max, _ := strconv.ParseFloat(reference.RangeMax, 64)
131
+	min, _ := strconv.ParseFloat(reference.RangeMin, 64)
132
+
133
+	normalTotal, _ := service.GetNormalInspectionTotalByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.SystemProjectId, reference.ID, max, min)
134
+	//获取数值异常的总数
135
+	unusualTotal, _ := service.GetUnusualInspectionTotalByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.SystemProjectId, reference.ID, max, min)
136
+	//获取没有检查的患者总数
137
+	noCheckTotal, _ := service.GetPatientNotInspectionTotal(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.SystemProjectId, reference.ID)
138
+
139
+	c.ServeSuccessJSON(map[string]interface{}{
140
+		"patient_count":  patientCount,
141
+		"normal_total":   normalTotal,
142
+		"unusual_total":  unusualTotal,
143
+		"no_check_total": noCheckTotal,
144
+		"reference":      reference,
145
+	})
146
+}
147
+func (c *StatisticsApiController) GetPersonInspectionStatistisc() {
148
+	start_date := c.GetString("start_time")
149
+	end_date := c.GetString("end_time")
150
+	project_id, _ := c.GetInt64("project_id")
151
+	item_id, _ := c.GetInt64("item_id")
152
+	patient_id, _ := c.GetInt64("patient_id")
153
+
154
+	timeLayout := "2006-01-02"
155
+	loc, _ := time.LoadLocation("Local")
156
+	var startTime int64
157
+	if len(start_date) > 0 {
158
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_date+" 00:00:00", loc)
159
+		fmt.Println("err-----------", err)
160
+		if err != nil {
161
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
162
+			return
163
+		}
164
+		startTime = theTime.Unix()
165
+	}
166
+	var endTime int64
167
+	if len(end_date) > 0 {
168
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_date+" 23:59:59", loc)
169
+		if err != nil {
170
+			utils.ErrorLog(err.Error())
171
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
172
+			return
173
+		}
174
+		endTime = theTime.Unix()
175
+	}
176
+
177
+	patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
178
+	//获取配置
179
+	reference, _ := service.GetInspectionReferenceThree(project_id, item_id)
180
+	//获取数值在正常范围内的总数
181
+	inspections, _ := service.GetPatientInspectionByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.SystemProjectId, reference.SysItemId, patient_id)
182
+
183
+	c.ServeSuccessJSON(map[string]interface{}{
184
+		"patient":     patient,
185
+		"reference":   reference,
186
+		"inspections": inspections,
187
+	})
17 188
 }
18 189
 
19 190
 func (c *StatisticsApiController) GetStatistics() {
@@ -34,10 +205,8 @@ func (c *StatisticsApiController) GetStatistics() {
34 205
 	weekStart := weekEnd - 6
35 206
 	// endDay := todayTime.AddDate(0, 0, weekEnd)
36 207
 	startDay := todayTime.AddDate(0, 0, weekStart)
37
-
38 208
 	//患者总数
39 209
 	patientCount := service.GetPatientCount(adminUserInfo.CurrentOrgId)
40
-
41 210
 	//今日透析
42 211
 	todayDialysisCount := service.GetDayDialysisCount(adminUserInfo.CurrentOrgId, todayTime.Unix())
43 212
 

+ 19 - 14
models/his_charge_models.go Ver fichero

@@ -53,6 +53,10 @@ type HisChargeOrderInfo struct {
53 53
 	UserOrgId                    int64                        `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
54 54
 	ProjectId                    int64                        `gorm:"column:project_id" json:"project_id" form:"project_id"`
55 55
 	Type                         int64                        `gorm:"column:type" json:"type" form:"type"`
56
+	FulamtOwnpayAmt              float64                      `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
57
+	OverlmtAmt                   float64                      `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
58
+	PreselfpayAmt                float64                      `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
59
+	PricUplmtAmt                 float64                      `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
56 60
 	HisChargePrescriptionProject HisChargePrescriptionProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
57 61
 	HisChargeDoctorAdviceInfo    HisChargeDoctorAdviceInfo    `gorm:"ForeignKey:AdviceId;AssociationForeignKey:ID" json:"advice"`
58 62
 }
@@ -216,20 +220,21 @@ func (HisChargeGoodInfo) TableName() string {
216 220
 }
217 221
 
218 222
 type HisLabelPrintInfo struct {
219
-	ID          int64  `gorm:"column:id" json:"id" form:"id"`
220
-	PatientId   int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
221
-	Number      string `gorm:"column:number" json:"number" form:"number"`
222
-	Ctime       int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
223
-	Mtime       int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
224
-	DoctorId    int64  `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
225
-	Status      int64  `gorm:"column:status" json:"status" form:"status"`
226
-	ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
227
-	ProjectId   int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
228
-	IsPrint     int64  `gorm:"column:is_print" json:"is_print" form:"is_print"`
229
-	RecordDate  int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
230
-	ItemId      int64  `gorm:"column:item_id" json:"item_id" form:"item_id"`
231
-	UserOrgId   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
232
-	PProjectId  int64  `gorm:"column:p_project_id" json:"p_project_id" form:"p_project_id"`
223
+	ID             int64          `gorm:"column:id" json:"id" form:"id"`
224
+	PatientId      int64          `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
225
+	Number         string         `gorm:"column:number" json:"number" form:"number"`
226
+	Ctime          int64          `gorm:"column:ctime" json:"ctime" form:"ctime"`
227
+	Mtime          int64          `gorm:"column:mtime" json:"mtime" form:"mtime"`
228
+	DoctorId       int64          `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
229
+	Status         int64          `gorm:"column:status" json:"status" form:"status"`
230
+	ProjectName    string         `gorm:"column:project_name" json:"project_name" form:"project_name"`
231
+	ProjectId      int64          `gorm:"column:project_id" json:"project_id" form:"project_id"`
232
+	IsPrint        int64          `gorm:"column:is_print" json:"is_print" form:"is_print"`
233
+	RecordDate     int64          `gorm:"column:record_date" json:"record_date" form:"record_date"`
234
+	ItemId         int64          `gorm:"column:item_id" json:"item_id" form:"item_id"`
235
+	HisProjectTeam HisProjectTeam `gorm:"ForeignKey:ID;AssociationForeignKey:ItemId" json:"team"`
236
+	UserOrgId      int64          `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
237
+	PProjectId     int64          `gorm:"column:p_project_id" json:"p_project_id" form:"p_project_id"`
233 238
 
234 239
 	FeedetlSn   string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
235 240
 	DoctorName  string `gorm:"column:doctor_name" json:"doctor_name" form:"doctor_name"`

+ 1 - 0
models/his_models.go Ver fichero

@@ -921,6 +921,7 @@ type XtHisProjectList struct {
921 921
 	Type         int64        `gorm:"column:type" json:"type" form:"type"`
922 922
 	XtHisProject XtHisProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
923 923
 	GoodInfo     GoodInfo     `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"good_info"`
924
+	PN           string       `gorm:"-" json:"pn" form:"pn"`
924 925
 }
925 926
 
926 927
 func (XtHisProjectList) TableName() string {

+ 21 - 0
models/his_print_models.go Ver fichero

@@ -123,3 +123,24 @@ type HisPrescriptionInfoTwo struct {
123 123
 func (HisPrescriptionInfoTwo) TableName() string {
124 124
 	return "his_prescription_info"
125 125
 }
126
+
127
+type HisLabelPrintStatusInfo struct {
128
+	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
129
+	PatientId          int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
130
+	Ctime              int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
131
+	Mtime              int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
132
+	Status             int64  `gorm:"column:status" json:"status" form:"status"`
133
+	IsCombinationPrint int64  `gorm:"column:is_combination_print" json:"is_combination_print" form:"is_combination_print"`
134
+	RecordDate         string `gorm:"column:record_date" json:"record_date" form:"record_date"`
135
+	ItemIds            string `gorm:"column:item_ids" json:"item_ids" form:"item_ids"`
136
+	UserOrgId          int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
137
+	ProjectIds         string `gorm:"column:project_ids" json:"project_ids" form:"project_ids"`
138
+	Ids                string `gorm:"column:ids" json:"ids" form:"ids"`
139
+	DoctorId           int64  `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
140
+	IsTeam             int64  `gorm:"column:is_team" json:"is_team" form:"is_team"`
141
+	IsPrint            int64  `gorm:"column:is_print" json:"is_print" form:"is_print"`
142
+}
143
+
144
+func (HisLabelPrintStatusInfo) TableName() string {
145
+	return "his_label_print_status_info"
146
+}

+ 32 - 0
models/inspection_models.go Ver fichero

@@ -64,6 +64,9 @@ type InspectionReference struct {
64 64
 	Status           int64  `gorm:"column:status" json:"status" form:"status"`
65 65
 	CreatedTime      int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
66 66
 	UpdatedTime      int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
67
+	SystemProjectId  int64  `gorm:"column:system_project_id" json:"system_project_id" form:"system_project_id"`
68
+	SystemItemId     int64  `gorm:"column:system_item_id" json:"system_item_id" form:"system_item_id"`
69
+	//remind 	 XtCheckRemind   `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ProjectId" json:"good_info"`
67 70
 }
68 71
 
69 72
 func (InspectionReference) TableName() string {
@@ -162,3 +165,32 @@ type XtPatientFeedback struct {
162 165
 func (XtPatientFeedback) TableName() string {
163 166
 	return "xt_patient_feedback"
164 167
 }
168
+
169
+type XtCheckRemind struct {
170
+	ID                  int64               `gorm:"column:id" json:"id" form:"id"`
171
+	ProjectId           int64               `gorm:"column:project_id" json:"project_id" form:"project_id"`
172
+	UserOrgId           int64               `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
173
+	Status              int64               `gorm:"column:status" json:"status" form:"status"`
174
+	LastRemindDate      int64               `gorm:"column:last_remind_date" json:"last_remind_date" form:"last_remind_date"`
175
+	PatientId           int64               `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
176
+	RemindCycle         int64               `gorm:"column:remind_cycle" json:"remind_cycle" form:"remind_cycle"`
177
+	IsOpen              int64               `gorm:"column:is_open" json:"is_open" form:"is_open"`
178
+	InspectionReference InspectionReference `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ProjectId" json:"re"`
179
+}
180
+
181
+func (XtCheckRemind) TableName() string {
182
+	return "xt_check_remind"
183
+}
184
+
185
+type XtCheckRemindCinfig struct {
186
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
187
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
188
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
189
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
190
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
191
+	IsOpen    int64 `gorm:"column:is_open" json:"is_open" form:"is_open"`
192
+}
193
+
194
+func (XtCheckRemindCinfig) TableName() string {
195
+	return "xt_check_remind_config"
196
+}

+ 20 - 0
service/gobal_config_service.go Ver fichero

@@ -1030,6 +1030,26 @@ func GetScheduleConfigById(id int64) (config models.ScheduleConfig, err error) {
1030 1030
 	return config, err
1031 1031
 }
1032 1032
 
1033
+func CreateCheckRemindConfig(config *models.XtCheckRemindCinfig) (err error) {
1034
+	err = XTWriteDB().Create(&config).Error
1035
+	return err
1036
+}
1037
+
1038
+func GetCheckRemindConfigById(user_org_id int64) (config models.XtCheckRemindCinfig, err error) {
1039
+	err = XTReadDB().Model(&models.XtCheckRemindCinfig{}).Where("user_org_id = ?", user_org_id).First(&config).Error
1040
+	return config, err
1041
+}
1042
+
1043
+func GetCheckRemindConfigByIdTwo(id int64) (config models.XtCheckRemindCinfig, err error) {
1044
+	err = XTReadDB().Model(&models.XtCheckRemindCinfig{}).Where("id = ?", id).First(&config).Error
1045
+	return config, err
1046
+}
1047
+
1048
+func SaveCheckRemindConfig(config *models.XtCheckRemindCinfig) (err error) {
1049
+	err = XTWriteDB().Save(&config).Error
1050
+	return err
1051
+}
1052
+
1033 1053
 //func Get(id int64)(config models.ScheduleConfig, err error){
1034 1054
 //	err = XTReadDB().Model(&models.ScheduleConfig{}).Where("id = ?", id).First(&config).Error
1035 1055
 //	return config, err

+ 44 - 0
service/his_charge_service.go Ver fichero

@@ -243,6 +243,8 @@ func GetAllPatientChargeSettle(org_id int64, start_time int64, end_time int64, k
243 243
 func GetLabelPrintList(page int64, limit int64, user_org_id int64, record_time int64, is_print int64, keywors string, tube_color int64) (labels []*models.HisLabelPrintInfo, total int64, err error) {
244 244
 	offset := (page - 1) * limit
245 245
 	db := readDb.Model(&models.HisLabelPrintInfo{})
246
+	db = db.Preload("HisProjectTeam", "status = 1")
247
+
246 248
 	if is_print > 0 {
247 249
 		db = db.Where("is_print = ?", is_print)
248 250
 	}
@@ -262,6 +264,7 @@ func GetLabelPrintList(page int64, limit int64, user_org_id int64, record_time i
262 264
 func GetLabelPrintListTwo(page int64, limit int64, user_org_id int64, record_time int64, is_print int64, keywors string, tube_color int64) (labels []*models.HisLabelPrintInfo, total int64, err error) {
263 265
 	offset := (page - 1) * limit
264 266
 	db := readDb.Model(&models.HisLabelPrintInfo{})
267
+	db = db.Preload("HisProjectTeam", "status = 1")
265 268
 	if is_print > 0 {
266 269
 		db = db.Where("is_print = ?", is_print)
267 270
 	}
@@ -279,6 +282,47 @@ func GetLabelPrintListTwo(page int64, limit int64, user_org_id int64, record_tim
279 282
 	return
280 283
 }
281 284
 
285
+func GetLabelPrintListThree(user_org_id int64, record_time int64, is_print int64, keywors string, tube_color int64) (labels []*models.HisLabelPrintInfo, total int64, err error) {
286
+	db := readDb.Model(&models.HisLabelPrintInfo{})
287
+
288
+	db = db.Preload("HisProjectTeam", "status = 1")
289
+	if is_print > 0 {
290
+		db = db.Where("is_print = ?", is_print)
291
+	}
292
+	if len(keywors) > 0 {
293
+		keywors = "%" + keywors + "%"
294
+		db = db.Where("patient_name Like ?", keywors)
295
+
296
+	}
297
+	//if tube_color > 0 {
298
+	//	db = db.Joins("Right join xt_his_project_team as team on team.id = his_label_print_info.item_id AND his_label_print_info.item_id <> 0 and team.status = 1 and team.tube_color = ?", tube_color)
299
+	//}
300
+
301
+	err = db.Where("his_label_print_info.user_org_id = ? AND his_label_print_info.record_date = ? AND his_label_print_info.status = 1 ", user_org_id, record_time).Count(&total).Find(&labels).Error
302
+	return
303
+}
304
+
305
+//func GetLabelPrintListFour(user_org_id int64, record_time int64, is_print int64, keywors string, tube_color int64) (labels []*models.HisLabelPrintInfo, total int64, err error) {
306
+//	db := readDb.Model(&models.HisLabelPrintInfo{})
307
+//	db = db.Preload("HisProjectTeam", "status = 1")
308
+//
309
+//	if is_print > 0 {
310
+//		db = db.Where("is_print = ?", is_print)
311
+//	}
312
+//	if len(keywors) > 0 {
313
+//		keywors = "%" + keywors + "%"
314
+//		db = db.Where("patient_name Like ?", keywors)
315
+//
316
+//	}
317
+//	//if tube_color > 0 {
318
+//	//	//db = db.Joins("Right join xt_his_project_team as team on team.id = his_label_print_info.item_id AND his_label_print_info.item_id <> 0 and team.status = 1 and team.tube_color = ?",tube_color)
319
+//	//	db = db.Joins("Right join xt_his_project as pro on pro.id = his_label_print_info.project_id AND his_label_print_info.item_id = 0 and  his_label_print_info.project_id > 0 and pro.status = 1 and pro.tube_color = ?", tube_color)
320
+//	//}
321
+//
322
+//	err = db.Where("his_label_print_info.user_org_id = ? AND his_label_print_info.record_date = ? AND his_label_print_info.status = 1 ", user_org_id, record_time).Count(&total).Find(&labels).Error
323
+//	return
324
+//}
325
+
282 326
 func GetLabelPrintInfo(id int64) (labels models.HisLabelPrintInfo, err error) {
283 327
 	db := readDb.Model(&models.HisLabelPrintInfo{})
284 328
 	err = db.Where("id = ?", id).First(&labels).Error

+ 13 - 13
service/his_deposit_service.go Ver fichero

@@ -397,19 +397,19 @@ func SpendDeposit(orgid, his_user_id, create_id int64, code string, deposit inte
397 397
 	if err != nil {
398 398
 		return
399 399
 	}
400
-	//开事务
401
-	tx := XTWriteDB().Begin()
402
-	defer func() {
403
-		if err != nil {
404
-			utils.ErrorLog("事务失败,原因为: %v", err.Error())
405
-			tx.Rollback()
406
-		} else {
407
-			tx.Commit()
408
-		}
409
-	}()
400
+	////开事务
401
+	//tx := XTWriteDB().Begin()
402
+	//defer func() {
403
+	//	if err != nil {
404
+	//		utils.ErrorLog("事务失败,原因为: %v", err.Error())
405
+	//		tx.Rollback()
406
+	//	} else {
407
+	//		tx.Commit()
408
+	//	}
409
+	//}()
410 410
 	//查询患者押金
411 411
 	tmp := models.Deposit{}
412
-	err = tx.Model(&models.Deposit{}).Where("his_patient_id = ? and user_org_id = ? and status = 1", his_user_id, orgid).Find(&tmp).Error
412
+	err = readDb.Model(&models.Deposit{}).Where("his_patient_id = ? and user_org_id = ? and status = 1", his_user_id, orgid).Find(&tmp).Error
413 413
 	if err != nil {
414 414
 		err = fmt.Errorf("押金余额不足")
415 415
 		return
@@ -420,7 +420,7 @@ func SpendDeposit(orgid, his_user_id, create_id int64, code string, deposit inte
420 420
 		return
421 421
 	}
422 422
 	//扣除患者押金
423
-	err = tx.Model(&models.Deposit{}).Where("id = ? and status = 1", tmp.ID).Updates(map[string]interface{}{
423
+	err = readDb.Model(&models.Deposit{}).Where("id = ? and status = 1", tmp.ID).Updates(map[string]interface{}{
424 424
 		"mtime":   time.Now().Unix(),
425 425
 		"deposit": tmp.Deposit.Sub(tmp_deposit),
426 426
 	}).Error
@@ -441,7 +441,7 @@ func SpendDeposit(orgid, his_user_id, create_id int64, code string, deposit inte
441 441
 		Mtime:          time.Now().Unix(),
442 442
 		TrialStatus:    1,
443 443
 	}
444
-	err = tx.Create(&dehistory).Error
444
+	err = readDb.Create(&dehistory).Error
445 445
 	return
446 446
 }
447 447
 

+ 25 - 0
service/his_hospital_service.go Ver fichero

@@ -580,3 +580,28 @@ func GetUnChargeHisHospitalPrescription(org_id int64, start_time int64, end_time
580 580
 		Find(&prescription).Error
581 581
 	return
582 582
 }
583
+
584
+func GetLastInHospitalRecord(patient_id int64, user_org_id int64) (record models.HisHospitalCheckRecord, err error) {
585
+	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("patient_id = ? AND status = 1 AND user_org_id = ? AND in_hospital_status = 1 AND out_hospital_status = 0", patient_id, user_org_id).Last(&record).Error
586
+	return
587
+}
588
+
589
+func GetHisInHospitalHistory(keyword string, startime int64, endtime int64, limit int64, page int64, orgid int64) (hisPatient []*models.HisHospitalCheckRecord, total int64, err error) {
590
+	offset := (page - 1) * limit
591
+	likeKey := "%" + keyword + "%"
592
+	db := XTReadDB().Model(&models.HisHospitalCheckRecord{})
593
+	if len(keyword) > 0 {
594
+		db = db.Where("name like ?", likeKey)
595
+	}
596
+	if startime > 0 {
597
+		db = db.Where("record_date >= ?", startime)
598
+	}
599
+	if endtime > 0 {
600
+		db = db.Where("record_date<=?", endtime)
601
+	}
602
+	if orgid > 0 {
603
+		db = db.Where("user_org_id = ?", orgid)
604
+	}
605
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("id desc").Find(&hisPatient).Error
606
+	return hisPatient, total, err
607
+}

+ 28 - 0
service/his_print_service.go Ver fichero

@@ -135,3 +135,31 @@ func GetBatchInspectionProjectHisPrescription(ids []string, record_time int64, u
135 135
 	return
136 136
 
137 137
 }
138
+
139
+func GetUnChargeHisPrescriptionTen(org_id int64, patient_id int64, record_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
140
+	err = readDb.Model(&models.HisPrescription{}).
141
+		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
142
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
143
+		}).
144
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
145
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
146
+		}).
147
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
148
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
149
+		}).Preload("TempHisOrder", func(db *gorm.DB) *gorm.DB {
150
+		return db.Where("status = 1 AND user_org_id = ? AND order_status <> 3  AND order_status <> 2  ", org_id)
151
+	}).
152
+		Where("(user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND order_status <> 3 AND p_type = ?)", org_id, record_date, patient_id, p_type).
153
+		Find(&prescription).Error
154
+	return
155
+}
156
+
157
+func CreateLabelPrint(label *models.HisLabelPrintStatusInfo) (err error) {
158
+	err = writeDb.Save(&label).Error
159
+	return
160
+}
161
+
162
+func GetLabelPrint(ids string, org_id int64, record_date string, patient_id int64) (label models.HisLabelPrintStatusInfo, err error) {
163
+	err = readDb.Model(&models.HisLabelPrintStatusInfo{}).Where("ids = ? and user_org_id = ? and record_date = ? and patient_id = ?", ids, org_id, record_date, patient_id).First(&label).Error
164
+	return
165
+}

+ 28 - 2
service/his_service.go Ver fichero

@@ -2592,8 +2592,8 @@ func UpdataOrderStatusThree(number string, user_org_id int64) (err error) {
2592 2592
 	return
2593 2593
 }
2594 2594
 
2595
-func UpDateOrderTwo(order *models.HisOrder) (err error) {
2596
-	err = writeDb.Save(&order).Error
2595
+func UpDateOrderTwo(order *models.HisOrder, tx *gorm.DB) (err error) {
2596
+	err = tx.Save(&order).Error
2597 2597
 	return
2598 2598
 }
2599 2599
 
@@ -2752,3 +2752,29 @@ func GetHisOrderByIDTenOne(order_id string) (order models.HisOrder, err error) {
2752 2752
 	err = readDb.Model(&models.HisOrder{}).Where("id = ? AND status = 1", order_id).First(&order).Error
2753 2753
 	return
2754 2754
 }
2755
+
2756
+func GetHisDoctorAdviceInfotwo(id int64) (models.HisDoctorAdviceInfo, error) {
2757
+	info := models.HisDoctorAdviceInfo{}
2758
+	err := readDb.Model(&info).Where("id = ? and status = 1", id).Find(&info).Error
2759
+	return info, err
2760
+}
2761
+
2762
+func GetHisDoctorAdviceInfothree(org_id int64, record_date int64) (info []*models.HisDoctorAdviceInfo, err error) {
2763
+	err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("user_org_id  = ? and status = 1 and record_date = ?", org_id, record_date).Find(&info).Error
2764
+	return
2765
+}
2766
+
2767
+func GetHisPrescriptionProjectByIDFour(org_id int64, record_date int64) (projects []*models.HisPrescriptionProject, err error) {
2768
+	err = readDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id  = ? and status = 1 and record_date = ?", org_id, record_date).Find(&projects).Error
2769
+	return
2770
+}
2771
+
2772
+func GetHisPrescriptionProjectByIDThree(id int64) (projects models.HisPrescriptionProject, err error) {
2773
+	err = readDb.Model(&models.HisPrescriptionProject{}).Where("id = ? AND status = 1", id).First(&projects).Error
2774
+	return
2775
+}
2776
+
2777
+func GetHisPrescriptionProjectByIDTwoone(id int64) (projects models.HisPrescriptionProject, err error) {
2778
+	err = readDb.Model(&models.HisPrescriptionProject{}).Preload("GoodInfo", "status = 1").Preload("HisProject", "status = 1").Where("id = ? AND status = 1", id).First(&projects).Error
2779
+	return
2780
+}

+ 1 - 1
service/his_summary_service.go Ver fichero

@@ -11,7 +11,7 @@ func GetHisSummaryDetailList(keyword string, item_type int64, patient_id int64,
11 11
 	err = XTReadDB().Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").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.patient_id = ?", start_time, end_time, org_id, patient_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
12 12
 		return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id,psn_cash_pay,acct_pay,fund_pay_sumamt,is_medicine_insurance,medfee_sumamt,maf_pay,hifes_pay").
13 13
 			Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
14
-				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Where("status = 1").
14
+				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type,fulamt_ownpay_amt,overlmt_amt,preselfpay_amt,pric_uplmt_amt").Where("status = 1").
15 15
 					Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
16 16
 						return db.Preload("Drug", "status = 1").Where("status = 1 ")
17 17
 					}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {

+ 51 - 0
service/inspection_service.go Ver fichero

@@ -215,6 +215,26 @@ func UpDateInfectiousRecordTime(orgId int64, patientId int64, time int64, remind
215 215
 	return
216 216
 }
217 217
 
218
+func CreateRemind(remind models.XtCheckRemind) (err error) {
219
+	err = writeDb.Create(&remind).Error
220
+	return
221
+}
222
+
223
+func UpDateCheckRemindRecordTime(orgId int64, patientId int64, time int64, project_id int64, remind_cycle int64) (err error) {
224
+	err = writeDb.Model(&models.XtCheckRemind{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? and project_id = ?", orgId, patientId, project_id).Updates(map[string]interface{}{"last_remind_date": time, "remind_cycle": remind_cycle}).Error
225
+	return
226
+}
227
+
228
+func UpDateCheckRemindRecordTimeTwo(orgId int64, patientId int64, time int64, project_id int64) (err error) {
229
+	err = writeDb.Model(&models.XtCheckRemind{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? and project_id = ?", orgId, patientId, project_id).Updates(map[string]interface{}{"last_remind_date": time}).Error
230
+	return
231
+}
232
+
233
+func GetCheckRemindRecordTime(orgId int64, patientId int64, project_id int64) (remind models.XtCheckRemind, err error) {
234
+	err = writeDb.Model(&models.XtCheckRemind{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? and project_id = ?", orgId, patientId, project_id).First(&remind).Error
235
+	return
236
+}
237
+
218 238
 func GetAllPatientInspection(orgId, patientId, page int64, projectId int64, start_time int64, end_time int64) (inspections []*models.Inspection, date int64, err error) {
219 239
 
220 240
 	//var projectCount models.UserInspectionProjectCount
@@ -264,3 +284,34 @@ func GetInspectionReferenceTwo(project_id int64) (reference []*models.Inspection
264 284
 	err = readDb.Model(&models.InspectionReference{}).Where("project_id = ? and status = 1", project_id).Order("project_id").Find(&reference).Error
265 285
 	return
266 286
 }
287
+
288
+func GetInspectionReferenceThree(project_id int64, item_id int64) (reference models.InspectionReference, err error) {
289
+	err = readDb.Model(&models.InspectionReference{}).Where("project_id = ? and id = ? and status = 1  and org_id = 0", project_id, item_id).Order("project_id").Find(&reference).Error
290
+	return
291
+}
292
+
293
+func GetInspectionTwo(startime int64, endtime int64, orgid int64, projectid int64, itemid int64) (inspection []*models.Inspection, total int64, err error) {
294
+	db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
295
+	db = db.Where("project_id = ? and item_id = ?", projectid, itemid)
296
+	if startime > 0 {
297
+		db = db.Where("x.inspect_date >= ?", startime)
298
+	}
299
+	if endtime > 0 {
300
+		db = db.Where("x.inspect_date<=?", endtime)
301
+	}
302
+	if orgid > 0 {
303
+		db = db.Where("x.org_id = ?", orgid)
304
+	}
305
+	if projectid > 0 {
306
+		db = db.Where("x.project_id = ?", projectid)
307
+	}
308
+	err = db.Count(&total).Order("x.inspect_date desc").Group("x.id").
309
+		Select("x.id,x.patient_id,x.org_id,x.project_id,x.item_id,x.item_name,x.project_name,x.inspect_type,x.inspect_value,x.inspect_date,x.created_time").Find(&inspection).Error
310
+	return inspection, total, err
311
+}
312
+
313
+// 查出日期差小于3天的数据
314
+func GetAllInspectionRemind(org_id int64, patient_id int64) (check []models.XtCheckRemind, err error) {
315
+	err = readDb.Model(&models.XtCheckRemind{}).Preload("InspectionReference", "status = 1").Where("patient_id = ? and status = 1  and user_org_id = ? and DATEDIFF(FROM_UNIXTIME(last_remind_date),NOW()) < 3 and last_remind_date <> 0", patient_id, org_id).Find(&check).Error
316
+	return
317
+}

+ 64 - 2
service/patientmanage_service.go Ver fichero

@@ -1000,9 +1000,7 @@ func GetInspectionByOrgId(orgid int64) (*models.XtInspectionReference, error) {
1000 1000
 }
1001 1001
 
1002 1002
 func GetAllProjectName(date int64, orgid int64, patientid int64) (inspection []*models.XtInspection, err error) {
1003
-
1004 1003
 	err = XTReadDB().Model(&inspection).Where("inspect_date = ? and org_id = ? and patient_id = ? and status = 1", date, orgid, patientid).Order("inspect_date desc").Group("project_name").Find(&inspection).Error
1005
-
1006 1004
 	return inspection, err
1007 1005
 }
1008 1006
 
@@ -1956,3 +1954,67 @@ func DeleteFirstDisease(id []string) error {
1956 1954
 	err := XTWriteDB().Model(models.XtPatientFirstDisease{}).Where("id in (?) and status=1", id).Updates(map[string]interface{}{"status": 0}).Error
1957 1955
 	return err
1958 1956
 }
1957
+
1958
+type InspectionCount struct {
1959
+	Count int64
1960
+}
1961
+
1962
+func GetNormalInspectionTotalByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, max_value float64, min_value float64) (total int64, err error) {
1963
+	var count []*InspectionCount
1964
+	err2 := XTReadDB().Table("xt_inspection as xti ").Select("count(*) as count").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x  WHERE (x.status = 1) AND (x.org_id = ? and x.reference_project_id = ? and x.reference_item_id = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE (xti.status = 1) AND (xti.org_id = ? and xti.reference_project_id = ? and xti.reference_item_id = ?  and xti.inspect_date >= ? and xti.inspect_date<= ? and xti.`inspect_value` < ? and xti.inspect_value > ? ) Group by xti.patient_id", orgid, projectid, item_id, startime, endtime, orgid, projectid, item_id, startime, endtime, max_value, min_value).Scan(&count).Error
1965
+	for _, items := range count {
1966
+		total = total + items.Count
1967
+	}
1968
+	return total, err2
1969
+}
1970
+func GetUnusualInspectionTotalByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, max_value float64, min_value float64) (total int64, err error) {
1971
+	var count []*InspectionCount
1972
+	err2 := XTReadDB().Table("xt_inspection as xti ").Select("count(*) as count").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x  WHERE (x.status = 1) AND (x.org_id = ? and x.reference_project_id = ? and x.reference_item_id = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE   (xti.status = 1 AND xti.org_id = ? and xti.reference_project_id = ? and xti.reference_item_id = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value > ?) OR (xti.status = 1 AND xti.org_id = ? and xti.reference_project_id = ? and xti.reference_item_id = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value < ?) Group by xti.patient_id", orgid, projectid, item_id, startime, endtime, orgid, projectid, item_id, startime, endtime, max_value, orgid, projectid, item_id, startime, endtime, min_value).Scan(&count).Error
1973
+	for _, items := range count {
1974
+		total = total + items.Count
1975
+	}
1976
+	return total, err2
1977
+}
1978
+
1979
+func GetPatientNotInspectionTotal(startime int64, endtime int64, orgid int64, projectid int64, item_id int64) (total int64, err error) {
1980
+	err = XTReadDB().Model(models.XtPatients{}).Joins("LEFT JOIN xt_inspection pd ON xt_patients.id = pd.patient_id and pd.org_id = ? and pd.reference_project_id = ? and pd.reference_item_id = ? and pd.inspect_date >= ? and pd.inspect_date<=? ", orgid, projectid, item_id, startime, endtime).Where("xt_patients.user_org_id = ? and xt_patients.status = 1 and pd.patient_id IS NULL", orgid).Count(&total).Error
1981
+	return total, err
1982
+}
1983
+
1984
+func GetPatientInspectionByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, patient_id int64) (inspections []*models.Inspection, err error) {
1985
+	db := XTReadDB().Table("xt_inspection as x").Select("patient_id,inspect_date,inspect_value").Where("x.status = 1")
1986
+	if startime > 0 {
1987
+		db = db.Where("x.inspect_date >= ?", startime)
1988
+	}
1989
+	if endtime > 0 {
1990
+		db = db.Where("x.inspect_date<=?", endtime)
1991
+	}
1992
+
1993
+	if orgid > 0 {
1994
+		db = db.Where("x.org_id = ?", orgid)
1995
+	}
1996
+	if projectid > 0 {
1997
+		db = db.Where("x.reference_project_id = ?", projectid)
1998
+	}
1999
+	if item_id > 0 {
2000
+		db = db.Where("x.reference_item_id = ?", item_id)
2001
+	}
2002
+	if patient_id > 0 {
2003
+		db = db.Where("x.patient_id = ?", patient_id)
2004
+	}
2005
+	err = db.Find(&inspections).Error
2006
+	return inspections, err
2007
+}
2008
+
2009
+func GetNormalInspectionPatientList(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, max_value float64, min_value float64, order_type int64, keyword string) (xti []*models.Inspection, err error) {
2010
+	err2 := XTReadDB().Table("xt_inspection as xti ").Select("xti.patient_id as patient_id,xti.inspect_date as inspect_date,xti.inspect_value as value").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x  WHERE (x.status = 1) AND (x.org_id = ? and x.reference_project_id = ? and x.reference_item_id = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE (xti.status = 1) AND (xti.org_id = ? and xti.reference_project_id = ? and xti.reference_item_id = ?  and xti.inspect_date >= ? and xti.inspect_date<= ? and xti.`inspect_value` < ? and xti.inspect_value > ? ) Group by xti.patient_id", orgid, projectid, item_id, startime, endtime, orgid, projectid, item_id, startime, endtime, max_value, min_value).Scan(&xti).Error
2011
+	return xti, err2
2012
+}
2013
+func GetUnusualInspectionPatientList(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, max_value float64, min_value float64, order_type int64, keyword string) (xti []*models.Inspection, err error) {
2014
+	err2 := XTReadDB().Table("xt_inspection as xti ").Select("xti.patient_id as patient_id,xti.inspect_date as inspect_date,xti.inspect_value as value").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x  WHERE (x.status = 1) AND (x.org_id = ? and x.reference_project_id = ? and x.reference_item_id = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE   (xti.status = 1 AND xti.org_id = ? and xti.reference_project_id = ? and xti.reference_item_id = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value > ?) OR (xti.status = 1 AND xti.org_id = ? and xti.reference_project_id = ? and xti.reference_item_id = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value < ?) Group by xti.patient_id", orgid, projectid, item_id, startime, endtime, orgid, projectid, item_id, startime, endtime, max_value, orgid, projectid, item_id, startime, endtime, min_value).Scan(&xti).Error
2015
+	return xti, err2
2016
+}
2017
+func GetPatientNotInspectionPatientList(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, keyword string) (patient models.XtPatients, err error) {
2018
+	err = XTReadDB().Model(models.XtPatients{}).Joins("LEFT JOIN xt_inspection pd ON xt_patients.id = pd.patient_id and pd.org_id = ? and pd.reference_project_id = ? and pd.reference_item_id = ? and pd.inspect_date >= ? and pd.inspect_date<=? ", orgid, projectid, item_id, startime, endtime).Where("xt_patients.user_org_id = ? and xt_patients.status = 1 and pd.patient_id IS NULL", orgid).Find(&patient).Error
2019
+	return patient, err
2020
+}