test_user 2 years ago
parent
commit
fec26e830f
4 changed files with 463 additions and 453 deletions
  1. 1 1
      conf/app.conf
  2. 362 340
      controllers/sg/his_api_controller.go
  3. 99 111
      main.go
  4. 1 1
      service/his_service.go

+ 1 - 1
conf/app.conf View File

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

+ 362 - 340
controllers/sg/his_api_controller.go View File

@@ -147,8 +147,8 @@ func (c *HisApiController) Get9001() {
147 147
 	}
148 148
 
149 149
 }
150
-func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
151
-
150
+func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res2 Result3101) {
151
+	var res Result3101
152 152
 	adminUser := c.GetAdminUserInfo()
153 153
 	roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
154 154
 	//his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
@@ -201,7 +201,7 @@ func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPati
201 201
 	pd.PatnName = his.Name
202 202
 	pd.Gend = his.Gend
203 203
 	pd.Brdy = his.Brdy
204
-	pd.Poolarea = his.InsuplcAdmdvs
204
+	pd.Poolarea = miConfig.MdtrtareaAdmvs
205 205
 	pd.CurrMdtrtID = his.Number
206 206
 
207 207
 	var fed models.FsiEncounterDtos
@@ -417,8 +417,10 @@ func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPati
417 417
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
418 418
 		return res
419 419
 	}
420
-	respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
420
+	respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
421
+	fmt.Println(respJSON)
421 422
 	result, _ := json.Marshal(respJSON)
423
+	fmt.Println(result)
422 424
 	if err := json.Unmarshal([]byte(result), &res); err != nil {
423 425
 		utils.ErrorLog("解析失败:%v", err)
424 426
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -699,7 +701,7 @@ func Check3101(c *HisApiController, patient_id int64, his_patient_id int64, admi
699 701
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
700 702
 		return res
701 703
 	}
702
-	respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
704
+	respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
703 705
 	result, _ := json.Marshal(respJSON)
704 706
 	if err := json.Unmarshal([]byte(result), &res); err != nil {
705 707
 		utils.ErrorLog("解析失败:%v", err)
@@ -1073,7 +1075,7 @@ func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admi
1073 1075
 		return res
1074 1076
 	}
1075 1077
 
1076
-	respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
1078
+	respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
1077 1079
 	result, _ := json.Marshal(respJSON)
1078 1080
 	if err := json.Unmarshal([]byte(result), &res); err != nil {
1079 1081
 		utils.ErrorLog("解析失败:%v", err)
@@ -5720,6 +5722,7 @@ func (c *HisApiController) GetRegisterInfo() {
5720 5722
 			timeFormat := tempTime.Format("20060102150405")
5721 5723
 			chrgBchno := rand.Intn(100000) + 10000
5722 5724
 			ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
5725
+			his.Number = ipt_otp_no
5723 5726
 			//count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
5724 5727
 			department, _ := service.GetDepartMentDetail(department)
5725 5728
 			//doctor_id := strconv.FormatInt(patientPrescription., 10)
@@ -5781,11 +5784,6 @@ func (c *HisApiController) GetRegisterInfo() {
5781 5784
 				insutype = med_type
5782 5785
 			}
5783 5786
 
5784
-			//for _, item := range rf {
5785
-			//	if item.Insutype == insutype {
5786
-			//		insuplc_admdvs = item.InsuplcAdmdvs
5787
-			//	}
5788
-			//}
5789 5787
 			var infocode int64
5790 5788
 			var resThree ResultThree
5791 5789
 			var resThree10265 ResultThree10265
@@ -5851,83 +5849,102 @@ func (c *HisApiController) GetRegisterInfo() {
5851 5849
 				}
5852 5850
 
5853 5851
 				var hisPrescription []*models.HisPrescription
5852
+
5853
+				for _, item := range rf {
5854
+					if item.Insutype == insutype {
5855
+						//insuplc_admdvs = item.InsuplcAdmdvs
5856
+						his.InsuplcAdmdvs = insuplc_admdvs
5857
+					}
5858
+				}
5859
+				his.Insutype = insutype
5860
+
5854 5861
 				res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
5862
+				fmt.Println(res3101)
5863
+				fmt.Println(res3101.Infcode)
5855 5864
 
5856
-				if res3101.Infcode == "0" && len(res3101.Output.Result) > 0 {
5857
-					for _, item := range res3101.Output.Result {
5858
-						if len(res3101.ErrMsg) == 0 {
5859
-							res3101.ErrMsg = item.VolaCont
5860
-						} else {
5861
-							res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
5865
+				if res3101.Infcode == "0" {
5866
+					fmt.Println("33333333")
5867
+					if len(res3101.Output.Result) > 0 {
5868
+						fmt.Println("222222")
5869
+
5870
+						for _, item := range res3101.Output.Result {
5871
+							if len(res3101.ErrMsg) == 0 {
5872
+								res3101.ErrMsg = item.VolaCont
5873
+							} else {
5874
+								res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
5875
+							}
5862 5876
 						}
5863
-					}
5864
-					c.ServeSuccessJSON(map[string]interface{}{
5865
-						"failed_code": -10,
5866
-						"msg":         res3101.ErrMsg,
5867
-					})
5868
-					return
5877
+						c.ServeSuccessJSON(map[string]interface{}{
5878
+							"failed_code": -10,
5879
+							"msg":         res3101.ErrMsg,
5880
+						})
5881
+						return
5882
+					} else {
5883
+						fmt.Println("11111")
5884
+						var api string
5885
+						if miConfig.MdtrtareaAdmvs == "320921" {
5869 5886
 
5870
-				} else if res3101.Infcode != "0" {
5871
-					c.ServeSuccessJSON(map[string]interface{}{
5872
-						"failed_code": -10,
5873
-						"msg":         res3101.ErrMsg,
5874
-					})
5875
-					return
5876
-				}
5887
+							api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
5888
+								"&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
5889
+								"&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
5877 5890
 
5878
-				var api string
5879
-				if miConfig.MdtrtareaAdmvs == "320921" {
5891
+						} else {
5892
+							api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
5893
+								"&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
5894
+								"&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
5880 5895
 
5881
-					api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
5882
-						"&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
5883
-						"&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
5896
+						}
5884 5897
 
5885
-				} else {
5886
-					api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
5887
-						"&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
5888
-						"&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
5898
+						resp, requestErr := http.Get(api)
5899
+						if requestErr != nil {
5900
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
5901
+							return
5902
+						}
5889 5903
 
5890
-				}
5904
+						body, ioErr := ioutil.ReadAll(resp.Body)
5891 5905
 
5892
-				resp, requestErr := http.Get(api)
5893
-				if requestErr != nil {
5894
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
5895
-					return
5896
-				}
5906
+						if ioErr != nil {
5907
+							utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
5908
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
5909
+							return
5910
+						}
5897 5911
 
5898
-				body, ioErr := ioutil.ReadAll(resp.Body)
5912
+						var respJSON map[string]interface{}
5899 5913
 
5900
-				if ioErr != nil {
5901
-					utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
5902
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
5903
-					return
5904
-				}
5914
+						if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
5915
+							utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
5916
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
5917
+							return
5918
+						}
5905 5919
 
5906
-				var respJSON map[string]interface{}
5920
+						respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
5907 5921
 
5908
-				if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
5909
-					utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
5910
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
5911
-					return
5912
-				}
5922
+						result, _ := json.Marshal(respJSON)
5913 5923
 
5914
-				respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
5924
+						if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
5925
+							utils.ErrorLog("解析失败:%v", err)
5926
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
5927
+							return
5928
+						}
5915 5929
 
5916
-				result, _ := json.Marshal(respJSON)
5930
+						resThree.ErrMsg = resThree10265.ErrMsg
5917 5931
 
5918
-				if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
5919
-					utils.ErrorLog("解析失败:%v", err)
5920
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
5921
-					return
5922
-				}
5932
+						resThree.Output = resThree10265.Output
5923 5933
 
5924
-				resThree.ErrMsg = resThree10265.ErrMsg
5934
+						resThree.InfRefmsgid = resThree10265.InfRefmsgid
5925 5935
 
5926
-				resThree.Output = resThree10265.Output
5936
+						infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
5927 5937
 
5928
-				resThree.InfRefmsgid = resThree10265.InfRefmsgid
5938
+					}
5939
+
5940
+				} else if res3101.Infcode != "0" {
5941
+					c.ServeSuccessJSON(map[string]interface{}{
5942
+						"failed_code": -10,
5943
+						"msg":         res3101.ErrMsg,
5944
+					})
5945
+					return
5946
+				}
5929 5947
 
