瀏覽代碼

11月8日库存管理

XMLWAN 3 年之前
父節點
當前提交
db78ce56cc

+ 1 - 1
conf/app.conf 查看文件

@@ -1,5 +1,5 @@
1 1
 appname = 血透
2
-httpport = 9531
2
+httpport = 9529
3 3
 runmode = dev
4 4
 
5 5
 #

+ 5 - 3
controllers/dialysis_api_controller.go 查看文件

@@ -1348,7 +1348,8 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1348 1348
 	remark := c.GetString("remark")
1349 1349
 	puncture_method := c.GetString("puncture_method")
1350 1350
 
1351
-	dialysis_count, _ := c.GetInt64("dialysis_count", 0)
1351
+	//dialysis_count, _ := c.GetInt64("dialysis_count", 0)
1352
+	dialysis_count := c.GetString("dialysis_count")
1352 1353
 	emergency_treatment, _ := c.GetInt64("emergency_treatment", 0)
1353 1354
 	emergency_treatment_other := c.GetString("emergency_treatment_other")
1354 1355
 	ductus_arantii := c.GetString("ductus_arantii")
@@ -1365,14 +1366,15 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1365 1366
 
1366 1367
 	is_infect, _ := c.GetInt64("is_infect", 0)
1367 1368
 	exposed, _ := c.GetFloat("exposed", 0)
1368
-	//skin, _ := c.GetInt64("skin", 0)
1369 1369
 	skin := c.GetString("skin")
1370 1370
 	skin_other := c.GetString("skin_other")
1371 1371
 	infect_other := c.GetString("infect_other")
1372 1372
 	ductus_arantii_other := c.GetString("ductus_arantii_other")
1373 1373
 	machine_type := c.GetString("machine_type")
1374 1374
 	puncture_needle := c.GetString("puncture_needle")
1375
-	humor_excessive_symptom, _ := c.GetInt64("humor_excessive_symptom", 0)
1375
+	//humor_excessive_symptom, _ := c.GetInt64("humor_excessive_symptom", 0)
1376
+
1377
+	humor_excessive_symptom := c.GetString("humor_excessive_symptom")
1376 1378
 	phinholing := c.GetString("pinholing")
1377 1379
 
1378 1380
 	catheter_suture := c.GetString("catheter_suture")

+ 4 - 3
controllers/doctors_api_controller.go 查看文件

@@ -62,6 +62,7 @@ func (c *DoctorsApiController) ScheduleAdvices() {
62 62
 	delivery_way := c.GetString("delivery_way")
63 63
 	schedule_type, _ := c.GetInt64("schedule_type")
64 64
 	partition_type, _ := c.GetInt64("partition_type")
65
+	patient_id, _ := c.GetInt64("patient_id")
65 66
 	if adviceType != 1 && adviceType != 3 && adviceType != 2 {
66 67
 		adviceType = 0
67 68
 	}
@@ -80,10 +81,10 @@ func (c *DoctorsApiController) ScheduleAdvices() {
80 81
 	adminUserInfo := c.GetAdminUserInfo()
81 82
 	orgID := adminUserInfo.CurrentOrgId
82 83
 
83
-	scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type)
84
-	hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type)
84
+	scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id)
85
+	hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id)
85 86
 
86
-	project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type)
87
+	project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id)
87 88
 
88 89
 	config, _ := service.GetHisDoctorConfig(orgID)
89 90
 	project_config, _ := service.GetHisProjectConfig(orgID)

+ 0 - 1
controllers/drug_stock_api_contorller.go 查看文件

@@ -755,7 +755,6 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
755 755
 
756 756
 			if item.WarehousingCount == warehouseInfo.WarehousingCount {
757 757
 				errs = service.UpDateDrugWarehousingInfo(item)
758
-				break
759 758
 			}
760 759
 		}
761 760
 	}

+ 2 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go 查看文件

@@ -1001,7 +1001,9 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1001 1001
 		assessmentAfterDislysis.CreatedTime = assessmentAfter.CreatedTime
1002 1002
 		assessmentAfterDislysis.ID = assessmentAfter.ID
1003 1003
 		err := service.UpdateAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
1004
+
1004 1005
 		if err == nil {
1006
+			fmt.Println("hhhhhhhhhhh0000000000", err)
1005 1007
 			c.ServeSuccessJSON(map[string]interface{}{
1006 1008
 				"assessmentAfterDislysis": assessmentAfterDislysis,
1007 1009
 			})

+ 5 - 11
controllers/mobile_api_controllers/patient_api_controller.go 查看文件

@@ -1936,10 +1936,7 @@ func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, dat
1936 1936
 		blood_access_part_id := dataBody["blood_access_part_id"].(string)
1937 1937
 		evaluation.BloodAccessPartId = blood_access_part_id
1938 1938
 	}
