|
@@ -109,11 +109,13 @@ func (VMHisOrder) TableName() string {
|
109
|
109
|
}
|
110
|
110
|
|
111
|
111
|
type Patients struct {
|
112
|
|
- ID int64 `gorm:"column:id" json:"id" form:"id"`
|
113
|
|
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
114
|
|
- Name string `gorm:"column:name" json:"name" form:"name"`
|
115
|
|
- Status int64 `gorm:"column:status" json:"status" form:"status"`
|
116
|
|
- IdCardNo string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
|
|
112
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
113
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
|
114
|
+ Name string `gorm:"column:name" json:"name" form:"name"`
|
|
115
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
116
|
+ IdCardNo string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
|
|
117
|
+ ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
|
|
118
|
+
|
117
|
119
|
Schedule Schedule `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"schedule"`
|
118
|
120
|
HisPatient HisPatient `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"his_patient"`
|
119
|
121
|
HisPrescription []*HisPrescription `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"prescription"`
|
|
@@ -139,11 +141,11 @@ func (HisPrescription) TableName() string {
|
139
|
141
|
}
|
140
|
142
|
|
141
|
143
|
func GetScheduleHisPatientList(org_id int64, keywords string, record_date int64) (patients []*Patients, err error) {
|
142
|
|
- db := readDb.Model(&Patients{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id).
|
|
144
|
+ db := readDb.Model(&Patients{}).Select("xt_patients.id,xt_patients.user_org_id,xt_patients.name,xt_patients.status,xt_patients.id_card_no,sch.schedule_type as sch_type").Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id).
|
143
|
145
|
Joins("join xt_schedule as sch ON sch.patient_id = xt_patients.id AND sch.schedule_date = ? AND sch.status = 1 AND sch.user_org_id = ?", record_date, org_id)
|
144
|
146
|
db = db.Preload("HisPatient", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
|
145
|
147
|
db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
|
146
|
|
- err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date).Group("xt_patients.id").Find(&patients).Error
|
|
148
|
+ err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date).Group("xt_patients.id").Order("sch_type").Find(&patients).Error
|
147
|
149
|
return
|
148
|
150
|
}
|
149
|
151
|
|