XMLWAN hace 4 años
padre
commit
cd82358e39

+ 4 - 4
controllers/base_api_controller.go Ver fichero

71
 	if this.GetAdminUserInfo() == nil {
71
 	if this.GetAdminUserInfo() == nil {
72
 		var userAdmin models.AdminUser
72
 		var userAdmin models.AdminUser
73
 		userAdmin.Id = 1448
73
 		userAdmin.Id = 1448
74
-		userAdmin.Mobile = "13318599895"
74
+		userAdmin.Mobile = "13318464649"
75
 
75
 
76
 		//userAdmin.Id = 597
76
 		//userAdmin.Id = 597
77
 		//userAdmin.Mobile = "19874122664"
77
 		//userAdmin.Mobile = "19874122664"
91
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
91
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
92
 		subscibes[4] = &subscibe
92
 		subscibes[4] = &subscibe
93
 		var adminUserInfo service.AdminUserInfo
93
 		var adminUserInfo service.AdminUserInfo
94
-		adminUserInfo.CurrentOrgId = 4
94
+		adminUserInfo.CurrentOrgId = 7957
95
 		adminUserInfo.CurrentAppId = 8642
95
 		adminUserInfo.CurrentAppId = 8642
96
 		adminUserInfo.AdminUser = &userAdmin
96
 		adminUserInfo.AdminUser = &userAdmin
97
 		adminUserInfo.Subscibes = subscibes
97
 		adminUserInfo.Subscibes = subscibes
317
 	if this.GetAdminUserInfo() == nil {
317
 	if this.GetAdminUserInfo() == nil {
318
 		var userAdmin models.AdminUser
318
 		var userAdmin models.AdminUser
319
 		userAdmin.Id = 1448
319
 		userAdmin.Id = 1448
320
-		userAdmin.Mobile = "13318599895"
320
+		userAdmin.Mobile = "13318464649"
321
 
321
 
322
 		//userAdmin.Id = 597
322
 		//userAdmin.Id = 597
323
 		//userAdmin.Mobile = "19874122664"
323
 		//userAdmin.Mobile = "19874122664"
337
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
337
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
338
 		subscibes[4] = &subscibe
338
 		subscibes[4] = &subscibe
339
 		var adminUserInfo service.AdminUserInfo
339
 		var adminUserInfo service.AdminUserInfo
340
-		adminUserInfo.CurrentOrgId = 4
340
+		adminUserInfo.CurrentOrgId = 7957
341
 		adminUserInfo.CurrentAppId = 8642
341
 		adminUserInfo.CurrentAppId = 8642
342
 		adminUserInfo.AdminUser = &userAdmin
342
 		adminUserInfo.AdminUser = &userAdmin
343
 		adminUserInfo.Subscibes = subscibes
343
 		adminUserInfo.Subscibes = subscibes

+ 6 - 2
controllers/dialysis_api_controller.go Ver fichero

246
 	blood := c.GetString("blood")
246
 	blood := c.GetString("blood")
247
 	dialysis_dialyszers := c.GetString("dialysis_dialyszers")
247
 	dialysis_dialyszers := c.GetString("dialysis_dialyszers")
248
 	dialysis_irrigation := c.GetString("dialysis_irrigation")
248
 	dialysis_irrigation := c.GetString("dialysis_irrigation")
249
+	antioxidant_commodity_name := c.GetString("antioxidant_commodity_name")
249
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
250
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
250
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
251
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
251
 
252
 
327
 		Blood:                      blood,
328
 		Blood:                      blood,
328
 		DialysisDialyszers:         dialysis_dialyszers,
329
 		DialysisDialyszers:         dialysis_dialyszers,
329
 		DialysisIrrigation:         dialysis_irrigation,
330
 		DialysisIrrigation:         dialysis_irrigation,
331
+		AntioxidantCommodityName:   antioxidant_commodity_name,
330
 	}
332
 	}
331
 
333
 
332
 	if appRole.UserType == 2 || appRole.UserType == 1 {
334
 	if appRole.UserType == 2 || appRole.UserType == 1 {
495
 	blood := c.GetString("blood")
497
 	blood := c.GetString("blood")
496
 	dialysis_dialyszers := c.GetString("dialysis_dialyszers")
498
 	dialysis_dialyszers := c.GetString("dialysis_dialyszers")
497
 	dialysis_irrigation := c.GetString("dialysis_irrigation")
499
 	dialysis_irrigation := c.GetString("dialysis_irrigation")
500
+	antioxidant_commodity_name := c.GetString("antioxidant_commodity_name")
498
 	var prescription_doctor int64
501
 	var prescription_doctor int64
499
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
502
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
500
 
503
 
587
 		Blood:                     blood,
590
 		Blood:                     blood,
588
 		DialysisIrrigation:        dialysis_irrigation,
591
 		DialysisIrrigation:        dialysis_irrigation,
589
 		DialysisDialyszers:        dialysis_dialyszers,
592
 		DialysisDialyszers:        dialysis_dialyszers,
593
+		AntioxidantCommodityName:  antioxidant_commodity_name,
590
 	}
594
 	}
591
 
595
 
592
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
596
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
2902
 		if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
2906
 		if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
2903
 
2907
 
2904
 			totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
2908
 			totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
2905
-			if template.TemplateId == 6 { //adminInfo.CurrentOrgId == 9538
2909
+			if template.TemplateId == 6 || template.TemplateId == 32 { //adminInfo.CurrentOrgId == 9538
2906
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
2910
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
2907
 				record.UltrafiltrationRate = ultrafiltration_rate
2911
 				record.UltrafiltrationRate = ultrafiltration_rate
2908
 			}
2912
 			}
2929
 		}
2933
 		}
2930
 	}
2934
 	}
2931
 
2935
 
2932
-	if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 {
2936
+	if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 {
2933
 		if ultrafiltration_rate > 0 && adminInfo.CurrentOrgId != 9538 {
2937
 		if ultrafiltration_rate > 0 && adminInfo.CurrentOrgId != 9538 {
2934
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
2938
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
2935
 			record.UltrafiltrationVolume = ultrafiltration_volume
2939
 			record.UltrafiltrationVolume = ultrafiltration_volume

+ 18 - 16
controllers/dialysis_record_api_controller.go Ver fichero

11
 	"XT_New/enums"
11
 	"XT_New/enums"
12
 	"XT_New/service"
12
 	"XT_New/service"
13
 	"XT_New/utils"
13
 	"XT_New/utils"
14
-	"net/http"
15
-	"net/url"
16
 	"fmt"
14
 	"fmt"
17
 	"github.com/astaxie/beego"
15
 	"github.com/astaxie/beego"
16
+	"net/http"
17
+	"net/url"
18
 )
18
 )
19
 
19
 
20
 func DialysisRecordAPIControllerRegistRouter() {
20
 func DialysisRecordAPIControllerRegistRouter() {
548
 	schedual_type, _ := this.GetInt64("schedual_type")
548
 	schedual_type, _ := this.GetInt64("schedual_type")
549
 
549
 
550
 	washpipe_nurse, _ := this.GetInt64("washpipe_nurse")
550
 	washpipe_nurse, _ := this.GetInt64("washpipe_nurse")
551
-
551
+	change_nurse, _ := this.GetInt64("change_nurse")
552
 	bedID, _ := this.GetInt64("bed")
552
 	bedID, _ := this.GetInt64("bed")
553
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
553
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
554
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
554
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
720
 		Modifier:      adminUserInfo.AdminUser.Id,
720
 		Modifier:      adminUserInfo.AdminUser.Id,
721
 		SchedualType:  schedual_type,
721
 		SchedualType:  schedual_type,
722
 		WashpipeNurse: washpipe_nurse,
722
 		WashpipeNurse: washpipe_nurse,
723
+		ChangeNurse:   change_nurse,
723
 	}
724
 	}
724
 
725
 
725
 	createErr := service.MobileCreateDialysisOrder(adminUserInfo.CurrentOrgId, patientID, dialysisRecord)
726
 	createErr := service.MobileCreateDialysisOrder(adminUserInfo.CurrentOrgId, patientID, dialysisRecord)
743
 			if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
744
 			if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
744
 
745
 
745
 				totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
746
 				totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
746
-				if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 {
747
+				if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 {
747
 					ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
748
 					ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
748
 				}
749
 				}
749
 				// 只针对方济医院
750
 				// 只针对方济医院
779
 			}
780
 			}
780
 		}
781
 		}
781
 
782
 
782
-		go func (){
783
+		go func() {
783
 			ssoDomain := beego.AppConfig.String("call_domain")
784
 			ssoDomain := beego.AppConfig.String("call_domain")
784
 			api := ssoDomain + "/index/uppatient"
785
 			api := ssoDomain + "/index/uppatient"
785
 			values := make(url.Values)
786
 			values := make(url.Values)
786
-			values.Set("org_id",  strconv.FormatInt(adminUserInfo.CurrentOrgId,10))
787
-			values.Set("admin_user_id", strconv.FormatInt(nurseID,10))
788
-			values.Set("patient_id",  strconv.FormatInt(patientID,10))
789
-			values.Set("up_time",  strconv.FormatInt(startDate.Unix(),10))
787
+			values.Set("org_id", strconv.FormatInt(adminUserInfo.CurrentOrgId, 10))
788
+			values.Set("admin_user_id", strconv.FormatInt(nurseID, 10))
789
+			values.Set("patient_id", strconv.FormatInt(patientID, 10))
790
+			values.Set("up_time", strconv.FormatInt(startDate.Unix(), 10))
790
 			http.PostForm(api, values)
791
 			http.PostForm(api, values)
791
-		} ()
792
+		}()
792
 
793
 