1939
-	//if dataBody["blood_access_part_id"] != nil && reflect.TypeOf(dataBody["blood_access_part_id"]).String() == "float64" {
1940
-	//	blood_access_part_id := int64(dataBody["blood_access_part_id"].(float64))
1941
-	//	evaluation.BloodAccessPartId = blood_access_part_id
1942
-	//}
1939
+
1943 1940
 	if dataBody["blood_access_part_opera_id"] != nil && reflect.TypeOf(dataBody["blood_access_part_opera_id"]).String() == "float64" {
1944 1941
 		blood_access_part_opera_id := int64(dataBody["blood_access_part_opera_id"].(float64))
1945 1942
 		evaluation.BloodAccessPartOperaId = blood_access_part_opera_id
@@ -1958,9 +1955,6 @@ func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, dat
1958 1955
 		is_hemorrhage, _ := strconv.ParseInt(ishemorrhage, 10, 64)
1959 1956
 		evaluation.IsHemorrhage = is_hemorrhage
1960 1957
 
1961
-		//if dataBody["is_hemorrhage"] != nil && reflect.TypeOf(dataBody["is_hemorrhage"]).String() == "float64" {
1962
-		//	is_hemorrhage := int64(dataBody["is_hemorrhage"].(float64))
1963
-		//	fmt.Println("is_hemorrhage2222222222222222",is_hemorrhage)
1964 1958
 		if is_hemorrhage != 1 && is_hemorrhage != 2 {
1965 1959
 			is_hemorrhage = 0
1966 1960
 		}
@@ -2031,8 +2025,8 @@ func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, dat
2031 2025
 
2032 2026
 	if dataBody["dialysis_count"] != nil && reflect.TypeOf(dataBody["dialysis_count"]).String() == "string" {
2033 2027
 		dialysis_count, _ := dataBody["dialysis_count"].(string)
2034
-		count, _ := strconv.ParseInt(dialysis_count, 10, 64)
2035
-		evaluation.DialysisCount = count
2028
+		//count, _ := strconv.ParseInt(dialysis_count, 10, 64)
2029
+		evaluation.DialysisCount = dialysis_count
2036 2030
 	}
2037 2031
 
2038 2032
 	if dataBody["is_infect"] != nil && reflect.TypeOf(dataBody["is_infect"]).String() == "string" {
@@ -2072,8 +2066,8 @@ func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, dat
2072 2066
 		evaluation.PunctureNeedle = punctureNeedle
2073 2067
 	}
2074 2068
 
2075
-	if dataBody["humor_excessive_symptom"] != nil && reflect.TypeOf(dataBody["humor_excessive_symptom"]).String() == "float64" {
2076
-		humor_excessive_symptom := int64(dataBody["humor_excessive_symptom"].(float64))
2069
+	if dataBody["humor_excessive_symptom"] != nil && reflect.TypeOf(dataBody["humor_excessive_symptom"]).String() == "string" {
2070
+		humor_excessive_symptom := dataBody["humor_excessive_symptom"].(string)
2077 2071
 		evaluation.HumorExcessiveSymptom = humor_excessive_symptom
2078 2072
 	}
2079 2073
 

+ 223 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go 查看文件

@@ -5,8 +5,12 @@ import (
5 5
 	"XT_New/enums"
6 6
 	"XT_New/models"
7 7
 	"XT_New/service"
8
+	"XT_New/utils"
9
+	"encoding/json"
8 10
 	"fmt"
9 11
 	"github.com/jinzhu/gorm"
12
+	"reflect"
13
+	"strconv"
10 14
 	"strings"
11 15
 	"time"
12 16
 )
@@ -417,3 +421,222 @@ func (this *StaffScheduleApiController) UpdateBloodSchedule() {
417 421
 		service.UpdateDialysisPrescriptionOne(prescription, patient_id, startTime)
418 422
 	}
419 423
 }
424
+
425
+func (this *StaffScheduleApiController) GetSchedulePatient() {
426
+
427
+	schedule, _ := this.GetInt64("schedule", 0) //1已2未
428
+	contagion, _ := this.GetInt64("contagion", 0)
429
+	keywords := this.GetString("keywords", "")
430
+	adminInfo := this.GetAdminUserInfo()
431
+
432
+	thisTime := time.Now()
433
+	weekDay := int(thisTime.Weekday())
434
+	if weekDay == 0 {
435
+		weekDay = 7
436
+	}
437
+	thisWeekEnd := 7 - weekDay
438
+	weekStartPoint := thisWeekEnd - 6
439
+	weekStartDay := thisTime.AddDate(0, 0, weekStartPoint)
440
+	weekEndPoint := thisWeekEnd + 7
441
+	weekEndDay := thisTime.AddDate(0, 0, weekEndPoint)
442
+	fmt.Println(weekStartPoint, weekStartDay, weekEndPoint, weekEndDay)
443
+
444
+	weekStartTime := weekStartDay.Format("2006-01-02") + " 00:00:00"
445
+	weekEndTime := weekEndDay.Format("2006-01-02") + " 23:59:59"
446
+	fmt.Println(weekStartTime, weekEndTime)
447
+
448
+	timeLayout := "2006-01-02 15:04:05"
449
+	loc, _ := time.LoadLocation("Local")
450
+	theStarTime, _ := time.ParseInLocation(timeLayout, weekStartTime, loc)
451
+	theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
452
+	weekStart := theStarTime.Unix()
453
+	weekEnd := theEndTime.Unix()
454
+
455
+	patients, _ := service.GetPatientWithScheduleAndSolution(adminInfo.CurrentOrgId, keywords, weekStart, weekEnd, schedule, contagion)
456
+
457
+	this.ServeSuccessJSON(map[string]interface{}{
458
+		"patients": patients,
459
+	})
460
+	return
461
+}
462
+
463
+func (c *StaffScheduleApiController) CreateMobileSchedulePatient() {
464
+
465
+	patientID, _ := c.GetInt64("patient_id", 0)
466
+	if patientID <= 0 {
467
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
468
+		return
469
+	}
470
+
471
+	adminUserInfo := c.GetAdminUserInfo()
472
+	patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patientID)
473
+	if patientInfo.ID == 0 {
474
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
475
+		return
476
+	}
477
+
478
+	var schedule models.Schedule
479
+	dataBody := make(map[string]interface{}, 0)
480
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
481
+	if err != nil {
482
+		utils.ErrorLog(err.Error())
483
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
484
+		return
485
+	}
486
+
487
+	if dataBody["schedule_date"] == nil || reflect.TypeOf(dataBody["schedule_date"]).String() != "string" {
488
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
489
+		return
490
+	}
491
+	scheduleDate, _ := dataBody["schedule_date"].(string)
492
+	if len(scheduleDate) == 0 {
493
+		utils.ErrorLog("len(schedule_date) == 0")
494
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
495
+		return
496
+	}
497
+	timeLayout := "2006-01-02"
498
+	loc, _ := time.LoadLocation("Local")
499
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", scheduleDate+" 00:00:00", loc)
500
+	if err != nil {
501
+		utils.ErrorLog(err.Error())
502
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
503
+		return
504
+	}
505
+	schedule.ScheduleDate = theTime.Unix()
506
+
507
+	timeNow := time.Now().Format("2006-01-02")
508
+	if timeNow > scheduleDate {
509
+		utils.ErrorLog(timeNow)
510
+		utils.ErrorLog(scheduleDate)
511
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleBeforeNow)
512
+		return
513
+	}
514
+
515
+	if dataBody["schedule_type"] == nil || reflect.TypeOf(dataBody["schedule_type"]).String() != "float64" {
516
+		utils.ErrorLog("schedule_type")
517
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
518
+		return
519
+	}
520
+	scheduleType := int64(dataBody["schedule_type"].(float64))
521
+	if scheduleType < 1 || scheduleType > 3 {
522
+		utils.ErrorLog("scheduleType < 3")
523
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
524
+		return
525
+	}
526
+	schedule.ScheduleType = scheduleType
527
+
528
+	if dataBody["bed_id"] == nil || reflect.TypeOf(dataBody["bed_id"]).String() != "float64" {
529
+		utils.ErrorLog("bed_id")
530
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
531
+		return
532
+	}
533
+	bedId := int64(dataBody["bed_id"].(float64))
534
+	if bedId < 1 {
535
+		utils.ErrorLog("bedId < 1")
536
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
537
+		return
538
+	}
539
+	schedule.BedId = bedId
540
+
541
+	if dataBody["partition_id"] == nil || reflect.TypeOf(dataBody["partition_id"]).String() != "float64" {
542
+		utils.ErrorLog("partition_id")
543
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
544
+		return
545
+	}
546
+	partitionId := int64(dataBody["partition_id"].(float64))
547
+	if partitionId < 1 {
548
+		utils.ErrorLog("partitionId < 1")
549
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
550
+		return
551
+	}
552
+	schedule.PartitionId = partitionId
553
+
554
+	if dataBody["schedule_week"] == nil || reflect.TypeOf(dataBody["schedule_week"]).String() != "float64" {
555
+		utils.ErrorLog("schedule_week")
556
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
557
+		return
558
+	}
559
+	scheduleWeek := int64(dataBody["schedule_week"].(float64))
560
+	if scheduleWeek < 1 || scheduleWeek > 7 {
561
+		utils.ErrorLog("scheduleWeek < 1")
562
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
563
+		return
564
+	}
565
+	schedule.ScheduleWeek = scheduleWeek
566
+
567
+	if dataBody["mode_id"] == nil || reflect.TypeOf(dataBody["mode_id"]).String() != "float64" {
568
+		utils.ErrorLog("mode_id")
569
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
570
+		return
571
+	}
572
+	modeId := int64(dataBody["mode_id"].(float64))
573
+	if modeId < 1 && modeId > 14 {
574
+		utils.ErrorLog("modeId < 1")
575
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
576
+		return
577
+	}
578
+	schedule.ModeId = modeId
579
+
580
+	schedule.PatientId = patientID
581
+	schedule.CreatedTime = time.Now().Unix()
582
+	schedule.UpdatedTime = time.Now().Unix()
583
+	schedule.Status = 1
584
+	schedule.UserOrgId = adminUserInfo.CurrentOrgId
585
+
586
+	bed, _ := service.GetDeviceNumberByID(adminUserInfo.CurrentOrgId, schedule.BedId)
587
+	if bed == nil {
588
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotExist)
589
+		return
590
+	}
591
+	if bed.ZoneID != schedule.PartitionId {
592
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotTheZone)
593
+		return
594
+	}
595
+
596
+	scheduleDateStart := scheduleDate + " 00:00:00"
597
+	scheduleDateEnd := scheduleDate + " 23:59:59"
598
+	timeLayout = "2006-01-02 15:04:05"
599
+	theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
600
+	theEndTime, _ := time.ParseInLocation(timeLayout, scheduleDateEnd, loc)
601
+	startTime := theStartTime.Unix()
602
+	endTime := theEndTime.Unix()
603
+
604
+	//一天只有排班一次
605
+	daySchedule, err := service.GetDaySchedule(adminUserInfo.CurrentOrgId, startTime, endTime, patientID)
606
+	if daySchedule.ID > 0 {
607
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleAgainOneDay)
608
+		return
609
+	}
610
+
611
+	//同天同位置只能排一个
612
+	pointSchedule, err := service.GetPointSchedule(adminUserInfo.CurrentOrgId, schedule.ScheduleDate, schedule.ScheduleWeek, schedule.ScheduleType, schedule.BedId)
613
+	if err != nil {
614
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
615
+		return
616
+	}
617
+	if pointSchedule.ID > 0 {
618
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePointScheduleExist)
619
+		return
620
+	}
621
+
622
+	redis := service.RedisClient()
623
+	defer redis.Close()
624
+	err = service.CreateSchedule(&schedule)
625
+
626
+	key := "scheduals_" + scheduleDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
627
+	redis.Set(key, "", time.Second)
628
+
629
+	fmt.Println(err)
630
+	if err != nil {
631
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateScheduleFail)
632
+		return
633
+	}
634
+	schedule.Patient = patientInfo.Name
635
+
636
+	c.ServeSuccessJSON(map[string]interface{}{
637
+		"msg":      "ok",
638
+		"schedule": schedule,
639
+	})
640
+	return
641
+
642
+}