5930
-				infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
5931 5948
 			} else if miConfig.MdtrtareaAdmvs == "350500" {
5932 5949
 
5933 5950
 				psn_info, _ := service.GetPsnByPatientId(id)
@@ -6931,7 +6948,7 @@ func (c *HisApiController) GetUploadInfo() {
6931 6948
 							}
6932 6949
 
6933 6950
 						} else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
6934
-							result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
6951
+							result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
6935 6952
 							if result3101.Infcode == "0" {
6936 6953
 								if len(result3101.Output.Result) > 0 {
6937 6954
 									var errMsgs []string
@@ -6944,76 +6961,76 @@ func (c *HisApiController) GetUploadInfo() {
6944 6961
 										"msg":         errMsgs,
6945 6962
 									})
6946 6963
 									return
6947
-								}
6948
-							}
6964
+								} else {
6965
+									psn_info, _ := service.GetPsnByPatientId(his.PatientId)
6966
+									psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
6967
+									bas := strings.Split(psn_info.CardInfo, "|")
6968
+									if his.IdCardType == 1 {
6969
+										cert_no = bas[2]
6970
+									} else if his.IdCardType == 3 {
6971
+										cert_no = his.Certno
6972
+										psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
6973
+									} else if his.IdCardType == 4 {
6974
+										cert_no = his.Certno
6975
+										psn_info.VerifyNumber = token
6976
+									}
6977
+									var api string
6978
+									if miConfig.MdtrtareaAdmvs == "320921" {
6979
+										api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
6980
+											his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
6981
+											"&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
6982
+											"&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
6983
+											"&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
6984
+											"&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
6985
+											"&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
6986
+									} else {
6987
+										api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
6988
+											his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
6989
+											"&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
6990
+											"&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
6991
+											"&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
6992
+											"&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
6993
+											"&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
6949 6994
 
6950
-							psn_info, _ := service.GetPsnByPatientId(his.PatientId)
6951
-							psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
6952
-							bas := strings.Split(psn_info.CardInfo, "|")
6953
-							if his.IdCardType == 1 {
6954
-								cert_no = bas[2]
6955
-							} else if his.IdCardType == 3 {
6956
-								cert_no = his.Certno
6957
-								psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
6958
-							} else if his.IdCardType == 4 {
6959
-								cert_no = his.Certno
6960
-								psn_info.VerifyNumber = token
6961
-							}
6962
-							var api string
6963
-							if miConfig.MdtrtareaAdmvs == "320921" {
6964
-								api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
6965
-									his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
6966
-									"&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
6967
-									"&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
6968
-									"&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
6969
-									"&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
6970
-									"&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
6971
-							} else {
6972
-								api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
6973
-									his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
6974
-									"&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
6975
-									"&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
6976
-									"&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
6977
-									"&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
6978
-									"&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
6995
+									}
6979 6996
 
6980
-							}
6997
+									resp, requestErr := http.Get(api)
6998
+									if requestErr != nil {
6999
+										c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7000
+										return
7001
+									}
7002
+									body, ioErr := ioutil.ReadAll(resp.Body)
7003
+									if ioErr != nil {
7004
+										utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
7005
+										c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7006
+										return
7007
+									}
7008
+									var respJSON map[string]interface{}
7009
+									if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
7010
+										utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
7011
+										c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7012
+										return
7013
+									}
6981 7014
 
