Browse Source

医保对接

csx 2 years ago
parent
commit
8a16bc0ed0

+ 1 - 1
controllers/his_api_controller.go View File

@@ -4953,7 +4953,7 @@ func (c *HisApiController) GetUploadInfo() {
4953 4953
 						DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
4954 4954
 						Cut:              fmt.Sprintf("%.4f", subItem.PrescribingNumber),
4955 4955
 						FeedetlSn:        subItem.FeedetlSn,
4956
-						Price:            fmt.Sprintf("%.2f", subItem.Price),
4956
+						Price:            fmt.Sprintf("%.4f", subItem.Price),
4957 4957
 						MedListCodg:      subItem.MedListCodg,
4958 4958
 						Type:             1,
4959 4959
 					}

+ 31 - 0
controllers/his_hospital_api_controller.go View File

@@ -250,6 +250,25 @@ func (c *HisHospitalApiController) GetUploadInfo() {
250 250
 				Type:             types,
251 251
 				SettleType:       settle_accounts_type,
252 252
 			}
253
+			if info.AdviceId > 0 && info.ProjectId == 0 {
254
+				info.MedChrgitmType = "09"
255
+			} else if info.AdviceId == 0 && info.ProjectId > 0 {
256
+				p, _ := service.GetHisPrescriptionProjectByIDTwo(info.ProjectId)
257
+				if p.Type == 2 {
258
+					if p.HisProject.CostClassify == 3 {
259
+						info.MedChrgitmType = "04"
260
+					}
261
+					if p.HisProject.CostClassify == 2 {
262
+						info.MedChrgitmType = "05"
263
+					}
264
+					if p.HisProject.CostClassify == 8 {
265
+						info.MedChrgitmType = "03"
266
+					}
267
+				} else {
268
+					info.MedChrgitmType = "08"
269
+
270
+				}
271
+			}
253 272
 			service.CreateOrderInfo(info)
254 273
 		}
255 274
 