+ 2 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_router.go 查看文件

@@ -21,4 +21,6 @@ func StaffScheduleApiControllersRegisterRouters() {
21 21
 	beego.Router("/m/api/ssearchpatient", &StaffScheduleApiController{}, "Get:SearchPatient")
22 22
 	beego.Router("/m/api/updatepatientschedule", &StaffScheduleApiController{}, "Get:UpdatePatientScheduleById")
23 23
 	beego.Router("/m/api/updateschedule", &StaffScheduleApiController{}, "Get:UpdateBloodSchedule")
24
+	beego.Router("m/api/schedule/patients", &StaffScheduleApiController{}, "Get:GetSchedulePatient")
25
+	beego.Router("/m/api/schedule/create", &StaffScheduleApiController{}, "Post:CreateMobileSchedulePatient")
24 26
 }

+ 6 - 4
controllers/stock_in_api_controller.go 查看文件

@@ -734,7 +734,6 @@ func (c *StockManagerApiController) EditWarehouse() {
734 734
 					Remark:           item.Remark,
735 735
 				}
736 736
 				service.UpdateWarehouseInfoByGoodIdOne(goodinfo, item.ID)
737
-				break
738 737
 			}
739 738
 
740 739
 		}
@@ -5339,7 +5338,7 @@ func (this *StockManagerApiController) GetReportStockList() {
5339 5338
 	fmt.Println("startTime", startTime, "endTime", endTime)
5340 5339
 	//list, total, _ := service.GetReportStockList(startTime, endTime, orgId, keyword, page, limit)
5341 5340
 
5342
-	list, total, _ := service.GetStockDamagedList(orgId, keyword, page, limit)
5341
+	list, total, _ := service.GetStockDamagedList(orgId, keyword, page, limit, startTime, endTime)
5343 5342
 	damageList, _ := service.GetStockDamagedCount(orgId)
5344 5343
 	doctorlist, _ := service.GetAllDoctorThree(orgId)
5345 5344
 
@@ -6482,9 +6481,12 @@ func (this *StockManagerApiController) SaveStockInventoryList() {
6482 6481
 func (this *StockManagerApiController) GetDamageDetailByGoodId() {
6483 6482
 
6484 6483
 	good_id, _ := this.GetInt64("good_id")
6485
-	list, _ := service.GetDamageDetailByGoodId(good_id)
6484
+	warehousing_order := this.GetString("warehousing_order")
6485
+	inventory_type, _ := this.GetInt64("type")
6486
+	fmt.Println("inventory_type23232323223322332", inventory_type)
6487
+	list, _ := service.GetDamageDetailByGoodId(good_id, warehousing_order, inventory_type)
6486 6488
 	orgId := this.GetAdminUserInfo().CurrentOrgId
6487
-	damageList, _ := service.GetStockDamagedCount(orgId)
6489
+	damageList, _ := service.GetStockDamagedCountOne(orgId, warehousing_order, inventory_type)
6488 6490
 	this.ServeSuccessJSON(map[string]interface{}{
6489 6491
 		"list":       list,
6490 6492
 		"damageList": damageList,

+ 2 - 2
models/dialysis.go 查看文件

@@ -287,7 +287,7 @@ type PredialysisEvaluation struct {
287 287
 	DuctusArantii                  string  `gorm:"column:ductus_arantii" json:"ductus_arantii"`
288 288
 	EmergencyTreatment             int64   `gorm:"column:emergency_treatment" json:"emergency_treatment"`
289 289
 	EmergencyTreatmentOther        string  `gorm:"column:emergency_treatment_other" json:"emergency_treatment_other"`
290
-	DialysisCount                  int64   `gorm:"column:dialysis_count" json:"dialysis_count"`
290
+	DialysisCount                  string  `gorm:"column:dialysis_count" json:"dialysis_count"`
291 291
 	AssessmentDoctor               int64   `gorm:"column:assessment_doctor" json:"assessment_doctor"`
292 292
 	AssessmentTime                 int64   `gorm:"column:assessment_time" json:"assessment_time"`
293 293
 	MachineType                    string  `gorm:"column:machine_type" json:"machine_type"`
@@ -301,7 +301,7 @@ type PredialysisEvaluation struct {
301 301
 	LastPostDialysisOther          string  `gorm:"column:last_post_dialysis_other" json:"last_post_dialysis_other"`
302 302
 	SymptomBeforeDialysisOther     string  `gorm:"column:symptom_before_dialysis_other" json:"symptom_before_dialysis_other"`
303 303
 	DialysisInterphaseOther        string  `gorm:"column:dialysis_interphase_other" json:"dialysis_interphase_other"`
304
-	HumorExcessiveSymptom          int64   `gorm:"column:humor_excessive_symptom" json:"humor_excessive_symptom"`
304
+	HumorExcessiveSymptom          string  `gorm:"column:humor_excessive_symptom" json:"humor_excessive_symptom"`
305 305
 	Phinholing                     string  `gorm:"column:pinholing" json:"pinholing" form:"pinholing"`
306 306
 	CatheterSuture                 string  `gorm:"column:catheter_suture" json:"catheter_suture" form:"catheter_suture"`
307 307
 	CatheterSutureOther            string  `gorm:"column:catheter_suture_other" json:"catheter_suture_other" form:"catheter_suture_other"`

+ 227 - 72
service/mobile_dialysis_service.go 查看文件

@@ -2150,76 +2150,157 @@ func GetHisDoctorAdviceCount(startime int64, endtime int64, deliveway string, or
2150 2150
 	return advice, err
2151 2151
 }
2152 2152
 
2153
-func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64) ([]*MScheduleDoctorAdviceVM, error) {
2153
+func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64, patient_id int64) ([]*MScheduleDoctorAdviceVM, error) {
2154 2154
 	var vms []*MScheduleDoctorAdviceVM
2155 2155
 	adviceWhere := ""
2156 2156
 	adviceCondition := []interface{}{}
2157 2157
 	if adviceType == 0 {
2158 2158
 		if patientType == 0 {
2159
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1)"
2160
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2159
+			if patient_id > 0 {
2160
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ?"
2161
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2162
+			} else {
2163
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1)"
2164
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2165
+			}
2161 2166
 
2162 2167
 		} else if patientType == 1 {
2163
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1)"
2164
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2168
+			if patient_id > 0 {
2169
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ?"
2170
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
2171
+			} else {
2172
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1)"
2173
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2174
+			}
2165 2175
 
2166 2176
 		} else if patientType == 2 {
2167
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1)"
2168
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2177
+			if patient_id > 0 {
2178
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?)"
2179
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2180
+			} else {
2181
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1)"
2182
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2183
+			}
2184
+
2169 2185
 		}
2170 2186
 
2171 2187
 	} else if adviceType == 1 {
2172 2188
 		if patientType == 0 {
2173
-			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ?  "
2174
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2189
+			if patient_id > 0 {
2190
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? "
2191
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2192
+			} else {
2193
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ?  "
2194
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2195
+			}
2175 2196
 
2176 2197
 		} else if patientType == 1 {
2177
-			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? "
2178
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2198
+			if patient_id > 0 {
2199
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? and patient_id = ?"
2200
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
2201
+			} else {
2202
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? "
2203
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2204
+			}
2179 2205
 
2180 2206
 		} else if patientType == 2 {
2181
-			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0"
2182
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2207
+			if patient_id > 0 {
2208
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0 and patient_id = ?"
2209
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2210
+			} else {
2211
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0"
2212
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2213
+			}
2183 2214
 
2184 2215
 		}
2185 2216
 
2186 2217
 	} else if adviceType == 3 {
2187 2218
 		if patientType == 0 {
2188
-			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ?  "
2189
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2219
+			if patient_id > 0 {
2220
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ? and patient_id = ?  "
2221
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2222
+			} else {
2223
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ?  "
2224
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2225
+			}
2190 2226
 
2191 2227
 		} else if patientType == 1 {
2192
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? "
2193
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2228
+			if patient_id > 0 {
2229
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? and patient_id = ?"
2230
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
2231
+			} else {
2232
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? "
2233
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2234
+			}
2235
+
2194 2236
 		} else if patientType == 2 {
2195
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3  AND execution_staff = 0"
2196
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2237
+			if patient_id > 0 {
2238
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3  AND execution_staff = 0 and patient_id = ?"
2239
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2240
+			} else {
2241
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3  AND execution_staff = 0"
2242
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2243
+			}
2244
+
2197 2245
 		}
2198 2246
 
2199 2247
 	} else if adviceType == 2 && len(deliverWay) > 0 {
2200 2248
 		if patientType == 0 {
2201
-			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ?"
2202
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
2249
+			if patient_id > 0 {
2250
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ? and patient_id = ?"
2251
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay, patient_id)
2252
+			} else {
2253
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ?"
2254
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
2255
+			}
2203 2256
 
2204 2257
 		} else if patientType == 1 {
2205
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?  and delivery_way = ? "
2206
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay)
2258
+			if patient_id > 0 {
2259
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?  and delivery_way = ? and patient_id = ?"
2260
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay, patient_id)
2261
+			} else {
2262
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?  and delivery_way = ? "
2263
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay)
2264
+			}
2265
+
2207 2266
 		} else if patientType == 2 {
2208
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0 and delivery_way = ?"
2209
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
2267
+			if patient_id > 0 {
2268
+
2269
+			} else {
2270
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0 and delivery_way = ?"
2271
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
2272
+			}
2273
+
2210 2274
 		}
