Преглед на файлове

Merge branch 'master' of http://git.shengws.com/csx/XT_New

csx преди 4 години
родител
ревизия
cf8d983dad

+ 53 - 0
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go Целия файл

602
 	fmt.Print("结束时间", endtime)
602
 	fmt.Print("结束时间", endtime)
603
 	limit, _ := this.GetInt64("limit")
603
 	limit, _ := this.GetInt64("limit")
604
 	page, _ := this.GetInt64("page")
604
 	page, _ := this.GetInt64("page")
605
+	fmt.Println("病人ID", newPatientInfo.BloodId)
605
 	advice, total, err := service.GetNewDoctorAdvice(newPatientInfo.BloodId, doctor_type, startime, endtime, limit, page, orgid)
606
 	advice, total, err := service.GetNewDoctorAdvice(newPatientInfo.BloodId, doctor_type, startime, endtime, limit, page, orgid)
607
+	one, t, date, err := service.GetNewDoctorAdviceOne(newPatientInfo.BloodId, page, orgid)
608
+	fmt.Print(one, t, date, err)
606
 	if err != nil {
609
 	if err != nil {
607
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
610
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
608
 		return
611
 		return
612
 		"advice": advice,
615
 		"advice": advice,
613
 		"total":  total,
616
 		"total":  total,
614
 		"doctor": doctor,
617
 		"doctor": doctor,
618
+		"one":    one,
615
 	})
619
 	})
616
 }
620
 }
617
 
621
 
1169
 	return
1173
 	return
1170
 }
1174
 }
1171
 
1175
 
1176
+func (this *NewDialysisApiController) DeletePatient() {
1177
+	id, _ := this.GetInt64("id")
1178
+	err := service.DeletePatient(id)
1179
+	fmt.Println("错误是什么", err)
1180
+	returnData := make(map[string]interface{}, 0)
1181
+	returnData["msg"] = "ok"
1182
+	this.ServeSuccessJSON(returnData)
1183
+	return
1184
+}
1185
+
1172
 func (this *NewDialysisApiController) UpdatedPatient() {
1186
 func (this *NewDialysisApiController) UpdatedPatient() {
1173
 
1187
 
1174
 	adminInfo := this.GetMobileAdminUserInfo()
1188
 	adminInfo := this.GetMobileAdminUserInfo()
1981
 		"patient": patient,
1995
 		"patient": patient,
1982
 	})
1996
 	})
1983
 }
1997
 }
1998
+
1999
+func (this *NewDialysisApiController) SaveName() {
2000
+	id := this.GetString("id")
2001
+	ids, _ := strconv.ParseInt(id, 10, 64)
2002
+	fmt.Println("id", ids)
2003
+	name := this.GetString("name")
2004
+	fmt.Println("name", name)
2005
+	role := models.SgjUserAdminRole{
2006
+		UserName: name,
2007
+	}
2008
+	err := service.SaveName(ids, &role)
2009
+	if err != nil {
2010
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2011
+		return
2012
+	}
2013
+	this.ServeSuccessJSON(map[string]interface{}{
2014
+		"role": role,
2015
+	})
2016
+}
2017
+
2018
+func (this *NewDialysisApiController) GetAllOrganization() {
2019
+
2020
+	id, _ := this.GetInt64("id")
2021
+	fmt.Println("id", id)
2022
+}
2023
+
2024
+func (this *NewDialysisApiController) GetMyOrganazition() {
2025
+	id, _ := this.GetInt64("id")
2026
+	fmt.Println("id", id)
2027
+	role, _ := service.GetAdminUserId(id)
2028
+	organaziton, err := service.GetMyOrganaziton(role.AdminUserId)
2029
+	if err != nil {
2030
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2031
+		return
2032
+	}
2033
+	this.ServeSuccessJSON(map[string]interface{}{
2034
+		"organaziton": organaziton,
2035
+	})
2036
+}

+ 4 - 0
controllers/new_mobile_api_controllers/new_mobile_api_router_register.go Целия файл

106
 	beego.Router("/m/api/patient/getinspectiondetail", &NewDialysisApiController{}, "Get:GetInspectionDetail")
106
 	beego.Router("/m/api/patient/getinspectiondetail", &NewDialysisApiController{}, "Get:GetInspectionDetail")
107
 	beego.Router("/m/api/patient/savefeed", &NewDialysisApiController{}, "Get:SaveFeed")
107
 	beego.Router("/m/api/patient/savefeed", &NewDialysisApiController{}, "Get:SaveFeed")
108
 	beego.Router("/m/api/patient/deletechild", &NewDialysisApiController{}, "Delete:DeleteChild")
