瀏覽代碼

耗材参数

XMLWAN 3 年之前
父節點
當前提交
0e22b5184d
共有 3 個文件被更改,包括 35 次插入3 次删除
  1. 3 1
      controllers/dialysis_record_api_controller.go
  2. 1 0
      models/dialysis.go
  3. 31 2
      service/mobile_dialysis_service.go

+ 3 - 1
controllers/dialysis_record_api_controller.go 查看文件

@@ -228,7 +228,9 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
228 228
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
229 229
 		return
230 230
 	}
231
-	dialysisSolution, getDialysisSolutionErr := service.GetDialysisSolution(adminInfo.CurrentOrgId, patientID, schedual.ModeId)
231
+	//dialysisSolution, getDialysisSolutionErr := service.GetDialysisSolution(adminInfo.CurrentOrgId, patientID, schedual.ModeId)
232
+	dialysisSolution, getDialysisSolutionErr := service.GetDialysisSolutionOne(adminInfo.CurrentOrgId, schedual.ModeId)
233
+
232 234
 	if getDialysisSolutionErr != nil {
233 235
 		this.ErrorLog("获取透析方案失败:%v", getDialysisSolutionErr)
234 236
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)

+ 1 - 0
models/dialysis.go 查看文件

@@ -810,6 +810,7 @@ type XtDialysisOrders struct {
810 810
 	Number         int64  `gorm:"column:number" json:"number" form:"number"`
811 811
 	UserName       int64  `gorm:"column:user_name" json:"user_name" form:"user_name"`
812 812
 	WashpipeNurse  int64  `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
813
+	ModeId         int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
813 814
 }
814 815
 
815 816
 type TreatmentMode struct {

+ 31 - 2
service/mobile_dialysis_service.go 查看文件

@@ -1336,6 +1336,19 @@ func GetDialysisSolution(orgID int64, patientID int64, mode_id int64) (*models.D
1336 1336
 	return &record, nil
1337 1337
 }
1338 1338
 
1339
+func GetDialysisSolutionOne(orgID int64, mode_id int64) (*models.DialysisSolution, error) {
1340
+	var record models.DialysisSolution
1341
+	err := readDb.Model(&models.DialysisSolution{}).Where("user_org_id = ? and status = 1 AND mode_id = ?", orgID, mode_id).Last(&record).Error
1342
+	if err != nil {
1343
+		if err == gorm.ErrRecordNotFound {
1344
+			return nil, nil
1345
+		} else {
1346
+			return nil, err
1347
+		}
1348
+	}
1349
+	return &record, nil
1350
+}
1351
+
1339 1352
 func GetLastDialysisPrescribeByModeId(orgID int64, patientID int64, mode_id int64) (*models.DialysisPrescription, error) {
1340 1353
 	var record models.DialysisPrescription
1341 1354
 	err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1  AND mode_id = ?", patientID, orgID, mode_id).Last(&record).Error
@@ -1950,9 +1963,25 @@ func BatchDeleteMonitor(ids []string) (err error) {
1950 1963
 	return
1951 1964
 }
1952 1965
 
1953
-func GetPatientDialysisRecordList(patientid int64, startime int64, endtime int64) (order []*models.XtDialysisOrder, err error) {
1966
+func GetPatientDialysisRecordList(patientid int64, startime int64, endtime int64) (order []*models.XtDialysisOrders, err error) {
1967
+
1968
+	//err = XTReadDB().Where("patient_id = ? and dialysis_date>=? and dialysis_date<=?  and status = 1", patientid, startime, endtime).Find(&order).Error
1969
+	//return order, err
1970
+
1971
+	db := XTReadDB().Table("xt_dialysis_order as x").Where("x.status = 1")
1972
+	table := XTReadDB().Table("xt_schedule as s")
1973
+	fmt.Println(table)
1974
+	if patientid > 0 {
1975
+		db = db.Where("x.patient_id")
1976
+	}
1977
+	if startime > 0 {
1978
+		db = db.Where("x.dialysis_date>=?", startime)
1979
+	}
1980
+	if endtime > 0 {
1981
+		db = db.Where("x.dialysis_date <= ?", endtime)
1982
+	}
1954 1983
 
1955
-	err = XTReadDB().Where("patient_id = ? and dialysis_date>=? and dialysis_date<=?  and status = 1", patientid, startime, endtime).Find(&order).Error
1984
+	err = db.Select("x.id,x.dialysis_date,x.schedual_type,s.mode_id").Joins("left join x.patient_id = s.patient_id and x.dialysis_date = s.schedule_date ").Scan(&order).Error
1956 1985
 	return order, err
1957 1986
 }
1958 1987