2211 2275
 
2212 2276
 	} else if adviceType == 2 && len(deliverWay) <= 0 {
2213 2277
 		if patientType == 0 {
2214
-			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ?"
2215
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2278
+			if patient_id > 0 {
2279
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and patient_id = ?"
2280
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2281
+			} else {
2282
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ?"
2283
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2284
+			}
2216 2285
 
2217 2286
 		} else if patientType == 1 {
2218
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?"
2219
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2287
+			if patient_id > 0 {
2288
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and patient_id = ?"
2289
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
2290
+			} else {
2291
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?"
2292
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2293
+			}
2294
+
2220 2295
 		} else if patientType == 2 {
2221
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0"
2222
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2296
+			if patient_id > 0 {
2297
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0 and patient_id = ?"
2298
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2299
+			} else {
2300
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0"
2301
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2302
+			}
2303
+
2223 2304
 		}
2224 2305
 
2225 2306
 	}
@@ -2249,7 +2330,7 @@ func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceTy
2249 2330
 	return vms, err
2250 2331
 }
2251 2332
 
2252
-func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string, scheduleType int64, partitionType int64) ([]*HisMScheduleDoctorAdviceVM, error) {
2333
+func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string, scheduleType int64, partitionType int64, patient_id int64) ([]*HisMScheduleDoctorAdviceVM, error) {
2253 2334
 
2254 2335
 	var vms []*HisMScheduleDoctorAdviceVM
2255 2336
 	if len(deliverWay) > 0 {
@@ -2260,19 +2341,36 @@ func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string,
2260 2341
 		if partitionType > 0 {
2261 2342
 			db = db.Where("partition_id = ?", partitionType)
2262 2343
 		}
2263
-		db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2264
-			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2265
-			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2266
-			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2267
-			Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ?", orgID, scheduleDate, deliverWay).
2268
-			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2269
-				return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2270
-			}).
2271
-			Where("status = 1 AND user_org_id = ?", orgID)
2272
-		if scheduleDate != 0 {
2273
-			db = db.Where("schedule_date = ?", scheduleDate)
2344
+		if patient_id > 0 {
2345
+			db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ? and id =?", orgID, patient_id).
2346
+				Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2347
+				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2348
+				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
2349
+				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and patient_id = ?", orgID, scheduleDate, deliverWay, patient_id).
2350
+				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2351
+					return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2352
+				}).
2353
+				Where("status = 1 AND user_org_id = ?", orgID)
2354
+			if scheduleDate != 0 {
2355
+				db = db.Where("schedule_date = ?", scheduleDate)
2356
+			}
2357
+			err = db.Find(&vms).Error
2358
+		} else {
2359
+			db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2360
+				Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2361
+				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2362
+				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2363
+				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ?", orgID, scheduleDate, deliverWay).
2364
+				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2365
+					return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2366
+				}).
2367
+				Where("status = 1 AND user_org_id = ?", orgID)
2368
+			if scheduleDate != 0 {
2369
+				db = db.Where("schedule_date = ?", scheduleDate)
2370
+			}
2371
+			err = db.Find(&vms).Error
2274 2372
 		}