6982
-							resp, requestErr := http.Get(api)
6983
-							if requestErr != nil {
6984
-								c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
6985
-								return
6986
-							}
6987
-							body, ioErr := ioutil.ReadAll(resp.Body)
6988
-							if ioErr != nil {
6989
-								utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
6990
-								c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
6991
-								return
6992
-							}
6993
-							var respJSON map[string]interface{}
6994
-							if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
6995
-								utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
6996
-								c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
6997
-								return
6998
-							}
7015
+									respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
7016
+									result, _ := json.Marshal(respJSON)
6999 7017
 
7000
-							respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
7001
-							result, _ := json.Marshal(respJSON)
7018
+									if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
7019
+										utils.ErrorLog("解析失败:%v", err)
7020
+										c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7021
+										return
7022
+									}
7002 7023
 
7003
-							if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
7004
-								utils.ErrorLog("解析失败:%v", err)
7005
-								c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7006
-								return
7024
+									res.InfRefmsgid = resSeven10265.InfRefmsgid
7025
+									res.Output = resSeven10265.Output
7026
+									res.ErrMsg = resSeven10265.ErrMsg
7027
+									res.Cainfo = resSeven10265.Cainfo
7028
+									res.WarnMsg = resSeven10265.WarnMsg
7029
+									infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
7030
+									res.Infcode = infocode
7031
+								}
7007 7032
 							}
7008 7033
 
7009
-							res.InfRefmsgid = resSeven10265.InfRefmsgid
7010
-							res.Output = resSeven10265.Output
7011
-							res.ErrMsg = resSeven10265.ErrMsg
7012
-							res.Cainfo = resSeven10265.Cainfo
7013
-							res.WarnMsg = resSeven10265.WarnMsg
7014
-							infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
7015
-							res.Infcode = infocode
7016
-
7017 7034
 						} else if miConfig.MdtrtareaAdmvs == "350500" {
7018 7035
 							psn_info, _ := service.GetPsnByPatientId(his.PatientId)
7019 7036
 							var cert_no string
@@ -7366,7 +7383,7 @@ func (c *HisApiController) GetUploadInfo() {
7366 7383
 				}
7367 7384
 
7368 7385
 			} else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
