|
@@ -10,6 +10,7 @@ import (
|
10
|
10
|
"github.com/astaxie/beego"
|
11
|
11
|
"io/ioutil"
|
12
|
12
|
"math/rand"
|
|
13
|
+ "os"
|
13
|
14
|
"strconv"
|
14
|
15
|
"strings"
|
15
|
16
|
"time"
|
|
@@ -28,8 +29,6 @@ type ResultReg struct {
|
28
|
29
|
type ResultSettle struct {
|
29
|
30
|
ResultCode string `json:"resultCode"`
|
30
|
31
|
ResultDesc string `json:"resultDesc"`
|
31
|
|
- DocId string `json:"docId"`
|
32
|
|
- Amount string `json:"amount"`
|
33
|
32
|
}
|
34
|
33
|
|
35
|
34
|
type ResultCancelSettle struct {
|
|
@@ -73,7 +72,6 @@ func CoordinateRcegistRouters() {
|
73
|
72
|
beego.Router("/coordinate/check", &CoordinateController{}, "get:SavePatientMessageInfo")
|
74
|
73
|
//坐标挂号
|
75
|
74
|
beego.Router("/coordinate/register", &CoordinateController{}, "get:Register")
|
76
|
|
- //beego.Router("/coordinate/getWaitPayDetail", &CoordinateController{}, "get:GetWaitPayDetail")
|
77
|
75
|
//坐标记账
|
78
|
76
|
beego.Router("/coordinate/opKeepAccounts", &CoordinateController{}, "get:OpKeepAccounts")
|
79
|
77
|
//坐标撤销记账
|
|
@@ -170,8 +168,8 @@ func (c *CoordinateController) Register() {
|
170
|
168
|
record_date := c.GetString("record_date")
|
171
|
169
|
admin_user_id, _ := c.GetInt64("admin_user_id")
|
172
|
170
|
org_id, _ := c.GetInt64("org_id")
|
173
|
|
- org_id = 4
|
174
|
171
|
patient, _ := service.GetPatientByID(org_id, patient_id)
|
|
172
|
+ org, _ := service.GetOrgById(org_id)
|
175
|
173
|
|
176
|
174
|
timeLayout := "2006-01-02"
|
177
|
175
|
loc, _ := time.LoadLocation("Local")
|
|
@@ -180,40 +178,40 @@ func (c *CoordinateController) Register() {
|
180
|
178
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
181
|
179
|
return
|
182
|
180
|
}
|
|
181
|
+ if len(patient.ZbPatientId) == 0 {
|
|
182
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnNoEmpty)
|
|
183
|
+ return
|
|
184
|
+ }
|
|
185
|
+
|
183
|
186
|
recordDateTime := theTime.Unix()
|
184
|
187
|
patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2)
|
185
|
188
|
if patientPrescription.ID == 0 {
|
186
|
189
|
patientPrescription, _ = service.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime)
|
187
|
190
|
}
|
188
|
|
- //department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
|
189
|
191
|
doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId)
|
190
|
|
-
|
191
|
|
- //admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
|
192
|
|
-
|
|
192
|
+ admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
|
193
|
193
|
reg := models.Reg{
|
194
|
194
|
DeptId: "0112",
|
195
|
195
|
PatientId: patient.ZbPatientId,
|
196
|
196
|
PatientName: patient.Name,
|
197
|
197
|
DoctorId: doctor_info.DoctorNumber,
|
198
|
198
|
RegDate: strings.Split(diagnosis_time, " ")[0],
|
199
|
|
- RegFee: "8",
|
200
|
|
- TreatFee: "10",
|
201
|
|
- OperatorId: "测试",
|
|
199
|
+ RegFee: "0",
|
|
200
|
+ TreatFee: "0",
|
|
201
|
+ OperatorId: admin_user_info.UserName,
|
202
|
202
|
IdCardNo: patient.IdCardNo,
|
203
|
203
|
}
|
204
|
204
|
|
205
|
205
|
result, request_log := service.SaveReg(reg)
|
206
|
206
|
fmt.Println(result)
|
207
|
207
|
fmt.Println(request_log)
|
208
|
|
-
|
|
208
|
+ saveLog(result, request_log, "登记", "登记", org.OrgName)
|
209
|
209
|
var res ResultReg
|
210
|
|
- //if err := json.Unmarshal([]byte(result), &res); err != nil {
|
211
|
|
- // utils.ErrorLog("解析失败:%v", err)
|
212
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
213
|
|
- // return
|
214
|
|
- //}
|
215
|
|
- res.ResultCode = "0"
|
216
|
|
- res.InfoSeq = "122333"
|
|
210
|
+ if err := json.Unmarshal([]byte(result), &res); err != nil {
|
|
211
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
212
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
213
|
+ return
|
|
214
|
+ }
|
217
|
215
|
if res.ResultCode == "0" {
|
218
|
216
|
timestamp := time.Now().Unix()
|
219
|
217
|
tempTime := time.Unix(timestamp, 0)
|
|
@@ -262,8 +260,12 @@ func (c *CoordinateController) Register() {
|
262
|
260
|
"his_info": his,
|
263
|
261
|
})
|
264
|
262
|
} else {
|
265
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
|
266
|
|
- return
|
|
263
|
+
|
|
264
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
265
|
+ "failed_code": -10,
|
|
266
|
+ "msg": res.ResultDesc,
|
|
267
|
+ })
|
|
268
|
+
|
267
|
269
|
}
|
268
|
270
|
}
|
269
|
271
|
|
|
@@ -287,7 +289,8 @@ func (c *CoordinateController) OpKeepAccounts() {
|
287
|
289
|
sick_type, _ := c.GetInt64("sick_type")
|
288
|
290
|
reg_type, _ := c.GetInt64("p_type")
|
289
|
291
|
org_id, _ := c.GetInt64("org_id")
|
290
|
|
- org_id = 4
|
|
292
|
+ org, _ := service.GetOrgById(org_id)
|
|
293
|
+
|
291
|
294
|
his, _ := service.GetHisPatientByIdThree(his_patient_id)
|
292
|
295
|
|
293
|
296
|
theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
|
|
@@ -433,22 +436,17 @@ func (c *CoordinateController) OpKeepAccounts() {
|
433
|
436
|
}
|
434
|
437
|
}
|
435
|
438
|
result, request_log := service.OpKeepAccounts(his.Number, customs)
|
436
|
|
-
|
437
|
|
- fmt.Println(result)
|
438
|
|
- fmt.Println(request_log)
|
|
439
|
+ saveLog(result, request_log, "记账", "记账", org.OrgName)
|
439
|
440
|
|
440
|
441
|
var res ResultSettle
|
441
|
|
- res.ResultCode = "0"
|
442
|
|
- res.DocId = "708275799870021632"
|
443
|
|
- res.Amount = "1088.00"
|
444
|
|
- //if err := json.Unmarshal([]byte(result), &res); err != nil {
|
445
|
|
- // utils.ErrorLog("解析失败:%v", err)
|
446
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
447
|
|
- // return
|
448
|
|
- //}
|
|
442
|
+ if err := json.Unmarshal([]byte(result), &res); err != nil {
|
|
443
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
444
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
445
|
+ return
|
|
446
|
+ }
|
449
|
447
|
if res.ResultCode == "0" {
|
450
|
|
- //allTotal := fmt.Sprintf("%.4f", total)
|
451
|
|
- totals, _ := strconv.ParseFloat(res.Amount, 64)
|
|
448
|
+
|
|
449
|
+ //totals, _ := strconv.ParseFloat(total, 64)
|
452
|
450
|
order := &models.HisOrder{
|
453
|
451
|
PsnNo: his.PsnNo,
|
454
|
452
|
UserOrgId: org_id,
|
|
@@ -461,8 +459,8 @@ func (c *CoordinateController) OpKeepAccounts() {
|
461
|
459
|
OrderStatus: 1,
|
462
|
460
|
MdtrtId: his.Number,
|
463
|
461
|
Number: chrg_bchno,
|
464
|
|
- SetlId: res.DocId,
|
465
|
|
- MedfeeSumamt: totals,
|
|
462
|
+ SetlId: "",
|
|
463
|
+ MedfeeSumamt: total,
|
466
|
464
|
MedType: strconv.Itoa(int(reg_type)),
|
467
|
465
|
SettleEndTime: end_time,
|
468
|
466
|
SettleStartTime: start_time,
|
|
@@ -536,6 +534,11 @@ func (c *CoordinateController) OpKeepAccounts() {
|
536
|
534
|
"msg": "记账成功",
|
537
|
535
|
})
|
538
|
536
|
}
|
|
537
|
+ } else {
|
|
538
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
539
|
+ "failed_code": -10,
|
|
540
|
+ "msg": res.ResultDesc,
|
|
541
|
+ })
|
539
|
542
|
}
|
540
|
543
|
|
541
|
544
|
}
|
|
@@ -544,7 +547,8 @@ func (c *CoordinateController) OpCancelKeepAccounts() {
|
544
|
547
|
order_id, _ := c.GetInt64("order_id")
|
545
|
548
|
admin_user_id, _ := c.GetInt64("admin_user_id")
|
546
|
549
|
org_id, _ := c.GetInt64("org_id")
|
547
|
|
- org_id = 4
|
|
550
|
+ org, _ := service.GetOrgById(org_id)
|
|
551
|
+
|
548
|
552
|
order, _ := service.GetHisOrderByID(order_id)
|
549
|
553
|
if order.ID == 0 {
|
550
|
554
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
|
|
@@ -553,7 +557,7 @@ func (c *CoordinateController) OpCancelKeepAccounts() {
|
553
|
557
|
|
554
|
558
|
role, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
|
555
|
559
|
result, request_log := service.OpCancelKeepAccounts(order.SetlId, role.UserName, role.DoctorNumber)
|
556
|
|
-
|
|
560
|
+ saveLog(result, request_log, "撤销记账", "撤销记账", org.OrgName)
|
557
|
561
|
var res RefundDetail
|
558
|
562
|
if err := json.Unmarshal([]byte(result), &res); err != nil {
|
559
|
563
|
utils.ErrorLog("解析失败:%v", err)
|
|
@@ -573,6 +577,10 @@ func (c *CoordinateController) OpCancelKeepAccounts() {
|
573
|
577
|
if len(res.Result) == flag {
|
574
|
578
|
isSuccess = true
|
575
|
579
|
}
|
|
580
|
+ var errMsg string
|
|
581
|
+ for _, item := range res.Result {
|
|
582
|
+ errMsg = errMsg + "\n" + item.ResultMsg
|
|
583
|
+ }
|
576
|
584
|
|
577
|
585
|
if isSuccess {
|
578
|
586
|
err := service.UpdataOrderStatus(order_id, order.Number, org_id)
|
|
@@ -585,8 +593,11 @@ func (c *CoordinateController) OpCancelKeepAccounts() {
|
585
|
593
|
return
|
586
|
594
|
}
|
587
|
595
|
} else {
|
588
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
589
|
|
- return
|
|
596
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
597
|
+ "failed_code": -10,
|
|
598
|
+ "msg": errMsg,
|
|
599
|
+ })
|
|
600
|
+
|
590
|
601
|
}
|
591
|
602
|
}
|
592
|
603
|
|
|
@@ -638,3 +649,45 @@ const (
|
638
|
649
|
UTF8 = Charset("UTF-8")
|
639
|
650
|
GB18030 = Charset("GB18030")
|
640
|
651
|
)
|
|
652
|
+
|
|
653
|
+func saveLog(result string, request string, infno string, desc string, org_name string) {
|
|
654
|
+
|
|
655
|
+ //org_id, _ := beego.AppConfig.Int64("org_id")
|
|
656
|
+ //miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
|
|
657
|
+ dir := org_name + "日志"
|
|
658
|
+ utils.Mkdir(dir)
|
|
659
|
+ month := time.Unix(1557042972, 0).Format("1")
|
|
660
|
+ year := time.Now().Format("2006")
|
|
661
|
+ month = time.Now().Format("01")
|
|
662
|
+ day := time.Now().Format("02")
|
|
663
|
+ hour := time.Now().Format("15")
|
|
664
|
+ min := time.Now().Format("04")
|
|
665
|
+ sec := time.Now().Format("05")
|
|
666
|
+
|
|
667
|
+ result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
|
|
668
|
+
|
|
669
|
+ file := org_name + "_" + year + month + day + "_log"
|
|
670
|
+ file_name := file + ".txt"
|
|
671
|
+ file_path := org_name + "日志" + "/" + file_name
|
|
672
|
+ exist, _ := utils.PathExists(file_path)
|
|
673
|
+ if exist { //存在
|
|
674
|
+ fmt.Println("存在")
|
|
675
|
+ f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
|
|
676
|
+ if err != nil {
|
|
677
|
+ fmt.Println("read fail")
|
|
678
|
+ }
|
|
679
|
+ content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
|
|
680
|
+ n, _ := f.Seek(0, 2)
|
|
681
|
+ _, err = f.WriteAt([]byte(content), n)
|
|
682
|
+
|
|
683
|
+ } else { //不存在
|
|
684
|
+ fmt.Println("文件不存在,创建文件")
|
|
685
|
+ f, err := os.Create(org_name + "日志" + "/" + file_name)
|
|
686
|
+ defer f.Close()
|
|
687
|
+ if err != nil {
|
|
688
|
+ } else {
|
|
689
|
+ _, err = f.Write([]byte("记录日志"))
|
|
690
|
+ }
|
|
691
|
+ }
|
|
692
|
+
|
|
693
|
+}
|