2275
-		err = db.Find(&vms).Error
2373
+
2276 2374
 	} else {
2277 2375
 		db := readDb.Table("xt_schedule")
2278 2376
 		if scheduleType > 0 {
@@ -2281,19 +2379,36 @@ func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string,
2281 2379
 		if partitionType > 0 {
2282 2380
 			db = db.Where("partition_id = ?", partitionType)
2283 2381
 		}
2284
-		db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2285
-			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2286
-			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2287
-			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2288
-			Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ?", orgID, scheduleDate).
2289
-			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2290
-				return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2291
-			}).
2292
-			Where("status = 1 AND user_org_id = ?", orgID)
2293
-		if scheduleDate != 0 {
2294
-			db = db.Where("schedule_date = ?", scheduleDate)
2382
+		if patient_id > 0 {
2383
+			db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ? and id = ?", orgID, patient_id).
2384
+				Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2385
+				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2386
+				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
2387
+				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
2388
+				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2389
+					return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2390
+				}).
2391
+				Where("status = 1 AND user_org_id = ?", orgID)
2392
+			if scheduleDate != 0 {
2393
+				db = db.Where("schedule_date = ?", scheduleDate)
2394
+			}
2395
+			err = db.Find(&vms).Error
2396
+		} else {
2397
+			db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2398
+				Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2399
+				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2400
+				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2401
+				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ?", orgID, scheduleDate).
2402
+				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2403
+					return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2404
+				}).
2405
+				Where("status = 1 AND user_org_id = ?", orgID)
2406
+			if scheduleDate != 0 {
2407
+				db = db.Where("schedule_date = ?", scheduleDate)
2408
+			}
2409
+			err = db.Find(&vms).Error
2295 2410
 		}
