Browse Source

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

csx 2 years ago
parent
commit
a1e1e2902b
1 changed files with 170 additions and 22 deletions
  1. 170 22
      controllers/sg/his_api_controller.go

+ 170 - 22
controllers/sg/his_api_controller.go View File

@@ -85,6 +85,39 @@ func HisManagerApiRegistRouters() {
85 85
 
86 86
 }
87 87
 
88
+type Result3101 struct {
89
+	Infcode     string      `json:"infcode"`
90
+	InfRefmsgid string      `json:"inf_refmsgid"`
91
+	RefmsgTime  string      `json:"refmsg_time"`
92
+	RespondTime string      `json:"respond_time"`
93
+	Enctype     string      `json:"enctype"`
94
+	Signtype    string      `json:"signtype"`
95
+	ErrMsg      interface{} `json:"err_msg"`
96
+	Output      struct {
97
+		Result []struct {
98
+			JudgeResultDetailDtos []struct {
99
+				VolaItemType string      `json:"vola_item_type"`
100
+				MdtrtID      string      `json:"mdtrt_id"`
101
+				JrdID        string      `json:"jrd_id"`
102
+				PatnID       string      `json:"patn_id"`
103
+				RxID         string      `json:"rx_id"`
104
+				VolaAmt      interface{} `json:"vola_amt"`
105
+			} `json:"judge_result_detail_dtos"`
106
+			RuleID       string  `json:"rule_id"`
107
+			VolaEvid     string  `json:"vola_evid"`
108
+			MdtrtID      string  `json:"mdtrt_id"`
109
+			RuleName     string  `json:"rule_name"`
110
+			VolaAmtStas  string  `json:"vola_amt_stas"`
111
+			JrID         string  `json:"jr_id"`
112
+			PatnID       string  `json:"patn_id"`
113
+			SevDeg       string  `json:"sev_deg"`
114
+			VolaAmt      float64 `json:"vola_amt"`
115
+			VolaBhvrType string  `json:"vola_bhvr_type"`
116
+			VolaCont     string  `json:"vola_cont"`
117
+		} `json:"result"`
118
+	} `json:"output"`
119
+}
120
+
88 121
 func (c *HisApiController) Get9001() {
89 122
 	adminUser := c.GetAdminUserInfo()
90 123
 	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
@@ -112,21 +145,21 @@ func (c *HisApiController) Get9001() {
112 145
 	}
113 146
 
114 147
 }
