ahyb_service.go 157KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556
  1. package service
  2. import (
  3. "bytes"
  4. "encoding/json"
  5. "fmt"
  6. "gdyb/models"
  7. "gdyb/utils/csbhttp"
  8. "github.com/astaxie/beego"
  9. "io/ioutil"
  10. "net/http"
  11. "strconv"
  12. "strings"
  13. "time"
  14. )
  15. // 人员基本信息
  16. func AHyb1101(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, id_card_type int64, card_sn string, certificates string, request_url string, name string,token string) (string, string) {
  17. timestamp := time.Now().Unix()
  18. //生成输入报文
  19. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, "")
  20. input := make(map[string]interface{})
  21. inputData := make(map[string]interface{})
  22. inputMessage["infno"] = "1101" // 交易编码
  23. if certificates == "3" {
  24. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  25. inputData["certno"] = certNo // 证件号码
  26. inputData["psn_cert_type"] = "99" // 人员证件类型
  27. } else {
  28. if id_card_type == 1 {
  29. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  30. inputData["card_sn"] = card_sn // 卡识别码
  31. inputData["certno"] = certNo // 证件号码
  32. inputData["psn_cert_type"] = "01" // 人员证件类型
  33. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  34. } else if id_card_type == 4 {
  35. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  36. inputData["card_sn"] = card_sn // 卡识别码
  37. inputData["certno"] = certNo // 证件号码
  38. inputData["psn_cert_type"] = "01" // 人员证件类型
  39. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  40. }else {
  41. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  42. inputData["card_sn"] = "" // 卡识别码
  43. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  44. inputData["certno"] = certNo // 证件号码
  45. inputData["psn_cert_type"] = "01" // 人员证件类型
  46. }
  47. }
  48. month := time.Unix(1557042972, 0).Format("1")
  49. year := time.Now().Format("2006")
  50. month = time.Now().Format("01")
  51. day := time.Now().Format("02")
  52. inputData["begntime"] = year + "-" +month + "-" + day // 开始时间
  53. inputData["psn_name"] = name // 人员姓名
  54. input["data"] = inputData
  55. inputMessage["input"] = input //交易输入
  56. argInputMessage := make(map[string]interface{})
  57. argInputMessage["arg0"] = inputMessage
  58. bytesData, err := json.Marshal(argInputMessage)
  59. fmt.Println(string(bytesData))
  60. if err != nil {
  61. fmt.Println(err.Error())
  62. return err.Error(), ""
  63. }
  64. reader := bytes.NewReader(bytesData)
  65. request_url = request_url + "1101"
  66. fmt.Println(request_url)
  67. request, err := http.NewRequest("POST", request_url, reader)
  68. if err != nil {
  69. fmt.Println(err.Error())
  70. return err.Error(), ""
  71. }
  72. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  73. //request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
  74. //request.Header.Set("_api_name", "hssServives")
  75. //request.Header.Set("_api_version", "1.0.0")
  76. //request.Header.Set("_api_access_key", access_key)
  77. //request.Header.Set("_api_signature", "")
  78. AHyb1901(request_url)
  79. client := http.Client{}
  80. resp, err := client.Do(request)
  81. if err != nil {
  82. fmt.Println(err.Error())
  83. return err.Error(), ""
  84. }
  85. respBytes, err := ioutil.ReadAll(resp.Body)
  86. if err != nil {
  87. fmt.Println(err.Error())
  88. return err.Error(), ""
  89. }
  90. str := string(respBytes)
  91. fmt.Println(str)
  92. return str, string(bytesData)
  93. }
  94. //人员基本信息版本2
  95. func AHyb1101A(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 string, request_url string, access_key string, id_card_no string, cainfo string) (string, string) {
  96. timestamp := time.Now().Unix()
  97. //生成输入报文
  98. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  99. input := make(map[string]interface{})
  100. inputData := make(map[string]interface{})
  101. inputMessage["infno"] = "1101" // 交易编码
  102. if certificates == "3" {
  103. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  104. inputData["certno"] = certNo // 证件号码
  105. inputData["psn_cert_type"] = "99" // 人员证件类型
  106. } else {
  107. if id_card_type == 1 {
  108. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  109. inputData["card_sn"] = card_sn // 卡识别码
  110. inputData["certno"] = id_card_no // 证件号码
  111. inputData["psn_cert_type"] = "01" // 人员证件类型
  112. } else {
  113. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  114. inputData["card_sn"] = "" // 卡识别码
  115. inputData["certno"] = certNo // 证件号码
  116. inputData["psn_cert_type"] = "01" // 人员证件类型
  117. }
  118. }
  119. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  120. month := time.Unix(1557042972, 0).Format("1")
  121. year := time.Now().Format("2006")
  122. month = time.Now().Format("01")
  123. day := time.Now().Format("02")
  124. inputData["begntime"] = year + "-" +month + "-" + day // 开始时间 // 开始时间
  125. inputData["psn_name"] = "" // 人员姓名
  126. input["data"] = inputData
  127. inputMessage["input"] = input //交易输入
  128. argInputMessage := make(map[string]interface{})
  129. argInputMessage["arg0"] = inputMessage
  130. bytesData, err := json.Marshal(argInputMessage)
  131. fmt.Println(string(bytesData))
  132. if err != nil {
  133. fmt.Println(err.Error())
  134. return err.Error(), ""
  135. }
  136. reader := bytes.NewReader(bytesData)
  137. request_url = request_url + "1101"
  138. fmt.Println(request_url)
  139. request, err := http.NewRequest("POST", request_url, reader)
  140. if err != nil {
  141. fmt.Println(err.Error())
  142. return err.Error(), ""
  143. }
  144. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  145. //request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
  146. //request.Header.Set("_api_name", "hssServives")
  147. //request.Header.Set("_api_version", "1.0.0")
  148. //request.Header.Set("_api_access_key", access_key)
  149. //request.Header.Set("_api_signature", "")
  150. client := http.Client{}
  151. resp, err := client.Do(request)
  152. if err != nil {
  153. fmt.Println(err.Error())
  154. return err.Error(), ""
  155. }
  156. respBytes, err := ioutil.ReadAll(resp.Body)
  157. if err != nil {
  158. fmt.Println(err.Error())
  159. return err.Error(), ""
  160. }
  161. str := string(respBytes)
  162. fmt.Println(str)
  163. return str, string(bytesData)
  164. }
  165. func AHyb1101B(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, request_url string, access_key string, Token string, cainfo string, id_card_no string) (string, string) {
  166. timestamp := time.Now().Unix()
  167. //生成输入报文
  168. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  169. input := make(map[string]interface{})
  170. inputData := make(map[string]interface{})
  171. inputMessage["infno"] = "1101" // 交易编码
  172. inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
  173. inputData["card_sn"] = "" // 卡识别码
  174. inputData["certno"] = "" // 证件号码
  175. inputData["psn_cert_type"] = "01" // 人员证件类型
  176. inputData["mdtrt_cert_no"] = id_card_no + "|" + Token // 就诊凭证编号
  177. inputData["begntime"] = "" // 开始时间
  178. inputData["psn_name"] = "" // 人员姓名
  179. input["data"] = inputData
  180. inputMessage["input"] = input //交易输入
  181. argInputMessage := make(map[string]interface{})
  182. argInputMessage["arg0"] = inputMessage
  183. bytesData, err := json.Marshal(argInputMessage)
  184. fmt.Println(string(bytesData))
  185. if err != nil {
  186. fmt.Println(err.Error())
  187. return err.Error(), ""
  188. }
  189. reader := bytes.NewReader(bytesData)
  190. request_url = request_url + "1101"
  191. fmt.Println(request_url)
  192. request, err := http.NewRequest("POST", request_url, reader)
  193. if err != nil {
  194. fmt.Println(err.Error())
  195. return err.Error(), ""
  196. }
  197. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  198. //request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
  199. //request.Header.Set("_api_name", "hssServives")
  200. //request.Header.Set("_api_version", "1.0.0")
  201. //request.Header.Set("_api_access_key", access_key)
  202. //request.Header.Set("_api_signature", "")
  203. client := http.Client{}
  204. resp, err := client.Do(request)
  205. if err != nil {
  206. fmt.Println(err.Error())
  207. return err.Error(), ""
  208. }
  209. respBytes, err := ioutil.ReadAll(resp.Body)
  210. if err != nil {
  211. fmt.Println(err.Error())
  212. return err.Error(), ""
  213. }
  214. str := string(respBytes)
  215. fmt.Println(str)
  216. return str, string(bytesData)
  217. }
  218. func AHyb1101ForEleCert(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, request_url string, access_key string, Token string, cainfo string, id_card_no string, name string) (string, string) {
  219. timestamp := time.Now().Unix()
  220. //生成输入报文
  221. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  222. input := make(map[string]interface{})
  223. inputData := make(map[string]interface{})
  224. inputMessage["infno"] = "1101" // 交易编码
  225. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  226. inputData["card_sn"] = "" // 卡识别码
  227. inputData["certno"] = id_card_no // 证件号码
  228. inputData["psn_cert_type"] = "01" // 人员证件类型
  229. inputData["mdtrt_cert_no"] = Token // 就诊凭证编号
  230. month := time.Unix(1557042972, 0).Format("1")
  231. year := time.Now().Format("2006")
  232. month = time.Now().Format("01")
  233. day := time.Now().Format("02")
  234. inputData["begntime"] = year + "-" +month + "-" + day
  235. inputData["psn_name"] = name // 人员姓名
  236. input["data"] = inputData
  237. inputMessage["input"] = input //交易输入
  238. argInputMessage := make(map[string]interface{})
  239. argInputMessage["arg0"] = inputMessage
  240. bytesData, err := json.Marshal(argInputMessage)
  241. fmt.Println(string(bytesData))
  242. if err != nil {
  243. fmt.Println(err.Error())
  244. return err.Error(), ""
  245. }
  246. reader := bytes.NewReader(bytesData)
  247. request_url = request_url + "1101"
  248. fmt.Println(request_url)
  249. request, err := http.NewRequest("POST", request_url, reader)
  250. if err != nil {
  251. fmt.Println(err.Error())
  252. return err.Error(), ""
  253. }
  254. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  255. //request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
  256. //request.Header.Set("_api_name", "hssServives")
  257. //request.Header.Set("_api_version", "1.0.0")
  258. //request.Header.Set("_api_access_key", access_key)
  259. //request.Header.Set("_api_signature", "")
  260. client := http.Client{}
  261. resp, err := client.Do(request)
  262. if err != nil {
  263. fmt.Println(err.Error())
  264. return err.Error(), ""
  265. }
  266. respBytes, err := ioutil.ReadAll(resp.Body)
  267. if err != nil {
  268. fmt.Println(err.Error())
  269. return err.Error(), ""
  270. }
  271. str := string(respBytes)
  272. fmt.Println(str)
  273. return str, string(bytesData)
  274. }
  275. // 门诊挂号
  276. func AHyb2201(psnNo string, insutype string, certNo string, org_name string, opera string, ipt_otp_no string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, doctor_name string, request_url string, access_key string, verify_number string, cainfo string, card_sn string) (string, string) {
  277. fmt.Println(opera)
  278. // 生成签名
  279. timestamp := time.Now().Unix()
  280. tempTime := time.Unix(timestamp, 0)
  281. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  282. // 生成输入报文
  283. inputMessage := SetAHInputMessage(timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  284. input := make(map[string]interface{})
  285. inputData := make(map[string]interface{})
  286. inputMessage["infno"] = "2201" // 交易编码
  287. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  288. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  289. inputData["begntime"] = timeFormatOne // 开始时间
  290. if id_card_type == 1 {
  291. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  292. inputData["card_sn"] = card_sn // 卡识别码
  293. inputData["certno"] = certNo // 证件号码
  294. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  295. } else if id_card_type == 3 {
  296. inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
  297. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  298. } else if id_card_type == 4 {
  299. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  300. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  301. } else {
  302. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  303. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  304. }
  305. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  306. inputData["atddr_no"] = doctor_id // 医师编码
  307. inputData["dr_name"] = doctor_name // 医师姓名
  308. inputData["dept_code"] = dept_code // 科室编码
  309. inputData["dept_name"] = dept // 科室名称
  310. inputData["caty"] = "A03.06" // 科别
  311. inputData["exp_content"] = "" //
  312. input["data"] = inputData
  313. inputMessage["input"] = input //交易输入
  314. argInputMessage := make(map[string]interface{})
  315. argInputMessage["arg0"] = inputMessage
  316. bytesData, err := json.Marshal(argInputMessage)
  317. fmt.Println(string(bytesData))
  318. if err != nil {
  319. fmt.Println(err.Error())
  320. return err.Error(), ""
  321. }
  322. reader := bytes.NewReader(bytesData)
  323. request_url = request_url + "2201"
  324. fmt.Println(request_url)
  325. request, err := http.NewRequest("POST", request_url, reader)
  326. if err != nil {
  327. fmt.Println(err.Error())
  328. return err.Error(), ""
  329. }
  330. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  331. //request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
  332. //request.Header.Set("_api_name", "hssServives")
  333. //request.Header.Set("_api_version", "1.0.0")
  334. //request.Header.Set("_api_access_key", access_key)
  335. //request.Header.Set("_api_signature", "")
  336. client := http.Client{}
  337. resp, err := client.Do(request)
  338. if err != nil {
  339. fmt.Println(err.Error())
  340. return err.Error(), ""
  341. }
  342. respBytes, err := ioutil.ReadAll(resp.Body)
  343. if err != nil {
  344. fmt.Println(err.Error())
  345. return err.Error(), ""
  346. }
  347. str := string(respBytes)
  348. fmt.Println(str)
  349. return str, string(bytesData)
  350. }
  351. // 门诊挂号撤销
  352. func AHyb2202(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, request_url string, access_key string, cainfo string) (string, string) {
  353. // 生成签名
  354. timestamp := time.Now().Unix()
  355. // 生成输入报文
  356. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  357. input := make(map[string]interface{})
  358. inputData := make(map[string]interface{})
  359. inputMessage["infno"] = "2202" // 交易编码
  360. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  361. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  362. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  363. //inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
  364. inputData["exp_content"] = "" //
  365. input["data"] = inputData
  366. inputMessage["input"] = input //交易输入
  367. argInputMessage := make(map[string]interface{})
  368. argInputMessage["arg0"] = inputMessage
  369. bytesData, err := json.Marshal(argInputMessage)
  370. fmt.Println(string(bytesData))
  371. if err != nil {
  372. fmt.Println(err.Error())
  373. return err.Error(), ""
  374. }
  375. reader := bytes.NewReader(bytesData)
  376. request_url = request_url + "2202"
  377. fmt.Println(request_url)
  378. request, err := http.NewRequest("POST", request_url, reader)
  379. if err != nil {
  380. fmt.Println(err.Error())
  381. return err.Error(), ""
  382. }
  383. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  384. //request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
  385. //request.Header.Set("_api_name", "hssServives")
  386. //request.Header.Set("_api_version", "1.0.0")
  387. //request.Header.Set("_api_access_key", access_key)
  388. //request.Header.Set("_api_signature", "")
  389. client := http.Client{}
  390. resp, err := client.Do(request)
  391. if err != nil {
  392. fmt.Println(err.Error())
  393. return err.Error(), ""
  394. }
  395. respBytes, err := ioutil.ReadAll(resp.Body)
  396. if err != nil {
  397. fmt.Println(err.Error())
  398. return err.Error(), ""
  399. }
  400. str := string(respBytes)
  401. fmt.Println(str)
  402. return str, string(bytesData)
  403. }
  404. // 门诊就诊信息上传
  405. func AHyb2203(psnNo string, mdtrtId string, operator string, department string, org_name string, med_type string,fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, sick_code string, sick_name string,config []*models.HisXtDiagnoseConfig, request_url string ,begin_time string, cainfo string,doctor_name string,doctor_number string) (string, string) {
  406. // 生成签名
  407. timestamp := time.Now().Unix()
  408. tempTime := time.Unix(timestamp, 0)
  409. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  410. // 生成输入报文
  411. inputMessage := SetAHInputMessage(timestamp, org_name, operator, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  412. input := make(map[string]interface{})
  413. inputData := make(map[string]interface{})
  414. diseinfo := make([]map[string]interface{}, 0)
  415. if med_type == "1111" || med_type == "1112" {
  416. med_type = "11"
  417. }
  418. inputMessage["infno"] = "2203" // 交易编码
  419. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  420. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  421. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  422. inputData["begntime"] = begin_time // 开始时间
  423. inputData["main_cond_dscr"] = "" // 主要病情描述
  424. inputData["dise_codg"] = sick_code // 病种编码
  425. inputData["dise_name"] = sick_name // 病种名称
  426. inputData["birctrl_type"] = "" // 计划生育手术类别
  427. //inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  428. for index, item := range config {
  429. diseinfo_sun := make(map[string]interface{})
  430. diseinfo_sun["diag_type"] = "1" // 诊断类别
  431. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  432. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  433. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  434. diseinfo_sun["diag_dept"] = department // 诊断科室
  435. diseinfo_sun["dise_dor_no"] = doctor_number // 诊断医生编码
  436. diseinfo_sun["dise_dor_name"] = doctor_name // 诊断医生姓名
  437. diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  438. diseinfo_sun["vali_flag"] = "1" // 有效标志
  439. diseinfo = append(diseinfo, diseinfo_sun)
  440. }
  441. //inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
  442. inputData["exp_content"] = "" //
  443. input["diseinfo"] = diseinfo
  444. input["mdtrtinfo"] = inputData
  445. inputMessage["input"] = input //交易输入
  446. argInputMessage := make(map[string]interface{})
  447. argInputMessage["arg0"] = inputMessage
  448. bytesData, err := json.Marshal(argInputMessage)
  449. fmt.Println(string(bytesData))
  450. if err != nil {
  451. fmt.Println(err.Error())
  452. return err.Error(), ""
  453. }
  454. reader := bytes.NewReader(bytesData)
  455. request_url = request_url + "2203"
  456. fmt.Println(request_url)
  457. request, err := http.NewRequest("POST", request_url, reader)
  458. if err != nil {
  459. fmt.Println(err.Error())
  460. return err.Error(), ""
  461. }
  462. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  463. //request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
  464. //request.Header.Set("_api_name", "hssServives")
  465. //request.Header.Set("_api_version", "1.0.0")
  466. //request.Header.Set("_api_access_key", access_key)
  467. //request.Header.Set("_api_signature", "")
  468. client := http.Client{}
  469. resp, err := client.Do(request)
  470. if err != nil {
  471. fmt.Println(err.Error())
  472. return err.Error(), ""
  473. }
  474. respBytes, err := ioutil.ReadAll(resp.Body)
  475. if err != nil {
  476. fmt.Println(err.Error())
  477. return err.Error(), ""
  478. }
  479. str := string(respBytes)
  480. fmt.Println(str)
  481. return str, string(bytesData)
  482. }
  483. func AHyb2406(psnNo string, mdtrtId string, cert_no string,psn_name string,operator string,ipt_otp_no string,ipt_psn_sp_flag_type string,ipt_psn_sp_flag string, org_name string,fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string,request_url string) (string, string) {
  484. // 生成签名
  485. timestamp := time.Now().Unix()
  486. // 生成输入报文
  487. inputMessage := SetAHInputMessage(timestamp, org_name, operator, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, "")
  488. input := make(map[string]interface{})
  489. inputData := make(map[string]interface{})
  490. inputMessage["infno"] = "2406" // 交易编码
  491. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  492. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  493. inputData["psn_cert_type"] = "01" // 人员编号 (来自1101接口返回)
  494. inputData["certno"] = cert_no // 人员编号 (来自1101接口返回)
  495. inputData["psn_name"] = psn_name // 人员编号 (来自1101接口返回)
  496. inputData["ipt_otp_no"] = ipt_otp_no // 人员编号 (来自1101接口返回)
  497. inputData["ipt_psn_sp_flag_type"] = ipt_psn_sp_flag_type // 人员编号 (来自1101接口返回)
  498. inputData["ipt_psn_sp_flag"] = ipt_psn_sp_flag // 人员编号 (来自1101接口返回)
  499. inputData["memo"] = "ZLFS00373" //
  500. inputData["admdvs"] = mdtrtarea_admvs //
  501. input["IptPsnSpFlagRegIn"] = inputData
  502. inputMessage["input"] = input //交易输入
  503. argInputMessage := make(map[string]interface{})
  504. argInputMessage["arg0"] = inputMessage
  505. bytesData, err := json.Marshal(argInputMessage)
  506. fmt.Println(string(bytesData))
  507. if err != nil {
  508. fmt.Println(err.Error())
  509. return err.Error(), ""
  510. }
  511. reader := bytes.NewReader(bytesData)
  512. request_url = request_url + "2406"
  513. fmt.Println(request_url)
  514. request, err := http.NewRequest("POST", request_url, reader)
  515. if err != nil {
  516. fmt.Println(err.Error())
  517. return err.Error(), ""
  518. }
  519. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  520. client := http.Client{}
  521. resp, err := client.Do(request)
  522. if err != nil {
  523. fmt.Println(err.Error())
  524. return err.Error(), ""
  525. }
  526. respBytes, err := ioutil.ReadAll(resp.Body)
  527. if err != nil {
  528. fmt.Println(err.Error())
  529. return err.Error(), ""
  530. }
  531. str := string(respBytes)
  532. fmt.Println(str)
  533. return str, string(bytesData)
  534. }
  535. func AHyb1901(url string) {
  536. // 生成签名
  537. timestamp := time.Now().Unix()
  538. // 生成输入报文
  539. inputMessage := SetAHInputMessage(timestamp, "阜阳经沃血液透析中心", "aaa", "H34120302409", "341200", "341200", "")
  540. input := make(map[string]interface{})
  541. inputData := make(map[string]interface{})
  542. inputMessage["infno"] = "1901" // 交易编码
  543. inputData["type"] = "ipt_psn_sp_flag_typ" // 就诊 ID(来自2201接口返回)
  544. inputData["parent_value"] = "" // 人员编号 (来自1101接口返回)
  545. inputData["admdvs"] = "341200" // 人员编号 (来自1101接口返回)
  546. inputData["date"] = "2024-02-22" // 人员编号 (来自1101接口返回)
  547. inputData["vali_flag"] = "1" // 人员编号 (来自1101接口返回)
  548. input["data"] = inputData
  549. inputMessage["input"] = input //交易输入
  550. argInputMessage := make(map[string]interface{})
  551. argInputMessage["arg0"] = inputMessage
  552. //var inputLog string
  553. bytesData, err := json.Marshal(argInputMessage)
  554. fmt.Println(string(bytesData))
  555. if err != nil {
  556. fmt.Println(err.Error())
  557. return
  558. }
  559. reader := bytes.NewReader(bytesData)
  560. url = url + "1901"
  561. request, err := http.NewRequest("POST", url, reader)
  562. if err != nil {
  563. fmt.Println(err.Error())
  564. return
  565. }
  566. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  567. client := http.Client{}
  568. resp, err := client.Do(request)
  569. if err != nil {
  570. fmt.Println(err.Error())
  571. return
  572. }
  573. respBytes, err := ioutil.ReadAll(resp.Body)
  574. if err != nil {
  575. fmt.Println(err.Error())
  576. return
  577. }
  578. str := string(respBytes)
  579. fmt.Println(str)
  580. return
  581. }
  582. // 门诊就诊信息上传
  583. func AHyb2203A(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, request_url string, access_key string, cainfo string) (string, string) {
  584. // 生成签名
  585. timestamp := time.Now().Unix()
  586. tempTime := time.Unix(timestamp, 0)
  587. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  588. // 生成输入报文
  589. inputMessage := SetAHInputMessage(timestamp, org_name, dept, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  590. input := make(map[string]interface{})
  591. inputData := make(map[string]interface{})
  592. diseinfo := make([]map[string]interface{}, 0)
  593. if med_type == "1111" || med_type == "1112" {
  594. med_type = "11"
  595. }
  596. inputMessage["infno"] = "2203A" // 交易编码
  597. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  598. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  599. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  600. inputData["begntime"] = timeFormatOne // 开始时间
  601. inputData["main_cond_dscr"] = "" // 主要病情描述
  602. inputData["dise_codg"] = sick_code // 病种编码
  603. inputData["dise_name"] = sick_name // 病种名称
  604. inputData["birctrl_type"] = "" // 计划生育手术类别
  605. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  606. inputData["matn_type"] = "" // 生育类别
  607. inputData["geso_val"] = "" // 孕周数
  608. for index, item := range config {
  609. diseinfo_sun := make(map[string]interface{})
  610. diseinfo_sun["diag_type"] = "1" // 诊断类别
  611. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  612. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  613. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  614. diseinfo_sun["diag_dept"] = department // 诊断科室
  615. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  616. diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  617. diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  618. diseinfo_sun["vali_flag"] = "1" // 有效标志
  619. diseinfo = append(diseinfo, diseinfo_sun)
  620. }
  621. input["diseinfo"] = diseinfo
  622. input["mdtrtinfo"] = inputData
  623. inputMessage["input"] = input //交易输入
  624. argInputMessage := make(map[string]interface{})
  625. argInputMessage["arg0"] = inputMessage
  626. bytesData, err := json.Marshal(argInputMessage)
  627. fmt.Println(string(bytesData))
  628. if err != nil {
  629. fmt.Println(err.Error())
  630. return err.Error(), ""
  631. }
  632. reader := bytes.NewReader(bytesData)
  633. request_url = request_url + "2203A"
  634. fmt.Println(request_url)
  635. request, err := http.NewRequest("POST", request_url, reader)
  636. if err != nil {
  637. fmt.Println(err.Error())
  638. return err.Error(), ""
  639. }
  640. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  641. //request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
  642. //request.Header.Set("_api_name", "hssServives")
  643. //request.Header.Set("_api_version", "1.0.0")
  644. //request.Header.Set("_api_access_key", access_key)
  645. //request.Header.Set("_api_signature", "")
  646. client := http.Client{}
  647. resp, err := client.Do(request)
  648. if err != nil {
  649. fmt.Println(err.Error())
  650. return err.Error(), ""
  651. }
  652. respBytes, err := ioutil.ReadAll(resp.Body)
  653. if err != nil {
  654. fmt.Println(err.Error())
  655. return err.Error(), ""
  656. }
  657. str := string(respBytes)
  658. fmt.Println(str)
  659. return str, string(bytesData)
  660. }
  661. // 门诊费用明细信息上传
  662. func AHyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescription, chrg_bchno string, org_name string, doctor string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, balance_accounts_type string, diag_code string, request_url string, access_key string, new_doctor_name string, time_stamp_2203 string, cainfo string,opter string) (string, string) {
  663. // 生成签名
  664. //timestamp := time.Now().Unix()
  665. timestamp2 := time.Now().Unix()
  666. //tempTime := time.Unix(timestamp2, 0)
  667. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  668. var customs []*Custom
  669. for _, item := range hisPrescription {
  670. tm := time.Unix(item.PreTime, 0)
  671. if item.Type == 1 { //药品
  672. for _, subItem := range item.HisDoctorAdviceInfo {
  673. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  674. //var randNum int
  675. //randNum = rand.Intn(10000) + 1000
  676. cus := &Custom{
  677. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  678. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  679. FeedetlSn: subItem.FeedetlSn,
  680. Price: fmt.Sprintf("%.4f", subItem.Price),
  681. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  682. HospApprFlag: subItem.HospApprFlag,
  683. DoctorNumber: doctor_id,
  684. DoctorName: new_doctor_name,
  685. ProvinceDrugMedListCodg: "",
  686. ProvinceGoodMedListCodg: "",
  687. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  688. }
  689. if subItem.BaseDrugLib.DrugClassify == "2" {
  690. cus.ProvinceDrugMedListCodg = subItem.BaseDrugLib.ProvincesCode
  691. }
  692. customs = append(customs, cus)
  693. }
  694. }
  695. }
  696. if item.Type == 2 { //项目
  697. for _, subItem := range item.HisPrescriptionProject {
  698. //var randNum int
  699. //randNum = rand.Intn(10000) + 1000
  700. if subItem.Type == 2 {
  701. if len(subItem.HisProject.MedicalCode) > 0 {
  702. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  703. cus := &Custom{
  704. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  705. Cut: fmt.Sprintf("%.4f", cnt),
  706. FeedetlSn: subItem.FeedetlSn,
  707. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  708. MedListCodg: subItem.HisProject.MedicalCode,
  709. DoctorNumber: doctor_id,
  710. DoctorName: new_doctor_name,
  711. HospApprFlag: -1,
  712. ProvinceDrugMedListCodg: "",
  713. ProvinceGoodMedListCodg: "",
  714. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  715. }
  716. customs = append(customs, cus)
  717. }
  718. } else if subItem.Type == 3 {
  719. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  720. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  721. cus := &Custom{
  722. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  723. Cut: fmt.Sprintf("%.4f", cnt),
  724. FeedetlSn: subItem.FeedetlSn,
  725. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  726. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  727. HospApprFlag: -1,
  728. DoctorNumber: doctor_id,
  729. DoctorName: new_doctor_name,
  730. ProvinceDrugMedListCodg: "",
  731. ProvinceGoodMedListCodg: subItem.GoodInfo.ProvincesCode,
  732. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  733. }
  734. customs = append(customs, cus)
  735. }
  736. }
  737. }
  738. }
  739. for _, subItem := range item.HisAdditionalCharge {
  740. if len(subItem.XtHisAddtionConfig.Code) > 0 {
  741. cus := &Custom{
  742. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
  743. Cut: fmt.Sprintf("%.4f", float64(subItem.Count)),
  744. FeedetlSn: subItem.FeedetlSn,
  745. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  746. MedListCodg: subItem.XtHisAddtionConfig.Code,
  747. HospApprFlag: -1,
  748. DoctorNumber: doctor_id,
  749. DoctorName: new_doctor_name,
  750. }
  751. customs = append(customs, cus)
  752. }
  753. }
  754. }
  755. // 生成输入报文
  756. inputMessage := SetAHInputMessage(timestamp2, org_name, opter, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  757. input := make(map[string]interface{})
  758. feedetail := make([]map[string]interface{}, 0)
  759. inputMessage["infno"] = "2204" // 交易编码
  760. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  761. for _, item := range customs {
  762. feedetailInfo := make(map[string]interface{})
  763. subfeedetailInfo := make(map[string]interface{})
  764. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  765. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  766. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  767. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  768. feedetailInfo["dise_codg"] = diag_code // 病种编码
  769. feedetailInfo["rxno"] = "" // 处方号
  770. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  771. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  772. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  773. feedetailInfo["medins_list_codg"] = item.FeedetlSn // 医药机构目录编码
  774. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  775. feedetailInfo["cnt"] = item.Cut // 数量
  776. feedetailInfo["pric"] = item.Price // 单价
  777. feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
  778. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  779. feedetailInfo["prd_days"] = "0" // 周期天数
  780. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  781. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  782. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  783. feedetailInfo["bilg_dr_codg"] = item.DoctorNumber // 开单医生编码
  784. feedetailInfo["bilg_dr_name"] = item.DoctorName // 开单医师姓名
  785. feedetailInfo["acord_dept_codg"] = "" // 受单科室编码
  786. feedetailInfo["acord_dept_name"] = "" // 受单科室名称
  787. feedetailInfo["orders_dr_code"] = "" // 受单医生编码
  788. feedetailInfo["orders_dr_name"] = "" // 受单医生姓名
  789. if balance_accounts_type == "8" {
  790. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  791. } else {
  792. if item.HospApprFlag != -1 {
  793. if item.HospApprFlag == 1 {
  794. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  795. } else if item.HospApprFlag == 2 {
  796. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  797. } else if item.HospApprFlag == 3 {
  798. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  799. } else {
  800. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  801. }
  802. } else {
  803. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  804. }
  805. }
  806. feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  807. feedetailInfo["etip_flag"] = "" // 外检标志
  808. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  809. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  810. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  811. subfeedetailInfo["tcmherb_prov_code"] = item.ProvinceDrugMedListCodg
  812. subfeedetailInfo["mcs_prov_code"] = item.ProvinceGoodMedListCodg
  813. feedetailInfo["exp_content"] = subfeedetailInfo
  814. feedetail = append(feedetail, feedetailInfo)
  815. }
  816. input["feedetail"] = feedetail
  817. inputMessage["input"] = input //交易输入
  818. argInputMessage := make(map[string]interface{})
  819. argInputMessage["arg0"] = inputMessage
  820. bytesData, err := json.Marshal(argInputMessage)
  821. fmt.Println(string(bytesData))
  822. if err != nil {
  823. fmt.Println(err.Error())
  824. return err.Error(), ""
  825. }
  826. reader := bytes.NewReader(bytesData)
  827. request_url = request_url + "2204"
  828. fmt.Println(request_url)
  829. request, err := http.NewRequest("POST", request_url, reader)
  830. if err != nil {
  831. fmt.Println(err.Error())
  832. return err.Error(), ""
  833. }
  834. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  835. //request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
  836. //request.Header.Set("_api_name", "hssServives")
  837. //request.Header.Set("_api_version", "1.0.0")
  838. //request.Header.Set("_api_access_key", access_key)
  839. //request.Header.Set("_api_signature", "")
  840. client := http.Client{}
  841. resp, err := client.Do(request)
  842. if err != nil {
  843. fmt.Println(err.Error())
  844. return err.Error(), ""
  845. }
  846. respBytes, err := ioutil.ReadAll(resp.Body)
  847. if err != nil {
  848. fmt.Println(err.Error())
  849. return err.Error(), ""
  850. }
  851. str := string(respBytes)
  852. fmt.Println(str)
  853. return str, string(bytesData)
  854. }
  855. // 门诊费用明细信息撤销
  856. func AHyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string, request_url string, access_key string, cainfo string) (string, string) {
  857. timestamp := time.Now().Unix()
  858. // 生成输入报文
  859. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  860. input := make(map[string]interface{})
  861. inputData := make(map[string]interface{})
  862. inputMessage["infno"] = "2205" // 交易编码
  863. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  864. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  865. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  866. inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
  867. input["data"] = inputData
  868. inputMessage["input"] = input //交易输入
  869. argInputMessage := make(map[string]interface{})
  870. argInputMessage["arg0"] = inputMessage
  871. bytesData, err := json.Marshal(argInputMessage)
  872. fmt.Println(string(bytesData))
  873. if err != nil {
  874. fmt.Println(err.Error())
  875. return err.Error(), ""
  876. }
  877. reader := bytes.NewReader(bytesData)
  878. request_url = request_url + "2205"
  879. fmt.Println(request_url)
  880. request, err := http.NewRequest("POST", request_url, reader)
  881. if err != nil {
  882. fmt.Println(err.Error())
  883. return err.Error(), ""
  884. }
  885. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  886. //request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
  887. //request.Header.Set("_api_name", "hssServives")
  888. //request.Header.Set("_api_version", "1.0.0")
  889. //request.Header.Set("_api_access_key", access_key)
  890. //request.Header.Set("_api_signature", "")
  891. client := http.Client{}
  892. resp, err := client.Do(request)
  893. if err != nil {
  894. fmt.Println(err.Error())
  895. return err.Error(), ""
  896. }
  897. respBytes, err := ioutil.ReadAll(resp.Body)
  898. if err != nil {
  899. fmt.Println(err.Error())
  900. return err.Error(), ""
  901. }
  902. str := string(respBytes)
  903. fmt.Println(str)
  904. return str, string(bytesData)
  905. }
  906. // 门诊预结算
  907. func AHyb2206(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,certificates int64, request_url string, access_key string, verify_number string, cainfo string,mdtrt_grp_type string) (string, string) {
  908. // 生成签名
  909. timestamp := time.Now().Unix() // inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  910. // inputData["mdtrt_cert_no"] = certNo
  911. // 生成输入报文
  912. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  913. input := make(map[string]interface{})
  914. inputData := make(map[string]interface{})
  915. inputMessage["infno"] = "2206" // 交易编码
  916. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  917. if certificates == 3 {
  918. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  919. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  920. } else {
  921. if id_card_type == 1 {
  922. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  923. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  924. } else if id_card_type == 3 {
  925. inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
  926. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  927. } else if id_card_type == 4 {
  928. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  929. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  930. } else {
  931. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  932. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  933. }
  934. }
  935. if insuplc_admdvs == "421300" {
  936. if med_type == "11" || med_type == "1112" || med_type == "1111" {
  937. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  938. } else if med_type == "14" {
  939. inputData["med_type"] = "140110" // 医疗类别 11 普通门诊 12 门诊挂号
  940. }
  941. } else {
  942. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  943. }
  944. inputData["medfee_sumamt"] = total // 医疗费总额
  945. inputData["psn_setlway"] = "02" // 个人结算方式 01 按项目结 02 按定额结算
  946. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  947. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  948. inputData["acct_used_flag"] = "0" // 个人账户使用标志 0否 1是
  949. inputData["insutype"] = insutype // 险种类型
  950. inputData["invono"] = "" // 发票号
  951. inputData2 := make(map[string]interface{})
  952. inputData2["trum_flag"] = ""
  953. inputData2["rel_ttp_flag"] = ""
  954. inputData2["otp_er_refl_flag"] = ""
  955. inputData2["mdtrt_grp_type"] = ""
  956. inputData2["need_ipt_flag"] = ""
  957. inputData["exp_content"] = inputData2 // 发票号
  958. input["data"] = inputData
  959. inputMessage["input"] = input //交易输入
  960. argInputMessage := make(map[string]interface{})
  961. argInputMessage["arg0"] = inputMessage
  962. bytesData, err := json.Marshal(argInputMessage)
  963. fmt.Println(string(bytesData))
  964. if err != nil {
  965. fmt.Println(err.Error())
  966. return err.Error(), ""
  967. }
  968. reader := bytes.NewReader(bytesData)
  969. request_url = request_url + "2206"
  970. fmt.Println(request_url)
  971. request, err := http.NewRequest("POST", request_url, reader)
  972. if err != nil {
  973. fmt.Println(err.Error())
  974. return err.Error(), ""
  975. }
  976. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  977. //request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
  978. //request.Header.Set("_api_name", "hssServives")
  979. //request.Header.Set("_api_version", "1.0.0")
  980. //request.Header.Set("_api_access_key", access_key)
  981. //request.Header.Set("_api_signature", "")
  982. client := http.Client{}
  983. resp, err := client.Do(request)
  984. if err != nil {
  985. fmt.Println(err.Error())
  986. return err.Error(), ""
  987. }
  988. respBytes, err := ioutil.ReadAll(resp.Body)
  989. if err != nil {
  990. fmt.Println(err.Error())
  991. return err.Error(), ""
  992. }
  993. str := string(respBytes)
  994. fmt.Println(str)
  995. return str, string(bytesData)
  996. }
  997. // 门诊预结算
  998. func AHyb2206Two(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64, request_url string, access_key string, verify_number string, cainfo string, card_sn string) (string, string) {
  999. // 生成签名
  1000. timestamp := time.Now().Unix() // inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1001. // inputData["mdtrt_cert_no"] = certNo
  1002. // 生成输入报文
  1003. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  1004. input := make(map[string]interface{})
  1005. inputData := make(map[string]interface{})
  1006. inputMessage["infno"] = "2206" // 交易编码
  1007. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1008. if certificates == 3 {
  1009. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1010. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1011. } else {
  1012. if id_card_type == 1 {
  1013. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1014. inputData["card_sn"] = card_sn // 卡识别码
  1015. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  1016. } else if id_card_type == 3 {
  1017. inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
  1018. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  1019. } else if id_card_type == 4 {
  1020. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  1021. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  1022. } else {
  1023. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1024. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1025. }
  1026. }
  1027. if insuplc_admdvs == "421300" {
  1028. if med_type == "11" || med_type == "1112" || med_type == "1111" {
  1029. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  1030. } else if med_type == "14" {
  1031. inputData["med_type"] = "140110" // 医疗类别 11 普通门诊 12 门诊挂号
  1032. }
  1033. } else {
  1034. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1035. }
  1036. inputData["medfee_sumamt"] = total // 医疗费总额
  1037. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1038. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1039. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1040. inputData["acct_used_flag"] = "0" // 个人账户使用标志 0否 1是
  1041. inputData["insutype"] = insutype // 险种类型
  1042. inputData["invono"] = "" // 发票号
  1043. inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
  1044. input["data"] = inputData
  1045. inputMessage["input"] = input //交易输入
  1046. argInputMessage := make(map[string]interface{})
  1047. argInputMessage["arg0"] = inputMessage
  1048. bytesData, err := json.Marshal(argInputMessage)
  1049. fmt.Println(string(bytesData))
  1050. if err != nil {
  1051. fmt.Println(err.Error())
  1052. return err.Error(), ""
  1053. }
  1054. reader := bytes.NewReader(bytesData)
  1055. request_url = request_url + "2206"
  1056. fmt.Println(request_url)
  1057. request, err := http.NewRequest("POST", request_url, reader)
  1058. if err != nil {
  1059. fmt.Println(err.Error())
  1060. return err.Error(), ""
  1061. }
  1062. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1063. //request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
  1064. //request.Header.Set("_api_name", "hssServives")
  1065. //request.Header.Set("_api_version", "1.0.0")
  1066. //request.Header.Set("_api_access_key", access_key)
  1067. //request.Header.Set("_api_signature", "")
  1068. client := http.Client{}
  1069. resp, err := client.Do(request)
  1070. if err != nil {
  1071. fmt.Println(err.Error())
  1072. return err.Error(), ""
  1073. }
  1074. respBytes, err := ioutil.ReadAll(resp.Body)
  1075. if err != nil {
  1076. fmt.Println(err.Error())
  1077. return err.Error(), ""
  1078. }
  1079. str := string(respBytes)
  1080. fmt.Println(str)
  1081. return str, string(bytesData)
  1082. }
  1083. // 门诊结算
  1084. func AHyb2207(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, acct_used_flag string, request_url string, access_key string, verify_number string, cainfo string,mdtrt_grp_type string) (string, string) {
  1085. // 生成签名
  1086. timestamp := time.Now().Unix()
  1087. // 生成输入报文
  1088. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  1089. input := make(map[string]interface{})
  1090. inputData := make(map[string]interface{})
  1091. inputMessage["infno"] = "2207" // 交易编码
  1092. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1093. if id_card_type == 1 {
  1094. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1095. inputData["mdtrt_cert_no"] = certNo + "|" + verify_number // 就诊凭证编号
  1096. } else if id_card_type == 3 {
  1097. inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
  1098. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  1099. } else if id_card_type == 4 {
  1100. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  1101. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  1102. } else {
  1103. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1104. inputData["mdtrt_cert_no"] = certNo
  1105. }
  1106. if med_type == "1111" || med_type == "1112" {
  1107. med_type = "11"
  1108. }
  1109. if insuplc_admdvs == "421300" {
  1110. if med_type == "11" {
  1111. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  1112. } else if med_type == "14" {
  1113. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  1114. }
  1115. } else {
  1116. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1117. }
  1118. inputData["medfee_sumamt"] = total // 医疗费总额
  1119. inputData["psn_setlway"] = "02" // 个人结算方式 01 按项目结 02 按定额结算
  1120. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1121. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1122. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  1123. inputData["insutype"] = insutype // 险种类型
  1124. inputData["invono"] = "" // 发票号
  1125. inputData["fulamt_ownpay_amt"] = 0 //
  1126. inputData["overlmt_selfpay"] = 0 //
  1127. inputData["preselfpay_amt"] = 0 //
  1128. inputData["inscp_scp_amt"] = 0 //
  1129. inputData2 := make(map[string]interface{})
  1130. inputData2["trum_flag"] = ""
  1131. inputData2["rel_ttp_flag"] = ""
  1132. inputData2["otp_er_refl_flag"] = ""
  1133. inputData2["mdtrt_grp_type"] = ""
  1134. inputData2["need_ipt_flag"] = ""
  1135. inputData["exp_content"] = inputData2
  1136. input["data"] = inputData
  1137. inputMessage["input"] = input //交易输入
  1138. argInputMessage := make(map[string]interface{})
  1139. argInputMessage["arg0"] = inputMessage
  1140. var inputLog string
  1141. bytesData, err := json.Marshal(argInputMessage)
  1142. fmt.Println(string(bytesData))
  1143. if err != nil {
  1144. fmt.Println(err.Error())
  1145. return err.Error(), ""
  1146. }
  1147. reader := bytes.NewReader(bytesData)
  1148. request_url = request_url + "2207"
  1149. fmt.Println(request_url)
  1150. request, err := http.NewRequest("POST", request_url, reader)
  1151. if err != nil {
  1152. fmt.Println(err.Error())
  1153. return err.Error(), ""
  1154. }
  1155. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1156. //request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
  1157. //request.Header.Set("_api_name", "hssServives")
  1158. //request.Header.Set("_api_version", "1.0.0")
  1159. //request.Header.Set("_api_access_key", access_key)
  1160. //request.Header.Set("_api_signature", "")
  1161. client := http.Client{}
  1162. resp, err := client.Do(request)
  1163. if err != nil {
  1164. fmt.Println(err.Error())
  1165. return err.Error(), ""
  1166. }
  1167. respBytes, err := ioutil.ReadAll(resp.Body)
  1168. if err != nil {
  1169. fmt.Println(err.Error())
  1170. return err.Error(), ""
  1171. }
  1172. str := string(respBytes)
  1173. fmt.Println(str)
  1174. return str, inputLog
  1175. }
  1176. // 门诊结算
  1177. func AHyb2207Two(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64, acct_used_flag string, request_url string, access_key string, verify_number string, cainfo string, card_sn string) (string, string) {
  1178. // 生成签名
  1179. timestamp := time.Now().Unix()
  1180. // 生成输入报文
  1181. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  1182. input := make(map[string]interface{})
  1183. inputData := make(map[string]interface{})
  1184. inputMessage["infno"] = "2207" // 交易编码
  1185. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1186. if id_card_type == 1 {
  1187. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1188. inputData["card_sn"] = card_sn // 卡识别码
  1189. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  1190. } else if id_card_type == 3 {
  1191. inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
  1192. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  1193. } else if id_card_type == 4 {
  1194. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  1195. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  1196. } else {
  1197. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1198. inputData["mdtrt_cert_no"] = certNo
  1199. }
  1200. if med_type == "1111" || med_type == "1112" {
  1201. med_type = "11"
  1202. }
  1203. if insuplc_admdvs == "421300" {
  1204. if med_type == "11" {
  1205. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  1206. } else if med_type == "14" {
  1207. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  1208. }
  1209. } else {
  1210. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1211. }
  1212. inputData["medfee_sumamt"] = total // 医疗费总额
  1213. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1214. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1215. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1216. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  1217. inputData["insutype"] = insutype // 险种类型
  1218. inputData["invono"] = "" // 发票号
  1219. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  1220. inputData["overlmt_selfpay"] = overlmt_selfpay //
  1221. inputData["preselfpay_amt"] = preselfpay_amt //
  1222. inputData["inscp_scp_amt"] = inscp_scp_amt //
  1223. inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
  1224. input["data"] = inputData
  1225. inputMessage["input"] = input //交易输入
  1226. argInputMessage := make(map[string]interface{})
  1227. argInputMessage["arg0"] = inputMessage
  1228. var inputLog string
  1229. bytesData, err := json.Marshal(argInputMessage)
  1230. fmt.Println(string(bytesData))
  1231. if err != nil {
  1232. fmt.Println(err.Error())
  1233. return err.Error(), ""
  1234. }
  1235. reader := bytes.NewReader(bytesData)
  1236. request_url = request_url + "2207"
  1237. fmt.Println(request_url)
  1238. request, err := http.NewRequest("POST", request_url, reader)
  1239. if err != nil {
  1240. fmt.Println(err.Error())
  1241. return err.Error(), ""
  1242. }
  1243. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1244. //request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
  1245. //request.Header.Set("_api_name", "hssServives")
  1246. //request.Header.Set("_api_version", "1.0.0")
  1247. //request.Header.Set("_api_access_key", access_key)
  1248. //request.Header.Set("_api_signature", "")
  1249. client := http.Client{}
  1250. resp, err := client.Do(request)
  1251. if err != nil {
  1252. fmt.Println(err.Error())
  1253. return err.Error(), ""
  1254. }
  1255. respBytes, err := ioutil.ReadAll(resp.Body)
  1256. if err != nil {
  1257. fmt.Println(err.Error())
  1258. return err.Error(), ""
  1259. }
  1260. str := string(respBytes)
  1261. fmt.Println(str)
  1262. return str, inputLog
  1263. }
  1264. func AHyb2207A(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64, acct_used_flag string, request_url string, access_key string, cainfo string) (string, string) {
  1265. // 生成签名
  1266. timestamp := time.Now().Unix()
  1267. // 生成输入报文
  1268. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  1269. input := make(map[string]interface{})
  1270. inputData := make(map[string]interface{})
  1271. inputMessage["infno"] = "2207A" // 交易编码
  1272. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1273. if certificates == 3 {
  1274. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1275. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1276. } else {
  1277. if id_card_type == 1 {
  1278. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1279. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1280. } else {
  1281. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1282. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1283. }
  1284. }
  1285. if med_type == "1111" || med_type == "1112" {
  1286. med_type = "11"
  1287. }
  1288. if insuplc_admdvs == "421300" {
  1289. if med_type == "11" {
  1290. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  1291. } else if med_type == "14" {
  1292. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  1293. }
  1294. } else {
  1295. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1296. }
  1297. inputData["medfee_sumamt"] = total // 医疗费总额
  1298. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1299. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1300. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1301. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  1302. inputData["insutype"] = insutype // 险种类型
  1303. inputData["invono"] = "" // 发票号
  1304. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  1305. inputData["overlmt_selfpay"] = overlmt_selfpay //
  1306. inputData["preselfpay_amt"] = preselfpay_amt //
  1307. inputData["inscp_scp_amt"] = inscp_scp_amt //
  1308. input["data"] = inputData
  1309. inputMessage["input"] = input //交易输入
  1310. argInputMessage := make(map[string]interface{})
  1311. argInputMessage["arg0"] = inputMessage
  1312. var inputLog string
  1313. bytesData, err := json.Marshal(argInputMessage)
  1314. fmt.Println(string(bytesData))
  1315. if err != nil {
  1316. fmt.Println(err.Error())
  1317. return err.Error(), ""
  1318. }
  1319. reader := bytes.NewReader(bytesData)
  1320. request_url = request_url + "2207A"
  1321. fmt.Println(request_url)
  1322. request, err := http.NewRequest("POST", request_url, reader)
  1323. if err != nil {
  1324. fmt.Println(err.Error())
  1325. return err.Error(), ""
  1326. }
  1327. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1328. //request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
  1329. //request.Header.Set("_api_name", "hssServives")
  1330. //request.Header.Set("_api_version", "1.0.0")
  1331. //request.Header.Set("_api_access_key", access_key)
  1332. //request.Header.Set("_api_signature", "")
  1333. client := http.Client{}
  1334. resp, err := client.Do(request)
  1335. if err != nil {
  1336. fmt.Println(err.Error())
  1337. return err.Error(), ""
  1338. }
  1339. respBytes, err := ioutil.ReadAll(resp.Body)
  1340. if err != nil {
  1341. fmt.Println(err.Error())
  1342. return err.Error(), ""
  1343. }
  1344. str := string(respBytes)
  1345. fmt.Println(str)
  1346. return str, inputLog
  1347. }
  1348. // 门诊结算撤销
  1349. func AHyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, request_url string, access_key string, cainfo string) (string, string) {
  1350. timestamp := time.Now().Unix()
  1351. // 生成输入报文
  1352. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  1353. input := make(map[string]interface{})
  1354. inputData := make(map[string]interface{})
  1355. inputMessage["infno"] = "2208" // 交易编码
  1356. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1357. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1358. inputData["setl_id"] = setlId // 结算 ID
  1359. inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
  1360. input["data"] = inputData
  1361. inputMessage["input"] = input //交易输入
  1362. argInputMessage := make(map[string]interface{})
  1363. argInputMessage["arg0"] = inputMessage
  1364. var inputLog string
  1365. bytesData, err := json.Marshal(argInputMessage)
  1366. fmt.Println(string(bytesData))
  1367. if err != nil {
  1368. fmt.Println(err.Error())
  1369. return err.Error(), ""
  1370. }
  1371. reader := bytes.NewReader(bytesData)
  1372. request_url = request_url + "2208"
  1373. fmt.Println(request_url)
  1374. request, err := http.NewRequest("POST", request_url, reader)
  1375. if err != nil {
  1376. fmt.Println(err.Error())
  1377. return err.Error(), ""
  1378. }
  1379. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1380. //request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
  1381. //request.Header.Set("_api_name", "hssServives")
  1382. //request.Header.Set("_api_version", "1.0.0")
  1383. //request.Header.Set("_api_access_key", access_key)
  1384. //request.Header.Set("_api_signature", "")
  1385. client := http.Client{}
  1386. resp, err := client.Do(request)
  1387. if err != nil {
  1388. fmt.Println(err.Error())
  1389. return err.Error(), ""
  1390. }
  1391. respBytes, err := ioutil.ReadAll(resp.Body)
  1392. if err != nil {
  1393. fmt.Println(err.Error())
  1394. return err.Error(), ""
  1395. }
  1396. str := string(respBytes)
  1397. fmt.Println(str)
  1398. return str, inputLog
  1399. }
  1400. func AHyb5203(baseParams models.BaseParams, businessParams models.BusinessParams) (string, string) {
  1401. timestamp := time.Now().Unix()
  1402. // 生成输入报文
  1403. inputMessage := SetAHInputMessage(timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.Cainfo)
  1404. input := make(map[string]interface{})
  1405. inputData := make(map[string]interface{})
  1406. inputMessage["infno"] = "5203" // 交易编码
  1407. inputData["psn_no"] = businessParams.PsnNo
  1408. inputData["setl_id"] = businessParams.SetlId
  1409. inputData["mdtrt_id"] = businessParams.MdtrtId
  1410. input["data"] = inputData
  1411. inputMessage["input"] = input //交易输入
  1412. argInputMessage := make(map[string]interface{})
  1413. argInputMessage["arg0"] = inputMessage
  1414. var inputLog string
  1415. bytesData, err := json.Marshal(argInputMessage)
  1416. fmt.Println(string(bytesData))
  1417. if err != nil {
  1418. fmt.Println(err.Error())
  1419. return err.Error(), ""
  1420. }
  1421. reader := bytes.NewReader(bytesData)
  1422. baseParams.RequestUrl =baseParams.RequestUrl + "5203"
  1423. request, err := http.NewRequest("POST", baseParams.RequestUrl, reader)
  1424. if err != nil {
  1425. fmt.Println(err.Error())
  1426. return err.Error(), ""
  1427. }
  1428. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1429. //request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
  1430. //request.Header.Set("_api_name", "hssServives")
  1431. //request.Header.Set("_api_version", "1.0.0")
  1432. //request.Header.Set("_api_access_key", access_key)
  1433. //request.Header.Set("_api_signature", "")
  1434. client := http.Client{}
  1435. resp, err := client.Do(request)
  1436. if err != nil {
  1437. fmt.Println(err.Error())
  1438. return err.Error(), ""
  1439. }
  1440. respBytes, err := ioutil.ReadAll(resp.Body)
  1441. if err != nil {
  1442. fmt.Println(err.Error())
  1443. return err.Error(), ""
  1444. }
  1445. str := string(respBytes)
  1446. fmt.Println(str)
  1447. return str, inputLog
  1448. }
  1449. func AHyb5202(baseParams models.BaseParams, businessParams models.BusinessParams) (string, string) {
  1450. timestamp := time.Now().Unix()
  1451. // 生成输入报文
  1452. inputMessage := SetAHInputMessage(timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.Cainfo)
  1453. input := make(map[string]interface{})
  1454. inputData := make(map[string]interface{})
  1455. inputMessage["infno"] = "5202" // 交易编码
  1456. inputData["psn_no"] = businessParams.PsnNo
  1457. inputData["mdtrt_id"] = businessParams.MdtrtId
  1458. input["data"] = inputData
  1459. inputMessage["input"] = input //交易输入
  1460. argInputMessage := make(map[string]interface{})
  1461. argInputMessage["arg0"] = inputMessage
  1462. bytesData, err := json.Marshal(argInputMessage)
  1463. fmt.Println(string(bytesData))
  1464. if err != nil {
  1465. fmt.Println(err.Error())
  1466. return err.Error(), ""
  1467. }
  1468. baseParams.RequestUrl = baseParams.RequestUrl + "5202"
  1469. //fmt.Println(AHHttpRequest(baseParams.RequestUrl, baseParams.AccessKey, baseParams.SecretKey, timestamp, string(bytesData)))
  1470. return AHHttpRequest(baseParams.RequestUrl, baseParams.AccessKey, baseParams.SecretKey, timestamp, string(bytesData), "5202"), string(bytesData)
  1471. }
  1472. func AHyb5201(baseParams models.BaseParams, businessParams models.BusinessParams) (string, string) {
  1473. timestamp := time.Now().Unix()
  1474. // 生成输入报文
  1475. inputMessage := SetAHInputMessage(timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.Cainfo)
  1476. input := make(map[string]interface{})
  1477. inputData := make(map[string]interface{})
  1478. inputMessage["infno"] = "5201" // 交易编码
  1479. inputData["psn_no"] = businessParams.PsnNo
  1480. inputData["begntime"] = "2023-06-01"
  1481. inputData["endtime"] = "2023-07-30"
  1482. inputData["med_type"] = "21"
  1483. inputData["mdtrt_id"] = businessParams.MdtrtId
  1484. input["data"] = inputData
  1485. inputMessage["input"] = input //交易输入
  1486. argInputMessage := make(map[string]interface{})
  1487. argInputMessage["arg0"] = inputMessage
  1488. bytesData, err := json.Marshal(argInputMessage)
  1489. fmt.Println(string(bytesData))
  1490. if err != nil {
  1491. fmt.Println(err.Error())
  1492. return err.Error(), ""
  1493. }
  1494. baseParams.RequestUrl = baseParams.RequestUrl + "5201"
  1495. //fmt.Println(AHHttpRequest(baseParams.RequestUrl, baseParams.AccessKey, baseParams.SecretKey, timestamp, string(bytesData)))
  1496. return AHHttpRequest(baseParams.RequestUrl, baseParams.AccessKey, baseParams.SecretKey, timestamp, string(bytesData), "5201"), string(bytesData)
  1497. }
  1498. func AHybZY1101(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, request_url string, access_key string, pBusiCardInfo string, id_card_no string, cainfo string) (string, string) {
  1499. timestamp := time.Now().Unix()
  1500. //生成输入报文
  1501. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  1502. input := make(map[string]interface{})
  1503. inputData := make(map[string]interface{})
  1504. inputMessage["infno"] = "1101" // 交易编码
  1505. if certificates == 3 {
  1506. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1507. inputData["certno"] = certNo // 证件号码
  1508. inputData["psn_cert_type"] = "99" // 人员证件类型
  1509. } else {
  1510. if id_card_type == 1 {
  1511. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1512. inputData["card_sn"] = card_sn // 卡识别码
  1513. inputData["certno"] = id_card_no // 证件号码
  1514. inputData["psn_cert_type"] = "01" // 人员证件类型
  1515. inputData["mdtrt_cert_no"] = certNo + "|" + pBusiCardInfo // 就诊凭证编号
  1516. } else {
  1517. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1518. inputData["card_sn"] = "" // 卡识别码
  1519. inputData["certno"] = certNo // 证件号码
  1520. inputData["psn_cert_type"] = "01" // 人员证件类型
  1521. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1522. }
  1523. }
  1524. inputData["begntime"] = "" // 开始时间
  1525. inputData["psn_name"] = "" // 人员姓名
  1526. input["data"] = inputData
  1527. inputMessage["input"] = input //交易输入
  1528. argInputMessage := make(map[string]interface{})
  1529. argInputMessage["arg0"] = inputMessage
  1530. var inputLog string
  1531. bytesData, _ := json.Marshal(argInputMessage)
  1532. inputLog = string(bytesData)
  1533. fmt.Println(string(bytesData))
  1534. if err != nil {
  1535. fmt.Println(err.Error())
  1536. return err.Error(), ""
  1537. }
  1538. request_url = request_url + "1101"
  1539. return AHHttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData), "1101"), inputLog
  1540. }
  1541. // 住院登记
  1542. func AHyb2401(struct2401 Struct2401, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, request_url string, cainfo string, access_key string) (string, string) {
  1543. // 生成签名
  1544. timestamp := time.Now().Unix()
  1545. //tempTime := time.Unix(timestamp, 0)
  1546. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1547. // 生成输入报文
  1548. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  1549. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1550. input := make(map[string]interface{})
  1551. inputData := make(map[string]interface{})
  1552. inputMessage["infno"] = "2401" // 交易编码
  1553. inputData["psn_no"] = struct2401.PsnNo // 人员编号 (来自1101接口返回)
  1554. inputData["insutype"] = struct2401.Insutype // 险种类型(来自1101接口返回)
  1555. inputData["tel"] = ""
  1556. inputData["coner_name"] = ""
  1557. inputData["begntime"] = struct2401.Begntime // 开始时间
  1558. inputData["mdtrt_cert_type"] = struct2401.MdtrtCertType // 就诊凭证类型
  1559. inputData["mdtrt_cert_no"] = struct2401.MdtrtCertNo // 就诊凭证编号
  1560. inputData["med_type"] = struct2401.MedType // 就诊凭证编号
  1561. inputData["ipt_no"] = struct2401.IptNo // 住院/门诊号
  1562. inputData["medrcdno"] = ""
  1563. inputData["atddr_no"] = struct2401.AtddrNo
  1564. inputData["chfpdr_name"] = struct2401.ChfpdrName
  1565. inputData["adm_diag_dscr"] = struct2401.AdmDiagDscr
  1566. inputData["adm_dept_codg"] = struct2401.AdmDeptCodg
  1567. inputData["adm_dept_name"] = struct2401.AdmDeptName
  1568. inputData["adm_bed"] = struct2401.AdmBed
  1569. inputData["dscg_maindiag_code"] = struct2401.DscgMaindiagCode
  1570. inputData["dscg_maindiag_name"] = struct2401.DscgMaindiagName
  1571. inputData["main_cond_dscr"] = ""
  1572. inputData["dise_codg"] = struct2401.DiseCodg
  1573. inputData["dise_name"] = struct2401.DiseName
  1574. inputData["oprn_oprt_code"] = ""
  1575. inputData["oprn_oprt_name"] = ""
  1576. inputData["fpsc_no"] = ""
  1577. inputData["matn_type"] = ""
  1578. inputData["birctrl_type"] = ""
  1579. inputData["latechb_flag"] = ""
  1580. inputData["geso_val"] = ""
  1581. inputData["fetts"] = ""
  1582. inputData["fetus_cnt"] = ""
  1583. inputData["pret_flag"] = ""
  1584. inputData["birctrl_matn_date"] = ""
  1585. inputData["dise_type_code"] = ""
  1586. inputData["insuplc_admdvs"] = insuplc_admdvs
  1587. inputData["mdtrtarea_admvs"] = mdtrtarea_admvs
  1588. inputData["card_sn"] = struct2401.Cardsn
  1589. inputData["psn_cert_type"] = struct2401.PsnCertType
  1590. inputData["certno"] = struct2401.Certno
  1591. inputData["psn_type"] = struct2401.PsnType
  1592. inputData["psn_name"] = struct2401.PsnName
  1593. inputDataArr := make([]map[string]interface{}, 0)
  1594. for _, item := range struct2401.Diseinfo {
  1595. inputDataTwo := make(map[string]interface{})
  1596. inputDataTwo["psn_no"] = item.PsnNo
  1597. inputDataTwo["diag_type"] = item.DiagType
  1598. inputDataTwo["maindiag_flag"] = item.MaindiagFlag
  1599. inputDataTwo["diag_srt_no"] = item.DiagSrtNo
  1600. inputDataTwo["diag_code"] = item.DiagCode
  1601. inputDataTwo["diag_name"] = item.DiagName
  1602. inputDataTwo["adm_cond"] = ""
  1603. inputDataTwo["diag_dept"] = item.DiagDept
  1604. inputDataTwo["dise_dor_no"] = item.DiseDorNo
  1605. inputDataTwo["dise_dor_name"] = item.DiseDorName
  1606. inputDataTwo["diag_time"] = item.DiagTime
  1607. inputDataArr = append(inputDataArr, inputDataTwo)
  1608. }
  1609. input["mdtrtinfo"] = inputData
  1610. input["diseinfo"] = inputDataArr
  1611. inputMessage["input"] = input //交易输入
  1612. argInputMessage := make(map[string]interface{})
  1613. argInputMessage["arg0"] = inputMessage
  1614. bytesData, err := json.Marshal(argInputMessage)
  1615. fmt.Println(string(bytesData))
  1616. requestLog := string(bytesData)
  1617. if err != nil {
  1618. fmt.Println(err.Error())
  1619. return err.Error(), ""
  1620. }
  1621. request_url = request_url + "2401"
  1622. return AHHttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData), "2401"), requestLog
  1623. }
  1624. func AHyb2403(struct2401 Struct2401, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, request_url string, cainfo string, access_key string) (string, string) {
  1625. // 生成签名
  1626. timestamp := time.Now().Unix()
  1627. //tempTime := time.Unix(timestamp, 0)
  1628. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1629. // 生成输入报文
  1630. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  1631. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1632. input := make(map[string]interface{})
  1633. inputData := make(map[string]interface{})
  1634. inputMessage["infno"] = "2403" // 交易编码
  1635. inputData["mdtrt_id"] = struct2401.PsnNo // 人员编号 (来自1101接口返回)
  1636. inputData["psn_no"] = struct2401.PsnNo // 人员编号 (来自1101接口返回)
  1637. inputData["coner_name"] = struct2401
  1638. inputData["tel"] = ""
  1639. inputData["begntime"] = struct2401.Begntime // 开始时间
  1640. inputData["endtime"] = struct2401.Begntime // 开始时间
  1641. inputData["mdtrt_cert_type"] = struct2401.MdtrtCertType // 就诊凭证类型
  1642. inputData["med_type"] = struct2401.MedType // 就诊凭证编号
  1643. inputData["ipt_opt_no"] = struct2401.IptNo // 住院/门诊号
  1644. inputData["medrcdno"] = ""
  1645. inputData["atddr_no"] = struct2401.AtddrNo
  1646. inputData["chfpdr_name"] = struct2401.ChfpdrName
  1647. inputData["adm_diag_dscr"] = struct2401.AdmDiagDscr
  1648. inputData["adm_dept_codg"] = struct2401.AdmDeptCodg
  1649. inputData["adm_dept_name"] = struct2401.AdmDeptName
  1650. inputData["adm_bed"] = struct2401.AdmBed
  1651. inputData["dscg_maindiag_code"] = struct2401.DscgMaindiagCode
  1652. inputData["dscg_maindiag_name"] = struct2401.DscgMaindiagName
  1653. inputData["main_cond_dscr"] = ""
  1654. inputData["dise_codg"] = struct2401.DiseCodg
  1655. inputData["dise_name"] = struct2401.DiseName
  1656. inputData["oprn_oprt_code"] = ""
  1657. inputData["oprn_oprt_name"] = ""
  1658. inputData["fpsc_no"] = ""
  1659. inputData["matn_type"] = ""
  1660. inputData["birctrl_type"] = ""
  1661. inputData["latechb_flag"] = ""
  1662. inputData["geso_val"] = ""
  1663. inputData["fetts"] = ""
  1664. inputData["fetus_cnt"] = ""
  1665. inputData["pret_flag"] = ""
  1666. inputData["birctrl_matn_date"] = ""
  1667. inputData["dise_type_code"] = ""
  1668. inputData["expContent"] = ""
  1669. inputDataArr := make([]map[string]interface{}, 0)
  1670. for _, item := range struct2401.Diseinfo {
  1671. inputDataTwo := make(map[string]interface{})
  1672. inputDataTwo["mdtrt_id"] = item.PsnNo
  1673. inputDataTwo["psn_no"] = item.PsnNo
  1674. inputDataTwo["diag_type"] = item.DiagType
  1675. inputDataTwo["maindiag_flag"] = item.MaindiagFlag
  1676. inputDataTwo["diag_srt_no"] = item.DiagSrtNo
  1677. inputDataTwo["diag_code"] = item.DiagCode
  1678. inputDataTwo["diag_name"] = item.DiagName
  1679. inputDataTwo["adm_cond"] = ""
  1680. inputDataTwo["diag_dept"] = item.DiagDept
  1681. inputDataTwo["dise_dor_no"] = item.DiseDorNo
  1682. inputDataTwo["dise_dor_name"] = item.DiseDorName
  1683. inputDataTwo["diag_time"] = item.DiagTime
  1684. inputDataArr = append(inputDataArr, inputDataTwo)
  1685. }
  1686. input["adminfo"] = inputData
  1687. input["diseinfo"] = inputDataArr
  1688. inputMessage["input"] = input //交易输入
  1689. argInputMessage := make(map[string]interface{})
  1690. argInputMessage["arg0"] = inputMessage
  1691. bytesData, err := json.Marshal(argInputMessage)
  1692. fmt.Println(string(bytesData))
  1693. requestLog := string(bytesData)
  1694. if err != nil {
  1695. fmt.Println(err.Error())
  1696. return err.Error(), ""
  1697. }
  1698. request_url = request_url + "2403"
  1699. return AHHttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData), "2403"), requestLog
  1700. }
  1701. func AHyb2404(mdtrt_id string, psn_no string, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, request_url string, cainfo string, access_key string) (string, string) {
  1702. // 生成签名
  1703. timestamp := time.Now().Unix()
  1704. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  1705. input := make(map[string]interface{})
  1706. inputData := make(map[string]interface{})
  1707. inputMessage["infno"] = "2404" // 交易编码
  1708. inputData["mdtrt_id"] = mdtrt_id // 人员编号 (来自1101接口返回)
  1709. inputData["psn_no"] = psn_no // 人员编号 (来自1101接口返回)
  1710. input["data"] = inputData
  1711. inputMessage["input"] = input //交易输入
  1712. argInputMessage := make(map[string]interface{})
  1713. argInputMessage["arg0"] = inputMessage
  1714. bytesData, err := json.Marshal(argInputMessage)
  1715. fmt.Println(string(bytesData))
  1716. requestLog := string(bytesData)
  1717. if err != nil {
  1718. fmt.Println(err.Error())
  1719. return err.Error(), ""
  1720. }
  1721. request_url = request_url + "2404"
  1722. return AHHttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData), "2404"), requestLog
  1723. }
  1724. func AHyb2405(mdtrt_id string, psn_no string, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, request_url string, cainfo string, access_key string) (string, string) {
  1725. // 生成签名
  1726. timestamp := time.Now().Unix()
  1727. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  1728. input := make(map[string]interface{})
  1729. inputData := make(map[string]interface{})
  1730. inputMessage["infno"] = "2405" // 交易编码
  1731. inputData["mdtrt_id"] = mdtrt_id // 人员编号 (来自1101接口返回)
  1732. inputData["psn_no"] = psn_no // 人员编号 (来自1101接口返回)
  1733. input["data"] = inputData
  1734. inputMessage["input"] = input //交易输入
  1735. bytesData, err := json.Marshal(inputMessage)
  1736. fmt.Println(string(bytesData))
  1737. requestLog := string(bytesData)
  1738. if err != nil {
  1739. fmt.Println(err.Error())
  1740. return err.Error(), ""
  1741. }
  1742. request_url = request_url + "2405"
  1743. return AHHttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData), "2405"), requestLog
  1744. }
  1745. func AHyb2402(struct2402 Struct2402, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, request_url string, cainfo string, access_key string) (string, string) {
  1746. // 生成签名
  1747. nonce := GetRandomString(32)
  1748. timestamp := time.Now().Unix()
  1749. // 生成输入报文
  1750. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1751. input := make(map[string]interface{})
  1752. inputData := make(map[string]interface{})
  1753. inputMessage["infno"] = "2402" // 交易编码
  1754. inputData["mdtrt_id"] = struct2402.MdtrtId // 人员编号 (来自1101接口返回)
  1755. inputData["psn_no"] = struct2402.PsnNo // 人员编号 (来自1101接口返回)
  1756. inputData["insutype"] = struct2402.Insutype // 险种类型(来自1101接口返回)
  1757. inputData["endtime"] = struct2402.Endtime // 结束时间
  1758. inputData["dise_codg"] = struct2402.DiseCode // 就诊凭证类型
  1759. inputData["dise_name"] = struct2402.DiseName // 就诊凭证类型
  1760. inputData["oprn_oprt_code"] = "" // 就诊凭证类型
  1761. inputData["oprn_oprt_name"] = "" // 就诊凭证类型
  1762. inputData["fpsc_no"] = "" // 就诊凭证类型
  1763. inputData["matn_type"] = "" // 就诊凭证类型
  1764. inputData["birctrl_type"] = "" // 就诊凭证类型
  1765. inputData["latechb_flag"] = "" // 就诊凭证类型
  1766. inputData["geso_val"] = ""
  1767. inputData["fetts"] = ""
  1768. inputData["fetus_cnt"] = ""
  1769. inputData["pret_flag"] = ""
  1770. inputData["birctrl_matn_date"] = ""
  1771. inputData["cop_flag"] = ""
  1772. inputData["dscg_dept_codg"] = struct2402.DscgDeptCodg
  1773. inputData["dscg_dept_name"] = struct2402.DscgDeptName
  1774. inputData["dscg_bed"] = "待定"
  1775. inputData["dscg_way"] = struct2402.DscgWay
  1776. inputData["die_date"] = ""
  1777. inputDataArr := make([]map[string]interface{}, 0)
  1778. for _, item := range struct2402.Diseinfo {
  1779. inputDataTwo := make(map[string]interface{})
  1780. inputDataTwo["psn_no"] = item.PsnNo
  1781. inputDataTwo["mdtrt_id"] = item.MdtrtId
  1782. inputDataTwo["diag_type"] = item.DiagType
  1783. inputDataTwo["maindiag_flag"] = item.MaindiagFlag
  1784. inputDataTwo["diag_srt_no"] = item.DiagSrtNo
  1785. inputDataTwo["diag_code"] = item.DiagCode
  1786. inputDataTwo["diag_name"] = item.DiagName
  1787. inputDataTwo["diag_dept"] = item.DiagDept
  1788. inputDataTwo["dise_dor_no"] = item.DiseDorNo
  1789. inputDataTwo["dise_dor_name"] = item.DiseDorName
  1790. inputDataTwo["diag_time"] = item.DiagTime
  1791. inputDataArr = append(inputDataArr, inputDataTwo)
  1792. }
  1793. input["dscginfo"] = inputData
  1794. input["diseinfo"] = inputDataArr
  1795. inputMessage["input"] = input //交易输入
  1796. bytesData, err := json.Marshal(inputMessage)
  1797. fmt.Println(string(bytesData))
  1798. requestLog := string(bytesData)
  1799. if err != nil {
  1800. fmt.Println(err.Error())
  1801. return err.Error(), ""
  1802. }
  1803. request_url = request_url + "2402"
  1804. return AHHttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData), "2402"), requestLog
  1805. }
  1806. func AHyb2301(psnNo string, mdtrtId string, hisPrescription []*models.NewCustom, med_type string, chrg_bchno string, dept_code string, dept string, doctor_id string, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, request_url string, cainfo string, access_key string) (string, string) {
  1807. // 生成签名
  1808. timestamp := time.Now().Unix()
  1809. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  1810. var customs []*models.NewCustom
  1811. customs = hisPrescription
  1812. // 生成输入报文
  1813. input := make(map[string]interface{})
  1814. feedetail := make([]map[string]interface{}, 0)
  1815. inputMessage["infno"] = "2301" // 交易编码
  1816. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  1817. for _, item := range customs {
  1818. org_id, _ := beego.AppConfig.Int64("org_id")
  1819. doctor_info, _ := GetAdminUserInfoByID(org_id, item.DoctorId)
  1820. feedetailInfo := make(map[string]interface{})
  1821. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  1822. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1823. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1824. feedetailInfo["med_type"] = med_type
  1825. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  1826. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  1827. feedetailInfo["medins_list_codg"] = fixmedins_code // 医药机构目录编码
  1828. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  1829. feedetailInfo["cnt"] = item.Cut // 数量
  1830. feedetailInfo["pric"] = item.Price // 单价
  1831. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  1832. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  1833. feedetailInfo["bilg_dr_codg"] = doctor_info.DoctorNumber // 开单医生编码
  1834. feedetailInfo["bilg_dr_name"] = doctor_info.UserName
  1835. feedetailInfo["acord_dept_codg"] = dept_code // 受单科室编码
  1836. feedetailInfo["acord_dept_name"] = dept // 受单科室名称
  1837. feedetailInfo["orders_dr_code"] = doctor_info.DoctorNumber // 受单医生编码
  1838. feedetailInfo["orders_dr_name"] = doctor_info.UserName // 受单医生姓名
  1839. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  1840. feedetailInfo["dise_codg"] = "" // 病种编码
  1841. feedetailInfo["rxno"] = "" // 处方号
  1842. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  1843. feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
  1844. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  1845. feedetailInfo["prd_days"] = "0" // 周期天数
  1846. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  1847. // 开单医师姓名
  1848. if item.HospApprFlag != -1 {
  1849. if item.HospApprFlag == 1 {
  1850. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  1851. } else if item.HospApprFlag == 2 {
  1852. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1853. } else if item.HospApprFlag == 3 {
  1854. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  1855. } else {
  1856. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1857. }
  1858. } else {
  1859. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1860. }
  1861. //feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  1862. feedetailInfo["etip_flag"] = "" // 外检标志
  1863. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  1864. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  1865. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  1866. feedetail = append(feedetail, feedetailInfo)
  1867. }
  1868. input["feedetail"] = feedetail
  1869. inputMessage["input"] = input //交易输入
  1870. bytesData, err := json.Marshal(inputMessage)
  1871. fmt.Println(string(bytesData))
  1872. requestLog := string(bytesData)
  1873. if err != nil {
  1874. fmt.Println(err.Error())
  1875. return err.Error(), ""
  1876. }
  1877. request_url = request_url + "2301"
  1878. return AHHttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData), "2301"), requestLog
  1879. }
  1880. func AHyb2302(psnNo string, mdtrtId string, refund_type int64, number string, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, request_url string, cainfo string, access_key string) (string, string) {
  1881. // 生成签名
  1882. nonce := GetRandomString(32)
  1883. timestamp := time.Now().Unix()
  1884. // 生成输入报文
  1885. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1886. input := make(map[string]interface{})
  1887. inputData := make(map[string]interface{})
  1888. inputMessage["infno"] = "2302" // 交易编码
  1889. if refund_type == 1 {
  1890. inputData["feedetl_sn"] = number //
  1891. } else {
  1892. inputData["feedetl_sn"] = "0000" //
  1893. }
  1894. inputData["mdtrt_id"] = mdtrtId // 就诊 ID
  1895. inputData["psn_no"] = psnNo // 人员编号
  1896. input["data"] = inputData
  1897. inputMessage["input"] = input //交易输入
  1898. bytesData, err := json.Marshal(inputMessage)
  1899. fmt.Println(string(bytesData))
  1900. requestLog := string(bytesData)
  1901. if err != nil {
  1902. fmt.Println(err.Error())
  1903. return err.Error(), ""
  1904. }
  1905. request_url = request_url + "2302"
  1906. return AHHttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData), "2302"), requestLog
  1907. }
  1908. func AHyb2303(psnNo string, mdtrtId string, certNo string, insutype string, total string, certificates int64, id_card_type int64, mid_setl_flag string, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, request_url string, cainfo string, access_key string,card_sn string,psn_type int64,psn_cert_type string,certno string,psn_name string) (string, string) {
  1909. // 生成签名
  1910. nonce := GetRandomString(32)
  1911. timestamp := time.Now().Unix()
  1912. // 生成输入报文
  1913. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1914. input := make(map[string]interface{})
  1915. inputData := make(map[string]interface{})
  1916. inputMessage["infno"] = "2303" // 交易编码
  1917. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1918. if certificates == 3 {
  1919. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1920. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1921. } else {
  1922. if id_card_type == 1 {
  1923. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1924. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1925. } else {
  1926. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1927. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1928. }
  1929. }
  1930. inputData["mdtrt_cert_sn"] = ""
  1931. inputData["mid_setl_flag"] = mid_setl_flag // 中途退费标志
  1932. inputData["medfee_sumamt"] = total // 医疗费总额
  1933. inputData["psn_setlway"] = "02" // 个人结算方式 01 按项目结 02 按定额结算
  1934. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1935. inputData["acct_used_flag"] = "1" // 个人账户使用标志 0否 1是
  1936. inputData["insutype"] = insutype // 险种类型
  1937. inputData["invono"] = "" // 发票号
  1938. inputData["dise_codg"] = "M07803" // 发票号
  1939. inputData["card_sn"] = card_sn // 发票号
  1940. inputData["psn_cert_type"] = psn_cert_type // 发票号
  1941. inputData["certno"] = certno // 发票号
  1942. inputData["psn_type"] = psn_type // 发票号
  1943. inputData["psn_name"] = psn_name // 发票号
  1944. inputData["insuplc_admdvs"] = insuplc_admdvs // 发票号
  1945. inputData["mdtrtarea_admvs"] = mdtrtarea_admvs // 发票号
  1946. input["data"] = inputData
  1947. inputMessage["input"] = input //交易输入
  1948. bytesData, err := json.Marshal(inputMessage)
  1949. fmt.Println(string(bytesData))
  1950. requestLog := string(bytesData)
  1951. if err != nil {
  1952. fmt.Println(err.Error())
  1953. return err.Error(), ""
  1954. }
  1955. request_url = request_url + "2303"
  1956. return AHHttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData), "2303"), requestLog
  1957. }
  1958. func AHyb2304(psnNo string, mdtrtId string, certNo string, insutype string, total string, certificates int64, id_card_type int64, mid_setl_flag string, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, request_url string, cainfo string, access_key string, fapiao_number string, acct_used_flag string) (string, string) {
  1959. // 生成签名
  1960. nonce := GetRandomString(32)
  1961. timestamp := time.Now().Unix()
  1962. // 生成输入报文
  1963. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1964. input := make(map[string]interface{})
  1965. inputData := make(map[string]interface{})
  1966. inputMessage["infno"] = "2304" // 交易编码
  1967. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1968. if certificates == 3 {
  1969. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1970. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1971. } else {
  1972. if id_card_type == 1 {
  1973. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1974. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1975. } else if id_card_type == 4 {
  1976. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  1977. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1978. } else {
  1979. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1980. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1981. }
  1982. }
  1983. inputData["insuplc_admdvs"] = insuplc_admdvs
  1984. inputData["mdtrtarea_admvs"] = mdtrtarea_admvs
  1985. inputData["mdtrt_cert_sn"] = ""
  1986. inputData["mid_setl_flag"] = mid_setl_flag // 中途退费标志
  1987. inputData["medfee_sumamt"] = total // 医疗费总额
  1988. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1989. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1990. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  1991. inputData["insutype"] = insutype // 险种类型
  1992. input["data"] = inputData
  1993. inputMessage["input"] = input //交易输入
  1994. bytesData, err := json.Marshal(inputMessage)
  1995. fmt.Println(string(bytesData))
  1996. requestLog := string(bytesData)
  1997. if err != nil {
  1998. fmt.Println(err.Error())
  1999. return err.Error(), ""
  2000. }
  2001. request_url = request_url + "2304"
  2002. return AHHttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData), "2304"), requestLog
  2003. }
  2004. func AHyb2305(psnNo string, mdtrtId string, setlId string, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, request_url string, cainfo string, access_key string) (string, string) {
  2005. // 生成签名
  2006. timestamp := time.Now().Unix()
  2007. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  2008. input := make(map[string]interface{})
  2009. inputData := make(map[string]interface{})
  2010. inputMessage["infno"] = "2305" // 交易编码
  2011. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2012. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  2013. inputData["setl_id"] = setlId // 结算 ID
  2014. input["data"] = inputData
  2015. inputMessage["input"] = input //交易输入
  2016. argInputMessage := make(map[string]interface{})
  2017. argInputMessage["arg0"] = inputMessage
  2018. bytesData, err := json.Marshal(argInputMessage)
  2019. fmt.Println(string(bytesData))
  2020. requestLog := string(bytesData)
  2021. if err != nil {
  2022. fmt.Println(err.Error())
  2023. return err.Error(), ""
  2024. }
  2025. request_url = request_url + "2305"
  2026. return AHHttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData), "2305"), requestLog
  2027. }
  2028. //CBS总线
  2029. func AHHttpRequest(url string, ak string, sk string, timestamp int64, json string, infno string) string {
  2030. fmt.Println(url)
  2031. //step 1. 设置请求参数
  2032. csbHP := csbhttp.NewHttpParams(url) //设置请求地址及url参数
  2033. //设置调用方式 get 或者 post
  2034. csbHP.SetMethod("post")
  2035. //设置 调用的服务名和版本
  2036. csbHP.SetApi("hsa-fsi-" + infno)
  2037. csbHP.SetVersion("1.0.0")
  2038. //添加附加的http请求头 (可以定义多条)
  2039. //key := "_api_access_key=" + ak + "&_api_name=" + "hssServives" + "&_api_timestamp=" + strconv.FormatInt(timestamp, 10) + "&_api_version=" + "1.0.0"
  2040. csbHP.AddHeader("_api_timestamp", strconv.FormatInt(timestamp, 10))
  2041. csbHP.AddHeader("_api_name", "hsa-fsi-"+infno)
  2042. csbHP.AddHeader("_api_version", "1.0.0")
  2043. csbHP.AddHeader("_api_access_key", ak)
  2044. csbHP.AddHeader("Content-Type", "application/json;charset=UTF-8")
  2045. //request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2046. //还可以,设置附加的byte[]或者json请求体
  2047. csbHP.SetContentBody(json, nil)
  2048. //设置请求的ak和sk
  2049. csbHP.SetAK(ak)
  2050. csbHP.SetSK(sk)
  2051. //打印请求参数信息
  2052. csbHP.Print()
  2053. //进行调用, 返回的第二项为resonse http headers (map[string][]string类型)
  2054. //res, _, err := csbhttp.Invoke(*csbHP, requestByte)
  2055. res, _, err := csbhttp.Invoke(*csbHP, strconv.FormatInt(timestamp, 10))
  2056. fmt.Println("err:")
  2057. fmt.Println(err)
  2058. //是否发成错误
  2059. if err != nil {
  2060. fmt.Println(err)
  2061. return ""
  2062. }
  2063. fmt.Println(res)
  2064. return res
  2065. }
  2066. // 生成基础报文
  2067. func SetAHInputMessage(timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, cainfo string) map[string]interface{} {
  2068. // 生成签名
  2069. tempTime := time.Unix(timestamp, 0)
  2070. //timeFormat := tempTime.Format("20060102150405")
  2071. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2072. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  2073. month := time.Unix(1557042972, 0).Format("1")
  2074. year := time.Now().Format("2006")
  2075. month = time.Now().Format("01")
  2076. day := time.Now().Format("02")
  2077. hour := time.Now().Format("15")
  2078. min := time.Now().Format("04")
  2079. sec := time.Now().Format("05")
  2080. msec := time.Now().Format("000")
  2081. // 生成输入报文
  2082. inputMessage := make(map[string]interface{})
  2083. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  2084. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  2085. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  2086. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  2087. inputMessage["dev_no"] = "1" // 设备编号
  2088. inputMessage["dev_safe_info"] = "1" // 设备安全信息
  2089. inputMessage["cainfo"] = cainfo // 数字签名信息
  2090. inputMessage["signtype"] = "SM3" // 签名类型
  2091. inputMessage["infver"] = "V1.0" // 接收方系统代码
  2092. inputMessage["opter_type"] = "1" // 经办人类别
  2093. inputMessage["opter"] = doctor // 经办人
  2094. inputMessage["opter_name"] = doctor // 经办人姓名
  2095. inputMessage["inf_time"] = timeFormatOne // 交易时间
  2096. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  2097. inputMessage["fixmedins_name"] = org_name
  2098. inputMessage["fixmedins_soft_fcty"] = "深圳市领透科技有限公司" //定点医药机构名称
  2099. //定点医药机构名称
  2100. inputMessage["sign_no"] = "" //交易签到流水号
  2101. return inputMessage
  2102. }
  2103. func AHyb5301(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, request_url string, access_key string, cainfo string) (string, string) {
  2104. // 生成签名
  2105. //nonce := GetRandomString(32)
  2106. timestamp := time.Now().Unix()
  2107. //signature := setSignature(timestamp, nonce, secret_key)
  2108. //tempTime := time.Unix(timestamp, 0)
  2109. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2110. //timeFormatTwo := tempTime.Format("2006-01-02")
  2111. // 生成输入报文
  2112. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  2113. input := make(map[string]interface{})
  2114. inputData := make(map[string]interface{})
  2115. inputMessage["infno"] = "5301" // 交易编码
  2116. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2117. input["data"] = inputData
  2118. inputMessage["input"] = input //交易输入
  2119. argInputMessage := make(map[string]interface{})
  2120. argInputMessage["arg0"] = inputMessage
  2121. bytesData, err := json.Marshal(argInputMessage)
  2122. fmt.Println(string(bytesData))
  2123. if err != nil {
  2124. fmt.Println(err.Error())
  2125. return err.Error(), ""
  2126. }
  2127. request_url = request_url + "5301"
  2128. return AHHttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData), "5301"), string(bytesData)
  2129. }
  2130. func AHyb2503(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, start_time string, end_time string, check_time string, request_url string, access_key string, cainfo string) (string, string) {
  2131. timestamp := time.Now().Unix()
  2132. // 生成输入报文
  2133. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  2134. input := make(map[string]interface{})
  2135. inputData := make(map[string]interface{})
  2136. inputMessage["infno"] = "2503" // 交易编码
  2137. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2138. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  2139. inputData["opsp_dise_code"] = sick_code // 险种类型(来自1101接口返回)
  2140. inputData["opsp_dise_name"] = sick_name // 险种类型(来自1101接口返回)
  2141. inputData["insu_optins"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  2142. inputData["ide_fixmedins_no"] = fixmedins_code // 险种类型(来自1101接口返回)
  2143. inputData["ide_fixmedins_name"] = org_name // 险种类型(来自1101接口返回)
  2144. inputData["hosp_ide_date"] = check_time // 险种类型(来自1101接口返回)
  2145. inputData["diag_dr_codg"] = doctor_id // 开始时间
  2146. inputData["diag_dr_name"] = doctor // 开始时间
  2147. inputData["begndate"] = start_time // 医师编码
  2148. inputData["tel"] = "" // 医师编码
  2149. inputData["addr"] = "" // 医师编码
  2150. inputData["enddate"] = end_time // 医师编码
  2151. input["data"] = inputData
  2152. inputMessage["input"] = input //交易输入
  2153. argInputMessage := make(map[string]interface{})
  2154. argInputMessage["arg0"] = inputMessage
  2155. bytesData, err := json.Marshal(argInputMessage)
  2156. fmt.Println(string(bytesData))
  2157. if err != nil {
  2158. fmt.Println(err.Error())
  2159. return err.Error(), ""
  2160. }
  2161. request_url = request_url + "2503"
  2162. return AHHttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData), "2503"), string(bytesData)
  2163. }
  2164. func AHyb3201(fixmedins_setl_cnt int64, acct_pay float64, fund_pay_sumamt float64, medfee_sumamt float64, stmt_begndate string, stmt_enddate string, setl_optins string, clr_type string, insutype string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, request_url string, access_key string, secret_key string, cainfo string) (string, string) {
  2165. // 生成签名
  2166. timestamp := time.Now().Unix()
  2167. // 生成输入报文
  2168. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  2169. input := make(map[string]interface{})
  2170. inputData := make(map[string]interface{})
  2171. inputMessage["infno"] = "3201" // 交易编码
  2172. inputData["insutype"] = insutype // 险种
  2173. inputData["clr_type"] = clr_type // 就诊 ID(来自2201接口返回)
  2174. inputData["setl_optins"] = setl_optins // 结算经办机构
  2175. inputData["stmt_begndate"] = stmt_begndate // 对帐开始时间
  2176. inputData["stmt_enddate"] = stmt_enddate //对帐结束时间
  2177. inputData["medfee_sumamt"] = medfee_sumamt //医疗费总额
  2178. inputData["fund_pay_sumamt"] = fund_pay_sumamt //基金支付总额
  2179. inputData["acct_pay"] = acct_pay //个人账户支付金额
  2180. inputData["fixmedins_setl_cnt"] = fixmedins_setl_cnt //定点医药机构结算笔数
  2181. inputData["refd_setl_flag"] = 0 //
  2182. input["data"] = inputData
  2183. inputMessage["input"] = input //交易输入
  2184. argInputMessage := make(map[string]interface{})
  2185. argInputMessage["arg0"] = inputMessage
  2186. bytesData, err := json.Marshal(argInputMessage)
  2187. fmt.Println(string(bytesData))
  2188. if err != nil {
  2189. fmt.Println(err.Error())
  2190. return err.Error(), ""
  2191. }
  2192. //request_url = request_url + "3201"
  2193. fmt.Println(request_url)
  2194. reader := bytes.NewReader(bytesData)
  2195. request_url = request_url + "3201"
  2196. request, err := http.NewRequest("POST", request_url, reader)
  2197. if err != nil {
  2198. fmt.Println(err.Error())
  2199. return err.Error(), ""
  2200. }
  2201. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2202. //request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
  2203. //request.Header.Set("_api_name", "hssServives")
  2204. //request.Header.Set("_api_version", "1.0.0")
  2205. //request.Header.Set("_api_access_key", access_key)
  2206. //request.Header.Set("_api_signature", "")
  2207. client := http.Client{}
  2208. resp, err := client.Do(request)
  2209. if err != nil {
  2210. fmt.Println(err.Error())
  2211. return err.Error(), ""
  2212. }
  2213. respBytes, err := ioutil.ReadAll(resp.Body)
  2214. if err != nil {
  2215. fmt.Println(err.Error())
  2216. return err.Error(), ""
  2217. }
  2218. str := string(respBytes)
  2219. fmt.Println(str)
  2220. return str, string(bytesData)
  2221. }
  2222. func AHyb9001(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, admin_user_id string, request_url string, cainfo string, access_key string) (string, string) {
  2223. fmt.Println(request_url)
  2224. // 生成签名
  2225. timestamp := time.Now().Unix()
  2226. // 生成输入报文
  2227. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  2228. input := make(map[string]interface{})
  2229. inputData := make(map[string]interface{})
  2230. inputMessage["infno"] = "9001" // 交易编码
  2231. inputData["opter_no"] = cainfo
  2232. inputData["mac"] = GetMacTwo() // 开始时间
  2233. inputData["ip"] = GetLocalIpTwo()
  2234. input["signIn"] = inputData
  2235. inputMessage["input"] = input //交易输入
  2236. argInputMessage := make(map[string]interface{})
  2237. argInputMessage["arg0"] = inputMessage
  2238. bytesData, err := json.Marshal(argInputMessage)
  2239. fmt.Println(string(bytesData))
  2240. if err != nil {
  2241. fmt.Println(err.Error())
  2242. return err.Error(), ""
  2243. }
  2244. reader := bytes.NewReader(bytesData)
  2245. request_url = request_url + "9001"
  2246. fmt.Println(request_url)
  2247. request, err := http.NewRequest("POST", request_url, reader)
  2248. if err != nil {
  2249. fmt.Println(err.Error())
  2250. return err.Error(), ""
  2251. }
  2252. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2253. //request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
  2254. //request.Header.Set("_api_name", "hssServives")
  2255. //request.Header.Set("_api_version", "1.0.0")
  2256. //request.Header.Set("_api_access_key", access_key)
  2257. //request.Header.Set("_api_signature", "")
  2258. client := http.Client{}
  2259. resp, err := client.Do(request)
  2260. if err != nil {
  2261. fmt.Println(err.Error())
  2262. return err.Error(), ""
  2263. }
  2264. respBytes, err := ioutil.ReadAll(resp.Body)
  2265. if err != nil {
  2266. fmt.Println(err.Error())
  2267. return err.Error(), ""
  2268. }
  2269. str := string(respBytes)
  2270. fmt.Println(str)
  2271. return str, string(bytesData)
  2272. }
  2273. func AHyb3101(pd models.PatientDtos, fed models.FsiEncounterDtos, fdds []*models.FsiDiagnoseDtos, fods []*models.FsiOrderDtos, fopds []*models.FsiOperationDtosData, params models.PublicParams, trig_scen string) (string, string) {
  2274. // 生成签名
  2275. timestamp := time.Now().Unix()
  2276. // 生成输入报文
  2277. inputMessage := SetAHInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  2278. input := make(map[string]interface{})
  2279. inputData := make(map[string]interface{})
  2280. patientDtosinputData := make(map[string]interface{})
  2281. fisEncounterDtosData := make(map[string]interface{})
  2282. fsiDiagnoseDtosDatas := make([]map[string]interface{}, 0)
  2283. fsiOrderDtosDatas := make([]map[string]interface{}, 0)
  2284. fsiOperationDtosData := make(map[string]interface{})
  2285. fsiOperationDtosDatas := make([]map[string]interface{}, 0)
  2286. //就诊信息
  2287. fisEncounterDtosData["mdtrt_id"] = fed.MdtrtID
  2288. fisEncounterDtosData["medins_id"] = fed.MedinsID
  2289. fisEncounterDtosData["medins_name"] = fed.MedinsName
  2290. fisEncounterDtosData["medins_admdvs"] = fed.MedinsAdmdvs
  2291. fisEncounterDtosData["medins_type"] = fed.MedinsType
  2292. fisEncounterDtosData["medins_lv"] = fed.MedinsLv
  2293. fisEncounterDtosData["wardarea_codg"] = fed.WardareaCodg
  2294. fisEncounterDtosData["wardno"] = fed.Wardno
  2295. fisEncounterDtosData["bedno"] = fed.Bedno
  2296. fisEncounterDtosData["adm_date"] = fed.AdmDate
  2297. fisEncounterDtosData["dscg_date"] = fed.DscgDate
  2298. fisEncounterDtosData["dscg_main_dise_codg"] = fed.DscgMainDiseCodg
  2299. fisEncounterDtosData["dscg_main_dise_name"] = fed.DscgMainDiseName
  2300. for _, fdd := range fdds {
  2301. fsiDiagnoseDtosData := make(map[string]interface{})
  2302. //诊断集合
  2303. fsiDiagnoseDtosData["dise_id"] = fdd.DiseID
  2304. fsiDiagnoseDtosData["inout_dise_type"] = fdd.InoutDiseType
  2305. fsiDiagnoseDtosData["maindise_flag"] = fdd.MaindiseFlag
  2306. fsiDiagnoseDtosData["dias_srt_no"] = fdd.DiasSrtNo
  2307. fsiDiagnoseDtosData["dise_codg"] = fdd.DiseCodg
  2308. fsiDiagnoseDtosData["dise_name"] = fdd.DiseName
  2309. fsiDiagnoseDtosData["dise_date"] = fdd.DiseDate
  2310. fsiDiagnoseDtosDatas = append(fsiDiagnoseDtosDatas, fsiDiagnoseDtosData)
  2311. }
  2312. fisEncounterDtosData["fsi_diagnose_dtos"] = fsiDiagnoseDtosDatas
  2313. fisEncounterDtosData["dr_codg"] = fed.DrCodg
  2314. fisEncounterDtosData["adm_dept_codg"] = fed.AdmDeptCodg
  2315. fisEncounterDtosData["adm_dept_name"] = fed.AdmDeptName
  2316. fisEncounterDtosData["dscg_dept_codg"] = fed.DscgDeptCodg
  2317. fisEncounterDtosData["dscg_dept_name"] = fed.DscgDeptName
  2318. fisEncounterDtosData["med_mdtrt_type"] = fed.MedMdtrtType
  2319. fisEncounterDtosData["med_type"] = fed.MedType
  2320. for _, fod := range fods {
  2321. fsiOrderDtosData := make(map[string]interface{})
  2322. //医嘱集合
  2323. fsiOrderDtosData["rx_id"] = fod.RxID
  2324. fsiOrderDtosData["rxno"] = fod.Rxno
  2325. fsiOrderDtosData["grpno"] = fod.Grpno
  2326. fsiOrderDtosData["long_drord_flag"] = fod.LongDrordFlag
  2327. fsiOrderDtosData["hilist_type"] = fod.HilistType
  2328. fsiOrderDtosData["chrg_type"] = fod.ChrgType
  2329. fsiOrderDtosData["drord_bhvr"] = fod.DrordBhvr
  2330. fsiOrderDtosData["hilist_code"] = fod.HilistCode
  2331. fsiOrderDtosData["hilist_name"] = fod.HilistName
  2332. fsiOrderDtosData["hilist_dosform"] = fod.HilistDosform
  2333. fsiOrderDtosData["hilist_lv"] = fod.HilistLv
  2334. fsiOrderDtosData["hilist_pric"] = fod.HilistPric
  2335. fsiOrderDtosData["lv1_hosp_item_pric"] = fod.Lv1HospItemPric
  2336. fsiOrderDtosData["lv2_hosp_item_pric"] = fod.Lv2HospItemPric
  2337. fsiOrderDtosData["lv3_hosp_item_pric"] = fod.Lv3HospItemPric
  2338. fsiOrderDtosData["hilist_memo"] = fod.HilistMemo
  2339. fsiOrderDtosData["hosplist_code"] = fod.HosplistCode
  2340. fsiOrderDtosData["hosplist_name"] = fod.HosplistName
  2341. fsiOrderDtosData["hosplist_dosform"] = fod.HosplistDosform
  2342. fsiOrderDtosData["cnt"] = fod.Cnt
  2343. fsiOrderDtosData["pric"] = fod.Pric
  2344. fsiOrderDtosData["sumamt"] = fod.Sumamt
  2345. fsiOrderDtosData["ownpay_amt"] = fod.OwnpayAmt
  2346. fsiOrderDtosData["selfpay_amt"] = fod.SelfpayAmt
  2347. fsiOrderDtosData["spec"] = fod.Spec
  2348. fsiOrderDtosData["spec_unt"] = fod.SpecUnt
  2349. fsiOrderDtosData["drord_begn_date"] = fod.DrordBegnDate
  2350. fsiOrderDtosData["drord_stop_date"] = fod.DrordStopDate
  2351. fsiOrderDtosData["drord_dept_codg"] = fod.DrordDeptCodg
  2352. fsiOrderDtosData["drord_dept_name"] = fod.DrordDeptName
  2353. fsiOrderDtosData["drord_dr_codg"] = fod.DrordDrCodg
  2354. fsiOrderDtosData["drord_dr_name"] = fod.DrordDrName
  2355. fsiOrderDtosData["drord_dr_profttl"] = fod.DrordDrProfttl
  2356. fsiOrderDtosData["curr_drord_flag"] = fod.CurrDrordFlag
  2357. fsiOrderDtosDatas = append(fsiOrderDtosDatas, fsiOrderDtosData)
  2358. }
  2359. fisEncounterDtosData["fsi_order_dtos"] = fsiOrderDtosDatas
  2360. fisEncounterDtosData["matn_stas"] = fed.MatnStas
  2361. fisEncounterDtosData["medfee_sumamt"] = fed.MedfeeSumamt
  2362. fisEncounterDtosData["ownpay_amt"] = fed.OwnpayAmt
  2363. fisEncounterDtosData["selfpay_amt"] = fed.SelfpayAmt
  2364. fisEncounterDtosData["acct_payamt"] = fed.AcctPayamt
  2365. fisEncounterDtosData["ma_amt"] = fed.MaAmt
  2366. fisEncounterDtosData["hifp_payamt"] = fed.HifpPayamt
  2367. fisEncounterDtosData["setl_totlnum"] = fed.SetlTotlnum
  2368. fisEncounterDtosData["insutype"] = fed.Insutype
  2369. fisEncounterDtosData["reim_flag"] = fed.ReimFlag
  2370. fisEncounterDtosData["out_setl_flag"] = fed.OutSetlFlag
  2371. //手术操作
  2372. for _, fopd := range fopds {
  2373. fsiOperationDtosData["setl_list_oprn_id"] = fopd.Setl_list_oprn_id
  2374. fsiOperationDtosData["oprn_code"] = fopd.Oprn_code
  2375. fsiOperationDtosData["oprn_name"] = fopd.Oprn_name
  2376. fsiOperationDtosData["main_oprn_flag"] = fopd.Main_oprn_flag
  2377. fsiOperationDtosData["oprn_date"] = fopd.Oprn_date
  2378. fsiOperationDtosData["anst_way"] = fopd.Anst_way
  2379. fsiOperationDtosData["oper_dr_name"] = fopd.Oper_dr_name
  2380. fsiOperationDtosData["oper_dr_code"] = fopd.Oper_dr_code
  2381. fsiOperationDtosData["anst_dr_name"] = fopd.Anst_dr_name
  2382. fsiOperationDtosData["anst_dr_code"] = fopd.Anst_dr_code
  2383. fsiOperationDtosDatas = append(fsiOperationDtosDatas, fsiOperationDtosData)
  2384. }
  2385. fisEncounterDtosData["fsi_operation_dtos"] = fsiOperationDtosDatas
  2386. patientDtosinputData["patn_id"] = pd.PatnID
  2387. patientDtosinputData["patn_name"] = pd.PatnName
  2388. patientDtosinputData["gend"] = pd.Gend
  2389. patientDtosinputData["brdy"] = pd.Brdy
  2390. patientDtosinputData["poolarea"] = pd.Poolarea
  2391. patientDtosinputData["curr_mdtrt_id"] = pd.CurrMdtrtID
  2392. patientDtosinputData["fsi_his_data_dto"] = ""
  2393. patientDtosinputData["fsi_encounter_dtos"] = fisEncounterDtosData
  2394. inputData["syscode"] = "LinkDialysis"
  2395. inputData["trig_scen"] = trig_scen
  2396. inputData["rule_ids"] = ""
  2397. inputData["task_id"] = ""
  2398. inputData["patient_dtos"] = patientDtosinputData
  2399. input["data"] = inputData
  2400. inputMessage["infno"] = "3101"
  2401. inputMessage["input"] = input //交易输入
  2402. argInputMessage := make(map[string]interface{})
  2403. argInputMessage["arg0"] = inputMessage
  2404. bytesData, err := json.Marshal(argInputMessage)
  2405. fmt.Println(string(bytesData))
  2406. if err != nil {
  2407. fmt.Println(err.Error())
  2408. return err.Error(), ""
  2409. }
  2410. params.RequestUrl = params.RequestUrl + "3101"
  2411. return AHHttpRequest(params.RequestUrl, params.AccessKey, params.SecretKey, timestamp, string(bytesData), "3101"), string(bytesData)
  2412. }
  2413. func AHyb3102(pd models.PatientDtos, fed models.FsiEncounterDtos, fdds []*models.FsiDiagnoseDtos, fods []*models.FsiOrderDtos, fopds []*models.FsiOperationDtosData, params models.PublicParams, trig_scen string) (string, string) {
  2414. // 生成签名
  2415. timestamp := time.Now().Unix()
  2416. // 生成输入报文
  2417. inputMessage := SetAHInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  2418. input := make(map[string]interface{})
  2419. inputData := make(map[string]interface{})
  2420. patientDtosinputData := make(map[string]interface{})
  2421. fisEncounterDtosData := make(map[string]interface{})
  2422. fsiDiagnoseDtosDatas := make([]map[string]interface{}, 0)
  2423. fsiOrderDtosDatas := make([]map[string]interface{}, 0)
  2424. fsiOperationDtosData := make(map[string]interface{})
  2425. fsiOperationDtosDatas := make([]map[string]interface{}, 0)
  2426. //就诊信息
  2427. fisEncounterDtosData["mdtrt_id"] = fed.MdtrtID
  2428. fisEncounterDtosData["medins_id"] = fed.MedinsID
  2429. fisEncounterDtosData["medins_name"] = fed.MedinsName
  2430. fisEncounterDtosData["medins_admdvs"] = fed.MedinsAdmdvs
  2431. fisEncounterDtosData["medins_type"] = fed.MedinsType
  2432. fisEncounterDtosData["medins_lv"] = fed.MedinsLv
  2433. fisEncounterDtosData["wardarea_codg"] = fed.WardareaCodg
  2434. fisEncounterDtosData["wardno"] = fed.Wardno
  2435. fisEncounterDtosData["bedno"] = fed.Bedno
  2436. fisEncounterDtosData["adm_date"] = fed.AdmDate
  2437. fisEncounterDtosData["dscg_date"] = fed.DscgDate
  2438. fisEncounterDtosData["dscg_main_dise_codg"] = fed.DscgMainDiseCodg
  2439. fisEncounterDtosData["dscg_main_dise_name"] = fed.DscgMainDiseName
  2440. for _, fdd := range fdds {
  2441. fsiDiagnoseDtosData := make(map[string]interface{})
  2442. //诊断集合
  2443. fsiDiagnoseDtosData["dise_id"] = fdd.DiseID
  2444. fsiDiagnoseDtosData["inout_dise_type"] = fdd.InoutDiseType
  2445. fsiDiagnoseDtosData["maindise_flag"] = fdd.MaindiseFlag
  2446. fsiDiagnoseDtosData["dias_srt_no"] = fdd.DiasSrtNo
  2447. fsiDiagnoseDtosData["dise_codg"] = fdd.DiseCodg
  2448. fsiDiagnoseDtosData["dise_name"] = fdd.DiseName
  2449. fsiDiagnoseDtosData["dise_date"] = fdd.DiseDate
  2450. fsiDiagnoseDtosDatas = append(fsiDiagnoseDtosDatas, fsiDiagnoseDtosData)
  2451. }
  2452. fisEncounterDtosData["fsi_diagnose_dtos"] = fsiDiagnoseDtosDatas
  2453. fisEncounterDtosData["dr_codg"] = fed.DrCodg
  2454. fisEncounterDtosData["adm_dept_codg"] = fed.AdmDeptCodg
  2455. fisEncounterDtosData["adm_dept_name"] = fed.AdmDeptName
  2456. fisEncounterDtosData["dscg_dept_codg"] = fed.DscgDeptCodg
  2457. fisEncounterDtosData["dscg_dept_name"] = fed.DscgDeptName
  2458. fisEncounterDtosData["med_mdtrt_type"] = fed.MedMdtrtType
  2459. fisEncounterDtosData["med_type"] = fed.MedType
  2460. for _, fod := range fods {
  2461. fsiOrderDtosData := make(map[string]interface{})
  2462. //医嘱集合
  2463. fsiOrderDtosData["rx_id"] = fod.RxID
  2464. fsiOrderDtosData["rxno"] = fod.Rxno
  2465. fsiOrderDtosData["grpno"] = fod.Grpno
  2466. fsiOrderDtosData["long_drord_flag"] = fod.LongDrordFlag
  2467. fsiOrderDtosData["hilist_type"] = fod.HilistType
  2468. fsiOrderDtosData["chrg_type"] = fod.ChrgType
  2469. fsiOrderDtosData["drord_bhvr"] = fod.DrordBhvr
  2470. fsiOrderDtosData["hilist_code"] = fod.HilistCode
  2471. fsiOrderDtosData["hilist_name"] = fod.HilistName
  2472. fsiOrderDtosData["hilist_dosform"] = fod.HilistDosform
  2473. fsiOrderDtosData["hilist_lv"] = fod.HilistLv
  2474. fsiOrderDtosData["hilist_pric"] = fod.HilistPric
  2475. fsiOrderDtosData["lv1_hosp_item_pric"] = fod.Lv1HospItemPric
  2476. fsiOrderDtosData["lv2_hosp_item_pric"] = fod.Lv2HospItemPric
  2477. fsiOrderDtosData["lv3_hosp_item_pric"] = fod.Lv3HospItemPric
  2478. fsiOrderDtosData["hilist_memo"] = fod.HilistMemo
  2479. fsiOrderDtosData["hosplist_code"] = fod.HosplistCode
  2480. fsiOrderDtosData["hosplist_name"] = fod.HosplistName
  2481. fsiOrderDtosData["hosplist_dosform"] = fod.HosplistDosform
  2482. fsiOrderDtosData["cnt"] = fod.Cnt
  2483. fsiOrderDtosData["pric"] = fod.Pric
  2484. fsiOrderDtosData["sumamt"] = fod.Sumamt
  2485. fsiOrderDtosData["ownpay_amt"] = fod.OwnpayAmt
  2486. fsiOrderDtosData["selfpay_amt"] = fod.SelfpayAmt
  2487. fsiOrderDtosData["spec"] = fod.Spec
  2488. fsiOrderDtosData["spec_unt"] = fod.SpecUnt
  2489. fsiOrderDtosData["drord_begn_date"] = fod.DrordBegnDate
  2490. fsiOrderDtosData["drord_stop_date"] = fod.DrordStopDate
  2491. fsiOrderDtosData["drord_dept_codg"] = fod.DrordDeptCodg
  2492. fsiOrderDtosData["drord_dept_name"] = fod.DrordDeptName
  2493. fsiOrderDtosData["drord_dr_codg"] = fod.DrordDrCodg
  2494. fsiOrderDtosData["drord_dr_name"] = fod.DrordDrName
  2495. fsiOrderDtosData["drord_dr_profttl"] = fod.DrordDrProfttl
  2496. fsiOrderDtosData["curr_drord_flag"] = fod.CurrDrordFlag
  2497. fsiOrderDtosDatas = append(fsiOrderDtosDatas, fsiOrderDtosData)
  2498. }
  2499. fisEncounterDtosData["fsi_order_dtos"] = fsiOrderDtosDatas
  2500. fisEncounterDtosData["matn_stas"] = fed.MatnStas
  2501. fisEncounterDtosData["medfee_sumamt"] = fed.MedfeeSumamt
  2502. fisEncounterDtosData["ownpay_amt"] = fed.OwnpayAmt
  2503. fisEncounterDtosData["selfpay_amt"] = fed.SelfpayAmt
  2504. fisEncounterDtosData["acct_payamt"] = fed.AcctPayamt
  2505. fisEncounterDtosData["ma_amt"] = fed.MaAmt
  2506. fisEncounterDtosData["hifp_payamt"] = fed.HifpPayamt
  2507. fisEncounterDtosData["setl_totlnum"] = fed.SetlTotlnum
  2508. fisEncounterDtosData["insutype"] = fed.Insutype
  2509. fisEncounterDtosData["reim_flag"] = fed.ReimFlag
  2510. fisEncounterDtosData["out_setl_flag"] = fed.OutSetlFlag
  2511. //手术操作
  2512. for _, fopd := range fopds {
  2513. fsiOperationDtosData["setl_list_oprn_id"] = fopd.Setl_list_oprn_id
  2514. fsiOperationDtosData["oprn_code"] = fopd.Oprn_code
  2515. fsiOperationDtosData["oprn_name"] = fopd.Oprn_name
  2516. fsiOperationDtosData["main_oprn_flag"] = fopd.Main_oprn_flag
  2517. fsiOperationDtosData["oprn_date"] = fopd.Oprn_date
  2518. fsiOperationDtosData["anst_way"] = fopd.Anst_way
  2519. fsiOperationDtosData["oper_dr_name"] = fopd.Oper_dr_name
  2520. fsiOperationDtosData["oper_dr_code"] = fopd.Oper_dr_code
  2521. fsiOperationDtosData["anst_dr_name"] = fopd.Anst_dr_name
  2522. fsiOperationDtosData["anst_dr_code"] = fopd.Anst_dr_code
  2523. fsiOperationDtosDatas = append(fsiOperationDtosDatas, fsiOperationDtosData)
  2524. }
  2525. fisEncounterDtosData["fsi_operation_dtos"] = fsiOperationDtosDatas
  2526. patientDtosinputData["patn_id"] = pd.PatnID
  2527. patientDtosinputData["patn_name"] = pd.PatnName
  2528. patientDtosinputData["gend"] = pd.Gend
  2529. patientDtosinputData["brdy"] = pd.Brdy
  2530. patientDtosinputData["poolarea"] = pd.Poolarea
  2531. patientDtosinputData["curr_mdtrt_id"] = pd.CurrMdtrtID
  2532. patientDtosinputData["fsi_his_data_dto"] = ""
  2533. patientDtosinputData["fsi_encounter_dtos"] = fisEncounterDtosData
  2534. inputData["syscode"] = "LinkDialysis"
  2535. inputData["trig_scen"] = trig_scen
  2536. inputData["rule_ids"] = ""
  2537. inputData["task_id"] = ""
  2538. inputData["patient_dtos"] = patientDtosinputData
  2539. input["data"] = inputData
  2540. inputMessage["infno"] = "3102"
  2541. inputMessage["input"] = input //交易输入
  2542. argInputMessage := make(map[string]interface{})
  2543. argInputMessage["arg0"] = inputMessage
  2544. bytesData, err := json.Marshal(argInputMessage)
  2545. fmt.Println(string(bytesData))
  2546. if err != nil {
  2547. fmt.Println(err.Error())
  2548. return err.Error(), ""
  2549. }
  2550. params.RequestUrl = params.RequestUrl + "3102"
  2551. return AHHttpRequest(params.RequestUrl, params.AccessKey, params.SecretKey, timestamp, string(bytesData), "3102"), string(bytesData)
  2552. }
  2553. func AHyb4101(struct4101 Struct4101, params models.PublicParams) (string, string) {
  2554. timestamp := time.Now().Unix()
  2555. inputMessage := SetAHInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  2556. // 生成输入报文
  2557. input := make(map[string]interface{})
  2558. inputData := make(map[string]interface{})
  2559. inputMessage["infno"] = "4101A" // 交易编码
  2560. year := time.Now().Format("2006")
  2561. month := time.Now().Format("01")
  2562. day := time.Now().Format("02")
  2563. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  2564. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  2565. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  2566. inputData["fixmedins_name"] = params.FixmedinsName // 定点医药机构名称 必填
  2567. inputData["fixmedins_code"] = params.FixmedinsCode // 定点医药机构编码 必填
  2568. inputData["hi_setl_lv"] = "" // 医保结算等级
  2569. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  2570. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  2571. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  2572. inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  2573. inputData["gend"] = struct4101.Gend // 性别 必填
  2574. inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  2575. inputData["age"] = struct4101.Age // 年龄 必填
  2576. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  2577. inputData["nwb_age"] = "" // 年龄 必填
  2578. inputData["naty"] = struct4101.Naty // 民族 必填
  2579. inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  2580. inputData["certno"] = struct4101.Certno // 证件号码 必填
  2581. inputData["prfs"] = struct4101.Prfs // 职业 必填
  2582. inputData["curr_addr"] = "" // 现住址 必填
  2583. inputData["emp_name"] = "" // 单位名称 必填
  2584. inputData["emp_addr"] = "" // 单位地址 必填
  2585. inputData["emp_tel"] = "" // 单位电话 必填
  2586. inputData["poscode"] = "" // 邮编 必填
  2587. inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  2588. inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  2589. inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  2590. inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  2591. inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  2592. inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  2593. inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  2594. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  2595. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  2596. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  2597. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  2598. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  2599. inputData["ipt_med_type"] = struct4101.IptMedType // 住院医疗类型 必填
  2600. inputData["adm_way"] = "" // 入院途径 必填
  2601. inputData["trt_type"] = "" // 治疗类别 必填
  2602. inputData["adm_time"] = struct4101.AdmTime // 入院时间 必填
  2603. inputData["adm_caty"] = struct4101.AdmCaty // 入院科别 必填
  2604. inputData["refldept_dept"] = "" // 转科科别 必填
  2605. inputData["dscg_time"] = struct4101.AdmEndTime // 出院时间 必填
  2606. inputData["dscg_caty"] = struct4101.AdmCaty // 出院科别 必填
  2607. inputData["act_ipt_days"] = "" // 实际住院天数 必填
  2608. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  2609. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  2610. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  2611. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  2612. inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  2613. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  2614. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  2615. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  2616. inputData["bld_cat"] = "" // 输血品种 必填
  2617. inputData["bld_amt"] = "" // 输血量 必填
  2618. inputData["bld_unt"] = "" // 输血计量单位 必填
  2619. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  2620. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  2621. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  2622. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  2623. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  2624. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  2625. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  2626. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  2627. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  2628. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  2629. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  2630. inputData["chfpdr_name"] = "" // 主诊医师姓名 必填
  2631. inputData["chfpdr_code"] = "" // 主诊医师代码 必填
  2632. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  2633. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  2634. inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  2635. inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  2636. inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  2637. inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  2638. inputData["hsorg"] = params.FixmedinsName // 医保机构 必填
  2639. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  2640. inputData["medins_fill_dept"] = params.FixmedinsName // 医疗机构填报部门 必填
  2641. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  2642. inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  2643. payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  2644. for _, item := range struct4101.CustomStruct {
  2645. payinfotemp := make(map[string]interface{})
  2646. 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" {
  2647. payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  2648. payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  2649. payinfo = append(payinfo, payinfotemp)
  2650. }
  2651. }
  2652. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  2653. opspdiseinfotemp := make(map[string]interface{})
  2654. opspdiseinfotemp["diag_name"] = struct4101.OpspdiseinfoStruct[len(struct4101.OpspdiseinfoStruct)-1].DiagName // 诊断名称 必填
  2655. opspdiseinfotemp["diag_code"] = struct4101.OpspdiseinfoStruct[len(struct4101.OpspdiseinfoStruct)-1].DiagCode // 诊断代码 必填
  2656. opspdiseinfotemp["oprn_oprt_name"] = struct4101.OpspdiseinfoStruct[len(struct4101.OpspdiseinfoStruct)-1].DiagName // 手术操作名称 必填
  2657. opspdiseinfotemp["oprn_oprt_code"] = struct4101.OpspdiseinfoStruct[len(struct4101.OpspdiseinfoStruct)-1].DiagCode // 手术操作代码 必填
  2658. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  2659. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  2660. for _, item := range struct4101.Diseinfo {
  2661. diseinfotemp := make(map[string]interface{})
  2662. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  2663. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  2664. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  2665. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  2666. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  2667. diseinfo = append(diseinfo, diseinfotemp)
  2668. }
  2669. iteminfo := make([]map[string]interface{}, 0)
  2670. for _, item := range struct4101.IteminfoStruct {
  2671. iteminfotemp := make(map[string]interface{})
  2672. iteminfotemp["med_chrgitm"] = item.MedChrgitm // 医疗收费项目 必填
  2673. iteminfotemp["amt"] = item.Amt // 金额 必填
  2674. iteminfotemp["claa_sumfee"] = item.ClaaSumfee // 甲类费用合计 必填
  2675. iteminfotemp["clab_amt"] = item.ClabAmt // 乙类金额 必填
  2676. iteminfotemp["fulamt_ownpay_amt"] = item.FulamtOwnpayAmt // 全自费金额 必填
  2677. iteminfotemp["oth_amt"] = item.OthAmt // 其他金额 必填
  2678. iteminfo = append(iteminfo, iteminfotemp)
  2679. }
  2680. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  2681. oprninfotemp := make(map[string]interface{})
  2682. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  2683. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  2684. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  2685. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  2686. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  2687. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  2688. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  2689. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  2690. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  2691. oprninfo = append(oprninfo, oprninfotemp)
  2692. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  2693. icuinfotemp := make(map[string]interface{})
  2694. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  2695. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  2696. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  2697. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  2698. icuinfo = append(icuinfo, icuinfotemp)
  2699. input["setlinfo"] = inputData
  2700. input["payinfo"] = payinfo
  2701. input["opspdiseinfo"] = opspdiseinfo
  2702. input["diseinfo"] = diseinfo
  2703. input["iteminfo"] = iteminfo
  2704. inputMessage["input"] = input //交易输入
  2705. argInputMessage := make(map[string]interface{})
  2706. argInputMessage["arg0"] = inputMessage
  2707. bytesData, _ := json.Marshal(argInputMessage)
  2708. fmt.Println(string(bytesData))
  2709. params.RequestUrl = params.RequestUrl + "4101"
  2710. return AHHttpRequest(params.RequestUrl, params.AccessKey, params.SecretKey, timestamp, string(bytesData), "4101A"), string(bytesData)
  2711. }
  2712. func AHyb4102(psn_no string, setl_id string, params models.PublicParams, stas_type string) (string, string) {
  2713. timestamp := time.Now().Unix()
  2714. inputMessage := SetAHInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  2715. // 生成输入报文
  2716. input := make(map[string]interface{})
  2717. inputData := make(map[string]interface{})
  2718. inputData2 := make(map[string]interface{})
  2719. inputMessage["infno"] = "4102" // 交易编码
  2720. inputData["setl_id"] = setl_id // 结算 ID 必填
  2721. inputData["psn_no"] = psn_no // 结算 ID 必填
  2722. inputData["stas_type"] = stas_type // 结算 ID 必填
  2723. inputData2["stastinfo"] = inputData
  2724. input["data"] = inputData2
  2725. inputMessage["input"] = input //交易输入
  2726. argInputMessage := make(map[string]interface{})
  2727. argInputMessage["arg0"] = inputMessage
  2728. bytesData, _ := json.Marshal(argInputMessage)
  2729. fmt.Println(string(bytesData))
  2730. params.RequestUrl = params.RequestUrl + "4102"
  2731. return AHHttpRequest(params.RequestUrl, params.AccessKey, params.SecretKey, timestamp, string(bytesData), "4102"), string(bytesData)
  2732. }
  2733. func AHyb4103(psn_no string, setl_id string, params models.PublicParams) (string, string) {
  2734. timestamp := time.Now().Unix()
  2735. inputMessage := SetAHInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  2736. // 生成输入报文
  2737. input := make(map[string]interface{})
  2738. inputData := make(map[string]interface{})
  2739. inputMessage["infno"] = "4103" // 交易编码
  2740. inputData["setl_id"] = setl_id // 结算 ID 必填
  2741. inputData["psn_no"] = psn_no // 结算 ID 必填
  2742. input["data"] = inputData
  2743. inputMessage["input"] = input //交易输入
  2744. argInputMessage := make(map[string]interface{})
  2745. argInputMessage["arg0"] = inputMessage
  2746. bytesData, _ := json.Marshal(argInputMessage)
  2747. params.RequestUrl = params.RequestUrl + "4103"
  2748. return AHHttpRequest(params.RequestUrl, params.AccessKey, params.SecretKey, timestamp, string(bytesData), "4103"), string(bytesData)
  2749. }
  2750. func AHyb4105( params models.PublicParams) (string, string) {
  2751. var meds []string
  2752. meds = append(meds,"21")
  2753. timestamp := time.Now().Unix()
  2754. inputMessage := SetAHInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  2755. // 生成输入报文
  2756. input := make(map[string]interface{})
  2757. inputData := make(map[string]interface{})
  2758. inputMessage["infno"] = "4105" // 交易编码
  2759. inputData["fixmedins_code"] = params.FixmedinsCode // 结算 ID 必填
  2760. inputData["medtype_list"] = meds // 结算 ID 必填
  2761. inputData["stt_begntime"] = "2023-11-01"// 结算 ID 必填
  2762. inputData["stt_endtime"] = "2023-11-31"// 结算 ID 必填
  2763. input["data"] = inputData
  2764. inputMessage["input"] = input //交易输入
  2765. argInputMessage := make(map[string]interface{})
  2766. argInputMessage["arg0"] = inputMessage
  2767. bytesData, _ := json.Marshal(argInputMessage)
  2768. fmt.Println(string(bytesData))
  2769. params.RequestUrl = params.RequestUrl + "4105"
  2770. return AHHttpRequest(params.RequestUrl, params.AccessKey, params.SecretKey, timestamp, string(bytesData), "4105"), string(bytesData)
  2771. }
  2772. func AHyb3501(struct3501 models.Struct3501) (string, string) {
  2773. timestamp := time.Now().Unix()
  2774. // 生成输入报文
  2775. inputMessage := SetAHInputMessage(timestamp, struct3501.OrgName, struct3501.Opter, struct3501.FixmedinsCode, struct3501.InsuplcAdmdvs, struct3501.MdtrtareaAdmvs, struct3501.Cainfo)
  2776. input := make(map[string]interface{})
  2777. inputData := make(map[string]interface{})
  2778. inputMessage["infno"] = "3501" // 交易编码
  2779. inputData["med_list_codg"] = struct3501.MedListCodg // 定点医药机构目录编号
  2780. inputData["fixmedins_hilist_id"] = struct3501.FixmedinsHilistId // 定点医药机构目录编号
  2781. inputData["fixmedins_hilist_name"] = struct3501.OrgName // 定点医药机构目录名称
  2782. inputData["rx_flag"] = struct3501.RxFlag //
  2783. inputData["invdate"] = struct3501.Invdate // 人员编号 (来自1101接口返回)
  2784. inputData["inv_cnt"] = struct3501.InvCnt // 人员编号 (来自1101接口返回)
  2785. inputData["manu_lotnum"] = struct3501.ManuLotnum // 人员编号 (来自1101接口返回)
  2786. inputData["fixmedins_bchno"] = struct3501.FixmedinsBchno // 人员编号 (来自1101接口返回)
  2787. inputData["manu_date"] = struct3501.ManuDate // 人员编号 (来自1101接口返回)
  2788. inputData["expy_end"] = struct3501.ExpyEnd // 人员编号 (来自1101接口返回)
  2789. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  2790. input["invinfo"] = inputData
  2791. inputMessage["input"] = input //交易输入
  2792. argInputMessage := make(map[string]interface{})
  2793. argInputMessage["arg0"] = inputMessage
  2794. bytesData, err := json.Marshal(argInputMessage)
  2795. fmt.Println(string(bytesData))
  2796. if err != nil {
  2797. fmt.Println(err.Error())
  2798. return err.Error(), ""
  2799. }
  2800. struct3501.RequestUrl = struct3501.RequestUrl + "3501"
  2801. return AHHttpRequest(struct3501.RequestUrl, struct3501.AccessKey, struct3501.SecretKey, timestamp, string(bytesData), "3501"), string(bytesData)
  2802. }
  2803. func AHyb3502(struct3502 models.Struct3502) (string, string) {
  2804. timestamp := time.Now().Unix()
  2805. // 生成输入报文
  2806. inputMessage := SetAHInputMessage(timestamp, struct3502.OrgName, struct3502.Opter, struct3502.FixmedinsCode, struct3502.InsuplcAdmdvs, struct3502.MdtrtareaAdmvs, struct3502.Cainfo)
  2807. input := make(map[string]interface{})
  2808. inputData := make(map[string]interface{})
  2809. inputMessage["infno"] = "3502" // 交易编码
  2810. inputData["med_list_codg"] = struct3502.MedListCodg // 定点医药机构目录编号
  2811. inputData["inv_chg_type"] = struct3502.InvChgType // 定点医药机构目录编号
  2812. inputData["fixmedins_hilist_id"] = struct3502.FixmedinsCode // 定点医药机构目录编号
  2813. inputData["fixmedins_hilist_name"] = struct3502.OrgName // 定点医药机构目录名称
  2814. inputData["fixmedins_bchno"] = struct3502.FixmedinsBchno // 人员编号 (来自1101接口返回)
  2815. inputData["pric"] = struct3502.Pric // 人员编号 (来自1101接口返回)
  2816. inputData["cnt"] = struct3502.Cnt // 人员编号 (来自1101接口返回)
  2817. inputData["rx_flag"] = struct3502.RxFlag //
  2818. inputData["inv_chg_time"] = struct3502.InvChgTime // 人员编号 (来自1101接口返回)
  2819. inputData["inv_chg_opter_name"] = "" // 人员编号 (来自1101接口返回)
  2820. inputData["memo"] = struct3502.Memo // 人员编号 (来自1101接口返回)
  2821. inputData["trdn_flag"] = "" // 人员编号 (来自1101接口返回)
  2822. input["invinfo"] = inputData
  2823. inputMessage["input"] = input //交易输入
  2824. argInputMessage := make(map[string]interface{})
  2825. argInputMessage["arg0"] = inputMessage
  2826. bytesData, err := json.Marshal(argInputMessage)
  2827. fmt.Println(string(bytesData))
  2828. if err != nil {
  2829. fmt.Println(err.Error())
  2830. return err.Error(), ""
  2831. }
  2832. struct3502.RequestUrl = struct3502.RequestUrl + "3502"
  2833. return AHHttpRequest(struct3502.RequestUrl, struct3502.AccessKey, struct3502.SecretKey, timestamp, string(bytesData), "3502"), string(bytesData)
  2834. }
  2835. func AHyb3503(struct3503 models.Struct3503) (string, string) {
  2836. timestamp := time.Now().Unix()
  2837. // 生成输入报文
  2838. inputMessage := SetAHInputMessage(timestamp, struct3503.OrgName, struct3503.Opter, struct3503.FixmedinsCode, struct3503.InsuplcAdmdvs, struct3503.MdtrtareaAdmvs, struct3503.Cainfo)
  2839. input := make(map[string]interface{})
  2840. inputData := make(map[string]interface{})
  2841. inputMessage["infno"] = "3503"
  2842. inputData["med_list_codg"] = struct3503.MedListCodg
  2843. inputData["fixmedins_hilist_id"] = struct3503.FixmedinsCode
  2844. inputData["fixmedins_hilist_name"] = struct3503.OrgName
  2845. inputData["dynt_no"] = ""
  2846. inputData["fixmedins_bchno"] = struct3503.FixmedinsBchno // 人员编号 (来自1101接口返回)
  2847. inputData["spler_name"] = struct3503.SplerName // 人员编号 (来自1101接口返回)
  2848. inputData["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  2849. inputData["manu_lotnum"] = struct3503.ManuLotnum // 人员编号 (来自1101接口返回)
  2850. inputData["prodentp_name"] = struct3503.ProdentpName // 人员编号 (来自1101接口返回)
  2851. inputData["aprvno"] = struct3503.Aprvno // 人员编号 (来自1101接口返回)
  2852. inputData["manu_date"] = struct3503.ManuDate // 人员编号 (来自1101接口返回)
  2853. inputData["expy_end"] = struct3503.ExpyEnd // 人员编号 (来自1101接口返回)
  2854. inputData["finl_trns_pric"] = struct3503.FinlTrnsPric // 人员编号 (来自1101接口返回)
  2855. inputData["purc_retn_cnt"] = struct3503.PurcRetnCnt // 人员编号 (来自1101接口返回)
  2856. inputData["purc_invo_codg"] = struct3503.PurcInvoCodg // 人员编号 (来自1101接口返回)
  2857. inputData["purc_invo_no"] = struct3503.PurcInvoNo // 人员编号 (来自1101接口返回)
  2858. inputData["rx_flag"] = struct3503.RxFlag // 人员编号 (来自1101接口返回)
  2859. inputData["purc_retn_stoin_time"] = struct3503.PurcRetnStoinTime // 人员编号 (来自1101接口返回)
  2860. inputData["purc_retn_opter_name"] = struct3503.PurcRetnOpterName // 人员编号 (来自1101接口返回)
  2861. inputData["prod_geay_flag"] = "" // 人员编号 (来自1101接口返回)
  2862. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  2863. input["purcinfo"] = inputData
  2864. inputMessage["input"] = input //交易输入
  2865. argInputMessage := make(map[string]interface{})
  2866. argInputMessage["arg0"] = inputMessage
  2867. bytesData, err := json.Marshal(argInputMessage)
  2868. fmt.Println(string(bytesData))
  2869. if err != nil {
  2870. fmt.Println(err.Error())
  2871. return err.Error(), ""
  2872. }
  2873. struct3503.RequestUrl = struct3503.RequestUrl + "3503"
  2874. return AHHttpRequest(struct3503.RequestUrl, struct3503.AccessKey, struct3503.SecretKey, timestamp, string(bytesData), "3503"), string(bytesData)
  2875. }
  2876. func AHyb3504(struct3504 models.Struct3504) (string, string) {
  2877. timestamp := time.Now().Unix()
  2878. // 生成输入报文
  2879. inputMessage := SetAHInputMessage(timestamp, struct3504.OrgName, struct3504.Opter, struct3504.FixmedinsCode, struct3504.InsuplcAdmdvs, struct3504.MdtrtareaAdmvs, struct3504.Cainfo)
  2880. input := make(map[string]interface{})
  2881. inputData := make(map[string]interface{})
  2882. inputMessage["infno"] = "3504" // 交易编码
  2883. inputData["med_list_codg"] = struct3504.MedListCodg // 定点医药机构目录编号
  2884. inputData["fixmedins_hilist_id"] = struct3504.FixmedinsHilistId // 定点医药机构目录编号
  2885. inputData["fixmedins_hilist_name"] = struct3504.FixmedinsHilistName // 定点医药机构目录名称
  2886. inputData["fixmedins_bchno"] = struct3504.FixmedinsBchno // 人员编号 (来自1101接口返回)
  2887. inputData["spler_name"] = struct3504.SplerName // 人员编号 (来自1101接口返回)
  2888. inputData["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  2889. inputData["manu_date"] = struct3504.ManuDate // 人员编号 (来自1101接口返回)
  2890. inputData["expy_end"] = struct3504.ExpyEnd // 人员编号 (来自1101接口返回)
  2891. inputData["finl_trns_pric"] = struct3504.FinlTrnsPric // 人员编号 (来自1101接口返回)
  2892. inputData["purc_retn_cnt"] = struct3504.PurcRetnCnt // 人员编号 (来自1101接口返回)
  2893. inputData["purc_invo_codg"] = struct3504.PurcInvoCodg // 人员编号 (来自1101接口返回)
  2894. inputData["purc_invo_no"] = struct3504.PurcInvoNo // 人员编号 (来自1101接口返回)
  2895. inputData["rx_flag"] = struct3504.RxFlag // 人员编号 (来自1101接口返回)
  2896. inputData["purc_retn_stoin_time"] = struct3504.PurcRetnStoinTime // 人员编号 (来自1101接口返回)
  2897. inputData["purc_retn_opter_name"] = struct3504.PurcRetnOpterName // 人员编号 (来自1101接口返回)
  2898. inputData["medins_prod_purc_no"] = "" // 人员编号 (来自1101接口返回)
  2899. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  2900. input["purcinfo"] = inputData
  2901. inputMessage["input"] = input //交易输入
  2902. argInputMessage := make(map[string]interface{})
  2903. argInputMessage["arg0"] = inputMessage
  2904. bytesData, err := json.Marshal(argInputMessage)
  2905. fmt.Println(string(bytesData))
  2906. if err != nil {
  2907. fmt.Println(err.Error())
  2908. return err.Error(), ""
  2909. }
  2910. struct3504.RequestUrl = struct3504.RequestUrl + "3504"
  2911. return AHHttpRequest(struct3504.RequestUrl, struct3504.AccessKey, struct3504.SecretKey, timestamp, string(bytesData), "3504"), string(bytesData)
  2912. }
  2913. //func AHyb3505(struct3505 models.Struct3505) (string, string) {
  2914. // timestamp := time.Now().Unix()
  2915. // // 生成输入报文
  2916. // inputMessage := SetAHInputMessage(timestamp, struct3505.OrgName, struct3505.Opter, struct3505.FixmedinsCode, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, struct3505.Cainfo)
  2917. // input := make(map[string]interface{})
  2918. // inputData := make(map[string]interface{})
  2919. // inputMessage["infno"] = "3505" // 交易编码
  2920. // inputData["med_list_codg"] = struct3505.MedListCodg // 定点医药机构目录编号
  2921. // inputData["fixmedins_hilist_id"] = struct3505.FixmedinsCode // 定点医药机构目录编号
  2922. // inputData["fixmedins_hilist_name"] = struct3505.OrgName // 定点医药机构目录名称
  2923. // inputData["fixmedins_bchno"] = struct3505.FixmedinsCode // 人员编号 (来自1101接口返回)
  2924. //
  2925. // inputData["prsc_dr_cert_type"] = struct3505.PrscDrCertType // 人员编号 (来自1101接口返回)
  2926. // inputData["prsc_dr_certno"] = struct3505.PrscDrCertno // 人员编号 (来自1101接口返回)
  2927. // inputData["prsc_dr_name"] = struct3505.PrscDrName // 人员编号 (来自1101接口返回)
  2928. // inputData["phar_cert_type"] = struct3505.PharCertType // 人员编号 (来自1101接口返回)
  2929. // inputData["phar_certno"] = struct3505.PharCertno // 人员编号 (来自1101接口返回)
  2930. //
  2931. // inputData["phar_name"] = struct3505.PharName // 人员编号 (来自1101接口返回)
  2932. // inputData["phar_prac_cert_no"] = struct3505.PharPracCertNo // 人员编号 (来自1101接口返回)
  2933. // inputData["hi_feesetl_type"] = struct3505.HiFeesetlType // 人员编号 (来自1101接口返回)
  2934. // inputData["setl_id"] = struct3505.SetlId // 人员编号 (来自1101接口返回)
  2935. // inputData["mdtrt_sn"] = struct3505.MdtrtSn // 人员编号 (来自1101接口返回)
  2936. // inputData["psn_no"] = struct3505.PsnNo // 人员编号 (来自1101接口返回)
  2937. // inputData["psn_cert_type"] = struct3505.PsnCertType // 人员编号 (来自1101接口返回)
  2938. // inputData["certno"] = struct3505.CertNo // 人员编号 (来自1101接口返回)
  2939. // inputData["psn_name"] = struct3505.PsnName // 人员编号 (来自1101接口返回)
  2940. // inputData["manu_lotnum"] = struct3505.ManuLotnum // 人员编号 (来自1101接口返回)
  2941. // inputData["manu_date"] = struct3505.ManuDate // 人员编号 (来自1101接口返回)
  2942. // inputData["expy_end"] = struct3505.ExpyEnd // 人员编号 (来自1101接口返回)
  2943. //
  2944. // inputData["rx_flag"] = struct3505.RxFlag // 人员编号 (来自1101接口返回)
  2945. // inputData["trdn_flag"] = struct3505.TrdnFlag // 人员编号 (来自1101接口返回)
  2946. //
  2947. // inputData["finl_trns_pric"] = struct3505.FinlTrnsPric // 人员编号 (来自1101接口返回)
  2948. // inputData["rxno"] = struct3505.Rxno // 人员编号 (来自1101接口返回)
  2949. // inputData["rx_circ_flag"] = struct3505.RxCircFlag // 人员编号 (来自1101接口返回)
  2950. //
  2951. // inputData["rtal_docno"] = struct3505.RtalDocno // 人员编号 (来自1101接口返回)
  2952. // inputData["stoout_no"] = struct3505.StooutNo // 人员编号 (来自1101接口返回)
  2953. //
  2954. // inputData["bchno"] = struct3505.Bchno // 人员编号 (来自1101接口返回)
  2955. // inputData["drug_trac_codg"] = struct3505.DrugTracCodg // 人员编号 (来自1101接口返回)
  2956. // inputData["drug_prod_barc"] = struct3505.DrugProdBarc // 人员编号 (来自1101接口返回)
  2957. // inputData["shelf_posi"] = struct3505.ShelfPosi // 人员编号 (来自1101接口返回)
  2958. // inputData["sel_retn_cnt"] = struct3505.SelRetnCnt // 人员编号 (来自1101接口返回)
  2959. // inputData["sel_retn_time"] = struct3505.SelRetnTime // 人员编号 (来自1101接口返回)
  2960. // inputData["sel_retn_opter_name"] = struct3505.SelRetnOpterName // 人员编号 (来自1101接口返回)
  2961. // inputData["memo"] = struct3505.Memo // 人员编号 (来自1101接口返回)
  2962. // input["selinfo"] = inputData
  2963. // inputMessage["input"] = input //交易输入
  2964. // argInputMessage := make(map[string]interface{})
  2965. // argInputMessage["arg0"] = inputMessage
  2966. // bytesData, err := json.Marshal(argInputMessage)
  2967. // fmt.Println(string(bytesData))
  2968. // if err != nil {
  2969. // fmt.Println(err.Error())
  2970. // return err.Error(), ""
  2971. // }
  2972. // struct3505.RequestUrl = struct3505.RequestUrl + "3505"
  2973. // return AHHttpRequest(struct3505.RequestUrl, struct3505.AccessKey, struct3505.SecretKey, timestamp, string(bytesData), "3505"), string(bytesData)
  2974. //
  2975. //}
  2976. func AHyb3506(struct3506 models.Struct3506) (string, string) {
  2977. timestamp := time.Now().Unix()
  2978. // 生成输入报文
  2979. inputMessage := SetAHInputMessage(timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsCode, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs, struct3506.Cainfo)
  2980. input := make(map[string]interface{})
  2981. inputData := make(map[string]interface{})
  2982. inputMessage["infno"] = "3506" // 交易编码
  2983. inputData["med_list_codg"] = struct3506.MedListCodg // 定点医药机构目录编号
  2984. inputData["fixmedins_hilist_id"] = struct3506.FixmedinsHilistId // 定点医药机构目录编号
  2985. inputData["fixmedins_hilist_name"] = struct3506.OrgName // 定点医药机构目录名称
  2986. inputData["fixmedins_bchno"] = struct3506.FixmedinsBchno // 人员编号 (来自1101接口返回)
  2987. inputData["setl_id"] = struct3506.SetlId // 人员编号 (来自1101接口返回)
  2988. inputData["psn_no"] = struct3506.PsnNo // 人员编号 (来自1101接口返回)
  2989. inputData["psn_cert_type"] = struct3506.PsnCertType // 人员编号 (来自1101接口返回)
  2990. inputData["certno"] = struct3506.Certno // 人员编号 (来自1101接口返回)
  2991. inputData["psn_name"] = struct3506.PsnName // 人员编号 (来自1101接口返回)
  2992. inputData["manu_lotnum"] = struct3506.ManuLotnum // 人员编号 (来自1101接口返回)
  2993. inputData["manu_date"] = struct3506.ManuDate // 人员编号 (来自1101接口返回)
  2994. inputData["expy_end"] = struct3506.ExpyEnd // 人员编号 (来自1101接口返回)
  2995. inputData["rx_flag"] = struct3506.RxFlag // 人员编号 (来自1101接口返回)
  2996. inputData["trdn_flag"] = struct3506.TrdnFlag // 人员编号 (来自1101接口返回)
  2997. inputData["finl_trns_pric"] = struct3506.FinlTrnsPric // 人员编号 (来自1101接口返回)
  2998. inputData["sel_retn_cnt"] = struct3506.SelRetnCnt // 人员编号 (来自1101接口返回)
  2999. inputData["sel_retn_time"] = struct3506.SelRetnTime // 人员编号 (来自1101接口返回)
  3000. inputData["sel_retn_opter_name"] = struct3506.SelRetnOpterName // 人员编号 (来自1101接口返回)
  3001. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  3002. inputData["medins_prod_sel_no"] = "" // 人员编号 (来自1101接口返回)
  3003. input["selinfo"] = inputData
  3004. inputMessage["input"] = input //交易输入
  3005. argInputMessage := make(map[string]interface{})
  3006. argInputMessage["arg0"] = inputMessage
  3007. bytesData, err := json.Marshal(argInputMessage)
  3008. fmt.Println(string(bytesData))
  3009. if err != nil {
  3010. fmt.Println(err.Error())
  3011. return err.Error(), ""
  3012. }
  3013. struct3506.RequestUrl = struct3506.RequestUrl + "3506"
  3014. return AHHttpRequest(struct3506.RequestUrl, struct3506.AccessKey, struct3506.SecretKey, timestamp, string(bytesData), "3506"), string(bytesData)
  3015. }
  3016. func AHyb3507(struct3507 models.Struct3507) (string, string) {
  3017. timestamp := time.Now().Unix()
  3018. // 生成输入报文
  3019. inputMessage := SetAHInputMessage(timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, struct3507.Cainfo)
  3020. input := make(map[string]interface{})
  3021. inputData := make(map[string]interface{})
  3022. inputMessage["infno"] = "3507" // 交易编码
  3023. inputData["fixmedins_bchno"] = struct3507.FixmedinsCode // 人员编号 (来自1101接口返回)
  3024. inputData["inv_data_type"] = struct3507.InvDataType // 人员编号 (来自1101接口返回)
  3025. input["data"] = inputData
  3026. inputMessage["input"] = input //交易输入
  3027. argInputMessage := make(map[string]interface{})
  3028. argInputMessage["arg0"] = inputMessage
  3029. bytesData, err := json.Marshal(argInputMessage)
  3030. fmt.Println(string(bytesData))
  3031. if err != nil {
  3032. fmt.Println(err.Error())
  3033. return err.Error(), ""
  3034. }
  3035. struct3507.RequestUrl = struct3507.RequestUrl + "3507"
  3036. return AHHttpRequest(struct3507.RequestUrl, struct3507.AccessKey, struct3507.SecretKey, timestamp, string(bytesData), "3507"), string(bytesData)
  3037. }
  3038. func AHyb3203(fixmedins_setl_cnt int64, acct_pay float64, fund_pay_sumamt float64, medfee_sumamt float64, stmt_begndate string, stmt_enddate string, setl_optins string, clr_type string, insutype string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, request_url string, access_key string, secret_key string, cainfo string) (string, string) {
  3039. // 生成签名
  3040. timestamp := time.Now().Unix()
  3041. // 生成输入报文
  3042. inputMessage := SetAHInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  3043. input := make(map[string]interface{})
  3044. inputData := make(map[string]interface{})
  3045. inputMessage["infno"] = "3203" // 交易编码
  3046. inputData["stmt_begndate"] = stmt_begndate // 对帐开始时间
  3047. inputData["stmt_enddate"] = stmt_enddate //对帐结束时间
  3048. inputData["medfee_sumamt"] = medfee_sumamt //医疗费总额
  3049. inputData["fund_pay_sumamt"] = fund_pay_sumamt //基金支付总额
  3050. inputData["acct_pay"] = acct_pay //个人账户支付金额
  3051. inputData["fixmedins_setl_cnt"] = fixmedins_setl_cnt //定点医药机构结算笔数
  3052. inputData["fixmedins_code"] = fixmedins_code //个人账户支付金额
  3053. input["data"] = inputData
  3054. inputMessage["input"] = input //交易输入
  3055. argInputMessage := make(map[string]interface{})
  3056. argInputMessage["arg0"] = inputMessage
  3057. bytesData, err := json.Marshal(argInputMessage)
  3058. fmt.Println(string(bytesData))
  3059. if err != nil {
  3060. fmt.Println(err.Error())
  3061. return err.Error(), ""
  3062. }
  3063. request_url = request_url + "3203"
  3064. return AHHttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData), "3203"), string(bytesData)
  3065. }
  3066. func AHyb3505(struct3505 models.Struct3505, secret_key string,request_url string) (string, string) {
  3067. // 生成签名
  3068. //nonce := GetRandomString(32)
  3069. timestamp := time.Now().Unix()
  3070. //signature := setSignature(timestamp, nonce, secret_key)
  3071. // 生成输入报文
  3072. inputMessage := SetAHInputMessage(timestamp, struct3505.OrgName, struct3505.Opter, struct3505.Code, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, struct3505.Cainfo)
  3073. input := make(map[string]interface{})
  3074. inputData := make(map[string]interface{})
  3075. inputMessage["infno"] = "3505" // 交易编码
  3076. inputData["med_list_codg"] = struct3505.MedListCodg // 定点医药机构目录编号
  3077. inputData["fixmedins_hilist_id"] = struct3505.FixmedinsHilistId // 定点医药机构目录编号
  3078. inputData["fixmedins_hilist_name"] = struct3505.FixmedinsHilistName // 定点医药机构目录名称
  3079. inputData["fixmedins_bchno"] = struct3505.FixmedinsBchno // 人员编号 (来自1101接口返回)
  3080. inputData["prsc_dr_cert_type"] = struct3505.PrscDrCertType // 人员编号 (来自1101接口返回)
  3081. inputData["prsc_dr_certno"] = struct3505.PrscDrCertno // 人员编号 (来自1101接口返回)
  3082. inputData["prsc_dr_name"] = struct3505.PrscDrName // 人员编号 (来自1101接口返回)
  3083. inputData["phar_cert_type"] = struct3505.PharCertType // 人员编号 (来自1101接口返回)
  3084. inputData["phar_certno"] = struct3505.PharCertno // 人员编号 (来自1101接口返回)
  3085. inputData["phar_name"] = struct3505.PharName // 人员编号 (来自1101接口返回)
  3086. inputData["phar_prac_cert_no"] = struct3505.PharPracCertNo // 人员编号 (来自1101接口返回)
  3087. inputData["hi_feesetl_type"] = struct3505.HiFeesetlType // 人员编号 (来自1101接口返回)
  3088. inputData["setl_id"] = struct3505.SetlId // 人员编号 (来自1101接口返回)
  3089. inputData["mdtrt_sn"] = struct3505.MdtrtSn // 人员编号 (来自1101接口返回)
  3090. inputData["psn_no"] = struct3505.PsnNo // 人员编号 (来自1101接口返回)
  3091. inputData["psn_cert_type"] = struct3505.PsnCertType // 人员编号 (来自1101接口返回)
  3092. inputData["certno"] = struct3505.CertNo // 人员编号 (来自1101接口返回)
  3093. inputData["psn_name"] = struct3505.PsnName // 人员编号 (来自1101接口返回)
  3094. inputData["manu_lotnum"] = struct3505.ManuLotnum // 人员编号 (来自1101接口返回)
  3095. inputData["manu_date"] = struct3505.ManuDate // 人员编号 (来自1101接口返回)
  3096. inputData["expy_end"] = struct3505.ExpyEnd // 人员编号 (来自1101接口返回)
  3097. inputData["rx_flag"] = struct3505.RxFlag // 人员编号 (来自1101接口返回)
  3098. inputData["trdn_flag"] = struct3505.TrdnFlag // 人员编号 (来自1101接口返回)
  3099. inputData["finl_trns_pric"] = struct3505.FinlTrnsPric // 人员编号 (来自1101接口返回)
  3100. inputData["rxno"] = struct3505.Rxno // 人员编号 (来自1101接口返回)
  3101. inputData["rx_circ_flag"] = struct3505.RxCircFlag // 人员编号 (来自1101接口返回)
  3102. inputData["rtal_docno"] = struct3505.RtalDocno // 人员编号 (来自1101接口返回)
  3103. inputData["stoout_no"] = struct3505.StooutNo // 人员编号 (来自1101接口返回)
  3104. inputData["bchno"] = struct3505.Bchno // 人员编号 (来自1101接口返回)
  3105. inputData["drug_trac_codg"] = struct3505.DrugTracCodg // 人员编号 (来自1101接口返回)
  3106. inputData["drug_prod_barc"] = struct3505.DrugProdBarc // 人员编号 (来自1101接口返回)
  3107. inputData["shelf_posi"] = struct3505.ShelfPosi // 人员编号 (来自1101接口返回)
  3108. inputData["sel_retn_cnt"] = struct3505.SelRetnCnt // 人员编号 (来自1101接口返回)
  3109. inputData["sel_retn_time"] = struct3505.SelRetnTime // 人员编号 (来自1101接口返回)
  3110. inputData["sel_retn_opter_name"] = struct3505.SelRetnOpterName // 人员编号 (来自1101接口返回)
  3111. inputData["mdtrt_setl_type"] = struct3505.MdtrtSetlType // 人员编号 (来自1101接口返回)
  3112. inputData["memo"] = struct3505.Memo // 人员编号 (来自1101接口返回)
  3113. //input["selinfo"] = inputData
  3114. feedetail := make([]map[string]interface{}, 0)
  3115. codes := strings.Split(struct3505.DrugTracCodg, ",")
  3116. for _, item := range codes {
  3117. druginputData := make(map[string]interface{})
  3118. druginputData["drug_trac_codg"] = item
  3119. feedetail = append(feedetail, druginputData)
  3120. }
  3121. inputData["drugtracinfo"] = feedetail
  3122. input["selinfo"] = inputData
  3123. inputMessage["input"] = input //交易输入
  3124. argInputMessage := make(map[string]interface{})
  3125. argInputMessage["arg0"] = inputMessage
  3126. bytesData, err := json.Marshal(argInputMessage)
  3127. fmt.Println(string(bytesData))
  3128. if err != nil {
  3129. fmt.Println(err.Error())
  3130. return err.Error(), ""
  3131. }
  3132. reader := bytes.NewReader(bytesData)
  3133. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  3134. //gdyb_url := beego.AppConfig.String("gdyb_url")
  3135. //gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3136. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3137. //url := gdyb_url + "3505"
  3138. request_url = request_url + "1101"
  3139. request, err := http.NewRequest("POST", request_url, reader)
  3140. if err != nil {
  3141. fmt.Println(err.Error())
  3142. return err.Error(), ""
  3143. }
  3144. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3145. client := http.Client{}
  3146. resp, err := client.Do(request)
  3147. if err != nil {
  3148. fmt.Println(err.Error())
  3149. return err.Error(), ""
  3150. }
  3151. respBytes, err := ioutil.ReadAll(resp.Body)
  3152. if err != nil {
  3153. fmt.Println(err.Error())
  3154. return err.Error(), ""
  3155. }
  3156. str := string(respBytes)
  3157. fmt.Println(str)
  3158. return str , string(bytesData)
  3159. }