test_user преди 1 година
родител
ревизия
85cc60f790

+ 6 - 3
conf/app.conf Целия файл

@@ -51,9 +51,12 @@ sso_domain = https://sso.kuyicloud.com
51 51
 call_domain = https://hf.sgjyun.com
52 52
 front_end_domain = "https://xt.kuyicloud.com/#"
53 53
 
54
-org_id = 9919
55
-gdyb_url = "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/"
56
-gdyb_paasid = "sg02_prd"
54
+org_id = 10485
55
+#gdyb_url = "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/"
56
+#gdyb_paasid = "sg02_prd"
57
+
58
+gdyb_url = "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/"
59
+gdyb_paasid = test_hosp
57 60
 
58 61
 readmysqlhost = shengws1.mysql.rds.aliyuncs.com
59 62
 readmysqlport = 3306

Файловите разлики са ограничени, защото са твърде много
+ 734 - 293
controllers/coordinate/coordinate_controller.go


+ 54 - 5
controllers/js/jsyb_controller.go Целия файл

@@ -10,8 +10,11 @@ import (
10 10
 	"gdyb/utils"
11 11
 	"github.com/astaxie/beego"
12 12
 	"github.com/axgle/mahonia"
13
+	"github.com/gorilla/websocket"
13 14
 	"golang.org/x/text/encoding/simplifiedchinese"
14 15
 	"io/ioutil"
16
+	"log"
17
+	"net/url"
15 18
 	"os"
16 19
 	"regexp"
17 20
 	"strconv"
@@ -119,7 +122,7 @@ func (c *JSybController) Get3261() {
119 122
 	url := c.GetString("url")
120 123
 	ak := c.GetString("ak")
121 124
 	cainfo := c.GetString("cainfo")
122
-	setl_mon := c.GetString("setl_mon")
125
+	setl_mon := c.GetString("month")
123 126
 	result, request := service.Jxyb3261(setl_mon, mdtrtarea_admvs, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, ak, secret_key, cainfo)
124 127
 	saveJsLog(result, request, "3261", "3261", org_name)
125 128
 	var dat2 map[string]interface{}
@@ -1777,11 +1780,9 @@ func (c *JSybController) ReadCard() {
1777 1780
 	case "4": //电子凭证
1778 1781
 		fmt.Println(operator_id)
1779 1782
 		fmt.Println(operator)
1780
-		pCardInfo, pBusiCardInfo := c.GetELeCertInfo(fixmedins_code, operator_id, operator)
1781
-		fmt.Println(pCardInfo)
1783
+		_, pBusiCardInfo := c.GetELeCertInfoTwo(fixmedins_code, operator_id, operator)
1782 1784
 		fmt.Println(pBusiCardInfo)
1783 1785
 		pBusiCardInfo = Remove0000(pBusiCardInfo)
1784
-		pCardInfo = Remove0000(pCardInfo)
1785 1786
 		var ele ELeCertData
1786 1787
 		err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
1787 1788
 		if err != nil {
@@ -1806,7 +1807,7 @@ func (c *JSybController) ReadCard() {
1806 1807
 			}
1807 1808
 			c.ServeSuccessJSON(map[string]interface{}{
1808 1809
 				"status":         "0",
1809
-				"card_info":      pCardInfo,
1810
+				"card_info":      "",
1810 1811
 				"busi_card_info": pBusiCardInfo,
1811 1812
 				"token":          token,
1812 1813
 				"result":         dat,
@@ -1951,6 +1952,54 @@ func (c *JSybController) GetELeCertInfo(code string, operator_id string, operato
1951 1952
 	return ConvertByte2String([]byte(DeleteExtraSpace(string(bytesData))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pBusiCardInfo))), GB18030)
1952 1953
 }
1953 1954
 
1955
+func (c *JSybController) GetELeCertInfoTwo(code string, operator_id string, operator_name string) (string, string) {
1956
+	// WebSocket服务器地址
1957
+	serverURL := "ws://127.0.0.1:8899"
1958
+
1959
+	// 解析WebSocket服务器地址
1960
+	u, err := url.Parse(serverURL)
1961
+	if err != nil {
1962
+		log.Fatal(err)
1963
+	}
1964
+
1965
+	// 建立WebSocket连接
1966
+	conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
1967
+	if err != nil {
1968
+		log.Fatal(err)
1969
+	}
1970
+	defer conn.Close()
1971
+	input2 := make(map[string]interface{})
1972
+
1973
+	input := make(map[string]interface{})
1974
+	inputData := make(map[string]interface{})
1975
+	inputData["orgId"] = code
1976
+	inputData["businessType"] = "01101"
1977
+	inputData["operatorId"] = operator_id
1978
+	inputData["operatorName"] = operator_name
1979
+	inputData["officeId"] = "001"
1980
+	inputData["officeName"] = "血透室"
1981
+	inputData["deviceType"] = ""
1982
+	input["data"] = inputData
1983
+	input["orgId"] = code
1984
+	input["transType"] = "ec.query"
1985
+	input2["url"] = "http://10.58.33.207:10086/localcfc/api/hsecfc/localQrCodeQuery"
1986
+	input2["indata"] = input
1987
+
1988
+	bytesData, _ := json.Marshal(input2)
1989
+	err = conn.WriteMessage(websocket.TextMessage, bytesData)
1990
+	if err != nil {
1991
+		fmt.Println(err)
1992
+	}
1993
+
1994
+	// 接收消息
1995
+	_, receivedMessage, err := conn.ReadMessage()
1996
+	if err != nil {
1997
+		fmt.Println(err)
1998
+	}
1999
+
2000
+	return "", string(receivedMessage)
2001
+}
2002
+
1954 2003
 func GetELeCertInfoSettle(code string, operator_id string, operator_name string) (string, string) {
1955 2004
 	DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
1956 2005
 	readCard := DllDef.MustFindProc("GetPersonInfo")

+ 99 - 8
controllers/nm/nm_controller.go Целия файл

@@ -53,13 +53,17 @@ func NmybRegistRouters() {
53 53
 
54 54
 	beego.Router("/nmyb/2201", &NmController{}, "get:Post2201")
55 55
 	beego.Router("/nmyb/2202", &NmController{}, "get:Post2202")
56
-	beego.Router("/nmyb/2203", &NmController{}, "get:Post2203")
57
-	beego.Router("/nmyb/2204", &NmController{}, "get:Post2204")
56
+	beego.Router("/nmyb/2203", &NmController{}, "post:Post2203")
57
+	beego.Router("/nmyb/2203C", &NmController{}, "post:Post2203C")
58
+
59
+	beego.Router("/nmyb/2204", &NmController{}, "post:Post2204")
58 60
 	beego.Router("/nmyb/2205", &NmController{}, "get:Post2205")
59 61
 	beego.Router("/nmyb/2206", &NmController{}, "get:Post2206")
60 62
 	beego.Router("/nmyb/2207", &NmController{}, "get:Post2207")
61 63
 	beego.Router("/nmyb/2208", &NmController{}, "get:Post2208")
62 64
 
65
+	beego.Router("/nmyb/2503", &NmController{}, "get:Post2503")
66
+
63 67
 }
64 68
 
65 69
 func (c *NmController) Post2201() {
@@ -67,7 +71,6 @@ func (c *NmController) Post2201() {
67 71
 	insutype := c.GetString("insutype")
68 72
 	certNo := c.GetString("cert_no")
69 73
 	org_name := c.GetString("org_name")
70
-	doctor := c.GetString("doctor")
71 74
 	ipt_otp_no := c.GetString("ipt_otp_no")
72 75
 	dept := c.GetString("dept")
73 76
 	verify_number := c.GetString("verify_number")
@@ -80,7 +83,9 @@ func (c *NmController) Post2201() {
80 83
 	id_card_type, _ := c.GetInt64("id_card_type")
81 84
 	doctor_name := c.GetString("doctor_name")
82 85
 	cainfo := c.GetString("cainfo")
83
-	result, request_log := service.Nmyb2201(psnNo, insutype, certNo, org_name, doctor, ipt_otp_no, dept, fixmedins_code, dept_code, doctor_id, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, doctor_name, url, verify_number, cainfo)
86
+	opter := c.GetString("opter")
87
+
88
+	result, request_log := service.Nmyb2201(psnNo, insutype, certNo, org_name, opter, ipt_otp_no, dept, fixmedins_code, dept_code, doctor_id, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, doctor_name, verify_number, cainfo)
84 89
 	saveJsLog(result, request_log, "2201", "挂号", org_name)
85 90
 	var dat map[string]interface{}
86 91
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
@@ -180,18 +185,73 @@ func (c *NmController) Post2203() {
180 185
 
181 186
 	}
182 187
 
183
-	var dat3 int64
184
-	if err := json.Unmarshal([]byte(strconv.FormatInt(timeStamp, 10)), &dat3); err == nil {
188
+	c.ServeSuccessJSON(map[string]interface{}{
189
+		"pre":         dat,
190
+		"request_log": dat2,
191
+	})
192
+}
193
+func (c *NmController) Post2203C() {
194
+
195
+	body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
196
+	var respJSON map[string]interface{}
197
+	if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
198
+		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
199
+		return
200
+	}
201
+	userJSONBytes, _ := json.Marshal(respJSON["config"])
202
+	var config []*models.HisXtDiagnoseConfig
203
+	if err := json.Unmarshal(userJSONBytes, &config); err != nil {
204
+		utils.ErrorLog("解析失败:%v", err)
205
+		return
206
+	}
207
+	fmt.Println(respJSON["psn_no"].(string))
208
+	fmt.Println(respJSON["mdtrt_id"].(string))
209
+
210
+	psnNo := respJSON["psn_no"].(string)
211
+	mdtrtId := respJSON["mdtrt_id"].(string)
212
+	doctor := respJSON["doctor"].(string)
213
+	department := respJSON["department"].(string)
214
+
215
+	org_name := respJSON["org_name"].(string)
216
+	med_type := respJSON["med_type"].(string)
217
+	doctor_id := respJSON["doctor_id"].(string)
218
+	fixmedins_code := respJSON["fixmedins_code"].(string)
219
+	sick_code := respJSON["sick_code"].(string)
220
+	sick_name := respJSON["sick_name"].(string)
221
+	dept := respJSON["dept"].(string)
222
+
223
+	insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
224
+	mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
225
+	secret_key := respJSON["secret_key"].(string)
226
+
227
+	begin_time := respJSON["begin_time"].(string)
228
+	cainfo := respJSON["cainfo"].(string)
229
+	//is_vaild := respJSON["is_vaild"].(string)
230
+
231
+	//cainfo := c.GetString("cainfo")
232
+
233
+	result, request_log := service.Nmyb2203C(psnNo, mdtrtId, doctor, department, org_name, med_type, doctor_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, sick_code, sick_name, dept, config, begin_time, cainfo)
234
+	saveJsLog(result, request_log, "2203", "上传就诊信息", org_name)
235
+	var dat2 map[string]interface{}
236
+	if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
237
+
238
+	} else {
239
+
240
+	}
241
+
242
+	var dat map[string]interface{}
243
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
185 244
 
186 245
 	} else {
187 246
 
188 247
 	}
248
+
189 249
 	c.ServeSuccessJSON(map[string]interface{}{
190 250
 		"pre":         dat,
191 251
 		"request_log": dat2,
192
-		"time_stamp":  dat3,
193 252
 	})
194 253
 }
254
+
195 255
 func (c *NmController) Post2204() {
196 256
 	body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
197 257
 	var respJSON map[string]interface{}
@@ -403,6 +463,37 @@ func (c *NmController) Post2208() {
403 463
 		"request_log": dat2,
404 464
 	})
405 465
 }
466
+func (c *NmController) Post2503() {
467
+	psnNo := c.GetString("psn_no")
468
+	insutype := c.GetString("insutype")
469
+	opera := c.GetString("opera")
470
+	org_name := c.GetString("org_name")
471
+	doctor := c.GetString("doctor")
472
+	doctor_id := c.GetString("doctor_id")
473
+	secret_key := c.GetString("secret_key")
474
+	fixmedins_code := c.GetString("fixmedins_code")
475
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
476
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
477
+	sick_name := c.GetString("sick_name")
478
+	sick_code := c.GetString("sick_code")
479
+	start_time := c.GetString("start_time")
480
+	end_time := c.GetString("end_time")
481
+	check_time := c.GetString("check_time")
482
+	hospital_name := c.GetString("hospital_name")
483
+	hospital_code := c.GetString("hospital_code")
484
+
485
+	result := service.Nmyb2503(psnNo, insutype, org_name, opera, doctor, fixmedins_code, doctor_id, insuplc_admdvs, mdtrtarea_admvs, secret_key, sick_name, sick_code, start_time, end_time, check_time, hospital_code, hospital_name)
486
+
487
+	var dat map[string]interface{}
488
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
489
+		fmt.Println(dat)
490
+	} else {
491
+		fmt.Println(err)
492
+	}
493
+	c.ServeSuccessJSON(map[string]interface{}{
494
+		"pre": dat,
495
+	})
496
+}
406 497
 
407 498
 func (c *NmController) GetNewELeInfo() {
408 499
 	token := c.GetString("token")
@@ -1460,7 +1551,7 @@ func (c *NmController) GetELeInfo(code string, operator_id string, operator_name
1460 1551
 	input := make(map[string]interface{})
1461 1552
 	inputData := make(map[string]interface{})
1462 1553
 	inputData["orgId"] = code
1463
-	inputData["businessType"] = "01103"
1554
+	inputData["businessType"] = "01101"
1464 1555
 	inputData["operatorId"] = operator_id
1465 1556
 	inputData["operatorName"] = operator_name
1466 1557
 	inputData["officeId"] = "001"

Файловите разлики са ограничени, защото са твърде много
+ 698 - 300
controllers/sg/his_api_controller.go


+ 96 - 0
controllers/zh/zh_his_api_controller.go Целия файл

@@ -566,7 +566,80 @@ func ZHHisManagerApiRegistRouters() {
566 566
 
567 567
 	beego.Router("/api/cardstatus", &ZHHisApiController{}, "get:GetCardStatus")
568 568
 
569
+	//beego.Router("/api/2403", &ZHHisApiController{}, "get:Get2403")
570
+	beego.Router("/api/5201", &ZHHisApiController{}, "get:Get5201")
571
+
572
+}
573
+func (c *ZHHisApiController) Get5201() {
574
+
569 575
 }
576
+
577
+//func (c *ZHHisApiController) Get2403(){
578
+//	id, _ := c.GetInt64("order_id")
579
+//	order,_ := service.GetHisOrderByID(id)
580
+//	hosp,_ := service.GetInHospitalRecordByNumber(order.MdtrtId)
581
+//
582
+//
583
+//	med_type := "21"
584
+//	id_card_type := hosp.IdCardType
585
+//
586
+//
587
+//
588
+//	diagnosis_ids_arr := strings.Split(hosp.Diagnosis, "-")
589
+//	adminInfo := c.GetAdminUserInfo()
590
+//	var patient service.Patients
591
+//	if id == 0 {
592
+//		patient, _ = service.GetPatientByIDCard(order.Certno, adminInfo.CurrentOrgId)
593
+//	} else {
594
+//		patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
595
+//	}
596
+//	diagnosisConfig, _ := service.FindDiagnoseByIds(diagnosis_ids_arr)
597
+//
598
+//	doctorInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, hosp.Doctor)
599
+//	//deviceNumber, _ := service.GetDeviceNumberByID(adm_bed, adminInfo.CurrentOrgId)
600
+//	departmentInfo, _ := service.GetDepartMentDetail(hosp.Departments)
601
+//
602
+//
603
+//
604
+//
605
+//	var struct2401 service.Struct2401
606
+//	struct2401.Insutype = "390"
607
+//	psn_info, _ := service.GetPsnByPatientId(patient.ID)
608
+//	if id_card_type == 1 {
609
+//		struct2401.MdtrtCertType = "03"
610
+//		bas := strings.Split(psn_info.CardInfo, "|")
611
+//		cardNumber := bas[2]
612
+//		struct2401.MdtrtCertNo = cardNumber
613
+//		struct2401.PsnNo = order.PsnNo
614
+//	} else if id_card_type == 4 {
615
+//		struct2401.MdtrtCertType = "01"
616
+//		struct2401.MdtrtCertNo = psn_info.VerifyNumber
617
+//		struct2401.PsnNo = psn_info.PsnNo
618
+//	} else {
619
+//		struct2401.MdtrtCertType = "02"
620
+//		struct2401.MdtrtCertNo = hosp.Certno
621
+//		struct2401.PsnNo = hosp.PsnNo
622
+//	}
623
+//
624
+//	struct2401.IptNo = "2023061415103410808113442"
625
+//	struct2401.AtddrNo = doctorInfo.DoctorNumber
626
+//	struct2401.ChfpdrName = doctorInfo.UserName
627
+//	struct2401.AdmDiagDscr = diagnosisConfig[0].ClassName
628
+//	struct2401.AdmDeptCodg = strconv.FormatInt(int64(departmentInfo.ID), 10)
629
+//	struct2401.AdmDeptName = departmentInfo.Name
630
+//	struct2401.AdmBed = ""
631
+//	struct2401.AdmBed = "待定"
632
+//
633
+//	struct2401.DscgMaindiagName = diagnosisConfig[0].ClassName
634
+//	struct2401.DscgMaindiagCode = diagnosisConfig[0].CountryCode
635
+//	struct2401.Begntime = "2023"
636
+//	struct2401.DiseCodg = sickConfig.CountryCode
637
+//	struct2401.DiseName = sickConfig.ClassName
638
+//
639
+//
640
+//
641
+//
642
+//}
570 643
 func (c *ZHHisApiController) GetCardStatus() {
571 644
 	//patient_id, _ := c.GetInt64("patient_id")
572 645
 	//record_date, _ := c.GetInt64("record_date")
@@ -1417,6 +1490,28 @@ func (c *ZHHisApiController) GetZHPatientInfo() {
1417 1490
 		if len(insutypes) == 0 {
1418 1491
 			insutype = "310"
1419 1492
 		}
1493
+
1494
+		Iinfos, _ := json.Marshal(res.Output.Iinfo)
1495
+		Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
1496
+		infoStr := string(Iinfos)
1497
+		idetinfoStr := string(Idetinfos)
1498
+		psn := &models.HisPsn{
1499
+			PsnNo:        res.Output.Baseinfo.PsnNo,
1500
+			Age:          res.Output.Baseinfo.Age,
1501
+			PatientId:    patient.ID,
1502
+			Certno:       res.Output.Baseinfo.Certno,
1503
+			Brdy:         res.Output.Baseinfo.Brdy,
1504
+			Gend:         res.Output.Baseinfo.Gend,
1505
+			Naty:         res.Output.Baseinfo.Naty,
1506
+			PsnCertType:  res.Output.Baseinfo.PsnCertType,
1507
+			PsnName:      res.Output.Baseinfo.PsnName,
1508
+			Idetinfo:     idetinfoStr,
1509
+			Insuinfo:     infoStr,
1510
+			UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
1511
+			VerifyNumber: "",
1512
+		}
1513
+		service.CreateHisPsn(psn)
1514
+
1420 1515
 		if res.Infcode != 0 {
1421 1516
 			c.ServeSuccessJSON(map[string]interface{}{
1422 1517
 				"failed_code": -10,
@@ -1815,6 +1910,7 @@ func (c *ZHHisApiController) GetZHInHospitalCheck() {
1815 1910
 		} else if miConfig.MdtrtareaAdmvs == "360399" {
1816 1911
 
1817 1912
 			result, request_log = service.Jxyb2401(struct2401, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey)
1913
+
1818 1914
 			saveLog(result, request_log, "2401", "入院登记")
1819 1915
 
1820 1916
 		} else {

+ 4 - 0
enums/error_code.go Целия файл

@@ -262,6 +262,8 @@ const ( // ErrorCode
262 262
 
263 263
 	ErrorCodeHisPatientNoRegException = 4000000
264 264
 	ErrorCodeCreateOrderExceptionT    = 200680000
265
+
266
+	ErrorPsnNoEmpty = 310000
265 267
 )
266 268
 
267 269
 var ErrCodeMsgs = map[int]string{
@@ -504,6 +506,8 @@ var ErrCodeMsgs = map[int]string{
504 506
 	ErrorCodeHisPatientNoRegException: "该患者尚未挂号,请先挂号",
505 507
 
506 508
 	ErrorCodeCreateOrderExceptionT: "记账失败",
509
+
510
+	ErrorPsnNoEmpty: "人员编码不能为空",
507 511
 }
508 512
 
509 513
 type SGJError struct {

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

@@ -1349,6 +1349,7 @@ type HisPsn struct {
1349 1349
 	Stage         string  `gorm:"column:stage" json:"stage" form:"stage"`
1350 1350
 	RecordDate    int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
1351 1351
 	InsuplcAdmdvs string  `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
1352
+	IdCardType    int64   `gorm:"column:id_card_type" json:"id_card_type" form:"id_card_type"`
1352 1353
 }
1353 1354
 
1354 1355
 func (HisPsn) TableName() string {

+ 1 - 0
models/zb_his_models.go Целия файл

@@ -9,4 +9,5 @@ type Reg struct {
9 9
 	RegFee      string
10 10
 	TreatFee    string
11 11
 	OperatorId  string
12
+	IdCardNo    string
12 13
 }

+ 1 - 1
routers/router.go Целия файл

@@ -32,6 +32,6 @@ func init() {
32 32
 	zh.ZHHisManagerApiRegistRouters()
33 33
 	js.JSybRegistRouters()
34 34
 	nm.NmybRegistRouters()
35
-	coordinate.CoordinateRegistRouters()
35
+	coordinate.CoordinateRcegistRouters()
36 36
 
37 37
 }

+ 297 - 128
service/coordinate_service.go Целия файл

@@ -11,21 +11,296 @@ import (
11 11
 	"time"
12 12
 )
13 13
 
14
-func UpdateHisPatientStatusTwo(his *models.VMHisPatient) {
14
+func SavePatientMessageInfo() (string, string) {
15
+
16
+	//input := make(map[string]interface{})
17
+	inputData := make(map[string]interface{})
18
+	inputData["patType"] = "1"                  // 就诊凭证编号
19
+	inputData["patIdNo"] = "440510199211080038" // 开始时间
20
+	inputData["patName"] = "测试患者4 "             // 人员姓名
21
+
22
+	inputData["patMobile"] = "13535547902" // 人员姓名
23
+	inputData["patSex"] = "M"              // 人员姓名
24
+	inputData["patMarriage"] = "1"         // 人员姓名
25
+	inputData["birthday"] = "1992-10-23"   // 人员姓名
26
+	inputData["patAddress"] = "11111"      // 人员姓名
27
+	inputData["thirdPartyID"] = "6936"     // 人员姓名
28
+	inputData["patAge"] = "30"             // 人员姓名
29
+	//input["req"] = inputData
30
+
31
+	var inputLog string
32
+	bytesData, err := json.Marshal(inputData)
33
+	inputLog = string(bytesData)
34
+	fmt.Println(string(bytesData))
35
+	if err != nil {
36
+		fmt.Println(err.Error())
37
+		return err.Error(), ""
38
+	}
39
+	reader := bytes.NewReader(bytesData)
40
+	var url string
41
+	gdyb_url := "http://218.104.146.179:9091/esb/listener/savePatientMessageInfo"
42
+	url = gdyb_url
43
+
44
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
45
+	request, err := http.NewRequest("GET", url, reader)
46
+	if err != nil {
47
+		fmt.Println(err.Error())
48
+		return err.Error(), ""
49
+	}
50
+
51
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
52
+	request.Header.Set("code", "Xmrjyy")
53
+
54
+	client := http.Client{}
55
+	resp, err := client.Do(request)
56
+	if err != nil {
57
+		fmt.Println(err.Error())
58
+		return err.Error(), ""
59
+	}
60
+	respBytes, err := ioutil.ReadAll(resp.Body)
61
+	if err != nil {
62
+		fmt.Println(err.Error())
63
+		return err.Error(), ""
64
+	}
65
+	fmt.Println(string(respBytes))
66
+	str := string(respBytes)
67
+	return str, inputLog
68
+
69
+}
70
+
71
+func SaveReg(reg models.Reg) (string, string) {
72
+
73
+	//input := make(map[string]interface{})
74
+	inputData := make(map[string]interface{})
75
+
76
+	inputData["deptId"] = reg.DeptId
77
+	inputData["clinicUnitId"] = ""
78
+	inputData["healthCardNo"] = ""
79
+	fmt.Println(reg.PatientId)
80
+	inputData["patientId"] = reg.PatientId
81
+	inputData["patientName"] = reg.PatientName
82
+	inputData["idCardNo"] = reg.IdCardNo
83
+	inputData["phone"] = ""
84
+	inputData["doctorId"] = ""
85
+	inputData["doctorLevelCode"] = ""
86
+	inputData["regDate"] = reg.RegDate
87
+
88
+	inputData["shiftCode"] = ""
89
+	inputData["startTime"] = ""
90
+	inputData["endTime"] = ""
91
+
92
+	inputData["scheduleId"] = ""
93
+	inputData["periodId"] = ""
94
+
95
+	inputData["svObjectId"] = ""
96
+	inputData["diseaseId"] = ""
97
+	inputData["regFee"] = reg.RegFee
98
+
99
+	inputData["treatFee"] = reg.TreatFee
100
+	inputData["operatorId"] = reg.OperatorId
101
+	inputData["remark"] = "血透"
102
+
103
+	inputData["orderType"] = "0"
104
+	inputData["clinicCode"] = ""
105
+	inputData["infoSeq"] = ""
106
+
107
+	//input["Request"] = inputData
108
+
109
+	var inputLog string
110
+	bytesData, err := json.Marshal(inputData)
111
+	inputLog = string(bytesData)
112
+	fmt.Println(string(bytesData))
113
+	if err != nil {
114
+		fmt.Println(err.Error())
115
+		return err.Error(), ""
116
+	}
117
+	reader := bytes.NewReader(bytesData)
118
+	var url string
119
+	gdyb_url := "http://218.104.146.179:9091/esb/listener/saveReg"
120
+	url = gdyb_url
121
+
122
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
123
+	request, err := http.NewRequest("POST", url, reader)
124
+	if err != nil {
125
+		fmt.Println(err.Error())
126
+		return err.Error(), ""
127
+	}
128
+
129
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
130
+	request.Header.Set("code", "Xmrjyy")
131
+
132
+	client := http.Client{}
133
+	resp, err := client.Do(request)
134
+	if err != nil {
135
+		fmt.Println(err.Error())
136
+		return err.Error(), ""
137
+	}
138
+	respBytes, err := ioutil.ReadAll(resp.Body)
139
+	if err != nil {
140
+		fmt.Println(err.Error())
141
+		return err.Error(), ""
142
+	}
143
+	fmt.Println(string(respBytes))
144
+	str := string(respBytes)
145
+	return str, inputLog
146
+
147
+}
148
+func GetWaitPayDetail() (string, string) {
149
+
150
+	//input := make(map[string]interface{})
151
+	inputData := make(map[string]interface{})
152
+
153
+	inputData["clinicSeq"] = "30445"              // 就诊凭证编号
154
+	inputData["prescriptionId"] = ""              // 开始时间
155
+	inputData["patientId"] = "701822660170096645" // 人员姓名
156
+
157
+	var inputLog string
158
+	bytesData, err := json.Marshal(inputData)
159
+	inputLog = string(bytesData)
160
+	fmt.Println(string(bytesData))
161
+	if err != nil {
162
+		fmt.Println(err.Error())
163
+		return err.Error(), ""
164
+	}
165
+	reader := bytes.NewReader(bytesData)
166
+	var url string
167
+	gdyb_url := "http://218.104.146.179:9091/esb/listener/getWaitPayDetail"
168
+	url = gdyb_url
169
+
170
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
171
+	request, err := http.NewRequest("POST", url, reader)
172
+	if err != nil {
173
+		fmt.Println(err.Error())
174
+		return err.Error(), ""
175
+	}
176
+
177
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
178
+	request.Header.Set("code", "Xmrjyy")
179
+
180
+	client := http.Client{}
181
+	resp, err := client.Do(request)
182
+	if err != nil {
183
+		fmt.Println(err.Error())
184
+		return err.Error(), ""
185
+	}
186
+	respBytes, err := ioutil.ReadAll(resp.Body)
187
+	if err != nil {
188
+		fmt.Println(err.Error())
189
+		return err.Error(), ""
190
+	}
191
+	fmt.Println(string(respBytes))
192
+	str := string(respBytes)
193
+	return str, inputLog
194
+
195
+}
196
+func OpKeepAccounts(number string, cus []*models.NewCustomTwo) (string, string) {
197
+
198
+	inputData := make(map[string]interface{})
199
+	feedetail := make([]map[string]interface{}, 0)
200
+	for _, item := range cus {
201
+		feedetailInfo := make(map[string]interface{})
202
+		feedetailInfo["itemCode"] = item.MedListCodg
203
+		feedetailInfo["num"] = item.Cut
204
+		feedetail = append(feedetail, feedetailInfo)
205
+	}
206
+	inputData["item"] = feedetail
207
+	inputData["clinicSeq"] = number // 就诊凭证编号
208
+	var inputLog string
209
+	bytesData, err := json.Marshal(inputData)
210
+	inputLog = string(bytesData)
211
+	fmt.Println(string(bytesData))
212
+	if err != nil {
213
+		fmt.Println(err.Error())
214
+		return err.Error(), ""
215
+	}
216
+	reader := bytes.NewReader(bytesData)
217
+	var url string
218
+	gdyb_url := "http://218.104.146.179:9091/esb/listener/opKeepAccounts"
219
+	url = gdyb_url
220
+
221
+	request, err := http.NewRequest("POST", url, reader)
222
+	if err != nil {
223
+		fmt.Println(err.Error())
224
+		return err.Error(), ""
225
+	}
226
+
227
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
228
+	request.Header.Set("code", "Xmrjyy")
229
+
230
+	client := http.Client{}
231
+	resp, err := client.Do(request)
232
+	if err != nil {
233
+		fmt.Println(err.Error())
234
+		return err.Error(), ""
235
+	}
236
+	respBytes, err := ioutil.ReadAll(resp.Body)
237
+	if err != nil {
238
+		fmt.Println(err.Error())
239
+		return err.Error(), ""
240
+	}
241
+	fmt.Println(string(respBytes))
242
+	str := string(respBytes)
243
+	return str, inputLog
244
+
245
+}
246
+func OpCancelKeepAccounts(setl_id string, op_name string, op_code string) (string, string) {
247
+	inputData := make(map[string]interface{})
248
+	inputData["docId"] = setl_id
249
+	inputData["operCode"] = "111"
250
+	inputData["operName"] = "2222"
251
+	var inputLog string
252
+	bytesData, err := json.Marshal(inputData)
253
+	inputLog = string(bytesData)
254
+	fmt.Println(string(bytesData))
255
+	if err != nil {
256
+		fmt.Println(err.Error())
257
+		return err.Error(), ""
258
+	}
259
+	reader := bytes.NewReader(bytesData)
260
+	var url string
261
+	gdyb_url := "http://218.104.146.179:9091/esb/listener/opCancelKeepAccounts"
262
+	url = gdyb_url
263
+	request, err := http.NewRequest("POST", url, reader)
264
+	if err != nil {
265
+		fmt.Println(err.Error())
266
+		return err.Error(), ""
267
+	}
268
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
269
+	request.Header.Set("code", "Xmrjyy")
270
+	client := http.Client{}
271
+	resp, err := client.Do(request)
272
+	if err != nil {
273
+		fmt.Println(err.Error())
274
+		return err.Error(), ""
275
+	}
276
+	respBytes, err := ioutil.ReadAll(resp.Body)
277
+	if err != nil {
278
+		fmt.Println(err.Error())
279
+		return err.Error(), ""
280
+	}
281
+	fmt.Println(string(respBytes))
282
+	str := string(respBytes)
283
+	return str, inputLog
284
+
285
+}
286
+
287
+func UpdateHisPatientStatusten(his *models.VMHisPatient) {
15 288
 	writeDb.Save(&his)
16 289
 }
17 290
 
18
-func GetUnSettleHisPrescriptionFiveTen(org_id int64, patient_id int64, record_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
291
+func GetUnSettleHisPrescriptionFive(org_id int64, patient_id int64, record_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
19 292
 	err = readDb.Model(&models.HisPrescription{}).
20 293
 		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
21 294
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
22 295
 		}).
23 296
 		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
24
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
297
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
25 298
 		}).
26 299
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
27
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
28
-		}).
300
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
301
+		}).Preload("TempHisOrder", func(db *gorm.DB) *gorm.DB {
302
+		return db.Where("status = 1 AND user_org_id = ? AND order_status <> 3  AND order_status <> 2  ", org_id)
303
+	}).
29 304
 		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND order_status <> 3 and order_status <> 5  AND p_type = ?", org_id, record_date, patient_id, p_type).
30 305
 		Find(&prescription).Error
31 306
 	return
@@ -121,7 +396,7 @@ func UploadPrescriptionForCoordinate(info models.UploadInfo) (string, string) {
121 396
 	for _, item := range info.PresInfo {
122 397
 		inputDataPresInfo := make(map[string]interface{})
123 398
 		inputDataPresInfo["cbm06"] = item.Cbm06
124
-		inputDataPresInfo["cbm07"] = item.Cbm07
399
+		inputDataPresInfo["cbm07"] = item.Cbm06
125 400
 		inputDataPresInfo["cbmid"] = item.Cbmid
126 401
 		presDetails := make([]map[string]interface{}, 0)
127 402
 
@@ -291,7 +566,7 @@ func UploadPrescriptionForCoordinateHospital(info models.UploadInfo) (string, st
291 566
 	}
292 567
 	reader := bytes.NewReader(bytesData)
293 568
 	var url string
294
-	gdyb_url := "http://218.104.146.179:90911/esb/listener/saveOrdInfoIp"
569
+	gdyb_url := "http://218.104.146.179:9091/esb/listener/saveOrdInfoIp"
295 570
 	url = gdyb_url
296 571
 
297 572
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
@@ -326,151 +601,45 @@ func UpDatePrescriptionNumberForCoordinate(user_org_id int64, ids []int64, numbe
326 601
 	return
327 602
 }
328 603
 
329
-func GetDrugInfo(bbx01 string) (string, string) {
330
-
331
-	//input := make(map[string]interface{})
332
-	inputData := make(map[string]interface{})
333
-	inputData["bbx01"] = bbx01 // 就诊凭证编号
334
-	inputData["name"] = ""     // 就诊凭证编号
335
-
336
-	var inputLog string
337
-	bytesData, err := json.Marshal(inputData)
338
-	inputLog = string(bytesData)
339
-	fmt.Println(string(bytesData))
340
-	if err != nil {
341
-		fmt.Println(err.Error())
342
-		return err.Error(), ""
343
-	}
344
-	reader := bytes.NewReader(bytesData)
345
-	var url string
346
-	gdyb_url := "http://218.104.146.179:9091/esb/listener/getGrug"
347
-	url = gdyb_url
348
-
349
-	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
350
-	request, err := http.NewRequest("GET", url, reader)
351
-	if err != nil {
352
-		fmt.Println(err.Error())
353
-		return err.Error(), ""
354
-	}
355
-
356
-	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
357
-	request.Header.Set("code", "Xmrjyy")
358
-
359
-	client := http.Client{}
360
-	resp, err := client.Do(request)
361
-	if err != nil {
362
-		fmt.Println(err.Error())
363
-		return err.Error(), ""
364
-	}
365
-	respBytes, err := ioutil.ReadAll(resp.Body)
366
-	if err != nil {
367
-		fmt.Println(err.Error())
368
-		return err.Error(), ""
369
-	}
370
-	fmt.Println(string(respBytes))
371
-	str := string(respBytes)
372
-	return str, inputLog
373
-
374
-}
375
-
376
-func GetGoodInfo(bbx01 string) (string, string) {
377
-
378
-	//input := make(map[string]interface{})
379
-	inputData := make(map[string]interface{})
380
-	inputData["bbx01"] = bbx01 // 就诊凭证编号
381
-	inputData["name"] = ""     // 就诊凭证编号
382
-
383
-	var inputLog string
384
-	bytesData, err := json.Marshal(inputData)
385
-	inputLog = string(bytesData)
386
-	fmt.Println(string(bytesData))
387
-	if err != nil {
388
-		fmt.Println(err.Error())
389
-		return err.Error(), ""
390
-	}
391
-	reader := bytes.NewReader(bytesData)
392
-	var url string
393
-	gdyb_url := "http://218.104.146.179:9091/esb/listener/getMaterial"
394
-	url = gdyb_url
395
-
396
-	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
397
-	request, err := http.NewRequest("GET", url, reader)
398
-	if err != nil {
399
-		fmt.Println(err.Error())
400
-		return err.Error(), ""
401
-	}
402
-
403
-	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
404
-	request.Header.Set("code", "Xmrjyy")
405
-
406
-	client := http.Client{}
407
-	resp, err := client.Do(request)
408
-	if err != nil {
409
-		fmt.Println(err.Error())
410
-		return err.Error(), ""
411
-	}
412
-	respBytes, err := ioutil.ReadAll(resp.Body)
413
-	if err != nil {
414
-		fmt.Println(err.Error())
415
-		return err.Error(), ""
416
-	}
417
-	fmt.Println(string(respBytes))
418
-	str := string(respBytes)
419
-	return str, inputLog
420
-
421
-}
422
-
423 604
 func FindPatientPrescriptionInfoTwo(org_id int64, patient_id int64, record_date int64, p_type int64) (info models.HisPrescriptionInfo, err error) {
424 605
 	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND p_type = ? ", org_id, record_date, patient_id, p_type).First(&info).Error
425 606
 	return
426 607
 
427 608
 }
428 609
 
429
-func FindLastPatientPrescriptionInfoTwoTen(org_id int64, patient_id int64, record_date int64) (info models.HisPrescriptionInfo, err error) {
430
-	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date < ? AND patient_id = ?", org_id, record_date, patient_id).Order("record_date desc").First(&info).Error
610
+func GetExecutionFrequencyByName(name string, org_id int64) (ef models.ExecutionFrequencyDic, err error) {
611
+	err = readDb.Model(&models.ExecutionFrequencyDic{}).Where("org_id = ? AND name = ?", org_id, name).First(&ef).Error
431 612
 	return
432 613
 }
433
-
434
-func GetUnSettleHisPrescriptionFive(org_id int64, patient_id int64, record_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
435
-	err = readDb.Model(&models.HisPrescription{}).
436
-		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
437
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
438
-		}).
439
-		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
440
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
441
-		}).
442
-		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
443
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
444
-		}).Preload("TempHisOrder", func(db *gorm.DB) *gorm.DB {
445
-		return db.Where("status = 1 AND user_org_id = ? AND order_status <> 3  AND order_status <> 2  ", org_id)
446
-	}).
447
-		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND order_status <> 3 and order_status <> 5  AND p_type = ?", org_id, record_date, patient_id, p_type).
448
-		Find(&prescription).Error
449
-	return
614
+func UpdataHisPateintTwo(his *models.VMHisPatient) {
615
+	writeDb.Save(&his)
450 616
 }
451 617
 
452
-func UpdataHisPateintTwoTen(his *models.VMHisPatient) {
618
+func UpdataHisPateintThree(his *models.HisPatient) {
453 619
 	writeDb.Save(&his)
454 620
 }
455 621
 
456
-func UpDateHisPrescriptionInfoNumberTen(user_org_id int64, id int64, number string, record_time int64, his_patient_id int64) (err error) {
622
+func UpDateHisPrescriptionInfoNumbertwo(user_org_id int64, id int64, number string, record_time int64, his_patient_id int64) (err error) {
457 623
 	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND his_patient_id = ? AND record_date = ?", user_org_id, his_patient_id, record_time).Updates(map[string]interface{}{"batch_number": number, "prescription_status": 3, "mtime": time.Now().Unix()}).Error
458 624
 
459 625
 	return
460 626
 }
461 627
 
462
-func UpdataOrderStatusThreeTen(number string, user_org_id int64) (err error) {
628
+func UpdataOrderStatusThreef(number string, user_org_id int64) (err error) {
463 629
 	err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 5, "mtime": time.Now().Unix()}).Error
464 630
 	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 5, "mtime": time.Now().Unix()}).Error
465 631
 	return
466 632
 }
467 633
 
468
-func GetExecutionFrequencyByName(name string, org_id int64) (ef models.ExecutionFrequencyDic, err error) {
469
-	err = readDb.Model(&models.ExecutionFrequencyDic{}).Where("(org_id = ? OR org_id = 0) AND name = ?", org_id, name).First(&ef).Error
634
+func UpdataOrderStatustwo(id int64, number string, user_org_id int64) (err error) {
635
+	err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, user_org_id).Updates(map[string]interface{}{"order_status": 3, "mtime": time.Now().Unix(), "status": 0}).Error
636
+	err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 1, "mtime": time.Now().Unix()}).Error
637
+	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 1, "mtime": time.Now().Unix()}).Error
470 638
 	return
471 639
 }
472 640
 
473
-func GetWayInfoByName(name string, org_id int64) (ef models.HisProject, err error) {
474
-	err = readDb.Model(&models.HisProject{}).Where("user_org_id = ? AND project_name = ? AND status= 1 AND cost_classify = 100", org_id, name).First(&ef).Error
475
-	return
641
+func GetHisPatientByIdThree(id int64) (models.HisPatient, error) {
642
+	patient := models.HisPatient{}
643
+	err := XTReadDB().Model(&patient).Where("id = ? and status = 1", id).First(&patient).Error
644
+	return patient, err
476 645
 }

+ 17 - 16
service/gdyb_service.go Целия файл

@@ -3698,6 +3698,7 @@ func setSignature(timestamp int64, nonce string, secret_key string) string {
3698 3698
 	fmt.Println(nonce)
3699 3699
 	fmt.Println(secret_key)
3700 3700
 	fmt.Println(strconv.FormatInt(timestamp, 10))
3701
+	fmt.Println(time.Now().UnixNano() / 1e6)
3701 3702
 
3702 3703
 	str := strconv.FormatInt(timestamp, 10) + secret_key + nonce + strconv.FormatInt(timestamp, 10)
3703 3704
 	hash := sha256.New()
@@ -4960,20 +4961,20 @@ func Gdyb3261(org_name string, doctor string, fixmedins_code string, insuplc_adm
4960 4961
 			}
4961 4962
 
4962 4963
 		}
4963
-		for _, item := range result3260.Output.Data[start-1 : stop] {
4964
-			if item.MdtrtId == "out20230418732788" {
4965
-				feedetailInfo := make(map[string]interface{})
4966
-				feedetailInfo["certno"] = item.Certno
4967
-				feedetailInfo["mdtrt_id"] = item.MdtrtId                  // 就诊 ID(来自2201接口返回)
4968
-				feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime     // 人员编号 (来自1101接口返回)
4969
-				feedetailInfo["setl_sn"] = item.SetlSn                    // 收费批次号
4970
-				feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt        // 病种编码
4971
-				feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
4972
-				feedetailInfo["cnfm_flag"] = "0"                          // 处方号
4973
-				feedetail = append(feedetail, feedetailInfo)
4974
-			}
4975
-
4976
-		}
4964
+		//for _, item := range result3260.Output.Data[start-1 : stop] {
4965
+		//	if item.MdtrtId == "out20230418732788" {
4966
+		//		feedetailInfo := make(map[string]interface{})
4967
+		//		feedetailInfo["certno"] = item.Certno
4968
+		//		feedetailInfo["mdtrt_id"] = item.MdtrtId                  // 就诊 ID(来自2201接口返回)
4969
+		//		feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime     // 人员编号 (来自1101接口返回)
4970
+		//		feedetailInfo["setl_sn"] = item.SetlSn                    // 收费批次号
4971
+		//		feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt        // 病种编码
4972
+		//		feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
4973
+		//		feedetailInfo["cnfm_flag"] = "0"                          // 处方号
4974
+		//		feedetail = append(feedetail, feedetailInfo)
4975
+		//	}
4976
+		//
4977
+		//}
4977 4978
 		//for _, item := range result3260.Output.Data[start-1 : stop] {
4978 4979
 		//	if item.SetlSn == "420100G9000712542625" {
4979 4980
 		//		feedetailInfo := make(map[string]interface{})
@@ -4989,7 +4990,7 @@ func Gdyb3261(org_name string, doctor string, fixmedins_code string, insuplc_adm
4989 4990
 		//
4990 4991
 		//}
4991 4992
 
4992
-		inputData["totalrow"] = 180 // 人员姓名
4993
+		inputData["totalrow"] = 174 // 人员姓名
4993 4994
 
4994 4995
 		// 创建一个新的 Excel 文件
4995 4996
 		//f := excelize.NewFile()
@@ -5081,7 +5082,7 @@ func Gdyb3262(org_name string, doctor string, fixmedins_code string, insuplc_adm
5081 5082
 	inputMessage["infno"] = "3262" // 交易编码
5082 5083
 
5083 5084
 	inputData["trt_year"] = year  // 就诊凭证编号
5084
-	inputData["trt_month"] = "06" // 开始时间
5085
+	inputData["trt_month"] = "07" // 开始时间
5085 5086
 	inputData["otransid"] = "0"   // 开始时间
5086 5087
 
5087 5088
 	input["data"] = inputData

+ 9 - 4
service/his_service.go Целия файл

@@ -1485,7 +1485,7 @@ func GetAllHisOrderTwo(org_id int64) (his []*models.HisOrder, err error) {
1485 1485
 }
1486 1486
 
1487 1487
 func GetAllHisOrder10106(org_id int64) (his []*models.HisOrder, err error) {
1488
-	err = readDb.Model(&models.HisOrder{}).Where("user_org_id = 10106  AND status = 1  AND  order_status = 2 AND setl_id <> ''  AND med_type = '14' AND setl_time >= '2023-06-01 00:00:00' AND setl_time <= '2023-06-30 23:59:00'").Order("setl_time asc").Find(&his).Error
1488
+	err = readDb.Model(&models.HisOrder{}).Where("user_org_id = 10106  AND status = 1  AND  order_status = 2 AND setl_id <> ''  AND med_type = '14' AND setl_time >= '2023-07-01 00:00:00' AND setl_time <= '2023-07-31 23:59:00'").Order("setl_time asc").Find(&his).Error
1489 1489
 	fmt.Println(err)
1490 1490
 	return
1491 1491
 }
@@ -1592,13 +1592,18 @@ func GetHisPrescriptionForMedType(org_id int64, patient_id int64, record_date in
1592 1592
 	return
1593 1593
 }
1594 1594
 
1595
-func GetOrderByTimeTen(start_time string, end_time string, org_id int64) (orders []models.FixMonRecDetailFileIn, err error) {
1596
-	err = readDb.Raw("SELECT CONCAT(insutype, '99', med_type, '555555') AS fund_key, insutype, '99' as `psn_type` , `med_type`, COUNT(DISTINCT `certno`) AS psn_cnt, count(*) as psn_time, sum(medfee_sumamt) as sumamt, sum(inscp_scp_amt) as amt, sum(fund_pay_sumamt) as fund FROM his_order where user_org_id = ? and status = 1 and order_status = 2 and setl_time >= ? and setl_time <= ? GROUP BY fund_key", org_id, start_time+" 00:00:00", end_time+" 23:00:00").Scan(&orders).Error
1595
+func GetOrderByTimeTen(start_time string, end_time string, org_id int64) (orders []*models.FixMonRecDetailFileIn, err error) {
1596
+	err = readDb.Raw("select CASE WHEN p.`insuplc_admdvs` LIKE '%3209%' THEN CONCAT(his_order.insutype, '99', his_order.med_type, '555555')  ELSE CONCAT(his_order.insutype, '99', his_order.med_type, '888888') END AS fund_key, his_order.insutype, '99' as `psn_type` , his_order.`med_type`, COUNT(DISTINCT his_order.`certno`) AS psn_cnt, count(*) as psn_time, sum(his_order.medfee_sumamt) as sumamt, sum(his_order.inscp_scp_amt) as amt, sum(his_order.fund_pay_sumamt) + sum(his_order.acct_pay)  as fund FROM his_order join his_patient p on p.number =  his_order.mdtrt_id where his_order.user_org_id = ? and his_order.status = 1 and his_order.order_status = 2 and his_order.setl_time >= ? and his_order.setl_time <= ? and his_order.setl_id <> '' GROUP BY fund_key", org_id, start_time+" 00:00:00", end_time+" 23:00:00").Scan(&orders).Error
1597
+	return
1598
+}
1599
+
1600
+func GetOrderByTimeTentwo(start_time string, end_time string, org_id int64) (orders []*models.FixMonRecDetailFileIn, err error) {
1601
+	err = readDb.Raw("select CASE WHEN p.`insuplc_admdvs` LIKE '%3209%' THEN CONCAT(his_order.insutype, '99', his_order.med_type, '555555')  ELSE CONCAT(his_order.insutype, '99', his_order.med_type, '888888') END AS fund_key, his_order.insutype, '99' as `psn_type` , his_order.`med_type`, COUNT(DISTINCT his_order.`certno`) AS psn_cnt, count(*) as psn_time, sum(his_order.medfee_sumamt) as sumamt, sum(his_order.inscp_scp_amt) as amt, sum(his_order.fund_pay_sumamt) + sum(his_order.acct_pay)  as fund FROM his_order join his_patient p on p.number =  his_order.mdtrt_id where his_order.user_org_id = ? and his_order.status = 0 and his_order.order_status = 3 and his_order.setl_time >= ? and his_order.setl_time <= ? and his_order.setl_id <> '' GROUP BY fund_key", org_id, start_time+" 00:00:00", end_time+" 23:00:00").Scan(&orders).Error
1597 1602
 	return
1598 1603
 }
1599 1604
 
1600 1605
 func GetOrderDetailByTimeTen(start_time string, end_time string, org_id int64, fund_key string) (fund []models.FundDetail, err error) {
1601
-	err = readDb.Raw("SELECT CONCAT(insutype, '99', med_type, '555555') as fund_key,  `setl_detail`  FROM his_order where user_org_id = ? and status = 1 and order_status = 2 and setl_time >= ? and setl_time <= ?  and CONCAT(insutype, '99', med_type, '555555')  = ?", org_id, start_time+" 00:00:00", end_time+" 23:59:00", fund_key).Scan(&fund).Error
1606
+	err = readDb.Raw("SELECT CASE WHEN p.`insuplc_admdvs` LIKE '%3209%' THEN CONCAT(his_order.insutype, '99', his_order.med_type, '555555')  ELSE CONCAT(his_order.insutype, '99', his_order.med_type, '888888') end AS fund_key, his_order.`setl_detail`  FROM his_order  join his_patient p on p.number =  his_order.mdtrt_id   where his_order.user_org_id = ? and his_order.status = 1 and his_order.order_status = 2 and his_order.setl_time >= ? and his_order.setl_time <= ?  and CONCAT(his_order.insutype, '99', his_order.med_type, '555555')  = ?", org_id, start_time+" 00:00:00", end_time+" 23:59:00", fund_key).Scan(&fund).Error
1602 1607
 	return
1603 1608
 }
1604 1609
 

+ 2 - 4
service/jsyb_service.go Целия файл

@@ -2079,8 +2079,8 @@ func Jxyb3262(setl_mon, org_name string, doctor string, fixmedins_code string, i
2079 2079
 		fixMonRecDetailFileIn["insutype"] = item.Insutype
2080 2080
 		fixMonRecDetailFileIn["psn_type"] = item.PsnType
2081 2081
 		fixMonRecDetailFileIn["med_type"] = item.MedType
2082
-		fixMonRecDetailFileIn["fix_blng_admdvs"] = mdtrtarea_admvs
2083
-		fixMonRecDetailFileIn["insu_admdvs"] = insuplc_admdvs
2082
+		fixMonRecDetailFileIn["fix_blng_admdvs"] = item.FixBlngAdmdvs
2083
+		fixMonRecDetailFileIn["insu_admdvs"] = item.InsuAdmdvs
2084 2084
 		fixMonRecDetailFileIn["psn_time"] = item.PsnTime
2085 2085
 		fixMonRecDetailFileIn["psn_cnt"] = item.PsnCnt
2086 2086
 		fixMonRecDetailFileIn["medfee_sumamt"] = item.MedfeeSumAmt
@@ -2094,8 +2094,6 @@ func Jxyb3262(setl_mon, org_name string, doctor string, fixmedins_code string, i
2094 2094
 		fund["fund_key"] = item.FundKey
2095 2095
 		fund["fix_blng_admdvs"] = item.FixBlngAdmdvs
2096 2096
 		fund["insu_admdvs"] = item.InsuAdmdvs
2097
-		fund["fix_blng_admdvs"] = item.FixBlngAdmdvs
2098
-		fund["insu_admdvs"] = item.InsuAdmdvs
2099 2097
 		fund["fund_code"] = item.FundCode
2100 2098
 		fund["fund_name"] = item.FundName
2101 2099
 		fund["fund_amt"] = item.FundAmt

+ 207 - 77
service/jx_service.go Целия файл

@@ -1012,6 +1012,53 @@ func Jxyb5203(baseParams models.BaseParams, businessParams models.BusinessParams
1012 1012
 
1013 1013
 	return JXHttpRequest(baseParams.RequestUrl, baseParams.AccessKey, baseParams.SecretKey, timestamp, string(bytesData), "5203"), string(bytesData)
1014 1014
 }
1015
+func Jxyb5202(baseParams models.BaseParams, businessParams models.BusinessParams) (string, string) {
1016
+	timestamp := time.Now().Unix()
1017
+	// 生成输入报文
1018
+	inputMessage := SetJXInputMessage(timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.Cainfo)
1019
+	input := make(map[string]interface{})
1020
+	inputData := make(map[string]interface{})
1021
+	inputMessage["infno"] = "5202" // 交易编码
1022
+	inputData["psn_no"] = businessParams.PsnNo
1023
+	inputData["mdtrt_id"] = businessParams.MdtrtId
1024
+	input["data"] = inputData
1025
+	inputMessage["input"] = input //交易输入
1026
+	bytesData, err := json.Marshal(inputMessage)
1027
+	fmt.Println(string(bytesData))
1028
+	if err != nil {
1029
+		fmt.Println(err.Error())
1030
+		return err.Error(), ""
1031
+	}
1032
+	baseParams.RequestUrl = baseParams.RequestUrl + "5202"
1033
+	//fmt.Println(JXHttpRequest(baseParams.RequestUrl, baseParams.AccessKey, baseParams.SecretKey, timestamp, string(bytesData)))
1034
+
1035
+	return JXHttpRequest(baseParams.RequestUrl, baseParams.AccessKey, baseParams.SecretKey, timestamp, string(bytesData), "5202"), string(bytesData)
1036
+}
1037
+func Jxyb5201(baseParams models.BaseParams, businessParams models.BusinessParams) (string, string) {
1038
+	timestamp := time.Now().Unix()
1039
+	// 生成输入报文
1040
+	inputMessage := SetJXInputMessage(timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.Cainfo)
1041
+	input := make(map[string]interface{})
1042
+	inputData := make(map[string]interface{})
1043
+	inputMessage["infno"] = "5201" // 交易编码
1044
+	inputData["psn_no"] = businessParams.PsnNo
1045
+	inputData["begntime"] = "2023-06-01"
1046
+	inputData["endtime"] = "2023-07-30"
1047
+	inputData["med_type"] = "21"
1048
+	inputData["mdtrt_id"] = businessParams.MdtrtId
1049
+	input["data"] = inputData
1050
+	inputMessage["input"] = input //交易输入
1051
+	bytesData, err := json.Marshal(inputMessage)
1052
+	fmt.Println(string(bytesData))
1053
+	if err != nil {
1054
+		fmt.Println(err.Error())
1055
+		return err.Error(), ""
1056
+	}
1057
+	baseParams.RequestUrl = baseParams.RequestUrl + "5201"
1058
+	//fmt.Println(JXHttpRequest(baseParams.RequestUrl, baseParams.AccessKey, baseParams.SecretKey, timestamp, string(bytesData)))
1059
+
1060
+	return JXHttpRequest(baseParams.RequestUrl, baseParams.AccessKey, baseParams.SecretKey, timestamp, string(bytesData), "5201"), string(bytesData)
1061
+}
1015 1062
 
1016 1063
 func JxybZY1101(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, request_url string, access_key string, pBusiCardInfo string, id_card_no string, cainfo string) (string, string) {
1017 1064
 	timestamp := time.Now().Unix()
@@ -1142,6 +1189,89 @@ func Jxyb2401(struct2401 Struct2401, secret_key string, org_name string, fixmedi
1142 1189
 	return JXHttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData), "2401"), requestLog
1143 1190
 
1144 1191
 }
1192
+
1193
+func Jxyb2403(struct2401 Struct2401, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, request_url string, cainfo string, access_key string) (string, string) {
1194
+	// 生成签名
1195
+	timestamp := time.Now().Unix()
1196
+	//tempTime := time.Unix(timestamp, 0)
1197
+	//timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
1198
+
1199
+	// 生成输入报文
1200
+	inputMessage := SetJXInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
1201
+	//inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
1202
+	input := make(map[string]interface{})
1203
+	inputData := make(map[string]interface{})
1204
+	inputMessage["infno"] = "2403"           // 交易编码
1205
+	inputData["mdtrt_id"] = struct2401.PsnNo // 人员编号 (来自1101接口返回)
1206
+	inputData["psn_no"] = struct2401.PsnNo   // 人员编号 (来自1101接口返回)
1207
+	inputData["coner_name"] = struct2401
1208
+	inputData["tel"] = ""
1209
+	inputData["begntime"] = struct2401.Begntime             // 开始时间
1210
+	inputData["endtime"] = struct2401.Begntime              // 开始时间
1211
+	inputData["mdtrt_cert_type"] = struct2401.MdtrtCertType // 就诊凭证类型
1212
+	inputData["med_type"] = struct2401.MedType              // 就诊凭证编号
1213
+	inputData["ipt_opt_no"] = struct2401.IptNo              // 住院/门诊号
1214
+
1215
+	inputData["medrcdno"] = ""
1216
+	inputData["atddr_no"] = struct2401.AtddrNo
1217
+	inputData["chfpdr_name"] = struct2401.ChfpdrName
1218
+	inputData["adm_diag_dscr"] = struct2401.AdmDiagDscr
1219
+	inputData["adm_dept_codg"] = struct2401.AdmDeptCodg
1220
+	inputData["adm_dept_name"] = struct2401.AdmDeptName
1221
+	inputData["adm_bed"] = struct2401.AdmBed
1222
+	inputData["dscg_maindiag_code"] = struct2401.DscgMaindiagCode
1223
+	inputData["dscg_maindiag_name"] = struct2401.DscgMaindiagName
1224
+	inputData["main_cond_dscr"] = ""
1225
+	inputData["dise_codg"] = struct2401.DiseCodg
1226
+	inputData["dise_name"] = struct2401.DiseName
1227
+	inputData["oprn_oprt_code"] = ""
1228
+	inputData["oprn_oprt_name"] = ""
1229
+	inputData["fpsc_no"] = ""
1230
+	inputData["matn_type"] = ""
1231
+	inputData["birctrl_type"] = ""
1232
+	inputData["latechb_flag"] = ""
1233
+	inputData["geso_val"] = ""
1234
+	inputData["fetts"] = ""
1235
+	inputData["fetus_cnt"] = ""
1236
+	inputData["pret_flag"] = ""
1237
+	inputData["birctrl_matn_date"] = ""
1238
+	inputData["dise_type_code"] = ""
1239
+	inputData["expContent"] = ""
1240
+
1241
+	inputDataArr := make([]map[string]interface{}, 0)
1242
+	for _, item := range struct2401.Diseinfo {
1243
+		inputDataTwo := make(map[string]interface{})
1244
+		inputDataTwo["mdtrt_id"] = item.PsnNo
1245
+
1246
+		inputDataTwo["psn_no"] = item.PsnNo
1247
+		inputDataTwo["diag_type"] = item.DiagType
1248
+		inputDataTwo["maindiag_flag"] = item.MaindiagFlag
1249
+		inputDataTwo["diag_srt_no"] = item.DiagSrtNo
1250
+		inputDataTwo["diag_code"] = item.DiagCode
1251
+		inputDataTwo["diag_name"] = item.DiagName
1252
+		inputDataTwo["adm_cond"] = ""
1253
+		inputDataTwo["diag_dept"] = item.DiagDept
1254
+		inputDataTwo["dise_dor_no"] = item.DiseDorNo
1255
+		inputDataTwo["dise_dor_name"] = item.DiseDorName
1256
+		inputDataTwo["diag_time"] = item.DiagTime
1257
+		inputDataArr = append(inputDataArr, inputDataTwo)
1258
+	}
1259
+	input["adminfo"] = inputData
1260
+	input["diseinfo"] = inputDataArr
1261
+	inputMessage["input"] = input //交易输入
1262
+
1263
+	bytesData, err := json.Marshal(inputMessage)
1264
+	fmt.Println(string(bytesData))
1265
+	requestLog := string(bytesData)
1266
+	if err != nil {
1267
+		fmt.Println(err.Error())
1268
+		return err.Error(), ""
1269
+	}
1270
+	request_url = request_url + "2403"
1271
+	return JXHttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData), "2403"), requestLog
1272
+
1273
+}
1274
+
1145 1275
 func Jxyb2404(mdtrt_id string, psn_no string, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, request_url string, cainfo string, access_key string) (string, string) {
1146 1276
 	// 生成签名
1147 1277
 	timestamp := time.Now().Unix()
@@ -2075,83 +2205,83 @@ func Jxyb4101(struct4101 Struct4101, params models.PublicParams) (string, string
2075 2205
 	inputData["setl_id"] = struct4101.SetlId   // 结算 ID  必填
2076 2206
 	inputData["psn_no"] = struct4101.PsnNo     // 结算 ID  必填
2077 2207
 
2078
-	inputData["fixmedins_name"] = params.FixmedinsName        // 定点医药机构名称  必填
2079
-	inputData["fixmedins_code"] = params.FixmedinsCode        // 定点医药机构编码  必填
2080
-	inputData["hi_setl_lv"] = ""                              // 医保结算等级
2081
-	inputData["hi_no"] = struct4101.PsnNo                     // 医保编号
2082
-	inputData["medcasno"] = struct4101.PsnNo                  // 病案号  必填
2083
-	inputData["dcla_time"] = year + "-" + month + "-" + day   // 申报时间  必填
2084
-	inputData["psn_name"] = struct4101.PsnName                // 人员姓名  必填
2085
-	inputData["gend"] = struct4101.Gend                       // 性别  必填
2086
-	inputData["brdy"] = struct4101.Brdy                       // 出生日期  必填
2087
-	inputData["age"] = struct4101.Age                         // 年龄  必填
2088
-	inputData["ntly"] = struct4101.Ntly                       // 国籍  必填
2089
-	inputData["nwb_age"] = ""                                 // 年龄  必填
2090
-	inputData["naty"] = struct4101.Naty                       // 民族  必填
2091
-	inputData["patn_cert_type"] = struct4101.PatnCertType     // 患者证件类别  必填
2092
-	inputData["certno"] = struct4101.Certno                   // 证件号码  必填
2093
-	inputData["prfs"] = struct4101.Prfs                       // 职业  必填
2094
-	inputData["curr_addr"] = ""                               // 现住址  必填
2095
-	inputData["emp_name"] = ""                                // 单位名称  必填
2096
-	inputData["emp_addr"] = ""                                // 单位地址  必填
2097
-	inputData["emp_tel"] = ""                                 // 单位电话  必填
2098
-	inputData["poscode"] = ""                                 // 邮编  必填
2099
-	inputData["coner_name"] = struct4101.ConerName            // 联系人姓名  必填
2100
-	inputData["patn_rlts"] = struct4101.PatnRlts              // 与患者关系  必填
2101
-	inputData["coner_addr"] = struct4101.ConerAddr            // 联系人地址  必填
2102
-	inputData["coner_tel"] = struct4101.ConerTel              // 联系人电话  必填
2103
-	inputData["hi_type"] = struct4101.HiType                  // 医保类型  必填
2104
-	inputData["insuplc"] = struct4101.Insuplc                 // 参保地  必填
2105
-	inputData["sp_psn_type"] = ""                             // 特殊人员类型  必填
2106
-	inputData["nwb_adm_type"] = ""                            // 新生儿入院类型  必填
2107
-	inputData["nwb_bir_wt"] = ""                              // 新生儿出生体重  必填
2108
-	inputData["nwb_adm_wt"] = ""                              // 新生儿入院体重  必填
2109
-	inputData["opsp_diag_caty"] = ""                          // 门诊慢特病诊断  必填
2110
-	inputData["opsp_mdtrt_date"] = ""                         // 门诊慢特病就诊日期  必填
2111
-	inputData["ipt_med_type"] = struct4101.IptMedType         // 住院医疗类型  必填
2112
-	inputData["adm_way"] = ""                                 // 入院途径  必填
2113
-	inputData["trt_type"] = ""                                // 治疗类别  必填
2114
-	inputData["adm_time"] = struct4101.AdmTime                // 入院时间  必填
2115
-	inputData["adm_caty"] = struct4101.AdmCaty                // 入院科别  必填
2116
-	inputData["refldept_dept"] = ""                           // 转科科别  必填
2117
-	inputData["dscg_time"] = struct4101.AdmEndTime            // 出院时间  必填
2118
-	inputData["dscg_caty"] = struct4101.AdmCaty               // 出院科别  必填
2119
-	inputData["act_ipt_days"] = ""                            // 实际住院天数  必填
2120
-	inputData["otp_wm_dise"] = ""                             // 门(急) 诊西医诊断  必填
2121
-	inputData["wm_dise_code"] = ""                            // 门(急) 诊中医诊断  必填
2122
-	inputData["otp_tcm_dise"] = ""                            // 西医诊断疾病代码  必填
2123
-	inputData["tcm_dise_code"] = ""                           // 中医诊断代码  必填
2124
-	inputData["oprn_oprt_code_cnt"] = ""                      // 手术操作代码计数  必填
2125
-	inputData["vent_used_dura"] = ""                          // 呼吸机使用时长  必填
2126
-	inputData["pwcry_bfadm_coma_dura"] = ""                   // 颅脑损伤患者入院前昏迷时长  必填
2127
-	inputData["pwcry_afadm_coma_dura"] = ""                   // 颅脑损伤患者入院后昏迷时长  必填
2128
-	inputData["bld_cat"] = ""                                 // 输血品种  必填
2129
-	inputData["bld_amt"] = ""                                 // 输血量  必填
2130
-	inputData["bld_unt"] = ""                                 // 输血计量单位  必填
2131
-	inputData["spga_nurscare_days"] = ""                      // 特级护理天数  必填
2132
-	inputData["lv1_nurscare_days"] = ""                       // 一级护理天数  必填
2133
-	inputData["scd_nurscare_days"] = ""                       // 二级护理天数  必填
2134
-	inputData["lv3_nurscare_days"] = ""                       // 三级护理天数  必填
2135
-	inputData["acp_medins_name"] = ""                         // 拟接收机构名称  必填
2136
-	inputData["acp_optins_code"] = ""                         // 拟接收机构代码  必填
2137
-	inputData["bill_code"] = struct4101.BillCode              // 票据代码  必填
2138
-	inputData["bill_no"] = struct4101.BillNo                  // 票据号码  必填
2139
-	inputData["biz_sn"] = struct4101.BizSn                    // 业务流水号  必填
2140
-	inputData["days_rinp_flag_31"] = ""                       // 出院 31 天内再住院计划标志  必填
2141
-	inputData["days_rinp_pup_31"] = ""                        // 出院 31 天内再住院目的  必填
2142
-	inputData["chfpdr_name"] = ""                             // 主诊医师姓名  必填
2143
-	inputData["chfpdr_code"] = ""                             // 主诊医师代码  必填
2144
-	inputData["setl_begn_date"] = struct4101.SetlBegnDate     // 结算开始日期  必填
2145
-	inputData["setl_end_date"] = struct4101.SetlEndDate       // 结算结束日期  必填
2146
-	inputData["psn_selfpay"] = struct4101.PsnSelfPay          // 个人自付  必填
2147
-	inputData["psn_ownpay"] = struct4101.PsnOwnPay            // 个人自费  必填
2148
-	inputData["acct_pay"] = struct4101.AcctPay                // 个人账户支出  必填
2149
-	inputData["hi_paymtd"] = struct4101.HiPaymtd              // 医保支付方式  必填
2150
-	inputData["hsorg"] = struct4101.Hsorg                     // 医保机构  必填
2151
-	inputData["hsorg_opter"] = struct4101.HsorgOpter          // 医保机构经办人  必填
2152
-	inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门  必填
2153
-	inputData["medins_fill_psn"] = struct4101.MedinsFillPsn   // 医疗机构填报人  必填
2154
-	inputData["psn_cashpay"] = struct4101.PsnCashpay          // 医疗机构填报人  必填
2208
+	inputData["fixmedins_name"] = params.FixmedinsName      // 定点医药机构名称  必填
2209
+	inputData["fixmedins_code"] = params.FixmedinsCode      // 定点医药机构编码  必填
2210
+	inputData["hi_setl_lv"] = ""                            // 医保结算等级
2211
+	inputData["hi_no"] = struct4101.PsnNo                   // 医保编号
2212
+	inputData["medcasno"] = struct4101.PsnNo                // 病案号  必填
2213
+	inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间  必填
2214
+	inputData["psn_name"] = struct4101.PsnName              // 人员姓名  必填
2215
+	inputData["gend"] = struct4101.Gend                     // 性别  必填
2216
+	inputData["brdy"] = struct4101.Brdy                     // 出生日期  必填
2217
+	inputData["age"] = struct4101.Age                       // 年龄  必填
2218
+	inputData["ntly"] = struct4101.Ntly                     // 国籍  必填
2219
+	inputData["nwb_age"] = ""                               // 年龄  必填
2220
+	inputData["naty"] = struct4101.Naty                     // 民族  必填
2221
+	inputData["patn_cert_type"] = struct4101.PatnCertType   // 患者证件类别  必填
2222
+	inputData["certno"] = struct4101.Certno                 // 证件号码  必填
2223
+	inputData["prfs"] = struct4101.Prfs                     // 职业  必填
2224
+	inputData["curr_addr"] = ""                             // 现住址  必填
2225
+	inputData["emp_name"] = ""                              // 单位名称  必填
2226
+	inputData["emp_addr"] = ""                              // 单位地址  必填
2227
+	inputData["emp_tel"] = ""                               // 单位电话  必填
2228
+	inputData["poscode"] = ""                               // 邮编  必填
2229
+	inputData["coner_name"] = struct4101.ConerName          // 联系人姓名  必填
2230
+	inputData["patn_rlts"] = struct4101.PatnRlts            // 与患者关系  必填
2231
+	inputData["coner_addr"] = struct4101.ConerAddr          // 联系人地址  必填
2232
+	inputData["coner_tel"] = struct4101.ConerTel            // 联系人电话  必填
2233
+	inputData["hi_type"] = struct4101.HiType                // 医保类型  必填
2234
+	inputData["insuplc"] = struct4101.Insuplc               // 参保地  必填
2235
+	inputData["sp_psn_type"] = ""                           // 特殊人员类型  必填
2236
+	inputData["nwb_adm_type"] = ""                          // 新生儿入院类型  必填
2237
+	inputData["nwb_bir_wt"] = ""                            // 新生儿出生体重  必填
2238
+	inputData["nwb_adm_wt"] = ""                            // 新生儿入院体重  必填
2239
+	inputData["opsp_diag_caty"] = ""                        // 门诊慢特病诊断  必填
2240
+	inputData["opsp_mdtrt_date"] = ""                       // 门诊慢特病就诊日期  必填
2241
+	inputData["ipt_med_type"] = struct4101.IptMedType       // 住院医疗类型  必填
2242
+	inputData["adm_way"] = ""                               // 入院途径  必填
2243
+	inputData["trt_type"] = ""                              // 治疗类别  必填
2244
+	inputData["adm_time"] = struct4101.AdmTime              // 入院时间  必填
2245
+	inputData["adm_caty"] = struct4101.AdmCaty              // 入院科别  必填
2246
+	inputData["refldept_dept"] = ""                         // 转科科别  必填
2247
+	inputData["dscg_time"] = struct4101.AdmEndTime          // 出院时间  必填
2248
+	inputData["dscg_caty"] = struct4101.AdmCaty             // 出院科别  必填
2249
+	inputData["act_ipt_days"] = ""                          // 实际住院天数  必填
2250
+	inputData["otp_wm_dise"] = ""                           // 门(急) 诊西医诊断  必填
2251
+	inputData["wm_dise_code"] = ""                          // 门(急) 诊中医诊断  必填
2252
+	inputData["otp_tcm_dise"] = ""                          // 西医诊断疾病代码  必填
2253
+	inputData["tcm_dise_code"] = ""                         // 中医诊断代码  必填
2254
+	inputData["oprn_oprt_code_cnt"] = ""                    // 手术操作代码计数  必填
2255
+	inputData["vent_used_dura"] = ""                        // 呼吸机使用时长  必填
2256
+	inputData["pwcry_bfadm_coma_dura"] = ""                 // 颅脑损伤患者入院前昏迷时长  必填
2257
+	inputData["pwcry_afadm_coma_dura"] = ""                 // 颅脑损伤患者入院后昏迷时长  必填
2258
+	inputData["bld_cat"] = ""                               // 输血品种  必填
2259
+	inputData["bld_amt"] = ""                               // 输血量  必填
2260
+	inputData["bld_unt"] = ""                               // 输血计量单位  必填
2261
+	inputData["spga_nurscare_days"] = ""                    // 特级护理天数  必填
2262
+	inputData["lv1_nurscare_days"] = ""                     // 一级护理天数  必填
2263
+	inputData["scd_nurscare_days"] = ""                     // 二级护理天数  必填
2264
+	inputData["lv3_nurscare_days"] = ""                     // 三级护理天数  必填
2265
+	inputData["acp_medins_name"] = ""                       // 拟接收机构名称  必填
2266
+	inputData["acp_optins_code"] = ""                       // 拟接收机构代码  必填
2267
+	inputData["bill_code"] = struct4101.BillCode            // 票据代码  必填
2268
+	inputData["bill_no"] = struct4101.BillNo                // 票据号码  必填
2269
+	inputData["biz_sn"] = struct4101.BizSn                  // 业务流水号  必填
2270
+	inputData["days_rinp_flag_31"] = ""                     // 出院 31 天内再住院计划标志  必填
2271
+	inputData["days_rinp_pup_31"] = ""                      // 出院 31 天内再住院目的  必填
2272
+	inputData["chfpdr_name"] = ""                           // 主诊医师姓名  必填
2273
+	inputData["chfpdr_code"] = ""                           // 主诊医师代码  必填
2274
+	inputData["setl_begn_date"] = struct4101.SetlBegnDate   // 结算开始日期  必填
2275
+	inputData["setl_end_date"] = struct4101.SetlEndDate     // 结算结束日期  必填
2276
+	inputData["psn_selfpay"] = struct4101.PsnSelfPay        // 个人自付  必填
2277
+	inputData["psn_ownpay"] = struct4101.PsnOwnPay          // 个人自费  必填
2278
+	inputData["acct_pay"] = struct4101.AcctPay              // 个人账户支出  必填
2279
+	inputData["hi_paymtd"] = struct4101.HiPaymtd            // 医保支付方式  必填
2280
+	inputData["hsorg"] = params.FixmedinsName               // 医保机构  必填
2281
+	inputData["hsorg_opter"] = struct4101.HsorgOpter        // 医保机构经办人  必填
2282
+	inputData["medins_fill_dept"] = params.FixmedinsName    // 医疗机构填报部门  必填
2283
+	inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人  必填
2284
+	inputData["psn_cashpay"] = struct4101.PsnCashpay        // 医疗机构填报人  必填
2155 2285
 
2156 2286
 	payinfo := make([]map[string]interface{}, 0) // 基金支付信息
2157 2287
 	for _, item := range struct4101.CustomStruct {

+ 216 - 37
service/nm_service.go Целия файл

@@ -5,14 +5,16 @@ import (
5 5
 	"encoding/json"
6 6
 	"fmt"
7 7
 	"gdyb/models"
8
+	"github.com/astaxie/beego"
8 9
 	"io/ioutil"
9 10
 	"net/http"
10 11
 	"strconv"
12
+	"strings"
11 13
 	"time"
12 14
 )
13 15
 
14 16
 // 门诊挂号
15
-func Nmyb2201(psnNo string, insutype string, certNo string, org_name string, opera string, ipt_otp_no string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, doctor_name string, request_url string, verify_number string, cainfo string) (string, string) {
17
+func Nmyb2201(psnNo string, insutype string, certNo string, org_name string, opera string, ipt_otp_no string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, doctor_name string, verify_number string, cainfo string) (string, string) {
16 18
 	// 生成签名
17 19
 	// 生成签名
18 20
 	nonce := GetRandomString(32)
@@ -20,9 +22,9 @@ func Nmyb2201(psnNo string, insutype string, certNo string, org_name string, ope
20 22
 	signature := setSignature(timestamp, nonce, secret_key)
21 23
 	tempTime := time.Unix(timestamp, 0)
22 24
 	timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
23
-
25
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
24 26
 	// 生成输入报文
25
-	inputMessage := SetJSInputMessage(timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
27
+	//inputMessage := SetInputMessage(timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
26 28
 	input := make(map[string]interface{})
27 29
 	inputData := make(map[string]interface{})
28 30
 	inputMessage["infno"] = "2201"        // 交易编码
@@ -31,8 +33,8 @@ func Nmyb2201(psnNo string, insutype string, certNo string, org_name string, ope
31 33
 	inputData["begntime"] = timeFormatOne // 开始时间
32 34
 
33 35
 	if id_card_type == 1 {
34
-		inputData["mdtrt_cert_type"] = "03"                       // 就诊凭证类型
35
-		inputData["mdtrt_cert_no"] = certNo + "|" + verify_number // 就诊凭证编号
36
+		inputData["mdtrt_cert_type"] = "03"        // 就诊凭证类型
37
+		inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
36 38
 	} else if id_card_type == 3 {
37 39
 		inputData["mdtrt_cert_type"] = "04"        // 就诊凭证类型
38 40
 		inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
@@ -40,8 +42,8 @@ func Nmyb2201(psnNo string, insutype string, certNo string, org_name string, ope
40 42
 		inputData["mdtrt_cert_type"] = "01"        // 就诊凭证类型
41 43
 		inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
42 44
 	} else {
43
-		inputData["mdtrt_cert_type"] = "02"        // 就诊凭证类型
44
-		inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
45
+		inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
46
+		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
45 47
 
46 48
 	}
47 49
 
@@ -68,9 +70,8 @@ func Nmyb2201(psnNo string, insutype string, certNo string, org_name string, ope
68 70
 
69 71
 	gdyb_url := beego.AppConfig.String("gdyb_url")
70 72
 	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
71
-	request_url = gdyb_url
72 73
 
73
-	request, err := http.NewRequest("POST", request_url, reader)
74
+	request, err := http.NewRequest("POST", gdyb_url, reader)
74 75
 	if err != nil {
75 76
 		fmt.Println(err.Error())
76 77
 		return err.Error(), ""
@@ -108,7 +109,9 @@ func Nmyb2202(psnNo string, mdtrtId string, ipt_otp_no string, org_name string,
108 109
 	signature := setSignature(timestamp, nonce, secret_key)
109 110
 
110 111
 	// 生成输入报文
111
-	inputMessage := SetJSInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
112
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
113
+
114
+	//inputMessage := SetInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
112 115
 	input := make(map[string]interface{})
113 116
 	inputData := make(map[string]interface{})
114 117
 	inputMessage["infno"] = "2202"       // 交易编码
@@ -255,10 +258,104 @@ func Nmyb2203(psnNo string, mdtrtId string, doctor string, department string, or
255 258
 	fmt.Println(str)
256 259
 	return str, requestLog
257 260
 
261
+}
262
+func Nmyb2203C(psnNo string, mdtrtId string, doctor string, department string, org_name string, med_type string, doctor_id string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_code string, sick_name string, dept string, config []*models.HisXtDiagnoseConfig, begin_time string, cainfo string) (string, string) {
263
+	// 生成签名
264
+	// 生成签名
265
+	nonce := GetRandomString(32)
266
+	timestamp := time.Now().Unix()
267
+	signature := setSignature(timestamp, nonce, secret_key)
268
+	//tempTime := time.Unix(timestamp, 0)
269
+	//timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
270
+	// 生成输入报文
271
+
272
+	tempTime := time.Unix(timestamp, 0)
273
+	timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
274
+	// 生成输入报文
275
+	inputMessage := SetJSInputMessage(timestamp, org_name, dept, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
276
+	input := make(map[string]interface{})
277
+	inputData := make(map[string]interface{})
278
+	diseinfo := make([]map[string]interface{}, 0)
279
+
280
+	if med_type == "1111" || med_type == "1112" {
281
+		med_type = "11"
282
+	}
283
+
284
+	inputMessage["infno"] = "2203A"     // 交易编码
285
+	inputData["mdtrt_id"] = mdtrtId     // 就诊 ID(来自2201接口返回)
286
+	inputData["psn_no"] = psnNo         // 人员编号 (来自1101接口返回)
287
+	inputData["med_type"] = med_type    // 医疗类别 16门诊特殊病
288
+	inputData["begntime"] = begin_time  // 开始时间
289
+	inputData["main_cond_dscr"] = ""    // 主要病情描述
290
+	inputData["dise_codg"] = sick_code  // 病种编码
291
+	inputData["dise_name"] = sick_name  // 病种名称
292
+	inputData["birctrl_type"] = ""      // 计划生育手术类别
293
+	inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
294
+
295
+	for index, item := range config {
296
+		diseinfo_sun := make(map[string]interface{})
297
+		diseinfo_sun["diag_type"] = "1"              // 诊断类别
298
+		diseinfo_sun["diag_srt_no"] = index          // 诊断排序号
299
+		diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
300
+		diseinfo_sun["diag_name"] = item.ClassName   // 诊断名称
301
+		diseinfo_sun["diag_dept"] = department       // 诊断科室
302
+		diseinfo_sun["dise_dor_no"] = doctor_id      // 诊断医生编码
303
+		diseinfo_sun["dise_dor_name"] = doctor       // 诊断医生姓名
304
+		diseinfo_sun["diag_time"] = timeFormatOne    // 诊断时间
305
+		diseinfo_sun["vali_flag"] = "0"              // 有效标志
306
+		diseinfo = append(diseinfo, diseinfo_sun)
307
+	}
308
+	//inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
309
+	inputData["exp_content"] = "" //
310
+
311
+	input["diseinfo"] = diseinfo
312
+	input["mdtrtinfo"] = inputData
313
+	inputMessage["input"] = input //交易输入
314
+	var requestLog string
315
+	bytesData, err := json.Marshal(inputMessage)
316
+	fmt.Println(string(bytesData))
317
+	requestLog = string(bytesData)
318
+	if err != nil {
319
+		fmt.Println(err.Error())
320
+		return err.Error(), ""
321
+	}
322
+	reader := bytes.NewReader(bytesData)
323
+
324
+	gdyb_url := beego.AppConfig.String("gdyb_url")
325
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
326
+
327
+	request, err := http.NewRequest("POST", gdyb_url, reader)
328
+	if err != nil {
329
+		fmt.Println(err.Error())
330
+		return err.Error(), ""
331
+	}
332
+
333
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
334
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
335
+	request.Header.Set("x-tif-signature", signature)
336
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
337
+	request.Header.Set("x-tif-nonce", nonce)
338
+
339
+	client := http.Client{}
340
+	resp, err := client.Do(request)
341
+	if err != nil {
342
+		fmt.Println(err.Error())
343
+		return err.Error(), ""
344
+	}
345
+	respBytes, err := ioutil.ReadAll(resp.Body)
346
+	if err != nil {
347
+		fmt.Println(err.Error())
348
+		return err.Error(), ""
349
+	}
350
+	str := string(respBytes)
351
+	fmt.Println(str)
352
+	return str, requestLog
353
+
258 354
 }
259 355
 
260 356
 // 门诊费用明细信息上传
261 357
 func Nmyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescription, chrg_bchno string, org_name string, doctor string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, balance_accounts_type string, diag_code string, request_url string, access_key string, new_doctor_name string, time_stamp_2203 string, cainfo string) (string, string) {
358
+
262 359
 	// 生成签名
263 360
 	timestamp := time.Now().Unix()
264 361
 	// 生成签名
@@ -394,23 +491,12 @@ func Nmyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescri
394 491
 		feedetailInfo["bilg_dept_codg"] = dept_code                  // 开单科室编码
395 492
 		feedetailInfo["bilg_dept_name"] = dept                       // 开单科室名称
396 493
 
397
-		if fixmedins_code == "H32092103007" {
398
-			feedetailInfo["bilg_dr_codg"] = "D320923012139"   // 开单医生编码
399
-			feedetailInfo["bilg_dr_name"] = "王曙光"             // 开单医师姓名
400
-			feedetailInfo["acord_dept_codg"] = ""             // 受单科室编码
401
-			feedetailInfo["acord_dept_name"] = ""             // 受单科室名称
402
-			feedetailInfo["orders_dr_code"] = "D320923012139" // 受单医生编码
403
-			feedetailInfo["orders_dr_name"] = "王曙光"           // 受单医生姓名
404
-
405
-		} else {
406
-			feedetailInfo["bilg_dr_codg"] = "D371621008686"   // 开单医生编码
407
-			feedetailInfo["bilg_dr_name"] = "王云刚"             // 开单医师姓名
408
-			feedetailInfo["acord_dept_codg"] = ""             // 受单科室编码
409
-			feedetailInfo["acord_dept_name"] = ""             // 受单科室名称
410
-			feedetailInfo["orders_dr_code"] = "D371621008686" // 受单医生编码
411
-			feedetailInfo["orders_dr_name"] = "王云刚"           // 受单医生姓名
412
-
413
-		}
494
+		feedetailInfo["bilg_dr_codg"] = doctor_id         // 开单医生编码
495
+		feedetailInfo["bilg_dr_name"] = new_doctor_name   // 开单医师姓名
496
+		feedetailInfo["acord_dept_codg"] = dept_code      // 受单科室编码
497
+		feedetailInfo["acord_dept_name"] = dept           // 受单科室名称
498
+		feedetailInfo["orders_dr_code"] = doctor_id       // 受单医生编码
499
+		feedetailInfo["orders_dr_name"] = new_doctor_name // 受单医生姓名
414 500
 
415 501
 		if balance_accounts_type == "8" {
416 502
 			feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
@@ -553,7 +639,10 @@ func Nmyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, d
553 639
 
554 640
 // 门诊预结算
555 641
 func Nmyb2206(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, request_url string, access_key string, verify_number string, cainfo string, mdtrt_grp_type string) (string, string) {
642
+	if !strings.Contains(insuplc_admdvs, "150") {
556 643
 
644
+		chrgBchno = "0000"
645
+	}
557 646
 	// 生成签名
558 647
 	nonce := GetRandomString(32)
559 648
 	timestamp := time.Now().Unix()
@@ -571,8 +660,8 @@ func Nmyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
571 660
 		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
572 661
 	} else {
573 662
 		if id_card_type == 1 {
574
-			inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
575
-			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
663
+			inputData["mdtrt_cert_type"] = "03"        // 就诊凭证类型
664
+			inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
576 665
 		} else if id_card_type == 3 {
577 666
 			inputData["mdtrt_cert_type"] = "04"        // 就诊凭证类型
578 667
 			inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
@@ -580,8 +669,8 @@ func Nmyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
580 669
 			inputData["mdtrt_cert_type"] = "01"        // 就诊凭证类型
581 670
 			inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
582 671
 		} else {
583
-			inputData["mdtrt_cert_type"] = "01"        // 就诊凭证类型
584
-			inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
672
+			inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
673
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
585 674
 		}
586 675
 	}
587 676
 	if insuplc_admdvs == "421300" {
@@ -654,6 +743,10 @@ func Nmyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
654 743
 
655 744
 // 门诊结算
656 745
 func Nmyb2207(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, request_url string, access_key string, verify_number string, cainfo string, mdtrt_grp_type string) (string, string) {
746
+	if !strings.Contains(insuplc_admdvs, "150") {
747
+
748
+		chrgBchno = "0000"
749
+	}
657 750
 	// 生成签名
658 751
 	nonce := GetRandomString(32)
659 752
 	timestamp := time.Now().Unix()
@@ -665,12 +758,12 @@ func Nmyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
665 758
 	inputData["psn_no"] = psnNo    // 人员编号 (来自1101接口返回)
666 759
 
667 760
 	if certificates == 3 {
668
-		inputData["mdtrt_cert_type"] = "99"                       // 就诊凭证类型
669
-		inputData["mdtrt_cert_no"] = certNo + "|" + verify_number // 就诊凭证编号
761
+		inputData["mdtrt_cert_type"] = "99"        // 就诊凭证类型
762
+		inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
670 763
 	} else {
671 764
 		if id_card_type == 1 {
672
-			inputData["mdtrt_cert_type"] = "03"                       // 就诊凭证类型
673
-			inputData["mdtrt_cert_no"] = certNo + "|" + verify_number // 就诊凭证编号
765
+			inputData["mdtrt_cert_type"] = "03"        // 就诊凭证类型
766
+			inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
674 767
 		} else if id_card_type == 3 {
675 768
 			inputData["mdtrt_cert_type"] = "04"        // 就诊凭证类型
676 769
 			inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
@@ -678,7 +771,8 @@ func Nmyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
678 771
 			inputData["mdtrt_cert_type"] = "01"        // 就诊凭证类型
679 772
 			inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
680 773
 		} else {
681
-
774
+			inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
775
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
682 776
 		}
683 777
 	}
684 778
 	if med_type == "1111" || med_type == "1112" {
@@ -699,7 +793,7 @@ func Nmyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
699 793
 	inputData["chrg_bchno"] = chrgBchno          // 收费批次号(来自2204生成的)
700 794
 	inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
701 795
 	inputData["insutype"] = insutype             // 险种类型
702
-	inputData["invono"] = ""                     // 发票号
796
+	inputData["invono"] = "12345"                // 发票号
703 797
 
704 798
 	inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
705 799
 	inputData["overlmt_selfpay"] = overlmt_selfpay     //
@@ -816,3 +910,88 @@ func Nmyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doct
816 910
 	str2 := string(mjson)
817 911
 	return str, str2
818 912
 }
913
+
914
+func Nmyb2503(psnNo string, insutype string, org_name string, op string, doctor string, fixmedins_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_name string, sick_code string, start_time string, end_time string, check_time string, hospital_code string, hospital_name string) string {
915
+	// 生成签名
916
+	nonce := GetRandomString(32)
917
+	timestamp := time.Now().Unix()
918
+	signature := setSignature(timestamp, nonce, secret_key)
919
+	//tempTime := time.Unix(timestamp, 0)
920
+	//timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
921
+
922
+	//timeFormatTwo := tempTime.Format("2006-01-02")
923
+
924
+	//t := time.Now()
925
+	//last := time.Date(t.Year(), time.December, 31, 0, 0, 0, 0, time.UTC)
926
+	//tm := time.Unix(last.Unix(), 0)
927
+
928
+	// 生成输入报文
929
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, op, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
930
+	input := make(map[string]interface{})
931
+	inputData := make(map[string]interface{})
932
+	inputMessage["infno"] = "2503"                  // 交易编码
933
+	inputData["psn_no"] = psnNo                     // 人员编号 (来自1101接口返回)
934
+	inputData["insutype"] = insutype                // 险种类型(来自1101接口返回)
935
+	inputData["opsp_dise_code"] = sick_code         // 险种类型(来自1101接口返回)
936
+	inputData["opsp_dise_name"] = sick_name         // 险种类型(来自1101接口返回)
937
+	inputData["insu_optins"] = insuplc_admdvs       // 险种类型(来自1101接口返回)
938
+	inputData["ide_fixmedins_no"] = hospital_code   // 险种类型(来自1101接口返回)
939
+	inputData["ide_fixmedins_name"] = hospital_name // 险种类型(来自1101接口返回)
940
+	inputData["hosp_ide_date"] = check_time         // 险种类型(来自1101接口返回)
941
+	inputData["diag_dr_codg"] = doctor_id           // 开始时间
942
+	inputData["diag_dr_name"] = doctor              // 开始时间
943
+	inputData["begndate"] = start_time              // 医师编码
944
+	inputData["tel"] = ""                           // 医师编码
945
+	inputData["addr"] = ""                          // 医师编码
946
+	inputData["enddate"] = end_time                 // 医师编码
947
+
948
+	input["data"] = inputData
949
+	inputMessage["input"] = input //交易输入
950
+	bytesData, err := json.Marshal(inputMessage)
951
+	fmt.Println(string(bytesData))
952
+	if err != nil {
953
+		fmt.Println(err.Error())
954
+		return err.Error()
955
+	}
956
+	reader := bytes.NewReader(bytesData)
957
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
958
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503"
959
+	gdyb_url := beego.AppConfig.String("gdyb_url")
960
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
961
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
962
+	//url := gdyb_url + "2503"
963
+
964
+	var url string
965
+	if fixmedins_code == "H15049901371" {
966
+		url = gdyb_url
967
+	} else {
968
+		url = gdyb_url + "2503"
969
+	}
970
+
971
+	request, err := http.NewRequest("POST", url, reader)
972
+	if err != nil {
973
+		fmt.Println(err.Error())
974
+		return err.Error()
975
+	}
976
+
977
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
978
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
979
+	request.Header.Set("x-tif-signature", signature)
980
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
981
+	request.Header.Set("x-tif-nonce", nonce)
982
+
983
+	client := http.Client{}
984
+	resp, err := client.Do(request)
985
+	if err != nil {
986
+		fmt.Println(err.Error())
987
+		return err.Error()
988
+	}
989
+	respBytes, err := ioutil.ReadAll(resp.Body)
990
+	if err != nil {
991
+		fmt.Println(err.Error())
992
+		return err.Error()
993
+	}
994
+	str := string(respBytes)
995
+	fmt.Println(str)
996
+	return str
997
+}