Kaynağa Gözat

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

csx 1 yıl önce
ebeveyn
işleme
3753fccb2a
2 değiştirilmiş dosya ile 235 ekleme ve 3 silme
  1. 143 3
      controllers/sg/his_api_controller.go
  2. 92 0
      service/fj_service.go

+ 143 - 3
controllers/sg/his_api_controller.go Dosyayı Görüntüle

@@ -2354,6 +2354,144 @@ func (c *HisApiController) ReadCard() {
2354 2354
 			//	return
2355 2355
 			//}
2356 2356
 
2357
+		} else if miConfig.MdtrtareaAdmvs == "350500" {
2358
+			type ELeData struct {
2359
+				Data struct {
2360
+					IdNo        string `json:"idNo"`
2361
+					IdType      string `json:"idType"`
2362
+					UserName    string `json:"userName"`
2363
+					EcToken     string `json:"ecToken"`
2364
+					InsuOrg     string `json:"insuOrg"`
2365
+					Gender      string `json:"gender"`
2366
+					Birthday    string `json:"birthday"`
2367
+					Nationality string `json:"nationality"`
2368
+					Email       string `json:"email"`
2369
+					Extra       string `json:"extra"`
2370
+				} `json:"data"`
2371
+				Code    int    `json:"code"`
2372
+				Message string `json:"message"`
2373
+			}
2374
+
2375
+			inputInfo, outPutInfo, errMsg := service.ReadEleCard(miConfig.Code)
2376
+			fmt.Println(errMsg)
2377
+
2378
+			if len(errMsg) == 0 {
2379
+				var ele ELeData
2380
+				err := json.Unmarshal([]byte(outPutInfo), &ele)
2381
+				if err != nil {
2382
+					utils.ErrorLog("解析失败:%v", err)
2383
+				}
2384
+				token := ele.Data.EcToken
2385
+				fmt.Println(inputInfo)
2386
+				fmt.Println(outPutInfo)
2387
+				result, requestLog, errMsgLog := service.FJyb1101ForEleToken(ele.Data.IdNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, "", certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, token)
2388
+
2389
+				saveLog(result, requestLog, "1101", "获取人员信息")
2390
+				fmt.Println(errMsgLog)
2391
+
2392
+				if len(errMsgLog) > 0 {
2393
+
2394
+				} else {
2395
+
2396
+					var dat map[string]interface{}
2397
+					if err := json.Unmarshal([]byte(result), &dat); err == nil {
2398
+						fmt.Println(dat)
2399
+					} else {
2400
+						fmt.Println(err)
2401
+					}
2402
+
2403
+					userJSONBytes, _ := json.Marshal(dat)
2404
+					var res ResultTwo
2405
+					if err := json.Unmarshal(userJSONBytes, &res); err != nil {
2406
+						utils.ErrorLog("解析失败:%v", err)
2407
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2408
+						return
2409
+					}
2410
+					res.ErrMsg = errMsgLog
2411
+					if res.Infcode == 0 {
2412
+						patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
2413
+						if err == gorm.ErrRecordNotFound {
2414
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
2415
+							return
2416
+						} else if err != nil {
2417
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2418
+							return
2419
+
2420
+						} else {
2421
+							fmt.Println(res)
2422
+							Iinfos, _ := json.Marshal(res.Output.Iinfo)
2423
+							Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
2424
+							infoStr := string(Iinfos)
2425
+							idetinfoStr := string(Idetinfos)
2426
+							psn := &models.HisPsn{
2427
+								PsnNo:        res.Output.Baseinfo.PsnNo,
2428
+								Age:          res.Output.Baseinfo.Age,
2429
+								PatientId:    patient.ID,
2430
+								Certno:       res.Output.Baseinfo.Certno,
2431
+								Brdy:         res.Output.Baseinfo.Brdy,
2432
+								Gend:         res.Output.Baseinfo.Gend,
2433
+								Naty:         res.Output.Baseinfo.Naty,
2434
+								PsnCertType:  res.Output.Baseinfo.PsnCertType,
2435
+								PsnName:      res.Output.Baseinfo.PsnName,
2436
+								Idetinfo:     idetinfoStr,
2437
+								Insuinfo:     infoStr,
2438
+								UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
2439
+								CardInfo:     outPutInfo,
2440
+								VerifyNumber: token,
2441
+							}
2442
+							service.CreateHisPsn(psn)
2443
+
2444
+							var rf []*ResultFive
2445
+							json.Unmarshal([]byte(infoStr), &rf)
2446
+
2447
+							var insutypes []*ResultFive
2448
+							var insutype string
2449
+							var is390 int = 0
2450
+							var is310 int = 0
2451
+
2452
+							for _, item := range rf {
2453
+								if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
2454
+									insutypes = append(insutypes, item)
2455
+								}
2456
+							}
2457
+
2458
+							if len(insutypes) == 1 {
2459
+								insutype = insutypes[0].Insutype
2460
+								//insuplc_admdvs = insutypes[0].InsuplcAdmdvs
2461
+							} else {
2462
+								for _, i := range insutypes {
2463
+									if i.Insutype == "390" {
2464
+										is390 = 1
2465
+									}
2466
+
2467
+									if i.Insutype == "310" {
2468
+										is310 = 1
2469
+									}
2470
+								}
2471
+							}
2472
+							if is390 == 1 {
2473
+								insutype = "390"
2474
+							}
2475
+
2476
+							if is310 == 1 {
2477
+								insutype = "310"
2478
+							}
2479
+
2480
+							if len(insutypes) == 0 {
2481
+								insutype = "310"
2482
+							}
2483
+							c.ServeSuccessJSON(map[string]interface{}{
2484
+								"patient":  patient,
2485
+								"number":   token,
2486
+								"insutype": insutype,
2487
+							})
2488
+						}
2489
+					} else {
2490
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
2491
+						return
2492
+					}
2493
+				}
2494
+			}
2357 2495
 		}
