fj_service.go 111KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774
  1. package service
  2. import (
  3. "bytes"
  4. "gdyb/models"
  5. "github.com/astaxie/beego"
  6. "github.com/axgle/mahonia"
  7. "golang.org/x/text/encoding/simplifiedchinese"
  8. "io/ioutil"
  9. "net/http"
  10. "regexp"
  11. "strconv"
  12. "strings"
  13. "syscall"
  14. "time"
  15. "unsafe"
  16. )
  17. //import (
  18. // "os/exec"
  19. // "time"
  20. //)
  21. //
  22. import (
  23. "encoding/json"
  24. "fmt"
  25. "os/exec"
  26. )
  27. //
  28. // 人员基本信息
  29. func FJyb1101(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, id_card_type int64, card_sn string, certificates int64, url string, app_id string, app_secret string, sign_key string, enc_key string) (string, string, string) {
  30. //生成签名
  31. nonce := GetRandomString(32)
  32. timestamp := time.Now().Unix()
  33. //生成输入报文
  34. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  35. input := make(map[string]interface{})
  36. inputData := make(map[string]interface{})
  37. inputMessage["infno"] = "1101" // 交易编码
  38. if certificates == 3 {
  39. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  40. inputData["certno"] = certNo // 证件号码
  41. inputData["psn_cert_type"] = "99" // 人员证件类型
  42. } else {
  43. if id_card_type == 1 {
  44. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  45. inputData["card_sn"] = card_sn // 卡识别码
  46. inputData["psn_cert_type"] = "" // 人员证件类型
  47. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  48. } else if id_card_type == 4 {
  49. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  50. inputData["card_sn"] = "" // 卡识别码
  51. inputData["certno"] = "" // 证件号码
  52. inputData["psn_cert_type"] = "" // 人员证件类型
  53. } else {
  54. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  55. inputData["card_sn"] = "" // 卡识别码
  56. inputData["psn_cert_type"] = "01" // 人员证件类型
  57. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  58. }
  59. }
  60. inputData["certno"] = certNo // 证件号码
  61. inputData["begntime"] = "" // 开始时间
  62. inputData["psn_name"] = "" // 人员姓名
  63. input["data"] = inputData
  64. inputMessage["input"] = input //交易输入
  65. var inputLog string
  66. bytesData, err := json.Marshal(inputMessage)
  67. inputLog = string(bytesData)
  68. fmt.Println(string(bytesData))
  69. if err != nil {
  70. fmt.Println(err.Error())
  71. return err.Error(), "", ""
  72. }
  73. enc := mahonia.NewEncoder("gbk")
  74. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  75. return output, inputLog, err_msg
  76. }
  77. func FJyb1101ForEleToken(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, id_card_type int64, card_sn string, certificates int64, url string, app_id string, app_secret string, sign_key string, enc_key string, token string, name string) (string, string, string) {
  78. //生成签名
  79. nonce := GetRandomString(32)
  80. timestamp := time.Now().Unix()
  81. //生成输入报文
  82. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  83. input := make(map[string]interface{})
  84. inputData := make(map[string]interface{})
  85. inputMessage["infno"] = "1101" // 交易编码
  86. if certificates == 3 {
  87. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  88. inputData["certno"] = certNo // 证件号码
  89. inputData["psn_cert_type"] = "99" // 人员证件类型
  90. inputData["psn_name"] = "" // 人员姓名
  91. } else {
  92. if id_card_type == 1 {
  93. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  94. inputData["card_sn"] = card_sn // 卡识别码
  95. inputData["psn_cert_type"] = "" // 人员证件类型
  96. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  97. inputData["psn_name"] = "" // 人员姓名
  98. } else if id_card_type == 4 {
  99. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  100. inputData["card_sn"] = "" // 卡识别码
  101. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  102. inputData["psn_cert_type"] = "01" // 人员证件类型
  103. inputData["psn_name"] = name // 人员姓名
  104. } else {
  105. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  106. inputData["card_sn"] = "" // 卡识别码
  107. inputData["psn_cert_type"] = "01" // 人员证件类型
  108. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  109. inputData["psn_name"] = "" // 人员姓名
  110. }
  111. }
  112. inputData["certno"] = certNo // 证件号码
  113. inputData["begntime"] = "" // 开始时间
  114. input["data"] = inputData
  115. inputMessage["input"] = input //交易输入
  116. var inputLog string
  117. bytesData, err := json.Marshal(inputMessage)
  118. inputLog = string(bytesData)
  119. fmt.Println(string(bytesData))
  120. if err != nil {
  121. fmt.Println(err.Error())
  122. return err.Error(), "", ""
  123. }
  124. enc := mahonia.NewEncoder("gbk")
  125. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  126. return output, inputLog, err_msg
  127. }
  128. // 门诊挂号
  129. func FJyb2201(psnNo string, insutype string, certNo string, org_name string, doctor 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, opter string, doctor_name string, url string, app_id string, app_secret string, sign_key string, enc_key string, card_number string, record_time string) (string, string, string) {
  130. // 生成签名
  131. nonce := GetRandomString(32)
  132. timestamp := time.Now().Unix()
  133. tempTime := time.Unix(timestamp, 0)
  134. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  135. // 生成输入报文
  136. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, opter, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  137. input := make(map[string]interface{})
  138. inputData := make(map[string]interface{})
  139. inputMessage["infno"] = "2201" // 交易编码
  140. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  141. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  142. inputData["begntime"] = record_time + " " + strings.Split(timeFormatOne, " ")[1] // 开始时间
  143. if id_card_type == 1 {
  144. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  145. inputData["mdtrt_cert_no"] = card_number // 就诊凭证编号
  146. } else if id_card_type == 4 {
  147. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  148. inputData["mdtrt_cert_no"] = card_number // 就诊凭证编号
  149. } else {
  150. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  151. inputData["mdtrt_cert_no"] = card_number // 就诊凭证编号
  152. }
  153. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  154. inputData["atddr_no"] = doctor_id // 医师编码
  155. inputData["dr_name"] = doctor_name // 医师姓名
  156. inputData["dept_code"] = dept_code // 科室编码
  157. inputData["dept_name"] = dept // 科室名称
  158. inputData["caty"] = "A03.06" // 科别
  159. input["data"] = inputData
  160. inputMessage["input"] = input //交易输入
  161. var requestLog string
  162. bytesData, err := json.Marshal(inputMessage)
  163. requestLog = string(bytesData)
  164. fmt.Println(string(bytesData))
  165. if err != nil {
  166. fmt.Println(err.Error())
  167. return err.Error(), "", ""
  168. }
  169. enc := mahonia.NewEncoder("gbk")
  170. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  171. return output, requestLog, err_msg
  172. }
  173. //门诊挂号撤销
  174. func FJyb2202(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, url string, app_id string, app_secret string, sign_key string, enc_key string) (string, string, string) {
  175. // 生成签名
  176. nonce := GetRandomString(32)
  177. timestamp := time.Now().Unix()
  178. // 生成输入报文
  179. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  180. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  181. input := make(map[string]interface{})
  182. inputData := make(map[string]interface{})
  183. inputMessage["infno"] = "2202" // 交易编码
  184. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  185. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  186. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  187. input["data"] = inputData
  188. inputMessage["input"] = input //交易输入
  189. var requestLog string
  190. bytesData, err := json.Marshal(inputMessage)
  191. fmt.Println(string(bytesData))
  192. requestLog = string(bytesData)
  193. if err != nil {
  194. fmt.Println(err.Error())
  195. return err.Error(), "", ""
  196. }
  197. enc := mahonia.NewEncoder("gbk")
  198. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  199. return output, requestLog, err_msg
  200. }
  201. // 门诊就诊信息上传
  202. func FJyb2203(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, doctor_name string, opter string, url string, app_id string, app_secret string, sign_key string, enc_key string) (string, string, string) {
  203. // 生成签名
  204. nonce := GetRandomString(32)
  205. timestamp := time.Now().Unix()
  206. tempTime := time.Unix(timestamp, 0)
  207. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  208. // 生成输入报文
  209. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  210. //inputMessage := SetInputMessage(nonce, timestamp, org_name, opter, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  211. input := make(map[string]interface{})
  212. inputData := make(map[string]interface{})
  213. diseinfo := make([]map[string]interface{}, 0)
  214. inputMessage["infno"] = "2203A" // 交易编码
  215. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  216. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  217. //inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  218. inputData["begntime"] = begin_time // 开始时间
  219. //inputData["begntime"] = // 开始时间
  220. inputData["main_cond_dscr"] = "" // 主要病情描述
  221. inputData["dise_codg"] = sick_code // 病种编码
  222. inputData["dise_name"] = sick_name // 病种名称
  223. inputData["birctrl_type"] = "" // 计划生育手术类别
  224. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  225. if insuplc_admdvs == "421300" {
  226. if med_type == "11" || med_type == "1111" || med_type == "1112" {
  227. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  228. } else if med_type == "14" {
  229. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  230. }
  231. } else {
  232. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  233. }
  234. for index, item := range config {
  235. diseinfo_sun := make(map[string]interface{})
  236. diseinfo_sun["diag_type"] = "1" // 诊断类别
  237. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  238. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  239. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  240. diseinfo_sun["diag_dept"] = department // 诊断科室
  241. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  242. diseinfo_sun["dise_dor_name"] = doctor_name // 诊断医生姓名
  243. diseinfo_sun["diag_time"] = begin_time + " " + strings.Split(timeFormatOne, " ")[1] // 诊断时间
  244. diseinfo_sun["vali_flag"] = "1" // 有效标志
  245. diseinfo = append(diseinfo, diseinfo_sun)
  246. }
  247. input["diseinfo"] = diseinfo
  248. input["mdtrtinfo"] = inputData
  249. inputMessage["input"] = input //交易输入
  250. var requestLog string
  251. bytesData, err := json.Marshal(inputMessage)
  252. fmt.Println(string(bytesData))
  253. requestLog = string(bytesData)
  254. if err != nil {
  255. fmt.Println(err.Error())
  256. return err.Error(), "", ""
  257. }
  258. enc := mahonia.NewEncoder("gbk")
  259. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  260. return output, requestLog, err_msg
  261. }
  262. // 门诊费用明细信息上传
  263. func FJyb2204(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, opter string, url string, app_id string, app_secret string, sign_key string, enc_key string, dise_code string, doctor_number string) (string, string, string) {
  264. // 生成签名
  265. nonce := GetRandomString(32)
  266. timestamp := time.Now().Unix()
  267. var customs []*Custom
  268. for _, item := range hisPrescription {
  269. tm := time.Unix(item.PreTime, 0)
  270. if item.Type == 1 { //药品
  271. for _, subItem := range item.HisDoctorAdviceInfo {
  272. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  273. //var randNum int
  274. //randNum = rand.Intn(10000) + 1000
  275. cus := &Custom{
  276. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  277. Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  278. FeedetlSn: subItem.FeedetlSn,
  279. Price: fmt.Sprintf("%.2f", subItem.Price),
  280. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  281. HospApprFlag: subItem.BaseDrugLib.HospApprFlag,
  282. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  283. Unit: subItem.PrescribingNumberUnit,
  284. }
  285. customs = append(customs, cus)
  286. }
  287. }
  288. }
  289. if item.Type == 2 { //项目
  290. for _, subItem := range item.HisPrescriptionProject {
  291. //var randNum int
  292. //randNum = rand.Intn(10000) + 1000
  293. if subItem.Type == 2 {
  294. if len(subItem.HisProject.MedicalCode) > 0 {
  295. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  296. cus := &Custom{
  297. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*cnt),
  298. Cut: fmt.Sprintf("%.2f", cnt),
  299. FeedetlSn: subItem.FeedetlSn,
  300. Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  301. MedListCodg: subItem.HisProject.MedicalCode,
  302. HospApprFlag: -1,
  303. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  304. Unit: subItem.HisProject.Unit,
  305. }
  306. customs = append(customs, cus)
  307. }
  308. } else if subItem.Type == 3 {
  309. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  310. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  311. cus := &Custom{
  312. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*cnt),
  313. Cut: fmt.Sprintf("%.2f", cnt),
  314. FeedetlSn: subItem.FeedetlSn,
  315. Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  316. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  317. HospApprFlag: -1,
  318. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  319. Unit: subItem.GoodInfo.PackingUnit,
  320. }
  321. customs = append(customs, cus)
  322. }
  323. }
  324. }
  325. }
  326. for _, subItem := range item.HisAdditionalCharge {
  327. if len(subItem.XtHisAddtionConfig.Code) > 0 {
  328. cus := &Custom{
  329. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  330. Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  331. FeedetlSn: subItem.FeedetlSn,
  332. Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  333. MedListCodg: subItem.XtHisAddtionConfig.Code,
  334. HospApprFlag: -1,
  335. }
  336. customs = append(customs, cus)
  337. }
  338. }
  339. }
  340. // 生成输入报文
  341. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  342. //inputMessage := SetInputMessage(nonce, timestamp, org_name, opter, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  343. input := make(map[string]interface{})
  344. feedetail := make([]map[string]interface{}, 0)
  345. inputMessage["infno"] = "2204" // 交易编码
  346. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  347. for _, item := range customs {
  348. feedetailInfo := make(map[string]interface{})
  349. subfeedetail := make(map[string]interface{})
  350. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  351. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  352. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  353. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  354. feedetailInfo["dise_codg"] = dise_code // 病种编码
  355. feedetailInfo["rxno"] = "" // 处方号
  356. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  357. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  358. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  359. feedetailInfo["medins_list_codg"] = fixmedins_code // 医药机构目录编码
  360. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  361. feedetailInfo["cnt"] = item.Cut // 数量
  362. feedetailInfo["pric"] = item.Price // 单价
  363. feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
  364. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  365. feedetailInfo["prd_days"] = "0" // 周期天数
  366. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  367. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  368. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  369. feedetailInfo["bilg_dr_codg"] = doctor_number // 开单医生编码
  370. feedetailInfo["bilg_dr_name"] = doctor // 开单医师姓名
  371. feedetailInfo["acord_dept_codg"] = "" // 受单科室编码
  372. feedetailInfo["acord_dept_name"] = "" // 受单科室名称
  373. feedetailInfo["orders_dr_code"] = "" // 受单医生编码
  374. feedetailInfo["orders_dr_name"] = "" // 受单医生姓名
  375. subfeedetail["prcunt"] = item.Unit
  376. feedetailInfo["exp_content"] = subfeedetail // 中药使用方式
  377. if balance_accounts_type == "8" {
  378. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  379. } else {
  380. if item.HospApprFlag != -1 {
  381. if item.HospApprFlag == 1 {
  382. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  383. } else if item.HospApprFlag == 2 {
  384. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  385. } else if item.HospApprFlag == 3 {
  386. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  387. } else {
  388. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  389. }
  390. } else {
  391. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  392. }
  393. }
  394. feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  395. feedetailInfo["etip_flag"] = "" // 外检标志
  396. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  397. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  398. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  399. feedetail = append(feedetail, feedetailInfo)
  400. }
  401. input["feedetail"] = feedetail
  402. inputMessage["input"] = input //交易输入
  403. var requestLog string
  404. bytesData, err := json.Marshal(inputMessage)
  405. requestLog = string(bytesData)
  406. if err != nil {
  407. fmt.Println(err.Error())
  408. return "", "", ""
  409. }
  410. enc := mahonia.NewEncoder("gbk")
  411. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  412. return output, requestLog, err_msg
  413. }
  414. // 门诊费用明细信息撤销
  415. func FJyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string, url string, app_id string, app_secret string, sign_key string, enc_key string) (string, string, string) {
  416. // 生成签名
  417. nonce := GetRandomString(32)
  418. timestamp := time.Now().Unix()
  419. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  420. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  421. input := make(map[string]interface{})
  422. inputData := make(map[string]interface{})
  423. inputMessage["infno"] = "2205" // 交易编码
  424. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  425. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  426. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  427. input["data"] = inputData
  428. inputMessage["input"] = input //交易输入
  429. bytesData, err := json.Marshal(inputMessage)
  430. fmt.Println(string(bytesData))
  431. var requestLog string
  432. requestLog = string(bytesData)
  433. if err != nil {
  434. fmt.Println(err.Error())
  435. return err.Error(), "", ""
  436. }
  437. enc := mahonia.NewEncoder("gbk")
  438. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  439. return output, requestLog, err_msg
  440. }
  441. // 门诊预结算
  442. func FJyb2206(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, url string, app_id string, app_secret string, sign_key string, enc_key string) (string, string, string) {
  443. // 生成签名
  444. nonce := GetRandomString(32)
  445. timestamp := time.Now().Unix()
  446. // 生成输入报文
  447. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  448. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  449. input := make(map[string]interface{})
  450. inputData := make(map[string]interface{})
  451. inputMessage["infno"] = "2206" // 交易编码
  452. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  453. if certificates == 3 {
  454. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  455. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  456. } else {
  457. if id_card_type == 1 {
  458. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  459. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  460. } else {
  461. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  462. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  463. }
  464. }
  465. if med_type == "1111" || med_type == "1112" {
  466. med_type = "11"
  467. }
  468. if insuplc_admdvs == "421300" {
  469. if med_type == "11" || med_type == "1111" || med_type == "1112" {
  470. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  471. } else if med_type == "14" {
  472. inputData["med_type"] = "140110" // 医疗类别 11 普通门诊 12 门诊挂号
  473. }
  474. } else {
  475. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  476. }
  477. inputData["medfee_sumamt"] = total // 医疗费总额
  478. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  479. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  480. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  481. inputData["acct_used_flag"] = "0" // 个人账户使用标志 0否 1是
  482. inputData["insutype"] = insutype // 险种类型
  483. inputData["invono"] = "" // 发票号
  484. inputData2 := make(map[string]interface{})
  485. inputData2["trum_flag"] = "0"
  486. inputData2["rel_ttp_flag"] = ""
  487. inputData2["otp_er_refl_flag"] = ""
  488. inputData["exp_content"] = inputData2 // 发票号
  489. input["data"] = inputData
  490. inputMessage["input"] = input //交易输入
  491. var requestLog string
  492. bytesData, err := json.Marshal(inputMessage)
  493. requestLog = string(bytesData)
  494. fmt.Println(string(bytesData))
  495. if err != nil {
  496. fmt.Println(err.Error())
  497. return err.Error(), "", ""
  498. }
  499. enc := mahonia.NewEncoder("gbk")
  500. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  501. return output, requestLog, err_msg
  502. }
  503. func FJyb2206ForToken(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, url string, app_id string, app_secret string, sign_key string, enc_key string) (string, string, string) {
  504. // 生成签名
  505. nonce := GetRandomString(32)
  506. timestamp := time.Now().Unix()
  507. // 生成输入报文
  508. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_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"] = "2206" // 交易编码
  513. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  514. if certificates == 3 {
  515. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  516. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  517. } else {
  518. if id_card_type == 1 {
  519. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  520. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  521. } else if id_card_type == 4 {
  522. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  523. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  524. } else {
  525. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  526. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  527. }
  528. }
  529. if med_type == "1111" || med_type == "1112" {
  530. med_type = "11"
  531. }
  532. if insuplc_admdvs == "421300" {
  533. if med_type == "11" || med_type == "1111" || med_type == "1112" {
  534. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  535. } else if med_type == "14" {
  536. inputData["med_type"] = "140110" // 医疗类别 11 普通门诊 12 门诊挂号
  537. }
  538. } else {
  539. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  540. }
  541. inputData["medfee_sumamt"] = total // 医疗费总额
  542. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  543. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  544. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  545. inputData["acct_used_flag"] = "0" // 个人账户使用标志 0否 1是
  546. inputData["insutype"] = insutype // 险种类型
  547. inputData["invono"] = "" // 发票号
  548. input["data"] = inputData
  549. inputMessage["input"] = input //交易输入
  550. var requestLog string
  551. bytesData, err := json.Marshal(inputMessage)
  552. requestLog = string(bytesData)
  553. fmt.Println(string(bytesData))
  554. if err != nil {
  555. fmt.Println(err.Error())
  556. return err.Error(), "", ""
  557. }
  558. enc := mahonia.NewEncoder("gbk")
  559. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  560. return output, requestLog, err_msg
  561. }
  562. // 门诊结算
  563. func FJyb2207(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, url string, app_id string, app_secret string, sign_key string, enc_key string) (string, string, string) {
  564. // 生成签名
  565. nonce := GetRandomString(32)
  566. timestamp := time.Now().Unix()
  567. // 生成输入报文
  568. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  569. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  570. input := make(map[string]interface{})
  571. inputData := make(map[string]interface{})
  572. inputMessage["infno"] = "2207" // 交易编码
  573. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  574. if certificates == 3 {
  575. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  576. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  577. } else {
  578. if id_card_type == 1 {
  579. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  580. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  581. } else if id_card_type == 4 {
  582. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  583. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  584. } else {
  585. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  586. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  587. }
  588. }
  589. if med_type == "1111" || med_type == "1112" {
  590. med_type = "11"
  591. }
  592. if insuplc_admdvs == "421300" {
  593. if med_type == "11" || med_type == "1111" || med_type == "1112" {
  594. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  595. } else if med_type == "14" {
  596. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  597. }
  598. } else {
  599. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  600. }
  601. inputData["medfee_sumamt"] = total // 医疗费总额
  602. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  603. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  604. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  605. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  606. inputData["insutype"] = insutype // 险种类型
  607. inputData["invono"] = "" // 发票号
  608. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  609. inputData["overlmt_selfpay"] = overlmt_selfpay //
  610. inputData["preselfpay_amt"] = preselfpay_amt //
  611. inputData["inscp_scp_amt"] = inscp_scp_amt //
  612. inputData2 := make(map[string]interface{})
  613. inputData2["trum_flag"] = "0"
  614. inputData2["rel_ttp_flag"] = ""
  615. inputData2["otp_er_refl_flag"] = ""
  616. inputData["exp_content"] = inputData2 // 发票号
  617. input["data"] = inputData
  618. inputMessage["input"] = input //交易输入
  619. bytesData, err := json.Marshal(inputMessage)
  620. fmt.Println(string(bytesData))
  621. if err != nil {
  622. fmt.Println(err.Error())
  623. return err.Error(), "", ""
  624. }
  625. var requestLog string
  626. requestLog = string(bytesData)
  627. enc := mahonia.NewEncoder("gbk")
  628. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  629. return output, requestLog, err_msg
  630. }
  631. func FJyb2207ForToken(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, url string, app_id string, app_secret string, sign_key string, enc_key string) (string, string, string) {
  632. // 生成签名
  633. nonce := GetRandomString(32)
  634. timestamp := time.Now().Unix()
  635. // 生成输入报文
  636. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  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"] = "2207" // 交易编码
  641. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  642. if certificates == 3 {
  643. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  644. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  645. } else {
  646. if id_card_type == 1 {
  647. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  648. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  649. } else if id_card_type == 4 {
  650. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  651. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  652. } else {
  653. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  654. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  655. }
  656. }
  657. if med_type == "1111" || med_type == "1112" {
  658. med_type = "11"
  659. }
  660. if insuplc_admdvs == "421300" {
  661. if med_type == "11" || med_type == "1111" || med_type == "1112" {
  662. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  663. } else if med_type == "14" {
  664. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  665. }
  666. } else {
  667. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  668. }
  669. inputData["medfee_sumamt"] = total // 医疗费总额
  670. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  671. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  672. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  673. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  674. inputData["insutype"] = insutype // 险种类型
  675. inputData["invono"] = "" // 发票号
  676. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  677. inputData["overlmt_selfpay"] = overlmt_selfpay //
  678. inputData["preselfpay_amt"] = preselfpay_amt //
  679. inputData["inscp_scp_amt"] = inscp_scp_amt //
  680. input["data"] = inputData
  681. inputMessage["input"] = input //交易输入
  682. bytesData, err := json.Marshal(inputMessage)
  683. fmt.Println(string(bytesData))
  684. if err != nil {
  685. fmt.Println(err.Error())
  686. return err.Error(), "", ""
  687. }
  688. var requestLog string
  689. requestLog = string(bytesData)
  690. enc := mahonia.NewEncoder("gbk")
  691. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  692. return output, requestLog, err_msg
  693. }
  694. // 门诊结算撤销
  695. func FJyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, url string, app_id string, app_secret string, sign_key string, enc_key string) (string, string, string) {
  696. // 生成签名
  697. nonce := GetRandomString(32)
  698. timestamp := time.Now().Unix()
  699. // 生成输入报文
  700. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  701. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  702. input := make(map[string]interface{})
  703. inputData := make(map[string]interface{})
  704. inputMessage["infno"] = "2208" // 交易编码
  705. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  706. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  707. inputData["setl_id"] = setlId // 结算 ID
  708. input["data"] = inputData
  709. inputMessage["input"] = input //交易输入
  710. bytesData, err := json.Marshal(inputMessage)
  711. fmt.Println(string(bytesData))
  712. if err != nil {
  713. fmt.Println(err.Error())
  714. return err.Error(), "", ""
  715. }
  716. var requestLog string
  717. requestLog = string(bytesData)
  718. enc := mahonia.NewEncoder("gbk")
  719. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  720. return output, requestLog, err_msg
  721. }
  722. func FJyb5203(baseParams models.BaseParams, businessParams models.BusinessParams, url string, app_id string, app_secret string, sign_key string, enc_key string) (string, string, string) {
  723. // 生成签名
  724. nonce := GetRandomString(32)
  725. timestamp := time.Now().Unix()
  726. // 生成输入报文
  727. inputMessage := SetFjInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, url, app_id, app_secret, sign_key, enc_key)
  728. input := make(map[string]interface{})
  729. inputData := make(map[string]interface{})
  730. inputMessage["infno"] = "5203" // 交易编码
  731. inputData["psn_no"] = businessParams.PsnNo
  732. inputData["setl_id"] = businessParams.SetlId
  733. inputData["mdtrt_id"] = businessParams.MdtrtId
  734. //inputData["med_type"] = med_type
  735. input["data"] = inputData
  736. inputMessage["input"] = input //交易输入
  737. bytesData, err := json.Marshal(inputMessage)
  738. if err != nil {
  739. fmt.Println(err.Error())
  740. return err.Error(), "", ""
  741. }
  742. var requestLog string
  743. requestLog = string(bytesData)
  744. enc := mahonia.NewEncoder("gbk")
  745. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  746. return output, requestLog, err_msg
  747. }
  748. //确认订单
  749. func FJyb6201(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, order models.HisOrder, url string, app_id string, app_secret string, sign_key string, enc_key string) string {
  750. // 生成签名
  751. nonce := GetRandomString(32)
  752. timestamp := time.Now().Unix()
  753. signature := setSignature(timestamp, nonce, secret_key)
  754. // 生成输入报文
  755. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  756. input := make(map[string]interface{})
  757. inputData := make(map[string]interface{})
  758. inputMessage["infno"] = "6201" // 交易编码
  759. inputData["mdtrt_id"] = order.MdtrtId
  760. inputData["chrg_bchno"] = order.Number
  761. inputData["psn_no"] = order.PsnNo
  762. inputData["psn_name"] = order.PsnName
  763. inputData["psn_cert_type"] = order.PsnCertType
  764. inputData["certno"] = order.Certno
  765. inputData["insutype"] = order.Insutype
  766. inputData["med_type"] = order.MedType
  767. inputData["medfee_sumamt"] = order.MedfeeSumamt
  768. inputData["fulamt_ownpay_amt"] = order.FulamtOwnpayAmt
  769. inputData["overlmt_selfpay"] = order.OverlmtSelfPay
  770. inputData["preselfpay_amt"] = order.PreselfpayAmt
  771. inputData["inscp_scp_amt"] = order.InscpScpAmt
  772. inputData["act_pay_dedc"] = order.ActPayDedc
  773. inputData["hifp_pay"] = order.HifpPay
  774. inputData["pool_prop_selfpay"] = order.PoolPropSelfpay
  775. inputData["cvlserv_pay"] = order.CvlservPay
  776. inputData["hifes_pay"] = order.HifesPay
  777. inputData["hifmi_pay"] = order.HifmiPay
  778. inputData["hifob_pay"] = order.HifobPay
  779. inputData["maf_pay"] = order.MafPay
  780. inputData["oth_pay"] = order.OthPay
  781. inputData["fund_pay_sumamt"] = order.FundPaySumamt
  782. inputData["psn_part_amt"] = order.PsnPartAmt
  783. inputData["acct_pay"] = order.AcctPay
  784. inputData["psn_cash_pay"] = order.PsnCashPay
  785. inputData["hosp_part_amt"] = order.HospPartAmt
  786. inputData["acct_mulaid_pay"] = order.AcctMulaidPay
  787. input["data"] = inputData
  788. inputMessage["input"] = input //交易输入
  789. bytesData, err := json.Marshal(inputMessage)
  790. fmt.Println(string(bytesData))
  791. if err != nil {
  792. fmt.Println(err.Error())
  793. return err.Error()
  794. }
  795. reader := bytes.NewReader(bytesData)
  796. gdyb_url := beego.AppConfig.String("gdyb_url")
  797. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  798. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  799. url = gdyb_url + "6201"
  800. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/6201"
  801. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/6201"
  802. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  803. request, err := http.NewRequest("POST", url, reader)
  804. if err != nil {
  805. fmt.Println(err.Error())
  806. return err.Error()
  807. }
  808. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  809. request.Header.Set("x-tif-paasid", gdyb_paasid)
  810. request.Header.Set("x-tif-signature", signature)
  811. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  812. request.Header.Set("x-tif-nonce", nonce)
  813. client := http.Client{}
  814. resp, err := client.Do(request)
  815. if err != nil {
  816. fmt.Println(err.Error())
  817. return err.Error()
  818. }
  819. respBytes, err := ioutil.ReadAll(resp.Body)
  820. if err != nil {
  821. fmt.Println(err.Error())
  822. return err.Error()
  823. }
  824. str := string(respBytes)
  825. fmt.Println(str)
  826. return str
  827. }
  828. // 医药机构费用结算对总账 func Gdyb3201( org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) string {
  829. func FJyb3201(baseParams models.BaseParams, businessParams models.BusinessParams, med string, fund string) (string, string, string) {
  830. fmt.Println(baseParams)
  831. fmt.Println(businessParams)
  832. // 生成签名
  833. nonce := GetRandomString(32)
  834. timestamp := time.Now().Unix()
  835. // 生成输入报文
  836. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  837. input := make(map[string]interface{})
  838. inputData := make(map[string]interface{})
  839. inputMessage["infno"] = "3201" // 交易编码
  840. inputMessage["url"] = baseParams.RequestUrl // 险种
  841. inputMessage["app_id"] = baseParams.AppID // 险种
  842. inputMessage["app_secret"] = baseParams.AppSecret // 险种
  843. inputMessage["sign_key"] = baseParams.SignKey // 险种
  844. inputMessage["enc_key"] = baseParams.EncKey // 险种
  845. inputData["insutype"] = businessParams.Insutype // 险种
  846. inputData["clr_type"] = "11" // 就诊 ID(来自2201接口返回)
  847. inputData["setl_optins"] = "350581" // 结算经办机构
  848. inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间
  849. inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间
  850. inputData["medfee_sumamt"] = med //医疗费总额
  851. inputData["fund_pay_sumamt"] = fund //基金支付总额
  852. inputData["acct_pay"] = businessParams.AcctPay //个人账户支付金额
  853. inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数
  854. inputData["refd_setl_flag"] = "0" // 就诊 ID(来自2201接口返回)
  855. input["data"] = inputData
  856. inputMessage["input"] = input //交易输入
  857. bytesData, err := json.Marshal(inputMessage)
  858. fmt.Println(string(bytesData))
  859. if err != nil {
  860. fmt.Println(err.Error())
  861. return err.Error(), "", ""
  862. }
  863. var requestLog string
  864. requestLog = string(bytesData)
  865. enc := mahonia.NewEncoder("gbk")
  866. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  867. return output, requestLog, err_msg
  868. }
  869. //文件上传
  870. //文件上传
  871. func FJyb9101(baseParams models.BaseParams, file_name string, file_byte []byte) string {
  872. // 生成签名
  873. nonce := GetRandomString(32)
  874. timestamp := time.Now().Unix()
  875. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  876. buf := new(bytes.Buffer)
  877. buf.ReadFrom(strings.NewReader(string(file_byte)))
  878. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  879. input := make(map[string]interface{})
  880. inputData := make(map[string]interface{})
  881. inputMessage["infno"] = "9101" // 交易编码
  882. inputData["file_name"] = file_name //文件名
  883. inputData["in"] = file_byte //文件数据
  884. inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码
  885. input["fsUploadIn"] = inputData
  886. inputMessage["input"] = input //交易输入
  887. bytesData, err := json.Marshal(inputMessage)
  888. fmt.Println(string(bytesData))
  889. if err != nil {
  890. fmt.Println(err.Error())
  891. return err.Error()
  892. }
  893. reader := bytes.NewReader(bytesData)
  894. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9101"
  895. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101"
  896. gdyb_url := beego.AppConfig.String("gdyb_url")
  897. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  898. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  899. url := gdyb_url + "9101"
  900. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101"
  901. request, err := http.NewRequest("POST", url, reader)
  902. if err != nil {
  903. fmt.Println(err.Error())
  904. return err.Error()
  905. }
  906. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  907. request.Header.Set("x-tif-paasid", gdyb_paasid)
  908. request.Header.Set("x-tif-signature", signature)
  909. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  910. request.Header.Set("x-tif-nonce", nonce)
  911. client := http.Client{}
  912. resp, err := client.Do(request)
  913. if err != nil {
  914. fmt.Println(err.Error())
  915. return err.Error()
  916. }
  917. respBytes, err := ioutil.ReadAll(resp.Body)
  918. if err != nil {
  919. fmt.Println(err.Error())
  920. return err.Error()
  921. }
  922. str := string(respBytes)
  923. fmt.Println(str)
  924. return str
  925. }
  926. func FJyb9102(baseParams models.BaseParams, file_name string, file_qury_no string) string {
  927. // 生成签名
  928. nonce := GetRandomString(32)
  929. timestamp := time.Now().Unix()
  930. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  931. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  932. input := make(map[string]interface{})
  933. inputData := make(map[string]interface{})
  934. inputMessage["infno"] = "9102" // 交易编码
  935. inputData["file_name"] = file_name //文件名
  936. inputData["file_qury_no"] = file_qury_no //文件数据
  937. inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码
  938. input["fsDownloadIn"] = inputData
  939. inputMessage["input"] = input //交易输入
  940. bytesData, err := json.Marshal(inputMessage)
  941. fmt.Println(string(bytesData))
  942. if err != nil {
  943. fmt.Println(err.Error())
  944. return err.Error()
  945. }
  946. reader := bytes.NewReader(bytesData)
  947. gdyb_url := beego.AppConfig.String("gdyb_url")
  948. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  949. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  950. url := gdyb_url + "9102"
  951. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9102"
  952. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102"
  953. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102"
  954. request, err := http.NewRequest("POST", url, reader)
  955. if err != nil {
  956. fmt.Println(err.Error())
  957. return err.Error()
  958. }
  959. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  960. request.Header.Set("x-tif-paasid", gdyb_paasid)
  961. request.Header.Set("x-tif-signature", signature)
  962. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  963. request.Header.Set("x-tif-nonce", nonce)
  964. client := http.Client{}
  965. resp, err := client.Do(request)
  966. if err != nil {
  967. fmt.Println(err.Error())
  968. return err.Error()
  969. }
  970. respBytes, err := ioutil.ReadAll(resp.Body)
  971. if err != nil {
  972. fmt.Println(err.Error())
  973. return err.Error()
  974. }
  975. str := string(respBytes)
  976. fmt.Println(str)
  977. return str
  978. }
  979. func FJyb3202(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  980. // 生成签名
  981. nonce := GetRandomString(32)
  982. timestamp := time.Now().Unix()
  983. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  984. // 生成输入报文
  985. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  986. input := make(map[string]interface{})
  987. inputData := make(map[string]interface{})
  988. inputMessage["infno"] = "3202" // 交易编码
  989. inputData["file_qury_no"] = businessParams.FileQuryNo // 险种
  990. inputData["setl_optins"] = baseParams.InsuplcAdmdvs // 结算经办机构
  991. inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间
  992. inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间
  993. inputData["medfee_sumamt"] = businessParams.MedfeeSumamt //医疗费总额
  994. inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额
  995. inputData["cash_payamt"] = businessParams.CashPayamt //现金支付金额
  996. inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数
  997. inputData["clr_type"] = "11" // 就诊 ID(来自2201接口返回)
  998. inputData["refd_setl_flag"] = 1 // 就诊 ID(来自2201接口返回)
  999. input["data"] = inputData
  1000. inputMessage["input"] = input //交易输入
  1001. bytesData, err := json.Marshal(inputMessage)
  1002. fmt.Println(string(bytesData))
  1003. if err != nil {
  1004. fmt.Println(err.Error())
  1005. return err.Error()
  1006. }
  1007. reader := bytes.NewReader(bytesData)
  1008. gdyb_url := beego.AppConfig.String("gdyb_url")
  1009. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1010. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1011. url := gdyb_url + "3202"
  1012. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3202"
  1013. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202"
  1014. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202"
  1015. request, err := http.NewRequest("POST", url, reader)
  1016. if err != nil {
  1017. fmt.Println(err.Error())
  1018. return err.Error()
  1019. }
  1020. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1021. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1022. request.Header.Set("x-tif-signature", signature)
  1023. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1024. request.Header.Set("x-tif-nonce", nonce)
  1025. client := http.Client{}
  1026. resp, err := client.Do(request)
  1027. if err != nil {
  1028. fmt.Println(err.Error())
  1029. return err.Error()
  1030. }
  1031. respBytes, err := ioutil.ReadAll(resp.Body)
  1032. if err != nil {
  1033. fmt.Println(err.Error())
  1034. return err.Error()
  1035. }
  1036. str := string(respBytes)
  1037. fmt.Println(str)
  1038. return str
  1039. }
  1040. //func Hbyb2001(baseParams models.BaseParams, psn_no string, insutype string, med_type string) string {
  1041. // // 生成签名
  1042. // nonce := GetRandomString(32)
  1043. // timestamp := time.Now().Unix()
  1044. // signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1045. //
  1046. // // 生成输入报文
  1047. // inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1048. // input := make(map[string]interface{})
  1049. // inputData := make(map[string]interface{})
  1050. // inputMessage["infno"] = "2001" // 交易编码
  1051. // inputData["psn_no"] = psn_no
  1052. // inputData["insutype"] = insutype
  1053. // inputData["med_type"] = med_type
  1054. // inputData["begntime"] = "2021-01-01 00:00:00"
  1055. // input["data"] = inputData
  1056. // inputMessage["input"] = input //交易输入
  1057. // bytesData, err := json.Marshal(inputMessage)
  1058. // fmt.Println(string(bytesData))
  1059. // if err != nil {
  1060. // fmt.Println(err.Error())
  1061. // return err.Error()
  1062. // }
  1063. // reader := bytes.NewReader(bytesData)
  1064. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
  1065. //
  1066. // gdyb_url := beego.AppConfig.String("gdyb_url")
  1067. // gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1068. //
  1069. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1070. // url := gdyb_url + "2001"
  1071. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301"
  1072. // request, err := http.NewRequest("POST", url, reader)
  1073. // if err != nil {
  1074. // fmt.Println(err.Error())
  1075. // return err.Error()
  1076. // }
  1077. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1078. // request.Header.Set("x-tif-paasid", gdyb_paasid)
  1079. // request.Header.Set("x-tif-signature", signature)
  1080. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1081. // request.Header.Set("x-tif-nonce", nonce)
  1082. // client := http.Client{}
  1083. // resp, err := client.Do(request)
  1084. // if err != nil {
  1085. // fmt.Println(err.Error())
  1086. // return err.Error()
  1087. // }
  1088. // respBytes, err := ioutil.ReadAll(resp.Body)
  1089. // if err != nil {
  1090. // fmt.Println(err.Error())
  1091. // return err.Error()
  1092. // }
  1093. // str := string(respBytes)
  1094. // fmt.Println(str)
  1095. // return str
  1096. //}
  1097. func FJyb3301(baseParams *models.BaseParams, name string, codg string, list_type_code string, start_time string, ent_time string, list_type string) string {
  1098. // 生成签名
  1099. nonce := GetRandomString(32)
  1100. timestamp := time.Now().Unix()
  1101. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1102. // 生成输入报文
  1103. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1104. input := make(map[string]interface{})
  1105. inputData := make(map[string]interface{})
  1106. inputMessage["infno"] = "3301" // 交易编码
  1107. inputData["fixmedins_hilist_id"] = codg
  1108. inputData["fixmedins_hilist_name"] = name
  1109. inputData["list_type"] = list_type
  1110. inputData["med_list_codg"] = codg
  1111. inputData["begndate"] = start_time
  1112. inputData["enddate"] = ent_time
  1113. inputData["aprvno"] = ""
  1114. inputData["dosform"] = ""
  1115. inputData["exct_cont"] = ""
  1116. inputData["item_cont"] = ""
  1117. inputData["prcunt"] = ""
  1118. inputData["spec"] = ""
  1119. inputData["pacspec"] = ""
  1120. inputData["memo"] = ""
  1121. input["data"] = inputData
  1122. inputMessage["input"] = input //交易输入
  1123. bytesData, err := json.Marshal(inputMessage)
  1124. fmt.Println(string(bytesData))
  1125. if err != nil {
  1126. fmt.Println(err.Error())
  1127. return err.Error()
  1128. }
  1129. reader := bytes.NewReader(bytesData)
  1130. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
  1131. //
  1132. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301"
  1133. gdyb_url := beego.AppConfig.String("gdyb_url")
  1134. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1135. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1136. url := gdyb_url + "3301"
  1137. request, err := http.NewRequest("POST", url, reader)
  1138. if err != nil {
  1139. fmt.Println(err.Error())
  1140. return err.Error()
  1141. }
  1142. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1143. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1144. request.Header.Set("x-tif-signature", signature)
  1145. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1146. request.Header.Set("x-tif-nonce", nonce)
  1147. client := http.Client{}
  1148. resp, err := client.Do(request)
  1149. if err != nil {
  1150. fmt.Println(err.Error())
  1151. return err.Error()
  1152. }
  1153. respBytes, err := ioutil.ReadAll(resp.Body)
  1154. if err != nil {
  1155. fmt.Println(err.Error())
  1156. return err.Error()
  1157. }
  1158. str := string(respBytes)
  1159. fmt.Println(str)
  1160. return str
  1161. }
  1162. func FJyb3302(baseParams *models.BaseParams, name string, codg string, list_type_code string) string {
  1163. // 生成签名
  1164. nonce := GetRandomString(32)
  1165. timestamp := time.Now().Unix()
  1166. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1167. // 生成输入报文
  1168. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1169. input := make(map[string]interface{})
  1170. inputData := make(map[string]interface{})
  1171. inputMessage["infno"] = "3302" // 交易编码
  1172. inputData["fixmedins_code"] = baseParams.FixmedinsCode
  1173. inputData["fixmedins_hilist_id"] = codg
  1174. inputData["list_type"] = list_type_code
  1175. inputData["med_list_codg"] = codg
  1176. input["data"] = inputData
  1177. inputMessage["input"] = input //交易输入
  1178. bytesData, err := json.Marshal(inputMessage)
  1179. fmt.Println(string(bytesData))
  1180. if err != nil {
  1181. fmt.Println(err.Error())
  1182. return err.Error()
  1183. }
  1184. reader := bytes.NewReader(bytesData)
  1185. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3302"
  1186. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3302"
  1187. gdyb_url := beego.AppConfig.String("gdyb_url")
  1188. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1189. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1190. url := gdyb_url + "3302"
  1191. request, err := http.NewRequest("POST", url, reader)
  1192. if err != nil {
  1193. fmt.Println(err.Error())
  1194. return err.Error()
  1195. }
  1196. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1197. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1198. request.Header.Set("x-tif-signature", signature)
  1199. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1200. request.Header.Set("x-tif-nonce", nonce)
  1201. client := http.Client{}
  1202. resp, err := client.Do(request)
  1203. if err != nil {
  1204. fmt.Println(err.Error())
  1205. return err.Error()
  1206. }
  1207. respBytes, err := ioutil.ReadAll(resp.Body)
  1208. if err != nil {
  1209. fmt.Println(err.Error())
  1210. return err.Error()
  1211. }
  1212. str := string(respBytes)
  1213. fmt.Println(str)
  1214. return str
  1215. }
  1216. func FJyb2505(psnNo string, doctor string, org_name string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, start_time string, end_time string) string {
  1217. // 生成签名
  1218. nonce := GetRandomString(32)
  1219. timestamp := time.Now().Unix()
  1220. signature := setSignature(timestamp, nonce, secret_key)
  1221. // 生成输入报文
  1222. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1223. input := make(map[string]interface{})
  1224. inputData := make(map[string]interface{})
  1225. inputMessage["infno"] = "2505"
  1226. inputData["psn_no"] = psnNo
  1227. inputData["biz_appy_type"] = "03"
  1228. inputData["begndate"] = start_time
  1229. inputData["enddate"] = end_time
  1230. inputData["fixmedins_code"] = fixmedins_code
  1231. inputData["fixmedins_name"] = org_name
  1232. inputData["tel"] = ""
  1233. inputData["addr"] = ""
  1234. inputData["agnter_name"] = ""
  1235. inputData["agnter_cert_type"] = ""
  1236. inputData["agnter_certno"] = ""
  1237. inputData["agnter_tel"] = ""
  1238. inputData["agnter_addr"] = ""
  1239. inputData["agnter_rlts"] = ""
  1240. inputData["fix_srt_no"] = ""
  1241. inputData["memo"] = ""
  1242. input["data"] = inputData
  1243. inputMessage["input"] = input //交易输入
  1244. bytesData, err := json.Marshal(inputMessage)
  1245. if err != nil {
  1246. fmt.Println(err.Error())
  1247. return err.Error()
  1248. }
  1249. reader := bytes.NewReader(bytesData)
  1250. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2505"
  1251. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2505"
  1252. gdyb_url := beego.AppConfig.String("gdyb_url")
  1253. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1254. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1255. url := gdyb_url + "2505"
  1256. request, err := http.NewRequest("POST", url, reader)
  1257. if err != nil {
  1258. fmt.Println(err.Error())
  1259. return err.Error()
  1260. }
  1261. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1262. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1263. request.Header.Set("x-tif-signature", signature)
  1264. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1265. request.Header.Set("x-tif-nonce", nonce)
  1266. client := http.Client{}
  1267. resp, err := client.Do(request)
  1268. if err != nil {
  1269. fmt.Println(err.Error())
  1270. return err.Error()
  1271. }
  1272. respBytes, err := ioutil.ReadAll(resp.Body)
  1273. if err != nil {
  1274. fmt.Println(err.Error())
  1275. return err.Error()
  1276. }
  1277. str := string(respBytes)
  1278. fmt.Println(str)
  1279. return str
  1280. }
  1281. func FJyb2506(psnNo string, doctor string, org_name string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, trt_dcla_detl_sn string) string {
  1282. // 生成签名
  1283. nonce := GetRandomString(32)
  1284. timestamp := time.Now().Unix()
  1285. signature := setSignature(timestamp, nonce, secret_key)
  1286. // 生成输入报文
  1287. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1288. input := make(map[string]interface{})
  1289. inputData := make(map[string]interface{})
  1290. inputMessage["infno"] = "2506"
  1291. inputData["psn_no"] = psnNo
  1292. inputData["trt_dcla_detl_sn"] = trt_dcla_detl_sn
  1293. inputData["memo"] = ""
  1294. input["data"] = inputData
  1295. inputMessage["input"] = input //交易输入
  1296. bytesData, err := json.Marshal(inputMessage)
  1297. fmt.Println(string(bytesData))
  1298. if err != nil {
  1299. fmt.Println(err.Error())
  1300. return err.Error()
  1301. }
  1302. reader := bytes.NewReader(bytesData)
  1303. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2506"
  1304. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2506"
  1305. gdyb_url := beego.AppConfig.String("gdyb_url")
  1306. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1307. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1308. url := gdyb_url + "2506"
  1309. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  1310. request, err := http.NewRequest("POST", url, reader)
  1311. if err != nil {
  1312. fmt.Println(err.Error())
  1313. return err.Error()
  1314. }
  1315. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1316. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1317. request.Header.Set("x-tif-signature", signature)
  1318. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1319. request.Header.Set("x-tif-nonce", nonce)
  1320. client := http.Client{}
  1321. resp, err := client.Do(request)
  1322. if err != nil {
  1323. fmt.Println(err.Error())
  1324. return err.Error()
  1325. }
  1326. respBytes, err := ioutil.ReadAll(resp.Body)
  1327. if err != nil {
  1328. fmt.Println(err.Error())
  1329. return err.Error()
  1330. }
  1331. str := string(respBytes)
  1332. fmt.Println(str)
  1333. return str
  1334. }
  1335. func FJyb2503(psnNo string, insutype string, org_name string, doctor string, fixmedins_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_name string, sick_code string) string {
  1336. // 生成签名
  1337. nonce := GetRandomString(32)
  1338. timestamp := time.Now().Unix()
  1339. signature := setSignature(timestamp, nonce, secret_key)
  1340. tempTime := time.Unix(timestamp, 0)
  1341. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1342. timeFormatTwo := tempTime.Format("2006-01-02")
  1343. t := time.Now()
  1344. last := time.Date(t.Year(), time.December, 31, 0, 0, 0, 0, time.UTC)
  1345. tm := time.Unix(last.Unix(), 0)
  1346. // 生成输入报文
  1347. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1348. input := make(map[string]interface{})
  1349. inputData := make(map[string]interface{})
  1350. inputMessage["infno"] = "2503" // 交易编码
  1351. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1352. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  1353. inputData["opsp_dise_code"] = sick_code // 险种类型(来自1101接口返回)
  1354. inputData["opsp_dise_name"] = sick_name // 险种类型(来自1101接口返回)
  1355. inputData["insu_optins"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  1356. inputData["ide_fixmedins_no"] = fixmedins_code // 险种类型(来自1101接口返回)
  1357. inputData["ide_fixmedins_name"] = org_name // 险种类型(来自1101接口返回)
  1358. inputData["hosp_ide_date"] = timeFormatTwo // 险种类型(来自1101接口返回)
  1359. inputData["diag_dr_codg"] = doctor_id // 开始时间
  1360. inputData["diag_dr_name"] = doctor // 开始时间
  1361. inputData["begndate"] = timeFormatTwo // 医师编码
  1362. inputData["tel"] = "" // 医师编码
  1363. inputData["addr"] = "" // 医师编码
  1364. inputData["enddate"] = tm.Format("2006-01-02") // 医师编码
  1365. input["data"] = inputData
  1366. inputMessage["input"] = input //交易输入
  1367. bytesData, err := json.Marshal(inputMessage)
  1368. fmt.Println(string(bytesData))
  1369. if err != nil {
  1370. fmt.Println(err.Error())
  1371. return err.Error()
  1372. }
  1373. reader := bytes.NewReader(bytesData)
  1374. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
  1375. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503"
  1376. gdyb_url := beego.AppConfig.String("gdyb_url")
  1377. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1378. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1379. url := gdyb_url + "2503"
  1380. request, err := http.NewRequest("POST", url, reader)
  1381. if err != nil {
  1382. fmt.Println(err.Error())
  1383. return err.Error()
  1384. }
  1385. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1386. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1387. request.Header.Set("x-tif-signature", signature)
  1388. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1389. request.Header.Set("x-tif-nonce", nonce)
  1390. client := http.Client{}
  1391. resp, err := client.Do(request)
  1392. if err != nil {
  1393. fmt.Println(err.Error())
  1394. return err.Error()
  1395. }
  1396. respBytes, err := ioutil.ReadAll(resp.Body)
  1397. if err != nil {
  1398. fmt.Println(err.Error())
  1399. return err.Error()
  1400. }
  1401. str := string(respBytes)
  1402. fmt.Println(str)
  1403. return str
  1404. }
  1405. func FJyb2504(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, trt_dcla_detl_sn string) string {
  1406. // 生成签名
  1407. nonce := GetRandomString(32)
  1408. timestamp := time.Now().Unix()
  1409. signature := setSignature(timestamp, nonce, secret_key)
  1410. // 生成输入报文
  1411. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1412. input := make(map[string]interface{})
  1413. inputData := make(map[string]interface{})
  1414. inputMessage["infno"] = "2504" // 交易编码
  1415. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1416. inputData["trt_dcla_detl_sn"] = trt_dcla_detl_sn // 人员编号 (来自1101接口返回)
  1417. inputData["memo"] = "撤销备案" // 人员编号 (来自1101接口返回)
  1418. input["data"] = inputData
  1419. inputMessage["input"] = input //交易输入
  1420. bytesData, err := json.Marshal(inputMessage)
  1421. fmt.Println(string(bytesData))
  1422. if err != nil {
  1423. fmt.Println(err.Error())
  1424. return err.Error()
  1425. }
  1426. reader := bytes.NewReader(bytesData)
  1427. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2504"
  1428. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2504"
  1429. gdyb_url := beego.AppConfig.String("gdyb_url")
  1430. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1431. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1432. url := gdyb_url + "2504"
  1433. request, err := http.NewRequest("POST", url, reader)
  1434. if err != nil {
  1435. fmt.Println(err.Error())
  1436. return err.Error()
  1437. }
  1438. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1439. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1440. request.Header.Set("x-tif-signature", signature)
  1441. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1442. request.Header.Set("x-tif-nonce", nonce)
  1443. client := http.Client{}
  1444. resp, err := client.Do(request)
  1445. if err != nil {
  1446. fmt.Println(err.Error())
  1447. return err.Error()
  1448. }
  1449. respBytes, err := ioutil.ReadAll(resp.Body)
  1450. if err != nil {
  1451. fmt.Println(err.Error())
  1452. return err.Error()
  1453. }
  1454. str := string(respBytes)
  1455. fmt.Println(str)
  1456. return str
  1457. }
  1458. //func Gdyb2503(psnNo string, doctor string, department string, diag string, org_name string, med_type string, doctor_id int64, fixmedins_code string, diag_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_code string, sick_name string) string {
  1459. // // 生成签名
  1460. // nonce := GetRandomString(32)
  1461. // timestamp := time.Now().Unix()
  1462. // signature := setSignature(timestamp, nonce, secret_key)
  1463. // tempTime := time.Unix(timestamp, 0)
  1464. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1465. //
  1466. // // 生成输入报文
  1467. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1468. // input := make(map[string]interface{})
  1469. // inputData := make(map[string]interface{})
  1470. // diseinfo := make([]map[string]interface{}, 0)
  1471. //
  1472. // inputMessage["infno"] = "2203" // 交易编码
  1473. // inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1474. // inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1475. // inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  1476. // inputData["begntime"] = timeFormatOne // 开始时间
  1477. // inputData["main_cond_dscr"] = "" // 主要病情描述
  1478. // inputData["dise_codg"] = sick_code // 病种编码
  1479. // inputData["dise_name"] = sick_name // 病种名称
  1480. // inputData["birctrl_type"] = "" // 计划生育手术类别
  1481. // inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  1482. //
  1483. // diseinfo_sun := make(map[string]interface{})
  1484. // diseinfo_sun["diag_type"] = "1" // 诊断类别
  1485. // diseinfo_sun["diag_srt_no"] = "1" // 诊断排序号
  1486. // diseinfo_sun["diag_code"] = diag_code // 诊断代码
  1487. // diseinfo_sun["diag_name"] = diag // 诊断名称
  1488. // diseinfo_sun["diag_dept"] = department // 诊断科室
  1489. // diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  1490. // diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  1491. // diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  1492. // diseinfo_sun["vali_flag"] = "1" // 有效标志
  1493. //
  1494. // diseinfo = append(diseinfo, diseinfo_sun)
  1495. // input["diseinfo"] = diseinfo
  1496. // input["mdtrtinfo"] = inputData
  1497. // inputMessage["input"] = input //交易输入
  1498. //
  1499. // bytesData, err := json.Marshal(inputMessage)
  1500. // fmt.Println(string(bytesData))
  1501. // if err != nil {
  1502. // fmt.Println(err.Error())
  1503. // return err.Error()
  1504. // }
  1505. // reader := bytes.NewReader(bytesData)
  1506. //
  1507. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
  1508. //
  1509. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  1510. // request, err := http.NewRequest("POST", url, reader)
  1511. // if err != nil {
  1512. // fmt.Println(err.Error())
  1513. // return err.Error()
  1514. // }
  1515. //
  1516. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1517. // request.Header.Set("x-tif-paasid", "sg03_prd")
  1518. // request.Header.Set("x-tif-signature", signature)
  1519. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1520. // request.Header.Set("x-tif-nonce", nonce)
  1521. //
  1522. // client := http.Client{}
  1523. // resp, err := client.Do(request)
  1524. // if err != nil {
  1525. // fmt.Println(err.Error())
  1526. // return err.Error()
  1527. // }
  1528. // respBytes, err := ioutil.ReadAll(resp.Body)
  1529. // if err != nil {
  1530. // fmt.Println(err.Error())
  1531. // return err.Error()
  1532. // }
  1533. // str := string(respBytes)
  1534. // fmt.Println(str)
  1535. // return str
  1536. //}
  1537. func FJyb5301(psnNo string, insutype string, org_name string, doctor string, fixmedins_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_name string, sick_code string) string {
  1538. // 生成签名
  1539. nonce := GetRandomString(32)
  1540. timestamp := time.Now().Unix()
  1541. signature := setSignature(timestamp, nonce, secret_key)
  1542. //tempTime := time.Unix(timestamp, 0)
  1543. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1544. //timeFormatTwo := tempTime.Format("2006-01-02")
  1545. // 生成输入报文
  1546. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1547. input := make(map[string]interface{})
  1548. inputData := make(map[string]interface{})
  1549. inputMessage["infno"] = "5301" // 交易编码
  1550. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1551. input["data"] = inputData
  1552. inputMessage["input"] = input //交易输入
  1553. bytesData, err := json.Marshal(inputMessage)
  1554. fmt.Println(string(bytesData))
  1555. if err != nil {
  1556. fmt.Println(err.Error())
  1557. return err.Error()
  1558. }
  1559. reader := bytes.NewReader(bytesData)
  1560. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1561. gdyb_url := beego.AppConfig.String("gdyb_url")
  1562. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1563. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1564. url := gdyb_url + "5301"
  1565. request, err := http.NewRequest("POST", url, reader)
  1566. if err != nil {
  1567. fmt.Println(err.Error())
  1568. return err.Error()
  1569. }
  1570. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1571. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1572. request.Header.Set("x-tif-signature", signature)
  1573. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1574. request.Header.Set("x-tif-nonce", nonce)
  1575. client := http.Client{}
  1576. resp, err := client.Do(request)
  1577. if err != nil {
  1578. fmt.Println(err.Error())
  1579. return err.Error()
  1580. }
  1581. respBytes, err := ioutil.ReadAll(resp.Body)
  1582. if err != nil {
  1583. fmt.Println(err.Error())
  1584. return err.Error()
  1585. }
  1586. str := string(respBytes)
  1587. fmt.Println(str)
  1588. return str
  1589. }
  1590. //
  1591. //func Hbyb4101(struct4101 Struct4101, secret_key string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) string {
  1592. // // 生成签名
  1593. // nonce := GetRandomString(32)
  1594. // timestamp := time.Now().Unix()
  1595. // signature := setSignature(timestamp, nonce, secret_key)
  1596. //
  1597. // // 生成输入报文
  1598. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1599. // input := make(map[string]interface{})
  1600. // inputData := make(map[string]interface{})
  1601. // inputMessage["infno"] = "4101" // 交易编码
  1602. //
  1603. // year := time.Now().Format("2006")
  1604. // month := time.Now().Format("01")
  1605. // day := time.Now().Format("02")
  1606. //
  1607. // inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  1608. // inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  1609. // inputData["fixmedins_name"] = org_name // 定点医药机构名称 必填
  1610. // inputData["fixmedins_code"] = fixmedins_code // 定点医药机构编码 必填
  1611. // inputData["hi_setl_lv"] = "" // 医保结算等级
  1612. // inputData["hi_no"] = "" // 医保编号
  1613. // inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  1614. // inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  1615. // inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  1616. // inputData["gend"] = struct4101.Gend // 性别 必填
  1617. // inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  1618. // inputData["age"] = struct4101.Age // 年龄 必填
  1619. // inputData["ntly"] = struct4101.Ntly // 国籍 必填
  1620. // inputData["nwb_age"] = "" // 年龄 必填
  1621. // inputData["naty"] = struct4101.Naty // 民族 必填
  1622. // inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  1623. // inputData["certno"] = struct4101.Certno // 证件号码 必填
  1624. // inputData["prfs"] = struct4101.Prfs // 职业 必填
  1625. // inputData["curr_addr"] = "" // 现住址 必填
  1626. // inputData["emp_name"] = "" // 单位名称 必填
  1627. // inputData["emp_addr"] = "" // 单位地址 必填
  1628. // inputData["emp_tel"] = "" // 单位电话 必填
  1629. // inputData["poscode"] = "" // 邮编 必填
  1630. // inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  1631. // inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  1632. // inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  1633. // inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  1634. // inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  1635. // inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  1636. // inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  1637. // inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  1638. // inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  1639. // inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  1640. // inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  1641. // inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  1642. // inputData["ipt_med_type"] = struct4101.IptMedType // 住院医疗类型 必填
  1643. // inputData["adm_way"] = "" // 入院途径 必填
  1644. // inputData["trt_type"] = "" // 治疗类别 必填
  1645. // inputData["adm_time"] = "" // 入院时间 必填
  1646. // inputData["adm_caty"] = struct4101.AdmCaty // 入院科别 必填
  1647. // inputData["refldept_dept"] = "" // 转科科别 必填
  1648. // inputData["dscg_time"] = "" // 出院时间 必填
  1649. // inputData["dscg_caty"] = struct4101.AdmCaty // 出院科别 必填
  1650. // inputData["act_ipt_days"] = "" // 实际住院天数 必填
  1651. // inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  1652. // inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  1653. // inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  1654. // inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  1655. // inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  1656. // inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  1657. // inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  1658. // inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  1659. // inputData["bld_cat"] = "" // 输血品种 必填
  1660. // inputData["bld_amt"] = "" // 输血量 必填
  1661. // inputData["bld_unt"] = "" // 输血计量单位 必填
  1662. // inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  1663. // inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  1664. // inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  1665. // inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  1666. // inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  1667. // inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  1668. // inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  1669. // inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  1670. // inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  1671. // inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  1672. // inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  1673. // inputData["chfpdr_name"] = "" // 主诊医师姓名 必填
  1674. // inputData["chfpdr_code"] = "" // 主诊医师代码 必填
  1675. // inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  1676. // inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  1677. // inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  1678. // inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  1679. // inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  1680. // inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  1681. // inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  1682. // inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  1683. // inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  1684. // inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  1685. // inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  1686. //
  1687. // payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  1688. // for _, item := range struct4101.CustomStruct {
  1689. // payinfotemp := make(map[string]interface{})
  1690. // if item.FundPayType == "310100" || item.FundPayType == "310200" || item.FundPayType == "320100" || item.FundPayType == "330100" || item.FundPayType == "340100" || item.FundPayType == "350100" || item.FundPayType == "370100" || item.FundPayType == "390100" || item.FundPayType == "610100" || item.FundPayType == "640100" || item.FundPayType == "620100" {
  1691. // payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  1692. // payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  1693. // payinfo = append(payinfo, payinfotemp)
  1694. // }
  1695. // }
  1696. // opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  1697. // for _, item := range struct4101.OpspdiseinfoStruct {
  1698. // opspdiseinfotemp := make(map[string]interface{})
  1699. // opspdiseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  1700. // opspdiseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  1701. // opspdiseinfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  1702. // opspdiseinfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  1703. //
  1704. // opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  1705. // }
  1706. //
  1707. // diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  1708. // for _, item := range struct4101.OpspdiseinfoStruct {
  1709. // fmt.Println(item.DiagName)
  1710. // diseinfotemp := make(map[string]interface{})
  1711. // diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  1712. // diseinfotemp["diag_type"] = item.MaindiagFlag // 诊断类别 必填
  1713. // diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  1714. // diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  1715. // diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  1716. // diseinfo = append(diseinfo, diseinfotemp)
  1717. // }
  1718. //
  1719. // iteminfo := make([]map[string]interface{}, 0) // 住院诊断信息
  1720. // for _, item := range struct4101.IteminfoStruct {
  1721. // iteminfotemp := make(map[string]interface{})
  1722. // iteminfotemp["med_chrgitm"] = item.MedChrgitm // 医疗收费项目 必填
  1723. // iteminfotemp["amt"] = item.Amt // 金额 必填
  1724. // iteminfotemp["claa_sumfee"] = item.ClaaSumfee // 甲类费用合计 必填
  1725. // iteminfotemp["clab_amt"] = item.ClabAmt // 乙类金额 必填
  1726. // iteminfotemp["fulamt_ownpay_amt"] = item.FulamtOwnpayAmt // 全自费金额 必填
  1727. // iteminfotemp["oth_amt"] = item.OthAmt // 其他金额 必填
  1728. // iteminfo = append(iteminfo, iteminfotemp)
  1729. // }
  1730. //
  1731. // oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  1732. // oprninfotemp := make(map[string]interface{})
  1733. // oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  1734. // oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  1735. // oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  1736. // oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  1737. // oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  1738. // oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  1739. // oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  1740. // oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  1741. // oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  1742. // oprninfo = append(oprninfo, oprninfotemp)
  1743. //
  1744. // icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  1745. // icuinfotemp := make(map[string]interface{})
  1746. // icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  1747. // icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  1748. // icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  1749. // icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  1750. // icuinfo = append(icuinfo, icuinfotemp)
  1751. //
  1752. // input["setlinfo"] = inputData
  1753. // input["payinfo"] = payinfo
  1754. // //input["opspdiseinfo"] = opspdiseinfo
  1755. // input["diseinfo"] = diseinfo
  1756. // input["iteminfo"] = iteminfo
  1757. // //input["oprninfo"] = oprninfo
  1758. // //input["icuinfo"] = icuinfo
  1759. // inputMessage["input"] = input //交易输入
  1760. //
  1761. // bytesData, err := json.Marshal(inputMessage)
  1762. // fmt.Println(string(bytesData))
  1763. // if err != nil {
  1764. // fmt.Println(err.Error())
  1765. // return err.Error()
  1766. // }
  1767. // reader := bytes.NewReader(bytesData)
  1768. //
  1769. // gdyb_url := beego.AppConfig.String("gdyb_url")
  1770. // gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1771. // url := gdyb_url + "4101"
  1772. //
  1773. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  1774. // request, err := http.NewRequest("POST", url, reader)
  1775. // if err != nil {
  1776. // fmt.Println(err.Error())
  1777. // return err.Error()
  1778. // }
  1779. //
  1780. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1781. // request.Header.Set("x-tif-paasid", gdyb_paasid)
  1782. // request.Header.Set("x-tif-signature", signature)
  1783. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1784. // request.Header.Set("x-tif-nonce", nonce)
  1785. //
  1786. // client := http.Client{}
  1787. // resp, err := client.Do(request)
  1788. // if err != nil {
  1789. // fmt.Println(err.Error())
  1790. // return err.Error()
  1791. // }
  1792. // respBytes, err := ioutil.ReadAll(resp.Body)
  1793. // if err != nil {
  1794. // fmt.Println(err.Error())
  1795. // return err.Error()
  1796. // }
  1797. // str := string(respBytes)
  1798. // fmt.Println(str)
  1799. // return str
  1800. //}
  1801. //func Gdyb1201(psnNo string, org_name string, doctor string) string {
  1802. // // 生成签名
  1803. // nonce := GetRandomString(32)
  1804. // timestamp := time.Now().Unix()
  1805. // signature := setSignature(timestamp, nonce)
  1806. //
  1807. // // 生成输入报文
  1808. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "")
  1809. // input := make(map[string]interface{})
  1810. // inputData := make(map[string]interface{})
  1811. // inputMessage["infno"] = "1201" // 交易编码
  1812. // inputData["fixmedins_type"] = psnNo // 人员编号 (来自1101接口返回)
  1813. // inputData["fixmedins_name"] = org_name // 人员编号 (来自1101接口返回)
  1814. // inputData["fixmedins_code"] = "" // 人员编号 (来自1101接口返回)
  1815. //
  1816. // input["medinsinfo"] = inputData
  1817. // inputMessage["input"] = input //交易输入
  1818. //
  1819. // bytesData, err := json.Marshal(inputMessage)
  1820. // fmt.Println(string(bytesData))
  1821. // if err != nil {
  1822. // fmt.Println(err.Error())
  1823. // return err.Error()
  1824. // }
  1825. // reader := bytes.NewReader(bytesData)
  1826. //
  1827. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
  1828. // request, err := http.NewRequest("POST", url, reader)
  1829. // if err != nil {
  1830. // fmt.Println(err.Error())
  1831. // return err.Error()
  1832. // }
  1833. //
  1834. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1835. // request.Header.Set("x-tif-paasid", "test_hosp")
  1836. // request.Header.Set("x-tif-signature", signature)
  1837. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1838. // request.Header.Set("x-tif-nonce", nonce)
  1839. //
  1840. // client := http.Client{}
  1841. // resp, err := client.Do(request)
  1842. // if err != nil {
  1843. // fmt.Println(err.Error())
  1844. // return err.Error()
  1845. // }
  1846. // respBytes, err := ioutil.ReadAll(resp.Body)
  1847. // if err != nil {
  1848. // fmt.Println(err.Error())
  1849. // return err.Error()
  1850. // }
  1851. // str := string(respBytes)
  1852. // fmt.Println(str)
  1853. // return str
  1854. //}
  1855. //func Gdyb5203(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  1856. // // 生成签名
  1857. // nonce := GetRandomString(32)
  1858. // timestamp := time.Now().Unix()
  1859. // signature := setSignature(timestamp, nonce, secret_key)
  1860. //
  1861. // // 生成输入报文
  1862. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1863. // input := make(map[string]interface{})
  1864. // inputData := make(map[string]interface{})
  1865. // inputMessage["infno"] = "5203" // 交易编码
  1866. //
  1867. // inputData["fixmedins_type"] = "1"
  1868. // inputData["fixmedins_name"] = org_name
  1869. // inputData["fixmedins_code"] = fixmedins_code
  1870. // input["medinsinfo"] = inputData
  1871. // inputMessage["input"] = input //交易输入
  1872. //
  1873. // bytesData, err := json.Marshal(inputMessage)
  1874. // fmt.Println(string(bytesData))
  1875. // if err != nil {
  1876. // fmt.Println(err.Error())
  1877. // return err.Error()
  1878. // }
  1879. // reader := bytes.NewReader(bytesData)
  1880. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1201"
  1881. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
  1882. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  1883. // request, err := http.NewRequest("POST", url, reader)
  1884. // if err != nil {
  1885. // fmt.Println(err.Error())
  1886. // return err.Error()
  1887. // }
  1888. //
  1889. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1890. // request.Header.Set("x-tif-paasid", "sg03_prd")
  1891. // request.Header.Set("x-tif-signature", signature)
  1892. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1893. // request.Header.Set("x-tif-nonce", nonce)
  1894. //
  1895. // client := http.Client{}
  1896. // resp, err := client.Do(request)
  1897. // if err != nil {
  1898. // fmt.Println(err.Error())
  1899. // return err.Error()
  1900. // }
  1901. // respBytes, err := ioutil.ReadAll(resp.Body)
  1902. // if err != nil {
  1903. // fmt.Println(err.Error())
  1904. // return err.Error()
  1905. // }
  1906. // fmt.Println(string(respBytes))
  1907. // str := string(respBytes)
  1908. // return str
  1909. //}
  1910. func FJyb2601(psnNo string, omsgid string, oinfno string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  1911. // 生成签名
  1912. nonce := GetRandomString(32)
  1913. timestamp := time.Now().Unix()
  1914. signature := setSignature(timestamp, nonce, secret_key)
  1915. // 生成输入报文
  1916. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1917. input := make(map[string]interface{})
  1918. inputData := make(map[string]interface{})
  1919. inputMessage["infno"] = "2601" // 交易编码
  1920. inputData["psn_no"] = psnNo
  1921. inputData["omsgid"] = omsgid
  1922. inputData["oinfno"] = oinfno
  1923. input["data"] = inputData
  1924. inputMessage["input"] = input //交易输入
  1925. bytesData, err := json.Marshal(inputMessage)
  1926. fmt.Println(string(bytesData))
  1927. if err != nil {
  1928. fmt.Println(err.Error())
  1929. return err.Error()
  1930. }
  1931. reader := bytes.NewReader(bytesData)
  1932. gdyb_url := beego.AppConfig.String("gdyb_url")
  1933. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1934. url := gdyb_url + "2601"
  1935. request, err := http.NewRequest("POST", url, reader)
  1936. if err != nil {
  1937. fmt.Println(err.Error())
  1938. return err.Error()
  1939. }
  1940. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1941. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1942. request.Header.Set("x-tif-signature", signature)
  1943. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1944. request.Header.Set("x-tif-nonce", nonce)
  1945. client := http.Client{}
  1946. resp, err := client.Do(request)
  1947. if err != nil {
  1948. fmt.Println(err.Error())
  1949. return err.Error()
  1950. }
  1951. respBytes, err := ioutil.ReadAll(resp.Body)
  1952. if err != nil {
  1953. fmt.Println(err.Error())
  1954. return err.Error()
  1955. }
  1956. str := string(respBytes)
  1957. fmt.Println(str)
  1958. return str
  1959. }
  1960. //人员信息版本3
  1961. func FJyb1101B(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) string {
  1962. //生成签名
  1963. nonce := GetRandomString(32)
  1964. timestamp := time.Now().Unix()
  1965. signature := setSignature(timestamp, nonce, secret_key)
  1966. //生成输入报文
  1967. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1968. input := make(map[string]interface{})
  1969. inputData := make(map[string]interface{})
  1970. inputMessage["infno"] = "1101" // 交易编码
  1971. if certificates == 3 {
  1972. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1973. inputData["certno"] = certNo // 证件号码
  1974. inputData["psn_cert_type"] = "99" // 人员证件类型
  1975. } else {
  1976. if id_card_type == 1 {
  1977. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1978. inputData["card_sn"] = "" // 卡识别码
  1979. inputData["certno"] = certNo // 证件号码
  1980. inputData["psn_cert_type"] = "01" // 人员证件类型
  1981. } else {
  1982. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1983. inputData["card_sn"] = "" // 卡识别码
  1984. inputData["certno"] = certNo // 证件号码
  1985. inputData["psn_cert_type"] = "1" // 人员证件类型
  1986. }
  1987. }
  1988. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1989. inputData["begntime"] = "" // 开始时间
  1990. inputData["psn_name"] = "" // 人员姓名
  1991. input["data"] = inputData
  1992. inputMessage["input"] = input //交易输入
  1993. bytesData, err := json.Marshal(inputMessage)
  1994. fmt.Println(string(bytesData))
  1995. if err != nil {
  1996. fmt.Println(err.Error())
  1997. return err.Error()
  1998. }
  1999. reader := bytes.NewReader(bytesData)
  2000. gdyb_url := beego.AppConfig.String("gdyb_url")
  2001. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2002. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2003. url := gdyb_url + "1101"
  2004. fmt.Println(url)
  2005. fmt.Println(gdyb_paasid)
  2006. fmt.Println(secret_key)
  2007. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  2008. request, err := http.NewRequest("POST", url, reader)
  2009. if err != nil {
  2010. fmt.Println(err.Error())
  2011. return err.Error()
  2012. }
  2013. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2014. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2015. request.Header.Set("x-tif-signature", signature)
  2016. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2017. request.Header.Set("x-tif-nonce", nonce)
  2018. client := http.Client{}
  2019. resp, err := client.Do(request)
  2020. if err != nil {
  2021. fmt.Println(err.Error())
  2022. return err.Error()
  2023. }
  2024. respBytes, err := ioutil.ReadAll(resp.Body)
  2025. if err != nil {
  2026. fmt.Println(err.Error())
  2027. return err.Error()
  2028. }
  2029. fmt.Println(string(respBytes))
  2030. str := string(respBytes)
  2031. return str
  2032. }
  2033. //人员信息版本4
  2034. func FJyb1101C(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) (string, string) {
  2035. //生成签名
  2036. nonce := GetRandomString(32)
  2037. timestamp := time.Now().Unix()
  2038. //signature := setSignature(timestamp, nonce, secret_key)
  2039. //生成输入报文
  2040. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2041. input := make(map[string]interface{})
  2042. inputData := make(map[string]interface{})
  2043. inputMessage["infno"] = "1101" // 交易编码
  2044. if certificates == 3 {
  2045. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  2046. inputData["certno"] = certNo // 证件号码
  2047. inputData["psn_cert_type"] = "99" // 人员证件类型
  2048. } else {
  2049. if id_card_type == 1 {
  2050. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  2051. inputData["card_sn"] = "" // 卡识别码
  2052. inputData["certno"] = "" // 证件号码
  2053. inputData["psn_cert_type"] = "" // 人员证件类型
  2054. } else {
  2055. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  2056. inputData["card_sn"] = "" // 卡识别码
  2057. inputData["certno"] = certNo // 证件号码
  2058. inputData["psn_cert_type"] = "1" // 人员证件类型
  2059. }
  2060. }
  2061. inputData["mdtrt_cert_no"] = "" // 就诊凭证编号
  2062. inputData["begntime"] = "" // 开始时间
  2063. inputData["psn_name"] = "" // 人员姓名
  2064. input["data"] = inputData
  2065. inputMessage["input"] = input //交易输入
  2066. bytesData, err := json.Marshal(inputMessage)
  2067. fmt.Println(string(bytesData))
  2068. if err != nil {
  2069. fmt.Println(err.Error())
  2070. return err.Error(), ""
  2071. }
  2072. var json2 string
  2073. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  2074. out, err := cmd.Output()
  2075. if err != nil {
  2076. fmt.Println("error:", err.Error())
  2077. }
  2078. fmt.Println(string(out))
  2079. return string(out), string(bytesData)
  2080. }
  2081. func FJyb90991(psn_no string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, pwd string) string {
  2082. //生成签名
  2083. nonce := GetRandomString(32)
  2084. timestamp := time.Now().Unix()
  2085. signature := setSignature(timestamp, nonce, secret_key)
  2086. //生成输入报文
  2087. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2088. input := make(map[string]interface{})
  2089. inputData := make(map[string]interface{})
  2090. inputMessage["infno"] = "90991" // 交易编码
  2091. inputData["fixmedins_code"] = fixmedins_code // 就诊凭证编号
  2092. inputData["psn_no"] = psn_no // 开始时间
  2093. inputData["card_pwd"] = pwd // 人员姓名
  2094. input["data"] = inputData
  2095. inputMessage["input"] = input //交易输入
  2096. bytesData, err := json.Marshal(inputMessage)
  2097. fmt.Println(string(bytesData))
  2098. if err != nil {
  2099. fmt.Println(err.Error())
  2100. return err.Error()
  2101. }
  2102. reader := bytes.NewReader(bytesData)
  2103. gdyb_url := beego.AppConfig.String("gdyb_url")
  2104. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2105. url := gdyb_url + "90991"
  2106. request, err := http.NewRequest("POST", url, reader)
  2107. if err != nil {
  2108. fmt.Println(err.Error())
  2109. return err.Error()
  2110. }
  2111. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2112. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2113. request.Header.Set("x-tif-signature", signature)
  2114. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2115. request.Header.Set("x-tif-nonce", nonce)
  2116. client := http.Client{}
  2117. resp, err := client.Do(request)
  2118. if err != nil {
  2119. fmt.Println(err.Error())
  2120. return err.Error()
  2121. }
  2122. respBytes, err := ioutil.ReadAll(resp.Body)
  2123. if err != nil {
  2124. fmt.Println(err.Error())
  2125. return err.Error()
  2126. }
  2127. fmt.Println(string(respBytes))
  2128. str := string(respBytes)
  2129. return str
  2130. }
  2131. func FJyb90100(psn_no string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  2132. //生成签名
  2133. nonce := GetRandomString(32)
  2134. timestamp := time.Now().Unix()
  2135. signature := setSignature(timestamp, nonce, secret_key)
  2136. //生成输入报文
  2137. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2138. input := make(map[string]interface{})
  2139. inputData := make(map[string]interface{})
  2140. inputMessage["infno"] = "90100" // 交易编码
  2141. inputData["psn_no"] = psn_no // 开始时间
  2142. input["data"] = inputData
  2143. inputMessage["input"] = input //交易输入
  2144. bytesData, err := json.Marshal(inputMessage)
  2145. fmt.Println(string(bytesData))
  2146. if err != nil {
  2147. fmt.Println(err.Error())
  2148. return err.Error()
  2149. }
  2150. reader := bytes.NewReader(bytesData)
  2151. gdyb_url := beego.AppConfig.String("gdyb_url")
  2152. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2153. url := gdyb_url + "90100"
  2154. request, err := http.NewRequest("POST", url, reader)
  2155. if err != nil {
  2156. fmt.Println(err.Error())
  2157. return err.Error()
  2158. }
  2159. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2160. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2161. request.Header.Set("x-tif-signature", signature)
  2162. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2163. request.Header.Set("x-tif-nonce", nonce)
  2164. client := http.Client{}
  2165. resp, err := client.Do(request)
  2166. if err != nil {
  2167. fmt.Println(err.Error())
  2168. return err.Error()
  2169. }
  2170. respBytes, err := ioutil.ReadAll(resp.Body)
  2171. if err != nil {
  2172. fmt.Println(err.Error())
  2173. return err.Error()
  2174. }
  2175. fmt.Println(string(respBytes))
  2176. str := string(respBytes)
  2177. return str
  2178. }
  2179. //func StrPtr(s string) uintptr {
  2180. // return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  2181. //}
  2182. func FJyb2001(secret_key string, org_name string, doctor_name string, code string, insuplcAdmdvs string, mdtrtareaAdmvs string, psn_no string, insutype string, med_type string) (string, string) {
  2183. if med_type == "1111" || med_type == "1112" {
  2184. med_type = "11"
  2185. }
  2186. // 生成签名
  2187. nonce := GetRandomString(32)
  2188. timestamp := time.Now().Unix()
  2189. //signature := setSignature(timestamp, nonce, secret_key)
  2190. tempTime := time.Unix(timestamp, 0)
  2191. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2192. // 生成输入报文
  2193. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor_name, code, insuplcAdmdvs, mdtrtareaAdmvs)
  2194. input := make(map[string]interface{})
  2195. inputData := make(map[string]interface{})
  2196. inputMessage["infno"] = "2001" // 交易编码
  2197. inputData["psn_no"] = psn_no
  2198. inputData["insutype"] = insutype
  2199. inputData["med_type"] = med_type
  2200. inputData["begntime"] = timeFormatOne
  2201. input["data"] = inputData
  2202. inputMessage["input"] = input //交易输入
  2203. bytesData, err := json.Marshal(inputMessage)
  2204. fmt.Println(string(bytesData))
  2205. if err != nil {
  2206. fmt.Println(err.Error())
  2207. return err.Error(), ""
  2208. }
  2209. var json2 string
  2210. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  2211. out, err := cmd.Output()
  2212. if err != nil {
  2213. fmt.Println("error:", err.Error())
  2214. }
  2215. return string(out), string(bytesData)
  2216. }
  2217. func SetFjInputMessage(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, url string, app_id string, app_secret string, sign_key string, enc_key string) map[string]interface{} {
  2218. // 生成签名
  2219. tempTime := time.Unix(timestamp, 0)
  2220. //timeFormat := tempTime.Format("20060102150405")
  2221. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2222. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  2223. month := time.Unix(1557042972, 0).Format("1")
  2224. year := time.Now().Format("2006")
  2225. month = time.Now().Format("01")
  2226. day := time.Now().Format("02")
  2227. hour := time.Now().Format("15")
  2228. min := time.Now().Format("04")
  2229. sec := time.Now().Format("05")
  2230. msec := time.Now().Format("000")
  2231. // 生成输入报文
  2232. inputMessage := make(map[string]interface{})
  2233. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  2234. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  2235. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  2236. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  2237. inputMessage["dev_no"] = "" // 设备编号
  2238. inputMessage["dev_safe_info"] = "" // 设备安全信息
  2239. inputMessage["cainfo"] = "" // 数字签名信息
  2240. inputMessage["signtype"] = "SM3" // 签名类型
  2241. inputMessage["infver"] = "V1.0" // 接收方系统代码
  2242. inputMessage["opter_type"] = "1" // 经办人类别
  2243. inputMessage["opter"] = doctor // 经办人
  2244. inputMessage["opter_name"] = doctor // 经办人姓名
  2245. inputMessage["inf_time"] = timeFormatOne // 交易时间
  2246. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  2247. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  2248. inputMessage["url"] = url //定点医药机构名称
  2249. inputMessage["app_id"] = app_id //定点医药机构名称
  2250. inputMessage["app_secret"] = app_secret //定点医药机构名称
  2251. inputMessage["sign_key"] = sign_key //定点医药机构名称
  2252. inputMessage["enc_key"] = enc_key //定点医药机构名称
  2253. if mdtrtarea_admvs == "440100" {
  2254. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  2255. } else {
  2256. inputMessage["sign_no"] = "" //交易签到流水号
  2257. }
  2258. return inputMessage
  2259. }
  2260. //人员信息版本
  2261. //func FjYB1101B(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) string {
  2262. // //生成签名
  2263. // nonce := GetRandomString(32)
  2264. // timestamp := time.Now().Unix()
  2265. // signature := setSignature(timestamp, nonce, secret_key)
  2266. // //生成输入报文
  2267. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2268. // input := make(map[string]interface{})
  2269. // inputData := make(map[string]interface{})
  2270. // inputMessage["infno"] = "1101" // 交易编码
  2271. //
  2272. // if certificates == 3 {
  2273. // inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  2274. // inputData["certno"] = certNo // 证件号码
  2275. // inputData["psn_cert_type"] = "99" // 人员证件类型
  2276. //
  2277. // } else {
  2278. // if certificates == 1 {
  2279. // if id_card_type == 1 {
  2280. // inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  2281. // inputData["card_sn"] = "" // 卡识别码
  2282. // inputData["certno"] = certNo // 证件号码
  2283. // inputData["psn_cert_type"] = "01" // 人员证件类型
  2284. // } else {
  2285. // inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  2286. // inputData["card_sn"] = "" // 卡识别码
  2287. // inputData["certno"] = certNo // 证件号码
  2288. // inputData["psn_cert_type"] = "01" // 人员证件类型
  2289. // }
  2290. //
  2291. // } else if certificates == 6 {
  2292. // inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  2293. // inputData["card_sn"] = "" // 卡识别码
  2294. // inputData["certno"] = certNo // 证件号码
  2295. // inputData["psn_cert_type"] = "17" // 人员证件类型
  2296. // }
  2297. //
  2298. // }
  2299. //
  2300. // inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  2301. // inputData["begntime"] = "" // 开始时间
  2302. // inputData["psn_name"] = "" // 人员姓名
  2303. // input["data"] = inputData
  2304. // inputMessage["input"] = input //交易输入
  2305. //
  2306. // bytesData, err := json.Marshal(inputMessage)
  2307. // fmt.Println(string(bytesData))
  2308. // if err != nil {
  2309. // fmt.Println(err.Error())
  2310. // return err.Error()
  2311. // }
  2312. // reader := bytes.NewReader(bytesData)
  2313. // gdyb_url := beego.AppConfig.String("gdyb_url")
  2314. // gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2315. //
  2316. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2317. // //url := gdyb_url + "1101"
  2318. // var url string
  2319. // if fixmedins_code == "H15049901371" {
  2320. // url = gdyb_url
  2321. // } else {
  2322. // url = gdyb_url + "1101"
  2323. // }
  2324. //
  2325. // fmt.Println(url)
  2326. // fmt.Println(gdyb_paasid)
  2327. // fmt.Println(secret_key)
  2328. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  2329. // request, err := http.NewRequest("POST", url, reader)
  2330. // if err != nil {
  2331. // fmt.Println(err.Error())
  2332. // return err.Error()
  2333. // }
  2334. //
  2335. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2336. // request.Header.Set("x-tif-paasid", gdyb_paasid)
  2337. // request.Header.Set("x-tif-signature", signature)
  2338. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2339. // request.Header.Set("x-tif-nonce", nonce)
  2340. //
  2341. // client := http.Client{}
  2342. // resp, err := client.Do(request)
  2343. // if err != nil {
  2344. // fmt.Println(err.Error())
  2345. // return err.Error()
  2346. // }
  2347. // respBytes, err := ioutil.ReadAll(resp.Body)
  2348. // if err != nil {
  2349. // fmt.Println(err.Error())
  2350. // return err.Error()
  2351. // }
  2352. // fmt.Println(string(respBytes))
  2353. // str := string(respBytes)
  2354. // return str
  2355. //}
  2356. func GetFjBusinessHandleInfo(inputStr []byte) (string, string) {
  2357. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  2358. readCard := DllDef.MustFindProc("business_handle")
  2359. if readCard == nil {
  2360. fmt.Println("readcard is nil")
  2361. readCard = DllDef.MustFindProc("read_cardinfo")
  2362. }
  2363. outputStr := make([]byte, 1002288)
  2364. errMessageStr := make([]byte, 2048)
  2365. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&inputStr[0])), uintptr(20000), (uintptr)(unsafe.Pointer(&outputStr[0])), (uintptr)(unsafe.Pointer(&errMessageStr[0])))
  2366. output_info := ConvertByte2String(outputStr, GB18030)
  2367. error_info := ConvertByte2String(errMessageStr, GB18030)
  2368. output_info = Remove0000(output_info)
  2369. error_info = Remove0000(error_info)
  2370. fmt.Println(output_info)
  2371. fmt.Println(error_info)
  2372. if ret2 != 0 {
  2373. return "", ""
  2374. }
  2375. return DeleteExtraSpace(output_info), DeleteExtraSpace(error_info)
  2376. }
  2377. func GetFjAuthorizationInfo(org_id string) {
  2378. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  2379. readCard := DllDef.MustFindProc("authorization")
  2380. if readCard == nil {
  2381. fmt.Println("readcard is nil")
  2382. readCard = DllDef.MustFindProc("authorization")
  2383. }
  2384. errMessageStr := make([]byte, 2048)
  2385. psw := org_id[len(org_id)-6 : len(org_id)]
  2386. fmt.Println(psw)
  2387. ret2, _, _ := readCard.Call(StrPtr(org_id), StrPtr(psw), (uintptr)(unsafe.Pointer(&errMessageStr[0])))
  2388. fmt.Println(string(errMessageStr))
  2389. if ret2 != 0 {
  2390. }
  2391. }
  2392. func Remove0000(s string) string {
  2393. str := make([]rune, 0, len(s))
  2394. for _, v := range []rune(s) {
  2395. if v == 0 {
  2396. continue
  2397. }
  2398. str = append(str, v)
  2399. }
  2400. return string(str)
  2401. }
  2402. func ConvertByte2String(byte []byte, charset Charset) string {
  2403. var str string
  2404. switch charset {
  2405. case GB18030:
  2406. decodeBytes, _ := simplifiedchinese.GB18030.NewDecoder().Bytes(byte)
  2407. str = string(decodeBytes)
  2408. case UTF8:
  2409. fallthrough
  2410. default:
  2411. str = string(byte)
  2412. }
  2413. return str
  2414. }
  2415. func DeleteExtraSpace(s string) string {
  2416. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  2417. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  2418. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  2419. reg, _ := regexp.Compile(regstr) //编译正则表达式
  2420. s2 := make([]byte, len(s1)) //定义字符数组切片
  2421. copy(s2, s1) //将字符串复制到切片
  2422. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  2423. for len(spc_index) > 0 { //找到适配项
  2424. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  2425. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  2426. }
  2427. return string(s2)
  2428. }
  2429. func ReadEleCard(code string) (string, string, string) {
  2430. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  2431. readCard := DllDef.MustFindProc("ec_decode")
  2432. //pCardInfo := make([]byte, 8192)
  2433. pBusiCardInfo := make([]byte, 2048)
  2434. pErrMsg := make([]byte, 2048)
  2435. data := make(map[string]interface{})
  2436. inputData := make(map[string]interface{})
  2437. inputData["orgId"] = code
  2438. inputData["businessType"] = "01101"
  2439. inputData["operatorId"] = "1"
  2440. inputData["operatorName"] = "admin"
  2441. inputData["officeId"] = "101"
  2442. inputData["officeName"] = "xt"
  2443. inputData["deviceType"] = ""
  2444. data["data"] = inputData
  2445. data["transType"] = "ec.query"
  2446. data["orgId"] = code
  2447. bytesData, _ := json.Marshal(data)
  2448. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])), (uintptr)(unsafe.Pointer(&pErrMsg[0])))
  2449. fmt.Println(ConvertToString(DeleteExtraSpace(string(pErrMsg)), "gbk", "utf-8"))
  2450. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  2451. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  2452. if ret2 != 0 {
  2453. return "", "", ""
  2454. }
  2455. //readCard.Dll.Release()
  2456. return ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"), ConvertToString(DeleteExtraSpace(string(pErrMsg)), "gbk", "utf-8")
  2457. }
  2458. func ReadEleCardForSettle(code string, user_name string, id int64) (string, string, string) {
  2459. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  2460. readCard := DllDef.MustFindProc("ec_decode")
  2461. pCardInfo := make([]byte, 8192)
  2462. pBusiCardInfo := make([]byte, 8192)
  2463. pErrMsg := make([]byte, 8192)
  2464. data := make(map[string]interface{})
  2465. inputData := make(map[string]interface{})
  2466. inputData["orgId"] = code
  2467. inputData["businessType"] = "01301"
  2468. inputData["operatorId"] = id
  2469. inputData["operatorName"] = user_name
  2470. inputData["officeId"] = "001"
  2471. inputData["officeName"] = "血透科"
  2472. data["data"] = inputData
  2473. data["transType"] = "ec.query"
  2474. data["orgId"] = code
  2475. bytesData, _ := json.Marshal(data)
  2476. pCardInfo = bytesData
  2477. pCardInfo = []byte(ConvertByte2String(pCardInfo, GB18030))
  2478. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])), (uintptr)(unsafe.Pointer(&pErrMsg[0])))
  2479. fmt.Println(ret2)
  2480. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  2481. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  2482. if ret2 != 0 {
  2483. return "", "", ""
  2484. }
  2485. return ConvertByte2String([]byte(DeleteExtraSpace(string(bytesData))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pBusiCardInfo))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pErrMsg))), GB18030)
  2486. }
  2487. //
  2488. //func GetLastPsnByInsOrg(patient_id int64) (psn models.HisPsn, err error){
  2489. // err := readDb.Model(&models.HisPsn{}).Where("patient_id = ? AND insuplc_admdvs <> ''",patient_id).Last(&psn).Error
  2490. // return
  2491. //}