2296
-		err = db.Find(&vms).Error
2411
+
2297 2412
 	}
2298 2413
 
2299 2414
 	return vms, err
@@ -2423,25 +2538,65 @@ func GetHisPrescriptionProject(org_id int64, patient_id int64, record_date int64
2423 2538
 	return
2424 2539
 }
2425 2540
 
2426
-func GetPCHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay string, patientType int, adminUserId int64) ([]*HisMScheduleProjectVM, error) {
2541
+func GetPCHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay string, patientType int, adminUserId int64, patient_id int64) ([]*HisMScheduleProjectVM, error) {
2427 2542
 	var vms []*HisMScheduleProjectVM
2428 2543
 	if patientType == 0 {
2429
-		db := readDb.
2430
-			Table("xt_schedule").
2431
-			Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2432
-			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2433
-				return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2434
-			}).
2435
-			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2436
-			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2437
-			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2438
-			Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2439
-				return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
2440
-			}).Where("status = 1 AND user_org_id = ?", orgID)
2441
-		if scheduleDate != 0 {
2442
-			db = db.Where("schedule_date = ?", scheduleDate)
2544
+
2545
+		if patient_id > 0 {
2546
+			db := readDb.
2547
+				Table("xt_schedule").
2548
+				Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2549
+				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2550
+					return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2551
+				}).
2552
+				Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2553
+				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2554
+				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
2555
+				Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2556
+					return db.Where("status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).Preload("HisProject").Preload("GoodInfo", "status=1")
2557
+				}).Where("status = 1 AND user_org_id = ?", orgID)
2558
+			if scheduleDate != 0 {
2559
+				db = db.Where("schedule_date = ?", scheduleDate)
2560
+			}
2561
+			err = db.Find(&vms).Error
2562
+		} else {
2563
+			if patient_id > 0 {
2564
+				db := readDb.
2565
+					Table("xt_schedule").
2566
+					Preload("SchedualPatient", "status = 1 AND user_org_id = ? and id= ?", orgID, patient_id).
2567
+					Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2568
+						return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2569
+					}).
2570
+					Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2571
+					Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2572
+					Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
2573
+					Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2574
+						return db.Where("status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).Preload("HisProject").Preload("GoodInfo", "status=1")
2575
+					}).Where("status = 1 AND user_org_id = ?", orgID)
2576
+				if scheduleDate != 0 {
2577
+					db = db.Where("schedule_date = ?", scheduleDate)
2578
+				}
2579
+				err = db.Find(&vms).Error
2580
+			} else {
2581
+				db := readDb.
2582
+					Table("xt_schedule").
2583
+					Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2584
+					Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2585
+						return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2586
+					}).
2587
+					Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2588
+					Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2589
+					Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2590
+					Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2591
+						return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
2592
+					}).Where("status = 1 AND user_org_id = ?", orgID)
2593
+				if scheduleDate != 0 {
2594
+					db = db.Where("schedule_date = ?", scheduleDate)
2595
+				}
2596
+				err = db.Find(&vms).Error
2597
+			}
2443 2598
 		}
