|
@@ -275,17 +275,71 @@ type AdviceDate struct {
|
275
|
275
|
RecordDate int64
|
276
|
276
|
}
|
277
|
277
|
|
278
|
|
-func GetDoctorAdviceByType(change_type int64, record_time int64, org_id int64, patient_id int64) (advice []*models.DoctorAdvice, err error) {
|
|
278
|
+type DoctorAdvice struct {
|
|
279
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
280
|
+ GroupNo int64 `gorm:"column:groupno" json:"groupno" form:"groupno"`
|
|
281
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
|
282
|
+ PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
|
|
283
|
+ AdviceType int64 `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
|
|
284
|
+ AdviceDate int64 `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
|
|
285
|
+ StartTime int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
|
|
286
|
+ AdviceName string `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
|
|
287
|
+ AdviceDesc string `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
|
|
288
|
+ ReminderDate int64 `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
|
|
289
|
+ SingleDose float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
|
|
290
|
+ SingleDoseUnit string `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
|
|
291
|
+ DrugSpec float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
|
|
292
|
+ DrugSpecUnit string `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
|
|
293
|
+ PrescribingNumber float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
|
|
294
|
+ PrescribingNumberUnit string `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
|
|
295
|
+ DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
|
|
296
|
+ ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
|
|
297
|
+ AdviceDoctor int64 `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
|
|
298
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
299
|
+ CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
|
|
300
|
+ UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
|
|
301
|
+ AdviceAffirm string `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
|
|
302
|
+ Remark string `gorm:"column:remark" json:"remark" form:"remark"`
|
|
303
|
+ StopTime int64 `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
|
|
304
|
+ StopReason string `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
|
|
305
|
+ StopDoctor int64 `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
|
|
306
|
+ StopState int64 `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
|
|
307
|
+ ParentId int64 `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
|
|
308
|
+ ExecutionTime int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
|
|
309
|
+ ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
|
|
310
|
+ ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
|
|
311
|
+ Checker int64 `gorm:"column:checker" json:"checker" form:"checker"`
|
|
312
|
+ RecordDate int64 `gorm:"column:record_date" json:"record_date"`
|
|
313
|
+ DialysisOrderId int64 `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
|
|
314
|
+ CheckTime int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
|
|
315
|
+ CheckState int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
|
|
316
|
+ AdviceId int64 `gorm:"-"`
|
|
317
|
+ RemindType int64 `gorm:"column:remind_type" json:"remind_type"`
|
|
318
|
+ FrequencyType int64 `gorm:"column:frequency_type" json:"frequency_type"`
|
|
319
|
+ DayCount int64 `gorm:"column:day_count" json:"day_count"`
|
|
320
|
+ WeekDay string `gorm:"column:week_day" json:"week_day"`
|
|
321
|
+ DoctorAdvice []*DoctorAdvice `gorm:"ForeignKey:ParentId;AssociationForeignKey:ID" json:"children"`
|
|
322
|
+ TemplateId string `gorm:"column:template_id" json:"template_id"`
|
|
323
|
+ Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
|
|
324
|
+ IsCheck int64 `gorm:"-" json:"is_check" form:"is_check"`
|
|
325
|
+}
|
|
326
|
+
|
|
327
|
+func (DoctorAdvice) TableName() string {
|
|
328
|
+ return "xt_doctor_advice"
|
|
329
|
+}
|
|
330
|
+
|
|
331
|
+func GetDoctorAdviceByType(change_type int64, record_time int64, org_id int64, patient_id int64) (advice []*DoctorAdvice, sch models.Schedule, err error) {
|
279
|
332
|
if change_type == 1 { //根据日期取出上一方数据
|
280
|
|
-
|
281
|
333
|
var Id AdviceDate
|
282
|
|
- err = readDb.Model(&models.DoctorAdvice{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date < ?", patient_id, org_id, record_time).Select("record_date").Group("record_date").Order("record_date asc").Scan(&Id).Error
|
283
|
|
- err = readDb.Model(&models.DoctorAdvice{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date = ?", patient_id, org_id, Id.RecordDate).Find(&advice).Error
|
|
334
|
+ err = readDb.Model(&DoctorAdvice{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date < ?", patient_id, org_id, record_time).Select("record_date").Group("record_date").Order("record_date asc").Scan(&Id).Error
|
|
335
|
+ err = readDb.Model(&models.Schedule{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND schedule_date = ?", patient_id, org_id, Id.RecordDate).Find(&sch).Error
|
|
336
|
+ err = readDb.Model(&DoctorAdvice{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date = ? AND parent_id= 0", patient_id, org_id, Id.RecordDate).Preload("DoctorAdvice", "status = 1 AND user_org_id = ? AND patient_id = ?", org_id, patient_id).Find(&advice).Error
|
284
|
337
|
|
285
|
338
|
} else if change_type == 2 {
|
286
|
339
|
var Id AdviceDate
|
287
|
|
- err = readDb.Model(&models.DoctorAdvice{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date > ?", patient_id, org_id, record_time).Select("record_date").Group("record_date").Order("record_date desc").Scan(&Id).Error
|
288
|
|
- err = readDb.Model(&models.DoctorAdvice{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date = ?", patient_id, org_id, Id.RecordDate).Find(&advice).Error
|
|
340
|
+ err = readDb.Model(&DoctorAdvice{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date > ?", patient_id, org_id, record_time).Select("record_date").Group("record_date").Order("record_date desc").Scan(&Id).Error
|
|
341
|
+ err = readDb.Model(&models.Schedule{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND schedule_date = ?", patient_id, org_id, Id.RecordDate).Find(&sch).Error
|
|
342
|
+ err = readDb.Model(&DoctorAdvice{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date = ? AND parent_id= 0", patient_id, org_id, Id.RecordDate).Preload("DoctorAdvice", "status = 1 AND user_org_id = ? AND patient_id = ?", org_id, patient_id).Find(&advice).Error
|
289
|
343
|
}
|
290
|
344
|
return
|
291
|
345
|
}
|