Browse Source

体积小

XMLWAN 3 years ago
parent
commit
6a007976d2

+ 12 - 0
controllers/xcx_mobile_api_controller.go/xcx_api_controller.go View File

@@ -34,6 +34,9 @@ func XcxApiControllersRegisterRouters() {
34 34
 
35 35
 	//获取透析记录
36 36
 	beego.Router("/xcx/api/mobile/dialysis", &XcxApiController{}, "Get:GetMobileSchedule")
37
+
38
+	//获取患者的电子病历
39
+	beego.Router("/xcx/api/mobile/getpatientinfo", &XcxApiController{}, "Get:GetPatientInfo")
37 40
 }
38 41
 
39 42
 type XcxApiController struct {
@@ -561,3 +564,12 @@ func (this *XcxApiController) GetMobileSchedule() {
561 564
 	this.ServeSuccessJSON(returnData)
562 565
 
563 566
 }
567
+
568
+func (this *XcxApiController) GetPatientInfo() {
569
+
570
+	patient_id, _ := this.GetInt64("patient_id")
571
+	patient, _ := service.GetXcxPatientInfo(patient_id)
572
+	this.ServeSuccessJSON(map[string]interface{}{
573
+		"patient": patient,
574
+	})
575
+}

+ 32 - 0
models/xcx_user_models.go View File

@@ -134,6 +134,8 @@ type BloodSchedule struct {
134 134
 	Status       int64 `gorm:"column:status" json:"status" form:"status"`
135 135
 	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
136 136
 	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
137
+	Name         string
138
+	Number       string
137 139
 }
138 140
 
139 141
 func (BloodSchedule) TableName() string {
@@ -141,6 +143,36 @@ func (BloodSchedule) TableName() string {
141 143
 	return "xt_schedule"
142 144
 }
143 145
 
146
+type XcxDeviceZone struct {
147
+	ID         int64  `gorm:"column:id" json:"id"`
148
+	OrgID      int64  `gorm:"column:org_id" json:"-"`
149
+	Name       string `json:"name"`
150
+	Type       int    `json:"type"`
151
+	Status     int8   `json:"-"`
152
+	CreateTime int64  `gorm:"column:ctime" json:"-"`
153
+	ModifyTime int64  `gorm:"column:mtime" json:"-"`
154
+}
155
+
156
+func (XcxDeviceZone) TableName() string {
157
+	return "xt_device_zone"
158
+}
159
+
160
+type XcxDeviceNumber struct {
161
+	ID         int64  `gorm:"column:id" json:"id"`
162
+	OrgID      int64  `gorm:"column:org_id" json:"-"`
163
+	Number     string `gorm:"column:number" json:"number"`
164
+	GroupID    int64  `gorm:"column:group_id" json:"group_id"`
165
+	ZoneID     int64  `gorm:"column:zone_id" json:"zone_id"`
166
+	Status     int8   `json:"-"`
167
+	CreateTime int64  `gorm:"column:ctime" json:"-"`
168
+	ModifyTime int64  `gorm:"column:mtime" json:"-"`
169
+	Sort       int64  `gorm:"column:sort" json:"sort" form:"sort"`
170
+}
171
+
172
+func (XcxDeviceNumber) TableName() string {
173
+	return "xt_device_number"
174
+}
175
+
144 176
 type XcXDialysisOrder struct {
145 177
 	ID                     int64  `gorm:"column:id" json:"id" form:"id"`
146 178
 	DialysisDate           int64  `gorm:"column:dialysis_date" json:"dialysis_date" form:"dialysis_date"`

+ 21 - 1
service/xcx_mobile_api_service.go View File

@@ -221,6 +221,26 @@ func GetTodayDialysis(recordDate int64, patient_id int64) (models.XcXDialysisOrd
221 221
 
222 222
 func GetNextPatientSchedule(patient_id int64, dialysis_date int64) (models.BloodSchedule, error) {
223 223
 	schedule := models.BloodSchedule{}
224
-	err := XTReadDB().Model(&schedule).Where("patient_id = ? and status = 1 and schedule_date>?", patient_id, dialysis_date).Order("schedule_date asc").First(&schedule).Error
224
+
225
+	//err := XTReadDB().Model(&schedule).Where("patient_id = ? and status = 1 and schedule_date>?", patient_id, dialysis_date).Order("schedule_date asc").First(&schedule).Error
226
+	//return schedule, err
227
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
228
+	table := XTReadDB().Table("xt_device_zone as z").Where("z.status =1")
229
+	tables := XTReadDB().Table("xt_device_number as n").Where("n.status =1")
230
+	fmt.Println(table, tables)
231
+	if patient_id > 0 {
232
+		db = db.Where("x.patient_id = ?", patient_id)
233
+	}
234
+	if dialysis_date > 0 {
235
+		db = db.Where("x.schedule_date >?", dialysis_date)
236
+	}
237
+	err := db.Select("x.patient_id,x.schedule_date,x.mode_id,z.name,n.number").Joins("left join xt_device_zone as z on z.id = x.partition_id").Joins("left join xt_device_number as n on n.id = x.bed_id").Order("x.schedule_date asc").Limit(1).Scan(&schedule).Error
225 238
 	return schedule, err
226 239
 }
240
+
241
+func GetXcxPatientInfo(patient_id int64) (models.XcxPatients, error) {
242
+
243
+	patients := models.XcxPatients{}
244
+	err := XTReadDB().Model(&patients).Where("id = ? and status = 1", patient_id).Find(&patients).Error
245
+	return patients, err
246
+}