Browse Source

医保对接

csx 2 years ago
parent
commit
656f5af634
2 changed files with 812 additions and 0 deletions
  1. 246 0
      controllers/public_api_controller.go
  2. 566 0
      service/app_version.go

+ 246 - 0
controllers/public_api_controller.go View File

@@ -73,8 +73,208 @@ func PublicApiRegistRouters() {
73 73
 
74 74
 	beego.Router("/handelHis", &PublicApiController{}, "get:HandleHisTwo")
75 75
 
76
+	beego.Router("/handelProject", &PublicApiController{}, "get:HandleProject")
77
+
78
+	beego.Router("/handelsettledata", &PublicApiController{}, "get:HandleSettleData")
79
+
80
+	beego.Router("/handelhispatient", &PublicApiController{}, "get:HandleHisPatient")
81
+
76 82
 	//beego.Router("/handelOrder", &PublicApiController{}, "get:HandleOrder")
77 83
 
84
+	beego.Router("/handleExportData", &PublicApiController{}, "get:HandleExportAllData")
85
+
86
+	beego.Router("/handleExportData10138", &PublicApiController{}, "get:HandleExportData10138")
87
+
88
+	beego.Router("/handleData10265", &PublicApiController{}, "get:HandleData10265")
89
+
90
+	beego.Router("/handleData10106", &PublicApiController{}, "get:HandleData10106")
91
+
92
+	beego.Router("/handelschedule", &PublicApiController{}, "get:HandleSchedule")
93
+	beego.Router("/handelscheduleTwo", &PublicApiController{}, "get:HandleScheduleTwo")
94
+
95
+}
96
+
97
+type ResultFiveT struct {
98
+	Balc                   float64 `json:"balc"`
99
+	CvlservFlag            string  `json:"cvlserv_flag"`
100
+	EmpName                string  `json:"emp_name"`
101
+	InsuplcAdmdvs          string  `json:"insuplc_admdvs"`
102
+	Insutype               string  `json:"insutype"`
103
+	PausInsuDansuplcAdmdvs string  `json:"paus_insu_dansuplc_admdvs"`
104
+	PausInsuDate           string  `json:"paus_insu_date"`
105
+	PsnInsuDate            string  `json:"psn_insu_date"`
106
+	PsnInsuStas            string  `json:"psn_insu_stas"`
107
+	PsnType                string  `json:"psn_type"`
108
+}
109
+
110
+func (c *PublicApiController) HandleSchedule() {
111
+	//fmt.Println("~~~~~~")
112
+	service.GetLongSolution()
113
+
114
+}
115
+
116
+func (c *PublicApiController) HandleScheduleTwo() {
117
+	models, _ := service.GetAllSchMode()
118
+	for _, item := range models {
119
+		if item.Mode == 1 {
120
+			templates, _ := service.GetOrgPatientScheduleTemplateIDs(item.OrgID)
121
+			thisTime := time.Now()
122
+			_, theWeek := thisTime.ISOWeek()
123
+			templates[0].Week = theWeek
124
+			service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, int8(templates[0].Week))
125
+		} else if item.Mode == 2 {
126
+			templates, _ := service.GetOrgPatientScheduleTemplateIDs(item.OrgID)
127
+			now := time.Now()
128
+			nextSecWeek := now.AddDate(0, 0, 14)
129
+			nextWeek := now.AddDate(0, 0, 7)
130
+			if item.ExecuteTimes%2 == 0 { //下第二周生成的是
131
+				templates[0].Week = service.GetWeeks(nextWeek.Format("2006-01-02 15:04:05"))
132
+				templates[1].Week = service.GetWeeks(nextSecWeek.Format("2006-01-02 15:04:05"))
133
+				service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, int8(templates[0].Week))
134
+				service.UpdateTemplateItemWeek(templates[1].OrgID, templates[1].ID, int8(templates[1].Week))
135
+
136
+			} else if item.ExecuteTimes%2 == 1 {
137
+				templates[0].Week = service.GetWeeks(nextSecWeek.Format("2006-01-02 15:04:05"))
138
+				templates[1].Week = service.GetWeeks(nextSecWeek.Format("2006-01-02 15:04:05"))
139
+				service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, int8(templates[0].Week))
140
+				service.UpdateTemplateItemWeek(templates[1].OrgID, templates[1].ID, int8(templates[1].Week))
141
+
142
+			}
143
+
144
+		}
145
+	}
146
+
147
+}
148
+
149
+func (c *PublicApiController) HandleHisPatient() {
150
+
151
+	ps, _ := service.GetHisPatient11111(10215)
152
+	for _, item := range ps {
153
+		var rf []*ResultFiveT
154
+		json.Unmarshal([]byte(item.Iinfo), &rf)
155
+		var insuplc_admdvs string
156
+		var insutype string
157
+		var is390 int = 0
158
+		var is310 int = 0
159
+		var insutypes []*ResultFiveT
160
+
161
+		for _, item := range rf {
162
+			if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
163
+				insutypes = append(insutypes, item)
164
+			}
165
+		}
166
+
167
+		fmt.Println(insutypes)
168
+		if len(insutypes) == 1 {
169
+			insutype = insutypes[0].Insutype
170
+			is390 = 1
171
+			fmt.Println("111111")
172
+			//insuplc_admdvs = insutypes[0].InsuplcAdmdvs
173
+		} else {
174
+			fmt.Println("222222")
175
+
176
+			for _, i := range insutypes {
177
+				if i.Insutype == "390" {
178
+					is390 = 1
179
+				}
180
+
181
+				if i.Insutype == "310" {
182
+					is310 = 1
183
+				}
184
+			}
185
+		}
186
+
187
+		if is390 == 1 {
188
+			insutype = "390"
189
+		}
190
+
191
+		if is310 == 1 {
192
+			insutype = "310"
193
+		}
194
+
195
+		if len(insutypes) == 0 {
196
+			insutype = "310"
197
+		}
198
+		for _, item := range rf {
199
+			if item.Insutype == insutype {
200
+				insuplc_admdvs = item.InsuplcAdmdvs
201
+			}
202
+		}
203
+		item.InsuplcAdmdvs = insuplc_admdvs
204
+
205
+		service.SaveHP(item)
206
+	}
207
+}
208
+
209
+func (c *PublicApiController) HandleSettleData() {
210
+	orders, _ := service.GetHisOrderDetailThree()
211
+	c.ServeSuccessJSON(map[string]interface{}{
212
+		"order": orders,
213
+	})
214
+}
215
+
216
+//func (c *PublicApiController) HandleData10106() {
217
+//	start_time := c.GetString("start_time")
218
+//	end_time := c.GetString("end_time")
219
+//
220
+//	timeLayout := "2006-01-02"
221
+//	loc, _ := time.LoadLocation("Local")
222
+//	startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
223
+//	if err != nil {
224
+//
225
+//	}
226
+//	startRecordDateTime := startTime.Unix()
227
+//
228
+//	endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
229
+//	if err != nil {
230
+//
231
+//	}
232
+//	endRecordDateTime := endTime.Unix()
233
+//	fmt.Println(startRecordDateTime)
234
+//	fmt.Println(endRecordDateTime)
235
+//
236
+//	orders, _ := service.GetHisOrderDetail10106(startRecordDateTime, endRecordDateTime)
237
+//	c.ServeSuccessJSON(map[string]interface{}{
238
+//		"order": orders,
239
+//	})
240
+//}
241
+
242
+func (c *PublicApiController) HandleData10106() {
243
+	start_time := c.GetString("start_time")
244
+	end_time := c.GetString("end_time")
245
+
246
+	start_time = "2022-11-01"
247
+	end_time = "2022-11-30"
248
+	timeLayout := "2006-01-02"
249
+	loc, _ := time.LoadLocation("Local")
250
+	startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
251
+	if err != nil {
252
+
253
+	}
254
+	startRecordDateTime := startTime.Unix()
255
+	endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
256
+	if err != nil {
257
+
258
+	}
259
+	endRecordDateTime := endTime.Unix()
260
+	fmt.Println(startRecordDateTime)
261
+	fmt.Println(endRecordDateTime)
262
+
263
+	orders, _ := service.GetHisOrderDetail10106(startRecordDateTime, endRecordDateTime)
264
+	c.ServeSuccessJSON(map[string]interface{}{
265
+		"order": orders,
266
+	})
267
+}
268
+
269
+func (c *PublicApiController) HandleProject() {
270
+	prescriptions := service.GetAllProjectPrescription()
271
+	for _, item := range prescriptions {
272
+		ps := service.GetAllProject(item.ID)
273
+		for _, subItem := range ps {
274
+			subItem.Status = 0
275
+			service.SaveHisProject(subItem)
276
+		}
277
+	}
78 278
 }