793
 		this.ServeSuccessJSON(map[string]interface{}{
794
 		this.ServeSuccessJSON(map[string]interface{}{
794
 			"dialysis_order": dialysisRecord,
795
 			"dialysis_order": dialysisRecord,
1010
 		return
1011
 		return
1011
 	}
1012
 	}
1012
 
1013
 
1013
-	go func (){
1014
+	go func() {
1014
 		ssoDomain := beego.AppConfig.String("call_domain")
1015
 		ssoDomain := beego.AppConfig.String("call_domain")
1015
 		api := ssoDomain + "/index/downpatient"
1016
 		api := ssoDomain + "/index/downpatient"
1016
 		values := make(url.Values)
1017
 		values := make(url.Values)
1017
-		values.Set("org_id",  strconv.FormatInt(adminUserInfo.CurrentOrgId,10))
1018
-		values.Set("admin_user_id", strconv.FormatInt(nurseID,10))
1019
-		values.Set("patient_id",  strconv.FormatInt(patientID,10))
1018
+		values.Set("org_id", strconv.FormatInt(adminUserInfo.CurrentOrgId, 10))
1019
+		values.Set("admin_user_id", strconv.FormatInt(nurseID, 10))
1020
+		values.Set("patient_id", strconv.FormatInt(patientID, 10))
1020
 		http.PostForm(api, values)
1021
 		http.PostForm(api, values)
1021
-	} ()
1022
+	}()
1022
 
1023
 
1023
 	updateErr := service.ModifyDialysisRecord(dialysisRecord.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id)
1024
 	updateErr := service.ModifyDialysisRecord(dialysisRecord.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id)
1024
 	if updateErr != nil {
1025
 	if updateErr != nil {
1049
 	washpipe_nurse, _ := this.GetInt64("washpipe_nurse")
1050
 	washpipe_nurse, _ := this.GetInt64("washpipe_nurse")
1050
 
1051
 
1051
 	schedual_type, _ := this.GetInt64("schedual_type")
1052
 	schedual_type, _ := this.GetInt64("schedual_type")
1052
-
1053
+	change_nurse, _ := this.GetInt64("change_nurse")
1053
 	if record_id == 0 {
1054
 	if record_id == 0 {
1054
 		this.ErrorLog("id:%v", record_id)
1055
 		this.ErrorLog("id:%v", record_id)
1055
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1056
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1178
 		Modifier:      adminUserInfo.AdminUser.Id,
1179
 		Modifier:      adminUserInfo.AdminUser.Id,
1179
 		SchedualType:  schedual_type,
1180
 		SchedualType:  schedual_type,
1180
 		WashpipeNurse: washpipe_nurse,
1181
 		WashpipeNurse: washpipe_nurse,
1182
+		ChangeNurse:   change_nurse,
1181
 	}
1183
 	}
1182
 
1184
 
1183
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
1185
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)

+ 183 - 0
controllers/gobal_config_api_controller.go Ver fichero

72
 	beego.Router("/api/passdetail/export", &GobalConfigApiController{}, "get:GetPassExportData")
72
 	beego.Router("/api/passdetail/export", &GobalConfigApiController{}, "get:GetPassExportData")
73
 	beego.Router("/api/consumedetail/export", &GobalConfigApiController{}, "get:GetExportData")
73
 	beego.Router("/api/consumedetail/export", &GobalConfigApiController{}, "get:GetExportData")
74
 
74
 
75
+	beego.Router("/api/drugstock/getdrugindetail", &GobalConfigApiController{}, "get:GetDrugInDetail")
76
+
77
+	beego.Router("/api/drugstock/getdrugcancelorder", &GobalConfigApiController{}, "get:GetDrugCancelOrder")
78
+
79
+	beego.Router("/api/drugstock/getdrugoutdetail", &GobalConfigApiController{}, "get:GetDrugOutDetail")
80
+
81
+	beego.Router("/api/drugstock/getdrugcanceldetail", &GobalConfigApiController{}, "get:GetDrugCancelDetail")
75
 }
82
 }
76
 
83
 
77
 //provinces, _ := service.GetDistrictsByUpid(0)21
84
 //provinces, _ := service.GetDistrictsByUpid(0)21
1406
 	})
1413
 	})
1407
 
1414
 
1408
 }
1415
 }
1416
+
1417
+func (c *GobalConfigApiController) GetDrugInDetail() {
1418
+
1419
+	start_time := c.GetString("start_time")
1420
+	end_time := c.GetString("end_time")
1421
+	timeLayout := "2006-01-02"
1422
+	loc, _ := time.LoadLocation("Local")
1423
+	var startTime int64
1424
+	if len(start_time) > 0 {
1425
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1426
+		if err != nil {
1427
+			fmt.Println(err)
1428
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1429
+			return
1430
+		}
1431
+		startTime = theTime.Unix()
1432
+	}
1433
+	var endTime int64
1434
+	if len(end_time) > 0 {
1435
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
1436
+		if err != nil {
1437
+			utils.ErrorLog(err.Error())
1438
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1439
+			return
1440
+		}
1441
+		endTime = theTime.Unix()
1442
+	}
1443
+	adminInfo := c.GetAdminUserInfo()
1444
+	order_type, _ := c.GetInt64("order_type")
1445
+	manufacturer_id, _ := c.GetInt64("manufacturer_id")
1446
+	keyword := c.GetString("keyword")
1447
+	page, _ := c.GetInt64("page")
1448
+	limit, _ := c.GetInt64("limit")
1449
+
1450
+	detail, total, err := service.GetDrugInOrderDetail(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit)
1451
+
1452
+	if err != nil {
1453
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1454
+		return
1455
+	}
1456
+	c.ServeSuccessJSON(map[string]interface{}{
1457
+		"detail": detail,
1458
+		"total":  total,
1459
+	})
1460
+}
1461
+
1462
+func (c *GobalConfigApiController) GetDrugCancelOrder() {
1463
+
1464
+	start_time := c.GetString("start_time")
1465
+	end_time := c.GetString("end_time")
1466
+	timeLayout := "2006-01-02"
1467
+	loc, _ := time.LoadLocation("Local")
1468
+	var startTime int64
1469
+	if len(start_time) > 0 {
1470
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1471
+		if err != nil {
1472
+			fmt.Println(err)
1473
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1474
+			return
1475
+		}
1476
+		startTime = theTime.Unix()
1477
+	}
1478
+	var endTime int64
1479
+	if len(end_time) > 0 {
1480
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
1481
+		if err != nil {
1482
+			utils.ErrorLog(err.Error())
1483
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1484
+			return
1485
+		}
1486
+		endTime = theTime.Unix()
1487
+	}
1488
+	adminInfo := c.GetAdminUserInfo()
1489
+	order_type, _ := c.GetInt64("order_type")
1490
+	manufacturer_id, _ := c.GetInt64("manufacturer_id")
1491
+	keyword := c.GetString("keyword")
1492
+	limit, _ := c.GetInt64("limit")
1493
+	page, _ := c.GetInt64("page")
1494
+
1495
+	order, total, err := service.GetDrugReturnOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, limit, page)
1496
+	if err != nil {
1497
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1498
+		return
1499
+	}
1500
+	c.ServeSuccessJSON(map[string]interface{}{
1501
+		"order": order,
1502
+		"total": total,
1503
+	})
1504
+}
1505
+
1506
+func (c *GobalConfigApiController) GetDrugOutDetail() {
1507
+
1508
+	start_time := c.GetString("start_time")
1509
+	end_time := c.GetString("end_time")
1510
+	timeLayout := "2006-01-02"
1511
+	loc, _ := time.LoadLocation("Local")
1512
+	var startTime int64
1513
+	if len(start_time) > 0 {
1514
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1515
+		if err != nil {
1516
+			fmt.Println(err)
1517
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1518
+			return
1519
+		}
1520
+		startTime = theTime.Unix()
1521
+	}
1522
+	var endTime int64
1523
+	if len(end_time) > 0 {
1524
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
1525
+		if err != nil {
1526
+			utils.ErrorLog(err.Error())
1527
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1528
+			return
1529
+		}
1530
+		endTime = theTime.Unix()
1531
+	}
1532
+	adminInfo := c.GetAdminUserInfo()
1533
+	order_type, _ := c.GetInt64("order_type")
1534
+	manufacturer_id, _ := c.GetInt64("manufacturer_id")
1535
+	keyword := c.GetString("keyword")
1536
+	limit, _ := c.GetInt64("limit")
1537
+	page, _ := c.GetInt64("page")
1538
+
1539
+	order, total, err := service.GetDrugOutOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit)
1540
+	if err != nil {
1541
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1542
+		return
1543
+	}
1544
+	c.ServeSuccessJSON(map[string]interface{}{
1545
+		"order": order,
1546
+		"total": total,
1547
+	})
1548
+}
1549
+
1550
+func (c *GobalConfigApiController) GetDrugCancelDetail() {
1551
+
1552
+	start_time := c.GetString("start_time")
1553
+	end_time := c.GetString("end_time")
1554
+	timeLayout := "2006-01-02"
1555
+	loc, _ := time.LoadLocation("Local")
1556
+	var startTime int64
1557
+	if len(start_time) > 0 {
1558
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1559
+		if err != nil {
1560
+			fmt.Println(err)
1561
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1562
+			return
1563
+		}
1564
+		startTime = theTime.Unix()
1565
+	}
1566
+	var endTime int64
1567
+	if len(end_time) > 0 {
1568
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
1569
+		if err != nil {
1570
+			utils.ErrorLog(err.Error())
1571
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1572
+			return
1573
+		}
1574
+		endTime = theTime.Unix()
1575
+	}
1576
+	adminInfo := c.GetAdminUserInfo()
1577
+	order_type, _ := c.GetInt64("order_type")
1578
+	manufacturer_id, _ := c.GetInt64("manufacturer_id")
1579
+	keyword := c.GetString("keyword")
1580
+	limit, _ := c.GetInt64("limit")
1581
+	page, _ := c.GetInt64("page")
1582
+	order, total, err := service.GetDrugCancelOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit)
1583
+	if err != nil {
1584
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1585
+		return
1586
+	}
1587
+	c.ServeSuccessJSON(map[string]interface{}{
1588
+		"order": order,
1589
+		"total": total,
1590
+	})
1591
+}

+ 17 - 16
controllers/mobile_api_controllers/check_weight_api_controller.go Ver fichero

619
 			}
619
 			}
620
 
620
 