7369
-				result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
7386
+				result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
7370 7387
 				if result3101.Infcode == "0" {
7371 7388
 					if len(result3101.Output.Result) > 0 {
7372 7389
 						var errMsgs []string
@@ -7379,99 +7396,101 @@ func (c *HisApiController) GetUploadInfo() {
7379 7396
 							"msg":         errMsgs,
7380 7397
 						})
7381 7398
 						return
7382
-					}
7383
-				}
7384
-				psn_info, _ := service.GetPsnByPatientId(his.PatientId)
7385
-				psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
7399
+					} else {
7400
+						psn_info, _ := service.GetPsnByPatientId(his.PatientId)
7401
+						psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
7386 7402
 
7387
-				//psn_info, _ := service.GetPsnByPatientId(id)
7388
-				bas := strings.Split(psn_info.CardInfo, "|")
7403
+						//psn_info, _ := service.GetPsnByPatientId(id)
7404
+						bas := strings.Split(psn_info.CardInfo, "|")
7389 7405
 
7390
-				if his.IdCardType == 1 {
7391
-					cert_no = bas[2]
7392
-				} else {
7393
-					cert_no = bas[1]
7394
-				}
7395
-
7396
-				//江苏地区国家医保医疗类别
7397
-				//职工透析:医疗类别选特殊情况门诊9933
7398
-				//居民血透门慢: 医疗类别选门诊慢病1402
7399
-				//var med_type string
7400
-				//if his.Insutype == "310" {
7401
-				//	if reg_type == 14 {
7402
-				//		med_type = "9933"
7403
-				//	} else if reg_type == 11 {
7404
-				//		med_type = "11"
7405
-				//
7406
-				//	}
7407
-				//} else if his.Insutype == "390" {
7408
-				//	if reg_type == 14 {
7409
-				//		med_type = "1402"
7410
-				//	} else if reg_type == 11 {
7411
-				//		med_type = "11"
7412
-				//	}
7413
-				//}
7414
-
7415
-				var api string
7416
-				if miConfig.MdtrtareaAdmvs == "320921" {
7417
-					api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
7418
-						his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
7419
-						"&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
7420
-						"&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
7421
-						"&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
7422
-						"&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
7423
-						"&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
7406
+						if his.IdCardType == 1 {
7407
+							cert_no = bas[2]
7408
+						} else {
7409
+							cert_no = bas[1]
7410
+						}
7424 7411
 
7425
-					//req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
7412
+						//江苏地区国家医保医疗类别
7413
+						//职工透析:医疗类别选特殊情况门诊9933
7414
+						//居民血透门慢: 医疗类别选门诊慢病1402
7415
+						//var med_type string
7416
+						//if his.Insutype == "310" {
7417
+						//	if reg_type == 14 {
7418
+						//		med_type = "9933"
7419
+						//	} else if reg_type == 11 {
7420
+						//		med_type = "11"
7421
+						//
7422
+						//	}
7423
+						//} else if his.Insutype == "390" {
7424
+						//	if reg_type == 14 {
7425
+						//		med_type = "1402"
7426
+						//	} else if reg_type == 11 {
7427
+						//		med_type = "11"
7428
+						//	}
7429
+						//}
7426 7430
 
7427
-				} else {
7428
-					//req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
7429
-					api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
7430
-						his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
7431
-						"&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
7432
-						"&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
7433
-						"&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
7434
-						"&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
7435
-						"&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
7431
+						var api string
7432
+						if miConfig.MdtrtareaAdmvs == "320921" {
7433
+							api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
7434
+								his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
7435
+								"&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
7436
+								"&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
7437
+								"&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
7438
+								"&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
7439
+								"&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
7436 7440
 
7437
-				}
7441
+							//req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
7438 7442
 
7439
-				resp, requestErr := http.Get(api)
7440
-				if requestErr != nil {
7441
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7442
-					return
7443
-				}
7443
+						} else {
7444
+							//req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
7445
+							api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
7446
+								his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
7447
+								"&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
7448
+								"&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
7449
+								"&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
7450
+								"&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
7451
+								"&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
7444 7452
 
7445
-				body, ioErr := ioutil.ReadAll(resp.Body)
7446
-				if ioErr != nil {
7447
-					utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
7448
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7449
-					return
7450
-				}
7451
-				var respJSON map[string]interface{}
7452
-				if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
7453
-					utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
7454
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7455
-					return
7456
-				}
7453
+						}
7457 7454
 
7458
-				respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
7459
-				result, _ := json.Marshal(respJSON)
7460
-				fmt.Println("log")
7461
-				fmt.Println(string(result))
7462
-				if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
7463
-					utils.ErrorLog("解析失败:%v", err)
7464
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7465
-					return
7466
-				}
7455
+						resp, requestErr := http.Get(api)
7456
+						if requestErr != nil {
7457
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7458
+							return
7459
+						}
7467 7460
 
7468
-				res.InfRefmsgid = resSeven10265.InfRefmsgid
7469
-				res.Output = resSeven10265.Output
7470
-				res.ErrMsg = resSeven10265.ErrMsg
7471
-				res.Cainfo = resSeven10265.Cainfo
7472
-				res.WarnMsg = resSeven10265.WarnMsg
7473
-				infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
7474
-				res.Infcode = infocode
7461
+						body, ioErr := ioutil.ReadAll(resp.Body)
7462
+						if ioErr != nil {
7463
+							utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
7464
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7465
+							return
7466
+						}
7467
+						var respJSON map[string]interface{}
7468
+						if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
7469
+							utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
7470
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7471
+							return
7472
+						}
7473
+
7474
+						respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
7475
+						result, _ := json.Marshal(respJSON)
7476
+						fmt.Println("log")
7477
+						fmt.Println(string(result))
7478
+						if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
7479
+							utils.ErrorLog("解析失败:%v", err)
7480
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7481
+							return
7482
+						}
7483
+
7484
+						res.InfRefmsgid = resSeven10265.InfRefmsgid
7485
+						res.Output = resSeven10265.Output
7486
+						res.ErrMsg = resSeven10265.ErrMsg
7487
+						res.Cainfo = resSeven10265.Cainfo
7488
+						res.WarnMsg = resSeven10265.WarnMsg
7489
+						infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
7490
+						res.Infcode = infocode
7491
+
7492
+					}
7493
+				}
7475 7494
 