79 279
 
80 280
 func (c *PublicApiController) HandleHisTwo() {
@@ -2070,3 +2270,49 @@ func (c *PublicApiController) Handle10215() {
2070 2270
 	}
2071 2271
 
2072 2272
 }
2273
+
2274
+func (c *PublicApiController) HandleExportAllData() {
2275
+	orders, _ := service.GetHisOrderDetail9504()
2276
+	c.ServeSuccessJSON(map[string]interface{}{
2277
+		"order": orders,
2278
+	})
2279
+}
2280
+
2281
+func (c *PublicApiController) HandleExportData10138() {
2282
+	orders, _ := service.GetHisOrderDetail10138()
2283
+	c.ServeSuccessJSON(map[string]interface{}{
2284
+		"order": orders,
2285
+	})
2286
+}
2287
+
2288
+func (c *PublicApiController) HandleData10265() {
2289
+	orders, _ := service.GetHisOrder10265()
2290
+	for _, items := range orders {
2291
+		if items.AdviceId == 0 && items.ProjectId > 0 {
2292
+			p, _ := service.GetHisPrescriptionProjectByIDTwo(items.ProjectId)
2293
+			if p.Type == 2 {
2294
+				if p.HisProject.CostClassify == 3 {
2295
+					items.MedChrgitmType = "04"
2296
+				}
2297
+
2298
+				if p.HisProject.CostClassify == 2 {
2299
+					items.MedChrgitmType = "05"
2300
+				}
2301
+
2302
+				if p.HisProject.CostClassify == 8 {
2303
+					items.MedChrgitmType = "03"
2304
+				}
2305
+
2306
+				//p.HisProject.CostClassify == 8
2307
+
2308
+			} else {
2309
+
2310
+				items.MedChrgitmType = "08"
2311
+
2312
+			}
2313
+
2314
+		}
2315
+		service.SaveOrderInfo(items)
2316
+	}
2317
+
2318
+}

+ 566 - 0
service/app_version.go View File

@@ -2,6 +2,7 @@ package service
2 2
 
3 3
 import (
4 4
 	"XT_New/models"
5
+	"fmt"
5 6
 	"github.com/jinzhu/gorm"
6 7
 	"time"
7 8
 )
@@ -456,3 +457,568 @@ func SaveHis(his *models.HisPatient) {
456 457
 	writeDb.Save(his)
457 458
 	return
458 459
 }
