Ver código fonte

Merge branch 'master' of http://git.shengws.com/csx/gdyb

csx 2 anos atrás
pai
commit
44d4076145

+ 94 - 45
controllers/nm/nm_controller.go Ver arquivo

@@ -451,7 +451,7 @@ func (c *NmController) ReadCard() {
451 451
 
452 452
 		}
453 453
 		break
454
-	case "3": //电子凭证
454
+	case "4": //电子凭证
455 455
 		_, pBusiCardInfo := c.GetELeInfo(fixmedins_code, operator_id, operator)
456 456
 		//fmt.Println(pCardInfo)
457 457
 		fmt.Println(pBusiCardInfo)
@@ -490,26 +490,22 @@ func (c *NmController) ReadCard() {
490 490
 	}
491 491
 
492 492
 }
493
-func (c *NmController) TestGetBasBaseInit(code string, secret_key string, ak string) {
493
+
494
+var initFlag int64 = 0
495
+
496
+func (c *NmController) TestGetBasBaseInit() {
494 497
 	DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
495 498
 	Iinit := DllDef.MustFindProc("Init")
496 499
 	//miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
497 500
 	str := make([]byte, 2048)
498 501
 	inputData := make(map[string]interface{})
499
-	inputData["IP"] = "10.72.3.87"
500
-	inputData["PORT"] = "8086"
501
-	inputData["TIMEOUT"] = "180"
502
+	inputData["IP"] = "10.144.211.75"
503
+	inputData["PORT"] = 7021
504
+	inputData["TIMEOUT"] = 180
502 505
 	inputData["LOG_PATH"] = "C:\\log\\"
503
-	//
504
-	inputData["EC_URL"] = "http://10.72.3.127:10086/localcfc/api/hsecfc/localQrCodeQuery"
505
-	inputData["CARD_PASSTYPE"] = "1"
506
-	inputData["API_NAME"] = "hssServives"
507
-	inputData["API_VERSION"] = "1.0.0"
508
-	inputData["ACCESS_KEY"] = ak
509
-
510
-	inputData["SECRETKEY"] = secret_key
511
-	inputData["ORG_ID"] = code
512
-	inputData["EXT"] = ""
506
+	//inputData["SFZ_DRIVER_TYPE"] = 0
507
+	inputData["URL"] = "/call1"
508
+
513 509
 	bytesData, _ := json.Marshal(inputData)
514 510
 	fmt.Println(inputData)
515 511
 	fmt.Println(bytesData)
@@ -529,59 +525,112 @@ func (c *NmController) TestGetBasBaseInit(code string, secret_key string, ak str
529 525
 	//initFlag = 1
530 526
 	return
531 527
 }
532
-func (c *NmController) GetBasBaseInfo() (string, string) {
528
+
529
+func (c *NmController) GetSFZBaseInfo() string {
530
+	DllDef := syscall.MustLoadDLL("SSCard.dll")
531
+	readCard := DllDef.MustFindProc("ReadSFZ")
532
+	if readCard == nil {
533
+		fmt.Println("readcard is nil")
534
+		readCard = DllDef.MustFindProc("ReadSFZ")
535
+	}
536
+
537
+	str := make([]byte, 256)
538
+	str1 := make([]byte, 256)
539
+	r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
540
+
541
+	fmt.Println(r)
542
+	return string(str)
543
+}
544
+
545
+func (c *NmController) GetBasBaseInfo(fixmedins_code string, mdtrtarea_admvs string, opter_name string, opter_id string, fixmedins_name string) string {
533 546
 	DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
534 547
 	readCard := DllDef.MustFindProc("ReadCardBas")
535 548
 	fmt.Println(readCard)
536 549
 	fmt.Println("!!!!!")
537
-	pCardInfo := make([]byte, 2048)
550
+
551
+	month := time.Unix(1557042972, 0).Format("1")
552
+	year := time.Now().Format("2006")
553
+	month = time.Now().Format("01")
554
+	day := time.Now().Format("02")
555
+
556
+	hour := time.Now().Format("15")
557
+	min := time.Now().Format("04")
558
+	sec := time.Now().Format("05")
559
+
560
+	msec := time.Now().Format("000")
561
+	timestamp := time.Now().Unix()
562
+
563
+	tempTime := time.Unix(timestamp, 0)
564
+	//timeFormat := tempTime.Format("20060102150405")
565
+	timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
566
+	//randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
567
+
568
+	inputData := make(map[string]interface{})
569
+	inputData["infno"] = "1199"
570
+	//inputData["msgid"] = "7021"
571
+	inputData["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
572
+	inputData["mdtrtarea_admvs"] = mdtrtarea_admvs                                           // 发送方报文 ID
573
+	inputData["recer_sys_code"] = "01"
574
+	inputData["infver"] = "V1.0"
575
+	inputData["opter_type"] = "1"
576
+	inputData["opter"] = opter_id
577
+	inputData["opter_name"] = opter_name
578
+	inputData["inf_time"] = timeFormatOne
579
+	inputData["fixmedins_code"] = fixmedins_code
580
+	inputData["fixmedins_name"] = fixmedins_name
581
+
582
+	inputData["dev_no"] = ""
583
+	inputData["dev_safe_info"] = ""
584
+	inputData["cainfo"] = ""
585
+	inputData["signtype"] = ""
586
+	inputData["sign_no"] = ""
587
+
588
+	bytesData, _ := json.Marshal(inputData)
589
+	fmt.Println(string(bytesData))
538 590
 	pBusiCardInfo := make([]byte, 8192)
539
-	ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
591
+	ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
540 592
 	fmt.Println(ret2)
541
-	fmt.Println(DeleteExtraSpace(string(pCardInfo)))
542 593
 	fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
543
-	fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pCardInfo)), "gbk", "utf-8"))
544 594
 	fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
545 595
 	if ret2 != 0 {
546
-		return "", ""
596
+		return ""
547 597
 	}
548
-	return DeleteExtraSpace(string(pCardInfo)), DeleteExtraSpace(string(pBusiCardInfo))
598
+	return DeleteExtraSpace(string(pBusiCardInfo))
549 599
 }
