XMLWAN 4 anni fa
parent
commit
a92ad6944a

+ 4 - 0
controllers/dialysis_record_api_controller.go Vedi File

@@ -278,6 +278,9 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
278 278
 		his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.CurrentOrgId, patientID, date.Unix())
279 279
 	}
280 280
 
281
+	//获取患者的最后一次血管通路数据
282
+	lastAssessment, parseDateErr := service.GetLastPassWayAssessment(adminInfo.CurrentOrgId, patientID)
283
+
281 284
 	returnData := map[string]interface{}{
282 285
 		"patient":                     patient,
283 286
 		"schedual":                    schedual,
@@ -306,6 +309,7 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
306 309
 		"is_open_config":              is_open_config,
307 310
 		"stockType":                   stockType,
308 311
 		"prepare":                     prepare,
312
+		"lastAssessment":              lastAssessment,
309 313
 	}
310 314
 	this.ServeSuccessJSON(returnData)
311 315
 

+ 219 - 8
controllers/doctors_api_controller.go Vedi File

@@ -30,6 +30,14 @@ func DoctorApiRegistRouters() {
30 30
 	beego.Router("/api/schedule/getdoctoradvicecount", &DoctorsApiController{}, "Get:GetDoctorAdviceCount")
31 31
 	beego.Router("/api/patient/savevasularaccess", &DoctorsApiController{}, "Get:SaveVasularAccess")
32 32
 	beego.Router("/api/patient/getallvascualraccesslist", &DoctorsApiController{}, "Get:GetAllVacualAccessList")
33
+	beego.Router("/api/patient/getvascularaccessbydetial", &DoctorsApiController{}, "Get:GetVascularAccessByDetail")
34
+	beego.Router("/api/patient/updatevasularaccess", &DoctorsApiController{}, "Get:UpdateVasularAccess")
35
+	beego.Router("/api/patient/deletevascularaccess", &DoctorsApiController{}, "Get:DeleteVasularAccess")
36
+	beego.Router("/api/patient/savepasswayassessment", &DoctorsApiController{}, "Get:SavePassWayAssessment")
37
+	beego.Router("/api/patient/getallpasswayassessment", &DoctorsApiController{}, "Get:GetAllPassWayAssessment")
38
+	beego.Router("/api/patient/getpasswayassmentbyid", &DoctorsApiController{}, "Get:GetPasswayAssesmentById")
39
+	beego.Router("/api/patient/updatepasswayassesment", &DoctorsApiController{}, "Get:UpdatePassWayAssesment")
40
+	beego.Router("/api/patient/deletepasswayassessment", &DoctorsApiController{}, "Get:DeleteWayAssessment")
33 41
 }
34 42
 
