test_user 2 年前
父节点
当前提交
1ea52923cc

+ 28 - 0
controllers/his_hospital_api_controller.go 查看文件

@@ -38,6 +38,8 @@ func HisHospitalManagerApiRegistRouters() {
38 38
 
39 39
 	beego.Router("/api/monthhospitaldetail/get", &HisHospitalApiController{}, "get:GetHisHospitalMonthDetailInfo")
40 40
 
41
+	beego.Router("/api/exportuncharge/get", &HisHospitalApiController{}, "get:GetExportHisHospitalUnChargeData")
42
+
41 43
 }
42 44
 func (c *HisHospitalApiController) RefundDetail() {
43 45
 	patient_id, _ := c.GetInt64("patient_id")
@@ -1056,3 +1058,29 @@ func (c *HisHospitalApiController) GetHisHospitalMonthDetailInfo() {
1056 1058
 		"his_info":            record,
1057 1059
 	})
1058 1060
 }
1061
+
1062
+func (c *HisHospitalApiController) GetExportHisHospitalUnChargeData() {
1063
+	start_time_str := c.GetString("start_time")
1064
+	end_time_str := c.GetString("end_time")
1065
+	timeLayout := "2006-01-02"
1066
+	loc, _ := time.LoadLocation("Local")
1067
+	adminInfo := c.GetAdminUserInfo()
1068
+	theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
1069
+	if err != nil {
1070
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1071
+		return
1072
+	}
1073
+	recordStartTime := theStartTime.Unix()
1074
+	theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
1075
+	if err != nil {
1076
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1077
+		return
1078
+	}
1079
+	recordEndTime := theEndTime.Unix()
1080
+	//var prescriptions []*models.HisPrescription
1081
+	var prescriptions []*models.ExportHisPrescription
1082
+	prescriptions, _ = service.GetUnChargeHisHospitalPrescription(adminInfo.CurrentOrgId, recordStartTime, recordEndTime)
1083
+	c.ServeSuccessJSON(map[string]interface{}{
1084
+		"month_prescriptions": prescriptions,
1085
+	})
1086
+}

+ 12 - 3
controllers/schedule_api_controller.go 查看文件