621
 			if lastPredialysisEvaluation != nil {
621
 			if lastPredialysisEvaluation != nil {
622
-				evaluation.BloodAccessPartId = lastPredialysisEvaluation.BloodAccessPartId           //血管通路部位
623
-				evaluation.BloodAccessPartOperaId = lastPredialysisEvaluation.BloodAccessPartOperaId //血管通路
624
-				evaluation.AdditionalWeight = lastPredialysisEvaluation.AdditionalWeight             //衣物重
625
-				evaluation.Temperature = lastPredialysisEvaluation.Temperature                       //温度
626
-				evaluation.BreathingRate = lastPredialysisEvaluation.BreathingRate                   //呼吸
627
-				evaluation.Catheter = lastPredialysisEvaluation.Catheter                             //导管
628
-				evaluation.InternalFistula = lastPredialysisEvaluation.InternalFistula               //内瘘
629
-				evaluation.PulseFrequency = lastPredialysisEvaluation.PulseFrequency                 //脉搏
630
-				evaluation.Complication = lastPredialysisEvaluation.Complication                     //并发症
631
-				evaluation.LastPostDialysis = lastPredialysisEvaluation.LastPostDialysis             //前次透析后症状
632
-				evaluation.DialysisInterphase = lastPredialysisEvaluation.DialysisInterphase         //透析期间
633
-				evaluation.SymptomBeforeDialysis = lastPredialysisEvaluation.SymptomBeforeDialysis   //透析前症状
634
-				evaluation.PunctureNeedle = lastPredialysisEvaluation.PunctureNeedle                 //穿刺针
635
-				evaluation.PunctureWay = lastPredialysisEvaluation.PunctureWay                       //穿刺方法
622
+				evaluation.BloodAccessPartId = lastPredialysisEvaluation.BloodAccessPartId
623
+				evaluation.BloodAccessPartOperaId = lastPredialysisEvaluation.BloodAccessPartOperaId
624
+				evaluation.AdditionalWeight = lastPredialysisEvaluation.AdditionalWeight
625
+				evaluation.Temperature = lastPredialysisEvaluation.Temperature
626
+				evaluation.BreathingRate = lastPredialysisEvaluation.BreathingRate
627
+				evaluation.Catheter = lastPredialysisEvaluation.Catheter
628
+				evaluation.InternalFistula = lastPredialysisEvaluation.InternalFistula
629
+				evaluation.PulseFrequency = lastPredialysisEvaluation.PulseFrequency
630
+				evaluation.Complication = lastPredialysisEvaluation.Complication
631
+				evaluation.LastPostDialysis = lastPredialysisEvaluation.LastPostDialysis
632
+				evaluation.DialysisInterphase = lastPredialysisEvaluation.DialysisInterphase
633
+				evaluation.SymptomBeforeDialysis = lastPredialysisEvaluation.SymptomBeforeDialysis
634
+				evaluation.PunctureNeedle = lastPredialysisEvaluation.PunctureNeedle
635
+				evaluation.PunctureWay = lastPredialysisEvaluation.PunctureWay
636
 
636
 
637
 				evaluation.InternalFistulaSkin = lastPredialysisEvaluation.InternalFistulaSkin //血透通路皮肤情况
637
 				evaluation.InternalFistulaSkin = lastPredialysisEvaluation.InternalFistulaSkin //血透通路皮肤情况
638
 				evaluation.CatheterBend = lastPredialysisEvaluation.CatheterBend               //导管打折
638
 				evaluation.CatheterBend = lastPredialysisEvaluation.CatheterBend               //导管打折
639
 				evaluation.IsHemorrhage = lastPredialysisEvaluation.IsHemorrhage               //出血
639
 				evaluation.IsHemorrhage = lastPredialysisEvaluation.IsHemorrhage               //出血
640
 				evaluation.IsInfect = lastPredialysisEvaluation.IsInfect                       //感染
640
 				evaluation.IsInfect = lastPredialysisEvaluation.IsInfect                       //感染
641
 				evaluation.Exposed = lastPredialysisEvaluation.Exposed                         // 外漏
641
 				evaluation.Exposed = lastPredialysisEvaluation.Exposed                         // 外漏
642
+				evaluation.DialysisCount = lastPredialysisEvaluation.DialysisCount             //呼吸频次
643
+				evaluation.Phinholing = lastPredialysisEvaluation.Phinholing
642
 
644
 
643
 			}
645
 			}
644
 		} else {
646
 		} else {
736
 	adminUserInfo := c.GetMobileAdminUserInfo()
738
 	adminUserInfo := c.GetMobileAdminUserInfo()
737
 
739
 
738
 	patientList, total, error := service.GetPatientListByUpdateTime(adminUserInfo.Org.Id, int64(syncTime))
740
 	patientList, total, error := service.GetPatientListByUpdateTime(adminUserInfo.Org.Id, int64(syncTime))
739
-	if len(patientList) > 0 {
740
 	need_update := 0
741
 	need_update := 0
741
-	if syncTime ==  0 {
742
+	if syncTime == 0 {
742
 		need_update = 1
743
 		need_update = 1
743
 	}
744
 	}
744
 	if error != nil {
745
 	if error != nil {

+ 27 - 20
controllers/mobile_api_controllers/dialysis_api_controller.go Ver fichero

13
 	"XT_New/models"
13
 	"XT_New/models"
14
 	"XT_New/service"
14
 	"XT_New/service"
15
 	"XT_New/utils"
15
 	"XT_New/utils"
16
+	"github.com/astaxie/beego"
16
 	"math"
17
 	"math"
17
 	"net/http"
18
 	"net/http"
18
 	"net/url"
19
 	"net/url"
19
-	"github.com/astaxie/beego"
20
 )
20
 )
21
 
21
 
22
 // type DialysisTestAPIController struct {
22
 // type DialysisTestAPIController struct {
1064
 	blood := c.GetString("blood")
1064
 	blood := c.GetString("blood")
1065
 	dialysis_dialyszers := c.GetString("dialysis_dialyszers")
1065
 	dialysis_dialyszers := c.GetString("dialysis_dialyszers")
1066
 	dialysis_irrigation := c.GetString("dialysis_irrigation")
1066
 	dialysis_irrigation := c.GetString("dialysis_irrigation")
1067
+	antioxidant_commodity_name := c.GetString("antioxidant_commodity_name")
1067
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
1068
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
1068
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
1069
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
1069
 	//
1070
 	//
1149
 		Blood:                      blood,
1150
 		Blood:                      blood,
1150
 		DialysisDialyszers:         dialysis_dialyszers,
1151
 		DialysisDialyszers:         dialysis_dialyszers,
1151
 		DialysisIrrigation:         dialysis_irrigation,
1152
 		DialysisIrrigation:         dialysis_irrigation,
1153
+		AntioxidantCommodityName:   antioxidant_commodity_name,
1152
 	}
1154
 	}
1153
 
1155
 
1154
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1156
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1448
 		dialysisOrder.FinishModifier = adminUserInfo.AdminUser.Id
1450
 		dialysisOrder.FinishModifier = adminUserInfo.AdminUser.Id
1449
 		dialysisOrder.EndTime = endDate.Unix()
1451
 		dialysisOrder.EndTime = endDate.Unix()
1450
 
1452
 
1451
-		go func (){
1453
+		go func() {
1452
 			ssoDomain := beego.AppConfig.String("call_domain")
1454
 			ssoDomain := beego.AppConfig.String("call_domain")
1453
 			api := ssoDomain + "/index/downpatient"
1455
 			api := ssoDomain + "/index/downpatient"
1454
 			values := make(url.Values)
1456
 			values := make(url.Values)
1455
-			values.Set("org_id",  strconv.FormatInt(adminUserInfo.AdminUser.Id,10))
1456
-			values.Set("admin_user_id", strconv.FormatInt(nurseID,10))
1457
-			values.Set("patient_id",  strconv.FormatInt(id,10))
1457
+			values.Set("org_id", strconv.FormatInt(adminUserInfo.AdminUser.Id, 10))
1458
+			values.Set("admin_user_id", strconv.FormatInt(nurseID, 10))
1459
+			values.Set("patient_id", strconv.FormatInt(id, 10))
1458
 			http.PostForm(api, values)
1460
 			http.PostForm(api, values)
1459
-		} ()
1461
+		}()
1460
 
1462
 
1461
 		if err == nil {
1463
 		if err == nil {
1462
 			c.ServeSuccessJSON(map[string]interface{}{
1464
 			c.ServeSuccessJSON(map[string]interface{}{
1515
 	bedID, _ := this.GetInt64("bed")
1517
 	bedID, _ := this.GetInt64("bed")
1516
 	start_time := this.GetString("start_time")
1518
 	start_time := this.GetString("start_time")
1517
 	washpipe_nurse, _ := this.GetInt64("washpipe_nurse")
1519
 	washpipe_nurse, _ := this.GetInt64("washpipe_nurse")
1518
-
1520
+	change_nurse, _ := this.GetInt64("change_nurse")
1519
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
1521
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
1520
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1522
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1521
 		return
1523
 		return
1683
 		Modifier:      adminUserInfo.AdminUser.Id,
1685
 		Modifier:      adminUserInfo.AdminUser.Id,
1684
 		SchedualType:  schedual_type,
1686
 		SchedualType:  schedual_type,
1685
 		WashpipeNurse: washpipe_nurse,
1687
 		WashpipeNurse: washpipe_nurse,
1688
+		ChangeNurse:   change_nurse,
1686
 	}
1689
 	}
1687
 
1690
 
1688
 	createErr := service.MobileCreateDialysisOrder(adminUserInfo.Org.Id, patientID, dialysisRecord)
1691
 	createErr := service.MobileCreateDialysisOrder(adminUserInfo.Org.Id, patientID, dialysisRecord)
1700
 		if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
1703
 		if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
1701
 
1704
 
1702
 			totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
1705
 			totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
1703
-			if template.TemplateId == 6 { //adminUserInfo.Org.Id == 9538
1706
+			if template.TemplateId == 6 || template.TemplateId == 32 { //adminUserInfo.Org.Id == 9538
1704
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
1707
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
1705
 			}
1708
 			}
1706
 
1709
 
1733
 	}
1736
 	}
1734
 
1737
 
1735
 	//只针对广慈医院
1738
 	//只针对广慈医院
1736
-	if template.TemplateId == 26 || template.TemplateId == 25 || template.TemplateId == 28 || adminUserInfo.Org.Id == 9987 || adminUserInfo.Org.Id == 9526 {
1739
+	if template.TemplateId == 26 || template.TemplateId == 25 || template.TemplateId == 28 || adminUserInfo.Org.Id == 9987 || adminUserInfo.Org.Id == 9526 || template.TemplateId == 32 {
1737
 		// 查询病人是否有透前评估数据
1740
 		// 查询病人是否有透前评估数据
1738
 		befor, errcode := service.GetAssessmentBefor(adminUserInfo.Org.Id, patientID, recordDate.Unix())
1741
 		befor, errcode := service.GetAssessmentBefor(adminUserInfo.Org.Id, patientID, recordDate.Unix())
1739
 		//如果有数据就插入
1742
 		//如果有数据就插入
1755
 		}
1758
 		}
1756
 	}
1759
 	}
