|
@@ -4,6 +4,8 @@ import (
|
4
|
4
|
"XT_New/models"
|
5
|
5
|
"fmt"
|
6
|
6
|
"github.com/jinzhu/gorm"
|
|
7
|
+ "math"
|
|
8
|
+ "strconv"
|
7
|
9
|
"time"
|
8
|
10
|
)
|
9
|
11
|
|
|
@@ -484,82 +486,82 @@ func GetAllProject(id int64) (pre []*models.HisPrescriptionProject) {
|
484
|
486
|
//}
|
485
|
487
|
|
486
|
488
|
type HisOrderTen struct {
|
487
|
|
- ID int64 `gorm:"column:id" json:"id" form:"id"`
|
488
|
|
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
489
|
|
- HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
|
490
|
|
- SettleAccountsDate int64 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
|
491
|
|
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
492
|
|
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
493
|
|
- Status int64 `gorm:"column:status" json:"status" form:"status"`
|
494
|
|
- Number string `gorm:"column:number" json:"number" form:"number"`
|
495
|
|
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
|
496
|
|
- Infcode int64 `gorm:"column:infcode" json:"infcode" form:"infcode"`
|
497
|
|
- WarnMsg string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
|
498
|
|
- Cainfo string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
|
499
|
|
- ErrMsg string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
|
500
|
|
- RespondTime string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
|
501
|
|
- InfRefmsgid string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
|
502
|
|
- OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
|
503
|
|
- MdtrtId string `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
|
504
|
|
- SetlId string `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
|
505
|
|
- PsnNo string `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
|
506
|
|
- PsnName string `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
|
507
|
|
- PsnCertType string `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
|
508
|
|
- Certno string `gorm:"column:certno" json:"certno" form:"certno"`
|
509
|
|
- Gend string `gorm:"column:gend" json:"gend" form:"gend"`
|
510
|
|
- Naty string `gorm:"column:naty" json:"naty" form:"naty"`
|
511
|
|
- Brdy time.Time `gorm:"column:brdy" json:"brdy" form:"brdy"`
|
512
|
|
- Age float64 `gorm:"column:age" json:"age" form:"age"`
|
513
|
|
- Insutype string `gorm:"column:insutype" json:"insutype" form:"insutype"`
|
514
|
|
- PsnType string `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
|
515
|
|
- CvlservFlag string `gorm:"column:cvlserv_flag" json:"cvlserv_flag" form:"cvlserv_flag"`
|
516
|
|
- SetlTime string `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
|
517
|
|
- MdtrtCertType string `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
|
518
|
|
- MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
|
519
|
|
- MedfeeSumamt float64 `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
|
520
|
|
- FulamtOwnpayAmt float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
|
521
|
|
- OverlmtSelfPay float64 `gorm:"column:overlmt_self_pay" json:"overlmt_self_pay" form:"overlmt_self_pay"`
|
522
|
|
- PreselfpayAmt float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
|
523
|
|
- InscpScpAmt float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
|
524
|
|
- ActPayDedc float64 `gorm:"column:act_pay_dedc" json:"act_pay_dedc" form:"act_pay_dedc"`
|
525
|
|
- HifpPay float64 `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
|
526
|
|
- CvlservPay float64 `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
|
527
|
|
- PoolPropSelfpay float64 `gorm:"column:pool_prop_selfpay" json:"pool_prop_selfpay" form:"pool_prop_selfpay"`
|
528
|
|
- HifesPay float64 `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
|
529
|
|
- HifmiPay float64 `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
|
530
|
|
- HifobPay float64 `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
|
531
|
|
- MafPay float64 `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
|
532
|
|
- OthPay float64 `gorm:"column:oth_pay" json:"oth_pay" form:"oth_pay"`
|
533
|
|
- FundPaySumamt float64 `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
|
534
|
|
- PsnPartAmt float64 `gorm:"column:psn_part_amt" json:"psn_part_amt" form:"psn_part_amt"`
|
535
|
|
- AcctPay float64 `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
|
536
|
|
- PsnCashPay float64 `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
|
537
|
|
- HospPartAmt float64 `gorm:"column:hosp_part_amt" json:"hosp_part_amt" form:"hosp_part_amt"`
|
538
|
|
- Balc float64 `gorm:"column:balc" json:"balc" form:"balc"`
|
539
|
|
- AcctMulaidPay float64 `gorm:"column:acct_mulaid_pay" json:"acct_mulaid_pay" form:"acct_mulaid_pay"`
|
540
|
|
- MedinsSetlId string `gorm:"column:medins_setl_id" json:"medins_setl_id" form:"medins_setl_id"`
|
541
|
|
- ClrOptins string `gorm:"column:clr_optins" json:"clr_optins" form:"clr_optins"`
|
542
|
|
- ClrWay string `gorm:"column:clr_way" json:"clr_way" form:"clr_way"`
|
543
|
|
- ClrType string `gorm:"column:clr_type" json:"clr_type" form:"clr_type"`
|
544
|
|
- SetlDetail string `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
|
545
|
|
- IsMedicineInsurance int64 `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
|
546
|
|
- PayWay int64 `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
|
547
|
|
- PayPrice float64 `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
|
548
|
|
- PayCardNo string `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
|
549
|
|
- DiscountPrice float64 `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
|
550
|
|
- PreferentialPrice float64 `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
|
551
|
|
- RealityPrice float64 `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
|
552
|
|
- FoundPrice float64 `gorm:"column:found_price" json:"found_price" form:"found_price"`
|
553
|
|
- MedicalInsurancePrice float64 `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
|
554
|
|
- PrivatePrice float64 `gorm:"column:private_price" json:"private_price" form:"private_price"`
|
555
|
|
- DepartmentName string `gorm:"-" json:"department_name" form:"department_name"`
|
556
|
|
- DoctorName string `gorm:"-" json:"doctor_name" form:"doctor_name"`
|
557
|
|
- Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
|
558
|
|
- PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
|
559
|
|
- Decimal float64 `gorm:"column:decimal" json:"decimal" form:"decimal"`
|
560
|
|
- VmHisOrderInfo9504 []*VmHisOrderInfo9504 `gorm:"ForeignKey:OrderNumber;AssociationForeignKey:Number" json:"info"`
|
561
|
|
- //HisPrescriptionTen []*HisPrescriptionTen `gorm:"ForeignKey:BatchNumber;AssociationForeignKey:Number" json:"info"`
|
562
|
|
- Patients Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
|
|
489
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
490
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
|
491
|
+ HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
|
|
492
|
+ SettleAccountsDate int64 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
|
|
493
|
+ Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
|
494
|
+ Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
|
495
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
496
|
+ Number string `gorm:"column:number" json:"number" form:"number"`
|
|
497
|
+ PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
|
|
498
|
+ Infcode int64 `gorm:"column:infcode" json:"infcode" form:"infcode"`
|
|
499
|
+ WarnMsg string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
|
|
500
|
+ Cainfo string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
|
|
501
|
+ ErrMsg string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
|
|
502
|
+ RespondTime string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
|
|
503
|
+ InfRefmsgid string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
|
|
504
|
+ OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
|
|
505
|
+ MdtrtId string `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
|
|
506
|
+ SetlId string `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
|
|
507
|
+ PsnNo string `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
|
|
508
|
+ PsnName string `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
|
|
509
|
+ PsnCertType string `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
|
|
510
|
+ Certno string `gorm:"column:certno" json:"certno" form:"certno"`
|
|
511
|
+ Gend string `gorm:"column:gend" json:"gend" form:"gend"`
|
|
512
|
+ Naty string `gorm:"column:naty" json:"naty" form:"naty"`
|
|
513
|
+ Brdy time.Time `gorm:"column:brdy" json:"brdy" form:"brdy"`
|
|
514
|
+ Age float64 `gorm:"column:age" json:"age" form:"age"`
|
|
515
|
+ Insutype string `gorm:"column:insutype" json:"insutype" form:"insutype"`
|
|
516
|
+ PsnType string `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
|
|
517
|
+ CvlservFlag string `gorm:"column:cvlserv_flag" json:"cvlserv_flag" form:"cvlserv_flag"`
|
|
518
|
+ SetlTime string `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
|
|
519
|
+ MdtrtCertType string `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
|
|
520
|
+ MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
|
|
521
|
+ MedfeeSumamt float64 `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
|
|
522
|
+ FulamtOwnpayAmt float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
|
|
523
|
+ OverlmtSelfPay float64 `gorm:"column:overlmt_self_pay" json:"overlmt_self_pay" form:"overlmt_self_pay"`
|
|
524
|
+ PreselfpayAmt float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
|
|
525
|
+ InscpScpAmt float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
|
|
526
|
+ ActPayDedc float64 `gorm:"column:act_pay_dedc" json:"act_pay_dedc" form:"act_pay_dedc"`
|
|
527
|
+ HifpPay float64 `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
|
|
528
|
+ CvlservPay float64 `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
|
|
529
|
+ PoolPropSelfpay float64 `gorm:"column:pool_prop_selfpay" json:"pool_prop_selfpay" form:"pool_prop_selfpay"`
|
|
530
|
+ HifesPay float64 `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
|
|
531
|
+ HifmiPay float64 `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
|
|
532
|
+ HifobPay float64 `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
|
|
533
|
+ MafPay float64 `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
|
|
534
|
+ OthPay float64 `gorm:"column:oth_pay" json:"oth_pay" form:"oth_pay"`
|
|
535
|
+ FundPaySumamt float64 `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
|
|
536
|
+ PsnPartAmt float64 `gorm:"column:psn_part_amt" json:"psn_part_amt" form:"psn_part_amt"`
|
|
537
|
+ AcctPay float64 `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
|
|
538
|
+ PsnCashPay float64 `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
|
|
539
|
+ HospPartAmt float64 `gorm:"column:hosp_part_amt" json:"hosp_part_amt" form:"hosp_part_amt"`
|
|
540
|
+ Balc float64 `gorm:"column:balc" json:"balc" form:"balc"`
|
|
541
|
+ AcctMulaidPay float64 `gorm:"column:acct_mulaid_pay" json:"acct_mulaid_pay" form:"acct_mulaid_pay"`
|
|
542
|
+ MedinsSetlId string `gorm:"column:medins_setl_id" json:"medins_setl_id" form:"medins_setl_id"`
|
|
543
|
+ ClrOptins string `gorm:"column:clr_optins" json:"clr_optins" form:"clr_optins"`
|
|
544
|
+ ClrWay string `gorm:"column:clr_way" json:"clr_way" form:"clr_way"`
|
|
545
|
+ ClrType string `gorm:"column:clr_type" json:"clr_type" form:"clr_type"`
|
|
546
|
+ SetlDetail string `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
|
|
547
|
+ IsMedicineInsurance int64 `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
|
|
548
|
+ PayWay int64 `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
|
|
549
|
+ PayPrice float64 `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
|
|
550
|
+ PayCardNo string `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
|
|
551
|
+ DiscountPrice float64 `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
|
|
552
|
+ PreferentialPrice float64 `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
|
|
553
|
+ RealityPrice float64 `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
|
|
554
|
+ FoundPrice float64 `gorm:"column:found_price" json:"found_price" form:"found_price"`
|
|
555
|
+ MedicalInsurancePrice float64 `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
|
|
556
|
+ PrivatePrice float64 `gorm:"column:private_price" json:"private_price" form:"private_price"`
|
|
557
|
+ DepartmentName string `gorm:"-" json:"department_name" form:"department_name"`
|
|
558
|
+ DoctorName string `gorm:"-" json:"doctor_name" form:"doctor_name"`
|
|
559
|
+ Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
|
|
560
|
+ PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
|
|
561
|
+ Decimal float64 `gorm:"column:decimal" json:"decimal" form:"decimal"`
|
|
562
|
+ //VmHisOrderInfo9504 []*VmHisOrderInfo9504 `gorm:"ForeignKey:OrderNumber;AssociationForeignKey:Number" json:"info"`
|
|
563
|
+ HisPrescriptionTen []*HisPrescriptionTen `gorm:"ForeignKey:BatchNumber;AssociationForeignKey:Number" json:"info"`
|
|
564
|
+ Patients Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
|
563
|
565
|
}
|
564
|
566
|
|
565
|
567
|
func (HisOrderTen) TableName() string {
|
|
@@ -597,14 +599,17 @@ func (HisPrescriptionTen) TableName() string {
|
597
|
599
|
return "his_prescription"
|
598
|
600
|
}
|
599
|
601
|
|
600
|
|
-func GetHisOrderDetailThree() (order []*HisOrderTen, err error) {
|
|
602
|
+func GetHisOrderDetailThree(start_time string, end_time string, org_id int64) (order []*HisOrderTen, err error) {
|
|
603
|
+ start_time = start_time + " 00:00:00"
|
|
604
|
+ end_time = end_time + " 23:59:00"
|
|
605
|
+
|
601
|
606
|
err = readDb.Model(&HisOrderTen{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
|
602
|
607
|
return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
|
603
|
608
|
return db.Where("status = 1").Preload("VMHisProject", "status = 1").Preload("VMGoodInfo", "status = 1")
|
604
|
609
|
}).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
|
605
|
610
|
return db.Where("status = 1").Preload("Drug", "status = 1")
|
606
|
611
|
})
|
607
|
|
- }).Where("setl_time >= '2024-01-01 00:00:00' AND setl_time <= '2024-01-31 23:59:00' AND status = 1 AND order_status =2 AND user_org_id = 10485").Find(&order).Order("patient_id").Error
|
|
612
|
+ }).Where("setl_time >= ? AND setl_time <= ? AND status = 1 AND order_status =2 AND user_org_id = ?", start_time, end_time, org_id).Find(&order).Order("patient_id").Error
|
608
|
613
|
return
|
609
|
614
|
}
|
610
|
615
|
|
|
@@ -686,7 +691,7 @@ func (HisPrescriptionProjectTen) TableName() string {
|
686
|
691
|
|
687
|
692
|
func GetHisPatient11111(orgid int64) (paitent []*models.HisHospitalCheckRecord, err error) {
|
688
|
693
|
|
689
|
|
- err = XTReadDB().Model(&paitent).Where("user_org_id = ? and status = 1 AND in_hosptial_time >= '2024-04-01 00:00:00' AND in_hosptial_time <= '2024-05-31 23:59:59'", orgid).Find(&paitent).Error
|
|
694
|
+ err = XTReadDB().Model(&paitent).Where("user_org_id = ? and status = 1 AND in_hosptial_time >= '2024-06-01 00:00:00' AND in_hosptial_time <= '2024-06-30 23:59:59'", orgid).Find(&paitent).Error
|
690
|
695
|
return paitent, err
|
691
|
696
|
}
|
692
|
697
|
|
|
@@ -902,7 +907,7 @@ func GetHisOrderDetail10138() (order []*HisOrderTen, err error) {
|
902
|
907
|
return db.Where("status = 1 AND order_status = 2").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
|
903
|
908
|
return db.Where("status = 1").Preload("VMHisProject")
|
904
|
909
|
})
|
905
|
|
- }).Where("setl_time >= '2024-01-01 00:00:00' AND setl_time <= '2024-03-31 23:00:00' AND status = 1 AND order_status =2 AND user_org_id = 10138").Find(&order).Error
|
|
910
|
+ }).Where("setl_time >= '2024-04-01 00:00:00' AND setl_time <= '2024-06-30 23:00:00' AND status = 1 AND order_status =2 AND user_org_id = 10278").Find(&order).Error
|
906
|
911
|
return
|
907
|
912
|
}
|
908
|
913
|
|
|
@@ -1402,3 +1407,207 @@ func GetOrderinfo(org_id int64) (info []models.HisOrderInfo, err error) {
|
1402
|
1407
|
}
|
1403
|
1408
|
return
|
1404
|
1409
|
}
|
|
1410
|
+
|
|
1411
|
+type Result22 struct {
|
|
1412
|
+ InspectDate string
|
|
1413
|
+ Inspect int64
|
|
1414
|
+ PatientID int64
|
|
1415
|
+ ItemID1 int64
|
|
1416
|
+ ItemID2 int64
|
|
1417
|
+ ItemName1 string
|
|
1418
|
+ ItemName2 string
|
|
1419
|
+ InspectValue1 string
|
|
1420
|
+ InspectValue2 string
|
|
1421
|
+ WeightAfter float64
|
|
1422
|
+ ActualUltrafiltration float64
|
|
1423
|
+ ActualTreatmentHour int64
|
|
1424
|
+ ActualTreatmentHours float64
|
|
1425
|
+ WeightBefore float64
|
|
1426
|
+}
|
|
1427
|
+
|
|
1428
|
+func Aaa() {
|
|
1429
|
+
|
|
1430
|
+ var inspections []Result22
|
|
1431
|
+ readDb.Raw(`
|
|
1432
|
+ SELECT
|
|
1433
|
+ DATE(FROM_UNIXTIME(xts.inspect_date)) AS inspect_date,
|
|
1434
|
+ xts.inspect,
|
|
1435
|
+ xts.patient_id,
|
|
1436
|
+ xts.item_id AS item_id_1,
|
|
1437
|
+ b.item_id AS item_id_2,
|
|
1438
|
+ xts.item_name AS item_name_1,
|
|
1439
|
+ b.item_name AS item_name_2,
|
|
1440
|
+ xts.inspect_value AS inspect_value1,
|
|
1441
|
+ b.inspect_value AS inspect_value2,
|
|
1442
|
+ b.weight_after,
|
|
1443
|
+ b.actual_ultrafiltration,
|
|
1444
|
+ b.actual_treatment_hour,
|
|
1445
|
+ b.actual_treatment_minute / 60.0 AS actual_treatment_hours,
|
|
1446
|
+ xts.weight_before
|
|
1447
|
+ FROM
|
|
1448
|
+ (SELECT
|
|
1449
|
+ DATE(FROM_UNIXTIME(xts.inspect_date)) AS inspect_date,
|
|
1450
|
+ xts.inspect_date as inspect,
|
|
1451
|
+ xts.patient_id,
|
|
1452
|
+ xts.item_id,
|
|
1453
|
+ xts.item_name,
|
|
1454
|
+ xts.inspect_value,
|
|
1455
|
+ be.weight_before
|
|
1456
|
+ FROM xt_inspection xts
|
|
1457
|
+ JOIN xt_assessment_before_dislysis be
|
|
1458
|
+ ON be.patient_id = xts.patient_id
|
|
1459
|
+ AND DATE(FROM_UNIXTIME(xts.inspect_date)) = DATE(FROM_UNIXTIME(be.assessment_date))
|
|
1460
|
+ WHERE xts.org_id = 10677 AND xts.item_id = 106770503) xts
|
|
1461
|
+ JOIN
|
|
1462
|
+ (SELECT
|
|
1463
|
+ DATE(FROM_UNIXTIME(xt.inspect_date)) AS inspect_date,
|
|
1464
|
+ xt.inspect_date as inspect,
|
|
1465
|
+ xt.patient_id,
|
|
1466
|
+ xt.item_id,
|
|
1467
|
+ xt.item_name,
|
|
1468
|
+ xt.inspect_value,
|
|
1469
|
+ ad.weight_after,
|
|
1470
|
+ ad.actual_ultrafiltration,
|
|
1471
|
+ ad.actual_treatment_hour,
|
|
1472
|
+ ad.actual_treatment_minute
|
|
1473
|
+ FROM xt_inspection xt
|
|
1474
|
+ JOIN xt_assessment_after_dislysis ad
|
|
1475
|
+ ON DATE(FROM_UNIXTIME(xt.inspect_date)) = DATE(FROM_UNIXTIME(ad.assessment_date))
|
|
1476
|
+ AND xt.patient_id = ad.patient_id
|
|
1477
|
+ WHERE xt.org_id = 10677 AND xt.item_id = 106771301
|
|
1478
|
+ AND ad.weight_after > 0
|
|
1479
|
+ AND ad.actual_ultrafiltration > 0) b
|
|
1480
|
+ ON xts.inspect_date = b.inspect_date
|
|
1481
|
+ AND xts.patient_id = b.patient_id;
|
|
1482
|
+ `).Scan(&inspections)
|
|
1483
|
+
|
|
1484
|
+ for _, item := range inspections {
|
|
1485
|
+ // 定义一个日期字符串
|
|
1486
|
+ timestamp := item.Inspect
|
|
1487
|
+ var ins models.Inspection
|
|
1488
|
+ ins.Status = 1
|
|
1489
|
+ ins.PatientId = item.PatientID
|
|
1490
|
+ ins.OrgId = 10677
|
|
1491
|
+ ins.ItemName = "透析前尿素氮"
|
|
1492
|
+ ins.CreatedTime = time.Now().Unix()
|
|
1493
|
+ ins.UpdatedTime = time.Now().Unix()
|
|
1494
|
+ ins.ProjectName = "KT/V"
|
|
1495
|
+ ins.InspectType = 3
|
|
1496
|
+ ins.InspectDate = timestamp
|
|
1497
|
+ ins.InspectValue = item.InspectValue1
|
|
1498
|
+ ins.ProjectId = 1014
|
|
1499
|
+ ins.ItemId = 10879
|
|
1500
|
+ writeDb.Create(&ins)
|
|
1501
|
+
|
|
1502
|
+ var ins2 models.Inspection
|
|
1503
|
+ ins2.Status = 1
|
|
1504
|
+ ins2.PatientId = item.PatientID
|
|
1505
|
+ ins2.OrgId = 10677
|
|
1506
|
+ ins2.ItemName = "透析后尿素氮"
|
|
1507
|
+ ins2.CreatedTime = time.Now().Unix()
|
|
1508
|
+ ins2.UpdatedTime = time.Now().Unix()
|
|
1509
|
+ ins2.ProjectName = "KT/V"
|
|
1510
|
+ ins2.InspectType = 3
|
|
1511
|
+ ins2.InspectDate = timestamp
|
|
1512
|
+ ins2.InspectValue = item.InspectValue2
|
|
1513
|
+ ins2.ProjectId = 1014
|
|
1514
|
+ ins2.ItemId = 10878
|
|
1515
|
+ writeDb.Create(&ins2)
|
|
1516
|
+
|
|
1517
|
+ var ins3 models.Inspection
|
|
1518
|
+ ins3.Status = 1
|
|
1519
|
+ ins3.PatientId = item.PatientID
|
|
1520
|
+ ins3.OrgId = 10677
|
|
1521
|
+ ins3.ItemName = "透析时间"
|
|
1522
|
+ ins3.CreatedTime = time.Now().Unix()
|
|
1523
|
+ ins3.UpdatedTime = time.Now().Unix()
|
|
1524
|
+ ins3.ProjectName = "KT/V"
|
|
1525
|
+ ins3.InspectType = 3
|
|
1526
|
+ ins3.InspectDate = timestamp
|
|
1527
|
+ strValue := fmt.Sprintf("%f", float64(item.ActualTreatmentHour)+item.ActualTreatmentHours)
|
|
1528
|
+ ins3.InspectValue = strValue
|
|
1529
|
+ ins3.ProjectId = 1014
|
|
1530
|
+ ins3.ItemId = 10877
|
|
1531
|
+ writeDb.Create(&ins3)
|
|
1532
|
+
|
|
1533
|
+ var ins4 models.Inspection
|
|
1534
|
+
|
|
1535
|
+ ins4.Status = 1
|
|
1536
|
+ ins4.PatientId = item.PatientID
|
|
1537
|
+ ins4.OrgId = 10677
|
|
1538
|
+ ins4.ItemName = "实际超滤量"
|
|
1539
|
+ ins4.CreatedTime = time.Now().Unix()
|
|
1540
|
+ ins4.UpdatedTime = time.Now().Unix()
|
|
1541
|
+ ins4.ProjectName = "KT/V"
|
|
1542
|
+ ins4.InspectType = 3
|
|
1543
|
+ ins4.InspectDate = timestamp
|
|
1544
|
+ strValue2 := fmt.Sprintf("%f", item.ActualUltrafiltration/1000)
|
|
1545
|
+ ins4.InspectValue = strValue2
|
|
1546
|
+ ins4.ProjectId = 1014
|
|
1547
|
+ ins4.ItemId = 10876
|
|
1548
|
+ writeDb.Create(&ins4)
|
|
1549
|
+
|
|
1550
|
+ var ins7 models.Inspection
|
|
1551
|
+ ins7.Status = 1
|
|
1552
|
+ ins7.PatientId = item.PatientID
|
|
1553
|
+ ins7.OrgId = 10677
|
|
1554
|
+ ins7.ItemName = "透后体重"
|
|
1555
|
+ ins7.CreatedTime = time.Now().Unix()
|
|
1556
|
+ ins7.UpdatedTime = time.Now().Unix()
|
|
1557
|
+ ins7.ProjectName = "KT/V"
|
|
1558
|
+ ins7.InspectType = 3
|
|
1559
|
+ ins7.InspectDate = timestamp
|
|
1560
|
+ strValue5 := fmt.Sprintf("%f", item.WeightAfter)
|
|
1561
|
+ ins7.InspectValue = strValue5
|
|
1562
|
+ ins7.ProjectId = 1014
|
|
1563
|
+ ins7.ItemId = 10874
|
|
1564
|
+ writeDb.Create(&ins7)
|
|
1565
|
+
|
|
1566
|
+ var ins8 models.Inspection
|
|
1567
|
+ ins8.Status = 1
|
|
1568
|
+ ins8.PatientId = item.PatientID
|
|
1569
|
+ ins8.OrgId = 10677
|
|
1570
|
+ ins8.ItemName = "KT/V"
|
|
1571
|
+ ins8.CreatedTime = time.Now().Unix()
|
|
1572
|
+ ins8.UpdatedTime = time.Now().Unix()
|
|
1573
|
+ ins8.ProjectName = "KT/V"
|
|
1574
|
+ ins8.InspectType = 3
|
|
1575
|
+ ins8.InspectDate = timestamp
|
|
1576
|
+ ins8.InspectValue = ""
|
|
1577
|
+ ins8.ProjectId = 1014
|
|
1578
|
+ ins8.ItemId = 10950
|
|
1579
|
+
|
|
1580
|
+ C0, _ := strconv.ParseFloat(item.InspectValue1, 64)
|
|
1581
|
+ Ct, _ := strconv.ParseFloat(item.InspectValue2, 64)
|
|
1582
|
+
|
|
1583
|
+ a := math.Log((Ct/C0 - (0.008 * (float64(item.ActualTreatmentHour) + item.ActualTreatmentHours))))
|
|
1584
|
+ b := (4 - 3.5*(Ct/C0)) * ((item.ActualUltrafiltration / 1000) / item.WeightAfter)
|
|
1585
|
+ c := -a + b
|
|
1586
|
+
|
|
1587
|
+ // 格式化输出,保留5位小数
|
|
1588
|
+ valueFormatted := fmt.Sprintf("%.5f", c)
|
|
1589
|
+
|
|
1590
|
+ ins8.InspectValue = valueFormatted
|
|
1591
|
+ writeDb.Create(&ins8)
|
|
1592
|
+
|
|
1593
|
+ var ins9 models.Inspection
|
|
1594
|
+ ins9.Status = 1
|
|
1595
|
+ ins9.PatientId = item.PatientID
|
|
1596
|
+ ins9.OrgId = 10677
|
|
1597
|
+ ins9.ItemName = "URR(%)"
|
|
1598
|
+ ins9.CreatedTime = time.Now().Unix()
|
|
1599
|
+ ins9.UpdatedTime = time.Now().Unix()
|
|
1600
|
+ ins9.ProjectName = "KT/V"
|
|
1601
|
+ ins9.InspectType = 3
|
|
1602
|
+ ins9.InspectDate = timestamp
|
|
1603
|
+ before, _ := strconv.ParseFloat(item.InspectValue1, 64)
|
|
1604
|
+ after, _ := strconv.ParseFloat(item.InspectValue2, 64)
|
|
1605
|
+ value2 := (((before - after) / before) * 100)
|
|
1606
|
+ rounded := math.Round(value2*100) / 100
|
|
1607
|
+ strValue6 := fmt.Sprintf("%f", rounded)
|
|
1608
|
+ ins9.InspectValue = strValue6
|
|
1609
|
+ ins9.ProjectId = 1014
|
|
1610
|
+ ins9.ItemId = 10951
|
|
1611
|
+ writeDb.Create(&ins9)
|
|
1612
|
+ }
|
|
1613
|
+}
|