nm_service.go 78KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021
  1. package service
  2. import (
  3. "bytes"
  4. "encoding/json"
  5. "fmt"
  6. "gdyb/models"
  7. "github.com/astaxie/beego"
  8. "io/ioutil"
  9. "net/http"
  10. "strconv"
  11. "strings"
  12. "time"
  13. )
  14. // 门诊挂号
  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, verify_number string, cainfo string) (string, string) {
  16. // 生成签名
  17. // 生成签名
  18. nonce := GetRandomString(32)
  19. timestamp := time.Now().Unix()
  20. signature := setSignature(timestamp, nonce, secret_key)
  21. tempTime := time.Unix(timestamp, 0)
  22. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  23. inputMessage := SetInputMessage(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  24. // 生成输入报文
  25. //inputMessage := SetInputMessage(timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  26. input := make(map[string]interface{})
  27. inputData := make(map[string]interface{})
  28. inputMessage["infno"] = "2201" // 交易编码
  29. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  30. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  31. inputData["begntime"] = timeFormatOne // 开始时间
  32. if id_card_type == 1 {
  33. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  34. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  35. } else if id_card_type == 3 {
  36. inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
  37. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  38. } else if id_card_type == 4 {
  39. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  40. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  41. } else {
  42. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  43. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  44. }
  45. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  46. inputData["atddr_no"] = doctor_id // 医师编码
  47. inputData["dr_name"] = doctor_name // 医师姓名
  48. inputData["dept_code"] = dept_code // 科室编码
  49. inputData["dept_name"] = dept // 科室名称
  50. inputData["caty"] = "A03.06" // 科别
  51. inputData["exp_content"] = "" //
  52. input["data"] = inputData
  53. inputMessage["input"] = input //交易输入
  54. var requestLog string
  55. bytesData, err := json.Marshal(inputMessage)
  56. requestLog = string(bytesData)
  57. fmt.Println(string(bytesData))
  58. if err != nil {
  59. fmt.Println(err.Error())
  60. return err.Error(), ""
  61. }
  62. reader := bytes.NewReader(bytesData)
  63. gdyb_url := beego.AppConfig.String("gdyb_url")
  64. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  65. request, err := http.NewRequest("POST", gdyb_url, reader)
  66. if err != nil {
  67. fmt.Println(err.Error())
  68. return err.Error(), ""
  69. }
  70. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  71. request.Header.Set("x-tif-paasid", gdyb_paasid)
  72. request.Header.Set("x-tif-signature", signature)
  73. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  74. request.Header.Set("x-tif-nonce", nonce)
  75. client := http.Client{}
  76. resp, err := client.Do(request)
  77. if err != nil {
  78. fmt.Println(err.Error())
  79. return err.Error(), ""
  80. }
  81. respBytes, err := ioutil.ReadAll(resp.Body)
  82. if err != nil {
  83. fmt.Println(err.Error())
  84. return err.Error(), ""
  85. }
  86. str := string(respBytes)
  87. fmt.Println(str)
  88. return str, requestLog
  89. }
  90. // 门诊挂号撤销
  91. func Nmyb2202(psnNo string, mdtrtId string, ipt_otp_no string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string, cainfo string) (string, string) {
  92. // 生成签名
  93. // 生成签名
  94. nonce := GetRandomString(32)
  95. timestamp := time.Now().Unix()
  96. signature := setSignature(timestamp, nonce, secret_key)
  97. // 生成输入报文
  98. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  99. //inputMessage := SetInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  100. input := make(map[string]interface{})
  101. inputData := make(map[string]interface{})
  102. inputMessage["infno"] = "2202" // 交易编码
  103. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  104. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  105. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  106. inputData["exp_content"] = "" //
  107. input["data"] = inputData
  108. inputMessage["input"] = input //交易输入
  109. var requestLog string
  110. bytesData, err := json.Marshal(inputMessage)
  111. fmt.Println(string(bytesData))
  112. requestLog = string(bytesData)
  113. if err != nil {
  114. fmt.Println(err.Error())
  115. return err.Error(), ""
  116. }
  117. reader := bytes.NewReader(bytesData)
  118. gdyb_url := beego.AppConfig.String("gdyb_url")
  119. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  120. request, err := http.NewRequest("POST", gdyb_url, reader)
  121. if err != nil {
  122. fmt.Println(err.Error())
  123. return err.Error(), ""
  124. }
  125. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  126. request.Header.Set("x-tif-paasid", gdyb_paasid)
  127. request.Header.Set("x-tif-signature", signature)
  128. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  129. request.Header.Set("x-tif-nonce", nonce)
  130. client := http.Client{}
  131. resp, err := client.Do(request)
  132. if err != nil {
  133. fmt.Println(err.Error())
  134. return err.Error(), ""
  135. }
  136. respBytes, err := ioutil.ReadAll(resp.Body)
  137. if err != nil {
  138. fmt.Println(err.Error())
  139. return err.Error(), ""
  140. }
  141. str := string(respBytes)
  142. fmt.Println(str)
  143. return str, requestLog
  144. }
  145. // 门诊就诊信息上传
  146. func Nmyb2203(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) {
  147. // 生成签名
  148. // 生成签名
  149. nonce := GetRandomString(32)
  150. timestamp := time.Now().Unix()
  151. signature := setSignature(timestamp, nonce, secret_key)
  152. //tempTime := time.Unix(timestamp, 0)
  153. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  154. // 生成输入报文
  155. tempTime := time.Unix(timestamp, 0)
  156. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  157. // 生成输入报文
  158. inputMessage := SetJSInputMessage(timestamp, org_name, dept, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  159. input := make(map[string]interface{})
  160. inputData := make(map[string]interface{})
  161. diseinfo := make([]map[string]interface{}, 0)
  162. if med_type == "1111" || med_type == "1112" {
  163. med_type = "11"
  164. }
  165. inputMessage["infno"] = "2203A" // 交易编码
  166. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  167. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  168. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  169. inputData["begntime"] = begin_time // 开始时间
  170. inputData["main_cond_dscr"] = "" // 主要病情描述
  171. inputData["dise_codg"] = sick_code // 病种编码
  172. inputData["dise_name"] = sick_name // 病种名称
  173. inputData["birctrl_type"] = "" // 计划生育手术类别
  174. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  175. for index, item := range config {
  176. diseinfo_sun := make(map[string]interface{})
  177. diseinfo_sun["diag_type"] = "1" // 诊断类别
  178. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  179. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  180. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  181. diseinfo_sun["diag_dept"] = department // 诊断科室
  182. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  183. diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  184. diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  185. diseinfo_sun["vali_flag"] = "1" // 有效标志
  186. diseinfo = append(diseinfo, diseinfo_sun)
  187. }
  188. //inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
  189. inputData["exp_content"] = "" //
  190. input["diseinfo"] = diseinfo
  191. input["mdtrtinfo"] = inputData
  192. inputMessage["input"] = input //交易输入
  193. var requestLog string
  194. bytesData, err := json.Marshal(inputMessage)
  195. fmt.Println(string(bytesData))
  196. requestLog = string(bytesData)
  197. if err != nil {
  198. fmt.Println(err.Error())
  199. return err.Error(), ""
  200. }
  201. reader := bytes.NewReader(bytesData)
  202. gdyb_url := beego.AppConfig.String("gdyb_url")
  203. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  204. request, err := http.NewRequest("POST", gdyb_url, reader)
  205. if err != nil {
  206. fmt.Println(err.Error())
  207. return err.Error(), ""
  208. }
  209. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  210. request.Header.Set("x-tif-paasid", gdyb_paasid)
  211. request.Header.Set("x-tif-signature", signature)
  212. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  213. request.Header.Set("x-tif-nonce", nonce)
  214. client := http.Client{}
  215. resp, err := client.Do(request)
  216. if err != nil {
  217. fmt.Println(err.Error())
  218. return err.Error(), ""
  219. }
  220. respBytes, err := ioutil.ReadAll(resp.Body)
  221. if err != nil {
  222. fmt.Println(err.Error())
  223. return err.Error(), ""
  224. }
  225. str := string(respBytes)
  226. fmt.Println(str)
  227. return str, requestLog
  228. }
  229. 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) {
  230. // 生成签名
  231. // 生成签名
  232. nonce := GetRandomString(32)
  233. timestamp := time.Now().Unix()
  234. signature := setSignature(timestamp, nonce, secret_key)
  235. //tempTime := time.Unix(timestamp, 0)
  236. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  237. // 生成输入报文
  238. tempTime := time.Unix(timestamp, 0)
  239. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  240. // 生成输入报文
  241. inputMessage := SetJSInputMessage(timestamp, org_name, dept, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  242. input := make(map[string]interface{})
  243. inputData := make(map[string]interface{})
  244. diseinfo := make([]map[string]interface{}, 0)
  245. if med_type == "1111" || med_type == "1112" {
  246. med_type = "11"
  247. }
  248. inputMessage["infno"] = "2203A" // 交易编码
  249. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  250. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  251. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  252. inputData["begntime"] = begin_time // 开始时间
  253. inputData["main_cond_dscr"] = "" // 主要病情描述
  254. inputData["dise_codg"] = sick_code // 病种编码
  255. inputData["dise_name"] = sick_name // 病种名称
  256. inputData["birctrl_type"] = "" // 计划生育手术类别
  257. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  258. for index, item := range config {
  259. diseinfo_sun := make(map[string]interface{})
  260. diseinfo_sun["diag_type"] = "1" // 诊断类别
  261. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  262. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  263. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  264. diseinfo_sun["diag_dept"] = department // 诊断科室
  265. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  266. diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  267. diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  268. diseinfo_sun["vali_flag"] = "0" // 有效标志
  269. diseinfo = append(diseinfo, diseinfo_sun)
  270. }
  271. //inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
  272. inputData["exp_content"] = "" //
  273. input["diseinfo"] = diseinfo
  274. input["mdtrtinfo"] = inputData
  275. inputMessage["input"] = input //交易输入
  276. var requestLog string
  277. bytesData, err := json.Marshal(inputMessage)
  278. fmt.Println(string(bytesData))
  279. requestLog = string(bytesData)
  280. if err != nil {
  281. fmt.Println(err.Error())
  282. return err.Error(), ""
  283. }
  284. reader := bytes.NewReader(bytesData)
  285. gdyb_url := beego.AppConfig.String("gdyb_url")
  286. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  287. request, err := http.NewRequest("POST", gdyb_url, reader)
  288. if err != nil {
  289. fmt.Println(err.Error())
  290. return err.Error(), ""
  291. }
  292. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  293. request.Header.Set("x-tif-paasid", gdyb_paasid)
  294. request.Header.Set("x-tif-signature", signature)
  295. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  296. request.Header.Set("x-tif-nonce", nonce)
  297. client := http.Client{}
  298. resp, err := client.Do(request)
  299. if err != nil {
  300. fmt.Println(err.Error())
  301. return err.Error(), ""
  302. }
  303. respBytes, err := ioutil.ReadAll(resp.Body)
  304. if err != nil {
  305. fmt.Println(err.Error())
  306. return err.Error(), ""
  307. }
  308. str := string(respBytes)
  309. fmt.Println(str)
  310. return str, requestLog
  311. }
  312. // 门诊费用明细信息上传
  313. 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) {
  314. // 生成签名
  315. timestamp := time.Now().Unix()
  316. // 生成签名
  317. nonce := GetRandomString(32)
  318. signature := setSignature(timestamp, nonce, secret_key)
  319. var customs []*Custom
  320. for _, item := range hisPrescription {
  321. tm := time.Now()
  322. if item.Type == 1 { //药品
  323. for _, subItem := range item.HisDoctorAdviceInfo {
  324. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  325. //var randNum int
  326. //randNum = rand.Intn(10000) + 1000
  327. cus := &Custom{
  328. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  329. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  330. FeedetlSn: subItem.FeedetlSn,
  331. Price: fmt.Sprintf("%.4f", subItem.Price),
  332. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  333. HospApprFlag: subItem.HospApprFlag,
  334. DoctorNumber: doctor_id,
  335. DoctorName: new_doctor_name,
  336. ProvinceDrugMedListCodg: "",
  337. ProvinceGoodMedListCodg: "",
  338. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  339. }
  340. if subItem.BaseDrugLib.DrugClassify == "2" {
  341. cus.ProvinceDrugMedListCodg = subItem.BaseDrugLib.ProvincesCode
  342. }
  343. customs = append(customs, cus)
  344. }
  345. }
  346. }
  347. if item.Type == 2 { //项目
  348. for _, subItem := range item.HisPrescriptionProject {
  349. //var randNum int
  350. //randNum = rand.Intn(10000) + 1000
  351. if subItem.Type == 2 {
  352. if len(subItem.HisProject.MedicalCode) > 0 {
  353. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  354. cus := &Custom{
  355. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  356. Cut: fmt.Sprintf("%.4f", cnt),
  357. FeedetlSn: subItem.FeedetlSn,
  358. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  359. MedListCodg: subItem.HisProject.MedicalCode,
  360. DoctorNumber: doctor_id,
  361. DoctorName: new_doctor_name,
  362. HospApprFlag: -1,
  363. ProvinceDrugMedListCodg: "",
  364. ProvinceGoodMedListCodg: "",
  365. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  366. }
  367. customs = append(customs, cus)
  368. }
  369. } else if subItem.Type == 3 {
  370. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  371. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  372. cus := &Custom{
  373. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  374. Cut: fmt.Sprintf("%.4f", cnt),
  375. FeedetlSn: subItem.FeedetlSn,
  376. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  377. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  378. HospApprFlag: -1,
  379. DoctorNumber: doctor_id,
  380. DoctorName: new_doctor_name,
  381. ProvinceDrugMedListCodg: "",
  382. ProvinceGoodMedListCodg: subItem.GoodInfo.ProvincesCode,
  383. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  384. }
  385. customs = append(customs, cus)
  386. }
  387. }
  388. }
  389. }
  390. for _, subItem := range item.HisAdditionalCharge {
  391. if len(subItem.XtHisAddtionConfig.Code) > 0 {
  392. cus := &Custom{
  393. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
  394. Cut: fmt.Sprintf("%.4f", float64(subItem.Count)),
  395. FeedetlSn: subItem.FeedetlSn,
  396. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  397. MedListCodg: subItem.XtHisAddtionConfig.Code,
  398. HospApprFlag: -1,
  399. DoctorNumber: doctor_id,
  400. DoctorName: new_doctor_name,
  401. }
  402. customs = append(customs, cus)
  403. }
  404. }
  405. }
  406. // 生成输入报文
  407. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  408. input := make(map[string]interface{})
  409. feedetail := make([]map[string]interface{}, 0)
  410. inputMessage["infno"] = "2204" // 交易编码
  411. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  412. for _, item := range customs {
  413. feedetailInfo := make(map[string]interface{})
  414. subfeedetailInfo := make(map[string]interface{})
  415. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  416. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  417. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  418. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  419. feedetailInfo["dise_codg"] = diag_code // 病种编码
  420. feedetailInfo["rxno"] = "" // 处方号
  421. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  422. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  423. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  424. feedetailInfo["medins_list_codg"] = fixmedins_code // 医药机构目录编码
  425. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  426. feedetailInfo["cnt"] = item.Cut // 数量
  427. feedetailInfo["pric"] = item.Price // 单价
  428. feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
  429. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  430. feedetailInfo["prd_days"] = "0" // 周期天数
  431. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  432. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  433. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  434. feedetailInfo["bilg_dr_codg"] = doctor_id // 开单医生编码
  435. feedetailInfo["bilg_dr_name"] = new_doctor_name // 开单医师姓名
  436. feedetailInfo["acord_dept_codg"] = dept_code // 受单科室编码
  437. feedetailInfo["acord_dept_name"] = dept // 受单科室名称
  438. feedetailInfo["orders_dr_code"] = doctor_id // 受单医生编码
  439. feedetailInfo["orders_dr_name"] = new_doctor_name // 受单医生姓名
  440. if balance_accounts_type == "8" {
  441. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  442. } else {
  443. if item.HospApprFlag != -1 {
  444. if item.HospApprFlag == 1 {
  445. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  446. } else if item.HospApprFlag == 2 {
  447. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  448. } else if item.HospApprFlag == 3 {
  449. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  450. } else {
  451. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  452. }
  453. } else {
  454. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  455. }
  456. }
  457. feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  458. feedetailInfo["etip_flag"] = "" // 外检标志
  459. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  460. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  461. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  462. subfeedetailInfo["tcmherb_prov_code"] = item.ProvinceDrugMedListCodg
  463. subfeedetailInfo["mcs_prov_code"] = item.ProvinceGoodMedListCodg
  464. feedetailInfo["exp_content"] = subfeedetailInfo
  465. feedetail = append(feedetail, feedetailInfo)
  466. }
  467. input["feedetail"] = feedetail
  468. inputMessage["input"] = input //交易输入
  469. var requestLog string
  470. bytesData, err := json.Marshal(inputMessage)
  471. requestLog = string(bytesData)
  472. fmt.Println(string(bytesData))
  473. if err != nil {
  474. fmt.Println(err.Error())
  475. return "", ""
  476. }
  477. reader := bytes.NewReader(bytesData)
  478. gdyb_url := beego.AppConfig.String("gdyb_url")
  479. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  480. request, err := http.NewRequest("POST", gdyb_url, reader)
  481. if err != nil {
  482. fmt.Println(err.Error())
  483. return "", ""
  484. }
  485. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  486. request.Header.Set("x-tif-paasid", gdyb_paasid)
  487. request.Header.Set("x-tif-signature", signature)
  488. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  489. request.Header.Set("x-tif-nonce", nonce)
  490. client := http.Client{}
  491. resp, err := client.Do(request)
  492. if err != nil {
  493. fmt.Println(err.Error())
  494. return "", ""
  495. }
  496. respBytes, err := ioutil.ReadAll(resp.Body)
  497. if err != nil {
  498. fmt.Println(err.Error())
  499. return "", ""
  500. }
  501. return string(respBytes), requestLog
  502. }
  503. // 门诊费用明细信息撤销
  504. func Nmyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string, request_url string, access_key string, cainfo string) (string, string) {
  505. // 生成签名
  506. nonce := GetRandomString(32)
  507. timestamp := time.Now().Unix()
  508. signature := setSignature(timestamp, nonce, secret_key)
  509. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  510. input := make(map[string]interface{})
  511. inputData := make(map[string]interface{})
  512. inputMessage["infno"] = "2205" // 交易编码
  513. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  514. inputData["chrg_bchno"] = "0000" // 收费批次号(来自2204生成的)
  515. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  516. inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
  517. input["data"] = inputData
  518. inputMessage["input"] = input //交易输入
  519. bytesData, err := json.Marshal(inputMessage)
  520. fmt.Println(string(bytesData))
  521. var requestLog string
  522. requestLog = string(bytesData)
  523. if err != nil {
  524. fmt.Println(err.Error())
  525. return err.Error(), ""
  526. }
  527. reader := bytes.NewReader(bytesData)
  528. gdyb_url := beego.AppConfig.String("gdyb_url")
  529. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  530. request, err := http.NewRequest("POST", gdyb_url, reader)
  531. fmt.Println(err)
  532. fmt.Println(request)
  533. if err != nil {
  534. fmt.Println(err.Error())
  535. return err.Error(), ""
  536. }
  537. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  538. request.Header.Set("x-tif-paasid", gdyb_paasid)
  539. request.Header.Set("x-tif-signature", signature)
  540. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  541. request.Header.Set("x-tif-nonce", nonce)
  542. client := http.Client{}
  543. resp, err := client.Do(request)
  544. if err != nil {
  545. fmt.Println(err.Error())
  546. return err.Error(), ""
  547. }
  548. respBytes, err := ioutil.ReadAll(resp.Body)
  549. if err != nil {
  550. fmt.Println(err.Error())
  551. return err.Error(), ""
  552. }
  553. str := string(respBytes)
  554. fmt.Println(str)
  555. return str, requestLog
  556. }
  557. // 门诊预结算
  558. 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) {
  559. if !strings.Contains(insuplc_admdvs, "150") {
  560. chrgBchno = "0000"
  561. }
  562. // 生成签名
  563. nonce := GetRandomString(32)
  564. timestamp := time.Now().Unix()
  565. signature := setSignature(timestamp, nonce, secret_key)
  566. // 生成输入报文
  567. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  568. input := make(map[string]interface{})
  569. inputData := make(map[string]interface{})
  570. inputMessage["infno"] = "2206" // 交易编码
  571. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  572. if certificates == 3 {
  573. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  574. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  575. } else {
  576. if id_card_type == 1 {
  577. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  578. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  579. } else if id_card_type == 3 {
  580. inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
  581. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  582. } else if id_card_type == 4 {
  583. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  584. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  585. } else {
  586. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  587. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  588. }
  589. }
  590. if insuplc_admdvs == "421300" {
  591. if med_type == "11" || med_type == "1112" || med_type == "1111" {
  592. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  593. } else if med_type == "14" {
  594. inputData["med_type"] = "140110" // 医疗类别 11 普通门诊 12 门诊挂号
  595. }
  596. } else {
  597. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  598. }
  599. inputData["medfee_sumamt"] = total // 医疗费总额
  600. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  601. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  602. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  603. inputData["acct_used_flag"] = "0" // 个人账户使用标志 0否 1是
  604. inputData["insutype"] = insutype // 险种类型
  605. inputData["invono"] = "" // 发票号
  606. inputData2 := make(map[string]interface{})
  607. inputData2["trum_flag"] = ""
  608. inputData2["rel_ttp_flag"] = ""
  609. inputData2["otp_er_refl_flag"] = ""
  610. inputData2["mdtrt_grp_type"] = mdtrt_grp_type
  611. inputData2["need_ipt_flag"] = ""
  612. inputData["exp_content"] = inputData2
  613. input["data"] = inputData
  614. inputMessage["input"] = input //交易输入
  615. var requestLog string
  616. bytesData, err := json.Marshal(inputMessage)
  617. requestLog = string(bytesData)
  618. fmt.Println(string(bytesData))
  619. if err != nil {
  620. fmt.Println(err.Error())
  621. return err.Error(), ""
  622. }
  623. reader := bytes.NewReader(bytesData)
  624. gdyb_url := beego.AppConfig.String("gdyb_url")
  625. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  626. request, err := http.NewRequest("POST", gdyb_url, reader)
  627. if err != nil {
  628. fmt.Println(err.Error())
  629. return err.Error(), ""
  630. }
  631. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  632. request.Header.Set("x-tif-paasid", gdyb_paasid)
  633. request.Header.Set("x-tif-signature", signature)
  634. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  635. request.Header.Set("x-tif-nonce", nonce)
  636. client := http.Client{}
  637. resp, err := client.Do(request)
  638. if err != nil {
  639. fmt.Println(err.Error())
  640. return err.Error(), ""
  641. }
  642. respBytes, err := ioutil.ReadAll(resp.Body)
  643. if err != nil {
  644. fmt.Println(err.Error())
  645. return err.Error(), ""
  646. }
  647. str := string(respBytes)
  648. fmt.Println(str)
  649. return str, requestLog
  650. }
  651. // 门诊结算
  652. 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) {
  653. if !strings.Contains(insuplc_admdvs, "150") {
  654. chrgBchno = "0000"
  655. }
  656. // 生成签名
  657. nonce := GetRandomString(32)
  658. timestamp := time.Now().Unix()
  659. signature := setSignature(timestamp, nonce, secret_key)
  660. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  661. input := make(map[string]interface{})
  662. inputData := make(map[string]interface{})
  663. inputMessage["infno"] = "2207" // 交易编码
  664. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  665. if certificates == 3 {
  666. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  667. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  668. } else {
  669. if id_card_type == 1 {
  670. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  671. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  672. } else if id_card_type == 3 {
  673. inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
  674. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  675. } else if id_card_type == 4 {
  676. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  677. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  678. } else {
  679. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  680. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  681. }
  682. }
  683. if med_type == "1111" || med_type == "1112" {
  684. med_type = "11"
  685. }
  686. if insuplc_admdvs == "421300" {
  687. if med_type == "11" {
  688. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  689. } else if med_type == "14" {
  690. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  691. }
  692. } else {
  693. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  694. }
  695. inputData["medfee_sumamt"] = total // 医疗费总额
  696. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  697. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  698. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  699. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  700. inputData["insutype"] = insutype // 险种类型
  701. inputData["invono"] = "12345" // 发票号
  702. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  703. inputData["overlmt_selfpay"] = overlmt_selfpay //
  704. inputData["preselfpay_amt"] = preselfpay_amt //
  705. inputData["inscp_scp_amt"] = inscp_scp_amt //
  706. inputData2 := make(map[string]interface{})
  707. inputData2["trum_flag"] = ""
  708. inputData2["rel_ttp_flag"] = ""
  709. inputData2["otp_er_refl_flag"] = ""
  710. inputData2["mdtrt_grp_type"] = mdtrt_grp_type
  711. inputData2["need_ipt_flag"] = ""
  712. inputData["exp_content"] = inputData2
  713. input["data"] = inputData
  714. inputMessage["input"] = input //交易输入
  715. bytesData, err := json.Marshal(inputMessage)
  716. fmt.Println(string(bytesData))
  717. if err != nil {
  718. fmt.Println(err.Error())
  719. return err.Error(), ""
  720. }
  721. reader := bytes.NewReader(bytesData)
  722. gdyb_url := beego.AppConfig.String("gdyb_url")
  723. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  724. request, err := http.NewRequest("POST", gdyb_url, reader)
  725. if err != nil {
  726. fmt.Println(err.Error())
  727. return err.Error(), ""
  728. }
  729. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  730. request.Header.Set("x-tif-paasid", gdyb_paasid)
  731. request.Header.Set("x-tif-signature", signature)
  732. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  733. request.Header.Set("x-tif-nonce", nonce)
  734. client := http.Client{}
  735. resp, err := client.Do(request)
  736. if err != nil {
  737. fmt.Println(err.Error())
  738. return err.Error(), ""
  739. }
  740. respBytes, err := ioutil.ReadAll(resp.Body)
  741. if err != nil {
  742. fmt.Println(err.Error())
  743. return err.Error(), ""
  744. }
  745. str := string(respBytes)
  746. fmt.Println(str)
  747. mjson, _ := json.Marshal(inputMessage)
  748. str2 := string(mjson)
  749. return str, str2
  750. }
  751. // 门诊结算撤销
  752. func Nmyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, request_url string, access_key string, cainfo string) (string, string) {
  753. // 生成签名
  754. nonce := GetRandomString(32)
  755. timestamp := time.Now().Unix()
  756. signature := setSignature(timestamp, nonce, secret_key)
  757. // 生成输入报文
  758. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  759. input := make(map[string]interface{})
  760. inputData := make(map[string]interface{})
  761. inputMessage["infno"] = "2208" // 交易编码
  762. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  763. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  764. inputData["setl_id"] = setlId // 结算 ID
  765. inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
  766. input["data"] = inputData
  767. inputMessage["input"] = input //交易输入
  768. bytesData, err := json.Marshal(inputMessage)
  769. fmt.Println(string(bytesData))
  770. if err != nil {
  771. fmt.Println(err.Error())
  772. return err.Error(), ""
  773. }
  774. reader := bytes.NewReader(bytesData)
  775. gdyb_url := beego.AppConfig.String("gdyb_url")
  776. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  777. request, err := http.NewRequest("POST", gdyb_url, reader)
  778. if err != nil {
  779. fmt.Println(err.Error())
  780. return err.Error(), ""
  781. }
  782. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  783. request.Header.Set("x-tif-paasid", gdyb_paasid)
  784. request.Header.Set("x-tif-signature", signature)
  785. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  786. request.Header.Set("x-tif-nonce", nonce)
  787. client := http.Client{}
  788. resp, err := client.Do(request)
  789. if err != nil {
  790. fmt.Println(err.Error())
  791. return err.Error(), ""
  792. }
  793. respBytes, err := ioutil.ReadAll(resp.Body)
  794. if err != nil {
  795. fmt.Println(err.Error())
  796. return err.Error(), ""
  797. }
  798. str := string(respBytes)
  799. fmt.Println(str)
  800. mjson, _ := json.Marshal(inputMessage)
  801. str2 := string(mjson)
  802. return str, str2
  803. }
  804. 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 {
  805. // 生成签名
  806. nonce := GetRandomString(32)
  807. timestamp := time.Now().Unix()
  808. signature := setSignature(timestamp, nonce, secret_key)
  809. //tempTime := time.Unix(timestamp, 0)
  810. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  811. //timeFormatTwo := tempTime.Format("2006-01-02")
  812. //t := time.Now()
  813. //last := time.Date(t.Year(), time.December, 31, 0, 0, 0, 0, time.UTC)
  814. //tm := time.Unix(last.Unix(), 0)
  815. // 生成输入报文
  816. inputMessage := SetInputMessage(nonce, timestamp, org_name, op, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  817. input := make(map[string]interface{})
  818. inputData := make(map[string]interface{})
  819. inputMessage["infno"] = "2503" // 交易编码
  820. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  821. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  822. inputData["opsp_dise_code"] = sick_code // 险种类型(来自1101接口返回)
  823. inputData["opsp_dise_name"] = sick_name // 险种类型(来自1101接口返回)
  824. inputData["insu_optins"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  825. inputData["ide_fixmedins_no"] = hospital_code // 险种类型(来自1101接口返回)
  826. inputData["ide_fixmedins_name"] = hospital_name // 险种类型(来自1101接口返回)
  827. inputData["hosp_ide_date"] = check_time // 险种类型(来自1101接口返回)
  828. inputData["diag_dr_codg"] = doctor_id // 开始时间
  829. inputData["diag_dr_name"] = doctor // 开始时间
  830. inputData["begndate"] = start_time // 医师编码
  831. inputData["tel"] = "" // 医师编码
  832. inputData["addr"] = "" // 医师编码
  833. inputData["enddate"] = end_time // 医师编码
  834. input["data"] = inputData
  835. inputMessage["input"] = input //交易输入
  836. bytesData, err := json.Marshal(inputMessage)
  837. fmt.Println(string(bytesData))
  838. if err != nil {
  839. fmt.Println(err.Error())
  840. return err.Error()
  841. }
  842. reader := bytes.NewReader(bytesData)
  843. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
  844. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503"
  845. gdyb_url := beego.AppConfig.String("gdyb_url")
  846. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  847. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  848. //url := gdyb_url + "2503"
  849. var url string
  850. if fixmedins_code == "H15049901371" {
  851. url = gdyb_url
  852. } else {
  853. url = gdyb_url + "2503"
  854. }
  855. request, err := http.NewRequest("POST", url, reader)
  856. if err != nil {
  857. fmt.Println(err.Error())
  858. return err.Error()
  859. }
  860. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  861. request.Header.Set("x-tif-paasid", gdyb_paasid)
  862. request.Header.Set("x-tif-signature", signature)
  863. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  864. request.Header.Set("x-tif-nonce", nonce)
  865. client := http.Client{}
  866. resp, err := client.Do(request)
  867. if err != nil {
  868. fmt.Println(err.Error())
  869. return err.Error()
  870. }
  871. respBytes, err := ioutil.ReadAll(resp.Body)
  872. if err != nil {
  873. fmt.Println(err.Error())
  874. return err.Error()
  875. }
  876. str := string(respBytes)
  877. fmt.Println(str)
  878. return str
  879. }
  880. func NMyb3501(struct3501 models.Struct3501, secret_key string) (string, string) {
  881. // 生成签名
  882. nonce := GetRandomString(32)
  883. timestamp := time.Now().Unix()
  884. signature := setSignature(timestamp, nonce, secret_key)
  885. // 生成输入报文
  886. inputMessage := SetGdInputMessage(timestamp, struct3501.OrgName, struct3501.Opter, struct3501.FixmedinsHilistId, struct3501.InsuplcAdmdvs, struct3501.MdtrtareaAdmvs, struct3501.Cainfo)
  887. input := make(map[string]interface{})
  888. inputData := make(map[string]interface{})
  889. inputMessage["infno"] = "3501" // 交易编码
  890. inputData["med_list_codg"] = struct3501.MedListCodg // 定点医药机构目录编号
  891. inputData["fixmedins_hilist_id"] = struct3501.FixmedinsHilistId // 定点医药机构目录编号
  892. inputData["fixmedins_hilist_name"] = struct3501.OrgName // 定点医药机构目录名称
  893. inputData["rx_flag"] = struct3501.RxFlag //
  894. inputData["invdate"] = struct3501.Invdate // 人员编号 (来自1101接口返回)
  895. inputData["inv_cnt"] = struct3501.InvCnt // 人员编号 (来自1101接口返回)
  896. inputData["manu_lotnum"] = struct3501.ManuLotnum // 人员编号 (来自1101接口返回)
  897. inputData["fixmedins_bchno"] = struct3501.FixmedinsBchno // 人员编号 (来自1101接口返回)
  898. inputData["manu_date"] = struct3501.ManuDate // 人员编号 (来自1101接口返回)
  899. inputData["expy_end"] = struct3501.ExpyEnd // 人员编号 (来自1101接口返回)
  900. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  901. input["invinfo"] = inputData
  902. inputMessage["input"] = input //交易输入
  903. bytesData, err := json.Marshal(inputMessage)
  904. fmt.Println(string(bytesData))
  905. if err != nil {
  906. fmt.Println(err.Error())
  907. return err.Error(),""
  908. }
  909. reader := bytes.NewReader(bytesData)
  910. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  911. gdyb_url := beego.AppConfig.String("gdyb_url")
  912. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  913. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  914. //url := gdyb_url + "3501"
  915. var url string
  916. url = gdyb_url
  917. request, err := http.NewRequest("POST", url, reader)
  918. if err != nil {
  919. fmt.Println(err.Error())
  920. return err.Error(), ""
  921. }
  922. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  923. request.Header.Set("x-tif-paasid", gdyb_paasid)
  924. request.Header.Set("x-tif-signature", signature)
  925. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  926. request.Header.Set("x-tif-nonce", nonce)
  927. client := http.Client{}
  928. resp, err := client.Do(request)
  929. if err != nil {
  930. fmt.Println(err.Error())
  931. return err.Error(), ""
  932. }
  933. respBytes, err := ioutil.ReadAll(resp.Body)
  934. if err != nil {
  935. fmt.Println(err.Error())
  936. return err.Error(), ""
  937. }
  938. str := string(respBytes)
  939. fmt.Println(str)
  940. return str, string(bytesData)
  941. }
  942. func NMyb3502(struct3502 models.Struct3502, secret_key string) (string, string) {
  943. // 生成签名
  944. nonce := GetRandomString(32)
  945. timestamp := time.Now().Unix()
  946. signature := setSignature(timestamp, nonce, secret_key)
  947. // 生成输入报文
  948. inputMessage := SetGdInputMessage(timestamp, struct3502.OrgName, struct3502.Opter, struct3502.FixmedinsCode, struct3502.InsuplcAdmdvs, struct3502.MdtrtareaAdmvs, struct3502.Cainfo)
  949. input := make(map[string]interface{})
  950. inputData := make(map[string]interface{})
  951. inputMessage["infno"] = "3502" // 交易编码
  952. inputData["med_list_codg"] = struct3502.MedListCodg // 定点医药机构目录编号
  953. inputData["inv_chg_type"] = struct3502.InvChgType // 定点医药机构目录编号
  954. inputData["fixmedins_hilist_id"] = struct3502.FixmedinsCode // 定点医药机构目录编号
  955. inputData["fixmedins_hilist_name"] = struct3502.FixmedinsHilistName // 定点医药机构目录名称
  956. inputData["fixmedins_bchno"] = struct3502.FixmedinsBchno // 人员编号 (来自1101接口返回)
  957. inputData["pric"] = struct3502.Pric // 人员编号 (来自1101接口返回)
  958. inputData["cnt"] = struct3502.Cnt // 人员编号 (来自1101接口返回)
  959. inputData["rx_flag"] = struct3502.RxFlag //
  960. inputData["inv_chg_time"] = struct3502.InvChgTime // 人员编号 (来自1101接口返回)
  961. inputData["inv_chg_opter_name"] = "" // 人员编号 (来自1101接口返回)
  962. inputData["memo"] = struct3502.Memo // 人员编号 (来自1101接口返回)
  963. inputData["trdn_flag"] = "" // 人员编号 (来自1101接口返回)
  964. input["invinfo"] = inputData
  965. inputMessage["input"] = input //交易输入
  966. bytesData, err := json.Marshal(inputMessage)
  967. fmt.Println(string(bytesData))
  968. if err != nil {
  969. fmt.Println(err.Error())
  970. return err.Error(),""
  971. }
  972. reader := bytes.NewReader(bytesData)
  973. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  974. gdyb_url := beego.AppConfig.String("gdyb_url")
  975. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  976. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  977. var url string
  978. url = gdyb_url
  979. request, err := http.NewRequest("POST", url, reader)
  980. if err != nil {
  981. fmt.Println(err.Error())
  982. return err.Error(),""
  983. }
  984. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  985. request.Header.Set("x-tif-paasid", gdyb_paasid)
  986. request.Header.Set("x-tif-signature", signature)
  987. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  988. request.Header.Set("x-tif-nonce", nonce)
  989. client := http.Client{}
  990. resp, err := client.Do(request)
  991. if err != nil {
  992. fmt.Println(err.Error())
  993. return err.Error(),""
  994. }
  995. respBytes, err := ioutil.ReadAll(resp.Body)
  996. if err != nil {
  997. fmt.Println(err.Error())
  998. return err.Error(),""
  999. }
  1000. str := string(respBytes)
  1001. fmt.Println(str)
  1002. return str,string(bytesData)
  1003. }
  1004. func NMyb3503(struct3503 models.Struct3503, secret_key string) (string,string) {
  1005. // 生成签名
  1006. nonce := GetRandomString(32)
  1007. timestamp := time.Now().Unix()
  1008. signature := setSignature(timestamp, nonce, secret_key)
  1009. // 生成输入报文
  1010. inputMessage := SetGdInputMessage(timestamp, struct3503.OrgName, struct3503.Opter, struct3503.FixmedinsHilistId, struct3503.InsuplcAdmdvs, struct3503.MdtrtareaAdmvs, struct3503.Cainfo)
  1011. input := make(map[string]interface{})
  1012. inputMessage["infno"] = "3503"
  1013. item := struct3503
  1014. feedetailInfo := make(map[string]interface{})
  1015. feedetailInfo["med_list_codg"] = item.MedListCodg
  1016. feedetailInfo["fixmedins_hilist_id"] = item.FixmedinsHilistId
  1017. feedetailInfo["fixmedins_hilist_name"] = item.FixmedinsHilistName
  1018. feedetailInfo["dynt_no"] = ""
  1019. feedetailInfo["fixmedins_bchno"] = item.FixmedinsBchno // 人员编号 (来自1101接口返回)
  1020. feedetailInfo["spler_name"] = item.SplerName // 人员编号 (来自1101接口返回)
  1021. feedetailInfo["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  1022. feedetailInfo["manu_lotnum"] = item.ManuLotnum // 人员编号 (来自1101接口返回)
  1023. feedetailInfo["prodentp_name"] = item.ProdentpName // 人员编号 (来自1101接口返回)
  1024. feedetailInfo["aprvno"] = item.Aprvno // 人员编号 (来自1101接口返回)
  1025. feedetailInfo["manu_date"] = item.ManuDate // 人员编号 (来自1101接口返回)
  1026. feedetailInfo["expy_end"] = item.ExpyEnd // 人员编号 (来自1101接口返回)
  1027. feedetailInfo["finl_trns_pric"] = item.FinlTrnsPric // 人员编号 (来自1101接口返回)
  1028. feedetailInfo["purc_retn_cnt"] = item.PurcRetnCnt // 人员编号 (来自1101接口返回)
  1029. feedetailInfo["purc_invo_codg"] = item.PurcInvoCodg // 人员编号 (来自1101接口返回)
  1030. feedetailInfo["purc_invo_no"] = item.PurcInvoNo // 人员编号 (来自1101接口返回)
  1031. feedetailInfo["rx_flag"] = item.RxFlag // 人员编号 (来自1101接口返回)
  1032. feedetailInfo["purc_retn_stoin_time"] = item.PurcRetnStoinTime // 人员编号 (来自1101接口返回)
  1033. feedetailInfo["purc_retn_opter_name"] = item.PurcRetnOpterName // 人员编号 (来自1101接口返回)
  1034. feedetailInfo["prod_geay_flag"] = "" // 人员编号 (来自1101接口返回)
  1035. feedetailInfo["memo"] = "" // 人员编号 (来自1101接口返回)
  1036. input["purcinfo"] = feedetailInfo
  1037. inputMessage["input"] = input //交易输入
  1038. bytesData, err := json.Marshal(inputMessage)
  1039. fmt.Println(string(bytesData))
  1040. if err != nil {
  1041. fmt.Println(err.Error())
  1042. return err.Error(),""
  1043. }
  1044. reader := bytes.NewReader(bytesData)
  1045. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1046. gdyb_url := beego.AppConfig.String("gdyb_url")
  1047. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1048. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1049. url := gdyb_url
  1050. request, err := http.NewRequest("POST", url, reader)
  1051. if err != nil {
  1052. fmt.Println(err.Error())
  1053. return err.Error(),""
  1054. }
  1055. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1056. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1057. request.Header.Set("x-tif-signature", signature)
  1058. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1059. request.Header.Set("x-tif-nonce", nonce)
  1060. client := http.Client{}
  1061. resp, err := client.Do(request)
  1062. if err != nil {
  1063. fmt.Println(err.Error())
  1064. return err.Error(),""
  1065. }
  1066. respBytes, err := ioutil.ReadAll(resp.Body)
  1067. if err != nil {
  1068. fmt.Println(err.Error())
  1069. return err.Error(),""
  1070. }
  1071. str := string(respBytes)
  1072. fmt.Println(str)
  1073. return str,string(bytesData)
  1074. }
  1075. func NMyb3504(struct3504 models.Struct3504, secret_key string) (string,string) {
  1076. // 生成签名
  1077. nonce := GetRandomString(32)
  1078. timestamp := time.Now().Unix()
  1079. signature := setSignature(timestamp, nonce, secret_key)
  1080. // 生成输入报文
  1081. inputMessage := SetGdInputMessage(timestamp, struct3504.OrgName, struct3504.Opter, struct3504.FixmedinsCode, struct3504.InsuplcAdmdvs, struct3504.MdtrtareaAdmvs, struct3504.Cainfo)
  1082. input := make(map[string]interface{})
  1083. inputData := make(map[string]interface{})
  1084. inputMessage["infno"] = "3504" // 交易编码
  1085. inputData["med_list_codg"] = struct3504.MedListCodg // 定点医药机构目录编号
  1086. inputData["fixmedins_hilist_id"] = struct3504.FixmedinsHilistId // 定点医药机构目录编号
  1087. inputData["fixmedins_hilist_name"] = struct3504.FixmedinsHilistName // 定点医药机构目录名称
  1088. inputData["fixmedins_bchno"] = struct3504.FixmedinsBchno // 人员编号 (来自1101接口返回)
  1089. inputData["spler_name"] = struct3504.SplerName // 人员编号 (来自1101接口返回)
  1090. inputData["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  1091. inputData["manu_date"] = struct3504.ManuDate // 人员编号 (来自1101接口返回)
  1092. inputData["expy_end"] = struct3504.ExpyEnd // 人员编号 (来自1101接口返回)
  1093. inputData["finl_trns_pric"] = struct3504.FinlTrnsPric // 人员编号 (来自1101接口返回)
  1094. inputData["purc_retn_cnt"] = struct3504.PurcRetnCnt // 人员编号 (来自1101接口返回)
  1095. inputData["purc_invo_codg"] = struct3504.PurcInvoCodg // 人员编号 (来自1101接口返回)
  1096. inputData["purc_invo_no"] = struct3504.PurcInvoNo // 人员编号 (来自1101接口返回)
  1097. inputData["rx_flag"] = struct3504.RxFlag
  1098. inputData["purc_retn_stoin_time"] = struct3504.PurcRetnStoin
  1099. inputData["purc_retn_opter_name"] = struct3504.PurcRetnStoin
  1100. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  1101. inputData["medins_prod_purc_no"] = "" // 人员编号 (来自1101接口返回)
  1102. input["purcinfo"] = inputData
  1103. inputMessage["input"] = input //交易输入
  1104. bytesData, err := json.Marshal(inputMessage)
  1105. fmt.Println(string(bytesData))
  1106. if err != nil {
  1107. fmt.Println(err.Error())
  1108. return err.Error(),""
  1109. }
  1110. reader := bytes.NewReader(bytesData)
  1111. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1112. gdyb_url := beego.AppConfig.String("gdyb_url")
  1113. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1114. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1115. url := gdyb_url
  1116. request, err := http.NewRequest("POST", url, reader)
  1117. if err != nil {
  1118. fmt.Println(err.Error())
  1119. return err.Error(),""
  1120. }
  1121. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1122. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1123. request.Header.Set("x-tif-signature", signature)
  1124. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1125. request.Header.Set("x-tif-nonce", nonce)
  1126. client := http.Client{}
  1127. resp, err := client.Do(request)
  1128. if err != nil {
  1129. fmt.Println(err.Error())
  1130. return err.Error(),""
  1131. }
  1132. respBytes, err := ioutil.ReadAll(resp.Body)
  1133. if err != nil {
  1134. fmt.Println(err.Error())
  1135. return err.Error(),""
  1136. }
  1137. str := string(respBytes)
  1138. fmt.Println(str)
  1139. return str,string(bytesData)
  1140. }
  1141. func NMyb3505(struct3505 models.Struct3505, secret_key string) (string,string) {
  1142. // 生成签名
  1143. nonce := GetRandomString(32)
  1144. timestamp := time.Now().Unix()
  1145. signature := setSignature(timestamp, nonce, secret_key)
  1146. // 生成输入报文
  1147. inputMessage := SetGdInputMessage(timestamp, struct3505.OrgName, struct3505.Opter, struct3505.Code, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, struct3505.Cainfo)
  1148. input := make(map[string]interface{})
  1149. inputData := make(map[string]interface{})
  1150. inputMessage["infno"] = "3505" // 交易编码
  1151. inputData["med_list_codg"] = struct3505.MedListCodg // 定点医药机构目录编号
  1152. inputData["fixmedins_hilist_id"] = struct3505.FixmedinsHilistId // 定点医药机构目录编号
  1153. inputData["fixmedins_hilist_name"] = struct3505.FixmedinsHilistName // 定点医药机构目录名称
  1154. inputData["fixmedins_bchno"] = struct3505.FixmedinsBchno // 人员编号 (来自1101接口返回)
  1155. inputData["prsc_dr_cert_type"] = struct3505.PrscDrCertType // 人员编号 (来自1101接口返回)
  1156. inputData["prsc_dr_certno"] = struct3505.PrscDrCertno // 人员编号 (来自1101接口返回)
  1157. inputData["prsc_dr_name"] = struct3505.PrscDrName // 人员编号 (来自1101接口返回)
  1158. inputData["phar_cert_type"] = struct3505.PharCertType // 人员编号 (来自1101接口返回)
  1159. inputData["phar_certno"] = struct3505.PharCertno // 人员编号 (来自1101接口返回)
  1160. inputData["phar_name"] = struct3505.PharName // 人员编号 (来自1101接口返回)
  1161. inputData["phar_prac_cert_no"] = struct3505.PharPracCertNo // 人员编号 (来自1101接口返回)
  1162. inputData["hi_feesetl_type"] = struct3505.HiFeesetlType // 人员编号 (来自1101接口返回)
  1163. inputData["setl_id"] = struct3505.SetlId // 人员编号 (来自1101接口返回)
  1164. inputData["mdtrt_sn"] = struct3505.MdtrtSn // 人员编号 (来自1101接口返回)
  1165. inputData["psn_no"] = struct3505.PsnNo // 人员编号 (来自1101接口返回)
  1166. inputData["psn_cert_type"] = struct3505.PsnCertType // 人员编号 (来自1101接口返回)
  1167. inputData["certno"] = struct3505.CertNo // 人员编号 (来自1101接口返回)
  1168. inputData["psn_name"] = struct3505.PsnName // 人员编号 (来自1101接口返回)
  1169. inputData["manu_lotnum"] = struct3505.ManuLotnum // 人员编号 (来自1101接口返回)
  1170. inputData["manu_date"] = struct3505.ManuDate // 人员编号 (来自1101接口返回)
  1171. inputData["expy_end"] = struct3505.ExpyEnd // 人员编号 (来自1101接口返回)
  1172. inputData["rx_flag"] = struct3505.RxFlag // 人员编号 (来自1101接口返回)
  1173. inputData["trdn_flag"] = struct3505.TrdnFlag // 人员编号 (来自1101接口返回)
  1174. inputData["finl_trns_pric"] = struct3505.FinlTrnsPric // 人员编号 (来自1101接口返回)
  1175. inputData["rxno"] = struct3505.Rxno // 人员编号 (来自1101接口返回)
  1176. inputData["rx_circ_flag"] = struct3505.RxCircFlag // 人员编号 (来自1101接口返回)
  1177. inputData["rtal_docno"] = struct3505.RtalDocno // 人员编号 (来自1101接口返回)
  1178. inputData["stoout_no"] = struct3505.StooutNo // 人员编号 (来自1101接口返回)
  1179. inputData["bchno"] = struct3505.Bchno // 人员编号 (来自1101接口返回)
  1180. inputData["drug_trac_codg"] = "---" // 人员编号 (来自1101接口返回)
  1181. inputData["drug_prod_barc"] = struct3505.DrugProdBarc // 人员编号 (来自1101接口返回)
  1182. inputData["shelf_posi"] = struct3505.ShelfPosi // 人员编号 (来自1101接口返回)
  1183. inputData["sel_retn_cnt"] = struct3505.SelRetnCnt // 人员编号 (来自1101接口返回)
  1184. inputData["sel_retn_time"] = struct3505.SelRetnTime // 人员编号 (来自1101接口返回)
  1185. inputData["sel_retn_opter_name"] = struct3505.SelRetnOpterName // 人员编号 (来自1101接口返回)
  1186. inputData["memo"] = struct3505.Memo // 人员编号 (来自1101接口返回)
  1187. feedetail := make([]map[string]interface{}, 0)
  1188. codes := strings.Split(struct3505.DrugTracCodg, ",")
  1189. for _, item := range codes {
  1190. if len(item) > 0 {
  1191. druginputData := make(map[string]interface{})
  1192. druginputData["drug_trac_codg"] = item
  1193. feedetail = append(feedetail, druginputData)
  1194. }
  1195. }
  1196. inputData["drugtracinfo"] = feedetail
  1197. input["selinfo"] = inputData
  1198. inputMessage["input"] = input //交易输入
  1199. bytesData, err := json.Marshal(inputMessage)
  1200. fmt.Println(string(bytesData))
  1201. if err != nil {
  1202. fmt.Println(err.Error())
  1203. return err.Error(),""
  1204. }
  1205. reader := bytes.NewReader(bytesData)
  1206. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1207. gdyb_url := beego.AppConfig.String("gdyb_url")
  1208. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1209. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1210. url := gdyb_url
  1211. request, err := http.NewRequest("POST", url, reader)
  1212. if err != nil {
  1213. fmt.Println(err.Error())
  1214. return err.Error(),""
  1215. }
  1216. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1217. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1218. request.Header.Set("x-tif-signature", signature)
  1219. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1220. request.Header.Set("x-tif-nonce", nonce)
  1221. client := http.Client{}
  1222. resp, err := client.Do(request)
  1223. if err != nil {
  1224. fmt.Println(err.Error())
  1225. return err.Error(),""
  1226. }
  1227. respBytes, err := ioutil.ReadAll(resp.Body)
  1228. if err != nil {
  1229. fmt.Println(err.Error())
  1230. return err.Error(),""
  1231. }
  1232. str := string(respBytes)
  1233. fmt.Println(str)
  1234. return str,string(bytesData)
  1235. }
  1236. func NMyb3506(struct3506 models.Struct3506, secret_key string) (string,string) {
  1237. // 生成签名
  1238. nonce := GetRandomString(32)
  1239. timestamp := time.Now().Unix()
  1240. signature := setSignature(timestamp, nonce, secret_key)
  1241. // 生成输入报文
  1242. inputMessage := SetGdInputMessage(timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsCode, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs, struct3506.Cainfo)
  1243. input := make(map[string]interface{})
  1244. inputData := make(map[string]interface{})
  1245. inputMessage["infno"] = "3506" // 交易编码
  1246. inputData["med_list_codg"] = struct3506.MedListCodg // 定点医药机构目录编号
  1247. inputData["fixmedins_hilist_id"] = struct3506.FixmedinsHilistId // 定点医药机构目录编号
  1248. inputData["fixmedins_hilist_name"] = struct3506.OrgName // 定点医药机构目录名称
  1249. inputData["fixmedins_bchno"] = struct3506.FixmedinsBchno // 人员编号 (来自1101接口返回)
  1250. inputData["setl_id"] = struct3506.SetlId // 人员编号 (来自1101接口返回)
  1251. inputData["psn_no"] = struct3506.PsnNo // 人员编号 (来自1101接口返回)
  1252. inputData["psn_cert_type"] = struct3506.PsnCertType // 人员编号 (来自1101接口返回)
  1253. inputData["certno"] = struct3506.Certno // 人员编号 (来自1101接口返回)
  1254. inputData["psn_name"] = struct3506.PsnName // 人员编号 (来自1101接口返回)
  1255. inputData["manu_lotnum"] = struct3506.ManuLotnum // 人员编号 (来自1101接口返回)
  1256. inputData["manu_date"] = struct3506.ManuDate // 人员编号 (来自1101接口返回)
  1257. inputData["expy_end"] = struct3506.ExpyEnd // 人员编号 (来自1101接口返回)
  1258. inputData["rx_flag"] = struct3506.RxFlag // 人员编号 (来自1101接口返回)
  1259. inputData["trdn_flag"] = struct3506.TrdnFlag // 人员编号 (来自1101接口返回)
  1260. inputData["finl_trns_pric"] = struct3506.FinlTrnsPric // 人员编号 (来自1101接口返回)
  1261. inputData["sel_retn_cnt"] = struct3506.SelRetnCnt // 人员编号 (来自1101接口返回)
  1262. inputData["sel_retn_time"] = struct3506.SelRetnTime // 人员编号 (来自1101接口返回)
  1263. inputData["sel_retn_opter_name"] = struct3506.SelRetnOpterName // 人员编号 (来自1101接口返回)
  1264. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  1265. inputData["medins_prod_sel_no"] = "" // 人员编号 (来自1101接口返回)
  1266. input["selinfo"] = inputData
  1267. inputMessage["input"] = input //交易输入
  1268. bytesData, err := json.Marshal(inputMessage)
  1269. fmt.Println(string(bytesData))
  1270. if err != nil {
  1271. fmt.Println(err.Error())
  1272. return err.Error(),""
  1273. }
  1274. reader := bytes.NewReader(bytesData)
  1275. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1276. gdyb_url := beego.AppConfig.String("gdyb_url")
  1277. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1278. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1279. url := gdyb_url
  1280. request, err := http.NewRequest("POST", url, reader)
  1281. if err != nil {
  1282. fmt.Println(err.Error())
  1283. return err.Error(),""
  1284. }
  1285. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1286. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1287. request.Header.Set("x-tif-signature", signature)
  1288. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1289. request.Header.Set("x-tif-nonce", nonce)
  1290. client := http.Client{}
  1291. resp, err := client.Do(request)
  1292. if err != nil {
  1293. fmt.Println(err.Error())
  1294. return err.Error(),""
  1295. }
  1296. respBytes, err := ioutil.ReadAll(resp.Body)
  1297. if err != nil {
  1298. fmt.Println(err.Error())
  1299. return err.Error(),""
  1300. }
  1301. str := string(respBytes)
  1302. fmt.Println(str)
  1303. return str,string(bytesData)
  1304. }
  1305. func NMyb3507(struct3507 models.Struct3507, secret_key string) (string,string) {
  1306. // 生成签名
  1307. nonce := GetRandomString(32)
  1308. timestamp := time.Now().Unix()
  1309. signature := setSignature(timestamp, nonce, secret_key)
  1310. // 生成输入报文
  1311. inputMessage := SetGdInputMessage(timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, struct3507.Cainfo)
  1312. input := make(map[string]interface{})
  1313. inputData := make(map[string]interface{})
  1314. inputMessage["infno"] = "3507" // 交易编码
  1315. inputData["fixmedins_bchno"] = struct3507.FixmedinsCode // 人员编号 (来自1101接口返回)
  1316. inputData["inv_data_type"] = struct3507.InvDataType // 人员编号 (来自1101接口返回)
  1317. input["data"] = inputData
  1318. inputMessage["input"] = input //交易输入
  1319. bytesData, err := json.Marshal(inputMessage)
  1320. fmt.Println(string(bytesData))
  1321. if err != nil {
  1322. fmt.Println(err.Error())
  1323. return err.Error(),""
  1324. }
  1325. reader := bytes.NewReader(bytesData)
  1326. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1327. gdyb_url := beego.AppConfig.String("gdyb_url")
  1328. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1329. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1330. url := gdyb_url
  1331. request, err := http.NewRequest("POST", url, reader)
  1332. if err != nil {
  1333. fmt.Println(err.Error())
  1334. return err.Error(),""
  1335. }
  1336. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1337. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1338. request.Header.Set("x-tif-signature", signature)
  1339. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1340. request.Header.Set("x-tif-nonce", nonce)
  1341. client := http.Client{}
  1342. resp, err := client.Do(request)
  1343. if err != nil {
  1344. fmt.Println(err.Error())
  1345. return err.Error(),""
  1346. }
  1347. respBytes, err := ioutil.ReadAll(resp.Body)
  1348. if err != nil {
  1349. fmt.Println(err.Error())
  1350. return err.Error(),""
  1351. }
  1352. str := string(respBytes)
  1353. fmt.Println(str)
  1354. return str,string(bytesData)
  1355. }
  1356. func NMyb3508(struct3508 models.Struct3508, secret_key string) (string,string) {
  1357. // 生成签名
  1358. nonce := GetRandomString(32)
  1359. timestamp := time.Now().Unix()
  1360. signature := setSignature(timestamp, nonce, secret_key)
  1361. // 生成输入报文
  1362. inputMessage := SetGdInputMessage(timestamp, struct3508.OrgName, struct3508.Opter, struct3508.FixmedinsCode, struct3508.InsuplcAdmdvs, struct3508.MdtrtareaAdmvs, struct3508.Cainfo)
  1363. input := make(map[string]interface{})
  1364. inputData := make(map[string]interface{})
  1365. inputMessage["infno"] = "3508"
  1366. inputData["fixmedins_code"] = struct3508.FixmedinsCode
  1367. inputData["medins_list_codg"] = struct3508.MedListCodg
  1368. inputData["fixmedins_bchno"] = ""
  1369. inputData["begndate"] = struct3508.Begndate
  1370. inputData["enddate"] = struct3508.Enddate
  1371. inputData["medins_prod_inv_no"] = ""
  1372. inputData["medins_list_name"] = ""
  1373. inputData["rx_flag"] = ""
  1374. inputData["list_sp_item_flag"] = ""
  1375. inputData["trdn_flag"] = ""
  1376. inputData["invdate"] = ""
  1377. inputData["manu_lotnum"] = ""
  1378. inputData["manu_date"] = ""
  1379. inputData["expy_end"] = ""
  1380. inputData["memo"] = ""
  1381. inputData["vali_flag"] = ""
  1382. inputData["rid"] = ""
  1383. inputData["crter_id"] = ""
  1384. inputData["crter_name"] = ""
  1385. inputData["crte_optins_no"] = ""
  1386. inputData["opter_id"] = ""
  1387. inputData["opter_name"] = ""
  1388. inputData["optins_no"] = ""
  1389. inputData["poolarea_no"] = ""
  1390. inputData["fixmedins_bchno"] = ""
  1391. inputData["inv_data_type"] = ""
  1392. input["data"] = inputData
  1393. inputMessage["input"] = input //交易输入
  1394. bytesData, err := json.Marshal(inputMessage)
  1395. fmt.Println(string(bytesData))
  1396. if err != nil {
  1397. fmt.Println(err.Error())
  1398. return err.Error(),""
  1399. }
  1400. reader := bytes.NewReader(bytesData)
  1401. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1402. gdyb_url := beego.AppConfig.String("gdyb_url")
  1403. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1404. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1405. url := gdyb_url
  1406. request, err := http.NewRequest("POST", url, reader)
  1407. if err != nil {
  1408. fmt.Println(err.Error())
  1409. return err.Error(),""
  1410. }
  1411. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1412. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1413. request.Header.Set("x-tif-signature", signature)
  1414. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1415. request.Header.Set("x-tif-nonce", nonce)
  1416. client := http.Client{}
  1417. resp, err := client.Do(request)
  1418. if err != nil {
  1419. fmt.Println(err.Error())
  1420. return err.Error(),""
  1421. }
  1422. respBytes, err := ioutil.ReadAll(resp.Body)
  1423. if err != nil {
  1424. fmt.Println(err.Error())
  1425. return err.Error(),""
  1426. }
  1427. str := string(respBytes)
  1428. fmt.Println(str)
  1429. return str,string(bytesData)
  1430. }
  1431. func NMyb3509(struct3509 models.Struct3509, secret_key string) (string,string) {
  1432. // 生成签名
  1433. nonce := GetRandomString(32)
  1434. timestamp := time.Now().Unix()
  1435. signature := setSignature(timestamp, nonce, secret_key)
  1436. // 生成输入报文
  1437. inputMessage := SetGdInputMessage(timestamp, struct3509.OrgName, struct3509.Opter, struct3509.FixmedinsCode, struct3509.InsuplcAdmdvs, struct3509.MdtrtareaAdmvs, struct3509.Cainfo)
  1438. input := make(map[string]interface{})
  1439. inputData := make(map[string]interface{})
  1440. inputMessage["infno"] = "3509"
  1441. inputData["fixmedins_code"] = struct3509.FixmedinsCode
  1442. //inputData["med_list_codg"] = struct3509.MedinsListCodg
  1443. inputData["medins_list_codg"] = struct3509.MedListCodg
  1444. inputData["fixmedins_bchno"] = ""
  1445. inputData["begndate"] = struct3509.Begndate
  1446. inputData["enddate"] = struct3509.Enddate
  1447. inputData["medins_prod_inv_no"] = ""
  1448. inputData["medins_list_name"] = ""
  1449. inputData["rx_flag"] = ""
  1450. inputData["list_sp_item_flag"] = ""
  1451. inputData["trdn_flag"] = ""
  1452. inputData["invdate"] = ""
  1453. inputData["manu_lotnum"] = ""
  1454. inputData["manu_date"] = ""
  1455. inputData["expy_end"] = ""
  1456. inputData["memo"] = ""
  1457. inputData["vali_flag"] = ""
  1458. inputData["rid"] = ""
  1459. inputData["crter_id"] = ""
  1460. inputData["crter_name"] = ""
  1461. inputData["crte_optins_no"] = ""
  1462. inputData["opter_id"] = ""
  1463. inputData["opter_name"] = ""
  1464. inputData["optins_no"] = ""
  1465. inputData["poolarea_no"] = ""
  1466. inputData["fixmedins_bchno"] = ""
  1467. inputData["inv_data_type"] = ""
  1468. input["data"] = inputData
  1469. inputMessage["input"] = input //交易输入
  1470. bytesData, err := json.Marshal(inputMessage)
  1471. fmt.Println(string(bytesData))
  1472. if err != nil {
  1473. fmt.Println(err.Error())
  1474. return err.Error(),""
  1475. }
  1476. reader := bytes.NewReader(bytesData)
  1477. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1478. gdyb_url := beego.AppConfig.String("gdyb_url")
  1479. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1480. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1481. url := gdyb_url
  1482. request, err := http.NewRequest("POST", url, reader)
  1483. if err != nil {
  1484. fmt.Println(err.Error())
  1485. return err.Error(),""
  1486. }
  1487. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1488. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1489. request.Header.Set("x-tif-signature", signature)
  1490. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1491. request.Header.Set("x-tif-nonce", nonce)
  1492. client := http.Client{}
  1493. resp, err := client.Do(request)
  1494. if err != nil {
  1495. fmt.Println(err.Error())
  1496. return err.Error(),""
  1497. }
  1498. respBytes, err := ioutil.ReadAll(resp.Body)
  1499. if err != nil {
  1500. fmt.Println(err.Error())
  1501. return err.Error(),""
  1502. }
  1503. str := string(respBytes)
  1504. fmt.Println(str)
  1505. return str,string(bytesData)
  1506. }
  1507. func NMyb3510(struct3510 models.Struct3510, secret_key string) (string,string) {
  1508. // 生成签名
  1509. nonce := GetRandomString(32)
  1510. timestamp := time.Now().Unix()
  1511. signature := setSignature(timestamp, nonce, secret_key)
  1512. // 生成输入报文
  1513. inputMessage := SetGdInputMessage(timestamp, struct3510.OrgName, struct3510.Opter, struct3510.FixmedinsCode, struct3510.InsuplcAdmdvs, struct3510.MdtrtareaAdmvs, struct3510.Cainfo)
  1514. input := make(map[string]interface{})
  1515. inputData := make(map[string]interface{})
  1516. inputMessage["infno"] = "3510"
  1517. inputData["fixmedins_code"] = struct3510.FixmedinsCode
  1518. //inputData["medins_list_codg"] = struct3510.MedinsListCodg
  1519. inputData["medins_list_codg"] = struct3510.MedListCodg
  1520. inputData["fixmedins_bchno"] = ""
  1521. inputData["begndate"] = struct3510.Begndate
  1522. inputData["enddate"] = struct3510.Enddate
  1523. inputData["medins_prod_inv_no"] = ""
  1524. inputData["medins_list_name"] = ""
  1525. inputData["rx_flag"] = ""
  1526. inputData["list_sp_item_flag"] = ""
  1527. inputData["trdn_flag"] = ""
  1528. inputData["invdate"] = ""
  1529. inputData["manu_lotnum"] = ""
  1530. inputData["manu_date"] = ""
  1531. inputData["expy_end"] = ""
  1532. inputData["memo"] = ""
  1533. inputData["vali_flag"] = ""
  1534. inputData["rid"] = ""
  1535. inputData["crter_id"] = ""
  1536. inputData["crter_name"] = ""
  1537. inputData["crte_optins_no"] = ""
  1538. inputData["opter_id"] = ""
  1539. inputData["opter_name"] = ""
  1540. inputData["optins_no"] = ""
  1541. inputData["poolarea_no"] = ""
  1542. inputData["fixmedins_bchno"] = ""
  1543. inputData["inv_data_type"] = ""
  1544. input["data"] = inputData
  1545. inputMessage["input"] = input //交易输入
  1546. bytesData, err := json.Marshal(inputMessage)
  1547. fmt.Println(string(bytesData))
  1548. if err != nil {
  1549. fmt.Println(err.Error())
  1550. return err.Error(),""
  1551. }
  1552. reader := bytes.NewReader(bytesData)
  1553. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1554. gdyb_url := beego.AppConfig.String("gdyb_url")
  1555. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1556. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1557. url := gdyb_url
  1558. request, err := http.NewRequest("POST", url, reader)
  1559. if err != nil {
  1560. fmt.Println(err.Error())
  1561. return err.Error(),""
  1562. }
  1563. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1564. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1565. request.Header.Set("x-tif-signature", signature)
  1566. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1567. request.Header.Set("x-tif-nonce", nonce)
  1568. client := http.Client{}
  1569. resp, err := client.Do(request)
  1570. if err != nil {
  1571. fmt.Println(err.Error())
  1572. return err.Error(),""
  1573. }
  1574. respBytes, err := ioutil.ReadAll(resp.Body)
  1575. if err != nil {
  1576. fmt.Println(err.Error())
  1577. return err.Error(),""
  1578. }
  1579. str := string(respBytes)
  1580. fmt.Println(str)
  1581. return str,string(bytesData)
  1582. }
  1583. func NMyb3511(struct3511 models.Struct3511, secret_key string) (string,string) {
  1584. // 生成签名
  1585. nonce := GetRandomString(32)
  1586. timestamp := time.Now().Unix()
  1587. signature := setSignature(timestamp, nonce, secret_key)
  1588. // 生成输入报文
  1589. inputMessage := SetGdInputMessage(timestamp, struct3511.OrgName, struct3511.Opter, struct3511.FixmedinsCode, struct3511.InsuplcAdmdvs, struct3511.MdtrtareaAdmvs, struct3511.Cainfo)
  1590. input := make(map[string]interface{})
  1591. inputData := make(map[string]interface{})
  1592. inputMessage["infno"] = "3511"
  1593. inputData["fixmedins_code"] = struct3511.FixmedinsCode
  1594. //inputData["medins_list_codg"] = struct3511.MedinsListCodg
  1595. inputData["medins_list_codg"] = struct3511.MedListCodg
  1596. inputData["fixmedins_bchno"] = ""
  1597. inputData["begndate"] = struct3511.Begndate
  1598. inputData["enddate"] = struct3511.Enddate
  1599. inputData["medins_prod_inv_no"] = ""
  1600. inputData["medins_list_name"] = ""
  1601. inputData["rx_flag"] = ""
  1602. inputData["list_sp_item_flag"] = ""
  1603. inputData["trdn_flag"] = ""
  1604. inputData["invdate"] = ""
  1605. inputData["manu_lotnum"] = ""
  1606. inputData["manu_date"] = ""
  1607. inputData["expy_end"] = ""
  1608. inputData["memo"] = ""
  1609. inputData["vali_flag"] = ""
  1610. inputData["rid"] = ""
  1611. inputData["crter_id"] = ""
  1612. inputData["crter_name"] = ""
  1613. inputData["crte_optins_no"] = ""
  1614. inputData["opter_id"] = ""
  1615. inputData["opter_name"] = ""
  1616. inputData["optins_no"] = ""
  1617. inputData["poolarea_no"] = ""
  1618. inputData["fixmedins_bchno"] = ""
  1619. inputData["inv_data_type"] = ""
  1620. input["data"] = inputData
  1621. inputMessage["input"] = input //交易输入
  1622. bytesData, err := json.Marshal(inputMessage)
  1623. fmt.Println(string(bytesData))
  1624. if err != nil {
  1625. fmt.Println(err.Error())
  1626. return err.Error(),""
  1627. }
  1628. reader := bytes.NewReader(bytesData)
  1629. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1630. gdyb_url := beego.AppConfig.String("gdyb_url")
  1631. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1632. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1633. url := gdyb_url
  1634. request, err := http.NewRequest("POST", url, reader)
  1635. if err != nil {
  1636. fmt.Println(err.Error())
  1637. return err.Error(),""
  1638. }
  1639. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1640. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1641. request.Header.Set("x-tif-signature", signature)
  1642. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1643. request.Header.Set("x-tif-nonce", nonce)
  1644. client := http.Client{}
  1645. resp, err := client.Do(request)
  1646. if err != nil {
  1647. fmt.Println(err.Error())
  1648. return err.Error(),""
  1649. }
  1650. respBytes, err := ioutil.ReadAll(resp.Body)
  1651. if err != nil {
  1652. fmt.Println(err.Error())
  1653. return err.Error(),""
  1654. }
  1655. str := string(respBytes)
  1656. fmt.Println(str)
  1657. return str,string(bytesData)
  1658. }
  1659. func NMyb3512(struct3512 models.Struct3512, secret_key string) (string,string) {
  1660. // 生成签名
  1661. nonce := GetRandomString(32)
  1662. timestamp := time.Now().Unix()
  1663. signature := setSignature(timestamp, nonce, secret_key)
  1664. // 生成输入报文
  1665. inputMessage := SetGdInputMessage(timestamp, struct3512.OrgName, struct3512.Opter, struct3512.FixmedinsCode, struct3512.InsuplcAdmdvs, struct3512.MdtrtareaAdmvs, struct3512.Cainfo)
  1666. input := make(map[string]interface{})
  1667. inputData := make(map[string]interface{})
  1668. inputMessage["infno"] = "3512"
  1669. inputData["fixmedins_code"] = struct3512.FixmedinsCode
  1670. //inputData["medins_list_codg"] = struct3512.MedinsListCodg
  1671. inputData["medins_list_codg"] = struct3512.MedListCodg
  1672. inputData["fixmedins_bchno"] = ""
  1673. inputData["begndate"] = struct3512.Begndate
  1674. inputData["enddate"] = struct3512.Enddate
  1675. inputData["medins_prod_inv_no"] = ""
  1676. inputData["medins_list_name"] = ""
  1677. inputData["rx_flag"] = ""
  1678. inputData["list_sp_item_flag"] = ""
  1679. inputData["trdn_flag"] = ""
  1680. inputData["invdate"] = ""
  1681. inputData["manu_lotnum"] = ""
  1682. inputData["manu_date"] = ""
  1683. inputData["expy_end"] = ""
  1684. inputData["memo"] = ""
  1685. inputData["vali_flag"] = ""
  1686. inputData["rid"] = ""
  1687. inputData["crter_id"] = ""
  1688. inputData["crter_name"] = ""
  1689. inputData["crte_optins_no"] = ""
  1690. inputData["opter_id"] = ""
  1691. inputData["opter_name"] = ""
  1692. inputData["optins_no"] = ""
  1693. inputData["poolarea_no"] = ""
  1694. inputData["fixmedins_bchno"] = ""
  1695. inputData["inv_data_type"] = ""
  1696. input["data"] = inputData
  1697. inputMessage["input"] = input //交易输入
  1698. bytesData, err := json.Marshal(inputMessage)
  1699. fmt.Println(string(bytesData))
  1700. if err != nil {
  1701. fmt.Println(err.Error())
  1702. return err.Error(),""
  1703. }
  1704. reader := bytes.NewReader(bytesData)
  1705. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1706. gdyb_url := beego.AppConfig.String("gdyb_url")
  1707. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1708. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1709. url := gdyb_url
  1710. request, err := http.NewRequest("POST", url, reader)
  1711. if err != nil {
  1712. fmt.Println(err.Error())
  1713. return err.Error(),""
  1714. }
  1715. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1716. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1717. request.Header.Set("x-tif-signature", signature)
  1718. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1719. request.Header.Set("x-tif-nonce", nonce)
  1720. client := http.Client{}
  1721. resp, err := client.Do(request)
  1722. if err != nil {
  1723. fmt.Println(err.Error())
  1724. return err.Error(),""
  1725. }
  1726. respBytes, err := ioutil.ReadAll(resp.Body)
  1727. if err != nil {
  1728. fmt.Println(err.Error())
  1729. return err.Error(),""
  1730. }
  1731. str := string(respBytes)
  1732. fmt.Println(str)
  1733. return str,string(bytesData)
  1734. }
  1735. func NMyb3513(struct3513 models.Struct3513, secret_key string) (string,string) {
  1736. // 生成签名
  1737. nonce := GetRandomString(32)
  1738. timestamp := time.Now().Unix()
  1739. signature := setSignature(timestamp, nonce, secret_key)
  1740. // 生成输入报文
  1741. inputMessage := SetGdInputMessage(timestamp, struct3513.OrgName, struct3513.Opter, struct3513.FixmedinsCode, struct3513.InsuplcAdmdvs, struct3513.MdtrtareaAdmvs, struct3513.Cainfo)
  1742. input := make(map[string]interface{})
  1743. inputData := make(map[string]interface{})
  1744. inputMessage["infno"] = "3513"
  1745. inputData["fixmedins_code"] = struct3513.FixmedinsCode
  1746. //inputData["medins_list_codg"] = struct3513.MedinsListCodg
  1747. inputData["medins_list_codg"] = struct3513.MedListCodg
  1748. inputData["fixmedins_bchno"] = ""
  1749. inputData["begndate"] = struct3513.Begndate
  1750. inputData["enddate"] = struct3513.Enddate
  1751. inputData["medins_prod_inv_no"] = ""
  1752. inputData["med_list_codg"] = ""
  1753. inputData["medins_list_name"] = ""
  1754. inputData["rx_flag"] = ""
  1755. inputData["list_sp_item_flag"] = ""
  1756. inputData["trdn_flag"] = ""
  1757. inputData["invdate"] = ""
  1758. inputData["manu_lotnum"] = ""
  1759. inputData["manu_date"] = ""
  1760. inputData["expy_end"] = ""
  1761. inputData["memo"] = ""
  1762. inputData["vali_flag"] = ""
  1763. inputData["rid"] = ""
  1764. inputData["crter_id"] = ""
  1765. inputData["crter_name"] = ""
  1766. inputData["crte_optins_no"] = ""
  1767. inputData["opter_id"] = ""
  1768. inputData["opter_name"] = ""
  1769. inputData["optins_no"] = ""
  1770. inputData["poolarea_no"] = ""
  1771. inputData["fixmedins_bchno"] = ""
  1772. inputData["inv_data_type"] = ""
  1773. input["data"] = inputData
  1774. inputMessage["input"] = input //交易输入
  1775. bytesData, err := json.Marshal(inputMessage)
  1776. fmt.Println(string(bytesData))
  1777. if err != nil {
  1778. fmt.Println(err.Error())
  1779. return err.Error(),""
  1780. }
  1781. reader := bytes.NewReader(bytesData)
  1782. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1783. gdyb_url := beego.AppConfig.String("gdyb_url")
  1784. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1785. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1786. url := gdyb_url
  1787. request, err := http.NewRequest("POST", url, reader)
  1788. if err != nil {
  1789. fmt.Println(err.Error())
  1790. return err.Error(),""
  1791. }
  1792. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1793. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1794. request.Header.Set("x-tif-signature", signature)
  1795. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1796. request.Header.Set("x-tif-nonce", nonce)
  1797. client := http.Client{}
  1798. resp, err := client.Do(request)
  1799. if err != nil {
  1800. fmt.Println(err.Error())
  1801. return err.Error(),""
  1802. }
  1803. respBytes, err := ioutil.ReadAll(resp.Body)
  1804. if err != nil {
  1805. fmt.Println(err.Error())
  1806. return err.Error(),""
  1807. }
  1808. str := string(respBytes)
  1809. fmt.Println(str)
  1810. return str,string(bytesData)
  1811. }