Browse Source

11月8日库存管理

XMLWAN 2 years ago
parent
commit
935b1eea7b
1 changed files with 25 additions and 2 deletions
  1. 25 2
      service/schedule_service.go

+ 25 - 2
service/schedule_service.go View File

@@ -674,7 +674,7 @@ func GetWeekDayScheduleById(orgid int64, scheduleDate int64, scheduleType int64,
674 674
 
675 675
 func GetWeekDayScheduleByIdThee(orgid int64, scheduleDate int64, scheduleType int64, zone []string) (list []*models.VmSchedulesRemind, err error) {
676 676
 
677
-	db := readDb2.Table("xt_schedule as x").Where("x.status = 1")
677
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
678 678
 	if orgid > 0 {
679 679
 		db = db.Where("x.user_org_id = ?", orgid)
680 680
 	}
@@ -701,7 +701,7 @@ func GetWeekDayScheduleByIdThee(orgid int64, scheduleDate int64, scheduleType in
701 701
 
702 702
 func GetWeekDayScheduleByIdTwo(orgid int64, scheduleDate int64, scheduleType int64, startDate int64, zone []string) (list []*models.VmSchedulesRemind, err error) {
703 703
 
704
-	db := readDb2.Table("xt_schedule as x").Where("x.status = 1")
704
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
705 705
 	if orgid > 0 {
706 706
 		db = db.Where("x.user_org_id = ?", orgid)
707 707
 	}
@@ -1160,3 +1160,26 @@ func GetDeathPatient(orgid int64) (patient []*models.XtPatients, err error) {
1160 1160
 	err = XTReadDB().Where("user_org_id = ? and (lapseto = 2 || lapseto = 3) and status = 1", orgid).Find(&patient).Error
1161 1161
 	return patient, err
1162 1162
 }
1163
+
1164
+func GetInitPrintData(patient_id int64, scheduleDate int64, orgid int64) (list []*models.VmSchedulesRemind, err error) {
1165
+
1166
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
1167
+	if orgid > 0 {
1168
+		db = db.Where("x.user_org_id = ?", orgid)
1169
+	}
1170
+	if patient_id > 0 {
1171
+		db = db.Where("patient_id = ?", patient_id)
1172
+	}
1173
+	if scheduleDate > 0 {
1174
+		db = db.Where("x.schedule_date >=? and x.schedule_date<=?", scheduleDate, scheduleDate)
1175
+	}
1176
+	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1 and dialysis_date =?", scheduleDate).Preload("XtAssessmentBeforeDislysis", "status = 1 and assessment_date =?", scheduleDate).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
1177
+		return db.Where("status =1 and parent_id = 0 and advice_date = ?", scheduleDate).Preload("ChildDoctorAdvice", "status = 1")
1178
+	}).Preload("HisDoctorAdviceInfo", "status = 1 and advice_date = ?", scheduleDate).Preload("DialysisPrescription", "status = 1 and record_date = ?", scheduleDate).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
1179
+		return db.Where("status =1").Order("id asc")
1180
+	}).Preload("LastAfterWeight", func(db *gorm.DB) *gorm.DB {
1181
+		return db.Where("user_org_id = ? and status = 1 and assessment_date < ?", orgid, scheduleDate)
1182
+	}).Find(&list).Error
1183
+
1184
+	return list, err
1185
+}