Browse Source

医保对接

csx 4 years ago
parent
commit
3f1ac66ef3
42 changed files with 3293 additions and 500 deletions
  1. 6 6
      controllers/base_api_controller.go
  2. 7 0
      controllers/data_api_controller.go
  3. 148 11
      controllers/dialysis_api_controller.go
  4. 10 0
      controllers/dialysis_record_api_controller.go
  5. 259 11
      controllers/doctors_api_controller.go
  6. 14 0
      controllers/gobal_config_api_controller.go
  7. 7 1
      controllers/his_project_api_controller.go
  8. 2 0
      controllers/inspection_api_controller.go
  9. 1207 207
      controllers/manage_api_controller.go
  10. 9 1
      controllers/manager_center_api_controller.go
  11. 290 80
      controllers/mobile_api_controllers/dialysis_api_controller.go
  12. 8 1
      controllers/mobile_api_controllers/dialysis_api_controller_extend.go
  13. 1 0
      controllers/mobile_api_controllers/mobile_api_router_register.go
  14. 44 1
      controllers/new_mobile_api_controllers/new_dialysis_api_controller.go
  15. 25 2
      controllers/new_mobile_api_controllers/new_manage_api_controller.go
  16. 1 0
      controllers/new_mobile_api_controllers/new_manage_api_router.go
  17. 2 0
      controllers/new_mobile_api_controllers/new_mobile_api_router_register.go
  18. 100 80
      controllers/patient_api_controller.go
  19. 128 0
      controllers/schedule_api_controller.go
  20. 1 0
      controllers/stock_good_api_controller.go
  21. 2 1
      controllers/stock_in_api_controller.go
  22. 1 0
      models/data_models.go
  23. 177 47
      models/device_models.go
  24. 4 0
      models/dialysis.go
  25. 1 0
      models/drug.go
  26. 2 0
      models/gobal_models.go
  27. 1 0
      models/his_models.go
  28. 4 0
      models/patient_models.go
  29. 79 0
      models/user_models.go
  30. 1 1
      service/data.go
  31. 26 1
      service/dialysis_service.go
  32. 3 3
      service/drug_stock_service.go
  33. 41 0
      service/gobal_config_service.go
  34. 9 2
      service/his_project_service.go
  35. 7 1
      service/inspection_service.go
  36. 333 28
      service/manage_service.go
  37. 163 4
      service/mobile_dialysis_service.go
  38. 2 2
      service/patient_service.go
  39. 105 5
      service/patientmanage_service.go
  40. 30 0
      service/schedule_service.go
  41. 1 1
      service/self_drug_service.go
  42. 32 3
      service/stock_service.go

+ 6 - 6
controllers/base_api_controller.go View File