2444
-		err = db.Find(&vms).Error
2599
+
2445 2600
 	}
2446 2601
 
2447 2602
 	if patientType > 0 {

+ 1 - 0
service/patient_service.go 查看文件

@@ -1105,6 +1105,7 @@ func MobileGetMonitorsWithPatient(orgID int64, keyword string, page int) ([]*mod
1105 1105
 
1106 1106
 func GetPatientByKeyWord(orgID int64, keywords string) (patient []*models.Patients, err error) {
1107 1107
 	db := readDb.Model(&models.Patients{}).Where("user_org_id=? and status=1", orgID)
1108
+	fmt.Println("keywords22222223322332322332322323323", keywords)
1108 1109
 	if len(keywords) > 0 {
1109 1110
 		likekey := "%" + keywords + "%"
1110 1111
 		err = db.Where("name LIKE ? OR dialysis_no LIKE ? ", likekey, likekey).Find(&patient).Error

+ 2 - 2
service/self_drug_service.go 查看文件

@@ -879,7 +879,7 @@ func CreateDrugDamage(damage models.XtDrugDamage) error {
879 879
 func GetDrugDamageList(startime int64, endtime int64, orgId int64, keyword string, limit int64, page int64) (adjust []*models.VmDrugInventory, total int64, err error) {
880 880
 	likeKey := "%" + keyword + "%"
881 881
 	offset := (page - 1) * limit
882
-	db := XTReadDB().Table("xt_drug_inventory as x").Where("x.status = 1 and inventory_type = 11")
882
+	db := XTReadDB().Table("xt_drug_inventory as x").Where("x.status = 1 and type = 4")
883 883
 	table := XTReadDB().Table("xt_base_drug as t").Where("t.status = 1")
884 884
 	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
885 885
 	fmt.Println(table, tab)
@@ -1126,7 +1126,7 @@ func CreateDrugWarehouseOutInfo(info models.DrugWarehouseOutInfo) error {
1126 1126
 
1127 1127
 func GetDamageByDrugId(drugid int64, warhousingorder string, drugtype int64) (drug []*models.VmXtDrugInventory, err error) {
1128 1128
 
1129
-	db := XTReadDB().Table("xt_drug_inventory").Where("status = 1 and inventory_type = 11 ")
1129
+	db := XTReadDB().Table("xt_drug_inventory").Where("status = 1 and type = 4 ")
1130 1130
 
1131 1131
 	if drugid > 0 {
1132 1132
 		db = db.Where("drug_id = ?", drugid)

+ 54 - 7
service/stock_service.go 查看文件

@@ -3888,7 +3888,7 @@ func UpdateCancelInfo(id int64) (models.CancelStock, error) {
3888 3888
 
3889 3889
 func GetStockBatchNumber(id int64, orgid int64) (info []*models.WarehousingInfo, err error) {
3890 3890
 
3891
-	err = XTReadDB().Model(&info).Where("good_id = ? and org_id = ? and status = 1 and number <> '' and stock_count<> 0", id, orgid).Find(&info).Error
3891
+	err = XTReadDB().Model(&info).Where("good_id = ? and org_id = ? and status = 1 and number <> ''", id, orgid).Find(&info).Error
3892 3892
 	return info, err
3893 3893
 }
3894 3894
 
@@ -4133,6 +4133,13 @@ func GetStockFlowList(limit int64, page int64, consumable_type int64, orgId int6
4133 4133
 		if consumable_type == 4 {
4134 4134
 			db = db.Where(" consumable_type = ?", consumable_type)
4135 4135
 		}
4136
+
4137
+		if consumable_type == 10 {
4138
+			db = db.Where(" consumable_type = ?", consumable_type)
4139
+		}
4140
+		if consumable_type == 11 {
4141
+			db = db.Where(" consumable_type = ?", consumable_type)
4142
+		}
4136 4143
 	}
4137 4144
 	if orgId > 0 {
4138 4145
 		db = db.Where("user_org_id = ?", orgId)
@@ -4592,7 +4599,7 @@ func GetReportStockList(startime int64, endtime int64, orgid int64, keyword stri
4592 4599
 	return adjust, total, err
4593 4600
 }
4594 4601
 
4595
-func GetStockDamagedList(orgid int64, keyword string, page int64, limit int64) (adjust []*models.VmStockInventory, total int64, err error) {
4602
+func GetStockDamagedList(orgid int64, keyword string, page int64, limit int64, startime int64, endtime int64) (adjust []*models.VmStockInventory, total int64, err error) {
4596 4603
 	likeKey := "%" + keyword + "%"
4597 4604
 	offset := (page - 1) * limit
4598 4605
 	db := XTReadDB().Table("xt_stock_inventory as x").Where("x.status = 1 and x.inventory_type = 4")
@@ -4607,15 +4614,41 @@ func GetStockDamagedList(orgid int64, keyword string, page int64, limit int64) (
4607 4614
 	if orgid > 0 {
4608 4615
 		db = db.Where("x.user_org_id = ?", orgid)
4609 4616
 	}
4617
+	if startime > 0 {
4618
+		db = db.Where("x.ctime >=?", startime)
4619
+	}
4620
+	if endtime > 0 {
4621
+		db = db.Where("x.ctime <=?", endtime)
4622
+	}
4610 4623
 
4611
-	err = db.Group("x.id").Select("x.id,x.good_name,x.specification_name,x.warehousing_unit,x.count,x.buy_price,x.packing_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.good_id,x.warehousing_order,x.license_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.number,t.packing_unit,r.user_name").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.creater").Joins("left join xt_good_information as t on t.id =x.good_id").Count(&total).Offset(offset).Limit(limit).Scan(&adjust).Error
4624
+	err = db.Group("x.id").Select("x.ctime,x.id,x.good_name,x.specification_name,x.warehousing_unit,x.count,x.buy_price,x.packing_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.good_id,x.warehousing_order,x.license_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.number,t.packing_unit,r.user_name").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.creater").Joins("left join xt_good_information as t on t.id =x.good_id").Count(&total).Offset(offset).Limit(limit).Scan(&adjust).Error
4612 4625
 	return adjust, total, err
4613 4626
 
4614 4627
 }
4615 4628
 
4629
+func GetStockDamagedCountOne(orgid int64, keyword string, inventory_type int64) (adjust []*models.VmStockInventory, err error) {
4630
+
4631
+	db := XTReadDB().Table("xt_stock_inventory as x").Where("x.status = 1")
4632
+	if inventory_type == 0 {
4633
+		db = db.Where("x.inventory_type = 4")
4634
+	}
4635
+	if inventory_type > 0 {
4636
+		db = db.Where("x.inventory_type = ?", inventory_type)
4637
+	}
4638
+	if len(keyword) > 0 {
4639
+		likeKey := "%" + keyword + "%"
4640
+		db = db.Where("x.warehousing_order like ?", likeKey)
4641
+	}
4642
+	if orgid > 0 {
4643
+		db = db.Where("x.user_org_id = ?", orgid)
4644
+	}
4645
+	err = db.Group("x.good_id").Select("x.id,x.good_name,x.specification_name,x.warehousing_unit,sum(x.count) as count,x.buy_price,x.packing_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.good_id,x.warehousing_order,x.license_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.number").Scan(&adjust).Error
4646
+	return adjust, err
4647
+}
4648
+
4616 4649
 func GetStockDamagedCount(orgid int64) (adjust []*models.VmStockInventory, err error) {
4617 4650
 
4618
-	db := XTReadDB().Table("xt_stock_inventory as x").Where("x.status = 1 and x.inventory_type = 4")
4651
+	db := XTReadDB().Table("xt_stock_inventory as x").Where("x.status = 1 and inventory_type = 4 ")
4619 4652
 	if orgid > 0 {
4620 4653
 		db = db.Where("x.user_org_id = ?", orgid)
4621 4654
 	}
@@ -4766,7 +4799,7 @@ func GetInventoryDetailList(keyword string, limit int64, page int64, orgid int64
4766 4799
 	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
4767 4800
 	fmt.Println(table, tab)
4768 4801
 	if len(keyword) > 0 {
4769
-		db = db.Where("x.good_name = ?", likeKey)
4802
+		db = db.Where("x.good_name like ?", likeKey)
4770 4803
 	}
4771 4804
 	if orgid > 0 {
4772 4805
 		db = db.Where("x.user_org_id = ?", orgid)
@@ -4866,9 +4899,23 @@ func UpdatedWarehousingInfo(info models.WarehousingInfo, id int64) error {
4866 4899
 	return err
4867 4900
 }
4868 4901
 
4869
-func GetDamageDetailByGoodId(good_id int64) (list []*models.XtStockInventory, err error) {
4902
+func GetDamageDetailByGoodId(good_id int64, keyword string, inventory_type int64) (list []*models.XtStockInventory, err error) {
4870 4903
 
4871
-	err = XTReadDB().Model(&list).Where("good_id = ? and status = 1", good_id).Find(&list).Error
4904
+	db := XTReadDB().Model(&list).Where(" status = 1")
4905
+	if good_id > 0 {
4906
+		db = db.Where("good_id = ?", good_id)
4907
+	}
4908
+	if len(keyword) > 0 {
4909
+		likeKey := "%" + keyword + "%"
4910
+		db = db.Where("warehousing_order like ?", likeKey)
4911
+	}
4912
+	if inventory_type > 0 {
4913
+		db = db.Where("inventory_type = ?", inventory_type)
4914
+	}
4915
+	if inventory_type == 0 {
4916
+		db = db.Where("inventory_type = 4")
4917
+	}
4918
+	err = db.Find(&list).Error
4872 4919
 
4873 4920
 	return list, err
4874 4921
 }