Browse Source

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

csx 3 years ago
parent
commit
829e7563ff

+ 1 - 1
conf/app.conf View File

@@ -44,7 +44,7 @@ appsecret="61ee2e6268497d5aa9de0b0187c39aea"
44 44
 
45 45
 
46 46
 [prod]
47
-org_id = 10106
47
+org_id = 10138
48 48
 mobile_token_expiration_second = 86400
49 49
 httpdomain = https://api.xt.kuyicloud.com
50 50
 sso_domain = https://sso.kuyicloud.com

+ 115 - 0
controllers/sg/his_api_controller.go View File

@@ -75,10 +75,106 @@ func HisManagerApiRegistRouters() {
75 75
 
76 76
 	beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
77 77
 
78
+	beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
79
+
78 80
 	//beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
79 81
 	//beego.Router("/api/testinit", &HisApiController{}, "get:TestGetBasBaseInit")
80 82
 	//beego.Router("/api/test", &HisApiController{}, "get:TestGetBasBaseInfo")
81 83
 
84
+}
85
+func (c *HisApiController) CheckCardPWD() {
86
+	card_pwd := c.GetString("card_pwd")
87
+	his_patient_id, _ := c.GetInt64("his_patient_id")
88
+	admin_user_id, _ := c.GetInt64("admin_user_id")
89
+	roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
90
+	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
91
+	his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
92
+	result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
93
+
94
+	var dat map[string]interface{}
95
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
96
+		fmt.Println(dat)
97
+	} else {
98
+		fmt.Println(err)
99
+	}
100
+
101
+	userJSONBytes, _ := json.Marshal(dat)
102
+	var res Result90991
103
+	if err := json.Unmarshal(userJSONBytes, &res); err != nil {
104
+		utils.ErrorLog("解析失败:%v", err)
105
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
106
+		return
107
+	}
108
+
109
+	if res.Infcode != 0 {
110
+		c.ServeSuccessJSON(map[string]interface{}{
111
+			"failed_code": -10,
112
+			"msg":         res.ErrMsg,
113
+		})
114
+		return
115
+	} else {
116
+		if res.Output.Baseinfo.CheckStat == "0" {
117
+			var msg string
118
+			switch res.Output.Baseinfo.CardStat {
119
+			case "00":
120
+				msg = "未激活"
121
+				break
122
+			case "10":
123
+				msg = "激活"
124
+
125
+				break
126
+			case "20":
127
+				msg = "窗口挂失"
128
+
129
+				break
130
+			case "21":
131
+				msg = "电话挂失"
132
+				break
133
+			case "22":
134
+				msg = "单位网上申报挂失"
135
+
136
+				break
137
+			case "23":
138
+				msg = "保健办挂失"
139
+
140
+				break
141
+			case "24":
142
+				msg = "个人网上挂失"
143
+
144
+				break
145
+			case "25":
146
+				msg = "网上服务大厅挂失"
147
+
148
+				break
149
+			case "30":
150
+				msg = "注销"
151
+
152
+				break
153
+			case "40":
154
+				msg = "回收"
155
+
156
+				break
157
+			case "99":
158
+				msg = "制卡中(无效卡)"
159
+
160
+				break
161
+
162
+			}
163
+
164
+			c.ServeSuccessJSON(map[string]interface{}{
165
+				"failed_code": -10,
166
+				"msg":         msg,
167
+			})
168
+			return
169
+
170
+		} else {
171
+			c.ServeSuccessJSON(map[string]interface{}{
172
+				"msg": "校验成功",
173
+			})
174
+			return
175
+		}
176
+	}
177
+
82 178
 }
83 179
 