7476 7495
 			} else if miConfig.MdtrtareaAdmvs == "350500" {
7477 7496
 				psn_info, _ := service.GetPsnByPatientId(his.PatientId)
@@ -8587,50 +8606,52 @@ func (c *HisApiController) GetPreUploadInfo() {
8587 8606
 							"msg":         errMsgs,
8588 8607
 						})
8589 8608
 						return
8590
-					}
8591
-				}
8609
+					} else {
8592 8610
 
8593
-				bytesData, _ := json.Marshal(data)
8594
-				var req *http.Request
8595
-				if miConfig.MdtrtareaAdmvs == "320921" {
8596
-					req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
8611
+						bytesData, _ := json.Marshal(data)
8612
+						var req *http.Request
8613
+						if miConfig.MdtrtareaAdmvs == "320921" {
8614
+							req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
8597 8615
 
8598
-				} else {
8599
-					req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
8600
-				}
8616
+						} else {
8617
+							req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
8618
+						}
8601 8619
 
8602
-				resp, _ := client.Do(req)
8603
-				defer resp.Body.Close()
8604
-				body, ioErr := ioutil.ReadAll(resp.Body)
8605
-				if ioErr != nil {
8606
-					utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
8607
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
8608
-					return
8609
-				}
8610
-				var respJSON map[string]interface{}
8611
-				if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
8612
-					utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
8613
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
8614
-					return
8615
-				}
8620
+						resp, _ := client.Do(req)
8621
+						defer resp.Body.Close()
8622
+						body, ioErr := ioutil.ReadAll(resp.Body)
8623
+						if ioErr != nil {
8624
+							utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
8625
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
8626
+							return
8627
+						}
8628
+						var respJSON map[string]interface{}
8629
+						if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
8630
+							utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
8631
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
8632
+							return
8633
+						}
8616 8634
 
8617
-				respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
8618
-				userJSONBytes, _ := json.Marshal(respJSON)
8619
-				fmt.Println("log")
8620
-				fmt.Println(string(userJSONBytes))
8621
-				if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
8622
-					utils.ErrorLog("解析失败:%v", err)
8623
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
8624
-					return
8625
-				}
8635
+						respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
8636
+						userJSONBytes, _ := json.Marshal(respJSON)
8637
+						fmt.Println("log")
8638
+						fmt.Println(string(userJSONBytes))
8639
+						if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
8640
+							utils.ErrorLog("解析失败:%v", err)
8641
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
8642
+							return
8643
+						}
8626 8644
 
8627
-				res.InfRefmsgid = resFour10265.InfRefmsgid
8628
-				res.Output = resFour10265.Output
8629
-				res.ErrMsg = resFour10265.ErrMsg
8630
-				res.Cainfo = resFour10265.Cainfo
8631
-				res.WarnMsg = resFour10265.WarnMsg
8632
-				infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
8633
-				res.Infcode = infocode
8645
+						res.InfRefmsgid = resFour10265.InfRefmsgid
8646
+						res.Output = resFour10265.Output
8647
+						res.ErrMsg = resFour10265.ErrMsg
8648
+						res.Cainfo = resFour10265.Cainfo
8649
+						res.WarnMsg = resFour10265.WarnMsg
8650
+						infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
8651
+						res.Infcode = infocode
8652
+
8653
+					}
8654
+				}
8634 8655
 
8635 8656
 			} else if miConfig.MdtrtareaAdmvs == "350500" {
8636 8657
 
@@ -8925,100 +8946,101 @@ func (c *HisApiController) GetPreUploadInfo() {
8925 8946
 									"msg":         errMsgs,
8926 8947
 								})
8927 8948
 								return
