Преглед на файлове

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

csx преди 1 година
родител
ревизия
f0e8802889
променени са 5 файла, в които са добавени 327 реда и са изтрити 19 реда
  1. 134 19
      controllers/sg/his_api_controller.go
  2. 2 0
      models/his_models.go
  3. 183 0
      service/fj_service.go
  4. 3 0
      service/gdyb_service.go
  5. 5 0
      service/his_service.go

+ 134 - 19
controllers/sg/his_api_controller.go Целия файл

@@ -87,6 +87,8 @@ func HisManagerApiRegistRouters() {
87 87
 
88 88
 	beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
89 89
 
90
+	beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
91
+
90 92
 }
91 93
 
92 94
 type Result3101 struct {
@@ -122,6 +124,108 @@ type Result3101 struct {
122 124
 	} `json:"output"`
123 125
 }
124 126
 
127
+func (c *HisApiController) ReadEleToken() {
128
+	admin_user_id, _ := c.GetInt64("admin_user_id")
129
+	his_patient_id, _ := c.GetInt64("his_patient_id")
130
+
131
+	adminUser := c.GetAdminUserInfo()
132
+	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
133
+	roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
134
+	his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
135
+
136
+	if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
137
+		tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
138
+		if len(tokens) > 0 {
139
+			c.ServeSuccessJSON(map[string]interface{}{
140
+				"msg": "读取成功,请在5分钟内进行结算操作",
141
+			})
142
+		} else {
143
+			c.ServeSuccessJSON(map[string]interface{}{
144
+				"failed_code": -10,
145
+				"msg":         "读取失败",
146
+			})
147
+		}
148
+
149
+	} else if miConfig.MdtrtareaAdmvs == "440305" {
150
+		if initFlag == 0 {
151
+			c.TestGetBasBaseInit()
152
+		}
153
+		token := c.GetEleBaseInfo()
154
+		token = Remove0000(token)
155
+		if len(token) > 0 {
156
+			c.ServeSuccessJSON(map[string]interface{}{
157
+				"msg": "读取成功,请在5分钟内进行结算操作",
158
+			})
159
+		} else {
160
+			c.ServeSuccessJSON(map[string]interface{}{
161
+				"failed_code": -10,
162
+				"msg":         "读取失败",
163
+			})
164
+		}
165
+
166
+	} else if miConfig.MdtrtareaAdmvs == "350500" {
167
+		_, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
168
+		if len(errMsg) == 0 {
169
+			type ELeData struct {
170
+				Data struct {
171
+					IdNo        string `json:"idNo"`
172
+					IdType      string `json:"idType"`
173
+					UserName    string `json:"userName"`
174
+					EcToken     string `json:"ecToken"`
175
+					InsuOrg     string `json:"insuOrg"`
176
+					Gender      string `json:"gender"`
177
+					Birthday    string `json:"birthday"`
178
+					Nationality string `json:"nationality"`
179
+					Email       string `json:"email"`
180
+					Extra       string `json:"extra"`
181
+				} `json:"data"`
182
+				Code    int    `json:"code"`
183
+				Message string `json:"message"`
184
+			}
185
+
186
+			var ele ELeData
187
+			err := json.Unmarshal([]byte(outPutInfo), &ele)
188
+			if err != nil {
189
+				utils.ErrorLog("解析失败:%v", err)
190
+			}
191
+			token := ele.Data.EcToken
192
+
193
+			if len(token) > 0 {
194
+				psn := &models.HisPsn{
195
+					PsnNo:        his.PsnNo,
196
+					Age:          0,
197
+					PatientId:    his.PatientId,
198
+					Certno:       his.Certno,
199
+					Brdy:         his.Brdy,
200
+					Gend:         his.Gend,
201
+					Naty:         his.Naty,
202
+					PsnCertType:  his.PsnCertType,
203
+					PsnName:      his.PsnName,
204
+					Idetinfo:     his.Idetinfo,
205
+					Insuinfo:     his.Iinfo,
206
+					UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
207
+					CardInfo:     outPutInfo,
208
+					VerifyNumber: token,
209
+				}
210
+				service.CreateHisPsn(psn)
211
+
212
+			}
213
+
214
+			if len(token) > 0 {
215
+				c.ServeSuccessJSON(map[string]interface{}{
216
+					"msg": "读取成功,请在5分钟内进行结算操作",
217
+				})
218
+			} else {
219
+				c.ServeSuccessJSON(map[string]interface{}{
220
+					"failed_code": -10,
221
+					"msg":         "读取失败",
222
+				})
223
+			}
224
+
225
+		}
226
+	}
227
+
228
+}
125 229
 func (c *HisApiController) Get9001() {
126 230
 	adminUser := c.GetAdminUserInfo()
127 231
 	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
@@ -7243,13 +7347,17 @@ func (c *HisApiController) GetUploadInfo() {
7243 7347
 							}
7244 7348
 
7245 7349
 						} else if miConfig.MdtrtareaAdmvs == "350500" {
7246
-							psn_info, _ := service.GetPsnByPatientId(his.PatientId)
7247 7350
 							var cert_no string
7248
-							if his.IdCardType == 1 {
7351
+							if his.IdCardType == 4 {
7352
+								psn_info, _ := service.GetPsnByPatientId(his.PatientId)
7353
+								cert_no = psn_info.VerifyNumber
7354
+								result2, src_resquest, _ = service.FJyb2207ForToken(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, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
7355
+
7356
+							} else if his.IdCardType == 1 {
7357
+								psn_info, _ := service.GetPsnByPatientId(his.PatientId)
7249 7358
 								cert_no = strings.Split(psn_info.CardInfo, "|")[0]
7359
+								result2, src_resquest, _ = service.FJyb2207(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, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
7250 7360
 							}
7251
-							fmt.Println(cert_no)
7252
-							result2, src_resquest, _ = service.FJyb2207(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, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
7253 7361
 
7254 7362
 							//result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, acct_used_flag)
7255 7363
 							var dat map[string]interface{}
@@ -7718,8 +7826,10 @@ func (c *HisApiController) GetUploadInfo() {
7718 7826
 				var cert_no string
7719 7827
 				if his.IdCardType == 1 {
7720 7828
 					cert_no = strings.Split(psn_info.CardInfo, "|")[0]
7829
+				} else {
7830
+					cert_no = psn_info.VerifyNumber
7831
+
7721 7832
 				}
7722
-				fmt.Println(cert_no)
7723 7833
 
7724 7834
 				result2, src_resquest, _ = service.FJyb2207(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, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
7725 7835
 				var dat map[string]interface{}
@@ -8580,15 +8690,7 @@ func (c *HisApiController) GetPreUploadInfo() {
8580 8690
 		if miConfig.MdtrtareaAdmvs == "320921" {
8581 8691
 			req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
8582 8692
 		} else {
8583
-			tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
8584
-			if len(tokens) > 0 {
8585
-				req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
8586
-			} else {
8587
-				c.ServeSuccessJSON(map[string]interface{}{
8588
-					"failed_code": -10,
8589
-					"msg":         "token无效",
8590
-				})
8591
-			}
8693
+			req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
8592 8694
 		}
8593 8695
 
8594 8696
 		resp, _ := client.Do(req)
@@ -8651,6 +8753,7 @@ func (c *HisApiController) GetPreUploadInfo() {
8651 8753
 		if miConfig.MdtrtareaAdmvs == "440781" { //
8652 8754
 			result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
8653 8755
 		} else {
8756
+
8654 8757
 			if miConfig.Code == "H15049901371" {
8655 8758
 				//赤峰地区国家医保医疗类别
8656 8759
 				//职工透析:医疗类别选特殊情况门诊990502
@@ -8672,8 +8775,8 @@ func (c *HisApiController) GetPreUploadInfo() {
8672 8775
 				result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, med_type, doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
8673 8776
 			} else {
8674 8777
 				result, requestLog = service.Gdyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
8675
-
8676 8778
 			}
8779
+
8677 8780
 			saveLog(result, requestLog, "2203", "上传就诊信息")
8678 8781
 			var respJSON2 map[string]interface{}
8679 8782
 			if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
@@ -8703,9 +8806,7 @@ func (c *HisApiController) GetPreUploadInfo() {
8703 8806
 				}
8704 8807
 			}
8705 8808
 		}
8706
-
8707 8809
 	}
8708
-
8709 8810
 	if res2.Infcode != 0 {
8710 8811
 		adminUser := c.GetAdminUserInfo()
8711 8812
 		errlog := &models.HisOrderError{
@@ -9279,8 +9380,16 @@ func (c *HisApiController) GetPreUploadInfo() {
9279 9380
 						}
9280 9381
 
9281 9382
 					} else if miConfig.MdtrtareaAdmvs == "350500" {
9383
+						psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId, recordDateTime)
9384
+						var result string
9385
+						var request_log string
9386
+						if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
9387
+							result, request_log, _ = service.FJyb2206ForToken(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, 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)
9388
+
9389
+						} else {
9390
+							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)
9391
+						}
9282 9392
 
9283
-						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)
9284 9393
 						var dat map[string]interface{}
9285 9394
 						if err := json.Unmarshal([]byte(result), &dat); err == nil {
9286 9395
 							fmt.Println(dat)
@@ -9318,7 +9427,13 @@ func (c *HisApiController) GetPreUploadInfo() {
9318 9427
 							}
9319 9428
 							result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, 0, 0, 0, 0, his.IdType)
9320 9429
 						} else {
9321
-							result, request_log = service.Gdyb2206(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)
9430
+							psn_info, _ := service.GetPsnByPatientId(his.PatientId)
9431
+							if his.IdCardType == 4 {
9432
+								result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, 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)
9433
+							} else {
9434
+								result, request_log = service.Gdyb2206(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)
9435
+							}
9436
+
9322 9437
 						}
9323 9438
 
9324 9439
 						var dat map[string]interface{}

+ 2 - 0
models/his_models.go Целия файл

@@ -1328,6 +1328,8 @@ type HisPsn struct {
1328 1328
 	UserOrgId    int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1329 1329
 	CardInfo     string  `gorm:"column:card_info" json:"card_info" form:"card_info"`
1330 1330
 	VerifyNumber string  `gorm:"column:verify_number" json:"verify_number" form:"verify_number"`
1331
+	Stage        string  `gorm:"column:stage" json:"stage" form:"stage"`
1332
+	RecordDate   int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
1331 1333
 }
1332 1334
 
1333 1335
 func (HisPsn) TableName() string {

+ 183 - 0
service/fj_service.go Целия файл

@@ -584,6 +584,79 @@ func FJyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
584 584
 	return output, requestLog, err_msg
585 585
 }
586 586
 
587
+func FJyb2206ForToken(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64, url string, app_id string, app_secret string, sign_key string, enc_key string) (string, string, string) {
588
+
589
+	// 生成签名
590
+	nonce := GetRandomString(32)
591
+	timestamp := time.Now().Unix()
592
+
593
+	// 生成输入报文
594
+	inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
595
+
596
+	//inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
597
+	input := make(map[string]interface{})
598
+	inputData := make(map[string]interface{})
599
+	inputMessage["infno"] = "2206" // 交易编码
600
+	inputData["psn_no"] = psnNo    // 人员编号 (来自1101接口返回)
601
+	if certificates == 3 {
602
+		inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
603
+		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
604
+	} else {
605
+		if id_card_type == 1 {
606
+			inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
607
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
608
+		} else if id_card_type == 4 {
609
+			inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
610
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
611
+
612
+		} else {
613
+			inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
614
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
615
+		}
616
+	}
617
+	if med_type == "1111" || med_type == "1112" {
618
+
619
+		med_type = "11"
620
+	}
621
+
622
+	if insuplc_admdvs == "421300" {
623
+		if med_type == "11" || med_type == "1111" || med_type == "1112" {
624
+			inputData["med_type"] = "110104" // 医疗类别 11 普通门诊  12 门诊挂号
625
+		} else if med_type == "14" {
626
+			inputData["med_type"] = "140110" // 医疗类别 11 普通门诊  12 门诊挂号
627
+		}
628
+	} else {
629
+		inputData["med_type"] = med_type // 医疗类别 11 普通门诊  12 门诊挂号
630
+	}
631
+
632
+	inputData["medfee_sumamt"] = total  // 医疗费总额
633
+	inputData["psn_setlway"] = "01"     // 个人结算方式 01 按项目结 02 按定额结算
634
+	inputData["mdtrt_id"] = mdtrtId     // 就诊 ID(来自2201接口返回)
635
+	inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
636
+	inputData["acct_used_flag"] = "0"   // 个人账户使用标志 0否 1是
637
+	inputData["insutype"] = insutype    // 险种类型
638
+	inputData["invono"] = ""            // 发票号
639
+
640
+	input["data"] = inputData
641
+	inputMessage["input"] = input //交易输入
642
+
643
+	var requestLog string
644
+
645
+	bytesData, err := json.Marshal(inputMessage)
646
+
647
+	requestLog = string(bytesData)
648
+	fmt.Println(string(bytesData))
649
+	if err != nil {
650
+		fmt.Println(err.Error())
651
+		return err.Error(), "", ""
652
+	}
653
+
654
+	enc := mahonia.NewEncoder("gbk")
655
+	output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
656
+
657
+	return output, requestLog, err_msg
658
+}
659
+
587 660
 //  门诊结算
588 661
 func FJyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64, acct_used_flag string, url string, app_id string, app_secret string, sign_key string, enc_key string) (string, string, string) {
589 662
 	// 生成签名
@@ -604,6 +677,81 @@ func FJyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
604 677
 		if id_card_type == 1 {
605 678
 			inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
606 679
 			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
680
+		} else if id_card_type == 4 {
681
+			inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
682
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
683
+		} else {
684
+			inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
685
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
686
+		}
687
+	}
688
+	if med_type == "1111" || med_type == "1112" {
689
+		med_type = "11"
690
+	}
691
+
692
+	if insuplc_admdvs == "421300" {
693
+		if med_type == "11" || med_type == "1111" || med_type == "1112" {
694
+			inputData["med_type"] = "110104" // 医疗类别 11 普通门诊  12 门诊挂号
695
+		} else if med_type == "14" {
696
+			inputData["med_type"] = "140101" // 医疗类别 11 普通门诊  12 门诊挂号
697
+		}
698
+	} else {
699
+		inputData["med_type"] = med_type // 医疗类别 11 普通门诊  12 门诊挂号
700
+	}
701
+	inputData["medfee_sumamt"] = total           // 医疗费总额
702
+	inputData["psn_setlway"] = "01"              // 个人结算方式 01 按项目结 02 按定额结算
703
+	inputData["mdtrt_id"] = mdtrtId              // 就诊 ID(来自2201接口返回)
704
+	inputData["chrg_bchno"] = chrgBchno          // 收费批次号(来自2204生成的)
705
+	inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
706
+	inputData["insutype"] = insutype             // 险种类型
707
+	inputData["invono"] = ""                     // 发票号
708
+
709
+	inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
710
+	inputData["overlmt_selfpay"] = overlmt_selfpay     //
711
+	inputData["preselfpay_amt"] = preselfpay_amt       //
712
+	inputData["inscp_scp_amt"] = inscp_scp_amt         //
713
+
714
+	input["data"] = inputData
715
+	inputMessage["input"] = input //交易输入
716
+
717
+	bytesData, err := json.Marshal(inputMessage)
718
+	fmt.Println(string(bytesData))
719
+	if err != nil {
720
+		fmt.Println(err.Error())
721
+		return err.Error(), "", ""
722
+	}
723
+
724
+	var requestLog string
725
+	requestLog = string(bytesData)
726
+
727
+	enc := mahonia.NewEncoder("gbk")
728
+	output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
729
+	return output, requestLog, err_msg
730
+}
731
+
732
+func FJyb2207ForToken(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64, acct_used_flag string, url string, app_id string, app_secret string, sign_key string, enc_key string) (string, string, string) {
733
+	// 生成签名
734
+	nonce := GetRandomString(32)
735
+	timestamp := time.Now().Unix()
736
+	// 生成输入报文
737
+	inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
738
+
739
+	//inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
740
+	input := make(map[string]interface{})
741
+	inputData := make(map[string]interface{})
742
+	inputMessage["infno"] = "2207" // 交易编码
743
+	inputData["psn_no"] = psnNo    // 人员编号 (来自1101接口返回)
744
+	if certificates == 3 {
745
+		inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
746
+		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
747
+	} else {
748
+		if id_card_type == 1 {
749
+			inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
750
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
751
+		} else if id_card_type == 4 {
752
+			inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
753
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
754
+
607 755
 		} else {
608 756
 			inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
609 757
 			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
@@ -2565,3 +2713,38 @@ func ReadEleCard(code string) (string, string, string) {
2565 2713
 	return ConvertByte2String([]byte(DeleteExtraSpace(string(bytesData))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pBusiCardInfo))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pErrMsg))), GB18030)
2566 2714
 
2567 2715
 }
2716
+
2717
+func ReadEleCardForSettle(code string, user_name string, id int64) (string, string, string) {
2718
+	DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
2719
+	readCard := DllDef.MustFindProc("ec_decode")
2720
+
2721
+	pCardInfo := make([]byte, 8192)
2722
+	pBusiCardInfo := make([]byte, 8192)
2723
+	pErrMsg := make([]byte, 8192)
2724
+
2725
+	data := make(map[string]interface{})
2726
+
2727
+	inputData := make(map[string]interface{})
2728
+	inputData["orgId"] = code
2729
+	inputData["businessType"] = "01301"
2730
+	inputData["operatorId"] = id
2731
+	inputData["operatorName"] = user_name
2732
+	inputData["officeId"] = "001"
2733
+	inputData["officeName"] = "血透科"
2734
+	data["data"] = inputData
2735
+	data["transType"] = "ec.query"
2736
+	data["orgId"] = code
2737
+	bytesData, _ := json.Marshal(data)
2738
+	pCardInfo = bytesData
2739
+	pCardInfo = []byte(ConvertByte2String(pCardInfo, GB18030))
2740
+
2741
+	ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])), (uintptr)(unsafe.Pointer(&pErrMsg[0])))
2742
+	fmt.Println(ret2)
2743
+	fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
2744
+	fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
2745
+	if ret2 != 0 {
2746
+		return "", "", ""
2747
+	}
2748
+	return ConvertByte2String([]byte(DeleteExtraSpace(string(bytesData))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pBusiCardInfo))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pErrMsg))), GB18030)
2749
+
2750
+}

+ 3 - 0
service/gdyb_service.go Целия файл

@@ -1192,6 +1192,9 @@ func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
1192 1192
 		if id_card_type == 1 {
1193 1193
 			inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
1194 1194
 			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
1195
+		} else if id_card_type == 4 {
1196
+			inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
1197
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
1195 1198
 		} else {
1196 1199
 			inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
1197 1200
 			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号

+ 5 - 0
service/his_service.go Целия файл

@@ -1411,6 +1411,11 @@ func GetPsnByPatientId(patient_id int64) (psn models.HisPsn, err error) {
1411 1411
 	return
1412 1412
 }
1413 1413
 
1414
+func GetPsnByPatientIdTwo(patient_id int64, record_date int64) (psn models.HisPsn, err error) {
1415
+	err = readDb.Model(&models.HisPsn{}).Where("patient_id = ? AND record_date = ? AND stage = 1", patient_id, record_date).Last(&psn).Error
1416
+	return
1417
+}
1418
+
1414 1419
 func GetAllHisOrder(org_id int64) (his []*models.HisOrder, err error) {
1415 1420
 	err = readDb.Model(&models.HisOrder{}).Where("user_org_id = ?  AND status = 1  AND  order_status = 2 AND setl_id <> ''  AND med_type = '14' AND setl_time >= '2022-05-01 00:00:00' AND setl_time <= '2022-06-01 23:59:59'", org_id).Order("setl_time asc").Find(&his).Error
1416 1421
 	return