|
@@ -177,7 +177,7 @@ func GetHisPrescription(org_id int64, patient_id int64, record_date int64) (pres
|
177
|
177
|
}
|
178
|
178
|
|
179
|
179
|
func GetAllDrugLibList(org_id int64) (list []*models.BaseDrugLib, err error) {
|
180
|
|
- err = readDb.Model(&models.BaseDrugLib{}).Where("org_id = ? AND status = 1", org_id).Find(&list).Error
|
|
180
|
+ err = readDb.Model(&models.BaseDrugLib{}).Preload("DrugWarehouseInfo", "status = 1 AND user_org_id = ?", org_id).Where("org_id = ? AND status = 1", org_id).Find(&list).Error
|
181
|
181
|
return
|
182
|
182
|
}
|
183
|
183
|
|
|
@@ -199,7 +199,9 @@ func FindAllHisAdviceTemplate(org_id int64) (temps []*models.HisDoctorAdvicePare
|
199
|
199
|
}
|
200
|
200
|
|
201
|
201
|
func GetHisAdminUserDoctors(org_id int64) (doctors []*models.UserAdminRole, err error) {
|
202
|
|
- err = readUserDb.Model(&models.UserAdminRole{}).Where("org_id = ? AND status = 1 AND (user_type = 1 OR user_type = 2)", org_id).Find(&doctors).Error
|
|
202
|
+ err = readUserDb.Model(&models.UserAdminRole{}).Preload("XtHisDepartment", func(db *gorm.DB) *gorm.DB {
|
|
203
|
+ return readDb.Model(&models.XtHisDepartment{}).Where("status = 1 AND user_org_id = ?", org_id)
|
|
204
|
+ }).Where("org_id = ? AND status = 1 AND (user_type = 1 OR user_type = 2)", org_id).Find(&doctors).Error
|
203
|
205
|
return
|
204
|
206
|
}
|
205
|
207
|
|
|
@@ -243,6 +245,12 @@ func FindPatientPrescriptionInfo(org_id int64, patient_id int64, record_date int
|
243
|
245
|
return
|
244
|
246
|
|
245
|
247
|
}
|
|
248
|
+
|
|
249
|
+func FindLastPatientPrescriptionInfo(org_id int64, patient_id int64, record_date int64) (info models.HisPrescriptionInfo, err error) {
|
|
250
|
+ err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date < ? AND patient_id = ?", org_id, record_date, patient_id).Order("record_date desc").First(&info).Error
|
|
251
|
+ return
|
|
252
|
+}
|
|
253
|
+
|
246
|
254
|
func SavePatientPrescriptionInfo(info models.HisPrescriptionInfo) (err error) {
|
247
|
255
|
err = writeDb.Save(&info).Error
|
248
|
256
|
return
|
|
@@ -315,27 +323,28 @@ func GetHisPrescriptionThree(org_id int64, patient_id int64, record_date int64,
|
315
|
323
|
}
|
316
|
324
|
|
317
|
325
|
type HisPrescriptionInfo struct {
|
318
|
|
- ID int64 `gorm:"column:id" json:"id" form:"id"`
|
319
|
|
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
320
|
|
- RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
|
321
|
|
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
|
322
|
|
- HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
|
323
|
|
- Status int64 `gorm:"column:status" json:"status" form:"status"`
|
324
|
|
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
325
|
|
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
326
|
|
- Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
|
327
|
|
- Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
|
328
|
|
- Diagnosis string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
|
329
|
|
- RegisterType string `gorm:"column:register_type" json:"register_type" form:"register_type"`
|
330
|
|
- Doctor string `gorm:"column:doctor" json:"doctor" form:"doctor"`
|
331
|
|
- Departments string `gorm:"column:departments" json:"departments" form:"departments"`
|
332
|
|
- SickHistory string `gorm:"column:sick_history" json:"sick_history" form:"sick_history"`
|
333
|
|
- Patients models.Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
|
334
|
|
- HisPatient models.HisPatient `gorm:"ForeignKey:HisPatientId,RecordDate;AssociationForeignKey:ID,RecordDate" json:"his_patient"`
|
335
|
|
- PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
|
336
|
|
- BatchNumber string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
|
337
|
|
- PrescriptionStatus int64 `gorm:"column:prescription_status" json:"prescription_status" form:"prescription_status"`
|
338
|
|
- DoctorId int64 `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
|
|
326
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
327
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
|
328
|
+ RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
|
|
329
|
+ PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
|
|
330
|
+ HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
|
|
331
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
332
|
+ Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
|
333
|
+ Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
|
334
|
+ Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
|
|
335
|
+ Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
|
|
336
|
+ Diagnosis string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
|
|
337
|
+ RegisterType string `gorm:"column:register_type" json:"register_type" form:"register_type"`
|
|
338
|
+ Doctor string `gorm:"column:doctor" json:"doctor" form:"doctor"`
|
|
339
|
+ Departments string `gorm:"column:departments" json:"departments" form:"departments"`
|
|
340
|
+ SickHistory string `gorm:"column:sick_history" json:"sick_history" form:"sick_history"`
|
|
341
|
+ Patients models.Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
|
|
342
|
+ HisPatient models.HisPatient `gorm:"ForeignKey:HisPatientId,RecordDate;AssociationForeignKey:ID,RecordDate" json:"his_patient"`
|
|
343
|
+ HisPatientCaseHistory models.HisPatientCaseHistory `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,RecordDate" json:"case_history"`
|
|
344
|
+ PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
|
|
345
|
+ BatchNumber string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
|
|
346
|
+ PrescriptionStatus int64 `gorm:"column:prescription_status" json:"prescription_status" form:"prescription_status"`
|
|
347
|
+ DoctorId int64 `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
|
339
|
348
|
}
|
340
|
349
|
|
341
|
350
|
func (HisPrescriptionInfo) TableName() string {
|
|
@@ -345,7 +354,9 @@ func (HisPrescriptionInfo) TableName() string {
|
345
|
354
|
func GetHisPrescriptionOrderList(org_id int64) (prescriptionOrder []*HisPrescriptionInfo, err error) {
|
346
|
355
|
err = readDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND user_org_id = ?", org_id).
|
347
|
356
|
Preload("Patients", "status = 1 AND user_org_id = ?", org_id).
|
348
|
|
- Preload("HisPatient", "status = 1 AND user_org_id = ?", org_id).Order("ctime desc").Find(&prescriptionOrder).Error
|
|
357
|
+ Preload("HisPatient", "status = 1 AND user_org_id = ?", org_id).
|
|
358
|
+ Preload("HisPatientCaseHistory", "status = 1 AND user_org_id = ?", org_id).
|
|
359
|
+ Order("ctime desc").Find(&prescriptionOrder).Error
|
349
|
360
|
return
|
350
|
361
|
|
351
|
362
|
}
|
|
@@ -353,7 +364,8 @@ func GetHisPrescriptionOrderList(org_id int64) (prescriptionOrder []*HisPrescrip
|
353
|
364
|
func GetHisPrescriptionOrderInfo(id int64, org_id int64) (prescriptionOrder HisPrescriptionInfo, err error) {
|
354
|
365
|
err = readDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND id = ? AND user_org_id = ? ", id, org_id).
|
355
|
366
|
Preload("Patients", "status = 1 AND user_org_id = ?", org_id).
|
356
|
|
- Preload("HisPatient", "status = 1 AND user_org_id = ?", org_id).First(&prescriptionOrder).Error
|
|
367
|
+ Preload("HisPatient", "status = 1 AND user_org_id = ?", org_id).
|
|
368
|
+ Preload("HisPatientCaseHistory", "status = 1 AND user_org_id = ?", org_id).First(&prescriptionOrder).Error
|
357
|
369
|
return
|
358
|
370
|
|
359
|
371
|
}
|
|
@@ -401,7 +413,7 @@ func UpDateOrder(order models.HisOrder) (err error) {
|
401
|
413
|
}
|
402
|
414
|
|
403
|
415
|
func UpdataOrderStatusTwo(number string, user_org_id int64) (err error) {
|
404
|
|
- err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 3, "mtime": time.Now().Unix()}).Error
|
|
416
|
+ err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 2, "mtime": time.Now().Unix()}).Error
|
405
|
417
|
err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 3, "mtime": time.Now().Unix()}).Error
|
406
|
418
|
return
|
407
|
419
|
}
|
|
@@ -422,3 +434,10 @@ func FindMedicalInsuranceInfo(org_id int64) (config models.MedicalInsuranceOrgCo
|
422
|
434
|
err = readDb.Model(&models.MedicalInsuranceOrgConfig{}).Where("status = 1 AND user_org_id = ?", org_id).First(&config).Error
|
423
|
435
|
return
|
424
|
436
|
}
|
|
437
|
+
|
|
438
|
+func FindAllSick(orgId int64) (list []*models.OutpatientServiceSick, err error) {
|
|
439
|
+ db := readDb.Model(&models.OutpatientServiceSick{})
|
|
440
|
+ db = db.Where("user_org_id = ? AND status = 1", orgId)
|
|
441
|
+ err = db.Order("ctime desc").Find(&list).Error
|
|
442
|
+ return
|
|
443
|
+}
|