108
 	beego.Router("/m/api/patient/deletechild", &NewDialysisApiController{}, "Delete:DeleteChild")
109
+	beego.Router("/m/api/patient/deletePatient", &NewDialysisApiController{}, "Delete:DeletePatient")
109
 	beego.Router("/m/api/patient/deleteinspection", &NewDialysisApiController{}, "Delete:DeleteInspection")
110
 	beego.Router("/m/api/patient/deleteinspection", &NewDialysisApiController{}, "Delete:DeleteInspection")
110
 	beego.Router("/m/api/patient/deletechildinspection", &NewDialysisApiController{}, "Delete:DeleteChildInspection")
111
 	beego.Router("/m/api/patient/deletechildinspection", &NewDialysisApiController{}, "Delete:DeleteChildInspection")
111
 	beego.Router("/m/api/patient/savemessage", &NewDialysisApiController{}, "Get:SaveMessage")
112
 	beego.Router("/m/api/patient/savemessage", &NewDialysisApiController{}, "Get:SaveMessage")
127
 	beego.Router("/m/api/patient/getmemberpatient", &NewDialysisApiController{}, "Get:GetMemberPatient")
128
 	beego.Router("/m/api/patient/getmemberpatient", &NewDialysisApiController{}, "Get:GetMemberPatient")
128
 	beego.Router("/m/api/patient/getslowpatient", &NewDialysisApiController{}, "Get:GetSlowPatient")
129
 	beego.Router("/m/api/patient/getslowpatient", &NewDialysisApiController{}, "Get:GetSlowPatient")
129
 	beego.Router("/m/api/patient/getbloodpatient", &NewDialysisApiController{}, "Get:GetBloodPatient")
130
 	beego.Router("/m/api/patient/getbloodpatient", &NewDialysisApiController{}, "Get:GetBloodPatient")
131
+	beego.Router("/m/api/patient/savename", &NewDialysisApiController{}, "Get:SaveName")
132
+	beego.Router("/m/api/patient/getallorganization", &NewDialysisApiController{}, "Get:GetAllOrganization")
133
+	beego.Router("/m/api/patient/getmyorganazition", &NewDialysisApiController{}, "Get:GetMyOrganazition")
130
 }
134
 }

+ 21 - 0
models/device_models.go Целия файл

91
 	return "xt_device_info_wte"
91
 	return "xt_device_info_wte"
92
 }
92
 }
93
 
93
 
94
+type DeviceZones struct {
95
+	ID         int64  `gorm:"column:id" json:"id"`
96
+	OrgID      int64  `gorm:"column:org_id" json:"-"`
97
+	Name       string `json:"name"`
98
+	Type       int    `json:"type"`
99
+	Status     int8   `json:"-"`
100
+	CreateTime int64  `gorm:"column:ctime" json:"-"`
101
+	ModifyTime int64  `gorm:"column:mtime" json:"-"`
102
+	Number     string `gorm:"column:number" json:"number" form:"number"`
103
+}
104
+
94
 type DeviceZone struct {
105
 type DeviceZone struct {
95
 	ID         int64  `gorm:"column:id" json:"id"`
106
 	ID         int64  `gorm:"column:id" json:"id"`
96
 	OrgID      int64  `gorm:"column:org_id" json:"-"`
107
 	OrgID      int64  `gorm:"column:org_id" json:"-"`
105
 	return "xt_device_zone"
116
 	return "xt_device_zone"
106
 }
117
 }
107
 
118
 
119
+type DeviceGroups struct {
120
+	ID         int64  `gorm:"column:id" json:"id"`
121
+	OrgID      int64  `gorm:"column:org_id" json:"-"`
122
+	Name       string `json:"name"`
123
+	Status     int8   `json:"-"`
124
+	CreateTime int64  `gorm:"column:ctime" json:"-"`
125
+	ModifyTime int64  `gorm:"column:mtime" json:"-"`
126
+	Number     string `gorm:"column:number" json:"number" form:"number"`
127
+}
128
+
108
 type DeviceGroup struct {
129
 type DeviceGroup struct {
109
 	ID         int64  `gorm:"column:id" json:"id"`
130
 	ID         int64  `gorm:"column:id" json:"id"`
110
 	OrgID      int64  `gorm:"column:org_id" json:"-"`
131
 	OrgID      int64  `gorm:"column:org_id" json:"-"`

+ 9 - 0
models/inspection_models.go Целия файл

72
 	ProjectId int64
72
 	ProjectId int64
73
 }
73
 }
74
 
74
 
