Browse Source

医保对接

csx 3 years ago
parent
commit
c0daa9dac5

+ 20 - 4
controllers/common_api_controller.go View File

@@ -1102,6 +1102,8 @@ func (this *CommonApiController) GetNormData() {
1102 1102
 func (this *CommonApiController) GetFirstQuarter() {
1103 1103
 	orgid := this.GetAdminUserInfo().CurrentOrgId
1104 1104
 	lapseto, _ := this.GetInt64("lapseto")
1105
+	origin, _ := this.GetInt64("origin")
1106
+
1105 1107
 	fmt.Println("转归", lapseto)
1106 1108
 	startime := this.GetString("startime")
1107 1109
 
@@ -1116,17 +1118,17 @@ func (this *CommonApiController) GetFirstQuarter() {
1116 1118
 	entime := endDate.Unix()
1117 1119
 	fmt.Println("结束日期", entime)
1118 1120
 	//统计数值类型的数据
1119
-	count, err := service.GetQuarterTotalCount(orgid, statime, entime, lapseto)
1121
+	count, err := service.GetQuarterTotalCount(orgid, statime, entime, lapseto, origin)
1120 1122
 	//统计rang_type== 2
1121
-	countwo, _ := service.GetQuarterTotalCountTwo(orgid, statime, entime, lapseto)
1123
+	countwo, _ := service.GetQuarterTotalCountTwo(orgid, statime, entime, lapseto, origin)
1122 1124
 
1123 1125
 	//获取收缩压数据
1124
-	systolic, systolicTotal, parseDateErr := service.GetSystolicBloodPressure(orgid, statime, entime)
1126
+	systolic, systolicTotal, parseDateErr := service.GetSystolicBloodPressureTwo(orgid, statime, entime, lapseto, origin)
1125 1127
 	//统计收缩压合格的数据
1126 1128
 	//systolic, sysstandTotal, parseDateErr := service.GetStandSystolicBloodPressure(orgid, statime, entime)
1127 1129
 
1128 1130
 	//获取舒张压数据
1129
-	diastolic, diastotal, parseDateErr := service.GetDiastolicBloodPressure(orgid, statime, entime)
1131
+	diastolic, diastotal, parseDateErr := service.GetDiastolicBloodPressureTwo(orgid, statime, entime, lapseto, origin)
1130 1132
 	//获取合格舒张压数据
1131 1133
 	//diastolic, diasstandtotal, parseDateErr := service.GetDiastolicStandPressure(orgid, statime, entime)
1132 1134
 	normData, _ := service.GetNormData(orgid)
@@ -2142,3 +2144,17 @@ func (this *CommonApiController) GetRolloutCount() {
2142 2144
 		"rollout": rollout,
2143 2145
 	})
2144 2146
 }
2147
+
2148
+func (this *CommonApiController) GetCheckExamine() {
2149
+	//check_type, _ := this.GetInt64("check_type")
2150
+	//start_time, _ := this.GetInt64("start_time")
2151
+	//end_time, _ := this.GetInt64("end_time")
2152
+	//total, _ := service.GetAllPatientCount(this.GetAdminUserInfo().CurrentOrgId)
2153
+	//xcg_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 1)    //血常规
2154
+	//xysh_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 2)   //血液生化
2155
+	//ipth_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 3)   //全段甲状旁腺激素
2156
+	//xqtdb_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 4)  //血清铁蛋白和转铁蛋白饱和度
2157
+	//xqqbdb_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 5) //血清前白蛋白
2158
+	//cfydb_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 6)  //c反应蛋白
2159
+	//
2160
+}

+ 5 - 0
controllers/common_api_router.go View File

@@ -59,4 +59,9 @@ func CommonApiControllersRegisterRouters() {
59 59
 	beego.Router("/com/api/getreatmodelist", &CommonApiController{}, "Get:GetTreatModeList")
60 60
 	beego.Router("/com/api/getcountmodeid", &CommonApiController{}, "Get:GetCountModeId")
61 61
 	beego.Router("/com/api/getrolloutcount", &CommonApiController{}, "Get:GetRolloutCount")
62
+
63
+	beego.Router("/com/api/getrolloutcount", &CommonApiController{}, "Get:GetRolloutCount")
64
+
65
+	beego.Router("/com/api/getcheckexamine", &CommonApiController{}, "Get:GetCheckExamine")
66
+
62 67
 }

+ 39 - 0
controllers/his_api_controller.go View File

@@ -105,6 +105,27 @@ func HisManagerApiRegistRouters() {
105 105
 
106 106
 	beego.Router("/api/orders", &HisApiController{}, "get:GetAllOrder")
107 107
 
108
+	beego.Router("/api/psn/ncds/delete", &HisApiController{}, "post:DeleteNCDS")
109
+
110
+	beego.Router("/api/bailin/export", &PublicApiController{}, "get:GetBaiLinExportData")
111
+
112
+}
113
+
114
+func (c *PublicApiController) GetBaiLinExportData() {
115
+	data := service.GetBaiLinOrderData()
116
+	fmt.Println(len(data))
117
+	var new_data []*models.NewCustomHisOrder
118
+	for _, item := range data {
119
+		if item.NewCustomHisOrderInfo.NewCustomHisPrescriptionProject.ID != 0 {
120
+			new_data = append(new_data, item)
121
+		}
122
+
123
+	}
124
+	fmt.Println(len(new_data))
125
+
126
+	c.ServeSuccessJSON(map[string]interface{}{
127
+		"list": new_data,
128
+	})
108 129
 }
109 130
 
110 131
 func (c *HisApiController) GetHisUnChargePatientList() {
@@ -5660,6 +5681,10 @@ func (c *HisApiController) GetPrivateExpensesInfo() {
5660 5681
 	}
5661 5682
 
5662 5683
 	orderInfos = append(orderInfos, orderInfos_two...)
5684
+	if c.GetAdminUserInfo().CurrentOrgId != 10138 {
5685
+		orderInfos = append(orderInfos, orderInfos_three...)
5686
+
5687
+	}
5663 5688
 
5664 5689
 	patient, _ := service.GetPatientByID(org_id, order.PatientId)
5665 5690
 	c.ServeSuccessJSON(map[string]interface{}{
@@ -6067,3 +6092,17 @@ func DeleteDrugWarehosueInfo(advice models.HisDoctorAdviceInfo) (err error) {
6067 6092
 	}
6068 6093
 	return err
6069 6094
 }
6095
+
6096
+func (this *HisApiController) DeleteNCDS() {
6097
+	id, _ := this.GetInt64("id", 0)
6098
+	if id > 0 {
6099
+		service.DeletePsnNCDSRecordById(id)
6100
+		this.ServeSuccessJSON(map[string]interface{}{
6101
+			"msg": "删除成功",
6102
+		})
6103
+	} else {
6104
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRecordFailedException)
6105
+		return
6106
+	}
6107
+
6108
+}

+ 13 - 9
controllers/his_hospital_api_controller.go View File

@@ -197,6 +197,9 @@ func (c *HisHospitalApiController) GetHisHospitalChargePatientInfo() {
197 197
 	} else if order_status == 2 {
198 198
 		monthPrescriptions, _ = service.GetChargeMonthHisPrescriptionFour(admin.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, p_type)
199 199
 	}
200
+
201
+	settle_prescriptions, _ := service.GetSettleHisHospitalPrescription(admin.CurrentOrgId, patient_id, his_patient_id, his_patient_info.RecordDate)
202
+
200 203
 	case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
201 204
 	patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfoTwo(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
202 205
 	order, _ := service.GetNewHisOrder(admin.CurrentOrgId, his_patient_info.Number, patient_id)
@@ -205,15 +208,16 @@ func (c *HisHospitalApiController) GetHisHospitalChargePatientInfo() {
205 208
 	department, _ := service.GetAllDepartMent(admin.CurrentOrgId)
206 209
 
207 210
 	c.ServeSuccessJSON(map[string]interface{}{
208
-		"his_info":            his_patient_info,
209
-		"xt_info":             xt_patient_info,
210
-		"prescription":        prescriptions,
211
-		"case_history":        case_history,
212
-		"info":                patientPrescriptionInfo,
213
-		"month_prescriptions": monthPrescriptions,
214
-		"order":               order,
215
-		"doctors":             doctors,
216
-		"department":          department,
211
+		"his_info":             his_patient_info,
212
+		"xt_info":              xt_patient_info,
213
+		"prescription":         prescriptions,
214
+		"case_history":         case_history,
215
+		"info":                 patientPrescriptionInfo,
216
+		"month_prescriptions":  monthPrescriptions,
217
+		"order":                order,
218
+		"doctors":              doctors,
219
+		"department":           department,
220
+		"settle_prescriptions": settle_prescriptions,
217 221
 	})
218 222
 	return
219 223
 

+ 12 - 5
controllers/his_project_api_controller.go View File

@@ -1218,15 +1218,18 @@ func (this *HisProjectApiController) GetDoctorAdvicePrint() {
1218 1218
 	his, _ := service.GetLastHisPatient(patient_id, adminUserInfo.CurrentOrgId)
1219 1219
 	//prescriptionInfo, _ := service.GetPrscriptionInfo(patient_id, recordDateTime)
1220 1220
 	hisPatient, _ := service.GetHisPatientById(patient_id)
1221
+	hisHospitalRecord, _ := service.GetLastHospitalRecordTwo(patient_id, adminUserInfo.CurrentOrgId)
1222
+
1221 1223
 	if err != nil {
1222 1224
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1223 1225
 		return
1224 1226
 	}
1225 1227
 	this.ServeSuccessJSON(map[string]interface{}{
1226
-		"advicePrint": advicePrint,
1227
-		"projectlist": projectlist,
1228
-		"hisPatient":  hisPatient,
1229
-		"his":         his,
1228
+		"advicePrint":       advicePrint,
1229
+		"projectlist":       projectlist,
1230
+		"hisPatient":        hisPatient,
1231
+		"his":               his,
1232
+		"hisHospitalRecord": hisHospitalRecord,
1230 1233
 	})
1231 1234
 }
1232 1235
 
@@ -1533,12 +1536,16 @@ func (this *HisProjectApiController) GetHisPatientDetail() {
1533 1536
 	patient_id, _ := this.GetInt64("patient_id")
1534 1537
 
1535 1538
 	hisPatient, err := service.GetHisPatientById(patient_id)
1539
+	//service.GetLastHospitalRecordTwo(patient_id,this.GetAdminUserInfo().CurrentOrgId)
1540
+	hisHospitalRecord, _ := service.GetLastHospitalRecordTwo(patient_id, this.GetAdminUserInfo().CurrentOrgId)
1541
+
1536 1542
 	if err != nil {
1537 1543
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1538 1544
 		return
1539 1545
 	}
1540 1546
 	this.ServeSuccessJSON(map[string]interface{}{
1541
-		"hisPatient": hisPatient,
1547
+		"hisPatient":        hisPatient,
1548
+		"hisHospitalRecord": hisHospitalRecord,
1542 1549
 	})
1543 1550
 }
1544 1551
 

+ 4 - 3
controllers/new_mobile_api_controllers/new_common_api_controller.go View File

@@ -534,6 +534,8 @@ func (this *NewCommonApiController) GetMobileFirstQuarter() {
534 534
 	adminUser := this.GetMobileAdminUserInfo()
535 535
 	orgid := adminUser.Org.Id
536 536
 	lapseto, _ := this.GetInt64("lapseto")
537
+	origin, _ := this.GetInt64("origin")
538
+
537 539
 	fmt.Println("转归", lapseto)
538 540
 	startime := this.GetString("startime")
539 541
 
@@ -547,13 +549,12 @@ func (this *NewCommonApiController) GetMobileFirstQuarter() {
547 549
 	endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
548 550
 	entime := endDate.Unix()
549 551
 
550
-	count, err := service.GetQuarterTotalCount(orgid, statime, entime, lapseto)
551
-	countwo, _ := service.GetQuarterTotalCountTwo(orgid, statime, entime, lapseto)
552
+	count, err := service.GetQuarterTotalCount(orgid, statime, entime, lapseto, origin)
553
+	countwo, _ := service.GetQuarterTotalCountTwo(orgid, statime, entime, lapseto, origin)
552 554
 	//获取收缩压数据
553 555
 	systolic, systolicTotal, parseDateErr := service.GetSystolicBloodPressure(orgid, statime, entime)
554 556
 	//统计收缩压合格的数据
555 557
 	//systolic, sysstandTotal, parseDateErr := service.GetStandSystolicBloodPressure(orgid, statime, entime)
556
-
557 558
 	//获取舒张压数据
558 559
 	diastolic, diastotal, parseDateErr := service.GetDiastolicBloodPressure(orgid, statime, entime)
559 560
 	//获取合格舒张压数据

+ 4 - 0
enums/error_code.go View File

@@ -242,6 +242,8 @@ const ( // ErrorCode
242 242
 	ErrorCodeHospitalNoExistDataException = 30009
243 243
 
244 244
 	ErrorCodeHospitalExistDataException = 300010
245
+
246
+	ErrorCodeRecordFailedException = 300011
245 247
 )
246 248
 
247 249
 var ErrCodeMsgs = map[int]string{
@@ -473,6 +475,8 @@ var ErrCodeMsgs = map[int]string{
473 475
 	ErrorCodeHospitalNoExistDataException: "请先办理出院才能进行结算",
474 476
 
475 477
 	ErrorCodeHospitalExistDataException: "该患者已经入院,请选办理出院结算后再进行办理入院操作",
478
+
479
+	ErrorCodeRecordFailedException: "记录不存在",
476 480
 }
477 481
 
478 482
 type SGJError struct {

+ 21 - 0
models/his_charge_models.go View File

@@ -218,3 +218,24 @@ type HisFapiaoRecord struct {
218 218
 func (HisFapiaoRecord) TableName() string {
219 219
 	return "his_fapiao_record"
220 220
 }
221
+
222
+type GdybPsnNcdsRecord struct {
223
+	ID            int64  `gorm:"column:id" json:"id" form:"id"`
224
+	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
225
+	PatientId     int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
226
+	PsnNo         string `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
227
+	Ctime         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
228
+	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
229
+	Status        int64  `gorm:"column:status" json:"status" form:"status"`
230
+	IsCancel      int64  `gorm:"column:is_cancel" json:"is_cancel" form:"is_cancel"`
231
+	TrtDclaDetlSn string `gorm:"column:trt_dcla_detl_sn" json:"trt_dcla_detl_sn" form:"trt_dcla_detl_sn"`
232
+	DoctorId      int64  `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
233
+	DepartmentId  int64  `gorm:"column:department_id" json:"department_id" form:"department_id"`
234
+	Insutype      string `gorm:"column:insutype" json:"insutype" form:"insutype"`
235
+	SickType      int64  `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
236
+	OrgName       string `gorm:"column:org_name" json:"org_name" form:"org_name"`
237
+}
238
+
239
+func (GdybPsnNcdsRecord) TableName() string {
240
+	return "gdyb_psn_ncds_record"
241
+}

+ 179 - 0
models/his_models.go View File

@@ -1635,3 +1635,182 @@ type HisStockPriceConfig struct {
1635 1635
 func (HisStockPriceConfig) TableName() string {
1636 1636
 	return "his_stock_price_config"
1637 1637
 }
1638
+
1639
+type NewCustomHisOrder struct {
1640
+	ID                    int64     `gorm:"column:id" json:"id" form:"id"`
1641
+	UserOrgId             int64     `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1642
+	HisPatientId          int64     `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
1643
+	SettleAccountsDate    int64     `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
1644
+	Ctime                 int64     `gorm:"column:ctime" json:"ctime" form:"ctime"`
1645
+	Mtime                 int64     `gorm:"column:mtime" json:"mtime" form:"mtime"`
1646
+	Status                int64     `gorm:"column:status" json:"status" form:"status"`
1647
+	Number                string    `gorm:"column:number" json:"number" form:"number"`
1648
+	PatientId             int64     `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1649
+	Infcode               int64     `gorm:"column:infcode" json:"infcode" form:"infcode"`
1650
+	WarnMsg               string    `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
1651
+	Cainfo                string    `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
1652
+	ErrMsg                string    `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
1653
+	RespondTime           string    `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
1654
+	InfRefmsgid           string    `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
1655
+	OrderStatus           int64     `gorm:"column:order_status" json:"order_status" form:"order_status"`
1656
+	MdtrtId               string    `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
1657
+	SetlId                string    `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
1658
+	PsnNo                 string    `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
1659
+	PsnName               string    `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
1660
+	PsnCertType           string    `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
1661
+	Certno                string    `gorm:"column:certno" json:"certno" form:"certno"`
1662
+	Gend                  string    `gorm:"column:gend" json:"gend" form:"gend"`
1663
+	Naty                  string    `gorm:"column:naty" json:"naty" form:"naty"`
1664
+	Brdy                  time.Time `gorm:"column:brdy" json:"brdy" form:"brdy"`
1665
+	Age                   float64   `gorm:"column:age" json:"age" form:"age"`
1666
+	Insutype              string    `gorm:"column:insutype" json:"insutype" form:"insutype"`
1667
+	PsnType               string    `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
1668
+	CvlservFlag           string    `gorm:"column:cvlserv_flag" json:"cvlserv_flag" form:"cvlserv_flag"`
1669
+	SetlTime              string    `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
1670
+	MdtrtCertType         string    `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
1671
+	MedType               string    `gorm:"column:med_type" json:"med_type" form:"med_type"`
1672
+	MedfeeSumamt          float64   `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
1673
+	FulamtOwnpayAmt       float64   `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
1674
+	OverlmtSelfPay        float64   `gorm:"column:overlmt_self_pay" json:"overlmt_self_pay" form:"overlmt_self_pay"`
1675
+	PreselfpayAmt         float64   `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
1676
+	InscpScpAmt           float64   `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
1677
+	ActPayDedc            float64   `gorm:"column:act_pay_dedc" json:"act_pay_dedc" form:"act_pay_dedc"`
1678
+	HifpPay               float64   `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
1679
+	CvlservPay            float64   `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
1680
+	PoolPropSelfpay       float64   `gorm:"column:pool_prop_selfpay" json:"pool_prop_selfpay" form:"pool_prop_selfpay"`
1681
+	HifesPay              float64   `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
1682
+	HifmiPay              float64   `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
1683
+	HifobPay              float64   `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
1684
+	MafPay                float64   `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
1685
+	OthPay                float64   `gorm:"column:oth_pay" json:"oth_pay" form:"oth_pay"`
1686
+	FundPaySumamt         float64   `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
1687
+	PsnPartAmt            float64   `gorm:"column:psn_part_amt" json:"psn_part_amt" form:"psn_part_amt"`
1688
+	AcctPay               float64   `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
1689
+	PsnCashPay            float64   `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
1690
+	HospPartAmt           float64   `gorm:"column:hosp_part_amt" json:"hosp_part_amt" form:"hosp_part_amt"`
1691
+	Balc                  float64   `gorm:"column:balc" json:"balc" form:"balc"`
1692
+	AcctMulaidPay         float64   `gorm:"column:acct_mulaid_pay" json:"acct_mulaid_pay" form:"acct_mulaid_pay"`
1693
+	MedinsSetlId          string    `gorm:"column:medins_setl_id" json:"medins_setl_id" form:"medins_setl_id"`
1694
+	ClrOptins             string    `gorm:"column:clr_optins" json:"clr_optins" form:"clr_optins"`
1695
+	ClrWay                string    `gorm:"column:clr_way" json:"clr_way" form:"clr_way"`
1696
+	ClrType               string    `gorm:"column:clr_type" json:"clr_type" form:"clr_type"`
1697
+	SetlDetail            string    `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
1698
+	IsMedicineInsurance   int64     `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
1699
+	PayWay                int64     `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
1700
+	PayPrice              float64   `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
1701
+	PayCardNo             string    `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
1702
+	DiscountPrice         float64   `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
1703
+	PreferentialPrice     float64   `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
1704
+	RealityPrice          float64   `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
1705
+	FoundPrice            float64   `gorm:"column:found_price" json:"found_price" form:"found_price"`
1706
+	MedicalInsurancePrice float64   `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
1707
+	PrivatePrice          float64   `gorm:"column:private_price" json:"private_price" form:"private_price"`
1708
+	DepartmentName        string    `gorm:"-" json:"department_name" form:"department_name"`
1709
+	DoctorName            string    `gorm:"-" json:"doctor_name" form:"doctor_name"`
1710
+	Creator               int64     `gorm:"column:creator" json:"creator" form:"creator"`
1711
+	PType                 int64     `gorm:"column:p_type" json:"p_type" form:"p_type"`
1712
+
1713
+	FaPiaoCode   string `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
1714
+	FaPiaoNumber string `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`
1715
+
1716
+	SettleType            int64                 `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
1717
+	SettleStartTime       int64                 `gorm:"column:settle_start_time" json:"settle_start_time" form:"settle_start_time"`
1718
+	SettleEndTime         int64                 `gorm:"column:settle_end_time" json:"settle_end_time" form:"settle_end_time"`
1719
+	NewCustomHisOrderInfo NewCustomHisOrderInfo `gorm:"ForeignKey:Number;AssociationForeignKey:OrderNumber" json:"order_info"`
1720
+	Patients              Patients              `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
1721
+}
1722
+
1723
+func (NewCustomHisOrder) TableName() string {
1724
+	return "his_order"
1725
+}
1726
+
1727
+type NewCustomHisOrderInfo struct {
1728
+	ID                              int64                           `gorm:"column:id" json:"id" form:"id"`
1729
+	OrderNumber                     string                          `gorm:"column:order_number" json:"order_number" form:"order_number"`
1730
+	UploadDate                      int64                           `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
1731
+	AdviceId                        int64                           `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
1732
+	DetItemFeeSumamt                float64                         `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
1733
+	Cnt                             float64                         `gorm:"column:cnt" json:"cnt" form:"cnt"`
1734
+	Pric                            float64                         `gorm:"column:pric" json:"pric" form:"pric"`
1735
+	PatientId                       int64                           `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1736
+	PricUplmtAmt                    float64                         `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
1737
+	SelfpayProp                     float64                         `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
1738
+	FulamtOwnpayAmt                 float64                         `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
1739
+	OverlmtAmt                      float64                         `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
1740
+	PreselfpayAmt                   float64                         `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
1741
+	BasMednFlag                     string                          `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
1742
+	MedChrgitmType                  string                          `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
1743
+	HiNegoDrugFlag                  string                          `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
1744
+	Status                          int64                           `gorm:"column:status" json:"status" form:"status"`
1745
+	Memo                            string                          `gorm:"column:memo" json:"memo" form:"memo"`
1746
+	FeedetlSn                       string                          `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1747
+	Mtime                           int64                           `gorm:"column:mtime" json:"mtime" form:"mtime"`
1748
+	InscpScpAmt                     float64                         `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
1749
+	DrtReimFlag                     string                          `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
1750
+	Ctime                           int64                           `gorm:"column:ctime" json:"ctime" form:"ctime"`
1751
+	ListSpItemFlag                  string                          `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
1752
+	ChldMedcFlag                    string                          `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
1753
+	LmtUsedFlag                     string                          `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
1754
+	ChrgitmLv                       string                          `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
1755
+	UserOrgId                       int64                           `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1756
+	HisPatientId                    int64                           `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
1757
+	OrderId                         int64                           `gorm:"column:order_id" json:"order_id" form:"order_id"`
1758
+	ProjectId                       int64                           `gorm:"column:project_id" json:"project_id" form:"project_id"`
1759
+	Type                            int64                           `gorm:"column:type" json:"type" form:"type"`
1760
+	ItemId                          int64                           `gorm:"column:item_id" json:"item_id" form:"item_id"`
1761
+	NewCustomHisPrescriptionProject NewCustomHisPrescriptionProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
1762
+	//HisDoctorAdviceInfo    HisDoctorAdviceInfo    `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"advice"`
1763
+}
1764
+
1765
+func (NewCustomHisOrderInfo) TableName() string {
1766
+	return "his_order_info"
1767
+}
1768
+
1769
+type NewCustomHisPrescriptionProject struct {
1770
+	ID                 int64      `gorm:"column:id" json:"id" form:"id"`
1771
+	ProjectId          int64      `gorm:"column:project_id" json:"project_id" form:"project_id"`
1772
+	Price              float64    `gorm:"column:price" json:"price" form:"price"`
1773
+	UserOrgId          int64      `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1774
+	Status             int64      `gorm:"column:status" json:"status" form:"status"`
1775
+	Ctime              int64      `gorm:"column:ctime" json:"ctime" form:"ctime"`
1776
+	Mtime              int64      `gorm:"column:mtime" json:"mtime" form:"mtime"`
1777
+	PatientId          int64      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1778
+	HisPatientId       int64      `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
1779
+	RecordDate         int64      `gorm:"column:record_date" json:"record_date" form:"record_date"`
1780
+	PrescriptionId     int64      `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
1781
+	Count              string     `gorm:"column:count" json:"count" form:"count"`
1782
+	FeedetlSn          string     `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1783
+	MedListCodg        string     `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
1784
+	SingleDose         string     `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
1785
+	DeliveryWay        string     `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
1786
+	ExecutionFrequency string     `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
1787
+	Day                string     `gorm:"column:day" json:"day" form:"day"`
1788
+	HisProject         HisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
1789
+	GoodInfo           GoodInfo   `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"good_info"`
1790
+
1791
+	Remark string `gorm:"column:remark" json:"remark" form:"remark"`
1792
+	Unit   string `gorm:"column:unit" json:"unit" form:"unit"`
1793
+	Type   int64  `gorm:"column:type" json:"type" form:"type"`
1794
+
1795
+	Doctor         int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
1796
+	ExecutionTime  int64 `gborm:"column:execution_time" json:"execution_time" form:"execution_time"`
1797
+	ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
1798
+	ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
1799
+	CheckTime      int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
1800
+	CheckState     int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
1801
+	Checker        int64 `gorm:"column:checker" json:"checker" form:"checker"`
1802
+	StartTime      int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
1803
+	TeamId         int64 `gorm:"column:team_id" json:"team_id" form:"team_id"`
1804
+
1805
+	XtHisProjectTeam XtHisProjectTeam `gorm:"ForeignKey:TeamId;AssociationForeignKey:ID" json:"team"`
1806
+
1807
+	FrequencyType int64        `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
1808
+	DayCount      int64        `gorm:"column:day_count" json:"day_count" form:"day_count"`
1809
+	WeekDay       string       `gorm:"column:week_day" json:"week_day" form:"week_day"`
1810
+	IsCheckTeam   int64        `gorm:"-" json:"is_check_team" form:"is_check_team"`
1811
+	HisOrderInfo  HisOrderInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"order_info"`
1812
+}
1813
+
1814
+func (NewCustomHisPrescriptionProject) TableName() string {
1815
+	return "his_prescription_project"
1816
+}

+ 92 - 39
service/common_service.go View File

@@ -497,8 +497,6 @@ func GetDialysisList(startime int64, endtime int64, page int64, limit int64, org
497 497
 
498 498
 	db := XTReadDB().Table("xt_dialysis_order as o").Where("o.status = 1")
499 499
 
500
-	d := XTReadDB().Table("xt_patients as p")
501
-	fmt.Println(d)
502 500
 	if orgid > 0 {
503 501
 		db = db.Where("o.user_org_id = ?", orgid)
504 502
 	}
@@ -509,7 +507,7 @@ func GetDialysisList(startime int64, endtime int64, page int64, limit int64, org
509 507
 		db = db.Where("o.dialysis_date<=?", endtime)
510 508
 	}
511 509
 	offset := (page - 1) * limit
512
-	err = db.Group("s.patient_id,s.mode_id").Select("s.mode_id,o.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").Joins("left join xt_dialysis_prescription as s on s.patient_id = o.patient_id AND s.record_date = o.dialysis_date AND s.mode_id > 0").Joins("left join  xt_patients as p on p.id = o.patient_id").Where("s.status = 1").Count(&total).Offset(offset).Limit(limit).Scan(&order).Error
510
+	err = db.Group("s.patient_id,s.mode_id").Select("s.mode_id,o.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").Joins("join xt_dialysis_prescription as s on s.patient_id = o.patient_id AND s.record_date = o.dialysis_date AND s.mode_id > 0").Joins("join  xt_patients as p on p.id = o.patient_id").Where("s.status = 1").Count(&total).Offset(offset).Limit(limit).Scan(&order).Error
513 511
 	return order, total, err
514 512
 
515 513
 }
@@ -526,16 +524,14 @@ func GetAllDialysisList(startime int64, endtime int64, orgid int64) (order []*mo
526 524
 	if endtime > 0 {
527 525
 		db = db.Where("o.dialysis_date<=?", endtime)
528 526
 	}
529
-	err = db.Group("s.patient_id,s.mode_id").Select("s.mode_id,s.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").Joins("left join xt_dialysis_prescription as s on s.patient_id = o.patient_id AND s.record_date = o.dialysis_date AND s.mode_id > 0").Joins("left join xt_patients as p on p.id = o.patient_id").Where("s.status = 1 ").Scan(&order).Error
527
+	err = db.Group("s.patient_id,s.mode_id").Select("s.mode_id,s.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").Joins("join xt_dialysis_prescription as s on s.patient_id = o.patient_id AND s.record_date = o.dialysis_date AND s.mode_id > 0").Joins("join xt_patients as p on p.id = o.patient_id").Where("s.status = 1 ").Scan(&order).Error
530 528
 	return order, err
531 529
 }
532 530
 
533 531
 func GetDialysisPatientList(startime int64, endtime int64, page int64, limit int64, orgid int64) (order []*models.BloodDialysisOrder, total int64, err error) {
534 532
 
535 533
 	db := XTReadDB().Table("xt_dialysis_order as o").Where("o.status = 1")
536
-	if orgid > 0 {
537
-		db = db.Where("o.user_org_id = ?", orgid)
538
-	}
534
+	db = db.Where("o.user_org_id = ?", orgid)
539 535
 	if startime > 0 {
540 536
 		db = db.Where("o.dialysis_date>=?", startime)
541 537
 	}
@@ -543,7 +539,7 @@ func GetDialysisPatientList(startime int64, endtime int64, page int64, limit int
543 539
 		db = db.Where("o.dialysis_date<=?", endtime)
544 540
 	}
545 541
 	offset := (page - 1) * limit
546
-	err = db.Group("s.patient_id").Select("s.mode_id,o.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").Joins("left join xt_dialysis_prescription as s on s.patient_id = o.patient_id AND s.record_date = o.dialysis_date AND s.mode_id > 0").Joins("left join  xt_patients as p on p.id = o.patient_id").Where("s.status =1 ").Count(&total).Offset(offset).Limit(limit).Scan(&order).Error
542
+	err = db.Group("s.patient_id").Select("s.mode_id,o.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").Joins("join xt_dialysis_prescription as s on s.patient_id = o.patient_id AND s.record_date = o.dialysis_date AND s.mode_id > 0 AND s.status =1").Joins("join  xt_patients as p on p.id = o.patient_id").Count(&total).Offset(offset).Limit(limit).Scan(&order).Error
547 543
 	return order, total, err
548 544
 }
549 545
 
@@ -644,9 +640,9 @@ func GetTreatList(orgid int64, startime int64, endtime int64, lapseto int64) (tt
644 640
 	if endtime > 0 {
645 641
 		db = db.Where("o.dialysis_date<=?", endtime)
646 642
 	}
647
-	if lapseto == 0 {
648
-		db = db.Where("p.lapseto = 1 or p.lapseto = 2")
649
-	}
643
+	//if lapseto == 0 {
644
+	//	db = db.Where("p.lapseto = 1 or p.lapseto = 2")
645
+	//}
650 646
 	if lapseto > 0 {
651 647
 		db = db.Where("p.lapseto = ?", lapseto)
652 648
 	}
@@ -659,7 +655,7 @@ func GetStatistics(orgID int64, startime int64, endtime int64, modeID int64) (dt
659 655
 	sql := "s.mode_id,from_unixtime(o.dialysis_date, '%Y%m%d') as date, count(o.dialysis_date) as number"
660 656
 	datesql := " o.dialysis_date as date"
661 657
 	group := "from_unixtime(o.dialysis_date, '%Y%m%d')"
662
-	db = db.Table(" xt_dialysis_order AS o").Joins("join xt_dialysis_prescription as s on o.patient_id = s.patient_id AND s.mode_id > 0").Where("s.record_date = o.dialysis_date and s.status =1")
658
+	db = db.Table(" xt_dialysis_order AS o").Joins("join xt_dialysis_prescription as s on o.patient_id = s.patient_id AND o.dialysis_date = s.record_date AND s.mode_id > 0")
663 659
 	if orgID > 0 {
664 660
 		db = db.Where("o.user_org_id = ?", orgID)
665 661
 	}
@@ -674,7 +670,7 @@ func GetStatistics(orgID int64, startime int64, endtime int64, modeID int64) (dt
674 670
 	}
675 671
 	db = db.Where("o.status=1")
676 672
 
677
-	err = db.Select("s.mode_id, count(s.mode_id) as number").Group("s.mode_id").Order("s.mode_id asc").Find(&ttd).Error
673
+	err = db.Select("s.mode_id, count(s.mode_id) as number").Order("s.mode_id asc").Find(&ttd).Error
678 674
 	if err != nil {
679 675
 		return
680 676
 	}
@@ -871,12 +867,6 @@ func GetPatientListInfo(orgid int64, startime int64, endtime int64, limit int64,
871 867
 func GetPatientDetailCheck(id int64, orgid int64, startime int64, endtime int64) (projectCounts []*models.PatientInspectionProjectCount, err error) {
872 868
 
873 869
 	db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
874
-	table := XTReadDB().Table("xt_inspection_reference as r")
875
-	fmt.Println(table)
876
-	d := XTReadDB().Table("xt_check_configuration as t").Where("t.status = 1")
877
-	pa := XTReadDB().Table("xt_patients as s")
878
-	fmt.Println(pa)
879
-	fmt.Println(d)
880 870
 	if id > 0 {
881 871
 		db = db.Where("s.id  = ?", id)
882 872
 	}
@@ -983,15 +973,10 @@ func GetFirstQuarter(orgid int64, startime int64, endtime int64) (inspection []*
983 973
 	return inspection, err
984 974
 }
985 975
 
986
-func GetQuarterTotalCount(orgid int64, startime int64, endtime int64, lapseto int64) (inspection []*models.VmPatientInspectionTwo, err error) {
976
+func GetQuarterTotalCount(orgid int64, startime int64, endtime int64, lapseto int64, origin int64) (inspection []*models.VmPatientInspectionTwo, err error) {
987 977
 	fmt.Println(lapseto)
978
+	fmt.Println(origin)
988 979
 	db := XTReadDB().Table("xt_inspection as x ").Where("x.status = 1")
989
-	table := XTReadDB().Table("xt_inspection_reference as r")
990
-	fmt.Println(table)
991
-	//d := XTReadDB().Table("xt_patients as s")
992
-	//fmt.Println(d)
993
-	q := XTReadDB().Table("x.xt_quality_control_standard as q")
994
-	fmt.Println(q)
995 980
 	if orgid > 0 {
996 981
 		db = db.Where("x.org_id = ? and x.inspect_value+0 <> 0 and r.range_type = 1 and q.user_org_id = ? and q.is_status = 1", orgid, orgid)
997 982
 	}
@@ -1001,23 +986,21 @@ func GetQuarterTotalCount(orgid int64, startime int64, endtime int64, lapseto in
1001 986
 	if endtime > 0 {
1002 987
 		db = db.Where("x.inspect_date <=?", endtime)
1003 988
 	}
1004
-	//if lapseto == 0 {
1005
-	//	db = db.Where("s.lapseto = 1 or s.lapseto = 2")
1006
-	//}
1007
-	//if lapseto > 0 {
1008
-	//	db = db.Where("s.lapseto = ?", lapseto)
1009
-	//}
989
+	if lapseto > 0 {
990
+		fmt.Println("11111")
991
+		db = db.Joins("join xt_patients as p On p.id = x.patient_id AND p.lapseto = ?", lapseto)
992
+	}
993
+	if origin > 0 {
994
+		fmt.Println("22222")
995
+
996
+		db = db.Joins("join xt_patients as p On p.id = x.patient_id AND p.source = ?", origin)
997
+	}
1010 998
 	err = db.Group("x.item_id").Select("sum(case when x.inspect_date >=? and x.inspect_date<=? then 1 else 0 end) as total,sum(case when x.inspect_value+0>=q.min_range+0 and x.inspect_value +0 <= q.large_range+0 and x.inspect_date >=? and x.inspect_date <=? then 1 else 0 end) as count,x.item_id,q.sort", startime, endtime, startime, endtime).Joins("left join xt_inspection_reference as r on ( r.item_id = x.item_id AND r.org_id > 0) OR ( x.item_id = r.id AND r.org_id = 0 ) ").Joins("left join xt_quality_control_standard as q on q.inspection_minor = x.item_id").Scan(&inspection).Error
1011 999
 	return inspection, err
1012 1000
 }
1013 1001
 
1014
-func GetQuarterTotalCountTwo(orgid int64, startime int64, endtime int64, lapseto int64) (inspection []*models.VmPatientInspectionTwo, err error) {
1015
-	fmt.Println(lapseto)
1002
+func GetQuarterTotalCountTwo(orgid int64, startime int64, endtime int64, lapseto int64, origin int64) (inspection []*models.VmPatientInspectionTwo, err error) {
1016 1003
 	db := XTReadDB().Table("xt_inspection as x ").Where("x.status = 1")
1017
-	table := XTReadDB().Table("xt_inspection_reference as r")
1018
-	fmt.Println(table)
1019
-	//d := XTReadDB().Table("xt_patients as s")
1020
-	//fmt.Println(d)
1021 1004
 	q := XTReadDB().Table("x.xt_quality_control_standard as q")
1022 1005
 	fmt.Println(q)
1023 1006
 	if orgid > 0 {
@@ -1029,6 +1012,13 @@ func GetQuarterTotalCountTwo(orgid int64, startime int64, endtime int64, lapseto
1029 1012
 	if endtime > 0 {
1030 1013
 		db = db.Where("x.inspect_date <=?", endtime)
1031 1014
 	}
1015
+
1016
+	if lapseto > 0 {
1017
+		db = db.Joins("join xt_patients as p On p.id = x.patient_id AND p.lapseto = ?", lapseto)
1018
+	}
1019
+	if origin > 0 {
1020
+		db = db.Joins("join xt_patients as p On p.id = x.patient_id AND p.source = ?", origin)
1021
+	}
1032 1022
 	//if lapseto == 0 {
1033 1023
 	//	db = db.Where("s.lapseto = 1 or s.lapseto = 2")
1034 1024
 	//}
@@ -2858,7 +2848,20 @@ func GetSystolicBloodPressure(orgid int64, startime int64, endtime int64) (recor
2858 2848
 	return record, total, err
2859 2849
 }
2860 2850
 
2861
-func GetStandSystolicBloodPressure(orgid int64, startime int64, endtime int64) (record []*models.XTMonitoringRecord, total int64, err error) {
2851
+func GetSystolicBloodPressureTwo(orgid int64, startime int64, endtime int64, lapseto int64, origin int64) (record []*models.VmMonitoringRecord, total int64, err error) {
2852
+
2853
+	db := XTReadDB().Table("xt_monitoring_record as x")
2854
+	if lapseto > 0 {
2855
+		db = db.Joins("join xt_patients as p on p.id = x.patient_id AND p.lapseto = ?", lapseto)
2856
+	}
2857
+	if origin > 0 {
2858
+		db = db.Joins("join xt_patients as p on p.id = x.patient_id AND p.source = ?", origin)
2859
+	}
2860
+	err = db.Select("x.id,x.systolic_blood_pressure").Where("x.user_org_id = ? and x.monitoring_date >=? and x.monitoring_date<=? and x.status = 1 and x.systolic_blood_pressure <> 0", orgid, startime, endtime).Group("x.monitoring_date,x.patient_id").Count(&total).Scan(&record).Error
2861
+	return record, total, err
2862
+}
2863
+
2864
+func GetStandSystolicBloodPressure(orgid int64, startime int64, endtime int64, lapseto int64, origin int64) (record []*models.XTMonitoringRecord, total int64, err error) {
2862 2865
 
2863 2866
 	db := XTReadDB().Table("xt_monitoring_record as x").Where("x.status = 1")
2864 2867
 	err = db.Select("x.id,s.sort").Joins("left join xt_quality_control_standard as s on s.user_org_id = x.user_org_id").Where("s.status = 1 and s.is_status = 0 and s.user_org_id = ? and x.user_org_id =? and x.monitoring_date>=? and x.monitoring_date <=? and s.inspection_minor = -1 and s.inspection_major = 0 and x.systolic_blood_pressure <> 0 and x.systolic_blood_pressure +0 >= s.min_range +0 and x.systolic_blood_pressure +0 <= s.large_range +0", orgid, orgid, startime, endtime).Group("x.monitoring_date,x.patient_id").Count(&total).Scan(&record).Error
@@ -2872,6 +2875,18 @@ func GetDiastolicBloodPressure(orgid int64, startime int64, endtime int64) (reco
2872 2875
 	return record, total, err
2873 2876
 }
2874 2877
 
2878
+func GetDiastolicBloodPressureTwo(orgid int64, startime int64, endtime int64, lapseto int64, origin int64) (record []*models.VmMonitoringRecord, total int64, err error) {
2879
+	db := XTReadDB().Table("xt_monitoring_record as x")
2880
+	if lapseto > 0 {
2881
+		db = db.Joins("join xt_patients as p on p.id = x.patient_id AND p.lapseto = ?", lapseto)
2882
+	}
2883
+	if origin > 0 {
2884
+		db = db.Joins("join xt_patients as p on p.id = x.patient_id AND p.source = ?", origin)
2885
+	}
2886
+	err = db.Select("x.id,x.diastolic_blood_pressure").Where("x.user_org_id = ? and x.monitoring_date >=? and x.monitoring_date<=? and x.status = 1 and x.diastolic_blood_pressure <> 0", orgid, startime, endtime).Group("x.monitoring_date,x.patient_id").Count(&total).Scan(&record).Error
2887
+	return record, total, err
2888
+}
2889
+
2875 2890
 func GetDiastolicStandPressure(orgid int64, startime int64, endtime int64) (record []*models.XTMonitoringRecord, total int64, err error) {
2876 2891
 	db := XTReadDB().Table("xt_monitoring_record as x").Where("x.status = 1")
2877 2892
 	err = db.Select("x.id,s.sort").Joins("left join xt_quality_control_standard as s on s.user_org_id = x.user_org_id").Where("s.status = 1 and s.is_status = 0 and s.user_org_id = ? and x.user_org_id =? and x.monitoring_date>=? and x.monitoring_date <=? and s.inspection_minor = -2 and s.inspection_major = 0 and x.diastolic_blood_pressure <> 0 and x.diastolic_blood_pressure +0 >= s.min_range +0 and x.diastolic_blood_pressure +0 <= s.large_range +0", orgid, orgid, startime, endtime).Group("x.monitoring_date,x.patient_id").Count(&total).Scan(&record).Error
@@ -3526,3 +3541,41 @@ func GetCountRollout(orgid int64, startime int64, endtime int64, lapsetotype int
3526 3541
 	}
3527 3542
 	return lapseto, err
3528 3543
 }
3544
+
3545
+func GetCheckExaminePercent(start_time int64, end_time int64, org_id int64, name_type int64) (total int64) {
3546
+
3547
+	switch name_type {
3548
+	case 1:
3549
+		key := "%" + "血常规" + "%"
3550
+		readDb.Model(&models.Inspection{}).Where("inspect_date >= ? AND inspect_date <= ? AND user_org_id = ? AND status = 1 AND (item_name Like ? Or project_name Like ?)", start_time, end_time, org_id, key).Group("patient_id").Count(&total)
3551
+
3552
+		break
3553
+	case 2:
3554
+		//key := "%" + "肝功能" + "%"
3555
+		//key1 := "%" + "肾功能" + "%"
3556
+		//key2 := "%" + "电解质" + "%"
3557
+		//key3 := "%" + "血脂" + "%"
3558
+		//readDb.Model(&models.Inspection{}).Where("inspect_date >= ? AND inspect_date <= ? AND user_org_id = ? AND status = 1 AND ((item_name Like ? Or project_name Like ?) Or (item_name Like ? Or project_name Like ?) Or (item_name Like ? Or project_name Like ?) Or (item_name Like ? Or project_name Like ?))", start_time, end_time, org_id, key, key, key1, key1, key2, key2, key3, key3).Group("patient_id").Count(&total)
3559
+
3560
+		break
3561
+	case 3:
3562
+		//key := "%" + "肝功能" + "%"
3563
+		//readDb.Model(&models.Inspection{}).Where("inspect_date >= ? AND inspect_date <= ? AND user_org_id = ? AND status = 1 AND ((item_name Like ? Or project_name Like ?) Or (item_name Like ? Or project_name Like ?) Or (item_name Like ? Or project_name Like ?) Or (item_name Like ? Or project_name Like ?))", start_time, end_time, org_id, key, key, key1, key1, key2, key2, key3, key3).Group("patient_id").Count(&total)
3564
+
3565
+		break
3566
+	case 4:
3567
+		break
3568
+	case 5:
3569
+		break
3570
+	case 6:
3571
+		break
3572
+
3573
+	}
3574
+
3575
+	return
3576
+}
3577
+
3578
+func GetAllPatientCount(orgid int64) (total int64, err error) {
3579
+	err = XTReadDB().Where("user_org_id = ? and status = 1", orgid).Count(&total).Error
3580
+	return
3581
+}

+ 21 - 0
service/his_hospital_service.go View File

@@ -269,6 +269,11 @@ func GetLastHospitalRecord(id int64, user_org_id int64) (record models.HisHospit
269 269
 	return
270 270
 }
271 271
 
272
+func GetLastHospitalRecordTwo(patient_id int64, user_org_id int64) (record models.HisHospitalCheckRecord, err error) {
273
+	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("patient_id = ? AND status = 1 AND user_org_id = ? AND in_hospital_status = 1 AND out_hospital_status = 0", patient_id, user_org_id).Last(&record).Error
274
+	return
275
+}
276
+
272 277
 func FindDiagnoseByIds(ids []string) ([]*models.HisXtDiagnoseConfig, error) {
273 278
 	dealer := []*models.HisXtDiagnoseConfig{}
274 279
 	err := readDb.Model(&models.HisXtDiagnoseConfig{}).Where("id IN (?) AND status = 1", ids).Find(&dealer).Error
@@ -296,3 +301,19 @@ func GetHospitalMonthHisPrescription(org_id int64, patient_id int64, start_time
296 301
 		Find(&prescription).Error
297 302
 	return
298 303
 }
304
+
305
+func GetSettleHisHospitalPrescription(org_id int64, patient_id int64, his_patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
306
+	err = readDb.Model(&models.HisPrescription{}).
307
+		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
308
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
309
+		}).
310
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
311
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
312
+		}).
313
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
314
+			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")
315
+		}).
316
+		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND patient_id = ? AND order_status = 4 ", org_id, record_date, patient_id).
317
+		Find(&prescription).Error
318
+	return
319
+}

+ 15 - 3
service/his_service.go View File

@@ -565,7 +565,7 @@ func GetUnChargeMonthHisPrescriptionThree(org_id int64, patient_id int64, start_
565 565
 		}).Preload("TempHisOrder", func(db *gorm.DB) *gorm.DB {
566 566
 		return db.Where("status = 1 AND user_org_id = ?", org_id)
567 567
 	}).
568
-		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ?  AND  order_status <> 2 AND order_status <> 3  AND p_type = ?", org_id, start_date, end_date, patient_id, p_type).
568
+		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ?  AND  order_status <> 2 AND order_status <> 3 AND order_status <> 4 AND p_type = ?", org_id, start_date, end_date, patient_id, p_type).
569 569
 		Find(&prescription).Error
570 570
 	return
571 571
 }
@@ -817,7 +817,7 @@ func FindPatientPrescriptionInfo(org_id int64, patient_id int64, record_date int
817 817
 }
818 818
 
819 819
 func FindPatientPrescriptionInfoTwo(org_id int64, patient_id int64, record_date int64, p_type int64) (info models.HisPrescriptionInfo, err error) {
820
-	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND p_type = ?  ", org_id, record_date, patient_id).First(&info).Error
820
+	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND p_type = ? ", org_id, record_date, patient_id, p_type).First(&info).Error
821 821
 	return
822 822
 
823 823
 }
@@ -2035,7 +2035,7 @@ func GetHisPrescriptionProjects(user_org_id int64, patient_id int64, record_time
2035 2035
 }
2036 2036
 
2037 2037
 func GetHisPrescriptionTeamProjects(user_org_id int64, patient_id int64, record_time int64) (projects []*models.HisPrescriptionProject, err error) {
2038
-	err = readDb.Model(&models.HisPrescriptionProject{}).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND  status = 1 AND team_id > 0", user_org_id, patient_id, record_time).Find(&projects).Error
2038
+	err = readDb.Model(&models.HisPrescriptionProject{}).Preload("XtHisProjectTeam", "status = 1 AND user_org_id = ?", user_org_id).Preload("HisProject", "status = 1 AND user_org_id = ?", user_org_id).Preload("GoodInfo", "status = 1 AND org_id = ?", user_org_id).Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND  status = 1 AND team_id > 0", user_org_id, patient_id, record_time).Find(&projects).Error
2039 2039
 	return
2040 2040
 }
2041 2041
 
@@ -2224,3 +2224,15 @@ func CreateHisLabelRecord(label *models.HisLabelPrintInfo) error {
2224 2224
 	err := writeDb.Save(&label).Error
2225 2225
 	return err
2226 2226
 }
2227
+
2228
+func DeletePsnNCDSRecordById(id int64) (err error) {
2229
+	err = writeDb.Model(&models.GdybPsnNcdsRecord{}).Where("id = ?", id).Updates(map[string]interface{}{"user_org_id": 1110000}).Error
2230
+	return
2231
+}
2232
+
2233
+func GetBaiLinOrderData() (order []*models.NewCustomHisOrder) {
2234
+	readDb.Model(&models.NewCustomHisOrder{}).Preload("Patients", "status = 1").Preload("NewCustomHisOrderInfo", func(db *gorm.DB) *gorm.DB {
2235
+		return db.Where("status = 1 AND project_id > 0").Preload("NewCustomHisPrescriptionProject", "(status = 1 and project_id = 1027 AND type = 2) OR (status = 1 AND project_id = 2036 AND type = 3)")
2236
+	}).Where("user_org_id = 10138 AND settle_accounts_date >= 1638288000 AND settle_accounts_date <= 1640880000 AND order_status = 2 AND status = 1 AND (medfee_sumamt = 50 OR medfee_sumamt = 40)").Find(&order)
2237
+	return
2238
+}