Browse Source

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

csx 3 years ago
parent
commit
e25181e1a2
2 changed files with 48 additions and 9 deletions
  1. 45 6
      controllers/sg/his_api_controller.go
  2. 3 3
      service/gdyb_service.go

+ 45 - 6
controllers/sg/his_api_controller.go View File

@@ -220,15 +220,51 @@ func (c *HisApiController) ReadCard() {
220 220
 
221 221
 	roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
222 222
 	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
223
-	if initFlag == 0 {
224
-		c.TestGetBasBaseInit()
225
-	}
223
+
226 224
 	switch id_card_type {
227 225
 	case 1:
228 226
 		if miConfig.MdtrtareaAdmvs == "421300" {
229
-			result := service.Gdyb1101C("", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", certificates)
230
-			fmt.Println(result)
227
+			result, request_log := service.Gdyb1101C("", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", certificates)
228
+			fmt.Println(request_log)
229
+			var dat map[string]interface{}
230
+			if err := json.Unmarshal([]byte(result), &dat); err == nil {
231
+				fmt.Println(dat)
232
+			} else {
233
+				fmt.Println(err)
234
+			}
235
+
236
+			userJSONBytes, _ := json.Marshal(dat)
237
+			var res ResultTwo
238
+			if err := json.Unmarshal(userJSONBytes, &res); err != nil {
239
+				utils.ErrorLog("解析失败:%v", err)
240
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
241
+				return
242
+			}
243
+
244
+			if res.Infcode == 0 {
245
+				patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
246
+				if err == gorm.ErrRecordNotFound {
247
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
248
+					return
249
+				} else if err != nil {
250
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
251
+					return
252
+
253
+				} else {
254
+					c.ServeSuccessJSON(map[string]interface{}{
255
+						"patient": patient,
256
+						"number":  res.Output.Baseinfo.Certno,
257
+					})
258
+				}
259
+			} else {
260
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
261
+				return
262
+			}
263
+
231 264
 		} else {
265
+			if initFlag == 0 {
266
+				c.TestGetBasBaseInit()
267
+			}
232 268
 			basStr := c.GetBasBaseInfo()
233 269
 			if len(basStr) == 0 {
234 270
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
@@ -1759,7 +1795,10 @@ func (c *HisApiController) GetRegisterInfo() {
1759 1795
 
1760 1796
 	if config.IsOpen == 1 {
1761 1797
 		//service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
1762
-		result, requestLog := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10))
1798
+
1799
+		result, requestLog := service.Gdyb1101C(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", certificates)
1800
+
1801
+		//result, requestLog := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10))
1763 1802
 		saveLog(result, requestLog, "1101")
1764 1803
 		//register_log = requestLog + "\r\n" + "\r\n" + "\r\n" + result
1765 1804
 		var res ResultTwo

+ 3 - 3
service/gdyb_service.go View File

@@ -3059,7 +3059,7 @@ func Gdyb1101B(certNo string, org_name string, doctor string, fixmedins_code str
3059 3059
 }
3060 3060
 
3061 3061
 //人员信息版本4
3062
-func Gdyb1101C(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) string {
3062
+func Gdyb1101C(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) (string, string) {
3063 3063
 	//生成签名
3064 3064
 	nonce := GetRandomString(32)
3065 3065
 	timestamp := time.Now().Unix()
@@ -3099,7 +3099,7 @@ func Gdyb1101C(certNo string, org_name string, doctor string, fixmedins_code str
3099 3099
 	fmt.Println(string(bytesData))
3100 3100
 	if err != nil {
3101 3101
 		fmt.Println(err.Error())
3102
-		return err.Error()
3102
+		return err.Error(), ""
3103 3103
 	}
3104 3104
 	var json2 string
3105 3105
 	cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
@@ -3108,7 +3108,7 @@ func Gdyb1101C(certNo string, org_name string, doctor string, fixmedins_code str
3108 3108
 		fmt.Println("error:", err.Error())
3109 3109
 	}
3110 3110
 	fmt.Println(string(out))
3111
-	return string(out)
3111
+	return string(out), string(bytesData)
3112 3112
 }
3113 3113
 
3114 3114
 func StrPtr(s string) uintptr {