Browse Source

Merge branch '20201014_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20201014_xt_api_new_branch

XMLWAN 3 years ago
parent
commit
6f1134bf9e
1 changed files with 23 additions and 3 deletions
  1. 23 3
      service/his_project_service.go

+ 23 - 3
service/his_project_service.go View File

@@ -596,11 +596,31 @@ func GetPrscriptionInfo(patientid int64, recorddata int64) (info []*models.HisPr
596 596
 
597 597
 }
598 598
 
599
-func GetPrescriptionByPatientId(patient_id int64, startime int64, p_type int64) (prescritpion []*models.HisPrescription, err error) {
600
-	err = XTReadDB().Model(&prescritpion).Where("patient_id = ? AND record_date =? AND p_type = ? AND status = 1", patient_id, startime, p_type).Find(&prescritpion).Error
601
-	return prescritpion, err
599
+func GetPrescriptionByPatientId(patient_id int64, startime int64, p_type int64) (prescription []*models.HisPrescription, err error) {
600
+	err = readDb.Model(&models.HisPrescription{}).
601
+		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
602
+			return db.Where("status = 1").Preload("XtHisAddtionConfig", "status=1")
603
+		}).
604
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
605
+			return db.Where("status = 1 ").Preload("Drug", "status=1")
606
+		}).
607
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
608
+			return db.Where("status = 1 ").Preload("HisProject").Preload("GoodInfo", "status=1")
609
+		}).
610
+		Where("patient_id = ? AND record_date =? AND p_type = ? AND status = 1", patient_id, startime, p_type).
611
+		Find(&prescription).Error
612
+	return
602 613
 }
603 614
 
615
+
616
+
617
+// func GetPrescriptionByPatientId(patient_id int64, startime int64, p_type int64) (prescritpion []*models.HisPrescription, err error) {
618
+// // 	err = XTReadDB().Model(&prescritpion).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
619
+// // 		return db.Where("status = 1 and user_org_id = ?", orgid).Preload("Drug", "status = 1")
620
+// // }).Where("patient_id = ? AND record_date =? AND p_type = ? AND status = 1", patient_id, startime, p_type).Find(&prescritpion).Error
621
+// // 	return prescritpion, err
622
+// }
623
+
604 624
 func GetTodayHisPatient(recod_date int64, patientid int64, user_org_id int64) (*models.XtHisPatient, error) {
605 625
 
606 626
 	patient := models.XtHisPatient{}