|
@@ -1300,3 +1300,68 @@ func GetMedicalInsuranceCostCompareList(orgID, page, limit int64, keywords strin
|
1300
|
1300
|
}
|
1301
|
1301
|
return
|
1302
|
1302
|
}
|
|
1303
|
+
|
|
1304
|
+type TempPatients struct {
|
|
1305
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
1306
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
|
1307
|
+ UserId int64 `gorm:"column:user_id" json:"user_id" form:"user_id"`
|
|
1308
|
+ Avatar string `gorm:"column:avatar" json:"avatar" form:"avatar"`
|
|
1309
|
+ Lapseto int64 `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
|
|
1310
|
+ Name string `gorm:"column:name" json:"name" form:"name"`
|
|
1311
|
+ IdCardNo string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
|
|
1312
|
+ Phone string `gorm:"column:phone" json:"phone" form:"phone"`
|
|
1313
|
+ HomeTelephone string `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
|
|
1314
|
+ HomeAddress string `gorm:"column:home_address" json:"home_address" form:"home_address"`
|
|
1315
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
1316
|
+ GdybPsnNcdsRecord GdybPsnNcdsRecord `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"record"`
|
|
1317
|
+}
|
|
1318
|
+
|
|
1319
|
+func (TempPatients) TableName() string {
|
|
1320
|
+ return "xt_patients"
|
|
1321
|
+}
|
|
1322
|
+
|
|
1323
|
+type GdybPsnNcdsRecord struct {
|
|
1324
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
1325
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
|
1326
|
+ PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
|
|
1327
|
+ PsnNo string `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
|
|
1328
|
+ Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
|
1329
|
+ Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
|
1330
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
1331
|
+ IsCancel int64 `gorm:"column:is_cancel" json:"is_cancel" form:"is_cancel"`
|
|
1332
|
+ TrtDclaDetlSn string `gorm:"column:trt_dcla_detl_sn" json:"trt_dcla_detl_sn" form:"trt_dcla_detl_sn"`
|
|
1333
|
+ DoctorId int64 `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
|
|
1334
|
+ DepartmentId int64 `gorm:"column:department_id" json:"department_id" form:"department_id"`
|
|
1335
|
+ Insutype string `gorm:"column:insutype" json:"insutype" form:"insutype"`
|
|
1336
|
+ SickType int64 `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
|
|
1337
|
+ OrgName string `gorm:"column:org_name" json:"org_name" form:"org_name"`
|
|
1338
|
+}
|
|
1339
|
+
|
|
1340
|
+func (GdybPsnNcdsRecord) TableName() string {
|
|
1341
|
+ return "gdyb_psn_ncds_record"
|
|
1342
|
+}
|
|
1343
|
+
|
|
1344
|
+func GetGdybPsnNcdsRecordList(orgID, page, limit int64, keywords string, is_cancel int64) (list []*TempPatients, total int64, err error) {
|
|
1345
|
+ offset := (page - 1) * limit
|
|
1346
|
+ db := readDb.Model(&TempPatients{})
|
|
1347
|
+ db = db.Preload("GdybPsnNcdsRecord", func(db *gorm.DB) *gorm.DB {
|
|
1348
|
+ return db.Model(&GdybPsnNcdsRecord{}).Where("user_org_id = ?", orgID).Order("id asc")
|
|
1349
|
+ })
|
|
1350
|
+ if len(keywords) == 0 {
|
|
1351
|
+ if is_cancel != 0 {
|
|
1352
|
+ db = db.Joins("JOIN gdyb_psn_ncds_record On gdyb_psn_ncds_record.patient_id = xt_patients.id AND gdyb_psn_ncds_record.is_cancel = ?", is_cancel)
|
|
1353
|
+ db = db.Where("user_org_id = ? AND status = 1 AND lapseto = 1", orgID)
|
|
1354
|
+ } else {
|
|
1355
|
+ db = db.Preload("GdybPsnNcdsRecord", "user_org_id = ?", orgID)
|
|
1356
|
+ db = db.Where("user_org_id = ? AND status = 1 AND lapseto = 1", orgID)
|
|
1357
|
+ }
|
|
1358
|
+ err = db.Count(&total).Offset(offset).Limit(limit).Find(&list).Error
|
|
1359
|
+ } else {
|
|
1360
|
+ keywords = "%" + keywords + "%"
|
|
1361
|
+ db = db.Where("user_org_id = ? AND status = 1 AND lapseto = 1 AND name LIKE ?", orgID, keywords)
|
|
1362
|
+ err = db.Count(&total).Offset(offset).Limit(limit).Find(&list).Error
|
|
1363
|
+
|
|
1364
|
+ }
|
|
1365
|
+
|
|
1366
|
+ return
|
|
1367
|
+}
|