35 43
 func (c *DoctorsApiController) ScheduleAdvices() {
@@ -329,9 +337,105 @@ func (this *DoctorsApiController) SaveVasularAccess() {
329 337
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
330 338
 	stop_reason := this.GetString("stop_reason")
331 339
 	user_status, _ := this.GetInt64("user_status")
340
+	stop_time := this.GetString("stop_time")
341
+	stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
342
+	patient_id, _ := this.GetInt64("patient_id")
332 343
 	adminUserInfo := this.GetAdminUserInfo()
333 344
 	orgId := adminUserInfo.CurrentOrgId
334 345
 	creator := adminUserInfo.AdminUser.Id
346
+
347
+	//查询改日期是否存在
348
+	_, errcode := service.GetDialysisDateByDate(startTime.Unix(), patient_id, orgId)
349
+	if errcode == gorm.ErrRecordNotFound {
350
+		access := models.XtPatientVascularAccess{
351
+			AccessProject:          access_project,
352
+			BloodAccessPartId:      blood_access_part_id,
353
+			BloodAccessPartOperaId: blood_access_part_opera_id,
354
+			FirstStartTime:         firstStartTime.Unix(),
355
+			InflowPass:             inflow_pass,
356
+			Remark:                 remark,
357
+			StartTime:              startTime.Unix(),
358
+			StopReason:             stop_reason,
359
+			UserStatus:             user_status,
360
+			Creator:                creator,
361
+			UserOrgId:              orgId,
362
+			Status:                 1,
363
+			Ctime:                  time.Now().Unix(),
364
+			StopTime:               stopTime.Unix(),
365
+			PatientId:              patient_id,
366
+		}
367
+		err := service.SaveVascularAccess(&access)
368
+		if err == nil {
369
+			this.ServeSuccessJSON(map[string]interface{}{
370
+				"access": access,
371
+			})
372
+			return
373
+		}
374
+	} else if errcode == nil {
375
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
376
+		return
377
+	}
378
+
379
+}
380
+
381
+func (this *DoctorsApiController) GetAllVacualAccessList() {
382
+
383
+	limit, _ := this.GetInt64("limit")
384
+	page, _ := this.GetInt64("page")
385
+	patient_id, _ := this.GetInt64("patient_id")
386
+	orgId := this.GetAdminUserInfo().CurrentOrgId
387
+	appId := this.GetAdminUserInfo().CurrentAppId
388
+	list, total, err := service.GetAllVacualAccessList(orgId, limit, page, patient_id)
389
+	doctor, err := service.GetAllDoctor(orgId, appId)
390
+	if err == nil {
391
+		this.ServeSuccessJSON(map[string]interface{}{
392
+			"list":   list,
393
+			"total":  total,
394
+			"doctor": doctor,
395
+		})
396
+		return
397
+	}
398
+}
399
+
400
+func (this *DoctorsApiController) GetVascularAccessByDetail() {
401
+
402
+	id, _ := this.GetInt64("id")
403
+
404
+	accessDetail, err := service.GetVasularAccessByDetail(id)
405
+	orgId := this.GetAdminUserInfo().CurrentOrgId
406
+	appId := this.GetAdminUserInfo().CurrentAppId
407
+	doctor, err := service.GetAllDoctor(orgId, appId)
408
+	if err == nil {
409
+		this.ServeSuccessJSON(map[string]interface{}{
410
+			"accessDetail": accessDetail,
411
+			"doctor":       doctor,
412
+		})
413
+		return
414
+	}
415
+}
416
+
417
+func (this *DoctorsApiController) UpdateVasularAccess() {
418
+	id, _ := this.GetInt64("id")
419
+	access_project, _ := this.GetInt64("access_project")
420
+	blood_access_part_id := this.GetString("blood_access_part_id")
421
+	blood_access_part_opera_id := this.GetString("blood_access_part_opera_id")
422
+	first_start_time := this.GetString("first_start_time")
423
+	timeLayout := "2006-01-02"
424
+	loc, _ := time.LoadLocation("Local")
425
+	firstStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", first_start_time+" 00:00:00", loc)
426
+	inflow_pass := this.GetString("inflow_pass")
427
+	remark := this.GetString("remark")
428
+	start_time := this.GetString("start_time")
429
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
430
+	stop_reason := this.GetString("stop_reason")
431
+	user_status, _ := this.GetInt64("user_status")
432
+	stop_time := this.GetString("stop_time")
433
+	stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
434
+	adminUserInfo := this.GetAdminUserInfo()
435
+	orgId := adminUserInfo.CurrentOrgId
436
+	creator := adminUserInfo.AdminUser.Id
437
+	patientId, _ := this.GetInt64("patient_id")
438
+	fmt.Println("patient_id222222222222222222", patientId)
335 439
 	access := models.XtPatientVascularAccess{
336 440
 		AccessProject:          access_project,
337 441
 		BloodAccessPartId:      blood_access_part_id,
@@ -342,26 +446,82 @@ func (this *DoctorsApiController) SaveVasularAccess() {
342 446
 		StartTime:              startTime.Unix(),
343 447
 		StopReason:             stop_reason,
344 448
 		UserStatus:             user_status,
345
-		Creator:                creator,
449
+		Modify:                 creator,
346 450
 		UserOrgId:              orgId,
347 451
 		Status:                 1,
348
-		Ctime:                  time.Now().Unix(),
452
+		StopTime:               stopTime.Unix(),
453
+	}
454
+	_, errcode := service.GetDialysisDateByDateOne(startTime.Unix(), patientId, orgId, id)
455
+	if errcode == gorm.ErrRecordNotFound {
456
+		err := service.UpdateVascularAccess(&access, id)
457
+		if err == nil {
458
+			this.ServeSuccessJSON(map[string]interface{}{
459
+				"access": access,
460
+			})
461
+			return
462
+		}
463
+	} else if errcode == nil {
464
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
465
+		return
349 466
 	}
350
-	err := service.SaveVascularAccess(&access)
467
+
468
+}
469
+
470
+func (this *DoctorsApiController) DeleteVasularAccess() {
471
+	id, _ := this.GetInt64("id")
472
+	err := service.DeleteVasularAccess(id)
473
+	fmt.Println(err)
474
+	returnData := make(map[string]interface{}, 0)
475
+	returnData["msg"] = "ok"
476
+	this.ServeSuccessJSON(returnData)
477
+	return
478
+}
479
+
480
+func (this *DoctorsApiController) SavePassWayAssessment() {
481
+
482
+	blood_dealwidth := this.GetString("blood_dealwith")
483
+	blood_project := this.GetString("blood_project")
484
+	blood_result := this.GetString("blood_result")
485
+	creator, _ := this.GetInt64("creator")
486
+	parent_id, _ := this.GetInt64("parent_id")
487
+	patient_id, _ := this.GetInt64("patient_id")
488
+	start_time := this.GetString("start_time")
489
+	timeLayout := "2006-01-02"
490
+	loc, _ := time.LoadLocation("Local")
491
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
492
+	modify := this.GetAdminUserInfo().AdminUser.Id
493
+	orgId := this.GetAdminUserInfo().CurrentOrgId
494
+	assessment := models.XtPatientPasswayAssessment{
495
+		StartTime:     startTime.Unix(),
496
+		BloodDealwith: blood_dealwidth,
497
+		BloodProject:  blood_project,
498
+		BloodResult:   blood_result,
499
+		Creator:       creator,
500
+		PatientId:     patient_id,
501
+		ParentId:      parent_id,
502
+		Modify:        modify,
503
+		UserOrgId:     orgId,
504
+		Status:        1,
505
+		Ctime:         time.Now().Unix(),
506
+	}
507
+
508
+	err := service.CreatePatientWayAssessment(&assessment)
351 509
 	if err == nil {
352 510
 		this.ServeSuccessJSON(map[string]interface{}{
353
-			"access": access,
511
+			"assessment": assessment,
354 512
 		})
355 513
 		return
356 514
 	}
357 515
 }
358 516
 
359
-func (this *DoctorsApiController) GetAllVacualAccessList() {
517
+func (this *DoctorsApiController) GetAllPassWayAssessment() {
360 518
 
361
-	limit, _ := this.GetInt64("limit")
519
+	patient_id, _ := this.GetInt64("patient_id")
520
+	parent_id, _ := this.GetInt64("parent_id")
362 521
 	page, _ := this.GetInt64("page")
363
-	orgId := this.GetAdminUserInfo().CurrentOrgId
364
-	list, total, err := service.GetAllVacualAccessList(orgId, limit, page)
522
+	limit, _ := this.GetInt64("limit")
523
+	adminUserInfo := this.GetAdminUserInfo()
524
+	list, total, err := service.GetAllPassWayAssessment(parent_id, patient_id, page, limit, adminUserInfo.CurrentOrgId)
365 525
 	if err == nil {
366 526
 		this.ServeSuccessJSON(map[string]interface{}{
367 527
 			"list":  list,
@@ -370,3 +530,54 @@ func (this *DoctorsApiController) GetAllVacualAccessList() {
370 530
 		return
371 531
 	}
372 532
 }
533
+
534
+func (this *DoctorsApiController) GetPasswayAssesmentById() {
535
+
536
+	id, _ := this.GetInt64("id")
537
+	assessment, err := service.GetPasswayAssesmentById(id)
538
+	if err == nil {
539
+		this.ServeSuccessJSON(map[string]interface{}{
540
+			"assessment": assessment,
541
+		})
542
+		return
543
+	}
544
+}
545
+
546
+func (this *DoctorsApiController) UpdatePassWayAssesment() {
547
+	id, _ := this.GetInt64("id")
548
+	blood_dealwidth := this.GetString("blood_dealwith")
549
+	blood_project := this.GetString("blood_project")
550
+	blood_result := this.GetString("blood_result")
551
+	creator, _ := this.GetInt64("creator")
552
+	start_time := this.GetString("start_time")
553
+	timeLayout := "2006-01-02"
554
+	loc, _ := time.LoadLocation("Local")
555
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
556
+	modify := this.GetAdminUserInfo().AdminUser.Id
557
+	assessment := models.XtPatientPasswayAssessment{
558
+		BloodResult:   blood_result,
559
+		BloodDealwith: blood_dealwidth,
560
+		BloodProject:  blood_project,
561
+		Creator:       creator,
562
+		StartTime:     startTime.Unix(),
563
+		Modify:        modify,
564
+	}
565
+	err := service.UpdatePassWayAssesment(&assessment, id)
566
+	if err == nil {
567
+		this.ServeSuccessJSON(map[string]interface{}{
568
+			"assessment": assessment,
569
+		})
570
+		return
571
+	}
572
+}
573
+
574
+func (this *DoctorsApiController) DeleteWayAssessment() {
575
+
576
+	id, _ := this.GetInt64("id")
577
+	err := service.DeleteWayAssessment(id)
578
+	fmt.Println(err)
579
+	returnData := make(map[string]interface{}, 0)
580
+	returnData["msg"] = "ok"
581
+	this.ServeSuccessJSON(returnData)
582
+	return
583
+}

+ 8 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go Vedi File

@@ -337,6 +337,7 @@ func (this *DialysisAPIController) DialysisRecord() {
337 337
 	}
338 338
 
339 339
 	dialysisPrescribe, _ := service.MobileGetDialysisPrescribeByModeId(adminInfo.Org.Id, patientID, date.Unix(), schedual.ModeId)
340
+
340 341
 	//if getDialysisPrescribeErr != nil {
341 342
 	//	this.ErrorLog("获取透析处方失败:%v", getDialysisPrescribeErr)
342 343
 	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -375,6 +376,11 @@ func (this *DialysisAPIController) DialysisRecord() {
375 376
 	stockType, _ := service.GetStockType(adminInfo.Org.Id)
376 377
 
377 378
 	prepare, _ := service.GetDialyStockOut(adminInfo.Org.Id, date.Unix(), patientID)
379
+
380
+	//获取最后一次血管通路
381
+	lastAssessment, parseDateErr := service.GetLastPassWayAssessment(adminInfo.Org.Id, patientID)
382
+
383
+	prescribeOne, parseDateErr := service.MobileGetDialysisPrescribeByModeIdOne(adminInfo.Org.Id, patientID, date.Unix())
378 384
 	var his_advices []*models.HisDoctorAdviceInfo
379 385
 	if is_open_config.IsOpen == 1 {
380 386
 		his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.Org.Id, patientID, date.Unix())
@@ -429,6 +435,8 @@ func (this *DialysisAPIController) DialysisRecord() {
429 435
 		"is_open_config":                 is_open_config,
430 436
 		"stockType":                      stockType,
431 437
 		"prepare":                        prepare,
438
+		"lastAssessment":                 lastAssessment,
439
+		"prescribeOne":                   prescribeOne,
432 440
 	}
433 441
 	this.ServeSuccessJSON(returnData)
434 442
 }

+ 44 - 1
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go Vedi File

@@ -2627,7 +2627,7 @@ func (this *NewDialysisApiController) GetRolePosition() {
2627 2627
 
2628 2628
 	//去查角色
2629 2629
 	role, err := service.GetAdminUserRole(cretor, orgid)
2630
-	fmt.Println("role----------------", role.RoleIds)
2630
+
2631 2631
 	role_ids := strings.Split(role.RoleIds, ",")
2632 2632
 	var names = ""
2633 2633
 	for _, item := range role_ids {
@@ -2750,3 +2750,46 @@ func (this *NewDialysisApiController) SaveCourseManageMentTwo() {
2750 2750
 		"record": record,
2751 2751
 	})
2752 2752
 }
2753
+
2754
+func (this *NewDialysisApiController) GetVascularAccess() {
2755
+
2756
+	limit, _ := this.GetInt64("limit")
2757
+	page, _ := this.GetInt64("page")
2758
+	patient_id, _ := this.GetInt64("patient_id")
2759
+	orgId := this.GetMobileAdminUserInfo().Org.Id
2760
+	adminInfo := this.GetMobileAdminUserInfo()
2761
+	appId := adminInfo.App.Id
2762
+	list, total, err := service.GetAllVacualAccessList(orgId, limit, page, patient_id)
2763
+	doctor, err := service.GetAllDoctor(orgId, appId)
2764
+	if err == nil {
2765
+		this.ServeSuccessJSON(map[string]interface{}{
2766
+			"list":   list,
2767
+			"total":  total,
2768
+			"doctor": doctor,
2769
+		})
2770
+		return
2771
+	}
2772
+}
2773
+
2774
+func (this *NewDialysisApiController) GetVascularAccessDetail() {
2775
+
2776
+	patient_id, _ := this.GetInt64("patient_id")
2777
+	parent_id, _ := this.GetInt64("parent_id")
2778
+	page, _ := this.GetInt64("page")
2779
+	limit, _ := this.GetInt64("limit")
2780
+	orgId := this.GetMobileAdminUserInfo().Org.Id
2781
+	list, total, err := service.GetAllPassWayAssessment(parent_id, patient_id, page, limit, orgId)
2782
+
2783
+	adminInfo := this.GetMobileAdminUserInfo()
2784
+	appId := adminInfo.App.Id
2785
+	allDoctor, err := service.GetAllDoctor(orgId, appId)
2786
+
2787
+	if err == nil {
2788
+		this.ServeSuccessJSON(map[string]interface{}{
2789
+			"list":      list,
2790
+			"total":     total,
2791
+			"allDoctor": allDoctor,
2792
+		})
2793
+		return
2794
+	}
2795
+}

+ 2 - 0
controllers/new_mobile_api_controllers/new_mobile_api_router_register.go Vedi File

@@ -162,6 +162,8 @@ func NewMobileAPIControllersRegisterRouters() {
162 162
 	beego.Router("/m/api/patient/deletemanagementtwo", &NewDialysisApiController{}, "Delete:DeleteManageMentTwo")
163 163
 	beego.Router("/m/api/patient/savecouresemanagement", &NewDialysisApiController{}, "Get:SaveCourseManageMent")
164 164
 	beego.Router("/m/api/patient/savecoursemanagementtwo", &NewDialysisApiController{}, "Get:SaveCourseManageMentTwo")
165
+	beego.Router("/m/api/patient/getvascularaccess", &NewDialysisApiController{}, "Get:GetVascularAccess")
166
+	beego.Router("/m/api/patient/getvascularaccessdetail", &NewDialysisApiController{}, "Get:GetVascularAccessDetail")
165 167
 
166 168
 	//His相关
167 169
 	beego.Router("/m/api/hispatientlist/get", &MobileHisApiController{}, "Get:GetHisPatientList")

+ 5 - 0
controllers/patient_api_controller.go Vedi File

@@ -3390,6 +3390,11 @@ func defaultSolutionFormData(solution *models.DialysisSolution, data []byte, met
3390 3390
 		solution.Remark = remark
3391 3391
 	}
3392 3392
 
3393
+	if dataBody["created_time"] != nil && reflect.TypeOf(dataBody["created_time"]).String() == "float64" {
3394
+		created_time := int64(dataBody["created_time"].(float64))
3395
+
3396
+		solution.CreatedTime = created_time
3397
+	}
3393 3398
 	return
3394 3399
 }
3395 3400
 

+ 1 - 0
controllers/stock_in_api_controller.go Vedi File

@@ -1985,6 +1985,7 @@ func (this *StockManagerApiController) GetOutStockTotalCount() {
1985 1985
 	warehouseOutTime, _ := this.GetInt64("warehouse_out_time")
1986 1986
 	adminUserInfo := this.GetAdminUserInfo()
1987 1987
 	stockCount, err := service.GetOutStockTotalCount(warehouseOutTime, adminUserInfo.CurrentOrgId)
1988
+
1988 1989
 	if err != nil {
1989 1990
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
1990 1991
 	}

+ 23 - 0
models/user_models.go Vedi File

@@ -487,9 +487,32 @@ type XtPatientVascularAccess struct {
487 487
 	Ctime                  int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
488 488
 	Mtime                  int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
489 489
 	Modify                 int64  `gorm:"column:modify" json:"modify" form:"modify"`
490
+	StopTime               int64  `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
491
+	PatientId              int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
490 492
 }
491 493
 
492 494
 func (XtPatientVascularAccess) TableName() string {
493 495
 
494 496
 	return "xt_patient_vascular_access"
495 497
 }
498
+
499
+type XtPatientPasswayAssessment struct {
500
+	ID            int64  `gorm:"column:id" json:"id" form:"id"`
501
+	StartTime     int64  `gorm:"column:start_time" json:"start_time" form:"start_time"`
502
+	Creator       int64  `gorm:"column:creator" json:"creator" form:"creator"`
503
+	BloodProject  string `gorm:"column:blood_project" json:"blood_project" form:"blood_project"`
504
+	BloodResult   string `gorm:"column:blood_result" json:"blood_result" form:"blood_result"`
505
+	BloodDealwith string `gorm:"column:blood_dealwith" json:"blood_dealwith" form:"blood_dealwith"`
506
+	Modify        int64  `gorm:"column:modify" json:"modify" form:"modify"`
507
+	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
508
+	PatientId     int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
509
+	ParentId      int64  `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
510
+	Status        int64  `gorm:"column:status" json:"status" form:"status"`
511
+	Ctime         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
512
+	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
513
+}
514
+
515
+func (XtPatientPasswayAssessment) TableName() string {
516
+
517
+	return "xt_patient_passway_assessment"
518
+}

+ 13 - 0
service/mobile_dialysis_service.go Vedi File

@@ -1190,6 +1190,19 @@ func MobileGetDialysisPrescribeByModeId(orgID int64, patientID int64, recordDate
1190 1190
 	return &record, nil
1191 1191
 }
1192 1192
 
1193
+func MobileGetDialysisPrescribeByModeIdOne(orgID int64, patientID int64, recordDate int64) (*models.DialysisPrescription, error) {
1194
+	var record models.DialysisPrescription
1195
+	err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ?", patientID, orgID, recordDate).First(&record).Error
1196
+	if err != nil {
1197
+		if err == gorm.ErrRecordNotFound {
1198
+			return nil, nil
1199
+		} else {
1200
+			return nil, err
1201
+		}
1202
+	}
1203
+	return &record, nil
1204
+}
1205
+
1193 1206
 func MobileGetLastDialysisPrescribe(orgID int64, patientID int64) (*models.DialysisPrescription, error) {
1194 1207
 	var record models.DialysisPrescription
1195 1208
 	err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 ", patientID, orgID).Last(&record).Error

+ 1 - 1
service/patient_service.go Vedi File

@@ -956,7 +956,7 @@ func GetPatientDialysisRecord(orgID, patientID int64, page, limit, start, end, m
956 956
 		db = db.Where("do.dialysis_date<=?", end)
957 957
 	}
958 958
 	if mode_id > 0 {
959
-		db = db.Joins("JOIN xt_dialysis_prescription as dp ON dp.record_id=do.id")
959
+		db = db.Joins("JOIN xt_dialysis_prescription as dp ON dp.patient_id=do.patient_id and dp.user_org_id = do.user_org_id and dp.record_date = do.dialysis_date")
960 960
 		db = db.Where("dp.mode_id=?", mode_id)
961 961
 	}
962 962
 

+ 82 - 2
service/patientmanage_service.go Vedi File

@@ -1475,15 +1475,95 @@ func GetDialysAfterRecord(patientid int64, startime int64, endtime int64, orgid
1475 1475
 	return dislysis, err
1476 1476
 }
1477 1477
 
1478
+func GetDialysisDateByDate(starTime int64, patientId int64, orgId int64) (*models.XtPatientVascularAccess, error) {
1479
+	access := models.XtPatientVascularAccess{}
1480
+	err := XTReadDB().Model(&access).Where("start_time = ? and patient_id = ? and user_org_id = ? and status = 1", starTime, patientId, orgId).Find(&access).Error
1481
+	if err == gorm.ErrRecordNotFound {
1482
+		return nil, err
1483
+	}
1484
+	if err != nil {
1485
+		return nil, err
1486
+	}
1487
+	return &access, nil
1488
+}
1489
+
1490
+func GetDialysisDateByDateOne(starTime int64, patientId int64, orgId int64, id int64) (*models.XtPatientVascularAccess, error) {
1491
+	access := models.XtPatientVascularAccess{}
1492
+	err := XTReadDB().Model(&access).Where("start_time = ? and patient_id = ? and user_org_id = ? and status = 1 and id <> ?", starTime, patientId, orgId, id).Find(&access).Error
1493
+	if err == gorm.ErrRecordNotFound {
1494
+		return nil, err
1495
+	}
1496
+	if err != nil {
1497
+		return nil, err
1498
+	}
1499
+	return &access, nil
1500
+}
1501
+
1478 1502
 func SaveVascularAccess(access *models.XtPatientVascularAccess) error {
1479 1503
 
1480 1504
 	err := XTWriteDB().Create(&access).Error
1481 1505
 	return err
1482 1506
 }
1483 1507
 
1484
-func GetAllVacualAccessList(orgid int64, limit int64, page int64) (vascular []*models.XtPatientVascularAccess, total int64, err error) {
1508
+func GetAllVacualAccessList(orgid int64, limit int64, page int64, patientId int64) (vascular []*models.XtPatientVascularAccess, total int64, err error) {
1485 1509
 
1486 1510
 	offset := (page - 1) * limit
1487
-	err = XTReadDB().Model(&vascular).Where("user_org_id = ? and status = 1", orgid).Count(&total).Offset(offset).Limit(limit).Find(&vascular).Error
1511
+	err = XTReadDB().Model(&vascular).Where("user_org_id = ? and status = 1 and patient_id = ?", orgid, patientId).Count(&total).Offset(offset).Limit(limit).Order("start_time desc").Find(&vascular).Error
1488 1512
 	return vascular, total, err
1489 1513
 }
1514
+
1515
+func GetVasularAccessByDetail(id int64) (models.XtPatientVascularAccess, error) {
1516
+	access := models.XtPatientVascularAccess{}
1517
+	err := XTReadDB().Where("id = ? and status =1", id).Find(&access).Error
1518
+	return access, err
1519
+}
1520
+
1521
+func UpdateVascularAccess(access *models.XtPatientVascularAccess, id int64) error {
1522
+
1523
+	err := XTWriteDB().Model(&access).Where("id= ?", id).Updates(map[string]interface{}{"access_project": access.AccessProject, "blood_access_part_id": access.BloodAccessPartId, "inflow_pass": access.InflowPass, "start_time": access.StartTime, "first_start_time": access.FirstStartTime, "blood_access_part_opera_id": access.BloodAccessPartOperaId, "stop_reason": access.StopReason, "remark": access.Remark, "user_status": access.UserStatus, "modify": access.Modify, "stop_time": access.StopTime}).Error
1524
+	return err
1525
+}
1526
+
1527
+func DeleteVasularAccess(id int64) error {
1528
+	access := models.XtPatientVascularAccess{}
1529
+	err := XTWriteDB().Model(&access).Where("id = ?", id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1530
+	return err
1531
+}
1532
+
1533
+func CreatePatientWayAssessment(assessment *models.XtPatientPasswayAssessment) error {
1534
+
1535
+	err := XTWriteDB().Create(&assessment).Error
1536
+	return err
1537
+}
1538
+
1539
+func GetAllPassWayAssessment(parent_id int64, patient_id int64, page int64, limit int64, orgid int64) (assessment []*models.XtPatientPasswayAssessment, total int64, err error) {
1540
+	offset := (page - 1) * limit
1541
+	err = XTReadDB().Model(&assessment).Where("parent_id = ? and patient_id = ? and user_org_id = ? and status =1", parent_id, patient_id, orgid).Count(&total).Offset(offset).Limit(limit).Order("start_time desc").Find(&assessment).Error
1542
+	return assessment, total, err
1543
+}
1544
+
1545
+func GetPasswayAssesmentById(id int64) (models.XtPatientPasswayAssessment, error) {
1546
+
1547
+	assessment := models.XtPatientPasswayAssessment{}
1548
+	err := XTReadDB().Model(&assessment).Where("id=? and status =1", id).Find(&assessment).Error
1549
+	return assessment, err
1550
+}
1551
+
1552
+func UpdatePassWayAssesment(assessment *models.XtPatientPasswayAssessment, id int64) error {
1553
+
1554
+	err := XTWriteDB().Model(&assessment).Where("id = ?", id).Updates(map[string]interface{}{"start_time": assessment.StartTime, "creator": assessment.Creator, "blood_project": assessment.BloodProject, "blood_result": assessment.BloodResult, "blood_dealwith": assessment.BloodDealwith, "modify": assessment.Modify, "updated_time": time.Now().Unix()}).Error
1555
+	return err
1556
+}
1557
+
1558
+func DeleteWayAssessment(id int64) error {
1559
+	assessment := models.XtPatientPasswayAssessment{}
1560
+	err := XTWriteDB().Model(&assessment).Where("id = ?", id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1561
+	return err
1562
+}
1563
+
1564
+func GetLastPassWayAssessment(orgid int64, patientId int64) (models.XtPatientVascularAccess, error) {
1565
+
1566
+	assessment := models.XtPatientVascularAccess{}
1567
+	err := XTReadDB().Model(&assessment).Where("user_org_id = ? and patient_id = ? and status =1 and user_status = 1", orgid, patientId).Order("start_time desc").Last(&assessment).Error
1568
+	return assessment, err
1569
+}

+ 1 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go Vedi File

@@ -506,6 +506,7 @@ type MonitoringRecordVM struct {
506 506
 	Creator                   int64   `gorm:"column:creator" json:"creator" form:"creator"`
507 507
 	Modify                    int64   `gorm:"column:modify" json:"modify" form:"modify"`
508 508
 	Heparin                   float64 `gorm:"column:heparin" json:"heparin" form:"heparin"`
509
+	DialysateFlow             float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
509 510
 }
510 511
 
511 512
 func (MonitoringRecordVM) TableName() string {

+ 1 - 1
service/self_drug_service.go Vedi File

@@ -793,6 +793,6 @@ func GetSelfOutStockQuery(startTime int64, endTime int64, orgid int64) (selfouts
793 793
 	if orgid > 0 {
794 794
 		db = db.Where("x.user_org_id = ?", orgid)
795 795
 	}
796
-	err = db.Select("x.drug_name_id,Sum(x.outstore_number) as count").Group("x.drug_name_id").Scan(&selfoutstock).Error
796
+	err = db.Select("x.drug_name_id,Sum(x.outstore_number) as count").Group("x.drug_name").Scan(&selfoutstock).Error
797 797
 	return selfoutstock, err
798 798
 }