Procházet zdrojové kódy

患者检验检查统计开发

XMLWAN před 5 roky
rodič
revize
3a8e0a01c3

+ 21 - 15
controllers/inspection_api_controller.go Zobrazit soubor

@@ -124,10 +124,10 @@ func (c *InspectionApiController) CreatePatientInspection() {
124 124
 		return
125 125
 	}
126 126
 
127
-	timeLayout := "2006-01-02 15:04:05"
127
+	timeLayout := "2006-01-02 15:04"
128 128
 	loc, _ := time.LoadLocation("Local")
129 129
 
130
-	theTime, err := time.ParseInLocation(timeLayout, from.InspectDate+" 00:00:00", loc)
130
+	theTime, err := time.ParseInLocation(timeLayout, from.InspectDate, loc)
131 131
 	if err != nil {
132 132
 		utils.ErrorLog(err.Error())
133 133
 		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "检验日期不正确")
@@ -226,13 +226,11 @@ func (c *InspectionApiController) CreatePatientInspection() {
226 226
 }
227 227
 
228 228
 func (c *InspectionApiController) EditPatientInspection() {
229
-	fmt.Println("触发了没有---------------------------------------")
230 229
 	patient, _ := c.GetInt64("patient", 0)
231 230
 	remind_cycle, _ := c.GetInt64("remind_cycle", 0)
232
-	dates := c.GetString("dates")
233
-	projectid := c.GetString("projectid")
234
-	fmt.Println("日期---", dates)
235
-	fmt.Println("projectid", projectid)
231
+	// dates := c.GetString("dates")
232
+	// projectid := c.GetString("projectid")
233
+
236 234
 	if patient <= 0 {
237 235
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
238 236
 		return
@@ -253,23 +251,31 @@ func (c *InspectionApiController) EditPatientInspection() {
253 251
 		return
254 252
 	}
255 253
 
256
-	timeLayout := "2006-01-02 15:04:05"
254
+	timeLayout := "2006-01-02 15:04"
257 255
 	loc, _ := time.LoadLocation("Local")
258 256
 
259
-	theTime, err := time.ParseInLocation(timeLayout, from.InspectDate+" 00:00:00", loc)
257
+	theTime, err := time.ParseInLocation(timeLayout, from.InspectDate, loc)
260 258
 	if err != nil {
261 259
 		utils.ErrorLog(err.Error())
262 260
 		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "检验日期不正确")
263 261
 		return
264 262
 	}
265 263
 
264
+	oldTime, olderr := time.ParseInLocation(timeLayout, from.OldInspectDate, loc)
265
+	if olderr != nil {
266
+		utils.ErrorLog(olderr.Error())
267
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "检验日期不正确")
268
+		return
269
+	}
270
+
266 271
 	if len(from.FormItem) == 0 {
267 272
 		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "未填写项目")
268 273
 		return
269 274
 	}
270 275
 
271 276
 	date := theTime.Unix()
