|
@@ -28,6 +28,7 @@ func HisHospitalManagerApiRegistRouters() {
|
28
|
28
|
beego.Router("/api/hospital/inthopitaluncheck/get", &HisHospitalApiController{}, "get:GetZHInHospitalUnCheck")
|
29
|
29
|
beego.Router("/api/hospital/outhopitaluncheck/get", &HisHospitalApiController{}, "get:GetZHOutHospitalUnCheck")
|
30
|
30
|
beego.Router("/api/hospital/refund", &HisHospitalApiController{}, "get:ZHRefund")
|
|
31
|
+ beego.Router("/api/hospital/upload", &HisHospitalApiController{}, "get:GetUploadInfo")
|
31
|
32
|
|
32
|
33
|
beego.Router("/api/hospitaldetail/list", &HisHospitalApiController{}, "get:GetHisHospitalDetailPatientList")
|
33
|
34
|
beego.Router("/api/hospitaldetail/info", &HisHospitalApiController{}, "get:GetHisHospitalDetailInfo")
|
|
@@ -36,6 +37,237 @@ func HisHospitalManagerApiRegistRouters() {
|
36
|
37
|
|
37
|
38
|
}
|
38
|
39
|
|
|
40
|
+func (c *HisHospitalApiController) GetUploadInfo() {
|
|
41
|
+ id, _ := c.GetInt64("id")
|
|
42
|
+ record_time := c.GetString("record_time")
|
|
43
|
+ in_hospital_id, _ := c.GetInt64("in_hospital_id")
|
|
44
|
+ settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
|
|
45
|
+
|
|
46
|
+ timeLayout := "2006-01-02"
|
|
47
|
+ loc, _ := time.LoadLocation("Local")
|
|
48
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
|
|
49
|
+ if err != nil {
|
|
50
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
51
|
+ return
|
|
52
|
+ }
|
|
53
|
+ recordDateTime := theTime.Unix()
|
|
54
|
+ adminUser := c.GetAdminUserInfo()
|
|
55
|
+
|
|
56
|
+ var prescriptions []*models.HisPrescription
|
|
57
|
+
|
|
58
|
+ if settle_accounts_type == 1 { //日结
|
|
59
|
+ prescriptions, _ = service.GetZHHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
|
|
60
|
+
|
|
61
|
+ } else { //月结
|
|
62
|
+ start_time_str := c.GetString("start_time")
|
|
63
|
+ end_time_str := c.GetString("end_time")
|
|
64
|
+ timeLayout := "2006-01-02"
|
|
65
|
+ loc, _ := time.LoadLocation("Local")
|
|
66
|
+ theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
|
|
67
|
+ if err != nil {
|
|
68
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
69
|
+ return
|
|
70
|
+ }
|
|
71
|
+ recordStartTime := theStartTime.Unix()
|
|
72
|
+ theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
|
|
73
|
+ if err != nil {
|
|
74
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
75
|
+ return
|
|
76
|
+ }
|
|
77
|
+ recordEndTime := theEndTime.Unix()
|
|
78
|
+ prescriptions, _ = service.GetZHMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
|
|
79
|
+
|
|
80
|
+ }
|
|
81
|
+
|
|
82
|
+ record, _ := service.GetInHospitalRecord(in_hospital_id)
|
|
83
|
+
|
|
84
|
+ if record.ID == 0 {
|
|
85
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
86
|
+ return
|
|
87
|
+ }
|
|
88
|
+
|
|
89
|
+ var ids []int64
|
|
90
|
+
|
|
91
|
+ for _, item := range prescriptions {
|
|
92
|
+ ids = append(ids, item.ID)
|
|
93
|
+ }
|
|
94
|
+ config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
|
|
95
|
+ if config.IsOpen == 1 { //对接了医保,走医保流程
|
|
96
|
+
|
|
97
|
+ var customs []*models.NewCustom
|
|
98
|
+
|
|
99
|
+ for _, item := range prescriptions {
|
|
100
|
+ tm := time.Unix(item.PreTime, 0)
|
|
101
|
+ if item.Type == 1 { //药品
|
|
102
|
+ for _, subItem := range item.HisDoctorAdviceInfo {
|
|
103
|
+ if len(subItem.Drug.MedicalInsuranceNumber) > 0 && subItem.Drug.IsUser != 1 {
|
|
104
|
+ //var randNum int
|
|
105
|
+ //randNum = rand.Intn(10000) + 1000
|
|
106
|
+ cus := &models.NewCustom{
|
|
107
|
+ DetItemFeeSumamt: subItem.Price * subItem.PrescribingNumber,
|
|
108
|
+ Cut: subItem.PrescribingNumber,
|
|
109
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
110
|
+ Price: subItem.Price,
|
|
111
|
+ MedListCodg: subItem.Drug.MedicalInsuranceNumber,
|
|
112
|
+ HospApprFlag: subItem.Drug.HospApprFlag,
|
|
113
|
+ FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
|
|
114
|
+ }
|
|
115
|
+
|
|
116
|
+ customs = append(customs, cus)
|
|
117
|
+ }
|
|
118
|
+ }
|
|
119
|
+ }
|
|
120
|
+
|
|
121
|
+ if item.Type == 2 { //项目
|
|
122
|
+ for _, subItem := range item.HisPrescriptionProject {
|
|
123
|
+ if subItem.Type == 2 {
|
|
124
|
+ if len(subItem.HisProject.MedicalCode) > 0 {
|
|
125
|
+ cnt, _ := strconv.ParseFloat(subItem.Count, 64)
|
|
126
|
+ cus := &models.NewCustom{
|
|
127
|
+ DetItemFeeSumamt: subItem.Price * cnt,
|
|
128
|
+ Cut: cnt,
|
|
129
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
130
|
+ Price: float64(subItem.Price),
|
|
131
|
+ MedListCodg: subItem.HisProject.MedicalCode,
|
|
132
|
+ HospApprFlag: -1,
|
|
133
|
+ FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
|
|
134
|
+ }
|
|
135
|
+ customs = append(customs, cus)
|
|
136
|
+ }
|
|
137
|
+ } else if subItem.Type == 3 {
|
|
138
|
+ if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 && subItem.GoodInfo.IsUser != 1 {
|
|
139
|
+ cnt, _ := strconv.ParseFloat(subItem.Count, 64)
|
|
140
|
+
|
|
141
|
+ cus := &models.NewCustom{
|
|
142
|
+ DetItemFeeSumamt: subItem.Price * cnt,
|
|
143
|
+ Cut: cnt,
|
|
144
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
145
|
+ Price: float64(subItem.Price),
|
|
146
|
+ MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
|
|
147
|
+ HospApprFlag: -1,
|
|
148
|
+ FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
|
|
149
|
+ }
|
|
150
|
+ customs = append(customs, cus)
|
|
151
|
+ }
|
|
152
|
+ }
|
|
153
|
+ }
|
|
154
|
+ }
|
|
155
|
+
|
|
156
|
+ }
|
|
157
|
+
|
|
158
|
+ if settle_accounts_type == 1 {
|
|
159
|
+ for _, subItem := range customs {
|
|
160
|
+ temp := strings.Split(subItem.FeedetlSn, "-")
|
|
161
|
+ var advice_id int64 = 0
|
|
162
|
+ var project_id int64 = 0
|
|
163
|
+ var types int64 = 0
|
|
164
|
+
|
|
165
|
+ id, _ := strconv.ParseInt(temp[2], 10, 64)
|
|
166
|
+ types, _ = strconv.ParseInt(temp[1], 10, 64)
|
|
167
|
+
|
|
168
|
+ if temp[1] == "1" {
|
|
169
|
+ advice_id = id
|
|
170
|
+ project_id = 0
|
|
171
|
+ } else if temp[1] == "2" {
|
|
172
|
+ advice_id = 0
|
|
173
|
+ project_id = id
|
|
174
|
+ }
|
|
175
|
+ info := &models.HisOrderInfo{
|
|
176
|
+ OrderNumber: record.Number,
|
|
177
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
178
|
+ UploadDate: recordDateTime,
|
|
179
|
+ AdviceId: advice_id,
|
|
180
|
+ DetItemFeeSumamt: subItem.DetItemFeeSumamt,
|
|
181
|
+ Cnt: subItem.Cut,
|
|
182
|
+ Pric: float64(subItem.Price),
|
|
183
|
+ PatientId: record.PatientId,
|
|
184
|
+ PricUplmtAmt: 0,
|
|
185
|
+ SelfpayProp: 0,
|
|
186
|
+ FulamtOwnpayAmt: 0,
|
|
187
|
+ OverlmtAmt: 0,
|
|
188
|
+ PreselfpayAmt: 0,
|
|
189
|
+ Status: 1,
|
|
190
|
+ Mtime: time.Now().Unix(),
|
|
191
|
+ Ctime: time.Now().Unix(),
|
|
192
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
193
|
+ HisPatientId: record.ID,
|
|
194
|
+ OrderId: 0,
|
|
195
|
+ ProjectId: project_id,
|
|
196
|
+ Type: types,
|
|
197
|
+ SettleType: settle_accounts_type,
|
|
198
|
+ }
|
|
199
|
+ service.CreateOrderInfo(info)
|
|
200
|
+ }
|
|
201
|
+
|
|
202
|
+ err := service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
|
|
203
|
+ service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
|
|
204
|
+ service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, record.PatientId, record.Number, recordDateTime)
|
|
205
|
+ if err == nil {
|
|
206
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
207
|
+ "msg": "上传费用明细成功",
|
|
208
|
+ })
|
|
209
|
+ return
|
|
210
|
+ } else {
|
|
211
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
212
|
+ return
|
|
213
|
+ }
|
|
214
|
+
|
|
215
|
+ } else {
|
|
216
|
+
|
|
217
|
+ for _, subItem := range customs {
|
|
218
|
+ temp := strings.Split(subItem.FeedetlSn, "-")
|
|
219
|
+ var advice_id int64 = 0
|
|
220
|
+ var project_id int64 = 0
|
|
221
|
+ var types int64 = 0
|
|
222
|
+
|
|
223
|
+ id, _ := strconv.ParseInt(temp[2], 10, 64)
|
|
224
|
+ types, _ = strconv.ParseInt(temp[1], 10, 64)
|
|
225
|
+
|
|
226
|
+ if temp[1] == "1" {
|
|
227
|
+ advice_id = id
|
|
228
|
+ project_id = 0
|
|
229
|
+ } else if temp[1] == "2" {
|
|
230
|
+ advice_id = 0
|
|
231
|
+ project_id = id
|
|
232
|
+ }
|
|
233
|
+ info := &models.HisOrderInfo{
|
|
234
|
+ OrderNumber: record.Number,
|
|
235
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
236
|
+ UploadDate: recordDateTime,
|
|
237
|
+ AdviceId: advice_id,
|
|
238
|
+ DetItemFeeSumamt: subItem.DetItemFeeSumamt,
|
|
239
|
+ Cnt: subItem.Cut,
|
|
240
|
+ Pric: float64(subItem.Price),
|
|
241
|
+ PatientId: record.PatientId,
|
|
242
|
+ PricUplmtAmt: 0,
|
|
243
|
+ SelfpayProp: 0,
|
|
244
|
+ FulamtOwnpayAmt: 0,
|
|
245
|
+ OverlmtAmt: 0,
|
|
246
|
+ PreselfpayAmt: 0,
|
|
247
|
+ Status: 1,
|
|
248
|
+ Mtime: time.Now().Unix(),
|
|
249
|
+ Ctime: time.Now().Unix(),
|
|
250
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
251
|
+ HisPatientId: record.ID,
|
|
252
|
+ OrderId: 0,
|
|
253
|
+ ProjectId: project_id,
|
|
254
|
+ Type: types,
|
|
255
|
+ SettleType: settle_accounts_type,
|
|
256
|
+ }
|
|
257
|
+ service.CreateOrderInfo(info)
|
|
258
|
+ }
|
|
259
|
+
|
|
260
|
+ service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
|
|
261
|
+ service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
|
|
262
|
+ service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, record.PatientId, record.Number, recordDateTime)
|
|
263
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
264
|
+ "msg": "上传费用明细成功",
|
|
265
|
+ })
|
|
266
|
+
|
|
267
|
+ }
|
|
268
|
+ }
|
|
269
|
+}
|
|
270
|
+
|
39
|
271
|
func (c *HisHospitalApiController) GetHisHospitalPatientList() {
|
40
|
272
|
record_date := c.GetString("record_date")
|
41
|
273
|
types, _ := c.GetInt64("type", 0)
|
|
@@ -51,7 +283,7 @@ func (c *HisHospitalApiController) GetHisHospitalPatientList() {
|
51
|
283
|
recordDateTime := theTime.Unix()
|
52
|
284
|
adminInfo := c.GetAdminUserInfo()
|
53
|
285
|
//var patients []*service.HospitalPatient
|
54
|
|
- tempPatients, _ := service.GetHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime)
|
|
286
|
+ tempPatients, _ := service.GetHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime, sch_type)
|
55
|
287
|
tempPatients_two, _ := service.GetHisHospitalSchPatientList(adminInfo.CurrentOrgId, recordDateTime, sch_type)
|
56
|
288
|
|
57
|
289
|
//当天有登记住院的和排班同时存在的话,删除掉排班的记录
|
|
@@ -375,12 +607,20 @@ func (c *HisHospitalApiController) GetZHInHospitalCheck() {
|
375
|
607
|
}
|
376
|
608
|
func (this *HisHospitalApiController) GetZHOutHospitalCheck() {
|
377
|
609
|
id, _ := this.GetInt64("id")
|
|
610
|
+ record_date := this.GetString("record_date")
|
|
611
|
+
|
378
|
612
|
record, _ := service.GetInHospitalRecord(id)
|
379
|
613
|
if record.ID == 0 {
|
380
|
614
|
this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
|
381
|
615
|
return
|
382
|
616
|
}
|
383
|
617
|
|
|
618
|
+ timeLayout := "2006-01-02"
|
|
619
|
+ loc, _ := time.LoadLocation("Local")
|
|
620
|
+ theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
|
|
621
|
+
|
|
622
|
+ recordDateTime := theTime.Unix()
|
|
623
|
+
|
384
|
624
|
timestamp := time.Now().Unix()
|
385
|
625
|
tempTime := time.Unix(timestamp, 0)
|
386
|
626
|
timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
|
|
@@ -388,18 +628,48 @@ func (this *HisHospitalApiController) GetZHOutHospitalCheck() {
|
388
|
628
|
record.OutHosptialTime = timeFormatOne
|
389
|
629
|
record.OutWay = 1
|
390
|
630
|
service.CreateHospitalRecord(&record)
|
|
631
|
+
|
|
632
|
+ orders, _ := service.GetHisOrderInfoByNumberFour(record.Number)
|
|
633
|
+ var total float64
|
|
634
|
+ for _, item := range orders {
|
|
635
|
+ total = total + item.DetItemFeeSumamt
|
|
636
|
+ }
|
|
637
|
+
|
|
638
|
+ order := &models.HisOrder{
|
|
639
|
+ UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
|
|
640
|
+ HisPatientId: record.ID,
|
|
641
|
+ PatientId: record.PatientId,
|
|
642
|
+ SettleAccountsDate: recordDateTime,
|
|
643
|
+ Ctime: time.Now().Unix(),
|
|
644
|
+ Mtime: time.Now().Unix(),
|
|
645
|
+ Status: 1,
|
|
646
|
+ Number: record.Number,
|
|
647
|
+ Infcode: 0,
|
|
648
|
+ WarnMsg: "",
|
|
649
|
+ Cainfo: "",
|
|
650
|
+ ErrMsg: "",
|
|
651
|
+ RespondTime: "",
|
|
652
|
+ InfRefmsgid: "",
|
|
653
|
+ OrderStatus: 1,
|
|
654
|
+ MdtrtId: record.Number,
|
|
655
|
+ IsMedicineInsurance: 1,
|
|
656
|
+ PType: 1,
|
|
657
|
+ MedfeeSumamt: total,
|
|
658
|
+ }
|
|
659
|
+ err := service.CreateOrder(order)
|
|
660
|
+ if err != nil {
|
|
661
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
662
|
+ return
|
|
663
|
+ }
|
|
664
|
+
|
391
|
665
|
this.ServeSuccessJSON(map[string]interface{}{
|
392
|
666
|
"msg": "出院成功",
|
393
|
667
|
})
|
394
|
668
|
|
395
|
669
|
}
|
396
|
670
|
func (c *HisHospitalApiController) GetSettleInfo() {
|
397
|
|
- id, _ := c.GetInt64("id")
|
398
|
|
- record_time := c.GetString("record_time")
|
|
671
|
+ order_id, _ := c.GetInt64("order_id")
|
399
|
672
|
in_hospital_id, _ := c.GetInt64("in_hospital_id")
|
400
|
|
- settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
|
401
|
|
-
|
402
|
|
- patient_id, _ := c.GetInt64("patient_id")
|
403
|
673
|
pay_way, _ := c.GetInt64("pay_way")
|
404
|
674
|
pay_price, _ := c.GetFloat("pay_price")
|
405
|
675
|
pay_card_no := c.GetString("pay_card_no")
|
|
@@ -411,107 +681,18 @@ func (c *HisHospitalApiController) GetSettleInfo() {
|
411
|
681
|
private_price, _ := c.GetFloat("private_price")
|
412
|
682
|
fapiao_code := c.GetString("fapiao_code")
|
413
|
683
|
fapiao_number := c.GetString("fapiao_number")
|
414
|
|
-
|
415
|
|
- timeLayout := "2006-01-02"
|
416
|
|
- loc, _ := time.LoadLocation("Local")
|
417
|
|
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
|
418
|
|
- if err != nil {
|
419
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
420
|
|
- return
|
421
|
|
- }
|
422
|
|
- recordDateTime := theTime.Unix()
|
423
|
|
- adminUser := c.GetAdminUserInfo()
|
424
|
|
-
|
425
|
|
- var prescriptions []*models.HisPrescription
|
426
|
|
-
|
427
|
|
- var start_time int64
|
428
|
|
- var end_time int64
|
429
|
|
-
|
430
|
|
- if settle_accounts_type == 1 { //日结
|
431
|
|
- //prescriptions, _ = service.GetZHHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
|
432
|
|
-
|
433
|
|
- } else { //月结
|
434
|
|
- start_time_str := c.GetString("start_time")
|
435
|
|
- end_time_str := c.GetString("end_time")
|
436
|
|
- timeLayout := "2006-01-02"
|
437
|
|
- loc, _ := time.LoadLocation("Local")
|
438
|
|
- theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
|
439
|
|
- if err != nil {
|
440
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
441
|
|
- return
|
442
|
|
- }
|
443
|
|
- recordStartTime := theStartTime.Unix()
|
444
|
|
- start_time = recordStartTime
|
445
|
|
- theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
|
446
|
|
- if err != nil {
|
447
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
448
|
|
- return
|
449
|
|
- }
|
450
|
|
- recordEndTime := theEndTime.Unix()
|
451
|
|
- end_time = recordEndTime
|
452
|
|
- prescriptions, _ = service.GetHospitalMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
|
453
|
|
-
|
454
|
|
- }
|
455
|
|
-
|
456
|
684
|
record, _ := service.GetInHospitalRecord(in_hospital_id)
|
457
|
|
-
|
|
685
|
+ order, _ := service.GetHisOrderByID(order_id)
|
|
686
|
+ chrg_bchno := order.Number
|
458
|
687
|
if record.ID == 0 {
|
459
|
688
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
460
|
689
|
return
|
461
|
690
|
}
|
462
|
|
-
|
463
|
|
- timestamp := time.Now().Unix()
|
464
|
|
- tempTime := time.Unix(timestamp, 0)
|
465
|
|
- timeFormat := tempTime.Format("20060102150405")
|
466
|
|
- chrgBchno := rand.Intn(100000) + 10000
|
467
|
|
- chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(record.PatientId, 10)
|
468
|
|
-
|
469
|
|
- var ids []int64
|
470
|
|
- fmt.Println(prescriptions)
|
471
|
|
- for _, item := range prescriptions {
|
472
|
|
- ids = append(ids, item.ID)
|
473
|
|
- }
|
474
|
|
- var total float64
|
475
|
|
- fmt.Println(prescriptions)
|
476
|
|
- for _, item := range prescriptions {
|
477
|
|
- fmt.Println(item)
|
478
|
|
- if item.Type == 1 { //药品
|
479
|
|
- for _, subItem := range item.HisDoctorAdviceInfo {
|
480
|
|
- total = total + (subItem.Price * subItem.PrescribingNumber)
|
481
|
|
- }
|
482
|
|
- }
|
483
|
|
- if item.Type == 2 { //项目
|
484
|
|
- for _, subItem := range item.HisPrescriptionProject {
|
485
|
|
- cut, _ := strconv.ParseFloat(subItem.Count, 64)
|
486
|
|
- total = total + (subItem.Price * cut)
|
487
|
|
- }
|
488
|
|
- }
|
489
|
|
-
|
490
|
|
- for _, subItem := range item.HisAdditionalCharge {
|
491
|
|
- total = total + (subItem.Price * float64(subItem.Count))
|
492
|
|
- }
|
493
|
|
- }
|
494
|
|
-
|
495
|
|
- allTotal := fmt.Sprintf("%.2f", total)
|
496
|
|
- totals, _ := strconv.ParseFloat(allTotal, 64)
|
497
|
|
- order := &models.HisOrder{
|
498
|
|
- UserOrgId: adminUser.CurrentOrgId,
|
499
|
|
- HisPatientId: record.ID,
|
500
|
|
- PatientId: patient_id,
|
501
|
|
- SettleAccountsDate: recordDateTime,
|
502
|
|
- Ctime: time.Now().Unix(),
|
503
|
|
- Mtime: time.Now().Unix(),
|
504
|
|
- Status: 1,
|
505
|
|
- OrderStatus: 2,
|
506
|
|
- MdtrtId: record.Number,
|
507
|
|
- Number: chrg_bchno,
|
508
|
|
- MedfeeSumamt: totals,
|
509
|
|
- SettleEndTime: end_time,
|
510
|
|
- SettleStartTime: start_time,
|
511
|
|
- SettleType: settle_accounts_type,
|
512
|
|
- PType: 1,
|
513
|
|
- Creator: c.GetAdminUserInfo().AdminUser.Id,
|
|
691
|
+ if record.InHospitalStatus == 1 && record.OutHospitalStatus == 0 {
|
|
692
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalNoExistDataException)
|
|
693
|
+ return
|
514
|
694
|
}
|
|
695
|
+ order.OrderStatus = 2
|
515
|
696
|
order.DiscountPrice = discount_price
|
516
|
697
|
order.MedicalInsurancePrice = medical_insurance_price
|
517
|
698
|
order.FaPiaoNumber = fapiao_number
|
|
@@ -523,115 +704,19 @@ func (c *HisHospitalApiController) GetSettleInfo() {
|
523
|
704
|
order.RealityPrice = reality_price
|
524
|
705
|
order.FoundPrice = found_price
|
525
|
706
|
order.PrivatePrice = private_price
|
526
|
|
- err = service.CreateOrder(order)
|
527
|
|
- if err != nil {
|
528
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
|
529
|
|
- return
|
530
|
|
- }
|
531
|
|
-
|
532
|
|
- var customs []*Custom
|
533
|
|
- for _, item := range prescriptions {
|
534
|
|
- if item.Type == 1 { //药品
|
535
|
|
- for _, subItem := range item.HisDoctorAdviceInfo {
|
536
|
|
- cus := &Custom{
|
537
|
|
- AdviceId: subItem.ID,
|
538
|
|
- ProjectId: 0,
|
539
|
|
- DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
|
540
|
|
- Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
|
541
|
|
- FeedetlSn: subItem.FeedetlSn,
|
542
|
|
- Price: fmt.Sprintf("%.2f", subItem.Price),
|
543
|
|
- MedListCodg: subItem.MedListCodg,
|
544
|
|
- Type: 1,
|
545
|
|
- }
|
546
|
|
- customs = append(customs, cus)
|
547
|
|
- }
|
548
|
|
- }
|
549
|
|
- if item.Type == 2 { //项目
|
550
|
|
-
|
551
|
|
- for _, subItem := range item.HisPrescriptionProject {
|
552
|
|
- cut, _ := strconv.ParseFloat(subItem.Count, 64)
|
553
|
|
-
|
554
|
|
- cus := &Custom{
|
555
|
|
- AdviceId: 0,
|
556
|
|
- ProjectId: subItem.ID,
|
557
|
|
- DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*cut),
|
558
|
|
- Cut: fmt.Sprintf("%.2f", cut),
|
559
|
|
- FeedetlSn: subItem.FeedetlSn,
|
560
|
|
- Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
|
561
|
|
- MedListCodg: subItem.MedListCodg,
|
562
|
|
- Type: 2,
|
563
|
|
- }
|
564
|
|
- customs = append(customs, cus)
|
565
|
|
- }
|
566
|
|
- }
|
567
|
|
- for _, item := range item.HisAdditionalCharge {
|
568
|
|
- cus := &Custom{
|
569
|
|
- ItemId: item.ID,
|
570
|
|
- AdviceId: 0,
|
571
|
|
- ProjectId: 0,
|
572
|
|
- DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
|
573
|
|
- Cut: fmt.Sprintf("%.2f", float64(item.Count)),
|
574
|
|
- FeedetlSn: item.FeedetlSn,
|
575
|
|
- Price: fmt.Sprintf("%.2f", float64(item.Price)),
|
576
|
|
- MedListCodg: item.XtHisAddtionConfig.Code,
|
577
|
|
- Type: 3,
|
578
|
|
- }
|
579
|
|
- customs = append(customs, cus)
|
580
|
|
- }
|
581
|
|
- }
|
582
|
|
- for _, item := range customs {
|
583
|
|
- var advice_id int64 = 0
|
584
|
|
- var project_id int64 = 0
|
585
|
|
- var item_id int64 = 0
|
586
|
|
-
|
587
|
|
- var types int64 = 0
|
588
|
|
-
|
589
|
|
- if item.Type == 1 {
|
590
|
|
- advice_id = item.AdviceId
|
591
|
|
- project_id = 0
|
592
|
|
- item_id = 0
|
593
|
|
- } else if item.Type == 2 {
|
594
|
|
- advice_id = 0
|
595
|
|
- item_id = 0
|
596
|
|
-
|
597
|
|
- project_id = item.ProjectId
|
598
|
|
- } else if item.Type == 3 {
|
599
|
|
- advice_id = 0
|
600
|
|
- item_id = item.ItemId
|
601
|
|
- project_id = 0
|
602
|
|
- }
|
603
|
|
- detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
|
604
|
|
- cut, _ := strconv.ParseFloat(item.Cut, 32)
|
605
|
|
- pric, _ := strconv.ParseFloat(item.Price, 32)
|
606
|
|
- info := &models.HisOrderInfo{
|
607
|
|
- OrderNumber: order.Number,
|
608
|
|
- UploadDate: time.Now().Unix(),
|
609
|
|
- AdviceId: advice_id,
|
610
|
|
- DetItemFeeSumamt: detItemFeeSumamt,
|
611
|
|
- Cnt: cut,
|
612
|
|
- Pric: pric,
|
613
|
|
- PatientId: id,
|
614
|
|
- Status: 1,
|
615
|
|
- Mtime: time.Now().Unix(),
|
616
|
|
- Ctime: time.Now().Unix(),
|
617
|
|
- UserOrgId: adminUser.CurrentOrgId,
|
618
|
|
- HisPatientId: record.ID,
|
619
|
|
- OrderId: order.ID,
|
620
|
|
- ProjectId: project_id,
|
621
|
|
- Type: types,
|
622
|
|
- ItemId: item_id,
|
623
|
|
- }
|
624
|
|
- service.CreateOrderInfo(info)
|
625
|
|
- }
|
626
|
|
- err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
|
627
|
|
- err = service.UpDateHospitalHisPrescriptionInfoNumber(adminUser.CurrentOrgId, chrg_bchno, start_time, end_time)
|
628
|
|
- err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
|
|
707
|
+ order.MdtrtId = record.Number
|
|
708
|
+ order.MedfeeSumamt = order.MedfeeSumamt
|
|
709
|
+ //order.SetlTime =
|
|
710
|
+ err := service.UpdataOrderStatusTwo(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId)
|
|
711
|
+ err = service.UpDateOrder(order)
|
629
|
712
|
if err == nil {
|
630
|
713
|
c.ServeSuccessJSON(map[string]interface{}{
|
631
|
714
|
"msg": "结算成功",
|
632
|
715
|
})
|
|
716
|
+ } else {
|
|
717
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
718
|
+ return
|
633
|
719
|
}
|
634
|
|
-
|
635
|
720
|
}
|
636
|
721
|
func (c *HisHospitalApiController) ZHRefund() {
|
637
|
722
|
order_id, _ := c.GetInt64("order_id")
|