nm_service.go 78KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010
  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.OrgName // 定点医药机构目录名称
  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.FixmedinsHilistId, 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.OrgName // 定点医药机构目录名称
  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"] = struct3505.DrugTracCodg // 人员编号 (来自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. input["selinfo"] = inputData
  1188. inputMessage["input"] = input //交易输入
  1189. bytesData, err := json.Marshal(inputMessage)
  1190. fmt.Println(string(bytesData))
  1191. if err != nil {
  1192. fmt.Println(err.Error())
  1193. return err.Error(),""
  1194. }
  1195. reader := bytes.NewReader(bytesData)
  1196. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1197. gdyb_url := beego.AppConfig.String("gdyb_url")
  1198. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1199. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1200. url := gdyb_url
  1201. request, err := http.NewRequest("POST", url, reader)
  1202. if err != nil {
  1203. fmt.Println(err.Error())
  1204. return err.Error(),""
  1205. }
  1206. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1207. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1208. request.Header.Set("x-tif-signature", signature)
  1209. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1210. request.Header.Set("x-tif-nonce", nonce)
  1211. client := http.Client{}
  1212. resp, err := client.Do(request)
  1213. if err != nil {
  1214. fmt.Println(err.Error())
  1215. return err.Error(),""
  1216. }
  1217. respBytes, err := ioutil.ReadAll(resp.Body)
  1218. if err != nil {
  1219. fmt.Println(err.Error())
  1220. return err.Error(),""
  1221. }
  1222. str := string(respBytes)
  1223. fmt.Println(str)
  1224. return str,string(bytesData)
  1225. }
  1226. func NMyb3506(struct3506 models.Struct3506, secret_key string) (string,string) {
  1227. // 生成签名
  1228. nonce := GetRandomString(32)
  1229. timestamp := time.Now().Unix()
  1230. signature := setSignature(timestamp, nonce, secret_key)
  1231. // 生成输入报文
  1232. inputMessage := SetGdInputMessage(timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsCode, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs, struct3506.Cainfo)
  1233. input := make(map[string]interface{})
  1234. inputData := make(map[string]interface{})
  1235. inputMessage["infno"] = "3506" // 交易编码
  1236. inputData["med_list_codg"] = struct3506.MedListCodg // 定点医药机构目录编号
  1237. inputData["fixmedins_hilist_id"] = struct3506.FixmedinsHilistId // 定点医药机构目录编号
  1238. inputData["fixmedins_hilist_name"] = struct3506.OrgName // 定点医药机构目录名称
  1239. inputData["fixmedins_bchno"] = struct3506.FixmedinsBchno // 人员编号 (来自1101接口返回)
  1240. inputData["setl_id"] = struct3506.SetlId // 人员编号 (来自1101接口返回)
  1241. inputData["psn_no"] = struct3506.PsnNo // 人员编号 (来自1101接口返回)
  1242. inputData["psn_cert_type"] = struct3506.PsnCertType // 人员编号 (来自1101接口返回)
  1243. inputData["certno"] = struct3506.Certno // 人员编号 (来自1101接口返回)
  1244. inputData["psn_name"] = struct3506.PsnName // 人员编号 (来自1101接口返回)
  1245. inputData["manu_lotnum"] = struct3506.ManuLotnum // 人员编号 (来自1101接口返回)
  1246. inputData["manu_date"] = struct3506.ManuDate // 人员编号 (来自1101接口返回)
  1247. inputData["expy_end"] = struct3506.ExpyEnd // 人员编号 (来自1101接口返回)
  1248. inputData["rx_flag"] = struct3506.RxFlag // 人员编号 (来自1101接口返回)
  1249. inputData["trdn_flag"] = struct3506.TrdnFlag // 人员编号 (来自1101接口返回)
  1250. inputData["finl_trns_pric"] = struct3506.FinlTrnsPric // 人员编号 (来自1101接口返回)
  1251. inputData["sel_retn_cnt"] = struct3506.SelRetnCnt // 人员编号 (来自1101接口返回)
  1252. inputData["sel_retn_time"] = struct3506.SelRetnTime // 人员编号 (来自1101接口返回)
  1253. inputData["sel_retn_opter_name"] = struct3506.SelRetnOpterName // 人员编号 (来自1101接口返回)
  1254. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  1255. inputData["medins_prod_sel_no"] = "" // 人员编号 (来自1101接口返回)
  1256. input["selinfo"] = inputData
  1257. inputMessage["input"] = input //交易输入
  1258. bytesData, err := json.Marshal(inputMessage)
  1259. fmt.Println(string(bytesData))
  1260. if err != nil {
  1261. fmt.Println(err.Error())
  1262. return err.Error(),""
  1263. }
  1264. reader := bytes.NewReader(bytesData)
  1265. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1266. gdyb_url := beego.AppConfig.String("gdyb_url")
  1267. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1268. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1269. url := gdyb_url
  1270. request, err := http.NewRequest("POST", url, reader)
  1271. if err != nil {
  1272. fmt.Println(err.Error())
  1273. return err.Error(),""
  1274. }
  1275. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1276. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1277. request.Header.Set("x-tif-signature", signature)
  1278. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1279. request.Header.Set("x-tif-nonce", nonce)
  1280. client := http.Client{}
  1281. resp, err := client.Do(request)
  1282. if err != nil {
  1283. fmt.Println(err.Error())
  1284. return err.Error(),""
  1285. }
  1286. respBytes, err := ioutil.ReadAll(resp.Body)
  1287. if err != nil {
  1288. fmt.Println(err.Error())
  1289. return err.Error(),""
  1290. }
  1291. str := string(respBytes)
  1292. fmt.Println(str)
  1293. return str,string(bytesData)
  1294. }
  1295. func NMyb3507(struct3507 models.Struct3507, secret_key string) (string,string) {
  1296. // 生成签名
  1297. nonce := GetRandomString(32)
  1298. timestamp := time.Now().Unix()
  1299. signature := setSignature(timestamp, nonce, secret_key)
  1300. // 生成输入报文
  1301. inputMessage := SetGdInputMessage(timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, struct3507.Cainfo)
  1302. input := make(map[string]interface{})
  1303. inputData := make(map[string]interface{})
  1304. inputMessage["infno"] = "3507" // 交易编码
  1305. inputData["fixmedins_bchno"] = struct3507.FixmedinsCode // 人员编号 (来自1101接口返回)
  1306. inputData["inv_data_type"] = struct3507.InvDataType // 人员编号 (来自1101接口返回)
  1307. input["data"] = inputData
  1308. inputMessage["input"] = input //交易输入
  1309. bytesData, err := json.Marshal(inputMessage)
  1310. fmt.Println(string(bytesData))
  1311. if err != nil {
  1312. fmt.Println(err.Error())
  1313. return err.Error(),""
  1314. }
  1315. reader := bytes.NewReader(bytesData)
  1316. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1317. gdyb_url := beego.AppConfig.String("gdyb_url")
  1318. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1319. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1320. url := gdyb_url
  1321. request, err := http.NewRequest("POST", url, reader)
  1322. if err != nil {
  1323. fmt.Println(err.Error())
  1324. return err.Error(),""
  1325. }
  1326. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1327. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1328. request.Header.Set("x-tif-signature", signature)
  1329. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1330. request.Header.Set("x-tif-nonce", nonce)
  1331. client := http.Client{}
  1332. resp, err := client.Do(request)
  1333. if err != nil {
  1334. fmt.Println(err.Error())
  1335. return err.Error(),""
  1336. }
  1337. respBytes, err := ioutil.ReadAll(resp.Body)
  1338. if err != nil {
  1339. fmt.Println(err.Error())
  1340. return err.Error(),""
  1341. }
  1342. str := string(respBytes)
  1343. fmt.Println(str)
  1344. return str,string(bytesData)
  1345. }
  1346. func NMyb3508(struct3508 models.Struct3508, secret_key string) (string,string) {
  1347. // 生成签名
  1348. nonce := GetRandomString(32)
  1349. timestamp := time.Now().Unix()
  1350. signature := setSignature(timestamp, nonce, secret_key)
  1351. // 生成输入报文
  1352. inputMessage := SetGdInputMessage(timestamp, struct3508.OrgName, struct3508.Opter, struct3508.FixmedinsCode, struct3508.InsuplcAdmdvs, struct3508.MdtrtareaAdmvs, struct3508.Cainfo)
  1353. input := make(map[string]interface{})
  1354. inputData := make(map[string]interface{})
  1355. inputMessage["infno"] = "3508"
  1356. inputData["fixmedins_code"] = struct3508.FixmedinsCode
  1357. inputData["medins_list_codg"] = struct3508.MedListCodg
  1358. inputData["fixmedins_bchno"] = ""
  1359. inputData["begndate"] = struct3508.Begndate
  1360. inputData["enddate"] = struct3508.Enddate
  1361. inputData["medins_prod_inv_no"] = ""
  1362. inputData["medins_list_name"] = ""
  1363. inputData["rx_flag"] = ""
  1364. inputData["list_sp_item_flag"] = ""
  1365. inputData["trdn_flag"] = ""
  1366. inputData["invdate"] = ""
  1367. inputData["manu_lotnum"] = ""
  1368. inputData["manu_date"] = ""
  1369. inputData["expy_end"] = ""
  1370. inputData["memo"] = ""
  1371. inputData["vali_flag"] = ""
  1372. inputData["rid"] = ""
  1373. inputData["crter_id"] = ""
  1374. inputData["crter_name"] = ""
  1375. inputData["crte_optins_no"] = ""
  1376. inputData["opter_id"] = ""
  1377. inputData["opter_name"] = ""
  1378. inputData["optins_no"] = ""
  1379. inputData["poolarea_no"] = ""
  1380. inputData["fixmedins_bchno"] = ""
  1381. inputData["inv_data_type"] = ""
  1382. input["data"] = inputData
  1383. inputMessage["input"] = input //交易输入
  1384. bytesData, err := json.Marshal(inputMessage)
  1385. fmt.Println(string(bytesData))
  1386. if err != nil {
  1387. fmt.Println(err.Error())
  1388. return err.Error(),""
  1389. }
  1390. reader := bytes.NewReader(bytesData)
  1391. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1392. gdyb_url := beego.AppConfig.String("gdyb_url")
  1393. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1394. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1395. url := gdyb_url
  1396. request, err := http.NewRequest("POST", url, reader)
  1397. if err != nil {
  1398. fmt.Println(err.Error())
  1399. return err.Error(),""
  1400. }
  1401. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1402. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1403. request.Header.Set("x-tif-signature", signature)
  1404. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1405. request.Header.Set("x-tif-nonce", nonce)
  1406. client := http.Client{}
  1407. resp, err := client.Do(request)
  1408. if err != nil {
  1409. fmt.Println(err.Error())
  1410. return err.Error(),""
  1411. }
  1412. respBytes, err := ioutil.ReadAll(resp.Body)
  1413. if err != nil {
  1414. fmt.Println(err.Error())
  1415. return err.Error(),""
  1416. }
  1417. str := string(respBytes)
  1418. fmt.Println(str)
  1419. return str,string(bytesData)
  1420. }
  1421. func NMyb3509(struct3509 models.Struct3509, secret_key string) (string,string) {
  1422. // 生成签名
  1423. nonce := GetRandomString(32)
  1424. timestamp := time.Now().Unix()
  1425. signature := setSignature(timestamp, nonce, secret_key)
  1426. // 生成输入报文
  1427. inputMessage := SetGdInputMessage(timestamp, struct3509.OrgName, struct3509.Opter, struct3509.FixmedinsCode, struct3509.InsuplcAdmdvs, struct3509.MdtrtareaAdmvs, struct3509.Cainfo)
  1428. input := make(map[string]interface{})
  1429. inputData := make(map[string]interface{})
  1430. inputMessage["infno"] = "3509"
  1431. inputData["fixmedins_code"] = struct3509.FixmedinsCode
  1432. //inputData["med_list_codg"] = struct3509.MedinsListCodg
  1433. inputData["medins_list_codg"] = struct3509.MedListCodg
  1434. inputData["fixmedins_bchno"] = ""
  1435. inputData["begndate"] = struct3509.Begndate
  1436. inputData["enddate"] = struct3509.Enddate
  1437. inputData["medins_prod_inv_no"] = ""
  1438. inputData["medins_list_name"] = ""
  1439. inputData["rx_flag"] = ""
  1440. inputData["list_sp_item_flag"] = ""
  1441. inputData["trdn_flag"] = ""
  1442. inputData["invdate"] = ""
  1443. inputData["manu_lotnum"] = ""
  1444. inputData["manu_date"] = ""
  1445. inputData["expy_end"] = ""
  1446. inputData["memo"] = ""
  1447. inputData["vali_flag"] = ""
  1448. inputData["rid"] = ""
  1449. inputData["crter_id"] = ""
  1450. inputData["crter_name"] = ""
  1451. inputData["crte_optins_no"] = ""
  1452. inputData["opter_id"] = ""
  1453. inputData["opter_name"] = ""
  1454. inputData["optins_no"] = ""
  1455. inputData["poolarea_no"] = ""
  1456. inputData["fixmedins_bchno"] = ""
  1457. inputData["inv_data_type"] = ""
  1458. input["data"] = inputData
  1459. inputMessage["input"] = input //交易输入
  1460. bytesData, err := json.Marshal(inputMessage)
  1461. fmt.Println(string(bytesData))
  1462. if err != nil {
  1463. fmt.Println(err.Error())
  1464. return err.Error(),""
  1465. }
  1466. reader := bytes.NewReader(bytesData)
  1467. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1468. gdyb_url := beego.AppConfig.String("gdyb_url")
  1469. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1470. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1471. url := gdyb_url
  1472. request, err := http.NewRequest("POST", url, reader)
  1473. if err != nil {
  1474. fmt.Println(err.Error())
  1475. return err.Error(),""
  1476. }
  1477. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1478. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1479. request.Header.Set("x-tif-signature", signature)
  1480. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1481. request.Header.Set("x-tif-nonce", nonce)
  1482. client := http.Client{}
  1483. resp, err := client.Do(request)
  1484. if err != nil {
  1485. fmt.Println(err.Error())
  1486. return err.Error(),""
  1487. }
  1488. respBytes, err := ioutil.ReadAll(resp.Body)
  1489. if err != nil {
  1490. fmt.Println(err.Error())
  1491. return err.Error(),""
  1492. }
  1493. str := string(respBytes)
  1494. fmt.Println(str)
  1495. return str,string(bytesData)
  1496. }
  1497. func NMyb3510(struct3510 models.Struct3510, secret_key string) (string,string) {
  1498. // 生成签名
  1499. nonce := GetRandomString(32)
  1500. timestamp := time.Now().Unix()
  1501. signature := setSignature(timestamp, nonce, secret_key)
  1502. // 生成输入报文
  1503. inputMessage := SetGdInputMessage(timestamp, struct3510.OrgName, struct3510.Opter, struct3510.FixmedinsCode, struct3510.InsuplcAdmdvs, struct3510.MdtrtareaAdmvs, struct3510.Cainfo)
  1504. input := make(map[string]interface{})
  1505. inputData := make(map[string]interface{})
  1506. inputMessage["infno"] = "3510"
  1507. inputData["fixmedins_code"] = struct3510.FixmedinsCode
  1508. //inputData["medins_list_codg"] = struct3510.MedinsListCodg
  1509. inputData["medins_list_codg"] = struct3510.MedListCodg
  1510. inputData["fixmedins_bchno"] = ""
  1511. inputData["begndate"] = struct3510.Begndate
  1512. inputData["enddate"] = struct3510.Enddate
  1513. inputData["medins_prod_inv_no"] = ""
  1514. inputData["medins_list_name"] = ""
  1515. inputData["rx_flag"] = ""
  1516. inputData["list_sp_item_flag"] = ""
  1517. inputData["trdn_flag"] = ""
  1518. inputData["invdate"] = ""
  1519. inputData["manu_lotnum"] = ""
  1520. inputData["manu_date"] = ""
  1521. inputData["expy_end"] = ""
  1522. inputData["memo"] = ""
  1523. inputData["vali_flag"] = ""
  1524. inputData["rid"] = ""
  1525. inputData["crter_id"] = ""
  1526. inputData["crter_name"] = ""
  1527. inputData["crte_optins_no"] = ""
  1528. inputData["opter_id"] = ""
  1529. inputData["opter_name"] = ""
  1530. inputData["optins_no"] = ""
  1531. inputData["poolarea_no"] = ""
  1532. inputData["fixmedins_bchno"] = ""
  1533. inputData["inv_data_type"] = ""
  1534. input["data"] = inputData
  1535. inputMessage["input"] = input //交易输入
  1536. bytesData, err := json.Marshal(inputMessage)
  1537. fmt.Println(string(bytesData))
  1538. if err != nil {
  1539. fmt.Println(err.Error())
  1540. return err.Error(),""
  1541. }
  1542. reader := bytes.NewReader(bytesData)
  1543. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1544. gdyb_url := beego.AppConfig.String("gdyb_url")
  1545. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1546. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1547. url := gdyb_url
  1548. request, err := http.NewRequest("POST", url, reader)
  1549. if err != nil {
  1550. fmt.Println(err.Error())
  1551. return err.Error(),""
  1552. }
  1553. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1554. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1555. request.Header.Set("x-tif-signature", signature)
  1556. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1557. request.Header.Set("x-tif-nonce", nonce)
  1558. client := http.Client{}
  1559. resp, err := client.Do(request)
  1560. if err != nil {
  1561. fmt.Println(err.Error())
  1562. return err.Error(),""
  1563. }
  1564. respBytes, err := ioutil.ReadAll(resp.Body)
  1565. if err != nil {
  1566. fmt.Println(err.Error())
  1567. return err.Error(),""
  1568. }
  1569. str := string(respBytes)
  1570. fmt.Println(str)
  1571. return str,string(bytesData)
  1572. }
  1573. func NMyb3511(struct3511 models.Struct3511, secret_key string) (string,string) {
  1574. // 生成签名
  1575. nonce := GetRandomString(32)
  1576. timestamp := time.Now().Unix()
  1577. signature := setSignature(timestamp, nonce, secret_key)
  1578. // 生成输入报文
  1579. inputMessage := SetGdInputMessage(timestamp, struct3511.OrgName, struct3511.Opter, struct3511.FixmedinsCode, struct3511.InsuplcAdmdvs, struct3511.MdtrtareaAdmvs, struct3511.Cainfo)
  1580. input := make(map[string]interface{})
  1581. inputData := make(map[string]interface{})
  1582. inputMessage["infno"] = "3511"
  1583. inputData["fixmedins_code"] = struct3511.FixmedinsCode
  1584. //inputData["medins_list_codg"] = struct3511.MedinsListCodg
  1585. inputData["medins_list_codg"] = struct3511.MedListCodg
  1586. inputData["fixmedins_bchno"] = ""
  1587. inputData["begndate"] = struct3511.Begndate
  1588. inputData["enddate"] = struct3511.Enddate
  1589. inputData["medins_prod_inv_no"] = ""
  1590. inputData["medins_list_name"] = ""
  1591. inputData["rx_flag"] = ""
  1592. inputData["list_sp_item_flag"] = ""
  1593. inputData["trdn_flag"] = ""
  1594. inputData["invdate"] = ""
  1595. inputData["manu_lotnum"] = ""
  1596. inputData["manu_date"] = ""
  1597. inputData["expy_end"] = ""
  1598. inputData["memo"] = ""
  1599. inputData["vali_flag"] = ""
  1600. inputData["rid"] = ""
  1601. inputData["crter_id"] = ""
  1602. inputData["crter_name"] = ""
  1603. inputData["crte_optins_no"] = ""
  1604. inputData["opter_id"] = ""
  1605. inputData["opter_name"] = ""
  1606. inputData["optins_no"] = ""
  1607. inputData["poolarea_no"] = ""
  1608. inputData["fixmedins_bchno"] = ""
  1609. inputData["inv_data_type"] = ""
  1610. input["data"] = inputData
  1611. inputMessage["input"] = input //交易输入
  1612. bytesData, err := json.Marshal(inputMessage)
  1613. fmt.Println(string(bytesData))
  1614. if err != nil {
  1615. fmt.Println(err.Error())
  1616. return err.Error(),""
  1617. }
  1618. reader := bytes.NewReader(bytesData)
  1619. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1620. gdyb_url := beego.AppConfig.String("gdyb_url")
  1621. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1622. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1623. url := gdyb_url
  1624. request, err := http.NewRequest("POST", url, reader)
  1625. if err != nil {
  1626. fmt.Println(err.Error())
  1627. return err.Error(),""
  1628. }
  1629. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1630. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1631. request.Header.Set("x-tif-signature", signature)
  1632. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1633. request.Header.Set("x-tif-nonce", nonce)
  1634. client := http.Client{}
  1635. resp, err := client.Do(request)
  1636. if err != nil {
  1637. fmt.Println(err.Error())
  1638. return err.Error(),""
  1639. }
  1640. respBytes, err := ioutil.ReadAll(resp.Body)
  1641. if err != nil {
  1642. fmt.Println(err.Error())
  1643. return err.Error(),""
  1644. }
  1645. str := string(respBytes)
  1646. fmt.Println(str)
  1647. return str,string(bytesData)
  1648. }
  1649. func NMyb3512(struct3512 models.Struct3512, secret_key string) (string,string) {
  1650. // 生成签名
  1651. nonce := GetRandomString(32)
  1652. timestamp := time.Now().Unix()
  1653. signature := setSignature(timestamp, nonce, secret_key)
  1654. // 生成输入报文
  1655. inputMessage := SetGdInputMessage(timestamp, struct3512.OrgName, struct3512.Opter, struct3512.FixmedinsCode, struct3512.InsuplcAdmdvs, struct3512.MdtrtareaAdmvs, struct3512.Cainfo)
  1656. input := make(map[string]interface{})
  1657. inputData := make(map[string]interface{})
  1658. inputMessage["infno"] = "3512"
  1659. inputData["fixmedins_code"] = struct3512.FixmedinsCode
  1660. //inputData["medins_list_codg"] = struct3512.MedinsListCodg
  1661. inputData["medins_list_codg"] = struct3512.MedListCodg
  1662. inputData["fixmedins_bchno"] = ""
  1663. inputData["begndate"] = struct3512.Begndate
  1664. inputData["enddate"] = struct3512.Enddate
  1665. inputData["medins_prod_inv_no"] = ""
  1666. inputData["medins_list_name"] = ""
  1667. inputData["rx_flag"] = ""
  1668. inputData["list_sp_item_flag"] = ""
  1669. inputData["trdn_flag"] = ""
  1670. inputData["invdate"] = ""
  1671. inputData["manu_lotnum"] = ""
  1672. inputData["manu_date"] = ""
  1673. inputData["expy_end"] = ""
  1674. inputData["memo"] = ""
  1675. inputData["vali_flag"] = ""
  1676. inputData["rid"] = ""
  1677. inputData["crter_id"] = ""
  1678. inputData["crter_name"] = ""
  1679. inputData["crte_optins_no"] = ""
  1680. inputData["opter_id"] = ""
  1681. inputData["opter_name"] = ""
  1682. inputData["optins_no"] = ""
  1683. inputData["poolarea_no"] = ""
  1684. inputData["fixmedins_bchno"] = ""
  1685. inputData["inv_data_type"] = ""
  1686. input["data"] = inputData
  1687. inputMessage["input"] = input //交易输入
  1688. bytesData, err := json.Marshal(inputMessage)
  1689. fmt.Println(string(bytesData))
  1690. if err != nil {
  1691. fmt.Println(err.Error())
  1692. return err.Error(),""
  1693. }
  1694. reader := bytes.NewReader(bytesData)
  1695. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1696. gdyb_url := beego.AppConfig.String("gdyb_url")
  1697. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1698. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1699. url := gdyb_url
  1700. request, err := http.NewRequest("POST", url, reader)
  1701. if err != nil {
  1702. fmt.Println(err.Error())
  1703. return err.Error(),""
  1704. }
  1705. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1706. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1707. request.Header.Set("x-tif-signature", signature)
  1708. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1709. request.Header.Set("x-tif-nonce", nonce)
  1710. client := http.Client{}
  1711. resp, err := client.Do(request)
  1712. if err != nil {
  1713. fmt.Println(err.Error())
  1714. return err.Error(),""
  1715. }
  1716. respBytes, err := ioutil.ReadAll(resp.Body)
  1717. if err != nil {
  1718. fmt.Println(err.Error())
  1719. return err.Error(),""
  1720. }
  1721. str := string(respBytes)
  1722. fmt.Println(str)
  1723. return str,string(bytesData)
  1724. }
  1725. func NMyb3513(struct3513 models.Struct3513, secret_key string) (string,string) {
  1726. // 生成签名
  1727. nonce := GetRandomString(32)
  1728. timestamp := time.Now().Unix()
  1729. signature := setSignature(timestamp, nonce, secret_key)
  1730. // 生成输入报文
  1731. inputMessage := SetGdInputMessage(timestamp, struct3513.OrgName, struct3513.Opter, struct3513.FixmedinsCode, struct3513.InsuplcAdmdvs, struct3513.MdtrtareaAdmvs, struct3513.Cainfo)
  1732. input := make(map[string]interface{})
  1733. inputData := make(map[string]interface{})
  1734. inputMessage["infno"] = "3513"
  1735. inputData["fixmedins_code"] = struct3513.FixmedinsCode
  1736. //inputData["medins_list_codg"] = struct3513.MedinsListCodg
  1737. inputData["medins_list_codg"] = struct3513.MedListCodg
  1738. inputData["fixmedins_bchno"] = ""
  1739. inputData["begndate"] = struct3513.Begndate
  1740. inputData["enddate"] = struct3513.Enddate
  1741. inputData["medins_prod_inv_no"] = ""
  1742. inputData["med_list_codg"] = ""
  1743. inputData["medins_list_name"] = ""
  1744. inputData["rx_flag"] = ""
  1745. inputData["list_sp_item_flag"] = ""
  1746. inputData["trdn_flag"] = ""
  1747. inputData["invdate"] = ""
  1748. inputData["manu_lotnum"] = ""
  1749. inputData["manu_date"] = ""
  1750. inputData["expy_end"] = ""
  1751. inputData["memo"] = ""
  1752. inputData["vali_flag"] = ""
  1753. inputData["rid"] = ""
  1754. inputData["crter_id"] = ""
  1755. inputData["crter_name"] = ""
  1756. inputData["crte_optins_no"] = ""
  1757. inputData["opter_id"] = ""
  1758. inputData["opter_name"] = ""
  1759. inputData["optins_no"] = ""
  1760. inputData["poolarea_no"] = ""
  1761. inputData["fixmedins_bchno"] = ""
  1762. inputData["inv_data_type"] = ""
  1763. input["data"] = inputData
  1764. inputMessage["input"] = input //交易输入
  1765. bytesData, err := json.Marshal(inputMessage)
  1766. fmt.Println(string(bytesData))
  1767. if err != nil {
  1768. fmt.Println(err.Error())
  1769. return err.Error(),""
  1770. }
  1771. reader := bytes.NewReader(bytesData)
  1772. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1773. gdyb_url := beego.AppConfig.String("gdyb_url")
  1774. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1775. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1776. url := gdyb_url
  1777. request, err := http.NewRequest("POST", url, reader)
  1778. if err != nil {
  1779. fmt.Println(err.Error())
  1780. return err.Error(),""
  1781. }
  1782. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1783. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1784. request.Header.Set("x-tif-signature", signature)
  1785. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1786. request.Header.Set("x-tif-nonce", nonce)
  1787. client := http.Client{}
  1788. resp, err := client.Do(request)
  1789. if err != nil {
  1790. fmt.Println(err.Error())
  1791. return err.Error(),""
  1792. }
  1793. respBytes, err := ioutil.ReadAll(resp.Body)
  1794. if err != nil {
  1795. fmt.Println(err.Error())
  1796. return err.Error(),""
  1797. }
  1798. str := string(respBytes)
  1799. fmt.Println(str)
  1800. return str,string(bytesData)
  1801. }