test_user 1 year ago
parent
commit
b89d67e533

+ 222 - 42
controllers/sg/his_api_controller.go View File

@@ -146,7 +146,7 @@ func (c *HisApiController) ReadEleToken() {
146 146
 			})
147 147
 		}
148 148
 
149
-	} else if miConfig.MdtrtareaAdmvs == "440305" {
149
+	} else if miConfig.MdtrtareaAdmvs == "440305" || miConfig.MdtrtareaAdmvs == "440305" || miConfig.MdtrtareaAdmvs == "441202" {
150 150
 		if initFlag == 0 {
151 151
 			c.TestGetBasBaseInit()
152 152
 		}
@@ -2334,9 +2334,12 @@ func (c *HisApiController) ReadCard() {
2334 2334
 			basNumber := bas[1]
2335 2335
 			fmt.Println(basNumber)
2336 2336
 			card_sn := bas[3]
2337
-			fmt.Println(card_sn)
2338
-			result, _ := service.Hnyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "")
2337
+			card_no := bas[2]
2339 2338
 
2339
+			fmt.Println(card_sn)
2340
+			name := bas[4]
2341
+			name = ConvertToString(name, "gbk", "utf-8")
2342
+			result, _ := service.Hnyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "", name, card_no)
2340 2343
 			//result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
2341 2344
 			var dat map[string]interface{}
