zh_his_service.go 70KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937
  1. package service
  2. import (
  3. "bytes"
  4. "encoding/json"
  5. "fmt"
  6. "gdyb/models"
  7. "github.com/astaxie/beego"
  8. "github.com/jinzhu/gorm"
  9. "io/ioutil"
  10. "net/http"
  11. "strconv"
  12. "time"
  13. _ "unsafe"
  14. )
  15. // 人员基本信息
  16. func ZHGdyb1101(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates int64, name string,admin_user_id int64) (string, string, string) {
  17. //生成签名
  18. var requestLog string
  19. var resultLog string
  20. //nonce := GetRandomString(32)
  21. //timestamp := time.Now().UnixNano() / 1e6
  22. //signature := setSignature(timestamp, nonce, secret_key)
  23. nonce := GetRandomString(32)
  24. timestamp := time.Now().Unix()
  25. signature := setSignature(timestamp, nonce, secret_key)
  26. inputMessage := make(map[string]interface{})
  27. //生成输入报文
  28. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  29. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  30. } else {
  31. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  32. }
  33. //inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  34. input := make(map[string]interface{})
  35. inputData := make(map[string]interface{})
  36. inputMessage["infno"] = "1101" // 交易编码
  37. if certificates == 3 {
  38. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  39. inputData["certno"] = certNo // 证件号码
  40. inputData["psn_cert_type"] = "99" // 人员证件类型
  41. } else {
  42. if id_card_type == 1 {
  43. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  44. inputData["card_sn"] = card_sn // 卡识别码
  45. inputData["certno"] = certNo // 证件号码
  46. inputData["psn_cert_type"] = "01" // 人员证件类型
  47. } else if id_card_type == 4 {
  48. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  49. inputData["card_sn"] = "" // 卡识别码
  50. inputData["certno"] = certNo // 证件号码
  51. inputData["psn_cert_type"] = "01" // 人员证件类型
  52. } else {
  53. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  54. inputData["card_sn"] = "" // 卡识别码
  55. inputData["certno"] = certNo // 证件号码
  56. inputData["psn_cert_type"] = "01" // 人员证件类型
  57. }
  58. }
  59. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  60. inputData["begntime"] = "" // 开始时间
  61. inputData["psn_name"] = name // 人员姓名
  62. input["data"] = inputData
  63. inputMessage["input"] = input //交易输入
  64. bytesData, err := json.Marshal(inputMessage)
  65. fmt.Println(string(bytesData))
  66. requestLog = string(bytesData)
  67. if err != nil {
  68. fmt.Println(err.Error())
  69. return err.Error(), "", ""
  70. }
  71. reader := bytes.NewReader(bytesData)
  72. gdyb_url := beego.AppConfig.String("gdyb_url")
  73. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  74. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  75. url := gdyb_url + "1101"
  76. if mdtrtarea_admvs == "150499" {
  77. url = gdyb_url
  78. }
  79. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  80. url = gdyb_url
  81. }
  82. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  83. request, err := http.NewRequest("POST", url, reader)
  84. if err != nil {
  85. fmt.Println(err.Error())
  86. return err.Error(), "", ""
  87. }
  88. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  89. request.Header.Set("x-tif-paasid", gdyb_paasid)
  90. request.Header.Set("x-tif-signature", signature)
  91. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  92. request.Header.Set("x-tif-nonce", nonce)
  93. client := http.Client{}
  94. resp, err := client.Do(request)
  95. if err != nil {
  96. fmt.Println(err.Error())
  97. return err.Error(), "", ""
  98. }
  99. respBytes, err := ioutil.ReadAll(resp.Body)
  100. if err != nil {
  101. fmt.Println(err.Error())
  102. return err.Error(), "", ""
  103. }
  104. fmt.Println(string(respBytes))
  105. str := string(respBytes)
  106. resultLog = str
  107. return str, requestLog, resultLog
  108. }
  109. func ZHGdyb1101d(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates int64, name string,admin_user_id int64,token string) (string, string, string) {
  110. //生成签名
  111. var requestLog string
  112. var resultLog string
  113. //nonce := GetRandomString(32)
  114. //timestamp := time.Now().UnixNano() / 1e6
  115. //signature := setSignature(timestamp, nonce, secret_key)
  116. nonce := GetRandomString(32)
  117. timestamp := time.Now().Unix()
  118. signature := setSignature(timestamp, nonce, secret_key)
  119. inputMessage := make(map[string]interface{})
  120. //生成输入报文
  121. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  122. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  123. } else {
  124. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  125. }
  126. //inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  127. input := make(map[string]interface{})
  128. inputData := make(map[string]interface{})
  129. inputMessage["infno"] = "1101" // 交易编码
  130. if certificates == 3 {
  131. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  132. inputData["certno"] = certNo // 证件号码
  133. inputData["psn_cert_type"] = "99" // 人员证件类型
  134. } else {
  135. if id_card_type == 1 {
  136. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  137. inputData["card_sn"] = card_sn // 卡识别码
  138. inputData["certno"] = certNo // 证件号码
  139. inputData["psn_cert_type"] = "01" // 人员证件类型
  140. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  141. } else if id_card_type == 4 {
  142. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  143. inputData["card_sn"] = "" // 卡识别码
  144. inputData["certno"] = certNo // 证件号码
  145. inputData["psn_cert_type"] = "01" // 人员证件类型
  146. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  147. } else {
  148. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  149. inputData["card_sn"] = "" // 卡识别码
  150. inputData["certno"] = certNo // 证件号码
  151. inputData["psn_cert_type"] = "01" // 人员证件类型
  152. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  153. }
  154. }
  155. inputData["begntime"] = "" // 开始时间
  156. inputData["psn_name"] = name // 人员姓名
  157. input["data"] = inputData
  158. inputMessage["input"] = input //交易输入
  159. bytesData, err := json.Marshal(inputMessage)
  160. fmt.Println(string(bytesData))
  161. requestLog = string(bytesData)
  162. if err != nil {
  163. fmt.Println(err.Error())
  164. return err.Error(), "", ""
  165. }
  166. reader := bytes.NewReader(bytesData)
  167. gdyb_url := beego.AppConfig.String("gdyb_url")
  168. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  169. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  170. url := gdyb_url + "1101"
  171. if mdtrtarea_admvs == "150499" {
  172. url = gdyb_url
  173. }
  174. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  175. url = gdyb_url
  176. }
  177. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  178. request, err := http.NewRequest("POST", url, reader)
  179. if err != nil {
  180. fmt.Println(err.Error())
  181. return err.Error(), "", ""
  182. }
  183. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  184. request.Header.Set("x-tif-paasid", gdyb_paasid)
  185. request.Header.Set("x-tif-signature", signature)
  186. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  187. request.Header.Set("x-tif-nonce", nonce)
  188. client := http.Client{}
  189. resp, err := client.Do(request)
  190. if err != nil {
  191. fmt.Println(err.Error())
  192. return err.Error(), "", ""
  193. }
  194. respBytes, err := ioutil.ReadAll(resp.Body)
  195. if err != nil {
  196. fmt.Println(err.Error())
  197. return err.Error(), "", ""
  198. }
  199. fmt.Println(string(respBytes))
  200. str := string(respBytes)
  201. resultLog = str
  202. return str, requestLog, resultLog
  203. }
  204. func ZHGdyb1101C(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates int64, name string) (string, string, string) {
  205. //生成签名
  206. var requestLog string
  207. var resultLog string
  208. nonce := GetRandomString(32)
  209. timestamp := time.Now().Unix()
  210. signature := setSignature(timestamp, nonce, secret_key)
  211. //生成输入报文
  212. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  213. input := make(map[string]interface{})
  214. inputData := make(map[string]interface{})
  215. inputMessage["infno"] = "1101" // 交易编码
  216. if certificates == 3 {
  217. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  218. inputData["certno"] = certNo // 证件号码
  219. inputData["psn_cert_type"] = "99" // 人员证件类型
  220. } else {
  221. if id_card_type == 1 {
  222. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  223. inputData["card_sn"] = card_sn // 卡识别码
  224. inputData["certno"] = certNo // 证件号码
  225. inputData["psn_cert_type"] = "01" // 人员证件类型
  226. } else {
  227. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  228. inputData["card_sn"] = "" // 卡识别码
  229. inputData["certno"] = certNo // 证件号码
  230. inputData["psn_cert_type"] = "01" // 人员证件类型
  231. }
  232. }
  233. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  234. inputData["begntime"] = "" // 开始时间
  235. inputData["psn_name"] = name // 人员姓名
  236. input["data"] = inputData
  237. inputMessage["input"] = input //交易输入
  238. bytesData, err := json.Marshal(inputMessage)
  239. fmt.Println(string(bytesData))
  240. requestLog = string(bytesData)
  241. if err != nil {
  242. fmt.Println(err.Error())
  243. return err.Error(), "", ""
  244. }
  245. reader := bytes.NewReader(bytesData)
  246. gdyb_url := beego.AppConfig.String("gdyb_url")
  247. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  248. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  249. url := gdyb_url + "1101"
  250. if mdtrtarea_admvs == "150499" {
  251. url = gdyb_url
  252. }
  253. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  254. request, err := http.NewRequest("POST", url, reader)
  255. if err != nil {
  256. fmt.Println(err.Error())
  257. return err.Error(), "", ""
  258. }
  259. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  260. request.Header.Set("x-tif-paasid", gdyb_paasid)
  261. request.Header.Set("x-tif-signature", signature)
  262. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  263. request.Header.Set("x-tif-nonce", nonce)
  264. client := http.Client{}
  265. resp, err := client.Do(request)
  266. if err != nil {
  267. fmt.Println(err.Error())
  268. return err.Error(), "", ""
  269. }
  270. respBytes, err := ioutil.ReadAll(resp.Body)
  271. if err != nil {
  272. fmt.Println(err.Error())
  273. return err.Error(), "", ""
  274. }
  275. fmt.Println(string(respBytes))
  276. str := string(respBytes)
  277. resultLog = str
  278. return str, requestLog, resultLog
  279. }
  280. func ZHGdyb1101B(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates int64, name string) (string, string) {
  281. //生成签名
  282. var requestLog string
  283. nonce := GetRandomString(32)
  284. timestamp := time.Now().Unix()
  285. signature := setSignature(timestamp, nonce, secret_key)
  286. //生成输入报文
  287. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  288. input := make(map[string]interface{})
  289. inputData := make(map[string]interface{})
  290. inputMessage["infno"] = "1101" // 交易编码
  291. if certificates == 3 {
  292. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  293. inputData["certno"] = certNo // 证件号码
  294. inputData["psn_cert_type"] = "99" // 人员证件类型
  295. } else {
  296. if id_card_type == 1 {
  297. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  298. inputData["card_sn"] = "" // 卡识别码
  299. inputData["certno"] = certNo // 证件号码
  300. inputData["psn_cert_type"] = "01" // 人员证件类型
  301. } else {
  302. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  303. inputData["card_sn"] = "" // 卡识别码
  304. inputData["certno"] = certNo // 证件号码
  305. inputData["psn_cert_type"] = "01" // 人员证件类型
  306. }
  307. }
  308. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  309. inputData["begntime"] = "" // 开始时间
  310. inputData["psn_name"] = "" // 人员姓名
  311. input["data"] = inputData
  312. inputMessage["input"] = input //交易输入
  313. bytesData, err := json.Marshal(inputMessage)
  314. fmt.Println(string(bytesData))
  315. requestLog = string(bytesData)
  316. if err != nil {
  317. fmt.Println(err.Error())
  318. return err.Error(), ""
  319. }
  320. reader := bytes.NewReader(bytesData)
  321. gdyb_url := beego.AppConfig.String("gdyb_url")
  322. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  323. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  324. url := gdyb_url + "1101"
  325. if mdtrtarea_admvs == "150499" {
  326. url = gdyb_url
  327. }
  328. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  329. request, err := http.NewRequest("POST", url, reader)
  330. if err != nil {
  331. fmt.Println(err.Error())
  332. return err.Error(), ""
  333. }
  334. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  335. request.Header.Set("x-tif-paasid", gdyb_paasid)
  336. request.Header.Set("x-tif-signature", signature)
  337. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  338. request.Header.Set("x-tif-nonce", nonce)
  339. client := http.Client{}
  340. resp, err := client.Do(request)
  341. if err != nil {
  342. fmt.Println(err.Error())
  343. return err.Error(), ""
  344. }
  345. respBytes, err := ioutil.ReadAll(resp.Body)
  346. if err != nil {
  347. fmt.Println(err.Error())
  348. return err.Error(), ""
  349. }
  350. fmt.Println(string(respBytes))
  351. str := string(respBytes)
  352. return str, requestLog
  353. }
  354. type DiseinfoStruct struct {
  355. PsnNo string
  356. DiagType string
  357. MaindiagFlag string
  358. DiagSrtNo string
  359. DiagCode string
  360. DiagName string
  361. DiagDept string
  362. DiseDorNo string
  363. DiseDorName string
  364. DiagTime string
  365. }
  366. type Struct2401 struct {
  367. PsnNo string
  368. Insutype string
  369. MdtrtCertType string
  370. MdtrtCertNo string
  371. MedType string
  372. IptNo string
  373. AtddrNo string
  374. ChfpdrName string
  375. AdmDiagDscr string
  376. AdmDeptCodg string
  377. AdmDeptName string
  378. AdmBed string
  379. DscgMaindiagCode string
  380. DscgMaindiagName string
  381. Diseinfo []DiseinfoStruct
  382. Begntime string
  383. DiseCodg string
  384. DiseName string
  385. Cardsn string
  386. PsnCertType string
  387. Certno string
  388. PsnType int64
  389. PsnName string
  390. }
  391. // 住院登记
  392. func ZHGdyb2401(struct2401 Struct2401, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string) (string, string) {
  393. // 生成签名
  394. nonce := GetRandomString(32)
  395. timestamp := time.Now().Unix()
  396. signature := setSignature(timestamp, nonce, secret_key)
  397. //tempTime := time.Unix(timestamp, 0)
  398. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  399. // 生成输入报文
  400. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  401. input := make(map[string]interface{})
  402. inputData := make(map[string]interface{})
  403. inputMessage["infno"] = "2401" // 交易编码
  404. inputData["psn_no"] = struct2401.PsnNo // 人员编号 (来自1101接口返回)
  405. inputData["insutype"] = struct2401.Insutype // 险种类型(来自1101接口返回)
  406. inputData["tel"] = ""
  407. inputData["coner_name"] = ""
  408. inputData["begntime"] = struct2401.Begntime // 开始时间
  409. inputData["mdtrt_cert_type"] = struct2401.MdtrtCertType // 就诊凭证类型
  410. inputData["mdtrt_cert_no"] = struct2401.MdtrtCertNo // 就诊凭证编号
  411. inputData["med_type"] = struct2401.MedType // 就诊凭证编号
  412. inputData["ipt_no"] = struct2401.IptNo // 住院/门诊号
  413. inputData["medrcdno"] = ""
  414. inputData["atddr_no"] = struct2401.AtddrNo
  415. inputData["chfpdr_name"] = struct2401.ChfpdrName
  416. inputData["adm_diag_dscr"] = struct2401.AdmDiagDscr
  417. inputData["adm_dept_codg"] = struct2401.AdmDeptCodg
  418. inputData["adm_dept_name"] = struct2401.AdmDeptName
  419. inputData["adm_bed"] = struct2401.AdmBed
  420. inputData["dscg_maindiag_code"] = struct2401.DscgMaindiagCode
  421. inputData["dscg_maindiag_name"] = struct2401.DscgMaindiagName
  422. inputData["main_cond_dscr"] = ""
  423. inputData["dise_codg"] = struct2401.DiseCodg
  424. inputData["dise_name"] = struct2401.DiseName
  425. inputData["oprn_oprt_code"] = ""
  426. inputData["oprn_oprt_name"] = ""
  427. inputData["fpsc_no"] = ""
  428. inputData["matn_type"] = ""
  429. inputData["birctrl_type"] = ""
  430. inputData["latechb_flag"] = ""
  431. inputData["geso_val"] = ""
  432. inputData["fetts"] = ""
  433. inputData["fetus_cnt"] = ""
  434. inputData["pret_flag"] = ""
  435. inputData["birctrl_matn_date"] = ""
  436. inputData["dise_type_code"] = ""
  437. inputDataArr := make([]map[string]interface{}, 0)
  438. for _, item := range struct2401.Diseinfo {
  439. inputDataTwo := make(map[string]interface{})
  440. inputDataTwo["psn_no"] = item.PsnNo
  441. inputDataTwo["diag_type"] = item.DiagType
  442. inputDataTwo["maindiag_flag"] = item.MaindiagFlag
  443. inputDataTwo["diag_srt_no"] = item.DiagSrtNo
  444. inputDataTwo["diag_code"] = item.DiagCode
  445. inputDataTwo["diag_name"] = item.DiagName
  446. inputDataTwo["adm_cond"] = ""
  447. inputDataTwo["diag_dept"] = item.DiagDept
  448. inputDataTwo["dise_dor_no"] = item.DiseDorNo
  449. inputDataTwo["dise_dor_name"] = item.DiseDorName
  450. inputDataTwo["diag_time"] = item.DiagTime
  451. inputDataArr = append(inputDataArr, inputDataTwo)
  452. }
  453. input["mdtrtinfo"] = inputData
  454. input["diseinfo"] = inputDataArr
  455. inputMessage["input"] = input //交易输入
  456. bytesData, err := json.Marshal(inputMessage)
  457. fmt.Println(string(bytesData))
  458. requestLog := string(bytesData)
  459. if err != nil {
  460. fmt.Println(err.Error())
  461. return err.Error(), ""
  462. }
  463. reader := bytes.NewReader(bytesData)
  464. gdyb_url := beego.AppConfig.String("gdyb_url")
  465. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  466. url := gdyb_url + "2401"
  467. if mdtrtarea_admvs == "150499" {
  468. url = gdyb_url
  469. }
  470. request, err := http.NewRequest("POST", url, reader)
  471. if err != nil {
  472. fmt.Println(err.Error())
  473. return err.Error(), ""
  474. }
  475. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  476. request.Header.Set("x-tif-paasid", gdyb_paasid)
  477. request.Header.Set("x-tif-signature", signature)
  478. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  479. request.Header.Set("x-tif-nonce", nonce)
  480. client := http.Client{}
  481. resp, err := client.Do(request)
  482. if err != nil {
  483. fmt.Println(err.Error())
  484. return err.Error(), ""
  485. }
  486. respBytes, err := ioutil.ReadAll(resp.Body)
  487. if err != nil {
  488. fmt.Println(err.Error())
  489. return err.Error(), ""
  490. }
  491. str := string(respBytes)
  492. fmt.Println(str)
  493. return str, requestLog
  494. }
  495. //住院撤销
  496. func ZHGdyb2404(mdtrt_id string, psn_no string, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string) (string, string) {
  497. // 生成签名
  498. nonce := GetRandomString(32)
  499. timestamp := time.Now().Unix()
  500. signature := setSignature(timestamp, nonce, secret_key)
  501. // 生成输入报文
  502. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  503. input := make(map[string]interface{})
  504. inputData := make(map[string]interface{})
  505. inputMessage["infno"] = "2404" // 交易编码
  506. inputData["mdtrt_id"] = mdtrt_id // 人员编号 (来自1101接口返回)
  507. inputData["psn_no"] = psn_no // 人员编号 (来自1101接口返回)
  508. input["data"] = inputData
  509. inputMessage["input"] = input //交易输入
  510. bytesData, err := json.Marshal(inputMessage)
  511. fmt.Println(string(bytesData))
  512. requestLog := string(bytesData)
  513. if err != nil {
  514. fmt.Println(err.Error())
  515. return err.Error(), ""
  516. }
  517. reader := bytes.NewReader(bytesData)
  518. gdyb_url := beego.AppConfig.String("gdyb_url")
  519. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  520. url := gdyb_url + "2404"
  521. if mdtrtarea_admvs == "150499" {
  522. url = gdyb_url
  523. }
  524. request, err := http.NewRequest("POST", url, reader)
  525. if err != nil {
  526. fmt.Println(err.Error())
  527. return err.Error(), ""
  528. }
  529. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  530. request.Header.Set("x-tif-paasid", gdyb_paasid)
  531. request.Header.Set("x-tif-signature", signature)
  532. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  533. request.Header.Set("x-tif-nonce", nonce)
  534. client := http.Client{}
  535. resp, err := client.Do(request)
  536. if err != nil {
  537. fmt.Println(err.Error())
  538. return err.Error(), ""
  539. }
  540. respBytes, err := ioutil.ReadAll(resp.Body)
  541. if err != nil {
  542. fmt.Println(err.Error())
  543. return err.Error(), ""
  544. }
  545. str := string(respBytes)
  546. fmt.Println(str)
  547. return str, requestLog
  548. }
  549. //出院撤销
  550. func ZHGdyb2405(mdtrt_id string, psn_no string, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string) (string, string) {
  551. // 生成签名
  552. nonce := GetRandomString(32)
  553. timestamp := time.Now().Unix()
  554. signature := setSignature(timestamp, nonce, secret_key)
  555. // 生成输入报文
  556. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  557. input := make(map[string]interface{})
  558. inputData := make(map[string]interface{})
  559. inputMessage["infno"] = "2405" // 交易编码
  560. inputData["mdtrt_id"] = mdtrt_id // 人员编号 (来自1101接口返回)
  561. inputData["psn_no"] = psn_no // 人员编号 (来自1101接口返回)
  562. input["data"] = inputData
  563. inputMessage["input"] = input //交易输入
  564. bytesData, err := json.Marshal(inputMessage)
  565. fmt.Println(string(bytesData))
  566. requestLog := string(bytesData)
  567. if err != nil {
  568. fmt.Println(err.Error())
  569. return err.Error(), ""
  570. }
  571. reader := bytes.NewReader(bytesData)
  572. gdyb_url := beego.AppConfig.String("gdyb_url")
  573. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  574. url := gdyb_url + "2405"
  575. if mdtrtarea_admvs == "150499" {
  576. url = gdyb_url
  577. }
  578. request, err := http.NewRequest("POST", url, reader)
  579. if err != nil {
  580. fmt.Println(err.Error())
  581. return err.Error(), ""
  582. }
  583. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  584. request.Header.Set("x-tif-paasid", gdyb_paasid)
  585. request.Header.Set("x-tif-signature", signature)
  586. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  587. request.Header.Set("x-tif-nonce", nonce)
  588. client := http.Client{}
  589. resp, err := client.Do(request)
  590. if err != nil {
  591. fmt.Println(err.Error())
  592. return err.Error(), ""
  593. }
  594. respBytes, err := ioutil.ReadAll(resp.Body)
  595. if err != nil {
  596. fmt.Println(err.Error())
  597. return err.Error(), ""
  598. }
  599. str := string(respBytes)
  600. fmt.Println(str)
  601. return str, requestLog
  602. }
  603. type Diseinfo2402Struct struct {
  604. MdtrtId string
  605. PsnNo string
  606. DiagType string
  607. MaindiagFlag string
  608. DiagSrtNo string
  609. DiagCode string
  610. DiagName string
  611. DiagDept string
  612. DiseDorNo string
  613. DiseDorName string
  614. DiagTime string
  615. }
  616. type Struct2402 struct {
  617. MdtrtId string
  618. PsnNo string
  619. Insutype string
  620. Endtime string
  621. DscgDeptCodg string
  622. DscgDeptName string
  623. DscgWay string
  624. Diseinfo []Diseinfo2402Struct
  625. DiseName string
  626. DiseCode string
  627. }
  628. // 出院
  629. func ZHGdyb2402(struct2402 Struct2402, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string) (string, string) {
  630. // 生成签名
  631. nonce := GetRandomString(32)
  632. timestamp := time.Now().Unix()
  633. signature := setSignature(timestamp, nonce, secret_key)
  634. //tempTime := time.Unix(timestamp, 0)
  635. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  636. // 生成输入报文
  637. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  638. input := make(map[string]interface{})
  639. inputData := make(map[string]interface{})
  640. inputMessage["infno"] = "2402" // 交易编码
  641. inputData["mdtrt_id"] = struct2402.MdtrtId // 人员编号 (来自1101接口返回)
  642. inputData["psn_no"] = struct2402.PsnNo // 人员编号 (来自1101接口返回)
  643. inputData["insutype"] = struct2402.Insutype // 险种类型(来自1101接口返回)
  644. inputData["endtime"] = struct2402.Endtime // 结束时间
  645. inputData["dise_codg"] = struct2402.DiseCode // 就诊凭证类型
  646. inputData["dise_name"] = struct2402.DiseName // 就诊凭证类型
  647. inputData["oprn_oprt_code"] = "" // 就诊凭证类型
  648. inputData["oprn_oprt_name"] = "" // 就诊凭证类型
  649. inputData["fpsc_no"] = "" // 就诊凭证类型
  650. inputData["matn_type"] = "" // 就诊凭证类型
  651. inputData["birctrl_type"] = "" // 就诊凭证类型
  652. inputData["latechb_flag"] = "" // 就诊凭证类型
  653. inputData["geso_val"] = ""
  654. inputData["fetts"] = ""
  655. inputData["fetus_cnt"] = ""
  656. inputData["pret_flag"] = ""
  657. inputData["birctrl_matn_date"] = ""
  658. inputData["cop_flag"] = ""
  659. inputData["dscg_dept_codg"] = struct2402.DscgDeptCodg
  660. inputData["dscg_dept_name"] = struct2402.DscgDeptName
  661. inputData["dscg_bed"] = "待定"
  662. inputData["dscg_way"] = struct2402.DscgWay
  663. inputData["die_date"] = ""
  664. inputDataArr := make([]map[string]interface{}, 0)
  665. for _, item := range struct2402.Diseinfo {
  666. inputDataTwo := make(map[string]interface{})
  667. inputDataTwo["psn_no"] = item.PsnNo
  668. inputDataTwo["mdtrt_id"] = item.MdtrtId
  669. inputDataTwo["diag_type"] = item.DiagType
  670. inputDataTwo["maindiag_flag"] = item.MaindiagFlag
  671. inputDataTwo["diag_srt_no"] = item.DiagSrtNo
  672. inputDataTwo["diag_code"] = item.DiagCode
  673. inputDataTwo["diag_name"] = item.DiagName
  674. inputDataTwo["diag_dept"] = item.DiagDept
  675. inputDataTwo["dise_dor_no"] = item.DiseDorNo
  676. inputDataTwo["dise_dor_name"] = item.DiseDorName
  677. inputDataTwo["diag_time"] = item.DiagTime
  678. inputDataArr = append(inputDataArr, inputDataTwo)
  679. }
  680. input["dscginfo"] = inputData
  681. input["diseinfo"] = inputDataArr
  682. inputMessage["input"] = input //交易输入
  683. bytesData, err := json.Marshal(inputMessage)
  684. fmt.Println(string(bytesData))
  685. request_log := string(bytesData)
  686. if err != nil {
  687. fmt.Println(err.Error())
  688. return err.Error(), ""
  689. }
  690. reader := bytes.NewReader(bytesData)
  691. gdyb_url := beego.AppConfig.String("gdyb_url")
  692. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  693. url := gdyb_url + "2402"
  694. if mdtrtarea_admvs == "150499" {
  695. url = gdyb_url
  696. }
  697. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2202"
  698. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
  699. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
  700. request, err := http.NewRequest("POST", url, reader)
  701. if err != nil {
  702. fmt.Println(err.Error())
  703. return err.Error(), ""
  704. }
  705. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  706. //request.Header.Set("x-tif-paasid", "test_hosp")
  707. request.Header.Set("x-tif-paasid", gdyb_paasid)
  708. request.Header.Set("x-tif-signature", signature)
  709. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  710. request.Header.Set("x-tif-nonce", nonce)
  711. client := http.Client{}
  712. resp, err := client.Do(request)
  713. if err != nil {
  714. fmt.Println(err.Error())
  715. return err.Error(), ""
  716. }
  717. respBytes, err := ioutil.ReadAll(resp.Body)
  718. if err != nil {
  719. fmt.Println(err.Error())
  720. return err.Error(), ""
  721. }
  722. str := string(respBytes)
  723. fmt.Println(str)
  724. return str, request_log
  725. }
  726. type ZHCustom struct {
  727. DetItemFeeSumamt string
  728. Cut string
  729. FeedetlSn string
  730. Price string
  731. MedListCodg string
  732. LmtUsedFlag int64
  733. HospApprFlag int64
  734. }
  735. type ZHRequestResult struct {
  736. Output ZHOutput `json:"output" form:"output"`
  737. Infcode int64 `gorm:"column:infcode" json:"infcode" form:"infcode"`
  738. WarnMsg string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
  739. Cainfo string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
  740. ErrMsg string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
  741. RespondTime string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
  742. InfRefmsgid string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
  743. }
  744. type ZHOutput struct {
  745. Result Result `json:"result" form:"result"`
  746. }
  747. type ZHResult struct {
  748. BasMednFlag string `json:"bas_medn_flag" form:"bas_medn_flag"`
  749. MedChrgitmType string `json:"med_chrgitm_type" form:"med_chrgitm_type"`
  750. DetItemFeeSumamt int64 `json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
  751. HiNegoDrugFlag string `json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
  752. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  753. FeedtlSn int64 `json:"feedtl_sn" form:"feedtl_sn"`
  754. UploadDate int64 `json:"upload_date" form:"upload_date"`
  755. AdviceId int64 `json:"advice_id" form:"advice_id"`
  756. Cnt int64 `json:"cnt" form:"cnt"`
  757. Pric float64 `json:"pric" form:"pric"`
  758. PatientId int64 `json:"patient_id" form:"patient_id"`
  759. PricUplmtAmt float64 `json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
  760. SelfpayProp float64 `json:"selfpay_prop" form:"selfpay_prop"`
  761. OverlmtAmt float64 `json:"overlmt_amt" form:"overlmt_amt"`
  762. PreselfpayAmt float64 `json:"preselfpay_amt" form:"preselfpay_amt"`
  763. Status int64 `json:"status" form:"status"`
  764. Memo string `json:"memo" form:"memo"`
  765. FeedetlSn string `json:"feedetl_sn" form:"feedetl_sn"`
  766. Mtime int64 `json:"mtime" form:"mtime"`
  767. InscpScpAmt float64 `json:"inscp_scp_amt" form:"inscp_scp_amt"`
  768. DrtReimFlag string `json:"drt_reim_flag" form:"drt_reim_flag"`
  769. Ctime int64 `json:"ctime" form:"ctime"`
  770. ListSpItemFlag string `json:"list_sp_item_flag" form:"list_sp_item_flag"`
  771. ChldMedcFlag string `json:"chld_medc_flag" form:"chld_medc_flag"`
  772. LmtUsedFlag string `json:"lmt_used_flag" form:"lmt_used_flag"`
  773. ChrgitmLv string `json:"chrgitm_lv" form:"chrgitm_lv"`
  774. UserOrgId int64 `json:"user_org_id" form:"user_org_id"`
  775. HisPatientId int64 `json:"his_patient_id" form:"his_patient_id"`
  776. OrderId int64 `json:"order_id" form:"order_id"`
  777. }
  778. // 住院费用明细信息上传
  779. func ZHGdyb2301(psnNo string, mdtrtId string, hisPrescription []*models.NewCustom, 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, med_type string, doctor_name string, doctor_number string) (string, string) {
  780. // 生成签名
  781. nonce := GetRandomString(32)
  782. timestamp := time.Now().Unix()
  783. signature := setSignature(timestamp, nonce, secret_key)
  784. //tempTime := time.Unix(timestamp, 0)
  785. //timeFormat := tempTime.Format("20060102150405")
  786. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  787. //chrgBchno := rand.Intn(100000) + 10000
  788. var customs []*models.NewCustom
  789. customs = hisPrescription
  790. // 生成输入报文
  791. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  792. input := make(map[string]interface{})
  793. feedetail := make([]map[string]interface{}, 0)
  794. inputMessage["infno"] = "2301" // 交易编码
  795. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  796. for _, item := range customs {
  797. org_id, _ := beego.AppConfig.Int64("org_id")
  798. doctor_info, _ := GetAdminUserInfoByID(org_id, item.DoctorId)
  799. feedetailInfo := make(map[string]interface{})
  800. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  801. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  802. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  803. feedetailInfo["med_type"] = med_type
  804. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  805. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  806. feedetailInfo["medins_list_codg"] = fixmedins_code // 医药机构目录编码
  807. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  808. feedetailInfo["cnt"] = item.Cut // 数量
  809. feedetailInfo["pric"] = item.Price // 单价
  810. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  811. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  812. feedetailInfo["bilg_dr_codg"] = doctor_info.DoctorNumber // 开单医生编码
  813. feedetailInfo["bilg_dr_name"] = doctor_info.UserName
  814. feedetailInfo["acord_dept_codg"] = dept_code // 受单科室编码
  815. feedetailInfo["acord_dept_name"] = dept // 受单科室名称
  816. feedetailInfo["orders_dr_code"] = doctor_info.DoctorNumber // 受单医生编码
  817. feedetailInfo["orders_dr_name"] = doctor_info.UserName // 受单医生姓名
  818. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  819. feedetailInfo["dise_codg"] = "" // 病种编码
  820. feedetailInfo["rxno"] = "" // 处方号
  821. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  822. feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
  823. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  824. feedetailInfo["prd_days"] = "0" // 周期天数
  825. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  826. // 开单医师姓名
  827. if item.HospApprFlag != -1 {
  828. if item.HospApprFlag == 1 {
  829. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  830. } else if item.HospApprFlag == 2 {
  831. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  832. } else if item.HospApprFlag == 3 {
  833. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  834. } else {
  835. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  836. }
  837. } else {
  838. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  839. }
  840. //feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  841. feedetailInfo["etip_flag"] = "" // 外检标志
  842. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  843. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  844. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  845. feedetail = append(feedetail, feedetailInfo)
  846. }
  847. input["feedetail"] = feedetail
  848. inputMessage["input"] = input //交易输入
  849. bytesData, err := json.Marshal(inputMessage)
  850. fmt.Println("----------")
  851. fmt.Println(string(bytesData))
  852. fmt.Println("----------")
  853. requestLog := string(bytesData)
  854. if err != nil {
  855. fmt.Println(err.Error())
  856. return "", ""
  857. }
  858. reader := bytes.NewReader(bytesData)
  859. gdyb_url := beego.AppConfig.String("gdyb_url")
  860. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  861. url := gdyb_url + "2301"
  862. if mdtrtarea_admvs == "150499" {
  863. url = gdyb_url
  864. }
  865. request, err := http.NewRequest("POST", url, reader)
  866. if err != nil {
  867. fmt.Println(err.Error())
  868. return "", ""
  869. }
  870. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  871. request.Header.Set("x-tif-paasid", gdyb_paasid)
  872. request.Header.Set("x-tif-signature", signature)
  873. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  874. request.Header.Set("x-tif-nonce", nonce)
  875. client := http.Client{}
  876. resp, err := client.Do(request)
  877. if err != nil {
  878. fmt.Println(err.Error())
  879. return "", ""
  880. }
  881. respBytes, err := ioutil.ReadAll(resp.Body)
  882. if err != nil {
  883. fmt.Println(err.Error())
  884. return "", ""
  885. }
  886. return string(respBytes), requestLog
  887. }
  888. func ZHGdyb2301A(psnNo string, mdtrtId string, hisPrescription []*models.NewCustom, 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, med_type string, opertor string) (string, string) {
  889. // 生成签名
  890. nonce := GetRandomString(32)
  891. timestamp := time.Now().Unix()
  892. signature := setSignature(timestamp, nonce, secret_key)
  893. //tempTime := time.Unix(timestamp, 0)
  894. //timeFormat := tempTime.Format("20060102150405")
  895. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  896. //chrgBchno := rand.Intn(100000) + 10000
  897. var customs []*models.NewCustom
  898. customs = hisPrescription
  899. // 生成输入报文
  900. inputMessage := SetInputMessage(nonce, timestamp, org_name, opertor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  901. input := make(map[string]interface{})
  902. feedetail := make([]map[string]interface{}, 0)
  903. inputMessage["infno"] = "2301" // 交易编码
  904. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  905. for _, item := range customs {
  906. feedetailInfo := make(map[string]interface{})
  907. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  908. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  909. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  910. feedetailInfo["med_type"] = med_type
  911. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  912. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  913. feedetailInfo["medins_list_codg"] = fixmedins_code // 医药机构目录编码
  914. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  915. feedetailInfo["cnt"] = item.Cut // 数量
  916. feedetailInfo["pric"] = item.Price // 单价
  917. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  918. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  919. feedetailInfo["bilg_dr_codg"] = doctor_id // 开单医生编码
  920. feedetailInfo["bilg_dr_name"] = doctor
  921. feedetailInfo["acord_dept_codg"] = dept_code // 受单科室编码
  922. feedetailInfo["acord_dept_name"] = dept // 受单科室名称
  923. feedetailInfo["orders_dr_code"] = doctor_id // 受单医生编码
  924. feedetailInfo["orders_dr_name"] = doctor // 受单医生姓名
  925. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  926. feedetailInfo["dise_codg"] = "" // 病种编码
  927. feedetailInfo["rxno"] = "" // 处方号
  928. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  929. feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
  930. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  931. feedetailInfo["prd_days"] = "0" // 周期天数
  932. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  933. // 开单医师姓名
  934. if item.HospApprFlag != -1 {
  935. if item.HospApprFlag == 1 {
  936. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  937. } else if item.HospApprFlag == 2 {
  938. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  939. } else if item.HospApprFlag == 3 {
  940. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  941. } else {
  942. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  943. }
  944. } else {
  945. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  946. }
  947. feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  948. feedetailInfo["etip_flag"] = "" // 外检标志
  949. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  950. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  951. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  952. feedetail = append(feedetail, feedetailInfo)
  953. }
  954. input["feedetail"] = feedetail
  955. inputMessage["input"] = input //交易输入
  956. bytesData, err := json.Marshal(inputMessage)
  957. fmt.Println("----------")
  958. fmt.Println(string(bytesData))
  959. fmt.Println("----------")
  960. requestLog := string(bytesData)
  961. if err != nil {
  962. fmt.Println(err.Error())
  963. return "", ""
  964. }
  965. reader := bytes.NewReader(bytesData)
  966. gdyb_url := beego.AppConfig.String("gdyb_url")
  967. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  968. url := gdyb_url + "2301"
  969. if mdtrtarea_admvs == "150499" {
  970. url = gdyb_url
  971. }
  972. request, err := http.NewRequest("POST", url, reader)
  973. if err != nil {
  974. fmt.Println(err.Error())
  975. return "", ""
  976. }
  977. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  978. request.Header.Set("x-tif-paasid", gdyb_paasid)
  979. request.Header.Set("x-tif-signature", signature)
  980. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  981. request.Header.Set("x-tif-nonce", nonce)
  982. client := http.Client{}
  983. resp, err := client.Do(request)
  984. if err != nil {
  985. fmt.Println(err.Error())
  986. return "", ""
  987. }
  988. respBytes, err := ioutil.ReadAll(resp.Body)
  989. if err != nil {
  990. fmt.Println(err.Error())
  991. return "", ""
  992. }
  993. return string(respBytes), requestLog
  994. }
  995. // 住院费用明细信息撤销
  996. func Gdyb2302(psnNo string, mdtrtId string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string, number string, refund_type int64) (string, string) {
  997. // 生成签名
  998. nonce := GetRandomString(32)
  999. timestamp := time.Now().Unix()
  1000. signature := setSignature(timestamp, nonce, secret_key)
  1001. // 生成输入报文
  1002. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1003. input := make(map[string]interface{})
  1004. inputData := make(map[string]interface{})
  1005. inputMessage["infno"] = "2302" // 交易编码
  1006. if refund_type == 1 {
  1007. inputData["feedetl_sn"] = number //
  1008. } else {
  1009. inputData["feedetl_sn"] = "0000" //
  1010. }
  1011. inputData["mdtrt_id"] = mdtrtId // 就诊 ID
  1012. inputData["psn_no"] = psnNo // 人员编号
  1013. input["data"] = inputData
  1014. inputMessage["input"] = input //交易输入
  1015. bytesData, err := json.Marshal(inputMessage)
  1016. fmt.Println(string(bytesData))
  1017. requestLog := string(bytesData)
  1018. if err != nil {
  1019. fmt.Println(err.Error())
  1020. return err.Error(), ""
  1021. }
  1022. reader := bytes.NewReader(bytesData)
  1023. gdyb_url := beego.AppConfig.String("gdyb_url")
  1024. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1025. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1026. url := gdyb_url + "2302"
  1027. if mdtrtarea_admvs == "150499" {
  1028. url = gdyb_url
  1029. }
  1030. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2205"
  1031. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
  1032. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
  1033. request, err := http.NewRequest("POST", url, reader)
  1034. fmt.Println(err)
  1035. fmt.Println(request)
  1036. if err != nil {
  1037. fmt.Println(err.Error())
  1038. return err.Error(), ""
  1039. }
  1040. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1041. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1042. request.Header.Set("x-tif-signature", signature)
  1043. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1044. request.Header.Set("x-tif-nonce", nonce)
  1045. client := http.Client{}
  1046. resp, err := client.Do(request)
  1047. if err != nil {
  1048. fmt.Println(err.Error())
  1049. return err.Error(), ""
  1050. }
  1051. respBytes, err := ioutil.ReadAll(resp.Body)
  1052. if err != nil {
  1053. fmt.Println(err.Error())
  1054. return err.Error(), ""
  1055. }
  1056. str := string(respBytes)
  1057. fmt.Println(str)
  1058. return str, requestLog
  1059. }
  1060. func ZHGdyb2303(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, mid_setl_flag string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64) (string, string) {
  1061. // 生成签名
  1062. nonce := GetRandomString(32)
  1063. timestamp := time.Now().Unix()
  1064. signature := setSignature(timestamp, nonce, secret_key)
  1065. // 生成输入报文
  1066. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1067. input := make(map[string]interface{})
  1068. inputData := make(map[string]interface{})
  1069. inputMessage["infno"] = "2303" // 交易编码
  1070. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1071. if certificates == 3 {
  1072. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1073. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1074. } else {
  1075. if id_card_type == 1 {
  1076. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1077. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1078. } else {
  1079. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1080. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1081. }
  1082. }
  1083. inputData["mdtrt_cert_sn"] = ""
  1084. inputData["mid_setl_flag"] = mid_setl_flag // 中途退费标志
  1085. inputData["medfee_sumamt"] = total // 医疗费总额
  1086. inputData["psn_setlway"] = "02" // 个人结算方式 01 按项目结 02 按定额结算
  1087. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1088. inputData["acct_used_flag"] = "1" // 个人账户使用标志 0否 1是
  1089. inputData["insutype"] = insutype // 险种类型
  1090. inputData["invono"] = "" // 发票号
  1091. inputData["dise_codg"] = "M07803" // 发票号
  1092. input["data"] = inputData
  1093. inputMessage["input"] = input //交易输入
  1094. bytesData, err := json.Marshal(inputMessage)
  1095. fmt.Println(string(bytesData))
  1096. if err != nil {
  1097. fmt.Println(err.Error())
  1098. return err.Error(), ""
  1099. }
  1100. reader := bytes.NewReader(bytesData)
  1101. gdyb_url := beego.AppConfig.String("gdyb_url")
  1102. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1103. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1104. url := gdyb_url + "2303"
  1105. if mdtrtarea_admvs == "150499" {
  1106. url = gdyb_url
  1107. }
  1108. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
  1109. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1110. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1111. request, err := http.NewRequest("POST", url, reader)
  1112. if err != nil {
  1113. fmt.Println(err.Error())
  1114. return err.Error(), ""
  1115. }
  1116. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1117. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1118. request.Header.Set("x-tif-signature", signature)
  1119. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1120. request.Header.Set("x-tif-nonce", nonce)
  1121. client := http.Client{}
  1122. resp, err := client.Do(request)
  1123. if err != nil {
  1124. fmt.Println(err.Error())
  1125. return err.Error(), ""
  1126. }
  1127. respBytes, err := ioutil.ReadAll(resp.Body)
  1128. if err != nil {
  1129. fmt.Println(err.Error())
  1130. return err.Error(), ""
  1131. }
  1132. str := string(respBytes)
  1133. fmt.Println(str)
  1134. mjson, _ := json.Marshal(inputMessage)
  1135. str2 := string(mjson)
  1136. return str, str2
  1137. }
  1138. // 住院结算
  1139. func ZHGdyb2304(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, mid_setl_flag string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64, fapiao_number string, acct_used_flag string) (string, string) {
  1140. // 生成签名
  1141. nonce := GetRandomString(32)
  1142. timestamp := time.Now().Unix()
  1143. signature := setSignature(timestamp, nonce, secret_key)
  1144. // 生成输入报文
  1145. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1146. input := make(map[string]interface{})
  1147. inputData := make(map[string]interface{})
  1148. inputMessage["infno"] = "2304" // 交易编码
  1149. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1150. if certificates == 3 {
  1151. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1152. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1153. } else {
  1154. if id_card_type == 1 {
  1155. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1156. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1157. } else if id_card_type == 4 {
  1158. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  1159. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1160. } else {
  1161. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1162. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1163. }
  1164. }
  1165. inputData["mdtrt_cert_sn"] = ""
  1166. inputData["mid_setl_flag"] = mid_setl_flag // 中途退费标志
  1167. inputData["medfee_sumamt"] = total // 医疗费总额
  1168. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1169. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1170. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  1171. inputData["insutype"] = insutype // 险种类型
  1172. inputData["invono"] = fapiao_number // 发票号
  1173. input["data"] = inputData
  1174. inputMessage["input"] = input //交易输入
  1175. bytesData, err := json.Marshal(inputMessage)
  1176. fmt.Println(string(bytesData))
  1177. if err != nil {
  1178. fmt.Println(err.Error())
  1179. return err.Error(), ""
  1180. }
  1181. reader := bytes.NewReader(bytesData)
  1182. gdyb_url := beego.AppConfig.String("gdyb_url")
  1183. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1184. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1185. url := gdyb_url + "2304"
  1186. if mdtrtarea_admvs == "150499" {
  1187. url = gdyb_url
  1188. }
  1189. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
  1190. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1191. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1192. request, err := http.NewRequest("POST", url, reader)
  1193. if err != nil {
  1194. fmt.Println(err.Error())
  1195. return err.Error(), ""
  1196. }
  1197. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1198. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1199. request.Header.Set("x-tif-signature", signature)
  1200. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1201. request.Header.Set("x-tif-nonce", nonce)
  1202. client := http.Client{}
  1203. resp, err := client.Do(request)
  1204. if err != nil {
  1205. fmt.Println(err.Error())
  1206. return err.Error(), ""
  1207. }
  1208. respBytes, err := ioutil.ReadAll(resp.Body)
  1209. if err != nil {
  1210. fmt.Println(err.Error())
  1211. return err.Error(), ""
  1212. }
  1213. str := string(respBytes)
  1214. fmt.Println(str)
  1215. mjson, _ := json.Marshal(inputMessage)
  1216. str2 := string(mjson)
  1217. return str, str2
  1218. }
  1219. func Gdyb26011(psnNo string, omsgid string, oinfno string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  1220. // 生成签名
  1221. nonce := GetRandomString(32)
  1222. timestamp := time.Now().Unix()
  1223. signature := setSignature(timestamp, nonce, secret_key)
  1224. // 生成输入报文
  1225. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1226. input := make(map[string]interface{})
  1227. inputData := make(map[string]interface{})
  1228. inputMessage["infno"] = "2601" // 交易编码
  1229. inputData["psn_no"] = psnNo
  1230. inputData["omsgid"] = omsgid
  1231. inputData["oinfno"] = oinfno
  1232. input["data"] = inputData
  1233. inputMessage["input"] = input //交易输入
  1234. bytesData, err := json.Marshal(inputMessage)
  1235. fmt.Println(string(bytesData))
  1236. if err != nil {
  1237. fmt.Println(err.Error())
  1238. return err.Error()
  1239. }
  1240. reader := bytes.NewReader(bytesData)
  1241. gdyb_url := beego.AppConfig.String("gdyb_url")
  1242. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1243. url := gdyb_url + "2601"
  1244. if mdtrtarea_admvs == "150499" {
  1245. url = gdyb_url
  1246. }
  1247. request, err := http.NewRequest("POST", url, reader)
  1248. if err != nil {
  1249. fmt.Println(err.Error())
  1250. return err.Error()
  1251. }
  1252. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1253. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1254. request.Header.Set("x-tif-signature", signature)
  1255. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1256. request.Header.Set("x-tif-nonce", nonce)
  1257. client := http.Client{}
  1258. resp, err := client.Do(request)
  1259. if err != nil {
  1260. fmt.Println(err.Error())
  1261. return err.Error()
  1262. }
  1263. respBytes, err := ioutil.ReadAll(resp.Body)
  1264. if err != nil {
  1265. fmt.Println(err.Error())
  1266. return err.Error()
  1267. }
  1268. str := string(respBytes)
  1269. fmt.Println(str)
  1270. return str
  1271. }
  1272. // 住院结算撤销
  1273. func Gdyb2305(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) (string, string) {
  1274. // 生成签名
  1275. nonce := GetRandomString(32)
  1276. timestamp := time.Now().Unix()
  1277. signature := setSignature(timestamp, nonce, secret_key)
  1278. // 生成输入报文
  1279. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1280. input := make(map[string]interface{})
  1281. inputData := make(map[string]interface{})
  1282. inputMessage["infno"] = "2305" // 交易编码
  1283. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1284. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1285. inputData["setl_id"] = setlId // 结算 ID
  1286. input["data"] = inputData
  1287. inputMessage["input"] = input //交易输入
  1288. bytesData, err := json.Marshal(inputMessage)
  1289. fmt.Println(string(bytesData))
  1290. if err != nil {
  1291. fmt.Println(err.Error())
  1292. return err.Error(), ""
  1293. }
  1294. reader := bytes.NewReader(bytesData)
  1295. gdyb_url := beego.AppConfig.String("gdyb_url")
  1296. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1297. url := gdyb_url + "2305"
  1298. if mdtrtarea_admvs == "150499" {
  1299. url = gdyb_url
  1300. }
  1301. request, err := http.NewRequest("POST", url, reader)
  1302. if err != nil {
  1303. fmt.Println(err.Error())
  1304. return err.Error(), ""
  1305. }
  1306. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1307. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1308. request.Header.Set("x-tif-signature", signature)
  1309. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1310. request.Header.Set("x-tif-nonce", nonce)
  1311. client := http.Client{}
  1312. resp, err := client.Do(request)
  1313. if err != nil {
  1314. fmt.Println(err.Error())
  1315. return err.Error(), ""
  1316. }
  1317. respBytes, err := ioutil.ReadAll(resp.Body)
  1318. if err != nil {
  1319. fmt.Println(err.Error())
  1320. return err.Error(), ""
  1321. }
  1322. str := string(respBytes)
  1323. fmt.Println(str)
  1324. mjson, _ := json.Marshal(inputMessage)
  1325. str2 := string(mjson)
  1326. return str, str2
  1327. }
  1328. func Gdyb90306(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) (string, string) {
  1329. // 生成签名
  1330. nonce := GetRandomString(32)
  1331. timestamp := time.Now().Unix()
  1332. signature := setSignature(timestamp, nonce, secret_key)
  1333. // 生成输入报文
  1334. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1335. input := make(map[string]interface{})
  1336. inputData := make(map[string]interface{})
  1337. inputMessage["infno"] = "90306" // 交易编码
  1338. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1339. inputData["setl_id"] = setlId // 结算 ID
  1340. input["data"] = inputData
  1341. inputMessage["input"] = input //交易输入
  1342. bytesData, err := json.Marshal(inputMessage)
  1343. fmt.Println(string(bytesData))
  1344. if err != nil {
  1345. fmt.Println(err.Error())
  1346. return err.Error(), ""
  1347. }
  1348. reader := bytes.NewReader(bytesData)
  1349. gdyb_url := beego.AppConfig.String("gdyb_url")
  1350. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1351. url := gdyb_url + "90306"
  1352. if mdtrtarea_admvs == "150499" {
  1353. url = gdyb_url
  1354. }
  1355. request, err := http.NewRequest("POST", url, reader)
  1356. if err != nil {
  1357. fmt.Println(err.Error())
  1358. return err.Error(), ""
  1359. }
  1360. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1361. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1362. request.Header.Set("x-tif-signature", signature)
  1363. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1364. request.Header.Set("x-tif-nonce", nonce)
  1365. client := http.Client{}
  1366. resp, err := client.Do(request)
  1367. if err != nil {
  1368. fmt.Println(err.Error())
  1369. return err.Error(), ""
  1370. }
  1371. respBytes, err := ioutil.ReadAll(resp.Body)
  1372. if err != nil {
  1373. fmt.Println(err.Error())
  1374. return err.Error(), ""
  1375. }
  1376. str := string(respBytes)
  1377. fmt.Println(str)
  1378. mjson, _ := json.Marshal(inputMessage)
  1379. str2 := string(mjson)
  1380. return str, str2
  1381. }
  1382. func CreateHospitalRecord(record *models.HisHospitalCheckRecord) (err error) {
  1383. err = writeDb.Save(&record).Error
  1384. return
  1385. }
  1386. func GetInHospitalRecord(id int64) (record models.HisHospitalCheckRecord, err error) {
  1387. err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("id = ? AND status = 1", id).First(&record).Error
  1388. return
  1389. }
  1390. func GetInHospitalRecordByNumber(number string) (record models.HisHospitalCheckRecord, err error) {
  1391. err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("number = ? AND status = 1", number).First(&record).Error
  1392. return
  1393. }
  1394. func GetLastHospitalRecord(id int64, user_org_id int64) (record models.HisHospitalCheckRecord, err error) {
  1395. err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("id = ? AND status = 1 AND user_org_id = ?", id, user_org_id).Last(&record).Error
  1396. return
  1397. }
  1398. func GetZHHisPrescription(org_id int64, patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
  1399. err = readDb.Model(&models.HisPrescription{}).
  1400. Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
  1401. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
  1402. }).
  1403. Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
  1404. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
  1405. }).
  1406. Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  1407. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1").Preload("GoodInfo", "status = 1")
  1408. }).
  1409. Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND order_status <> 4 AND p_type = 1", org_id, record_date, patient_id).
  1410. Find(&prescription).Error
  1411. return
  1412. }
  1413. func GetZHMonthHisPrescription(org_id int64, patient_id int64, start_time int64, end_time int64) (prescription []*models.HisPrescription, err error) {
  1414. err = readDb.Model(&models.HisPrescription{}).
  1415. Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
  1416. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
  1417. }).
  1418. Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
  1419. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
  1420. }).
  1421. Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  1422. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1").Preload("GoodInfo", "status = 1")
  1423. }).
  1424. Where("user_org_id = ? AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND order_status <> 4 AND status = 1 AND p_type = 1 ", org_id, start_time, end_time, patient_id).
  1425. Find(&prescription).Error
  1426. return
  1427. }
  1428. func GetZHHisUploadPrescription(org_id int64, patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
  1429. err = readDb.Model(&models.HisPrescription{}).
  1430. Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
  1431. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
  1432. }).
  1433. Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
  1434. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
  1435. }).
  1436. Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  1437. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
  1438. }).
  1439. Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status = 4 AND p_type = 1", org_id, record_date, patient_id).
  1440. Find(&prescription).Error
  1441. return
  1442. }
  1443. func GetZHMonthHisUploadPrescription(org_id int64, patient_id int64, start_time int64, end_time int64) (prescription []*models.HisPrescription, err error) {
  1444. err = readDb.Model(&models.HisPrescription{}).
  1445. Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
  1446. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
  1447. }).
  1448. Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
  1449. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
  1450. }).
  1451. Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  1452. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
  1453. }).
  1454. Where("user_org_id = ? AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status == 4 AND status = 1 AND p_type = 1 ", org_id, start_time, end_time, patient_id).
  1455. Find(&prescription).Error
  1456. return
  1457. }
  1458. func GetZHHisUploadOrderInfo(org_id int64, patient_id int64, record_date int64, record_end_date int64, number string) (infos []*models.HisOrderInfo, err error) {
  1459. err = readDb.Model(&models.HisOrderInfo{}).
  1460. Where("user_org_id = ? AND status = 1 AND upload_date <= ? AND upload_date >= ? AND patient_id = ? AND order_number = ? ", org_id, record_end_date, record_date, patient_id, number).
  1461. Find(&infos).Error
  1462. return
  1463. }
  1464. func UpDateOrderInfoStatus(patient_id int64, record_date int64, org_id int64, record_two_date int64) (err error) {
  1465. err = writeDb.Model(&models.HisOrderInfo{}).Where("user_org_id = ? AND status = 1 AND upload_date <= ? AND upload_date >= ? AND patient_id = ?", org_id, record_two_date, record_date, patient_id).Updates(map[string]interface{}{"status": 0}).Error
  1466. return
  1467. }
  1468. func UpDatePrescriptionOrderStatusTwo(patient_id int64, record_date int64, org_id int64) (err error) {
  1469. err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND p_type = 1", org_id, record_date, patient_id).Updates(map[string]interface{}{"order_status": 1}).Error
  1470. return
  1471. }
  1472. //func GetAllOrderInfoByNumber(number string) (infos []*models.HisOrderInfo, err error){
  1473. //
  1474. // err = readDb.Model(&models.HisOrderInfo{}).Where("user_org_id = ? AND ")
  1475. //}
  1476. func GetZHSettleMonthHisPrescription(org_id int64, patient_id int64, start_time int64, end_time int64) (prescription []*models.HisPrescription, err error) {
  1477. err = readDb.Model(&models.HisPrescription{}).
  1478. Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
  1479. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
  1480. }).
  1481. Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
  1482. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
  1483. }).
  1484. Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  1485. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1").Preload("GoodInfo", "status = 1")
  1486. }).
  1487. Where("user_org_id = ? AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND order_status <> 4 AND status = 1 AND p_type = 1 ", org_id, start_time, end_time, patient_id).
  1488. Find(&prescription).Error
  1489. return
  1490. }
  1491. func ZHyb5203(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  1492. fmt.Println("~~~~~~1")
  1493. fmt.Println(baseParams)
  1494. fmt.Println(businessParams)
  1495. // 生成签名
  1496. nonce := GetRandomString(32)
  1497. timestamp := time.Now().Unix()
  1498. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1499. fmt.Println("~~~~~~2")
  1500. // 生成输入报文
  1501. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1502. input := make(map[string]interface{})
  1503. inputData := make(map[string]interface{})
  1504. inputMessage["infno"] = "5203" // 交易编码
  1505. inputData["psn_no"] = businessParams.PsnNo
  1506. inputData["setl_id"] = businessParams.SetlId
  1507. inputData["mdtrt_id"] = businessParams.MdtrtId
  1508. input["data"] = inputData
  1509. inputMessage["input"] = input //交易输入
  1510. bytesData, err := json.Marshal(inputMessage)
  1511. fmt.Println(string(bytesData))
  1512. fmt.Println("~~~~~~")
  1513. fmt.Println("~~~~~~")
  1514. fmt.Println(string(bytesData))
  1515. if err != nil {
  1516. fmt.Println(err.Error())
  1517. return err.Error()
  1518. }
  1519. reader := bytes.NewReader(bytesData)
  1520. gdyb_url := beego.AppConfig.String("gdyb_url")
  1521. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1522. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1523. //url := gdyb_url + "5203"
  1524. var url string
  1525. if baseParams.FixmedinsCode == "H15049901371" {
  1526. url = gdyb_url
  1527. } else {
  1528. url = gdyb_url + "5203"
  1529. }
  1530. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
  1531. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  1532. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  1533. request, err := http.NewRequest("POST", url, reader)
  1534. if err != nil {
  1535. fmt.Println(err.Error())
  1536. return err.Error()
  1537. }
  1538. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1539. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1540. request.Header.Set("x-tif-signature", signature)
  1541. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1542. request.Header.Set("x-tif-nonce", nonce)
  1543. client := http.Client{}
  1544. resp, err := client.Do(request)
  1545. if err != nil {
  1546. fmt.Println(err.Error())
  1547. return err.Error()
  1548. }
  1549. respBytes, err := ioutil.ReadAll(resp.Body)
  1550. if err != nil {
  1551. fmt.Println(err.Error())
  1552. return err.Error()
  1553. }
  1554. str := string(respBytes)
  1555. fmt.Println(str)
  1556. return str
  1557. }
  1558. func ZHyb4102(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  1559. // 生成签名
  1560. nonce := GetRandomString(32)
  1561. timestamp := time.Now().Unix()
  1562. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1563. fmt.Println("~~~~~~2")
  1564. // 生成输入报文
  1565. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1566. input := make(map[string]interface{})
  1567. inputData := make(map[string]interface{})
  1568. inputMessage["infno"] = "4102" // 交易编码
  1569. inputDataDetail := make(map[string]interface{})
  1570. inputDataDetails := make([]map[string]interface{}, 0)
  1571. inputDataDetail["psn_no"] = businessParams.PsnNo
  1572. inputDataDetail["setl_id"] = businessParams.SetlId
  1573. inputDataDetail["stas_type"] = businessParams.StasType
  1574. inputDataDetails = append(inputDataDetails, inputDataDetail)
  1575. inputData["stastinfo"] = inputDataDetails
  1576. input["data"] = inputData
  1577. inputMessage["input"] = input //交易输入
  1578. bytesData, err := json.Marshal(inputMessage)
  1579. fmt.Println(string(bytesData))
  1580. fmt.Println(string(bytesData))
  1581. if err != nil {
  1582. fmt.Println(err.Error())
  1583. return err.Error()
  1584. }
  1585. reader := bytes.NewReader(bytesData)
  1586. gdyb_url := beego.AppConfig.String("gdyb_url")
  1587. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1588. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1589. //url := gdyb_url + "5203"
  1590. var url string
  1591. if baseParams.FixmedinsCode == "H15049901371" {
  1592. url = gdyb_url
  1593. } else {
  1594. url = gdyb_url + "4102"
  1595. }
  1596. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
  1597. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  1598. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  1599. request, err := http.NewRequest("POST", url, reader)
  1600. if err != nil {
  1601. fmt.Println(err.Error())
  1602. return err.Error()
  1603. }
  1604. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1605. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1606. request.Header.Set("x-tif-signature", signature)
  1607. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1608. request.Header.Set("x-tif-nonce", nonce)
  1609. client := http.Client{}
  1610. resp, err := client.Do(request)
  1611. if err != nil {
  1612. fmt.Println(err.Error())
  1613. return err.Error()
  1614. }
  1615. respBytes, err := ioutil.ReadAll(resp.Body)
  1616. if err != nil {
  1617. fmt.Println(err.Error())
  1618. return err.Error()
  1619. }
  1620. str := string(respBytes)
  1621. fmt.Println(str)
  1622. return str
  1623. }
  1624. func ZHyb4103(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  1625. // 生成签名
  1626. nonce := GetRandomString(32)
  1627. timestamp := time.Now().Unix()
  1628. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1629. // 生成输入报文
  1630. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1631. input := make(map[string]interface{})
  1632. inputData := make(map[string]interface{})
  1633. inputMessage["infno"] = "4103" // 交易编码
  1634. inputData["psn_no"] = businessParams.PsnNo
  1635. inputData["setl_id"] = businessParams.SetlId
  1636. input["data"] = inputData
  1637. inputMessage["input"] = input //交易输入
  1638. bytesData, err := json.Marshal(inputMessage)
  1639. fmt.Println(string(bytesData))
  1640. fmt.Println(string(bytesData))
  1641. if err != nil {
  1642. fmt.Println(err.Error())
  1643. return err.Error()
  1644. }
  1645. reader := bytes.NewReader(bytesData)
  1646. gdyb_url := beego.AppConfig.String("gdyb_url")
  1647. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1648. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1649. //url := gdyb_url + "5203"
  1650. var url string
  1651. if baseParams.FixmedinsCode == "H15049901371" {
  1652. url = gdyb_url
  1653. } else {
  1654. url = gdyb_url + "4103"
  1655. }
  1656. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
  1657. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  1658. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  1659. request, err := http.NewRequest("POST", url, reader)
  1660. if err != nil {
  1661. fmt.Println(err.Error())
  1662. return err.Error()
  1663. }
  1664. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1665. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1666. request.Header.Set("x-tif-signature", signature)
  1667. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1668. request.Header.Set("x-tif-nonce", nonce)
  1669. client := http.Client{}
  1670. resp, err := client.Do(request)
  1671. if err != nil {
  1672. fmt.Println(err.Error())
  1673. return err.Error()
  1674. }
  1675. respBytes, err := ioutil.ReadAll(resp.Body)
  1676. if err != nil {
  1677. fmt.Println(err.Error())
  1678. return err.Error()
  1679. }
  1680. str := string(respBytes)
  1681. fmt.Println(str)
  1682. return str
  1683. }
  1684. func ZHyb4104(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  1685. // 生成签名
  1686. nonce := GetRandomString(32)
  1687. timestamp := time.Now().Unix()
  1688. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1689. // 生成输入报文
  1690. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1691. input := make(map[string]interface{})
  1692. inputData := make(map[string]interface{})
  1693. inputMessage["infno"] = "4104" // 交易编码
  1694. inputData["setl_ym"] = "202306"
  1695. inputData["page_num"] = "1"
  1696. inputData["page_size"] = "100"
  1697. input["data"] = inputData
  1698. inputMessage["input"] = input //交易输入
  1699. bytesData, err := json.Marshal(inputMessage)
  1700. fmt.Println(string(bytesData))
  1701. fmt.Println(string(bytesData))
  1702. if err != nil {
  1703. fmt.Println(err.Error())
  1704. return err.Error()
  1705. }
  1706. reader := bytes.NewReader(bytesData)
  1707. gdyb_url := beego.AppConfig.String("gdyb_url")
  1708. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1709. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1710. //url := gdyb_url + "5203"
  1711. var url string
  1712. if baseParams.FixmedinsCode == "H15049901371" {
  1713. url = gdyb_url
  1714. } else {
  1715. url = gdyb_url + "4103"
  1716. }
  1717. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
  1718. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  1719. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  1720. request, err := http.NewRequest("POST", url, reader)
  1721. if err != nil {
  1722. fmt.Println(err.Error())
  1723. return err.Error()
  1724. }
  1725. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1726. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1727. request.Header.Set("x-tif-signature", signature)
  1728. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1729. request.Header.Set("x-tif-nonce", nonce)
  1730. client := http.Client{}
  1731. resp, err := client.Do(request)
  1732. if err != nil {
  1733. fmt.Println(err.Error())
  1734. return err.Error()
  1735. }
  1736. respBytes, err := ioutil.ReadAll(resp.Body)
  1737. if err != nil {
  1738. fmt.Println(err.Error())
  1739. return err.Error()
  1740. }
  1741. str := string(respBytes)
  1742. fmt.Println(str)
  1743. return str
  1744. }