XMLWAN пре 5 година
родитељ
комит
2f45157ba0

+ 1 - 1
conf/app.conf Прегледај датотеку

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

+ 3 - 3
controllers/dialysis_api_controller.go Прегледај датотеку

4314
 	//获取医嘱内容
4314
 	//获取医嘱内容
4315
 	doctor, err := service.FindDoctor(doctorAdvice.AdviceDoctor, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
4315
 	doctor, err := service.FindDoctor(doctorAdvice.AdviceDoctor, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
4316
 	DoctorName, err := service.FindDoctorName(doctorAdvice.AdviceDoctor, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
4316
 	DoctorName, err := service.FindDoctorName(doctorAdvice.AdviceDoctor, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
4317
-	fmt.Print("err-----------------------------------------------------------------", err)
4317
+	//fmt.Print("err-----------------------------------------------------------------", err)
4318
 	DoctorAdvice, _ := service.FindDoctorAdviceOrderById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4318
 	DoctorAdvice, _ := service.FindDoctorAdviceOrderById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4319
 	doctorAdevieInfo, err := service.FindDoctorAdviceByInfo(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4319
 	doctorAdevieInfo, err := service.FindDoctorAdviceByInfo(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4320
 	//获取上次的透后体重
4320
 	//获取上次的透后体重
4350
 	check, _ := service.FindDoubleCheckById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
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
 	templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
4355
 	templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
4356
 	c.ServeSuccessJSON(map[string]interface{}{
4356
 	c.ServeSuccessJSON(map[string]interface{}{
4357
 		"xtdate":                  xtdate,
4357
 		"xtdate":                  xtdate,

+ 13 - 1
controllers/mobile_api_controllers/dialysis_api_controller.go Прегледај датотеку

366
 
366
 
367
 	//dialysisSolution, getDialysisSolutionErr := service.MobileGetDialysisSolution(adminInfo.Org.Id, patientID)
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
 	if getLPEErr != nil {
371
 	if getLPEErr != nil {
372
 		this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
372
 		this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
387
 	goodTypes, _ := service.FindAllGoodTypeByType(1)          //查出所有库存配置的系统类型
387
 	goodTypes, _ := service.FindAllGoodTypeByType(1)          //查出所有库存配置的系统类型
388
 	goodInfos, _ := service.FindAllGoodInfo(adminInfo.Org.Id) //查出所有库存配置的系统类型
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
 	returnData := map[string]interface{}{
394
 	returnData := map[string]interface{}{
391
 		"patient":                        patient,
395
 		"patient":                        patient,
392
 		"schedual":                       schedual,
396
 		"schedual":                       schedual,
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 Прегледај датотеку

108
 
108
 
109
 	beego.Router("/m/api/schedule/get", &DialysisAPIController{}, "Get:GetSchedule")
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 Прегледај датотеку

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

+ 85 - 36
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go Прегледај датотеку

555
 }
555
 }
556
 
556
 
557
 func (this *NewDialysisApiController) GetPatientDetail() {
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
 	id, _ := this.GetInt64("id")
565
 	id, _ := this.GetInt64("id")
559
 	//获取病人详情信息
566
 	//获取病人详情信息
560
 	detail, err := service.GetPatientDetailTwo(id)
567
 	detail, err := service.GetPatientDetailTwo(id)
574
 		"diseases":       diseases,
581
 		"diseases":       diseases,
575
 		"slowDiseases":   slowDiseases,
582
 		"slowDiseases":   slowDiseases,
576
 		"cronicDiseases": cronicDiseases,
583
 		"cronicDiseases": cronicDiseases,
584
+		"nowdate":        nowdate,
577
 	})
585
 	})
578
 }
586
 }
579
 
587
 
1837
 	fmt.Println("分区型号", zonetype)
1845
 	fmt.Println("分区型号", zonetype)
1838
 	strInt64 := strconv.FormatInt(zonetype, 10)
1846
 	strInt64 := strconv.FormatInt(zonetype, 10)
1839
 	typeid, _ := strconv.Atoi(strInt64)
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
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1867
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1850
 		return
1868
 		return
1851
 	}
1869
 	}
1852
-	this.ServeSuccessJSON(map[string]interface{}{
1853
-		"zone": zone,
1854
-	})
1855
 }
1870
 }
1856
 
1871
 
1857
 func (this *NewDialysisApiController) GetAllZone() {
1872
 func (this *NewDialysisApiController) GetAllZone() {
1886
 	orgid := adminUser.Org.Id
1901
 	orgid := adminUser.Org.Id
1887
 	name := this.GetString("name")
1902
 	name := this.GetString("name")
1888
 	fmt.Println("name", name)
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
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1921
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1898
 		return
1922
 		return
1899
 	}
1923
 	}
1900
-	this.ServeSuccessJSON(map[string]interface{}{
1901
-		"group": group,
1902
-	})
1924
+
1903
 }
1925
 }
1904
 
1926
 
1905
 func (this *NewDialysisApiController) GetAllGroup() {
1927
 func (this *NewDialysisApiController) GetAllGroup() {
1955
 	fmt.Print("zone", zone)
1977
 	fmt.Print("zone", zone)
1956
 	group, _ := this.GetInt64("group")
1978
 	group, _ := this.GetInt64("group")
1957
 	fmt.Println("group", group)
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
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1999
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1969
 		return
2000
 		return
1970
 	}
2001
 	}
1971
-	this.ServeSuccessJSON(map[string]interface{}{
1972
-		"number": number,
1973
-	})
2002
+
1974
 }