84 180
 func (c *HisApiController) ReadCard() {
@@ -1492,6 +1588,25 @@ type ResultSeventeen struct {
1492 1588
 	WarnInfo    string `json:"warn_info"`
1493 1589
 }
1494 1590
 
1591
+type Result90991 struct {
1592
+	ErrMsg      string `json:"err_msg"`
1593
+	InfRefmsgid string `json:"inf_refmsgid"`
1594
+	Infcode     int64  `json:"infcode"`
1595
+	Output      struct {
1596
+		Baseinfo struct {
1597
+			PsnNo     string `json:"psn_no"`
1598
+			CardStat  string `json:"card_stat"`
1599
+			Certno    string `json:"certno"`
1600
+			PsnName   string `json:"psn_name"`
1601
+			CheckStat string `json:"check_stat"`
1602
+		} `json:"baseinfo"`
1603
+	} `json:"output"`
1604
+	RefmsgTime  string      `json:"refmsg_time"`
1605
+	RespondTime string      `json:"respond_time"`
1606
+	Signtype    interface{} `json:"signtype"`
1607
+	WarnInfo    interface{} `json:"warn_info"`
1608
+}
1609
+
1495 1610
 type Custom struct {
1496 1611
 	DetItemFeeSumamt string
1497 1612
 	Cut              string

+ 22 - 16
controllers/sz/sz_his_api_controller.go View File

@@ -2153,7 +2153,7 @@ func (c *SZHisApiController) GetSettleInfo() {
2153 2153
 	his_patient_id, _ := c.GetInt64("his_patient_id")
2154 2154
 
2155 2155
 	id_str := c.GetString("ids")
2156
-	ids_arr := strings.Split(id_str,  ",")
2156
+	ids_arr := strings.Split(id_str, ",")
2157 2157
 
2158 2158
 	order_id, _ := c.GetInt64("order_id")
2159 2159
 
@@ -2196,12 +2196,12 @@ func (c *SZHisApiController) GetSettleInfo() {
2196 2196
 		var end_time int64
2197 2197
 
2198 2198
 		if settle_accounts_type == 1 { //日结
2199
-			if reg_type == 11{
2199
+			if reg_type == 11 {
2200 2200
 
2201
-				prescriptions,_ = service.GetPrescriptionByIds(ids_arr,adminUser.CurrentOrgId)
2202
-		   }else{
2203
-			prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
2204
-		   }
2201
+				prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
2202
+			} else {
2203
+				prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
2204
+			}
2205 2205
 
2206 2206
 		} else { //月结
2207 2207
 			start_time_str := c.GetString("start_time")
@@ -2555,13 +2555,16 @@ func (c *SZHisApiController) GetSettleInfo() {
2555 2555
 
2556 2556
 			total, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", total), 64)
2557 2557
 
2558
-			yiliao_number, id_card_number, verifyCode, version_code, health_card_no, _, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code + "|")
2558
+			new_number := miConfig.Code + year + month + day +
2559
+				fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
2560
+
2561
+			yiliao_number, id_card_number, verifyCode, version_code, health_card_no, _, ret4 := ReadBasCardGetNumber("FY005" + "|" + new_number + "|" + miConfig.Code + "|")
2559 2562
 
2560 2563
 			if ret4 == 0 {
2561 2564
 				//根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
2562 2565
 				tempPatient, _ := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
2563 2566
 				if tempPatient.ID == patient_id {
2564
-					result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor_code, drug_doctor_name, reg_type, sick.CountryCode)
2567
+					result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor_code, drug_doctor_name, reg_type, sick.CountryCode, new_number)
2565 2568
 					var dat map[string]interface{}
2566 2569
 					if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
2567 2570
 						fmt.Println(dat)
@@ -2728,7 +2731,7 @@ func (c *SZHisApiController) GetSettleInfo() {
2728 2731
 				//根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
2729 2732
 				tempPatient, _ := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
2730 2733
 				if tempPatient.ID == patient_id {
2731
-					result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, order.MedfeeSumamt, yiliao_number, verifyCode, order.OrgSetlNumber, mz_number, version_code, drug_doctor_code, drug_doctor_name, reg_type, sick.CountryCode)
2734
+					result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, order.MedfeeSumamt, yiliao_number, verifyCode, order.OrgSetlNumber, mz_number, version_code, drug_doctor_code, drug_doctor_name, reg_type, sick.CountryCode, number)
2732 2735
 					var dat map[string]interface{}
2733 2736
 					if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
2734 2737
 						fmt.Println(dat)
@@ -2994,7 +2997,7 @@ func (c *SZHisApiController) GetPreSettleInfo() {
2994 2997
 	sick_type, _ := c.GetInt64("sick_type")
2995 2998
 
2996 2999
 	id_str := c.GetString("ids")
2997
-	ids_arr := strings.Split(id_str,  ",")
3000
+	ids_arr := strings.Split(id_str, ",")
2998 3001
 
2999 3002
 	timestamp := time.Now().Unix()
3000 3003
 	tempTime := time.Unix(timestamp, 0)
@@ -3024,12 +3027,12 @@ func (c *SZHisApiController) GetPreSettleInfo() {
3024 3027
 	var end_time int64
3025 3028
 
3026 3029
 	if settle_accounts_type == 1 { //日结
3027
-		if reg_type == 11{
3030
+		if reg_type == 11 {
3028 3031
 
3029
-			prescriptions,_ = service.GetPrescriptionByIds(ids_arr,adminUser.CurrentOrgId)
3030
-		   }else{
3032
+			prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
3033
+		} else {
3031 3034
 			prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
3032
-		   }
3035
+		}
3033 3036
 
3034 3037
 	} else { //月结
3035 3038
 		start_time_str := c.GetString("start_time")
@@ -3384,13 +3387,16 @@ func (c *SZHisApiController) GetPreSettleInfo() {
3384 3387
 
3385 3388
 		total, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", total), 64)
3386 3389
 
3387
-		yiliao_number, id_card_number, verifyCode, version_code, health_card_no, _, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code + "|")
3390
+		new_number := miConfig.Code + year + month + day +
3391
+			fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
3392
+
3393
+		yiliao_number, id_card_number, verifyCode, version_code, health_card_no, _, ret4 := ReadBasCardGetNumber("FY004" + "|" + new_number + "|" + miConfig.Code + "|")
3388 3394
 
3389 3395
 		if ret4 == 0 {
3390 3396
 			//根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
3391 3397
 			tempPatient, _ := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
3392 3398
 			if tempPatient.ID == patient_id {
3393
-				result_three := service.SzybFY004(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor_code, drug_doctor_name, reg_type, sick.CountryCode)
3399
+				result_three := service.SzybFY004(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor_code, drug_doctor_name, reg_type, sick.CountryCode, new_number)
3394 3400
 				var dat map[string]interface{}
3395 3401
 				if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
3396 3402
 					fmt.Println(dat)

+ 56 - 0
service/gdyb_service.go View File

@@ -2863,3 +2863,59 @@ func Gdyb1101B(certNo string, org_name string, doctor string, fixmedins_code str
2863 2863
 func StrPtr(s string) uintptr {
2864 2864
 	return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
2865 2865
 }
2866
+
2867
+func Gdyb90991(psn_no string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, pwd string) string {
2868
+	//生成签名
2869
+	nonce := GetRandomString(32)
2870
+	timestamp := time.Now().Unix()
2871
+	signature := setSignature(timestamp, nonce, secret_key)
2872
+	//生成输入报文
2873
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
2874
+	input := make(map[string]interface{})
2875
+	inputData := make(map[string]interface{})
2876
+	inputMessage["infno"] = "90991" // 交易编码
2877
+
2878
+	inputData["fixmedins_code"] = fixmedins_code // 就诊凭证编号
2879
+	inputData["psn_no"] = psn_no                 // 开始时间
2880
+	inputData["card_pwd"] = pwd                  // 人员姓名
2881
+	input["data"] = inputData
2882
+	inputMessage["input"] = input //交易输入
2883
+
2884
+	bytesData, err := json.Marshal(inputMessage)
2885
+	fmt.Println(string(bytesData))
2886
+	if err != nil {
2887
+		fmt.Println(err.Error())
2888
+		return err.Error()
2889
+	}
2890
+	reader := bytes.NewReader(bytesData)
2891
+	gdyb_url := beego.AppConfig.String("gdyb_url")
2892
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
2893
+
2894
+	url := gdyb_url + "90991"
2895
+	request, err := http.NewRequest("POST", url, reader)
2896
+	if err != nil {
2897
+		fmt.Println(err.Error())
2898
+		return err.Error()
2899
+	}
2900
+
2901
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
2902
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
2903
+	request.Header.Set("x-tif-signature", signature)
2904
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
2905
+	request.Header.Set("x-tif-nonce", nonce)
2906
+
2907
+	client := http.Client{}
2908
+	resp, err := client.Do(request)
2909
+	if err != nil {
2910
+		fmt.Println(err.Error())
2911
+		return err.Error()
2912
+	}
2913
+	respBytes, err := ioutil.ReadAll(resp.Body)
2914
+	if err != nil {
2915
+		fmt.Println(err.Error())
2916
+		return err.Error()
2917
+	}
2918
+	fmt.Println(string(respBytes))
2919
+	str := string(respBytes)
2920
+	return str
2921
+}

+ 19 - 14
service/his_service.go View File

@@ -1099,22 +1099,22 @@ func GetDoctorList(orgid int64) (role []*models.SgjUserAdminRole, err error) {
1099 1099
 
1100 1100
 func GetPrescriptionByIds(ids []string, org_id int64) (prescription []*models.HisPrescription, err error) {
1101 1101
 	err = readDb.Model(&models.HisPrescription{}).
1102
-	 Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
1103
-	  return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
1104
-	 }).
1105
-	 Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1106
-	  return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
1107
-	 }).
1108
-	 Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1109
-	  return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
1110
-	 }).Preload("TempHisOrder", func(db *gorm.DB) *gorm.DB {
1111
-	 return db.Where("status = 1 AND user_org_id = ?", org_id)
1102
+		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
1103
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
1104
+		}).
1105
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1106
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
1107
+		}).
1108
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1109
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
1110
+		}).Preload("TempHisOrder", func(db *gorm.DB) *gorm.DB {
1111
+		return db.Where("status = 1 AND user_org_id = ?", org_id)
1112 1112
 	}).
1113
-	 Where("id in (?) AND user_org_id = ? AND status = 1", ids,org_id).
1114
-	 Find(&prescription).Error
1115
-	
1113
+		Where("id in (?) AND user_org_id = ? AND status = 1", ids, org_id).
1114
+		Find(&prescription).Error
1115
+
1116 1116
 	return
1117
-   }
1117
+}
1118 1118
 
1119 1119
 func GetDoctorListTwo(orgid int64) (role []*models.SgjUserAdminRole, err error) {
1120 1120
 
@@ -1308,3 +1308,8 @@ func GetMonthHisPrescriptionTwo(org_id int64, patient_id int64, start_time int64
1308 1308
 		Find(&prescription).Error
1309 1309
 	return
1310 1310
 }
1311
+
1312
+func GetNewHisPatientInfoFour(org_id int64, id int64) (info models.HisPatient, err error) {
1313
+	err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND id = ?", org_id, id).First(&info).Error
1314
+	return
1315
+}

+ 4 - 4
service/sz_his_service.go View File

@@ -309,8 +309,8 @@ func SzybFY002(doctor string, doctor_code string, fixmedins_code string, datas [
309 309
 	str := string(respBytes)
310 310
 	return str
311 311
 }
312
-func SzybFY004(doctor string, doctor_code string, fixmedins_code string, total float64, account string, verify_code string, serial_number string, mz_number string, version_code string, drug_doctor string, drug_doctor_name string, medical_care int64, code string) string {
313
-	inputMessage := SetSZInputMessage(doctor, doctor_code, fixmedins_code, verify_code, serial_number)
312
+func SzybFY004(doctor string, doctor_code string, fixmedins_code string, total float64, account string, verify_code string, serial_number string, mz_number string, version_code string, drug_doctor string, drug_doctor_name string, medical_care int64, code string, new_number string) string {
313
+	inputMessage := SetSZInputMessage(doctor, doctor_code, fixmedins_code, verify_code, new_number)
314 314
 	inputData := make(map[string]interface{})
315 315
 	inputMessage["transType"] = "FY004" // 交易编码
316 316
 
@@ -370,9 +370,9 @@ func SzybFY004(doctor string, doctor_code string, fixmedins_code string, total f
370 370
 	str := string(respBytes)
371 371
 	return str
372 372
 }
373
-func SzybFY005(doctor string, doctor_code string, fixmedins_code string, total float64, account string, verify_code string, serial_number string, mz_number string, version_code string, drug_doctor string, drug_doctor_name string, medical_care int64, code string) string {
373
+func SzybFY005(doctor string, doctor_code string, fixmedins_code string, total float64, account string, verify_code string, serial_number string, mz_number string, version_code string, drug_doctor string, drug_doctor_name string, medical_care int64, code string, new_number string) string {
374 374
 	// 生成输入报文
375
-	inputMessage := SetSZInputMessage(doctor, doctor_code, fixmedins_code, verify_code, serial_number)
375
+	inputMessage := SetSZInputMessage(doctor, doctor_code, fixmedins_code, verify_code, new_number)
376 376
 	inputData := make(map[string]interface{})
377 377
 	inputMessage["transType"] = "FY005" // 交易编码
378 378