600
+
550 601
 func (c *NmController) GetELeInfo(code string, operator_id string, operator_name string) (string, string) {
551
-	DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
552
-	readCard := DllDef.MustFindProc("EcCardQuery")
602
+	DllDef := syscall.MustLoadDLL("NationECCode.dll")
603
+	readCard := DllDef.MustFindProc("NationEcTrans")
553 604
 	fmt.Println(readCard)
554 605
 	fmt.Println("!!!!!")
555
-	//pCardInfo := make([]byte, 8192)
556 606
 	pBusiCardInfo := make([]byte, 8192)
557
-
558
-	//data := make(map[string]interface{})
559
-	//pData := make(map[string]interface{})
560
-
561
-	//inputData := make(map[string]interface{})
562
-	//inputData["orgId"] = code
563
-	//inputData["businessType"] = "01101"
564
-	//inputData["operatorId"] = operator_id
565
-	//inputData["operatorName"] = operator_name
566
-	//inputData["officeId"] = "001"
567
-	//inputData["officeName"] = "血透室"
568
-
569
-	//data["data"] = inputData
570
-	//data["transType"] = "ec.query"
571
-	//data["orgId"] = code
572
-	//bytesData, _ := json.Marshal(data)
573
-	//pCardInfo = bytesData
574
-	ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
607
+	input := make(map[string]interface{})
608
+	inputData := make(map[string]interface{})
609
+	inputData["orgId"] = code
610
+	inputData["businessType"] = "01101"
611
+	inputData["operatorId"] = operator_id
612
+	inputData["operatorName"] = operator_name
613
+	inputData["officeId"] = "001"
614
+	inputData["officeName"] = "血透室"
615
+	inputData["deviceType"] = ""
616
+	input["data"] = inputData
617
+	input["orgId"] = code
618
+	input["transType"] = "ec.query"
619
+
620
+	bytesData, _ := json.Marshal(input)
621
+	gdyb_url := beego.AppConfig.String("gdyb_url")
622
+
623
+	url := gdyb_url + "/localcfc/api/hsecfc/localQrCodeQuery"
624
+	ret2, _, _ := readCard.Call(StrPtr(url), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
575 625
 	fmt.Println(ret2)
576
-	//fmt.Println(DeleteExtraSpace(string(bytesData)))
577 626
 	fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
578
-	//fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
579 627
 	fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
580 628
 	if ret2 != 0 {
581 629
 		return "", ""
582 630
 	}
583 631
 	return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
584 632
 }
633
+
585 634
 func IntPtr(n int) uintptr {
586 635
 	return uintptr(n)
587 636
 }

+ 16 - 4
controllers/sg/his_api_controller.go Ver arquivo

@@ -8878,10 +8878,20 @@ func (c *HisApiController) GetSettleAccounts() {
8878 8878
 			bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
8879 8879
 		}
8880 8880
 
8881
-		if item.MedChrgitmType == "03" { //检查费
8882
-			checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
8883
-			checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
8884
-			checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
8881
+		if c.GetAdminUserInfo().CurrentOrgId == 10188 {
8882
+			if item.MedChrgitmType == "03" { //检查费
8883
+				treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
8884
+				treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
8885
+				treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
8886
+			}
8887
+		} else {
8888
+
8889
+			if item.MedChrgitmType == "03" { //检查费
8890
+				checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
8891
+				checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
8892
+				checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
8893
+			}
8894
+
8885 8895
 		}
8886 8896
 
8887 8897
 		if item.MedChrgitmType == "04" { //化验费
@@ -8891,9 +8901,11 @@ func (c *HisApiController) GetSettleAccounts() {
8891 8901
 		}
8892 8902
 
8893 8903
 		if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
8904
+
8894 8905
 			treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
8895 8906
 			treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
8896 8907
 			treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
8908
+
8897 8909
 		}
8898 8910
 
8899 8911
 		if item.MedChrgitmType == "06" { //手术费

+ 127 - 151
controllers/zh/zh_his_api_controller.go Ver arquivo

@@ -2893,121 +2893,96 @@ type ELeData struct {
2893 2893
 func (c *ZHHisApiController) ReadCard() {
2894 2894
 	id_card_type, _ := c.GetInt64("id_card_type")
2895 2895
 	admin_user_id, _ := c.GetInt64("admin_user_id")
2896
-	certificates, _ := c.GetInt64("certificates")
2896
+	//certificates, _ := c.GetInt64("certificates")
2897 2897
 	fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
2898 2898
 	roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
2899 2899
 	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
2900 2900
 
2901
-	switch id_card_type {
2902
-	case 1:
2903
-		if initFlag == 0 {
2904
-			c.TestGetBasBaseInit()
2905
-		}
2906
-		basStr := c.GetBasBaseInfo(miConfig.Code, miConfig.MdtrtareaAdmvs, roles.UserName, strconv.FormatInt(roles.ID, 10), miConfig.OrgName)
2907
-		if len(basStr) == 0 {
2908
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
2909
-			return
2910
-		}
2911
-		fmt.Println(basStr)
2912
-		bas := strings.Split(basStr, "|")
2913
-		basNumber := bas[1]
2914
-		fmt.Println(basNumber)
2915
-		card_sn := bas[3]
2916
-		fmt.Println(card_sn)
2917
-		result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
2918
-		var dat map[string]interface{}
2919
-		if err := json.Unmarshal([]byte(result), &dat); err == nil {
2920
-			fmt.Println(dat)
2921
-		} else {
2922
-			fmt.Println(err)
2923
-		}
2901
+	var api string
2902
+	api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
2903
+		"&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
2904
+	fmt.Println(api)
2924 2905
 
2925
-		userJSONBytes, _ := json.Marshal(dat)
2926
-		var res ResultTwo
2927
-		if err := json.Unmarshal(userJSONBytes, &res); err != nil {
2928
-			utils.ErrorLog("解析失败:%v", err)
2929
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2930
-			return
2931
-		}
2906
+	resp, requestErr := http.Get(api)
2907
+	if requestErr != nil {
2908
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2909
+		return
2910
+	}
2932 2911
 
2933
-		if res.Infcode == 0 {
2912
+	body, ioErr := ioutil.ReadAll(resp.Body)
2913
+	if ioErr != nil {
2914
+		utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
2915
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2916
+		return
2917
+	}
2918
+	var respJSON map[string]interface{}
2919
+	if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
2920
+		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
2921
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2922
+		return
2923
+	}
2924
+	var status string
2925
+	status = respJSON["data"].(map[string]interface{})["status"].(string)
2926
+	card_type := respJSON["data"].(map[string]interface{})["type"].(string)
2927
+	//console.log()
2928
+	fmt.Println("type===")
2934 2929
 
2935
-			var insutypes []string
2936
-			var insutype string
2937
-			var is390 int = 0
2938
-			var is310 int = 0
2939
-			for _, item := range res.Output.Iinfo {
2940
-				if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
2941
-					insutypes = append(insutypes, item.Insutype)
2942
-				}
2943
-			}
2944
-			if len(insutypes) == 1 {
2945
-				insutype = insutypes[0]
2946
-			} else {
2947
-				for _, i := range insutypes {
2948
-					if i == "390" {
2949
-						is390 = 1
2950
-					}
2930
+	fmt.Println(card_type)
2951 2931
 
2952
-					if i == "310" {
2953
-						is310 = 1
2954
-					}
2955
-				}
2956
-			}
2957
-			if is390 == 1 {
2958
-				insutype = "390"
2959
-			}
2960
-			if is310 == 1 {
2961
-				insutype = "310"
2962
-			}
2963
-			if len(insutypes) == 0 {
2964
-				insutype = "310"
2965
-			}
2932
+	var token string
2933
+	var res ResultTwo           //1101结果
2934
+	var res10265 ResultTwo10265 //1101结果
2935
+	var card_info string        //卡信息
2936
+	var busi_card_info string
2966 2937
 
2967
-			patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
2968
-			if err == gorm.ErrRecordNotFound {
2969
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
2970
-				return
2971
-			} else if err != nil {
2972
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2973
-				return
2938
+	card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
2939
+	busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
2974 2940
 
2975
-			} else {
2976
-				c.ServeSuccessJSON(map[string]interface{}{
2977
-					"patient":  patient,
2978
-					"number":   basNumber,
2979
-					"info":     res,
2980
-					"insutype": insutype,
2981
-				})
2941
+	if status == "0" { //读卡成功
2942
+		if card_type == "1" {
2943
+
2944
+			respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
2945
+			result, _ := json.Marshal(respJSON)
2946
+
2947
+			if err := json.Unmarshal([]byte(result), &res10265); err != nil {
2948
+				utils.ErrorLog("解析失败:%v", err)
2949
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2950
+				return
2982 2951
 			}
2952
+			res.ErrMsg = res10265.ErrMsg
2953
+			infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
2954
+			res.Infcode = infocode
2955
+			res.Output = res10265.Output
2956
+			res.InfRefmsgid = res10265.InfRefmsgid
2957
+
2983 2958
 		} else {
2984
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
2985
-			return
2986
-		}
2987
-		break
2988
-	case 2:
2989
-		SFZStr := c.GetSFZBaseInfo()
2990
-		id_card_str := strings.Split(SFZStr, "^")
2991
-		id_card_number := id_card_str[0]
2992
-		card_sn := ""
2993
-		result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
2994
-		var dat map[string]interface{}
2995
-		if err := json.Unmarshal([]byte(result), &dat); err == nil {
2996
-			fmt.Println(dat)
2997
-		} else {
2998
-			fmt.Println(err)
2999
-		}
2959
+			//var card_info string //卡信息
2960
+			//var busi_card_info string
2961
+
2962
+			token = respJSON["data"].(map[string]interface{})["token"].(string)
2963
+			//busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
2964
+
2965
+			//fmt.Println(card_info)
2966
+			//fmt.Println(busi_card_info)
2967
+
2968
+			respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
2969
+			result, _ := json.Marshal(respJSON)
2970
+
2971
+			if err := json.Unmarshal([]byte(result), &res10265); err != nil {
2972
+				utils.ErrorLog("解析失败:%v", err)
2973
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2974
+				return
2975
+			}
2976
+			res.ErrMsg = res10265.ErrMsg
2977
+			infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
2978
+			res.Infcode = infocode
2979
+			res.Output = res10265.Output
2980
+			res.InfRefmsgid = res10265.InfRefmsgid
3000 2981
 
3001
-		userJSONBytes, _ := json.Marshal(dat)
3002
-		var res ResultTwo
3003
-		if err := json.Unmarshal(userJSONBytes, &res); err != nil {
3004
-			utils.ErrorLog("解析失败:%v", err)
3005
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3006
-			return
3007 2982
 		}
3008 2983
 
3009 2984
 		if res.Infcode == 0 {
3010
-			patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
2985
+			patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
3011 2986
 			if err == gorm.ErrRecordNotFound {
3012 2987
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
3013 2988
 				return
@@ -3016,71 +2991,72 @@ func (c *ZHHisApiController) ReadCard() {
3016 2991
 				return
3017 2992
 
3018 2993
 			} else {
3019
-				c.ServeSuccessJSON(map[string]interface{}{
3020
-					"patient": patient,
3021
-					"number":  id_card_number,
3022
-					"info":    res,
3023
-				})
3024
-			}
3025
-		} else {
3026
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
3027
-			return
3028
-		}
3029
-
3030
-		break
3031
-	case 4:
3032
-		_, pBusiCardInfo := c.GetELeInfo(miConfig.Code, strconv.FormatInt(roles.ID, 10), roles.UserName)
3033
-
3034
-		var ele ELeData
3035
-		err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
3036
-		if err != nil {
3037
-			utils.ErrorLog("解析失败:%v", err)
3038
-		}
3039
-		token := ele.Data.EcToken
3040
-		fmt.Println(token)
3041
-		if len(token) > 0 {
3042
-			result := service.Gdyb1101ForEleCert("", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "")
3043
-			var dat map[string]interface{}
3044
-			if err := json.Unmarshal([]byte(result), &dat); err == nil {
3045
-				fmt.Println(dat)
3046
-			} else {
3047
-				fmt.Println(err)
3048
-			}
3049
-			userJSONBytes, _ := json.Marshal(dat)
3050
-			var res ResultTwo
3051
-			if err := json.Unmarshal(userJSONBytes, &res); err != nil {
3052
-				utils.ErrorLog("解析失败:%v", err)
3053
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3054
-				return
3055
-			}
3056
-
3057
-			if res.Infcode == 0 {
3058
-				patient, err := service.GetPatientByNumber(ele.Data.IdNo, c.GetAdminUserInfo().CurrentOrgId)
3059
-				if err == gorm.ErrRecordNotFound {
3060
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
3061
-					return
3062
-				} else if err != nil {
3063
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3064
-					return
3065 2994
 
2995
+				if card_type == "1" {
2996
+					bas := strings.Split(card_info, "|")
2997
+					basNumber := bas[2]
2998
+					Iinfos, _ := json.Marshal(res.Output.Iinfo)
2999
+					Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
3000
+					infoStr := string(Iinfos)
3001
+					idetinfoStr := string(Idetinfos)
3002
+					psn := &models.HisPsn{
3003
+						PsnNo:        res.Output.Baseinfo.PsnNo,
3004
+						Age:          res.Output.Baseinfo.Age,
3005
+						PatientId:    patient.ID,
3006
+						Certno:       res.Output.Baseinfo.Certno,
3007
+						Brdy:         res.Output.Baseinfo.Brdy,
3008
+						Gend:         res.Output.Baseinfo.Gend,
3009
+						Naty:         res.Output.Baseinfo.Naty,
3010
+						PsnCertType:  res.Output.Baseinfo.PsnCertType,
3011
+						PsnName:      res.Output.Baseinfo.PsnName,
3012
+						Idetinfo:     idetinfoStr,
3013
+						Insuinfo:     infoStr,
3014
+						UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
3015
+						CardInfo:     card_info,
3016
+						VerifyNumber: busi_card_info,
3017
+					}
3018
+					service.CreateHisPsn(psn)
3019
+					c.ServeSuccessJSON(map[string]interface{}{
3020
+						"patient": patient,
3021
+						"number":  basNumber,
3022
+					})
3066 3023
 				} else {
3024
+					Iinfos, _ := json.Marshal(res.Output.Iinfo)
3025
+					Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
3026
+					infoStr := string(Iinfos)
3027
+					idetinfoStr := string(Idetinfos)
3028
+					psn := &models.HisPsn{
3029
+						PsnNo:        res.Output.Baseinfo.PsnNo,
3030
+						Age:          res.Output.Baseinfo.Age,
3031
+						PatientId:    patient.ID,
3032
+						Certno:       res.Output.Baseinfo.Certno,
3033
+						Brdy:         res.Output.Baseinfo.Brdy,
3034
+						Gend:         res.Output.Baseinfo.Gend,
3035
+						Naty:         res.Output.Baseinfo.Naty,
3036
+						PsnCertType:  res.Output.Baseinfo.PsnCertType,
3037
+						PsnName:      res.Output.Baseinfo.PsnName,
3038
+						Idetinfo:     idetinfoStr,
3039
+						Insuinfo:     infoStr,
3040
+						UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
3041
+						CardInfo:     card_info,
3042
+						VerifyNumber: token,
3043
+					}
3044
+					service.CreateHisPsn(psn)
3067 3045
 					c.ServeSuccessJSON(map[string]interface{}{
3068 3046
 						"patient": patient,
3069 3047
 						"number":  token,
3070
-						"info":    res,
3071 3048
 					})
3072 3049
 				}
3073
-			} else {
3074
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
3075
-				return
3076 3050
 			}
3077 3051
 		} else {
3078 3052
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
3079 3053
 			return
3080 3054
 		}
3081
-		break
3082
-	}
3055
+	} else { //读卡失败
3056
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
3057
+		return
3083 3058
 
3059
+	}
3084 3060
 }
3085 3061
 
3086 3062
 var initFlag int64 = 0