75
+type UserDoctorAdvicesCount struct {
76
+	PatientId int64
77
+	Count     int64
78
+}
79
+
75
 type InspectionReferenceMap struct {
80
 type InspectionReferenceMap struct {
76
 	ProjectName         string                `gorm:"-" json:"project_name" form:"project_name"`
81
 	ProjectName         string                `gorm:"-" json:"project_name" form:"project_name"`
77
 	Project             string                `gorm:"-" json:"project" form:"project"`
82
 	Project             string                `gorm:"-" json:"project" form:"project"`
100
 	InspectDate int64
105
 	InspectDate int64
101
 }
106
 }
102
 
107
 
108
+type AdviceDate struct {
109
+	RecordDate int64
110
+}
111
+
103
 type XtPatientFeedback struct {
112
 type XtPatientFeedback struct {
104
 	ID          int64  `gorm:"column:id" json:"id" form:"id"`
113
 	ID          int64  `gorm:"column:id" json:"id" form:"id"`
105
 	ProblemType int64  `gorm:"column:problem_type" json:"problem_type" form:"problem_type"`
114
 	ProblemType int64  `gorm:"column:problem_type" json:"problem_type" form:"problem_type"`

+ 43 - 0
models/org_models.go Целия файл

107
 func (Illness) TableName() string {
107
 func (Illness) TableName() string {
108
 	return "sgj_user_illness"
108
 	return "sgj_user_illness"
109
 }
109
 }
110
+
111
+type SgjUserOrg struct {
112
+	ID              int64   `gorm:"column:id" json:"id" form:"id"`
113
+	Creator         int64   `gorm:"column:creator" json:"creator" form:"creator"`
114
+	OrgName         string  `gorm:"column:org_name" json:"org_name" form:"org_name"`
115
+	OrgShortName    string  `gorm:"column:org_short_name" json:"org_short_name" form:"org_short_name"`
116
+	OrgLogo         string  `gorm:"column:org_logo" json:"org_logo" form:"org_logo"`
117
+	OrgIntroduction string  `gorm:"column:org_introduction" json:"org_introduction" form:"org_introduction"`
118
+	Illness         string  `gorm:"column:illness" json:"illness" form:"illness"`
119
+	Province        int64   `gorm:"column:province" json:"province" form:"province"`
120
+	City            int64   `gorm:"column:city" json:"city" form:"city"`
121
+	District        int64   `gorm:"column:district" json:"district" form:"district"`
122
+	Address         string  `gorm:"column:address" json:"address" form:"address"`
123
+	Longitude       string  `gorm:"column:longitude" json:"longitude" form:"longitude"`
124
+	Latitude        string  `gorm:"column:latitude" json:"latitude" form:"latitude"`
125
+	OrgType         int64   `gorm:"column:org_type" json:"org_type" form:"org_type"`
126
+	Comments        int64   `gorm:"column:comments" json:"comments" form:"comments"`
127
+	Evaluate        float64 `gorm:"column:evaluate" json:"evaluate" form:"evaluate"`
128
+	Gallery         string  `gorm:"column:gallery" json:"gallery" form:"gallery"`
129
+	BusinessWeek    string  `gorm:"column:business_week" json:"business_week" form:"business_week"`
130
+	BusinessTime    string  `gorm:"column:business_time" json:"business_time" form:"business_time"`
131
+	ContactName     string  `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
132
+	Telephone       string  `gorm:"column:telephone" json:"telephone" form:"telephone"`
133
+	Claim           int64   `gorm:"column:claim" json:"claim" form:"claim"`
134
+	OperatingState  int64   `gorm:"column:operating_state" json:"operating_state" form:"operating_state"`
135
+	Status          int64   `gorm:"column:status" json:"status" form:"status"`
136
+	Ctime           int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
137
+	Mtime           int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
138
+	Source          int64   `gorm:"column:source" json:"source" form:"source"`
139
+	Ttype           int64   `gorm:"column:ttype" json:"ttype" form:"ttype"`
140
+	Ttid            int64   `gorm:"column:ttid" json:"ttid" form:"ttid"`
141
+	Tuid            int64   `gorm:"column:tuid" json:"tuid" form:"tuid"`
142
+	Reason          string  `gorm:"column:reason" json:"reason" form:"reason"`
143
+	Level           int64   `gorm:"column:level" json:"level" form:"level"`
144
+	Website         string  `gorm:"column:website" json:"website" form:"website"`
145
+	Import          int64   `gorm:"column:import" json:"import" form:"import"`
146
+	Sortno          int64   `gorm:"column:sortno" json:"sortno" form:"sortno"`
147
+	IsSuperAdmin    int64   `gorm:"column:is_super_admin" json:"is_super_admin" form:"is_super_admin"`
148
+}
149
+
150
+func (SgjUserOrg) TableName() string {
151
+	return "sgj_user_org"
152
+}

+ 6 - 0
service/inspection_service.go Целия файл

22
 	return
22
 	return
23
 }
23
 }
24
 
24
 
25
+func GetAdvices(orgid int64, patientid int64, recorddate int64) (advcie []*models.DoctorAdvice, err error) {
26
+
27
+	err = XTReadDB().Model(&models.DoctorAdvice{}).Where("patient_id = ? and user_org_id = ? and record_date = ? and status =1", patientid, orgid, recorddate).Find(&advcie).Error
28
+	return
29
+}
30
+
25
 func CreatePatientInspection(inspectins []models.Inspection) (err error) {
31
 func CreatePatientInspection(inspectins []models.Inspection) (err error) {
26
 	if len(inspectins) == 0 {
32
 	if len(inspectins) == 0 {
27
 		err = errors.New("Inspections Cant be nil.")
33
 		err = errors.New("Inspections Cant be nil.")

+ 71 - 4
service/patientmanage_service.go Целия файл

504
 
504
 
505
 }
505
 }
506
 
506
 
507
+func GetNewDoctorAdviceOne(patientID int64, page int64, orgID int64) (doctoradvice []*models.DoctorAdvice, total int64, date int64, err error) {
508
+
509
+	var advicesCount models.UserDoctorAdvicesCount
510
+
511
+	err = XTReadDB().Model(&models.DoctorAdvice{}).Where("patient_id = ? and user_org_id = ? and status =1", patientID, orgID).Select("count(distinct record_date) as count,patient_id").Scan(&advicesCount).Error
512
+
513
+	if err != nil {
514
+		return
515
+	}
516
+	total = advicesCount.Count
517
+	if total == 0 || page > total {
518
+		return
519
+	}
520
+
521
+	var Id models.AdviceDate
522
+
523
+	err = XTReadDB().Model(models.DoctorAdvice{}).Where("patient_id = ? and user_org_id = ? and status = 1", patientID, orgID).Select("record_date").Group("record_date").Order("created_time desc").Offset(page - 1).Limit(10).Scan(&Id).Error
524
+	if err != nil {
525
+		return
526
+	}
527
+
528
+	if Id.RecordDate == 0 {
529
+		return
530
+	}
531
+
532
+	date = Id.RecordDate
533
+	fmt.Println("结构是==============", Id.RecordDate)
534
+	doctoradvice, err = GetAdvices(orgID, patientID, Id.RecordDate)
535
+	if err != nil {
536
+		return
537
+	}
538
+	return
539
+
540
+}
541
+
507
 func GetDryWeight(patientid int64, startime int64, endtime int64, limit int64, page int64, orgId int64) (dryWeight []*models.XtPatientDryweight, total int64, err error) {
542
 func GetDryWeight(patientid int64, startime int64, endtime int64, limit int64, page int64, orgId int64) (dryWeight []*models.XtPatientDryweight, total int64, err error) {
508
 	db := XTReadDB().Table("xt_patient_dryweight as x").Where("x.status = 1")
543
 	db := XTReadDB().Table("xt_patient_dryweight as x").Where("x.status = 1")
509
 	if orgId > 0 {
544
 	if orgId > 0 {
871
 	return err
906
 	return err
872
 }
907
 }
873
 
908
 
909
+func DeletePatient(id int64) error {
910
+
911
+	err = XTWriteDB().Model(models.DoctorAdvice{}).Where("id=? and parent_id = ?", id, id).Update(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()}).Error
912
+	return err
913
+}
914
+
874
 func GetNewPatient(id int64) (models.XtPatientsNew, error) {
915
 func GetNewPatient(id int64) (models.XtPatientsNew, error) {
875
 	patientsNew := models.XtPatientsNew{}
916
 	patientsNew := models.XtPatientsNew{}
876
 	err := XTReadDB().Model(&patientsNew).Where("id=?", id).Find(&patientsNew).Error
917
 	err := XTReadDB().Model(&patientsNew).Where("id=?", id).Find(&patientsNew).Error
1014
 	return err
1055
 	return err
1015
 }
1056
 }
1016
 
1057
 
1017
-func GetAllZone(orgid int64, page int64, limit int64) (zone []*models.DeviceZone, total int64, err error) {
1058
+func GetAllZone(orgid int64, page int64, limit int64) (zone []*models.DeviceZones, total int64, err error) {
1018
 
1059
 
1019
 	db := XTReadDB().Table("xt_device_zone as x").Where("x.status =1")
1060
 	db := XTReadDB().Table("xt_device_zone as x").Where("x.status =1")
1061
+	table := XTReadDB().Table("xt_device_number as n")
1062
+	fmt.Println("table", table)
1020
 	if orgid > 0 {
1063
 	if orgid > 0 {
1021
 		db = db.Where("x.org_id = ?", orgid)
1064
 		db = db.Where("x.org_id = ?", orgid)
1022
 	}
1065
 	}
1023
 	offset := (page - 1) * limit
1066
 	offset := (page - 1) * limit
1024
-	err = db.Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Select("x.id,x.org_id,x.name,x.type").Find(&zone).Error
1067
+	err = db.Group("x.id").Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Select("x.id,x.org_id,x.name,x.type,n.number").Joins("left join xt_device_number as n on n.zone_id = x.id").Scan(&zone).Error
1025
 	return zone, total, err
1068
 	return zone, total, err
1026
 }
1069
 }
1027
 
1070
 
1036
 	return err
1079
 	return err
1037
 }
1080
 }
1038
 
1081
 
1039
-func GetAllGroup(orgid int64, page int64, limit int64) (group []*models.DeviceGroup, total int64, err error) {
1082
+func GetAllGroup(orgid int64, page int64, limit int64) (group []*models.DeviceGroups, total int64, err error) {
1040
 	db := XTReadDB().Table("xt_device_group as x").Where("x.status = 1")
1083
 	db := XTReadDB().Table("xt_device_group as x").Where("x.status = 1")
1084
+	table := XTReadDB().Table("xt_device_number as n")
1085
+	fmt.Println("table", table)
1041
 	if orgid > 0 {
1086
 	if orgid > 0 {
1042
 		db = db.Where("x.org_id = ?", orgid)
1087
 		db = db.Where("x.org_id = ?", orgid)
1043
 	}
1088
 	}
1044
 	offset := (page - 1) * limit
1089
 	offset := (page - 1) * limit
1045
-	err = db.Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Select("x.id,x.org_id,x.name,x.status,x.ctime,x.mtime").Find(&group).Error
1090
+	err = db.Group("x.id").Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Select("x.id,x.org_id,x.name,x.status,x.ctime,x.mtime,n.number").Joins("left join xt_device_number as n on n.group_id = x.id").Scan(&group).Error
1046
 	return group, total, err
1091
 	return group, total, err
1047
 }
1092
 }
1048
 
1093
 
1103
 	err = XTReadDB().Model(&patients).Where("user_org_id = ? AND blood_patients = ? AND status = 1", orgid, 1).Find(&patients).Error
1148
 	err = XTReadDB().Model(&patients).Where("user_org_id = ? AND blood_patients = ? AND status = 1", orgid, 1).Find(&patients).Error
1104
 	return patients, err
1149
 	return patients, err
1105
 }
1150
 }
1151
+
1152
+func SaveName(id int64, role *models.SgjUserAdminRole) error {
1153
+
1154
+	err = UserWriteDB().Model(models.SgjUserAdminRole{}).Where("id=?", id).Update(map[string]interface{}{"user_name": role.UserName, "mtime": time.Now().Unix()}).Error
1155
+	return err
1156
+}
1157
+
1158
+func GetAdminUserId(id int64) (models.SgjUserAdminRole, error) {
1159
+
1160
+	role := models.SgjUserAdminRole{}
1161
+	err := UserReadDB().Where("id=? and status =1", id).Find(&role).Error
1162
+	return role, err
1163
+}
1164
+
1165
+func GetMyOrganaziton(id int64) (org []*models.SgjUserOrg, err error) {
1166
+
1167
+	db := UserReadDB().Table("sgj_user_org as x").Where("x.status = 1")
1168
+	table := UserReadDB().Table("sgj_user_admin as a")
1169
+	fmt.Println("table", table)
1170
+	err = db.Select("x.id,x.creator,x.org_name,x.org_short_name,x.org_logo,x.org_introduction,x.illness,x.province,x.city,x.district,x.address,x.longitude,x.latitude,x.org_type,x.comments,x.evaluate,x.gallery,x.business_week,x.business_time,x.contact_name,x.telephone,x.claim,x.operating_state,x.source,x.ttype,x.ttid,x.tuid,x.reason,x.level,x.website,x.import,x.sortno,a.is_super_admin").Joins("left join sgj_user_admin as a on a.id = x.creator").Where("x.creator = ?", id).Scan(&org).Error
1171
+	return org, err
1172
+}