115
-func (c *HisApiController) Check3101(patient_id int64, his_patient_id int64, admin_user_id int64) {
148
+func Check3101(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
116 149
 
117 150
 	adminUser := c.GetAdminUserInfo()
118 151
 	roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
119 152
 	his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
120 153
 	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
121
-	record_time := c.GetString("record_time")
122
-	trig_scen := c.GetString("trig_scen")
154
+	//record_time := c.GetString("record_time")
155
+	//trig_scen := c.GetString("trig_scen")
123 156
 
124 157
 	timeLayout := "2006-01-02"
125 158
 	loc, _ := time.LoadLocation("Local")
126 159
 	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
127 160
 	if err != nil {
128 161
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
129
-		return
162
+		return res
130 163
 	}
131 164
 	recordDateTime := theTime.Unix()
132 165
 
@@ -140,7 +173,7 @@ func (c *HisApiController) Check3101(patient_id int64, his_patient_id int64, adm
140 173
 	//
141 174
 	diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
142 175
 
143
-	prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
176
+	//prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
144 177
 
145 178
 	var pp models.PublicParams
146 179
 	pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
@@ -374,26 +407,32 @@ func (c *HisApiController) Check3101(patient_id int64, his_patient_id int64, adm
374 407
 	if ioErr != nil {
375 408
 		utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
376 409
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
377
-		return
410
+		return res
378 411
 	}
379 412
 	var respJSON map[string]interface{}
380 413
 	if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
381 414
 		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
382 415
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
383
-		return
416
+		return res
417
+	}
418
+	respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
419
+	result, _ := json.Marshal(respJSON)
420
+	if err := json.Unmarshal([]byte(result), &res); err != nil {
421
+		utils.ErrorLog("解析失败:%v", err)
422
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
423
+		return res
384 424
 	}
385 425
 
386
-	//手术操作集合
387
-	//手术操作集合
426
+	return res
388 427
 
389 428
 }
390 429
 
391
-func (c *HisApiController) Check3102() {
392
-	patient_id, _ := c.GetInt64("patient_id")
393
-	order_id, _ := c.GetInt64("order_id")
394
-	his_patient_id, _ := c.GetInt64("his_patient_id")
395
-	admin_user_id, _ := c.GetInt64("admin_user_id")
396
-	trig_scen := c.GetString("trig_scen")
430
+func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
431
+	////patient_id, _ := c.GetInt64("patient_id")
432
+	//order_id, _ := c.GetInt64("order_id")
433
+	////his_patient_id, _ := c.GetInt64("his_patient_id")
434
+	////admin_user_id, _ := c.GetInt64("admin_user_id")
435
+	//trig_scen := c.GetString("trig_scen")
397 436
 
398 437
 	adminUser := c.GetAdminUserInfo()
399 438
 	roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
@@ -741,15 +780,24 @@ func (c *HisApiController) Check3102() {
741 780
 	if ioErr != nil {
742 781
 		utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
743 782
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
744
-		return
783
+		return res
745 784
 	}
746 785
 	var respJSON map[string]interface{}
747 786
 	if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
748 787
 		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
749 788
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
750
-		return
789
+		return res
790
+	}
791
+
792
+	respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
793
+	result, _ := json.Marshal(respJSON)
794
+	if err := json.Unmarshal([]byte(result), &res); err != nil {
795
+		utils.ErrorLog("解析失败:%v", err)
796
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
797
+		return res
751 798
 	}
752 799
 
800
+	return res
753 801
 	//手术操作集合
754 802
 
755 803
 	//手术操作集合
@@ -5553,6 +5601,8 @@ func (c *HisApiController) GetRegisterInfo() {
5553 5601
 				}
5554 5602
 				infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
5555 5603
 			} else {
5604
+				//Check3101(c, patient.ID, his.ID, admin_user_id)
5605
+
5556 5606
 				psn_info, _ := service.GetPsnByPatientId(id)
5557 5607
 				result, requestLog := service.Gdyb2201A(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time, psn_info.VerifyNumber)
5558 5608
 				saveLog(result, requestLog, "2201A", "挂号")
@@ -5618,9 +5668,94 @@ func (c *HisApiController) GetRegisterInfo() {
5618 5668
 			service.UpdateHisPatientStatus(&his)
5619 5669
 			service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
5620 5670
 
5621
-			c.ServeSuccessJSON(map[string]interface{}{
5622
-				"his_info": his,
5623
-			})
5671
+			var prescriptions []*models.HisPrescription
5672
+			res := Check3101(c, patient.ID, his.ID, admin_user_id, "1", record_time, prescriptions)
5673
+
5674
+			if res.Infcode == "0" {
5675
+				if len(res.Output.Result) > 0 {
5676
+					var res2 ResultSix
5677
+					var resSix10265 ResultSix10265
5678
+					var api3 string
5679
+					if miConfig.MdtrtareaAdmvs == "320921" {
5680
+						api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
5681
+							"&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
5682
+							"&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
5683
+
5684
+						//req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
5685
+
5686
+					} else {
5687
+						//req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
5688
+						api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
5689
+							"&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
5690
+							"&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
5691
+					}
5692
+
5693
+					resp3, requestErr3 := http.Get(api3)
5694
+					if requestErr3 != nil {
5695
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
5696
+						return
5697
+					}
5698
+
5699
+					body3, ioErr3 := ioutil.ReadAll(resp3.Body)
5700
+					if ioErr3 != nil {
5701
+						utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
5702
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
5703
+						return
5704
+					}
5705
+					var respJSON3 map[string]interface{}
5706
+					if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
5707
+						utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
5708
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
5709
+						return
5710
+					}
5711
+
5712
+					respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
5713
+					userJSONBytes3, _ := json.Marshal(respJSON3)
5714
+					if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
5715
+						utils.ErrorLog("解析失败:%v", err)
5716
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
5717
+						return
5718
+					}
5719
+
5720
+					res2.InfRefmsgid = resSix10265.InfRefmsgid
5721
+					res2.Output = resSix10265.Output
5722
+					res2.ErrMsg = resSix10265.ErrMsg
5723
+					res2.Cainfo = resSix10265.Cainfo
5724
+					res2.WarnMsg = resSix10265.WarnMsg
5725
+					infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
5726
+					res2.Infcode = infocode
5727
+
5728
+					if res2.Infcode == 0 {
5729
+						var msg []string
5730
+						msg = append(msg, "挂号失败")
5731
+						for _, item := range res.Output.Result {
5732
+							msg = append(msg, item.VolaCont)
5733
+						}
5734
+						c.ServeSuccessJSON(map[string]interface{}{
5735
+							"failed_code": -10,
5736
+							"msg":         msg,
5737
+						})
5738
+
5739
+					} else {
5740
+						c.ServeSuccessJSON(map[string]interface{}{
5741
+							"failed_code": -10,
5742
+							"msg":         res2.ErrMsg,
5743
+						})
5744
+
5745
+					}
5746
+
5747
+				} else {
5748
+					c.ServeSuccessJSON(map[string]interface{}{
5749
+						"his_info": his,
5750
+					})
5751
+				}
5752
+			} else {
5753
+				c.ServeSuccessJSON(map[string]interface{}{
5754
+					"failed_code": -10,
5755
+					"msg":         res.ErrMsg,
5756
+				})
5757
+
5758
+			}
5624 5759
 
5625 5760
 		} else {
5626 5761
 			adminUser := c.GetAdminUserInfo()
@@ -6129,8 +6264,22 @@ func (c *HisApiController) GetUploadInfo() {
6129 6264
 					}
6130 6265
 
6131 6266
 				} else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
6132
-					bytesData, _ := json.Marshal(data)
6267
+					result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
6268
+					if result3101.Infcode == "0" {
6269
+						if len(result3101.Output.Result) > 0 {
6270
+							var errMsgs []string
6271
+							for _, item := range result3101.Output.Result {
6272
+								errMsgs = append(errMsgs, item.VolaCont)
6133 6273
 
6274
+							}
6275
+							c.ServeSuccessJSON(map[string]interface{}{
6276
+								"failed_code": -10,
6277
+								"msg":         errMsgs,
6278
+							})
6279
+							return
6280
+						}
6281
+					}
6282
+					bytesData, _ := json.Marshal(data)
6134 6283
 					var req *http.Request
6135 6284
 					if miConfig.MdtrtareaAdmvs == "320921" {
6136 6285
 						req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
@@ -7881,7 +8030,6 @@ func (c *HisApiController) GetPreUploadInfo() {
7881 8030
 
7882 8031
 			//api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
7883 8032
 			//	"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
7884
-
7885 8033
 		} else {
7886 8034
 			req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
7887 8035