2358 2496
 		break
2359 2497
 	}
@@ -6024,11 +6162,12 @@ func (c *HisApiController) GetRegisterInfo() {
6024 6162
 				var cert_no string
6025 6163
 				if id_card_type == 1 {
6026 6164
 					cert_no = strings.Split(psn_info.CardInfo, "|")[0]
6165
+				} else if id_card_type == 4 {
6166
+					cert_no = psn_info.VerifyNumber
6027 6167
 				} else {
6028
-					cert_no = strings.Split(psn_info.CardInfo, "|")[1]
6029
-
6168
+					cert_no = psn_info.VerifyNumber
6030 6169
 				}
6031
-				fmt.Println(cert_no)
6170
+
6032 6171
 				result, requestLog, _ := service.FJyb2201(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, roles.UserName, doctor_info.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, cert_no)
6033 6172
 				saveLog(result, requestLog, "2201", "挂号")
6034 6173
 				if miConfig.Code == "H15049901371" {
@@ -8451,6 +8590,7 @@ func (c *HisApiController) GetPreUploadInfo() {
8451 8590
 		res2.Infcode = infocode
8452 8591
 
8453 8592
 	} else if miConfig.MdtrtareaAdmvs == "350500" {
8593
+
8454 8594
 		result, requestLog, _ := service.FJyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
8455 8595
 		saveLog(result, requestLog, "2203", "上传就诊信息")
8456 8596
 		var respJSON2 map[string]interface{}

+ 92 - 0
service/fj_service.go Dosyayı Görüntüle

@@ -87,6 +87,63 @@ func FJyb1101(certNo string, org_name string, doctor string, fixmedins_code stri
87 87
 	return output, inputLog, err_msg
88 88
 }
89 89
 
90
+func FJyb1101ForEleToken(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, id_card_type int64, card_sn string, certificates int64, url string, app_id string, app_secret string, sign_key string, enc_key string, token string) (string, string, string) {
91
+	//生成签名
92
+	nonce := GetRandomString(32)
93
+	timestamp := time.Now().Unix()
94
+	//生成输入报文
95
+
96
+	inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
97
+	input := make(map[string]interface{})
98
+	inputData := make(map[string]interface{})
99
+	inputMessage["infno"] = "1101" // 交易编码
100
+
101
+	if certificates == 3 {
102
+		inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
103
+		inputData["certno"] = certNo        // 证件号码
104
+		inputData["psn_cert_type"] = "99"   // 人员证件类型
105
+
106
+	} else {
107
+		if id_card_type == 1 {
108
+			inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
109
+			inputData["card_sn"] = card_sn      // 卡识别码
110
+			inputData["psn_cert_type"] = ""     // 人员证件类型
111
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
112
+
113
+		} else if id_card_type == 4 {
114
+			inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
115
+			inputData["card_sn"] = ""           // 卡识别码
116
+			inputData["mdtrt_cert_no"] = token  // 就诊凭证编号
117
+			inputData["psn_cert_type"] = ""     // 人员证件类型
118
+
119
+		} else {
120
+			inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
121
+			inputData["card_sn"] = ""           // 卡识别码
122
+			inputData["psn_cert_type"] = "01"   // 人员证件类型
123
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
124
+
125
+		}
126
+	}
127
+	inputData["certno"] = certNo // 证件号码
128
+
129
+	inputData["begntime"] = "" // 开始时间
130
+	inputData["psn_name"] = "" // 人员姓名
131
+	input["data"] = inputData
132
+	inputMessage["input"] = input //交易输入
133
+
134
+	var inputLog string
135
+	bytesData, err := json.Marshal(inputMessage)
136
+	inputLog = string(bytesData)
137
+	fmt.Println(string(bytesData))
138
+	if err != nil {
139
+		fmt.Println(err.Error())
140
+		return err.Error(), "", ""
141
+	}
142
+	enc := mahonia.NewEncoder("gbk")
143
+	output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
144
+	return output, inputLog, err_msg
145
+}
146
+
90 147
 // 门诊挂号
91 148
 func FJyb2201(psnNo string, insutype string, certNo string, org_name string, doctor string, ipt_otp_no string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, opter string, doctor_name string, url string, app_id string, app_secret string, sign_key string, enc_key string, card_number string) (string, string, string) {
92 149
 	// 生成签名
@@ -2473,3 +2530,38 @@ func DeleteExtraSpace(s string) string {
2473 2530
 	}
2474 2531
 	return string(s2)
2475 2532
 }
2533
+
2534
+func ReadEleCard(code string) (string, string, string) {
2535
+	DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
2536
+	readCard := DllDef.MustFindProc("ec_decode")
2537
+
2538
+	pCardInfo := make([]byte, 8192)
2539
+	pBusiCardInfo := make([]byte, 8192)
2540
+	pErrMsg := make([]byte, 8192)
2541
+
2542
+	data := make(map[string]interface{})
2543
+
2544
+	inputData := make(map[string]interface{})
2545
+	inputData["orgId"] = code
2546
+	inputData["businessType"] = "01101"
2547
+	inputData["operatorId"] = "1"
2548
+	inputData["operatorName"] = "admin"
2549
+	inputData["officeId"] = "001"
2550
+	inputData["officeName"] = "血透科"
2551
+	data["data"] = inputData
2552
+	data["transType"] = "ec.query"
2553
+	data["orgId"] = code
2554
+	bytesData, _ := json.Marshal(data)
2555
+	pCardInfo = bytesData
2556
+	pCardInfo = []byte(ConvertByte2String(pCardInfo, GB18030))
2557
+
2558
+	ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])), (uintptr)(unsafe.Pointer(&pErrMsg[0])))
2559
+	fmt.Println(ret2)
2560
+	fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
2561
+	fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
2562
+	if ret2 != 0 {
2563
+		return "", "", ""
2564
+	}
2565
+	return ConvertByte2String([]byte(DeleteExtraSpace(string(bytesData))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pBusiCardInfo))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pErrMsg))), GB18030)
2566
+
2567
+}