hn_service.go 104KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122
  1. package service
  2. import (
  3. //"bytes"
  4. "encoding/json"
  5. "fmt"
  6. "gdyb/models"
  7. "gdyb/utils/csbhttp"
  8. //"net/http"
  9. "strconv"
  10. "time"
  11. )
  12. // 人员基本信息
  13. func Hnyb1101(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, cainfo string, name string, mdtrt_cert_no string) (string, string) {
  14. timestamp := time.Now().Unix()
  15. //生成输入报文
  16. inputMessage := SetHnInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  17. input := make(map[string]interface{})
  18. inputData := make(map[string]interface{})
  19. inputMessage["infno"] = "1101" // 交易编码
  20. if certificates == "3" {
  21. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  22. inputData["certno"] = certNo // 证件号码
  23. inputData["psn_cert_type"] = "99" // 人员证件类型
  24. inputData["mdtrt_cert_no"] = mdtrt_cert_no // 就诊凭证编号
  25. } else {
  26. if id_card_type == 1 {
  27. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  28. inputData["card_sn"] = card_sn // 卡识别码
  29. inputData["certno"] = certNo // 证件号码
  30. inputData["psn_cert_type"] = "01" // 人员证件类型
  31. inputData["mdtrt_cert_no"] = mdtrt_cert_no // 就诊凭证编号
  32. } else if id_card_type == 2 {
  33. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  34. inputData["card_sn"] = "" // 卡识别码
  35. inputData["certno"] = certNo // 证件号码
  36. inputData["psn_cert_type"] = "01" // 人员证件类型
  37. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  38. }
  39. }
  40. inputData["begntime"] = "" // 开始时间
  41. inputData["psn_name"] = name // 人员姓名
  42. input["data"] = inputData
  43. inputMessage["input"] = input //交易输入
  44. var inputLog string
  45. bytesData, _ := json.Marshal(inputMessage)
  46. inputLog = string(bytesData)
  47. fmt.Println(string(bytesData))
  48. if err != nil {
  49. fmt.Println(err.Error())
  50. return err.Error(), ""
  51. }
  52. request_url = request_url + "1101"
  53. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  54. return HNHttpRequest(request_url, access_key, secret_key, timestamp2, string(bytesData), "1101"), inputLog
  55. }
  56. //人员基本信息版本2
  57. func Hnybyb1101A(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, pBusiCardInfo string, id_card_no string, cainfo string) (string, string) {
  58. timestamp := time.Now().Unix()
  59. //生成输入报文
  60. inputMessage := SetHnInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  61. input := make(map[string]interface{})
  62. inputData := make(map[string]interface{})
  63. inputMessage["infno"] = "1101" // 交易编码
  64. if certificates == "3" {
  65. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  66. inputData["certno"] = certNo // 证件号码
  67. inputData["psn_cert_type"] = "99" // 人员证件类型
  68. } else {
  69. if id_card_type == 1 {
  70. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  71. inputData["card_sn"] = card_sn // 卡识别码
  72. inputData["certno"] = id_card_no // 证件号码
  73. inputData["psn_cert_type"] = "01" // 人员证件类型
  74. } else {
  75. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  76. inputData["card_sn"] = "" // 卡识别码
  77. inputData["certno"] = certNo // 证件号码
  78. inputData["psn_cert_type"] = "01" // 人员证件类型
  79. }
  80. }
  81. inputData["mdtrt_cert_no"] = certNo + "|" + pBusiCardInfo // 就诊凭证编号
  82. inputData["begntime"] = "" // 开始时间
  83. inputData["psn_name"] = "" // 人员姓名
  84. input["data"] = inputData
  85. inputMessage["input"] = input //交易输入
  86. var inputLog string
  87. bytesData, _ := json.Marshal(inputMessage)
  88. inputLog = string(bytesData)
  89. fmt.Println(string(bytesData))
  90. if err != nil {
  91. fmt.Println(err.Error())
  92. return err.Error(), ""
  93. }
  94. request_url = request_url + "1101"
  95. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  96. return HNHttpRequest(request_url, access_key, secret_key, timestamp2, string(bytesData), "1101"), inputLog
  97. }
  98. func Hnyb1101B(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) {
  99. timestamp := time.Now().Unix()
  100. //生成输入报文
  101. inputMessage := SetHnInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  102. input := make(map[string]interface{})
  103. inputData := make(map[string]interface{})
  104. inputMessage["infno"] = "1101" // 交易编码
  105. inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
  106. inputData["card_sn"] = "" // 卡识别码
  107. inputData["certno"] = "" // 证件号码
  108. inputData["psn_cert_type"] = "01" // 人员证件类型
  109. inputData["mdtrt_cert_no"] = id_card_no + "|" + Token // 就诊凭证编号
  110. inputData["begntime"] = "" // 开始时间
  111. inputData["psn_name"] = "" // 人员姓名
  112. input["data"] = inputData
  113. inputMessage["input"] = input //交易输入
  114. var inputLog string
  115. bytesData, _ := json.Marshal(inputMessage)
  116. inputLog = string(bytesData)
  117. fmt.Println(string(bytesData))
  118. if err != nil {
  119. fmt.Println(err.Error())
  120. return err.Error(), ""
  121. }
  122. request_url = request_url + "1101"
  123. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  124. return HNHttpRequest(request_url, access_key, secret_key, timestamp2, string(bytesData), "1101"), inputLog
  125. }
  126. func Hnyb1101ForEleCert(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) {
  127. timestamp := time.Now().Unix()
  128. //生成输入报文
  129. inputMessage := SetHnInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  130. input := make(map[string]interface{})
  131. inputData := make(map[string]interface{})
  132. inputMessage["infno"] = "1101" // 交易编码
  133. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  134. inputData["card_sn"] = "" // 卡识别码
  135. inputData["certno"] = id_card_no // 证件号码
  136. inputData["psn_cert_type"] = "01" // 人员证件类型
  137. inputData["mdtrt_cert_no"] = Token // 就诊凭证编号
  138. inputData["begntime"] = "" // 开始时间
  139. inputData["psn_name"] = name // 人员姓名
  140. input["data"] = inputData
  141. inputMessage["input"] = input //交易输入
  142. var inputLog string
  143. bytesData, _ := json.Marshal(inputMessage)
  144. inputLog = string(bytesData)
  145. fmt.Println(string(bytesData))
  146. if err != nil {
  147. fmt.Println(err.Error())
  148. return err.Error(), ""
  149. }
  150. request_url = request_url + "1101"
  151. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  152. return HNHttpRequest(request_url, access_key, secret_key, timestamp2, string(bytesData), "1101"), inputLog
  153. }
  154. // 门诊挂号
  155. func Hnyb2201(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) {
  156. fmt.Println(opera)
  157. // 生成签名
  158. timestamp := time.Now().Unix()
  159. tempTime := time.Unix(timestamp, 0)
  160. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  161. // 生成输入报文
  162. inputMessage := SetHnInputMessage(timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  163. input := make(map[string]interface{})
  164. inputData := make(map[string]interface{})
  165. inputMessage["infno"] = "2201" // 交易编码
  166. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  167. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  168. inputData["begntime"] = timeFormatOne // 开始时间
  169. if id_card_type == 1 {
  170. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  171. inputData["card_sn"] = card_sn // 卡识别码
  172. inputData["certno"] = certNo // 证件号码
  173. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  174. } else if id_card_type == 3 {
  175. inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
  176. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  177. } else if id_card_type == 4 {
  178. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  179. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  180. } else {
  181. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  182. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  183. }
  184. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  185. inputData["atddr_no"] = doctor_id // 医师编码
  186. inputData["dr_name"] = doctor_name // 医师姓名
  187. inputData["dept_code"] = dept_code // 科室编码
  188. inputData["dept_name"] = dept // 科室名称
  189. inputData["caty"] = "A03.06" // 科别
  190. inputData["exp_content"] = "" //
  191. input["data"] = inputData
  192. inputMessage["input"] = input //交易输入
  193. var requestLog string
  194. bytesData, err := json.Marshal(inputMessage)
  195. requestLog = string(bytesData)
  196. fmt.Println(string(bytesData))
  197. if err != nil {
  198. fmt.Println(err.Error())
  199. return err.Error(), ""
  200. }
  201. request_url = request_url + "2201"
  202. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  203. return HNHttpRequest(request_url, access_key, secret_key, timestamp2, string(bytesData), "2201"), requestLog
  204. }
  205. // 门诊挂号撤销
  206. func Hnyb2202(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) {
  207. // 生成签名
  208. timestamp := time.Now().Unix()
  209. // 生成输入报文
  210. inputMessage := SetHnInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  211. input := make(map[string]interface{})
  212. inputData := make(map[string]interface{})
  213. inputMessage["infno"] = "2202" // 交易编码
  214. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  215. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  216. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  217. //inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
  218. inputData["exp_content"] = "" //
  219. input["data"] = inputData
  220. inputMessage["input"] = input //交易输入
  221. var requestLog string
  222. bytesData, err := json.Marshal(inputMessage)
  223. fmt.Println(string(bytesData))
  224. requestLog = string(bytesData)
  225. if err != nil {
  226. fmt.Println(err.Error())
  227. return err.Error(), ""
  228. }
  229. request_url = request_url + "2202"
  230. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  231. //fmt.Println(HttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData)))
  232. return HNHttpRequest(request_url, access_key, secret_key, timestamp2, string(bytesData), "2202"), requestLog
  233. }
  234. // 门诊就诊信息上传
  235. func Hnyb2203(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, begin_time string, cainfo string) (string, string, int64) {
  236. // 生成签名
  237. timestamp := time.Now().Unix()
  238. tempTime := time.Unix(timestamp, 0)
  239. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  240. // 生成输入报文
  241. inputMessage := SetHnInputMessage(timestamp, org_name, dept, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  242. input := make(map[string]interface{})
  243. inputData := make(map[string]interface{})
  244. diseinfo := make([]map[string]interface{}, 0)
  245. if med_type == "1111" || med_type == "1112" {
  246. med_type = "11"
  247. }
  248. inputMessage["infno"] = "2203" // 交易编码
  249. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  250. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  251. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  252. inputData["begntime"] = begin_time // 开始时间
  253. inputData["main_cond_dscr"] = "" // 主要病情描述
  254. inputData["dise_codg"] = sick_code // 病种编码
  255. inputData["dise_name"] = sick_name // 病种名称
  256. inputData["birctrl_type"] = "" // 计划生育手术类别
  257. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  258. for index, item := range config {
  259. diseinfo_sun := make(map[string]interface{})
  260. diseinfo_sun["diag_type"] = "1" // 诊断类别
  261. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  262. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  263. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  264. diseinfo_sun["diag_dept"] = department // 诊断科室
  265. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  266. diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  267. diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  268. diseinfo_sun["vali_flag"] = "1" // 有效标志
  269. diseinfo = append(diseinfo, diseinfo_sun)
  270. }
  271. //inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
  272. inputData["exp_content"] = "" //
  273. input["diseinfo"] = diseinfo
  274. input["mdtrtinfo"] = inputData
  275. inputMessage["input"] = input //交易输入
  276. var requestLog string
  277. bytesData, err := json.Marshal(inputMessage)
  278. fmt.Println(string(bytesData))
  279. requestLog = string(bytesData)
  280. if err != nil {
  281. fmt.Println(err.Error())
  282. return err.Error(), "", 0
  283. }
  284. request_url = request_url + "2203"
  285. //fmt.Println(HttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData)))
  286. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  287. return HNHttpRequest(request_url, access_key, secret_key, timestamp2, string(bytesData), "2203"), requestLog, timestamp
  288. }
  289. // 门诊就诊信息上传
  290. func Hnyb2203A(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) {
  291. // 生成签名
  292. timestamp := time.Now().Unix()
  293. tempTime := time.Unix(timestamp, 0)
  294. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  295. // 生成输入报文
  296. inputMessage := SetHnInputMessage(timestamp, org_name, dept, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  297. input := make(map[string]interface{})
  298. inputData := make(map[string]interface{})
  299. diseinfo := make([]map[string]interface{}, 0)
  300. if med_type == "1111" || med_type == "1112" {
  301. med_type = "11"
  302. }
  303. inputMessage["infno"] = "2203" // 交易编码
  304. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  305. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  306. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  307. inputData["begntime"] = timeFormatOne // 开始时间
  308. inputData["main_cond_dscr"] = "" // 主要病情描述
  309. inputData["dise_codg"] = sick_code // 病种编码
  310. inputData["dise_name"] = sick_name // 病种名称
  311. inputData["birctrl_type"] = "" // 计划生育手术类别
  312. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  313. inputData["matn_type"] = "" // 生育类别
  314. inputData["geso_val"] = "" // 孕周数
  315. for index, item := range config {
  316. diseinfo_sun := make(map[string]interface{})
  317. diseinfo_sun["diag_type"] = "1" // 诊断类别
  318. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  319. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  320. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  321. diseinfo_sun["diag_dept"] = department // 诊断科室
  322. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  323. diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  324. diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  325. diseinfo_sun["vali_flag"] = "1" // 有效标志
  326. diseinfo = append(diseinfo, diseinfo_sun)
  327. }
  328. input["diseinfo"] = diseinfo
  329. input["mdtrtinfo"] = inputData
  330. inputMessage["input"] = input //交易输入
  331. var requestLog string
  332. bytesData, err := json.Marshal(inputMessage)
  333. fmt.Println(string(bytesData))
  334. requestLog = string(bytesData)
  335. if err != nil {
  336. fmt.Println(err.Error())
  337. return err.Error(), ""
  338. }
  339. request_url = request_url + "2203"
  340. //fmt.Println(HttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData)))
  341. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  342. return HNHttpRequest(request_url, access_key, secret_key, timestamp2, string(bytesData), "2203"), requestLog
  343. }
  344. // 门诊费用明细信息上传
  345. func Hnyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescription, chrg_bchno string, org_name string, doctor string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, balance_accounts_type string, diag_code string, request_url string, access_key string, new_doctor_name string, time_stamp_2203 string, cainfo string) (string, string) {
  346. // 生成签名
  347. //timestamp := time.Now().Unix()
  348. //timestamp := time.Now().Unix()
  349. timestamp2 := time.Now().Unix()
  350. tempTime := time.Unix(timestamp2, 0)
  351. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  352. var customs []*Custom
  353. for _, item := range hisPrescription {
  354. //tm := time.Unix(item.PreTime, 0)
  355. if item.Type == 1 { //药品
  356. for _, subItem := range item.HisDoctorAdviceInfo {
  357. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  358. //var randNum int
  359. //randNum = rand.Intn(10000) + 1000
  360. cus := &Custom{
  361. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  362. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  363. FeedetlSn: subItem.FeedetlSn,
  364. Price: fmt.Sprintf("%.4f", subItem.Price),
  365. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  366. HospApprFlag: subItem.HospApprFlag,
  367. DoctorNumber: doctor_id,
  368. DoctorName: new_doctor_name,
  369. ProvinceDrugMedListCodg: "",
  370. ProvinceGoodMedListCodg: "",
  371. FeeOcurTime: timeFormatOne,
  372. }
  373. if subItem.BaseDrugLib.DrugClassify == "2" {
  374. cus.ProvinceDrugMedListCodg = subItem.BaseDrugLib.ProvincesCode
  375. }
  376. customs = append(customs, cus)
  377. }
  378. }
  379. }
  380. if item.Type == 2 { //项目
  381. for _, subItem := range item.HisPrescriptionProject {
  382. //var randNum int
  383. //randNum = rand.Intn(10000) + 1000
  384. if subItem.Type == 2 {
  385. if len(subItem.HisProject.MedicalCode) > 0 {
  386. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  387. cus := &Custom{
  388. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  389. Cut: fmt.Sprintf("%.4f", cnt),
  390. FeedetlSn: subItem.FeedetlSn,
  391. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  392. MedListCodg: subItem.HisProject.MedicalCode,
  393. DoctorNumber: doctor_id,
  394. DoctorName: new_doctor_name,
  395. HospApprFlag: -1,
  396. ProvinceDrugMedListCodg: "",
  397. ProvinceGoodMedListCodg: "",
  398. FeeOcurTime: timeFormatOne,
  399. }
  400. customs = append(customs, cus)
  401. }
  402. } else if subItem.Type == 3 {
  403. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  404. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  405. cus := &Custom{
  406. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  407. Cut: fmt.Sprintf("%.4f", cnt),
  408. FeedetlSn: subItem.FeedetlSn,
  409. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  410. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  411. HospApprFlag: -1,
  412. DoctorNumber: doctor_id,
  413. DoctorName: new_doctor_name,
  414. ProvinceDrugMedListCodg: "",
  415. ProvinceGoodMedListCodg: subItem.GoodInfo.ProvincesCode,
  416. FeeOcurTime: timeFormatOne,
  417. }
  418. customs = append(customs, cus)
  419. }
  420. }
  421. }
  422. }
  423. for _, subItem := range item.HisAdditionalCharge {
  424. if len(subItem.XtHisAddtionConfig.Code) > 0 {
  425. cus := &Custom{
  426. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
  427. Cut: fmt.Sprintf("%.4f", float64(subItem.Count)),
  428. FeedetlSn: subItem.FeedetlSn,
  429. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  430. MedListCodg: subItem.XtHisAddtionConfig.Code,
  431. HospApprFlag: -1,
  432. DoctorNumber: doctor_id,
  433. DoctorName: new_doctor_name,
  434. }
  435. customs = append(customs, cus)
  436. }
  437. }
  438. }
  439. // 生成输入报文
  440. inputMessage := SetHnInputMessage(timestamp2, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  441. input := make(map[string]interface{})
  442. feedetail := make([]map[string]interface{}, 0)
  443. inputMessage["infno"] = "2204" // 交易编码
  444. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  445. for _, item := range customs {
  446. feedetailInfo := make(map[string]interface{})
  447. subfeedetailInfo := make(map[string]interface{})
  448. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  449. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  450. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  451. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  452. feedetailInfo["dise_codg"] = diag_code // 病种编码
  453. feedetailInfo["rxno"] = "" // 处方号
  454. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  455. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  456. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  457. feedetailInfo["medins_list_codg"] = item.MedListCodg // 医药机构目录编码
  458. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  459. feedetailInfo["cnt"] = item.Cut // 数量
  460. feedetailInfo["pric"] = item.Price // 单价
  461. feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
  462. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  463. feedetailInfo["prd_days"] = "0" // 周期天数
  464. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  465. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  466. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  467. feedetailInfo["bilg_dr_codg"] = item.DoctorNumber // 开单医生编码
  468. feedetailInfo["bilg_dr_name"] = item.DoctorName // 开单医师姓名
  469. feedetailInfo["acord_dept_codg"] = "" // 受单科室编码
  470. feedetailInfo["acord_dept_name"] = "" // 受单科室名称
  471. feedetailInfo["orders_dr_code"] = "" // 受单医生编码
  472. feedetailInfo["orders_dr_name"] = "" // 受单医生姓名
  473. if balance_accounts_type == "8" {
  474. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  475. } else {
  476. if item.HospApprFlag != -1 {
  477. if item.HospApprFlag == 1 {
  478. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  479. } else if item.HospApprFlag == 2 {
  480. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  481. } else if item.HospApprFlag == 3 {
  482. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  483. } else {
  484. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  485. }
  486. } else {
  487. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  488. }
  489. }
  490. feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  491. feedetailInfo["etip_flag"] = "" // 外检标志
  492. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  493. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  494. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  495. subfeedetailInfo["tcmherb_prov_code"] = item.ProvinceDrugMedListCodg
  496. subfeedetailInfo["mcs_prov_code"] = item.ProvinceGoodMedListCodg
  497. feedetailInfo["exp_content"] = subfeedetailInfo
  498. feedetail = append(feedetail, feedetailInfo)
  499. }
  500. input["feedetail"] = feedetail
  501. inputMessage["input"] = input //交易输入
  502. var requestLog string
  503. bytesData, err := json.Marshal(inputMessage)
  504. requestLog = string(bytesData)
  505. fmt.Println(string(bytesData))
  506. if err != nil {
  507. fmt.Println(err.Error())
  508. return "", ""
  509. }
  510. request_url = request_url + "2204"
  511. //fmt.Println(HNHttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData)))
  512. timestamp5 := time.Now().UnixNano() / int64(time.Millisecond)
  513. return HNHttpRequest(request_url, access_key, secret_key, timestamp5, string(bytesData), "2204"), requestLog
  514. }
  515. // 门诊费用明细信息撤销
  516. func Hnyb2205(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) {
  517. timestamp := time.Now().Unix()
  518. // 生成输入报文
  519. inputMessage := SetHnInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  520. input := make(map[string]interface{})
  521. inputData := make(map[string]interface{})
  522. inputMessage["infno"] = "2205" // 交易编码
  523. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  524. inputData["chrg_bchno"] = "0000" // 收费批次号(来自2204生成的)
  525. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  526. inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
  527. input["data"] = inputData
  528. inputMessage["input"] = input //交易输入
  529. bytesData, err := json.Marshal(inputMessage)
  530. fmt.Println(string(bytesData))
  531. var requestLog string
  532. requestLog = string(bytesData)
  533. if err != nil {
  534. fmt.Println(err.Error())
  535. return err.Error(), ""
  536. }
  537. request_url = request_url + "2205"
  538. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  539. return HNHttpRequest(request_url, access_key, secret_key, timestamp2, string(bytesData), "2205"), requestLog
  540. }
  541. // 门诊预结算
  542. func Hnyb2206(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, acct_used_flag string) (string, string) {
  543. // 生成签名
  544. timestamp := time.Now().Unix() // inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  545. // inputData["mdtrt_cert_no"] = certNo
  546. // 生成输入报文
  547. inputMessage := SetHnInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  548. input := make(map[string]interface{})
  549. inputData := make(map[string]interface{})
  550. inputMessage["infno"] = "2206" // 交易编码
  551. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  552. if certificates == 3 {
  553. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  554. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  555. } else {
  556. if id_card_type == 1 {
  557. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  558. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  559. } else if id_card_type == 3 {
  560. inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
  561. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  562. } else if id_card_type == 4 {
  563. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  564. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  565. } else {
  566. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  567. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  568. }
  569. }
  570. if insuplc_admdvs == "421300" {
  571. if med_type == "11" || med_type == "1112" || med_type == "1111" {
  572. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  573. } else if med_type == "14" {
  574. inputData["med_type"] = "140110" // 医疗类别 11 普通门诊 12 门诊挂号
  575. }
  576. } else {
  577. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  578. }
  579. inputData["medfee_sumamt"] = total // 医疗费总额
  580. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  581. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  582. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  583. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  584. inputData["insutype"] = insutype // 险种类型
  585. inputData["invono"] = "" // 发票号
  586. inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
  587. input["data"] = inputData
  588. inputMessage["input"] = input //交易输入
  589. var requestLog string
  590. bytesData, err := json.Marshal(inputMessage)
  591. requestLog = string(bytesData)
  592. fmt.Println(string(bytesData))
  593. if err != nil {
  594. fmt.Println(err.Error())
  595. return err.Error(), ""
  596. }
  597. request_url = request_url + "2206"
  598. //fmt.Println(HNHttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData)))
  599. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  600. return HNHttpRequest(request_url, access_key, secret_key, timestamp2, string(bytesData), "2206"), requestLog
  601. }
  602. // 门诊预结算
  603. func Hnyb2206Two(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, acct_used_flag string) (string, string) {
  604. // 生成签名
  605. timestamp := time.Now().Unix() // inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  606. // inputData["mdtrt_cert_no"] = certNo
  607. // 生成输入报文
  608. inputMessage := SetHnInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  609. input := make(map[string]interface{})
  610. inputData := make(map[string]interface{})
  611. inputMessage["infno"] = "2206" // 交易编码
  612. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  613. if certificates == 3 {
  614. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  615. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  616. } else {
  617. if id_card_type == 1 {
  618. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  619. inputData["card_sn"] = card_sn // 卡识别码
  620. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  621. } else if id_card_type == 3 {
  622. inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
  623. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  624. } else if id_card_type == 4 {
  625. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  626. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  627. } else {
  628. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  629. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  630. }
  631. }
  632. if insuplc_admdvs == "421300" {
  633. if med_type == "11" || med_type == "1112" || med_type == "1111" {
  634. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  635. } else if med_type == "14" {
  636. inputData["med_type"] = "140110" // 医疗类别 11 普通门诊 12 门诊挂号
  637. }
  638. } else {
  639. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  640. }
  641. inputData["medfee_sumamt"] = total // 医疗费总额
  642. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  643. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  644. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  645. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  646. inputData["insutype"] = insutype // 险种类型
  647. inputData["invono"] = "" // 发票号
  648. inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
  649. input["data"] = inputData
  650. inputMessage["input"] = input //交易输入
  651. var requestLog string
  652. bytesData, err := json.Marshal(inputMessage)
  653. requestLog = string(bytesData)
  654. fmt.Println(string(bytesData))
  655. if err != nil {
  656. fmt.Println(err.Error())
  657. return err.Error(), ""
  658. }
  659. request_url = request_url + "2206"
  660. //fmt.Println(HNHttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData)))
  661. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  662. return HNHttpRequest(request_url, access_key, secret_key, timestamp2, string(bytesData), "2206"), requestLog
  663. }
  664. // 门诊结算
  665. func Hnyb2207(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) (string, string) {
  666. // 生成签名
  667. timestamp := time.Now().Unix()
  668. // 生成输入报文
  669. inputMessage := SetHnInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  670. input := make(map[string]interface{})
  671. inputData := make(map[string]interface{})
  672. inputMessage["infno"] = "2207" // 交易编码
  673. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  674. if id_card_type == 1 {
  675. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  676. inputData["mdtrt_cert_no"] = certNo + "|" + verify_number // 就诊凭证编号
  677. } else if id_card_type == 3 {
  678. inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
  679. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  680. } else if id_card_type == 4 {
  681. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  682. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  683. } else {
  684. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  685. inputData["mdtrt_cert_no"] = certNo
  686. }
  687. if med_type == "1111" || med_type == "1112" {
  688. med_type = "11"
  689. }
  690. if insuplc_admdvs == "421300" {
  691. if med_type == "11" {
  692. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  693. } else if med_type == "14" {
  694. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  695. }
  696. } else {
  697. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  698. }
  699. inputData["medfee_sumamt"] = total // 医疗费总额
  700. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  701. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  702. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  703. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  704. inputData["insutype"] = insutype // 险种类型
  705. inputData["invono"] = "" // 发票号
  706. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  707. inputData["overlmt_selfpay"] = overlmt_selfpay //
  708. inputData["preselfpay_amt"] = preselfpay_amt //
  709. inputData["inscp_scp_amt"] = inscp_scp_amt //
  710. inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
  711. input["data"] = inputData
  712. inputMessage["input"] = input //交易输入
  713. bytesData, err := json.Marshal(inputMessage)
  714. fmt.Println(string(bytesData))
  715. if err != nil {
  716. fmt.Println(err.Error())
  717. return err.Error(), ""
  718. }
  719. request_url = request_url + "2207"
  720. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  721. return HNHttpRequest(request_url, access_key, secret_key, timestamp2, string(bytesData), "2207"), string(bytesData)
  722. }
  723. // 门诊结算
  724. func Hnyb2207Two(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) {
  725. // 生成签名
  726. timestamp := time.Now().Unix()
  727. // 生成输入报文
  728. inputMessage := SetHnInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  729. input := make(map[string]interface{})
  730. inputData := make(map[string]interface{})
  731. inputMessage["infno"] = "2207" // 交易编码
  732. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  733. if id_card_type == 1 {
  734. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  735. inputData["card_sn"] = card_sn // 卡识别码
  736. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  737. } else if id_card_type == 3 {
  738. inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
  739. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  740. } else if id_card_type == 4 {
  741. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  742. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  743. } else {
  744. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  745. inputData["mdtrt_cert_no"] = certNo
  746. }
  747. if med_type == "1111" || med_type == "1112" {
  748. med_type = "11"
  749. }
  750. if insuplc_admdvs == "421300" {
  751. if med_type == "11" {
  752. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  753. } else if med_type == "14" {
  754. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  755. }
  756. } else {
  757. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  758. }
  759. inputData["medfee_sumamt"] = total // 医疗费总额
  760. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  761. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  762. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  763. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  764. inputData["insutype"] = insutype // 险种类型
  765. inputData["invono"] = "" // 发票号
  766. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  767. inputData["overlmt_selfpay"] = overlmt_selfpay //
  768. inputData["preselfpay_amt"] = preselfpay_amt //
  769. inputData["inscp_scp_amt"] = inscp_scp_amt //
  770. inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
  771. input["data"] = inputData
  772. inputMessage["input"] = input //交易输入
  773. bytesData, err := json.Marshal(inputMessage)
  774. fmt.Println(string(bytesData))
  775. if err != nil {
  776. fmt.Println(err.Error())
  777. return err.Error(), ""
  778. }
  779. request_url = request_url + "2207"
  780. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  781. return HNHttpRequest(request_url, access_key, secret_key, timestamp2, string(bytesData), "2207"), string(bytesData)
  782. }
  783. func Hnyb2207A(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) {
  784. // 生成签名
  785. timestamp := time.Now().Unix()
  786. // 生成输入报文
  787. inputMessage := SetHnInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  788. input := make(map[string]interface{})
  789. inputData := make(map[string]interface{})
  790. inputMessage["infno"] = "2207A" // 交易编码
  791. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  792. if certificates == 3 {
  793. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  794. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  795. } else {
  796. if id_card_type == 1 {
  797. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  798. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  799. } else {
  800. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  801. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  802. }
  803. }
  804. if med_type == "1111" || med_type == "1112" {
  805. med_type = "11"
  806. }
  807. if insuplc_admdvs == "421300" {
  808. if med_type == "11" {
  809. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  810. } else if med_type == "14" {
  811. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  812. }
  813. } else {
  814. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  815. }
  816. inputData["medfee_sumamt"] = total // 医疗费总额
  817. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  818. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  819. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  820. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  821. inputData["insutype"] = insutype // 险种类型
  822. inputData["invono"] = "" // 发票号
  823. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  824. inputData["overlmt_selfpay"] = overlmt_selfpay //
  825. inputData["preselfpay_amt"] = preselfpay_amt //
  826. inputData["inscp_scp_amt"] = inscp_scp_amt //
  827. input["data"] = inputData
  828. inputMessage["input"] = input //交易输入
  829. bytesData, err := json.Marshal(inputMessage)
  830. fmt.Println(string(bytesData))
  831. if err != nil {
  832. fmt.Println(err.Error())
  833. return err.Error(), ""
  834. }
  835. request_url = request_url + "2207A"
  836. //fmt.Println(HNHttpRequestHNHttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData)))
  837. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  838. return HNHttpRequest(request_url, access_key, secret_key, timestamp2, string(bytesData), "2207A"), string(bytesData)
  839. }
  840. // 门诊结算撤销
  841. func Hnyb2208(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) {
  842. timestamp := time.Now().Unix()
  843. // 生成输入报文
  844. inputMessage := SetHnInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  845. input := make(map[string]interface{})
  846. inputData := make(map[string]interface{})
  847. inputMessage["infno"] = "2208" // 交易编码
  848. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  849. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  850. inputData["setl_id"] = setlId // 结算 ID
  851. inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
  852. input["data"] = inputData
  853. inputMessage["input"] = input //交易输入
  854. bytesData, err := json.Marshal(inputMessage)
  855. fmt.Println(string(bytesData))
  856. if err != nil {
  857. fmt.Println(err.Error())
  858. return err.Error(), ""
  859. }
  860. request_url = request_url + "2208"
  861. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  862. return HNHttpRequest(request_url, access_key, secret_key, timestamp2, string(bytesData), "2208"), string(bytesData)
  863. }
  864. func Hnyb5203(baseParams models.BaseParams, businessParams models.BusinessParams) (string, string) {
  865. timestamp := time.Now().Unix()
  866. // 生成输入报文
  867. inputMessage := SetHnInputMessage(timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.Cainfo)
  868. input := make(map[string]interface{})
  869. inputData := make(map[string]interface{})
  870. inputMessage["infno"] = "5203" // 交易编码
  871. inputData["psn_no"] = businessParams.PsnNo
  872. inputData["setl_id"] = businessParams.SetlId
  873. inputData["mdtrt_id"] = businessParams.MdtrtId
  874. input["data"] = inputData
  875. inputMessage["input"] = input //交易输入
  876. bytesData, err := json.Marshal(inputMessage)
  877. fmt.Println(string(bytesData))
  878. if err != nil {
  879. fmt.Println(err.Error())
  880. return err.Error(), ""
  881. }
  882. baseParams.RequestUrl = baseParams.RequestUrl + "5203"
  883. //fmt.Println(HNHttpRequest(baseParams.RequestUrl, baseParams.AccessKey, baseParams.SecretKey, timestamp, string(bytesData)))
  884. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  885. return HNHttpRequest(baseParams.RequestUrl, baseParams.AccessKey, baseParams.SecretKey, timestamp2, string(bytesData), "5203"), string(bytesData)
  886. }
  887. //CBS总线
  888. func HNHttpRequest(url string, ak string, sk string, timestamp int64, json string, infno string) string {
  889. fmt.Println(url)
  890. //step 1. 设置请求参数
  891. csbHP := csbhttp.NewHttpParams(url) //设置请求地址及url参数
  892. //设置调用方式 get 或者 post
  893. csbHP.SetMethod("post")
  894. //设置 调用的服务名和版本
  895. csbHP.SetApi(infno)
  896. csbHP.SetVersion("1.0.0")
  897. //添加附加的http请求头 (可以定义多条)
  898. //key := "_api_access_key=" + ak + "&_api_name=" + "hssServives" + "&_api_timestamp=" + strconv.FormatInt(timestamp, 10) + "&_api_version=" + "1.0.0"
  899. csbHP.AddHeader("_api_timestamp", strconv.FormatInt(timestamp, 10))
  900. csbHP.AddHeader("_api_name", infno)
  901. csbHP.AddHeader("_api_version", "1.0.0")
  902. csbHP.AddHeader("_api_access_key", ak)
  903. csbHP.AddHeader("Content-Type", "application/json;charset=UTF-8")
  904. //request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  905. //还可以,设置附加的byte[]或者json请求体
  906. csbHP.SetContentBody(json, nil)
  907. //设置请求的ak和sk
  908. csbHP.SetAK(ak)
  909. csbHP.SetSK(sk)
  910. //打印请求参数信息
  911. csbHP.Print()
  912. //进行调用, 返回的第二项为resonse http headers (map[string][]string类型)
  913. //res, _, err := csbhttp.Invoke(*csbHP, requestByte)
  914. res, _, err := csbhttp.Invoke(*csbHP, strconv.FormatInt(timestamp, 10))
  915. fmt.Println("err:")
  916. fmt.Println(err)
  917. //是否发成错误
  918. if err != nil {
  919. fmt.Println(err)
  920. return ""
  921. }
  922. fmt.Println(res)
  923. return res
  924. }
  925. // 生成基础报文
  926. func SetHnInputMessage(timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, cainfo string) map[string]interface{} {
  927. // 生成签名
  928. tempTime := time.Unix(timestamp, 0)
  929. //timeFormat := tempTime.Format("20060102150405")
  930. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  931. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  932. month := time.Unix(1557042972, 0).Format("1")
  933. year := time.Now().Format("2006")
  934. month = time.Now().Format("01")
  935. day := time.Now().Format("02")
  936. hour := time.Now().Format("15")
  937. min := time.Now().Format("04")
  938. sec := time.Now().Format("05")
  939. msec := time.Now().Format("000")
  940. // 生成输入报文
  941. inputMessage := make(map[string]interface{})
  942. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  943. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  944. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  945. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  946. inputMessage["dev_no"] = "1" // 设备编号
  947. inputMessage["dev_safe_info"] = "1" // 设备安全信息
  948. inputMessage["cainfo"] = cainfo // 数字签名信息
  949. inputMessage["signtype"] = "SM3" // 签名类型
  950. inputMessage["infver"] = "V1.0" // 接收方系统代码
  951. inputMessage["opter_type"] = "1" // 经办人类别
  952. inputMessage["opter"] = doctor // 经办人
  953. inputMessage["opter_name"] = doctor // 经办人姓名
  954. inputMessage["inf_time"] = timeFormatOne // 交易时间
  955. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  956. inputMessage["fixmedins_name"] = org_name
  957. inputMessage["fixmedins_soft_fcty"] = "深圳市领透科技有限公司" //定点医药机构名称
  958. //定点医药机构名称
  959. inputMessage["sign_no"] = "" //交易签到流水号
  960. return inputMessage
  961. }
  962. func Hnyb5301(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) {
  963. // 生成签名
  964. //nonce := GetRandomString(32)
  965. timestamp := time.Now().Unix()
  966. //signature := setSignature(timestamp, nonce, secret_key)
  967. //tempTime := time.Unix(timestamp, 0)
  968. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  969. //timeFormatTwo := tempTime.Format("2006-01-02")
  970. // 生成输入报文
  971. inputMessage := SetHnInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  972. input := make(map[string]interface{})
  973. inputData := make(map[string]interface{})
  974. inputMessage["infno"] = "5301" // 交易编码
  975. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  976. input["data"] = inputData
  977. inputMessage["input"] = input //交易输入
  978. bytesData, err := json.Marshal(inputMessage)
  979. fmt.Println(string(bytesData))
  980. if err != nil {
  981. fmt.Println(err.Error())
  982. return err.Error(), ""
  983. }
  984. request_url = request_url + "5301"
  985. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  986. return HNHttpRequest(request_url, access_key, secret_key, timestamp2, string(bytesData), "5301"), string(bytesData)
  987. }
  988. func Hnyb2503(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) {
  989. timestamp := time.Now().Unix()
  990. // 生成输入报文
  991. inputMessage := SetHnInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  992. input := make(map[string]interface{})
  993. inputData := make(map[string]interface{})
  994. inputMessage["infno"] = "2503" // 交易编码
  995. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  996. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  997. inputData["opsp_dise_code"] = sick_code // 险种类型(来自1101接口返回)
  998. inputData["opsp_dise_name"] = sick_name // 险种类型(来自1101接口返回)
  999. inputData["insu_optins"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  1000. inputData["ide_fixmedins_no"] = fixmedins_code // 险种类型(来自1101接口返回)
  1001. inputData["ide_fixmedins_name"] = org_name // 险种类型(来自1101接口返回)
  1002. inputData["hosp_ide_date"] = check_time // 险种类型(来自1101接口返回)
  1003. inputData["diag_dr_codg"] = doctor_id // 开始时间
  1004. inputData["diag_dr_name"] = doctor // 开始时间
  1005. inputData["begndate"] = start_time // 医师编码
  1006. inputData["tel"] = "" // 医师编码
  1007. inputData["addr"] = "" // 医师编码
  1008. inputData["enddate"] = end_time // 医师编码
  1009. input["data"] = inputData
  1010. inputMessage["input"] = input //交易输入
  1011. bytesData, err := json.Marshal(inputMessage)
  1012. fmt.Println(string(bytesData))
  1013. if err != nil {
  1014. fmt.Println(err.Error())
  1015. return err.Error(), ""
  1016. }
  1017. request_url = request_url + "2503"
  1018. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  1019. return HNHttpRequest(request_url, access_key, secret_key, timestamp2, string(bytesData), "2503"), string(bytesData)
  1020. }
  1021. func Hnyb3201(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) {
  1022. // 生成签名
  1023. timestamp := time.Now().Unix()
  1024. // 生成输入报文
  1025. inputMessage := SetHnInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  1026. input := make(map[string]interface{})
  1027. inputData := make(map[string]interface{})
  1028. inputMessage["infno"] = "3201" // 交易编码
  1029. inputData["insutype"] = insutype // 险种
  1030. inputData["clr_type"] = clr_type // 就诊 ID(来自2201接口返回)
  1031. inputData["setl_optins"] = setl_optins // 结算经办机构
  1032. inputData["stmt_begndate"] = stmt_begndate // 对帐开始时间
  1033. inputData["stmt_enddate"] = stmt_enddate //对帐结束时间
  1034. inputData["medfee_sumamt"] = fmt.Sprintf("%.2f", medfee_sumamt) //医疗费总额
  1035. inputData["fund_pay_sumamt"] = fmt.Sprintf("%.2f", fund_pay_sumamt) //基金支付总额
  1036. inputData["acct_pay"] = fmt.Sprintf("%.2f", acct_pay) //个人账户支付金额
  1037. inputData["fixmedins_setl_cnt"] = fixmedins_setl_cnt //定点医药机构结算笔数
  1038. inputData["refd_setl_flag"] = 0 //
  1039. input["data"] = inputData
  1040. inputMessage["input"] = input //交易输入
  1041. bytesData, err := json.Marshal(inputMessage)
  1042. fmt.Println(string(bytesData))
  1043. if err != nil {
  1044. fmt.Println(err.Error())
  1045. return err.Error(), ""
  1046. }
  1047. request_url = request_url + "3201"
  1048. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  1049. return HNHttpRequest(request_url, access_key, secret_key, timestamp2, string(bytesData), "3201"), string(bytesData)
  1050. }
  1051. func Hnyb9001(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, admin_user_id int64, request_url string, cainfo string, access_key string) (string, string) {
  1052. // 生成签名
  1053. timestamp := time.Now().Unix()
  1054. // 生成输入报文
  1055. inputMessage := SetHnInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  1056. input := make(map[string]interface{})
  1057. inputData := make(map[string]interface{})
  1058. inputMessage["infno"] = "9001" // 交易编码
  1059. inputData["opter_no"] = admin_user_id
  1060. inputData["mac"] = GetMacTwo() // 开始时间
  1061. inputData["ip"] = GetLocalIpTwo()
  1062. input["signIn"] = inputData
  1063. inputMessage["input"] = input //交易输入
  1064. bytesData, err := json.Marshal(inputMessage)
  1065. fmt.Println(string(bytesData))
  1066. if err != nil {
  1067. fmt.Println(err.Error())
  1068. return err.Error(), ""
  1069. }
  1070. //reader := bytes.NewReader(bytesData)
  1071. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1072. //gdyb_url := beego.AppConfig.String("gdyb_url")
  1073. //gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1074. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1075. //url := gdyb_url
  1076. //request, err := http.NewRequest("POST", request_url+"9001", reader)
  1077. //if err != nil {
  1078. // fmt.Println(err.Error())
  1079. // return err.Error(), ""
  1080. //}
  1081. //
  1082. //request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1083. //request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
  1084. //request.Header.Set("_api_name", "hssServives")
  1085. //request.Header.Set("_api_version", "1.0.0")
  1086. //request.Header.Set("_api_access_key", access_key)
  1087. //request.Header.Set("_api_signature", "")
  1088. //
  1089. //client := http.Client{}
  1090. //resp, err := client.Do(request)
  1091. //if err != nil {
  1092. // fmt.Println(err.Error())
  1093. // return err.Error(), ""
  1094. //}
  1095. //respBytes, err := ioutil.ReadAll(resp.Body)
  1096. //if err != nil {
  1097. // fmt.Println(err.Error())
  1098. // return err.Error(), ""
  1099. //}
  1100. //str := string(respBytes)
  1101. //fmt.Println(str)
  1102. //return str, ""
  1103. request_url = request_url + "9001"
  1104. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  1105. return HNHttpRequest(request_url, access_key, secret_key, timestamp2, string(bytesData), "9001"), string(bytesData)
  1106. }
  1107. func Hnyb3101(pd models.PatientDtos, fed models.FsiEncounterDtos, fdds []*models.FsiDiagnoseDtos, fods []*models.FsiOrderDtos, fopds []*models.FsiOperationDtosData, params models.PublicParams, trig_scen string) (string, string) {
  1108. // 生成签名
  1109. timestamp := time.Now().Unix()
  1110. // 生成输入报文
  1111. inputMessage := SetHnInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  1112. input := make(map[string]interface{})
  1113. inputData := make(map[string]interface{})
  1114. patientDtosinputData := make(map[string]interface{})
  1115. fisEncounterDtosData := make(map[string]interface{})
  1116. fsiDiagnoseDtosDatas := make([]map[string]interface{}, 0)
  1117. fsiOrderDtosDatas := make([]map[string]interface{}, 0)
  1118. fsiOperationDtosData := make(map[string]interface{})
  1119. fsiOperationDtosDatas := make([]map[string]interface{}, 0)
  1120. //就诊信息
  1121. fisEncounterDtosData["mdtrt_id"] = fed.MdtrtID
  1122. fisEncounterDtosData["medins_id"] = fed.MedinsID
  1123. fisEncounterDtosData["medins_name"] = fed.MedinsName
  1124. fisEncounterDtosData["medins_admdvs"] = fed.MedinsAdmdvs
  1125. fisEncounterDtosData["medins_type"] = fed.MedinsType
  1126. fisEncounterDtosData["medins_lv"] = fed.MedinsLv
  1127. fisEncounterDtosData["wardarea_codg"] = fed.WardareaCodg
  1128. fisEncounterDtosData["wardno"] = fed.Wardno
  1129. fisEncounterDtosData["bedno"] = fed.Bedno
  1130. fisEncounterDtosData["adm_date"] = fed.AdmDate
  1131. fisEncounterDtosData["dscg_date"] = fed.DscgDate
  1132. fisEncounterDtosData["dscg_main_dise_codg"] = fed.DscgMainDiseCodg
  1133. fisEncounterDtosData["dscg_main_dise_name"] = fed.DscgMainDiseName
  1134. for _, fdd := range fdds {
  1135. fsiDiagnoseDtosData := make(map[string]interface{})
  1136. //诊断集合
  1137. fsiDiagnoseDtosData["dise_id"] = fdd.DiseID
  1138. fsiDiagnoseDtosData["inout_dise_type"] = fdd.InoutDiseType
  1139. fsiDiagnoseDtosData["maindise_flag"] = fdd.MaindiseFlag
  1140. fsiDiagnoseDtosData["dias_srt_no"] = fdd.DiasSrtNo
  1141. fsiDiagnoseDtosData["dise_codg"] = fdd.DiseCodg
  1142. fsiDiagnoseDtosData["dise_name"] = fdd.DiseName
  1143. fsiDiagnoseDtosData["dise_date"] = fdd.DiseDate
  1144. fsiDiagnoseDtosDatas = append(fsiDiagnoseDtosDatas, fsiDiagnoseDtosData)
  1145. }
  1146. fisEncounterDtosData["fsi_diagnose_dtos"] = fsiDiagnoseDtosDatas
  1147. fisEncounterDtosData["dr_codg"] = fed.DrCodg
  1148. fisEncounterDtosData["adm_dept_codg"] = fed.AdmDeptCodg
  1149. fisEncounterDtosData["adm_dept_name"] = fed.AdmDeptName
  1150. fisEncounterDtosData["dscg_dept_codg"] = fed.DscgDeptCodg
  1151. fisEncounterDtosData["dscg_dept_name"] = fed.DscgDeptName
  1152. fisEncounterDtosData["med_mdtrt_type"] = fed.MedMdtrtType
  1153. fisEncounterDtosData["med_type"] = fed.MedType
  1154. for _, fod := range fods {
  1155. fsiOrderDtosData := make(map[string]interface{})
  1156. //医嘱集合
  1157. fsiOrderDtosData["rx_id"] = fod.RxID
  1158. fsiOrderDtosData["rxno"] = fod.Rxno
  1159. fsiOrderDtosData["grpno"] = fod.Grpno
  1160. fsiOrderDtosData["long_drord_flag"] = fod.LongDrordFlag
  1161. fsiOrderDtosData["hilist_type"] = fod.HilistType
  1162. fsiOrderDtosData["chrg_type"] = fod.ChrgType
  1163. fsiOrderDtosData["drord_bhvr"] = fod.DrordBhvr
  1164. fsiOrderDtosData["hilist_code"] = fod.HilistCode
  1165. fsiOrderDtosData["hilist_name"] = fod.HilistName
  1166. fsiOrderDtosData["hilist_dosform"] = fod.HilistDosform
  1167. fsiOrderDtosData["hilist_lv"] = fod.HilistLv
  1168. fsiOrderDtosData["hilist_pric"] = fod.HilistPric
  1169. fsiOrderDtosData["lv1_hosp_item_pric"] = fod.Lv1HospItemPric
  1170. fsiOrderDtosData["lv2_hosp_item_pric"] = fod.Lv2HospItemPric
  1171. fsiOrderDtosData["lv3_hosp_item_pric"] = fod.Lv3HospItemPric
  1172. fsiOrderDtosData["hilist_memo"] = fod.HilistMemo
  1173. fsiOrderDtosData["hosplist_code"] = fod.HosplistCode
  1174. fsiOrderDtosData["hosplist_name"] = fod.HosplistName
  1175. fsiOrderDtosData["hosplist_dosform"] = fod.HosplistDosform
  1176. fsiOrderDtosData["cnt"] = fod.Cnt
  1177. fsiOrderDtosData["pric"] = fod.Pric
  1178. fsiOrderDtosData["sumamt"] = fod.Sumamt
  1179. fsiOrderDtosData["ownpay_amt"] = fod.OwnpayAmt
  1180. fsiOrderDtosData["selfpay_amt"] = fod.SelfpayAmt
  1181. fsiOrderDtosData["spec"] = fod.Spec
  1182. fsiOrderDtosData["spec_unt"] = fod.SpecUnt
  1183. fsiOrderDtosData["drord_begn_date"] = fod.DrordBegnDate
  1184. fsiOrderDtosData["drord_stop_date"] = fod.DrordStopDate
  1185. fsiOrderDtosData["drord_dept_codg"] = fod.DrordDeptCodg
  1186. fsiOrderDtosData["drord_dept_name"] = fod.DrordDeptName
  1187. fsiOrderDtosData["drord_dr_codg"] = fod.DrordDrCodg
  1188. fsiOrderDtosData["drord_dr_name"] = fod.DrordDrName
  1189. fsiOrderDtosData["drord_dr_profttl"] = fod.DrordDrProfttl
  1190. fsiOrderDtosData["curr_drord_flag"] = fod.CurrDrordFlag
  1191. fsiOrderDtosDatas = append(fsiOrderDtosDatas, fsiOrderDtosData)
  1192. }
  1193. fisEncounterDtosData["fsi_order_dtos"] = fsiOrderDtosDatas
  1194. fisEncounterDtosData["matn_stas"] = fed.MatnStas
  1195. fisEncounterDtosData["medfee_sumamt"] = fed.MedfeeSumamt
  1196. fisEncounterDtosData["ownpay_amt"] = fed.OwnpayAmt
  1197. fisEncounterDtosData["selfpay_amt"] = fed.SelfpayAmt
  1198. fisEncounterDtosData["acct_payamt"] = fed.AcctPayamt
  1199. fisEncounterDtosData["ma_amt"] = fed.MaAmt
  1200. fisEncounterDtosData["hifp_payamt"] = fed.HifpPayamt
  1201. fisEncounterDtosData["setl_totlnum"] = fed.SetlTotlnum
  1202. fisEncounterDtosData["insutype"] = fed.Insutype
  1203. fisEncounterDtosData["reim_flag"] = fed.ReimFlag
  1204. fisEncounterDtosData["out_setl_flag"] = fed.OutSetlFlag
  1205. //手术操作
  1206. for _, fopd := range fopds {
  1207. fsiOperationDtosData["setl_list_oprn_id"] = fopd.Setl_list_oprn_id
  1208. fsiOperationDtosData["oprn_code"] = fopd.Oprn_code
  1209. fsiOperationDtosData["oprn_name"] = fopd.Oprn_name
  1210. fsiOperationDtosData["main_oprn_flag"] = fopd.Main_oprn_flag
  1211. fsiOperationDtosData["oprn_date"] = fopd.Oprn_date
  1212. fsiOperationDtosData["anst_way"] = fopd.Anst_way
  1213. fsiOperationDtosData["oper_dr_name"] = fopd.Oper_dr_name
  1214. fsiOperationDtosData["oper_dr_code"] = fopd.Oper_dr_code
  1215. fsiOperationDtosData["anst_dr_name"] = fopd.Anst_dr_name
  1216. fsiOperationDtosData["anst_dr_code"] = fopd.Anst_dr_code
  1217. fsiOperationDtosDatas = append(fsiOperationDtosDatas, fsiOperationDtosData)
  1218. }
  1219. fisEncounterDtosData["fsi_operation_dtos"] = fsiOperationDtosDatas
  1220. patientDtosinputData["patn_id"] = pd.PatnID
  1221. patientDtosinputData["patn_name"] = pd.PatnName
  1222. patientDtosinputData["gend"] = pd.Gend
  1223. patientDtosinputData["brdy"] = pd.Brdy
  1224. patientDtosinputData["poolarea"] = pd.Poolarea
  1225. patientDtosinputData["curr_mdtrt_id"] = pd.CurrMdtrtID
  1226. patientDtosinputData["fsi_his_data_dto"] = ""
  1227. patientDtosinputData["fsi_encounter_dtos"] = fisEncounterDtosData
  1228. inputData["syscode"] = "LinkDialysis"
  1229. inputData["trig_scen"] = trig_scen
  1230. inputData["rule_ids"] = ""
  1231. inputData["task_id"] = ""
  1232. inputData["patient_dtos"] = patientDtosinputData
  1233. input["data"] = inputData
  1234. inputMessage["infno"] = "3101"
  1235. inputMessage["input"] = input //交易输入
  1236. bytesData, err := json.Marshal(inputMessage)
  1237. fmt.Println(string(bytesData))
  1238. if err != nil {
  1239. fmt.Println(err.Error())
  1240. return err.Error(), ""
  1241. }
  1242. params.RequestUrl = params.RequestUrl + "3101"
  1243. return HNHttpRequest(params.RequestUrl, params.AccessKey, params.SecretKey, timestamp, string(bytesData), "3101"), string(bytesData)
  1244. }
  1245. func Hnyb3102(pd models.PatientDtos, fed models.FsiEncounterDtos, fdds []*models.FsiDiagnoseDtos, fods []*models.FsiOrderDtos, fopds []*models.FsiOperationDtosData, params models.PublicParams, trig_scen string) (string, string) {
  1246. // 生成签名
  1247. timestamp := time.Now().Unix()
  1248. // 生成输入报文
  1249. inputMessage := SetHnInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  1250. input := make(map[string]interface{})
  1251. inputData := make(map[string]interface{})
  1252. patientDtosinputData := make(map[string]interface{})
  1253. fisEncounterDtosData := make(map[string]interface{})
  1254. fsiDiagnoseDtosDatas := make([]map[string]interface{}, 0)
  1255. fsiOrderDtosDatas := make([]map[string]interface{}, 0)
  1256. fsiOperationDtosData := make(map[string]interface{})
  1257. fsiOperationDtosDatas := make([]map[string]interface{}, 0)
  1258. //就诊信息
  1259. fisEncounterDtosData["mdtrt_id"] = fed.MdtrtID
  1260. fisEncounterDtosData["medins_id"] = fed.MedinsID
  1261. fisEncounterDtosData["medins_name"] = fed.MedinsName
  1262. fisEncounterDtosData["medins_admdvs"] = fed.MedinsAdmdvs
  1263. fisEncounterDtosData["medins_type"] = fed.MedinsType
  1264. fisEncounterDtosData["medins_lv"] = fed.MedinsLv
  1265. fisEncounterDtosData["wardarea_codg"] = fed.WardareaCodg
  1266. fisEncounterDtosData["wardno"] = fed.Wardno
  1267. fisEncounterDtosData["bedno"] = fed.Bedno
  1268. fisEncounterDtosData["adm_date"] = fed.AdmDate
  1269. fisEncounterDtosData["dscg_date"] = fed.DscgDate
  1270. fisEncounterDtosData["dscg_main_dise_codg"] = fed.DscgMainDiseCodg
  1271. fisEncounterDtosData["dscg_main_dise_name"] = fed.DscgMainDiseName
  1272. for _, fdd := range fdds {
  1273. fsiDiagnoseDtosData := make(map[string]interface{})
  1274. //诊断集合
  1275. fsiDiagnoseDtosData["dise_id"] = fdd.DiseID
  1276. fsiDiagnoseDtosData["inout_dise_type"] = fdd.InoutDiseType
  1277. fsiDiagnoseDtosData["maindise_flag"] = fdd.MaindiseFlag
  1278. fsiDiagnoseDtosData["dias_srt_no"] = fdd.DiasSrtNo
  1279. fsiDiagnoseDtosData["dise_codg"] = fdd.DiseCodg
  1280. fsiDiagnoseDtosData["dise_name"] = fdd.DiseName
  1281. fsiDiagnoseDtosData["dise_date"] = fdd.DiseDate
  1282. fsiDiagnoseDtosDatas = append(fsiDiagnoseDtosDatas, fsiDiagnoseDtosData)
  1283. }
  1284. fisEncounterDtosData["fsi_diagnose_dtos"] = fsiDiagnoseDtosDatas
  1285. fisEncounterDtosData["dr_codg"] = fed.DrCodg
  1286. fisEncounterDtosData["adm_dept_codg"] = fed.AdmDeptCodg
  1287. fisEncounterDtosData["adm_dept_name"] = fed.AdmDeptName
  1288. fisEncounterDtosData["dscg_dept_codg"] = fed.DscgDeptCodg
  1289. fisEncounterDtosData["dscg_dept_name"] = fed.DscgDeptName
  1290. fisEncounterDtosData["med_mdtrt_type"] = fed.MedMdtrtType
  1291. fisEncounterDtosData["med_type"] = fed.MedType
  1292. for _, fod := range fods {
  1293. fsiOrderDtosData := make(map[string]interface{})
  1294. //医嘱集合
  1295. fsiOrderDtosData["rx_id"] = fod.RxID
  1296. fsiOrderDtosData["rxno"] = fod.Rxno
  1297. fsiOrderDtosData["grpno"] = fod.Grpno
  1298. fsiOrderDtosData["long_drord_flag"] = fod.LongDrordFlag
  1299. fsiOrderDtosData["hilist_type"] = fod.HilistType
  1300. fsiOrderDtosData["chrg_type"] = fod.ChrgType
  1301. fsiOrderDtosData["drord_bhvr"] = fod.DrordBhvr
  1302. fsiOrderDtosData["hilist_code"] = fod.HilistCode
  1303. fsiOrderDtosData["hilist_name"] = fod.HilistName
  1304. fsiOrderDtosData["hilist_dosform"] = fod.HilistDosform
  1305. fsiOrderDtosData["hilist_lv"] = fod.HilistLv
  1306. fsiOrderDtosData["hilist_pric"] = fod.HilistPric
  1307. fsiOrderDtosData["lv1_hosp_item_pric"] = fod.Lv1HospItemPric
  1308. fsiOrderDtosData["lv2_hosp_item_pric"] = fod.Lv2HospItemPric
  1309. fsiOrderDtosData["lv3_hosp_item_pric"] = fod.Lv3HospItemPric
  1310. fsiOrderDtosData["hilist_memo"] = fod.HilistMemo
  1311. fsiOrderDtosData["hosplist_code"] = fod.HosplistCode
  1312. fsiOrderDtosData["hosplist_name"] = fod.HosplistName
  1313. fsiOrderDtosData["hosplist_dosform"] = fod.HosplistDosform
  1314. fsiOrderDtosData["cnt"] = fod.Cnt
  1315. fsiOrderDtosData["pric"] = fod.Pric
  1316. fsiOrderDtosData["sumamt"] = fod.Sumamt
  1317. fsiOrderDtosData["ownpay_amt"] = fod.OwnpayAmt
  1318. fsiOrderDtosData["selfpay_amt"] = fod.SelfpayAmt
  1319. fsiOrderDtosData["spec"] = fod.Spec
  1320. fsiOrderDtosData["spec_unt"] = fod.SpecUnt
  1321. fsiOrderDtosData["drord_begn_date"] = fod.DrordBegnDate
  1322. fsiOrderDtosData["drord_stop_date"] = fod.DrordStopDate
  1323. fsiOrderDtosData["drord_dept_codg"] = fod.DrordDeptCodg
  1324. fsiOrderDtosData["drord_dept_name"] = fod.DrordDeptName
  1325. fsiOrderDtosData["drord_dr_codg"] = fod.DrordDrCodg
  1326. fsiOrderDtosData["drord_dr_name"] = fod.DrordDrName
  1327. fsiOrderDtosData["drord_dr_profttl"] = fod.DrordDrProfttl
  1328. fsiOrderDtosData["curr_drord_flag"] = fod.CurrDrordFlag
  1329. fsiOrderDtosDatas = append(fsiOrderDtosDatas, fsiOrderDtosData)
  1330. }
  1331. fisEncounterDtosData["fsi_order_dtos"] = fsiOrderDtosDatas
  1332. fisEncounterDtosData["matn_stas"] = fed.MatnStas
  1333. fisEncounterDtosData["medfee_sumamt"] = fed.MedfeeSumamt
  1334. fisEncounterDtosData["ownpay_amt"] = fed.OwnpayAmt
  1335. fisEncounterDtosData["selfpay_amt"] = fed.SelfpayAmt
  1336. fisEncounterDtosData["acct_payamt"] = fed.AcctPayamt
  1337. fisEncounterDtosData["ma_amt"] = fed.MaAmt
  1338. fisEncounterDtosData["hifp_payamt"] = fed.HifpPayamt
  1339. fisEncounterDtosData["setl_totlnum"] = fed.SetlTotlnum
  1340. fisEncounterDtosData["insutype"] = fed.Insutype
  1341. fisEncounterDtosData["reim_flag"] = fed.ReimFlag
  1342. fisEncounterDtosData["out_setl_flag"] = fed.OutSetlFlag
  1343. //手术操作
  1344. for _, fopd := range fopds {
  1345. fsiOperationDtosData["setl_list_oprn_id"] = fopd.Setl_list_oprn_id
  1346. fsiOperationDtosData["oprn_code"] = fopd.Oprn_code
  1347. fsiOperationDtosData["oprn_name"] = fopd.Oprn_name
  1348. fsiOperationDtosData["main_oprn_flag"] = fopd.Main_oprn_flag
  1349. fsiOperationDtosData["oprn_date"] = fopd.Oprn_date
  1350. fsiOperationDtosData["anst_way"] = fopd.Anst_way
  1351. fsiOperationDtosData["oper_dr_name"] = fopd.Oper_dr_name
  1352. fsiOperationDtosData["oper_dr_code"] = fopd.Oper_dr_code
  1353. fsiOperationDtosData["anst_dr_name"] = fopd.Anst_dr_name
  1354. fsiOperationDtosData["anst_dr_code"] = fopd.Anst_dr_code
  1355. fsiOperationDtosDatas = append(fsiOperationDtosDatas, fsiOperationDtosData)
  1356. }
  1357. fisEncounterDtosData["fsi_operation_dtos"] = fsiOperationDtosDatas
  1358. patientDtosinputData["patn_id"] = pd.PatnID
  1359. patientDtosinputData["patn_name"] = pd.PatnName
  1360. patientDtosinputData["gend"] = pd.Gend
  1361. patientDtosinputData["brdy"] = pd.Brdy
  1362. patientDtosinputData["poolarea"] = pd.Poolarea
  1363. patientDtosinputData["curr_mdtrt_id"] = pd.CurrMdtrtID
  1364. patientDtosinputData["fsi_his_data_dto"] = ""
  1365. patientDtosinputData["fsi_encounter_dtos"] = fisEncounterDtosData
  1366. inputData["syscode"] = "LinkDialysis"
  1367. inputData["trig_scen"] = trig_scen
  1368. inputData["rule_ids"] = ""
  1369. inputData["task_id"] = ""
  1370. inputData["patient_dtos"] = patientDtosinputData
  1371. input["data"] = inputData
  1372. inputMessage["infno"] = "3102"
  1373. inputMessage["input"] = input //交易输入
  1374. bytesData, err := json.Marshal(inputMessage)
  1375. fmt.Println(string(bytesData))
  1376. if err != nil {
  1377. fmt.Println(err.Error())
  1378. return err.Error(), ""
  1379. }
  1380. params.RequestUrl = params.RequestUrl + "3102"
  1381. return HNHttpRequest(params.RequestUrl, params.AccessKey, params.SecretKey, timestamp, string(bytesData), "3102"), string(bytesData)
  1382. }
  1383. func Hnyb4101(struct4101 Struct4101, params models.PublicParams) (string, string) {
  1384. timestamp := time.Now().Unix()
  1385. inputMessage := SetHnInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  1386. // 生成输入报文
  1387. input := make(map[string]interface{})
  1388. inputData := make(map[string]interface{})
  1389. inputMessage["infno"] = "4101A" // 交易编码
  1390. year := time.Now().Format("2006")
  1391. month := time.Now().Format("01")
  1392. day := time.Now().Format("02")
  1393. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  1394. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  1395. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  1396. inputData["fixmedins_name"] = params.FixmedinsName // 定点医药机构名称 必填
  1397. inputData["fixmedins_code"] = params.FixmedinsCode // 定点医药机构编码 必填
  1398. inputData["hi_setl_lv"] = "" // 医保结算等级
  1399. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  1400. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  1401. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  1402. inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  1403. inputData["gend"] = struct4101.Gend // 性别 必填
  1404. inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  1405. inputData["age"] = struct4101.Age // 年龄 必填
  1406. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  1407. inputData["resp_nurs_code"] = "N430822004867" // 民族 必填
  1408. inputData["nwb_age"] = "" // 年龄 必填
  1409. inputData["naty"] = struct4101.Naty // 民族 必填
  1410. inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  1411. inputData["certno"] = struct4101.Certno // 证件号码 必填
  1412. inputData["prfs"] = struct4101.Prfs // 职业 必填
  1413. inputData["curr_addr"] = "" // 现住址 必填
  1414. inputData["emp_name"] = "" // 单位名称 必填
  1415. inputData["emp_addr"] = "" // 单位地址 必填
  1416. inputData["emp_tel"] = "" // 单位电话 必填
  1417. inputData["poscode"] = "" // 邮编 必填
  1418. inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  1419. inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  1420. inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  1421. inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  1422. inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  1423. inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  1424. inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  1425. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  1426. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  1427. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  1428. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  1429. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  1430. inputData["ipt_med_type"] = struct4101.IptMedType // 住院医疗类型 必填
  1431. inputData["adm_way"] = "" // 入院途径 必填
  1432. inputData["trt_type"] = "10" // 治疗类别 必填
  1433. inputData["adm_time"] = struct4101.AdmTime // 入院时间 必填
  1434. inputData["adm_caty"] = struct4101.AdmCaty // 入院科别 必填
  1435. inputData["refldept_dept"] = "" // 转科科别 必填
  1436. inputData["dscg_time"] = struct4101.AdmEndTime // 出院时间 必填
  1437. inputData["dscg_caty"] = struct4101.AdmCaty // 出院科别 必填
  1438. inputData["act_ipt_days"] = "" // 实际住院天数 必填
  1439. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  1440. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  1441. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  1442. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  1443. inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  1444. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  1445. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  1446. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  1447. inputData["bld_cat"] = "" // 输血品种 必填
  1448. inputData["bld_amt"] = "" // 输血量 必填
  1449. inputData["bld_unt"] = "" // 输血计量单位 必填
  1450. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  1451. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  1452. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  1453. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  1454. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  1455. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  1456. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  1457. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  1458. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  1459. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  1460. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  1461. inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  1462. inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  1463. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  1464. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  1465. inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  1466. inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  1467. inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  1468. inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  1469. inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  1470. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  1471. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  1472. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  1473. inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  1474. payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  1475. for _, item := range struct4101.CustomStruct {
  1476. payinfotemp := make(map[string]interface{})
  1477. 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" {
  1478. payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  1479. payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  1480. payinfo = append(payinfo, payinfotemp)
  1481. }
  1482. }
  1483. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  1484. opspdiseinfotemp := make(map[string]interface{})
  1485. opspdiseinfotemp["diag_name"] = struct4101.OpspdiseinfoStruct[len(struct4101.OpspdiseinfoStruct)-1].DiagName // 诊断名称 必填
  1486. opspdiseinfotemp["diag_code"] = struct4101.OpspdiseinfoStruct[len(struct4101.OpspdiseinfoStruct)-1].DiagCode // 诊断代码 必填
  1487. opspdiseinfotemp["oprn_oprt_name"] = struct4101.OpspdiseinfoStruct[len(struct4101.OpspdiseinfoStruct)-1].DiagName // 手术操作名称 必填
  1488. opspdiseinfotemp["oprn_oprt_code"] = struct4101.OpspdiseinfoStruct[len(struct4101.OpspdiseinfoStruct)-1].DiagCode // 手术操作代码 必填
  1489. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  1490. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  1491. for _, item := range struct4101.Diseinfo {
  1492. diseinfotemp := make(map[string]interface{})
  1493. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  1494. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  1495. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  1496. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  1497. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  1498. diseinfo = append(diseinfo, diseinfotemp)
  1499. }
  1500. iteminfo := make([]map[string]interface{}, 0)
  1501. for _, item := range struct4101.IteminfoStruct {
  1502. iteminfotemp := make(map[string]interface{})
  1503. iteminfotemp["med_chrgitm"] = item.MedChrgitm // 医疗收费项目 必填
  1504. iteminfotemp["amt"] = item.Amt // 金额 必填
  1505. iteminfotemp["claa_sumfee"] = item.ClaaSumfee // 甲类费用合计 必填
  1506. iteminfotemp["clab_amt"] = item.ClabAmt // 乙类金额 必填
  1507. iteminfotemp["fulamt_ownpay_amt"] = item.FulamtOwnpayAmt // 全自费金额 必填
  1508. iteminfotemp["oth_amt"] = item.OthAmt // 其他金额 必填
  1509. iteminfo = append(iteminfo, iteminfotemp)
  1510. }
  1511. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  1512. oprninfotemp := make(map[string]interface{})
  1513. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  1514. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  1515. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  1516. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  1517. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  1518. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  1519. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  1520. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  1521. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  1522. oprninfo = append(oprninfo, oprninfotemp)
  1523. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  1524. icuinfotemp := make(map[string]interface{})
  1525. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  1526. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  1527. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  1528. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  1529. icuinfo = append(icuinfo, icuinfotemp)
  1530. input["setlinfo"] = inputData
  1531. input["payinfo"] = payinfo
  1532. input["opspdiseinfo"] = opspdiseinfo
  1533. input["diseinfo"] = diseinfo
  1534. input["iteminfo"] = iteminfo
  1535. inputMessage["input"] = input //交易输入
  1536. bytesData, _ := json.Marshal(inputMessage)
  1537. fmt.Println(string(bytesData))
  1538. params.RequestUrl = params.RequestUrl + "4101"
  1539. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  1540. return HNHttpRequest(params.RequestUrl, params.AccessKey, params.SecretKey, timestamp2, string(bytesData), "4101"), string(bytesData)
  1541. }
  1542. func Hnyb3501(struct3501 models.Struct3501) (string, string) {
  1543. timestamp := time.Now().Unix()
  1544. // 生成输入报文
  1545. inputMessage := SetHnInputMessage(timestamp, struct3501.OrgName, struct3501.Opter, struct3501.FixmedinsCode, struct3501.InsuplcAdmdvs, struct3501.MdtrtareaAdmvs, struct3501.Cainfo)
  1546. input := make(map[string]interface{})
  1547. inputData := make(map[string]interface{})
  1548. inputMessage["infno"] = "3501" // 交易编码
  1549. inputData["med_list_codg"] = struct3501.MedListCodg // 定点医药机构目录编号
  1550. inputData["fixmedins_hilist_id"] = struct3501.FixmedinsHilistId // 定点医药机构目录编号
  1551. inputData["fixmedins_hilist_name"] = struct3501.OrgName // 定点医药机构目录名称
  1552. inputData["rx_flag"] = struct3501.RxFlag //
  1553. inputData["invdate"] = struct3501.Invdate // 人员编号 (来自1101接口返回)
  1554. inputData["inv_cnt"] = struct3501.InvCnt // 人员编号 (来自1101接口返回)
  1555. inputData["manu_lotnum"] = struct3501.ManuLotnum // 人员编号 (来自1101接口返回)
  1556. inputData["fixmedins_bchno"] = struct3501.FixmedinsBchno // 人员编号 (来自1101接口返回)
  1557. inputData["manu_date"] = struct3501.ManuDate // 人员编号 (来自1101接口返回)
  1558. inputData["expy_end"] = struct3501.ExpyEnd // 人员编号 (来自1101接口返回)
  1559. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  1560. input["invinfo"] = inputData
  1561. inputMessage["input"] = input //交易输入
  1562. bytesData, err := json.Marshal(inputMessage)
  1563. fmt.Println(string(bytesData))
  1564. if err != nil {
  1565. fmt.Println(err.Error())
  1566. return err.Error(), ""
  1567. }
  1568. struct3501.RequestUrl = struct3501.RequestUrl + "3501"
  1569. return HNHttpRequest(struct3501.RequestUrl, struct3501.AccessKey, struct3501.SecretKey, timestamp, string(bytesData), "3501"), string(bytesData)
  1570. }
  1571. func Hnyb3502(struct3502 models.Struct3502) (string, string) {
  1572. timestamp := time.Now().Unix()
  1573. // 生成输入报文
  1574. inputMessage := SetHnInputMessage(timestamp, struct3502.OrgName, struct3502.Opter, struct3502.FixmedinsCode, struct3502.InsuplcAdmdvs, struct3502.MdtrtareaAdmvs, struct3502.Cainfo)
  1575. input := make(map[string]interface{})
  1576. inputData := make(map[string]interface{})
  1577. inputMessage["infno"] = "3502" // 交易编码
  1578. inputData["med_list_codg"] = struct3502.MedListCodg // 定点医药机构目录编号
  1579. inputData["inv_chg_type"] = struct3502.InvChgType // 定点医药机构目录编号
  1580. inputData["fixmedins_hilist_id"] = struct3502.FixmedinsCode // 定点医药机构目录编号
  1581. inputData["fixmedins_hilist_name"] = struct3502.OrgName // 定点医药机构目录名称
  1582. inputData["fixmedins_bchno"] = struct3502.FixmedinsBchno // 人员编号 (来自1101接口返回)
  1583. inputData["pric"] = struct3502.Pric // 人员编号 (来自1101接口返回)
  1584. inputData["cnt"] = struct3502.Cnt // 人员编号 (来自1101接口返回)
  1585. inputData["rx_flag"] = struct3502.RxFlag //
  1586. inputData["inv_chg_time"] = struct3502.InvChgTime // 人员编号 (来自1101接口返回)
  1587. inputData["inv_chg_opter_name"] = "" // 人员编号 (来自1101接口返回)
  1588. inputData["memo"] = struct3502.Memo // 人员编号 (来自1101接口返回)
  1589. inputData["trdn_flag"] = "" // 人员编号 (来自1101接口返回)
  1590. input["invinfo"] = inputData
  1591. inputMessage["input"] = input //交易输入
  1592. bytesData, err := json.Marshal(inputMessage)
  1593. fmt.Println(string(bytesData))
  1594. if err != nil {
  1595. fmt.Println(err.Error())
  1596. return err.Error(), ""
  1597. }
  1598. struct3502.RequestUrl = struct3502.RequestUrl + "3502"
  1599. return HNHttpRequest(struct3502.RequestUrl, struct3502.AccessKey, struct3502.SecretKey, timestamp, string(bytesData), "3502"), string(bytesData)
  1600. }
  1601. func Hnyb3503(struct3503 models.Struct3503) (string, string) {
  1602. timestamp := time.Now().Unix()
  1603. // 生成输入报文
  1604. inputMessage := SetHnInputMessage(timestamp, struct3503.OrgName, struct3503.Opter, struct3503.FixmedinsCode, struct3503.InsuplcAdmdvs, struct3503.MdtrtareaAdmvs, struct3503.Cainfo)
  1605. input := make(map[string]interface{})
  1606. inputData := make(map[string]interface{})
  1607. inputMessage["infno"] = "3503"
  1608. inputData["med_list_codg"] = struct3503.MedListCodg
  1609. inputData["fixmedins_hilist_id"] = struct3503.FixmedinsCode
  1610. inputData["fixmedins_hilist_name"] = struct3503.OrgName
  1611. inputData["dynt_no"] = ""
  1612. inputData["fixmedins_bchno"] = struct3503.FixmedinsBchno // 人员编号 (来自1101接口返回)
  1613. inputData["spler_name"] = struct3503.SplerName // 人员编号 (来自1101接口返回)
  1614. inputData["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  1615. inputData["manu_lotnum"] = struct3503.ManuLotnum // 人员编号 (来自1101接口返回)
  1616. inputData["prodentp_name"] = struct3503.ProdentpName // 人员编号 (来自1101接口返回)
  1617. inputData["aprvno"] = struct3503.Aprvno // 人员编号 (来自1101接口返回)
  1618. inputData["manu_date"] = struct3503.ManuDate // 人员编号 (来自1101接口返回)
  1619. inputData["expy_end"] = struct3503.ExpyEnd // 人员编号 (来自1101接口返回)
  1620. inputData["finl_trns_pric"] = struct3503.FinlTrnsPric // 人员编号 (来自1101接口返回)
  1621. inputData["purc_retn_cnt"] = struct3503.PurcRetnCnt // 人员编号 (来自1101接口返回)
  1622. inputData["purc_invo_codg"] = struct3503.PurcInvoCodg // 人员编号 (来自1101接口返回)
  1623. inputData["purc_invo_no"] = struct3503.PurcInvoNo // 人员编号 (来自1101接口返回)
  1624. inputData["rx_flag"] = struct3503.RxFlag // 人员编号 (来自1101接口返回)
  1625. inputData["purc_retn_stoin_time"] = struct3503.PurcRetnStoinTime // 人员编号 (来自1101接口返回)
  1626. inputData["purc_retn_opter_name"] = struct3503.PurcRetnOpterName // 人员编号 (来自1101接口返回)
  1627. inputData["prod_geay_flag"] = "" // 人员编号 (来自1101接口返回)
  1628. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  1629. input["purcinfo"] = inputData
  1630. inputMessage["input"] = input //交易输入
  1631. bytesData, err := json.Marshal(inputMessage)
  1632. fmt.Println(string(bytesData))
  1633. if err != nil {
  1634. fmt.Println(err.Error())
  1635. return err.Error(), ""
  1636. }
  1637. struct3503.RequestUrl = struct3503.RequestUrl + "3503"
  1638. return HNHttpRequest(struct3503.RequestUrl, struct3503.AccessKey, struct3503.SecretKey, timestamp, string(bytesData), "3503"), string(bytesData)
  1639. }
  1640. func Hnyb3504(struct3504 models.Struct3504) (string, string) {
  1641. timestamp := time.Now().Unix()
  1642. // 生成输入报文
  1643. inputMessage := SetHnInputMessage(timestamp, struct3504.OrgName, struct3504.Opter, struct3504.FixmedinsCode, struct3504.InsuplcAdmdvs, struct3504.MdtrtareaAdmvs, struct3504.Cainfo)
  1644. input := make(map[string]interface{})
  1645. inputData := make(map[string]interface{})
  1646. inputMessage["infno"] = "3504" // 交易编码
  1647. inputData["med_list_codg"] = struct3504.MedListCodg // 定点医药机构目录编号
  1648. inputData["fixmedins_hilist_id"] = struct3504.FixmedinsHilistId // 定点医药机构目录编号
  1649. inputData["fixmedins_hilist_name"] = struct3504.FixmedinsHilistName // 定点医药机构目录名称
  1650. inputData["fixmedins_bchno"] = struct3504.FixmedinsBchno // 人员编号 (来自1101接口返回)
  1651. inputData["spler_name"] = struct3504.SplerName // 人员编号 (来自1101接口返回)
  1652. inputData["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  1653. inputData["manu_date"] = struct3504.ManuDate // 人员编号 (来自1101接口返回)
  1654. inputData["expy_end"] = struct3504.ExpyEnd // 人员编号 (来自1101接口返回)
  1655. inputData["finl_trns_pric"] = struct3504.FinlTrnsPric // 人员编号 (来自1101接口返回)
  1656. inputData["purc_retn_cnt"] = struct3504.PurcRetnCnt // 人员编号 (来自1101接口返回)
  1657. inputData["purc_invo_codg"] = struct3504.PurcInvoCodg // 人员编号 (来自1101接口返回)
  1658. inputData["purc_invo_no"] = struct3504.PurcInvoNo // 人员编号 (来自1101接口返回)
  1659. inputData["rx_flag"] = struct3504.RxFlag // 人员编号 (来自1101接口返回)
  1660. inputData["purc_retn_stoin_time"] = struct3504.PurcRetnStoinTime // 人员编号 (来自1101接口返回)
  1661. inputData["purc_retn_opter_name"] = struct3504.PurcRetnOpterName // 人员编号 (来自1101接口返回)
  1662. inputData["medins_prod_purc_no"] = "" // 人员编号 (来自1101接口返回)
  1663. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  1664. input["purcinfo"] = inputData
  1665. inputMessage["input"] = input //交易输入
  1666. bytesData, err := json.Marshal(inputMessage)
  1667. fmt.Println(string(bytesData))
  1668. if err != nil {
  1669. fmt.Println(err.Error())
  1670. return err.Error(), ""
  1671. }
  1672. struct3504.RequestUrl = struct3504.RequestUrl + "3504"
  1673. return HNHttpRequest(struct3504.RequestUrl, struct3504.AccessKey, struct3504.SecretKey, timestamp, string(bytesData), "3504"), string(bytesData)
  1674. }
  1675. func Hnyb3505(struct3505 models.Struct3505) (string, string) {
  1676. timestamp := time.Now().Unix()
  1677. // 生成输入报文
  1678. inputMessage := SetHnInputMessage(timestamp, struct3505.OrgName, struct3505.Opter, struct3505.FixmedinsCode, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, struct3505.Cainfo)
  1679. input := make(map[string]interface{})
  1680. inputData := make(map[string]interface{})
  1681. inputMessage["infno"] = "3505" // 交易编码
  1682. inputData["med_list_codg"] = struct3505.MedListCodg // 定点医药机构目录编号
  1683. inputData["fixmedins_hilist_id"] = struct3505.FixmedinsCode // 定点医药机构目录编号
  1684. inputData["fixmedins_hilist_name"] = struct3505.OrgName // 定点医药机构目录名称
  1685. inputData["fixmedins_bchno"] = struct3505.FixmedinsCode // 人员编号 (来自1101接口返回)
  1686. inputData["prsc_dr_cert_type"] = struct3505.PrscDrCertType // 人员编号 (来自1101接口返回)
  1687. inputData["prsc_dr_certno"] = struct3505.PrscDrCertno // 人员编号 (来自1101接口返回)
  1688. inputData["prsc_dr_name"] = struct3505.PrscDrName // 人员编号 (来自1101接口返回)
  1689. inputData["phar_cert_type"] = struct3505.PharCertType // 人员编号 (来自1101接口返回)
  1690. inputData["phar_certno"] = struct3505.PharCertno // 人员编号 (来自1101接口返回)
  1691. inputData["phar_name"] = struct3505.PharName // 人员编号 (来自1101接口返回)
  1692. inputData["phar_prac_cert_no"] = struct3505.PharPracCertNo // 人员编号 (来自1101接口返回)
  1693. inputData["hi_feesetl_type"] = struct3505.HiFeesetlType // 人员编号 (来自1101接口返回)
  1694. inputData["setl_id"] = struct3505.SetlId // 人员编号 (来自1101接口返回)
  1695. inputData["mdtrt_sn"] = struct3505.MdtrtSn // 人员编号 (来自1101接口返回)
  1696. inputData["psn_no"] = struct3505.PsnNo // 人员编号 (来自1101接口返回)
  1697. inputData["psn_cert_type"] = struct3505.PsnCertType // 人员编号 (来自1101接口返回)
  1698. inputData["certno"] = struct3505.CertNo // 人员编号 (来自1101接口返回)
  1699. inputData["psn_name"] = struct3505.PsnName // 人员编号 (来自1101接口返回)
  1700. inputData["manu_lotnum"] = struct3505.ManuLotnum // 人员编号 (来自1101接口返回)
  1701. inputData["manu_date"] = struct3505.ManuDate // 人员编号 (来自1101接口返回)
  1702. inputData["expy_end"] = struct3505.ExpyEnd // 人员编号 (来自1101接口返回)
  1703. inputData["rx_flag"] = struct3505.RxFlag // 人员编号 (来自1101接口返回)
  1704. inputData["trdn_flag"] = struct3505.TrdnFlag // 人员编号 (来自1101接口返回)
  1705. inputData["finl_trns_pric"] = struct3505.FinlTrnsPric // 人员编号 (来自1101接口返回)
  1706. inputData["rxno"] = struct3505.Rxno // 人员编号 (来自1101接口返回)
  1707. inputData["rx_circ_flag"] = struct3505.RxCircFlag // 人员编号 (来自1101接口返回)
  1708. inputData["rtal_docno"] = struct3505.RtalDocno // 人员编号 (来自1101接口返回)
  1709. inputData["stoout_no"] = struct3505.StooutNo // 人员编号 (来自1101接口返回)
  1710. inputData["bchno"] = struct3505.Bchno // 人员编号 (来自1101接口返回)
  1711. inputData["drug_trac_codg"] = struct3505.DrugTracCodg // 人员编号 (来自1101接口返回)
  1712. inputData["drug_prod_barc"] = struct3505.DrugProdBarc // 人员编号 (来自1101接口返回)
  1713. inputData["shelf_posi"] = struct3505.ShelfPosi // 人员编号 (来自1101接口返回)
  1714. inputData["sel_retn_cnt"] = struct3505.SelRetnCnt // 人员编号 (来自1101接口返回)
  1715. inputData["sel_retn_time"] = struct3505.SelRetnTime // 人员编号 (来自1101接口返回)
  1716. inputData["sel_retn_opter_name"] = struct3505.SelRetnOpterName // 人员编号 (来自1101接口返回)
  1717. inputData["memo"] = struct3505.Memo // 人员编号 (来自1101接口返回)
  1718. input["selinfo"] = inputData
  1719. inputMessage["input"] = input //交易输入
  1720. bytesData, err := json.Marshal(inputMessage)
  1721. fmt.Println(string(bytesData))
  1722. if err != nil {
  1723. fmt.Println(err.Error())
  1724. return err.Error(), ""
  1725. }
  1726. struct3505.RequestUrl = struct3505.RequestUrl + "3505"
  1727. return HNHttpRequest(struct3505.RequestUrl, struct3505.AccessKey, struct3505.SecretKey, timestamp, string(bytesData), "3505"), string(bytesData)
  1728. }
  1729. func Hnyb3506(struct3506 models.Struct3506) (string, string) {
  1730. timestamp := time.Now().Unix()
  1731. // 生成输入报文
  1732. inputMessage := SetHnInputMessage(timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsCode, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs, struct3506.Cainfo)
  1733. input := make(map[string]interface{})
  1734. inputData := make(map[string]interface{})
  1735. inputMessage["infno"] = "3506" // 交易编码
  1736. inputData["med_list_codg"] = struct3506.MedListCodg // 定点医药机构目录编号
  1737. inputData["fixmedins_hilist_id"] = struct3506.FixmedinsHilistId // 定点医药机构目录编号
  1738. inputData["fixmedins_hilist_name"] = struct3506.OrgName // 定点医药机构目录名称
  1739. inputData["fixmedins_bchno"] = struct3506.FixmedinsBchno // 人员编号 (来自1101接口返回)
  1740. inputData["setl_id"] = struct3506.SetlId // 人员编号 (来自1101接口返回)
  1741. inputData["psn_no"] = struct3506.PsnNo // 人员编号 (来自1101接口返回)
  1742. inputData["psn_cert_type"] = struct3506.PsnCertType // 人员编号 (来自1101接口返回)
  1743. inputData["certno"] = struct3506.Certno // 人员编号 (来自1101接口返回)
  1744. inputData["psn_name"] = struct3506.PsnName // 人员编号 (来自1101接口返回)
  1745. inputData["manu_lotnum"] = struct3506.ManuLotnum // 人员编号 (来自1101接口返回)
  1746. inputData["manu_date"] = struct3506.ManuDate // 人员编号 (来自1101接口返回)
  1747. inputData["expy_end"] = struct3506.ExpyEnd // 人员编号 (来自1101接口返回)
  1748. inputData["rx_flag"] = struct3506.RxFlag // 人员编号 (来自1101接口返回)
  1749. inputData["trdn_flag"] = struct3506.TrdnFlag // 人员编号 (来自1101接口返回)
  1750. inputData["finl_trns_pric"] = struct3506.FinlTrnsPric // 人员编号 (来自1101接口返回)
  1751. inputData["sel_retn_cnt"] = struct3506.SelRetnCnt // 人员编号 (来自1101接口返回)
  1752. inputData["sel_retn_time"] = struct3506.SelRetnTime // 人员编号 (来自1101接口返回)
  1753. inputData["sel_retn_opter_name"] = struct3506.SelRetnOpterName // 人员编号 (来自1101接口返回)
  1754. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  1755. inputData["medins_prod_sel_no"] = "" // 人员编号 (来自1101接口返回)
  1756. input["selinfo"] = inputData
  1757. inputMessage["input"] = input //交易输入
  1758. bytesData, err := json.Marshal(inputMessage)
  1759. fmt.Println(string(bytesData))
  1760. if err != nil {
  1761. fmt.Println(err.Error())
  1762. return err.Error(), ""
  1763. }
  1764. struct3506.RequestUrl = struct3506.RequestUrl + "3506"
  1765. return HNHttpRequest(struct3506.RequestUrl, struct3506.AccessKey, struct3506.SecretKey, timestamp, string(bytesData), "3506"), string(bytesData)
  1766. }
  1767. func Hnyb3507(struct3507 models.Struct3507) (string, string) {
  1768. timestamp := time.Now().Unix()
  1769. // 生成输入报文
  1770. inputMessage := SetHnInputMessage(timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, struct3507.Cainfo)
  1771. input := make(map[string]interface{})
  1772. inputData := make(map[string]interface{})
  1773. inputMessage["infno"] = "3507" // 交易编码
  1774. inputData["fixmedins_bchno"] = struct3507.FixmedinsCode // 人员编号 (来自1101接口返回)
  1775. inputData["inv_data_type"] = struct3507.InvDataType // 人员编号 (来自1101接口返回)
  1776. input["data"] = inputData
  1777. inputMessage["input"] = input //交易输入
  1778. bytesData, err := json.Marshal(inputMessage)
  1779. fmt.Println(string(bytesData))
  1780. if err != nil {
  1781. fmt.Println(err.Error())
  1782. return err.Error(), ""
  1783. }
  1784. struct3507.RequestUrl = struct3507.RequestUrl + "3507"
  1785. return HNHttpRequest(struct3507.RequestUrl, struct3507.AccessKey, struct3507.SecretKey, timestamp, string(bytesData), "3507"), string(bytesData)
  1786. }
  1787. func Hnyb3301(org_name string,opera string,fixmedins_code string,insuplc_admdvs string,mdtrtarea_admvs string,cainfo string, name string, codg string, list_type string,start_time string, ent_time string, request_url string,access_key string,secret_key string) (string,string) {
  1788. // 生成签名
  1789. //nonce := GetRandomString(32)
  1790. // 生成签名
  1791. timestamp := time.Now().Unix()
  1792. //tempTime := time.Unix(timestamp, 0)
  1793. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1794. inputMessage := SetHnInputMessage(timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  1795. // 生成输入报文
  1796. //inputMessage := SetHnInputMessage(timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.Cainfo)
  1797. //inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1798. input := make(map[string]interface{})
  1799. inputData := make(map[string]interface{})
  1800. inputMessage["infno"] = "3301" // 交易编码
  1801. inputData["fixmedins_hilist_id"] = codg
  1802. inputData["fixmedins_hilist_name"] = name
  1803. inputData["list_type"] = list_type
  1804. inputData["med_list_codg"] = codg
  1805. inputData["begndate"] = start_time
  1806. inputData["enddate"] = ent_time
  1807. inputData["aprvno"] = ""
  1808. inputData["dosform"] = ""
  1809. inputData["exct_cont"] = ""
  1810. inputData["item_cont"] = ""
  1811. inputData["prcunt"] = ""
  1812. inputData["spec"] = ""
  1813. inputData["pacspec"] = ""
  1814. inputData["memo"] = ""
  1815. input["data"] = inputData
  1816. inputMessage["input"] = input //交易输入
  1817. bytesData, err := json.Marshal(inputMessage)
  1818. fmt.Println(string(bytesData))
  1819. if err != nil {
  1820. fmt.Println(err.Error())
  1821. return err.Error(),""
  1822. }
  1823. request_url = request_url + "3301"
  1824. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  1825. return HNHttpRequest(request_url, access_key, secret_key, timestamp2, string(bytesData), "3301"), string(bytesData)
  1826. }
  1827. func Hnyb3302(org_name string,opera string,fixmedins_code string,insuplc_admdvs string,mdtrtarea_admvs string,cainfo string, name string, codg string, list_type string,start_time string, ent_time string, request_url string,access_key string,secret_key string) (string,string) {
  1828. // 生成签名
  1829. //nonce := GetRandomString(32)
  1830. // 生成签名
  1831. timestamp := time.Now().Unix()
  1832. //tempTime := time.Unix(timestamp, 0)
  1833. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1834. inputMessage := SetHnInputMessage(timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  1835. // 生成输入报文
  1836. //inputMessage := SetHnInputMessage(timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.Cainfo)
  1837. //inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1838. input := make(map[string]interface{})
  1839. inputData := make(map[string]interface{})
  1840. inputMessage["infno"] = "3302" // 交易编码
  1841. inputData["fixmedins_code"] = fixmedins_code
  1842. inputData["fixmedins_hilist_id"] = codg
  1843. inputData["list_type"] = list_type
  1844. inputData["med_list_codg"] = codg
  1845. input["data"] = inputData
  1846. inputMessage["input"] = input //交易输入
  1847. bytesData, err := json.Marshal(inputMessage)
  1848. fmt.Println(string(bytesData))
  1849. if err != nil {
  1850. fmt.Println(err.Error())
  1851. return err.Error(),""
  1852. }
  1853. request_url = request_url + "3302"
  1854. timestamp2 := time.Now().UnixNano() / int64(time.Millisecond)
  1855. return HNHttpRequest(request_url, access_key, secret_key, timestamp2, string(bytesData), "3302"), string(bytesData)
  1856. }