csx 4 anni fa
parent
commit
7c3d37f320
2 ha cambiato i file con 108 aggiunte e 1 eliminazioni
  1. 55 1
      controllers/his_api_controller.go
  2. 53 0
      service/gdyb_service.go

+ 55 - 1
controllers/his_api_controller.go Vedi File

@@ -44,6 +44,8 @@ func HisManagerApiRegistRouters() {
44 44
 
45 45
 	beego.Router("/api/code/get", &HisApiController{}, "get:GetCode")
46 46
 
47
+	beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
48
+
47 49
 }
48 50
 
49 51
 func (c *HisApiController) Sscard() {
@@ -938,7 +940,7 @@ func (c *HisApiController) GetUploadInfo() {
938 940
 				mdtrt_id := his.Number
939 941
 				chrg_bchno := chrg_bchno
940 942
 				cert_no := his.Certno
941
-				insutype := "310"
943
+				insutype := rf[0].Insutype
942 944
 				api := "http://127.0.0.1:9532/" + "gdyb/eight?cert_no=" + cert_no + "&insutype=" +
943 945
 					insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
944 946
 					"&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
@@ -1983,6 +1985,58 @@ func (c *HisApiController) GetCode() {
1983 1985
 
1984 1986
 }
1985 1987
 
1988
+func (c *HisApiController) CheckTreatment() {
1989
+
1990
+	patient_id, _ := c.GetInt64("patient_id", 0)
1991
+	record_time := c.GetString("record_time")
1992
+	insutype := c.GetString("insutype")
1993
+
1994
+	timeLayout := "2006-01-02"
1995
+	loc, _ := time.LoadLocation("Local")
1996
+	adminUser := c.GetAdminUserInfo()
1997
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
1998
+	fmt.Println(err)
1999
+	if err != nil {
2000
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2001
+		return
2002
+	}
2003
+	recordDateTime := theTime.Unix()
2004
+	his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
2005
+	patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
2006
+
2007
+	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
2008
+	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
2009
+
2010
+	var user_name string
2011
+	role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
2012
+	if role.ID == 0 {
2013
+		user_name = "xxx"
2014
+	} else {
2015
+		user_name = role.UserName
2016
+	}
2017
+
2018
+	baseParams := models.BaseParams{
2019
+		SecretKey:      miConfig.SecretKey,
2020
+		FixmedinsCode:  miConfig.Code,
2021
+		InsuplcAdmdvs:  miConfig.InsuplcAdmdvs,
2022
+		MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
2023
+		OrgName:        miConfig.OrgName,
2024
+		Doctor:         user_name,
2025
+	}
2026
+
2027
+	if config.IsOpen == 1 {
2028
+		result := service.Gdyb2001(baseParams, his.PsnNo, insutype, strconv.FormatInt(patientPrescription.RegisterType, 10))
2029
+		var dat map[string]interface{}
2030
+		if err := json.Unmarshal([]byte(result), &dat); err == nil {
2031
+			fmt.Println(dat)
2032
+		} else {
2033
+			fmt.Println(err)
2034
+		}
2035
+
2036
+	}
2037
+
2038
+}
2039
+
1986 2040
 func PathExists(path string) (bool, error) {
1987 2041
 	_, err := os.Stat(path)
1988 2042
 	if err == nil {

+ 53 - 0
service/gdyb_service.go Vedi File

@@ -1102,6 +1102,59 @@ func Gdyb3301(baseParams models.BaseParams, name string, codg string) string {
1102 1102
 	return str
1103 1103
 }
1104 1104
 
1105
+func Gdyb2001(baseParams models.BaseParams, psn_no string, insutype string, med_type string) string {
1106
+	// 生成签名
1107
+	nonce := GetRandomString(32)
1108
+	timestamp := time.Now().Unix()
1109
+	signature := setSignature(timestamp, nonce, baseParams.SecretKey)
1110
+
1111
+	// 生成输入报文
1112
+	inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
1113
+	input := make(map[string]interface{})
1114
+	inputData := make(map[string]interface{})
1115
+	inputMessage["infno"] = "2001" // 交易编码
1116
+	inputData["psn_no"] = psn_no
1117
+	inputData["insutype"] = insutype
1118
+	inputData["med_type"] = med_type
1119
+	inputData["begntime"] = "2021-01-01 00:00:00"
1120
+	input["data"] = inputData
1121
+	inputMessage["input"] = input //交易输入
1122
+	bytesData, err := json.Marshal(inputMessage)
1123
+	fmt.Println(string(bytesData))
1124
+	if err != nil {
1125
+		fmt.Println(err.Error())
1126
+		return err.Error()
1127
+	}
1128
+	reader := bytes.NewReader(bytesData)
1129
+	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2001"
1130
+
1131
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
1132
+	request, err := http.NewRequest("POST", url, reader)
1133
+	if err != nil {
1134
+		fmt.Println(err.Error())
1135
+		return err.Error()
1136
+	}
1137
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1138
+	request.Header.Set("x-tif-paasid", "sg03_prd")
1139
+	request.Header.Set("x-tif-signature", signature)
1140
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
1141
+	request.Header.Set("x-tif-nonce", nonce)
1142
+	client := http.Client{}
1143
+	resp, err := client.Do(request)
1144
+	if err != nil {
1145
+		fmt.Println(err.Error())
1146
+		return err.Error()
1147
+	}
1148
+	respBytes, err := ioutil.ReadAll(resp.Body)
1149
+	if err != nil {
1150
+		fmt.Println(err.Error())
1151
+		return err.Error()
1152
+	}
1153
+	str := string(respBytes)
1154
+	fmt.Println(str)
1155
+	return str
1156
+}
1157
+
1105 1158
 //  门诊结算撤销
1106 1159
 //func Gdyb4101(psnNo string, mdtrtId string, setlId string) string {
1107 1160
 //	// 生成签名