fj_service.go 113KB

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