csx hace 4 años
padre
commit
dc829b88c0

+ 14 - 6
controllers/device_api_controller.go Ver fichero

@@ -2,6 +2,7 @@ package controllers
2 2
 
3 3
 import (
4 4
 	"XT_New/utils"
5
+	"github.com/jinzhu/gorm"
5 6
 	"time"
6 7
 
7 8
 	"XT_New/enums"
@@ -525,15 +526,22 @@ func (this *DeviceAPIController) CreateZone() {
525 526
 	}
526 527
 
527 528
 	adminInfo := this.GetAdminUserInfo()
528
-	zone, createErr := service.CreateDeviceZone(adminInfo.CurrentOrgId, name, type_)
529
-	if createErr != nil {
530
-		this.ErrorLog("创建设备分区失败:%v", createErr)
529
+	_, errcode := service.GetZoneByName(name, adminInfo.CurrentOrgId)
530
+	fmt.Println("errcode=----------", errcode)
531
+	if errcode == gorm.ErrRecordNotFound {
532
+		zone, createErr := service.CreateDeviceZone(adminInfo.CurrentOrgId, name, type_)
533
+		if createErr != nil {
534
+			this.ErrorLog("创建设备分区失败:%v", createErr)
535
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
536
+			return
537
+		}
538
+		this.ServeSuccessJSON(map[string]interface{}{
539
+			"zone": zone,
540
+		})
541
+	} else if errcode == nil {
531 542
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
532 543
 		return
533 544
 	}
534
-	this.ServeSuccessJSON(map[string]interface{}{
535
-		"zone": zone,
536
-	})
537 545
 }
538 546
 
539 547
 // /api/device/zone/modify [post] ModifyZone

+ 3 - 3
controllers/dialysis_api_controller.go Ver fichero

@@ -4314,7 +4314,7 @@ func (c *DialysisApiController) GetDialysisOrder() {
4314 4314
 	//获取医嘱内容
4315 4315
 	doctor, err := service.FindDoctor(doctorAdvice.AdviceDoctor, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
4316 4316
 	DoctorName, err := service.FindDoctorName(doctorAdvice.AdviceDoctor, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
4317
-	fmt.Print("err-----------------------------------------------------------------", err)
4317
+	//fmt.Print("err-----------------------------------------------------------------", err)
4318 4318
 	DoctorAdvice, _ := service.FindDoctorAdviceOrderById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4319 4319
 	doctorAdevieInfo, err := service.FindDoctorAdviceByInfo(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4320 4320
 	//获取上次的透后体重
@@ -4350,8 +4350,8 @@ func (c *DialysisApiController) GetDialysisOrder() {
4350 4350
 	check, _ := service.FindDoubleCheckById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4351 4351
 
4352 4352
 	//相关操作对应的操作人
4353
-	operators, _ := service.GetAdminUserES(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, operatorIDs)
4354
-
4353
+	//operators, _ := service.GetAdminUserES(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, operatorIDs)
4354
+	operators, err := service.GetAdminUserEsOne(adminUserInfo.CurrentOrgId)
4355 4355
 	templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
4356 4356
 	c.ServeSuccessJSON(map[string]interface{}{
4357 4357
 		"xtdate":                  xtdate,

+ 13 - 1
controllers/mobile_api_controllers/dialysis_api_controller.go Ver fichero

@@ -366,7 +366,7 @@ func (this *DialysisAPIController) DialysisRecord() {
366 366
 
367 367
 	//dialysisSolution, getDialysisSolutionErr := service.MobileGetDialysisSolution(adminInfo.Org.Id, patientID)
368 368
 
369
-	operators, _ := service.GetAllAdminUserES(adminInfo.Org.Id, adminInfo.App.Id)
369
+	//operators, _ := service.GetAllAdminUserES(adminInfo.Org.Id, adminInfo.App.Id)
370 370
 
371 371
 	if getLPEErr != nil {
372 372
 		this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
@@ -387,6 +387,10 @@ func (this *DialysisAPIController) DialysisRecord() {
387 387
 	goodTypes, _ := service.FindAllGoodTypeByType(1)          //查出所有库存配置的系统类型
388 388
 	goodInfos, _ := service.FindAllGoodInfo(adminInfo.Org.Id) //查出所有库存配置的系统类型
389 389
 
390
+	operators, err := service.GetAllStarfEs(adminInfo.Org.Id)
391
+	fmt.Println("报错-------", err)
392
+	fmt.Println("op----------------------------------------------------------", operators)
393
+
390 394
 	returnData := map[string]interface{}{
391 395
 		"patient":                        patient,
392 396
 		"schedual":                       schedual,
@@ -6247,3 +6251,11 @@ func (c *DialysisAPIController) GetSchedule() {
6247 6251
 	})
6248 6252
 
6249 6253
 }
6254
+
6255
+func (c *DialysisAPIController) GetPatientId() {
6256
+	id, _ := c.GetInt64("id")
6257
+	patientId, _ := service.GetPatientId(id)
6258
+	c.ServeSuccessJSON(map[string]interface{}{
6259
+		"patient": patientId,
6260
+	})
6261
+}

+ 2 - 0
controllers/mobile_api_controllers/mobile_api_router_register.go Ver fichero

@@ -108,4 +108,6 @@ func MobileAPIControllersRegisterRouters() {
108 108
 
109 109
 	beego.Router("/m/api/schedule/get", &DialysisAPIController{}, "Get:GetSchedule")
110 110
 
111
+	beego.Router("/m/api/getPatientid", &DialysisAPIController{}, "Get:GetPatientId")
112
+
111 113
 }

+ 2 - 2
controllers/mobile_api_controllers/patient_api_controller.go Ver fichero

@@ -2080,7 +2080,6 @@ func (c *PatientApiController) GetDoctorAdvices() {
2080 2080
 }
2081 2081
 
2082 2082
 func (c *PatientApiController) GetPrintDialysisOrder() {
2083
-	fmt.Println("触发-------------------------")
2084 2083
 	xtno := c.GetString("xtno")
2085 2084
 	xtdate := c.GetString("xtdate")
2086 2085
 
@@ -2152,7 +2151,8 @@ func (c *PatientApiController) GetPrintDialysisOrder() {
2152 2151
 	receiverTreatmentAccess, _ := service.FindReceiverTreatmentAccessRecordById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
2153 2152
 
2154 2153
 	//相关操作对应的操作人
2155
-	operators, _ := service.GetAdminUserESTwo(adminUserInfo.Org.Id)
2154
+	//operators, _ := service.GetAdminUserES(adminUserInfo.Org.Id, adminUserInfo.App.Id, operatorIDs)
2155
+	operators, err := service.GetAllStarfEs(adminUserInfo.Org.Id)
2156 2156
 	templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
2157 2157
 	check, _ := service.FindDoubleCheckById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
2158 2158
 	c.ServeSuccessJSON(map[string]interface{}{

+ 85 - 36
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go Ver fichero

@@ -555,6 +555,13 @@ func (this *NewDialysisApiController) SavePatient() {
555 555
 }
556 556
 
557 557
 func (this *NewDialysisApiController) GetPatientDetail() {
558
+	nowDateTime := time.Now()
559
+	nowDate := nowDateTime.Format("2006-01-02")
560
+	nowDate += " 00:00:00"
561
+	timeLayout := "2006-01-02"
562
+	loc, _ := time.LoadLocation("Local")
563
+	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", nowDate, loc)
564
+	nowdate := theTime.Unix()
558 565
 	id, _ := this.GetInt64("id")
559 566
 	//获取病人详情信息
560 567
 	detail, err := service.GetPatientDetailTwo(id)
@@ -574,6 +581,7 @@ func (this *NewDialysisApiController) GetPatientDetail() {
574 581
 		"diseases":       diseases,
575 582
 		"slowDiseases":   slowDiseases,
576 583
 		"cronicDiseases": cronicDiseases,
584
+		"nowdate":        nowdate,
577 585
 	})
578 586
 }
579 587
 
@@ -1837,21 +1845,28 @@ func (this *NewDialysisApiController) SavePartition() {
1837 1845
 	fmt.Println("分区型号", zonetype)
1838 1846
 	strInt64 := strconv.FormatInt(zonetype, 10)
1839 1847
 	typeid, _ := strconv.Atoi(strInt64)
1840
-	zone := models.DeviceZone{
1841
-		Name:       name,
1842
-		Type:       typeid,
1843
-		OrgID:      adminInfo.Org.Id,
1844
-		Status:     1,
1845
-		CreateTime: time.Now().Unix(),
1846
-	}
1847
-	err := service.CreatedZone(&zone)
1848
-	if err != nil {
1848
+	_, errcode := service.GetPartitionByName(name, adminInfo.Org.Id)
1849
+	fmt.Println("errcode-------", errcode)
1850
+	if errcode == gorm.ErrRecordNotFound {
1851
+		zone := models.DeviceZone{
1852
+			Name:       name,
1853
+			Type:       typeid,
1854
+			OrgID:      adminInfo.Org.Id,
1855
+			Status:     1,
1856
+			CreateTime: time.Now().Unix(),
1857
+		}
1858
+		err := service.CreatedZone(&zone)
1859
+		if err != nil {
1860
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1861
+			return
1862
+		}
1863
+		this.ServeSuccessJSON(map[string]interface{}{
1864
+			"zone": zone,
1865
+		})
1866
+	} else if errcode == nil {
1849 1867
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1850 1868
 		return
1851 1869
 	}
1852
-	this.ServeSuccessJSON(map[string]interface{}{
1853
-		"zone": zone,
1854
-	})
1855 1870
 }
1856 1871
 
1857 1872
 func (this *NewDialysisApiController) GetAllZone() {
@@ -1886,20 +1901,27 @@ func (this *NewDialysisApiController) SaveGroup() {
1886 1901
 	orgid := adminUser.Org.Id
1887 1902
 	name := this.GetString("name")
1888 1903
 	fmt.Println("name", name)
1889
-	group := models.DeviceGroup{
1890
-		Name:       name,
1891
-		Status:     1,
1892
-		CreateTime: time.Now().Unix(),
1893
-		OrgID:      orgid,
1894
-	}
1895
-	err := service.SaveGroup(&group)
1896
-	if err != nil {
1904
+	_, errcode := service.GetGroupByName(name, orgid)
1905
+	if errcode == gorm.ErrRecordNotFound {
1906
+		group := models.DeviceGroup{
1907
+			Name:       name,
1908
+			Status:     1,
1909
+			CreateTime: time.Now().Unix(),
1910
+			OrgID:      orgid,
1911
+		}
1912
+		err := service.SaveGroup(&group)
1913
+		if err != nil {
1914
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1915
+			return
1916
+		}
1917
+		this.ServeSuccessJSON(map[string]interface{}{
1918
+			"group": group,
1919
+		})
1920
+	} else if errcode == nil {
1897 1921
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1898 1922
 		return
1899 1923
 	}
1900
-	this.ServeSuccessJSON(map[string]interface{}{
1901
-		"group": group,
1902
-	})
1924
+
1903 1925
 }
1904 1926
 
1905 1927
 func (this *NewDialysisApiController) GetAllGroup() {
@@ -1955,22 +1977,29 @@ func (this *NewDialysisApiController) SaveBed() {
1955 1977
 	fmt.Print("zone", zone)
1956 1978
 	group, _ := this.GetInt64("group")
1957 1979
 	fmt.Println("group", group)
1958
-	number := models.DeviceNumber{
1959
-		Number:     name,
1960
-		ZoneID:     zone,
1961
-		GroupID:    group,
1962
-		OrgID:      orgid,
1963
-		Status:     1,
1964
-		CreateTime: time.Now().Unix(),
1965
-	}
1966
-	err := service.CreateNumber(&number)
1967
-	if err != nil {
1980
+	_, errcode := service.GetBedByName(name, orgid)
1981
+	if errcode == gorm.ErrRecordNotFound {
1982
+		number := models.DeviceNumber{
1983
+			Number:     name,
1984
+			ZoneID:     zone,
1985
+			GroupID:    group,
1986
+			OrgID:      orgid,
1987
+			Status:     1,
1988
+			CreateTime: time.Now().Unix(),
1989
+		}
1990
+		err := service.CreateNumber(&number)
1991
+		if err != nil {
1992
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1993
+			return
1994
+		}
1995
+		this.ServeSuccessJSON(map[string]interface{}{
1996
+			"number": number,
1997
+		})
1998
+	} else if errcode == nil {
1968 1999
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1969 2000
 		return
1970 2001
 	}
1971
-	this.ServeSuccessJSON(map[string]interface{}{
1972
-		"number": number,
1973
-	})
2002
+
1974 2003
 }
1975 2004
 
1976 2005
 func (this *NewDialysisApiController) GetAllNumber() {
@@ -2278,11 +2307,18 @@ func (this *NewDialysisApiController) GetPartionDetail() {
2278 2307
 }
2279 2308
 
2280 2309
 func (this *NewDialysisApiController) UpdatePartition() {
2310
+	adminUser := this.GetMobileAdminUserInfo()
2311
+	orgid := adminUser.Org.Id
2281 2312
 	id, _ := this.GetInt64("id")
2282 2313
 	name := this.GetString("name")
2283 2314
 	zoneType, _ := this.GetInt64("type")
2284 2315
 	strInt64 := strconv.FormatInt(zoneType, 10)
2285 2316
 	typeid, _ := strconv.Atoi(strInt64)
2317
+	byName, _ := service.GetPartitionByNameOne(name, orgid)
2318
+	if byName.ID > 0 && byName.ID != id {
2319
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2320
+		return
2321
+	}
2286 2322
 	zone := models.DeviceZone{
2287 2323
 		Name: name,
2288 2324
 		Type: typeid,
@@ -2311,8 +2347,14 @@ func (this *NewDialysisApiController) GetGroupDetail() {
2311 2347
 }
2312 2348
 
2313 2349
 func (this *NewDialysisApiController) UpdateGroup() {
2350
+	adminUser := this.GetMobileAdminUserInfo()
2351
+	orgid := adminUser.Org.Id
2314 2352
 	id, _ := this.GetInt64("id")
2315 2353
 	name := this.GetString("name")
2354
+	byName, _ := service.GetGroupByNameOne(name, orgid)
2355
+	if byName.ID > 0 && byName.ID != id {
2356
+		return
2357
+	}
2316 2358
 	group := models.DeviceGroup{Name: name}
2317 2359
 	err := service.UpdateGroup(id, &group)
2318 2360
 	if err != nil {
@@ -2343,6 +2385,8 @@ func (this *NewDialysisApiController) GetBedDetail() {
2343 2385
 }
2344 2386
 
2345 2387
 func (this *NewDialysisApiController) UpdatedBed() {
2388
+	adminUser := this.GetMobileAdminUserInfo()
2389
+	orgId := adminUser.Org.Id
2346 2390
 	id, _ := this.GetInt64("id")
2347 2391
 	name := this.GetString("name")
2348 2392
 	fmt.Println("name", name)
@@ -2350,6 +2394,11 @@ func (this *NewDialysisApiController) UpdatedBed() {
2350 2394
 	fmt.Println("zone", zone)
2351 2395
 	group, _ := this.GetInt64("group")
2352 2396
 	fmt.Println("group", group)
2397
+	BedName, _ := service.GetBedByNameOne(name, orgId)
2398
+	fmt.Println("-----", BedName.ID)
2399
+	if BedName.ID > 0 && BedName.ID != id {
2400
+		return
2401
+	}
2353 2402
 	number := models.DeviceNumber{
2354 2403
 		Number:  name,
2355 2404
 		ZoneID:  zone,

+ 24 - 0
models/admin_user_models.go Ver fichero

@@ -71,6 +71,30 @@ func (AdminUserElectronicSignature) TableName() string {
71 71
 	return "sgj_user_admin_electronic_signature"
72 72
 }
73 73
 
74
+type SgjUserAdminRoles struct {
75
+	ID            int64  `gorm:"column:id" json:"id" form:"id"`
76
+	AdminUserId   int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
77
+	OrgId         int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
78
+	AppId         int64  `gorm:"column:app_id" json:"app_id" form:"app_id"`
79
+	RoleId        int64  `gorm:"column:role_id" json:"role_id" form:"role_id"`
80
+	UserName      string `gorm:"column:user_name" json:"user_name" form:"user_name"`
81
+	Avatar        string `gorm:"column:avatar" json:"avatar" form:"avatar"`
82
+	UserType      int64  `gorm:"column:user_type" json:"user_type" form:"user_type"`
83
+	UserTitle     int64  `gorm:"column:user_title" json:"user_title" form:"user_title"`
84
+	Intro         string `gorm:"column:intro" json:"intro" form:"intro"`
85
+	Status        int64  `gorm:"column:status" json:"status" form:"status"`
86
+	Ctime         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
87
+	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
88
+	UserTitleName string `gorm:"column:user_title_name" json:"user_title_name" form:"user_title_name"`
89
+	RoleIds       string `gorm:"column:role_ids" json:"role_ids" form:"role_ids"`
90
+	Message       string `gorm:"column:message" json:"message" form:"message"`
91
+	Sex           int64  `gorm:"column:sex" json:"sex" form:"sex"`
92
+	Birthday      int64  `gorm:"column:birthday" json:"birthday" form:"birthday"`
93
+	Creator       int64  `gorm:"column:creator" json:"creator" form:"creator"`
94
+	Url           string `gorm:"column:url" json:"url" form:"url"`
95
+	Hash          string `gorm:"column:hash" json:"hash" form:"hash"`
96
+}
97
+
74 98
 // 管理员用户特殊权限,详见表注释
75 99
 type AdminUserSpecialPermission struct {
76 100
 	ID          int64 `gorm:"column:id" json:"id"`

+ 24 - 0
models/dialysis.go Ver fichero

@@ -856,3 +856,27 @@ type SgjUserAdmin struct {
856 856
 func (SgjUserAdmin) TableName() string {
857 857
 	return "sgj_user_admin"
858 858
 }
859
+
860
+type UserAdminRoles struct {
861
+	ID            int64  `gorm:"column:id" json:"id" form:"id"`
862
+	AdminUserId   int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
863
+	OrgId         int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
864
+	AppId         int64  `gorm:"column:app_id" json:"app_id" form:"app_id"`
865
+	RoleId        int64  `gorm:"column:role_id" json:"role_id" form:"role_id"`
866
+	UserName      string `gorm:"column:user_name" json:"user_name" form:"user_name"`
867
+	Avatar        string `gorm:"column:avatar" json:"avatar" form:"avatar"`
868
+	UserType      int64  `gorm:"column:user_type" json:"user_type" form:"user_type"`
869
+	UserTitle     int64  `gorm:"column:user_title" json:"user_title" form:"user_title"`
870
+	Intro         string `gorm:"column:intro" json:"intro" form:"intro"`
871
+	Status        int64  `gorm:"column:status" json:"status" form:"status"`
872
+	Ctime         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
873
+	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
874
+	UserTitleName string `gorm:"column:user_title_name" json:"user_title_name" form:"user_title_name"`
875
+	RoleIds       string `gorm:"column:role_ids" json:"role_ids" form:"role_ids"`
876
+	Message       string `gorm:"column:message" json:"message" form:"message"`
877
+	Sex           int64  `gorm:"column:sex" json:"sex" form:"sex"`
878
+	Birthday      int64  `gorm:"column:birthday" json:"birthday" form:"birthday"`
879
+	Creator       int64  `gorm:"column:creator" json:"creator" form:"creator"`
880
+	Url           string `gorm:"column:url" json:"url" form:"url"`
881
+	Hash          string `gorm:"column:hash" json:"hash" form:"hash"`
882
+}

+ 20 - 0
service/device_service.go Ver fichero

@@ -272,6 +272,19 @@ func GetDeviceZoneByID(orgID int64, zoneID int64) (*models.DeviceZone, error) {
272 272
 	return &zone, nil
273 273
 }
274 274
 
275
+func GetZoneByName(name string, orgid int64) (*models.DeviceZone, error) {
276
+	zones := models.DeviceZone{}
277
+	err := XTReadDB().Model(&zones).Where("name = ? and org_id = ? and status = 1", name, orgid).Find(&zones).Error
278
+	if err != nil {
279
+		if err == gorm.ErrRecordNotFound {
280
+			return nil, nil
281
+		} else {
282
+			return nil, err
283
+		}
284
+	}
285
+	return &zones, nil
286
+}
287
+
275 288
 func CreateDeviceZone(orgID int64, name string, type_ int) (*models.DeviceZone, error) {
276 289
 	now := time.Now().Unix()
277 290
 	zone := models.DeviceZone{
@@ -648,3 +661,10 @@ func GetTreatModel(id int64, orgid int64) (mode []*models.DeviceTreatmentmode, e
648 661
 
649 662
 	return mode, err
650 663
 }
664
+
665
+func GetPatientId(id int64) (models.XtPatientsNew, error) {
666
+
667
+	patientsNew := models.XtPatientsNew{}
668
+	err := XTReadDB().Model(&patientsNew).Where("blood_id = ? and status = 1", id).Find(&patientsNew).Error
669
+	return patientsNew, err
670
+}

+ 15 - 18
service/dialysis_service.go Ver fichero

@@ -695,25 +695,13 @@ func GetAdminUserES(orgID int64, appID int64, ids []int64) (es []*models.AdminUs
695 695
 	return
696 696
 }
697 697
 
698
-type MobileMedicalStaffVM struct {
699
-	Id       int64  `json:"id"`
700
-	Name     string `json:"name"`
701
-	UserType int64  `json:"user_type"`
702
-	ES_URL   string `gorm:"column:es_url" json:"es_url"`
703
-	Creator  int64  `gorm:"column:creator" json:"creator"`
704
-}
705
-
706
-func GetAdminUserESTwo(orgID int64) (staffs []*MobileMedicalStaffVM, err error) {
707
-	err = readUserDb.Table("sgj_user_admin_role as uar").
708
-		Joins("JOIN sgj_user_admin as ua ON ua.id = uar.admin_user_id").
709
-		Joins("LEFT JOIN sgj_user_admin_electronic_signature as es ON es.creator = uar.admin_user_id and es.status = 1").
710
-		Where("uar.status = 1 and uar.org_id = ?  and ua.status = 1", orgID).
711
-		Where("uar.status = 1 and uar.org_id = ?  and ua.status = 1", orgID).
712
-		Select("ua.id, uar.user_name as name, uar.user_type, es.url as url,es.creator as creator").
713
-		Scan(&staffs).
714
-		Error
698
+func GetAdminUserEsOne(orgid int64) (admin []*models.UserAdminRoles, err error) {
715 699
 
716
-	return
700
+	db := readUserDb.Table("sgj_user_admin_role as x").Where("x.status = 1")
701
+	table := readUserDb.Table("sgj_user_admin_electronic_signature as s")
702
+	fmt.Println("table", table)
703
+	err = db.Select("x.id,x.admin_user_id,x.user_name,x.org_id,s.creator,s.url,s.hash").Joins("left join sgj_user_admin_electronic_signature as s on s.creator = x.admin_user_id").Where("x.org_id = ?", orgid).Scan(&admin).Error
704
+	return admin, err
717 705
 }
718 706
 
719 707
 func UpDateDialysisPrescriptionDoctorSign(patient int64, date int64, orgId int64, doctor_id int64) (err error) {
@@ -726,6 +714,15 @@ func GetAllAdminUserES(orgID int64, appId int64) (es []*models.AdminUserElectron
726 714
 	return
727 715
 }
728 716
 
717
+func GetAllStarfEs(orgid int64) (es []*models.SgjUserAdminRoles, err error) {
718
+
719
+	db := readUserDb.Table("sgj_user_admin_role as x").Where("x.status = 1")
720
+	table := readUserDb.Table("sgj_user_admin_electronic_signature as s")
721
+	fmt.Println("table", table)
722
+	err = db.Select("x.id,x.admin_user_id,x.org_id,x.app_id,x.role_id,x.user_name,x.avatar,x.user_type,s.creator,s.url,s.hash").Joins("left join sgj_user_admin_electronic_signature as s on s.creator = x.admin_user_id and s.status = 1").Where("x.org_id = ?", orgid).Scan(&es).Error
723
+	return es, err
724
+}
725
+
729 726
 func FindLastMonitorRecord(patient_id int64, org_id int64) (record models.MonitoringRecord, err error) {
730 727
 	err = readDb.Model(&models.MonitoringRecord{}).Where("patient_id = ? AND status = 1 AND user_org_id = ?", patient_id, org_id).Last(&record).Error
731 728
 	return

+ 53 - 0
service/patientmanage_service.go Ver fichero

@@ -1077,6 +1077,24 @@ func SaveBirthday(id int64, role *models.SgjUserAdminRole) error {
1077 1077
 	return err
1078 1078
 }
1079 1079
 
1080
+func GetPartitionByName(name string, orgid int64) (*models.DeviceZone, error) {
1081
+	zone := models.DeviceZone{}
1082
+	err := XTReadDB().Model(&zone).Where("name = ? and org_id = ? and status = 1", name, orgid).Find(&zone).Error
1083
+	if err == gorm.ErrRecordNotFound {
1084
+		return nil, err
1085
+	}
1086
+	if err != nil {
1087
+		return nil, err
1088
+	}
1089
+	return &zone, nil
1090
+}
1091
+
1092
+func GetPartitionByNameOne(name string, orgid int64) (zone models.DeviceZone, err error) {
1093
+
1094
+	err = XTReadDB().Model(&zone).Where("name = ? and org_id = ? and status = 1", name, orgid).First(&zone).Error
1095
+	return zone, err
1096
+}
1097
+
1080 1098
 func CreatedZone(zone *models.DeviceZone) error {
1081 1099
 
1082 1100
 	err := XTWriteDB().Model(&zone).Create(&zone).Error
@@ -1102,6 +1120,23 @@ func DeleteZoneById(id int64) error {
1102 1120
 	return err
1103 1121
 }
1104 1122
 
1123
+func GetGroupByName(name string, orgid int64) (*models.DeviceGroup, error) {
1124
+	group := models.DeviceGroup{}
1125
+	err := XTReadDB().Model(&group).Where("name = ? and org_id = ? and status = 1", name, orgid).Find(&group).Error
1126
+	if err == gorm.ErrRecordNotFound {
1127
+		return nil, err
1128
+	}
1129
+	if err != nil {
1130
+		return nil, err
1131
+	}
1132
+	return &group, nil
1133
+}
1134
+
1135
+func GetGroupByNameOne(name string, orgid int64) (group models.DeviceGroup, err error) {
1136
+	err = XTReadDB().Model(&group).Where("name = ? and org_id = ? and status =1", name, orgid).First(&group).Error
1137
+	return group, err
1138
+}
1139
+
1105 1140
 func SaveGroup(group *models.DeviceGroup) error {
1106 1141
 	err := XTWriteDB().Model(&group).Create(&group).Error
1107 1142
 	return err
@@ -1136,6 +1171,24 @@ func GetAllGroupOne(orgid int64) (group []*models.DeviceGroup, err error) {
1136 1171
 	return group, err
1137 1172
 }
1138 1173
 
1174
+func GetBedByName(name string, orgid int64) (*models.DeviceNumber, error) {
1175
+	number := models.DeviceNumber{}
1176
+	err := XTReadDB().Model(&number).Where("number=? and org_id = ? and status =1", name, orgid).Find(&number).Error
1177
+	if err == gorm.ErrRecordNotFound {
1178
+		return nil, err
1179
+	}
1180
+	if err != nil {
1181
+		return nil, err
1182
+	}
1183
+	return &number, nil
1184
+}
1185
+
1186
+func GetBedByNameOne(name string, orgid int64) (number models.DeviceNumber, err error) {
1187
+
1188
+	err = XTReadDB().Model(&number).Where("number=? and org_id = ? and status = 1", name, orgid).First(&number).Error
1189
+	return number, err
1190
+}
1191
+
1139 1192
 func CreateNumber(number *models.DeviceNumber) error {
1140 1193
 
1141 1194
 	err := XTWriteDB().Model(&number).Create(&number).Error