1757
 
1760
 
1758
-	go func (){
1761
+	go func() {
1759
 		ssoDomain := beego.AppConfig.String("call_domain")
1762
 		ssoDomain := beego.AppConfig.String("call_domain")
1760
 		api := ssoDomain + "/index/uppatient"
1763
 		api := ssoDomain + "/index/uppatient"
1761
 		values := make(url.Values)
1764
 		values := make(url.Values)
1762
-		values.Set("org_id",  strconv.FormatInt(adminUserInfo.Org.Id,10))
1763
-		values.Set("admin_user_id", strconv.FormatInt(nurseID,10))
1764
-		values.Set("patient_id",  strconv.FormatInt(patientID,10))
1765
-		values.Set("up_time",  strconv.FormatInt(startDate.Unix(),10))
1765
+		values.Set("org_id", strconv.FormatInt(adminUserInfo.Org.Id, 10))
1766
+		values.Set("admin_user_id", strconv.FormatInt(nurseID, 10))
1767
+		values.Set("patient_id", strconv.FormatInt(patientID, 10))
1768
+		values.Set("up_time", strconv.FormatInt(startDate.Unix(), 10))
1766
 		http.PostForm(api, values)
1769
 		http.PostForm(api, values)
1767
-	} ()
1770
+	}()
1768
 
1771
 
1769
 	if createErr != nil {
1772
 	if createErr != nil {
1770
 		this.ErrorLog("上机失败:%v", createErr)
1773
 		this.ErrorLog("上机失败:%v", createErr)
1864
 	blood := c.GetString("blood")
1867
 	blood := c.GetString("blood")
1865
 	dialysis_dialyszers := c.GetString("dialysis_dialyszers")
1868
 	dialysis_dialyszers := c.GetString("dialysis_dialyszers")
1866
 	dialysis_irrigation := c.GetString("dialysis_irrigation")
1869
 	dialysis_irrigation := c.GetString("dialysis_irrigation")
1870
+	antioxidant_commodity_name := c.GetString("antioxidant_commodity_name")
1867
 	if mode_id > 0 {
1871
 	if mode_id > 0 {
1868
 		service.ModifyScheduleMode(mode_id, patient.ID, recordDate.Unix(), adminUserInfo.Org.Id)
1872
 		service.ModifyScheduleMode(mode_id, patient.ID, recordDate.Unix(), adminUserInfo.Org.Id)
1869
 	}
1873
 	}
1950
 		Blood:                     blood,
1954
 		Blood:                     blood,
1951
 		DialysisDialyszers:        dialysis_dialyszers,
1955
 		DialysisDialyszers:        dialysis_dialyszers,
1952
 		DialysisIrrigation:        dialysis_irrigation,
1956
 		DialysisIrrigation:        dialysis_irrigation,
1957
+		AntioxidantCommodityName:  antioxidant_commodity_name,
1953
 	}
1958
 	}
1954
 
1959
 
1955
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1960
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
2120
 			fmt.Println("4444444445555")
2125
 			fmt.Println("4444444445555")
2121
 
2126
 
2122
 			totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
2127
 			totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
2123
-			if template.TemplateId == 6 {
2128
+			if template.TemplateId == 6 || template.TemplateId == 32 {
2124
 				fmt.Println("12222222")
2129
 				fmt.Println("12222222")
2125
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
2130
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
2126
 				record.UltrafiltrationRate = ultrafiltration_rate
2131
 				record.UltrafiltrationRate = ultrafiltration_rate
2148
 		}
2153
 		}
2149
 	}
2154
 	}
2150
 
2155
 
2151
-	if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 { //adminInfo.Org.Id == 9538
2156
+	if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 { //adminInfo.Org.Id == 9538
2152
 		if ultrafiltration_rate > 0 && adminInfo.Org.Id != 9538 {
2157
 		if ultrafiltration_rate > 0 && adminInfo.Org.Id != 9538 {
2153
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
2158
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
2154
 			record.UltrafiltrationVolume = ultrafiltration_volume
2159
 			record.UltrafiltrationVolume = ultrafiltration_volume
2169
 	start_time := this.GetString("start_time")
2174
 	start_time := this.GetString("start_time")
2170
 	schedual_type, _ := this.GetInt64("schedual_type")
2175
 	schedual_type, _ := this.GetInt64("schedual_type")
2171
 	washpipe_nurse, _ := this.GetInt64("washpipe_nurse")
2176
 	washpipe_nurse, _ := this.GetInt64("washpipe_nurse")
2172
-
2177
+	change_nurse, _ := this.GetInt64("change_nurse")
2173
 	if record_id == 0 {
2178
 	if record_id == 0 {
2174
 		this.ErrorLog("id:%v", record_id)
2179
 		this.ErrorLog("id:%v", record_id)
2175
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2180
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2298
 		Modifier:      adminUserInfo.AdminUser.Id,
2303
 		Modifier:      adminUserInfo.AdminUser.Id,
2299
 		WashpipeNurse: washpipe_nurse,
2304
 		WashpipeNurse: washpipe_nurse,
2300
 		SchedualType:  schedual_type,
2305
 		SchedualType:  schedual_type,
2306
+		ChangeNurse:   change_nurse,
2301
 	}
2307
 	}
2302
 
2308
 
2303
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
2309
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
4046
 
4052
 
4047
 	adminUser := c.GetMobileAdminUserInfo()
4053
 	adminUser := c.GetMobileAdminUserInfo()
4048
 	outInfo, err := service.MobileGetGoodsStatistics(adminUser.Org.Id, theStartTime, theEndtTime)
4054
 	outInfo, err := service.MobileGetGoodsStatistics(adminUser.Org.Id, theStartTime, theEndtTime)
4049
-
4055
+	stockCount, err := service.GetOutStockTotalCountOne(theStartTime, theEndtTime, adminUser.Org.Id)
4050
 	if err == nil {
4056
 	if err == nil {
4051
 		c.ServeSuccessJSON(map[string]interface{}{
4057
 		c.ServeSuccessJSON(map[string]interface{}{
4052
-			"stock_out": outInfo,
4058
+			"stock_out":  outInfo,
4059
+			"stockCount": stockCount,
4053
 		})
4060
 		})
4054
 		return
4061
 		return
4055
 
4062
 

+ 82 - 82
controllers/patient_api_controller.go Ver fichero

254
 	//获取老表的最后一条数据
254
 	//获取老表的最后一条数据
255
 	patients, err := service.GetLastPatientData(adminUserInfo.CurrentOrgId)
255
 	patients, err := service.GetLastPatientData(adminUserInfo.CurrentOrgId)
256
 	patientsNew := models.XtPatientsNew{
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
 		HealthCareDueAlertDate:       patients.HealthCareDueAlertDate,
280
 		HealthCareDueAlertDate:       patients.HealthCareDueAlertDate,
281
 		EducationLevel:               patients.EducationLevel,
281
 		EducationLevel:               patients.EducationLevel,
282
 		Profession:                   patients.Profession,
282
 		Profession:                   patients.Profession,
322
 		Nation:                       patients.Nation,
322
 		Nation:                       patients.Nation,
323
 		NativePlace:                  patients.NativePlace,
323
 		NativePlace:                  patients.NativePlace,
324
 		Age:                          patients.Age,
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
 	err = service.CreatePatientsNew(&patientsNew)
349
 	err = service.CreatePatientsNew(&patientsNew)
481
 		return
481
 		return
482
 	}
482
 	}
483
 	patientsNew := models.XtPatientsNew{
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
 		HealthCareDueAlertDate:    patient.HealthCareDueAlertDate,
506
 		HealthCareDueAlertDate:    patient.HealthCareDueAlertDate,
507
 		EducationLevel:            patient.EducationLevel,
507
 		EducationLevel:            patient.EducationLevel,
508
 		Profession:                patient.Profession,
508
 		Profession:                patient.Profession,
544
 		Nation:                    patient.Nation,
544
 		Nation:                    patient.Nation,
545
 		NativePlace:               patient.NativePlace,
545
 		NativePlace:               patient.NativePlace,
546
 		Age:                       patient.Age,
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
 	//	//更新病人ID获取新表病人ID
561
 	//	//更新病人ID获取新表病人ID
562
 	err = service.UpdatepatientTwo(&patientsNew, id)
562
 	err = service.UpdatepatientTwo(&patientsNew, id)
659
 		return
659
 		return
660
 	}
660
 	}
661
 	lapsetoType := int64(patientBody["lapseto_type"].(float64))
661
 	lapsetoType := int64(patientBody["lapseto_type"].(float64))
662
-	if lapsetoType <= 0 || lapsetoType >= 3 {
663
-		utils.ErrorLog("lapsetoType <= 0 || lapsetoType >= 3")
662
+	if lapsetoType <= 0 || lapsetoType > 3 {
663
+		utils.ErrorLog("lapsetoType <= 0 || lapsetoType > 3")
664
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
664
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
665
 		return
665
 		return
666
 	}
666
 	}

+ 4 - 3
controllers/print_data_api_controller.go Ver fichero

91
 	}
91
 	}
92
 
92
 
93
 	list, err := service.FindPrintStockGoodInfoByType(types, startTime, endTime, adminUserInfo.CurrentOrgId)
93
 	list, err := service.FindPrintStockGoodInfoByType(types, startTime, endTime, adminUserInfo.CurrentOrgId)
94
-
94
+	stockTotal, err := service.GetOutStockTotalCountTwo(startTime, endTime, adminUserInfo.CurrentOrgId)
95
 	if err != nil {
95
 	if err != nil {
96
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
96
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
97
 	} else {
97
 	} else {
98
 		this.ServeSuccessJSON(map[string]interface{}{
98
 		this.ServeSuccessJSON(map[string]interface{}{
99
-			"list": list,
100
-			"type": types,
99
+			"list":       list,
100
+			"type":       types,
101
+			"stockTotal": stockTotal,
101
 		})
102
 		})
102
 	}
103
 	}
103
 }
104
 }