2342 2345
 			if err := json.Unmarshal([]byte(result), &dat); err == nil {
@@ -2510,44 +2513,160 @@ func (c *HisApiController) ReadCard() {
2510 2513
 			break
2511 2514
 		}
2512 2515
 	case 2:
2513
-		SFZStr := c.GetSFZBaseInfo()
2514
-		id_card_str := strings.Split(SFZStr, "^")
2515
-		id_card_number := id_card_str[0]
2516
-		card_sn := ""
2517
-		result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
2518
-		var dat map[string]interface{}
2519
-		if err := json.Unmarshal([]byte(result), &dat); err == nil {
2520
-			fmt.Println(dat)
2521
-		} else {
2522
-			fmt.Println(err)
2523
-		}
2516
+		if miConfig.MdtrtareaAdmvs == "430800" {
2517
+			if initFlag == 0 {
2518
+				c.TestGetHnBasBaseInit()
2519
+			}
2520
+			SFZStr := c.GetSFZBaseInfo()
2521
+			if len(SFZStr) == 0 {
2522
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
2523
+				return
2524
+			}
2525
+			fmt.Println(SFZStr)
2526
+			id_card_str := strings.Split(SFZStr, "^")
2524 2527
 
2525
-		userJSONBytes, _ := json.Marshal(dat)
2526
-		var res ResultTwo
2527
-		if err := json.Unmarshal(userJSONBytes, &res); err != nil {
2528
-			utils.ErrorLog("解析失败:%v", err)
2529
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2530
-			return
2531
-		}
2528
+			card_no := id_card_str[0]
2529
+			name := id_card_str[1]
2532 2530
 
2533
-		if res.Infcode == 0 {
2534
-			patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
2535
-			if err == gorm.ErrRecordNotFound {
2536
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
2537
-				return
2538
-			} else if err != nil {
2539
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2531
+			name = ConvertToString(name, "gbk", "utf-8")
2532
+			result, _ := service.Hnyb1101(card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "", name, card_no)
2533
+			var dat map[string]interface{}
2534
+			if err := json.Unmarshal([]byte(result), &dat); err == nil {
2535
+				fmt.Println(dat)
2536
+			} else {
2537
+				fmt.Println(err)
2538
+			}
2539
+
2540
+			userJSONBytes, _ := json.Marshal(dat)
2541
+			var res ResultTwo
2542
+			if err := json.Unmarshal(userJSONBytes, &res); err != nil {
2543
+				utils.ErrorLog("解析失败:%v", err)
2544
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2540 2545
 				return
2546
+			}
2541 2547
 
2548
+			if res.Infcode == 0 {
2549
+				patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
2550
+				if err == gorm.ErrRecordNotFound {
2551
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
2552
+					return
2553
+				} else if err != nil {
2554
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2555
+					return
2556
+
2557
+				} else {
2558
+					Iinfos, _ := json.Marshal(res.Output.Iinfo)
2559
+					Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
2560
+					infoStr := string(Iinfos)
2561
+					idetinfoStr := string(Idetinfos)
2562
+					psn := &models.HisPsn{
2563
+						PsnNo:        res.Output.Baseinfo.PsnNo,
2564
+						Age:          res.Output.Baseinfo.Age,
2565
+						PatientId:    patient.ID,
2566
+						Certno:       res.Output.Baseinfo.Certno,
2567
+						Brdy:         res.Output.Baseinfo.Brdy,
2568
+						Gend:         res.Output.Baseinfo.Gend,
2569
+						Naty:         res.Output.Baseinfo.Naty,
2570
+						PsnCertType:  res.Output.Baseinfo.PsnCertType,
2571
+						PsnName:      res.Output.Baseinfo.PsnName,
2572
+						Idetinfo:     idetinfoStr,
2573
+						Insuinfo:     infoStr,
2574
+						UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
2575
+						CardInfo:     SFZStr,
2576
+						VerifyNumber: "",
2577
+					}
2578
+					service.CreateHisPsn(psn)
2579
+					var rf []*ResultFive
2580
+					json.Unmarshal([]byte(infoStr), &rf)
2581
+
2582
+					var insutypes []*ResultFive
2583
+					var insutype string
2584
+					var is390 int = 0
2585
+					var is310 int = 0
2586
+
2587
+					for _, item := range rf {
2588
+						if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
2589
+							insutypes = append(insutypes, item)
2590
+						}
2591
+					}
2592
+
2593
+					if len(insutypes) == 1 {
2594
+						insutype = insutypes[0].Insutype
2595
+					} else {
2596
+						for _, i := range insutypes {
2597
+							if i.Insutype == "390" {
2598
+								is390 = 1
2599
+							}
2600
+
2601
+							if i.Insutype == "310" {
2602
+								is310 = 1
2603
+							}
2604
+						}
2605
+					}
2606
+					if is390 == 1 {
2607
+						insutype = "390"
2608
+					}
2609
+
2610
+					if is310 == 1 {
2611
+						insutype = "310"
2612
+					}
2613
+
2614
+					if len(insutypes) == 0 {
2615
+						insutype = "310"
2616
+					}
2617
+
2618
+					c.ServeSuccessJSON(map[string]interface{}{
2619
+						"patient":  patient,
2620
+						"number":   card_no,
2621
+						"insutype": insutype,
2622
+					})
2623
+				}
2542 2624
 			} else {
2543
-				c.ServeSuccessJSON(map[string]interface{}{
2544
-					"patient": patient,
2545
-					"number":  id_card_number,
2546
-				})
2625
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
2626
+				return
2547 2627
 			}
2628
+
2548 2629
 		} else {
2549
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
2550
-			return
2630
+			SFZStr := c.GetSFZBaseInfo()
2631
+			id_card_str := strings.Split(SFZStr, "^")
2632
+			id_card_number := id_card_str[0]
2633
+			card_sn := ""
2634
+			result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
2635
+			var dat map[string]interface{}
2636
+			if err := json.Unmarshal([]byte(result), &dat); err == nil {
2637
+				fmt.Println(dat)
2638
+			} else {
2639
+				fmt.Println(err)
2640
+			}
2641
+
2642
+			userJSONBytes, _ := json.Marshal(dat)
2643
+			var res ResultTwo
2644
+			if err := json.Unmarshal(userJSONBytes, &res); err != nil {
2645
+				utils.ErrorLog("解析失败:%v", err)
2646
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2647
+				return
2648
+			}
2649
+
2650
+			if res.Infcode == 0 {
2651
+				patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
2652
+				if err == gorm.ErrRecordNotFound {
2653
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
2654
+					return
2655
+				} else if err != nil {
2656
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2657
+					return
2658
+
2659
+				} else {
2660
+					c.ServeSuccessJSON(map[string]interface{}{
2661
+						"patient": patient,
2662
+						"number":  id_card_number,
2663
+					})
2664
+				}
2665
+			} else {
2666
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
2667
+				return
2668
+			}
2669
+
2551 2670
 		}
2552 2671
 
2553 2672
 		break
@@ -2969,6 +3088,67 @@ func (c *HisApiController) ReadCard() {
2969 3088
 				return
2970 3089
 			}
2971 3090
 
3091
+		} else if miConfig.MdtrtareaAdmvs == "430800" {
3092
+
3093
+			if initFlag == 0 {
3094
+				c.TestGetBasBaseInit()
3095
+			}
3096
+			token := c.GetEleBaseInfo()
3097
+
3098
+			token = Remove0000(token)
3099
+
3100
+			result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", "", "")
3101
+			saveLog(result2, requestLog2, "1101", "获取人员信息")
3102
+			//
3103
+			var res ResultTwo
3104
+			if err := json.Unmarshal([]byte(result2), &res); err != nil {
3105
+				utils.ErrorLog("解析失败:%v", err)
3106
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3107
+				return
3108
+			}
3109
+
3110
+			if res.Infcode == 0 {
3111
+				patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
3112
+				if err == gorm.ErrRecordNotFound {
3113
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
3114
+					return
3115
+				} else if err != nil {
3116
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3117
+					return
3118
+
3119
+				} else {
3120
+					Iinfos, _ := json.Marshal(res.Output.Iinfo)
3121
+					Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
3122
+					infoStr := string(Iinfos)
3123
+					idetinfoStr := string(Idetinfos)
3124
+					psn := &models.HisPsn{
3125
+						PsnNo:        res.Output.Baseinfo.PsnNo,
3126
+						Age:          res.Output.Baseinfo.Age,
3127
+						PatientId:    patient.ID,
3128
+						Certno:       res.Output.Baseinfo.Certno,
3129
+						Brdy:         res.Output.Baseinfo.Brdy,
3130
+						Gend:         res.Output.Baseinfo.Gend,
3131
+						Naty:         res.Output.Baseinfo.Naty,
3132
+						PsnCertType:  res.Output.Baseinfo.PsnCertType,
3133
+						PsnName:      res.Output.Baseinfo.PsnName,
3134
+						Idetinfo:     idetinfoStr,
3135
+						Insuinfo:     infoStr,
3136
+						UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
3137
+						CardInfo:     "",
3138
+						VerifyNumber: token,
3139
+					}
3140
+					service.CreateHisPsn(psn)
3141
+
3142
+					c.ServeSuccessJSON(map[string]interface{}{
3143
+						"patient": patient,
3144
+						"number":  token,
3145
+					})
3146
+				}
3147
+			} else {
3148
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
3149
+				return
3150
+			}
3151
+
2972 3152
 		} else if miConfig.MdtrtareaAdmvs == "360399" {
2973 3153
 			//if initFlag == 0 {
2974 3154
 			c.TestGetJiangXiBasBaseInit()
@@ -3469,7 +3649,7 @@ func (c *HisApiController) TestGetHnBasBaseInit() {
3469 3649
 	Iinit := DllDef.MustFindProc("Init")
3470 3650
 	//miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
3471 3651
 	//http://10.77.211.236/CSB/hsa-fsi-1303
3472
-	ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430802"))
3652
+	ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
3473 3653
 	if ret != 0 {
3474 3654
 		fmt.Println("SSCard的报错原因:", err)
3475 3655
 		fmt.Println("SSCard的运算结果为:", ret)
@@ -3510,9 +3690,9 @@ func (c *HisApiController) GetSFZBaseInfo() string {
3510 3690
 		readCard = DllDef.MustFindProc("ReadSFZ")
3511 3691
 	}
3512 3692
 
3513
-	str := make([]byte, 256)
3514
-	str1 := make([]byte, 256)
3515
-	r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
3693
+	str := make([]byte, 1024)
3694
+	str1 := make([]byte, 1024)
3695
+	r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(4096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(4096))
3516 3696
 
3517 3697
 	fmt.Println(r)
3518 3698
 	return string(str)
@@ -7037,7 +7217,7 @@ func (c *HisApiController) GetRegisterInfo() {
7037 7217
 				verify_number = psn_info.VerifyNumber
7038 7218
 
7039 7219
 			} else if id_card_type == 2 {
7040
-				result, requestLog := service.Hnyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "")
7220
+				result, requestLog := service.Hnyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "", "", Certno)
7041 7221
 				saveLog(result, requestLog, "1101", "人员基本信息获取")
7042 7222
 				if err := json.Unmarshal([]byte(result), &res); err != nil {
7043 7223
 					utils.ErrorLog("解析失败:%v", err)
@@ -10137,7 +10317,7 @@ func (c *HisApiController) GetPreUploadInfo() {
10137 10317
 		data["org_name"] = miConfig.OrgName
10138 10318
 		data["doctor"] = doctor_info.UserName
10139 10319
 		data["doctor_id"] = doctor_info.DoctorNumber
10140
-		data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
10320
+		data["dept"] = department.Name
10141 10321
 		data["fixmedins_code"] = miConfig.Code
10142 10322
 		data["opter"] = roles.UserName
10143 10323
 		data["dept_code"] = department.Number
@@ -10748,12 +10928,12 @@ func (c *HisApiController) GetPreUploadInfo() {
10748 10928
 							bas := strings.Split(psn_info.CardInfo, "|")
10749 10929
 							basNumber := bas[2]
10750 10930
 							card_sn := bas[3]
10751
-							result, request_log = service.Jxyb2206Two(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn)
10931
+							result, request_log = service.Hnyb2206Two(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn)
10752 10932
 
10753 10933
 						} else {
10754 10934
 							psn_info, _ := service.GetPsnByPatientId(his.PatientId)
10755 10935
 
10756
-							result, request_log = service.Jxyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "")
10936
+							result, request_log = service.Hnyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "")
10757 10937
 
10758 10938
 						}
10759 10939
 						var dat map[string]interface{}

+ 383 - 116
controllers/zh/zh_his_api_controller.go View File

@@ -1510,7 +1510,7 @@ func (c *ZHHisApiController) GetZHInHospitalCheck() {
1510 1510
 			if med_type == 14 {
1511 1511
 				if insutype == "390" {
1512 1512
 
1513
-					struct2401.MedType = "990502"
1513
+					struct2401.MedType = "9933"
1514 1514
 
1515 1515
 				} else if insutype == "310" {
1516 1516
 
@@ -3683,148 +3683,288 @@ type ELeData struct {
3683 3683
 	Message string `json:"message"`
3684 3684
 }
3685 3685
 
3686
+var initFlagTwo int64 = 0
3687
+
3686 3688
 func (c *ZHHisApiController) ReadCard() {
3687 3689
 	id_card_type, _ := c.GetInt64("id_card_type")
3688 3690
 	admin_user_id, _ := c.GetInt64("admin_user_id")
3689 3691
 	roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
3690 3692
 	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
3691 3693
 
3692
-	if miConfig.MdtrtareaAdmvs == "" {
3694
+	switch id_card_type {
3695
+	case 1: //社保卡
3696
+		if miConfig.MdtrtareaAdmvs == "150499" {
3697
+			var api string
3698
+			api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
3699
+				"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
3693 3700
 
3694
-	} else {
3701
+			fmt.Println(api)
3695 3702
 
3696
-	}
3703
+			resp, requestErr := http.Get(api)
3704
+			if requestErr != nil {
3705
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3706
+				return
3707
+			}
3697 3708
 
3698
-	var api string
3699
-	api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
3700
-		"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
3709
+			body, ioErr := ioutil.ReadAll(resp.Body)
3710
+			if ioErr != nil {
3711
+				utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
3712
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3713
+				return
3714
+			}
3715
+			var respJSON map[string]interface{}
3716
+			if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
3717
+				utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
3718
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3719
+				return
3720
+			}
3721
+			var status string
3722
+			status = respJSON["data"].(map[string]interface{})["status"].(string)
3723
+			card_type := respJSON["data"].(map[string]interface{})["type"].(string)
3724
+			//console.log()
3725
+			fmt.Println("type===")
3701 3726
 
3702
-	fmt.Println(api)
3727
+			fmt.Println(card_type)
3703 3728
 
3704
-	resp, requestErr := http.Get(api)
3705
-	if requestErr != nil {
3706
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3707
-		return
3708
-	}
3729
+			var token string
3730
+			var res ResultTwo           //1101结果
3731
+			var res10265 ResultTwo10265 //1101结果
3732
+			var card_info string        //卡信息
3733
+			var busi_card_info string
3709 3734
 
3710
-	body, ioErr := ioutil.ReadAll(resp.Body)
3711
-	if ioErr != nil {
3712
-		utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
3713
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3714
-		return
3715
-	}
3716
-	var respJSON map[string]interface{}
3717
-	if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
3718
-		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
3719
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3720
-		return
3721
-	}
3722
-	var status string
3723
-	status = respJSON["data"].(map[string]interface{})["status"].(string)
3724
-	card_type := respJSON["data"].(map[string]interface{})["type"].(string)
3725
-	//console.log()
3726
-	fmt.Println("type===")
3735
+			card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
3736
+			busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
3727 3737
 
3728
-	fmt.Println(card_type)
3738
+			if status == "0" { //读卡成功
3739
+				if card_type == "1" {
3729 3740
 
3730
-	var token string
3731
-	var res ResultTwo           //1101结果
3732
-	var res10265 ResultTwo10265 //1101结果
3733
-	var card_info string        //卡信息
3734
-	var busi_card_info string
3741
+					respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
3742
+					result, _ := json.Marshal(respJSON)
3735 3743
 
3736
-	card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
3737
-	busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
3744
+					if err := json.Unmarshal([]byte(result), &res10265); err != nil {
3745
+						utils.ErrorLog("解析失败:%v", err)
3746
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3747
+						return
3748
+					}
3749
+					res.ErrMsg = res10265.ErrMsg
3750
+					infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
3751
+					res.Infcode = infocode
3752
+					res.Output = res10265.Output
3753
+					res.InfRefmsgid = res10265.InfRefmsgid
3738 3754
 
3739
-	if status == "0" { //读卡成功
3740
-		if card_type == "1" {
3755
+				} else {
3756
+					//var card_info string //卡信息
3757
+					//var busi_card_info string
3741 3758
 
3742
-			respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
3743
-			result, _ := json.Marshal(respJSON)
3759
+					token = respJSON["data"].(map[string]interface{})["token"].(string)
3760
+					//busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
3744 3761
 
3745
-			if err := json.Unmarshal([]byte(result), &res10265); err != nil {
3746
-				utils.ErrorLog("解析失败:%v", err)
3747
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3762
+					//fmt.Println(card_info)
3763
+					//fmt.Println(busi_card_info)
3764
+
3765
+					respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
3766
+					result, _ := json.Marshal(respJSON)
3767
+
3768
+					if err := json.Unmarshal([]byte(result), &res10265); err != nil {
3769
+						utils.ErrorLog("解析失败:%v", err)
3770
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3771
+						return
3772
+					}
3773
+					res.ErrMsg = res10265.ErrMsg
3774
+					infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
3775
+					res.Infcode = infocode
3776
+					res.Output = res10265.Output
3777
+					res.InfRefmsgid = res10265.InfRefmsgid
3778
+
3779
+				}
3780
+
3781
+				if res.Infcode == 0 {
3782
+					var insutypes []string
3783
+					var insutype string
3784
+					var is390 int = 0
3785
+					var is310 int = 0
3786
+					for _, item := range res.Output.Iinfo {
3787
+						if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
3788
+							insutypes = append(insutypes, item.Insutype)
3789
+						}
3790
+					}
3791
+					if len(insutypes) == 1 {
3792
+						insutype = insutypes[0]
3793
+					} else {
3794
+						for _, i := range insutypes {
3795
+							if i == "390" {
3796
+								is390 = 1
3797
+							}
3798
+
3799
+							if i == "310" {
3800
+								is310 = 1
3801
+							}
3802
+						}
3803
+					}
3804
+					if is390 == 1 {
3805
+						insutype = "390"
3806
+					}
3807
+					if is310 == 1 {
3808
+						insutype = "310"
3809
+					}
3810
+					if len(insutypes) == 0 {
3811
+						insutype = "310"
3812
+					}
3813
+
3814
+					patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
3815
+					if err == gorm.ErrRecordNotFound {
3816
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
3817
+						return
3818
+					} else if err != nil {
3819
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3820
+						return
3821
+
3822
+					} else {
3823
+
3824
+						if card_type == "1" {
3825
+							bas := strings.Split(card_info, "|")
3826
+							basNumber := bas[2]
3827
+							Iinfos, _ := json.Marshal(res.Output.Iinfo)
3828
+							Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
3829
+							infoStr := string(Iinfos)
3830
+							idetinfoStr := string(Idetinfos)
3831
+							psn := &models.HisPsn{
3832
+								PsnNo:        res.Output.Baseinfo.PsnNo,
3833
+								Age:          res.Output.Baseinfo.Age,
3834
+								PatientId:    patient.ID,
3835
+								Certno:       res.Output.Baseinfo.Certno,
3836
+								Brdy:         res.Output.Baseinfo.Brdy,
3837
+								Gend:         res.Output.Baseinfo.Gend,
3838
+								Naty:         res.Output.Baseinfo.Naty,
3839
+								PsnCertType:  res.Output.Baseinfo.PsnCertType,
3840
+								PsnName:      res.Output.Baseinfo.PsnName,
3841
+								Idetinfo:     idetinfoStr,
3842
+								Insuinfo:     infoStr,
3843
+								UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
3844
+								CardInfo:     card_info,
3845
+								VerifyNumber: busi_card_info,
3846
+							}
3847
+							service.CreateHisPsn(psn)
3848
+							c.ServeSuccessJSON(map[string]interface{}{
3849
+								"patient":  patient,
3850
+								"number":   basNumber,
3851
+								"info":     res,
3852
+								"insutype": insutype,
3853
+							})
3854
+						} else {
3855
+							Iinfos, _ := json.Marshal(res.Output.Iinfo)
3856
+							Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
3857
+							infoStr := string(Iinfos)
3858
+							idetinfoStr := string(Idetinfos)
3859
+							psn := &models.HisPsn{
3860
+								PsnNo:        res.Output.Baseinfo.PsnNo,
3861
+								Age:          res.Output.Baseinfo.Age,
3862
+								PatientId:    patient.ID,
3863
+								Certno:       res.Output.Baseinfo.Certno,
3864
+								Brdy:         res.Output.Baseinfo.Brdy,
3865
+								Gend:         res.Output.Baseinfo.Gend,
3866
+								Naty:         res.Output.Baseinfo.Naty,
3867
+								PsnCertType:  res.Output.Baseinfo.PsnCertType,
3868
+								PsnName:      res.Output.Baseinfo.PsnName,
3869
+								Idetinfo:     idetinfoStr,
3870
+								Insuinfo:     infoStr,
3871
+								UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
3872
+								CardInfo:     card_info,
3873
+								VerifyNumber: token,
3874
+							}
3875
+							service.CreateHisPsn(psn)
3876
+							c.ServeSuccessJSON(map[string]interface{}{
3877
+								"patient":  patient,
3878
+								"number":   token,
3879
+								"info":     res,
3880
+								"insutype": insutype,
3881
+							})
3882
+						}
3883
+					}
3884
+				} else {
3885
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
3886
+					return
3887
+				}
3888
+			} else { //读卡失败
3889
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
3748 3890
 				return
3891
+
3749 3892
 			}
3750
-			res.ErrMsg = res10265.ErrMsg
3751
-			infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
3752
-			res.Infcode = infocode
3753
-			res.Output = res10265.Output
3754
-			res.InfRefmsgid = res10265.InfRefmsgid
3755 3893
 
3756 3894
 		} else {
3757
-			//var card_info string //卡信息
3758
-			//var busi_card_info string
3759 3895
 
3760
-			token = respJSON["data"].(map[string]interface{})["token"].(string)
3761
-			//busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
3896
+			if initFlagTwo == 0 {
3897
+				c.TestGetBasBaseInitTwo()
3898
+			}
3899
+			basStr := c.GetBasBaseInfoTwo()
3900
+			if len(basStr) == 0 {
3901
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
3902
+				return
3903
+			}
3904
+			fmt.Println(basStr)
3905
+			bas := strings.Split(basStr, "|")
3906
+			id_card_no := bas[1]
3762 3907
 
3763
-			//fmt.Println(card_info)
3764
-			//fmt.Println(busi_card_info)
3908
+			result, _ := service.ZHGdyb1101B(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "", 1, "")
3765 3909
 
3766
-			respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
3767
-			result, _ := json.Marshal(respJSON)
3910
+			//result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
3911
+			var dat map[string]interface{}
3912
+			if err := json.Unmarshal([]byte(result), &dat); err == nil {
3913
+				fmt.Println(dat)
3914
+			} else {
3915
+				fmt.Println(err)
3916
+			}
3768 3917
 
3769
-			if err := json.Unmarshal([]byte(result), &res10265); err != nil {
3918
+			userJSONBytes, _ := json.Marshal(dat)
3919
+			var res ResultTwo
3920
+			if err := json.Unmarshal(userJSONBytes, &res); err != nil {
3770 3921
 				utils.ErrorLog("解析失败:%v", err)
3771 3922
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3772 3923
 				return
3773 3924
 			}
3774
-			res.ErrMsg = res10265.ErrMsg
3775
-			infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
3776
-			res.Infcode = infocode
3777
-			res.Output = res10265.Output
3778
-			res.InfRefmsgid = res10265.InfRefmsgid
3779 3925
 
3780
-		}
3926
+			if res.Infcode == 0 {
3927
+				patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
3928
+				if err == gorm.ErrRecordNotFound {
3929
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
3930
+					return
3931
+				} else if err != nil {
3932
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3933
+					return
3781 3934
 
3782
-		if res.Infcode == 0 {
3783
-			var insutypes []string
3784
-			var insutype string
3785
-			var is390 int = 0
3786
-			var is310 int = 0
3787
-			for _, item := range res.Output.Iinfo {
3788
-				if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
3789
-					insutypes = append(insutypes, item.Insutype)
3790
-				}
3791
-			}
3792
-			if len(insutypes) == 1 {
3793
-				insutype = insutypes[0]
3794
-			} else {
3795
-				for _, i := range insutypes {
3796
-					if i == "390" {
3797
-						is390 = 1
3935
+				} else {
3936
+					var insutypes []string
3937
+					var insutype string
3938
+					var is390 int = 0
3939
+					var is310 int = 0
3940
+					for _, item := range res.Output.Iinfo {
3941
+						if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
3942
+							insutypes = append(insutypes, item.Insutype)
3943
+						}
3798 3944
 					}
3945
+					if len(insutypes) == 1 {
3946
+						insutype = insutypes[0]
3947
+					} else {
3948
+						for _, i := range insutypes {
3949
+							if i == "390" {
3950
+								is390 = 1
3951
+							}
3799 3952
 
3800
-					if i == "310" {
3801
-						is310 = 1
3953
+							if i == "310" {
3954
+								is310 = 1
3955
+							}
3956
+						}
3957
+					}
3958
+					if is390 == 1 {
3959
+						insutype = "390"
3960
+					}
3961
+					if is310 == 1 {
3962
+						insutype = "310"
3963
+					}
3964
+					if len(insutypes) == 0 {
3965
+						insutype = "310"
3802 3966
 					}
3803
-				}
3804
-			}
3805
-			if is390 == 1 {
3806
-				insutype = "390"
3807
-			}
3808
-			if is310 == 1 {
3809
-				insutype = "310"
3810
-			}
3811
-			if len(insutypes) == 0 {
3812
-				insutype = "310"
3813
-			}
3814
-
3815
-			patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
3816
-			if err == gorm.ErrRecordNotFound {
3817
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
3818
-				return
3819
-			} else if err != nil {
3820
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3821
-				return
3822
-
3823
-			} else {
3824 3967
 
3825
-				if card_type == "1" {
3826
-					bas := strings.Split(card_info, "|")
3827
-					basNumber := bas[2]
3828 3968
 					Iinfos, _ := json.Marshal(res.Output.Iinfo)
3829 3969
 					Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
3830 3970
 					infoStr := string(Iinfos)
@@ -3842,17 +3982,85 @@ func (c *ZHHisApiController) ReadCard() {
3842 3982
 						Idetinfo:     idetinfoStr,
3843 3983
 						Insuinfo:     infoStr,
3844 3984
 						UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
3845
-						CardInfo:     card_info,
3846
-						VerifyNumber: busi_card_info,
3985
+						CardInfo:     basStr,
3986
+						VerifyNumber: "",
3847 3987
 					}
3848 3988
 					service.CreateHisPsn(psn)
3849 3989
 					c.ServeSuccessJSON(map[string]interface{}{
3850 3990
 						"patient":  patient,
3851
-						"number":   basNumber,
3991
+						"number":   id_card_no,
3852 3992
 						"info":     res,
3853 3993
 						"insutype": insutype,
3854 3994
 					})
3995
+				}
3996
+			} else {
3997
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
3998
+				return
3999
+			}
4000
+
4001
+		}
4002
+		break
4003
+	case 4: //电子凭证
4004
+		if miConfig.MdtrtareaAdmvs == "150499" {
4005
+
4006
+		} else {
4007
+			if initFlagTwo == 0 {
4008
+				c.TestGetBasBaseInitTwo()
4009
+			}
4010
+			token := c.GetEleBaseInfoTwo()
4011
+			token = Remove0000(token)
4012
+			result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token)
4013
+			saveLog(result2, requestLog2, "1101", "获取人员信息")
4014
+			//
4015
+			var res ResultTwo
4016
+			if err := json.Unmarshal([]byte(result2), &res); err != nil {
4017
+				utils.ErrorLog("解析失败:%v", err)
4018
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4019
+				return
4020
+			}
4021
+
4022
+			if res.Infcode == 0 {
4023
+				patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
4024
+				if err == gorm.ErrRecordNotFound {
4025
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
4026
+					return
4027
+				} else if err != nil {
4028
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
4029
+					return
4030
+
3855 4031
 				} else {
4032
+					var insutypes []string
4033
+					var insutype string
4034
+					var is390 int = 0
4035
+					var is310 int = 0
4036
+					for _, item := range res.Output.Iinfo {
4037
+						if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
4038
+							insutypes = append(insutypes, item.Insutype)
4039
+						}
4040
+					}
4041
+					if len(insutypes) == 1 {
4042
+						insutype = insutypes[0]
4043
+					} else {
4044
+						for _, i := range insutypes {
4045
+							if i == "390" {
4046
+								is390 = 1
4047
+							}
4048
+
4049
+							if i == "310" {
4050
+								is310 = 1
4051
+							}
4052
+						}
4053
+					}
4054
+					if is390 == 1 {
4055
+						insutype = "390"
4056
+					}
4057
+					if is310 == 1 {
4058
+						insutype = "310"
4059
+					}
4060
+					if len(insutypes) == 0 {
4061
+						insutype = "310"
4062
+					}
4063
+
3856 4064
 					Iinfos, _ := json.Marshal(res.Output.Iinfo)
3857 4065
 					Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
3858 4066
 					infoStr := string(Iinfos)
@@ -3870,7 +4078,7 @@ func (c *ZHHisApiController) ReadCard() {
3870 4078
 						Idetinfo:     idetinfoStr,
3871 4079
 						Insuinfo:     infoStr,
3872 4080
 						UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
3873
-						CardInfo:     card_info,
4081
+						CardInfo:     "",
3874 4082
 						VerifyNumber: token,
3875 4083
 					}
3876 4084
 					service.CreateHisPsn(psn)
@@ -3881,16 +4089,75 @@ func (c *ZHHisApiController) ReadCard() {
3881 4089
 						"insutype": insutype,
3882 4090
 					})
3883 4091
 				}
4092
+			} else {
4093
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
4094
+				return
3884 4095
 			}
3885
-		} else {
3886
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
3887
-			return
4096
+
3888 4097
 		}
3889
-	} else { //读卡失败
3890
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
4098
+		break
4099
+	}
4100
+}
4101
+func (c *ZHHisApiController) GetEleBaseInfoTwo() string {
4102
+	DllDef := syscall.MustLoadDLL("SSCard.dll")
4103
+	readCard := DllDef.MustFindProc("GetQRBase")
4104
+	fmt.Println(readCard)
4105
+
4106
+	if readCard == nil {
4107
+		fmt.Println("readcard is nil")
4108
+		readCard = DllDef.MustFindProc("GetQRBase")
4109
+	}
4110
+	str := make([]byte, 1024)
4111
+	str1 := make([]byte, 1024)
4112
+	ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
4113
+	fmt.Println(ret2)
4114
+	fmt.Println(string(str1))
4115
+	fmt.Println(string(str))
4116
+	fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
4117
+	fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
4118
+	if ret2 != 0 {
4119
+		return ""
4120
+	}
4121
+	return string(str)
4122
+}
4123
+
4124
+func (c *ZHHisApiController) TestGetBasBaseInitTwo() {
4125
+	DllDef := syscall.MustLoadDLL("SSCard.dll")
4126
+	Iinit := DllDef.MustFindProc("Init")
4127
+	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
4128
+
4129
+	ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.MdtrtareaAdmvs))
4130
+	if ret != 0 {
4131
+		fmt.Println("SSCard的报错原因:", err)
4132
+		fmt.Println("SSCard的运算结果为:", ret)
4133
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
3891 4134
 		return
4135
+	}
4136
+
4137
+	result := int(ret)
4138
+	fmt.Println("SSCard的运算结果为1:", result)
4139
+	initFlagTwo = 1
4140
+	return
4141
+}
3892 4142
 
4143
+func (c *ZHHisApiController) GetBasBaseInfoTwo() string {
4144
+	DllDef := syscall.MustLoadDLL("SSCard.dll")
4145
+	readCard := DllDef.MustFindProc("ReadCardBas")
4146
+	if readCard == nil {
4147
+		fmt.Println("readcard is nil")
4148
+		readCard = DllDef.MustFindProc("ReadCardBas")
4149
+	}
4150
+	str := make([]byte, 1024)
4151
+	str1 := make([]byte, 1024)
4152
+	ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
4153
+	fmt.Println(string(str1))
4154
+	fmt.Println(string(str))
4155
+	fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
4156
+	fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
4157
+	if ret2 != 0 {
4158
+		return ""
3893 4159
 	}
4160
+	return string(str)
3894 4161
 }
3895 4162
 
3896 4163
 var initFlag int64 = 0

+ 16 - 13
service/hn_service.go View File

@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 // 人员基本信息
16
-func Hnyb1101(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates string, request_url string, access_key string, cainfo string) (string, string) {
16
+func Hnyb1101(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates string, request_url string, access_key string, cainfo string, name string, mdtrt_cert_no string) (string, string) {
17 17
 	timestamp := time.Now().Unix()
18 18
 	//生成输入报文
19 19
 	inputMessage := SetJSInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
@@ -23,28 +23,31 @@ func Hnyb1101(certNo string, org_name string, doctor string, fixmedins_code stri
23 23
 	inputMessage["infno"] = "1101" // 交易编码
24 24
 
25 25
 	if certificates == "3" {
26
-		inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
27
-		inputData["certno"] = certNo        // 证件号码
28
-		inputData["psn_cert_type"] = "99"   // 人员证件类型
26
+		inputData["mdtrt_cert_type"] = "99"        // 就诊凭证类型
27
+		inputData["certno"] = certNo               // 证件号码
28
+		inputData["psn_cert_type"] = "99"          // 人员证件类型
29
+		inputData["mdtrt_cert_no"] = mdtrt_cert_no // 就诊凭证编号
29 30
 
30 31
 	} else {
31 32
 		if id_card_type == 1 {
32
-			inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
33
-			inputData["card_sn"] = card_sn      // 卡识别码
34
-			inputData["certno"] = certNo        // 证件号码
35
-			inputData["psn_cert_type"] = "01"   // 人员证件类型
33
+			inputData["mdtrt_cert_type"] = "03"        // 就诊凭证类型
34
+			inputData["card_sn"] = card_sn             // 卡识别码
35
+			inputData["certno"] = certNo               // 证件号码
36
+			inputData["psn_cert_type"] = "01"          // 人员证件类型
37
+			inputData["mdtrt_cert_no"] = mdtrt_cert_no // 就诊凭证编号
36 38
 
37
-		} else {
39
+		} else if id_card_type == 2 {
38 40
 			inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
39 41
 			inputData["card_sn"] = ""           // 卡识别码
40 42
 			inputData["certno"] = certNo        // 证件号码
41 43
 			inputData["psn_cert_type"] = "01"   // 人员证件类型
44
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
45
+
42 46
 		}
43 47
 	}
44 48
 
45
-	inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
46
-	inputData["begntime"] = ""          // 开始时间
47
-	inputData["psn_name"] = ""          // 人员姓名
49
+	inputData["begntime"] = ""   // 开始时间
50
+	inputData["psn_name"] = name // 人员姓名
48 51
 	input["data"] = inputData
49 52
 	inputMessage["input"] = input //交易输入
50 53
 
@@ -382,7 +385,7 @@ func Hnyb2203A(psnNo string, mdtrtId string, doctor string, department string, o
382 385
 		fmt.Println(err.Error())
383 386
 		return err.Error(), ""
384 387
 	}
385
-	request_url = request_url + "2203A"
388
+	request_url = request_url + "2203"
386 389
 	//fmt.Println(HttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData)))
387 390
 
388 391
 	return HNHttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData), "2203"), requestLog

+ 2 - 2
service/jsyb_service.go View File

@@ -1017,12 +1017,12 @@ func SetJSInputMessage(timestamp int64, org_name string, doctor string, fixmedin
1017 1017
 	inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
1018 1018
 	inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs                                           // 就医地医保区划
1019 1019
 	inputMessage["insuplc_admdvs"] = insuplc_admdvs                                             // 参保地医保区划
1020
-	inputMessage["recer_sys_code"] = "1"                                                        // 接收方系统代码
1020
+	inputMessage["recer_sys_code"] = "MBS_LOCAL"                                                // 接收方系统代码
1021 1021
 	inputMessage["dev_no"] = "1"                                                                // 设备编号
1022 1022
 	inputMessage["dev_safe_info"] = "1"                                                         // 设备安全信息
1023 1023
 	inputMessage["cainfo"] = cainfo                                                             // 数字签名信息
1024 1024
 	inputMessage["signtype"] = "SM3"                                                            // 签名类型
1025
-	inputMessage["infver"] = "V1.0"                                                             // 接收方系统代码
1025
+	inputMessage["infver"] = "1.0.0"                                                            // 接收方系统代码
1026 1026
 	inputMessage["opter_type"] = "1"                                                            // 经办人类别
1027 1027
 	if fixmedins_code == "H32090403023" {
1028 1028
 

+ 83 - 0
service/zh_his_service.go View File

@@ -100,6 +100,89 @@ func ZHGdyb1101(certNo string, org_name string, doctor string, fixmedins_code st
100 100
 	return str, requestLog, resultLog
101 101
 }
102 102
 
103
+func ZHGdyb1101B(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates int64, name string) (string, string) {
104
+	//生成签名
105
+	var requestLog string
106
+	nonce := GetRandomString(32)
107
+	timestamp := time.Now().Unix()
108
+	signature := setSignature(timestamp, nonce, secret_key)
109
+	//生成输入报文
110
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
111
+	input := make(map[string]interface{})
112
+	inputData := make(map[string]interface{})
113
+	inputMessage["infno"] = "1101" // 交易编码
114
+
115
+	if certificates == 3 {
116
+		inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
117
+		inputData["certno"] = certNo        // 证件号码
118
+		inputData["psn_cert_type"] = "99"   // 人员证件类型
119
+
120
+	} else {
121
+		if id_card_type == 1 {
122
+			inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
123
+			inputData["card_sn"] = ""           // 卡识别码
124
+			inputData["certno"] = certNo        // 证件号码
125
+			inputData["psn_cert_type"] = "01"   // 人员证件类型
126
+
127
+		} else {
128
+			inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
129
+			inputData["card_sn"] = ""           // 卡识别码
130
+			inputData["certno"] = certNo        // 证件号码
131
+			inputData["psn_cert_type"] = "01"   // 人员证件类型
132
+		}
133
+	}
134
+
135
+	inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
136
+	inputData["begntime"] = ""          // 开始时间
137
+	inputData["psn_name"] = ""          // 人员姓名
138
+	input["data"] = inputData
139
+	inputMessage["input"] = input //交易输入
140
+
141
+	bytesData, err := json.Marshal(inputMessage)
142
+	fmt.Println(string(bytesData))
143
+	requestLog = string(bytesData)
144
+	if err != nil {
145
+		fmt.Println(err.Error())
146
+		return err.Error(), ""
147
+	}
148
+	reader := bytes.NewReader(bytesData)
149
+	gdyb_url := beego.AppConfig.String("gdyb_url")
150
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
151
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
152
+	url := gdyb_url + "1101"
153
+	if mdtrtarea_admvs == "150499" {
154
+		url = gdyb_url
155
+	}
156
+
157
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
158
+	request, err := http.NewRequest("POST", url, reader)
159
+	if err != nil {
160
+		fmt.Println(err.Error())
161
+		return err.Error(), ""
162
+	}
163
+
164
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
165
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
166
+	request.Header.Set("x-tif-signature", signature)
167
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
168
+	request.Header.Set("x-tif-nonce", nonce)
169
+
170
+	client := http.Client{}
171
+	resp, err := client.Do(request)
172
+	if err != nil {
173
+		fmt.Println(err.Error())
174
+		return err.Error(), ""
175
+	}
176
+	respBytes, err := ioutil.ReadAll(resp.Body)
177
+	if err != nil {
178
+		fmt.Println(err.Error())
179
+		return err.Error(), ""
180
+	}
181
+	fmt.Println(string(respBytes))
182
+	str := string(respBytes)
183
+	return str, requestLog
184
+}
185
+
103 186
 type DiseinfoStruct struct {
104 187
 	PsnNo        string
105 188
 	DiagType     string