|
@@ -134,3 +134,199 @@ func GetBatchHisOrderInfoByNumber(order_number string) (order []models.BatchHisO
|
134
|
134
|
err = readDb.Model(&models.BatchHisOrderInfo{}).Where("order_number = ? and status = 1", order_number).Find(&order).Error
|
135
|
135
|
return
|
136
|
136
|
}
|
|
137
|
+
|
|
138
|
+type Results struct {
|
|
139
|
+ SerialNo string `gorm:"column:序号"`
|
|
140
|
+ MedicalArea string `gorm:"column:医疗区划"`
|
|
141
|
+ CertNo string `gorm:"column:证件号码"`
|
|
142
|
+ PsnName string `gorm:"column:姓名"`
|
|
143
|
+ Gender string `gorm:"column:性别"`
|
|
144
|
+ Occupation string `gorm:"column:职业"`
|
|
145
|
+ MedicalType string `gorm:"column:医疗类别"`
|
|
146
|
+ AdmissionTime string `gorm:"column:入院时间"`
|
|
147
|
+ DischargeTime string `gorm:"column:出院时间"`
|
|
148
|
+ SettlementTime string `gorm:"column:结算时间"`
|
|
149
|
+ DischargeDiagnosis string `gorm:"column:出院诊断"`
|
|
150
|
+ InpatientDays int `gorm:"column:住院天数"`
|
|
151
|
+ MedicalFeeTotal float64 `gorm:"column:医疗费总额"`
|
|
152
|
+ HifpPay float64 `gorm:"column:统筹支付金额"`
|
|
153
|
+ ActPayDedc float64 `gorm:"column:起付线"`
|
|
154
|
+ HifobPay float64 `gorm:"column:职工大额基金支付"`
|
|
155
|
+ HifmiPay float64 `gorm:"column:居民大病基金支出"`
|
|
156
|
+ HifesPay float64 `gorm:"column:企业补充"`
|
|
157
|
+ CvlservPay float64 `gorm:"column:公务员补助"`
|
|
158
|
+ MafPay float64 `gorm:"column:医疗救助"`
|
|
159
|
+ OthPay float64 `gorm:"column:其他支付"`
|
|
160
|
+ HospPartAmt float64 `gorm:"column:医院负担"`
|
|
161
|
+ AcctPay float64 `gorm:"column:个账支付"`
|
|
162
|
+ AcctMulaidPay float64 `gorm:"column:共济支付"`
|
|
163
|
+ FundPaySumamt float64 `gorm:"column:基金支付金额"`
|
|
164
|
+ PsnCashPay float64 `gorm:"column:现金支付"`
|
|
165
|
+}
|
|
166
|
+
|
|
167
|
+type SummaryResults struct {
|
|
168
|
+ InsuranceType string `gorm:"column:险种类型"` // 险种类型
|
|
169
|
+ MedicalArea string `gorm:"column:统筹区"` // 统筹区
|
|
170
|
+ SettlementCategory string `gorm:"column:清算类别"` // 清算类别
|
|
171
|
+ PeopleCount int `gorm:"column:人数"` // 人数
|
|
172
|
+ VisitCount int `gorm:"column:人次"` // 人次
|
|
173
|
+ TotalMedicalFee float64 `gorm:"column:医保费用合计"` // 医保费用合计
|
|
174
|
+ PoolFundPay float64 `gorm:"column:统筹支付金额"` // 统筹支付金额
|
|
175
|
+ BigDiseaseFundPay float64 `gorm:"column:大病基金支付"` // 大病基金支付
|
|
176
|
+ PublicServantPay float64 `gorm:"column:公务员补助"` // 公务员补助
|
|
177
|
+ MedicalAssistance float64 `gorm:"column:医疗救助"` // 医疗救助
|
|
178
|
+ OtherPay float64 `gorm:"column:其他支付"` // 其他支付
|
|
179
|
+ AcctPay float64 `gorm:"column:个账支付"` // 个账支付
|
|
180
|
+ MutualAidPay float64 `gorm:"column:共济支付"` // 共济支付
|
|
181
|
+ CashPay float64 `gorm:"column:现金支付"` // 现金支付
|
|
182
|
+}
|
|
183
|
+
|
|
184
|
+func GetHisOrderBy10726Detail(start_time string, end_time string) ([]Results, error) {
|
|
185
|
+ //err = readDb.Model(&models.HisOrder10726{}).Select("").Where("setl_time >= ? and setl_time <= ? AND status = 1 and order_status = 2 and user_org_id = 10721", start_time+" 00:00:00", end_time+" 23:59:00").Find(&order).Error
|
|
186
|
+ var result []Results
|
|
187
|
+ readDb.Table("his_order").Select(`
|
|
188
|
+ '' AS 序号,
|
|
189
|
+ '乐安县' AS 医疗区划,
|
|
190
|
+ certno AS 证件号码,
|
|
191
|
+ psn_name AS 姓名,
|
|
192
|
+ CASE
|
|
193
|
+ WHEN gend = '1' THEN '男'
|
|
194
|
+ WHEN gend = '2' THEN '女'
|
|
195
|
+ END AS 性别,
|
|
196
|
+ CASE
|
|
197
|
+ WHEN psn_type IN ('14', '15') THEN '居民(成年)'
|
|
198
|
+ END AS 职业,
|
|
199
|
+ CASE
|
|
200
|
+ WHEN med_type = '990101' THEN '单病种门诊'
|
|
201
|
+ WHEN med_type = '14' THEN '门诊慢特病'
|
|
202
|
+ END AS 医疗类别,
|
|
203
|
+ setl_time AS 入院时间,
|
|
204
|
+ setl_time AS 出院时间,
|
|
205
|
+ setl_time AS 结算时间,
|
|
206
|
+ CASE
|
|
207
|
+ WHEN med_type = '990101' THEN '尿毒症(免费透析)'
|
|
208
|
+ WHEN med_type = '14' THEN '尿毒症期'
|
|
209
|
+ END AS 出院诊断,
|
|
210
|
+ 1 AS 住院天数,
|
|
211
|
+ medfee_sumamt AS 医疗费总额,
|
|
212
|
+ hifp_pay AS 统筹支付金额,
|
|
213
|
+ act_pay_dedc AS 起付线,
|
|
214
|
+ hifob_pay AS 职工大额基金支付,
|
|
215
|
+ hifmi_pay AS 居民大病基金支出,
|
|
216
|
+ hifes_pay AS 企业补充,
|
|
217
|
+ cvlserv_pay AS 公务员补助,
|
|
218
|
+ maf_pay AS 医疗救助,
|
|
219
|
+ oth_pay AS 其他支付,
|
|
220
|
+ hosp_part_amt AS 医院负担,
|
|
221
|
+ acct_pay AS 个账支付,
|
|
222
|
+ acct_mulaid_pay AS 共济支付,
|
|
223
|
+ fund_pay_sumamt AS 基金支付金额,
|
|
224
|
+ psn_cash_pay AS 现金支付
|
|
225
|
+ `).Where("user_org_id = ?", 10726).
|
|
226
|
+ Where("order_status = ?", 2).
|
|
227
|
+ Where("setl_time >= ?", start_time).
|
|
228
|
+ Where("setl_time <= ?", end_time).
|
|
229
|
+ Where("is_medicine_insurance = ?", 1).
|
|
230
|
+ Where("status = ?", 1).
|
|
231
|
+ Scan(&result)
|
|
232
|
+ return result, err
|
|
233
|
+}
|
|
234
|
+
|
|
235
|
+func GetHisOrderBy10726Summary(start_time string, end_time string) ([]SummaryResults, error) {
|
|
236
|
+ var result []SummaryResults
|
|
237
|
+ err = readDb.Table("his_order").
|
|
238
|
+ Select(`
|
|
239
|
+ CASE
|
|
240
|
+ WHEN insutype = "390" THEN "城乡居民"
|
|
241
|
+ WHEN insutype = "310" THEN "职工"
|
|
242
|
+ END AS "险种类型",
|
|
243
|
+ "乐安县" AS 统筹区,
|
|
244
|
+ "门诊" AS 清算类别,
|
|
245
|
+ COUNT(DISTINCT patient_id) AS 人数,
|
|
246
|
+ COUNT(id) AS 人次,
|
|
247
|
+ SUM(medfee_sumamt) AS 医保费用合计,
|
|
248
|
+ SUM(hifp_pay) AS 统筹支付金额,
|
|
249
|
+ SUM(hifmi_pay) AS 大病基金支付,
|
|
250
|
+ SUM(cvlserv_pay) AS 公务员补助,
|
|
251
|
+ SUM(maf_pay) AS 医疗救助,
|
|
252
|
+ SUM(oth_pay) AS 其他支付,
|
|
253
|
+ SUM(acct_pay) AS 个账支付,
|
|
254
|
+ SUM(acct_mulaid_pay) AS 共济支付,
|
|
255
|
+ SUM(psn_cash_pay) AS 现金支付
|
|
256
|
+ `).
|
|
257
|
+ Where("user_org_id = ? AND order_status = ? AND setl_time >= ? AND setl_time <= ? AND is_medicine_insurance = ? AND status = ?",
|
|
258
|
+ 10726, 2, start_time, end_time, 1, 1).
|
|
259
|
+ Group("insutype").
|
|
260
|
+ Scan(&result).Error
|
|
261
|
+ return result, err
|
|
262
|
+
|
|
263
|
+}
|
|
264
|
+
|
|
265
|
+type MedicalCharges struct {
|
|
266
|
+ SerialNo string `gorm:"column:编号"` // 编号
|
|
267
|
+ MedicalInsuranceNo string `gorm:"column:医疗保险号"` // 医疗保险号
|
|
268
|
+ PsnName string `gorm:"column:姓名"` // 姓名
|
|
269
|
+ BedsFee float64 `gorm:"column:床位费"` // 床位费
|
|
270
|
+ ConsultationFee float64 `gorm:"column:诊察费"` // 诊察费
|
|
271
|
+ ExaminationFee float64 `gorm:"column:检查费"` // 检查费
|
|
272
|
+ LaboratoryFee float64 `gorm:"column:化验费"` // 化验费
|
|
273
|
+ TreatmentFee float64 `gorm:"column:治疗费"` // 治疗费
|
|
274
|
+ NursingFee float64 `gorm:"column:护理费"` // 护理费
|
|
275
|
+ HealthMaterialsFee float64 `gorm:"column:卫生材料费"` // 卫生材料费
|
|
276
|
+ WesternMedicineFee float64 `gorm:"column:西药费"` // 西药费
|
|
277
|
+ ChineseMedicineFee float64 `gorm:"column:中药饮片费"` // 中药饮片费
|
|
278
|
+ ChinesePatentMedicineFee float64 `gorm:"column:中成药费"` // 中成药费
|
|
279
|
+ GeneralTreatmentFee float64 `gorm:"column:一般诊疗费"` // 一般诊疗费
|
|
280
|
+ RegistrationFee float64 `gorm:"column:挂号费"` // 挂号费
|
|
281
|
+ OtherFee float64 `gorm:"column:其他费"` // 其他费
|
|
282
|
+ TotalMedicalFee float64 `gorm:"column:医疗费总额"` // 医疗费总额
|
|
283
|
+ SelfPay float64 `gorm:"column:个人自付金额"` // 个人自付金额
|
|
284
|
+ AcctPay float64 `gorm:"column:基本账户支付"` // 基本账户支付
|
|
285
|
+ MutualAidAcctPay float64 `gorm:"column:共济账户支付"` // 共济账户支付
|
|
286
|
+ PublicServantPay float64 `gorm:"column:公务员补助"` // 公务员补助
|
|
287
|
+ PoolFundPay float64 `gorm:"column:统筹支付金额"` // 统筹支付金额
|
|
288
|
+ MedicalAssistance float64 `gorm:"column:医疗救助"` // 医疗救助
|
|
289
|
+ BigDiseasePay float64 `gorm:"column:大病支付"` // 大病支付
|
|
290
|
+ EnterpriseSupplement float64 `gorm:"column:企业补充支付"` // 企业补充支付
|
|
291
|
+ MajorDiseaseSupplement float64 `gorm:"column:重大疾病补充"` // 重大疾病补充 (Empty in SQL, will be left blank in Go)
|
|
292
|
+ OtherPayment float64 `gorm:"column:其它支付"` // 其它支付
|
|
293
|
+}
|
|
294
|
+
|
|
295
|
+func GetHisOrderBy10697Summary(start_time string, end_time string, ins string) (results []MedicalCharges, err error) {
|
|
296
|
+ err = readDb.Table("his_order").
|
|
297
|
+ Select(`
|
|
298
|
+ "" AS 编号,
|
|
299
|
+ his_order.certno AS 医疗保险号,
|
|
300
|
+ his_order.psn_name AS 姓名,
|
|
301
|
+ SUM(CASE WHEN i.med_chrgitm_type = '01' THEN i.det_item_fee_sumamt ELSE 0 END) AS 床位费,
|
|
302
|
+ SUM(CASE WHEN i.med_chrgitm_type = '02' THEN i.det_item_fee_sumamt ELSE 0 END) AS 诊察费,
|
|
303
|
+ SUM(CASE WHEN i.med_chrgitm_type = '03' THEN i.det_item_fee_sumamt ELSE 0 END) AS 检查费,
|
|
304
|
+ SUM(CASE WHEN i.med_chrgitm_type = '04' THEN i.det_item_fee_sumamt ELSE 0 END) AS 化验费,
|
|
305
|
+ SUM(CASE WHEN i.med_chrgitm_type = '05' THEN i.det_item_fee_sumamt ELSE 0 END) AS 治疗费,
|
|
306
|
+ SUM(CASE WHEN i.med_chrgitm_type = '07' THEN i.det_item_fee_sumamt ELSE 0 END) AS 护理费,
|
|
307
|
+ SUM(CASE WHEN i.med_chrgitm_type = '08' THEN i.det_item_fee_sumamt ELSE 0 END) AS 卫生材料费,
|
|
308
|
+ SUM(CASE WHEN i.med_chrgitm_type = '09' THEN i.det_item_fee_sumamt ELSE 0 END) AS 西药费,
|
|
309
|
+ SUM(CASE WHEN i.med_chrgitm_type = '10' THEN i.det_item_fee_sumamt ELSE 0 END) AS 中药饮片费,
|
|
310
|
+ SUM(CASE WHEN i.med_chrgitm_type = '11' THEN i.det_item_fee_sumamt ELSE 0 END) AS 中成药费,
|
|
311
|
+ SUM(CASE WHEN i.med_chrgitm_type = '12' THEN i.det_item_fee_sumamt ELSE 0 END) AS 一般诊疗费,
|
|
312
|
+ SUM(CASE WHEN i.med_chrgitm_type = '13' THEN i.det_item_fee_sumamt ELSE 0 END) AS 挂号费,
|
|
313
|
+ SUM(CASE WHEN i.med_chrgitm_type = '14' THEN i.det_item_fee_sumamt ELSE 0 END) AS 其他费,
|
|
314
|
+ SUM(his_order.medfee_sumamt) AS 医疗费总额,
|
|
315
|
+ SUM(his_order.psn_cash_pay) AS 个人自付金额,
|
|
316
|
+ SUM(his_order.acct_pay) AS 基本账户支付,
|
|
317
|
+ SUM(his_order.acct_mulaid_pay) AS 共济账户支付,
|
|
318
|
+ SUM(his_order.cvlserv_pay) AS 公务员补助,
|
|
319
|
+ SUM(his_order.hifp_pay) AS 统筹支付金额,
|
|
320
|
+ SUM(his_order.maf_pay) AS 医疗救助,
|
|
321
|
+ SUM(his_order.hifmi_pay) AS 大病支付,
|
|
322
|
+ SUM(his_order.hifes_pay) AS 企业补充支付,
|
|
323
|
+ "" AS 重大疾病补充,
|
|
324
|
+ SUM(his_order.oth_pay) AS 其它支付
|
|
325
|
+ `).
|
|
326
|
+ Joins("JOIN his_order_info i ON his_order.number = i.order_number").
|
|
327
|
+ Where("his_order.user_org_id = ? AND his_order.order_status = ? AND his_order.setl_time >= ? AND his_order.setl_time <= ? AND his_order.is_medicine_insurance = ? AND his_order.insutype = ? AND his_order.STATUS = ?",
|
|
328
|
+ 10697, 2, start_time+" 00:00:00", end_time+" 23:59:59", 1, ins, 1).
|
|
329
|
+ Group("his_order.patient_id").
|
|
330
|
+ Scan(&results).Error
|
|
331
|
+ return
|
|
332
|
+}
|