2003
 }
1975
 
2004
 
1976
 func (this *NewDialysisApiController) GetAllNumber() {
2005
 func (this *NewDialysisApiController) GetAllNumber() {
2278
 }
2307
 }
2279
 
2308
 
2280
 func (this *NewDialysisApiController) UpdatePartition() {
2309
 func (this *NewDialysisApiController) UpdatePartition() {
2310
+	adminUser := this.GetMobileAdminUserInfo()
2311
+	orgid := adminUser.Org.Id
2281
 	id, _ := this.GetInt64("id")
2312
 	id, _ := this.GetInt64("id")
2282
 	name := this.GetString("name")
2313
 	name := this.GetString("name")
2283
 	zoneType, _ := this.GetInt64("type")
2314
 	zoneType, _ := this.GetInt64("type")
2284
 	strInt64 := strconv.FormatInt(zoneType, 10)
2315
 	strInt64 := strconv.FormatInt(zoneType, 10)
2285
 	typeid, _ := strconv.Atoi(strInt64)
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
 	zone := models.DeviceZone{
2322
 	zone := models.DeviceZone{
2287
 		Name: name,
2323
 		Name: name,
2288
 		Type: typeid,
2324
 		Type: typeid,
2311
 }
2347
 }
2312
 
2348
 
2313
 func (this *NewDialysisApiController) UpdateGroup() {
2349
 func (this *NewDialysisApiController) UpdateGroup() {
2350
+	adminUser := this.GetMobileAdminUserInfo()
2351
+	orgid := adminUser.Org.Id
2314
 	id, _ := this.GetInt64("id")
2352
 	id, _ := this.GetInt64("id")
2315
 	name := this.GetString("name")
2353
 	name := this.GetString("name")
2354
+	byName, _ := service.GetGroupByNameOne(name, orgid)
2355
+	if byName.ID > 0 && byName.ID != id {
2356
+		return
2357
+	}
2316
 	group := models.DeviceGroup{Name: name}
2358
 	group := models.DeviceGroup{Name: name}
2317
 	err := service.UpdateGroup(id, &group)
2359
 	err := service.UpdateGroup(id, &group)
2318
 	if err != nil {
2360
 	if err != nil {
2343
 }
2385
 }
2344
 
2386
 
2345
 func (this *NewDialysisApiController) UpdatedBed() {
2387
 func (this *NewDialysisApiController) UpdatedBed() {
2388
+	adminUser := this.GetMobileAdminUserInfo()
2389
+	orgId := adminUser.Org.Id
2346
 	id, _ := this.GetInt64("id")
2390
 	id, _ := this.GetInt64("id")
2347
 	name := this.GetString("name")
2391
 	name := this.GetString("name")
2348
 	fmt.Println("name", name)
2392
 	fmt.Println("name", name)
2350
 	fmt.Println("zone", zone)
2394
 	fmt.Println("zone", zone)
2351
 	group, _ := this.GetInt64("group")
2395
 	group, _ := this.GetInt64("group")
2352
 	fmt.Println("group", group)
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
 	number := models.DeviceNumber{
2402
 	number := models.DeviceNumber{
2354
 		Number:  name,
2403
 		Number:  name,
2355
 		ZoneID:  zone,
2404
 		ZoneID:  zone,

+ 24 - 0
models/admin_user_models.go Прегледај датотеку

71
 	return "sgj_user_admin_electronic_signature"
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
 type AdminUserSpecialPermission struct {
99
 type AdminUserSpecialPermission struct {
76
 	ID          int64 `gorm:"column:id" json:"id"`
100
 	ID          int64 `gorm:"column:id" json:"id"`

+ 24 - 0
models/dialysis.go Прегледај датотеку

808
 	return "xt_gobal_template"
808
 	return "xt_gobal_template"
809
 }
809
 }
810
 
810
 
811
+type UserAdminRoles struct {
812
+	ID            int64  `gorm:"column:id" json:"id" form:"id"`
813
+	AdminUserId   int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
814
+	OrgId         int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
815
+	AppId         int64  `gorm:"column:app_id" json:"app_id" form:"app_id"`
816
+	RoleId        int64  `gorm:"column:role_id" json:"role_id" form:"role_id"`
817
+	UserName      string `gorm:"column:user_name" json:"user_name" form:"user_name"`
818
+	Avatar        string `gorm:"column:avatar" json:"avatar" form:"avatar"`
819
+	UserType      int64  `gorm:"column:user_type" json:"user_type" form:"user_type"`
820
+	UserTitle     int64  `gorm:"column:user_title" json:"user_title" form:"user_title"`
821
+	Intro         string `gorm:"column:intro" json:"intro" form:"intro"`
822
+	Status        int64  `gorm:"column:status" json:"status" form:"status"`
823
+	Ctime         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
824
+	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
825
+	UserTitleName string `gorm:"column:user_title_name" json:"user_title_name" form:"user_title_name"`
826
+	RoleIds       string `gorm:"column:role_ids" json:"role_ids" form:"role_ids"`
827
+	Message       string `gorm:"column:message" json:"message" form:"message"`
828
+	Sex           int64  `gorm:"column:sex" json:"sex" form:"sex"`
829
+	Birthday      int64  `gorm:"column:birthday" json:"birthday" form:"birthday"`
830
+	Creator       int64  `gorm:"column:creator" json:"creator" form:"creator"`
831
+	Url           string `gorm:"column:url" json:"url" form:"url"`
832
+	Hash          string `gorm:"column:hash" json:"hash" form:"hash"`
833
+}
834
+
811
 type SgjUserAdminRole struct {
835
 type SgjUserAdminRole struct {
812
 	ID            int64  `gorm:"column:id" json:"id" form:"id"`
836
 	ID            int64  `gorm:"column:id" json:"id" form:"id"`
813
 	AdminUserId   int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
837
 	AdminUserId   int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`

+ 7 - 0
service/device_service.go Прегледај датотеку

648
 
648
 
649
 	return mode, err
649
 	return mode, err
650
 }
650
 }
651
+
652
+func GetPatientId(id int64) (models.XtPatientsNew, error) {
653
+
654
+	patientsNew := models.XtPatientsNew{}
655
+	err := XTReadDB().Model(&patientsNew).Where("blood_id = ? and status = 1", id).Find(&patientsNew).Error
656
+	return patientsNew, err
657
+}

+ 18 - 0
service/dialysis_service.go Прегледај датотеку

695
 	return
695
 	return
696
 }
696
 }
697
 
697
 
698
+func GetAdminUserEsOne(orgid int64) (adminrole []*models.UserAdminRoles, err error) {
699
+
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)
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(&adminrole).Error
704
+	return adminrole, err
705
+}
706
+
698
 func UpDateDialysisPrescriptionDoctorSign(patient int64, date int64, orgId int64, doctor_id int64) (err error) {
707
 func UpDateDialysisPrescriptionDoctorSign(patient int64, date int64, orgId int64, doctor_id int64) (err error) {
699
 	err = writeDb.Model(&models.DialysisPrescription{}).Where("user_org_id = ? AND patient_id = ? AND record_date = ? ", orgId, patient, date).Updates(map[string]interface{}{"prescription_doctor": doctor_id}).Error
708
 	err = writeDb.Model(&models.DialysisPrescription{}).Where("user_org_id = ? AND patient_id = ? AND record_date = ? ", orgId, patient, date).Updates(map[string]interface{}{"prescription_doctor": doctor_id}).Error
700
 	return
709
 	return
705
 	return
714
 	return
706
 }
715
 }
707
 
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
+
708
 func FindLastMonitorRecord(patient_id int64, org_id int64) (record models.MonitoringRecord, err error) {
726
 func FindLastMonitorRecord(patient_id int64, org_id int64) (record models.MonitoringRecord, err error) {
709
 	err = readDb.Model(&models.MonitoringRecord{}).Where("patient_id = ? AND status = 1 AND user_org_id = ?", patient_id, org_id).Last(&record).Error
727
 	err = readDb.Model(&models.MonitoringRecord{}).Where("patient_id = ? AND status = 1 AND user_org_id = ?", patient_id, org_id).Last(&record).Error
710
 	return
728
 	return

+ 53 - 0
service/patientmanage_service.go Прегледај датотеку

1077
 	return err
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
 func CreatedZone(zone *models.DeviceZone) error {
1098
 func CreatedZone(zone *models.DeviceZone) error {
1081
 
1099
 
1082
 	err := XTWriteDB().Model(&zone).Create(&zone).Error
1100
 	err := XTWriteDB().Model(&zone).Create(&zone).Error
1102
 	return err
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
 func SaveGroup(group *models.DeviceGroup) error {
1140
 func SaveGroup(group *models.DeviceGroup) error {
1106
 	err := XTWriteDB().Model(&group).Create(&group).Error
1141
 	err := XTWriteDB().Model(&group).Create(&group).Error
1107
 	return err
1142
 	return err
1136
 	return group, err
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
 func CreateNumber(number *models.DeviceNumber) error {
1192
 func CreateNumber(number *models.DeviceNumber) error {
1140
 
1193
 
1141
 	err := XTWriteDB().Model(&number).Create(&number).Error
1194
 	err := XTWriteDB().Model(&number).Create(&number).Error