@@ -1260,6 +1260,10 @@ func (c *ScheduleApiController) GetSchedules() {
1260 1260
 	partition_id, _ := c.GetInt64("partition_id")
1261 1261
 	schedule_type, _ := c.GetInt64("schedule_type")
1262 1262
 
1263
+	is_before, _ := c.GetInt64("is_before")
1264
+	start_time := c.GetString("start_time")
1265
+	end_time := c.GetString("end_time")
1266
+
1263 1267
 	adminInfo := c.GetAdminUserInfo()
1264 1268
 
1265 1269
 	thisTime := time.Now()
@@ -1303,6 +1307,14 @@ func (c *ScheduleApiController) GetSchedules() {
1303 1307
 	theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
1304 1308
 	weekStartPoint := theStarTime.Unix()
1305 1309
 	weekEndPoint := theEndTime.Unix()
1310
+	if is_before > 0 {
1311
+		timeLayout := "2006-01-02 15:04:05"
1312
+		loc, _ := time.LoadLocation("Local")
1313
+		theStarTime, _ := time.ParseInLocation(timeLayout, start_time, loc)
1314
+		theEndTime, _ := time.ParseInLocation(timeLayout, end_time, loc)
1315
+		weekStartPoint = theStarTime.Unix()
1316
+		weekEndPoint = theEndTime.Unix()
1317
+	}
1306 1318
 
1307 1319
 	schdules, _ := service.GetWeekScheduleOne(adminInfo.CurrentOrgId, weekStartPoint, weekEndPoint, partition_id, schedule_type)
1308 1320
 	c.ServeSuccessJSON(map[string]interface{}{
@@ -4322,11 +4334,9 @@ func (c *ScheduleApiController) GetScheduleOne() {
4322 4334
 
4323 4335
 	week, _ := c.GetInt64("weekTime", 0) //1:last, 2:this 3:next 4 nextTwo
4324 4336
 	patitionIdStr := c.GetString("patitionid")
4325
-
4326 4337
 	ids := strings.Split(patitionIdStr, ",")
4327 4338
 	fmt.Println("patitonStr", ids)
4328 4339
 	schedule_type, _ := c.GetInt64("schedule_type")
4329
-
4330 4340
 	adminInfo := c.GetAdminUserInfo()
4331 4341
 
4332 4342
 	thisTime := time.Now()
@@ -4372,7 +4382,6 @@ func (c *ScheduleApiController) GetScheduleOne() {
4372 4382
 	weekEndPoint := theEndTime.Unix()
4373 4383
 
4374 4384
 	schdules, _ := service.GetWeekScheduleTwo(adminInfo.CurrentOrgId, weekStartPoint, weekEndPoint, ids, schedule_type)
4375
-
4376 4385
 	schedulesGroup, _ := service.GetScheduleTotalCount(adminInfo.CurrentOrgId, weekStartPoint, weekEndPoint, ids, schedule_type)
4377 4386
 	c.ServeSuccessJSON(map[string]interface{}{
4378 4387
 		"days":           days,

+ 32 - 0
models/his_models.go 查看文件

@@ -132,6 +132,7 @@ type HisPatient struct {
132 132
 	SickType               int64   `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
133 133
 	PatientInfo            string  `gorm:"column:patient_info" json:"patient_info" form:"patient_info"`
134 134
 	InsuplcAdmdvs          string  `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
135
+	Insutype               string  `gorm:"column:insutype" json:"insutype" form:"insutype"`
135 136
 }
136 137
 
137 138
 func (HisPatient) TableName() string {
@@ -2522,3 +2523,34 @@ type GoodHisPrescriptionProject struct {
2522 2523
 func (GoodHisPrescriptionProject) TableName() string {
2523 2524
 	return "his_prescription_project"
2524 2525
 }
2526
+
2527
+type ExportHisPrescription struct {
2528
+	ID                     int64                     `gorm:"column:id" json:"id" form:"id"`
2529
+	UserOrgId              int64                     `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2530
+	RecordDate             int64                     `gorm:"column:record_date" json:"record_date" form:"record_date"`
2531
+	PatientId              int64                     `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2532
+	HisPatientId           int64                     `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
2533
+	Status                 int64                     `gorm:"column:status" json:"status" form:"status"`
2534
+	Ctime                  int64                     `gorm:"column:ctime" json:"ctime" form:"ctime"`
2535
+	Mtime                  int64                     `gorm:"column:mtime" json:"mtime" form:"mtime"`
2536
+	Number                 string                    `gorm:"column:number" json:"number" form:"number"`
2537
+	Type                   int64                     `gorm:"column:type" json:"type" form:"type"`
2538
+	Doctor                 string                    `gorm:"column:doctor" json:"doctor" form:"doctor"`
2539
+	Creator                int64                     `gorm:"column:creator" json:"creator" form:"creator"`
2540
+	Modifier               int64                     `gorm:"column:modifier" json:"modifier" form:"modifier"`
2541
+	OrderStatus            int64                     `gorm:"column:order_status" json:"order_status" form:"order_status"`
2542
+	PreTime                int64                     `gorm:"column:pre_time" json:"pre_time" form:"pre_time"`
2543
+	BatchNumber            string                    `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
2544
+	PrescriptionNumber     string                    `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
2545
+	Patients               Patients                  `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
2546
+	HisDoctorAdviceInfo    []*HisDoctorAdviceInfo    `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
2547
+	HisPrescriptionProject []*HisPrescriptionProject `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
2548
+	Total                  string                    `gorm:"-" json:"total" form:"total"`
2549
+	PType                  int64                     `gorm:"column:p_type" json:"p_type" form:"p_type"`
2550
+	MedType                string                    `gorm:"column:med_type" json:"med_type" form:"med_type"`
2551
+	IsMedicine             int64                     `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
2552
+}
2553
+
2554
+func (ExportHisPrescription) TableName() string {
2555
+	return "his_prescription"
2556
+}

+ 24 - 0
models/schedule_models.go 查看文件

@@ -59,6 +59,30 @@ func (Schedule) TableName() string {
59 59
 	return "xt_schedule"
60 60
 }
61 61
 
62
+type ScheduleTwo struct {
63
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
64
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
65
+	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
66
+	BedId        int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
67
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
68
+	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
69
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
70
+	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
71
+	ModeId       int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
72
+	Status       int64 `gorm:"column:status" json:"status" form:"status"`
73
+	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
74
+	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
75
+	IsExport     int64 `gorm:"column:is_export" json:"is_export" form:"is_export"`
76
+
77
+	Patient                   string               `gorm:"-" json:"patient" form:"patient"`
78
+	PatientInfectiousDiseases []InfectiousDiseases `json:"patient_contagions" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
79
+	DialysisMachineName       string               `gorm:"column:dialysis_machine_name" json:"dialysis_machine_name" form:"dialysis_machine_name"`
80
+}
81
+
82
+func (ScheduleTwo) TableName() string {
83
+	return "xt_schedule"
84
+}
85
+
62 86
 type SchedulePatients struct {
63 87
 	ID           int64              `gorm:"column:id" json:"id" form:"id"`
64 88
 	UserOrgId    int64              `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`

+ 14 - 0
service/his_hospital_service.go 查看文件

@@ -565,3 +565,17 @@ func GetHisPrescriptionProjectByIDTwo(id int64) (projects models.HisPrescription
565 565
 	err = readDb.Model(&models.HisPrescriptionProject{}).Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("id = ? AND status = 1", id).First(&projects).Error
566 566
 	return
567 567
 }
568
+
569
+func GetUnChargeHisHospitalPrescription(org_id int64, start_time int64, end_time int64) (prescription []*models.ExportHisPrescription, err error) {
570
+	err = readDb.Model(&models.ExportHisPrescription{}).
571
+		Preload("Patients", "status = 1").
572
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
573
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
574
+		}).
575
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
576
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
577
+		}).
578
+		Where("user_org_id = ? AND status = 1 AND  record_date <= ? AND record_date >= ?  AND  order_status =  4 AND p_type = 1", org_id, end_time, start_time).
579
+		Find(&prescription).Error
580
+	return
581
+}

+ 92 - 2
service/his_print_service.go 查看文件

@@ -18,18 +18,108 @@ func GetBatchDrugHisPrescription(ids []string, record_time int64, user_org_id in
18 18
 	return
19 19
 }
20 20
 
21
+type HisPrintPrescriptionProject struct {
22
+	ID                 int64      `gorm:"column:id" json:"id" form:"id"`
23
+	ProjectId          int64      `gorm:"column:project_id" json:"project_id" form:"project_id"`
24
+	Price              float64    `gorm:"column:price" json:"price" form:"price"`
25
+	UserOrgId          int64      `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
26
+	Status             int64      `gorm:"column:status" json:"status" form:"status"`
27
+	Ctime              int64      `gorm:"column:ctime" json:"ctime" form:"ctime"`
28
+	Mtime              int64      `gorm:"column:mtime" json:"mtime" form:"mtime"`
29
+	PatientId          int64      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
30
+	HisPatientId       int64      `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
31
+	RecordDate         int64      `gorm:"column:record_date" json:"record_date" form:"record_date"`
32
+	PrescriptionId     int64      `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
33
+	Count              string     `gorm:"column:count" json:"count" form:"count"`
34
+	FeedetlSn          string     `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
35
+	MedListCodg        string     `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
36
+	SingleDose         string     `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
37
+	DeliveryWay        string     `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
38
+	ExecutionFrequency string     `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
39
+	Day                string     `gorm:"column:day" json:"day" form:"day"`
40
+	HisProject         HisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
41
+	GoodInfo           GoodInfo   `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"good_info"`
42
+	Remark             string     `gorm:"column:remark" json:"remark" form:"remark"`
43
+	Unit               string     `gorm:"column:unit" json:"unit" form:"unit"`
44
+	Type               int64      `gorm:"column:type" json:"type" form:"type"`
45
+	Doctor             int64      `gorm:"column:doctor" json:"doctor" form:"doctor"`
46
+	ExecutionTime      int64      `gborm:"column:execution_time" json:"execution_time" form:"execution_time"`
47
+	ExecutionStaff     int64      `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
48
+	ExecutionState     int64      `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
49
+	CheckTime          int64      `gorm:"column:check_time" json:"check_time" form:"check_time"`
50
+	CheckState         int64      `gorm:"column:check_state" json:"check_state" form:"check_state"`
51
+	Checker            int64      `gorm:"column:checker" json:"checker" form:"checker"`
52
+	StartTime          int64      `gorm:"column:start_time" json:"start_time" form:"start_time"`
53
+	TeamId             int64      `gorm:"column:team_id" json:"team_id" form:"team_id"`
54
+
55
+	FrequencyType        int64  `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
56
+	DayCount             int64  `gorm:"column:day_count" json:"day_count" form:"day_count"`
57
+	WeekDay              string `gorm:"column:week_day" json:"week_day" form:"week_day"`
58
+	IsCheckTeam          int64  `gorm:"-" json:"is_check_team" form:"is_check_team"`
59
+	ExecutionFrequencyId int64  `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
60
+}
61
+
62
+type HisProject struct {
63
+	ID                          int64   `gorm:"column:id" json:"id" form:"id"`
64
+	ProjectName                 string  `gorm:"column:project_name" json:"project_name" form:"project_name"`
65
+	Pinyin                      string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
66
+	Wubi                        string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
67
+	Price                       float64 `gorm:"column:price" json:"price" form:"price"`
68
+	Unit                        string  `gorm:"column:unit" json:"unit" form:"unit"`
69
+	CostClassify                int64   `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
70
+	ExecutiveSection            int64   `gorm:"column:executive_section" json:"executive_section" form:"executive_section"`
71
+	MedicalCoverage             int64   `gorm:"column:medical_coverage" json:"medical_coverage" form:"medical_coverage"`
72
+	StatisticalClassification   int64   `gorm:"column:statistical_classification" json:"statistical_classification" form:"statistical_classification"`
73
+	DiseaseDirectory            int64   `gorm:"column:disease_directory" json:"disease_directory" form:"disease_directory"`
74
+	IsRecord                    int64   `gorm:"column:is_record" json:"is_record" form:"is_record"`
75
+	MedicalCode                 string  `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
76
+	TubeColor                   int64   `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
77
+	MedicalStatus               int64   `gorm:"column:medical_status" json:"medical_status" form:"medical_status"`
78
+	Remark                      string  `gorm:"column:remark" json:"remark" form:"remark"`
79
+	Sign                        int64   `gorm:"column:sign" json:"sign" form:"sign"`
80
+	DefaultNumber               string  `gorm:"column:default_number" json:"default_number" form:"default_number"`
81
+	IsDefault                   int64   `gorm:"column:is_default" json:"is_default" form:"is_default"`
82
+	IsCharge                    int64   `gorm:"column:is_charge" json:"is_charge" form:"is_charge"`
83
+	IsEstimate                  int64   `gorm:"column:is_estimate" json:"is_estimate" form:"is_estimate"`
84
+	IsWorkload                  int64   `gorm:"column:is_workload" json:"is_workload" form:"is_workload"`
85
+	Sort                        string  `gorm:"column:sort" json:"sort" form:"sort"`
86
+	DoctorAdvice                int64   `gorm:"column:doctor_advice" json:"doctor_advice" form:"doctor_advice"`
87
+	UserOrgId                   int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
88
+	Status                      int64   `gorm:"column:status" json:"status" form:"status"`
89
+	CreatedTime                 int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
90
+	UpdatedTime                 int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
91
+	DeliveryWay                 string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
92
+	NumberDays                  string  `gorm:"column:number_days" json:"number_days" form:"number_days"`
93
+	Total                       string  `gorm:"column:total" json:"total" form:"total"`
94
+	Category                    int64   `gorm:"column:category" json:"category" form:"category"`
95
+	IsMark                      int64   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
96
+	SpecailProject              int64   `gorm:"column:specail_project" json:"specail_project" form:"specail_project"`
97
+	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
98
+	RecordDate                  int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
99
+	SingleDose                  string  `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
100
+	ExecutionFrequency          string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
101
+}
102
+
103
+func (HisProject) TableName() string {
104
+	return "xt_his_project"
105
+}
106
+
107
+func (HisPrintPrescriptionProject) TableName() string {
108
+	return "his_prescription_project"
109
+}
110
+
21 111
 func GetBatchProjectHisPrescription(ids []string, record_time int64, user_org_id int64) (patients []*models.PrintPatient, err error) {
22 112
 	readDb.Model(&models.PrintPatient{}).Preload("HisPrintPatient", "status = 1 AND record_date = ?", record_time).
23 113
 		Preload("HisPrintPrescription", func(db *gorm.DB) *gorm.DB {
24 114
 			return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND type <> 1 AND p_type = 2", user_org_id, record_time).
25 115
 				Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
26
-					return db.Joins("Join xt_his_project p On p.id = his_prescription_project.project_id  AND p.cost_classify != 3").Where("his_prescription_project.status = 1 AND his_prescription_project.user_org_id = ?", user_org_id).Where("his_prescription_project.status = 1 ").Preload("HisProject", "status = 1").Preload("GoodInfo", "status=1")
116
+					return db.Joins("").Joins("Join xt_his_project p On p.id = his_prescription_project.project_id ").Where("his_prescription_project.status = 1 AND his_prescription_project.user_org_id = ?", user_org_id).Where("his_prescription_project.status = 1 ").Preload("HisProject", "status = 1").Preload("GoodInfo", "status=1")
27 117
 				})
28 118
 		}).
29 119
 		Preload("HisPrescriptionInfoTwo", "status = 1 AND record_date = ?", record_time).
30 120
 		Where("id in (?) AND user_org_id = ?  ", ids, user_org_id).Find(&patients)
31
-	return
32 121
 
122
+	return
33 123
 }
34 124
 
35 125
 func GetBatchInspectionProjectHisPrescription(ids []string, record_time int64, user_org_id int64) (patients []*models.PrintPatient, err error) {

+ 48 - 5
service/schedule_service.go 查看文件

@@ -111,7 +111,7 @@ func GetWeekScheduleOne(orgID int64, start, end int64, partionid int64, schedule
111 111
 	return
112 112
 }
113 113
 
114
-func GetWeekScheduleTwo(orgID int64, start, end int64, schIds []string, scheduletype int64) (schedules []*models.Schedule, err error) {
114
+func GetWeekScheduleTwo(orgID int64, start, end int64, schIds []string, scheduletype int64) (schedules []*models.ScheduleTwo, err error) {
115 115
 
116 116
 	db := readDb.Table("xt_schedule as s")
117 117
 	if len(schIds) > 0 {
@@ -154,7 +154,7 @@ func GetScheduleTotalCount(orgID int64, start, end int64, schIds []string, sched
154 154
 
155 155
 }
156 156
 
157
-func GetWeekScheduleThree(orgID int64, start, end int64, schIds []string, scheduletype int64, WeekDayIds []string) (schedules []*models.Schedule, err error) {
157
+func GetWeekScheduleThree(orgID int64, start, end int64, schIds []string, scheduletype int64, WeekDayIds []string) (schedules []*models.ScheduleTwo, err error) {
158 158
 
159 159
 	db := readDb.Table("xt_schedule as s")
160 160
 
@@ -496,14 +496,57 @@ type WeekSchedulePrintVM struct {
496 496
 	Mode         *models.TreatmentMode `gorm:"ForeignKey:ModeID" json:"mode"`
497 497
 }
498 498
 
499
+type WeekSchedulePrintPatients struct {
500
+	ID        int64  `gorm:"column:id" json:"id" form:"id"`
501
+	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
502
+	Name      string `gorm:"column:name" json:"name" form:"name"`
503
+	Status    int64  `gorm:"column:status" json:"status" form:"status"`
504
+}
505
+
506
+func (WeekSchedulePrintPatients) TableName() string {
507
+	return "xt_patients"
508
+}
509
+
510
+type WeekSchedulePrintDeviceNumber struct {
511
+	ID         int64  `gorm:"column:id" json:"id"`
512
+	OrgID      int64  `gorm:"column:org_id" json:"-"`
513
+	Number     string `gorm:"column:number" json:"number"`
514
+	GroupID    int64  `gorm:"column:group_id" json:"group_id"`
515
+	ZoneID     int64  `gorm:"column:zone_id" json:"zone_id"`
516
+	Status     int64  `gorm:"column:status" json:"status" form:"status"`
517
+	CreateTime int64  `gorm:"column:ctime" json:"-"`
518
+	ModifyTime int64  `gorm:"column:mtime" json:"-"`
519
+	Sort       int64  `gorm:"column:sort" json:"sort" form:"sort"`
520
+}
521
+
522
+func (WeekSchedulePrintDeviceNumber) TableName() string {
523
+	return "xt_device_number"
524
+}
525
+
526
+type WeekSchedulePrintVMTwo struct {
527
+	ID             int64 `gorm:"column:id" json:"id"`
528
+	ZoneID         int64 `gorm:"column:partition_id" json:"zone_id"`
529
+	DeviceNumberID int64 `gorm:"column:bed_id" json:"device_number_id"`
530
+	PatientID      int64 `gorm:"column:patient_id" json:"patient_id"`
531
+	ScheduleDate   int64 `gorm:"column:schedule_date" json:"schedule_date"`
532
+	ScheduleType   int64 `gorm:"column:schedule_type" json:"schedule_type"`
533
+	ScheduleWeek   int64 `gorm:"column:schedule_week" json:"schedule_week"`
534
+	ModeID         int64 `gorm:"column:mode_id" json:"mode_id"`
535
+
536
+	Patient      *WeekSchedulePrintPatients     `gorm:"ForeignKey:PatientID" json:"patient"`
537
+	DeviceNumber *WeekSchedulePrintDeviceNumber `gorm:"ForeignKey:DeviceNumberID" json:"device_number"`
538
+	Zone         *models.DeviceZone             `gorm:"ForeignKey:ZoneID" json:"zone"`
539
+	Mode         *models.TreatmentMode          `gorm:"ForeignKey:ModeID" json:"mode"`
540
+}
541
+
499 542
 type PrintCount struct {
500 543
 	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type"`
501 544
 	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week"`
502 545
 	Count        int64
503 546
 }
504 547
 
505
-func GetPrinitWeekSchedules(orgID int64, start, end int64) ([]*WeekSchedulePrintVM, error) {
506
-	var schedules []*WeekSchedulePrintVM
548
+func GetPrinitWeekSchedules(orgID int64, start, end int64) ([]*WeekSchedulePrintVMTwo, error) {
549
+	var schedules []*WeekSchedulePrintVMTwo
507 550
 	err := readDb.Table("xt_schedule as s").
508 551
 		Preload("Patient", "status = 1 and user_org_id = ?", orgID).
509 552
 		Preload("DeviceNumber", "status = 1 and org_id = ?", orgID).
@@ -878,7 +921,7 @@ func GetWeekDayScheduleByIdThee(orgid int64, scheduleDate int64, scheduleType in
878 921
 		db = db.Where("x.partition_id in (?)", zone)
879 922
 	}
880 923
 
881
-	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 {
924
+	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("SchedulesPatientsVM", "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 {
882 925
 		return db.Where("status =1 and parent_id = 0 and advice_date = ?", scheduleDate).Preload("ChildDoctorAdvice", "status = 1")
883 926
 	}).Preload("HisDoctorAdviceInfo", "status = 1 and advice_date = ? and user_org_id = ? ", scheduleDate, orgid).Preload("DialysisPrescription", "status = 1 and record_date =? and user_org_id = ?", scheduleDate, orgid).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
884 927
 		return db.Where("status =1").Order("id asc")