|
@@ -1181,7 +1181,10 @@ func GetMobileHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay
|
1181
|
1181
|
Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
1182
|
1182
|
Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
1183
|
1183
|
Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
1184
|
|
- return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
|
|
1184
|
+ return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id = 0", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
|
|
1185
|
+ }).
|
|
1186
|
+ Preload("HisPrescriptionTeamProject", func(db *gorm.DB) *gorm.DB {
|
|
1187
|
+ return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id > 0", orgID, scheduleDate).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
|
1185
|
1188
|
}).
|
1186
|
1189
|
Where("status = 1 AND user_org_id = ?", orgID)
|
1187
|
1190
|
if scheduleDate != 0 {
|
|
@@ -1202,7 +1205,10 @@ func GetMobileHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay
|
1202
|
1205
|
Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
1203
|
1206
|
Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
|
1204
|
1207
|
Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
1205
|
|
- return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
|
|
1208
|
+ return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id = 0", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
|
|
1209
|
+ }).
|
|
1210
|
+ Preload("HisPrescriptionTeamProject", func(db *gorm.DB) *gorm.DB {
|
|
1211
|
+ return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id > 0", orgID, scheduleDate).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
|
1206
|
1212
|
}).
|
1207
|
1213
|
Where("status = 1 AND user_org_id = ?", orgID)
|
1208
|
1214
|
if scheduleDate != 0 {
|
|
@@ -2070,20 +2076,21 @@ func (HisMScheduleDoctorAdviceVMOne) TableName() string {
|
2070
|
2076
|
}
|
2071
|
2077
|
|
2072
|
2078
|
type HisMScheduleProjectVM struct {
|
2073
|
|
- ID int64 `gorm:"column:id" json:"id"`
|
2074
|
|
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id"`
|
2075
|
|
- PartitionId int64 `gorm:"column:partition_id" json:"partition_id"`
|
2076
|
|
- BedId int64 `gorm:"column:bed_id" json:"bed_id"`
|
2077
|
|
- PatientId int64 `gorm:"column:patient_id" json:"patient_id"`
|
2078
|
|
- ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date"`
|
2079
|
|
- ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type"`
|
2080
|
|
- ModeId int64 `gorm:"column:mode_id" json:"mode_id"`
|
2081
|
|
- Status int64 `gorm:"column:status" json:"status"`
|
2082
|
|
- DialysisOrder *MDialysisOrderVM `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"dialysis_order"`
|
2083
|
|
- SchedualPatient *MSchedualPatientVM `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
|
2084
|
|
- DeviceNumber *MDeviceNumberVM `gorm:"ForeignKey:BedId" json:"device_number"`
|
2085
|
|
- Prescription *models.DialysisPrescriptionList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
|
2086
|
|
- HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"project"`
|
|
2079
|
+ ID int64 `gorm:"column:id" json:"id"`
|
|
2080
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id"`
|
|
2081
|
+ PartitionId int64 `gorm:"column:partition_id" json:"partition_id"`
|
|
2082
|
+ BedId int64 `gorm:"column:bed_id" json:"bed_id"`
|
|
2083
|
+ PatientId int64 `gorm:"column:patient_id" json:"patient_id"`
|
|
2084
|
+ ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date"`
|
|
2085
|
+ ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type"`
|
|
2086
|
+ ModeId int64 `gorm:"column:mode_id" json:"mode_id"`
|
|
2087
|
+ Status int64 `gorm:"column:status" json:"status"`
|
|
2088
|
+ DialysisOrder *MDialysisOrderVM `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"dialysis_order"`
|
|
2089
|
+ SchedualPatient *MSchedualPatientVM `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
|
|
2090
|
+ DeviceNumber *MDeviceNumberVM `gorm:"ForeignKey:BedId" json:"device_number"`
|
|
2091
|
+ Prescription *models.DialysisPrescriptionList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
|
|
2092
|
+ HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"project"`
|
|
2093
|
+ HisPrescriptionTeamProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"team_project"`
|
2087
|
2094
|
}
|
2088
|
2095
|
|
2089
|
2096
|
func (HisMScheduleProjectVM) TableName() string {
|
|
@@ -2150,76 +2157,157 @@ func GetHisDoctorAdviceCount(startime int64, endtime int64, deliveway string, or
|
2150
|
2157
|
return advice, err
|
2151
|
2158
|
}
|
2152
|
2159
|
|
2153
|
|
-func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64) ([]*MScheduleDoctorAdviceVM, error) {
|
|
2160
|
+func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64, patient_id int64) ([]*MScheduleDoctorAdviceVM, error) {
|
2154
|
2161
|
var vms []*MScheduleDoctorAdviceVM
|
2155
|
2162
|
adviceWhere := ""
|
2156
|
2163
|
adviceCondition := []interface{}{}
|
2157
|
2164
|
if adviceType == 0 {
|
2158
|
2165
|
if patientType == 0 {
|
2159
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1)"
|
2160
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2166
|
+ if patient_id > 0 {
|
|
2167
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ?"
|
|
2168
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
2169
|
+ } else {
|
|
2170
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1)"
|
|
2171
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2172
|
+ }
|
2161
|
2173
|
|
2162
|
2174
|
} else if patientType == 1 {
|
2163
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1)"
|
2164
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
2175
|
+ if patient_id > 0 {
|
|
2176
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ?"
|
|
2177
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
|
|
2178
|
+ } else {
|
|
2179
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1)"
|
|
2180
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
2181
|
+ }
|
2165
|
2182
|
|
2166
|
2183
|
} else if patientType == 2 {
|
2167
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1)"
|
2168
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2184
|
+ if patient_id > 0 {
|
|
2185
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?)"
|
|
2186
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
2187
|
+ } else {
|
|
2188
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1)"
|
|
2189
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2190
|
+ }
|
|
2191
|
+
|
2169
|
2192
|
}
|
2170
|
2193
|
|
2171
|
2194
|
} else if adviceType == 1 {
|
2172
|
2195
|
if patientType == 0 {
|
2173
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? "
|
2174
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2196
|
+ if patient_id > 0 {
|
|
2197
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? "
|
|
2198
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
2199
|
+ } else {
|
|
2200
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? "
|
|
2201
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2202
|
+ }
|
2175
|
2203
|
|
2176
|
2204
|
} else if patientType == 1 {
|
2177
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? "
|
2178
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
2205
|
+ if patient_id > 0 {
|
|
2206
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? and patient_id = ?"
|
|
2207
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
|
|
2208
|
+ } else {
|
|
2209
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? "
|
|
2210
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
2211
|
+ }
|
2179
|
2212
|
|
2180
|
2213
|
} else if patientType == 2 {
|
2181
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0"
|
2182
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2214
|
+ if patient_id > 0 {
|
|
2215
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0 and patient_id = ?"
|
|
2216
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
2217
|
+ } else {
|
|
2218
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0"
|
|
2219
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2220
|
+ }
|
2183
|
2221
|
|
2184
|
2222
|
}
|
2185
|
2223
|
|
2186
|
2224
|
} else if adviceType == 3 {
|
2187
|
2225
|
if patientType == 0 {
|
2188
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ? "
|
2189
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2226
|
+ if patient_id > 0 {
|
|
2227
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ? and patient_id = ? "
|
|
2228
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
2229
|
+ } else {
|
|
2230
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ? "
|
|
2231
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2232
|
+ }
|
2190
|
2233
|
|
2191
|
2234
|
} else if patientType == 1 {
|
2192
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? "
|
2193
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
2235
|
+ if patient_id > 0 {
|
|
2236
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? and patient_id = ?"
|
|
2237
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
|
|
2238
|
+ } else {
|
|
2239
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? "
|
|
2240
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
2241
|
+ }
|
|
2242
|
+
|
2194
|
2243
|
} else if patientType == 2 {
|
2195
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND execution_staff = 0"
|
2196
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2244
|
+ if patient_id > 0 {
|
|
2245
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND execution_staff = 0 and patient_id = ?"
|
|
2246
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
2247
|
+ } else {
|
|
2248
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND execution_staff = 0"
|
|
2249
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2250
|
+ }
|
|
2251
|
+
|
2197
|
2252
|
}
|
2198
|
2253
|
|
2199
|
2254
|
} else if adviceType == 2 && len(deliverWay) > 0 {
|
2200
|
2255
|
if patientType == 0 {
|
2201
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ?"
|
2202
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
|
|
2256
|
+ if patient_id > 0 {
|
|
2257
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ? and patient_id = ?"
|
|
2258
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay, patient_id)
|
|
2259
|
+ } else {
|
|
2260
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ?"
|
|
2261
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
|
|
2262
|
+ }
|
2203
|
2263
|
|
2204
|
2264
|
} else if patientType == 1 {
|
2205
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and delivery_way = ? "
|
2206
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay)
|
|
2265
|
+ if patient_id > 0 {
|
|
2266
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and delivery_way = ? and patient_id = ?"
|
|
2267
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay, patient_id)
|
|
2268
|
+ } else {
|
|
2269
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and delivery_way = ? "
|
|
2270
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay)
|
|
2271
|
+ }
|
|
2272
|
+
|
2207
|
2273
|
} else if patientType == 2 {
|
2208
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND execution_staff = 0 and delivery_way = ?"
|
2209
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
|
|
2274
|
+ if patient_id > 0 {
|
|
2275
|
+
|
|
2276
|
+ } else {
|
|
2277
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND execution_staff = 0 and delivery_way = ?"
|
|
2278
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
|
|
2279
|
+ }
|
|
2280
|
+
|
2210
|
2281
|
}
|
2211
|
2282
|
|
2212
|
2283
|
} else if adviceType == 2 && len(deliverWay) <= 0 {
|
2213
|
2284
|
if patientType == 0 {
|
2214
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ?"
|
2215
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2285
|
+ if patient_id > 0 {
|
|
2286
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and patient_id = ?"
|
|
2287
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
2288
|
+ } else {
|
|
2289
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ?"
|
|
2290
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2291
|
+ }
|
2216
|
2292
|
|
2217
|
2293
|
} else if patientType == 1 {
|
2218
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?"
|
2219
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
2294
|
+ if patient_id > 0 {
|
|
2295
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and patient_id = ?"
|
|
2296
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
|
|
2297
|
+ } else {
|
|
2298
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?"
|
|
2299
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
2300
|
+ }
|
|
2301
|
+
|
2220
|
2302
|
} else if patientType == 2 {
|
2221
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND execution_staff = 0"
|
2222
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2303
|
+ if patient_id > 0 {
|
|
2304
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND execution_staff = 0 and patient_id = ?"
|
|
2305
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
2306
|
+ } else {
|
|
2307
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND execution_staff = 0"
|
|
2308
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2309
|
+ }
|
|
2310
|
+
|
2223
|
2311
|
}
|
2224
|
2312
|
|
2225
|
2313
|
}
|
|
@@ -2249,7 +2337,7 @@ func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceTy
|
2249
|
2337
|
return vms, err
|
2250
|
2338
|
}
|
2251
|
2339
|
|
2252
|
|
-func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string, scheduleType int64, partitionType int64) ([]*HisMScheduleDoctorAdviceVM, error) {
|
|
2340
|
+func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string, scheduleType int64, partitionType int64, patient_id int64) ([]*HisMScheduleDoctorAdviceVM, error) {
|
2253
|
2341
|
|
2254
|
2342
|
var vms []*HisMScheduleDoctorAdviceVM
|
2255
|
2343
|
if len(deliverWay) > 0 {
|
|
@@ -2260,19 +2348,36 @@ func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string,
|
2260
|
2348
|
if partitionType > 0 {
|
2261
|
2349
|
db = db.Where("partition_id = ?", partitionType)
|
2262
|
2350
|
}
|
2263
|
|
- db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
2264
|
|
- Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
2265
|
|
- Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
2266
|
|
- Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
2267
|
|
- Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ?", orgID, scheduleDate, deliverWay).
|
2268
|
|
- Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
2269
|
|
- return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
2270
|
|
- }).
|
2271
|
|
- Where("status = 1 AND user_org_id = ?", orgID)
|
2272
|
|
- if scheduleDate != 0 {
|
2273
|
|
- db = db.Where("schedule_date = ?", scheduleDate)
|
|
2351
|
+ if patient_id > 0 {
|
|
2352
|
+ db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ? and id =?", orgID, patient_id).
|
|
2353
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
2354
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
2355
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
|
|
2356
|
+ Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and patient_id = ?", orgID, scheduleDate, deliverWay, patient_id).
|
|
2357
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
2358
|
+ return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
2359
|
+ }).
|
|
2360
|
+ Where("status = 1 AND user_org_id = ?", orgID)
|
|
2361
|
+ if scheduleDate != 0 {
|
|
2362
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
2363
|
+ }
|
|
2364
|
+ err = db.Find(&vms).Error
|
|
2365
|
+ } else {
|
|
2366
|
+ db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
2367
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
2368
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
2369
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
2370
|
+ Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ?", orgID, scheduleDate, deliverWay).
|
|
2371
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
2372
|
+ return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
2373
|
+ }).
|
|
2374
|
+ Where("status = 1 AND user_org_id = ?", orgID)
|
|
2375
|
+ if scheduleDate != 0 {
|
|
2376
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
2377
|
+ }
|
|
2378
|
+ err = db.Find(&vms).Error
|
2274
|
2379
|
}
|
2275
|
|
- err = db.Find(&vms).Error
|
|
2380
|
+
|
2276
|
2381
|
} else {
|
2277
|
2382
|
db := readDb.Table("xt_schedule")
|
2278
|
2383
|
if scheduleType > 0 {
|
|
@@ -2281,19 +2386,36 @@ func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string,
|
2281
|
2386
|
if partitionType > 0 {
|
2282
|
2387
|
db = db.Where("partition_id = ?", partitionType)
|
2283
|
2388
|
}
|
2284
|
|
- db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
2285
|
|
- Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
2286
|
|
- Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
2287
|
|
- Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
2288
|
|
- Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ?", orgID, scheduleDate).
|
2289
|
|
- Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
2290
|
|
- return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
2291
|
|
- }).
|
2292
|
|
- Where("status = 1 AND user_org_id = ?", orgID)
|
2293
|
|
- if scheduleDate != 0 {
|
2294
|
|
- db = db.Where("schedule_date = ?", scheduleDate)
|
|
2389
|
+ if patient_id > 0 {
|
|
2390
|
+ db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ? and id = ?", orgID, patient_id).
|
|
2391
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
2392
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
2393
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
|
|
2394
|
+ Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
|
|
2395
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
2396
|
+ return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
2397
|
+ }).
|
|
2398
|
+ Where("status = 1 AND user_org_id = ?", orgID)
|
|
2399
|
+ if scheduleDate != 0 {
|
|
2400
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
2401
|
+ }
|
|
2402
|
+ err = db.Find(&vms).Error
|
|
2403
|
+ } else {
|
|
2404
|
+ db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
2405
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
2406
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
2407
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
2408
|
+ Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ?", orgID, scheduleDate).
|
|
2409
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
2410
|
+ return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
2411
|
+ }).
|
|
2412
|
+ Where("status = 1 AND user_org_id = ?", orgID)
|
|
2413
|
+ if scheduleDate != 0 {
|
|
2414
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
2415
|
+ }
|
|
2416
|
+ err = db.Find(&vms).Error
|
2295
|
2417
|
}
|
2296
|
|
- err = db.Find(&vms).Error
|
|
2418
|
+
|
2297
|
2419
|
}
|
2298
|
2420
|
|
2299
|
2421
|
return vms, err
|
|
@@ -2423,25 +2545,74 @@ func GetHisPrescriptionProject(org_id int64, patient_id int64, record_date int64
|
2423
|
2545
|
return
|
2424
|
2546
|
}
|
2425
|
2547
|
|
2426
|
|
-func GetPCHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay string, patientType int, adminUserId int64) ([]*HisMScheduleProjectVM, error) {
|
|
2548
|
+func GetPCHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay string, patientType int, adminUserId int64, patient_id int64) ([]*HisMScheduleProjectVM, error) {
|
2427
|
2549
|
var vms []*HisMScheduleProjectVM
|
2428
|
2550
|
if patientType == 0 {
|
2429
|
|
- db := readDb.
|
2430
|
|
- Table("xt_schedule").
|
2431
|
|
- Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
2432
|
|
- Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
2433
|
|
- return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
2434
|
|
- }).
|
2435
|
|
- Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
2436
|
|
- Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
2437
|
|
- Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
2438
|
|
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
2439
|
|
- return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
|
2440
|
|
- }).Where("status = 1 AND user_org_id = ?", orgID)
|
2441
|
|
- if scheduleDate != 0 {
|
2442
|
|
- db = db.Where("schedule_date = ?", scheduleDate)
|
|
2551
|
+
|
|
2552
|
+ if patient_id > 0 {
|
|
2553
|
+ db := readDb.
|
|
2554
|
+ Table("xt_schedule").
|
|
2555
|
+ Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
2556
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
2557
|
+ return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
2558
|
+ }).
|
|
2559
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
2560
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
2561
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
|
|
2562
|
+ Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
|
2563
|
+ return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id = 0", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
|
|
2564
|
+ }).
|
|
2565
|
+ Preload("HisPrescriptionTeamProject", func(db *gorm.DB) *gorm.DB {
|
|
2566
|
+ return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id > 0", orgID, scheduleDate).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
|
|
2567
|
+ }).Where("status = 1 AND user_org_id = ?", orgID)
|
|
2568
|
+ if scheduleDate != 0 {
|
|
2569
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
2570
|
+ }
|
|
2571
|
+ err = db.Find(&vms).Error
|
|
2572
|
+ } else {
|
|
2573
|
+ if patient_id > 0 {
|
|
2574
|
+ db := readDb.
|
|
2575
|
+ Table("xt_schedule").
|
|
2576
|
+ Preload("SchedualPatient", "status = 1 AND user_org_id = ? and id= ?", orgID, patient_id).
|
|
2577
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
2578
|
+ return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
2579
|
+ }).
|
|
2580
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
2581
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
2582
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
|
|
2583
|
+ Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
|
2584
|
+ return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id = 0", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
|
|
2585
|
+ }).
|
|
2586
|
+ Preload("HisPrescriptionTeamProject", func(db *gorm.DB) *gorm.DB {
|
|
2587
|
+ return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id > 0", orgID, scheduleDate).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
|
|
2588
|
+ }).Where("status = 1 AND user_org_id = ?", orgID)
|
|
2589
|
+ if scheduleDate != 0 {
|
|
2590
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
2591
|
+ }
|
|
2592
|
+ err = db.Find(&vms).Error
|
|
2593
|
+ } else {
|
|
2594
|
+ db := readDb.
|
|
2595
|
+ Table("xt_schedule").
|
|
2596
|
+ Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
2597
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
2598
|
+ return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
2599
|
+ }).
|
|
2600
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
2601
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
2602
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
2603
|
+ Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
|
2604
|
+ return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id = 0", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
|
|
2605
|
+ }).
|
|
2606
|
+ Preload("HisPrescriptionTeamProject", func(db *gorm.DB) *gorm.DB {
|
|
2607
|
+ return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id > 0", orgID, scheduleDate).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
|
|
2608
|
+ }).Where("status = 1 AND user_org_id = ?", orgID)
|
|
2609
|
+ if scheduleDate != 0 {
|
|
2610
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
2611
|
+ }
|
|
2612
|
+ err = db.Find(&vms).Error
|
|
2613
|
+ }
|
2443
|
2614
|
}
|
2444
|
|
- err = db.Find(&vms).Error
|
|
2615
|
+
|
2445
|
2616
|
}
|
2446
|
2617
|
|
2447
|
2618
|
if patientType > 0 {
|
|
@@ -2456,9 +2627,11 @@ func GetPCHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay str
|
2456
|
2627
|
Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
2457
|
2628
|
Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
|
2458
|
2629
|
Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
2459
|
|
- return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
|
|
2630
|
+ return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id = 0", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
|
2460
|
2631
|
}).
|
2461
|
|
- Where("status = 1 AND user_org_id = ?", orgID)
|
|
2632
|
+ Preload("HisPrescriptionTeamProject", func(db *gorm.DB) *gorm.DB {
|
|
2633
|
+ return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id > 0", orgID, scheduleDate).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
|
|
2634
|
+ }).Where("status = 1 AND user_org_id = ?", orgID)
|
2462
|
2635
|
if scheduleDate != 0 {
|
2463
|
2636
|
db = db.Where("schedule_date = ?", scheduleDate)
|
2464
|
2637
|
}
|