@@ -828,7 +847,19 @@ func (c *HisHospitalApiController) GetSettleInfo() {
828 847
 	order.PrivatePrice = private_price
829 848
 	order.MdtrtId = record.Number
830 849
 	order.MedfeeSumamt = order.MedfeeSumamt
850
+	order.PsnCashPay = order.MedfeeSumamt
851
+	order.PsnName = record.Name
852
+	order.Certno = record.IdCardNo
853
+	order.IsMedicineInsurance = 0
831 854
 	order.Decimal = decimal
855
+	year2 := time.Now().Format("2006")
856
+	month2 := time.Now().Format("01")
857
+	day2 := time.Now().Format("02")
858
+	hour := time.Now().Format("15")
859
+	min := time.Now().Format("04")
860
+	second := time.Now().Format("05")
861
+
862
+	order.SetlTime = year2 + "-" + month2 + "-" + day2 + " " + hour + ":" + min + ":" + second
832 863
 	//order.SetlTime =
833 864
 	err := service.UpdataOrderStatusTwoTX(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId, tx)
834 865
 	err = service.UpDateOrderTX(order, tx)

+ 15 - 13
models/his_charge_models.go View File

@@ -90,19 +90,21 @@ func (SettlePatient) TableName() string {
90 90
 }
91 91
 
92 92
 type HisChargeOrder struct {
93
-	ID                  int64                 `gorm:"column:id" json:"id" form:"id"`
94
-	UserOrgId           int64                 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
95
-	HisPatientId        int64                 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
96
-	SettleAccountsDate  int64                 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
97
-	Status              int64                 `gorm:"column:status" json:"status" form:"status"`
98
-	Number              string                `gorm:"column:number" json:"number" form:"number"`
99
-	OrderStatus         int64                 `gorm:"column:order_status" json:"order_status" form:"order_status"`
100
-	MdtrtId             string                `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
101
-	PatientId           int64                 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
102
-	HifesPay            float64               `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
103
-	MafPay              float64               `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
104
-	FundPaySumamt       float64               `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
105
-	AcctPay             float64               `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
93
+	ID                 int64   `gorm:"column:id" json:"id" form:"id"`
94
+	UserOrgId          int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
95
+	HisPatientId       int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
96
+	SettleAccountsDate int64   `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
97
+	Status             int64   `gorm:"column:status" json:"status" form:"status"`
98
+	Number             string  `gorm:"column:number" json:"number" form:"number"`
99
+	OrderStatus        int64   `gorm:"column:order_status" json:"order_status" form:"order_status"`
100
+	MdtrtId            string  `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
101
+	PatientId          int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
102
+	HifesPay           float64 `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
103
+	MafPay             float64 `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
104
+	FundPaySumamt      float64 `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
105
+	AcctPay            float64 `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
106
+	MedfeeSumamt       float64 `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
107
+
106 108
 	PsnCashPay          float64               `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
107 109
 	IsMedicineInsurance int64                 `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
108 110
 	HisChargeOrderInfo  []*HisChargeOrderInfo `gorm:"ForeignKey:OrderNumber;AssociationForeignKey:Number" json:"order_info"`

+ 110 - 0
service/coordinate_service.go View File

@@ -486,6 +486,116 @@ func UploadPrescriptionForCoordinate(info models.UploadInfo) (string, string) {
486 486
 
487 487
 }
488 488
 
489
+func UploadPrescriptionForCoordinateHospital(info models.UploadInfo) (string, string) {
490
+
491
+	//input := make(map[string]interface{})
492
+	inputData := make(map[string]interface{})
493
+
494
+	diags := make([]map[string]interface{}, 0)
495
+	//diags := make([]map[string]interface{}, 0)
496
+
497
+	presInfos := make([]map[string]interface{}, 0)
498
+
499
+	for _, item := range info.Diag {
500
+		inputDataDiag := make(map[string]interface{})
501
+		inputDataDiag["vao06"] = item.Vao06
502
+		inputDataDiag["bak02"] = item.Bak02
503
+		diags = append(diags, inputDataDiag)
504
+	}
505
+
506
+	for _, item := range info.PresInfo {
507
+		inputDataPresInfo := make(map[string]interface{})
508
+		inputDataPresInfo["cbm06"] = item.Cbm06
509
+		inputDataPresInfo["cbm07"] = item.Cbm06
510
+		inputDataPresInfo["cbmid"] = item.Cbmid
511
+		presDetails := make([]map[string]interface{}, 0)
512
+
513
+		for _, subItem := range item.PresDetail {
514
+			inputDataPresDetail := make(map[string]interface{})
515
+			inputDataPresDetail["vaf59"] = subItem.Vaf59
516
+			Items := make([]map[string]interface{}, 0)
517
+			for _, subSubItem := range subItem.Item {
518
+				inputDataItem := make(map[string]interface{})
519
+				inputDataItem["bbx01"] = subSubItem.Bbx01
520
+				inputDataItem["bda01"] = subSubItem.Bda01
521
+				inputDataItem["bby01"] = subSubItem.Bby01
522
+				inputDataItem["bck01b"] = subSubItem.Bck01b
523
+				inputDataItem["bck01d"] = subSubItem.Bck01d
524
+				inputDataItem["bdi01"] = subSubItem.Bdi01
525
+				inputDataItem["rownr"] = subSubItem.Rownr
526
+				inputDataItem["vaf11"] = subSubItem.Vaf11
527
+				inputDataItem["vaf14"] = subSubItem.Vaf14
528
+				inputDataItem["vaf15"] = subSubItem.Vaf15
529
+				inputDataItem["vaf17"] = subSubItem.Vaf17
530
+				inputDataItem["vaf18"] = subSubItem.Vaf18
531
+				inputDataItem["vaf19"] = subSubItem.Vaf19
532
+				inputDataItem["vaf20"] = subSubItem.Vaf20
533
+				inputDataItem["vaf21"] = subSubItem.Vaf21
534
+				inputDataItem["vaf22"] = subSubItem.Vaf22
535
+				inputDataItem["vaf32"] = subSubItem.Vaf32
536
+				inputDataItem["vaf35"] = subSubItem.Vaf35
537
+				inputDataItem["vaf36"] = subSubItem.Vaf36
538
+				inputDataItem["vaf58"] = subSubItem.Vaf58
539
+				inputDataItem["vaf61"] = subSubItem.Vaf61
540
+				Items = append(Items, inputDataItem)
541
+
542
+			}
543
+			inputDataPresDetail["item"] = Items
544
+			presDetails = append(presDetails, inputDataPresDetail)
545
+		}
546
+		inputDataPresInfo["presDetail"] = presDetails
547
+		presInfos = append(presInfos, inputDataPresInfo)
548
+	}
549
+
550
+	inputData["vaa01"] = info.Vaa01   // 就诊凭证编号
551
+	inputData["Fasong"] = info.Fasong // 就诊凭证编号
552
+	inputData["vaa07"] = info.Vaa07   // 就诊凭证编号
553
+	inputData["bck01c"] = info.Bck01c // 就诊凭证编号
554
+	inputData["bce02a"] = "1001"      // 就诊凭证编号
555
+
556
+	inputData["diag"] = diags         // 就诊凭证编号
557
+	inputData["presInfo"] = presInfos // 就诊凭证编号
558
+
559
+	var inputLog string
560
+	bytesData, err := json.Marshal(inputData)
561
+	inputLog = string(bytesData)
562
+	fmt.Println(string(bytesData))
563
+	if err != nil {
564
+		fmt.Println(err.Error())
565
+		return err.Error(), ""
566
+	}
567
+	reader := bytes.NewReader(bytesData)
568
+	var url string
569
+	gdyb_url := "http://218.104.146.179:9091/esb/listener/saveOrdInfoIp"
570
+	url = gdyb_url
571
+
572
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
573
+	request, err := http.NewRequest("POST", url, reader)
574
+	if err != nil {
575
+		fmt.Println(err.Error())
576
+		return err.Error(), ""
577
+	}
578
+
579
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
580
+	request.Header.Set("code", "Xmrjyy")
581
+
582
+	client := http.Client{}
583
+	resp, err := client.Do(request)
584
+	if err != nil {
585
+		fmt.Println(err.Error())
586
+		return err.Error(), ""
587
+	}
588
+	respBytes, err := ioutil.ReadAll(resp.Body)
589
+	if err != nil {
590
+		fmt.Println(err.Error())
591
+		return err.Error(), ""
592
+	}
593
+	fmt.Println(string(respBytes))
594
+	str := string(respBytes)
595
+	return str, inputLog
596
+
597
+}
598
+
489 599
 func UpDatePrescriptionNumberForCoordinate(user_org_id int64, ids []int64, number string) (err error) {
490 600
 	err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND status = 1 AND id in (?)", user_org_id, ids).Updates(map[string]interface{}{"batch_number": number, "mtime": time.Now().Unix(), "order_status": 6}).Error
491 601
 	return

+ 1 - 1
service/his_summary_service.go View File

@@ -9,7 +9,7 @@ import (
9 9
 func GetHisSummaryDetailList(keyword string, item_type int64, patient_id int64, org_id int64, start_time int64, end_time int64) (patients []*models.ChargePatient, err error) {
10 10
 
11 11
 	err = XTReadDB().Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 and orders.patient_id = ?", start_time, end_time, org_id, patient_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
12
-		return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id,psn_cash_pay,acct_pay,fund_pay_sumamt,is_medicine_insurance").
12
+		return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id,psn_cash_pay,acct_pay,fund_pay_sumamt,is_medicine_insurance,medfee_sumamt").
13 13
 			Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
14 14
 				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Where("status = 1").
15 15
 					Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {