Browse Source

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

csx 3 years ago
parent
commit
c5dacad18e

+ 1 - 1
conf/app.conf View File

@@ -1,6 +1,6 @@
1 1
 appname = 血透
2 2
 httpport = 9532
3
-runmode = prod
3
+runmode = dev
4 4
 
5 5
 #
6 6
 copyrequestbody = true

+ 31 - 31
controllers/sg/gdyb_controller.go View File

@@ -22,7 +22,7 @@ func GdybRegistRouters() {
22 22
 	beego.Router("/gdyb/four", &GdybController{}, "get:PostFour")
23 23
 	beego.Router("/gdyb/five", &GdybController{}, "post:PostFive")
24 24
 	beego.Router("/gdyb/six", &GdybController{}, "get:PostSix")
25
-	beego.Router("/gdyb/seven", &GdybController{}, "get:PostSeven")
25
+	//beego.Router("/gdyb/seven", &GdybController{}, "get:PostSeven")
26 26
 	beego.Router("/gdyb/eight", &GdybController{}, "get:PostEight")
27 27
 	//beego.Router("/gdyb/nine", &GdybController{}, "get:PostNine")
28 28
 	beego.Router("/gdyb/ten", &GdybController{}, "get:PostTen")
@@ -274,36 +274,36 @@ func (c *GdybController) PostSix() {
274 274
 	})
275 275
 }
276 276
 
277
-func (c *GdybController) PostSeven() {
278
-	psnNo := c.GetString("psn_no")
279
-	mdtrtId := c.GetString("mdtrt_id")
280
-	chrgBchno := c.GetString("chrg_bchno")
281
-	certNo := c.GetString("cert_no")
282
-	insutype := c.GetString("insutype")
283
-	total := c.GetString("total")
284
-	org_name := c.GetString("org_name")
285
-	doctor := c.GetString("doctor")
286
-	fixmedins_code := c.GetString("fixmedins_code")
287
-	insuplc_admdvs := c.GetString("insuplc_admdvs")
288
-	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
289
-	secret_key := c.GetString("secret_key")
290
-	med_type := c.GetString("med_type")
291
-	id_card_type, _ := c.GetInt64("id_card_type")
292
-
293
-	//result := service.Gdyb2206(psnNo/**/, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, secret_key)
294
-
295
-	result := service.Gdyb2206(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, id_card_type)
296
-
297
-	var dat map[string]interface{}
298
-	if err := json.Unmarshal([]byte(result), &dat); err == nil {
299
-		fmt.Println(dat)
300
-	} else {
301
-		fmt.Println(err)
302
-	}
303
-	c.ServeSuccessJSON(map[string]interface{}{
304
-		"pre": dat,
305
-	})
306
-}
277
+//func (c *GdybController) PostSeven() {
278
+//	psnNo := c.GetString("psn_no")
279
+//	mdtrtId := c.GetString("mdtrt_id")
280
+//	chrgBchno := c.GetString("chrg_bchno")
281
+//	certNo := c.GetString("cert_no")
282
+//	insutype := c.GetString("insutype")
283
+//	total := c.GetString("total")
284
+//	org_name := c.GetString("org_name")
285
+//	doctor := c.GetString("doctor")
286
+//	fixmedins_code := c.GetString("fixmedins_code")
287
+//	insuplc_admdvs := c.GetString("insuplc_admdvs")
288
+//	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
289
+//	secret_key := c.GetString("secret_key")
290
+//	med_type := c.GetString("med_type")
291
+//	id_card_type, _ := c.GetInt64("id_card_type")
292
+//
293
+//	//result := service.Gdyb2206(psnNo/**/, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, secret_key)
294
+//
295
+//	result := service.Gdyb2206(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, id_card_type)
296
+//
297
+//	var dat map[string]interface{}
298
+//	if err := json.Unmarshal([]byte(result), &dat); err == nil {
299
+//		fmt.Println(dat)
300
+//	} else {
301
+//		fmt.Println(err)
302
+//	}
303
+//	c.ServeSuccessJSON(map[string]interface{}{
304
+//		"pre": dat,
305
+//	})
306
+//}
307 307
 