+ 58 - 0
controllers/schedule_api_controller.go Ver fichero

40
 
40
 
41
 	beego.Router("/api/schedule_template/cancel", &ScheduleApiController{}, "post:CancelScheduleTemplate")
41
 	beego.Router("/api/schedule_template/cancel", &ScheduleApiController{}, "post:CancelScheduleTemplate")
42
 	beego.Router("/api/schedule/getnextscheduleweekday", &ScheduleApiController{}, "Get:GetNextWeekDaySchedule")
42
 	beego.Router("/api/schedule/getnextscheduleweekday", &ScheduleApiController{}, "Get:GetNextWeekDaySchedule")
43
+
44
+	beego.Router("/api/schedule/getthreeweeklist", &ScheduleApiController{}, "Get:GetThreeWeekList")
45
+
46
+	beego.Router("/api/schedule/getallzones", &ScheduleApiController{}, "Get:GetAllZones")
43
 }
47
 }
44
 
48
 
45
 func (c *ScheduleApiController) GetWeekPanels() {
49
 func (c *ScheduleApiController) GetWeekPanels() {
1915
 		"schedule": schedule,
1919
 		"schedule": schedule,
1916
 	})
1920
 	})
1917
 }
1921
 }
1922
+
1923
+func (this *ScheduleApiController) GetThreeWeekList() {
1924
+	start_time := this.GetString("start_time")
1925
+	end_time := this.GetString("end_time")
1926
+	partition_id, _ := this.GetInt64("partition_id")
1927
+	schedule_type, _ := this.GetInt64("schedule_type")
1928
+	fmt.Println(partition_id, schedule_type)
1929
+	timeLayout := "2006-01-02"
1930
+	loc, _ := time.LoadLocation("Local")
1931
+
1932
+	var theStartTIme int64
1933
+	if len(start_time) > 0 {
1934
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1935
+		if err != nil {
1936
+			utils.ErrorLog(err.Error())
1937
+		}
1938
+		theStartTIme = theTime.Unix()
1939
+	}
1940
+	var theEndtTIme int64
1941
+	if len(end_time) > 0 {
1942
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
1943
+		if err != nil {
1944
+			utils.ErrorLog(err.Error())
1945
+		}
1946
+		theEndtTIme = theTime.Unix()
1947
+	}
1948
+
1949
+	adminUserInfo := this.GetAdminUserInfo()
1950
+	orgId := adminUserInfo.CurrentOrgId
1951
+	partitions, _ := service.GetSchedulePartitionPanel(orgId)
1952
+	list, err := service.GetThreeWeekList(theStartTIme, theEndtTIme, orgId, schedule_type, partition_id)
1953
+	if err != nil {
1954
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1955
+		return
1956
+	}
1957
+	this.ServeSuccessJSON(map[string]interface{}{
1958
+		"list":       list,
1959
+		"partitions": partitions,
1960
+	})
1961
+}
1962
+
1963
+func (this *ScheduleApiController) GetAllZones() {
1964
+
1965
+	adminUserInfo := this.GetAdminUserInfo()
1966
+	orgId := adminUserInfo.CurrentOrgId
1967
+	zones, err := service.GetAllZoneOne(orgId)
1968
+	if err != nil {
1969
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1970
+		return
1971
+	}
1972
+	this.ServeSuccessJSON(map[string]interface{}{
1973
+		"zones": zones,
1974
+	})
1975
+}

+ 32 - 0
controllers/self_drug_api_congtroller.go Ver fichero

51
 	beego.Router("/api/drug/deleteDrugNamebyid", &SelfDrugApiController{}, "Get:DeleteDrugNameById")
51
 	beego.Router("/api/drug/deleteDrugNamebyid", &SelfDrugApiController{}, "Get:DeleteDrugNameById")
52
 	beego.Router("/api/drug/getpatientdetail", &SelfDrugApiController{}, "Get:GetPatientDetail")
52
 	beego.Router("/api/drug/getpatientdetail", &SelfDrugApiController{}, "Get:GetPatientDetail")
53
 	//beego.Router("/api/drug/getpatientdetail",&SelfDrugApiController{},"Get:ToPatientDetail")
53
 	//beego.Router("/api/drug/getpatientdetail",&SelfDrugApiController{},"Get:ToPatientDetail")
54
+	beego.Router("/api/drug/getselfstockquery", &SelfDrugApiController{}, "Get:GetSelfStockQuery")
54
 }
55
 }
55
 
56
 
56
 func (this *SelfDrugApiController) GetCurrentPatient() {
57
 func (this *SelfDrugApiController) GetCurrentPatient() {
881
 //    "patient": patient,
882
 //    "patient": patient,
882
 //  })
883
 //  })
883
 //}
884
 //}
885
+
886
+func (this *SelfDrugApiController) GetSelfStockQuery() {
887
+
888
+	adminUserInfo := this.GetAdminUserInfo()
889
+	orgId := adminUserInfo.CurrentOrgId
890
+	type_name, _ := this.GetInt64("type_name")
891
+	keywords := this.GetString("keywords")
892
+	timeLayout := "2006-01-02"
893
+	loc, _ := time.LoadLocation("Local")
894
+	start_time := this.GetString("start_time")
895
+	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
896
+	startUnix := theTime.Unix()
897
+	end_time := this.GetString("end_time")
898
+	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
899
+	endTimeUnix := endTimes.Unix()
900
+	page, _ := this.GetInt64("page")
901
+	limit, _ := this.GetInt64("limit")
902
+	//统计入库数量
903
+	stockQuery, total, err := service.GetSelfStockQuery(type_name, keywords, startUnix, endTimeUnix, orgId, limit, page)
904
+	//统计出库数量
905
+	stockOutQuery, err := service.GetSelfOutStockQuery(startUnix, endTimeUnix, orgId)
906
+	if err != nil {
907
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
908
+		return
909
+	}
910
+	this.ServeSuccessJSON(map[string]interface{}{
911
+		"stockQuery":    stockQuery,
912
+		"total":         total,
913
+		"stockOutQuery": stockOutQuery,
914
+	})
915
+}

+ 11 - 0
models/device_models.go Ver fichero

881
 
881
 
882
 	return "xt_device_information"
882
 	return "xt_device_information"
883
 }
883
 }
884
+
885
+type VmSchedule struct {
886
+	ScheduleDate int64  `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
887
+	ScheduleType int64  `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
888
+	ScheduleWeek int64  `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
889
+	BedId        int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
890
+	Partition    int64  `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
891
+	Name         string `gorm:"column:name" json:"name" form:"name"`
892
+	Number       string `gorm:"column:number" json:"number" form:"number"`
893
+	ZoneName     string `gorm:"column:name" json:"zon_name" form:"name"`
894
+}

+ 1 - 0
models/dialysis.go Ver fichero

736
 	SchedualType   int64         `gorm:"column:schedual_type" json:"schedual_type"`
736
 	SchedualType   int64         `gorm:"column:schedual_type" json:"schedual_type"`
737
 	UserAdminRole  UserAdminRole `json:"role" gorm:"foreignkey:AdminUserId;AssociationForeignKey:StartNurse;"`
737
 	UserAdminRole  UserAdminRole `json:"role" gorm:"foreignkey:AdminUserId;AssociationForeignKey:StartNurse;"`
738
 	WashpipeNurse  int64         `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
738
 	WashpipeNurse  int64         `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
739
+	ChangeNurse    int64         `gorm:"column:change_nurse" json:"change_nurse" form:"change_nurse"`
739
 }
740
 }
740
 
741
 
741
 func (DialysisOrder) TableName() string {
742
 func (DialysisOrder) TableName() string {

+ 10 - 7
models/patient_models.go Ver fichero

227
 	Blood                      string        `gorm:"column:blood" json:"blood"`
227
 	Blood                      string        `gorm:"column:blood" json:"blood"`
228
 	DialysisDialyszers         string        `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
228
 	DialysisDialyszers         string        `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
229
 	DialysisIrrigation         string        `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
229
 	DialysisIrrigation         string        `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
230
+	AntioxidantCommodityName   string        `gorm:"column:antioxidant_commodity_name" json:"antioxidant_commodity_name" form:"antioxidant_commodity_name"`
230
 }
231
 }
231
 
232
 
232
 func (DialysisPrescription) TableName() string {
233
 func (DialysisPrescription) TableName() string {
234
 }
235
 }
235
 
236
 
236
 type DialysisPrescriptionList struct {
237
 type DialysisPrescriptionList struct {
237
-	ID                         int64  `gorm:"column:id" json:"id"`
238
-	UserOrgId                  int64  `gorm:"column:user_org_id" json:"user_org_id"`
239
-	PatientId                  int64  `gorm:"column:patient_id" json:"patient_id"`
240
-	RecordDate                 int64  `gorm:"column:record_date" json:"record_date"`
241
-	RecordId                   int64  `gorm:"column:record_id" json:"record_id"`
242
-	Creater                    int64  `gorm:"column:creater" json:"creater"`
243
-	DialyzerPerfusionApparatus string `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus" form:"dialyzer_perfusion_apparatus"`
238
+	ID                         int64   `gorm:"column:id" json:"id"`
239
+	UserOrgId                  int64   `gorm:"column:user_org_id" json:"user_org_id"`
240
+	PatientId                  int64   `gorm:"column:patient_id" json:"patient_id"`
241
+	RecordDate                 int64   `gorm:"column:record_date" json:"record_date"`
242
+	RecordId                   int64   `gorm:"column:record_id" json:"record_id"`
243
+	Creater                    int64   `gorm:"column:creater" json:"creater"`
244
+	DialyzerPerfusionApparatus string  `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus" form:"dialyzer_perfusion_apparatus"`
245
+	TargetUltrafiltration      float64 `gorm:"column:target_ultrafiltration" json:"target_ultrafiltration"`
246
+	BloodAccess                int64   `gorm:"column:blood_access" json:"blood_access"`
244
 }
247
 }
245
 
248
 
