|
@@ -363,399 +363,400 @@ type Custom struct {
|
363
|
363
|
//}
|
364
|
364
|
|
365
|
365
|
//获取读卡信息 -- 门诊挂号
|
366
|
|
-//func (c *SZHisApiController) GetRegisterInfo() {
|
367
|
|
-// adminInfo := c.GetAdminUserInfo()
|
368
|
|
-// admin_user_id, _ := c.GetInt64("admin_user_id")
|
369
|
|
-// patient_id, _ := c.GetInt64("id")
|
370
|
|
-// record_time := c.GetString("record_time")
|
371
|
|
-// settlementValue, _ := c.GetInt64("settlement_value")
|
372
|
|
-// medical_insurance_card := c.GetString("medical_insurance_card")
|
373
|
|
-// name := c.GetString("name")
|
374
|
|
-// id_card_type, _ := c.GetInt64("id_card_type")
|
375
|
|
-// certificates, _ := c.GetInt64("certificates")
|
376
|
|
-// medical_care, _ := c.GetInt64("medical_care")
|
377
|
|
-// birthday := c.GetString("birthday")
|
378
|
|
-// id_card := c.GetString("id_card")
|
379
|
|
-// register_type, _ := c.GetInt64("register")
|
380
|
|
-// doctor, _ := c.GetInt64("doctor")
|
381
|
|
-// department, _ := c.GetInt64("department")
|
382
|
|
-// gender, _ := c.GetInt64("sex")
|
383
|
|
-// registration_fee, _ := c.GetFloat("registration_fee")
|
384
|
|
-// medical_expenses, _ := c.GetFloat("medical_expenses")
|
385
|
|
-// social_type, _ := c.GetInt64("social_type")
|
386
|
|
-//
|
387
|
|
-// is_yidi, _ := c.GetInt64("is_yidi")
|
388
|
|
-//
|
389
|
|
-// timeLayout := "2006-01-02"
|
390
|
|
-// loc, _ := time.LoadLocation("Local")
|
391
|
|
-// birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
|
392
|
|
-// birthUnix := birthdays.Unix()
|
393
|
|
-//
|
394
|
|
-// theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
|
395
|
|
-// if err != nil {
|
396
|
|
-// c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
397
|
|
-// return
|
398
|
|
-// }
|
399
|
|
-//
|
400
|
|
-// var patient service.Patients
|
401
|
|
-// if patient_id == 0 {
|
402
|
|
-// patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
|
403
|
|
-// } else {
|
404
|
|
-// patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
|
405
|
|
-// }
|
406
|
|
-//
|
407
|
|
-// miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
|
408
|
|
-// if patient.ID == 0 {
|
409
|
|
-// c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
|
410
|
|
-// return
|
411
|
|
-// }
|
412
|
|
-// if len(patient.IdCardNo) == 0 {
|
413
|
|
-// c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
|
414
|
|
-// return
|
415
|
|
-// }
|
416
|
|
-//
|
417
|
|
-// adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
|
418
|
|
-// his, _ := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient_id, theTime.Unix())
|
419
|
|
-//
|
420
|
|
-// var custom_code string
|
421
|
|
-// var custom_project_name string
|
422
|
|
-// var allPrice float64
|
423
|
|
-//
|
424
|
|
-// switch register_type {
|
425
|
|
-// case 1:
|
426
|
|
-// custom_code = "110100002"
|
427
|
|
-// custom_project_name = "普通门诊"
|
428
|
|
-// allPrice = 10
|
429
|
|
-// break
|
430
|
|
-// case 3:
|
431
|
|
-// custom_code = "110200002-2"
|
432
|
|
-// custom_project_name = "主任医师"
|
433
|
|
-// allPrice = 10
|
434
|
|
-//
|
435
|
|
-// break
|
436
|
|
-// case 2:
|
437
|
|
-// custom_code = "110200002-3"
|
438
|
|
-// custom_project_name = "副主任医师"
|
439
|
|
-// allPrice = 10
|
440
|
|
-//
|
441
|
|
-// break
|
442
|
|
-// case 4:
|
443
|
|
-// custom_code = "0"
|
444
|
|
-// custom_project_name = "免受诊金"
|
445
|
|
-// allPrice = 0
|
446
|
|
-// break
|
447
|
|
-// case 5:
|
448
|
|
-// custom_code = "110200002-1"
|
449
|
|
-// custom_project_name = "专家"
|
450
|
|
-// allPrice = 10
|
451
|
|
-//
|
452
|
|
-// break
|
453
|
|
-// }
|
454
|
|
-//
|
455
|
|
-// if his.ID == 0 {
|
456
|
|
-//
|
457
|
|
-// var doctor_name string
|
458
|
|
-// var doctor_code string
|
459
|
|
-// if adminRole.ID == 0 {
|
460
|
|
-//
|
461
|
|
-// doctor_name = ""
|
462
|
|
-// doctor_code = "1001"
|
463
|
|
-// doctor_name = ""
|
464
|
|
-// doctor_code = ""
|
465
|
|
-//
|
466
|
|
-// } else {
|
467
|
|
-// doctor_name = adminRole.UserName
|
468
|
|
-// doctor_code = strconv.FormatInt(admin_user_id, 10)
|
469
|
|
-//
|
470
|
|
-// }
|
471
|
|
-// month := time.Unix(1557042972, 0).Format("1")
|
472
|
|
-// year := time.Now().Format("2006")
|
473
|
|
-// month = time.Now().Format("01")
|
474
|
|
-// day := time.Now().Format("02")
|
475
|
|
-//
|
476
|
|
-// //流水号
|
477
|
|
-// //
|
478
|
|
-// number := miConfig.Code + year + month + day +
|
479
|
|
-// fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
|
480
|
|
-// mz_number := year + month + day + strconv.FormatInt(patient_id, 10) +
|
481
|
|
-// fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
|
482
|
|
-// //1.判断读卡类型
|
483
|
|
-// //2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
|
484
|
|
-// yiliao_number, id_card_number, verifyCode, version_code, _, ret4 := ReadBasCardGetNumber("MZ002" + "|" + number + "|" + miConfig.Code + "|")
|
485
|
|
-// fmt.Println(yiliao_number)
|
486
|
|
-// fmt.Println(id_card_number)
|
487
|
|
-// fmt.Println(verifyCode)
|
488
|
|
-// fmt.Println(version_code)
|
489
|
|
-// fmt.Println(ret4)
|
490
|
|
-//
|
491
|
|
-// dept_code := "0305"
|
492
|
|
-// is_yidi = 1
|
493
|
|
-// tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
|
494
|
|
-// //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
|
495
|
|
-// if tempPatient.ID == patient_id {
|
496
|
|
-// if ret4 == 0 { //本地卡流程
|
497
|
|
-// if is_yidi == 1 {
|
498
|
|
-// //本地就医流程
|
499
|
|
-// //挂号
|
500
|
|
-// resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, dept_code, yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice,medical_care)
|
501
|
|
-// var dat map[string]interface{}
|
502
|
|
-// if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
|
503
|
|
-// fmt.Println(dat)
|
504
|
|
-// } else {
|
505
|
|
-// fmt.Println(err)
|
506
|
|
-// }
|
507
|
|
-// userJSONBytes, _ := json.Marshal(dat)
|
508
|
|
-// var res ResultOne
|
509
|
|
-// if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
510
|
|
-// utils.ErrorLog("解析失败:%v", err)
|
511
|
|
-// c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
512
|
|
-// return
|
513
|
|
-// }
|
514
|
|
-// if res.Transreturncode == "00000000" {
|
515
|
|
-// his := models.VMHisPatient{
|
516
|
|
-// Name: name,
|
517
|
|
-// Gender: gender,
|
518
|
|
-// Birthday: birthUnix,
|
519
|
|
-// MedicalTreatmentType: medical_care,
|
520
|
|
-// IdType: certificates,
|
521
|
|
-// IdCardNo: id_card,
|
522
|
|
-// BalanceAccountsType: settlementValue,
|
523
|
|
-// SocialType: social_type,
|
524
|
|
-// MedicalInsuranceNumber: medical_insurance_card,
|
525
|
|
-// RegisterType: register_type,
|
526
|
|
-// RegisterCost: registration_fee,
|
527
|
|
-// TreatmentCost: medical_expenses,
|
528
|
|
-// Status: 1,
|
529
|
|
-// Ctime: time.Now().Unix(),
|
530
|
|
-// Mtime: time.Now().Unix(),
|
531
|
|
-// Iinfo: resp_result,
|
532
|
|
-// PatientId: patient.ID,
|
533
|
|
-// RecordDate: theTime.Unix(),
|
534
|
|
-// UserOrgId: adminInfo.CurrentOrgId,
|
535
|
|
-// AdminUserId: admin_user_id,
|
536
|
|
-// IsReturn: 1,
|
537
|
|
-// IdCardType: id_card_type,
|
538
|
|
-// Doctor: doctor,
|
539
|
|
-// Departments: department,
|
540
|
|
-// YiliaoNumber: yiliao_number,
|
541
|
|
-// MzNumber: number,
|
542
|
|
-// Number: mz_number,
|
543
|
|
-// }
|
544
|
|
-// service.CreateHisPatientTwo(&his)
|
545
|
|
-// c.ServeSuccessJSON(map[string]interface{}{
|
546
|
|
-// "msg": "挂号成功",
|
547
|
|
-// })
|
548
|
|
-// } else {
|
549
|
|
-// c.ServeSuccessJSON(map[string]interface{}{
|
550
|
|
-// "failed_code": -10,
|
551
|
|
-// "msg": res.Transreturnmessage,
|
552
|
|
-// })
|
553
|
|
-// return
|
554
|
|
-// }
|
555
|
|
-//
|
556
|
|
-// } else {
|
557
|
|
-// //异地就医流程
|
558
|
|
-// //异地走鉴权流程
|
559
|
|
-// //authResult := CardAuth(number)
|
560
|
|
-// //fmt.Println(authResult)
|
561
|
|
-//
|
562
|
|
-// //tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
|
563
|
|
-// //if tempPatient.ID == patient_id {
|
564
|
|
-// resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
|
565
|
|
-// var dat map[string]interface{}
|
566
|
|
-// if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
|
567
|
|
-// fmt.Println(dat)
|
568
|
|
-// } else {
|
569
|
|
-// fmt.Println(err)
|
570
|
|
-// }
|
571
|
|
-//
|
572
|
|
-// userJSONBytes, _ := json.Marshal(dat)
|
573
|
|
-//
|
574
|
|
-// var res ResultOne
|
575
|
|
-// if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
576
|
|
-// utils.ErrorLog("解析失败:%v", err)
|
577
|
|
-// c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
578
|
|
-// return
|
579
|
|
-// }
|
580
|
|
-// if res.Transreturncode == "00000000" {
|
581
|
|
-// his := models.VMHisPatient{
|
582
|
|
-// Name: name,
|
583
|
|
-// Gender: gender,
|
584
|
|
-// Birthday: birthUnix,
|
585
|
|
-// MedicalTreatmentType: medical_care,
|
586
|
|
-// IdType: certificates,
|
587
|
|
-// IdCardNo: id_card,
|
588
|
|
-// BalanceAccountsType: settlementValue,
|
589
|
|
-// SocialType: social_type,
|
590
|
|
-// MedicalInsuranceNumber: medical_insurance_card,
|
591
|
|
-// RegisterType: register_type,
|
592
|
|
-// RegisterCost: registration_fee,
|
593
|
|
-// TreatmentCost: medical_expenses,
|
594
|
|
-// Status: 1,
|
595
|
|
-// Ctime: time.Now().Unix(),
|
596
|
|
-// Mtime: time.Now().Unix(),
|
597
|
|
-// Iinfo: resp_result,
|
598
|
|
-// PatientId: patient.ID,
|
599
|
|
-// RecordDate: theTime.Unix(),
|
600
|
|
-// UserOrgId: adminInfo.CurrentOrgId,
|
601
|
|
-// AdminUserId: admin_user_id,
|
602
|
|
-// IsReturn: 1,
|
603
|
|
-// IdCardType: id_card_type,
|
604
|
|
-// Doctor: doctor,
|
605
|
|
-// Departments: department,
|
606
|
|
-// YiliaoNumber: yiliao_number,
|
607
|
|
-// MzNumber: number,
|
608
|
|
-// Number: mz_number,
|
609
|
|
-// }
|
610
|
|
-// service.CreateHisPatientTwo(&his)
|
611
|
|
-// c.ServeSuccessJSON(map[string]interface{}{
|
612
|
|
-// "msg": "挂号成功",
|
613
|
|
-// })
|
614
|
|
-// } else {
|
615
|
|
-// c.ServeSuccessJSON(map[string]interface{}{
|
616
|
|
-// "failed_code": -10,
|
617
|
|
-// "msg": res.Transreturnmessage,
|
618
|
|
-// })
|
619
|
|
-// return
|
620
|
|
-// }
|
621
|
|
-//
|
622
|
|
-// }
|
623
|
|
-//
|
624
|
|
-// } else { //异地卡流程
|
625
|
|
-// //readCardBasResult := ReadCardBasHSM(number)
|
626
|
|
-// //fmt.Println(readCardBasResult)
|
627
|
|
-// //是否异地就医,是的话走鉴权流程,不是的话走门诊挂号
|
628
|
|
-// if is_yidi == 1 { //1本地就医
|
629
|
|
-// resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
|
630
|
|
-// var dat map[string]interface{}
|
631
|
|
-// if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
|
632
|
|
-// fmt.Println(dat)
|
633
|
|
-// } else {
|
634
|
|
-// fmt.Println(err)
|
635
|
|
-// }
|
636
|
|
-//
|
637
|
|
-// userJSONBytes, _ := json.Marshal(dat)
|
638
|
|
-//
|
639
|
|
-// var res ResultOne
|
640
|
|
-// if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
641
|
|
-// utils.ErrorLog("解析失败:%v", err)
|
642
|
|
-// c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
643
|
|
-// return
|
644
|
|
-// }
|
645
|
|
-// if res.Transreturncode == "00000000" {
|
646
|
|
-// his := models.VMHisPatient{
|
647
|
|
-// Name: name,
|
648
|
|
-// Gender: gender,
|
649
|
|
-// Birthday: birthUnix,
|
650
|
|
-// MedicalTreatmentType: medical_care,
|
651
|
|
-// IdType: certificates,
|
652
|
|
-// IdCardNo: id_card,
|
653
|
|
-// BalanceAccountsType: settlementValue,
|
654
|
|
-// SocialType: social_type,
|
655
|
|
-// MedicalInsuranceNumber: medical_insurance_card,
|
656
|
|
-// RegisterType: register_type,
|
657
|
|
-// RegisterCost: registration_fee,
|
658
|
|
-// TreatmentCost: medical_expenses,
|
659
|
|
-// Status: 1,
|
660
|
|
-// Ctime: time.Now().Unix(),
|
661
|
|
-// Mtime: time.Now().Unix(),
|
662
|
|
-// Iinfo: resp_result,
|
663
|
|
-// PatientId: patient.ID,
|
664
|
|
-// RecordDate: theTime.Unix(),
|
665
|
|
-// UserOrgId: adminInfo.CurrentOrgId,
|
666
|
|
-// AdminUserId: admin_user_id,
|
667
|
|
-// IsReturn: 1,
|
668
|
|
-// IdCardType: id_card_type,
|
669
|
|
-// Doctor: doctor,
|
670
|
|
-// Departments: department,
|
671
|
|
-// YiliaoNumber: yiliao_number,
|
672
|
|
-// MzNumber: number,
|
673
|
|
-// Number: mz_number,
|
674
|
|
-// }
|
675
|
|
-// service.CreateHisPatientTwo(&his)
|
676
|
|
-// c.ServeSuccessJSON(map[string]interface{}{
|
677
|
|
-// "msg": "挂号成功",
|
678
|
|
-// })
|
679
|
|
-// } else {
|
680
|
|
-// c.ServeSuccessJSON(map[string]interface{}{
|
681
|
|
-// "failed_code": -10,
|
682
|
|
-// "msg": res.Transreturnmessage,
|
683
|
|
-// })
|
684
|
|
-// return
|
685
|
|
-// }
|
686
|
|
-//
|
687
|
|
-// } else { //异地就医需要走鉴权流程
|
688
|
|
-// //authResult := CardAuth(number)
|
689
|
|
-// //fmt.Println(authResult)
|
690
|
|
-// resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
|
691
|
|
-// var dat map[string]interface{}
|
692
|
|
-// if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
|
693
|
|
-// fmt.Println(dat)
|
694
|
|
-// } else {
|
695
|
|
-// fmt.Println(err)
|
696
|
|
-// }
|
697
|
|
-//
|
698
|
|
-// userJSONBytes, _ := json.Marshal(dat)
|
699
|
|
-//
|
700
|
|
-// var res ResultOne
|
701
|
|
-// if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
702
|
|
-// utils.ErrorLog("解析失败:%v", err)
|
703
|
|
-// c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
704
|
|
-// return
|
705
|
|
-// }
|
706
|
|
-// if res.Transreturncode == "00000000" {
|
707
|
|
-// his := models.VMHisPatient{
|
708
|
|
-// Name: name,
|
709
|
|
-// Gender: gender,
|
710
|
|
-// Birthday: birthUnix,
|
711
|
|
-// MedicalTreatmentType: medical_care,
|
712
|
|
-// IdType: certificates,
|
713
|
|
-// IdCardNo: id_card,
|
714
|
|
-// BalanceAccountsType: settlementValue,
|
715
|
|
-// SocialType: social_type,
|
716
|
|
-// MedicalInsuranceNumber: medical_insurance_card,
|
717
|
|
-// RegisterType: register_type,
|
718
|
|
-// RegisterCost: registration_fee,
|
719
|
|
-// TreatmentCost: medical_expenses,
|
720
|
|
-// Status: 1,
|
721
|
|
-// Ctime: time.Now().Unix(),
|
722
|
|
-// Mtime: time.Now().Unix(),
|
723
|
|
-// Iinfo: resp_result,
|
724
|
|
-// PatientId: patient.ID,
|
725
|
|
-// RecordDate: theTime.Unix(),
|
726
|
|
-// UserOrgId: adminInfo.CurrentOrgId,
|
727
|
|
-// AdminUserId: admin_user_id,
|
728
|
|
-// IsReturn: 1,
|
729
|
|
-// IdCardType: id_card_type,
|
730
|
|
-// Doctor: doctor,
|
731
|
|
-// Departments: department,
|
732
|
|
-// YiliaoNumber: yiliao_number,
|
733
|
|
-// MzNumber: number,
|
734
|
|
-// Number: mz_number,
|
735
|
|
-// }
|
736
|
|
-// service.CreateHisPatientTwo(&his)
|
737
|
|
-// c.ServeSuccessJSON(map[string]interface{}{
|
738
|
|
-// "msg": "挂号成功",
|
739
|
|
-// })
|
740
|
|
-// } else {
|
741
|
|
-// c.ServeSuccessJSON(map[string]interface{}{
|
742
|
|
-// "failed_code": -10,
|
743
|
|
-// "msg": res.Transreturnmessage,
|
744
|
|
-// })
|
745
|
|
-// return
|
746
|
|
-// }
|
747
|
|
-//
|
748
|
|
-// }
|
749
|
|
-// }
|
750
|
|
-// } else {
|
751
|
|
-// c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
|
752
|
|
-// return
|
753
|
|
-// }
|
754
|
|
-// } else {
|
755
|
|
-// c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
|
756
|
|
-// return
|
757
|
|
-// }
|
758
|
|
-//}
|
|
366
|
+func (c *SZHisApiController) GetRegisterInfo() {
|
|
367
|
+ adminInfo := c.GetAdminUserInfo()
|
|
368
|
+ admin_user_id, _ := c.GetInt64("admin_user_id")
|
|
369
|
+ patient_id, _ := c.GetInt64("id")
|
|
370
|
+ record_time := c.GetString("record_time")
|
|
371
|
+ settlementValue, _ := c.GetInt64("settlement_value")
|
|
372
|
+ medical_insurance_card := c.GetString("medical_insurance_card")
|
|
373
|
+ name := c.GetString("name")
|
|
374
|
+ id_card_type, _ := c.GetInt64("id_card_type")
|
|
375
|
+ certificates, _ := c.GetInt64("certificates")
|
|
376
|
+ medical_care, _ := c.GetInt64("medical_care")
|
|
377
|
+ birthday := c.GetString("birthday")
|
|
378
|
+ id_card := c.GetString("id_card")
|
|
379
|
+ register_type, _ := c.GetInt64("register")
|
|
380
|
+ doctor, _ := c.GetInt64("doctor")
|
|
381
|
+ department, _ := c.GetInt64("department")
|
|
382
|
+ gender, _ := c.GetInt64("sex")
|
|
383
|
+ registration_fee, _ := c.GetFloat("registration_fee")
|
|
384
|
+ medical_expenses, _ := c.GetFloat("medical_expenses")
|
|
385
|
+ social_type, _ := c.GetInt64("social_type")
|
|
386
|
+
|
|
387
|
+ is_yidi, _ := c.GetInt64("is_yidi")
|
|
388
|
+
|
|
389
|
+ timeLayout := "2006-01-02"
|
|
390
|
+ loc, _ := time.LoadLocation("Local")
|
|
391
|
+ birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
|
|
392
|
+ birthUnix := birthdays.Unix()
|
|
393
|
+
|
|
394
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
|
|
395
|
+ if err != nil {
|
|
396
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
397
|
+ return
|
|
398
|
+ }
|
|
399
|
+
|
|
400
|
+ var patient service.Patients
|
|
401
|
+ if patient_id == 0 {
|
|
402
|
+ patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
|
|
403
|
+ } else {
|
|
404
|
+ patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
|
|
405
|
+ }
|
|
406
|
+
|
|
407
|
+ miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
|
|
408
|
+ if patient.ID == 0 {
|
|
409
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
|
|
410
|
+ return
|
|
411
|
+ }
|
|
412
|
+ if len(patient.IdCardNo) == 0 {
|
|
413
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
|
|
414
|
+ return
|
|
415
|
+ }
|
|
416
|
+
|
|
417
|
+ adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
|
|
418
|
+ his, _ := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient_id, theTime.Unix())
|
|
419
|
+
|
|
420
|
+ var custom_code string
|
|
421
|
+ var custom_project_name string
|
|
422
|
+ var allPrice float64
|
|
423
|
+
|
|
424
|
+ switch register_type {
|
|
425
|
+ case 1:
|
|
426
|
+ custom_code = "110100002"
|
|
427
|
+ custom_project_name = "普通门诊"
|
|
428
|
+ allPrice = 10
|
|
429
|
+ break
|
|
430
|
+ case 3:
|
|
431
|
+ custom_code = "110200002-2"
|
|
432
|
+ custom_project_name = "主任医师"
|
|
433
|
+ allPrice = 10
|
|
434
|
+
|
|
435
|
+ break
|
|
436
|
+ case 2:
|
|
437
|
+ custom_code = "110200002-3"
|
|
438
|
+ custom_project_name = "副主任医师"
|
|
439
|
+ allPrice = 10
|
|
440
|
+
|
|
441
|
+ break
|
|
442
|
+ case 4:
|
|
443
|
+ custom_code = "0"
|
|
444
|
+ custom_project_name = "免受诊金"
|
|
445
|
+ allPrice = 0
|
|
446
|
+ break
|
|
447
|
+ case 5:
|
|
448
|
+ custom_code = "110200002-1"
|
|
449
|
+ custom_project_name = "专家"
|
|
450
|
+ allPrice = 10
|
|
451
|
+
|
|
452
|
+ break
|
|
453
|
+ }
|
|
454
|
+
|
|
455
|
+ if his.ID == 0 {
|
|
456
|
+
|
|
457
|
+ var doctor_name string
|
|
458
|
+ var doctor_code string
|
|
459
|
+ if adminRole.ID == 0 {
|
|
460
|
+
|
|
461
|
+ doctor_name = ""
|
|
462
|
+ doctor_code = "1001"
|
|
463
|
+ doctor_name = ""
|
|
464
|
+ doctor_code = ""
|
|
465
|
+
|
|
466
|
+ } else {
|
|
467
|
+ doctor_name = adminRole.UserName
|
|
468
|
+ doctor_code = strconv.FormatInt(admin_user_id, 10)
|
|
469
|
+
|
|
470
|
+ }
|
|
471
|
+ month := time.Unix(1557042972, 0).Format("1")
|
|
472
|
+ year := time.Now().Format("2006")
|
|
473
|
+ month = time.Now().Format("01")
|
|
474
|
+ day := time.Now().Format("02")
|
|
475
|
+
|
|
476
|
+ //流水号
|
|
477
|
+ //
|
|
478
|
+ number := miConfig.Code + year + month + day +
|
|
479
|
+ fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
|
|
480
|
+ mz_number := year + month + day + strconv.FormatInt(patient_id, 10) +
|
|
481
|
+ fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
|
|
482
|
+ //1.判断读卡类型
|
|
483
|
+ //2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
|
|
484
|
+ yiliao_number, id_card_number, verifyCode, version_code, _, ret4 := ReadBasCardGetNumber("MZ002" + "|" + number + "|" + miConfig.Code + "|")
|
|
485
|
+ fmt.Println(yiliao_number)
|
|
486
|
+ fmt.Println(id_card_number)
|
|
487
|
+ fmt.Println(verifyCode)
|
|
488
|
+ fmt.Println(version_code)
|
|
489
|
+ fmt.Println(ret4)
|
|
490
|
+
|
|
491
|
+ dept_code := "0305"
|
|
492
|
+ is_yidi = 1
|
|
493
|
+ tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
|
|
494
|
+ //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
|
|
495
|
+ if tempPatient.ID == patient_id {
|
|
496
|
+ if ret4 == 0 { //本地卡流程
|
|
497
|
+ if is_yidi == 1 {
|
|
498
|
+ //本地就医流程
|
|
499
|
+ //挂号
|
|
500
|
+ resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, dept_code, yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
|
|
501
|
+ var dat map[string]interface{}
|
|
502
|
+ if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
|
|
503
|
+ fmt.Println(dat)
|
|
504
|
+ } else {
|
|
505
|
+ fmt.Println(err)
|
|
506
|
+ }
|
|
507
|
+ userJSONBytes, _ := json.Marshal(dat)
|
|
508
|
+ var res ResultOne
|
|
509
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
510
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
511
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
512
|
+ return
|
|
513
|
+ }
|
|
514
|
+ if res.Transreturncode == "00000000" {
|
|
515
|
+ his := models.VMHisPatient{
|
|
516
|
+ Name: name,
|
|
517
|
+ Gender: gender,
|
|
518
|
+ Birthday: birthUnix,
|
|
519
|
+ MedicalTreatmentType: medical_care,
|
|
520
|
+ IdType: certificates,
|
|
521
|
+ IdCardNo: id_card,
|
|
522
|
+ BalanceAccountsType: settlementValue,
|
|
523
|
+ SocialType: social_type,
|
|
524
|
+ MedicalInsuranceNumber: medical_insurance_card,
|
|
525
|
+ RegisterType: register_type,
|
|
526
|
+ RegisterCost: registration_fee,
|
|
527
|
+ TreatmentCost: medical_expenses,
|
|
528
|
+ Status: 1,
|
|
529
|
+ Ctime: time.Now().Unix(),
|
|
530
|
+ Mtime: time.Now().Unix(),
|
|
531
|
+ Iinfo: resp_result,
|
|
532
|
+ PatientId: patient.ID,
|
|
533
|
+ RecordDate: theTime.Unix(),
|
|
534
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
535
|
+ AdminUserId: admin_user_id,
|
|
536
|
+ IsReturn: 1,
|
|
537
|
+ IdCardType: id_card_type,
|
|
538
|
+ Doctor: doctor,
|
|
539
|
+ Departments: department,
|
|
540
|
+ YiliaoNumber: yiliao_number,
|
|
541
|
+ MzNumber: number,
|
|
542
|
+ Number: mz_number,
|
|
543
|
+ }
|
|
544
|
+ service.CreateHisPatientTwo(&his)
|
|
545
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
546
|
+ "msg": "挂号成功",
|
|
547
|
+ })
|
|
548
|
+ } else {
|
|
549
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
550
|
+ "failed_code": -10,
|
|
551
|
+ "msg": res.Transreturnmessage,
|
|
552
|
+ })
|
|
553
|
+ return
|
|
554
|
+ }
|
|
555
|
+
|
|
556
|
+ } else {
|
|
557
|
+ //异地就医流程
|
|
558
|
+ //异地走鉴权流程
|
|
559
|
+ //authResult := CardAuth(number)
|
|
560
|
+ //fmt.Println(authResult)
|
|
561
|
+
|
|
562
|
+ //tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
|
|
563
|
+ //if tempPatient.ID == patient_id {
|
|
564
|
+ resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
|
|
565
|
+ var dat map[string]interface{}
|
|
566
|
+ if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
|
|
567
|
+ fmt.Println(dat)
|
|
568
|
+ } else {
|
|
569
|
+ fmt.Println(err)
|
|
570
|
+ }
|
|
571
|
+
|
|
572
|
+ userJSONBytes, _ := json.Marshal(dat)
|
|
573
|
+
|
|
574
|
+ var res ResultOne
|
|
575
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
576
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
577
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
578
|
+ return
|
|
579
|
+ }
|
|
580
|
+ if res.Transreturncode == "00000000" {
|
|
581
|
+ his := models.VMHisPatient{
|
|
582
|
+ Name: name,
|
|
583
|
+ Gender: gender,
|
|
584
|
+ Birthday: birthUnix,
|
|
585
|
+ MedicalTreatmentType: medical_care,
|
|
586
|
+ IdType: certificates,
|
|
587
|
+ IdCardNo: id_card,
|
|
588
|
+ BalanceAccountsType: settlementValue,
|
|
589
|
+ SocialType: social_type,
|
|
590
|
+ MedicalInsuranceNumber: medical_insurance_card,
|
|
591
|
+ RegisterType: register_type,
|
|
592
|
+ RegisterCost: registration_fee,
|
|
593
|
+ TreatmentCost: medical_expenses,
|
|
594
|
+ Status: 1,
|
|
595
|
+ Ctime: time.Now().Unix(),
|
|
596
|
+ Mtime: time.Now().Unix(),
|
|
597
|
+ Iinfo: resp_result,
|
|
598
|
+ PatientId: patient.ID,
|
|
599
|
+ RecordDate: theTime.Unix(),
|
|
600
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
601
|
+ AdminUserId: admin_user_id,
|
|
602
|
+ IsReturn: 1,
|
|
603
|
+ IdCardType: id_card_type,
|
|
604
|
+ Doctor: doctor,
|
|
605
|
+ Departments: department,
|
|
606
|
+ YiliaoNumber: yiliao_number,
|
|
607
|
+ MzNumber: number,
|
|
608
|
+ Number: mz_number,
|
|
609
|
+ }
|
|
610
|
+ service.CreateHisPatientTwo(&his)
|
|
611
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
612
|
+ "msg": "挂号成功",
|
|
613
|
+ })
|
|
614
|
+ } else {
|
|
615
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
616
|
+ "failed_code": -10,
|
|
617
|
+ "msg": res.Transreturnmessage,
|
|
618
|
+ })
|
|
619
|
+ return
|
|
620
|
+ }
|
|
621
|
+
|
|
622
|
+ }
|
|
623
|
+
|
|
624
|
+ } else { //异地卡流程
|
|
625
|
+ //readCardBasResult := ReadCardBasHSM(number)
|
|
626
|
+ //fmt.Println(readCardBasResult)
|
|
627
|
+ //是否异地就医,是的话走鉴权流程,不是的话走门诊挂号
|
|
628
|
+ if is_yidi == 1 { //1本地就医
|
|
629
|
+ resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
|
|
630
|
+ var dat map[string]interface{}
|
|
631
|
+ if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
|
|
632
|
+ fmt.Println(dat)
|
|
633
|
+ } else {
|
|
634
|
+ fmt.Println(err)
|
|
635
|
+ }
|
|
636
|
+
|
|
637
|
+ userJSONBytes, _ := json.Marshal(dat)
|
|
638
|
+
|
|
639
|
+ var res ResultOne
|
|
640
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
641
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
642
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
643
|
+ return
|
|
644
|
+ }
|
|
645
|
+ if res.Transreturncode == "00000000" {
|
|
646
|
+ his := models.VMHisPatient{
|
|
647
|
+ Name: name,
|
|
648
|
+ Gender: gender,
|
|
649
|
+ Birthday: birthUnix,
|
|
650
|
+ MedicalTreatmentType: medical_care,
|
|
651
|
+ IdType: certificates,
|
|
652
|
+ IdCardNo: id_card,
|
|
653
|
+ BalanceAccountsType: settlementValue,
|
|
654
|
+ SocialType: social_type,
|
|
655
|
+ MedicalInsuranceNumber: medical_insurance_card,
|
|
656
|
+ RegisterType: register_type,
|
|
657
|
+ RegisterCost: registration_fee,
|
|
658
|
+ TreatmentCost: medical_expenses,
|
|
659
|
+ Status: 1,
|
|
660
|
+ Ctime: time.Now().Unix(),
|
|
661
|
+ Mtime: time.Now().Unix(),
|
|
662
|
+ Iinfo: resp_result,
|
|
663
|
+ PatientId: patient.ID,
|
|
664
|
+ RecordDate: theTime.Unix(),
|
|
665
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
666
|
+ AdminUserId: admin_user_id,
|
|
667
|
+ IsReturn: 1,
|
|
668
|
+ IdCardType: id_card_type,
|
|
669
|
+ Doctor: doctor,
|
|
670
|
+ Departments: department,
|
|
671
|
+ YiliaoNumber: yiliao_number,
|
|
672
|
+ MzNumber: number,
|
|
673
|
+ Number: mz_number,
|
|
674
|
+ }
|
|
675
|
+ service.CreateHisPatientTwo(&his)
|
|
676
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
677
|
+ "msg": "挂号成功",
|
|
678
|
+ })
|
|
679
|
+ } else {
|
|
680
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
681
|
+ "failed_code": -10,
|
|
682
|
+ "msg": res.Transreturnmessage,
|
|
683
|
+ })
|
|
684
|
+ return
|
|
685
|
+ }
|
|
686
|
+
|
|
687
|
+ } else { //异地就医需要走鉴权流程
|
|
688
|
+ //authResult := CardAuth(number)
|
|
689
|
+ //fmt.Println(authResult)
|
|
690
|
+ resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
|
|
691
|
+ var dat map[string]interface{}
|
|
692
|
+ if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
|
|
693
|
+ fmt.Println(dat)
|
|
694
|
+ } else {
|
|
695
|
+ fmt.Println(err)
|
|
696
|
+ }
|
|
697
|
+
|
|
698
|
+ userJSONBytes, _ := json.Marshal(dat)
|
|
699
|
+
|
|
700
|
+ var res ResultOne
|
|
701
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
702
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
703
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
704
|
+ return
|
|
705
|
+ }
|
|
706
|
+ if res.Transreturncode == "00000000" {
|
|
707
|
+ his := models.VMHisPatient{
|
|
708
|
+ Name: name,
|
|
709
|
+ Gender: gender,
|
|
710
|
+ Birthday: birthUnix,
|
|
711
|
+ MedicalTreatmentType: medical_care,
|
|
712
|
+ IdType: certificates,
|
|
713
|
+ IdCardNo: id_card,
|
|
714
|
+ BalanceAccountsType: settlementValue,
|
|
715
|
+ SocialType: social_type,
|
|
716
|
+ MedicalInsuranceNumber: medical_insurance_card,
|
|
717
|
+ RegisterType: register_type,
|
|
718
|
+ RegisterCost: registration_fee,
|
|
719
|
+ TreatmentCost: medical_expenses,
|
|
720
|
+ Status: 1,
|
|
721
|
+ Ctime: time.Now().Unix(),
|
|
722
|
+ Mtime: time.Now().Unix(),
|
|
723
|
+ Iinfo: resp_result,
|
|
724
|
+ PatientId: patient.ID,
|
|
725
|
+ RecordDate: theTime.Unix(),
|
|
726
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
727
|
+ AdminUserId: admin_user_id,
|
|
728
|
+ IsReturn: 1,
|
|
729
|
+ IdCardType: id_card_type,
|
|
730
|
+ Doctor: doctor,
|
|
731
|
+ Departments: department,
|
|
732
|
+ YiliaoNumber: yiliao_number,
|
|
733
|
+ MzNumber: number,
|
|
734
|
+ Number: mz_number,
|
|
735
|
+ }
|
|
736
|
+ service.CreateHisPatientTwo(&his)
|
|
737
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
738
|
+ "msg": "挂号成功",
|
|
739
|
+ })
|
|
740
|
+ } else {
|
|
741
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
742
|
+ "failed_code": -10,
|
|
743
|
+ "msg": res.Transreturnmessage,
|
|
744
|
+ })
|
|
745
|
+ return
|
|
746
|
+ }
|
|
747
|
+
|
|
748
|
+ }
|
|
749
|
+ }
|
|
750
|
+ } else {
|
|
751
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
|
|
752
|
+ return
|
|
753
|
+ }
|
|
754
|
+ } else {
|
|
755
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
|
|
756
|
+ return
|
|
757
|
+ }
|
|
758
|
+}
|
|
759
|
+
|
759
|
760
|
//func (c *SZHisApiController) GetRegisterInfo() {
|
760
|
761
|
// adminInfo := c.GetAdminUserInfo()
|
761
|
762
|
// admin_user_id, _ := c.GetInt64("admin_user_id")
|