@@ -81,7 +81,7 @@ func (this *BaseAuthAPIController) Prepare() {
81 81
 		userAdmin.ModifyTime = 1530786071
82 82
 		var subscibe models.ServeSubscibe
83 83
 		subscibe.ID = 1
84
-		subscibe.OrgId = 9919
84
+		subscibe.OrgId = 3877
85 85
 		subscibe.PeriodStart = 1538035409
86 86
 		subscibe.PeriodEnd = 1569571409
87 87
 		subscibe.State = 1
@@ -91,14 +91,14 @@ func (this *BaseAuthAPIController) Prepare() {
91 91
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
92 92
 		subscibes[4] = &subscibe
93 93
 		var adminUserInfo service.AdminUserInfo
94
-		adminUserInfo.CurrentOrgId = 9919
94
+		adminUserInfo.CurrentOrgId = 3877
95 95
 		adminUserInfo.CurrentAppId = 4
96 96
 		adminUserInfo.AdminUser = &userAdmin
97 97
 		adminUserInfo.Subscibes = subscibes
98 98
 		this.SetSession("admin_user_info", &adminUserInfo)
99 99
 
100
-		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
101
-		//this.StopRun()
100
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
101
+		this.StopRun()
102 102
 
103 103
 	}
104 104
 
@@ -327,7 +327,7 @@ func (this *BaseServeAPIController) Prepare() {
327 327
 		userAdmin.ModifyTime = 1530786071
328 328
 		var subscibe models.ServeSubscibe
329 329
 		subscibe.ID = 1
330
-		subscibe.OrgId = 9919
330
+		subscibe.OrgId = 3877
331 331
 		subscibe.PeriodStart = 1538035409
332 332
 		subscibe.PeriodEnd = 1569571409
333 333
 		subscibe.State = 1
@@ -337,7 +337,7 @@ func (this *BaseServeAPIController) Prepare() {
337 337
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
338 338
 		subscibes[4] = &subscibe
339 339
 		var adminUserInfo service.AdminUserInfo
340
-		adminUserInfo.CurrentOrgId = 9919
340
+		adminUserInfo.CurrentOrgId = 3877
341 341
 		adminUserInfo.CurrentAppId = 4
342 342
 		adminUserInfo.AdminUser = &userAdmin
343 343
 		adminUserInfo.Subscibes = subscibes

+ 7 - 0
controllers/data_api_controller.go View File

@@ -224,6 +224,7 @@ func (c *DataApiController) UpdateChildConfig() {
224 224
 	dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
225 225
 	dataconfig.Remark = string(dataBody["remark"].(string))
226 226
 	dataconfig.Order = int64(dataBody["orders"].(float64))
227
+	dataconfig.FieldType = int64(dataBody["field_type"].(float64))
227 228
 	fmt.Println("dataconfitg------", dataconfig.Order)
228 229
 	//if dataBody["orders"] != nil {
229 230
 	//	dataconfig.Order = int64(dataBody["orders"].(float64))
@@ -348,6 +349,12 @@ func (c *DataApiController) CreateChildConfig() {
348 349
 		dataconfig.Order = 0
349 350
 	}
350 351
 
352
+	if dataBody["field_type"] != nil {
353
+		dataconfig.FieldType = int64(dataBody["field_type"].(float64))
354
+	} else {
355
+		dataconfig.FieldType = 0
356
+	}
357
+
351 358
 	// 验证关键字段的值是否重复
352 359
 	// thisConfig,_:=service.FindConfigByName(dataconfig.Module, dataconfig.Name,dataconfig.ParentId,dataconfig.OrgId)
353 360
 	// if thisConfig.ID >0 {

+ 148 - 11
controllers/dialysis_api_controller.go View File

@@ -244,8 +244,9 @@ func (c *DialysisApiController) PostPrescription() {
244 244
 	//fmt.Println("下机前推注鱼精蛋白",push_the_protamine)
245 245
 	// var prescription_doctor int64
246 246
 	blood := c.GetString("blood")
247
-	//dialysis_dialyszers := c.GetString("dialysis_dialyszers")
248
-	//dialysis_irrigation := c.GetString("dialysis_irrigation")
247
+	dialysis_dialyszers := c.GetString("dialysis_dialyszers")
248
+
249
+	dialysis_irrigation := c.GetString("dialysis_irrigation")
249 250
 	antioxidant_commodity_name := c.GetString("antioxidant_commodity_name")
250 251
 	displace_speed := c.GetString("displace_speed")
251 252
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
@@ -326,13 +327,78 @@ func (c *DialysisApiController) PostPrescription() {
326 327
 		PreImpulse:                 preImpules,
327 328
 		AnticoagulantStopTimeHour:  anticoagulant_stop_time_hour,
328 329
 		AnticoagulantStopTimeMin:   anticoagulant_stop_time_min,
329
-		Blood:                      blood,
330
-		//DialysisDialyszers:         dialysis_dialyszers,
331
-		//DialysisIrrigation:         dialysis_irrigation,
330
+		Blood:                    blood,
331
+		DialysisDialyszers:       dialysis_dialyszers,
332
+		DialysisIrrigation:       dialysis_irrigation,
332 333
 		AntioxidantCommodityName: antioxidant_commodity_name,
333 334
 		DisplaceSpeed:            displace_speed,
334 335
 	}
335 336
 
337
+	//查询最近透析准备表里是否存在 透析器 灌流器
338
+
339
+	//splitStr := strings.Split(dialysis_dialyszers, ",")
340
+	//
341
+	//splitIrrigation := strings.Split(dialysis_irrigation, ",")
342
+	//
343
+	//mation, _ := service.GetGoodInfoMation(adminUserInfo.CurrentOrgId)
344
+	//if len(mation)>0{
345
+	//  for _, item := range splitStr {
346
+	//    for _,it := range mation{
347
+	//      if(item == it.SpecificationName){
348
+	//
349
+	//        //查询最近一次的透析器
350
+	//        _, errcode := service.GetDialysisBeforePrepare(it.GoodTypeId, it.ID, adminUserInfo.CurrentOrgId,patient)
351
+	//
352
+	//        if errcode == gorm.ErrRecordNotFound{
353
+	//          //插入数据
354
+	//          prepare := models.DialysisBeforePrepare{
355
+	//            UserOrgId:  adminUserInfo.CurrentOrgId,
356
+	//            PatientId:  patient,
357
+	//            RecordDate: recordDate.Unix(),
358
+	//            GoodTypeId: it.GoodTypeId,
359
+	//            GoodId:     it.ID,
360
+	//            Count:      1,
361
+	//            Ctime:      time.Now().Unix(),
362
+	//            Creater:    adminUserInfo.AdminUser.Id,
363
+	//            Status:1,
364
+	//
365
+	//          }
366
+	//          errcode := service.CreateDialysisBeforePrepareOne(&prepare)
367
+	//          fmt.Println("",errcode)
368
+	//        }
369
+	//      }
370
+	//    }
371
+	//
372
+	//  }
373
+	//
374
+	//  for _, item := range splitIrrigation {
375
+	//    for _,it := range mation{
376
+	//      if(item == it.SpecificationName){
377
+	//        //查询最近一次的透析器
378
+	//        _, errcode := service.GetDialysisBeforePrepare(it.GoodTypeId, it.ID, adminUserInfo.CurrentOrgId,patient)
379
+	//        if errcode == gorm.ErrRecordNotFound{
380
+	//          //插入数据
381
+	//          prepare := models.DialysisBeforePrepare{
382
+	//            UserOrgId:  adminUserInfo.CurrentOrgId,
383
+	//            PatientId:  patient,
384
+	//            RecordDate: recordDate.Unix(),
385
+	//            GoodTypeId: it.GoodTypeId,
386
+	//            GoodId:     it.ID,
387
+	//            Count:      1,
388
+	//            Ctime:      time.Now().Unix(),
389
+	//            Creater:    adminUserInfo.AdminUser.Id,
390
+	//            Status:1,
391
+	//
392
+	//          }
393
+	//          errcode := service.CreateDialysisBeforePrepareOne(&prepare)
394
+	//          fmt.Println(errcode)
395
+	//      }
396
+	//      }
397
+	//    }
398
+	//  }
399
+	//
400
+	//}
401
+
336 402
 	if appRole.UserType == 2 || appRole.UserType == 1 {
337 403
 		prescription.PrescriptionDoctor = appRole.AdminUserId
338 404
 	}
@@ -497,8 +563,8 @@ func (c *DialysisApiController) PostSoulution() {
497 563
 	anticoagulant_stop_time_hour, _ := c.GetInt64("anticoagulant_stop_time_hour", 0)
498 564
 	anticoagulant_stop_time_min, _ := c.GetInt64("anticoagulant_stop_time_min", 0)
499 565
 	blood := c.GetString("blood")
500
-	//dialysis_dialyszers := c.GetString("dialysis_dialyszers")
501
-	//dialysis_irrigation := c.GetString("dialysis_irrigation")
566
+	dialysis_dialyszers := c.GetString("dialysis_dialyszers")
567
+	dialysis_irrigation := c.GetString("dialysis_irrigation")
502 568
 	antioxidant_commodity_name := c.GetString("antioxidant_commodity_name")
503 569
 	displace_speed := c.GetString("displace_speed")
504 570
 	var prescription_doctor int64
@@ -590,13 +656,77 @@ func (c *DialysisApiController) PostSoulution() {
590 656
 
591 657
 		AnticoagulantStopTimeHour: anticoagulant_stop_time_hour,
592 658
 		AnticoagulantStopTimeMin:  anticoagulant_stop_time_min,
593
-		Blood:                     blood,
594
-		//DialysisIrrigation:        dialysis_irrigation,
595
-		//DialysisDialyszers:        dialysis_dialyszers,
659
+		Blood:                    blood,
660
+		DialysisIrrigation:       dialysis_irrigation,
661
+		DialysisDialyszers:       dialysis_dialyszers,
596 662
 		AntioxidantCommodityName: antioxidant_commodity_name,
597 663
 		DisplaceSpeed:            displace_speed,
598 664
 	}
599 665
 
666
+	//查询最近透析准备表里是否存在 透析器 灌流器
667
+
668
+	//splitStr := strings.Split(dialysis_dialyszers, ",")
669
+	//
670
+	//splitIrrigation := strings.Split(dialysis_irrigation, ",")
671
+	//
672
+	//mation, _ := service.GetGoodInfoMation(adminUserInfo.CurrentOrgId)
673
+	//if len(mation)>0{
674
+	//  for _, item := range splitStr {
675
+	//    for _,it := range mation{
676
+	//      if(item == it.SpecificationName){
677
+	//
678
+	//        //查询最近一次的透析器
679
+	//        _, errcode := service.GetDialysisBeforePrepare(it.GoodTypeId, it.ID, adminUserInfo.CurrentOrgId,patient)
680
+	//
681
+	//        if errcode == gorm.ErrRecordNotFound{
682
+	//          //插入数据
683
+	//          prepare := models.DialysisBeforePrepare{
684
+	//            UserOrgId:  adminUserInfo.CurrentOrgId,
685
+	//            PatientId:  patient,
686
+	//            RecordDate: recordDate.Unix(),
687
+	//            GoodTypeId: it.GoodTypeId,
688
+	//            GoodId:     it.ID,
689
+	//            Count:      1,
690
+	//            Ctime:      time.Now().Unix(),
691
+	//            Creater:    adminUserInfo.AdminUser.Id,
692
+	//            Status:1,
693
+	//
694
+	//          }
695
+	//          errcode := service.CreateDialysisBeforePrepareOne(&prepare)
696
+	//          fmt.Println("",errcode)
697
+	//        }
698
+	//      }
699
+	//    }
700
+	//
701
+	//  }
702
+	//
703
+	//  for _, item := range splitIrrigation {
704
+	//    for _,it := range mation{
705
+	//      if(item == it.SpecificationName){
706
+	//        //查询最近一次的透析器
707
+	//        _, errcode := service.GetDialysisBeforePrepare(it.GoodTypeId, it.ID, adminUserInfo.CurrentOrgId,patient)
708
+	//        if errcode == gorm.ErrRecordNotFound{
709
+	//          //插入数据
710
+	//          prepare := models.DialysisBeforePrepare{
711
+	//            UserOrgId:  adminUserInfo.CurrentOrgId,
712
+	//            PatientId:  patient,
713
+	//            RecordDate: recordDate.Unix(),
714
+	//            GoodTypeId: it.GoodTypeId,
715
+	//            GoodId:     it.ID,
716
+	//            Count:      1,
717
+	//            Ctime:      time.Now().Unix(),
718
+	//            Creater:    adminUserInfo.AdminUser.Id,
719
+	//            Status:1,
720
+	//
721
+	//          }
722
+	//          errcode := service.CreateDialysisBeforePrepareOne(&prepare)
723
+	//          fmt.Println(errcode)
724
+	//        }
725
+	//      }
726
+	//    }
727
+	//  }
728
+	//}
729
+
600 730
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
601 731
 	if dialysisPrescription.ID == 0 { //新增
602 732
 		if appRole.UserType == 2 || appRole.UserType == 1 {
@@ -604,7 +734,7 @@ func (c *DialysisApiController) PostSoulution() {
604 734
 		}
605 735
 
606 736
 		prescription.Creater = adminUserInfo.AdminUser.Id
607
-		//prescription.Creater = adminUserInfo.AdminUser.Id
737
+
608 738
 	} else { //修改
609 739
 
610 740
 		//template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
@@ -687,6 +817,8 @@ func (c *DialysisApiController) PostSoulution() {
687 817
 		BodyFluidOther:             body_fluid_other,
688 818
 		ReplacementTotal:           replacement_total,
689 819
 		TargetKtv:                  target_ktv,
820
+		DialysisIrrigation:         dialysis_irrigation,
821
+		DialysisDialyszers:         dialysis_dialyszers,
690 822
 	}
691 823
 	err := service.SavePrescriptionAndCreateSolution(&solution, &prescription)
692 824
 	if err == nil {
@@ -1955,6 +2087,9 @@ func (c *DialysisApiController) CreateMonitor() {
1955 2087
 	result := c.GetString("results")
1956 2088
 
1957 2089
 	monitoring_nurse, _ := c.GetInt64("monitoring_nurse", 0)
2090
+
2091
+	monitor_anticoagulant, _ := c.GetInt64("monitor_anticoagulant")
2092
+	monitor_anticoagulant_value := c.GetString("monitor_anticoagulant_value")
1958 2093
 	monitoring_date = monitoring_date / 1000
1959 2094
 	// operate_time = operate_time / 1000
1960 2095
 	if patient <= 0 {
@@ -2007,6 +2142,8 @@ func (c *DialysisApiController) CreateMonitor() {
2007 2142
 		DisplacementFlowQuantity:  displacement_flow_quantity,
2008 2143
 		Heparin:                   heparin,
2009 2144
 		DialysateFlow:             dialysate_flow,
2145
+		MonitorAnticoagulant:      monitor_anticoagulant,
2146
+		MonitorAnticoagulantValue: monitor_anticoagulant_value,
2010 2147
 	}
2011 2148
 
2012 2149
 	err := service.CreateMonitor(&monitorRecord)

+ 10 - 0
controllers/dialysis_record_api_controller.go View 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
 
@@ -345,6 +349,8 @@ type EditMonitorParamObject struct {
345 349
 	DialysateFlow             float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
346 350
 	Urr                       string  `gorm:"column:urr" json:"urr" form:"urr"`
347 351
 	BloodSugar                float64 `gorm:"column:blood_sugar" json:"blood_sugar" form:"blood_sugar"`
352
+	MonitorAnticoagulant      int64   `gorm:"column:monitor_anticoagulant" json:"monitor_anticoagulant" form:"monitor_anticoagulant"`
353
+	MonitorAnticoagulantValue string  `gorm:"column:monitor_anticoagulant_value" json:"monitor_anticoagulant_value" form:"monitor_anticoagulant_value"`
348 354
 }
349 355
 
350 356
 // /api/dislysis/monitor/edit [post]
@@ -455,6 +461,8 @@ func (this *DialysisRecordAPIController) EditMonitor() {
455 461
 			DialysateFlow:             monitorParam.DialysateFlow,
456 462
 			Urr:                       monitorParam.Urr,
457 463
 			BloodSugar:                monitorParam.BloodSugar,
464
+			MonitorAnticoagulant:      monitorParam.MonitorAnticoagulant,
465
+			MonitorAnticoagulantValue: monitorParam.MonitorAnticoagulantValue,
458 466
 		}
459 467
 		createErr := service.CreateMonitor(&monitor)
460 468
 		if createErr != nil {
@@ -521,6 +529,8 @@ func (this *DialysisRecordAPIController) EditMonitor() {
521 529
 		monitor.DialysateFlow = monitorParam.DialysateFlow
522 530
 		monitor.Urr = monitorParam.Urr
523 531
 		monitor.BloodSugar = monitorParam.BloodSugar
532
+		monitor.MonitorAnticoagulant = monitorParam.MonitorAnticoagulant
533
+		monitor.MonitorAnticoagulantValue = monitorParam.MonitorAnticoagulantValue
524 534
 		updateErr := service.UpdateMonitor(monitor)
525 535
 		if updateErr != nil {
526 536
 			this.ErrorLog("修改透析监测记录失败:%v", updateErr)

+ 259 - 11
controllers/doctors_api_controller.go View File

@@ -30,6 +30,15 @@ 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")
41
+	beego.Router("/api/patient/getaccesslist", &DoctorsApiController{}, "Get:GetAccessList")
33 42
 }
34 43
 
35 44
 func (c *DoctorsApiController) ScheduleAdvices() {
@@ -37,7 +46,8 @@ func (c *DoctorsApiController) ScheduleAdvices() {
37 46
 	adviceType, _ := c.GetInt("advice_type")
38 47
 	patientType, _ := c.GetInt("patient_type")
39 48
 	delivery_way := c.GetString("delivery_way")
40
-
49
+	schedule_type, _ := c.GetInt64("schedule_type")
50
+	partition_type, _ := c.GetInt64("partition_type")
41 51
 	if adviceType != 1 && adviceType != 3 && adviceType != 2 {
42 52
 		adviceType = 0
43 53
 	}
@@ -56,8 +66,8 @@ func (c *DoctorsApiController) ScheduleAdvices() {
56 66
 	adminUserInfo := c.GetAdminUserInfo()
57 67
 	orgID := adminUserInfo.CurrentOrgId
58 68
 
59
-	scheduals, err := service.MobileGetScheduleDoctorAdvices(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way)
60
-	hisAdvices, _ := service.GetHisDoctorAdvices(orgID, date.Unix(), delivery_way)
69
+	scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type)
70
+	hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type)
61 71
 	config, _ := service.GetHisDoctorConfig(orgID)
62 72
 	adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
63 73
 	if err != nil {
@@ -329,9 +339,116 @@ func (this *DoctorsApiController) SaveVasularAccess() {
329 339
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
330 340
 	stop_reason := this.GetString("stop_reason")
331 341
 	user_status, _ := this.GetInt64("user_status")
342
+	stop_time := this.GetString("stop_time")
343
+	stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
344
+	patient_id, _ := this.GetInt64("patient_id")
345
+	other_vascular := this.GetString("other_vascular")
346
+	ci_type, _ := this.GetInt64("ci_type")
347
+	blood_cultupe, _ := this.GetInt64("blood_cultupe")
348
+	sequelae_type, _ := this.GetInt64("sequelae_type")
332 349
 	adminUserInfo := this.GetAdminUserInfo()
333 350
 	orgId := adminUserInfo.CurrentOrgId
334 351
 	creator := adminUserInfo.AdminUser.Id
352
+
353
+	//查询改日期是否存在
354
+	_, errcode := service.GetDialysisDateByDate(startTime.Unix(), patient_id, orgId)
355
+	if errcode == gorm.ErrRecordNotFound {
356
+		access := models.XtPatientVascularAccess{
357
+			AccessProject:          access_project,
358
+			BloodAccessPartId:      blood_access_part_id,
359
+			BloodAccessPartOperaId: blood_access_part_opera_id,
360
+			FirstStartTime:         firstStartTime.Unix(),
361
+			InflowPass:             inflow_pass,
362
+			Remark:                 remark,
363
+			StartTime:              startTime.Unix(),
364
+			StopReason:             stop_reason,
365
+			UserStatus:             user_status,
366
+			Creator:                creator,
367
+			UserOrgId:              orgId,
368
+			Status:                 1,
369
+			Ctime:                  time.Now().Unix(),
370
+			StopTime:               stopTime.Unix(),
371
+			PatientId:              patient_id,
372
+			OtherVascular:          other_vascular,
373
+			CiType:                 ci_type,
374
+			BloodCultupe:           blood_cultupe,
375
+			SequelaeType:           sequelae_type,
376
+		}
377
+		err := service.SaveVascularAccess(&access)
378
+		if err == nil {
379
+			this.ServeSuccessJSON(map[string]interface{}{
380
+				"access": access,
381
+			})
382
+			return
383
+		}
384
+	} else if errcode == nil {
385
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
386
+		return
387
+	}
388
+
389
+}
390
+
391
+func (this *DoctorsApiController) GetAllVacualAccessList() {
392
+
393
+	limit, _ := this.GetInt64("limit")
394
+	page, _ := this.GetInt64("page")
395
+	patient_id, _ := this.GetInt64("patient_id")
396
+	orgId := this.GetAdminUserInfo().CurrentOrgId
397
+	appId := this.GetAdminUserInfo().CurrentAppId
398
+	list, total, err := service.GetAllVacualAccessList(orgId, limit, page, patient_id)
399
+	doctor, err := service.GetAllDoctor(orgId, appId)
400
+	if err == nil {
401
+		this.ServeSuccessJSON(map[string]interface{}{
402
+			"list":   list,
403
+			"total":  total,
404
+			"doctor": doctor,
405
+		})
406
+		return
407
+	}
408
+}
409
+
410
+func (this *DoctorsApiController) GetVascularAccessByDetail() {
411
+
412
+	id, _ := this.GetInt64("id")
413
+
414
+	accessDetail, err := service.GetVasularAccessByDetail(id)
415
+	orgId := this.GetAdminUserInfo().CurrentOrgId
416
+	appId := this.GetAdminUserInfo().CurrentAppId
417
+	doctor, err := service.GetAllDoctor(orgId, appId)
418
+	if err == nil {
419
+		this.ServeSuccessJSON(map[string]interface{}{
420
+			"accessDetail": accessDetail,
421
+			"doctor":       doctor,
422
+		})
423
+		return
424
+	}
425
+}
426
+
427
+func (this *DoctorsApiController) UpdateVasularAccess() {
428
+	id, _ := this.GetInt64("id")
429
+	access_project, _ := this.GetInt64("access_project")
430
+	blood_access_part_id := this.GetString("blood_access_part_id")
431
+	blood_access_part_opera_id := this.GetString("blood_access_part_opera_id")
432
+	first_start_time := this.GetString("first_start_time")
433
+	timeLayout := "2006-01-02"
434
+	loc, _ := time.LoadLocation("Local")
435
+	firstStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", first_start_time+" 00:00:00", loc)
436
+	inflow_pass := this.GetString("inflow_pass")
437
+	remark := this.GetString("remark")
438
+	start_time := this.GetString("start_time")
439
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
440
+	stop_reason := this.GetString("stop_reason")
441
+	user_status, _ := this.GetInt64("user_status")
442
+	stop_time := this.GetString("stop_time")
443
+	stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
444
+	adminUserInfo := this.GetAdminUserInfo()
445
+	orgId := adminUserInfo.CurrentOrgId
446
+	creator := adminUserInfo.AdminUser.Id
447
+	patientId, _ := this.GetInt64("patient_id")
448
+	other_vascular := this.GetString("other_vascular")
449
+	ci_type, _ := this.GetInt64("ci_type")
450
+	blood_cultupe, _ := this.GetInt64("blood_cultupe")
451
+	sequelae_type, _ := this.GetInt64("sequelae_type")
335 452
 	access := models.XtPatientVascularAccess{
336 453
 		AccessProject:          access_project,
337 454
 		BloodAccessPartId:      blood_access_part_id,
@@ -342,26 +459,86 @@ func (this *DoctorsApiController) SaveVasularAccess() {
342 459
 		StartTime:              startTime.Unix(),
343 460
 		StopReason:             stop_reason,
344 461
 		UserStatus:             user_status,
345
-		Creator:                creator,
462
+		Modify:                 creator,
346 463
 		UserOrgId:              orgId,
347 464
 		Status:                 1,
348
-		Ctime:                  time.Now().Unix(),
465
+		StopTime:               stopTime.Unix(),
466
+		OtherVascular:          other_vascular,
467
+		CiType:                 ci_type,
468
+		BloodCultupe:           blood_cultupe,
469
+		SequelaeType:           sequelae_type,
470
+	}
471
+	_, errcode := service.GetDialysisDateByDateOne(startTime.Unix(), patientId, orgId, id)
472
+	if errcode == gorm.ErrRecordNotFound {
473
+		err := service.UpdateVascularAccess(&access, id)
474
+		if err == nil {
475
+			this.ServeSuccessJSON(map[string]interface{}{
476
+				"access": access,
477
+			})
478
+			return
479
+		}
480
+	} else if errcode == nil {
481
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
482
+		return
483
+	}
484
+
485
+}
486
+
487
+func (this *DoctorsApiController) DeleteVasularAccess() {
488
+	id, _ := this.GetInt64("id")
489
+	err := service.DeleteVasularAccess(id)
490
+	fmt.Println(err)
491
+	returnData := make(map[string]interface{}, 0)
492
+	returnData["msg"] = "ok"
493
+	this.ServeSuccessJSON(returnData)
494
+	return
495
+}
496
+
497
+func (this *DoctorsApiController) SavePassWayAssessment() {
498
+
499
+	blood_dealwidth := this.GetString("blood_dealwith")
500
+	blood_project := this.GetString("blood_project")
501
+	blood_result := this.GetString("blood_result")
502
+	creator, _ := this.GetInt64("creator")
503
+	parent_id, _ := this.GetInt64("parent_id")
504
+	patient_id, _ := this.GetInt64("patient_id")
505
+	start_time := this.GetString("start_time")
506
+	timeLayout := "2006-01-02"
507
+	loc, _ := time.LoadLocation("Local")
508
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
509
+	modify := this.GetAdminUserInfo().AdminUser.Id
510
+	orgId := this.GetAdminUserInfo().CurrentOrgId
511
+	assessment := models.XtPatientPasswayAssessment{
512
+		StartTime:     startTime.Unix(),
513
+		BloodDealwith: blood_dealwidth,
514
+		BloodProject:  blood_project,
515
+		BloodResult:   blood_result,
516
+		Creator:       creator,
517
+		PatientId:     patient_id,
518
+		ParentId:      parent_id,
519
+		Modify:        modify,
520
+		UserOrgId:     orgId,
521
+		Status:        1,
522
+		Ctime:         time.Now().Unix(),
349 523
 	}
350
-	err := service.SaveVascularAccess(&access)
524
+
525
+	err := service.CreatePatientWayAssessment(&assessment)
351 526
 	if err == nil {
352 527
 		this.ServeSuccessJSON(map[string]interface{}{
353
-			"access": access,
528
+			"assessment": assessment,
354 529
 		})
355 530
 		return
356 531
 	}
357 532
 }
358 533
 
359
-func (this *DoctorsApiController) GetAllVacualAccessList() {
534
+func (this *DoctorsApiController) GetAllPassWayAssessment() {
360 535
 
361
-	limit, _ := this.GetInt64("limit")
536
+	patient_id, _ := this.GetInt64("patient_id")
537
+	parent_id, _ := this.GetInt64("parent_id")
362 538
 	page, _ := this.GetInt64("page")
363
-	orgId := this.GetAdminUserInfo().CurrentOrgId
364
-	list, total, err := service.GetAllVacualAccessList(orgId, limit, page)
539
+	limit, _ := this.GetInt64("limit")
540
+	adminUserInfo := this.GetAdminUserInfo()
541
+	list, total, err := service.GetAllPassWayAssessment(parent_id, patient_id, page, limit, adminUserInfo.CurrentOrgId)
365 542
 	if err == nil {
366 543
 		this.ServeSuccessJSON(map[string]interface{}{
367 544
 			"list":  list,
@@ -370,3 +547,74 @@ func (this *DoctorsApiController) GetAllVacualAccessList() {
370 547
 		return
371 548
 	}
372 549
 }
550
+
551
+func (this *DoctorsApiController) GetPasswayAssesmentById() {
552
+
553
+	id, _ := this.GetInt64("id")
554
+	assessment, err := service.GetPasswayAssesmentById(id)
555
+	if err == nil {
556
+		this.ServeSuccessJSON(map[string]interface{}{
557
+			"assessment": assessment,
558
+		})
559
+		return
560
+	}
561
+}
562
+
563
+func (this *DoctorsApiController) UpdatePassWayAssesment() {
564
+	id, _ := this.GetInt64("id")
565
+	blood_dealwidth := this.GetString("blood_dealwith")
566
+	blood_project := this.GetString("blood_project")
567
+	blood_result := this.GetString("blood_result")
568
+	creator, _ := this.GetInt64("creator")
569
+	start_time := this.GetString("start_time")
570
+	timeLayout := "2006-01-02"
571
+	loc, _ := time.LoadLocation("Local")
572
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
573
+	modify := this.GetAdminUserInfo().AdminUser.Id
574
+	assessment := models.XtPatientPasswayAssessment{
575
+		BloodResult:   blood_result,
576
+		BloodDealwith: blood_dealwidth,
577
+		BloodProject:  blood_project,
578
+		Creator:       creator,
579
+		StartTime:     startTime.Unix(),
580
+		Modify:        modify,
581
+	}
582
+	err := service.UpdatePassWayAssesment(&assessment, id)
583
+	if err == nil {
584
+		this.ServeSuccessJSON(map[string]interface{}{
585
+			"assessment": assessment,
586
+		})
587
+		return
588
+	}
589
+}
590
+
591
+func (this *DoctorsApiController) DeleteWayAssessment() {
592
+
593
+	id, _ := this.GetInt64("id")
594
+	err := service.DeleteWayAssessment(id)
595
+	fmt.Println(err)
596
+	returnData := make(map[string]interface{}, 0)
597
+	returnData["msg"] = "ok"
598
+	this.ServeSuccessJSON(returnData)
599
+	return
600
+}
601
+
602
+func (this *DoctorsApiController) GetAccessList() {
603
+
604
+	adminUserInfo := this.GetAdminUserInfo()
605
+	orgId := adminUserInfo.CurrentOrgId
606
+	//血管通路
607
+	list, err := service.GetAccessList(orgId)
608
+	blood_access_part_opera, err := service.GetParentAccessList(orgId, list.ID)
609
+
610
+	//血管通路部位
611
+	access, err := service.GetBloodAccess(orgId)
612
+	blood_access_part, err := service.GetParentAccessList(orgId, access.ID)
613
+	if err == nil {
614
+		this.ServeSuccessJSON(map[string]interface{}{
615
+			"blood_access_part_opera": blood_access_part_opera,
616
+			"blood_access_part":       blood_access_part,
617
+		})
618
+		return
619
+	}
620
+}

+ 14 - 0
controllers/gobal_config_api_controller.go View File

@@ -757,8 +757,11 @@ func (c *GobalConfigApiController) UpdateSystemPrescription() {
757 757
 func (c *GobalConfigApiController) GetAllSystemPrescription() {
758 758
 	adminUserInfo := c.GetAdminUserInfo()
759 759
 	prescriptions, _ := service.FindAllSystemPrescription(adminUserInfo.CurrentOrgId)
760
+
761
+	stockType, _ := service.GetStockType(adminUserInfo.CurrentOrgId)
760 762
 	c.ServeSuccessJSON(map[string]interface{}{
761 763
 		"prescriptions": prescriptions,
764
+		"stockType":     stockType,
762 765
 	})
763 766
 }
764 767
 
@@ -990,6 +993,17 @@ func defaultSystemSolutionFormData(solution *models.SystemPrescription, data []b
990 993
 		solution.Remark = remark
991 994
 	}
992 995
 
996
+	if dataBody["dialysis_dialyszers"] != nil && reflect.TypeOf(dataBody["dialysis_dialyszers"]).String() == "string" {
997
+		dialysisDialyszers := dataBody["dialysis_dialyszers"].(string)
998
+		fmt.Println("dialysisDialysis22222222222", dialysisDialyszers)
999
+		solution.DialysisDialyszers = dialysisDialyszers
1000
+	}
1001
+
1002
+	if dataBody["dialysis_irrigation"] != nil && reflect.TypeOf(dataBody["dialysis_irrigation"]).String() == "string" {
1003
+		dialysisIrrigation := dataBody["dialysis_irrigation"].(string)
1004
+		solution.DialysisIrrigation = dialysisIrrigation
1005
+	}
1006
+
993 1007
 	return
994 1008
 }
995 1009
 

+ 7 - 1
controllers/his_project_api_controller.go View File

@@ -309,7 +309,7 @@ func (this *HisProjectApiController) SaveProjectTeam() {
309 309
 	team_type, _ := this.GetInt64("team_type")
310 310
 	remark := this.GetString("remark")
311 311
 	ids := this.GetString("ids")
312
-
312
+	item_id := this.GetString("item_id")
313 313
 	adminUserInfo := this.GetAdminUserInfo()
314 314
 	orgId := adminUserInfo.CurrentOrgId
315 315
 	projectTeam := models.XtHisProjectTeam{
@@ -324,6 +324,7 @@ func (this *HisProjectApiController) SaveProjectTeam() {
324 324
 		Status:      1,
325 325
 		CreatedTime: time.Now().Unix(),
326 326
 		ProjectId:   ids,
327
+		ItemId:      item_id,
327 328
 	}
328 329
 	//fmt.Println(projectTeam)
329 330
 
@@ -397,6 +398,7 @@ func (this *HisProjectApiController) UpdatedProjectTeam() {
397 398
 	team_type, _ := this.GetInt64("team_type")
398 399
 	remark := this.GetString("remark")
399 400
 	ids := this.GetString("ids")
401
+	item_id := this.GetString("item_id")
400 402
 	projectTeam := models.XtHisProjectTeam{
401 403
 		ProjectTeam: project_team,
402 404
 		Price:       price_float,
@@ -406,6 +408,7 @@ func (this *HisProjectApiController) UpdatedProjectTeam() {
406 408
 		TeamType:    team_type,
407 409
 		Remark:      remark,
408 410
 		ProjectId:   ids,
411
+		ItemId:      item_id,
409 412
 	}
410 413
 
411 414
 	err := service.UpdatedProjectTeam(id, &projectTeam)
@@ -620,12 +623,15 @@ func (this *HisProjectApiController) AddProjectList() {
620 623
 	}
621 624
 	err := service.CreateProjectList(&projectList)
622 625
 	detail, _ := service.GetProjectDetail(id)
626
+
627
+	item, err := service.GetLastItem(orgId)
623 628
 	if err != nil {
624 629
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
625 630
 		return
626 631
 	}
627 632
 	this.ServeSuccessJSON(map[string]interface{}{
628 633
 		"projectList": detail,
634
+		"item":        item,
629 635
 	})
630 636
 	return
631 637
 }

+ 2 - 0
controllers/inspection_api_controller.go View File

@@ -92,9 +92,11 @@ func (c *InspectionApiController) PatientInspectionReference() {
92 92
 		}
93 93
 	}
94 94
 
95
+	list, err := service.GetInspectionReferenceByOrgId(0)
95 96
 	c.ServeSuccessJSON(map[string]interface{}{
96 97
 		"reference":    reference,
97 98
 		"patient_info": patient_info,
99
+		"list":         list,
98 100
 	})
99 101
 	return
100 102
 

File diff suppressed because it is too large
+ 1207 - 207
controllers/manage_api_controller.go


+ 9 - 1
controllers/manager_center_api_controller.go View File

@@ -126,7 +126,7 @@ func (c *ManagerCenterApiController) CreateBaseDrugLib() {
126 126
 	is_charge_predict, _ := c.GetInt64("is_charge_predict")
127 127
 	is_statistics_work, _ := c.GetInt64("is_statistics_work")
128 128
 	is_charge_use, _ := c.GetInt64("is_charge_use")
129
-
129
+	dealer, _ := c.GetInt64("dealer")
130 130
 	adminInfo := c.GetAdminUserInfo()
131 131
 
132 132
 	drugLib := &models.BaseDrugLib{
@@ -178,6 +178,7 @@ func (c *ManagerCenterApiController) CreateBaseDrugLib() {
178 178
 		Status:                 1,
179 179
 		Ctime:                  time.Now().Unix(),
180 180
 		Mtime:                  time.Now().Unix(),
181
+		Dealer:                 dealer,
181 182
 	}
182 183
 
183 184
 	total := service.FindAllDrugLibRecordTotal(adminInfo.CurrentOrgId)
@@ -254,6 +255,7 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
254 255
 	is_charge_use, _ := c.GetInt64("is_charge_use")
255 256
 	drug_code := c.GetString("drug_code")
256 257
 	//unit := c.GetString("unit")
258
+	dealer, _ := c.GetInt64("dealer")
257 259
 	adminInfo := c.GetAdminUserInfo()
258 260
 	drug, _ := service.FindBaseDrugLibRecord(adminInfo.CurrentOrgId, id)
259 261
 
@@ -308,6 +310,7 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
308 310
 		Ctime:                  drug.Ctime,
309 311
 		Mtime:                  time.Now().Unix(),
310 312
 		DrugCode:               drug_code,
313
+		Dealer:                 dealer,
311 314
 	}
312 315
 
313 316
 	err := service.UpdateBaseDrugLib(drugLib)
@@ -1546,6 +1549,11 @@ func (c *ManagerCenterApiController) ModifyGoodInfo() {
1546 1549
 		RetailPrice:            retail_price,
1547 1550
 	}
1548 1551
 
1552
+	totals := service.FindGoodInfoByNameOne(specification_name, adminUserInfo.CurrentOrgId, good_id, id)
1553
+	if totals > 0 {
1554
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodInfoNameExistError)
1555
+		return
1556
+	}
1549 1557
 	err, goodInfos := service.ModifyGoodInfo(&goodInfo)
1550 1558
 	if err == nil {
1551 1559
 		c.ServeSuccessJSON(map[string]interface{}{

+ 290 - 80
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -91,6 +91,7 @@ func (this *DialysisAPIController) Scheduals() {
91 91
 
92 92
 	if len(scheduals_json_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
93 93
 		scheduals, err := service.MobileGetDialysisScheduals(orgID, date.Unix(), schedualType)
94
+
94 95
 		if err != nil {
95 96
 			this.ErrorLog("获取排班信息失败:%v", err)
96 97
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -117,6 +118,7 @@ func (this *DialysisAPIController) Scheduals() {
117 118
 		} else {
118 119
 
119 120
 		}
121
+
120 122
 		this.ServeSuccessJSON(map[string]interface{}{
121 123
 			"scheduals": dat,
122 124
 			"redis":     "true",
@@ -337,6 +339,7 @@ func (this *DialysisAPIController) DialysisRecord() {
337 339
 	}
338 340
 
339 341
 	dialysisPrescribe, _ := service.MobileGetDialysisPrescribeByModeId(adminInfo.Org.Id, patientID, date.Unix(), schedual.ModeId)
342
+
340 343
 	//if getDialysisPrescribeErr != nil {
341 344
 	//	this.ErrorLog("获取透析处方失败:%v", getDialysisPrescribeErr)
342 345
 	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -375,6 +378,11 @@ func (this *DialysisAPIController) DialysisRecord() {
375 378
 	stockType, _ := service.GetStockType(adminInfo.Org.Id)
376 379
 
377 380
 	prepare, _ := service.GetDialyStockOut(adminInfo.Org.Id, date.Unix(), patientID)
381
+
382
+	//获取最后一次血管通路
383
+	lastAssessment, parseDateErr := service.GetLastPassWayAssessment(adminInfo.Org.Id, patientID)
384
+
385
+	prescribeOne, parseDateErr := service.MobileGetDialysisPrescribeByModeIdOne(adminInfo.Org.Id, patientID, date.Unix())
378 386
 	var his_advices []*models.HisDoctorAdviceInfo
379 387
 	if is_open_config.IsOpen == 1 {
380 388
 		his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.Org.Id, patientID, date.Unix())
@@ -429,6 +437,8 @@ func (this *DialysisAPIController) DialysisRecord() {
429 437
 		"is_open_config":                 is_open_config,
430 438
 		"stockType":                      stockType,
431 439
 		"prepare":                        prepare,
440
+		"lastAssessment":                 lastAssessment,
441
+		"prescribeOne":                   prescribeOne,
432 442
 	}
433 443
 	this.ServeSuccessJSON(returnData)
434 444
 }
@@ -1155,6 +1165,71 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1155 1165
 		DisplaceSpeed:            displace_speed,
1156 1166
 	}
1157 1167
 
1168
+	//查询最近透析准备表里是否存在 透析器 灌流器
1169
+
1170
+	//
1171
+	//splitStr := strings.Split(dialysis_dialyszers, ",")
1172
+	//
1173
+	//splitIrrigation := strings.Split(dialysis_irrigation, ",")
1174
+	//
1175
+	//mation, _ := service.GetGoodInfoMation(adminUserInfo.Org.Id)
1176
+	//if len(mation)>0{
1177
+	//  for _, item := range splitStr {
1178
+	//    for _,it := range mation{
1179
+	//      if(item == it.SpecificationName){
1180
+	//
1181
+	//        //查询最近一次的透析器
1182
+	//        _, errcode := service.GetDialysisBeforePrepare(it.GoodTypeId, it.ID, adminUserInfo.Org.Id,id)
1183
+	//
1184
+	//        if errcode == gorm.ErrRecordNotFound{
1185
+	//          //插入数据
1186
+	//          prepare := models.DialysisBeforePrepare{
1187
+	//            UserOrgId:  adminUserInfo.Org.Id,
1188
+	//            PatientId:  id,
1189
+	//            RecordDate: recordDate.Unix(),
1190
+	//            GoodTypeId: it.GoodTypeId,
1191
+	//            GoodId:     it.ID,
1192
+	//            Count:      1,
1193
+	//            Ctime:      time.Now().Unix(),
1194
+	//            Creater:    adminUserInfo.AdminUser.Id,
1195
+	//            Status:1,
1196
+	//
1197
+	//          }
1198
+	//          errcode := service.CreateDialysisBeforePrepareOne(&prepare)
1199
+	//          fmt.Println("",errcode)
1200
+	//        }
1201
+	//      }
1202
+	//    }
1203
+	//
1204
+	//  }
1205
+	//
1206
+	//  for _, item := range splitIrrigation {
1207
+	//    for _,it := range mation{
1208
+	//      if(item == it.SpecificationName){
1209
+	//        //查询最近一次的透析器
1210
+	//        _, errcode := service.GetDialysisBeforePrepare(it.GoodTypeId, it.ID, adminUserInfo.Org.Id,id)
1211
+	//        if errcode == gorm.ErrRecordNotFound{
1212
+	//          //插入数据
1213
+	//          prepare := models.DialysisBeforePrepare{
1214
+	//            UserOrgId:  adminUserInfo.Org.Id,
1215
+	//            PatientId:  id,
1216
+	//            RecordDate: recordDate.Unix(),
1217
+	//            GoodTypeId: it.GoodTypeId,
1218
+	//            GoodId:     it.ID,
1219
+	//            Count:      1,
1220
+	//            Ctime:      time.Now().Unix(),
1221
+	//            Creater:    adminUserInfo.AdminUser.Id,
1222
+	//            Status:1,
1223
+	//
1224
+	//          }
1225
+	//          errcode := service.CreateDialysisBeforePrepareOne(&prepare)
1226
+	//          fmt.Println(errcode)
1227
+	//        }
1228
+	//      }
1229
+	//    }
1230
+	//  }
1231
+	//}
1232
+
1158 1233
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1159 1234
 	if dialysisPrescription.ID == 0 { //新增
1160 1235
 		//if mode_id > 0 {
@@ -1514,6 +1589,7 @@ func (c *DialysisAPIController) GetSchedualPatientsList() {
1514 1589
 // @param nurse:int 上机护士
1515 1590
 // @param bed:int 床位号
1516 1591
 func (this *DialysisAPIController) StartDialysis() {
1592
+
1517 1593
 	patientID, _ := this.GetInt64("patient_id")
1518 1594
 	recordDateStr := this.GetString("record_date")
1519 1595
 	nurseID, _ := this.GetInt64("nurse")
@@ -1569,15 +1645,15 @@ func (this *DialysisAPIController) StartDialysis() {
1569 1645
 	}
1570 1646
 
1571 1647
 	nurse, getNurseErr = service.GetAdminUserByUserID(puncture_nurse)
1572
-	if getNurseErr != nil {
1573
-		this.ErrorLog("获取护士失败:%v", getNurseErr)
1574
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1575
-		return
1576
-	} else if nurse == nil {
1577
-		this.ErrorLog("护士不存在")
1578
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1579
-		return
1580
-	}
1648
+	//if getNurseErr != nil {
1649
+	//	this.ErrorLog("获取护士失败:%v", getNurseErr)
1650
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1651
+	//	return
1652
+	//} else if nurse == nil {
1653
+	//	this.ErrorLog("护士不存在")
1654
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1655
+	//	return
1656
+	//}
1581 1657
 
1582 1658
 	deviceNumber, getDeviceNumberErr := service.GetDeviceNumberByID(adminUserInfo.Org.Id, bedID)
1583 1659
 	if getDeviceNumberErr != nil {
@@ -2055,8 +2131,75 @@ func (c *DialysisAPIController) PostSolution() {
2055 2131
 		BodyFluidOther:             body_fluid_other,
2056 2132
 		ReplacementTotal:           replacement_total,
2057 2133
 		TargetKtv:                  target_ktv,
2134
+		DialysisDialyszers:         dialysis_dialyszers,
2135
+		DialysisIrrigation:         dialysis_irrigation,
2058 2136
 	}
2059 2137
 	service.SavePrescriptionAndCreateSolution(&solution, &prescription)
2138
+
2139
+	//查询最近透析准备表里是否存在 透析器 灌流器
2140
+
2141
+	//splitStr := strings.Split(dialysis_dialyszers, ",")
2142
+	//
2143
+	//splitIrrigation := strings.Split(dialysis_irrigation, ",")
2144
+	//
2145
+	//mation, _ := service.GetGoodInfoMation(adminUserInfo.Org.Id)
2146
+	//if len(mation)>0{
2147
+	//  for _, item := range splitStr {
2148
+	//    for _,it := range mation{
2149
+	//      if(item == it.SpecificationName){
2150
+	//
2151
+	//        //查询最近一次的透析器
2152
+	//        _, errcode := service.GetDialysisBeforePrepare(it.GoodTypeId, it.ID, adminUserInfo.Org.Id,id)
2153
+	//
2154
+	//        if errcode == gorm.ErrRecordNotFound{
2155
+	//          //插入数据
2156
+	//          prepare := models.DialysisBeforePrepare{
2157
+	//            UserOrgId:  adminUserInfo.Org.Id,
2158
+	//            PatientId:  id,
2159
+	//            RecordDate: recordDate.Unix(),
2160
+	//            GoodTypeId: it.GoodTypeId,
2161
+	//            GoodId:     it.ID,
2162
+	//            Count:      1,
2163
+	//            Ctime:      time.Now().Unix(),
2164
+	//            Creater:    adminUserInfo.AdminUser.Id,
2165
+	//            Status:1,
2166
+	//
2167
+	//          }
2168
+	//          errcode := service.CreateDialysisBeforePrepareOne(&prepare)
2169
+	//          fmt.Println("",errcode)
2170
+	//        }
2171
+	//      }
2172
+	//    }
2173
+	//
2174
+	//  }
2175
+	//
2176
+	//  for _, item := range splitIrrigation {
2177
+	//    for _,it := range mation{
2178
+	//      if(item == it.SpecificationName){
2179
+	//        //查询最近一次的透析器
2180
+	//        _, errcode := service.GetDialysisBeforePrepare(it.GoodTypeId, it.ID, adminUserInfo.Org.Id,id)
2181
+	//        if errcode == gorm.ErrRecordNotFound{
2182
+	//          //插入数据
2183
+	//          prepare := models.DialysisBeforePrepare{
2184
+	//            UserOrgId:  adminUserInfo.Org.Id,
2185
+	//            PatientId:  id,
2186
+	//            RecordDate: recordDate.Unix(),
2187
+	//            GoodTypeId: it.GoodTypeId,
2188
+	//            GoodId:     it.ID,
2189
+	//            Count:      1,
2190
+	//            Ctime:      time.Now().Unix(),
2191
+	//            Creater:    adminUserInfo.AdminUser.Id,
2192
+	//            Status:1,
2193
+	//
2194
+	//          }
2195
+	//          errcode := service.CreateDialysisBeforePrepareOne(&prepare)
2196
+	//          fmt.Println(errcode)
2197
+	//        }
2198
+	//      }
2199
+	//    }
2200
+	//  }
2201
+	//}
2202
+
2060 2203
 	c.ServeSuccessJSON(map[string]interface{}{
2061 2204
 		"solution":     &solution,
2062 2205
 		"prescription": &prescription,
@@ -2221,15 +2364,15 @@ func (this *DialysisAPIController) ModifyStartDialysisOrder() {
2221 2364
 	}
2222 2365
 
2223 2366
 	nurse, getNurseErr = service.GetAdminUserByUserID(puncture_nurse)
2224
-	if getNurseErr != nil {
2225
-		this.ErrorLog("获取护士失败:%v", getNurseErr)
2226
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2227
-		return
2228
-	} else if nurse == nil {
2229
-		this.ErrorLog("护士不存在")
2230
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2231
-		return
2232
-	}
2367
+	//if getNurseErr != nil {
2368
+	//	this.ErrorLog("获取护士失败:%v", getNurseErr)
2369
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2370
+	//	return
2371
+	//} else if nurse == nil {
2372
+	//	this.ErrorLog("护士不存在")
2373
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2374
+	//	return
2375
+	//}
2233 2376
 
2234 2377
 	deviceNumber, getDeviceNumberErr := service.GetDeviceNumberByID(adminUserInfo.Org.Id, bedID)
2235 2378
 	if getDeviceNumberErr != nil {
@@ -3031,6 +3174,7 @@ func (c *DialysisAPIController) CreateConsumables() {
3031 3174
 
3032 3175
 	if dataBody["goods"] != nil && reflect.TypeOf(dataBody["goods"]).String() == "[]interface {}" {
3033 3176
 		goods, _ := dataBody["goods"].([]interface{})
3177
+
3034 3178
 		if len(goods) > 0 {
3035 3179
 			for _, item := range goods {
3036 3180
 				items := item.(map[string]interface{})
@@ -3056,23 +3200,25 @@ func (c *DialysisAPIController) CreateConsumables() {
3056 3200
 				}
3057 3201
 
3058 3202
 				count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
3059
-				//commdity_code := items["commdity_code"].(string)
3060
-				//fmt.Println("新建22222222222222",commdity_code)
3203
+				commdity_code := items["commdity_code"].(string)
3204
+
3061 3205
 				adminUser := c.GetMobileAdminUserInfo()
3062 3206
 				prepare := &models.DialysisBeforePrepare{
3063
-					UserOrgId:  adminUser.Org.Id,
3064
-					PatientId:  patient_id,
3065
-					RecordDate: record_time,
3066
-					GoodId:     good_id,
3067
-					GoodTypeId: good_type_id,
3068
-					Count:      count,
3069
-					Ctime:      time.Now().Unix(),
3070
-					Mtime:      time.Now().Unix(),
3071
-					Creater:    adminUser.AdminUser.Id,
3072
-					Modifier:   0,
3073
-					//CommdityCode:commdity_code,
3207
+					UserOrgId:    adminUser.Org.Id,
3208
+					PatientId:    patient_id,
3209
+					RecordDate:   record_time,
3210
+					GoodId:       good_id,
3211
+					GoodTypeId:   good_type_id,
3212
+					Count:        count,
3213
+					Ctime:        time.Now().Unix(),
3214
+					Mtime:        time.Now().Unix(),
3215
+					Creater:      adminUser.AdminUser.Id,
3216
+					Modifier:     0,
3217
+					CommdityCode: commdity_code,
3074 3218
 				}
3219
+				//问题点
3075 3220
 				record_count := service.FindDialysisBeforePrepare(prepare.PatientId, prepare.GoodId, prepare.GoodTypeId, adminUser.Org.Id, record_time)
3221
+
3076 3222
 				if record_count == 0 {
3077 3223
 					beforePrepares = append(beforePrepares, prepare)
3078 3224
 				}
@@ -3149,22 +3295,22 @@ func (c *DialysisAPIController) CreateConsumables() {
3149 3295
 				}
3150 3296
 				ctime := int64(items["ctime"].(float64))
3151 3297
 
3152
-				//commdity_code := items["commdity_code"].(string)
3153
-				//fmt.Println("commdityecode22222222222222222222",commdity_code)
3298
+				commdity_code := items["commdity_code"].(string)
3299
+
3154 3300
 				prepare := &models.DialysisBeforePrepare{
3155
-					ID:         id,
3156
-					UserOrgId:  adminUser.Org.Id,
3157
-					PatientId:  patient_id,
3158
-					RecordDate: record_time,
3159
-					GoodId:     good_id,
3160
-					GoodTypeId: good_type_id,
3161
-					Count:      count,
3162
-					Ctime:      ctime,
3163
-					Mtime:      time.Now().Unix(),
3164
-					Creater:    creater,
3165
-					Modifier:   adminUser.AdminUser.Id,
3166
-					Status:     1,
3167
-					//CommdityCode: commdity_code,
3301
+					ID:           id,
3302
+					UserOrgId:    adminUser.Org.Id,
3303
+					PatientId:    patient_id,
3304
+					RecordDate:   record_time,
3305
+					GoodId:       good_id,
3306
+					GoodTypeId:   good_type_id,
3307
+					Count:        count,
3308
+					Ctime:        ctime,
3309
+					Mtime:        time.Now().Unix(),
3310
+					Creater:      creater,
3311
+					Modifier:     adminUser.AdminUser.Id,
3312
+					Status:       1,
3313
+					CommdityCode: commdity_code,
3168 3314
 				}
3169 3315
 				updateBeforePrepares = append(updateBeforePrepares, prepare)
3170 3316
 
@@ -3394,6 +3540,7 @@ func (c *DialysisAPIController) EditConsumables() {
3394 3540
 
3395 3541
 	var newBeforePrepares []*models.DialysisBeforePrepare
3396 3542
 
3543
+	//判断是否开启自动出库
3397 3544
 	_, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
3398 3545
 
3399 3546
 	if record.IsOpen == 1 {
@@ -3461,23 +3608,23 @@ func (c *DialysisAPIController) EditConsumables() {
3461 3608
 						return
3462 3609
 					}
3463 3610
 					ctime := int64(items["ctime"].(float64))
3464
-					//commdity_code := items["commdity_code"].(string)
3465
-					//fmt.Println("commdityecode22222222222222222222",commdity_code)
3611
+					commdity_code := items["commdity_code"].(string)
3612
+
3466 3613
 					adminUser := c.GetMobileAdminUserInfo()
3467 3614
 					prepare := &models.DialysisBeforePrepare{
3468
-						ID:         id,
3469
-						UserOrgId:  adminUser.Org.Id,
3470
-						PatientId:  patient_id,
3471
-						RecordDate: record_time,
3472
-						GoodId:     good_id,
3473
-						GoodTypeId: good_type_id,
3474
-						Count:      count,
3475
-						Ctime:      ctime,
3476
-						Mtime:      time.Now().Unix(),
3477
-						Creater:    creater,
3478
-						Modifier:   adminUser.AdminUser.Id,
3479
-						Status:     1,
3480
-						//CommdityCode: commdity_code,
3615
+						ID:           id,
3616
+						UserOrgId:    adminUser.Org.Id,
3617
+						PatientId:    patient_id,
3618
+						RecordDate:   record_time,
3619
+						GoodId:       good_id,
3620
+						GoodTypeId:   good_type_id,
3621
+						Count:        count,
3622
+						Ctime:        ctime,
3623
+						Mtime:        time.Now().Unix(),
3624
+						Creater:      creater,
3625
+						Modifier:     adminUser.AdminUser.Id,
3626
+						Status:       1,
3627
+						CommdityCode: commdity_code,
3481 3628
 					}
3482 3629
 					beforePrepares = append(beforePrepares, prepare)
3483 3630
 
@@ -3485,6 +3632,7 @@ func (c *DialysisAPIController) EditConsumables() {
3485 3632
 			}
3486 3633
 		}
3487 3634
 
3635
+		//查询今日患者出库列表
3488 3636
 		consumables_source, _ := service.FindConsumablesByDate(adminInfo.Org.Id, patient_id, record_time)
3489 3637
 
3490 3638
 		if dataBody["new_goods"] != nil && reflect.TypeOf(dataBody["new_goods"]).String() == "[]interface {}" {
@@ -3514,30 +3662,34 @@ func (c *DialysisAPIController) EditConsumables() {
3514 3662
 					}
3515 3663
 
3516 3664
 					count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
3517
-					//commdity_code := items["commdity_code"].(string)
3518
-					//fmt.Println("commdityecode22222222222222222222",commdity_code)
3665
+
3666
+					commdity_code := items["commdity_code"].(string)
3667
+					fmt.Println("commdityecode", commdity_code)
3519 3668
 					adminUser := c.GetMobileAdminUserInfo()
3520 3669
 					prepare := &models.DialysisBeforePrepare{
3521
-						UserOrgId:  adminUser.Org.Id,
3522
-						PatientId:  patient_id,
3523
-						RecordDate: record_time,
3524
-						GoodId:     good_id,
3525
-						GoodTypeId: good_type_id,
3526
-						Count:      count,
3527
-						Ctime:      time.Now().Unix(),
3528
-						Mtime:      time.Now().Unix(),
3529
-						Creater:    adminUser.AdminUser.Id,
3530
-						Modifier:   0,
3531
-						//CommdityCode:commdity_code,
3670
+						UserOrgId:    adminUser.Org.Id,
3671
+						PatientId:    patient_id,
3672
+						RecordDate:   record_time,
3673
+						GoodId:       good_id,
3674
+						GoodTypeId:   good_type_id,
3675
+						Count:        count,
3676
+						Ctime:        time.Now().Unix(),
3677
+						Mtime:        time.Now().Unix(),
3678
+						Creater:      adminUser.AdminUser.Id,
3679
+						Modifier:     0,
3680
+						CommdityCode: commdity_code,
3532 3681
 					}
3533 3682
 					newBeforePrepares = append(newBeforePrepares, prepare)
3534 3683
 
3535 3684
 				}
3536 3685
 				newBeforePrepares = RemoveRepeatedGood(newBeforePrepares)
3537 3686
 			}
3687
+
3688
+			//创建数据
3538 3689
 			service.CreateDialysisBeforePrepare(newBeforePrepares)
3539 3690
 		}
3540 3691
 
3692
+		//查询是否有出库单
3541 3693
 		out, err := service.FindStockOutByIsSys(adminInfo.Org.Id, 1, record_time)
3542 3694
 		if err == gorm.ErrRecordNotFound {
3543 3695
 			//没有记录,则创建出库单
@@ -3563,7 +3715,9 @@ func (c *DialysisAPIController) EditConsumables() {
3563 3715
 				Type:                    1,
3564 3716
 				IsSys:                   1,
3565 3717
 			}
3718
+			//创建出库单
3566 3719
 			err := service.AddSigleWarehouseOut(&warehouseOut)
3720
+			fmt.Println("err", err)
3567 3721
 			if err != nil {
3568 3722
 				utils.TraceLog("创建出库单失败 err = %v", err)
3569 3723
 			} else {
@@ -3588,6 +3742,7 @@ func (c *DialysisAPIController) EditConsumables() {
3588 3742
 						}
3589 3743
 						stockInInfo, _ := service.FindLastStockInInfoRecord(item.GoodId, adminInfo.Org.Id)
3590 3744
 						warehouseOutInfo.Price = stockInInfo.Price
3745
+						//创建出库详情
3591 3746
 						err := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
3592 3747
 						if err == nil {
3593 3748
 							details := &models.AutomaticReduceDetail{
@@ -3607,11 +3762,13 @@ func (c *DialysisAPIController) EditConsumables() {
3607 3762
 					}
3608 3763
 				}
3609 3764
 			}
3765
+			//没有出库单创建
3610 3766
 		} else if err == nil {
3611 3767
 
3612 3768
 			if len(newBeforePrepares) > 0 { //新增
3613 3769
 
3614 3770
 				for _, item := range newBeforePrepares {
3771
+
3615 3772
 					outInfo, err := service.FindStockOutInfoByTypeId(adminInfo.Org.Id, item.GoodTypeId, item.GoodId, out.ID, out.WarehouseOutOrderNumber)
3616 3773
 
3617 3774
 					if err == gorm.ErrRecordNotFound {
@@ -3800,15 +3957,12 @@ func (c *DialysisAPIController) EditConsumables() {
3800 3957
 									}
3801 3958
 								}
3802 3959
 
3803
-								fmt.Println("444444444")
3804
-
3805 3960
 							}
3806 3961
 						}
3807 3962
 					}
3808 3963
 				}
3809 3964
 			}
3810 3965
 		}
3811
-		fmt.Println("655555555")
3812 3966
 
3813 3967
 		var errs error
3814 3968
 		if len(beforePrepares) > 0 {
@@ -4007,6 +4161,9 @@ func (c *DialysisAPIController) GetDialysisGoods() {
4007 4161
 
4008 4162
 	goodTypes, _ := service.FindAllGoodType(adminUser.Org.Id)
4009 4163
 
4164
+	//获取当天该病人的透析处方
4165
+	prescribe, parseDateErr := service.GetDialysisPrescribe(adminUser.Org.Id, patient_id, date.Unix())
4166
+	good_info, _ := service.FindAllGoodInfo(adminUser.Org.Id)
4010 4167
 	if err == gorm.ErrRecordNotFound {
4011 4168
 
4012 4169
 		dialysisGoods, _, total := service.MobileGetDialysisGoods(adminUser.Org.Id, date.Unix(), schedule_type, partition_id, page, 0, patient_id, "", schedualEndDate)
@@ -4023,6 +4180,8 @@ func (c *DialysisAPIController) GetDialysisGoods() {
4023 4180
 			"dialysis_goods": dialysisGoods,
4024 4181
 			"good_type":      goodTypes,
4025 4182
 			"total":          total,
4183
+			"prescribe":      prescribe,
4184
+			"good_info":      good_info,
4026 4185
 		})
4027 4186
 		return
4028 4187
 
@@ -4046,6 +4205,8 @@ func (c *DialysisAPIController) GetDialysisGoods() {
4046 4205
 				"dialysis_goods": dialysisGoods,
4047 4206
 				"good_type":      goodTypes,
4048 4207
 				"total":          total,
4208
+				"prescribe":      prescribe,
4209
+				"good_info":      good_info,
4049 4210
 			})
4050 4211
 			return
4051 4212
 
@@ -4112,11 +4273,17 @@ func (c *DialysisAPIController) GetStockInGoodInfo() {
4112 4273
 
4113 4274
 	goodUser, _ := service.GetAllStockOutUserDetail(patient_id, adminUser.Org.Id, date.Unix())
4114 4275
 	lastGoodUserDetial, _ := service.GetLastDialysisGoods(patient_id, adminUser.Org.Id, date.Unix())
4276
+
4277
+	//获取今日患者的透析处方参数
4278
+
4279
+	prescribe, parseDateErr := service.GetDialysisPrescribe(adminUser.Org.Id, patient_id, date.Unix())
4280
+
4115 4281
 	c.ServeSuccessJSON(map[string]interface{}{
4116 4282
 		"good_type":      goodTypes,
4117 4283
 		"good_user":      goodUser,
4118 4284
 		"good_info":      good_info,
4119 4285
 		"last_good_user": lastGoodUserDetial,
4286
+		"prescription":   prescribe,
4120 4287
 	})
4121 4288
 	return
4122 4289
 
@@ -4158,15 +4325,16 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
4158 4325
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4159 4326
 					return
4160 4327
 				}
4161
-				good_id := int64(items["good_id"].(float64))
4162 4328
 
4329
+				good_id := int64(items["good_id"].(float64))
4330
+				fmt.Println("goood_id2222222222222222", good_id)
4163 4331
 				if items["good_type_id"] == nil || reflect.TypeOf(items["good_type_id"]).String() != "float64" {
4164 4332
 					utils.ErrorLog("good_type_id")
4165 4333
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4166 4334
 					return
4167 4335
 				}
4168 4336
 				good_type_id := int64(items["good_type_id"].(float64))
4169
-
4337
+				fmt.Println("goood_id2222222222222222", good_type_id)
4170 4338
 				if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "string" {
4171 4339
 					utils.ErrorLog("count")
4172 4340
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -4174,7 +4342,7 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
4174 4342
 				}
4175 4343
 
4176 4344
 				count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
4177
-
4345
+				fmt.Println("count22222222", count)
4178 4346
 				adminUser := c.GetMobileAdminUserInfo()
4179 4347
 				prepare := &models.DialysisBeforePrepare{
4180 4348
 					UserOrgId:  adminUser.Org.Id,
@@ -4424,3 +4592,45 @@ func (c *DialysisAPIController) GetDepartment() {
4424 4592
 	}
4425 4593
 
4426 4594
 }
4595
+
4596
+func (c *DialysisAPIController) GetMobilePrintStockGood() {
4597
+
4598
+	types, _ := c.GetInt("type", 0)
4599
+	start_time := c.GetString("start_time")
4600
+	end_time := c.GetString("end_time")
4601
+	orgId := c.GetMobileAdminUserInfo().Org.Id
4602
+
4603
+	timeLayout := "2006-01-02"
4604
+	loc, _ := time.LoadLocation("Local")
4605
+	var startTime int64
4606
+	if len(start_time) > 0 {
4607
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4608
+		if err != nil {
4609
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4610
+			return
4611
+		}
4612
+		startTime = theTime.Unix()
4613
+	}
4614
+	var endTime int64
4615
+	if len(end_time) > 0 {
4616
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
4617
+		if err != nil {
4618
+			utils.ErrorLog(err.Error())
4619
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4620
+			return
4621
+		}
4622
+		endTime = theTime.Unix()
4623
+	}
4624
+
4625
+	list, err := service.FindPrintStockGoodInfoByType(types, startTime, endTime, orgId)
4626
+	stockTotal, err := service.GetOutStockTotalCountTwo(startTime, endTime, orgId)
4627
+	if err != nil {
4628
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4629
+	} else {
4630
+		c.ServeSuccessJSON(map[string]interface{}{
4631
+			"list":       list,
4632
+			"type":       types,
4633
+			"stockTotal": stockTotal,
4634
+		})
4635
+	}
4636
+}

+ 8 - 1
controllers/mobile_api_controllers/dialysis_api_controller_extend.go View File

@@ -92,6 +92,8 @@ func (this *DialysisAPIController) AddMonitorRecord() {
92 92
 	dialysate_flow, _ := this.GetFloat("dialysate_flow")
93 93
 	urr := this.GetString("urr")
94 94
 	blood_sugar, _ := this.GetFloat("blood_sugar")
95
+	monitor_anticoagulant, _ := this.GetInt64("monitor_anticoagulant")
96
+	monitor_anticoagulant_value := this.GetString("monitor_anticoagulant_value")
95 97
 	adminInfo := this.GetMobileAdminUserInfo()
96 98
 	patient, getPatientErr := service.MobileGetPatientById(adminInfo.Org.Id, patientID)
97 99
 	if getPatientErr != nil {
@@ -146,6 +148,8 @@ func (this *DialysisAPIController) AddMonitorRecord() {
146 148
 		DialysateFlow:             dialysate_flow,
147 149
 		Urr:                       urr,
148 150
 		BloodSugar:                blood_sugar,
151
+		MonitorAnticoagulant:      monitor_anticoagulant,
152
+		MonitorAnticoagulantValue: monitor_anticoagulant_value,
149 153
 	}
150 154
 
151 155
 	err := service.CreateMonitor(&record)
@@ -240,7 +244,8 @@ func (this *DialysisAPIController) EditMonitorRecord() {
240 244
 	urr := this.GetString("urr")
241 245
 	blood_sugar, _ := this.GetFloat("blood_sugar")
242 246
 	adminInfo := this.GetMobileAdminUserInfo()
243
-
247
+	monitor_anticoagulant, _ := this.GetInt64("monitor_anticoagulant")
248
+	monitor_anticoagulant_value := this.GetString("monitor_anticoagulant_value")
244 249
 	monitor, err := service.GetMonitor(adminInfo.Org.Id, patientID, id)
245 250
 	if err != nil {
246 251
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -288,6 +293,8 @@ func (this *DialysisAPIController) EditMonitorRecord() {
288 293
 	monitor.DialysateFlow = dialysate_flow
289 294
 	monitor.Urr = urr
290 295
 	monitor.BloodSugar = blood_sugar
296
+	monitor.MonitorAnticoagulant = monitor_anticoagulant
297
+	monitor.MonitorAnticoagulantValue = monitor_anticoagulant_value
291 298
 	err = service.UpdateMonitor(monitor)
292 299
 	if err != nil {
293 300
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorUpdate)

+ 1 - 0
controllers/mobile_api_controllers/mobile_api_router_register.go View File

@@ -137,4 +137,5 @@ func MobileAPIControllersRegisterRouters() {
137 137
 
138 138
 	beego.Router("/m/api/department/get", &DialysisAPIController{}, "Get:GetDepartment")
139 139
 
140
+	beego.Router("/m/api/getmobileprintstockgood", &DialysisAPIController{}, "Get:GetMobilePrintStockGood")
140 141
 }

+ 44 - 1
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go View 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
+}

+ 25 - 2
controllers/new_mobile_api_controllers/new_manage_api_controller.go View File

@@ -43,8 +43,7 @@ func (this *NewManageApiController) GetDisInfectionTime() {
43 43
 	unitType, _ := service.GetUnitType(bedid, orgid)
44 44
 	//查询使用登记最后一条消毒记录
45 45
 	infomation, err := service.GetLaseDeviceInfomation(orgid, bedid, scheduledate, scheduletype)
46
-	fmt.Println("infomation========", infomation)
47
-	fmt.Println("err-------", err)
46
+	fmt.Println("err", err)
48 47
 	if err == gorm.ErrRecordNotFound {
49 48
 		//查询改设备是否有消毒计划
50 49
 		plan, errcode := service.GetDisInfectionTime(orgid, unitType.UnitType, scheduletype, scheduleweek)
@@ -216,3 +215,27 @@ func (this *NewManageApiController) SaveDisInfectionInfo() {
216 215
 		}
217 216
 	}
218 217
 }
218
+
219
+func (this *NewManageApiController) GetDeviceInformation() {
220
+
221
+	adminUser := this.GetMobileAdminUserInfo()
222
+	orgid := adminUser.Org.Id
223
+
224
+	scheduleDate := this.GetString("schedule_date")
225
+	recordDate, parseErr := utils.ParseTimeStringToTime("2006-01-02", scheduleDate)
226
+	if parseErr != nil {
227
+		this.ErrorLog("时间解析失败:%v", parseErr)
228
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
229
+		return
230
+	}
231
+	fmt.Println("recordDate2222222", recordDate.Unix())
232
+	//查询今日所有设备使用登记
233
+	information, err := service.GetDeviceInfomation(orgid, recordDate.Unix())
234
+	if err != nil {
235
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
236
+		return
237
+	}
238
+	this.ServeSuccessJSON(map[string]interface{}{
239
+		"information": information,
240
+	})
241
+}

+ 1 - 0
controllers/new_mobile_api_controllers/new_manage_api_router.go View File

@@ -7,4 +7,5 @@ func NewManageApiControllersRegisterRouters() {
7 7
 	beego.Router("m/api/getequitautoinfo", &NewManageApiController{}, "Get:GetEquitAutoInfo")
8 8
 	beego.Router("m/api/getdisinfection", &NewManageApiController{}, "Get:GetDisInfectionTime")
9 9
 	beego.Router("/m/api/savedisinfectioninfo", &NewManageApiController{}, "Get:SaveDisInfectionInfo")
10
+	beego.Router("/m/api/getdeviceinformation", &NewManageApiController{}, "Get:GetDeviceInformation")
10 11
 }

+ 2 - 0
controllers/new_mobile_api_controllers/new_mobile_api_router_register.go View 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")

+ 100 - 80
controllers/patient_api_controller.go View File

@@ -254,29 +254,29 @@ func (c *PatientApiController) CreatePatient() {
254 254
 	//获取老表的最后一条数据
255 255
 	patients, err := service.GetLastPatientData(adminUserInfo.CurrentOrgId)
256 256
 	patientsNew := models.XtPatientsNew{
257
-		UserOrgId:                    adminUserInfo.CurrentOrgId,
258
-		UserId:                       0,
259
-		Avatar:                       patients.Avatar,
260
-		PatientType:                  patients.PatientType,
261
-		DialysisNo:                   patients.DialysisNo,
262
-		AdmissionNumber:              patients.AdmissionNumber,
263
-		Source:                       patients.Source,
264
-		Lapseto:                      patients.Lapseto,
265
-		PartitionId:                  patients.PartitionId,
266
-		BedId:                        patients.BedId,
267
-		Name:                         patients.Name,
268
-		Alias:                        patients.Alias,
269
-		Gender:                       patients.Gender,
270
-		MaritalStatus:                patients.MaritalStatus,
271
-		IdCardNo:                     patients.IdCardNo,
272
-		Birthday:                     patients.Birthday,
273
-		ReimbursementWayId:           patients.ReimbursementWayId,
274
-		HealthCareType:               patients.HealthCareType,
275
-		HealthCareNo:                 patients.HealthCareNo,
276
-		HealthCareDueDate:            patients.HealthCareDueDate,
277
-		Height:                       patients.Height,
278
-		BloodType:                    patients.BloodType,
279
-		Rh:                           patients.Rh,
257
+		UserOrgId:          adminUserInfo.CurrentOrgId,
258
+		UserId:             0,
259
+		Avatar:             patients.Avatar,
260
+		PatientType:        patients.PatientType,
261
+		DialysisNo:         patients.DialysisNo,
262
+		AdmissionNumber:    patients.AdmissionNumber,
263
+		Source:             patients.Source,
264
+		Lapseto:            patients.Lapseto,
265
+		PartitionId:        patients.PartitionId,
266
+		BedId:              patients.BedId,
267
+		Name:               patients.Name,
268
+		Alias:              patients.Alias,
269
+		Gender:             patients.Gender,
270
+		MaritalStatus:      patients.MaritalStatus,
271
+		IdCardNo:           patients.IdCardNo,
272
+		Birthday:           patients.Birthday,
273
+		ReimbursementWayId: patients.ReimbursementWayId,
274
+		HealthCareType:     patients.HealthCareType,
275
+		HealthCareNo:       patients.HealthCareNo,
276
+		HealthCareDueDate:  patients.HealthCareDueDate,
277
+		Height:             patients.Height,
278
+		BloodType:          patients.BloodType,
279
+		Rh:                 patients.Rh,
280 280
 		HealthCareDueAlertDate:       patients.HealthCareDueAlertDate,
281 281
 		EducationLevel:               patients.EducationLevel,
282 282
 		Profession:                   patients.Profession,
@@ -322,28 +322,28 @@ func (c *PatientApiController) CreatePatient() {
322 322
 		Nation:                       patients.Nation,
323 323
 		NativePlace:                  patients.NativePlace,
324 324
 		Age:                          patients.Age,
325
-		InfectiousNextRecordTime:     patients.InfectiousNextRecordTime,
326
-		IsInfectious:                 patients.IsInfectious,
327
-		RemindCycle:                  patients.RemindCycle,
328
-		ResponseResult:               patients.ResponseResult,
329
-		IsOpenRemind:                 patients.IsOpenRemind,
330
-		FirstTreatmentDate:           patients.FirstTreatmentDate,
331
-		DialysisAge:                  patients.DialysisAge,
332
-		ExpenseKind:                  patients.ExpenseKind,
333
-		TellPhone:                    patients.TellPhone,
334
-		ContactName:                  patients.ContactName,
335
-		BloodPatients:                1,
336
-		SlowPatients:                 0,
337
-		MemberPatients:               0,
338
-		EcommerPatients:              "",
339
-		BloodId:                      patients.ID,
340
-		SlowId:                       0,
341
-		MemberId:                     0,
342
-		MemberFistdate:               0,
343
-		MemberPatienttype:            0,
344
-		MemberTreatement:             0,
345
-		EquitmentId:                  "",
346
-		UserSysBeforeCount:           patient.UserSysBeforeCount,
325
+		InfectiousNextRecordTime: patients.InfectiousNextRecordTime,
326
+		IsInfectious:             patients.IsInfectious,
327
+		RemindCycle:              patients.RemindCycle,
328
+		ResponseResult:           patients.ResponseResult,
329
+		IsOpenRemind:             patients.IsOpenRemind,
330
+		FirstTreatmentDate:       patients.FirstTreatmentDate,
331
+		DialysisAge:              patients.DialysisAge,
332
+		ExpenseKind:              patients.ExpenseKind,
333
+		TellPhone:                patients.TellPhone,
334
+		ContactName:              patients.ContactName,
335
+		BloodPatients:            1,
336
+		SlowPatients:             0,
337
+		MemberPatients:           0,
338
+		EcommerPatients:          "",
339
+		BloodId:                  patients.ID,
340
+		SlowId:                   0,
341
+		MemberId:                 0,
342
+		MemberFistdate:           0,
343
+		MemberPatienttype:        0,
344
+		MemberTreatement:         0,
345
+		EquitmentId:              "",
346
+		UserSysBeforeCount:       patient.UserSysBeforeCount,
347 347
 	}
348 348
 
349 349
 	err = service.CreatePatientsNew(&patientsNew)
@@ -481,28 +481,28 @@ func (c *PatientApiController) EditPatient() {
481 481
 		return
482 482
 	}
483 483
 	patientsNew := models.XtPatientsNew{
484
-		UserOrgId:                 patient.UserOrgId,
485
-		UserId:                    patient.UserId,
486
-		Avatar:                    patient.Avatar,
487
-		PatientType:               patient.PatientType,
488
-		DialysisNo:                patient.DialysisNo,
489
-		AdmissionNumber:           patient.AdmissionNumber,
490
-		Source:                    patient.Source,
491
-		PartitionId:               patient.PartitionId,
492
-		BedId:                     patient.BedId,
493
-		Name:                      patient.Name,
494
-		Alias:                     patient.Alias,
495
-		Gender:                    patient.Gender,
496
-		MaritalStatus:             patient.MaritalStatus,
497
-		IdCardNo:                  patient.IdCardNo,
498
-		Birthday:                  patient.Birthday,
499
-		ReimbursementWayId:        patient.ReimbursementWayId,
500
-		HealthCareType:            patient.HealthCareType,
501
-		HealthCareNo:              patient.HealthCareNo,
502
-		HealthCareDueDate:         patient.HealthCareDueDate,
503
-		Height:                    patient.Height,
504
-		BloodType:                 patient.BloodType,
505
-		Rh:                        patient.Rh,
484
+		UserOrgId:          patient.UserOrgId,
485
+		UserId:             patient.UserId,
486
+		Avatar:             patient.Avatar,
487
+		PatientType:        patient.PatientType,
488
+		DialysisNo:         patient.DialysisNo,
489
+		AdmissionNumber:    patient.AdmissionNumber,
490
+		Source:             patient.Source,
491
+		PartitionId:        patient.PartitionId,
492
+		BedId:              patient.BedId,
493
+		Name:               patient.Name,
494
+		Alias:              patient.Alias,
495
+		Gender:             patient.Gender,
496
+		MaritalStatus:      patient.MaritalStatus,
497
+		IdCardNo:           patient.IdCardNo,
498
+		Birthday:           patient.Birthday,
499
+		ReimbursementWayId: patient.ReimbursementWayId,
500
+		HealthCareType:     patient.HealthCareType,
501
+		HealthCareNo:       patient.HealthCareNo,
502
+		HealthCareDueDate:  patient.HealthCareDueDate,
503
+		Height:             patient.Height,
504
+		BloodType:          patient.BloodType,
505
+		Rh:                 patient.Rh,
506 506
 		HealthCareDueAlertDate:    patient.HealthCareDueAlertDate,
507 507
 		EducationLevel:            patient.EducationLevel,
508 508
 		Profession:                patient.Profession,
@@ -544,19 +544,19 @@ func (c *PatientApiController) EditPatient() {
544 544
 		Nation:                    patient.Nation,
545 545
 		NativePlace:               patient.NativePlace,
546 546
 		Age:                       patient.Age,
547
-		InfectiousNextRecordTime:  patient.InfectiousNextRecordTime,
548
-		IsInfectious:              patient.IsInfectious,
549
-		RemindCycle:               patient.RemindCycle,
550
-		ResponseResult:            patient.ResponseResult,
551
-		IsOpenRemind:              patient.IsOpenRemind,
552
-		FirstTreatmentDate:        patient.FirstTreatmentDate,
553
-		DialysisAge:               patient.DialysisAge,
554
-		ExpenseKind:               patient.ExpenseKind,
555
-		TellPhone:                 patient.TellPhone,
556
-		ContactName:               patient.ContactName,
557
-		UpdatedTime:               time.Now().Unix(),
558
-		BloodPatients:             1,
559
-		Lapseto:                   patient.Lapseto,
547
+		InfectiousNextRecordTime: patient.InfectiousNextRecordTime,
548
+		IsInfectious:             patient.IsInfectious,
549
+		RemindCycle:              patient.RemindCycle,
550
+		ResponseResult:           patient.ResponseResult,
551
+		IsOpenRemind:             patient.IsOpenRemind,
552
+		FirstTreatmentDate:       patient.FirstTreatmentDate,
553
+		DialysisAge:              patient.DialysisAge,
554
+		ExpenseKind:              patient.ExpenseKind,
555
+		TellPhone:                patient.TellPhone,
556
+		ContactName:              patient.ContactName,
557
+		UpdatedTime:              time.Now().Unix(),
558
+		BloodPatients:            1,
559
+		Lapseto:                  patient.Lapseto,
560 560
 	}
561 561
 	//	//更新病人ID获取新表病人ID
562 562
 	err = service.UpdatepatientTwo(&patientsNew, id)
@@ -854,6 +854,8 @@ func (c *PatientApiController) UpdateDialysisSolution() {
854 854
 		BloodAccess:                solution.BloodAccess,
855 855
 		DialysateFlow:              solution.DialysateFlow,
856 856
 		DialysateTemperature:       solution.DialysateTemperature,
857
+		DialysisIrrigation:         solution.DialysisIrrigation,
858
+		DialysisDialyszers:         solution.DialysisDialyszers,
857 859
 	}
858 860
 	service.UpdatePatientDialysisSolutionOne(solution.PatientId, adminUserInfo.CurrentOrgId, &prescription, todayTime.Unix())
859 861
 	if err != nil {
@@ -926,9 +928,11 @@ func (c *PatientApiController) GetPatientDialysisSolutionList() {
926 928
 	adminUserInfo := c.GetAdminUserInfo()
927 929
 
928 930
 	solutions, total, _ := service.GetPatientDialysisSolutionList(adminUserInfo.CurrentOrgId, id, page, limit)
931
+	stockType, _ := service.GetStockType(adminUserInfo.CurrentOrgId)
929 932
 	c.ServeSuccessJSON(map[string]interface{}{
930 933
 		"solutions": solutions,
931 934
 		"total":     total,
935
+		"stockType": stockType,
932 936
 	})
933 937
 	return
934 938
 }
@@ -3390,6 +3394,22 @@ func defaultSolutionFormData(solution *models.DialysisSolution, data []byte, met
3390 3394
 		solution.Remark = remark
3391 3395
 	}
3392 3396
 
3397
+	if dataBody["created_time"] != nil && reflect.TypeOf(dataBody["created_time"]).String() == "float64" {
3398
+		created_time := int64(dataBody["created_time"].(float64))
3399
+
3400
+		solution.CreatedTime = created_time
3401
+	}
3402
+
3403
+	if dataBody["dialysis_dialyszers"] != nil && reflect.TypeOf(dataBody["dialysis_dialyszers"]).String() == "string" {
3404
+		dialysisDialyszers := dataBody["dialysis_dialyszers"].(string)
3405
+		solution.DialysisDialyszers = dialysisDialyszers
3406
+	}
3407
+
3408
+	if dataBody["dialysis_irrigation"] != nil && reflect.TypeOf(dataBody["dialysis_irrigation"]).String() == "string" {
3409
+		dialysisIrrigation := dataBody["dialysis_irrigation"].(string)
3410
+		solution.DialysisIrrigation = dialysisIrrigation
3411
+	}
3412
+
3393 3413
 	return
3394 3414
 }
3395 3415
 

+ 128 - 0
controllers/schedule_api_controller.go View File

@@ -44,6 +44,8 @@ func ScheduleApiRegistRouters() {
44 44
 	beego.Router("/api/schedule/getthreeweeklist", &ScheduleApiController{}, "Get:GetThreeWeekList")
45 45
 
46 46
 	beego.Router("/api/schedule/getallzones", &ScheduleApiController{}, "Get:GetAllZones")
47
+
48
+	beego.Router("/api/schedule/copypatientschedules", &ScheduleApiController{}, "Get:GetCopyPatientSchedules")
47 49
 }
48 50
 
49 51
 func (c *ScheduleApiController) GetWeekPanels() {
@@ -1928,7 +1930,9 @@ func (this *ScheduleApiController) GetNextWeekDaySchedule() {
1928 1930
 	week_time, _ := this.GetInt64("week_time")
1929 1931
 	start_time, _ := this.GetInt64("start_time")
1930 1932
 	end_time, _ := this.GetInt64("end_time")
1933
+
1931 1934
 	adminUserInfo := this.GetAdminUserInfo()
1935
+
1932 1936
 	schedule, err := service.GetNextWeekDaySchedule(week_type, week_time, start_time, end_time, adminUserInfo.CurrentOrgId)
1933 1937
 	if err != nil {
1934 1938
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -1992,3 +1996,127 @@ func (this *ScheduleApiController) GetAllZones() {
1992 1996
 		"zones": zones,
1993 1997
 	})
1994 1998
 }
1999
+
2000
+func (this *ScheduleApiController) GetCopyPatientSchedules() {
2001
+	adminUserInfo := this.GetAdminUserInfo()
2002
+	orgId := adminUserInfo.CurrentOrgId
2003
+	start_time, _ := this.GetInt64("start_time")
2004
+	fmt.Println("start_time", start_time)
2005
+	end_time, _ := this.GetInt64("end_time")
2006
+	fmt.Println("end_time", end_time)
2007
+	copy_startime, _ := this.GetInt64("copy_startime")
2008
+	fmt.Println("copy_startime", copy_startime)
2009
+	copy_endtime, _ := this.GetInt64("copy_endtime")
2010
+
2011
+	//获取本周患者排班
2012
+	schedules, _ := service.GetWeekSchedules(orgId, start_time, end_time)
2013
+
2014
+	//查询复制中的排班日期是否存在
2015
+	_, errcode := service.GetLastWeekSchedule(orgId, copy_startime, copy_endtime)
2016
+
2017
+	if errcode == gorm.ErrRecordNotFound {
2018
+		//如果没有直接新增
2019
+
2020
+		for _, item := range schedules {
2021
+			//fmt.Println(item.StartTime+604800)
2022
+			//礼拜1
2023
+			if item.ScheduleWeek == 1 {
2024
+				item.ScheduleDate = copy_startime
2025
+			}
2026
+			if item.ScheduleWeek == 2 {
2027
+				item.ScheduleDate = copy_startime + 86400
2028
+			}
2029
+			if item.ScheduleWeek == 3 {
2030
+				item.ScheduleDate = copy_startime + 172800
2031
+			}
2032
+			if item.ScheduleWeek == 4 {
2033
+				item.ScheduleDate = copy_startime + 259200
2034
+			}
2035
+			if item.ScheduleWeek == 5 {
2036
+				item.ScheduleDate = copy_startime + 345600
2037
+			}
2038
+
2039
+			if item.ScheduleWeek == 6 {
2040
+				item.ScheduleDate = copy_startime + 432000
2041
+			}
2042
+			//礼拜天
2043
+			if item.ScheduleWeek == 0 {
2044
+				item.ScheduleDate = copy_endtime
2045
+			}
2046
+			schedule := models.XtSchedule{
2047
+				UserOrgId:    item.UserOrgId,
2048
+				PartitionId:  item.PartitionId,
2049
+				BedId:        item.BedId,
2050
+				PatientId:    item.PatientId,
2051
+				ScheduleDate: item.ScheduleDate,
2052
+				ScheduleType: item.ScheduleType,
2053
+				ScheduleWeek: item.ScheduleWeek,
2054
+				ModeId:       item.ModeId,
2055
+				Status:       1,
2056
+				CreatedTime:  time.Now().Unix(),
2057
+			}
2058
+
2059
+			err := service.AddPatientSchedule(&schedule)
2060
+			if err != nil {
2061
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2062
+				return
2063
+			}
2064
+			this.ServeSuccessJSON(map[string]interface{}{
2065
+				"schedule": schedule,
2066
+			})
2067
+		}
2068
+	} else if errcode == nil {
2069
+
2070
+		//先清除复制周的排班
2071
+		errcode := service.UpdatePatientSchedule(orgId, copy_startime, copy_endtime)
2072
+		fmt.Println(errcode)
2073
+		for _, item := range schedules {
2074
+			//fmt.Println(item.StartTime+604800)
2075
+			//礼拜1
2076
+			if item.ScheduleWeek == 1 {
2077
+				item.ScheduleDate = copy_startime
2078
+			}
2079
+			if item.ScheduleWeek == 2 {
2080
+				item.ScheduleDate = copy_startime + 86400
2081
+			}
2082
+			if item.ScheduleWeek == 3 {
2083
+				item.ScheduleDate = copy_startime + 172800
2084
+			}
2085
+			if item.ScheduleWeek == 4 {
2086
+				item.ScheduleDate = copy_startime + 259200
2087
+			}
2088
+			if item.ScheduleWeek == 5 {
2089
+				item.ScheduleDate = copy_startime + 345600
2090
+			}
2091
+
2092
+			if item.ScheduleWeek == 6 {
2093
+				item.ScheduleDate = copy_startime + 432000
2094
+			}
2095
+			//礼拜天
2096
+			if item.ScheduleWeek == 0 {
2097
+				item.ScheduleDate = copy_endtime
2098
+			}
2099
+			schedule := models.XtSchedule{
2100
+				UserOrgId:    item.UserOrgId,
2101
+				PartitionId:  item.PartitionId,
2102
+				BedId:        item.BedId,
2103
+				PatientId:    item.PatientId,
2104
+				ScheduleDate: item.ScheduleDate,
2105
+				ScheduleType: item.ScheduleType,
2106
+				ScheduleWeek: item.ScheduleWeek,
2107
+				ModeId:       item.ModeId,
2108
+				Status:       1,
2109
+				CreatedTime:  time.Now().Unix(),
2110
+			}
2111
+
2112
+			err := service.AddPatientSchedule(&schedule)
2113
+			if err != nil {
2114
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2115
+				return
2116
+			}
2117
+			this.ServeSuccessJSON(map[string]interface{}{
2118
+				"schedule": schedule,
2119
+			})
2120
+		}
2121
+	}
2122
+}

+ 1 - 0
controllers/stock_good_api_controller.go View File

@@ -51,6 +51,7 @@ func (c *StockGoodApiController) CreateGoodType() {
51 51
 	total := service.FindAllGoodTypeTotal(adminUserInfo.CurrentOrgId)
52 52
 	code := strconv.FormatInt(total+1, 10)
53 53
 	code = "34000000" + code
54
+
54 55
 	goodType := models.GoodsType{
55 56
 		TypeCode:       code,
56 57
 		TypeName:       type_name,

+ 2 - 1
controllers/stock_in_api_controller.go View File

@@ -1379,7 +1379,7 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1379 1379
 					sys_record_time := int64(items["sys_record_time"].(float64))
1380 1380
 
1381 1381
 					warehouseOutInfo := &models.WarehouseOutInfo{
1382
-						ID:                      id,
1382
+						ID: id,
1383 1383
 						WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1384 1384
 						WarehouseOutId:          warehouseOut.ID,
1385 1385
 						GoodId:                  good_id,
@@ -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
 	}

+ 1 - 0
models/data_models.go View File

@@ -18,6 +18,7 @@ type Dataconfig struct {
18 18
 	Content        string `gorm:"column:content" json:"content" form:"content"`
19 19
 	Order          int64  `gorm:"column:orders" json:"orders" form:"orders"`
20 20
 	Code           string `gorm:"column:code" json:"code" form:"code"`
21
+	FieldType      int64  `gorm:"column:field_type" json:"field_type" form:"field_type"`
21 22
 }
22 23
 
23 24
 func (Dataconfig) TableName() string {

+ 177 - 47
models/device_models.go View File

@@ -584,6 +584,9 @@ type DeviceCultures struct {
584 584
 	EquitmentId       int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
585 585
 	UserName          string `gorm:"column:user_name" json:"user_name" form:"user_name"`
586 586
 	Bed               string `gorm:"column:bed" json:"bed" form:"bed"`
587
+	Sort              string `gorm:"column:sort" json:"sort" form:"sort"`
588
+	PassExamination   int64  `gorm:"column:pass_examination" json:"pass_examination" form:"pass_examination"`
589
+	Modifications     int64  `gorm:"column:modifications" json:"modifications" form:"modifications"`
587 590
 }
588 591
 
589 592
 //细菌培养检测
@@ -605,6 +608,9 @@ type DeviceCulture struct {
605 608
 	UserOrgId         int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
606 609
 	EquitmentId       int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
607 610
 	Bed               string `gorm:"column:bed" json:"bed" form:"bed"`
611
+	Sort              string `gorm:"column:sort" json:"sort" form:"sort"`
612
+	PassExamination   int64  `gorm:"column:pass_examination" json:"pass_examination" form:"pass_examination"`
613
+	Modifications     int64  `gorm:"column:modifications" json:"modifications" form:"modifications"`
608 614
 }
609 615
 
610 616
 func (DeviceCulture) TableName() string {
@@ -631,6 +637,9 @@ type DeviceDialysates struct {
631 637
 	EquitmentId       int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
632 638
 	UserName          string `gorm:"column:user_name" json:"user_name" form:"user_name"`
633 639
 	Bed               string `gorm:"column:bed" json:"bed" form:"bed"`
640
+	Sort              string `gorm:"column:sort" json:"sort" form:"sort"`
641
+	PassExamination   int64  `gorm:"column:pass_examination" json:"pass_examination" form:"pass_examination"`
642
+	Modifications     int64  `gorm:"column:modifications" json:"modifications" form:"modifications"`
634 643
 }
635 644
 
636 645
 //内霉素检测
@@ -652,6 +661,9 @@ type DeviceDialysate struct {
652 661
 	BedId             int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
653 662
 	EquitmentId       int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
654 663
 	Bed               string `gorm:"column:bed" json:"bed" form:"bed"`
664
+	Sort              string `gorm:"column:sort" json:"sort" form:"sort"`
665
+	PassExamination   int64  `gorm:"column:pass_examination" json:"pass_examination" form:"pass_examination"`
666
+	Modifications     int64  `gorm:"column:modifications" json:"modifications" form:"modifications"`
655 667
 }
656 668
 
657 669
 func (DeviceDialysate) TableName() string {
@@ -660,57 +672,63 @@ func (DeviceDialysate) TableName() string {
660 672
 }
661 673
 
662 674
 type DeviceIons struct {
663
-	ID             int64  `gorm:"column:id" json:"id" form:"id"`
664
-	SamplingDate   int64  `gorm:"column:sampling_date" json:"sampling_date" form:"sampling_date"`
665
-	Samplerc       int64  `gorm:"column:samplerc" json:"samplerc" form:"samplerc"`
666
-	DetectionUnit  string `gorm:"column:detection_unit" json:"detection_unit" form:"detection_unit"`
667
-	ConcentrateNof string `gorm:"column:concentrate_nof" json:"concentrate_nof" form:"concentrate_nof"`
668
-	ConcentrateNog string `gorm:"column:concentrate_nog" json:"concentrate_nog" form:"concentrate_nog"`
669
-	DateReportc    int64  `gorm:"column:date_reportc" json:"date_reportc" form:"date_reportc"`
670
-	ActualNa       string `gorm:"column:actual_na" json:"actual_na" form:"actual_na"`
671
-	ActualPna      string `gorm:"column:actual_pna" json:"actual_pna" form:"actual_pna"`
672
-	ActualK        string `gorm:"column:actual_k" json:"actual_k" form:"actual_k"`
673
-	ActualCa       string `gorm:"column:actual_ca" json:"actual_ca" form:"actual_ca"`
674
-	ActualCi       string `gorm:"column:actual_ci" json:"actual_ci" form:"actual_ci"`
675
-	ActualHco      string `gorm:"column:actual_hco" json:"actual_hco" form:"actual_hco"`
676
-	ActualMg       string `gorm:"column:actual_mg" json:"actual_mg" form:"actual_mg"`
677
-	ActualPh       string `gorm:"column:actual_ph" json:"actual_ph" form:"actual_ph"`
678
-	Remakes        string `gorm:"column:remakes" json:"remakes" form:"remakes"`
679
-	Status         int64  `gorm:"column:status" json:"status" form:"status"`
680
-	UserOrgId      int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
681
-	Ctime          int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
682
-	Mtime          int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
683
-	BedId          int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
684
-	EquitmentId    int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
685
-	UserName       string `gorm:"column:user_name" json:"user_name" form:"user_name"`
686
-	Bed            string `gorm:"column:bed" json:"bed" form:"bed"`
675
+	ID              int64  `gorm:"column:id" json:"id" form:"id"`
676
+	SamplingDate    int64  `gorm:"column:sampling_date" json:"sampling_date" form:"sampling_date"`
677
+	Samplerc        int64  `gorm:"column:samplerc" json:"samplerc" form:"samplerc"`
678
+	DetectionUnit   string `gorm:"column:detection_unit" json:"detection_unit" form:"detection_unit"`
679
+	ConcentrateNof  string `gorm:"column:concentrate_nof" json:"concentrate_nof" form:"concentrate_nof"`
680
+	ConcentrateNog  string `gorm:"column:concentrate_nog" json:"concentrate_nog" form:"concentrate_nog"`
681
+	DateReportc     int64  `gorm:"column:date_reportc" json:"date_reportc" form:"date_reportc"`
682
+	ActualNa        string `gorm:"column:actual_na" json:"actual_na" form:"actual_na"`
683
+	ActualPna       string `gorm:"column:actual_pna" json:"actual_pna" form:"actual_pna"`
684
+	ActualK         string `gorm:"column:actual_k" json:"actual_k" form:"actual_k"`
685
+	ActualCa        string `gorm:"column:actual_ca" json:"actual_ca" form:"actual_ca"`
686
+	ActualCi        string `gorm:"column:actual_ci" json:"actual_ci" form:"actual_ci"`
687
+	ActualHco       string `gorm:"column:actual_hco" json:"actual_hco" form:"actual_hco"`
688
+	ActualMg        string `gorm:"column:actual_mg" json:"actual_mg" form:"actual_mg"`
689
+	ActualPh        string `gorm:"column:actual_ph" json:"actual_ph" form:"actual_ph"`
690
+	Remakes         string `gorm:"column:remakes" json:"remakes" form:"remakes"`
691
+	Status          int64  `gorm:"column:status" json:"status" form:"status"`
692
+	UserOrgId       int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
693
+	Ctime           int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
694
+	Mtime           int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
695
+	BedId           int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
696
+	EquitmentId     int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
697
+	UserName        string `gorm:"column:user_name" json:"user_name" form:"user_name"`
698
+	Bed             string `gorm:"column:bed" json:"bed" form:"bed"`
699
+	Sort            string `gorm:"column:sort" json:"sort" form:"sort"`
700
+	PassExamination int64  `gorm:"column:pass_examination" json:"pass_examination" form:"pass_examination"`
701
+	Modifications   int64  `gorm:"column:modifications" json:"modifications" form:"modifications"`
687 702
 }
688 703
 
689 704
 //透析液离子浓度检测
690 705
 type DeviceIon struct {
691
-	ID             int64  `gorm:"column:id" json:"id" form:"id"`
692
-	SamplingDate   int64  `gorm:"column:sampling_date" json:"sampling_date" form:"sampling_date"`
693
-	Samplerc       int64  `gorm:"column:samplerc" json:"samplerc" form:"samplerc"`
694
-	DetectionUnit  string `gorm:"column:detection_unit" json:"detection_unit" form:"detection_unit"`
695
-	ConcentrateNof string `gorm:"column:concentrate_nof" json:"concentrate_nof" form:"concentrate_nof"`
696
-	ConcentrateNog string `gorm:"column:concentrate_nog" json:"concentrate_nog" form:"concentrate_nog"`
697
-	DateReportc    int64  `gorm:"column:date_reportc" json:"date_reportc" form:"date_reportc"`
698
-	ActualNa       string `gorm:"column:actual_na" json:"actual_na" form:"actual_na"`
699
-	ActualPna      string `gorm:"column:actual_pna" json:"actual_pna" form:"actual_pna"`
700
-	ActualK        string `gorm:"column:actual_k" json:"actual_k" form:"actual_k"`
701
-	ActualCa       string `gorm:"column:actual_ca" json:"actual_ca" form:"actual_ca"`
702
-	ActualCi       string `gorm:"column:actual_ci" json:"actual_ci" form:"actual_ci"`
703
-	ActualHco      string `gorm:"column:actual_hco" json:"actual_hco" form:"actual_hco"`
704
-	ActualMg       string `gorm:"column:actual_mg" json:"actual_mg" form:"actual_mg"`
705
-	ActualPh       string `gorm:"column:actual_ph" json:"actual_ph" form:"actual_ph"`
706
-	Remakes        string `gorm:"column:remakes" json:"remakes" form:"remakes"`
707
-	Status         int64  `gorm:"column:status" json:"status" form:"status"`
708
-	UserOrgId      int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
709
-	Ctime          int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
710
-	Mtime          int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
711
-	BedId          int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
712
-	EquitmentId    int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
713
-	Bed            string `gorm:"column:bed" json:"bed" form:"bed"`
706
+	ID              int64  `gorm:"column:id" json:"id" form:"id"`
707
+	SamplingDate    int64  `gorm:"column:sampling_date" json:"sampling_date" form:"sampling_date"`
708
+	Samplerc        int64  `gorm:"column:samplerc" json:"samplerc" form:"samplerc"`
709
+	DetectionUnit   string `gorm:"column:detection_unit" json:"detection_unit" form:"detection_unit"`
710
+	ConcentrateNof  string `gorm:"column:concentrate_nof" json:"concentrate_nof" form:"concentrate_nof"`
711
+	ConcentrateNog  string `gorm:"column:concentrate_nog" json:"concentrate_nog" form:"concentrate_nog"`
712
+	DateReportc     int64  `gorm:"column:date_reportc" json:"date_reportc" form:"date_reportc"`
713
+	ActualNa        string `gorm:"column:actual_na" json:"actual_na" form:"actual_na"`
714
+	ActualPna       string `gorm:"column:actual_pna" json:"actual_pna" form:"actual_pna"`
715
+	ActualK         string `gorm:"column:actual_k" json:"actual_k" form:"actual_k"`
716
+	ActualCa        string `gorm:"column:actual_ca" json:"actual_ca" form:"actual_ca"`
717
+	ActualCi        string `gorm:"column:actual_ci" json:"actual_ci" form:"actual_ci"`
718
+	ActualHco       string `gorm:"column:actual_hco" json:"actual_hco" form:"actual_hco"`
719
+	ActualMg        string `gorm:"column:actual_mg" json:"actual_mg" form:"actual_mg"`
720
+	ActualPh        string `gorm:"column:actual_ph" json:"actual_ph" form:"actual_ph"`
721
+	Remakes         string `gorm:"column:remakes" json:"remakes" form:"remakes"`
722
+	Status          int64  `gorm:"column:status" json:"status" form:"status"`
723
+	UserOrgId       int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
724
+	Ctime           int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
725
+	Mtime           int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
726
+	BedId           int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
727
+	EquitmentId     int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
728
+	Bed             string `gorm:"column:bed" json:"bed" form:"bed"`
729
+	Sort            string `gorm:"column:sort" json:"sort" form:"sort"`
730
+	PassExamination int64  `gorm:"column:pass_examination" json:"pass_examination" form:"pass_examination"`
731
+	Modifications   int64  `gorm:"column:modifications" json:"modifications" form:"modifications"`
714 732
 }
715 733
 
716 734
 func (DeviceIon) TableName() string {
@@ -892,3 +910,115 @@ type VmSchedule struct {
892 910
 	Number       string `gorm:"column:number" json:"number" form:"number"`
893 911
 	ZoneName     string `gorm:"column:name" json:"zon_name" form:"name"`
894 912
 }
913
+
914
+type XtDeviceOxygenates struct {
915
+	ID                int64  `gorm:"column:id" json:"id" form:"id"`
916
+	SamplingDate      int64  `gorm:"column:sampling_date" json:"sampling_date" form:"sampling_date"`
917
+	Specimenb         int64  `gorm:"column:specimenb" json:"specimenb" form:"specimenb"`
918
+	ConcentrateNoc    string `gorm:"column:concentrate_noc" json:"concentrate_noc" form:"concentrate_noc"`
919
+	ConcentratebNod   string `gorm:"column:concentrateb_nod" json:"concentrateb_nod" form:"concentrateb_nod"`
920
+	SamplingLocationb int64  `gorm:"column:sampling_locationb" json:"sampling_locationb" form:"sampling_locationb"`
921
+	DetectionUnit     string `gorm:"column:detection_unit" json:"detection_unit" form:"detection_unit"`
922
+	Samplerb          int64  `gorm:"column:samplerb" json:"samplerb" form:"samplerb"`
923
+	ReportingDateb    int64  `gorm:"column:reporting_dateb" json:"reporting_dateb" form:"reporting_dateb"`
924
+	DetectionResultb  string `gorm:"column:detection_resultb" json:"detection_resultb" form:"detection_resultb"`
925
+	Status            int64  `gorm:"column:status" json:"status" form:"status"`
926
+	UserOrgId         int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
927
+	Ctime             int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
928
+	Mtime             int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
929
+	BedId             int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
930
+	EquitmentId       int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
931
+	Bed               string `gorm:"column:bed" json:"bed" form:"bed"`
932
+	Sort              string `gorm:"column:sort" json:"sort" form:"sort"`
933
+	PassExamination   int64  `gorm:"column:pass_examination" json:"pass_examination" form:"pass_examination"`
934
+	Modifications     int64  `gorm:"column:modifications" json:"modifications" form:"modifications"`
935
+}
936
+
937
+func (XtDeviceOxygenates) TableName() string {
938
+
939
+	return "xt_device_oxygenates"
940
+}
941
+
942
+type XtDeviceHadwater struct {
943
+	ID                int64  `gorm:"column:id" json:"id" form:"id"`
944
+	SamplingDate      int64  `gorm:"column:sampling_date" json:"sampling_date" form:"sampling_date"`
945
+	Specimenb         int64  `gorm:"column:specimenb" json:"specimenb" form:"specimenb"`
946
+	ConcentrateNoc    string `gorm:"column:concentrate_noc" json:"concentrate_noc" form:"concentrate_noc"`
947
+	ConcentratebNod   string `gorm:"column:concentrateb_nod" json:"concentrateb_nod" form:"concentrateb_nod"`
948
+	SamplingLocationb int64  `gorm:"column:sampling_locationb" json:"sampling_locationb" form:"sampling_locationb"`
949
+	DetectionUnit     string `gorm:"column:detection_unit" json:"detection_unit" form:"detection_unit"`
950
+	Samplerb          int64  `gorm:"column:samplerb" json:"samplerb" form:"samplerb"`
951
+	ReportingDateb    int64  `gorm:"column:reporting_dateb" json:"reporting_dateb" form:"reporting_dateb"`
952
+	DetectionResultb  string `gorm:"column:detection_resultb" json:"detection_resultb" form:"detection_resultb"`
953
+	Status            int64  `gorm:"column:status" json:"status" form:"status"`
954
+	UserOrgId         int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
955
+	Ctime             int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
956
+	Mtime             int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
957
+	BedId             int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
958
+	EquitmentId       int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
959
+	Bed               string `gorm:"column:bed" json:"bed" form:"bed"`
960
+	Sort              string `gorm:"column:sort" json:"sort" form:"sort"`
961
+	PassExamination   int64  `gorm:"column:pass_examination" json:"pass_examination" form:"pass_examination"`
962
+	Modifications     int64  `gorm:"column:modifications" json:"modifications" form:"modifications"`
963
+}
964
+
965
+func (XtDeviceHadwater) TableName() string {
966
+
967
+	return "xt_device_hadwater"
968
+}
969
+
970
+type XtDeviceWater struct {
971
+	ID                int64  `gorm:"column:id" json:"id" form:"id"`
972
+	SamplingDate      int64  `gorm:"column:sampling_date" json:"sampling_date" form:"sampling_date"`
973
+	Specimenb         int64  `gorm:"column:specimenb" json:"specimenb" form:"specimenb"`
974
+	ConcentrateNoc    string `gorm:"column:concentrate_noc" json:"concentrate_noc" form:"concentrate_noc"`
975
+	ConcentratebNod   string `gorm:"column:concentrateb_nod" json:"concentrateb_nod" form:"concentrateb_nod"`
976
+	SamplingLocationb int64  `gorm:"column:sampling_locationb" json:"sampling_locationb" form:"sampling_locationb"`
977
+	DetectionUnit     string `gorm:"column:detection_unit" json:"detection_unit" form:"detection_unit"`
978
+	Samplerb          int64  `gorm:"column:samplerb" json:"samplerb" form:"samplerb"`
979
+	ReportingDateb    int64  `gorm:"column:reporting_dateb" json:"reporting_dateb" form:"reporting_dateb"`
980
+	DetectionResultb  string `gorm:"column:detection_resultb" json:"detection_resultb" form:"detection_resultb"`
981
+	Status            int64  `gorm:"column:status" json:"status" form:"status"`
982
+	UserOrgId         int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
983
+	Ctime             int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
984
+	Mtime             int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
985
+	BedId             int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
986
+	EquitmentId       int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
987
+	Bed               string `gorm:"column:bed" json:"bed" form:"bed"`
988
+	Sort              string `gorm:"column:sort" json:"sort" form:"sort"`
989
+	PassExamination   int64  `gorm:"column:pass_examination" json:"pass_examination" form:"pass_examination"`
990
+	Modifications     int64  `gorm:"column:modifications" json:"modifications" form:"modifications"`
991
+}
992
+
993
+func (XtDeviceWater) TableName() string {
994
+
995
+	return "xt_device_water"
996
+}
997
+
998
+type XtDevicePh struct {
999
+	ID                int64  `gorm:"column:id" json:"id" form:"id"`
1000
+	SamplingDate      int64  `gorm:"column:sampling_date" json:"sampling_date" form:"sampling_date"`
1001
+	Specimenb         int64  `gorm:"column:specimenb" json:"specimenb" form:"specimenb"`
1002
+	ConcentrateNoc    string `gorm:"column:concentrate_noc" json:"concentrate_noc" form:"concentrate_noc"`
1003
+	ConcentratebNod   string `gorm:"column:concentrateb_nod" json:"concentrateb_nod" form:"concentrateb_nod"`
1004
+	SamplingLocationb int64  `gorm:"column:sampling_locationb" json:"sampling_locationb" form:"sampling_locationb"`
1005
+	DetectionUnit     string `gorm:"column:detection_unit" json:"detection_unit" form:"detection_unit"`
1006
+	Samplerb          int64  `gorm:"column:samplerb" json:"samplerb" form:"samplerb"`
1007
+	ReportingDateb    int64  `gorm:"column:reporting_dateb" json:"reporting_dateb" form:"reporting_dateb"`
1008
+	DetectionResultb  string `gorm:"column:detection_resultb" json:"detection_resultb" form:"detection_resultb"`
1009
+	Status            int64  `gorm:"column:status" json:"status" form:"status"`
1010
+	UserOrgId         int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1011
+	Ctime             int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
1012
+	Mtime             int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
1013
+	BedId             int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
1014
+	EquitmentId       int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
1015
+	Bed               string `gorm:"column:bed" json:"bed" form:"bed"`
1016
+	Sort              string `gorm:"column:sort" json:"sort" form:"sort"`
1017
+	PassExamination   int64  `gorm:"column:pass_examination" json:"pass_examination" form:"pass_examination"`
1018
+	Modifications     int64  `gorm:"column:modifications" json:"modifications" form:"modifications"`
1019
+}
1020
+
1021
+func (XtDevicePh) TableName() string {
1022
+
1023
+	return "xt_device_ph"
1024
+}

+ 4 - 0
models/dialysis.go View File

@@ -355,6 +355,8 @@ type DoctorAdvices struct {
355 355
 	AnticoagulantShouji        float64         `gorm:"column:anticoagulant_shouji" json:"anticoagulant_shouji" form:"anticoagulant_shouji"`
356 356
 	AnticoagulantWeichi        float64         `gorm:"column:anticoagulant_weichi" json:"anticoagulant_weichi" form:"anticoagulant_weichi"`
357 357
 	AnticoagulantZongliang     float64         `gorm:"column:anticoagulant_zongliang" json:"anticoagulant_zongliang" form:"anticoagulant_zongliang"`
358
+	DialysisDialyszers         string          `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
359
+	DialysisIrrigation         string          `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
358 360
 }
359 361
 
360 362
 type DoctorAdvice struct {
@@ -683,6 +685,8 @@ type MonitoringRecord struct {
683 685
 	DialysateFlow             float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
684 686
 	Urr                       string  `gorm:"column:urr" json:"urr"`
685 687
 	BloodSugar                float64 `gorm:"column:blood_sugar" json:"blood_sugar" form:"blood_sugar"`
688
+	MonitorAnticoagulant      int64   `gorm:"column:monitor_anticoagulant" json:"monitor_anticoagulant" form:"monitor_anticoagulant"`
689
+	MonitorAnticoagulantValue string  `gorm:"column:monitor_anticoagulant_value" json:"monitor_anticoagulant_value" form:"monitor_anticoagulant_value"`
686 690
 }
687 691
 
688 692
 func (MonitoringRecord) TableName() string {

+ 1 - 0
models/drug.go View File

@@ -53,6 +53,7 @@ type BaseDrugLib struct {
53 53
 	DrugCode               string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
54 54
 	DoseCode               string  `gorm:"column:dose_code" json:"dose_code" form:"dose_code"`
55 55
 
56
+	Dealer int64 `gorm:"column:dealer" json:"dealer" form:"dealer"`
56 57
 	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
57 58
 }
58 59
 

+ 2 - 0
models/gobal_models.go View File

@@ -82,6 +82,8 @@ type SystemPrescription struct {
82 82
 	Ultrafiltration            float64 `gorm:"column:ultrafiltration" json:"ultrafiltration" form:"ultrafiltration"`
83 83
 	BodyFluidOther             string  `gorm:"column:body_fluid_other" json:"body_fluid_other" form:"body_fluid_other"`
84 84
 	TargetKtv                  float64 `gorm:"column:target_ktv" json:"target_ktv" form:"target_ktv"`
85
+	DialysisDialyszers         string  `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
86
+	DialysisIrrigation         string  `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
85 87
 }
86 88
 
87 89
 func (SystemPrescription) TableName() string {

+ 1 - 0
models/his_models.go View File

@@ -59,6 +59,7 @@ type XtHisProjectTeam struct {
59 59
 	CreatedTime int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
60 60
 	UpdatedTime int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
61 61
 	ProjectId   string  `gorm:"column:project_id" json:"project_id" form:"project_id"`
62
+	ItemId      string  `gorm:"column:item_id" json:"item_id" form:"item_id"`
62 63
 }
63 64
 
64 65
 func (XtHisProjectTeam) TableName() string {

+ 4 - 0
models/patient_models.go View File

@@ -246,6 +246,8 @@ type DialysisPrescriptionList struct {
246 246
 	DialyzerPerfusionApparatus string  `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus" form:"dialyzer_perfusion_apparatus"`
247 247
 	TargetUltrafiltration      float64 `gorm:"column:target_ultrafiltration" json:"target_ultrafiltration"`
248 248
 	BloodAccess                int64   `gorm:"column:blood_access" json:"blood_access"`
249
+	DialysisDialyszers         string  `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
250
+	DialysisIrrigation         string  `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
249 251
 }
250 252
 
251 253
 func (DialysisPrescriptionList) TableName() string {
@@ -325,6 +327,8 @@ type DialysisSolution struct {
325 327
 	DialyzerPerfusionApparatus string  `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus"`
326 328
 	BodyFluidOther             string  `gorm:"column:body_fluid_other" json:"body_fluid_other"`
327 329
 	TargetKtv                  float64 `gorm:"column:target_ktv" json:"target_ktv"`
330
+	DialysisDialyszers         string  `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
331
+	DialysisIrrigation         string  `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
328 332
 }
329 333
 
330 334
 func (DialysisSolution) TableName() string {

+ 79 - 0
models/user_models.go View File

@@ -335,6 +335,8 @@ type XtDialysisSolution struct {
335 335
 	Ultrafiltration            float64 `gorm:"column:ultrafiltration" json:"ultrafiltration" form:"ultrafiltration"`
336 336
 	BodyFluidOther             string  `gorm:"column:body_fluid_other" json:"body_fluid_other" form:"body_fluid_other"`
337 337
 	TargetKtv                  float64 `gorm:"column:target_ktv" json:"target_ktv" form:"target_ktv"`
338
+	DialysisDialyszers         string  `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
339
+	DialysisIrrigation         string  `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
338 340
 }
339 341
 
340 342
 func (XtDialysisSolution) TableName() string {
@@ -487,9 +489,86 @@ type XtPatientVascularAccess struct {
487 489
 	Ctime                  int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
488 490
 	Mtime                  int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
489 491
 	Modify                 int64  `gorm:"column:modify" json:"modify" form:"modify"`
492
+	StopTime               int64  `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
493
+	PatientId              int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
494
+	OtherVascular          string `gorm:"column:other_vascular" json:"other_vascular" form:"other_vascular"`
495
+	CiType                 int64  `gorm:"column:ci_type" json:"ci_type" form:"ci_type"`
496
+	BloodCultupe           int64  `gorm:"column:blood_cultupe" json:"blood_cultupe" form:"blood_cultupe"`
497
+	SequelaeType           int64  `gorm:"column:sequelae_type" json:"sequelae_type" form:"sequelae_type"`
490 498
 }
491 499
 
492 500
 func (XtPatientVascularAccess) TableName() string {
493 501
 
494 502
 	return "xt_patient_vascular_access"
495 503
 }
504
+
505
+type XtPatientPasswayAssessment struct {
506
+	ID            int64  `gorm:"column:id" json:"id" form:"id"`
507
+	StartTime     int64  `gorm:"column:start_time" json:"start_time" form:"start_time"`
508
+	Creator       int64  `gorm:"column:creator" json:"creator" form:"creator"`
509
+	BloodProject  string `gorm:"column:blood_project" json:"blood_project" form:"blood_project"`
510
+	BloodResult   string `gorm:"column:blood_result" json:"blood_result" form:"blood_result"`
511
+	BloodDealwith string `gorm:"column:blood_dealwith" json:"blood_dealwith" form:"blood_dealwith"`
512
+	Modify        int64  `gorm:"column:modify" json:"modify" form:"modify"`
513
+	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
514
+	PatientId     int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
515
+	ParentId      int64  `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
516
+	Status        int64  `gorm:"column:status" json:"status" form:"status"`
517
+	Ctime         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
518
+	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
519
+}
520
+
521
+func (XtPatientPasswayAssessment) TableName() string {
522
+
523
+	return "xt_patient_passway_assessment"
524
+}
525
+
526
+type XtAerialDetection struct {
527
+	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
528
+	StartTime           int64  `gorm:"column:start_time" json:"start_time" form:"start_time"`
529
+	CreatedTime         int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
530
+	Class               int64  `gorm:"column:class" json:"class" form:"class"`
531
+	DisinfectionMethods string `gorm:"column:disinfection_methods" json:"disinfection_methods" form:"disinfection_methods"`
532
+	DisinfectionFluid   string `gorm:"column:disinfection_fluid" json:"disinfection_fluid" form:"disinfection_fluid"`
533
+	Sort                string `gorm:"column:sort" json:"sort" form:"sort"`
534
+	Creator             int64  `gorm:"column:creator" json:"creator" form:"creator"`
535
+	DetectionTime       int64  `gorm:"column:detection_time" json:"detection_time" form:"detection_time"`
536
+	DetectionResult     string `gorm:"column:detection_result" json:"detection_result" form:"detection_result"`
537
+	UploadTime          int64  `gorm:"column:upload_time" json:"upload_time" form:"upload_time"`
538
+	CheckOut            int64  `gorm:"column:check_out" json:"check_out" form:"check_out"`
539
+	Modifications       int64  `gorm:"column:modifications" json:"modifications" form:"modifications"`
540
+	UserOrgId           int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
541
+	Ctime               int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
542
+	Mtime               int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
543
+	Status              int64  `gorm:"column:status" json:"status" form:"status"`
544
+}
545
+
546
+func (XtAerialDetection) TableName() string {
547
+
548
+	return "xt_aerial_detection"
549
+}
550
+
551
+type XtBodyDetection struct {
552
+	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
553
+	StartTime           int64  `gorm:"column:start_time" json:"start_time" form:"start_time"`
554
+	CreatedTime         int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
555
+	Class               int64  `gorm:"column:class" json:"class" form:"class"`
556
+	DisinfectionMethods string `gorm:"column:disinfection_methods" json:"disinfection_methods" form:"disinfection_methods"`
557
+	DisinfectionFluid   string `gorm:"column:disinfection_fluid" json:"disinfection_fluid" form:"disinfection_fluid"`
558
+	Sort                string `gorm:"column:sort" json:"sort" form:"sort"`
559
+	Creator             int64  `gorm:"column:creator" json:"creator" form:"creator"`
560
+	DetectionTime       int64  `gorm:"column:detection_time" json:"detection_time" form:"detection_time"`
561
+	DetectionResult     string `gorm:"column:detection_result" json:"detection_result" form:"detection_result"`
562
+	UploadTime          int64  `gorm:"column:upload_time" json:"upload_time" form:"upload_time"`
563
+	CheckOut            int64  `gorm:"column:check_out" json:"check_out" form:"check_out"`
564
+	Modifications       int64  `gorm:"column:modifications" json:"modifications" form:"modifications"`
565
+	UserOrgId           int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
566
+	Ctime               int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
567
+	Mtime               int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
568
+	Status              int64  `gorm:"column:status" json:"status" form:"status"`
569
+}
570
+
571
+func (XtBodyDetection) TableName() string {
572
+
573
+	return "xt_body_detection"
574
+}

+ 1 - 1
service/data.go View File

@@ -247,7 +247,7 @@ func FindConfigByTitleForUpdate(module string, title string, org_id int64, id in
247 247
 }
248 248
 
249 249
 func UpdateChildConfig(dataconfig *models.Dataconfig) (err error) {
250
-	err = readDb.Model(&models.Dataconfig{}).Where("id =?", dataconfig.ID).Update(map[string]interface{}{"name": dataconfig.Name, "update_time": dataconfig.UpdatedTime, "remark": dataconfig.Remark, "orders": dataconfig.Order}).Error
250
+	err = readDb.Model(&models.Dataconfig{}).Where("id =?", dataconfig.ID).Update(map[string]interface{}{"name": dataconfig.Name, "update_time": dataconfig.UpdatedTime, "remark": dataconfig.Remark, "orders": dataconfig.Order, "field_type": dataconfig.FieldType}).Error
251 251
 	return
252 252
 }
253 253
 

+ 26 - 1
service/dialysis_service.go View File

@@ -1122,7 +1122,7 @@ func UpdateDrugUserInfoDetails(drug_id int64, time int64, org_id int64, patient_
1122 1122
 }
1123 1123
 
1124 1124
 func FindDialysisBeforePrepare(patient_id int64, good_id int64, good_type_id int64, user_org_id int64, record_time int64) (count int64) {
1125
-	readDb.Model(&models.DialysisBeforePrepare{}).Where("user_org_id = ? AND patient_id = ?  AND good_id = ? AND good_type_id = ? AND record_date = ? AND status = 1", user_org_id, patient_id, good_id, good_type_id, record_time).Count(&count)
1125
+	readDb.Model(&models.DialysisBeforePrepare{}).Where("user_org_id = ? AND patient_id = ?  AND good_id = ? AND good_type_id = ? AND record_date = ? AND status = 1 AND count<> 0", user_org_id, patient_id, good_id, good_type_id, record_time).Count(&count)
1126 1126
 	return
1127 1127
 
1128 1128
 }
@@ -1148,3 +1148,28 @@ func SaveHisDoctorAdvice(advice *models.HisDoctorAdviceInfo) (err error) {
1148 1148
 	err = writeDb.Save(&advice).Error
1149 1149
 	return
1150 1150
 }
1151
+
1152
+func GetGoodInfoMation(orgid int64) (goodinfo []*models.GoodInfo, err error) {
1153
+
1154
+	err = XTReadDB().Model(&goodinfo).Where("org_id = ? and status = 1", orgid).Find(&goodinfo).Error
1155
+	return goodinfo, err
1156
+}
1157
+
1158
+func GetDialysisBeforePrepare(goodTypeId int64, goodId int64, orgid int64, patientId int64) (*models.DialysisBeforePrepare, error) {
1159
+
1160
+	prepare := models.DialysisBeforePrepare{}
1161
+	err := XTReadDB().Where("good_type_id = ? and good_id = ? and user_org_id = ? and status =1 and patient_id = ?", goodTypeId, goodId, orgid, patientId).Last(&prepare).Error
1162
+	if err == gorm.ErrRecordNotFound {
1163
+		return nil, err
1164
+	}
1165
+	if err != nil {
1166
+		return nil, err
1167
+	}
1168
+	return &prepare, nil
1169
+}
1170
+
1171
+func CreateDialysisBeforePrepareOne(prepare *models.DialysisBeforePrepare) error {
1172
+
1173
+	err := XTReadDB().Create(&prepare).Error
1174
+	return err
1175
+}

+ 3 - 3
service/drug_stock_service.go View File

@@ -35,9 +35,9 @@ func FindAllDrugByManufactureId(manufacturer_id int64, dealer_id int64, org_id i
35 35
 	if manufacturer_id > 0 {
36 36
 		db = db.Where("manufacturer = ?", manufacturer_id)
37 37
 	}
38
-	//if dealer_id > 0 {
39
-	//	db = db.Where("dealer = ?", dealer_id)
40
-	//}
38
+	if dealer_id > 0 {
39
+		db = db.Where("dealer = ?", dealer_id)
40
+	}
41 41
 	err = db.Preload("DrugSpecs", "status = 1 AND org_id = ? AND find_in_set('停用',drug_status) = 0", org_id).Group("drug_name").Find(&goodInfo).Error
42 42
 	return goodInfo, err
43 43
 }

+ 41 - 0
service/gobal_config_service.go View File

@@ -354,3 +354,44 @@ func GetDrugCancelOrder(startime int64, endtime int64, orgid int64, orderType in
354 354
 
355 355
 	return cancel, total, err
356 356
 }
357
+
358
+func FindPrintStockGoodInfoByType(types int, startTime int64, end_time int64, orgId int64) (list []*models.StockInfo, err error) {
359
+
360
+	db := XTReadDB().Model(&models.StockInfo{})
361
+	db = db.Where("xt_good_information.org_id = ? AND xt_good_information.status = 1", orgId)
362
+	if types == 1 {
363
+		db = db.Joins("JOIN xt_warehouse_info AS info ON info.good_id=xt_good_information.id AND info.status = 1 AND info.org_id = ?", orgId).Group("xt_good_information.id")
364
+		db = db.Preload("QueryWarehousingInfo", func(db *gorm.DB) *gorm.DB {
365
+			return db.Where("xt_warehouse_info.org_id = ? AND xt_warehouse_info.status = 1", orgId).Joins("JOIN xt_warehouse AS warehouse ON warehouse.id = xt_warehouse_info.warehousing_id AND warehouse.status = 1 AND warehouse.warehousing_time >=? AND warehouse.warehousing_time<= ? AND warehouse.org_id = ?", startTime, end_time, orgId)
366
+		})
367
+	} else if types == 2 {
368
+		db = db.Joins("JOIN xt_sales_return_info AS info ON info.good_id=xt_good_information.id AND info.status = 1 AND info.org_id = ?", orgId).Group("xt_good_information.id")
369
+		db = db.Preload("QuerySalesReturnInfo", func(db *gorm.DB) *gorm.DB {
370
+			return db.Where("xt_sales_return_info.org_id = ? AND xt_sales_return_info.status = 1", orgId).Joins("JOIN xt_sales_return AS sales ON sales.id = xt_sales_return_info.sales_return_id AND sales.status = 1 AND sales.return_time >=? AND sales.return_time<= ? AND sales.org_id = ?", startTime, end_time, orgId)
371
+		})
372
+
373
+	} else if types == 3 {
374
+		db = db.Joins("JOIN xt_warehouse_out_info AS info ON info.good_id=xt_good_information.id AND info.status = 1 AND info.org_id = ?", orgId).Group("xt_good_information.id")
375
+		db = db.Preload("QueryWarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
376
+			return db.Where("xt_warehouse_out_info.org_id = ? AND xt_warehouse_out_info.status = 1", orgId).Joins("JOIN xt_warehouse_out ON xt_warehouse_out.id = xt_warehouse_out_info.warehouse_out_id AND xt_warehouse_out.status = 1 AND xt_warehouse_out.warehouse_out_time >=? AND xt_warehouse_out.warehouse_out_time<= ? AND xt_warehouse_out.org_id = ? ", startTime, end_time, orgId)
377
+		})
378
+
379
+	} else if types == 4 {
380
+
381
+		db = db.Joins("JOIN xt_cancel_stock_info AS info ON info.good_id=xt_good_information.id AND info.status = 1 AND info.org_id = ?", orgId).Group("xt_good_information.id")
382
+		db = db.Preload("QueryCancelStockInfo", func(db *gorm.DB) *gorm.DB {
383
+			return db.Where("xt_cancel_stock_info.org_id = ? AND xt_cancel_stock_info.status = 1", orgId).Joins("JOIN xt_cancel_stock AS cancel ON cancel.id = xt_cancel_stock_info.cancel_stock_id AND cancel.status = 1 AND cancel.return_time >=? AND cancel.return_time<= ? AND cancel.org_id = ?", startTime, end_time, orgId)
384
+		})
385
+
386
+	}
387
+	db = db.Preload("GoodsType", "org_id = ? AND status = 1", orgId)
388
+	err = db.Order("ctime desc").Find(&list).Error
389
+	return
390
+}
391
+
392
+func GetOutStockTotalCountTwo(startime int64, endtime int64, orgid int64) (autoMatic []*models.NewXtAutomaticReduceDetail, err error) {
393
+
394
+	err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.record_time,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and x.record_time >= ? and x.record_time<=? and `status` = 1)  as b GROUP BY good_id", orgid, startime, endtime).Scan(&autoMatic).Error
395
+
396
+	return autoMatic, err
397
+}

+ 9 - 2
service/his_project_service.go View File

@@ -107,7 +107,7 @@ func GetProjectTeamDetail(id int64) (models.XtHisProjectTeam, error) {
107 107
 
108 108
 func UpdatedProjectTeam(id int64, team *models.XtHisProjectTeam) error {
109 109
 
110
-	err := XTWriteDB().Model(&team).Where("id=? and status = 1", id).Updates(map[string]interface{}{"project_team": team.ProjectTeam, "price": team.Price, "pinyin": team.Pinyin, "wubi": team.Wubi, "tube_color": team.TubeColor, "team_type": team.TeamType, "remark": team.Remark, "project_id": team.ProjectId}).Error
110
+	err := XTWriteDB().Model(&team).Where("id=? and status = 1", id).Updates(map[string]interface{}{"project_team": team.ProjectTeam, "price": team.Price, "pinyin": team.Pinyin, "wubi": team.Wubi, "tube_color": team.TubeColor, "team_type": team.TeamType, "remark": team.Remark, "project_id": team.ProjectId, "item_id": team.ItemId}).Error
111 111
 	return err
112 112
 }
113 113
 
@@ -305,7 +305,7 @@ func GetHisPatientHistory(keyword string, startime int64, endtime int64, registt
305 305
 		db = db.Where("x.user_org_id = ?", orgid)
306 306
 	}
307 307
 	db = db.Preload("HisOrder", "status = 1 AND user_org_id = ?", orgid)
308
-	err = db.Select("x.id,x.balance_accounts_type,x.medical_insurance_number,x.name,x.gender,x.id_type,x.medical_treatment_type,x.birthday,x.record_date,x.age,x.phone_number,x.id_card_no,x.register_type,x.admin_user_id,x.departments,x.is_need_cost_of_production,x.register_cost,x.treatment_cost,x.cost_of_production,x.total,x.user_org_id,x.patient_id,x.number,x.is_return,x.doctor,x.ctime,x.social_type,x.phone").Count(&total).Offset(offset).Limit(limit).Order("x.id desc").Find(&hisPatient).Error
308
+	err = db.Select("x.id,x.balance_accounts_type,x.medical_insurance_number,x.name,x.gender,x.id_type,x.medical_treatment_type,x.birthday,x.record_date,x.age,x.phone_number,x.id_card_no,x.register_type,x.admin_user_id,x.departments,x.is_need_cost_of_production,x.register_cost,x.treatment_cost,x.cost_of_production,x.total,x.user_org_id,x.patient_id,x.number,x.is_return,x.doctor,x.ctime,x.social_type,x.phone,x.status").Count(&total).Offset(offset).Limit(limit).Order("x.id desc").Find(&hisPatient).Error
309 309
 	return hisPatient, total, err
310 310
 }
311 311
 
@@ -684,3 +684,10 @@ func GetProjectHisList(orgid int64) (hisProjectList []*models.XtHisProjectList,
684 684
 	error = XTReadDB().Model(&hisProjectList).Where("user_org_id = ? and status = 1", orgid).Group("project_id").Find(&hisProjectList).Error
685 685
 	return hisProjectList, error
686 686
 }
687
+
688
+func GetLastItem(orgid int64) (models.XtHisProjectList, error) {
689
+
690
+	list := models.XtHisProjectList{}
691
+	err := XTReadDB().Model(&list).Where("user_org_id = ? and status = 1", orgid).Last(&list).Error
692
+	return list, err
693
+}

+ 7 - 1
service/inspection_service.go View File

@@ -139,7 +139,7 @@ func GetPatientInspections(orgId, patientId, projectId, page int64) (inspections
139 139
 	}
140 140
 
141 141
 	var Id models.InspectionDate
142
-	err = readDb.Model(&models.Inspection{}).Where("patient_id=? and org_id=? and project_id=? and status=1", patientId, orgId, projectId).Select("inspect_date").Group("inspect_date").Order("inspect_date desc").Offset(page - 1).Limit(1).Scan(&Id).Error
142
+	err = readDb.Model(&models.Inspection{}).Where("patient_id=? and org_id=? and project_id=? and status=1", patientId, orgId, projectId).Select("inspect_date").Group("inspect_date").Order("created_time desc").Offset(page - 1).Limit(1).Scan(&Id).Error
143 143
 	if err != nil {
144 144
 		return
145 145
 	}
@@ -211,3 +211,9 @@ func GetAllInspectionReference(orgId int64) (inspectionReference []*models.Inspe
211 211
 	err = readDb.Model(&models.InspectionReference{}).Where("org_id = ? AND status = 1", orgId).Find(&inspectionReference).Error
212 212
 	return
213 213
 }
214
+
215
+func GetInspectionReferenceByOrgId(orgid int64) (insepciton []*models.XtInspectionReference, err error) {
216
+
217
+	err = readDb.Model(&insepciton).Where("org_id = ? and status = 1 and project_name = '传染病检查'", orgid).Find(&insepciton).Error
218
+	return insepciton, err
219
+}

+ 333 - 28
service/manage_service.go View File

@@ -448,7 +448,7 @@ func GetAllCulture(orgId int64) (cultures []*models.DeviceCultures, err error) {
448 448
 	if orgId > 0 {
449 449
 		db = db.Where("x.user_org_id = ?", orgId)
450 450
 	}
451
-	err = db.Group("x.id").Select("x.id,x.speling_date,x.specimen,x.concentrate_noa,x.concentrate_nob,x.sampling_locationa,x.detection_unit,x.sampler,x.reporting_date,x.detection_result,x.bed_id,x.bed,r.user_name").Joins("Left Join sgj_user_admin_role as r on r.admin_user_id = x.sampler").Scan(&cultures).Error
451
+	err = db.Group("x.id").Select("x.id,x.speling_date,x.specimen,x.concentrate_noa,x.concentrate_nob,x.sampling_locationa,x.detection_unit,x.sampler,x.reporting_date,x.detection_result,x.bed_id,x.bed,x.sort,x.pass_examination,x.modifications,r.user_name").Joins("Left Join sgj_user_admin_role as r on r.admin_user_id = x.sampler").Scan(&cultures).Error
452 452
 	return cultures, err
453 453
 }
454 454
 
@@ -459,7 +459,7 @@ func GetAllDialysate(orgId int64) (dialysate []*models.DeviceDialysates, err err
459 459
 	if orgId > 0 {
460 460
 		db = db.Where("x.user_org_id = ?", orgId)
461 461
 	}
462
-	err = db.Group("x.id").Select("x.id,x.sampling_date,x.specimenb,x.concentrate_noc,x.concentrateb_nod,x.sampling_locationb,x.detection_unit,x.samplerb,x.reporting_dateb,x.detection_resultb,x.bed_id,x.bed,r.user_name").Joins("Left Join sgj_user_admin_role as r on r.admin_user_id = x.samplerb").Scan(&dialysate).Error
462
+	err = db.Group("x.id").Select("x.id,x.sampling_date,x.specimenb,x.concentrate_noc,x.concentrateb_nod,x.sampling_locationb,x.detection_unit,x.samplerb,x.reporting_dateb,x.detection_resultb,x.bed_id,x.bed,x.sort,x.pass_examination,x.modifications,r.user_name").Joins("Left Join sgj_user_admin_role as r on r.admin_user_id = x.samplerb").Scan(&dialysate).Error
463 463
 
464 464
 	return dialysate, err
465 465
 }
@@ -471,7 +471,7 @@ func GetAllDeviceIon(orgId int64) (ions []*models.DeviceIons, err error) {
471 471
 	if orgId > 0 {
472 472
 		db = db.Where("x.user_org_id = ?", orgId)
473 473
 	}
474
-	err = db.Group("x.id").Select("x.id,x.sampling_date,x.samplerc,x.detection_unit,x.concentrate_nof,x.concentrate_nog,x.date_reportc,x.actual_na,x.actual_pna,x.actual_k,x.actual_ca,x.actual_ci,x.actual_hco,x.actual_mg,x.actual_ph,x.remakes,x.bed_id,x.bed,r.user_name").Joins("Left Join sgj_user_admin_role as r on r.admin_user_id = x.samplerc").Scan(&ions).Error
474
+	err = db.Group("x.id").Select("x.id,x.sampling_date,x.samplerc,x.detection_unit,x.concentrate_nof,x.concentrate_nog,x.date_reportc,x.actual_na,x.actual_pna,x.actual_k,x.actual_ca,x.actual_ci,x.actual_hco,x.actual_mg,x.actual_ph,x.remakes,x.bed_id,x.bed,x.sort,x.pass_examination,x.modifications,r.user_name").Joins("Left Join sgj_user_admin_role as r on r.admin_user_id = x.samplerc").Scan(&ions).Error
475 475
 	return ions, err
476 476
 }
477 477
 
@@ -489,7 +489,7 @@ func GetSampler(id int64) (models.App_Role, error) {
489 489
 
490 490
 func UpdateCulture(id int64, orgid int64, culture *models.DeviceCulture) error {
491 491
 
492
-	err := writeUserDb.Model(&culture).Where("id= ? AND user_org_id = ? AND status = ?", id, orgid, 1).Updates(map[string]interface{}{"speling_date": culture.SpelingDate, "specimen": culture.Specimen, "concentrate_noa": culture.ConcentrateNoa, "concentrate_nob": culture.ConcentrateNob, "sampling_locationa": culture.SamplingLocationa, "detection_unit": culture.DetectionUnit, "sampler": culture.Sampler, "reporting_date": culture.ReportingDate, "detection_result": culture.DetectionResult, "mtime": time.Now().Unix()}).Error
492
+	err := writeUserDb.Model(&culture).Where("id= ? AND user_org_id = ? AND status = ?", id, orgid, 1).Updates(map[string]interface{}{"speling_date": culture.SpelingDate, "specimen": culture.Specimen, "concentrate_noa": culture.ConcentrateNoa, "concentrate_nob": culture.ConcentrateNob, "sampling_locationa": culture.SamplingLocationa, "detection_unit": culture.DetectionUnit, "sampler": culture.Sampler, "reporting_date": culture.ReportingDate, "detection_result": culture.DetectionResult, "sort": culture.Sort, "pass_examination": culture.PassExamination, "modifications": culture.Modifications, "mtime": time.Now().Unix()}).Error
493 493
 	return err
494 494
 }
495 495
 
@@ -518,7 +518,7 @@ func GetDialystate(id int64) (models.DeviceDialysate, error) {
518 518
 
519 519
 func Updatedialystate(id int64, orgid int64, dialysate *models.DeviceDialysate) error {
520 520
 
521
-	err := writeUserDb.Model(&dialysate).Where("id=? AND user_org_id = ? AND status = 1", id, orgid).Updates(map[string]interface{}{"sampling_date": dialysate.SamplingDate, "specimenb": dialysate.Specimenb, "concentrate_noc": dialysate.ConcentrateNoc, "concentrateb_nod": dialysate.ConcentratebNod, "sampling_locationb": dialysate.SamplingLocationb, "detection_unit": dialysate.DetectionUnit, "samplerb": dialysate.Samplerb, "reporting_dateb": dialysate.ReportingDateb, "detection_resultb": dialysate.DetectionResultb, "mtime": time.Now().Unix()}).Error
521
+	err := writeUserDb.Model(&dialysate).Where("id=? AND user_org_id = ? AND status = 1", id, orgid).Updates(map[string]interface{}{"sampling_date": dialysate.SamplingDate, "specimenb": dialysate.Specimenb, "concentrate_noc": dialysate.ConcentrateNoc, "concentrateb_nod": dialysate.ConcentratebNod, "sampling_locationb": dialysate.SamplingLocationb, "detection_unit": dialysate.DetectionUnit, "samplerb": dialysate.Samplerb, "reporting_dateb": dialysate.ReportingDateb, "detection_resultb": dialysate.DetectionResultb, "sort": dialysate.Sort, "pass_examination": dialysate.PassExamination, "modifications": dialysate.Modifications, "mtime": time.Now().Unix()}).Error
522 522
 	return err
523 523
 }
524 524
 
@@ -548,7 +548,7 @@ func GetIon(id int64) (models.DeviceIon, error) {
548 548
 
549 549
 func UpdateIon(id int64, orgid int64, ion *models.DeviceIon) error {
550 550
 
551
-	err := writeUserDb.Model(&ion).Where("id = ? AND user_org_id = ? AND status = 1", id, orgid).Updates(map[string]interface{}{"sampling_date": ion.SamplingDate, "samplerc": ion.Samplerc, "detection_unit": ion.DetectionUnit, "concentrate_nof": ion.ConcentrateNof, "concentrate_nog": ion.ConcentrateNog, "date_reportc": ion.DateReportc, "actual_na": ion.ActualNa, "actual_pna": ion.ActualPna, "actual_k": ion.ActualK, "actual_ca": ion.ActualCa, "actual_ci": ion.ActualCi, "actual_hco": ion.ActualCi, "actual_mg": ion.ActualMg, "actual_ph": ion.ActualPh, "remakes": ion.Remakes, "mtime": time.Now().Unix()}).Error
551
+	err := writeUserDb.Model(&ion).Where("id = ? AND user_org_id = ? AND status = 1", id, orgid).Updates(map[string]interface{}{"sampling_date": ion.SamplingDate, "samplerc": ion.Samplerc, "detection_unit": ion.DetectionUnit, "concentrate_nof": ion.ConcentrateNof, "concentrate_nog": ion.ConcentrateNog, "date_reportc": ion.DateReportc, "actual_na": ion.ActualNa, "actual_pna": ion.ActualPna, "actual_k": ion.ActualK, "actual_ca": ion.ActualCa, "actual_ci": ion.ActualCi, "actual_hco": ion.ActualCi, "actual_mg": ion.ActualMg, "actual_ph": ion.ActualPh, "remakes": ion.Remakes, "sort": ion.Sort, "pass_examination": ion.PassExamination, "modifications": ion.Modifications, "mtime": time.Now().Unix()}).Error
552 552
 	return err
553 553
 }
554 554
 
@@ -588,28 +588,6 @@ func GetCultureData(bedid int64, start int64, end int64, orgId int64) (cultures
588 588
 	return cultures, err
589 589
 }
590 590
 
591
-func GetDialysateData(bedid int64, start int64, end int64, orgId int64) (dialysate []*models.DeviceDialysates, err error) {
592
-	db := UserReadDB().Table("xt_device_dialysate as x").Where("x.status = 1")
593
-	table := UserReadDB().Table("sgj_user_admin_role as r")
594
-	fmt.Println("table", table)
595
-	if orgId > 0 {
596
-		db = db.Where("x.user_org_id = ?", orgId)
597
-	}
598
-	if bedid > 0 {
599
-		db = db.Where("x.bed_id = ?", bedid)
600
-	}
601
-	if start > 0 {
602
-		db = db.Where("x.sampling_date >= ?", start)
603
-	}
604
-	if end > 0 {
605
-		db = db.Where("x.sampling_date <= ?", end)
606
-	}
607
-
608
-	err = db.Group("x.id").Select("x.id,x.sampling_date,x.specimenb,x.concentrate_noc,x.concentrateb_nod,x.sampling_locationb,x.detection_unit,x.samplerb,x.reporting_dateb,x.detection_resultb,x.bed_id,x.bed,r.user_name").Joins("Left Join sgj_user_admin_role as r on r.admin_user_id = x.samplerb").Scan(&dialysate).Error
609
-
610
-	return dialysate, err
611
-}
612
-
613 591
 func GetDeviceIonData(bedid int64, start int64, end int64, orgId int64) (ions []*models.DeviceIons, err error) {
614 592
 	db := UserReadDB().Table("xt_device_ion as x").Where("x.status = 1")
615 593
 	table := UserReadDB().Table("sgj_user_admin_role as r")
@@ -1236,3 +1214,330 @@ func DeleteEquit(id int64) (models.DeviceAddmacher, error) {
1236 1214
 	err := UserWriteDB().Model(&addmacher).Where("id=?", id).Updates(map[string]interface{}{"status": 0}).Error
1237 1215
 	return addmacher, err
1238 1216
 }
1217
+
1218
+func GetDeviceInfomation(orgid int64, scheduledate int64) (information []*models.DeviceInformation, err error) {
1219
+
1220
+	err = UserReadDB().Model(&information).Where("user_org_id = ? and date = ? and status =1", orgid, scheduledate).Find(&information).Error
1221
+	return information, err
1222
+}
1223
+
1224
+func CreateOxygenates(oxygenates *models.XtDeviceOxygenates) error {
1225
+
1226
+	err := UserWriteDB().Create(&oxygenates).Error
1227
+	return err
1228
+}
1229
+
1230
+func CreateHadWater(hadwater *models.XtDeviceHadwater) error {
1231
+
1232
+	err := UserWriteDB().Create(&hadwater).Error
1233
+	return err
1234
+}
1235
+
1236
+func CreateWater(water *models.XtDeviceWater) error {
1237
+
1238
+	err := UserWriteDB().Create(&water).Error
1239
+	return err
1240
+}
1241
+
1242
+func CreateDevicePh(ph *models.XtDevicePh) error {
1243
+
1244
+	err := UserWriteDB().Create(&ph).Error
1245
+	return err
1246
+}
1247
+
1248
+func GetAllDeviceOxygenates(orgId int64) (dialysate []*models.DeviceDialysates, err error) {
1249
+	db := UserReadDB().Table("xt_device_oxygenates as x").Where("x.status = 1")
1250
+	table := UserReadDB().Table("sgj_user_admin_role as r")
1251
+	fmt.Println("table", table)
1252
+	if orgId > 0 {
1253
+		db = db.Where("x.user_org_id = ?", orgId)
1254
+	}
1255
+	err = db.Group("x.id").Select("x.id,x.sampling_date,x.specimenb,x.concentrate_noc,x.concentrateb_nod,x.sampling_locationb,x.detection_unit,x.samplerb,x.reporting_dateb,x.detection_resultb,x.bed_id,x.bed,x.sort,x.pass_examination,x.modifications,r.user_name").Joins("Left Join sgj_user_admin_role as r on r.admin_user_id = x.samplerb").Scan(&dialysate).Error
1256
+
1257
+	return dialysate, err
1258
+}
1259
+
1260
+func GetAllHadWater(orgId int64) (dialysate []*models.DeviceDialysates, err error) {
1261
+	db := UserReadDB().Table("xt_device_hadwater as x").Where("x.status = 1")
1262
+	table := UserReadDB().Table("sgj_user_admin_role as r")
1263
+	fmt.Println("table", table)
1264
+	if orgId > 0 {
1265
+		db = db.Where("x.user_org_id = ?", orgId)
1266
+	}
1267
+	err = db.Group("x.id").Select("x.id,x.sampling_date,x.specimenb,x.concentrate_noc,x.concentrateb_nod,x.sampling_locationb,x.detection_unit,x.samplerb,x.reporting_dateb,x.detection_resultb,x.bed_id,x.bed,x.sort,x.pass_examination,x.modifications,r.user_name").Joins("Left Join sgj_user_admin_role as r on r.admin_user_id = x.samplerb").Scan(&dialysate).Error
1268
+
1269
+	return dialysate, err
1270
+}
1271
+
1272
+func GetDeviceWater(orgId int64) (dialysate []*models.DeviceDialysates, err error) {
1273
+	db := UserReadDB().Table("xt_device_water as x").Where("x.status = 1")
1274
+	table := UserReadDB().Table("sgj_user_admin_role as r")
1275
+	fmt.Println("table", table)
1276
+	if orgId > 0 {
1277
+		db = db.Where("x.user_org_id = ?", orgId)
1278
+	}
1279
+	err = db.Group("x.id").Select("x.id,x.sampling_date,x.specimenb,x.concentrate_noc,x.concentrateb_nod,x.sampling_locationb,x.detection_unit,x.samplerb,x.reporting_dateb,x.detection_resultb,x.bed_id,x.bed,x.sort,x.pass_examination,x.modifications,r.user_name").Joins("Left Join sgj_user_admin_role as r on r.admin_user_id = x.samplerb").Scan(&dialysate).Error
1280
+
1281
+	return dialysate, err
1282
+}
1283
+
1284
+func GetDevicePH(orgId int64) (dialysate []*models.DeviceDialysates, err error) {
1285
+	db := UserReadDB().Table("xt_device_ph as x").Where("x.status = 1")
1286
+	table := UserReadDB().Table("sgj_user_admin_role as r")
1287
+	fmt.Println("table", table)
1288
+	if orgId > 0 {
1289
+		db = db.Where("x.user_org_id = ?", orgId)
1290
+	}
1291
+	err = db.Group("x.id").Select("x.id,x.sampling_date,x.specimenb,x.concentrate_noc,x.concentrateb_nod,x.sampling_locationb,x.detection_unit,x.samplerb,x.reporting_dateb,x.detection_resultb,x.bed_id,x.bed,x.sort,x.pass_examination,x.modifications,r.user_name").Joins("Left Join sgj_user_admin_role as r on r.admin_user_id = x.samplerb").Scan(&dialysate).Error
1292
+
1293
+	return dialysate, err
1294
+}
1295
+
1296
+func GetDialysateData(bedid int64, start int64, end int64, orgId int64) (dialysate []*models.DeviceDialysates, err error) {
1297
+	db := UserReadDB().Table("xt_device_dialysate as x").Where("x.status = 1")
1298
+	table := UserReadDB().Table("sgj_user_admin_role as r")
1299
+	fmt.Println("table", table)
1300
+	if orgId > 0 {
1301
+		db = db.Where("x.user_org_id = ?", orgId)
1302
+	}
1303
+	if bedid > 0 {
1304
+		db = db.Where("x.bed_id = ?", bedid)
1305
+	}
1306
+	if start > 0 {
1307
+		db = db.Where("x.sampling_date >= ?", start)
1308
+	}
1309
+	if end > 0 {
1310
+		db = db.Where("x.sampling_date <= ?", end)
1311
+	}
1312
+
1313
+	err = db.Group("x.id").Select("x.id,x.sampling_date,x.specimenb,x.concentrate_noc,x.concentrateb_nod,x.sampling_locationb,x.detection_unit,x.samplerb,x.reporting_dateb,x.detection_resultb,x.bed_id,x.bed,r.user_name").Joins("Left Join sgj_user_admin_role as r on r.admin_user_id = x.samplerb").Scan(&dialysate).Error
1314
+
1315
+	return dialysate, err
1316
+}
1317
+
1318
+func GetOxygenates(bedid int64, start int64, end int64, orgId int64) (dialysate []*models.DeviceDialysates, err error) {
1319
+	db := UserReadDB().Table("xt_device_oxygenates as x").Where("x.status = 1")
1320
+	table := UserReadDB().Table("sgj_user_admin_role as r")
1321
+	fmt.Println("table", table)
1322
+	if orgId > 0 {
1323
+		db = db.Where("x.user_org_id = ?", orgId)
1324
+	}
1325
+	if bedid > 0 {
1326
+		db = db.Where("x.bed_id = ?", bedid)
1327
+	}
1328
+	if start > 0 {
1329
+		db = db.Where("x.sampling_date >= ?", start)
1330
+	}
1331
+	if end > 0 {
1332
+		db = db.Where("x.sampling_date <= ?", end)
1333
+	}
1334
+
1335
+	err = db.Group("x.id").Select("x.id,x.sampling_date,x.specimenb,x.concentrate_noc,x.concentrateb_nod,x.sampling_locationb,x.detection_unit,x.samplerb,x.reporting_dateb,x.detection_resultb,x.bed_id,x.bed,r.user_name").Joins("Left Join sgj_user_admin_role as r on r.admin_user_id = x.samplerb").Scan(&dialysate).Error
1336
+
1337
+	return dialysate, err
1338
+}
1339
+
1340
+func GetHardWater(bedid int64, start int64, end int64, orgId int64) (dialysate []*models.DeviceDialysates, err error) {
1341
+	db := UserReadDB().Table("xt_device_hadwater as x").Where("x.status = 1")
1342
+	table := UserReadDB().Table("sgj_user_admin_role as r")
1343
+	fmt.Println("table", table)
1344
+	if orgId > 0 {
1345
+		db = db.Where("x.user_org_id = ?", orgId)
1346
+	}
1347
+	if bedid > 0 {
1348
+		db = db.Where("x.bed_id = ?", bedid)
1349
+	}
1350
+	if start > 0 {
1351
+		db = db.Where("x.sampling_date >= ?", start)
1352
+	}
1353
+	if end > 0 {
1354
+		db = db.Where("x.sampling_date <= ?", end)
1355
+	}
1356
+
1357
+	err = db.Group("x.id").Select("x.id,x.sampling_date,x.specimenb,x.concentrate_noc,x.concentrateb_nod,x.sampling_locationb,x.detection_unit,x.samplerb,x.reporting_dateb,x.detection_resultb,x.bed_id,x.bed,r.user_name").Joins("Left Join sgj_user_admin_role as r on r.admin_user_id = x.samplerb").Scan(&dialysate).Error
1358
+
1359
+	return dialysate, err
1360
+}
1361
+
1362
+func GetWater(bedid int64, start int64, end int64, orgId int64) (dialysate []*models.DeviceDialysates, err error) {
1363
+	db := UserReadDB().Table("xt_device_water as x").Where("x.status = 1")
1364
+	table := UserReadDB().Table("sgj_user_admin_role as r")
1365
+	fmt.Println("table", table)
1366
+	if orgId > 0 {
1367
+		db = db.Where("x.user_org_id = ?", orgId)
1368
+	}
1369
+	if bedid > 0 {
1370
+		db = db.Where("x.bed_id = ?", bedid)
1371
+	}
1372
+	if start > 0 {
1373
+		db = db.Where("x.sampling_date >= ?", start)
1374
+	}
1375
+	if end > 0 {
1376
+		db = db.Where("x.sampling_date <= ?", end)
1377
+	}
1378
+
1379
+	err = db.Group("x.id").Select("x.id,x.sampling_date,x.specimenb,x.concentrate_noc,x.concentrateb_nod,x.sampling_locationb,x.detection_unit,x.samplerb,x.reporting_dateb,x.detection_resultb,x.bed_id,x.bed,r.user_name").Joins("Left Join sgj_user_admin_role as r on r.admin_user_id = x.samplerb").Scan(&dialysate).Error
1380
+
1381
+	return dialysate, err
1382
+}
1383
+
1384
+func GetDevicePh(bedid int64, start int64, end int64, orgId int64) (dialysate []*models.DeviceDialysates, err error) {
1385
+	db := UserReadDB().Table("xt_device_ph as x").Where("x.status = 1")
1386
+	table := UserReadDB().Table("sgj_user_admin_role as r")
1387
+	fmt.Println("table", table)
1388
+	if orgId > 0 {
1389
+		db = db.Where("x.user_org_id = ?", orgId)
1390
+	}
1391
+	if bedid > 0 {
1392
+		db = db.Where("x.bed_id = ?", bedid)
1393
+	}
1394
+	if start > 0 {
1395
+		db = db.Where("x.sampling_date >= ?", start)
1396
+	}
1397
+	if end > 0 {
1398
+		db = db.Where("x.sampling_date <= ?", end)
1399
+	}
1400
+
1401
+	err = db.Group("x.id").Select("x.id,x.sampling_date,x.specimenb,x.concentrate_noc,x.concentrateb_nod,x.sampling_locationb,x.detection_unit,x.samplerb,x.reporting_dateb,x.detection_resultb,x.bed_id,x.bed,r.user_name").Joins("Left Join sgj_user_admin_role as r on r.admin_user_id = x.samplerb").Scan(&dialysate).Error
1402
+
1403
+	return dialysate, err
1404
+}
1405
+
1406
+func GetOxygenatesById(id int64) (models.XtDeviceOxygenates, error) {
1407
+	oxygenates := models.XtDeviceOxygenates{}
1408
+	err := UserReadDB().Model(&oxygenates).Where("id = ? and status = 1", id).Find(&oxygenates).Error
1409
+	return oxygenates, err
1410
+}
1411
+
1412
+func UpdateOxygenates(id int64, orgid int64, dialysate *models.XtDeviceOxygenates) error {
1413
+	err := writeUserDb.Model(&dialysate).Where("id=? AND user_org_id = ? AND status = 1", id, orgid).Updates(map[string]interface{}{"sampling_date": dialysate.SamplingDate, "specimenb": dialysate.Specimenb, "concentrate_noc": dialysate.ConcentrateNoc, "concentrateb_nod": dialysate.ConcentratebNod, "sampling_locationb": dialysate.SamplingLocationb, "detection_unit": dialysate.DetectionUnit, "samplerb": dialysate.Samplerb, "reporting_dateb": dialysate.ReportingDateb, "detection_resultb": dialysate.DetectionResultb, "sort": dialysate.Sort, "pass_examination": dialysate.PassExamination, "modifications": dialysate.Modifications, "mtime": time.Now().Unix()}).Error
1414
+	return err
1415
+}
1416
+
1417
+func GetHardWaterById(id int64) (models.XtDeviceHadwater, error) {
1418
+	hadwater := models.XtDeviceHadwater{}
1419
+	err := UserReadDB().Model(&hadwater).Where("id = ? and status = 1", id).Find(&hadwater).Error
1420
+	return hadwater, err
1421
+}
1422
+
1423
+func GetWaterById(id int64) (models.XtDeviceWater, error) {
1424
+
1425
+	water := models.XtDeviceWater{}
1426
+	err := UserReadDB().Model(&water).Where("id=? and status =1", id).Find(&water).Error
1427
+	return water, err
1428
+}
1429
+
1430
+func GetDevicePhById(id int64) (models.XtDevicePh, error) {
1431
+
1432
+	devicePh := models.XtDevicePh{}
1433
+	err := UserReadDB().Model(&devicePh).Where("id = ? and status =1", id).Find(&devicePh).Error
1434
+	return devicePh, err
1435
+}
1436
+
1437
+func CreateAerialDetection(detection *models.XtAerialDetection) error {
1438
+
1439
+	err := XTWriteDB().Create(&detection).Error
1440
+	return err
1441
+}
1442
+
1443
+func GetAirList(limit int64, page int64, orgid int64) (airlist []*models.XtAerialDetection, total int64, err error) {
1444
+	offset := (page - 1) * limit
1445
+	err = XTReadDB().Model(&airlist).Where("user_org_id = ? and status =1", orgid).Count(&total).Limit(limit).Offset(offset).Order("created_time desc").Find(&airlist).Error
1446
+	return airlist, total, err
1447
+}
1448
+
1449
+func GetAirDisinfectDetail(id int64) (models.XtAerialDetection, error) {
1450
+
1451
+	detection := models.XtAerialDetection{}
1452
+	err := XTReadDB().Model(&detection).Where("id = ? and status = 1", id).Find(&detection).Error
1453
+	return detection, err
1454
+}
1455
+
1456
+func UpdateAeriaDetection(detection *models.XtAerialDetection, id int64) error {
1457
+
1458
+	err := XTWriteDB().Model(&detection).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"start_time": detection.StartTime, "created_time": detection.CreatedTime, "class": detection.Class, "disinfection_methods": detection.DisinfectionMethods, "disinfection_fluid": detection.DisinfectionFluid, "sort": detection.Sort, "creator": detection.Creator, "detection_time": detection.DetectionTime, "detection_result": detection.DetectionResult, "upload_time": detection.UploadTime, "check_out": detection.CheckOut, "modifications": detection.Modifications}).Error
1459
+	return err
1460
+}
1461
+
1462
+func DeleteAirDisinfect(id int64) error {
1463
+	detection := models.XtAerialDetection{}
1464
+	err := XTWriteDB().Model(&detection).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
1465
+	return err
1466
+}
1467
+
1468
+func SaveBodyDetection(detection *models.XtBodyDetection) error {
1469
+
1470
+	err := XTWriteDB().Create(&detection).Error
1471
+	return err
1472
+}
1473
+
1474
+func GetBodyList(limit int64, page int64, orgid int64) (body []*models.XtBodyDetection, total int64, err error) {
1475
+
1476
+	offset := (page - 1) * limit
1477
+	err = XTReadDB().Model(&body).Where("user_org_id = ? and status =1", orgid).Count(&total).Limit(limit).Offset(offset).Order("created_time desc").Find(&body).Error
1478
+	return body, total, err
1479
+
1480
+}
1481
+
1482
+func GetBodyDisinfectDetail(id int64) (models.XtBodyDetection, error) {
1483
+
1484
+	detection := models.XtBodyDetection{}
1485
+	err := XTReadDB().Model(&detection).Where("id = ? and status = 1", id).Find(&detection).Error
1486
+	return detection, err
1487
+}
1488
+
1489
+func UpdateBodyDetection(detection *models.XtBodyDetection, id int64) error {
1490
+
1491
+	err := XTWriteDB().Model(&detection).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"start_time": detection.StartTime, "created_time": detection.CreatedTime, "class": detection.Class, "disinfection_methods": detection.DisinfectionMethods, "disinfection_fluid": detection.DisinfectionFluid, "sort": detection.Sort, "creator": detection.Creator, "detection_time": detection.DetectionTime, "detection_result": detection.DetectionResult, "upload_time": detection.UploadTime, "check_out": detection.CheckOut, "modifications": detection.Modifications}).Error
1492
+	return err
1493
+}
1494
+
1495
+func DeleteBodyDisInfect(id int64) error {
1496
+
1497
+	detection := models.XtBodyDetection{}
1498
+	err := XTWriteDB().Model(&detection).Where("id = ?  and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
1499
+	return err
1500
+}
1501
+
1502
+func UpdateHadWater(id int64, orgid int64, hadwater *models.XtDeviceHadwater) error {
1503
+
1504
+	err := writeUserDb.Model(&hadwater).Where("id=? AND user_org_id = ? AND status = 1", id, orgid).Updates(map[string]interface{}{"sampling_date": hadwater.SamplingDate, "specimenb": hadwater.Specimenb, "concentrate_noc": hadwater.ConcentrateNoc, "concentrateb_nod": hadwater.ConcentratebNod, "sampling_locationb": hadwater.SamplingLocationb, "detection_unit": hadwater.DetectionUnit, "samplerb": hadwater.Samplerb, "reporting_dateb": hadwater.ReportingDateb, "detection_resultb": hadwater.DetectionResultb, "sort": hadwater.Sort, "pass_examination": hadwater.PassExamination, "modifications": hadwater.Modifications, "mtime": time.Now().Unix()}).Error
1505
+	return err
1506
+}
1507
+
1508
+func UpdateDeviceWater(id int64, orgid int64, hadwater *models.XtDeviceWater) error {
1509
+
1510
+	err := writeUserDb.Model(&hadwater).Where("id=? AND user_org_id = ? AND status = 1", id, orgid).Updates(map[string]interface{}{"sampling_date": hadwater.SamplingDate, "specimenb": hadwater.Specimenb, "concentrate_noc": hadwater.ConcentrateNoc, "concentrateb_nod": hadwater.ConcentratebNod, "sampling_locationb": hadwater.SamplingLocationb, "detection_unit": hadwater.DetectionUnit, "samplerb": hadwater.Samplerb, "reporting_dateb": hadwater.ReportingDateb, "detection_resultb": hadwater.DetectionResultb, "sort": hadwater.Sort, "pass_examination": hadwater.PassExamination, "modifications": hadwater.Modifications, "mtime": time.Now().Unix()}).Error
1511
+	return err
1512
+}
1513
+
1514
+func UpdateDivicePh(id int64, orgid int64, hadwater *models.XtDevicePh) error {
1515
+	err := writeUserDb.Model(&hadwater).Where("id=? AND user_org_id = ? AND status = 1", id, orgid).Updates(map[string]interface{}{"sampling_date": hadwater.SamplingDate, "specimenb": hadwater.Specimenb, "concentrate_noc": hadwater.ConcentrateNoc, "concentrateb_nod": hadwater.ConcentratebNod, "sampling_locationb": hadwater.SamplingLocationb, "detection_unit": hadwater.DetectionUnit, "samplerb": hadwater.Samplerb, "reporting_dateb": hadwater.ReportingDateb, "detection_resultb": hadwater.DetectionResultb, "sort": hadwater.Sort, "pass_examination": hadwater.PassExamination, "modifications": hadwater.Modifications, "mtime": time.Now().Unix()}).Error
1516
+	return err
1517
+}
1518
+
1519
+func DeleteOxygenates(id int64) error {
1520
+	oxygenates := models.XtDeviceOxygenates{}
1521
+	err := writeUserDb.Model(&oxygenates).Where("id = ? ", id).Updates(map[string]interface{}{"status": 0}).Error
1522
+	return err
1523
+}
1524
+
1525
+func DeleteHadWater(id int64) error {
1526
+	hadwater := models.XtDeviceHadwater{}
1527
+	err := writeUserDb.Model(&hadwater).Where("id =?", id).Updates(map[string]interface{}{"status": 0}).Error
1528
+	return err
1529
+}
1530
+
1531
+func DeleteWater(id int64) error {
1532
+
1533
+	water := models.XtDeviceWater{}
1534
+	err := writeUserDb.Model(&water).Where("id = ? ", id).Updates(map[string]interface{}{"status": 0}).Error
1535
+	return err
1536
+}
1537
+
1538
+func DeleteDevicePh(id int64) error {
1539
+
1540
+	ph := models.XtDevicePh{}
1541
+	err := writeUserDb.Model(&ph).Where("id = ? ", id).Updates(map[string]interface{}{"status": 0}).Error
1542
+	return err
1543
+}

+ 163 - 4
service/mobile_dialysis_service.go View File

@@ -794,9 +794,6 @@ func (MDoctorAdviceVM) TableName() string {
794 794
 func MobileGetScheduleDoctorAdvices(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string) ([]*MScheduleDoctorAdviceVM, error) {
795 795
 	var vms []*MScheduleDoctorAdviceVM
796 796
 	adviceWhere := ""
797
-	fmt.Println("advicetype", adviceType)
798
-	fmt.Println("patientType", patientType)
799
-	fmt.Println("adminUserId", adminUserId)
800 797
 	adviceCondition := []interface{}{}
801 798
 	if adviceType == 0 {
802 799
 		if patientType == 0 {
@@ -944,7 +941,7 @@ func MobileCreateDialysisOrder(orgID int64, patientID int64, order *models.Dialy
944 941
 	}
945 942
 
946 943
 	// 接诊评估
947
-	if err := tx.Model(&models.ReceiveTreatmentAsses{}).Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND status = 1", orgID, patientID, order.DialysisDate).Updates(map[string]interface{}{"record_id": order.ID, "updated_time": now.Unix()}).Error; err != nil {
944
+	if err := tx.Model(&models.ReceiveTreatmentAsses{}).Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND status = 1", orgID, patientID, order.DialysisDate).Updates(map[string]interface{}{"record_id": order.ID, "update_time": now.Unix()}).Error; err != nil {
948 945
 		tx.Rollback()
949 946
 		return err
950 947
 	}
@@ -1203,6 +1200,19 @@ func MobileGetDialysisPrescribeByModeId(orgID int64, patientID int64, recordDate
1203 1200
 	return &record, nil
1204 1201
 }
1205 1202
 
1203
+func MobileGetDialysisPrescribeByModeIdOne(orgID int64, patientID int64, recordDate int64) (*models.DialysisPrescription, error) {
1204
+	var record models.DialysisPrescription
1205
+	err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ?", patientID, orgID, recordDate).First(&record).Error
1206
+	if err != nil {
1207
+		if err == gorm.ErrRecordNotFound {
1208
+			return nil, nil
1209
+		} else {
1210
+			return nil, err
1211
+		}
1212
+	}
1213
+	return &record, nil
1214
+}
1215
+
1206 1216
 func MobileGetLastDialysisPrescribe(orgID int64, patientID int64) (*models.DialysisPrescription, error) {
1207 1217
 	var record models.DialysisPrescription
1208 1218
 	err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 ", patientID, orgID).Last(&record).Error
@@ -1779,3 +1789,152 @@ func GetHisDoctorAdviceCount(startime int64, endtime int64, deliveway string, or
1779 1789
 	err = db.Select("x.advice_name,x.advice_desc,x.delivery_way,count(x.id) as total").Group("x.advice_name,x.advice_desc").Scan(&advice).Error
1780 1790
 	return advice, err
1781 1791
 }
1792
+
1793
+func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64) ([]*MScheduleDoctorAdviceVM, error) {
1794
+	var vms []*MScheduleDoctorAdviceVM
1795
+	adviceWhere := ""
1796
+	adviceCondition := []interface{}{}
1797
+	if adviceType == 0 {
1798
+		if patientType == 0 {
1799
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1)"
1800
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1801
+
1802
+		} else if patientType == 1 {
1803
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1)"
1804
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
1805
+
1806
+		} else if patientType == 2 {
1807
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1)"
1808
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1809
+		}
1810
+
1811
+	} else if adviceType == 1 {
1812
+		if patientType == 0 {
1813
+			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ?  "
1814
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1815
+
1816
+		} else if patientType == 1 {
1817
+			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? "
1818
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
1819
+
1820
+		} else if patientType == 2 {
1821
+			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0"
1822
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1823
+
1824
+		}
1825
+
1826
+	} else if adviceType == 3 {
1827
+		if patientType == 0 {
1828
+			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ?  "
1829
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1830
+
1831
+		} else if patientType == 1 {
1832
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? "
1833
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
1834
+		} else if patientType == 2 {
1835
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3  AND execution_staff = 0"
1836
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1837
+		}
1838
+
1839
+	} else if adviceType == 2 && len(deliverWay) > 0 {
1840
+		if patientType == 0 {
1841
+			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ?"
1842
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
1843
+
1844
+		} else if patientType == 1 {
1845
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?  and delivery_way = ? "
1846
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay)
1847
+		} else if patientType == 2 {
1848
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0 and delivery_way = ?"
1849
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
1850
+		}
1851
+
1852
+	} else if adviceType == 2 && len(deliverWay) <= 0 {
1853
+		if patientType == 0 {
1854
+			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ?"
1855
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1856
+
1857
+		} else if patientType == 1 {
1858
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?"
1859
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
1860
+		} else if patientType == 2 {
1861
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0"
1862
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1863
+		}
1864
+
1865
+	}
1866
+
1867
+	db := readDb.Table("xt_schedule")
1868
+	if scheduleType > 0 {
1869
+		db = db.Where("schedule_type = ?", scheduleType)
1870
+	}
1871
+	if partitonType > 0 {
1872
+		db = db.Where("partition_id = ?", partitonType)
1873
+	}
1874
+	db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1875
+		Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1876
+			return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1877
+		}).
1878
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1879
+		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1880
+		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1881
+		Preload("DialysisAssesmentBefor", "status =1 AND user_org_id = ? and assessment_date =?", orgID, scheduleDate).
1882
+		Preload("DoctorAdvices", adviceCondition...).
1883
+		Where("status = 1 AND user_org_id = ?", orgID)
1884
+	if scheduleDate != 0 {
1885
+		db = db.Where("schedule_date = ?", scheduleDate)
1886
+	}
1887
+
1888
+	err := db.Find(&vms).Error
1889
+	return vms, err
1890
+}
1891
+
1892
+func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string, scheduleType int64, partitionType int64) ([]*HisMScheduleDoctorAdviceVM, error) {
1893
+
1894
+	var vms []*HisMScheduleDoctorAdviceVM
1895
+	if len(deliverWay) > 0 {
1896
+		db := readDb.Table("xt_schedule")
1897
+		if scheduleType > 0 {
1898
+			db = db.Where("schedule_type = ?", scheduleType)
1899
+		}
1900
+		if partitionType > 0 {
1901
+			db = db.Where("partition_id = ?", partitionType)
1902
+		}
1903
+		db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1904
+			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1905
+				return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1906
+			}).
1907
+			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1908
+			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1909
+			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1910
+			Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ?", orgID, scheduleDate, deliverWay).
1911
+			Where("status = 1 AND user_org_id = ?", orgID)
1912
+		if scheduleDate != 0 {
1913
+			db = db.Where("schedule_date = ?", scheduleDate)
1914
+		}
1915
+		err = db.Find(&vms).Error
1916
+	} else {
1917
+		db := readDb.Table("xt_schedule")
1918
+		if scheduleType > 0 {
1919
+			db = db.Where("schedule_type = ?", scheduleType)
1920
+		}
1921
+		if partitionType > 0 {
1922
+			db = db.Where("partition_id = ?", partitionType)
1923
+		}
1924
+		db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1925
+			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1926
+				return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1927
+			}).
1928
+			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1929
+			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1930
+			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1931
+			Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ?", orgID, scheduleDate).
1932
+			Where("status = 1 AND user_org_id = ?", orgID)
1933
+		if scheduleDate != 0 {
1934
+			db = db.Where("schedule_date = ?", scheduleDate)
1935
+		}
1936
+		err = db.Find(&vms).Error
1937
+	}
1938
+
1939
+	return vms, err
1940
+}

+ 2 - 2
service/patient_service.go View 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
 
@@ -1476,7 +1476,7 @@ func GetDialysisCount(orgid int64, partitionid int64) (order []*models.BloodDial
1476 1476
 
1477 1477
 func UpdatePatientDialysisSolutionOne(patientid int64, orgid int64, prescription *models.DialysisPrescription, timenow int64) error {
1478 1478
 
1479
-	err = XTWriteDB().Model(&prescription).Where("patient_id = ? and user_org_id = ? and record_date = ? ", patientid, orgid, timenow).Updates(map[string]interface{}{"dialyzer": prescription.Dialyzer, "anticoagulant": prescription.Anticoagulant, "mode_id": prescription.ModeId, "dialysis_duration_hour": prescription.DialysisDurationHour, "anticoagulant_shouji": prescription.AnticoagulantShouji, "anticoagulant_weichi": prescription.AnticoagulantWeichi, "anticoagulant_zongliang": prescription.AnticoagulantZongliang, "kalium": prescription.Kalium, "sodium": prescription.Sodium, "calcium": prescription.Calcium, "dialyzer_perfusion_apparatus": prescription.DialyzerPerfusionApparatus, "blood_access": prescription.BloodAccess, "dialysate_flow": prescription.DialysateFlow, "dialysate_temperature": prescription.DialysateTemperature}).Error
1479
+	err = XTWriteDB().Model(&prescription).Where("patient_id = ? and user_org_id = ? and record_date = ? ", patientid, orgid, timenow).Updates(map[string]interface{}{"dialyzer": prescription.Dialyzer, "anticoagulant": prescription.Anticoagulant, "mode_id": prescription.ModeId, "dialysis_duration_hour": prescription.DialysisDurationHour, "anticoagulant_shouji": prescription.AnticoagulantShouji, "anticoagulant_weichi": prescription.AnticoagulantWeichi, "anticoagulant_zongliang": prescription.AnticoagulantZongliang, "kalium": prescription.Kalium, "sodium": prescription.Sodium, "calcium": prescription.Calcium, "dialyzer_perfusion_apparatus": prescription.DialyzerPerfusionApparatus, "blood_access": prescription.BloodAccess, "dialysate_flow": prescription.DialysateFlow, "dialysate_temperature": prescription.DialysateTemperature, "dialysis_dialyszers": prescription.DialysisDialyszers, "dialysis_irrigation": prescription.DialysisIrrigation}).Error
1480 1480
 	return err
1481 1481
 }
1482 1482
 

+ 105 - 5
service/patientmanage_service.go View File

@@ -527,7 +527,7 @@ func GetNewDoctorAdvice(patientID int64, advice_type int64, start int64, end int
527 527
 		db = db.Where("x.start_time<=?", end)
528 528
 	}
529 529
 	//offset := (page - 1) * limit
530
-	err = db.Group("x.id").Count(&total).Select("x.id, x.user_org_id, x.patient_id, x.advice_type, x.advice_date, x.record_date, x.start_time, x.advice_name,x.advice_desc, x.reminder_date, x.drug_spec, x.drug_spec_unit, x.single_dose, x.single_dose_unit, x.prescribing_number, x.prescribing_number_unit, x.delivery_way, x.execution_frequency, x.advice_doctor, x.status, x.created_time,x.updated_time, x.advice_affirm, x.remark, x.stop_time, x.stop_reason, x.stop_doctor, x.stop_state, x.parent_id, x.execution_time, x.execution_staff, x.execution_state, x.checker, x.check_state, x.check_time, x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.parent_id,r.user_name,s.dialyzer_perfusion_apparatus,s.anticoagulant,s.anticoagulant_shouji,s.anticoagulant_weichi,s.anticoagulant_zongliang, IF(x.parent_id > 0, x.parent_id, x.id) as advice_order").Joins("Left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Joins("left join xt_dialysis_prescription as s on s.patient_id = x.patient_id and s.record_date = x.advice_date and s.user_org_id = ?", orgID).Order("start_time desc, groupno desc, advice_order desc, id asc").Scan(&doctoradvice).Error
530
+	err = db.Group("x.id").Count(&total).Select("x.id, x.user_org_id, x.patient_id, x.advice_type, x.advice_date, x.record_date, x.start_time, x.advice_name,x.advice_desc, x.reminder_date, x.drug_spec, x.drug_spec_unit, x.single_dose, x.single_dose_unit, x.prescribing_number, x.prescribing_number_unit, x.delivery_way, x.execution_frequency, x.advice_doctor, x.status, x.created_time,x.updated_time, x.advice_affirm, x.remark, x.stop_time, x.stop_reason, x.stop_doctor, x.stop_state, x.parent_id, x.execution_time, x.execution_staff, x.execution_state, x.checker, x.check_state, x.check_time, x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.parent_id,r.user_name,s.dialyzer_perfusion_apparatus,s.anticoagulant,s.anticoagulant_shouji,s.anticoagulant_weichi,s.anticoagulant_zongliang,s.dialysis_dialyszers,s.dialysis_irrigation, IF(x.parent_id > 0, x.parent_id, x.id) as advice_order").Joins("Left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Joins("left join xt_dialysis_prescription as s on s.patient_id = x.patient_id and s.record_date = x.advice_date and s.user_org_id = ?", orgID).Order("start_time desc, groupno desc, advice_order desc, id asc").Scan(&doctoradvice).Error
531 531
 	fmt.Print("err", err)
532 532
 	return
533 533
 
@@ -562,7 +562,7 @@ func GetNewDoctorAdviceOne(patientID int64, advice_type int64, start int64, end
562 562
 		db = db.Where("x.start_time<=?", end)
563 563
 	}
564 564
 	offset := (page - 1) * limit
565
-	err = db.Order("x.start_time desc").Group("x.start_time").Count(&total).Offset(offset).Limit(limit).Select("x.id, x.user_org_id, x.patient_id, x.advice_type, x.advice_date, x.record_date, x.start_time, x.advice_name,x.advice_desc, x.reminder_date, x.drug_spec, x.drug_spec_unit, x.single_dose, x.single_dose_unit, x.prescribing_number, x.prescribing_number_unit, x.delivery_way, x.execution_frequency, x.advice_doctor, x.status, x.created_time,x.updated_time, x.advice_affirm, x.remark, x.stop_time, x.stop_reason, x.stop_doctor, x.stop_state, x.parent_id, x.execution_time, x.execution_staff, x.execution_state, x.checker, x.check_state, x.check_time, x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.parent_id,r.user_name,s.dialyzer_perfusion_apparatus,s.anticoagulant,s.anticoagulant_shouji,s.anticoagulant_weichi,s.anticoagulant_zongliang, IF(x.parent_id > 0, x.parent_id, x.id) as advice_order").Joins("Left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Joins("left join xt_dialysis_prescription as s on s.patient_id = x.patient_id and s.record_date = x.advice_date and s.user_org_id = ?", orgID).Scan(&doctoradvice).Error
565
+	err = db.Order("x.start_time desc").Group("x.start_time").Count(&total).Offset(offset).Limit(limit).Select("x.id, x.user_org_id, x.patient_id, x.advice_type, x.advice_date, x.record_date, x.start_time, x.advice_name,x.advice_desc, x.reminder_date, x.drug_spec, x.drug_spec_unit, x.single_dose, x.single_dose_unit, x.prescribing_number, x.prescribing_number_unit, x.delivery_way, x.execution_frequency, x.advice_doctor, x.status, x.created_time,x.updated_time, x.advice_affirm, x.remark, x.stop_time, x.stop_reason, x.stop_doctor, x.stop_state, x.parent_id, x.execution_time, x.execution_staff, x.execution_state, x.checker, x.check_state, x.check_time, x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.parent_id,r.user_name,s.dialyzer_perfusion_apparatus,s.anticoagulant,s.anticoagulant_shouji,s.anticoagulant_weichi,s.anticoagulant_zongliang,s.dialysis_dialyszers,s.dialysis_irrigation, IF(x.parent_id > 0, x.parent_id, x.id) as advice_order").Joins("Left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Joins("left join xt_dialysis_prescription as s on s.patient_id = x.patient_id and s.record_date = x.advice_date and s.user_org_id = ?", orgID).Scan(&doctoradvice).Error
566 566
 	fmt.Print("错误是什么", err)
567 567
 	return
568 568
 }
@@ -654,7 +654,7 @@ func GetlongDialysisrecord(patientid int64, startime int64, endtime int64, limit
654 654
 	}
655 655
 	offset := (page - 1) * limit
656 656
 	err = db.Count(&total).Order("x.created_time desc").Offset(offset).Limit(limit).Group("x.id").
657
-		Select("x.id,x.name,x.sub_name,x.user_org_id,x.patient_id,x.parent_id,x.type,x.period,x.times,x.anticoagulant,x.anticoagulant_shouji,x.anticoagulant_weichi,x.anticoagulant_zongliang,x.anticoagulant_gaimingcheng,x.anticoagulant_gaijiliang,x.mode_name,x.mode_id,x.dialysis_duration,x.replacement_way,x.hemodialysis_machine,x.blood_filter,x.perfusion_apparatus,x.blood_flow_volume,x.dewater,x.displace_liqui,x.glucose,x.dry_weight,x.dialysate_flow,x.kalium,x.sodium,x.calcium,x.bicarbonate,x.doctor,x.first_dialysis,x.remark,x.initiate_mode,x.affirm_state,x.use_state,x.status,x.registrars_id,x.created_time,x.updated_time,x.solution_type,x.dialysate_temperature,x.conductivity,x.dialysis_duration_hour,x.dialysis_duration_minute,x.target_ultrafiltration,x.dialysate_formulation,x.dialyzer,x.replacement_total,x.dialyzer_perfusion_apparatus,x.body_fluid,x.special_medicine,x.special_medicine_other,x.displace_liqui_part,x.displace_liqui_value,x.blood_access,x.ultrafiltration,x.body_fluid_other,x.target_ktv").Find(&prescription).Error
657
+		Select("x.id,x.name,x.sub_name,x.user_org_id,x.patient_id,x.parent_id,x.type,x.period,x.times,x.anticoagulant,x.anticoagulant_shouji,x.anticoagulant_weichi,x.anticoagulant_zongliang,x.anticoagulant_gaimingcheng,x.anticoagulant_gaijiliang,x.mode_name,x.mode_id,x.dialysis_duration,x.replacement_way,x.hemodialysis_machine,x.blood_filter,x.perfusion_apparatus,x.blood_flow_volume,x.dewater,x.displace_liqui,x.glucose,x.dry_weight,x.dialysate_flow,x.kalium,x.sodium,x.calcium,x.bicarbonate,x.doctor,x.first_dialysis,x.remark,x.initiate_mode,x.affirm_state,x.use_state,x.status,x.registrars_id,x.created_time,x.updated_time,x.solution_type,x.dialysate_temperature,x.conductivity,x.dialysis_duration_hour,x.dialysis_duration_minute,x.target_ultrafiltration,x.dialysate_formulation,x.dialyzer,x.replacement_total,x.dialyzer_perfusion_apparatus,x.body_fluid,x.special_medicine,x.special_medicine_other,x.displace_liqui_part,x.displace_liqui_value,x.blood_access,x.ultrafiltration,x.body_fluid_other,x.target_ktv,x.dialysis_dialyszers,x.dialysis_irrigation").Find(&prescription).Error
658 658
 
659 659
 	return
660 660
 }
@@ -1475,15 +1475,115 @@ 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, "other_vascular": access.OtherVascular, "ci_type": access.CiType, "blood_cultupe": access.BloodCultupe, "sequelae_type": access.SequelaeType}).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
+}
1570
+
1571
+func GetAccessList(orgid int64) (*models.Dataconfig, error) {
1572
+
1573
+	dataconfig := models.Dataconfig{}
1574
+	err := XTReadDB().Model(&dataconfig).Where("org_id = 0 and name = '血管通路' and status = ?", 1).Find(&dataconfig).Error
1575
+	return &dataconfig, err
1576
+}
1577
+
1578
+func GetParentAccessList(orgid int64, parentid int64) (dataconfig []*models.Dataconfig, err error) {
1579
+
1580
+	err = XTReadDB().Model(&dataconfig).Where("org_id in(0,?) and parent_id = ? and status =1", orgid, parentid).Find(&dataconfig).Error
1581
+	return dataconfig, err
1582
+
1583
+}
1584
+
1585
+func GetBloodAccess(orgid int64) (*models.Dataconfig, error) {
1586
+	dataconfig := models.Dataconfig{}
1587
+	err := XTReadDB().Model(&dataconfig).Where("org_id = 0 and name = '血管通路部位' and status = 1 ").Find(&dataconfig).Error
1588
+	return &dataconfig, err
1589
+}

+ 30 - 0
service/schedule_service.go View File

@@ -719,3 +719,33 @@ func UpdatedDialysisPrescription(prescription *models.DialysisPrescription, reco
719 719
 	err := XTWriteDB().Model(&prescription).Where("record_date = ? and patient_id = ? and user_org_id = ?", recordDate, patientid, orgid).Update(map[string]interface{}{"mode_id": prescription.ModeId, "updated_time": time.Now().Unix()}).Error
720 720
 	return err
721 721
 }
722
+
723
+func GetWeekSchedules(orgid int64, startime int64, endtime int64) (scheudle []*models.XtSchedule, err error) {
724
+
725
+	err = XTReadDB().Model(&scheudle).Where("user_org_id = ? and status = 1 and schedule_date>=? and schedule_date<=?", orgid, startime, endtime).Find(&scheudle).Error
726
+	return scheudle, err
727
+}
728
+
729
+func GetLastWeekSchedule(orgid int64, startime int64, endtime int64) (*models.XtSchedule, error) {
730
+	schedule := models.XtSchedule{}
731
+	err := XTReadDB().Where("user_org_id = ? and status =1 and schedule_date>=? and schedule_date<=?", orgid, startime, endtime).Find(&schedule).Error
732
+	if err == gorm.ErrRecordNotFound {
733
+		return nil, err
734
+	}
735
+	if err != nil {
736
+		return nil, err
737
+	}
738
+	return &schedule, nil
739
+}
740
+func AddPatientSchedule(schedule *models.XtSchedule) error {
741
+
742
+	err := XTWriteDB().Create(&schedule).Error
743
+	return err
744
+}
745
+
746
+func UpdatePatientSchedule(orgid int64, startime int64, endtime int64) error {
747
+
748
+	schedule := models.XtSchedule{}
749
+	err := XTWriteDB().Model(&schedule).Where("user_org_id = ? and schedule_date>=? and schedule_date<=? and status =1", orgid, startime, endtime).Updates(map[string]interface{}{"status": 0}).Error
750
+	return err
751
+}

+ 1 - 1
service/self_drug_service.go View 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
 }

+ 32 - 3
service/stock_service.go View File

@@ -121,6 +121,30 @@ func FindAllGoodTypeTotal(orgId int64) (total int64) {
121 121
 	return
122 122
 }
123 123
 
124
+func GetGoodsTypeIsExist(orgid int64) (*models.GoodsType, error) {
125
+	goodsType := models.GoodsType{}
126
+	err := XTReadDB().Where("org_id = ? and stock_attribute = 2 and status =1", orgid).Find(&goodsType).Error
127
+	if err == gorm.ErrRecordNotFound {
128
+		return nil, err
129
+	}
130
+	if err != nil {
131
+		return nil, err
132
+	}
133
+	return &goodsType, nil
134
+}
135
+
136
+func GetGoodsTypeIsExistOne(orgid int64) (*models.GoodsType, error) {
137
+	goodsType := models.GoodsType{}
138
+	err := XTReadDB().Where("org_id = ? and stock_attribute = 3 and status = 1", orgid).Find(&goodsType).Error
139
+	if err == gorm.ErrRecordNotFound {
140
+		return nil, err
141
+	}
142
+	if err != nil {
143
+		return nil, err
144
+	}
145
+	return &goodsType, nil
146
+}
147
+
124 148
 func AddSigleGoodType(goodType *models.GoodsType) (error, *models.GoodsType) {
125 149
 	err := writeDb.Create(&goodType).Error
126 150
 	return err, goodType
@@ -233,7 +257,7 @@ func FindGoodInfoList(orgId int64, page int64, limit int64, keyword string, is_u
233 257
 	db = db.Preload("GoodsType", "org_id = ? AND status = 1", orgId)
234 258
 	if len(keyword) > 0 {
235 259
 		likeKey := "%" + keyword + "%"
236
-		db = db.Where("good_code LIKE ? OR specification_name LIKE ?", likeKey, likeKey)
260
+		db = db.Where("good_code LIKE ? OR good_name LIKE ?", likeKey, likeKey)
237 261
 	} else {
238 262
 		if is_use > 0 {
239 263
 			if is_use == 1 {
@@ -1940,6 +1964,11 @@ func FindGoodInfoByName(name string, org_id int64, good_type_id int64) (total in
1940 1964
 	return
1941 1965
 }
1942 1966
 
1967
+func FindGoodInfoByNameOne(name string, org_id int64, good_type_id int64, id int64) (total int64) {
1968
+	readDb.Model(&models.GoodInfo{}).Where("org_id = ? AND status = 1 AND specification_name = ? AND good_type_id = ? and id <> ? ", org_id, name, good_type_id, id).Count(&total)
1969
+	return
1970
+}
1971
+
1943 1972
 func FindAllGoodTypeByType(types int64) (goodType []*models.GoodsType, err error) {
1944 1973
 	err = readDb.Model(&models.GoodsType{}).Where("type = ? AND status = 1", types).Find(&goodType).Error
1945 1974
 	return goodType, err
@@ -2067,7 +2096,7 @@ func UpdateDrugStockOutInfoCount2(org_id int64, id int64, count int64) {
2067 2096
 
2068 2097
 func FindPatientAutomaticReduceRecord(org_id int64, record_time int64, good_id int64, good_type_id int64, patient_id int64) (count int64, err error) {
2069 2098
 
2070
-	err = readDb.Model(&models.AutomaticReduceDetail{}).Where("org_id = ? AND status = 1 AND good_id = ? AND good_type_id = ? AND patient_id = ? AND record_time = ?", org_id, good_id, good_type_id, patient_id, record_time).Count(&count).Error
2099
+	err = readDb.Model(&models.AutomaticReduceDetail{}).Where("org_id = ? AND status = 1 AND good_id = ? AND good_type_id = ? AND patient_id = ? AND record_time = ? AND count <> 0", org_id, good_id, good_type_id, patient_id, record_time).Count(&count).Error
2071 2100
 	return
2072 2101
 
2073 2102
 }
@@ -2110,7 +2139,7 @@ func GetStockInGoodInfo(orgId int64) (stockIn []*VMWarehousingInfo, err error) {
2110 2139
 }
2111 2140
 
2112 2141
 func GetAllStockOutUserDetail(patient_id int64, orgId int64, record_time int64) (goodUser []*models.DialysisBeforePrepare, err error) {
2113
-	err = readDb.Model(&models.DialysisBeforePrepare{}).Where("patient_id = ? AND user_org_id = ? AND record_date = ? AND status = 1", patient_id, orgId, record_time).Find(&goodUser).Error
2142
+	err = readDb.Model(&models.DialysisBeforePrepare{}).Where("patient_id = ? AND user_org_id = ? AND record_date = ? AND status = 1 AND count <> 0 ", patient_id, orgId, record_time).Find(&goodUser).Error
2114 2143
 	return
2115 2144
 }
2116 2145