246
 func (DialysisPrescriptionList) TableName() string {
249
 func (DialysisPrescriptionList) TableName() string {

+ 122 - 0
models/self_drug_models.go Ver fichero

410
 func (XtDrugStockConfig) TableName() string {
410
 func (XtDrugStockConfig) TableName() string {
411
 	return "xt_drug_stock_config"
411
 	return "xt_drug_stock_config"
412
 }
412
 }
413
+
414
+type XtSelfOutStockOne struct {
415
+	DrugName   string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
416
+	DrugNameId int64  `gorm:"column:drug_name_id" json:"drug_name_id" form:"drug_name_id"`
417
+	DrugSpec   string `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
418
+	Count      int64
419
+	drug_type  int64 `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
420
+}
421
+
422
+type BloodDrugWarehouseInfo struct {
423
+	ID               int64   `gorm:"column:id" json:"id" form:"id"`
424
+	WarehousingId    int64   `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
425
+	DrugId           int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
426
+	Number           string  `gorm:"column:number" json:"number" form:"number"`
427
+	ProductDate      int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
428
+	ExpiryDate       int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
429
+	WarehousingCount int64   `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
430
+	Price            float64 `gorm:"column:price" json:"price" form:"price"`
431
+	TotalPrice       float64 `gorm:"column:total_price" json:"total_price" form:"total_price"`
432
+	Dealer           int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
433
+	Manufacturer     int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
434
+	Remark           string  `gorm:"column:remark" json:"remark" form:"remark"`
435
+	Ctime            int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
436
+	Mtime            int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
437
+	Status           int64   `gorm:"column:status" json:"status" form:"status"`
438
+	OrgId            int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
439
+	IsReturn         int64   `gorm:"column:is_return" json:"is_return" form:"is_return"`
440
+	WarehousingOrder string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
441
+	Type             int64   `gorm:"column:type" json:"type" form:"type"`
442
+	RetailPrice      float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
443
+	RetailTotalPrice float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
444
+	DrugType         int64   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
445
+	DrugName         string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
446
+	DrugSpec         string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
447
+	Creater          int64   `gorm:"column:creater" json:"creater" form:"creater"`
448
+	MinUnit          string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
449
+}
450
+
451
+type BloodDrugCancelStockInfo struct {
452
+	ID               int64   `gorm:"column:id" json:"id" form:"id"`
453
+	DrugId           int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
454
+	CancelStockId    int64   `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
455
+	Count            int64   `gorm:"column:count" json:"count" form:"count"`
456
+	Price            float64 `gorm:"column:price" json:"price" form:"price"`
457
+	Total            float64 `gorm:"column:total" json:"total" form:"total"`
458
+	ProductDate      int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
459
+	ExpiryDate       int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
460
+	Ctime            int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
461
+	Mtime            int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
462
+	Status           int64   `gorm:"column:status" json:"status" form:"status"`
463
+	OrgId            int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
464
+	OrderNumber      string  `gorm:"column:order_number" json:"order_number" form:"order_number"`
465
+	Type             int64   `gorm:"column:type" json:"type" form:"type"`
466
+	Dealer           int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
467
+	Manufacturer     int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
468
+	RetailPrice      float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
469
+	RetailTotalPrice float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
470
+	Number           string  `gorm:"column:number" json:"number" form:"number"`
471
+	DrugType         int64   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
472
+	DrugName         string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
473
+	DrugSpec         string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
474
+	Creater          int64   `gorm:"column:creater" json:"creater" form:"creater"`
475
+	MinUnit          string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
476
+}
477
+
478
+type BloodDrugSalesReturnInfo struct {
479
+	ID               int64   `gorm:"column:id" json:"id" form:"id"`
480
+	DrugId           int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
481
+	SalesReturnId    int64   `gorm:"column:sales_return_id" json:"sales_return_id" form:"sales_return_id"`
482
+	Count            int64   `gorm:"column:count" json:"count" form:"count"`
483
+	Price            float64 `gorm:"column:price" json:"price" form:"price"`
484
+	Total            float64 `gorm:"column:total" json:"total" form:"total"`
485
+	ProductDate      int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
486
+	ExpiryDate       int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
487
+	Ctime            int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
488
+	Mtime            int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
489
+	Status           int64   `gorm:"column:status" json:"status" form:"status"`
490
+	OrgId            int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
491
+	OrderNumber      string  `gorm:"column:order_number" json:"order_number" form:"order_number"`
492
+	Type             int64   `gorm:"column:type" json:"type" form:"type"`
493
+	Dealer           int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
494
+	Manufacturer     int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
495
+	RetailPrice      float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
496
+	RetailTotalPrice float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
497
+	Number           string  `gorm:"column:number" json:"number" form:"number"`
498
+	DrugType         int64   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
499
+	DrugName         string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
500
+	DrugSpec         string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
501
+	Creater          int64   `gorm:"column:creater" json:"creater" form:"creater"`
502
+	MinUnit          string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
503
+}
504
+
505
+type BloodDrugWarehouseOutInfo struct {
506
+	ID                      int64   `gorm:"column:id" json:"id" form:"id"`
507
+	WarehouseOutId          int64   `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
508
+	DrugId                  int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
509
+	WarehousingOutTarget    int64   `gorm:"column:warehousing_out_target" json:"warehousing_out_target" form:"warehousing_out_target"`
510
+	Count                   int64   `gorm:"column:count" json:"count" form:"count"`
511
+	Price                   float64 `gorm:"column:price" json:"price" form:"price"`
512
+	TotalPrice              float64 `gorm:"column:total_price" json:"total_price" form:"total_price"`
513
+	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
514
+	ExpiryDate              int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
515
+	Mtime                   int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
516
+	Ctime                   int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
517
+	Status                  int64   `gorm:"column:status" json:"status" form:"status"`
518
+	OrgId                   int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
519
+	Remark                  string  `gorm:"column:remark" json:"remark" form:"remark"`
520
+	IsCancel                int64   `gorm:"column:is_cancel" json:"is_cancel" form:"is_cancel"`
521
+	WarehouseOutOrderNumber string  `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
522
+	Type                    int64   `gorm:"column:type" json:"type" form:"type"`
523
+	Dealer                  int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
524
+	Manufacturer            int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
525
+	IsSys                   int64   `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
526
+	SysRecordTime           int64   `gorm:"column:sys_record_time" json:"sys_record_time" form:"sys_record_time"`
527
+	RetailPrice             float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
528
+	RetailTotalPrice        float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
529
+	DrugType                int64   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
530
+	DrugName                string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
531
+	DrugSpec                string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
532
+	Creater                 int64   `gorm:"column:creater" json:"creater" form:"creater"`
533
+	MinUnit                 string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
534
+}

+ 1 - 1
service/dialysis_service.go Ver fichero

637
 		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
637
 		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
638
 		Preload("TreatmentSummary", "status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).
638
 		Preload("TreatmentSummary", "status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).
639
 		Preload("Advices", "status = 1 AND user_org_id = ? AND advice_date = ? ", orgID, scheduleDate).
639
 		Preload("Advices", "status = 1 AND user_org_id = ? AND advice_date = ? ", orgID, scheduleDate).
640
-
640
+		Preload("AssessmentAfterDislysis", "status = 1 AND user_org_id = ? and assessment_date = ?", orgID, scheduleDate).
641
 		// Preload("DialysisOrder.MonitoringRecords", "status = 1 AND user_org_id = ?", orgID).
641
 		// Preload("DialysisOrder.MonitoringRecords", "status = 1 AND user_org_id = ?", orgID).
642
 		Where("status = 1 AND user_org_id = ?", orgID)
642
 		Where("status = 1 AND user_org_id = ?", orgID)
643
 	if scheduleDate != 0 {
643
 	if scheduleDate != 0 {

+ 1 - 1
service/doctor_schedule_service.go Ver fichero

592
 		db = db.Where("s.schedule_type = ?", classtype)
592
 		db = db.Where("s.schedule_type = ?", classtype)
593
 	}
593
 	}
594
 	err = db.Preload("DeviceZone", " status= 1").Preload("DeviceNumber", "status= 1").
594
 	err = db.Preload("DeviceZone", " status= 1").Preload("DeviceNumber", "status= 1").
595
-		Preload("DialysisOrder", "status =1").Joins("JOIN xt_patients as p ON p.id = s.patient_id").Where("s.user_org_id = ? and s.schedule_date = ? and s.status =1", orgid, startime).
595
+		Preload("DialysisOrder", "status =1").Joins("JOIN xt_patients as p ON p.id = s.patient_id and p.lapseto = 1 and p.user_org_id =?", orgid).Where("s.user_org_id = ? and s.schedule_date = ? and s.status =1", orgid, startime).
596
 		Select("s.id, s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id,p.name as patient").Find(&schedule).Error
596
 		Select("s.id, s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id,p.name as patient").Find(&schedule).Error
597
 	return schedule, err
597
 	return schedule, err
598
 }
598
 }

+ 141 - 0
service/gobal_config_service.go Ver fichero

2
 
2
 
3
 import (
3
 import (
4
 	"XT_New/models"
4
 	"XT_New/models"
5
+	"fmt"
5
 	"github.com/jinzhu/gorm"
6
 	"github.com/jinzhu/gorm"
6
 )
7
 )
7
 
8
 
213
 	err = db.Order("ctime desc").Find(&order).Error
214
 	err = db.Order("ctime desc").Find(&order).Error
214
 	return
215
 	return
215
 }
216
 }