8928
-							}
8929
-						}
8930
-
8931
-						psn_info, _ := service.GetPsnByPatientId(his.PatientId)
8932
-						psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
8933
-
8934
-						bas := strings.Split(psn_info.CardInfo, "|")
8935
-
8936
-						if his.IdCardType == 1 {
8937
-							cert_no = bas[2]
8938
-						} else {
8939
-							cert_no = bas[1]
8940
-						}
8941
-						//江苏地区国家医保医疗类别
8942
-						//职工透析:医疗类别选特殊情况门诊9933
8943
-						//居民血透门慢: 医疗类别选门诊慢病1402
8944
-						//var med_type string
8945
-						//if his.Insutype == "310" {
8946
-						//	if reg_type == 14 {
8947
-						//		med_type = "9933"
8948
-						//	} else if reg_type == 11 {
8949
-						//		med_type = "11"
8950
-						//
8951
-						//	}
8952
-						//} else if his.Insutype == "390" {
8953
-						//	if reg_type == 14 {
8954
-						//		med_type = "1402"
8955
-						//	} else if reg_type == 11 {
8956
-						//		med_type = "11"
8957
-						//	}
8958
-						//}
8949
+							} else {
8950
+								psn_info, _ := service.GetPsnByPatientId(his.PatientId)
8951
+								psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
8959 8952
 
8960
-						var api string
8953
+								bas := strings.Split(psn_info.CardInfo, "|")
8961 8954
 
8962
-						if miConfig.MdtrtareaAdmvs == "320921" {
8963
-							api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
8964
-								his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
8965
-								"&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
8966
-								"&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
8967
-								"&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
8968
-								"&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
8969
-								"&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
8955
+								if his.IdCardType == 1 {
8956
+									cert_no = bas[2]
8957
+								} else {
8958
+									cert_no = bas[1]
8959
+								}
8960
+								//江苏地区国家医保医疗类别
8961
+								//职工透析:医疗类别选特殊情况门诊9933
8962
+								//居民血透门慢: 医疗类别选门诊慢病1402
8963
+								//var med_type string
8964
+								//if his.Insutype == "310" {
8965
+								//	if reg_type == 14 {
8966
+								//		med_type = "9933"
8967
+								//	} else if reg_type == 11 {
8968
+								//		med_type = "11"
8969
+								//
8970
+								//	}
8971
+								//} else if his.Insutype == "390" {
8972
+								//	if reg_type == 14 {
8973
+								//		med_type = "1402"
8974
+								//	} else if reg_type == 11 {
8975
+								//		med_type = "11"
8976
+								//	}
8977
+								//}
8978
+
8979
+								var api string
8980
+
8981
+								if miConfig.MdtrtareaAdmvs == "320921" {
8982
+									api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
8983
+										his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
8984
+										"&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
8985
+										"&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
8986
+										"&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
8987
+										"&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
8988
+										"&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
8989
+
8990
+									//req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
8991
+
8992
+								} else {
8993
+									//req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
8994
+									api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
8995
+										his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
8996
+										"&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
8997
+										"&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
8998
+										"&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
8999
+										"&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
9000
+										"&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
8970 9001
 
8971
-							//req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
9002
+								}
8972 9003
 
8973
-						} else {
8974
-							//req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
8975
-							api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
8976
-								his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
8977
-								"&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
8978
-								"&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
8979
-								"&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
8980
-								"&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
8981
-								"&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
9004
+								resp, requestErr := http.Get(api)
9005
+								if requestErr != nil {
9006
+									c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
9007
+									return
9008
+								}
8982 9009
 
8983
-						}
9010
+								body, ioErr := ioutil.ReadAll(resp.Body)
9011
+								if ioErr != nil {
9012
+									utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
9013
+									c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
9014
+									return
9015
+								}
9016
+								var respJSON map[string]interface{}
9017
+								if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
9018
+									utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
9019
+									c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
9020
+									return
9021
+								}
8984 9022
 
8985
-						resp, requestErr := http.Get(api)
8986
-						if requestErr != nil {
8987
-							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
8988
-							return
8989
-						}
9023
+								respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
9024
+								result, _ := json.Marshal(respJSON)
9025
+								fmt.Println("log")
9026
+								fmt.Println(string(result))
9027
+								if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
9028
+									utils.ErrorLog("解析失败:%v", err)
9029
+									c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
9030
+									return
9031
+								}
8990 9032
 
8991
-						body, ioErr := ioutil.ReadAll(resp.Body)
8992
-						if ioErr != nil {
8993
-							utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
8994
-							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
8995
-							return
8996
-						}
8997
-						var respJSON map[string]interface{}
8998
-						if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
8999
-							utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
9000
-							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
9001
-							return
9002
-						}
9033
+								res.InfRefmsgid = resSeven10265.InfRefmsgid
9034
+								res.Output = resSeven10265.Output
9035
+								res.ErrMsg = resSeven10265.ErrMsg
9036
+								res.Cainfo = resSeven10265.Cainfo
9037
+								res.WarnMsg = resSeven10265.WarnMsg
9038
+								infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
9039
+								res.Infcode = infocode
9003 9040
 
9004
-						respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
9005
-						result, _ := json.Marshal(respJSON)
9006
-						fmt.Println("log")
9007
-						fmt.Println(string(result))
9008
-						if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
9009
-							utils.ErrorLog("解析失败:%v", err)
9010
-							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
9011
-							return
9041
+							}
9012 9042
 						}
9013 9043
 
9014
-						res.InfRefmsgid = resSeven10265.InfRefmsgid
9015
-						res.Output = resSeven10265.Output
9016
-						res.ErrMsg = resSeven10265.ErrMsg
9017
-						res.Cainfo = resSeven10265.Cainfo
9018
-						res.WarnMsg = resSeven10265.WarnMsg
9019
-						infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
9020
-						res.Infcode = infocode
9021
-
9022 9044
 					} else if miConfig.MdtrtareaAdmvs == "350500" {
9023 9045
 
9024 9046
 						result, request_log, _ := service.FJyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)

+ 99 - 111
main.go View File

@@ -2,19 +2,10 @@ package main
2 2
 