272
-	insp, err := service.GetPatientInspectionByDate(adminUserInfo.CurrentOrgId, patient, date, from.ProjectId)
277
+	oldDate := oldTime.Unix()
278
+	insp, err := service.GetPatientInspectionByDate(adminUserInfo.CurrentOrgId, patient, oldDate, from.ProjectId)
273 279
 	if err != nil {
274 280
 		utils.ErrorLog("%v", err)
275 281
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -306,10 +312,10 @@ func (c *InspectionApiController) EditPatientInspection() {
306 312
 			inspection.CreatedTime = time.Now().Unix()
307 313
 			inspection.UpdatedTime = time.Now().Unix()
308 314
 			addinsp = append(addinsp, inspection)
309
-		} else if _, exi := inspMap[item.ID]; exi {
310
-			fmt.Println("2222222222")
315
+		} else {
311 316
 			inspection := *inspMap[item.ID]
312 317
 			inspection.InspectValue = item.Value
318
+			inspection.InspectDate = date
313 319
 			inspection.UpdatedTime = time.Now().Unix()
314 320
 			editinsp = append(editinsp, inspection)
315 321
 			noMap = append(noMap, item.ID)
@@ -373,15 +379,15 @@ func (c *InspectionApiController) DeletePatientInspection() {
373 379
 	patient, _ := c.GetInt64("patient", 0)
374 380
 	ProjectId, _ := c.GetInt64("project_id", 0)
375 381
 	InspectDate := c.GetString("date")
376
-	if patient <= 0 || ProjectId <= 0 || len(InspectDate) != 10 {
382
+	if patient <= 0 || ProjectId <= 0 || len(InspectDate) < 10 {
377 383
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
378 384
 		return
379 385
 	}
380 386
 
381
-	timeLayout := "2006-01-02 15:04:05"
387
+	timeLayout := "2006-01-02 15:04"
382 388
 	loc, _ := time.LoadLocation("Local")
383 389
 
384
-	theTime, err := time.ParseInLocation(timeLayout, InspectDate+" 00:00:00", loc)
390
+	theTime, err := time.ParseInLocation(timeLayout, InspectDate, loc)
385 391
 	if err != nil {
386 392
 		utils.ErrorLog(err.Error())
387 393
 		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "检验日期不正确")

+ 125 - 0
controllers/new_mobile_api_controllers/new_common_api_controller.go Zobrazit soubor

@@ -370,3 +370,128 @@ func (this *NewCommonApiController) GetSeachPatientDetail() {
370 370
 		"PatientsInfo": PatientsInfo,
371 371
 	})
372 372
 }
373
+
374
+func (this *NewCommonApiController) GetMobileNormdata() {
375
+
376
+	adminInfo := this.GetMobileAdminUserInfo()
377
+	orgid := adminInfo.Org.Id
378
+	//获取系统数据
379
+	normdata, err := service.GetNormDataByOrgId(orgid)
380
+	if len(normdata) == 0 {
381
+		normdata, err := service.GetNormData(0)
382
+		if err != nil {
383
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
384
+			return
385
+		}
386
+		this.ServeSuccessJSON(map[string]interface{}{
387
+			"normdata": normdata,
388
+		})
389
+	}
390
+	if err != nil {
391
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
392
+		return
393
+	}
394
+	this.ServeSuccessJSON(map[string]interface{}{
395
+		"normdata": normdata,
396
+	})
397
+}
398
+
399
+func (this *NewCommonApiController) GetMobileProjectlsit() {
400
+
401
+	adminInfo := this.GetMobileAdminUserInfo()
402
+	orgid := adminInfo.Org.Id
403
+	fmt.Println("orgid", orgid)
404
+	lapseto, _ := this.GetInt64("lapseto")
405
+	fmt.Println("专柜", lapseto)
406
+	itemtype, _ := this.GetInt64("itemtype")
407
+	fmt.Println("itemtype", itemtype)
408
+	modetype, _ := this.GetInt64("modeltype")
409
+	fmt.Println(modetype)
410
+
411
+	firstQuarterStart := this.GetString("first_quarter_start")
412
+	firstQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", firstQuarterStart)
413
+	firstQuarterStartUnix := firstQuarterStartStr.Unix()
414
+	fmt.Println("第一季度开始时间", firstQuarterStartUnix)
415
+	fisrtQuarterEnd := this.GetString("first_qurter_end")
416
+	fisrtQuarterEndStr := fisrtQuarterEnd + " 23:59:59"
417
+	fisrtQuarterEnds, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", fisrtQuarterEndStr)
418
+	fisrtQuarterEndStrUnix := fisrtQuarterEnds.Unix()
419
+	fmt.Println("第一季度结束时间", fisrtQuarterEndStrUnix)
420
+
421
+	secondeQuarterStart := this.GetString("second_qurter_start")
422
+	secondeQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", secondeQuarterStart)
423
+	secondeQuarterStartUnix := secondeQuarterStartStr.Unix()
424
+	fmt.Println("第二季度开始时间", secondeQuarterStartUnix)
425
+	secondQuarterEnd := this.GetString("second_qurter_end")
426
+	secondQuarterEndStr := secondQuarterEnd + " 23:59:59"
427
+	secondQuarterEnds, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
428
+	secondQuarterEndStrUnix := secondQuarterEnds.Unix()
429
+	fmt.Println("第二季度结束时间", secondQuarterEndStrUnix)
430
+
431
+	threeQuarterStart := this.GetString("three_qurter_start")
432
+	threeQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", threeQuarterStart)
433
+	threeQuarterStartUnix := threeQuarterStartStr.Unix()
434
+	fmt.Println("第三季度开始时间", threeQuarterStartUnix)
435
+	threeQuarterEnd := this.GetString("three_qurter_end")
436
+	threeQuarterEndStr := threeQuarterEnd + " 23:59:59"
437
+	threeQuarterEnds, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", threeQuarterEndStr)
438
+	threeQuarterEndStrUnix := threeQuarterEnds.Unix()
439
+	fmt.Println("第三季度结束时间", threeQuarterEndStrUnix)
440
+
441
+	fourQuarterStart := this.GetString("four_qurter_start")
442
+	fourQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", fourQuarterStart)
443
+	fourQuarterStartUnix := fourQuarterStartStr.Unix()
444
+	fmt.Println("第四季度开始时间", fourQuarterStartUnix)
445
+	fourQuarterEnd := this.GetString("four_qurter_end")
446
+	fourQuarterEndStr := fourQuarterEnd + " 23:59:59"
447
+	fourQuarterEnds, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", fourQuarterEndStr)
448
+	fourQuarterEndStrUnix := fourQuarterEnds.Unix()
449
+	fmt.Println("第四季度结束时间", fourQuarterEndStrUnix)
450
+
451
+	//按季度统计
452
+	if itemtype == 1 {
453
+		//统计总共
454
+		list, err := service.GetProjectList(orgid, lapseto, modetype, firstQuarterStartUnix, fourQuarterEndStrUnix, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
455
+		//统计达标个数
456
+		standList, err := service.GetProjectStandList(orgid, lapseto, modetype, firstQuarterStartUnix, fourQuarterEndStrUnix, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
457
+		if err != nil {
458
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
459
+			return
460
+		}
461
+
462
+		this.ServeSuccessJSON(map[string]interface{}{
463
+			"list":      list,
464
+			"standList": standList,
465
+		})
466
+	}
467
+}
468
+
469
+func (this *NewCommonApiController) GetMobileFirstQuarter() {
470
+
471
+	adminUser := this.GetMobileAdminUserInfo()
472
+	orgid := adminUser.Org.Id
473
+	lapseto, _ := this.GetInt64("lapseto")
474
+	fmt.Println("转归", lapseto)
475
+	startime := this.GetString("startime")
476
+	fmt.Println("startime", startime)
477
+	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
478
+	fmt.Println("parseDateErr", parseDateErr)
479
+	statime := startDate.Unix()
480
+	fmt.Println("开始时间", statime)
481
+	endtime := this.GetString("endtime")
482
+	fmt.Println("endtime", endtime)
483
+	endTimeYMDHmsStr := endtime + " 23:59:59"
484
+	endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
485
+	entime := endDate.Unix()
486
+	fmt.Println("结束日期", entime)
487
+	//group, parseDateErr := service.GetItemNameGroup(orgid, statime, entime)
488
+	//quarter, err := service.GetFirstQuarter(orgid, statime, entime)
489
+	count, err := service.GetQuarterTotalCount(orgid, statime, entime, lapseto)
490
+	if err != nil {
491
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
492
+		return
493
+	}
494
+	this.ServeSuccessJSON(map[string]interface{}{
495
+		"count": count,
496
+	})
497
+}

+ 3 - 0
controllers/new_mobile_api_controllers/new_common_api_router.go Zobrazit soubor

@@ -18,4 +18,7 @@ func NewCommonApiControllersRegisterRouters() {
18 18
 	beego.Router("/m/api/getmobileInspectionList", &NewCommonApiController{}, "Get:GetMobileInspectionList")
19 19
 	beego.Router("/m/api/getpatientinspectiondetail", &NewCommonApiController{}, "Get:GetPatientInspectionDetail")
20 20
 	beego.Router("m/api/getseachpatientdetail", &NewCommonApiController{}, "Get:GetSeachPatientDetail")
21
+	beego.Router("m/api/getmobilenormdata", &NewCommonApiController{}, "Get:GetMobileNormdata")
22
+	beego.Router("m/api/getmobileprojectlist", &NewCommonApiController{}, "Get:GetMobileProjectlsit")
23
+	beego.Router("/m/api/getmobilefirstquarter", &NewCommonApiController{}, "Get:GetMobileFirstQuarter")
21 24
 }

+ 5 - 5
models/common_models.go Zobrazit soubor

@@ -290,11 +290,11 @@ type DialysisTotalDataStruct struct {
290 290
 	ModeID string `json:"mode_id"`
291 291
 }
292 292
 
293
-type UserInspectionProjectCount struct {
294
-	PatientId int64
295
-	Count     int64
296
-	ProjectId int64
297
-}
293
+//type UserInspectionProjectCount struct {
294
+//  PatientId int64
295
+//  Count     int64
296
+//  ProjectId int64
297
+//}
298 298
 
299 299
 type InspectionReferenceMaps struct {
300 300
 	ProjectName        string               `gorm:"-" json:"project_name" form:"project_name"`

+ 11 - 4
models/inspection_models.go Zobrazit soubor

@@ -77,6 +77,12 @@ type UserInspectionProjectCounts struct {
77 77
 	Sort                int64
78 78
 }
79 79
 
80
+type UserInspectionProjectCount struct {
81
+	PatientId int64
82
+	Count     int64
83
+	ProjectId int64
84
+}
85
+
80 86
 type UserDoctorAdvicesCount struct {
81 87
 	PatientId int64
82 88
 	Count     int64
@@ -91,10 +97,11 @@ type InspectionReferenceMap struct {
91 97
 }
92 98
 
93 99
 type InepectionForm struct {
94
-	Method      string `json:"method"`
95
-	ProjectId   int64  `json:"project_id"`
96
-	InspectDate string `json:"inspect_date"`
97
-	FormItem    []struct {
100
+	Method         string `json:"method"`
101
+	ProjectId      int64  `json:"project_id"`
102
+	InspectDate    string `json:"inspect_date"`
103
+	OldInspectDate string `json:"old_inspect_date"`
104
+	FormItem       []struct {
98 105
 		ID          int64  `json:"id"`
99 106
 		ProjectId   int64  `json:"project_id"`
100 107
 		ProjectName string `json:"project_name"`