217
+
218
+func GetDrugInOrderDetail(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string, page int64, limit int64) (drugInfo []*models.BloodDrugWarehouseInfo, total int64, err error) {
219
+
220
+	likeKey := "%" + keyword + "%"
221
+	offset := (page - 1) * limit
222
+
223
+	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
224
+	dbOne := XTReadDB().Table("xt_base_drug as t").Where("t.status =1")
225
+	dbTwo := XTReadDB().Table("xt_drug_warehouse as s").Where("s.status = 1")
226
+	fmt.Print(dbOne, dbTwo)
227
+	if startime > 0 {
228
+		db = db.Where("x.ctime >=?", startime)
229
+	}
230
+	if endtime > 0 {
231
+		db = db.Where("x.ctime <=?", endtime)
232
+	}
233
+	if orgid > 0 {
234
+		db = db.Where("x.org_id =?", orgid)
235
+	}
236
+	if orderType > 0 {
237
+		db = db.Where("x.type = ?", orderType)
238
+	}
239
+
240
+	if len(keyword) > 0 {
241
+
242
+		db = db.Where("x.warehousing_order like ? or t.drug_spec like ? or s.creater like ?", likeKey, likeKey, likeKey)
243
+
244
+	}
245
+
246
+	if manufacturerId > 0 {
247
+		err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.total_price,x.dealer,t.manufacturer,x.remark,x.ctime,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,t.drug_type,t.drug_name,t.drug_spec,t.min_unit,s.creater").Joins("left join xt_base_drug as t on t.id = x.drug_id and t.org_id = ? and t.status =1", orgid).Where("t.manufacturer = ?", manufacturerId).Joins("left join xt_drug_warehouse as s on s.id = x.warehousing_id and s.org_id = ? and s.status =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&drugInfo).Error
248
+	} else {
249
+		err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.total_price,x.dealer,t.manufacturer,x.remark,x.ctime,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,t.drug_type,t.drug_name,t.drug_spec,t.min_unit,s.creater").Joins("left join xt_base_drug as t on t.id = x.drug_id and t.org_id = ? and t.status =1", orgid).Joins("left join xt_drug_warehouse as s on s.id = x.warehousing_id and s.org_id = ? and s.status =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&drugInfo).Error
250
+	}
251
+
252
+	return drugInfo, total, err
253
+}
254
+
255
+func GetDrugReturnOrder(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string, limit int64, page int64) (returninfo []*models.BloodDrugSalesReturnInfo, total int64, err error) {
256
+
257
+	likeKey := "%" + keyword + "%"
258
+	offset := (page - 1) * limit
259
+	db := XTReadDB().Table("xt_drug_sales_return_info as x").Where("x.status =1")
260
+	dbOne := XTReadDB().Table("xt_base_drug as s").Where("s.status =1")
261
+	dbTwo := XTReadDB().Table("xt_drug_sales_return as r").Where("r.status = 1")
262
+	fmt.Print(dbOne, dbTwo)
263
+	if startime > 0 {
264
+		db = db.Where("x.ctime >= ?", startime)
265
+	}
266
+	if endtime > 0 {
267
+		db = db.Where("x.ctime <=?", endtime)
268
+	}
269
+	if orgid > 0 {
270
+		db = db.Where("x.org_id = ?", orgid)
271
+	}
272
+	if orderType > 0 {
273
+		db = db.Where("x.type = ?", orderType)
274
+	}
275
+
276
+	if len(keyword) > 0 {
277
+
278
+		db = db.Where("x.order_number like ? or s.drug_spec like ? or r.creater like ?", likeKey, likeKey, likeKey)
279
+	}
280
+
281
+	if manufacturerId > 0 {
282
+		err = db.Select("x.id,x.drug_id,x.sales_return_id,x.count,x.price,x.total,x.product_date,x.expiry_date,x.ctime,x.org_id,x.order_number,x.type,x.dealer,x.manufacturer,x.retail_price,x.retail_total_price,x.number,s.drug_name,s.drug_spec,s.drug_type,s.min_unit,r.creater").Joins("left join xt_base_drug as s on s.id = x.drug_id and s.org_id = ? and s.status = 1", orgid).Joins("left join xt_drug_sales_return as r on r.id = x.sales_return_id and r.org_id = ? and r.status =1", orgid).Where("r.manufacturer = ?", manufacturerId).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&returninfo).Error
283
+	} else {
284
+		err = db.Select("x.id,x.drug_id,x.sales_return_id,x.count,x.price,x.total,x.product_date,x.expiry_date,x.ctime,x.org_id,x.order_number,x.type,x.dealer,x.manufacturer,x.retail_price,x.retail_total_price,x.number,s.drug_name,s.drug_spec,s.drug_type,s.min_unit,r.creater").Joins("left join xt_base_drug as s on s.id = x.drug_id and s.org_id = ? and s.status = 1", orgid).Joins("left join xt_drug_sales_return as r on r.id = x.sales_return_id and r.org_id = ? and r.status =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&returninfo).Error
285
+	}
286
+
287
+	return returninfo, total, err
288
+}
289
+
290
+func GetDrugOutOrder(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string, page int64, limit int64) (outinfo []*models.BloodDrugWarehouseOutInfo, total int64, err error) {
291
+
292
+	likeKey := "%" + keyword + "%"
293
+	offset := (page - 1) * limit
294
+	db := XTReadDB().Table("xt_drug_warehouse_out_info as x").Where("x.status =1")
295
+	dbOne := XTReadDB().Table("xt_base_drug as b").Where("b.status =1")
296
+	dbTwo := XTReadDB().Table("xt_drug_warehouse_out as t").Where("t.status = 1")
297
+	fmt.Print(dbOne, dbTwo)
298
+	if startime > 0 {
299
+		db = db.Where("x.ctime >=?", startime)
300
+	}
301
+	if endtime > 0 {
302
+		db = db.Where("x.ctime <=?", endtime)
303
+	}
304
+
305
+	if orgid > 0 {
306
+		db = db.Where("x.org_id = ?", orgid)
307
+	}
308
+	if orderType > 0 {
309
+		db = db.Where("x.type = ?", orderType)
310
+	}
311
+
312
+	if len(keyword) > 0 {
313
+		db = db.Where("x.warehouse_out_order_number like ? or b.drug_spec like ? or t.creater like ?", likeKey, likeKey, likeKey)
314
+	}
315
+
316
+	if manufacturerId > 0 {
317
+		err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,b.drug_name,b.drug_spec,b.drug_type,b.min_unit,t.creater").Joins("left join xt_base_drug as b on b.id = x.drug_id and b.org_id = ? and b.status =1", orgid).Joins("left join xt_drug_warehouse_out as t on t.id = x.warehouse_out_id and t.org_id = ? and t.status  =1", orgid).Where("t.manufacturer = ?", manufacturerId).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&outinfo).Error
318
+	} else {
319
+		err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,b.drug_name,b.drug_spec,b.drug_type,b.min_unit,t.creater").Joins("left join xt_base_drug as b on b.id = x.drug_id and b.org_id = ? and b.status =1", orgid).Joins("left join xt_drug_warehouse_out as t on t.id = x.warehouse_out_id and t.org_id = ? and t.status  =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&outinfo).Error
320
+	}
321
+
322
+	return outinfo, total, err
323
+}
324
+
325
+func GetDrugCancelOrder(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string, page int64, limit int64) (cancel []*models.BloodDrugCancelStockInfo, total int64, err error) {
326
+
327
+	likeKey := "%" + keyword + "%"
328
+	offset := (page - 1) * limit
329
+	db := XTReadDB().Table("xt_drug_cancel_stock_info as x").Where("x.status =1")
330
+	dbOne := XTReadDB().Table("xt_base_drug as s").Where("s.status =1")
331
+	dbTwo := XTReadDB().Table("xt_drug_cancel_stock as t").Where("t.status = 1")
332
+	fmt.Print(dbOne, dbTwo)
333
+	if startime > 0 {
334
+		db = db.Where("x.ctime >= ?", startime)
335
+	}
336
+	if endtime > 0 {
337
+		db = db.Where("x.ctime<=?", endtime)
338
+	}
339
+	if orgid > 0 {
340
+		db = db.Where("x.org_id = ?", orgid)
341
+	}
342
+	if orderType > 0 {
343
+		db = db.Where("x.type = ? ", orderType)
344
+	}
345
+	if len(keyword) > 0 {
346
+		db = db.Where("x.order_number like ? or s.drug_spec like ? or t.creater like ?", likeKey, likeKey, likeKey)
347
+	}
348
+
349
+	if manufacturerId > 0 {
350
+		err = db.Select("x.id,x.drug_id,x.cancel_stock_id,x.count,x.price,x.total,x.product_date,x.expiry_date,x.ctime,x.org_id,x.order_number,x.type,x.dealer,x.manufacturer,x.retail_price,x.retail_total_price,x.number,s.drug_name,s.drug_type,s.drug_spec,s.min_unit,t.creater").Joins("left join xt_base_drug as s on s.id = x.drug_id and s.org_id = ? and s.status = 1", orgid).Joins("left join xt_drug_cancel_stock as t on t.id = x.cancel_stock_id and t.org_id = ? and t.status =1", orgid).Where("t.manufacturer = ?", manufacturerId).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&cancel).Error
351
+	} else {
352
+		err = db.Select("x.id,x.drug_id,x.cancel_stock_id,x.count,x.price,x.total,x.product_date,x.expiry_date,x.ctime,x.org_id,x.order_number,x.type,x.dealer,x.manufacturer,x.retail_price,x.retail_total_price,x.number,s.drug_name,s.drug_type,s.drug_spec,s.min_unit,t.creater").Joins("left join xt_base_drug as s on s.id = x.drug_id and s.org_id = ? and s.status = 1", orgid).Joins("left join xt_drug_cancel_stock as t on t.id = x.cancel_stock_id and t.org_id = ? and t.status =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&cancel).Error
353
+	}
354
+
355
+	return cancel, total, err
356
+}

+ 1 - 1
service/mobile_dialysis_service.go Ver fichero

