123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- package service
-
- import (
- "XT_New/models"
- "github.com/jinzhu/gorm"
- )
-
- type ExportPatient struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- Name string `gorm:"column:name" json:"name" form:"name"`
- Lapseto int64 `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- IdCardNo string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
- XtCount int64 `gorm:"column:-" json:"xt_count" form:"xt_count"`
- SettleOrder []*SettleOrder `gorm:"ForeignKey:PatientID;AssociationForeignKey:ID" json:"orders"`
- }
-
- func (ExportPatient) TableName() string {
- return "xt_patients"
- }
-
- type SettleOrder struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
- OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
- MdtrtId string `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
- Number string `gorm:"column:number" json:"number" form:"number"`
- SetlId string `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
- Insutype string `gorm:"column:insutype" json:"insutype" form:"insutype"`
- SetlTime string `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
- MedfeeSumamt float64 `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
- FulamtOwnpayAmt float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
- OverlmtSelfPay float64 `gorm:"column:overlmt_self_pay" json:"overlmt_self_pay" form:"overlmt_self_pay"`
- PreselfpayAmt float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
- InscpScpAmt float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
- ActPayDedc float64 `gorm:"column:act_pay_dedc" json:"act_pay_dedc" form:"act_pay_dedc"`
- HifpPay float64 `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
- CvlservPay float64 `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
- PoolPropSelfpay float64 `gorm:"column:pool_prop_selfpay" json:"pool_prop_selfpay" form:"pool_prop_selfpay"`
- HifesPay float64 `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
- HifmiPay float64 `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
- HifobPay float64 `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
- MafPay float64 `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
- OthPay float64 `gorm:"column:oth_pay" json:"oth_pay" form:"oth_pay"`
- FundPaySumamt float64 `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
- PsnPartAmt float64 `gorm:"column:psn_part_amt" json:"psn_part_amt" form:"psn_part_amt"`
- AcctPay float64 `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
- PsnCashPay float64 `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
- HospPartAmt float64 `gorm:"column:hosp_part_amt" json:"hosp_part_amt" form:"hosp_part_amt"`
- IsMedicineInsurance int64 `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
- OrderInfo9919 []*OrderInfo9919 `gorm:"ForeignKey:OrderNumber;AssociationForeignKey:Number" json:"info"`
- }
-
- func (SettleOrder) TableName() string {
- return "his_order"
- }
-
- type OrderInfo9919 struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- OrderNumber string `gorm:"column:order_number" json:"order_number" form:"order_number"`
- UploadDate int64 `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
- AdviceId int64 `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
- DetItemFeeSumamt float64 `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
- Cnt float64 `gorm:"column:cnt" json:"cnt" form:"cnt"`
- Pric float64 `gorm:"column:pric" json:"pric" form:"pric"`
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
- PricUplmtAmt float64 `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
- SelfpayProp float64 `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
- FulamtOwnpayAmt float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
- OverlmtAmt float64 `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
- PreselfpayAmt float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
- BasMednFlag string `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
- MedChrgitmType string `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
- HiNegoDrugFlag string `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- Memo string `gorm:"column:memo" json:"memo" form:"memo"`
- FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
- InscpScpAmt float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
- DrtReimFlag string `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
- ListSpItemFlag string `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
- ChldMedcFlag string `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
- LmtUsedFlag string `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
- ChrgitmLv string `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
- OrderId int64 `gorm:"column:order_id" json:"order_id" form:"order_id"`
- ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
- Type int64 `gorm:"column:type" json:"type" form:"type"`
- ItemId int64 `gorm:"column:item_id" json:"item_id" form:"item_id"`
- SettleType int64 `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
- }
-
- func (OrderInfo9919) TableName() string {
- return "his_order_info"
- }
-
- func GetHisOrderDetailFor310(start_time string, end_time string, org_id int64) (patients []*ExportPatient, err error) {
- err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1 AND FROM_UNIXTIME(orders.ctime) >= ? AND FROM_UNIXTIME(orders.ctime) <= ? AND orders.user_org_id = ? AND orders.order_status = 2 and orders.insutype = 310", start_time, end_time, org_id).Preload("SettleOrder", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND setl_time >= ? AND setl_time <= ? AND user_org_id = ? AND order_status = 2 and insutype = 310", start_time, end_time, org_id).Preload("OrderInfo9919", "status = 1").Order("ctime")
- }).Where("p.status = 1 AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
-
- for _, item := range patients {
- var total int64
- readDb.Model(&models.DialysisOrder{}).Where("patient_id = ? AND status = 1 AND stage = 2 AND FROM_UNIXTIME(dialysis_date) <= ? AND FROM_UNIXTIME(dialysis_date) >= ?", item.ID, end_time, start_time).Count(&total)
- item.XtCount = total
-
- }
- return
- }
-
- func GetHisOrderDetailFor390(start_time string, end_time string, org_id int64) (patients []*ExportPatient, err error) {
- err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1 AND FROM_UNIXTIME(orders.ctime) >= ? AND FROM_UNIXTIME(orders.ctime) <= ? AND orders.user_org_id = ? AND orders.order_status = 2 and orders.insutype = 390", start_time, end_time, org_id).Preload("SettleOrder", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND setl_time >= ? AND setl_time <= ? AND user_org_id = ? AND order_status = 2 and insutype = 390", start_time, end_time, org_id).Preload("OrderInfo9919", "status = 1").Order("ctime")
- }).Where("p.status = 1 AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
- for _, item := range patients {
- var total int64
- readDb.Model(&models.DialysisOrder{}).Where("patient_id = ? AND status = 1 AND stage = 2 AND FROM_UNIXTIME(dialysis_date) <= ? AND FROM_UNIXTIME(dialysis_date) >= ?", item.ID, end_time, start_time).Count(&total)
- item.XtCount = total
-
- }
- return
- }
- func GetHisOrderByTime(patient_id int64, start_time string, end_time string) (order []models.HisOrder, err error) {
- err = readDb.Model(&models.HisOrder{}).Where("patient_id = ? AND status = 1 and order_status = 2 and FROM_UNIXTIME(settle_accounts_date) >= ? and FROM_UNIXTIME(settle_accounts_date) <= ?", patient_id, start_time+" 00:00:00", end_time+" 23:59:00").Find(&order).Error
- return
- }
-
- func GetBatchHisOrderInfoByNumber(order_number string) (order []models.BatchHisOrderInfo, err error) {
- err = readDb.Model(&models.BatchHisOrderInfo{}).Where("order_number = ? and status = 1", order_number).Find(&order).Error
- return
- }
|