460
+
461
+func GetAllProjectPrescription() (pre []*models.HisPrescription) {
462
+	readDb.Model(&models.HisPrescription{}).Where("user_org_id = 10215 AND status = 1 AND type = 2 AND order_status = 1 AND record_date >= 1659283200").Find(&pre)
463
+	return
464
+}
465
+
466
+func GetAllProject(id int64) (pre []*models.HisPrescriptionProject) {
467
+	readDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id = 10215 AND status = 1 AND project_id = 1735  AND prescription_id = ?", id).Find(&pre)
468
+	return
469
+}
470
+
471
+//func GetHisOrderDetailByNumberTwo(order_number string, org_id int64) (order []*HisOrderInfo, err error) {
472
+//	readDb.Model(&models.Patients{})
473
+//
474
+//	err = readDb.Model(&HisOrderInfo{}).Where("order_number = ? AND status = 1", order_number).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
475
+//		return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("VMHisPrescriptionTwo", "status = 1 AND user_org_id = ?", org_id).Preload("VMHisProject", "status = 1 AND user_org_id = ?", org_id).Preload("VMGoodInfo", "status = 1 AND org_id = ?", org_id)
476
+//	}).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
477
+//		return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("VMHisPrescriptionTwo", "status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status = 1 AND org_id = ?", org_id)
478
+//	}).Find(&order).Error
479
+//	return
480
+//}
481
+
482
+type HisOrderTen struct {
483
+	ID                    int64                 `gorm:"column:id" json:"id" form:"id"`
484
+	UserOrgId             int64                 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
485
+	HisPatientId          int64                 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
486
+	SettleAccountsDate    int64                 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
487
+	Ctime                 int64                 `gorm:"column:ctime" json:"ctime" form:"ctime"`
488
+	Mtime                 int64                 `gorm:"column:mtime" json:"mtime" form:"mtime"`
489
+	Status                int64                 `gorm:"column:status" json:"status" form:"status"`
490
+	Number                string                `gorm:"column:number" json:"number" form:"number"`
491
+	PatientId             int64                 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
492
+	Infcode               int64                 `gorm:"column:infcode" json:"infcode" form:"infcode"`
493
+	WarnMsg               string                `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
494
+	Cainfo                string                `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
495
+	ErrMsg                string                `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
496
+	RespondTime           string                `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
497
+	InfRefmsgid           string                `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
498
+	OrderStatus           int64                 `gorm:"column:order_status" json:"order_status" form:"order_status"`
499
+	MdtrtId               string                `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
500
+	SetlId                string                `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
501
+	PsnNo                 string                `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
502
+	PsnName               string                `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
503
+	PsnCertType           string                `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
504
+	Certno                string                `gorm:"column:certno" json:"certno" form:"certno"`
505
+	Gend                  string                `gorm:"column:gend" json:"gend" form:"gend"`
506
+	Naty                  string                `gorm:"column:naty" json:"naty" form:"naty"`
507
+	Brdy                  time.Time             `gorm:"column:brdy" json:"brdy" form:"brdy"`
508
+	Age                   float64               `gorm:"column:age" json:"age" form:"age"`
509
+	Insutype              string                `gorm:"column:insutype" json:"insutype" form:"insutype"`
510
+	PsnType               string                `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
511
+	CvlservFlag           string                `gorm:"column:cvlserv_flag" json:"cvlserv_flag" form:"cvlserv_flag"`
512
+	SetlTime              string                `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
513
+	MdtrtCertType         string                `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
514
+	MedType               string                `gorm:"column:med_type" json:"med_type" form:"med_type"`
515
+	MedfeeSumamt          float64               `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
516
+	FulamtOwnpayAmt       float64               `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
517
+	OverlmtSelfPay        float64               `gorm:"column:overlmt_self_pay" json:"overlmt_self_pay" form:"overlmt_self_pay"`
518
+	PreselfpayAmt         float64               `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
519
+	InscpScpAmt           float64               `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
520
+	ActPayDedc            float64               `gorm:"column:act_pay_dedc" json:"act_pay_dedc" form:"act_pay_dedc"`
521
+	HifpPay               float64               `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
522
+	CvlservPay            float64               `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
523
+	PoolPropSelfpay       float64               `gorm:"column:pool_prop_selfpay" json:"pool_prop_selfpay" form:"pool_prop_selfpay"`
524
+	HifesPay              float64               `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
525
+	HifmiPay              float64               `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
526
+	HifobPay              float64               `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
527
+	MafPay                float64               `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
528
+	OthPay                float64               `gorm:"column:oth_pay" json:"oth_pay" form:"oth_pay"`
529
+	FundPaySumamt         float64               `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
530
+	PsnPartAmt            float64               `gorm:"column:psn_part_amt" json:"psn_part_amt" form:"psn_part_amt"`
531
+	AcctPay               float64               `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
532
+	PsnCashPay            float64               `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
533
+	HospPartAmt           float64               `gorm:"column:hosp_part_amt" json:"hosp_part_amt" form:"hosp_part_amt"`
534
+	Balc                  float64               `gorm:"column:balc" json:"balc" form:"balc"`
535
+	AcctMulaidPay         float64               `gorm:"column:acct_mulaid_pay" json:"acct_mulaid_pay" form:"acct_mulaid_pay"`
536
+	MedinsSetlId          string                `gorm:"column:medins_setl_id" json:"medins_setl_id" form:"medins_setl_id"`
537
+	ClrOptins             string                `gorm:"column:clr_optins" json:"clr_optins" form:"clr_optins"`
538
+	ClrWay                string                `gorm:"column:clr_way" json:"clr_way" form:"clr_way"`
539
+	ClrType               string                `gorm:"column:clr_type" json:"clr_type" form:"clr_type"`
540
+	SetlDetail            string                `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
541
+	IsMedicineInsurance   int64                 `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
542
+	PayWay                int64                 `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
543
+	PayPrice              float64               `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
544
+	PayCardNo             string                `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
545
+	DiscountPrice         float64               `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
546
+	PreferentialPrice     float64               `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
547
+	RealityPrice          float64               `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
548
+	FoundPrice            float64               `gorm:"column:found_price" json:"found_price" form:"found_price"`
549
+	MedicalInsurancePrice float64               `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
550
+	PrivatePrice          float64               `gorm:"column:private_price" json:"private_price" form:"private_price"`
551
+	DepartmentName        string                `gorm:"-" json:"department_name" form:"department_name"`
552
+	DoctorName            string                `gorm:"-" json:"doctor_name" form:"doctor_name"`
553
+	Creator               int64                 `gorm:"column:creator" json:"creator" form:"creator"`
554
+	PType                 int64                 `gorm:"column:p_type" json:"p_type" form:"p_type"`
555
+	Decimal               float64               `gorm:"column:decimal" json:"decimal" form:"decimal"`
556
+	HisPrescriptionTen    []*HisPrescriptionTen `gorm:"ForeignKey:BatchNumber;AssociationForeignKey:Number" json:"info"`
557
+	Patients              Patients              `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
558
+}
559
+
560
+func (HisOrderTen) TableName() string {
561
+	return "his_order"
562
+}
563
+
564
+type HisPrescriptionTen struct {
565
+	ID                        int64                        `gorm:"column:id" json:"id" form:"id"`
566
+	UserOrgId                 int64                        `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
567
+	RecordDate                int64                        `gorm:"column:record_date" json:"record_date" form:"record_date"`
568
+	PatientId                 int64                        `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
569
+	HisPatientId              int64                        `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
570
+	Status                    int64                        `gorm:"column:status" json:"status" form:"status"`
571
+	Ctime                     int64                        `gorm:"column:ctime" json:"ctime" form:"ctime"`
572
+	Mtime                     int64                        `gorm:"column:mtime" json:"mtime" form:"mtime"`
573
+	Number                    string                       `gorm:"column:number" json:"number" form:"number"`
574
+	Type                      int64                        `gorm:"column:type" json:"type" form:"type"`
575
+	Doctor                    string                       `gorm:"column:doctor" json:"doctor" form:"doctor"`
576
+	Creator                   int64                        `gorm:"column:creator" json:"creator" form:"creator"`
577
+	Modifier                  int64                        `gorm:"column:modifier" json:"modifier" form:"modifier"`
578
+	OrderStatus               int64                        `gorm:"column:order_status" json:"order_status" form:"order_status"`
579
+	PreTime                   int64                        `gorm:"column:pre_time" json:"pre_time" form:"pre_time"`
580
+	BatchNumber               string                       `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
581
+	PrescriptionNumber        string                       `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
582
+	Patients                  Patients                     `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
583
+	HisDoctorAdviceInfoTen    []*HisDoctorAdviceInfoTen    `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
584
+	HisPrescriptionProjectTen []*HisPrescriptionProjectTen `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
585
+	Total                     string                       `gorm:"-" json:"total" form:"total"`
586
+	PType                     int64                        `gorm:"column:p_type" json:"p_type" form:"p_type"`
587
+	MedType                   string                       `gorm:"column:med_type" json:"med_type" form:"med_type"`
588
+	IsMedicine                int64                        `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
589
+}
590
+
591
+func (HisPrescriptionTen) TableName() string {
592
+	return "his_prescription"
593
+}
594
+
595
+func GetHisOrderDetailThree() (order []*HisOrderTen, err error) {
596
+	err = readDb.Model(&HisOrderTen{}).Preload("Patients", "status = 1").Preload("HisPrescriptionTen", func(db *gorm.DB) *gorm.DB {
597
+		return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
598
+			return db.Where("status = 1").Preload("VMHisProject", "status = 1").Preload("VMGoodInfo", "status = 1")
599
+		}).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
600
+			return db.Where("status = 1").Preload("Drug", "status = 1")
601
+		})
602
+	}).Where("settle_accounts_date >= 1659283200 AND settle_accounts_date <= 1661788800 AND status = 1 AND order_status =2 and p_type = 1 AND user_org_id = 10215").Find(&order).Order("patient_id").Error
603
+	return
604
+}
605
+
606
+type HisDoctorAdviceInfoTen struct {
607
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
608
+	UserOrgId             int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
609
+	PatientId             int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
610
+	AdviceDate            int64   `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
611
+	AdviceName            string  `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
612
+	AdviceDesc            string  `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
613
+	SingleDose            float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
614
+	SingleDoseUnit        string  `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
615
+	PrescribingNumber     float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
616
+	PrescribingNumberUnit string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
617
+	DeliveryWay           string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
618
+	ExecutionFrequency    string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
619
+	Status                int64   `gorm:"column:status" json:"status" form:"status"`
620
+	CreatedTime           int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
621
+	RecordDate            int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
622
+	DrugSpec              float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
623
+	DrugSpecUnit          string  `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
624
+	PrescriptionId        int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
625
+
626
+	Price                float64 `gorm:"column:price" json:"price" form:"price"`
627
+	DrugId               int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
628
+	Drug                 Drug    `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" json:"drug"`
629
+	IsMedicine           int64   `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
630
+	ExecutionFrequencyId int64   `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
631
+}
632
+
633
+func (HisDoctorAdviceInfoTen) TableName() string {
634
+	return "his_doctor_advice_info"
635
+}
636
+
637
+type HisPrescriptionProjectTen struct {
638
+	ID                 int64        `gorm:"column:id" json:"id" form:"id"`
639
+	ProjectId          int64        `gorm:"column:project_id" json:"project_id" form:"project_id"`
640
+	Price              float64      `gorm:"column:price" json:"price" form:"price"`
641
+	UserOrgId          int64        `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
642
+	Status             int64        `gorm:"column:status" json:"status" form:"status"`
643
+	Ctime              int64        `gorm:"column:ctime" json:"ctime" form:"ctime"`
644
+	Mtime              int64        `gorm:"column:mtime" json:"mtime" form:"mtime"`
645
+	PatientId          int64        `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
646
+	HisPatientId       int64        `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
647
+	RecordDate         int64        `gorm:"column:record_date" json:"record_date" form:"record_date"`
648
+	PrescriptionId     int64        `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
649
+	Count              string       `gorm:"column:count" json:"count" form:"count"`
650
+	FeedetlSn          string       `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
651
+	MedListCodg        string       `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
652
+	SingleDose         string       `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
653
+	DeliveryWay        string       `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
654
+	ExecutionFrequency string       `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
655
+	Day                string       `gorm:"column:day" json:"day" form:"day"`
656
+	VMHisProject       VMHisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
657
+	VMGoodInfo         VMGoodInfo   `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"good_info"`
658
+	Remark             string       `gorm:"column:remark" json:"remark" form:"remark"`
659
+	Unit               string       `gorm:"column:unit" json:"unit" form:"unit"`
660
+	Type               int64        `gorm:"column:type" json:"type" form:"type"`
661
+	Doctor             int64        `gorm:"column:doctor" json:"doctor" form:"doctor"`
662
+	ExecutionTime      int64        `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
663
+	ExecutionStaff     int64        `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
664
+	ExecutionState     int64        `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
665
+	CheckTime          int64        `gorm:"column:check_time" json:"check_time" form:"check_time"`
666
+	CheckState         int64        `gorm:"column:check_state" json:"check_state" form:"check_state"`
667
+	Checker            int64        `gorm:"column:checker" json:"checker" form:"checker"`
668
+	StartTime          int64        `gorm:"column:start_time" json:"start_time" form:"start_time"`
669
+	TeamId             int64        `gorm:"column:team_id" json:"team_id" form:"team_id"`
670
+
671
+	FrequencyType        int64  `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
672
+	DayCount             int64  `gorm:"column:day_count" json:"day_count" form:"day_count"`
673
+	WeekDay              string `gorm:"column:week_day" json:"week_day" form:"week_day"`
674
+	ExecutionFrequencyId int64  `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
675
+}
676
+
677
+func (HisPrescriptionProjectTen) TableName() string {
678
+	return "his_prescription_project"
679
+}
680
+
681
+func GetHisPatient11111(orgid int64) (paitent []*models.HisHospitalCheckRecord, err error) {
682
+	err = XTReadDB().Model(&paitent).Where("user_org_id = ?  and status = 1 AND in_hosptial_time >= '2022-11-01 00:00:00' AND in_hosptial_time <= '2022-11-30 23:59:59'", orgid).Find(&paitent).Error
683
+	return paitent, err
684
+}
685
+
686
+func SaveHP(paitent *models.HisHospitalCheckRecord) {
687
+	writeDb.Save(&paitent)
688
+
689
+}
690
+
691
+type HisOrder9504 struct {
692
+	ID                    int64     `gorm:"column:id" json:"id" form:"id"`
693
+	UserOrgId             int64     `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
694
+	HisPatientId          int64     `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
695
+	SettleAccountsDate    int64     `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
696
+	Ctime                 int64     `gorm:"column:ctime" json:"ctime" form:"ctime"`
697
+	Mtime                 int64     `gorm:"column:mtime" json:"mtime" form:"mtime"`
698
+	Status                int64     `gorm:"column:status" json:"status" form:"status"`
699
+	Number                string    `gorm:"column:number" json:"number" form:"number"`
700
+	PatientId             int64     `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
701
+	Infcode               int64     `gorm:"column:infcode" json:"infcode" form:"infcode"`
702
+	WarnMsg               string    `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
703
+	Cainfo                string    `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
704
+	ErrMsg                string    `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
705
+	RespondTime           string    `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
706
+	InfRefmsgid           string    `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
707
+	OrderStatus           int64     `gorm:"column:order_status" json:"order_status" form:"order_status"`
708
+	MdtrtId               string    `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
709
+	SetlId                string    `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
710
+	PsnNo                 string    `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
711
+	PsnName               string    `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
712
+	PsnCertType           string    `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
713
+	Certno                string    `gorm:"column:certno" json:"certno" form:"certno"`
714
+	Gend                  string    `gorm:"column:gend" json:"gend" form:"gend"`
715
+	Naty                  string    `gorm:"column:naty" json:"naty" form:"naty"`
716
+	Brdy                  time.Time `gorm:"column:brdy" json:"brdy" form:"brdy"`
717
+	Age                   float64   `gorm:"column:age" json:"age" form:"age"`
718
+	Insutype              string    `gorm:"column:insutype" json:"insutype" form:"insutype"`
719
+	PsnType               string    `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
720
+	CvlservFlag           string    `gorm:"column:cvlserv_flag" json:"cvlserv_flag" form:"cvlserv_flag"`
721
+	SetlTime              string    `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
722
+	MdtrtCertType         string    `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
723
+	MedType               string    `gorm:"column:med_type" json:"med_type" form:"med_type"`
724
+	MedfeeSumamt          float64   `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
725
+	FulamtOwnpayAmt       float64   `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
726
+	OverlmtSelfPay        float64   `gorm:"column:overlmt_self_pay" json:"overlmt_self_pay" form:"overlmt_self_pay"`
727
+	PreselfpayAmt         float64   `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
728
+	InscpScpAmt           float64   `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
729
+	ActPayDedc            float64   `gorm:"column:act_pay_dedc" json:"act_pay_dedc" form:"act_pay_dedc"`
730
+	HifpPay               float64   `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
731
+	CvlservPay            float64   `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
732
+	PoolPropSelfpay       float64   `gorm:"column:pool_prop_selfpay" json:"pool_prop_selfpay" form:"pool_prop_selfpay"`
733
+	HifesPay              float64   `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
734
+	HifmiPay              float64   `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
735
+	HifobPay              float64   `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
736
+	MafPay                float64   `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
737
+	OthPay                float64   `gorm:"column:oth_pay" json:"oth_pay" form:"oth_pay"`
738
+	FundPaySumamt         float64   `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
739
+	PsnPartAmt            float64   `gorm:"column:psn_part_amt" json:"psn_part_amt" form:"psn_part_amt"`
740
+	AcctPay               float64   `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
741
+	PsnCashPay            float64   `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
742
+	HospPartAmt           float64   `gorm:"column:hosp_part_amt" json:"hosp_part_amt" form:"hosp_part_amt"`
743
+	Balc                  float64   `gorm:"column:balc" json:"balc" form:"balc"`
744
+	AcctMulaidPay         float64   `gorm:"column:acct_mulaid_pay" json:"acct_mulaid_pay" form:"acct_mulaid_pay"`
745
+	MedinsSetlId          string    `gorm:"column:medins_setl_id" json:"medins_setl_id" form:"medins_setl_id"`
746
+	ClrOptins             string    `gorm:"column:clr_optins" json:"clr_optins" form:"clr_optins"`
747
+	ClrWay                string    `gorm:"column:clr_way" json:"clr_way" form:"clr_way"`
748
+	ClrType               string    `gorm:"column:clr_type" json:"clr_type" form:"clr_type"`
749
+	SetlDetail            string    `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
750
+	IsMedicineInsurance   int64     `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
751
+	PayWay                int64     `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
752
+	PayPrice              float64   `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
753
+	PayCardNo             string    `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
754
+	DiscountPrice         float64   `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
755
+	PreferentialPrice     float64   `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
756
+	RealityPrice          float64   `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
757
+	FoundPrice            float64   `gorm:"column:found_price" json:"found_price" form:"found_price"`
758
+	MedicalInsurancePrice float64   `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
759
+	PrivatePrice          float64   `gorm:"column:private_price" json:"private_price" form:"private_price"`
760
+	DepartmentName        string    `gorm:"-" json:"department_name" form:"department_name"`
761
+	DoctorName            string    `gorm:"-" json:"doctor_name" form:"doctor_name"`
762
+	SettleStartTime       int64     `gorm:"settle_start_time" json:"settle_start_time" form:"settle_start_time"`
763
+
764
+	Creator            int64                 `gorm:"column:creator" json:"creator" form:"creator"`
765
+	PType              int64                 `gorm:"column:p_type" json:"p_type" form:"p_type"`
766
+	Decimal            float64               `gorm:"column:decimal" json:"decimal" form:"decimal"`
767
+	VmHisOrderInfo9504 []*VmHisOrderInfo9504 `gorm:"ForeignKey:OrderNumber;AssociationForeignKey:Number" json:"info"`
768
+	Patients           Patients              `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
769
+}
770
+
771
+func (HisOrder9504) TableName() string {
772
+	return "his_order"
773
+}
774
+
775
+type VmHisOrderInfo9504 struct {
776
+	ID                        int64                     `gorm:"column:id" json:"id" form:"id"`
777
+	OrderNumber               string                    `gorm:"column:order_number" json:"order_number" form:"order_number"`
778
+	UploadDate                int64                     `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
779
+	AdviceId                  int64                     `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
780
+	DetItemFeeSumamt          float64                   `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
781
+	Cnt                       float64                   `gorm:"column:cnt" json:"cnt" form:"cnt"`
782
+	Pric                      float64                   `gorm:"column:pric" json:"pric" form:"pric"`
783
+	PatientId                 int64                     `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
784
+	PricUplmtAmt              float64                   `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
785
+	SelfpayProp               float64                   `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
786
+	FulamtOwnpayAmt           float64                   `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
787
+	OverlmtAmt                float64                   `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
788
+	PreselfpayAmt             float64                   `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
789
+	BasMednFlag               string                    `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
790
+	MedChrgitmType            string                    `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
791
+	HiNegoDrugFlag            string                    `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
792
+	Status                    int64                     `gorm:"column:status" json:"status" form:"status"`
793
+	Memo                      string                    `gorm:"column:memo" json:"memo" form:"memo"`
794
+	FeedetlSn                 string                    `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
795
+	Mtime                     int64                     `gorm:"column:mtime" json:"mtime" form:"mtime"`
796
+	InscpScpAmt               float64                   `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
797
+	DrtReimFlag               string                    `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
798
+	Ctime                     int64                     `gorm:"column:ctime" json:"ctime" form:"ctime"`
799
+	ListSpItemFlag            string                    `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
800
+	ChldMedcFlag              string                    `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
801
+	LmtUsedFlag               string                    `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
802
+	ChrgitmLv                 string                    `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
803
+	UserOrgId                 int64                     `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
804
+	HisPatientId              int64                     `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
805
+	OrderId                   int64                     `gorm:"column:order_id" json:"order_id" form:"order_id"`
806
+	ProjectId                 int64                     `gorm:"column:project_id" json:"project_id" form:"project_id"`
807
+	Type                      int64                     `gorm:"column:type" json:"type" form:"type"`
808
+	ItemId                    int64                     `gorm:"column:item_id" json:"item_id" form:"item_id"`
809
+	SettleType                int64                     `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
810
+	HisPrescriptionProjectTen HisPrescriptionProjectTen `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
811
+	HisDoctorAdviceInfoTen    HisDoctorAdviceInfoTen    `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"advices"`
812
+}
813
+
814
+func (VmHisOrderInfo9504) TableName() string {
815
+	return "his_order_info"
816
+}
817
+
818
+type VmHisOrderInfo95042 struct {
819
+	ID               int64   `gorm:"column:id" json:"id" form:"id"`
820
+	OrderNumber      string  `gorm:"column:order_number" json:"order_number" form:"order_number"`
821
+	UploadDate       int64   `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
822
+	AdviceId         int64   `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
823
+	DetItemFeeSumamt float64 `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
824
+	Cnt              float64 `gorm:"column:cnt" json:"cnt" form:"cnt"`
825
+	Pric             float64 `gorm:"column:pric" json:"pric" form:"pric"`
826
+	PatientId        int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
827
+	PricUplmtAmt     float64 `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
828
+	SelfpayProp      float64 `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
829
+	FulamtOwnpayAmt  float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
830
+	OverlmtAmt       float64 `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
831
+	PreselfpayAmt    float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
832
+	BasMednFlag      string  `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
833
+	MedChrgitmType   string  `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
834
+	HiNegoDrugFlag   string  `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
835
+	Status           int64   `gorm:"column:status" json:"status" form:"status"`
836
+	Memo             string  `gorm:"column:memo" json:"memo" form:"memo"`
837
+	FeedetlSn        string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
838
+	Mtime            int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
839
+	InscpScpAmt      float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
840
+	DrtReimFlag      string  `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
841
+	Ctime            int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
842
+	ListSpItemFlag   string  `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
843
+	ChldMedcFlag     string  `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
844
+	LmtUsedFlag      string  `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
845
+	ChrgitmLv        string  `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
846
+	UserOrgId        int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
847
+	HisPatientId     int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
848
+	OrderId          int64   `gorm:"column:order_id" json:"order_id" form:"order_id"`
849
+	ProjectId        int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
850
+	Type             int64   `gorm:"column:type" json:"type" form:"type"`
851
+	ItemId           int64   `gorm:"column:item_id" json:"item_id" form:"item_id"`
852
+	SettleType       int64   `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
853
+}
854
+
855
+func (VmHisOrderInfo95042) TableName() string {
856
+	return "his_order_info"
857
+}
858
+
859
+func GetHisOrderDetail9504() (order []*HisOrder9504, err error) {
860
+	err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
861
+		return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
862
+			return db.Where("status = 1").Preload("VMHisProject", "status = 1").Preload("VMGoodInfo", "status = 1")
863
+		}).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
864
+			return db.Where("status = 1").Preload("Drug", "status = 1")
865
+		})
866
+	}).Where("settle_accounts_date >= 1640966400 AND settle_accounts_date <= 1661875200 AND status = 1 AND order_status =2  AND user_org_id = 9504").Find(&order).Order("setl_time").Error
867
+	return
868
+}
869
+
870
+func GetHisOrderDetail10188() (order []*HisOrder9504, err error) {
871
+	err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
872
+		return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
873
+			return db.Where("status = 1").Preload("VMHisProject", "status = 1").Preload("VMGoodInfo", "status = 1")
874
+		})
875
+	}).Where("settle_accounts_date >= 1654012800 AND settle_accounts_date <= 1661875200 AND status = 1 AND order_status =2  AND user_org_id = 10188").Find(&order).Order("setl_time").Error
876
+	return
877
+}
878
+
879
+//func GetHisOrderDetail10138() (order []*HisOrder9504, err error) {
880
+//	err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
881
+//		return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
882
+//			return db.Where("status = 1").Preload("VMHisProject", "status = 1")
883
+//		})
884
+//	}).Where("settle_accounts_date >= 1640966400 AND settle_accounts_date <= 1648656000 AND status = 1 AND order_status =2  AND user_org_id = 10138").Find(&order).Order("setl_time").Error
885
+//	return
886
+//}
887
+
888
+func GetHisOrderDetail10138() (order []*HisOrderTen, err error) {
889
+	err = readDb.Model(&HisOrderTen{}).Preload("HisPrescriptionTen", func(db *gorm.DB) *gorm.DB {
890
+		return db.Where("status = 1 AND order_status = 2").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
891
+			return db.Where("status = 1").Preload("VMHisProject")
892
+		})
893
+	}).Where("settle_accounts_date >= 1656604800 AND settle_accounts_date <= 1664553599 AND status = 1 AND order_status =2  AND user_org_id = 10138").Find(&order).Error
894
+	return
895
+}
896
+
897
+func GetHisOrderDetail10265() (order_infos []*VmHisOrderInfo9504, err error) {
898
+	err = readDb.Model(&VmHisOrderInfo9504{}).Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
899
+		return db.Preload("VMHisProject").Preload("VMGoodInfo", "status = 1")
900
+	}).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
901
+		return db.Where("status = 1").Preload("Drug", "status = 1")
902
+	}).Where(" status = 1  AND user_org_id = 10265 AND order_number = '2022090814370516482'").Find(&order_infos).Error
903
+	return
904
+}
905
+
906
+func GetHisOrder10265() (order_infos []*VmHisOrderInfo9504, err error) {
907
+	err = readDb.Model(&VmHisOrderInfo95042{}).Where(" status = 1  AND user_org_id = 10265 AND order_number = '2022092912130116192' AND project_id > 0").Find(&order_infos).Error
908
+	return
909
+}
910
+
911
+func SaveOrderInfo(info *VmHisOrderInfo9504) {
912
+	writeDb.Save(&info)
913
+}
914
+
915
+func GetHisOrderDetail10106(start_time int64, end_time int64) (order []*HisOrder9504, err error) {
916
+	err = readDb.Model(&HisOrder9504{}).Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
917
+		return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
918
+			return db.Where("status = 1").Preload("VMHisProject").Preload("VMGoodInfo")
919
+		}).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
920
+			return db.Where("status = 1").Preload("Drug")
921
+		})
922
+	}).Where("settle_accounts_date >= ? AND settle_accounts_date <= ? AND status = 1 AND order_status =2  AND user_org_id = 10106", start_time, end_time).Find(&order).Order("setl_time").Error
923
+	return
924
+}
925
+
926
+func GetLongSolution() {
927
+	records, _ := GetAllSchedules()
928
+	fmt.Println(records)
929
+	for _, item := range records {
930
+		//1.透析器   2.灌流器     3.透析器/灌流器
931
+		so, _ := GetDialysisSolutionTwo(item.UserOrgId, item.PatientId, item.ModeId)
932
+		filedRecordOne, _ := FindFiledBy(item.UserOrgId, "透析器")
933
+		filedRecordTwo, _ := FindFiledBy(item.UserOrgId, "灌流器")
934
+		filedRecordThree, _ := FindFiledBy(item.UserOrgId, "透析器/灌流器")
935
+		if filedRecordOne.IsShow == 1 {
936
+			item.DialysisMachineName = so.DialysisDialyszers
937
+		}
938
+		if filedRecordThree.IsShow == 1 {
939
+			if len(item.DialysisMachineName) > 0 {
940
+				item.DialysisMachineName = item.DialysisMachineName + "," + so.DialyzerPerfusionApparatus
941
+
942
+			} else {
943
+				item.DialysisMachineName = so.DialyzerPerfusionApparatus
944
+
945
+			}
946
+		}
947
+		if filedRecordTwo.IsShow == 1 {
948
+			if len(item.DialysisMachineName) > 0 {
949
+				item.DialysisMachineName = item.DialysisMachineName + "," + so.DialysisIrrigation
950
+
951
+			} else {
952
+				item.DialysisMachineName = so.DialysisIrrigation
953
+
954
+			}
955
+		}
956
+
957
+		UpdateSch(item)
958
+
959
+	}
960
+}
961
+
962
+func GetAllSchMode() (modes []*models.PatientScheduleTemplateMode, getModesErr error) {
963
+	getModesErr = readDb.Model(&models.PatientScheduleTemplateMode{}).Where("mode <> 0 AND status = 1 ").Find(&modes).Error
964
+	return
965
+}
966
+
967
+type DialysisSolutionTwo struct {
968
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
969
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
970
+}
971
+
972
+func (DialysisSolutionTwo) TableName() string {
973
+	return "xt_dialysis_solution"
974
+}
975
+
976
+type Schedule struct {
977
+	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
978
+	UserOrgId           int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
979
+	PatientId           int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
980
+	Status              int64  `gorm:"column:status" json:"status" form:"status"`
981
+	ScheduleDate        int64  `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
982
+	ModeId              int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
983
+	DialysisMachineName string `gorm:"column:dialysis_machine_name" json:"dialysis_machine_name" form:"dialysis_machine_name"`
984
+}
985
+
986
+func (Schedule) TableName() string {
987
+	return "xt_schedule"
988
+}
989
+
990
+func GetAllSchedules() ([]Schedule, error) {
991
+	var record []Schedule
992
+
993
+	err := readDb.Model(&Schedule{}).Where("status = 1 AND schedule_date > 1670774400").Find(&record).Error
994
+	if err != nil {
995
+		if err == gorm.ErrRecordNotFound {
996
+			return nil, nil
997
+		} else {
998
+			return nil, err
999
+		}
1000
+	}
1001
+	return record, nil
1002
+}
1003
+
1004
+func FindFiledBy(org_id int64, name string) (filedConfig models.FiledConfig, err error) {
1005
+	err = readDb.Model(&models.FiledConfig{}).Where("org_id =? AND  module = 1 AND filed_name_cn= ?", org_id, name).First(&filedConfig).Error
1006
+	return
1007
+}
1008
+
1009
+// 透析方案
1010
+func GetDialysisSolutionTwo(orgID int64, patientID int64, mode_id int64) (models.DialysisSolution, error) {
1011
+	var record models.DialysisSolution
1012
+	err := readDb.Model(&models.DialysisSolution{}).Where("patient_id = ? and user_org_id = ? and status = 1 AND mode_id = ?", patientID, orgID, mode_id).Last(&record).Error
1013
+	return record, err
1014
+}
1015
+
1016
+func UpdateSch(sch Schedule) (err error) {
1017
+	err = writeDb.Model(&Schedule{}).Where("status=1 AND id = ?", sch.ID).Updates(map[string]interface{}{"dialysis_machine_name": sch.DialysisMachineName}).Error
1018
+	return
1019
+}
1020
+
1021
+func SaveSch(sch models.Schedule) (err error) {
1022
+	err = writeDb.Save(&sch).Error
1023
+	return
1024
+}