1126
 func ModifyStartDialysisOrder(order *models.DialysisOrder) error {
1126
 func ModifyStartDialysisOrder(order *models.DialysisOrder) error {
1127
 	tx := writeDb.Begin()
1127
 	tx := writeDb.Begin()
1128
 	updateTime := time.Now().Unix()
1128
 	updateTime := time.Now().Unix()
1129
-	err := tx.Model(&models.DialysisOrder{}).Where("user_org_id = ? AND id = ? AND status = 1 ", order.UserOrgId, order.ID).Updates(map[string]interface{}{"start_nurse": order.StartNurse, "updated_time": updateTime, "bed_id": order.BedID, "puncture_nurse": order.PunctureNurse, "start_time": order.StartTime, "modifier": order.Modifier, "schedual_type": order.SchedualType, "washpipe_nurse": order.WashpipeNurse}).Error
1129
+	err := tx.Model(&models.DialysisOrder{}).Where("user_org_id = ? AND id = ? AND status = 1 ", order.UserOrgId, order.ID).Updates(map[string]interface{}{"start_nurse": order.StartNurse, "updated_time": updateTime, "bed_id": order.BedID, "puncture_nurse": order.PunctureNurse, "start_time": order.StartTime, "modifier": order.Modifier, "schedual_type": order.SchedualType, "washpipe_nurse": order.WashpipeNurse, "change_nurse": order.ChangeNurse}).Error
1130
 	if err != nil {
1130
 	if err != nil {
1131
 		tx.Rollback()
1131
 		tx.Rollback()
1132
 		return err
1132
 		return err

+ 2 - 2
service/patient_service.go Ver fichero

1193
 	var totals Total
1193
 	var totals Total
1194
 
1194
 
1195
 	offset := (page - 1) * limit
1195
 	offset := (page - 1) * limit
1196
-	err = readDb.Raw("select *  from xt_patients where user_org_id = ? AND infectious_next_record_time > 0 AND status = 1  AND date_sub(DATE_FORMAT(date(from_unixtime(`xt_patients`.`infectious_next_record_time`)),'%Y-%m-%d'), interval 7 day) <= now() Order by infectious_next_record_time", org_id).Offset(offset).Limit(limit).Scan(&patient).Error
1197
-	readDb.Raw("select Count(id) as count  from xt_patients where user_org_id = ? AND infectious_next_record_time > 0 AND status = 1  AND date_sub(DATE_FORMAT(date(from_unixtime(`xt_patients`.`infectious_next_record_time`)),'%Y-%m-%d'), interval 7 day) <= now() Order by infectious_next_record_time", org_id).Scan(&totals)
1196
+	err = readDb.Raw("select *  from xt_patients where user_org_id = ? AND lapseto = 1 AND infectious_next_record_time > 0 AND status = 1  AND date_sub(DATE_FORMAT(date(from_unixtime(`xt_patients`.`infectious_next_record_time`)),'%Y-%m-%d'), interval 7 day) <= now() Order by infectious_next_record_time", org_id).Offset(offset).Limit(limit).Scan(&patient).Error
1197
+	readDb.Raw("select Count(id) as count  from xt_patients where user_org_id = ? AND lapseto = 1 AND infectious_next_record_time > 0 AND status = 1  AND date_sub(DATE_FORMAT(date(from_unixtime(`xt_patients`.`infectious_next_record_time`)),'%Y-%m-%d'), interval 7 day) <= now() Order by infectious_next_record_time", org_id).Scan(&totals)
1198
 
1198
 
1199
 	return totals.Count, patient, err
1199
 	return totals.Count, patient, err
1200
 }
1200
 }

+ 1 - 1
service/patientmanage_service.go Ver fichero

1167
 
1167
 
1168
 func GetAllZoneOne(orgid int64) (zone []*models.DeviceZone, err error) {
1168
 func GetAllZoneOne(orgid int64) (zone []*models.DeviceZone, err error) {
1169
 
1169
 
1170
-	err = XTReadDB().Model(&zone).Where("org_id = ?", orgid).Find(&zone).Error
1170
+	err = XTReadDB().Model(&zone).Where("org_id = ? and status =1", orgid).Find(&zone).Error
1171
 	return zone, err
1171
 	return zone, err
1172
 }
1172
 }
1173
 
1173
 

+ 8 - 1
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go Ver fichero

42
 				Where("user_org_id = ? AND advice_type = 2 AND status = 1", orgID).
42
 				Where("user_org_id = ? AND advice_type = 2 AND status = 1", orgID).
43
 				Order("start_time asc, groupno desc, advice_order desc, id asc")
43
 				Order("start_time asc, groupno desc, advice_order desc, id asc")
44
 		}).
44
 		}).
45
-		Where("user_org_id = ? AND status = 1 AND id in (?)", orgID, schIDs).
45
+		Where("user_org_id = ? AND status = 1 AND id in (?)", orgID, schIDs).Order("schedule_date desc").
46
 		Find(&schedules).
46
 		Find(&schedules).
47
 		Error
47
 		Error
48
 	if err != nil {
48
 	if err != nil {
186
 	err = p_service.XTReadDB().Model(&models.DialysisOrder{}).Where("dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
186
 	err = p_service.XTReadDB().Model(&models.DialysisOrder{}).Where("dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
187
 	return
187
 	return
188
 }
188
 }
189
+
190
+func GetOutStockTotalCountTwo(startime int64, endtime int64, orgid int64) (autoMatic []*models.NewXtAutomaticReduceDetail, err error) {
191
+
192
+	err = p_service.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
193
+
194
+	return autoMatic, err
195
+}

+ 23 - 0
service/schedule_service.go Ver fichero

662
 		Find(&schedules).Error
662
 		Find(&schedules).Error
663
 	return schedules, err
663
 	return schedules, err
664
 }
664
 }
665
+
666
+func GetThreeWeekList(startime int64, endtime int64, orgid int64, scheduletype int64, partionid int64) (schedule []*models.VmSchedule, err error) {
667
+
668
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status =1")
669
+	if startime > 0 {
670
+		db = db.Where("x.schedule_date >=?", startime)
671
+	}
672
+	if endtime > 0 {
673
+		db = db.Where("x.schedule_date <=?", endtime)
674
+	}
675
+	if orgid > 0 {
676
+		db = db.Where("x.user_org_id = ?", orgid)
677
+	}
678
+	if scheduletype > 0 {
679
+		db = db.Where("x.schedule_type = ?", scheduletype)
680
+	}
681
+	if partionid > 0 {
682
+		db = db.Where("x.partition_id = ?", partionid)
683
+	}
684
+	err = db.Select("x.schedule_date,x.schedule_type,x.schedule_week,x.bed_id,x.partition_id,t.name,n.number,z.name").Joins("left join xt_patients as t on t.id = x.patient_id and t.user_org_id = ? and t.status = 1", orgid).Joins("left join xt_device_zone as z on z.id = x.partition_id and z.org_id = ? and z.status =1", orgid).Joins("left join xt_device_number as n on n.id = x.bed_id and n.org_id = ? and n.status =1", orgid).Scan(&schedule).Error
685
+
686
+	return schedule, err
687
+}

+ 44 - 0
service/self_drug_service.go Ver fichero

752
 	err := XTWriteDB().Model(&stock).Where("id = ?", id).Updates(map[string]interface{}{"drug_name": stock.DrugName, "drug_name_id": stock.DrugNameId, "drug_spec": stock.DrugSpec, "outstore_number": stock.OutstoreNumber, "admin_user_id": stock.AdminUserId, "storck_time": stock.StorckTime, "patient_id": stock.PatientId, "stock_out_number": stock.StockOutNumber, "exit_mode": stock.ExitMode, "medic_id": stock.MedicId, "updated_time": time.Now().Unix()}).Error
752
 	err := XTWriteDB().Model(&stock).Where("id = ?", id).Updates(map[string]interface{}{"drug_name": stock.DrugName, "drug_name_id": stock.DrugNameId, "drug_spec": stock.DrugSpec, "outstore_number": stock.OutstoreNumber, "admin_user_id": stock.AdminUserId, "storck_time": stock.StorckTime, "patient_id": stock.PatientId, "stock_out_number": stock.StockOutNumber, "exit_mode": stock.ExitMode, "medic_id": stock.MedicId, "updated_time": time.Now().Unix()}).Error
753
 	return err
753
 	return err
754
 }
754
 }
755
+
756
+func GetSelfStockQuery(typename int64, keywords string, startime int64, endtime int64, orgid int64, limit int64, page int64) (selfoutstock []*models.XtSelfOutStockOne, total int64, err error) {
757
+	offset := (page - 1) * limit
758
+	db := XTReadDB().Table("xt_self_stock as x").Where("x.status = 1")
759
+	likeKey := "%" + keywords + "%"
760
+	if len(keywords) > 0 {
761
+		db = db.Where("x.drug_name like ? ", likeKey)
762
+	}
763
+
764
+	if startime > 0 {
765
+		db = db.Where("x.storck_time >=?", startime)
766
+	}
767
+	if endtime > 0 {
768
+		db = db.Where("x.storck_time<=?", endtime)
769
+	}
770
+
771
+	if orgid > 0 {
772
+		db = db.Where("x.user_org_id = ?", orgid)
773
+	}
774
+
775
+	if typename > 0 {
776
+		err = db.Select("x.drug_name,x.drug_name_id,x.drug_spec,Sum(store_number) as count,b.drug_type").Joins("left join xt_base_drug as b on b.id = x.drug_name_id and b.org_id = ? and b.status =1 ", orgid).Where("b.drug_type = ?", typename).Group("x.drug_name_id").Count(&total).Offset(offset).Limit(limit).Scan(&selfoutstock).Error
777
+	} else {
778
+		err = db.Select("x.drug_name,x.drug_name_id,x.drug_spec,Sum(store_number) as count,b.drug_type").Joins("left join xt_base_drug as b on b.id = x.drug_name_id and b.org_id = ? and b.status =1", orgid).Group("x.drug_name_id").Count(&total).Offset(offset).Limit(limit).Scan(&selfoutstock).Error
779
+	}
780
+
781
+	return selfoutstock, total, err
782
+}
783
+
784
+func GetSelfOutStockQuery(startTime int64, endTime int64, orgid int64) (selfoutstock []*models.XtSelfOutStockOne, err error) {
785
+
786
+	db := XTReadDB().Table("xt_self_out_stock as x").Where("x.status = 1")
787
+	if startTime > 0 {
788
+		db = db.Where("x.storck_time >?", startTime)
789
+	}
790
+	if endTime > 0 {
791
+		db = db.Where("x.storck_time<=?", endTime)
792
+	}
793
+	if orgid > 0 {
794
+		db = db.Where("x.user_org_id = ?", orgid)
795
+	}
796
+	err = db.Select("x.drug_name_id,Sum(x.outstore_number) as count").Group("x.drug_name_id").Scan(&selfoutstock).Error
797
+	return selfoutstock, err
798
+}

+ 6 - 0
service/stock_service.go Ver fichero

2163
 	return autoMatic, err
2163
 	return autoMatic, err
2164
 
2164
 
2165
 }
2165
 }
2166
+
2167
+func GetOutStockTotalCountOne(startime int64, endtime int64, orgid int64) (autoMatic []*models.NewXtAutomaticReduceDetail, err error) {
2168
+	err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,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
2169
+
2170
+	return autoMatic, err
2171
+}