Browse Source

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

csx 4 years ago
parent
commit
94267fd3b4
1 changed files with 62 additions and 0 deletions
  1. 62 0
      controllers/sg/his_api_controller.go

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

@@ -56,7 +56,10 @@ func HisManagerApiRegistRouters() {
56 56
 	beego.Router("/api/310", &HisApiController{}, "get:Check310")
57 57
 	beego.Router("/api/390", &HisApiController{}, "get:Check390")
58 58
 
59
+	beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
60
+
59 61
 	//备案撤销相关接口
62
+
60 63
 	beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
61 64
 	beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
62 65
 	beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
@@ -3806,6 +3809,65 @@ func (c *HisApiController) UnCheckCode() {
3806 3809
 	}
3807 3810
 
3808 3811
 }
3812
+func (c *HisApiController) GetPatientInfo() {
3813
+	id_card_no := c.GetString("id_card_no")
3814
+	admin_user_id, _ := c.GetInt64("admin_user_id")
3815
+
3816
+	patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
3817
+
3818
+	if patient.ID == 0 {
3819
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
3820
+		return
3821
+	}
3822
+
3823
+	role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
3824
+	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
3825
+	config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
3826
+	if config.IsOpen == 1 {
3827
+		api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + id_card_no + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
3828
+		resp, requestErr := http.Get(api)
3829
+		if requestErr != nil {
3830
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3831
+			return
3832
+		}
3833
+		defer resp.Body.Close()
3834
+		body, ioErr := ioutil.ReadAll(resp.Body)
3835
+		if ioErr != nil {
3836
+			utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
3837
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3838
+			return
3839
+		}
3840
+		var respJSON map[string]interface{}
3841
+
3842
+		if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
3843
+			utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
3844
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3845
+			return
3846
+		}
3847
+
3848
+		userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
3849
+		userJSONBytes, _ := json.Marshal(userJSON)
3850
+		var res ResultTwo
3851
+		if err := json.Unmarshal(userJSONBytes, &res); err != nil {
3852
+			utils.ErrorLog("解析失败:%v", err)
3853
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3854
+			return
3855
+		}
3856
+
3857
+		if res.Infcode == -1 {
3858
+			c.ServeSuccessJSON(map[string]interface{}{
3859
+				"failed_code": -10,
3860
+				"msg":         res.ErrMsg,
3861
+			})
3862
+		} else {
3863
+			c.ServeSuccessJSON(map[string]interface{}{
3864
+				"failed_code": 0,
3865
+				"info":        res,
3866
+			})
3867
+		}
3868
+
3869
+	}
3870
+}
3809 3871
 func (c *HisApiController) PsnPutOnRecord() {
3810 3872
 	record_type, _ := c.GetInt64("type")
3811 3873
 	patient_id, _ := c.GetInt64("patient_id")