|
@@ -6,6 +6,9 @@ import (
|
6
|
6
|
"XT_New/service"
|
7
|
7
|
"fmt"
|
8
|
8
|
"github.com/astaxie/beego"
|
|
9
|
+ "math/rand"
|
|
10
|
+ "strconv"
|
|
11
|
+ "strings"
|
9
|
12
|
"time"
|
10
|
13
|
)
|
11
|
14
|
|
|
@@ -14,62 +17,17 @@ type HisHospitalApiController struct {
|
14
|
17
|
}
|
15
|
18
|
|
16
|
19
|
func HisHospitalManagerApiRegistRouters() {
|
17
|
|
-
|
18
|
20
|
beego.Router("/api/hishospitalpatient/list", &HisHospitalApiController{}, "get:GetHisHospitalPatientList")
|
19
|
|
-
|
20
|
|
- //beego.Router("/api/hishospitalprescription/list", &HisHospitalApiController{}, "get:GetHisHospitalPrescriptionList")
|
21
|
|
-
|
22
|
21
|
beego.Router("/api/hospitalcharge/list", &HisHospitalApiController{}, "get:GetHisHospitalChargePatientList")
|
23
|
22
|
beego.Router("/api/hospotalcharge/info", &HisHospitalApiController{}, "get:GetHisHospitalChargePatientInfo")
|
24
|
|
-
|
25
|
23
|
beego.Router("/api/hospitalprescription/list", &HisHospitalApiController{}, "get:GetHisHospitalPrescriptionList")
|
26
|
|
- //beego.Router("/api/hishospitalprescription/info", &HisApiController{}, "get:GetHisHospitalPrescriptionInfo")
|
27
|
|
-
|
28
|
|
- //beego.Router("/api/hisprescription/create", &HisApiController{}, "post:CreateHisPrescription")
|
29
|
|
- //beego.Router("/api/hisprescription/edit", &HisApiController{}, "post:EditHisPrescription")
|
30
|
|
-
|
31
|
|
- //beego.Router("/api/doctorworkstation/casehistory/list", &HisApiController{}, "get:GetHisPatientCaseHistoryList")
|
32
|
|
- //beego.Router("/api/doctorworkstation/casehistory/get", &HisApiController{}, "get:GetHisPatientCaseHistory")
|
33
|
|
- //beego.Router("/api/doctorworkstation/casehistory/create", &HisApiController{}, "get:CreateHisPatientCaseHistory")
|
34
|
|
-
|
35
|
|
- //beego.Router("/api/doctorworkstation/casehistorytemplate/create", &HisApiController{}, "get:CreateCaseHistoryTemplate")
|
36
|
|
- //beego.Router("/api/doctorworkstation/casehistorytemplate/get", &HisApiController{}, "get:GetCaseHistoryTemplate")
|
37
|
|
-
|
38
|
|
- //beego.Router("/api/hisorder/list", &HisApiController{}, "get:GetHisOrderList")
|
39
|
|
- //beego.Router("/api/hisorder/get", &HisApiController{}, "get:GetHisOrder")
|
40
|
|
-
|
41
|
|
- //beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
|
42
|
|
- //
|
43
|
|
- //beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
|
44
|
|
- //
|
45
|
|
- //beego.Router("/api/refund/post", &HisApiController{}, "post:Refund")
|
46
|
|
- //
|
47
|
|
- //beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
|
48
|
|
- //
|
49
|
|
- //beego.Router("/api/doctor/list", &HisApiController{}, "get:GetAdminUsers")
|
50
|
|
-
|
51
|
|
- //beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
|
52
|
|
- //新增附加费用
|
53
|
|
- //beego.Router("/api/his/additionalcharge", &HisApiController{}, "Post:AdditionalCharge")
|
54
|
|
- //beego.Router("/api/additionalcharge/get", &HisApiController{}, "Get:GetAdditionalcharge")
|
55
|
|
- //beego.Router("/api/hisprescription/get", &HisApiController{}, "Get:GetLastOrNextHisPrescription")
|
56
|
|
- //beego.Router("/api/callhisprescription/get", &HisApiController{}, "Get:GetCallHisPrescription")
|
57
|
|
- //beego.Router("/api/dayprescription/get", &HisApiController{}, "get:GetHisDayPrescription")
|
58
|
|
- //beego.Router("/api/charge/list", &HisApiController{}, "get:GetHisChargePatientList")
|
59
|
|
- //beego.Router("/api/charge/info", &HisApiController{}, "get:GetHisChargePatientInfo")
|
60
|
|
- //beego.Router("/api/unregister/list", &HisApiController{}, "get:GetHisUnRegisterPatientList")
|
61
|
|
- //beego.Router("/api/orderdetail/get", &HisApiController{}, "get:GetAllOrderDetail")
|
62
|
|
- //beego.Router("/api/orderdetaicollect/get", &HisApiController{}, "get:GetAllOrderDetailCollect")
|
63
|
|
- //beego.Router("/api/cost/compare", &HisApiController{}, "get:GetMedicalInsuranceCostCompareList")
|
64
|
|
- //beego.Router("/api/record/list", &HisApiController{}, "get:GetPutOnRecordList")
|
65
|
|
- //
|
66
|
|
- //beego.Router("/api/comparedata/get", &HisApiController{}, "get:GetCompareData")
|
67
|
|
- //beego.Router("/api/fapiao/get", &HisApiController{}, "get:GetFaPiaoData")
|
68
|
|
- //
|
69
|
|
- //beego.Router("/api/incomestatistics/get", &HisApiController{}, "get:GetIncomeStatisticsData")
|
70
|
|
- //
|
71
|
|
- //beego.Router("/api/postprojectinformation", &HisApiController{}, "post:PostProjectInformation")
|
72
|
24
|
|
|
25
|
+ beego.Router("/api/hospital/inhopitalcheck/get", &HisHospitalApiController{}, "get:GetZHInHospitalCheck")
|
|
26
|
+ beego.Router("/api/hospital/outhopitalcheck/get", &HisHospitalApiController{}, "get:GetZHOutHospitalCheck")
|
|
27
|
+ beego.Router("/api/hospital/settle/get", &HisHospitalApiController{}, "get:GetSettleInfo")
|
|
28
|
+ beego.Router("/api/hospital/inthopitaluncheck/get", &HisHospitalApiController{}, "get:GetZHInHospitalUnCheck")
|
|
29
|
+ beego.Router("/api/hospital/outhopitaluncheck/get", &HisHospitalApiController{}, "get:GetZHOutHospitalUnCheck")
|
|
30
|
+ beego.Router("/api/hospital/refund", &HisHospitalApiController{}, "get:ZHRefund")
|
73
|
31
|
}
|
74
|
32
|
|
75
|
33
|
func (c *HisHospitalApiController) GetHisHospitalPatientList() {
|
|
@@ -157,7 +115,6 @@ func (c *HisHospitalApiController) GetHisHospitalPatientList() {
|
157
|
115
|
})
|
158
|
116
|
}
|
159
|
117
|
}
|
160
|
|
-
|
161
|
118
|
func (c *HisHospitalApiController) GetHisHospitalChargePatientList() {
|
162
|
119
|
record_date := c.GetString("record_date")
|
163
|
120
|
timeLayout := "2006-01-02"
|
|
@@ -170,7 +127,8 @@ func (c *HisHospitalApiController) GetHisHospitalChargePatientList() {
|
170
|
127
|
recordDateTime := theTime.Unix()
|
171
|
128
|
adminInfo := c.GetAdminUserInfo()
|
172
|
129
|
//tempPatients, _ := service.GetAllChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
|
173
|
|
- tempPatients, _ := service.GetNewAllChargeHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime)
|
|
130
|
+ orders, _ := service.GetNewAllChargeHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime)
|
|
131
|
+ tempPatients, _ := service.GetNewAllUnChargeHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime)
|
174
|
132
|
|
175
|
133
|
var patients []*service.HospitalPatient
|
176
|
134
|
for _, item := range tempPatients {
|
|
@@ -182,11 +140,11 @@ func (c *HisHospitalApiController) GetHisHospitalChargePatientList() {
|
182
|
140
|
}
|
183
|
141
|
|
184
|
142
|
c.ServeSuccessJSON(map[string]interface{}{
|
185
|
|
- "list": patients,
|
186
|
|
- "list_two": patients,
|
|
143
|
+ "list": patients,
|
|
144
|
+ "list_two": patients,
|
|
145
|
+ "charge_list": orders,
|
187
|
146
|
})
|
188
|
147
|
}
|
189
|
|
-
|
190
|
148
|
func (c *HisHospitalApiController) GetHisHospitalChargePatientInfo() {
|
191
|
149
|
patient_id, _ := c.GetInt64("patient_id")
|
192
|
150
|
his_patient_id, _ := c.GetInt64("his_patient_id")
|
|
@@ -256,7 +214,6 @@ func (c *HisHospitalApiController) GetHisHospitalChargePatientInfo() {
|
256
|
214
|
return
|
257
|
215
|
|
258
|
216
|
}
|
259
|
|
-
|
260
|
217
|
func (c *HisHospitalApiController) GetHisHospitalrescriptionList() {
|
261
|
218
|
record_date := c.GetString("record_date")
|
262
|
219
|
keywords := c.GetString("keywords")
|
|
@@ -287,7 +244,6 @@ func (c *HisHospitalApiController) GetHisHospitalrescriptionList() {
|
287
|
244
|
return
|
288
|
245
|
}
|
289
|
246
|
}
|
290
|
|
-
|
291
|
247
|
func (c *HisHospitalApiController) GetHisHospitalPrescriptionList() {
|
292
|
248
|
record_date := c.GetString("record_date")
|
293
|
249
|
keywords := c.GetString("keywords")
|
|
@@ -315,3 +271,390 @@ func (c *HisHospitalApiController) GetHisHospitalPrescriptionList() {
|
315
|
271
|
}
|
316
|
272
|
|
317
|
273
|
}
|
|
274
|
+
|
|
275
|
+func (c *HisHospitalApiController) GetZHInHospitalCheck() {
|
|
276
|
+ id, _ := c.GetInt64("id")
|
|
277
|
+ record_time := c.GetString("record_time")
|
|
278
|
+ name := c.GetString("name")
|
|
279
|
+ phone := c.GetString("phone")
|
|
280
|
+ id_card_type, _ := c.GetInt64("id_card_type")
|
|
281
|
+ certificates, _ := c.GetInt64("certificates")
|
|
282
|
+ id_card_no := c.GetString("id_card_no")
|
|
283
|
+ doctor, _ := c.GetInt64("doctor")
|
|
284
|
+ admin_user_id, _ := c.GetInt64("admin_user_id")
|
|
285
|
+ department, _ := c.GetInt64("department")
|
|
286
|
+ adm_bed, _ := c.GetInt64("adm_bed")
|
|
287
|
+ diagnosis_ids := c.GetString("diagnosis")
|
|
288
|
+ sick_type, _ := c.GetInt64("sick_type")
|
|
289
|
+ start_time := c.GetString("start_time")
|
|
290
|
+ balance_accounts_type, _ := c.GetInt64("balance_accounts_type")
|
|
291
|
+ med_type, _ := c.GetInt64("med_type")
|
|
292
|
+ timeLayout := "2006-01-02"
|
|
293
|
+ loc, _ := time.LoadLocation("Local")
|
|
294
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
|
|
295
|
+ if err != nil {
|
|
296
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
297
|
+ return
|
|
298
|
+ }
|
|
299
|
+ recordDateTime := theTime.Unix()
|
|
300
|
+ adminInfo := c.GetAdminUserInfo()
|
|
301
|
+ record, _ := service.GetLastHospitalRecord(id, adminInfo.CurrentOrgId)
|
|
302
|
+ if record.ID != 0 {
|
|
303
|
+ if record.InHospitalStatus == 1 && record.OutHospitalStatus != 1 {
|
|
304
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalExistDataException)
|
|
305
|
+ return
|
|
306
|
+ }
|
|
307
|
+ }
|
|
308
|
+ timestamp := time.Now().Unix()
|
|
309
|
+ tempTime := time.Unix(timestamp, 0)
|
|
310
|
+ timeFormat := tempTime.Format("20060102150405")
|
|
311
|
+ chrgBchno := rand.Intn(100000) + 10000
|
|
312
|
+ ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(id, 10)
|
|
313
|
+
|
|
314
|
+ timeStr := time.Now().Format("2006-01-02 15:04:05")
|
|
315
|
+ fmt.Println(timeStr)
|
|
316
|
+ timeArr := strings.Split(timeStr, " ")
|
|
317
|
+ fmt.Println(timeArr)
|
|
318
|
+
|
|
319
|
+ timeArrTwo := strings.Split(timeArr[0], "-")
|
|
320
|
+ timeArrThree := strings.Split(timeArr[1], ":")
|
|
321
|
+ var str = timeArrTwo[0] + timeArrTwo[1] + timeArrTwo[2] + timeArrThree[0] + timeArrThree[1] + timeArrThree[2] + strconv.FormatInt(id, 10)
|
|
322
|
+
|
|
323
|
+ inHospital := &models.HisHospitalCheckRecord{
|
|
324
|
+ PatientId: id,
|
|
325
|
+ Name: name,
|
|
326
|
+ MedicalTreatmentType: med_type,
|
|
327
|
+ RecordDate: recordDateTime,
|
|
328
|
+ IdCardNo: id_card_no,
|
|
329
|
+ AdminUserId: admin_user_id,
|
|
330
|
+ Departments: department,
|
|
331
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
332
|
+ Status: 1,
|
|
333
|
+ Ctime: time.Now().Unix(),
|
|
334
|
+ Mtime: time.Now().Unix(),
|
|
335
|
+ Number: str,
|
|
336
|
+ Doctor: doctor,
|
|
337
|
+ Certno: id_card_no,
|
|
338
|
+ MedType: med_type,
|
|
339
|
+ IptOtpNo: ipt_otp_no,
|
|
340
|
+ AdmBed: adm_bed,
|
|
341
|
+ IdCardType: id_card_type,
|
|
342
|
+ Diagnosis: diagnosis_ids,
|
|
343
|
+ SickType: sick_type,
|
|
344
|
+ MdtrtCertType: "02",
|
|
345
|
+ InHosptialTime: start_time,
|
|
346
|
+ OutHosptialTime: "",
|
|
347
|
+ InHospitalStatus: 1,
|
|
348
|
+ Certificates: certificates,
|
|
349
|
+ Phone: phone,
|
|
350
|
+ BalanceAccountsType: balance_accounts_type,
|
|
351
|
+ }
|
|
352
|
+ service.CreateHospitalRecord(inHospital)
|
|
353
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
354
|
+ "msg": "办理入院成功",
|
|
355
|
+ "info": inHospital,
|
|
356
|
+ })
|
|
357
|
+}
|
|
358
|
+func (this *HisHospitalApiController) GetZHOutHospitalCheck() {
|
|
359
|
+ id, _ := this.GetInt64("id")
|
|
360
|
+ record, _ := service.GetInHospitalRecord(id)
|
|
361
|
+ if record.ID == 0 {
|
|
362
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
|
|
363
|
+ return
|
|
364
|
+ }
|
|
365
|
+
|
|
366
|
+ timestamp := time.Now().Unix()
|
|
367
|
+ tempTime := time.Unix(timestamp, 0)
|
|
368
|
+ timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
|
|
369
|
+ record.OutHospitalStatus = 1
|
|
370
|
+ record.OutHosptialTime = timeFormatOne
|
|
371
|
+ record.OutWay = 1
|
|
372
|
+ service.CreateHospitalRecord(&record)
|
|
373
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
374
|
+ "msg": "出院成功",
|
|
375
|
+ })
|
|
376
|
+
|
|
377
|
+}
|
|
378
|
+func (c *HisHospitalApiController) GetSettleInfo() {
|
|
379
|
+ id, _ := c.GetInt64("id")
|
|
380
|
+ record_time := c.GetString("record_time")
|
|
381
|
+ in_hospital_id, _ := c.GetInt64("in_hospital_id")
|
|
382
|
+ settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
|
|
383
|
+
|
|
384
|
+ patient_id, _ := c.GetInt64("patient_id")
|
|
385
|
+ pay_way, _ := c.GetInt64("pay_way")
|
|
386
|
+ pay_price, _ := c.GetFloat("pay_price")
|
|
387
|
+ pay_card_no := c.GetString("pay_card_no")
|
|
388
|
+ discount_price, _ := c.GetFloat("discount_price")
|
|
389
|
+ preferential_price, _ := c.GetFloat("preferential_price")
|
|
390
|
+ reality_price, _ := c.GetFloat("reality_price")
|
|
391
|
+ found_price, _ := c.GetFloat("found_price")
|
|
392
|
+ medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
|
|
393
|
+ private_price, _ := c.GetFloat("private_price")
|
|
394
|
+ fapiao_code := c.GetString("fapiao_code")
|
|
395
|
+ fapiao_number := c.GetString("fapiao_number")
|
|
396
|
+
|
|
397
|
+ timeLayout := "2006-01-02"
|
|
398
|
+ loc, _ := time.LoadLocation("Local")
|
|
399
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
|
|
400
|
+ if err != nil {
|
|
401
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
402
|
+ return
|
|
403
|
+ }
|
|
404
|
+ recordDateTime := theTime.Unix()
|
|
405
|
+ adminUser := c.GetAdminUserInfo()
|
|
406
|
+
|
|
407
|
+ var prescriptions []*models.HisPrescription
|
|
408
|
+
|
|
409
|
+ var start_time int64
|
|
410
|
+ var end_time int64
|
|
411
|
+
|
|
412
|
+ if settle_accounts_type == 1 { //日结
|
|
413
|
+ //prescriptions, _ = service.GetZHHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
|
|
414
|
+
|
|
415
|
+ } else { //月结
|
|
416
|
+ start_time_str := c.GetString("start_time")
|
|
417
|
+ end_time_str := c.GetString("end_time")
|
|
418
|
+ timeLayout := "2006-01-02"
|
|
419
|
+ loc, _ := time.LoadLocation("Local")
|
|
420
|
+ theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
|
|
421
|
+ if err != nil {
|
|
422
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
423
|
+ return
|
|
424
|
+ }
|
|
425
|
+ recordStartTime := theStartTime.Unix()
|
|
426
|
+ start_time = recordStartTime
|
|
427
|
+ theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
|
|
428
|
+ if err != nil {
|
|
429
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
430
|
+ return
|
|
431
|
+ }
|
|
432
|
+ recordEndTime := theEndTime.Unix()
|
|
433
|
+ end_time = recordEndTime
|
|
434
|
+ prescriptions, _ = service.GetHospitalMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
|
|
435
|
+
|
|
436
|
+ }
|
|
437
|
+
|
|
438
|
+ record, _ := service.GetInHospitalRecord(in_hospital_id)
|
|
439
|
+
|
|
440
|
+ if record.ID == 0 {
|
|
441
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
442
|
+ return
|
|
443
|
+ }
|
|
444
|
+
|
|
445
|
+ timestamp := time.Now().Unix()
|
|
446
|
+ tempTime := time.Unix(timestamp, 0)
|
|
447
|
+ timeFormat := tempTime.Format("20060102150405")
|
|
448
|
+ chrgBchno := rand.Intn(100000) + 10000
|
|
449
|
+ chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(record.PatientId, 10)
|
|
450
|
+
|
|
451
|
+ var ids []int64
|
|
452
|
+ fmt.Println(prescriptions)
|
|
453
|
+ for _, item := range prescriptions {
|
|
454
|
+ ids = append(ids, item.ID)
|
|
455
|
+ }
|
|
456
|
+ var total float64
|
|
457
|
+ fmt.Println(prescriptions)
|
|
458
|
+ for _, item := range prescriptions {
|
|
459
|
+ fmt.Println(item)
|
|
460
|
+ if item.Type == 1 { //药品
|
|
461
|
+ for _, subItem := range item.HisDoctorAdviceInfo {
|
|
462
|
+ total = total + (subItem.Price * subItem.PrescribingNumber)
|
|
463
|
+ }
|
|
464
|
+ }
|
|
465
|
+ if item.Type == 2 { //项目
|
|
466
|
+ for _, subItem := range item.HisPrescriptionProject {
|
|
467
|
+ total = total + (subItem.Price * float64(subItem.Count))
|
|
468
|
+ }
|
|
469
|
+ }
|
|
470
|
+
|
|
471
|
+ for _, subItem := range item.HisAdditionalCharge {
|
|
472
|
+ total = total + (subItem.Price * float64(subItem.Count))
|
|
473
|
+ }
|
|
474
|
+ }
|
|
475
|
+
|
|
476
|
+ allTotal := fmt.Sprintf("%.2f", total)
|
|
477
|
+ totals, _ := strconv.ParseFloat(allTotal, 64)
|
|
478
|
+ order := &models.HisOrder{
|
|
479
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
480
|
+ HisPatientId: record.ID,
|
|
481
|
+ PatientId: patient_id,
|
|
482
|
+ SettleAccountsDate: recordDateTime,
|
|
483
|
+ Ctime: time.Now().Unix(),
|
|
484
|
+ Mtime: time.Now().Unix(),
|
|
485
|
+ Status: 1,
|
|
486
|
+ OrderStatus: 2,
|
|
487
|
+ MdtrtId: record.Number,
|
|
488
|
+ Number: chrg_bchno,
|
|
489
|
+ MedfeeSumamt: totals,
|
|
490
|
+ SettleEndTime: end_time,
|
|
491
|
+ SettleStartTime: start_time,
|
|
492
|
+ SettleType: settle_accounts_type,
|
|
493
|
+ PType: 1,
|
|
494
|
+ }
|
|
495
|
+ order.DiscountPrice = discount_price
|
|
496
|
+ order.MedicalInsurancePrice = medical_insurance_price
|
|
497
|
+ order.FaPiaoNumber = fapiao_number
|
|
498
|
+ order.FaPiaoCode = fapiao_code
|
|
499
|
+ order.PayWay = pay_way
|
|
500
|
+ order.PayPrice = pay_price
|
|
501
|
+ order.PayCardNo = pay_card_no
|
|
502
|
+ order.PreferentialPrice = preferential_price
|
|
503
|
+ order.RealityPrice = reality_price
|
|
504
|
+ order.FoundPrice = found_price
|
|
505
|
+ order.PrivatePrice = private_price
|
|
506
|
+ err = service.CreateOrder(order)
|
|
507
|
+ if err != nil {
|
|
508
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
|
|
509
|
+ return
|
|
510
|
+ }
|
|
511
|
+
|
|
512
|
+ var customs []*Custom
|
|
513
|
+ for _, item := range prescriptions {
|
|
514
|
+ if item.Type == 1 { //药品
|
|
515
|
+ for _, subItem := range item.HisDoctorAdviceInfo {
|
|
516
|
+ cus := &Custom{
|
|
517
|
+ AdviceId: subItem.ID,
|
|
518
|
+ ProjectId: 0,
|
|
519
|
+ DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
|
|
520
|
+ Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
|
|
521
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
522
|
+ Price: fmt.Sprintf("%.2f", subItem.Price),
|
|
523
|
+ MedListCodg: subItem.MedListCodg,
|
|
524
|
+ Type: 1,
|
|
525
|
+ }
|
|
526
|
+ customs = append(customs, cus)
|
|
527
|
+ }
|
|
528
|
+ }
|
|
529
|
+ if item.Type == 2 { //项目
|
|
530
|
+ for _, subItem := range item.HisPrescriptionProject {
|
|
531
|
+ cus := &Custom{
|
|
532
|
+ AdviceId: 0,
|
|
533
|
+ ProjectId: subItem.ID,
|
|
534
|
+ DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
|
|
535
|
+ Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
|
|
536
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
537
|
+ Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
|
|
538
|
+ MedListCodg: subItem.MedListCodg,
|
|
539
|
+ Type: 2,
|
|
540
|
+ }
|
|
541
|
+ customs = append(customs, cus)
|
|
542
|
+ }
|
|
543
|
+ }
|
|
544
|
+ for _, item := range item.HisAdditionalCharge {
|
|
545
|
+ cus := &Custom{
|
|
546
|
+ ItemId: item.ID,
|
|
547
|
+ AdviceId: 0,
|
|
548
|
+ ProjectId: 0,
|
|
549
|
+ DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
|
|
550
|
+ Cut: fmt.Sprintf("%.2f", float64(item.Count)),
|
|
551
|
+ FeedetlSn: item.FeedetlSn,
|
|
552
|
+ Price: fmt.Sprintf("%.2f", float64(item.Price)),
|
|
553
|
+ MedListCodg: item.XtHisAddtionConfig.Code,
|
|
554
|
+ Type: 3,
|
|
555
|
+ }
|
|
556
|
+ customs = append(customs, cus)
|
|
557
|
+ }
|
|
558
|
+ }
|
|
559
|
+ for _, item := range customs {
|
|
560
|
+ var advice_id int64 = 0
|
|
561
|
+ var project_id int64 = 0
|
|
562
|
+ var item_id int64 = 0
|
|
563
|
+
|
|
564
|
+ var types int64 = 0
|
|
565
|
+
|
|
566
|
+ if item.Type == 1 {
|
|
567
|
+ advice_id = item.AdviceId
|
|
568
|
+ project_id = 0
|
|
569
|
+ item_id = 0
|
|
570
|
+ } else if item.Type == 2 {
|
|
571
|
+ advice_id = 0
|
|
572
|
+ item_id = 0
|
|
573
|
+
|
|
574
|
+ project_id = item.ProjectId
|
|
575
|
+ } else if item.Type == 3 {
|
|
576
|
+ advice_id = 0
|
|
577
|
+ item_id = item.ItemId
|
|
578
|
+ project_id = 0
|
|
579
|
+ }
|
|
580
|
+ detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
|
|
581
|
+ cut, _ := strconv.ParseFloat(item.Cut, 32)
|
|
582
|
+ pric, _ := strconv.ParseFloat(item.Price, 32)
|
|
583
|
+ info := &models.HisOrderInfo{
|
|
584
|
+ OrderNumber: order.Number,
|
|
585
|
+ UploadDate: time.Now().Unix(),
|
|
586
|
+ AdviceId: advice_id,
|
|
587
|
+ DetItemFeeSumamt: detItemFeeSumamt,
|
|
588
|
+ Cnt: cut,
|
|
589
|
+ Pric: pric,
|
|
590
|
+ PatientId: id,
|
|
591
|
+ Status: 1,
|
|
592
|
+ Mtime: time.Now().Unix(),
|
|
593
|
+ Ctime: time.Now().Unix(),
|
|
594
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
595
|
+ HisPatientId: record.ID,
|
|
596
|
+ OrderId: order.ID,
|
|
597
|
+ ProjectId: project_id,
|
|
598
|
+ Type: types,
|
|
599
|
+ ItemId: item_id,
|
|
600
|
+ }
|
|
601
|
+ service.CreateOrderInfo(info)
|
|
602
|
+ }
|
|
603
|
+ err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
|
|
604
|
+ err = service.UpDateHospitalHisPrescriptionInfoNumber(adminUser.CurrentOrgId, chrg_bchno, start_time, end_time)
|
|
605
|
+ err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
|
|
606
|
+ if err == nil {
|
|
607
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
608
|
+ "msg": "结算成功",
|
|
609
|
+ })
|
|
610
|
+ }
|
|
611
|
+
|
|
612
|
+}
|
|
613
|
+func (c *HisHospitalApiController) ZHRefund() {
|
|
614
|
+ order_id, _ := c.GetInt64("order_id")
|
|
615
|
+ adminUser := c.GetAdminUserInfo()
|
|
616
|
+ var order models.HisOrder
|
|
617
|
+ order, _ = service.GetHisOrderByID(order_id)
|
|
618
|
+
|
|
619
|
+ err := service.UpdataHospitalOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
|
|
620
|
+ if err == nil {
|
|
621
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
622
|
+ "msg": "退费成功",
|
|
623
|
+ })
|
|
624
|
+ } else {
|
|
625
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
626
|
+ return
|
|
627
|
+ }
|
|
628
|
+
|
|
629
|
+}
|
|
630
|
+func (this *HisHospitalApiController) GetZHOutHospitalUnCheck() {
|
|
631
|
+ id, _ := this.GetInt64("id")
|
|
632
|
+ record, _ := service.GetInHospitalRecord(id)
|
|
633
|
+ if record.ID == 0 {
|
|
634
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
|
|
635
|
+ return
|
|
636
|
+ }
|
|
637
|
+ record.OutHospitalStatus = 0
|
|
638
|
+ service.CreateHospitalRecord(&record)
|
|
639
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
640
|
+ "msg": "撤销出院成功",
|
|
641
|
+ })
|
|
642
|
+
|
|
643
|
+}
|
|
644
|
+func (this *HisHospitalApiController) GetZHInHospitalUnCheck() {
|
|
645
|
+ id, _ := this.GetInt64("id")
|
|
646
|
+
|
|
647
|
+ record, _ := service.GetInHospitalRecord(id)
|
|
648
|
+ if record.ID == 0 {
|
|
649
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
|
|
650
|
+ return
|
|
651
|
+ }
|
|
652
|
+
|
|
653
|
+ record.Status = 0
|
|
654
|
+ service.CreateHospitalRecord(&record)
|
|
655
|
+
|
|
656
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
657
|
+ "msg": "撤销入院成功",
|
|
658
|
+ })
|
|
659
|
+
|
|
660
|
+}
|