3 3
 import (
4 4
 	"gdyb/service"
5
-	"github.com/qiniu/api.v7/auth/qbox"
6
-	"github.com/qiniu/api.v7/storage"
7
-
8
-	//"gdyb/service"
9
-
10
-	//"context"
11
-	"fmt"
12
-	"gdyb/models"
13
-	//"gdyb/service"
14 5
 	//"github.com/qiniu/api.v7/auth/qbox"
15 6
 	//"github.com/qiniu/api.v7/storage"
16
-	"strconv"
17
-	"time"
7
+
8
+	//"gdyb/service"
18 9
 
19 10
 	//"gdyb/models"
20 11
 	_ "gdyb/routers"
@@ -26,9 +17,6 @@ import (
26 17
 
27 18
 	//"gdyb/service"
28 19
 	"github.com/astaxie/beego"
29
-	//"github.com/qiniu/api.v7/auth/qbox"
30
-	//"github.com/qiniu/api.v7/storage"
31
-	"os"
32 20
 	//"strconv"
33 21
 	//"time"
34 22
 )
@@ -803,104 +791,104 @@ type ResultSeventeen struct {
803 791
 //	}
804 792
 //}
805 793
 
806
-func CreateLog(miConfig models.MedicalInsuranceOrgConfig) {
807
-	Mkdir(miConfig.OrgName + "日志")
808
-	//org_id,_ := beego.AppConfig.Int("org_id")
809
-	month := time.Unix(1557042972, 0).Format("1")
810
-	year := time.Now().Format("2006")
811
-	month = time.Now().Format("01")
812
-	day := time.Now().Format("02")
813
-	file := strconv.FormatInt(miConfig.UserOrgId, 10) + "_" + year + month + day + "_log"
814
-	file_name := file + ".txt"
815
-	file_path := miConfig.OrgName + "日志" + "/" + file_name
816
-	exist, _ := PathExists(file_path)
817
-	if exist { //存在
818
-		fmt.Println("存在")
819
-		f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
820
-		if err != nil {
821
-			fmt.Println("read fail")
822
-		}
823
-		content := "\r\r\r"
824
-		n, _ := f.Seek(0, 2)
825
-		_, err = f.WriteAt([]byte(content), n)
826
-
827
-	} else { //不存在
828
-		fmt.Println("文件不存在,创建文件")
829
-		f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
830
-		defer f.Close()
831
-		if err != nil {
832
-		} else {
833
-			_, err = f.Write([]byte("记录日志"))
834
-		}
835
-	}
836
-
837
-}
838
-
839
-func UploadLog(miConfig models.MedicalInsuranceOrgConfig) {
840
-	//获取七牛云上的文件信息,不存在则表示没上传到七牛云,上传昨天日志信息
841
-	nTime := time.Now()
842
-	yesTime := nTime.AddDate(0, 0, -1)
843
-	file_key := strconv.FormatInt(miConfig.UserOrgId, 10) + "_" + yesTime.Format("20060102") + "_log.txt"
844
-	mac := qbox.NewMac(beego.AppConfig.String("qiniu_accesskey"), beego.AppConfig.String("qiniu_secretkey"))
845
-	cfg := storage.Config{
846
-		// 是否使用https域名进行资源管理
847
-		UseHTTPS: true,
848
-	}
849
-	// 指定空间所在的区域,如果不指定将自动探测
850
-	// 如果没有特殊需求,默认不需要指定
851
-	//cfg.Zone=&storage.ZoneHuabei
852
-	bucketManager := storage.NewBucketManager(mac, &cfg)
853
-	bucket := beego.AppConfig.String("qiniu_bucket")
854
-	key := file_key
855
-	file, sErr := bucketManager.Stat(bucket, key)
856
-	fmt.Println(file)
857
-	fmt.Println(sErr)
858
-	fmt.Println(miConfig.OrgName + "日志" + "/" + file_key)
859
-
860
-	if sErr != nil {
861
-		fmt.Println("七牛云上文件不存在,上传到七牛云")
862
-		//判断本地文件是否存在,存在则执行上传操作
863
-		exist, _ := PathExists(miConfig.OrgName + "日志" + "/" + file_key)
864
-		if exist {
865
-			//upload_qiniu(miConfig.OrgName+"日志"+"/"+file_key, file_key)
866
-		} else {
867
-			fmt.Println("本地文件不存在")
868
-
869
-		}
870
-	} else {
871
-		fmt.Println("七牛云文件存在")
872
-	}
794
+//func CreateLog(miConfig models.MedicalInsuranceOrgConfig) {
795
+//	Mkdir(miConfig.OrgName + "日志")
796
+//	//org_id,_ := beego.AppConfig.Int("org_id")
797
+//	month := time.Unix(1557042972, 0).Format("1")
798
+//	year := time.Now().Format("2006")
799
+//	month = time.Now().Format("01")
800
+//	day := time.Now().Format("02")
801
+//	file := strconv.FormatInt(miConfig.UserOrgId, 10) + "_" + year + month + day + "_log"
802
+//	file_name := file + ".txt"
803
+//	file_path := miConfig.OrgName + "日志" + "/" + file_name
804
+//	exist, _ := PathExists(file_path)
805
+//	if exist { //存在
806
+//		fmt.Println("存在")
807
+//		f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
808
+//		if err != nil {
809
+//			fmt.Println("read fail")
810
+//		}
811
+//		content := "\r\r\r"
812
+//		n, _ := f.Seek(0, 2)
813
+//		_, err = f.WriteAt([]byte(content), n)
814
+//
815
+//	} else { //不存在
816
+//		fmt.Println("文件不存在,创建文件")
817
+//		f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
818
+//		defer f.Close()
819
+//		if err != nil {
820
+//		} else {
821
+//			_, err = f.Write([]byte("记录日志"))
822
+//		}
823
+//	}
824
+//
825
+//}
873 826
 
874
-}
875
-func Mkdir(dir string) {
876
-	// 创建文件夹
877
-	exist, err := PathExists(dir)
878
-	if err != nil {
879
-		fmt.Println(err.Error())
880
-	} else {
881
-		if exist {
882
-			fmt.Println(dir + "文件夹已存在!")
883
-		} else {
884
-			// 文件夹名称,权限
885
-			err := os.Mkdir(dir, os.ModePerm)
886
-			if err != nil {
887
-				fmt.Println(dir+"文件夹创建失败:", err.Error())
888
-			} else {
889
-				fmt.Println(dir + "文件夹创建成功!")
890
-			}
891
-		}
892
-	}
893
-}
894
-func PathExists(path string) (bool, error) {
895
-	_, err := os.Stat(path)
896
-	if err == nil {
897
-		return true, nil
898
-	}
899
-	if os.IsNotExist(err) {
900
-		return false, nil
901
-	}
902
-	return false, err
903
-}
827
+//func UploadLog(miConfig models.MedicalInsuranceOrgConfig) {
828
+//	//获取七牛云上的文件信息,不存在则表示没上传到七牛云,上传昨天日志信息
829
+//	nTime := time.Now()
830
+//	yesTime := nTime.AddDate(0, 0, -1)
831
+//	file_key := strconv.FormatInt(miConfig.UserOrgId, 10) + "_" + yesTime.Format("20060102") + "_log.txt"
832
+//	mac := qbox.NewMac(beego.AppConfig.String("qiniu_accesskey"), beego.AppConfig.String("qiniu_secretkey"))
833
+//	cfg := storage.Config{
834
+//		// 是否使用https域名进行资源管理
835
+//		UseHTTPS: true,
836
+//	}
837
+//	// 指定空间所在的区域,如果不指定将自动探测
838
+//	// 如果没有特殊需求,默认不需要指定
839
+//	//cfg.Zone=&storage.ZoneHuabei
840
+//	bucketManager := storage.NewBucketManager(mac, &cfg)
841
+//	bucket := beego.AppConfig.String("qiniu_bucket")
842
+//	key := file_key
843
+//	file, sErr := bucketManager.Stat(bucket, key)
844
+//	fmt.Println(file)
845
+//	fmt.Println(sErr)
846
+//	fmt.Println(miConfig.OrgName + "日志" + "/" + file_key)
847
+//
848
+//	if sErr != nil {
849
+//		fmt.Println("七牛云上文件不存在,上传到七牛云")
850
+//		//判断本地文件是否存在,存在则执行上传操作
851
+//		exist, _ := PathExists(miConfig.OrgName + "日志" + "/" + file_key)
852
+//		if exist {
853
+//			//upload_qiniu(miConfig.OrgName+"日志"+"/"+file_key, file_key)
854
+//		} else {
855
+//			fmt.Println("本地文件不存在")
856
+//
857
+//		}
858
+//	} else {
859
+//		fmt.Println("七牛云文件存在")
860
+//	}
861
+//
862
+//}
863
+//func Mkdir(dir string) {
864
+//	// 创建文件夹
865
+//	exist, err := PathExists(dir)
866
+//	if err != nil {
867
+//		fmt.Println(err.Error())
868
+//	} else {
869
+//		if exist {
870
+//			fmt.Println(dir + "文件夹已存在!")
871
+//		} else {
872
+//			// 文件夹名称,权限
873
+//			err := os.Mkdir(dir, os.ModePerm)
874
+//			if err != nil {
875
+//				fmt.Println(dir+"文件夹创建失败:", err.Error())
876
+//			} else {
877
+//				fmt.Println(dir + "文件夹创建成功!")
878
+//			}
879
+//		}
880
+//	}
881
+//}
882
+//func PathExists(path string) (bool, error) {
883
+//	_, err := os.Stat(path)
884
+//	if err == nil {
885
+//		return true, nil
886
+//	}
887
+//	if os.IsNotExist(err) {
888
+//		return false, nil
889
+//	}
890
+//	return false, err
891
+//}
904 892
 
905 893
 //func upload_qiniu(filePath string, keys string) {
906 894
 //	key := keys

+ 1 - 1
service/his_service.go View File

@@ -521,7 +521,7 @@ func FindLastPatientPrescriptionInfo(org_id int64, patient_id int64, record_date
521 521
 }
522 522
 
523 523
 func FindLastPatientPrescriptionInfoTwo(org_id int64, patient_id int64, record_date int64) (info models.HisPrescriptionInfo, err error) {
524
-	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND patient_id = ?", org_id, record_date, patient_id).Last(&info).Error
524
+	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND patient_id = ?", org_id, patient_id).Last(&info).Error
525 525
 	return
526 526
 }
527 527