|
@@ -0,0 +1,639 @@
|
|
1
|
+package controllers
|
|
2
|
+
|
|
3
|
+import (
|
|
4
|
+ "XT_New/enums"
|
|
5
|
+ "XT_New/models"
|
|
6
|
+ "XT_New/service"
|
|
7
|
+ "XT_New/utils"
|
|
8
|
+ "encoding/json"
|
|
9
|
+ "fmt"
|
|
10
|
+ "github.com/astaxie/beego"
|
|
11
|
+ "io/ioutil"
|
|
12
|
+ "math/rand"
|
|
13
|
+ "strconv"
|
|
14
|
+ "strings"
|
|
15
|
+ "time"
|
|
16
|
+)
|
|
17
|
+
|
|
18
|
+type CoordinateController struct {
|
|
19
|
+ BaseAPIController
|
|
20
|
+}
|
|
21
|
+
|
|
22
|
+type ResultReg struct {
|
|
23
|
+ ResultCode string `json:"resultCode"`
|
|
24
|
+ ResultDesc string `json:"resultDesc"`
|
|
25
|
+ InfoSeq string `json:"infoSeq"`
|
|
26
|
+}
|
|
27
|
+
|
|
28
|
+type ResultSettle struct {
|
|
29
|
+ ResultCode string `json:"resultCode"`
|
|
30
|
+ ResultDesc string `json:"resultDesc"`
|
|
31
|
+ DocId string `json:"docId"`
|
|
32
|
+ Amount string `json:"amount"`
|
|
33
|
+}
|
|
34
|
+
|
|
35
|
+type ResultCancelSettle struct {
|
|
36
|
+ ResultCode string `json:"resultCode"`
|
|
37
|
+ ResultDesc string `json:"resultDesc"`
|
|
38
|
+}
|
|
39
|
+
|
|
40
|
+type Settle struct {
|
|
41
|
+ PatientId string `json:"resultCode"`
|
|
42
|
+ DocId string `json:"docId"`
|
|
43
|
+ InfoSeq string `json:"infoSeq"`
|
|
44
|
+}
|
|
45
|
+
|
|
46
|
+type Refund struct {
|
|
47
|
+ PatientId string `json:"resultCode"`
|
|
48
|
+ DocId string `json:"docId"`
|
|
49
|
+ InfoSeq string `json:"infoSeq"`
|
|
50
|
+}
|
|
51
|
+
|
|
52
|
+type RefundDetail struct {
|
|
53
|
+ Msg string `json:"msg"`
|
|
54
|
+ Result []struct {
|
|
55
|
+ ResultMsg string `json:"resultMsg"`
|
|
56
|
+ Code string `json:"code"`
|
|
57
|
+ Records int `json:"records"`
|
|
58
|
+ TotalPage int `json:"totalPage"`
|
|
59
|
+ List []struct {
|
|
60
|
+ Zae01 int64 `json:"ZAE01"`
|
|
61
|
+ } `json:"list"`
|
|
62
|
+ RecordsTotal int `json:"recordsTotal"`
|
|
63
|
+ Pagenumber int `json:"pagenumber"`
|
|
64
|
+ Result string `json:"result"`
|
|
65
|
+ Total int `json:"total"`
|
|
66
|
+ RecordsFtered int `json:"recordsFtered"`
|
|
67
|
+ Page int `json:"page"`
|
|
68
|
+ } `json:"result"`
|
|
69
|
+ Code string `json:"code"`
|
|
70
|
+}
|
|
71
|
+
|
|
72
|
+func CoordinateRegistRouters() {
|
|
73
|
+ beego.Router("/coordinate/check", &CoordinateController{}, "get:SavePatientMessageInfo")
|
|
74
|
+ //坐标挂号
|
|
75
|
+ beego.Router("/coordinate/register", &CoordinateController{}, "get:Register")
|
|
76
|
+ //beego.Router("/coordinate/getWaitPayDetail", &CoordinateController{}, "get:GetWaitPayDetail")
|
|
77
|
+ //坐标记账
|
|
78
|
+ beego.Router("/coordinate/opKeepAccounts", &CoordinateController{}, "get:OpKeepAccounts")
|
|
79
|
+ //坐标撤销记账
|
|
80
|
+ beego.Router("/coordinate/opCancelKeepAccounts", &CoordinateController{}, "get:OpCancelKeepAccounts")
|
|
81
|
+ //坐标结算回调
|
|
82
|
+ beego.Router("/coordinate/settle", &CoordinateController{}, "post:Settle")
|
|
83
|
+ //坐标退费回调
|
|
84
|
+ beego.Router("/coordinate/refund", &CoordinateController{}, "post:Refund")
|
|
85
|
+
|
|
86
|
+}
|
|
87
|
+
|
|
88
|
+func (c *CoordinateController) Settle() {
|
|
89
|
+ //参数1 patient_id
|
|
90
|
+ //参数2 就诊号
|
|
91
|
+ //参数3 单据id
|
|
92
|
+ fmt.Println(c.Ctx.Request.Body)
|
|
93
|
+
|
|
94
|
+ body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
|
|
95
|
+ fmt.Println(string(body))
|
|
96
|
+
|
|
97
|
+ var respJSON map[string]interface{}
|
|
98
|
+ if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
|
99
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
100
|
+ return
|
|
101
|
+ }
|
|
102
|
+ patien_id := respJSON["patientId"].(string)
|
|
103
|
+ infoSeq := respJSON["infoSeq"].(string)
|
|
104
|
+ docId := respJSON["docId"].(string)
|
|
105
|
+ fmt.Println(patien_id)
|
|
106
|
+ fmt.Println(infoSeq)
|
|
107
|
+ fmt.Println(docId)
|
|
108
|
+
|
|
109
|
+ order, _ := service.GetHisOrderFour(patien_id, infoSeq, docId)
|
|
110
|
+ if order.ID == 0 {
|
|
111
|
+ json := make(map[string]interface{})
|
|
112
|
+ json["msg"] = "结算记录不存在,请检查参数是否正确"
|
|
113
|
+ json["code"] = "-1"
|
|
114
|
+ c.Data["json"] = json
|
|
115
|
+ c.ServeJSON()
|
|
116
|
+ return
|
|
117
|
+ }
|
|
118
|
+ order.OrderStatus = 2
|
|
119
|
+ service.UpDateOrder(order)
|
|
120
|
+ service.UpdataOrderStatusTwo(order.Number, order.UserOrgId)
|
|
121
|
+ json := make(map[string]interface{})
|
|
122
|
+ json["msg"] = "结算成功"
|
|
123
|
+ json["code"] = "0"
|
|
124
|
+ c.Data["json"] = json
|
|
125
|
+ c.ServeJSON()
|
|
126
|
+ return
|
|
127
|
+}
|
|
128
|
+func (c *CoordinateController) Refund() {
|
|
129
|
+ //参数1 patient_id
|
|
130
|
+ //参数2 就诊号
|
|
131
|
+ //参数3 单据id
|
|
132
|
+ body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
|
|
133
|
+ var respJSON map[string]interface{}
|
|
134
|
+ if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
|
135
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
136
|
+ return
|
|
137
|
+ }
|
|
138
|
+ patien_id := respJSON["patientId"].(string)
|
|
139
|
+ infoSeq := respJSON["infoSeq"].(string)
|
|
140
|
+ docId := respJSON["docId"].(string)
|
|
141
|
+ order, _ := service.GetHisOrderFour(patien_id, infoSeq, docId)
|
|
142
|
+ if order.ID == 0 {
|
|
143
|
+ json := make(map[string]interface{})
|
|
144
|
+ json["msg"] = "结算记录不存在,请检查参数是否正确"
|
|
145
|
+ json["code"] = "-1"
|
|
146
|
+ c.Data["json"] = json
|
|
147
|
+ c.ServeJSON()
|
|
148
|
+ return
|
|
149
|
+ }
|
|
150
|
+ service.UpdataOrderStatus(order.ID, order.Number, order.UserOrgId)
|
|
151
|
+ json := make(map[string]interface{})
|
|
152
|
+ json["msg"] = "退费成功"
|
|
153
|
+ json["code"] = "0"
|
|
154
|
+ c.Data["json"] = json
|
|
155
|
+ c.ServeJSON()
|
|
156
|
+ return
|
|
157
|
+}
|
|
158
|
+
|
|
159
|
+func (c *CoordinateController) SavePatientMessageInfo() {
|
|
160
|
+ result, request_log := service.SavePatientMessageInfo()
|
|
161
|
+ fmt.Println(result)
|
|
162
|
+ fmt.Println(request_log)
|
|
163
|
+
|
|
164
|
+}
|
|
165
|
+
|
|
166
|
+func (c *CoordinateController) Register() {
|
|
167
|
+ patient_id, _ := c.GetInt64("patient_id")
|
|
168
|
+ diagnosis_time := c.GetString("diagnosis_time")
|
|
169
|
+ record_date := c.GetString("record_date")
|
|
170
|
+ admin_user_id, _ := c.GetInt64("admin_user_id")
|
|
171
|
+ org_id, _ := c.GetInt64("org_id")
|
|
172
|
+ org_id = 4
|
|
173
|
+ patient, _ := service.GetPatientByID(org_id, patient_id)
|
|
174
|
+
|
|
175
|
+ timeLayout := "2006-01-02"
|
|
176
|
+ loc, _ := time.LoadLocation("Local")
|
|
177
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
|
|
178
|
+ if err != nil {
|
|
179
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
180
|
+ return
|
|
181
|
+ }
|
|
182
|
+ recordDateTime := theTime.Unix()
|
|
183
|
+ patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2)
|
|
184
|
+ if patientPrescription.ID == 0 {
|
|
185
|
+ patientPrescription, _ = service.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime)
|
|
186
|
+ }
|
|
187
|
+ //department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
|
|
188
|
+ doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId)
|
|
189
|
+
|
|
190
|
+ //admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
|
|
191
|
+
|
|
192
|
+ reg := models.Reg{
|
|
193
|
+ DeptId: "0112",
|
|
194
|
+ PatientId: patient.ZbPatientId,
|
|
195
|
+ PatientName: patient.Name,
|
|
196
|
+ DoctorId: doctor_info.DoctorNumber,
|
|
197
|
+ RegDate: strings.Split(diagnosis_time, " ")[0],
|
|
198
|
+ RegFee: "8",
|
|
199
|
+ TreatFee: "10",
|
|
200
|
+ OperatorId: "测试",
|
|
201
|
+ IdCardNo: patient.IdCardNo,
|
|
202
|
+ }
|
|
203
|
+
|
|
204
|
+ result, request_log := service.SaveReg(reg)
|
|
205
|
+ fmt.Println(result)
|
|
206
|
+ fmt.Println(request_log)
|
|
207
|
+
|
|
208
|
+ var res ResultReg
|
|
209
|
+ //if err := json.Unmarshal([]byte(result), &res); err != nil {
|
|
210
|
+ // utils.ErrorLog("解析失败:%v", err)
|
|
211
|
+ // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
212
|
+ // return
|
|
213
|
+ //}
|
|
214
|
+ res.ResultCode = "0"
|
|
215
|
+ res.InfoSeq = "122333"
|
|
216
|
+ if res.ResultCode == "0" {
|
|
217
|
+ timestamp := time.Now().Unix()
|
|
218
|
+ tempTime := time.Unix(timestamp, 0)
|
|
219
|
+ timeFormat := tempTime.Format("20060102150405")
|
|
220
|
+ chrgBchno := rand.Intn(100000) + 10000
|
|
221
|
+ ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(patient.ID, 10)
|
|
222
|
+ his := models.VMHisPatient{
|
|
223
|
+ Name: patient.Name,
|
|
224
|
+ Gender: patient.Gender,
|
|
225
|
+ Birthday: patient.Birthday,
|
|
226
|
+ MedicalTreatmentType: 0,
|
|
227
|
+ IdType: 1,
|
|
228
|
+ IdCardNo: patient.IdCardNo,
|
|
229
|
+ BalanceAccountsType: 1,
|
|
230
|
+ MedicalInsuranceNumber: "",
|
|
231
|
+ RegisterType: 0,
|
|
232
|
+ RegisterCost: 0,
|
|
233
|
+ TreatmentCost: 0,
|
|
234
|
+ Status: 1,
|
|
235
|
+ Ctime: time.Now().Unix(),
|
|
236
|
+ Mtime: time.Now().Unix(),
|
|
237
|
+ PsnNo: patient.ZbPatientId,
|
|
238
|
+ PsnCertType: "",
|
|
239
|
+ Certno: patient.IdCardNo,
|
|
240
|
+ PsnName: patient.Name,
|
|
241
|
+ Gend: "",
|
|
242
|
+ Naty: "",
|
|
243
|
+ Brdy: "",
|
|
244
|
+ Age: 0,
|
|
245
|
+ Iinfo: "",
|
|
246
|
+ Idetinfo: "",
|
|
247
|
+ PatientId: patient.ID,
|
|
248
|
+ RecordDate: theTime.Unix(),
|
|
249
|
+ UserOrgId: org_id,
|
|
250
|
+ AdminUserId: admin_user_id,
|
|
251
|
+ IsReturn: 1,
|
|
252
|
+ Doctor: patientPrescription.DoctorId,
|
|
253
|
+ Departments: patientPrescription.Departments,
|
|
254
|
+ IptOtpNo: ipt_otp_no,
|
|
255
|
+ Number: res.InfoSeq,
|
|
256
|
+ PhoneNumber: patient.Phone,
|
|
257
|
+ }
|
|
258
|
+ service.UpdateHisPatientStatus(&his)
|
|
259
|
+ service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, org_id)
|
|
260
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
261
|
+ "his_info": his,
|
|
262
|
+ })
|
|
263
|
+ } else {
|
|
264
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
|
|
265
|
+ return
|
|
266
|
+ }
|
|
267
|
+}
|
|
268
|
+
|
|
269
|
+//func (c *CoordinateController) GetWaitPayDetail() {
|
|
270
|
+// result, request_log := service.GetWaitPayDetail()
|
|
271
|
+// fmt.Println(result)
|
|
272
|
+// fmt.Println(request_log)
|
|
273
|
+//
|
|
274
|
+//}
|
|
275
|
+
|
|
276
|
+func (c *CoordinateController) OpKeepAccounts() {
|
|
277
|
+ id, _ := c.GetInt64("id")
|
|
278
|
+ record_time := c.GetString("record_time")
|
|
279
|
+ his_patient_id, _ := c.GetInt64("his_patient_id")
|
|
280
|
+ timeLayout := "2006-01-02"
|
|
281
|
+ loc, _ := time.LoadLocation("Local")
|
|
282
|
+ settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
|
|
283
|
+ fapiao_code := c.GetString("fapiao_code")
|
|
284
|
+ fapiao_number := c.GetString("fapiao_number")
|
|
285
|
+ diagnosis_id := c.GetString("diagnosis")
|
|
286
|
+ sick_type, _ := c.GetInt64("sick_type")
|
|
287
|
+ reg_type, _ := c.GetInt64("p_type")
|
|
288
|
+ org_id, _ := c.GetInt64("org_id")
|
|
289
|
+ org_id = 4
|
|
290
|
+ his, _ := service.GetHisPatientByIdThree(his_patient_id)
|
|
291
|
+
|
|
292
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
|
|
293
|
+ if err != nil {
|
|
294
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
295
|
+ return
|
|
296
|
+ }
|
|
297
|
+ recordDateTime := theTime.Unix()
|
|
298
|
+ //adminUser := c.GetAdminUserInfo()
|
|
299
|
+ var prescriptions []*models.HisPrescription
|
|
300
|
+ var start_time int64
|
|
301
|
+ var end_time int64
|
|
302
|
+
|
|
303
|
+ //ids_str := c.GetString("ids")
|
|
304
|
+ //ids_arr := strings.Split(ids_str, ",")
|
|
305
|
+
|
|
306
|
+ if settle_accounts_type == 1 { //日结
|
|
307
|
+ //fmt.Println(reg_type)
|
|
308
|
+ prescriptions, _ = service.GetUnSettleHisPrescriptionFive(org_id, id, recordDateTime, 2)
|
|
309
|
+
|
|
310
|
+ } else { //月结
|
|
311
|
+
|
|
312
|
+ start_time_str := c.GetString("start_time")
|
|
313
|
+ end_time_str := c.GetString("end_time")
|
|
314
|
+ timeLayout := "2006-01-02"
|
|
315
|
+ loc, _ := time.LoadLocation("Local")
|
|
316
|
+ theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
|
|
317
|
+ if err != nil {
|
|
318
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
319
|
+ return
|
|
320
|
+ }
|
|
321
|
+ recordStartTime := theStartTime.Unix()
|
|
322
|
+ start_time = recordStartTime
|
|
323
|
+ theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
|
|
324
|
+ if err != nil {
|
|
325
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
326
|
+ return
|
|
327
|
+ }
|
|
328
|
+ recordEndTime := theEndTime.Unix()
|
|
329
|
+ end_time = recordEndTime
|
|
330
|
+ prescriptions, _ = service.GetUnSettleMonthHisPrescription(org_id, id, recordStartTime, recordEndTime)
|
|
331
|
+ }
|
|
332
|
+
|
|
333
|
+ timestamp := time.Now().Unix()
|
|
334
|
+ tempTime := time.Unix(timestamp, 0)
|
|
335
|
+ timeFormat := tempTime.Format("20060102150405")
|
|
336
|
+ chrgBchno := rand.Intn(100000) + 10000
|
|
337
|
+ chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
|
|
338
|
+ strconv.FormatInt(his.PatientId, 10)
|
|
339
|
+
|
|
340
|
+ var ids []int64
|
|
341
|
+
|
|
342
|
+ for _, item := range prescriptions {
|
|
343
|
+ ids = append(ids, item.ID)
|
|
344
|
+ }
|
|
345
|
+ var total float64
|
|
346
|
+
|
|
347
|
+ for _, item := range prescriptions {
|
|
348
|
+ fmt.Println(item)
|
|
349
|
+ if item.Type == 1 { //药品
|
|
350
|
+ for _, subItem := range item.HisDoctorAdviceInfo {
|
|
351
|
+ total = total + (subItem.Price * subItem.PrescribingNumber)
|
|
352
|
+ }
|
|
353
|
+ }
|
|
354
|
+ if item.Type == 2 { //项目
|
|
355
|
+ for _, subItem := range item.HisPrescriptionProject {
|
|
356
|
+ cnt, _ := strconv.ParseFloat(subItem.Count, 64)
|
|
357
|
+ total = total + (subItem.Price * cnt)
|
|
358
|
+ }
|
|
359
|
+ }
|
|
360
|
+
|
|
361
|
+ for _, subItem := range item.HisAdditionalCharge {
|
|
362
|
+ total = total + (subItem.Price * float64(subItem.Count))
|
|
363
|
+ }
|
|
364
|
+ }
|
|
365
|
+
|
|
366
|
+ tm := time.Unix(time.Now().Unix(), 0)
|
|
367
|
+
|
|
368
|
+ var customs []*models.NewCustomTwo
|
|
369
|
+ for _, item := range prescriptions {
|
|
370
|
+ if item.Type == 1 { //药品
|
|
371
|
+ for _, subItem := range item.HisDoctorAdviceInfo {
|
|
372
|
+ cus := &models.NewCustomTwo{
|
|
373
|
+ AdviceId: subItem.ID,
|
|
374
|
+ ProjectId: 0,
|
|
375
|
+ DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
|
|
376
|
+ Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
|
|
377
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
378
|
+ Price: fmt.Sprintf("%.2f", subItem.Price),
|
|
379
|
+ MedListCodg: subItem.Drug.MedicalInsuranceNumber,
|
|
380
|
+ Type: 1,
|
|
381
|
+ }
|
|
382
|
+ customs = append(customs, cus)
|
|
383
|
+ }
|
|
384
|
+ }
|
|
385
|
+ if item.Type == 2 { //项目
|
|
386
|
+ for _, subItem := range item.HisPrescriptionProject {
|
|
387
|
+ if subItem.Type == 2 {
|
|
388
|
+ cnt, _ := strconv.ParseFloat(subItem.Count, 64)
|
|
389
|
+ cus := &models.NewCustomTwo{
|
|
390
|
+ AdviceId: 0,
|
|
391
|
+ ProjectId: subItem.ID,
|
|
392
|
+ DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
|
|
393
|
+ Cut: fmt.Sprintf("%.4f", cnt),
|
|
394
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
395
|
+ Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
|
|
396
|
+ MedListCodg: subItem.HisProject.MedicalCode,
|
|
397
|
+ Type: 2,
|
|
398
|
+ }
|
|
399
|
+ customs = append(customs, cus)
|
|
400
|
+
|
|
401
|
+ } else {
|
|
402
|
+ cnt, _ := strconv.ParseFloat(subItem.Count, 64)
|
|
403
|
+ cus := &models.NewCustomTwo{
|
|
404
|
+ AdviceId: 0,
|
|
405
|
+ ProjectId: subItem.ID,
|
|
406
|
+ DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
|
|
407
|
+ Cut: fmt.Sprintf("%.4f", cnt),
|
|
408
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
409
|
+ Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
|
|
410
|
+ MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
|
|
411
|
+ Type: 3,
|
|
412
|
+ }
|
|
413
|
+ customs = append(customs, cus)
|
|
414
|
+
|
|
415
|
+ }
|
|
416
|
+
|
|
417
|
+ }
|
|
418
|
+ }
|
|
419
|
+ for _, item := range item.HisAdditionalCharge {
|
|
420
|
+ cus := &models.NewCustomTwo{
|
|
421
|
+ ItemId: item.ID,
|
|
422
|
+ AdviceId: 0,
|
|
423
|
+ ProjectId: 0,
|
|
424
|
+ DetItemFeeSumamt: fmt.Sprintf("%.4f", item.Price),
|
|
425
|
+ Cut: fmt.Sprintf("%.4f", float64(item.Count)),
|
|
426
|
+ FeedetlSn: item.FeedetlSn,
|
|
427
|
+ Price: fmt.Sprintf("%.4f", float64(item.Price)),
|
|
428
|
+ MedListCodg: item.XtHisAddtionConfig.Code,
|
|
429
|
+ Type: 3,
|
|
430
|
+ }
|
|
431
|
+ customs = append(customs, cus)
|
|
432
|
+ }
|
|
433
|
+ }
|
|
434
|
+ result, request_log := service.OpKeepAccounts(his.Number, customs)
|
|
435
|
+
|
|
436
|
+ fmt.Println(result)
|
|
437
|
+ fmt.Println(request_log)
|
|
438
|
+
|
|
439
|
+ var res ResultSettle
|
|
440
|
+ res.ResultCode = "0"
|
|
441
|
+ res.DocId = "708275799870021632"
|
|
442
|
+ res.Amount = "1088.00"
|
|
443
|
+ //if err := json.Unmarshal([]byte(result), &res); err != nil {
|
|
444
|
+ // utils.ErrorLog("解析失败:%v", err)
|
|
445
|
+ // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
446
|
+ // return
|
|
447
|
+ //}
|
|
448
|
+ if res.ResultCode == "0" {
|
|
449
|
+ //allTotal := fmt.Sprintf("%.4f", total)
|
|
450
|
+ totals, _ := strconv.ParseFloat(res.Amount, 64)
|
|
451
|
+ order := &models.HisOrder{
|
|
452
|
+ PsnNo: his.PsnNo,
|
|
453
|
+ UserOrgId: org_id,
|
|
454
|
+ HisPatientId: his.ID,
|
|
455
|
+ PatientId: id,
|
|
456
|
+ SettleAccountsDate: recordDateTime,
|
|
457
|
+ Ctime: time.Now().Unix(),
|
|
458
|
+ Mtime: time.Now().Unix(),
|
|
459
|
+ Status: 1,
|
|
460
|
+ OrderStatus: 1,
|
|
461
|
+ MdtrtId: his.Number,
|
|
462
|
+ Number: chrg_bchno,
|
|
463
|
+ SetlId: res.DocId,
|
|
464
|
+ MedfeeSumamt: totals,
|
|
465
|
+ MedType: strconv.Itoa(int(reg_type)),
|
|
466
|
+ SettleEndTime: end_time,
|
|
467
|
+ SettleStartTime: start_time,
|
|
468
|
+ SettleType: settle_accounts_type,
|
|
469
|
+ FaPiaoCode: fapiao_code,
|
|
470
|
+ FaPiaoNumber: fapiao_number,
|
|
471
|
+ Diagnosis: diagnosis_id,
|
|
472
|
+ PType: 2,
|
|
473
|
+ SetlTime: tm.Format("2006-01-02 15:04:05"),
|
|
474
|
+ }
|
|
475
|
+ err = service.CreateOrder(order)
|
|
476
|
+ if err != nil {
|
|
477
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
|
|
478
|
+ return
|
|
479
|
+ }
|
|
480
|
+
|
|
481
|
+ for _, item := range customs {
|
|
482
|
+ var advice_id int64 = 0
|
|
483
|
+ var project_id int64 = 0
|
|
484
|
+ var item_id int64 = 0
|
|
485
|
+
|
|
486
|
+ var types int64 = 0
|
|
487
|
+
|
|
488
|
+ if item.Type == 1 {
|
|
489
|
+ advice_id = item.AdviceId
|
|
490
|
+ project_id = 0
|
|
491
|
+ item_id = 0
|
|
492
|
+ } else if item.Type == 2 {
|
|
493
|
+ advice_id = 0
|
|
494
|
+ item_id = 0
|
|
495
|
+
|
|
496
|
+ project_id = item.ProjectId
|
|
497
|
+ } else if item.Type == 3 {
|
|
498
|
+ advice_id = 0
|
|
499
|
+ item_id = item.ItemId
|
|
500
|
+ project_id = 0
|
|
501
|
+ }
|
|
502
|
+ detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
|
|
503
|
+ cut, _ := strconv.ParseFloat(item.Cut, 32)
|
|
504
|
+ pric, _ := strconv.ParseFloat(item.Price, 32)
|
|
505
|
+ info := &models.HisOrderInfo{
|
|
506
|
+ OrderNumber: order.Number,
|
|
507
|
+ UploadDate: time.Now().Unix(),
|
|
508
|
+ AdviceId: advice_id,
|
|
509
|
+ DetItemFeeSumamt: detItemFeeSumamt,
|
|
510
|
+ Cnt: cut,
|
|
511
|
+ Pric: pric,
|
|
512
|
+ PatientId: id,
|
|
513
|
+ Status: 1,
|
|
514
|
+ Mtime: time.Now().Unix(),
|
|
515
|
+ Ctime: time.Now().Unix(),
|
|
516
|
+ UserOrgId: org_id,
|
|
517
|
+ HisPatientId: his.ID,
|
|
518
|
+ OrderId: order.ID,
|
|
519
|
+ ProjectId: project_id,
|
|
520
|
+ Type: types,
|
|
521
|
+ ItemId: item_id,
|
|
522
|
+ }
|
|
523
|
+ service.CreateOrderInfo(info)
|
|
524
|
+ }
|
|
525
|
+ his.Diagnosis = diagnosis_id
|
|
526
|
+ his.SickType = sick_type
|
|
527
|
+ his.RegisterType = reg_type
|
|
528
|
+ his.MedicalTreatmentType = reg_type
|
|
529
|
+ service.UpdataHisPateint(&his)
|
|
530
|
+ err = service.UpDatePrescriptionNumber(org_id, ids, chrg_bchno)
|
|
531
|
+ err = service.UpDateHisPrescriptionInfoNumber(org_id, id, chrg_bchno, recordDateTime, his_patient_id)
|
|
532
|
+ err = service.UpdataOrderStatusThree(chrg_bchno, org_id)
|
|
533
|
+ if err == nil {
|
|
534
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
535
|
+ "msg": "记账成功",
|
|
536
|
+ })
|
|
537
|
+ }
|
|
538
|
+ }
|
|
539
|
+
|
|
540
|
+}
|
|
541
|
+
|
|
542
|
+func (c *CoordinateController) OpCancelKeepAccounts() {
|
|
543
|
+ order_id, _ := c.GetInt64("order_id")
|
|
544
|
+ admin_user_id, _ := c.GetInt64("admin_user_id")
|
|
545
|
+ org_id, _ := c.GetInt64("org_id")
|
|
546
|
+ org_id = 4
|
|
547
|
+ order, _ := service.GetHisOrderByID(order_id)
|
|
548
|
+ if order.ID == 0 {
|
|
549
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
|
|
550
|
+ return
|
|
551
|
+ }
|
|
552
|
+
|
|
553
|
+ role, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
|
|
554
|
+ result, request_log := service.OpCancelKeepAccounts(order.SetlId, role.UserName, role.DoctorNumber)
|
|
555
|
+
|
|
556
|
+ var res RefundDetail
|
|
557
|
+ if err := json.Unmarshal([]byte(result), &res); err != nil {
|
|
558
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
559
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
560
|
+ return
|
|
561
|
+ }
|
|
562
|
+ fmt.Println(result)
|
|
563
|
+ fmt.Println(request_log)
|
|
564
|
+ fmt.Println(res)
|
|
565
|
+ flag := 0
|
|
566
|
+ isSuccess := false
|
|
567
|
+ for _, item := range res.Result {
|
|
568
|
+ if item.Code == "200" {
|
|
569
|
+ flag = flag + 1
|
|
570
|
+ }
|
|
571
|
+ }
|
|
572
|
+ if len(res.Result) == flag {
|
|
573
|
+ isSuccess = true
|
|
574
|
+ }
|
|
575
|
+
|
|
576
|
+ if isSuccess {
|
|
577
|
+ err := service.UpdataOrderStatus(order_id, order.Number, org_id)
|
|
578
|
+ if err == nil {
|
|
579
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
580
|
+ "msg": "撤销记账成功",
|
|
581
|
+ })
|
|
582
|
+ } else {
|
|
583
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
584
|
+ return
|
|
585
|
+ }
|
|
586
|
+ } else {
|
|
587
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
588
|
+ return
|
|
589
|
+ }
|
|
590
|
+}
|
|
591
|
+
|
|
592
|
+//func saveLog(result string, request string, infno string, desc string) {
|
|
593
|
+//
|
|
594
|
+// org_id, _ := beego.AppConfig.Int64("org_id")
|
|
595
|
+// miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
|
|
596
|
+// dir := miConfig.OrgName + "日志"
|
|
597
|
+// utils.Mkdir(dir)
|
|
598
|
+// month := time.Unix(1557042972, 0).Format("1")
|
|
599
|
+// year := time.Now().Format("2006")
|
|
600
|
+// month = time.Now().Format("01")
|
|
601
|
+// day := time.Now().Format("02")
|
|
602
|
+// hour := time.Now().Format("15")
|
|
603
|
+// min := time.Now().Format("04")
|
|
604
|
+// sec := time.Now().Format("05")
|
|
605
|
+//
|
|
606
|
+// result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
|
|
607
|
+//
|
|
608
|
+// file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
|
|
609
|
+// file_name := file + ".txt"
|
|
610
|
+// file_path := miConfig.OrgName + "日志" + "/" + file_name
|
|
611
|
+// exist, _ := utils.PathExists(file_path)
|
|
612
|
+// if exist { //存在
|
|
613
|
+// fmt.Println("存在")
|
|
614
|
+// f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
|
|
615
|
+// if err != nil {
|
|
616
|
+// fmt.Println("read fail")
|
|
617
|
+// }
|
|
618
|
+// content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
|
|
619
|
+// n, _ := f.Seek(0, 2)
|
|
620
|
+// _, err = f.WriteAt([]byte(content), n)
|
|
621
|
+//
|
|
622
|
+// } else { //不存在
|
|
623
|
+// fmt.Println("文件不存在,创建文件")
|
|
624
|
+// f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
|
|
625
|
+// defer f.Close()
|
|
626
|
+// if err != nil {
|
|
627
|
+// } else {
|
|
628
|
+// _, err = f.Write([]byte("记录日志"))
|
|
629
|
+// }
|
|
630
|
+// }
|
|
631
|
+//
|
|
632
|
+//}
|
|
633
|
+
|
|
634
|
+type Charset string
|
|
635
|
+
|
|
636
|
+const (
|
|
637
|
+ UTF8 = Charset("UTF-8")
|
|
638
|
+ GB18030 = Charset("GB18030")
|
|
639
|
+)
|