308 308
 func (c *GdybController) PostEight() {
309 309
 	psnNo := c.GetString("psn_no")

File diff suppressed because it is too large
+ 1586 - 1052
controllers/sg/his_api_controller.go


+ 15 - 7
controllers/sz/sz_his_api_controller.go View File

@@ -2152,6 +2152,9 @@ func (c *SZHisApiController) GetSettleInfo() {
2152 2152
 	admin_user_id, _ := c.GetInt64("admin_user_id")
2153 2153
 	his_patient_id, _ := c.GetInt64("his_patient_id")
2154 2154
 
2155
+	sick_type, _ := c.GetInt64("sick_type")
2156
+	reg_type, _ := c.GetInt64("p_type")
2157
+
2155 2158
 	timestamp := time.Now().Unix()
2156 2159
 	tempTime := time.Unix(timestamp, 0)
2157 2160
 	timeFormat := tempTime.Format("20060102150405")
@@ -2186,7 +2189,7 @@ func (c *SZHisApiController) GetSettleInfo() {
2186 2189
 		var end_time int64
2187 2190
 
2188 2191
 		if settle_accounts_type == 1 { //日结
2189
-			prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
2192
+			prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, his.MedicalTreatmentType)
2190 2193
 
2191 2194
 		} else { //月结
2192 2195
 			start_time_str := c.GetString("start_time")
@@ -2209,7 +2212,7 @@ func (c *SZHisApiController) GetSettleInfo() {
2209 2212
 			recordEndTime := theEndTime.Unix()
2210 2213
 			end_time = recordEndTime
2211 2214
 
2212
-			prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
2215
+			prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime, his.MedicalTreatmentType)
2213 2216
 		}
2214 2217
 
2215 2218
 		var ids []int64
@@ -2219,7 +2222,7 @@ func (c *SZHisApiController) GetSettleInfo() {
2219 2222
 
2220 2223
 		patientPrescription, _ := service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
2221 2224
 
2222
-		sick, _ := service.FindSickById(patientPrescription.SickType)
2225
+		sick, _ := service.FindSickById(sick_type)
2223 2226
 
2224 2227
 		if sick.ID == 0 {
2225 2228
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamSickTypeWrong)
@@ -2543,7 +2546,7 @@ func (c *SZHisApiController) GetSettleInfo() {
2543 2546
 				//根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
2544 2547
 				tempPatient, _ := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
2545 2548
 				if tempPatient.ID == patient_id {
2546
-					result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor_code, drug_doctor_name, his.MedicalTreatmentType, sick.CountryCode)
2549
+					result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor_code, drug_doctor_name, reg_type, sick.CountryCode)
2547 2550
 					var dat map[string]interface{}
2548 2551
 					if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
2549 2552
 						fmt.Println(dat)
@@ -2579,6 +2582,7 @@ func (c *SZHisApiController) GetSettleInfo() {
2579 2582
 						order.PsnCashPay = res.Transbody.Akb067
2580 2583
 						order.PsnPartAmt = res.Transbody.Akb067
2581 2584
 						order.AccountPrice = res.Transbody.Aae240
2585
+						order.MedType = strconv.Itoa(int(reg_type))
2582 2586
 						order.MzNumber = mz_number
2583 2587
 						order.MdtrtId = mz_number
2584 2588
 						order.YiliaoNumber = yiliao_number
@@ -2709,7 +2713,7 @@ func (c *SZHisApiController) GetSettleInfo() {
2709 2713
 				//根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
2710 2714
 				tempPatient, _ := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
2711 2715
 				if tempPatient.ID == patient_id {
2712
-					result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, order.MedfeeSumamt, yiliao_number, verifyCode, order.OrgSetlNumber, mz_number, version_code, drug_doctor_code, drug_doctor_name, his.MedicalTreatmentType, sick.CountryCode)
2716
+					result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, order.MedfeeSumamt, yiliao_number, verifyCode, order.OrgSetlNumber, mz_number, version_code, drug_doctor_code, drug_doctor_name, reg_type, sick.CountryCode)
2713 2717
 					var dat map[string]interface{}
2714 2718
 					if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
2715 2719
 						fmt.Println(dat)
@@ -2971,6 +2975,9 @@ func (c *SZHisApiController) GetPreSettleInfo() {
2971 2975
 	admin_user_id, _ := c.GetInt64("admin_user_id")
2972 2976
 	his_patient_id, _ := c.GetInt64("his_patient_id")
2973 2977
 
2978
+	reg_type, _ := c.GetInt64("p_type")
2979
+	sick_type, _ := c.GetInt64("sick_type")
2980
+
2974 2981
 	timestamp := time.Now().Unix()
2975 2982
 	tempTime := time.Unix(timestamp, 0)
2976 2983
 	timeFormat := tempTime.Format("20060102150405")
@@ -3032,7 +3039,7 @@ func (c *SZHisApiController) GetPreSettleInfo() {
3032 3039
 
3033 3040
 	patientPrescription, _ := service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
3034 3041
 
3035
-	sick, _ := service.FindSickById(patientPrescription.SickType)
3042
+	sick, _ := service.FindSickById(sick_type)
3036 3043
 
3037 3044
 	if sick.ID == 0 {
3038 3045
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamSickTypeWrong)
@@ -3265,6 +3272,7 @@ func (c *SZHisApiController) GetPreSettleInfo() {
3265 3272
 			InfRefmsgid:         "",
3266 3273
 			OrderStatus:         1,
3267 3274
 			IsMedicineInsurance: 1,
3275
+			MedType:             strconv.Itoa(int(reg_type)),
3268 3276
 			SettleType:          settle_accounts_type,
3269 3277
 			SettleStartTime:     start_time,
3270 3278
 			SettleEndTime:       end_time,
@@ -3356,7 +3364,7 @@ func (c *SZHisApiController) GetPreSettleInfo() {
3356 3364
 			//根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
3357 3365
 			tempPatient, _ := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
3358 3366
 			if tempPatient.ID == patient_id {
3359
-				result_three := service.SzybFY004(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor_code, drug_doctor_name, his.MedicalTreatmentType, sick.CountryCode)
3367
+				result_three := service.SzybFY004(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor_code, drug_doctor_name, reg_type, sick.CountryCode)
3360 3368
 				var dat map[string]interface{}
3361 3369
 				if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
3362 3370
 					fmt.Println(dat)

+ 93 - 11
service/gdyb_service.go View File

@@ -872,7 +872,7 @@ func Gdyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, d
872 872
 
873 873
 //  门诊预结算
874 874
 //func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, secret_key string) string {
875
-func Gdyb2206(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) string {
875
+func Gdyb2206(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) string {
876 876
 
877 877
 	// 生成签名
878 878
 	nonce := GetRandomString(32)
@@ -881,28 +881,30 @@ func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
881 881
 
882 882
 	// 生成输入报文
883 883
 	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
884
-
885 884
 	input := make(map[string]interface{})
886 885
 	inputData := make(map[string]interface{})
887 886
 	inputMessage["infno"] = "2206" // 交易编码
888
-
889
-	inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
890
-
891
-	if id_card_type == 1 {
892
-		inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
887
+	inputData["psn_no"] = psnNo    // 人员编号 (来自1101接口返回)
888
+	if certificates == 3 {
889
+		inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
893 890
 		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
894 891
 	} else {
895
-		inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
896
-		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
892
+		if id_card_type == 1 {
893
+			inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
894
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
895
+		} else {
896
+			inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
897
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
898
+		}
897 899
 	}
898
-
899
-	inputData["med_type"] = "11"        // 医疗类别 11 普通门诊  12 门诊挂号
900
+	inputData["med_type"] = med_type    // 医疗类别 11 普通门诊  12 门诊挂号
900 901
 	inputData["medfee_sumamt"] = total  // 医疗费总额
901 902
 	inputData["psn_setlway"] = "01"     // 个人结算方式 01 按项目结 02 按定额结算
902 903
 	inputData["mdtrt_id"] = mdtrtId     // 就诊 ID(来自2201接口返回)
903 904
 	inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
904 905
 	inputData["acct_used_flag"] = "1"   // 个人账户使用标志 0否 1是
905 906
 	inputData["insutype"] = insutype    // 险种类型
907
+	inputData["invono"] = ""            // 发票号
906 908
 
907 909
 	input["data"] = inputData
908 910
 	inputMessage["input"] = input //交易输入
@@ -2713,3 +2715,83 @@ func Gdyb2601(psnNo string, omsgid string, oinfno string, org_name string, docto
2713 2715
 	fmt.Println(str)
2714 2716
 	return str
2715 2717
 }
2718
+
2719
+//人员信息版本3
2720
+func Gdyb1101B(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates int64) string {
2721
+	//生成签名
2722
+	nonce := GetRandomString(32)
2723
+	timestamp := time.Now().Unix()
2724
+	signature := setSignature(timestamp, nonce, secret_key)
2725
+	//生成输入报文
2726
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
2727
+	input := make(map[string]interface{})
2728
+	inputData := make(map[string]interface{})
2729
+	inputMessage["infno"] = "1101" // 交易编码
2730
+
2731
+	if certificates == 3 {
2732
+		inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
2733
+		inputData["certno"] = certNo        // 证件号码
2734
+		inputData["psn_cert_type"] = "99"   // 人员证件类型
2735
+
2736
+	} else {
2737
+		if id_card_type == 1 {
2738
+			inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
2739
+			inputData["card_sn"] = card_sn      // 卡识别码
2740
+			inputData["certno"] = certNo        // 证件号码
2741
+			inputData["psn_cert_type"] = "1"    // 人员证件类型
2742
+
2743
+		} else {
2744
+			inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
2745
+			inputData["card_sn"] = ""           // 卡识别码
2746
+			inputData["certno"] = certNo        // 证件号码
2747
+			inputData["psn_cert_type"] = "1"    // 人员证件类型
2748
+		}
2749
+	}
2750
+
2751
+	inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
2752
+	inputData["begntime"] = ""          // 开始时间
2753
+	inputData["psn_name"] = ""          // 人员姓名
2754
+	input["data"] = inputData
2755
+	inputMessage["input"] = input //交易输入
2756
+
2757
+	bytesData, err := json.Marshal(inputMessage)
2758
+	fmt.Println(string(bytesData))
2759
+	if err != nil {
2760
+		fmt.Println(err.Error())
2761
+		return err.Error()
2762
+	}
2763
+	reader := bytes.NewReader(bytesData)
2764
+	gdyb_url := beego.AppConfig.String("gdyb_url")
2765
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
2766
+
2767
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
2768
+	url := gdyb_url + "1101"
2769
+
2770
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
2771
+	request, err := http.NewRequest("POST", url, reader)
2772
+	if err != nil {
2773
+		fmt.Println(err.Error())
2774
+		return err.Error()
2775
+	}
2776
+
2777
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
2778
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
2779
+	request.Header.Set("x-tif-signature", signature)
2780
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
2781
+	request.Header.Set("x-tif-nonce", nonce)
2782
+
2783
+	client := http.Client{}
2784
+	resp, err := client.Do(request)
2785
+	if err != nil {
2786
+		fmt.Println(err.Error())
2787
+		return err.Error()
2788
+	}
2789
+	respBytes, err := ioutil.ReadAll(resp.Body)
2790
+	if err != nil {
2791
+		fmt.Println(err.Error())
2792
+		return err.Error()
2793
+	}
2794
+	fmt.Println(string(respBytes))
2795
+	str := string(respBytes)
2796
+	return str
2797
+}

+ 36 - 0
service/his_service.go View File

@@ -1253,3 +1253,39 @@ func GetNewHisOrderThree(mdtrt_id string) (order HisOrder, err error) {
1253 1253
 	err = readDb.Model(&HisOrder{}).Where("status = 1 AND mdtrt_id=?  ", mdtrt_id).First(&order).Error
1254 1254
 	return
1255 1255
 }
1256
+
1257
+func UpdateHisPatientThree(his *models.HisPatient) {
1258
+	writeDb.Save(&his)
1259
+}
1260
+
1261
+func GetNewHisPrescriptionTwo(org_id int64, his_patient_id int64, record_date int64, med_type int64) (prescription []*models.HisPrescription, err error) {
1262
+	err = readDb.Model(&models.HisPrescription{}).
1263
+		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
1264
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
1265
+		}).
1266
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1267
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
1268
+		}).
1269
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1270
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1").Preload("GoodInfo", "status=1")
1271
+		}).
1272
+		Where("user_org_id = ? AND status = 1 AND record_date = ? AND his_patient_id = ? AND order_status <> 2 AND p_type <> 1 AND med_type = ?", org_id, record_date, his_patient_id, med_type).
1273
+		Find(&prescription).Error
1274
+	return
1275
+}
1276
+
1277
+func GetMonthHisPrescriptionTwo(org_id int64, patient_id int64, start_time int64, end_time int64, med_type int64) (prescription []*models.HisPrescription, err error) {
1278
+	err = readDb.Model(&models.HisPrescription{}).
1279
+		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
1280
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
1281
+		}).
1282
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1283
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
1284
+		}).
1285
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1286
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1").Preload("GoodInfo", "status=1")
1287
+		}).
1288
+		Where("user_org_id = ? AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND status = 1  AND p_type <> 1 AND med_type = ?", org_id, start_time, end_time, patient_id, med_type).
1289
+		Find(&prescription).Error
1290
+	return
1291
+}