Просмотр исходного кода

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

csx 2 лет назад
Родитель
Сommit
75b2288545

+ 155 - 2
controllers/zh/zh_his_api_controller.go Просмотреть файл

@@ -464,6 +464,7 @@ func ZHHisManagerApiRegistRouters() {
464 464
 	beego.Router("/zh/api/inhopitalcheck/get", &ZHHisApiController{}, "get:GetZHInHospitalCheck")
465 465
 	beego.Router("/zh/api/outhopitalcheck/get", &ZHHisApiController{}, "get:GetZHOutHospitalCheck")
466 466
 	beego.Router("/zh/api/uploadinfo/get", &ZHHisApiController{}, "get:GetUploadInfo")
467
+	beego.Router("/zh/api/presettle/get", &ZHHisApiController{}, "get:GetPreSettleInfo")
467 468
 	beego.Router("/zh/api/settle/get", &ZHHisApiController{}, "get:GetSettleInfo")
468 469
 	beego.Router("/zh/api/inthopitaluncheck/get", &ZHHisApiController{}, "get:GetZHInHospitalUnCheck")
469 470
 	beego.Router("/zh/api/outhopitaluncheck/get", &ZHHisApiController{}, "get:GetZHOutHospitalUnCheck")
@@ -952,6 +953,7 @@ func (this *ZHHisApiController) GetZHOutHospitalCheck() {
952 953
 	patient_id, _ := this.GetInt64("patient_id")
953 954
 	admin_user_id, _ := this.GetInt64("admin_user_id")
954 955
 	record_time := this.GetString("record_time")
956
+	out_time := this.GetString("out_time")
955 957
 
956 958
 	adminInfo := this.GetAdminUserInfo()
957 959
 	miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
@@ -996,7 +998,7 @@ func (this *ZHHisApiController) GetZHOutHospitalCheck() {
996 998
 	struct2402.PsnNo = record.PsnNo
997 999
 	struct2402.Insutype = record.InsutypeType
998 1000
 	struct2402.DscgWay = "1"
999
-	struct2402.Endtime = timeFormatOne
1001
+	struct2402.Endtime = out_time
1000 1002
 	struct2402.DscgDeptName = departmentInfo.Number
1001 1003
 	struct2402.DscgDeptCodg = strconv.FormatInt(int64(departmentInfo.ID), 10)
1002 1004
 	struct2402.MdtrtId = record.Number
@@ -1289,6 +1291,157 @@ func (c *ZHHisApiController) GetSettleInfo() {
1289 1291
 	}
1290 1292
 
1291 1293
 }
1294
+func (c *ZHHisApiController) GetPreSettleInfo() {
1295
+	order_id, _ := c.GetInt64("order_id")
1296
+	patient_id, _ := c.GetInt64("patient_id")
1297
+	in_hospital_id, _ := c.GetInt64("in_hospital_id")
1298
+	admin_user_id, _ := c.GetInt64("admin_user_id")
1299
+
1300
+	record, _ := service.GetInHospitalRecord(in_hospital_id)
1301
+	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
1302
+	roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
1303
+	order, _ := service.GetHisOrderByID(order_id)
1304
+	allTotal := fmt.Sprintf("%.4f", order.MedfeeSumamt)
1305
+	var rf []*ResultFive
1306
+	json.Unmarshal([]byte(record.Iinfo), &rf)
1307
+	chrg_bchno := order.Number
1308
+	cert_no := record.Certno
1309
+	if record.ID == 0 {
1310
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1311
+		return
1312
+	}
1313
+	if record.InHospitalStatus == 1 && record.OutHospitalStatus == 0 {
1314
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalNoExistDataException)
1315
+		return
1316
+	}
1317
+	if record.IdCardType == 1 {
1318
+	} else {
1319
+		cert_no = record.Certno
1320
+	}
1321
+	var result string
1322
+	var src_resquest string
1323
+	result, src_resquest = service.ZHGdyb2303(record.PsnNo, record.Number, chrg_bchno, cert_no, record.InsutypeType, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "0", record.IdCardType, 0, 0, 0, 0, record.Certificates)
1324
+	saveLog(result, src_resquest, "2303", "住院预结算")
1325
+	var dat map[string]interface{}
1326
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
1327
+		fmt.Println(dat)
1328
+	} else {
1329
+		fmt.Println(err)
1330
+	}
1331
+	userJSONBytes, _ := json.Marshal(dat)
1332
+	var res ResultSeven
1333
+	var resSeven10265 ResultSeven10265
1334
+	if miConfig.Code == "H15049901371" {
1335
+		if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
1336
+			utils.ErrorLog("解析失败:%v", err)
1337
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1338
+			return
1339
+		}
1340
+		Infcode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
1341
+		res.Infcode = Infcode
1342
+		res.InfRefmsgid = resSeven10265.InfRefmsgid
1343
+		res.RespondTime = resSeven10265.RespondTime
1344
+		res.ErrMsg = resSeven10265.ErrMsg
1345
+		res.Output = resSeven10265.Output
1346
+		res.WarnMsg = resSeven10265.WarnMsg
1347
+		res.Cainfo = resSeven10265.Cainfo
1348
+
1349
+	} else {
1350
+		if err := json.Unmarshal(userJSONBytes, &res); err != nil {
1351
+			utils.ErrorLog("解析失败:%v", err)
1352
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1353
+			return
1354
+		}
1355
+
1356
+	}
1357
+
1358
+	if res.Infcode != 0 {
1359
+		errlog := &models.HisOrderError{
1360
+			UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
1361
+			Ctime:      time.Now().Unix(),
1362
+			Mtime:      time.Now().Unix(),
1363
+			Number:     chrg_bchno,
1364
+			ErrMsg:     res.ErrMsg,
1365
+			Status:     1,
1366
+			PatientId:  patient_id,
1367
+			RecordTime: time.Now().Unix(),
1368
+			Stage:      6,
1369
+		}
1370
+		service.CreateErrMsgLog(errlog)
1371
+		c.ServeSuccessJSON(map[string]interface{}{
1372
+			"failed_code": -10,
1373
+			"msg":         res.ErrMsg,
1374
+		})
1375
+		return
1376
+	} else {
1377
+		//order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
1378
+		order.OrderStatus = 2
1379
+		order.MdtrtId = res.Output.Setlinfo.MdtrtID
1380
+		order.SetlId = res.Output.Setlinfo.SetlID
1381
+		order.PsnNo = res.Output.Setlinfo.PsnNo
1382
+		order.PsnName = res.Output.Setlinfo.PsnName
1383
+		order.PsnCertType = res.Output.Setlinfo.PsnCertType
1384
+		order.Certno = res.Output.Setlinfo.Certno
1385
+		order.Gend = res.Output.Setlinfo.Gend
1386
+		order.Naty = res.Output.Setlinfo.Naty
1387
+		order.Age = res.Output.Setlinfo.Age
1388
+		order.Insutype = res.Output.Setlinfo.Insutype
1389
+		order.PsnType = res.Output.Setlinfo.PsnType
1390
+		order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
1391
+		order.SetlTime = res.Output.Setlinfo.SetlTime
1392
+		order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
1393
+		if res.Output.Setlinfo.MedType == "140104" {
1394
+
1395
+			order.MedType = "14"
1396
+
1397
+		} else {
1398
+
1399
+			order.MedType = res.Output.Setlinfo.MedType
1400
+
1401
+		}
1402
+		order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
1403
+		order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
1404
+		order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
1405
+		order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
1406
+		order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
1407
+		order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
1408
+		order.HifpPay = res.Output.Setlinfo.HifpPay
1409
+		order.CvlservPay = res.Output.Setlinfo.CvlservPay
1410
+		order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
1411
+		order.HifesPay = res.Output.Setlinfo.HifesPay
1412
+		order.HifobPay = res.Output.Setlinfo.HifobPay
1413
+		order.MafPay = res.Output.Setlinfo.MafPay
1414
+		order.OthPay = res.Output.Setlinfo.OthPay
1415
+		order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
1416
+		order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
1417
+		order.AcctPay = res.Output.Setlinfo.AcctPay
1418
+		order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
1419
+		order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
1420
+		order.Balc = res.Output.Setlinfo.Balc
1421
+		order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
1422
+		order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
1423
+		order.ClrOptins = res.Output.Setlinfo.ClrOptins
1424
+		order.ClrWay = res.Output.Setlinfo.ClrWay
1425
+		order.Creator = order.Creator
1426
+		order.Modify = roles.AdminUserId
1427
+		order.RequestLog = src_resquest
1428
+		setlDetail, _ := json.Marshal(res.Output.Setldetail)
1429
+		detailStr := string(setlDetail)
1430
+		order.SetlDetail = detailStr
1431
+		err := service.UpdataOrderStatusTwo(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId)
1432
+		err = service.UpDateOrder(order)
1433
+		if err == nil {
1434
+			c.ServeSuccessJSON(map[string]interface{}{
1435
+				"msg": "结算成功",
1436
+			})
1437
+		} else {
1438
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
1439
+			return
1440
+		}
1441
+	}
1442
+
1443
+}
1444
+
1292 1445
 func (c *ZHHisApiController) GetUploadInfo() {
1293 1446
 	id, _ := c.GetInt64("id")
1294 1447
 	record_time := c.GetString("record_time")
@@ -1421,7 +1574,7 @@ func (c *ZHHisApiController) GetUploadInfo() {
1421 1574
 		for _, item := range prescriptions {
1422 1575
 			if item.Type == 1 { //药品
1423 1576
 				for _, subItem := range item.HisDoctorAdviceInfo {
1424
-					if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
1577
+					if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
1425 1578
 						//var randNum int
1426 1579
 						//randNum = rand.Intn(10000) + 1000
1427 1580
 						cus := &models.NewCustom{

+ 2 - 0
models/drug.go Просмотреть файл

@@ -68,6 +68,8 @@ type BaseDrugLib struct {
68 68
 	DoseUnit  string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
69 69
 	DrugDay   string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
70 70
 	MinPrice  float64 `gorm:"column:min_price" json:"min_price" form:"min_price"`
71
+	IsUser    int64   `gorm:"column:is_user" json:"is_user" form:"is_user"`
72
+
71 73
 	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
72 74
 }
73 75
 

+ 1 - 0
models/his_models.go Просмотреть файл

@@ -445,6 +445,7 @@ type VMDrug struct {
445 445
 	MedicalInsuranceNumber string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number"`
446 446
 	HospApprFlag           int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
447 447
 	LmtUsedFlag            int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
448
+	IsUser                 int64   `gorm:"column:is_user" json:"is_user" form:"is_user"`
448 449
 }
449 450
 
450 451
 func (VMDrug) TableName() string {

+ 1 - 0
models/self_drug_models.go Просмотреть файл

@@ -69,6 +69,7 @@ type XtBaseDrug struct {
69 69
 	IsMark               int64   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
70 70
 	HospApprFlag         int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
71 71
 	LmtUsedFlag          int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
72
+	IsUser               int64   `gorm:"column:is_user" json:"is_user" form:"is_user"`
72 73
 }
73 74
 
74 75
 func (XtBaseDrug) TableName() string {

+ 2 - 1
service/gdyb_service.go Просмотреть файл

@@ -785,6 +785,7 @@ type Custom struct {
785 785
 	DoctorName              string
786 786
 	ProvinceDrugMedListCodg string
787 787
 	ProvinceGoodMedListCodg string
788
+	IsUser                  int64
788 789
 }
789 790
 
790 791
 type RequestResult struct {
@@ -850,7 +851,7 @@ func Gdyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescri
850 851
 
851 852
 		if item.Type == 1 { //药品
852 853
 			for _, subItem := range item.HisDoctorAdviceInfo {
853
-				if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
854
+				if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
854 855
 					//var randNum int
855 856
 					//randNum = rand.Intn(10000) + 1000
856 857
 					role, _ := GetAdminUserInfoByID(item.UserOrgId, new_doctor_id)

+ 2 - 0
service/his_service.go Просмотреть файл

@@ -416,6 +416,8 @@ type BaseDrugLib struct {
416 416
 	DrugCode             string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
417 417
 	HospApprFlag         int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
418 418
 	LmtUsedFlag          int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
419
+	IsUser               int64   `gorm:"column:is_user" json:"is_user" form:"is_user"`
420
+
419 421
 	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
420 422
 	OtherDrugWarehouseInfo []*OtherDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"stock_in"`
421 423
 	VMDrugSalesReturnInfo  []*VMDrugSalesReturnInfo  `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"sales_return"`

+ 87 - 0
service/zh_his_service.go Просмотреть файл

@@ -749,6 +749,93 @@ func Gdyb2302(psnNo string, mdtrtId string, org_name string, doctor string, insu
749 749
 	return str, requestLog
750 750
 }
751 751
 
752
+func ZHGdyb2303(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, mid_setl_flag string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64) (string, string) {
753
+	// 生成签名
754
+	nonce := GetRandomString(32)
755
+	timestamp := time.Now().Unix()
756
+	signature := setSignature(timestamp, nonce, secret_key)
757
+
758
+	// 生成输入报文
759
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
760
+	input := make(map[string]interface{})
761
+	inputData := make(map[string]interface{})
762
+	inputMessage["infno"] = "2303" // 交易编码
763
+	inputData["psn_no"] = psnNo    // 人员编号 (来自1101接口返回)
764
+	if certificates == 3 {
765
+		inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
766
+		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
767
+	} else {
768
+		if id_card_type == 1 {
769
+			inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
770
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
771
+		} else {
772
+			inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
773
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
774
+		}
775
+	}
776
+	inputData["mdtrt_cert_sn"] = ""
777
+	inputData["mid_setl_flag"] = mid_setl_flag // 中途退费标志
778
+	inputData["medfee_sumamt"] = total         // 医疗费总额
779
+	inputData["psn_setlway"] = "01"            // 个人结算方式 01 按项目结 02 按定额结算
780
+	inputData["mdtrt_id"] = mdtrtId            // 就诊 ID(来自2201接口返回)
781
+	inputData["acct_used_flag"] = "1"          // 个人账户使用标志 0否 1是
782
+	inputData["insutype"] = insutype           // 险种类型
783
+	inputData["invono"] = ""                   // 发票号
784
+
785
+	input["data"] = inputData
786
+	inputMessage["input"] = input //交易输入
787
+
788
+	bytesData, err := json.Marshal(inputMessage)
789
+	fmt.Println(string(bytesData))
790
+	if err != nil {
791
+		fmt.Println(err.Error())
792
+		return err.Error(), ""
793
+	}
794
+	reader := bytes.NewReader(bytesData)
795
+	gdyb_url := beego.AppConfig.String("gdyb_url")
796
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
797
+
798
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
799
+	url := gdyb_url + "2304"
800
+	if mdtrtarea_admvs == "150499" {
801
+		url = gdyb_url
802
+	}
803
+
804
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
805
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
806
+
807
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
808
+	request, err := http.NewRequest("POST", url, reader)
809
+	if err != nil {
810
+		fmt.Println(err.Error())
811
+		return err.Error(), ""
812
+	}
813
+
814
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
815
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
816
+	request.Header.Set("x-tif-signature", signature)
817
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
818
+	request.Header.Set("x-tif-nonce", nonce)
819
+
820
+	client := http.Client{}
821
+	resp, err := client.Do(request)
822
+	if err != nil {
823
+		fmt.Println(err.Error())
824
+		return err.Error(), ""
825
+	}
826
+	respBytes, err := ioutil.ReadAll(resp.Body)
827
+	if err != nil {
828
+		fmt.Println(err.Error())
829
+		return err.Error(), ""
830
+	}
831
+	str := string(respBytes)
832
+	fmt.Println(str)
833
+	mjson, _ := json.Marshal(inputMessage)
834
+	str2 := string(mjson)
835
+
836
+	return str, str2
837
+}
838
+
752 839
 //  住院结算
753 840
 func ZHGdyb2304(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, mid_setl_flag string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64) (string, string) {
754 841
 	// 生成签名