zh_his_api_controller.go 116KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444
  1. package zh
  2. import (
  3. "bytes"
  4. "encoding/json"
  5. "fmt"
  6. "gdyb/controllers"
  7. "gdyb/enums"
  8. "gdyb/models"
  9. "gdyb/service"
  10. "gdyb/utils"
  11. "github.com/astaxie/beego"
  12. "github.com/axgle/mahonia"
  13. "github.com/jinzhu/gorm"
  14. "io/ioutil"
  15. "math"
  16. "math/rand"
  17. "net/http"
  18. "os"
  19. "regexp"
  20. "strconv"
  21. "strings"
  22. "syscall"
  23. "time"
  24. "unsafe"
  25. )
  26. type ZHHisApiController struct {
  27. controllers.BaseAuthAPIController
  28. }
  29. type ResultSix struct {
  30. Cainfo interface{} `json:"cainfo"`
  31. ErrMsg string `json:"err_msg"`
  32. InfRefmsgid string `json:"inf_refmsgid"`
  33. Infcode int64 `json:"infcode"`
  34. Output struct {
  35. } `json:"output"`
  36. RefmsgTime string `json:"refmsg_time"`
  37. RespondTime string `json:"respond_time"`
  38. Signtype interface{} `json:"signtype"`
  39. WarnMsg interface{} `json:"warn_msg"`
  40. }
  41. type ResultTwo struct {
  42. ErrMsg string `json:"err_msg"`
  43. InfRefmsgid string `json:"inf_refmsgid"`
  44. Infcode int64 `json:"infcode"`
  45. Output struct {
  46. Baseinfo struct {
  47. Age float64 `json:"age"`
  48. Brdy string `json:"brdy"`
  49. Certno string `json:"certno"`
  50. Gend string `json:"gend"`
  51. Naty string `json:"naty"`
  52. PsnCertType string `json:"psn_cert_type"`
  53. PsnName string `json:"psn_name"`
  54. PsnNo string `json:"psn_no"`
  55. } `json:"baseinfo"`
  56. Idetinfo []interface{} `json:"idetinfo"`
  57. Iinfo []struct {
  58. Balc float64 `json:"balc"`
  59. CvlservFlag string `json:"cvlserv_flag"`
  60. EmpName string `json:"emp_name"`
  61. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  62. Insutype string `json:"insutype"`
  63. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  64. PausInsuDate string `json:"paus_insu_date"`
  65. PsnInsuDate string `json:"psn_insu_date"`
  66. PsnInsuStas string `json:"psn_insu_stas"`
  67. PsnType string `json:"psn_type"`
  68. } `json:"insuinfo"`
  69. } `json:"output"`
  70. RefmsgTime string `json:"refmsg_time"`
  71. RespondTime string `json:"respond_time"`
  72. Signtype interface{} `json:"signtype"`
  73. WarnInfo interface{} `json:"warn_info"`
  74. }
  75. type ResultTwo10265 struct {
  76. ErrMsg string `json:"err_msg"`
  77. InfRefmsgid string `json:"inf_refmsgid"`
  78. Infcode string `json:"infcode"`
  79. Output struct {
  80. Baseinfo struct {
  81. Age float64 `json:"age"`
  82. Brdy string `json:"brdy"`
  83. Certno string `json:"certno"`
  84. Gend string `json:"gend"`
  85. Naty string `json:"naty"`
  86. PsnCertType string `json:"psn_cert_type"`
  87. PsnName string `json:"psn_name"`
  88. PsnNo string `json:"psn_no"`
  89. } `json:"baseinfo"`
  90. Idetinfo []interface{} `json:"idetinfo"`
  91. Iinfo []struct {
  92. Balc float64 `json:"balc"`
  93. CvlservFlag string `json:"cvlserv_flag"`
  94. EmpName string `json:"emp_name"`
  95. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  96. Insutype string `json:"insutype"`
  97. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  98. PausInsuDate string `json:"paus_insu_date"`
  99. PsnInsuDate string `json:"psn_insu_date"`
  100. PsnInsuStas string `json:"psn_insu_stas"`
  101. PsnType string `json:"psn_type"`
  102. } `json:"insuinfo"`
  103. } `json:"output"`
  104. RefmsgTime string `json:"refmsg_time"`
  105. RespondTime string `json:"respond_time"`
  106. Signtype interface{} `json:"signtype"`
  107. WarnInfo interface{} `json:"warn_info"`
  108. }
  109. type ResultThree struct {
  110. Cainfo interface{} `json:"cainfo"`
  111. ErrMsg string `json:"err_msg"`
  112. InfRefmsgid string `json:"inf_refmsgid"`
  113. Infcode int64 `json:"infcode"`
  114. Output struct {
  115. Result struct {
  116. MdtrtID string `json:"mdtrt_id"`
  117. } `json:"result"`
  118. } `json:"output"`
  119. RefmsgTime string `json:"refmsg_time"`
  120. RespondTime string `json:"respond_time"`
  121. Signtype interface{} `json:"signtype"`
  122. WarnMsg interface{} `json:"warn_msg"`
  123. }
  124. type ResultThree10265 struct {
  125. Cainfo interface{} `json:"cainfo"`
  126. ErrMsg string `json:"err_msg"`
  127. InfRefmsgid string `json:"inf_refmsgid"`
  128. Infcode string `json:"infcode"`
  129. Output struct {
  130. Result struct {
  131. MdtrtID string `json:"mdtrt_id"`
  132. } `json:"result"`
  133. } `json:"output"`
  134. RefmsgTime string `json:"refmsg_time"`
  135. RespondTime string `json:"respond_time"`
  136. Signtype interface{} `json:"signtype"`
  137. WarnMsg interface{} `json:"warn_msg"`
  138. }
  139. type ResultFour struct {
  140. Cainfo string `json:"cainfo"`
  141. ErrMsg string `json:"err_msg"`
  142. InfRefmsgid string `json:"inf_refmsgid"`
  143. Infcode int64 `json:"infcode"`
  144. Output struct {
  145. Result []struct {
  146. BasMednFlag string `json:"bas_medn_flag"`
  147. ChldMedcFlag string `json:"chld_medc_flag"`
  148. ChrgitmLv string `json:"chrgitm_lv"`
  149. Cnt float64 `json:"cnt"`
  150. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  151. DrtReimFlag string `json:"drt_reim_flag"`
  152. FeedetlSn string `json:"feedetl_sn"`
  153. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  154. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  155. InscpScpAmt float64 `json:"inscp_scp_amt"`
  156. ListSpItemFlag string `json:"list_sp_item_flag"`
  157. LmtUsedFlag string `json:"lmt_used_flag"`
  158. MedChrgitmType string `json:"med_chrgitm_type"`
  159. Memo string `json:"memo"`
  160. OverlmtAmt float64 `json:"overlmt_amt"`
  161. PreselfpayAmt float64 `json:"preselfpay_amt"`
  162. Pric float64 `json:"pric"`
  163. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  164. SelfpayProp float64 `json:"selfpay_prop"`
  165. } `json:"result"`
  166. } `json:"output"`
  167. RefmsgTime string `json:"refmsg_time"`
  168. RespondTime string `json:"respond_time"`
  169. Signtype string `json:"signtype"`
  170. WarnMsg string `json:"warn_msg"`
  171. }
  172. type ResultFour10265 struct {
  173. Cainfo string `json:"cainfo"`
  174. ErrMsg string `json:"err_msg"`
  175. InfRefmsgid string `json:"inf_refmsgid"`
  176. Infcode string `json:"infcode"`
  177. Output struct {
  178. Result []struct {
  179. BasMednFlag string `json:"bas_medn_flag"`
  180. ChldMedcFlag string `json:"chld_medc_flag"`
  181. ChrgitmLv string `json:"chrgitm_lv"`
  182. Cnt float64 `json:"cnt"`
  183. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  184. DrtReimFlag string `json:"drt_reim_flag"`
  185. FeedetlSn string `json:"feedetl_sn"`
  186. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  187. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  188. InscpScpAmt float64 `json:"inscp_scp_amt"`
  189. ListSpItemFlag string `json:"list_sp_item_flag"`
  190. LmtUsedFlag string `json:"lmt_used_flag"`
  191. MedChrgitmType string `json:"med_chrgitm_type"`
  192. Memo string `json:"memo"`
  193. OverlmtAmt float64 `json:"overlmt_amt"`
  194. PreselfpayAmt float64 `json:"preselfpay_amt"`
  195. Pric float64 `json:"pric"`
  196. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  197. SelfpayProp float64 `json:"selfpay_prop"`
  198. } `json:"result"`
  199. } `json:"output"`
  200. RefmsgTime string `json:"refmsg_time"`
  201. RespondTime string `json:"respond_time"`
  202. Signtype string `json:"signtype"`
  203. WarnMsg string `json:"warn_msg"`
  204. }
  205. type ResultFive struct {
  206. Balc float64 `json:"balc"`
  207. CvlservFlag string `json:"cvlserv_flag"`
  208. EmpName string `json:"emp_name"`
  209. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  210. Insutype string `json:"insutype"`
  211. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  212. PausInsuDate string `json:"paus_insu_date"`
  213. PsnInsuDate string `json:"psn_insu_date"`
  214. PsnInsuStas string `json:"psn_insu_stas"`
  215. PsnType string `json:"psn_type"`
  216. }
  217. type ResultSeven struct {
  218. Cainfo string `json:"cainfo"`
  219. ErrMsg string `json:"err_msg"`
  220. InfRefmsgid string `json:"inf_refmsgid"`
  221. Infcode int64 `json:"infcode"`
  222. Output struct {
  223. Setldetail []interface{} `json:"setldetail"`
  224. Setlinfo struct {
  225. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  226. AcctPay float64 `json:"acct_pay"`
  227. ActPayDedc float64 `json:"act_pay_dedc"`
  228. Age float64 `json:"age"`
  229. Balc float64 `json:"balc"`
  230. Brdy string `json:"brdy"`
  231. Certno string `json:"certno"`
  232. ClrOptins string `json:"clr_optins"`
  233. ClrType string `json:"clr_type"`
  234. ClrWay string `json:"clr_way"`
  235. CvlservFlag string `json:"cvlserv_flag"`
  236. CvlservPay float64 `json:"cvlserv_pay"`
  237. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  238. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  239. Gend string `json:"gend"`
  240. HifesPay float64 `json:"hifes_pay"`
  241. HifmiPay float64 `json:"hifmi_pay"`
  242. HifpPay float64 `json:"hifp_pay"`
  243. HospPartAmt float64 `json:"hosp_part_amt"`
  244. InscpScpAmt float64 `json:"inscp_scp_amt"`
  245. Insutype string `json:"insutype"`
  246. MafPay float64 `json:"maf_pay"`
  247. MdtrtCertType string `json:"mdtrt_cert_type"`
  248. HifobPay float64 `json:"hifob_pay"`
  249. MdtrtID string `json:"mdtrt_id"`
  250. MedType string `json:"med_type"`
  251. MedfeeSumamt float64 `json:"medfee_sumamt"`
  252. MedinsSetlID string `json:"medins_setl_id"`
  253. Naty string `json:"naty"`
  254. OthPay float64 `json:"oth_pay"`
  255. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  256. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  257. PreselfpayAmt float64 `json:"preselfpay_amt"`
  258. PsnCashPay float64 `json:"psn_cash_pay"`
  259. PsnCertType string `json:"psn_cert_type"`
  260. PsnName string `json:"psn_name"`
  261. PsnNo string `json:"psn_no"`
  262. PsnPartAmt float64 `json:"psn_part_amt"`
  263. PsnType string `json:"psn_type"`
  264. SetlID string `json:"setl_id"`
  265. SetlTime string `json:"setl_time"`
  266. } `json:"setlinfo"`
  267. } `json:"output"`
  268. RefmsgTime string `json:"refmsg_time"`
  269. RespondTime string `json:"respond_time"`
  270. Signtype interface{} `json:"signtype"`
  271. WarnMsg interface{} `json:"warn_msg"`
  272. }
  273. type ResultSeven10265 struct {
  274. Cainfo string `json:"cainfo"`
  275. ErrMsg string `json:"err_msg"`
  276. InfRefmsgid string `json:"inf_refmsgid"`
  277. Infcode string `json:"infcode"`
  278. Output struct {
  279. Setldetail []interface{} `json:"setldetail"`
  280. Setlinfo struct {
  281. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  282. AcctPay float64 `json:"acct_pay"`
  283. ActPayDedc float64 `json:"act_pay_dedc"`
  284. Age float64 `json:"age"`
  285. Balc float64 `json:"balc"`
  286. Brdy string `json:"brdy"`
  287. Certno string `json:"certno"`
  288. ClrOptins string `json:"clr_optins"`
  289. ClrType string `json:"clr_type"`
  290. ClrWay string `json:"clr_way"`
  291. CvlservFlag string `json:"cvlserv_flag"`
  292. CvlservPay float64 `json:"cvlserv_pay"`
  293. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  294. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  295. Gend string `json:"gend"`
  296. HifesPay float64 `json:"hifes_pay"`
  297. HifmiPay float64 `json:"hifmi_pay"`
  298. HifpPay float64 `json:"hifp_pay"`
  299. HospPartAmt float64 `json:"hosp_part_amt"`
  300. InscpScpAmt float64 `json:"inscp_scp_amt"`
  301. Insutype string `json:"insutype"`
  302. MafPay float64 `json:"maf_pay"`
  303. MdtrtCertType string `json:"mdtrt_cert_type"`
  304. HifobPay float64 `json:"hifob_pay"`
  305. MdtrtID string `json:"mdtrt_id"`
  306. MedType string `json:"med_type"`
  307. MedfeeSumamt float64 `json:"medfee_sumamt"`
  308. MedinsSetlID string `json:"medins_setl_id"`
  309. Naty string `json:"naty"`
  310. OthPay float64 `json:"oth_pay"`
  311. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  312. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  313. PreselfpayAmt float64 `json:"preselfpay_amt"`
  314. PsnCashPay float64 `json:"psn_cash_pay"`
  315. PsnCertType string `json:"psn_cert_type"`
  316. PsnName string `json:"psn_name"`
  317. PsnNo string `json:"psn_no"`
  318. PsnPartAmt float64 `json:"psn_part_amt"`
  319. PsnType string `json:"psn_type"`
  320. SetlID string `json:"setl_id"`
  321. SetlTime string `json:"setl_time"`
  322. } `json:"setlinfo"`
  323. } `json:"output"`
  324. RefmsgTime string `json:"refmsg_time"`
  325. RespondTime string `json:"respond_time"`
  326. Signtype interface{} `json:"signtype"`
  327. WarnMsg interface{} `json:"warn_msg"`
  328. }
  329. type ResultSixteen struct {
  330. Cainfo string `json:"cainfo"`
  331. ErrMsg string `json:"err_msg"`
  332. InfRefmsgid string `json:"inf_refmsgid"`
  333. Infcode int64 `json:"infcode"`
  334. Output struct {
  335. Setldetail []interface{} `json:"setldetail"`
  336. Setlinfo struct {
  337. MdtrtID string `json:"mdtrt_id"`
  338. SetlID string `json:"setl_id"`
  339. ClrOptins string `json:"clr_optins"`
  340. SetlTime string `json:"setl_time"`
  341. MedfeeSumamt float64 `json:"medfee_sumamt"`
  342. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  343. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  344. PreselfpayAmt float64 `json:"preselfpay_amt"`
  345. InscpScpAmt float64 `json:"inscp_scp_amt"`
  346. ActPayDedc float64 `json:"act_pay_dedc"`
  347. HifpPay float64 `json:"hifp_pay"`
  348. PoolPropSe float64 `json:"pool_prop_selfpay"`
  349. Lfpay float64 `json:"selfpay"`
  350. CvlservPay float64 `json:"cvlserv_pay"`
  351. HifesPay float64 `json:"hifes_pay"`
  352. HifmiPay float64 `json:"hifmi_pay"`
  353. HifobPay float64 `json:"hifob_pay"`
  354. MafPay float64 `json:"maf_pay"`
  355. OthPay float64 `json:"oth_pay"`
  356. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  357. PsnPartAmt float64 `json:"psn_part_amt"`
  358. AcctPay float64 `json:"acct_pay"`
  359. Balc float64 `json:"balc"`
  360. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  361. HospPartAmt float64 `json:"hosp_part_amt"`
  362. MedinsSetlID string `json:"medins_setl_id"`
  363. PdnCashPay string `json:"pdn_cash_pay"`
  364. } `json:"setlinfo"`
  365. } `json:"output"`
  366. RefmsgTime string `json:"refmsg_time"`
  367. RespondTime string `json:"respond_time"`
  368. Signtype interface{} `json:"signtype"`
  369. WarnMsg interface{} `json:"warn_msg"`
  370. }
  371. type ResultSixteen10265 struct {
  372. Cainfo string `json:"cainfo"`
  373. ErrMsg string `json:"err_msg"`
  374. InfRefmsgid string `json:"inf_refmsgid"`
  375. Infcode string `json:"infcode"`
  376. Output struct {
  377. Setldetail []interface{} `json:"setldetail"`
  378. Setlinfo struct {
  379. MdtrtID string `json:"mdtrt_id"`
  380. SetlID string `json:"setl_id"`
  381. ClrOptins string `json:"clr_optins"`
  382. SetlTime string `json:"setl_time"`
  383. MedfeeSumamt float64 `json:"medfee_sumamt"`
  384. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  385. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  386. PreselfpayAmt float64 `json:"preselfpay_amt"`
  387. InscpScpAmt float64 `json:"inscp_scp_amt"`
  388. ActPayDedc float64 `json:"act_pay_dedc"`
  389. HifpPay float64 `json:"hifp_pay"`
  390. PoolPropSe float64 `json:"pool_prop_selfpay"`
  391. Lfpay float64 `json:"selfpay"`
  392. CvlservPay float64 `json:"cvlserv_pay"`
  393. HifesPay float64 `json:"hifes_pay"`
  394. HifmiPay float64 `json:"hifmi_pay"`
  395. HifobPay float64 `json:"hifob_pay"`
  396. MafPay float64 `json:"maf_pay"`
  397. OthPay float64 `json:"oth_pay"`
  398. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  399. PsnPartAmt float64 `json:"psn_part_amt"`
  400. AcctPay float64 `json:"acct_pay"`
  401. Balc float64 `json:"balc"`
  402. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  403. HospPartAmt float64 `json:"hosp_part_amt"`
  404. MedinsSetlID string `json:"medins_setl_id"`
  405. PdnCashPay string `json:"pdn_cash_pay"`
  406. } `json:"setlinfo"`
  407. } `json:"output"`
  408. RefmsgTime string `json:"refmsg_time"`
  409. RespondTime string `json:"respond_time"`
  410. Signtype interface{} `json:"signtype"`
  411. WarnMsg interface{} `json:"warn_msg"`
  412. }
  413. type Custom struct {
  414. DetItemFeeSumamt string
  415. Cut string
  416. FeedetlSn string
  417. Price string
  418. MedListCodg string
  419. Type int64
  420. AdviceId int64
  421. ProjectId int64
  422. ItemId int64
  423. }
  424. type ResultEmpty struct {
  425. Cainfo interface{} `json:"cainfo"`
  426. ErrMsg string `json:"err_msg"`
  427. InfRefmsgid string `json:"inf_refmsgid"`
  428. Infcode int64 `json:"infcode"`
  429. Output struct {
  430. } `json:"output"`
  431. RefmsgTime string `json:"refmsg_time"`
  432. RespondTime string `json:"respond_time"`
  433. Signtype interface{} `json:"signtype"`
  434. WarnMsg interface{} `json:"warn_msg"`
  435. }
  436. type ResultEmpty10265 struct {
  437. Cainfo interface{} `json:"cainfo"`
  438. ErrMsg string `json:"err_msg"`
  439. InfRefmsgid string `json:"inf_refmsgid"`
  440. Infcode string `json:"infcode"`
  441. Output struct {
  442. } `json:"output"`
  443. RefmsgTime string `json:"refmsg_time"`
  444. RespondTime string `json:"respond_time"`
  445. Signtype interface{} `json:"signtype"`
  446. WarnMsg interface{} `json:"warn_msg"`
  447. }
  448. type CustomResult struct {
  449. BasMednFlag string `json:"bas_medn_flag"`
  450. ChldMedcFlag string `json:"chld_medc_flag"`
  451. ChrgitmLv string `json:"chrgitm_lv"`
  452. Cnt float64 `json:"cnt"`
  453. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  454. DrtReimFlag string `json:"drt_reim_flag"`
  455. FeedetlSn string `json:"feedetl_sn"`
  456. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  457. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  458. InscpScpAmt float64 `json:"inscp_scp_amt"`
  459. ListSpItemFlag string `json:"list_sp_item_flag"`
  460. LmtUsedFlag string `json:"lmt_used_flag"`
  461. MedChrgitmType string `json:"med_chrgitm_type"`
  462. Memo string `json:"memo"`
  463. OverlmtAmt float64 `json:"overlmt_amt"`
  464. PreselfpayAmt float64 `json:"preselfpay_amt"`
  465. Pric float64 `json:"pric"`
  466. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  467. SelfpayProp float64 `json:"selfpay_prop"`
  468. }
  469. func ZHHisManagerApiRegistRouters() {
  470. beego.Router("/zh/api/inhopitalcheck/get", &ZHHisApiController{}, "get:GetZHInHospitalCheck")
  471. beego.Router("/zh/api/outhopitalcheck/get", &ZHHisApiController{}, "get:GetZHOutHospitalCheck")
  472. beego.Router("/zh/api/uploadinfo/get", &ZHHisApiController{}, "get:GetUploadInfo")
  473. beego.Router("/zh/api/presettle/get", &ZHHisApiController{}, "get:GetPreSettleInfo")
  474. beego.Router("/zh/api/settle/get", &ZHHisApiController{}, "get:GetSettleInfo")
  475. beego.Router("/zh/api/inthopitaluncheck/get", &ZHHisApiController{}, "get:GetZHInHospitalUnCheck")
  476. beego.Router("/zh/api/outhopitaluncheck/get", &ZHHisApiController{}, "get:GetZHOutHospitalUnCheck")
  477. beego.Router("/zh/api/refund", &ZHHisApiController{}, "get:ZHRefund")
  478. beego.Router("/zh/api/refunddetail", &ZHHisApiController{}, "get:ZHRefundDetail")
  479. beego.Router("/zh/api/patient/info", &ZHHisApiController{}, "get:GetZHPatientInfo")
  480. beego.Router("/zh/api/readcard", &ZHHisApiController{}, "get:ReadCard")
  481. beego.Router("/zh/api/clearsettle", &ZHHisApiController{}, "get:ClearSettle")
  482. }
  483. func (c *ZHHisApiController) ClearSettle() {
  484. order_id, _ := c.GetInt64("order_id")
  485. admin_user_id, _ := c.GetInt64("admin_user_id")
  486. adminUser := c.GetAdminUserInfo()
  487. var order models.HisOrder
  488. order, _ = service.GetHisOrderByID(order_id)
  489. record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  490. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  491. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  492. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  493. if config.IsOpen == 1 { //对接了医保,走医保流程
  494. var result string
  495. var requestLog string
  496. result, requestLog = service.Gdyb90306(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  497. saveLog(result, requestLog, "90306", "撤销结算清单")
  498. var dat map[string]interface{}
  499. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  500. fmt.Println(dat)
  501. } else {
  502. fmt.Println(err)
  503. }
  504. userJSONBytes, _ := json.Marshal(dat)
  505. var res ResultSix
  506. //var resSixteen ResultSixteen10265
  507. if miConfig.Code == "H15049901371" {
  508. //if err := json.Unmarshal(userJSONBytes, &resSixteen); err != nil {
  509. // utils.ErrorLog("解析失败:%v", err)
  510. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  511. // return
  512. //}
  513. //res.Cainfo = resSixteen.Cainfo
  514. //res.WarnMsg = resSixteen.WarnMsg
  515. //res.Output = resSixteen.Output
  516. //res.ErrMsg = resSixteen.ErrMsg
  517. //res.RespondTime = resSixteen.RespondTime
  518. //Infcode, _ := strconv.ParseInt(resSixteen.Infcode, 10, 64)
  519. //res.Infcode = Infcode
  520. } else {
  521. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  522. utils.ErrorLog("解析失败:%v", err)
  523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  524. return
  525. }
  526. }
  527. if res.Infcode == 0 {
  528. record, _ := service.GetUploadRecord(order_id)
  529. record.Status = 0
  530. service.UpdateRecord(&record)
  531. c.ServeSuccessJSON(map[string]interface{}{
  532. "msg": "撤销成功",
  533. })
  534. } else {
  535. c.ServeSuccessJSON(map[string]interface{}{
  536. "code": -10,
  537. "msg": res.ErrMsg,
  538. })
  539. }
  540. }
  541. }
  542. func (c *ZHHisApiController) GetZHPatientInfo() {
  543. id_card_no := c.GetString("id_card_no")
  544. admin_user_id, _ := c.GetInt64("admin_user_id")
  545. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  546. if patient.ID == 0 {
  547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  548. return
  549. }
  550. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  551. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  552. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  553. if config.IsOpen == 1 {
  554. var result string
  555. var request_log string
  556. var result_log string
  557. if miConfig.MdtrtareaAdmvs == "150499" {
  558. //请求内网数据
  559. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  560. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  561. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&name=" + patient.Name
  562. resp, requestErr := http.Get(api)
  563. if requestErr != nil {
  564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  565. return
  566. }
  567. body, ioErr := ioutil.ReadAll(resp.Body)
  568. if ioErr != nil {
  569. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  571. return
  572. }
  573. var respJSON map[string]interface{}
  574. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  577. return
  578. }
  579. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  580. result_byte, _ := json.Marshal(respJSON)
  581. result = string(result_byte)
  582. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  583. } else {
  584. result, request_log, result_log = service.ZHGdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", 1, patient.Name)
  585. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  586. }
  587. //result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  588. var dat map[string]interface{}
  589. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  590. fmt.Println(dat)
  591. } else {
  592. fmt.Println(err)
  593. }
  594. userJSONBytes, _ := json.Marshal(dat)
  595. var res ResultTwo
  596. var resTwo10265 ResultTwo10265
  597. if miConfig.Code == "H15049901371" {
  598. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  599. utils.ErrorLog("解析失败:%v", err)
  600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  601. return
  602. }
  603. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  604. res.Infcode = Infcode
  605. res.ErrMsg = resTwo10265.ErrMsg
  606. res.Output = resTwo10265.Output
  607. res.InfRefmsgid = resTwo10265.InfRefmsgid
  608. res.RespondTime = resTwo10265.RespondTime
  609. res.WarnInfo = resTwo10265.WarnInfo
  610. } else {
  611. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  612. utils.ErrorLog("解析失败:%v", err)
  613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  614. return
  615. }
  616. }
  617. var insutypes []string
  618. var insutype string
  619. var is390 int = 0
  620. var is310 int = 0
  621. for _, item := range res.Output.Iinfo {
  622. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  623. insutypes = append(insutypes, item.Insutype)
  624. }
  625. }
  626. if len(insutypes) == 1 {
  627. insutype = insutypes[0]
  628. } else {
  629. for _, i := range insutypes {
  630. if i == "390" {
  631. is390 = 1
  632. }
  633. if i == "310" {
  634. is310 = 1
  635. }
  636. }
  637. }
  638. if is390 == 1 {
  639. insutype = "390"
  640. }
  641. if is310 == 1 {
  642. insutype = "310"
  643. }
  644. if len(insutypes) == 0 {
  645. insutype = "310"
  646. }
  647. if res.Infcode != 0 {
  648. c.ServeSuccessJSON(map[string]interface{}{
  649. "failed_code": -10,
  650. "msg": res.ErrMsg,
  651. })
  652. } else {
  653. c.ServeSuccessJSON(map[string]interface{}{
  654. "failed_code": 0,
  655. "info": res,
  656. "insutype": insutype,
  657. })
  658. }
  659. }
  660. }
  661. func (c *ZHHisApiController) GetZHInHospitalCheck() {
  662. id, _ := c.GetInt64("id")
  663. record_time := c.GetString("record_time")
  664. name := c.GetString("name")
  665. phone := c.GetString("phone")
  666. id_card_type, _ := c.GetInt64("id_card_type")
  667. certificates, _ := c.GetInt64("certificates")
  668. id_card_no := c.GetString("id_card_no")
  669. doctor, _ := c.GetInt64("doctor")
  670. admin_user_id, _ := c.GetInt64("admin_user_id")
  671. department, _ := c.GetInt64("department")
  672. adm_bed, _ := c.GetInt64("adm_bed")
  673. diagnosis_ids := c.GetString("diagnosis")
  674. sick_type, _ := c.GetInt64("sick_type")
  675. start_time := c.GetString("start_time")
  676. insuplc_admdvs := c.GetString("insuplc_admdvs")
  677. balance_accounts_type, _ := c.GetInt64("balance_accounts_type")
  678. social_type, _ := c.GetInt64("social_type")
  679. psn_type, _ := c.GetInt64("psn_type")
  680. //reg_type, _ := c.GetInt64("p_type")
  681. med_type, _ := c.GetInt64("med_type")
  682. diagnosis_ids_arr := strings.Split(diagnosis_ids, "-")
  683. timeLayout := "2006-01-02"
  684. loc, _ := time.LoadLocation("Local")
  685. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  686. if err != nil {
  687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  688. return
  689. }
  690. recordDateTime := theTime.Unix()
  691. adminInfo := c.GetAdminUserInfo()
  692. record, _ := service.GetLastHospitalRecord(id, adminInfo.CurrentOrgId)
  693. if record.ID != 0 {
  694. if record.InHospitalStatus == 1 && record.OutHospitalStatus != 1 {
  695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalExistDataException)
  696. return
  697. }
  698. }
  699. var patient service.Patients
  700. if id == 0 {
  701. patient, _ = service.GetPatientByIDCard(id_card_no, adminInfo.CurrentOrgId)
  702. } else {
  703. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  704. }
  705. diagnosisConfig, _ := service.FindDiagnoseByIds(diagnosis_ids_arr)
  706. sickConfig, _ := service.FindSickById(sick_type)
  707. departmentInfo, _ := service.GetDepartMentDetail(department)
  708. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  709. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  710. var result string
  711. var request_log string
  712. var result_log string
  713. var res2 ResultTwo
  714. var resTwo10265 ResultTwo10265
  715. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  716. if miConfig.MdtrtareaAdmvs == "150499" {
  717. if id_card_type == 2 {
  718. mdtrt_cert_no := ""
  719. card_sn := ""
  720. if record.IdCardType == 1 {
  721. bas := strings.Split(psn_info.CardInfo, "|")
  722. cardNumber := bas[2]
  723. mdtrt_cert_no = cardNumber
  724. card_sn = bas[3]
  725. } else {
  726. mdtrt_cert_no = id_card_no
  727. }
  728. //请求内网数据
  729. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + mdtrt_cert_no +
  730. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  731. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + card_sn + "&certificates=" + strconv.FormatInt(certificates, 10) + "&name=" + patient.Name
  732. resp, requestErr := http.Get(api)
  733. if requestErr != nil {
  734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  735. return
  736. }
  737. body, ioErr := ioutil.ReadAll(resp.Body)
  738. if ioErr != nil {
  739. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  741. return
  742. }
  743. var respJSON map[string]interface{}
  744. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  747. return
  748. }
  749. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  750. result_byte, _ := json.Marshal(respJSON)
  751. result = string(result_byte)
  752. var dat map[string]interface{}
  753. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  754. fmt.Println(dat)
  755. } else {
  756. fmt.Println(err)
  757. }
  758. userJSONBytes, _ := json.Marshal(dat)
  759. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  760. utils.ErrorLog("解析失败:%v", err)
  761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  762. return
  763. }
  764. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  765. res2.Infcode = Infcode
  766. res2.ErrMsg = resTwo10265.ErrMsg
  767. res2.Output = resTwo10265.Output
  768. res2.InfRefmsgid = resTwo10265.InfRefmsgid
  769. res2.RespondTime = resTwo10265.RespondTime
  770. res2.WarnInfo = resTwo10265.WarnInfo
  771. } else {
  772. res2.Infcode = 0
  773. res2.Output.Baseinfo.PsnNo = psn_info.PsnNo
  774. res2.Output.Baseinfo.Certno = patient.IdCardNo
  775. }
  776. } else {
  777. result, request_log, result_log = service.ZHGdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", certificates, name)
  778. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  779. }
  780. doctorInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  781. deviceNumber, _ := service.GetDeviceNumberByID(adm_bed, adminInfo.CurrentOrgId)
  782. if miConfig.MdtrtareaAdmvs != "150499" {
  783. var dat map[string]interface{}
  784. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  785. fmt.Println(dat)
  786. } else {
  787. fmt.Println(err)
  788. }
  789. userJSONBytes, _ := json.Marshal(dat)
  790. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  791. utils.ErrorLog("解析失败:%v", err)
  792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  793. return
  794. }
  795. }
  796. var infoStr string
  797. if miConfig.MdtrtareaAdmvs == "150499" {
  798. if id_card_type == 2 {
  799. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  800. infoStr = string(Iinfos)
  801. } else {
  802. infoStr = psn_info.Insuinfo
  803. }
  804. } else {
  805. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  806. infoStr = string(Iinfos)
  807. }
  808. var rf []*ResultFive
  809. json.Unmarshal([]byte(infoStr), &rf)
  810. var insutypes []*ResultFive
  811. var insutype string
  812. var is390 int = 0
  813. var is310 int = 0
  814. for _, item := range rf {
  815. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  816. insutypes = append(insutypes, item)
  817. }
  818. }
  819. if len(insutypes) == 1 {
  820. insutype = insutypes[0].Insutype
  821. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  822. } else {
  823. for _, i := range insutypes {
  824. if i.Insutype == "390" {
  825. is390 = 1
  826. }
  827. if i.Insutype == "310" {
  828. is310 = 1
  829. }
  830. }
  831. }
  832. if is390 == 1 {
  833. insutype = "390"
  834. }
  835. if is310 == 1 {
  836. insutype = "310"
  837. }
  838. if len(insutypes) == 0 {
  839. insutype = "310"
  840. }
  841. if len(insutypes) == 2 {
  842. insutype = strconv.FormatInt(social_type, 10)
  843. }
  844. //for _, item := range rf {
  845. // if item.Insutype == insutype {
  846. // insuplc_admdvs = item.InsuplcAdmdvs
  847. // }
  848. //}
  849. if res2.Infcode == 0 {
  850. //var insutypes []string
  851. //
  852. //var insutype string
  853. //var is390 int = 0
  854. //var is310 int = 0
  855. //for _, item := range res2.Output.Iinfo {
  856. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  857. // insutypes = append(insutypes, item.Insutype)
  858. // }
  859. //}
  860. //if len(insutypes) == 1 {
  861. // insutype = insutypes[0]
  862. //} else {
  863. // for _, i := range insutypes {
  864. // if i == "390" {
  865. // is390 = 1
  866. // }
  867. //
  868. // if i == "310" {
  869. // is310 = 1
  870. // }
  871. // }
  872. //}
  873. //if is390 == 1 {
  874. // insutype = "390"
  875. //}
  876. //if is310 == 1 {
  877. // insutype = "310"
  878. //}
  879. //
  880. //if len(insutypes) == 0 {
  881. // insutype = "310"
  882. //}
  883. if len(insuplc_admdvs) == 0 {
  884. insuplc_admdvs = miConfig.InsuplcAdmdvs
  885. }
  886. timestamp := time.Now().Unix()
  887. tempTime := time.Unix(timestamp, 0)
  888. timeFormat := tempTime.Format("20060102150405")
  889. chrgBchno := rand.Intn(100000) + 10000
  890. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(id, 10)
  891. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  892. var struct2401 service.Struct2401
  893. struct2401.PsnNo = res2.Output.Baseinfo.PsnNo
  894. struct2401.Insutype = insutype
  895. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  896. if id_card_type == 1 {
  897. struct2401.MdtrtCertType = "03"
  898. bas := strings.Split(psn_info.CardInfo, "|")
  899. cardNumber := bas[2]
  900. struct2401.MdtrtCertNo = cardNumber
  901. } else {
  902. struct2401.MdtrtCertType = "02"
  903. struct2401.MdtrtCertNo = res2.Output.Baseinfo.Certno
  904. }
  905. if miConfig.Code == "H15049901371" {
  906. if med_type == 14 {
  907. if insutype == "390" {
  908. struct2401.MedType = "9933"
  909. } else if insutype == "310" {
  910. struct2401.MedType = "990502"
  911. }
  912. } else if med_type == 11 {
  913. struct2401.MedType = "11"
  914. }
  915. } else {
  916. struct2401.MedType = strconv.FormatInt(int64(med_type), 10)
  917. }
  918. struct2401.IptNo = ipt_otp_no
  919. struct2401.AtddrNo = strconv.FormatInt(int64(doctorInfo.AdminUserId), 10)
  920. struct2401.ChfpdrName = doctorInfo.UserName
  921. struct2401.AdmDiagDscr = diagnosisConfig[0].ClassName
  922. struct2401.AdmDeptCodg = strconv.FormatInt(int64(departmentInfo.ID), 10)
  923. struct2401.AdmDeptName = departmentInfo.Name
  924. struct2401.AdmBed = deviceNumber.Number
  925. struct2401.AdmBed = "待定"
  926. struct2401.DscgMaindiagName = diagnosisConfig[0].ClassName
  927. struct2401.DscgMaindiagCode = diagnosisConfig[0].CountryCode
  928. struct2401.Begntime = start_time
  929. struct2401.DiseCodg = sickConfig.CountryCode
  930. struct2401.DiseName = sickConfig.ClassName
  931. var dises []service.DiseinfoStruct
  932. for index, item := range diagnosisConfig {
  933. var dise service.DiseinfoStruct
  934. dise.PsnNo = res2.Output.Baseinfo.PsnNo
  935. dise.DiagType = "1"
  936. if index == 0 {
  937. dise.MaindiagFlag = "1"
  938. } else {
  939. dise.MaindiagFlag = "2"
  940. }
  941. dise.DiagSrtNo = strconv.FormatInt(int64(index), 10)
  942. dise.DiseDorName = doctorInfo.UserName
  943. dise.DiagCode = item.CountryCode
  944. dise.DiagName = item.ClassName
  945. dise.DiagDept = departmentInfo.Name
  946. dise.DiseDorNo = strconv.FormatInt(int64(doctorInfo.AdminUserId), 10)
  947. dise.DiagTime = timeFormatOne
  948. dises = append(dises, dise)
  949. }
  950. struct2401.Diseinfo = dises
  951. var result string
  952. var request_log string
  953. if miConfig.MdtrtareaAdmvs == "150499" {
  954. data := make(map[string]interface{})
  955. data["org_name"] = miConfig.OrgName
  956. data["doctor"] = role.UserName
  957. data["fixmedins_code"] = miConfig.Code
  958. data["insuplc_admdvs"] = insuplc_admdvs
  959. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  960. data["secret_key"] = miConfig.SecretKey
  961. data["struct_2401"] = struct2401
  962. var req *http.Request
  963. bytesData, _ := json.Marshal(data)
  964. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2401", bytes.NewReader(bytesData))
  965. client := &http.Client{}
  966. resp, _ := client.Do(req)
  967. defer resp.Body.Close()
  968. body, ioErr := ioutil.ReadAll(resp.Body)
  969. if ioErr != nil {
  970. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  972. return
  973. }
  974. var respJSON map[string]interface{}
  975. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  978. return
  979. }
  980. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  981. result_byte, _ := json.Marshal(respJSON)
  982. result = string(result_byte)
  983. } else {
  984. result, request_log = service.ZHGdyb2401(struct2401, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, insuplc_admdvs, miConfig.MdtrtareaAdmvs)
  985. saveLog(result, request_log, "2401", "入院登记")
  986. }
  987. var dat map[string]interface{}
  988. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  989. fmt.Println(dat)
  990. } else {
  991. fmt.Println(err)
  992. }
  993. userJSONBytes, _ := json.Marshal(dat)
  994. var res ResultThree
  995. var resThree10265 ResultThree10265
  996. if miConfig.Code == "H15049901371" {
  997. if err := json.Unmarshal(userJSONBytes, &resThree10265); err != nil {
  998. utils.ErrorLog("解析失败:%v", err)
  999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1000. return
  1001. }
  1002. Infcode, _ := strconv.ParseInt(resThree10265.Infcode, 10, 64)
  1003. res.Infcode = Infcode
  1004. res.ErrMsg = resThree10265.ErrMsg
  1005. res.Output = resThree10265.Output
  1006. res.InfRefmsgid = resThree10265.InfRefmsgid
  1007. res.RespondTime = resThree10265.RespondTime
  1008. } else {
  1009. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1010. utils.ErrorLog("解析失败:%v", err)
  1011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1012. return
  1013. }
  1014. }
  1015. if res.Infcode == 0 {
  1016. //result2 := service.Gdyb5301Two(res2.Output.Baseinfo.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1017. //fmt.Println(result2)
  1018. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  1019. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  1020. infoStr := string(Iinfos)
  1021. idetinfoStr := string(Idetinfos)
  1022. inHospital := &models.HisHospitalCheckRecord{
  1023. PatientId: id,
  1024. Name: name,
  1025. MedicalTreatmentType: med_type,
  1026. RecordDate: recordDateTime,
  1027. IdCardNo: id_card_no,
  1028. AdminUserId: admin_user_id,
  1029. Departments: department,
  1030. UserOrgId: adminInfo.CurrentOrgId,
  1031. Status: 1,
  1032. Ctime: time.Now().Unix(),
  1033. Mtime: time.Now().Unix(),
  1034. Number: res.Output.Result.MdtrtID,
  1035. Doctor: doctor,
  1036. PsnNo: res2.Output.Baseinfo.PsnNo,
  1037. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  1038. Certno: res2.Output.Baseinfo.Certno,
  1039. PsnName: res2.Output.Baseinfo.PsnName,
  1040. Gend: res2.Output.Baseinfo.Gend,
  1041. Naty: res2.Output.Baseinfo.Naty,
  1042. MedType: med_type,
  1043. InsutypeType: insutype,
  1044. Brdy: res2.Output.Baseinfo.Brdy,
  1045. Iinfo: infoStr,
  1046. Idetinfo: idetinfoStr,
  1047. IptOtpNo: ipt_otp_no,
  1048. AdmBed: adm_bed,
  1049. IdCardType: id_card_type,
  1050. Diagnosis: diagnosis_ids,
  1051. SickType: sick_type,
  1052. MdtrtCertType: "02",
  1053. InHosptialTime: start_time,
  1054. OutHosptialTime: "",
  1055. InHospitalStatus: 1,
  1056. Certificates: certificates,
  1057. Phone: phone,
  1058. BalanceAccountsType: balance_accounts_type,
  1059. PsnType: psn_type,
  1060. InsuplcAdmdvs: insuplc_admdvs,
  1061. }
  1062. service.CreateHospitalRecord(inHospital)
  1063. c.ServeSuccessJSON(map[string]interface{}{
  1064. "msg": "办理入院成功",
  1065. "info": inHospital,
  1066. })
  1067. } else {
  1068. c.ServeSuccessJSON(map[string]interface{}{
  1069. "failed_code": -10,
  1070. "msg": res.ErrMsg,
  1071. })
  1072. }
  1073. } else {
  1074. c.ServeSuccessJSON(map[string]interface{}{
  1075. "failed_code": -10,
  1076. "msg": res2.ErrMsg,
  1077. })
  1078. return
  1079. }
  1080. }
  1081. func (this *ZHHisApiController) GetZHOutHospitalCheck() {
  1082. id, _ := this.GetInt64("id")
  1083. patient_id, _ := this.GetInt64("patient_id")
  1084. admin_user_id, _ := this.GetInt64("admin_user_id")
  1085. record_time := this.GetString("record_time")
  1086. out_time := this.GetString("out_time")
  1087. adminInfo := this.GetAdminUserInfo()
  1088. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1089. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1090. record, _ := service.GetInHospitalRecord(id)
  1091. if record.ID == 0 {
  1092. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  1093. return
  1094. }
  1095. timeLayout := "2006-01-02"
  1096. loc, _ := time.LoadLocation("Local")
  1097. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1098. if err != nil {
  1099. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1100. return
  1101. }
  1102. recordDateTime := theTime.Unix()
  1103. var patient service.Patients
  1104. if patient_id == 0 {
  1105. patient, _ = service.GetPatientByIDCard(record.IdCardNo, adminInfo.CurrentOrgId)
  1106. } else {
  1107. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  1108. }
  1109. fmt.Println(patient)
  1110. diagnosis_ids_arr := strings.Split(record.Diagnosis, "-")
  1111. diagnosisConfig, _ := service.FindDiagnoseByIds(diagnosis_ids_arr)
  1112. departmentInfo, _ := service.GetDepartMentDetail(record.Departments)
  1113. doctorInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, record.Doctor)
  1114. //deviceNumber, _ := service.GetDeviceNumberByID(record.AdmBed, adminInfo.CurrentOrgId)
  1115. sickConfig, _ := service.FindSickById(record.SickType)
  1116. var struct2402 service.Struct2402
  1117. timestamp := time.Now().Unix()
  1118. tempTime := time.Unix(timestamp, 0)
  1119. //timeFormat := tempTime.Format("20060102150405")
  1120. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1121. struct2402.PsnNo = record.PsnNo
  1122. struct2402.Insutype = record.InsutypeType
  1123. struct2402.DscgWay = "1"
  1124. struct2402.Endtime = out_time
  1125. struct2402.DscgDeptName = departmentInfo.Number
  1126. struct2402.DscgDeptCodg = strconv.FormatInt(int64(departmentInfo.ID), 10)
  1127. struct2402.MdtrtId = record.Number
  1128. var dises []service.Diseinfo2402Struct
  1129. for index, item := range diagnosisConfig {
  1130. var dise service.Diseinfo2402Struct
  1131. dise.PsnNo = record.PsnNo
  1132. dise.DiagType = "1"
  1133. if index == 0 {
  1134. dise.MaindiagFlag = "1"
  1135. } else {
  1136. dise.MaindiagFlag = "2"
  1137. }
  1138. dise.MdtrtId = record.Number
  1139. dise.DiagSrtNo = strconv.FormatInt(int64(item.ID), 10)
  1140. dise.DiseDorName = doctorInfo.UserName
  1141. dise.DiagCode = item.CountryCode
  1142. dise.DiagName = item.ClassName
  1143. dise.DiagDept = departmentInfo.Name
  1144. dise.DiseDorNo = strconv.FormatInt(int64(doctorInfo.AdminUserId), 10)
  1145. dise.DiagTime = timeFormatOne
  1146. dises = append(dises, dise)
  1147. }
  1148. struct2402.Diseinfo = dises
  1149. struct2402.DiseName = sickConfig.ClassName
  1150. struct2402.DiseCode = sickConfig.CountryCode
  1151. var result string
  1152. var request_log string
  1153. if miConfig.MdtrtareaAdmvs == "150499" {
  1154. data := make(map[string]interface{})
  1155. data["org_name"] = miConfig.OrgName
  1156. data["doctor"] = role.UserName
  1157. data["fixmedins_code"] = miConfig.Code
  1158. data["insuplc_admdvs"] = record.InsuplcAdmdvs
  1159. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1160. data["secret_key"] = miConfig.SecretKey
  1161. data["struct_2402"] = struct2402
  1162. var req *http.Request
  1163. bytesData, _ := json.Marshal(data)
  1164. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2402", bytes.NewReader(bytesData))
  1165. client := &http.Client{}
  1166. resp, _ := client.Do(req)
  1167. defer resp.Body.Close()
  1168. body, ioErr := ioutil.ReadAll(resp.Body)
  1169. if ioErr != nil {
  1170. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1171. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1172. return
  1173. }
  1174. var respJSON map[string]interface{}
  1175. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1177. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1178. return
  1179. }
  1180. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1181. result_byte, _ := json.Marshal(respJSON)
  1182. result = string(result_byte)
  1183. } else {
  1184. result, request_log = service.ZHGdyb2402(struct2402, miConfig.OrgName, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  1185. saveLog(result, request_log, "2402", "出院")
  1186. }
  1187. var dat map[string]interface{}
  1188. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1189. fmt.Println(dat)
  1190. } else {
  1191. fmt.Println(err)
  1192. }
  1193. userJSONBytes, _ := json.Marshal(dat)
  1194. var res ResultEmpty
  1195. var resEmpty10265 ResultEmpty10265
  1196. if miConfig.Code == "H15049901371" {
  1197. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1198. utils.ErrorLog("解析失败:%v", err)
  1199. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1200. return
  1201. }
  1202. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1203. res.Infcode = Infcode
  1204. res.RespondTime = resEmpty10265.RespondTime
  1205. res.ErrMsg = resEmpty10265.ErrMsg
  1206. res.Output = resEmpty10265.Output
  1207. res.WarnMsg = resEmpty10265.WarnMsg
  1208. } else {
  1209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1210. utils.ErrorLog("解析失败:%v", err)
  1211. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1212. return
  1213. }
  1214. }
  1215. if res.Infcode == 0 {
  1216. record.OutHospitalStatus = 1
  1217. record.OutHosptialTime = struct2402.Endtime
  1218. record.OutWay = 1
  1219. service.CreateHospitalRecord(&record)
  1220. orders, _ := service.GetHisOrderInfoByNumberFour(record.Number)
  1221. var total float64
  1222. for _, item := range orders {
  1223. total = total + item.DetItemFeeSumamt
  1224. }
  1225. order := &models.HisOrder{
  1226. UserOrgId: adminInfo.CurrentOrgId,
  1227. HisPatientId: record.ID,
  1228. PatientId: record.PatientId,
  1229. SettleAccountsDate: recordDateTime,
  1230. Ctime: time.Now().Unix(),
  1231. Mtime: time.Now().Unix(),
  1232. Status: 1,
  1233. Number: record.Number,
  1234. Infcode: 0,
  1235. WarnMsg: "",
  1236. Cainfo: "",
  1237. ErrMsg: "",
  1238. RespondTime: "",
  1239. InfRefmsgid: "",
  1240. OrderStatus: 1,
  1241. MdtrtId: record.Number,
  1242. IsMedicineInsurance: 1,
  1243. PType: 1,
  1244. MedfeeSumamt: total,
  1245. }
  1246. err = service.CreateOrder(order)
  1247. if err != nil {
  1248. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  1249. return
  1250. }
  1251. this.ServeSuccessJSON(map[string]interface{}{
  1252. "msg": "出院成功",
  1253. })
  1254. } else {
  1255. this.ServeSuccessJSON(map[string]interface{}{
  1256. "failed_code": -10,
  1257. "msg": res.ErrMsg,
  1258. })
  1259. }
  1260. }
  1261. func (c *ZHHisApiController) GetSettleInfo() {
  1262. order_id, _ := c.GetInt64("order_id")
  1263. patient_id, _ := c.GetInt64("patient_id")
  1264. in_hospital_id, _ := c.GetInt64("in_hospital_id")
  1265. admin_user_id, _ := c.GetInt64("admin_user_id")
  1266. pay_way, _ := c.GetInt64("pay_way")
  1267. pay_price, _ := c.GetFloat("pay_price")
  1268. pay_card_no := c.GetString("pay_card_no")
  1269. discount_price, _ := c.GetFloat("discount_price")
  1270. preferential_price, _ := c.GetFloat("preferential_price")
  1271. reality_price, _ := c.GetFloat("reality_price")
  1272. found_price, _ := c.GetFloat("found_price")
  1273. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  1274. private_price, _ := c.GetFloat("private_price")
  1275. fapiao_code := c.GetString("fapiao_code")
  1276. fapiao_number := c.GetString("fapiao_number")
  1277. record, _ := service.GetInHospitalRecord(in_hospital_id)
  1278. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1279. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1280. order, _ := service.GetHisOrderByID(order_id)
  1281. //dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  1282. //tmp_decimal := c.GetString("tmp_decimal")
  1283. //var decimal float64 //本次使用的押金
  1284. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  1285. tmp_decimal := c.GetString("tmp_decimal")
  1286. var decimal float64 //本次使用的押金
  1287. var errmsg error
  1288. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  1289. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  1290. return
  1291. }
  1292. if len(tmp_decimal) > 0 {
  1293. if tmp_decimal[0] == 45 {
  1294. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  1295. return
  1296. }
  1297. }
  1298. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  1299. if errs != nil {
  1300. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额错误")
  1301. return
  1302. }
  1303. decimal = tt
  1304. var rf []*ResultFive
  1305. json.Unmarshal([]byte(record.Iinfo), &rf)
  1306. chrg_bchno := order.Number
  1307. cert_no := record.Certno
  1308. if record.ID == 0 {
  1309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1310. return
  1311. }
  1312. if record.InHospitalStatus == 1 && record.OutHospitalStatus == 0 {
  1313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalNoExistDataException)
  1314. return
  1315. }
  1316. if record.IdCardType == 1 {
  1317. } else {
  1318. cert_no = record.Certno
  1319. }
  1320. var result string
  1321. var src_resquest string
  1322. timeLayout := "2006-01-02"
  1323. loc, _ := time.LoadLocation("Local")
  1324. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record.InHosptialTime, loc)
  1325. if err != nil {
  1326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1327. return
  1328. }
  1329. recordStartDateTime := theTime.Unix()
  1330. theTimeEnd, err := time.ParseInLocation(timeLayout+" 15:04:05", record.OutHosptialTime, loc)
  1331. if err != nil {
  1332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1333. return
  1334. }
  1335. recordEndDateTime := theTimeEnd.Unix()
  1336. prescriptions, _ := service.GetZHSettleMonthHisPrescription(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordStartDateTime, recordEndDateTime)
  1337. var total float64
  1338. for _, item := range prescriptions {
  1339. if item.Type == 1 { //药品
  1340. for _, subItem := range item.HisDoctorAdviceInfo {
  1341. total = total + (subItem.Price * subItem.PrescribingNumber)
  1342. }
  1343. }
  1344. if item.Type == 2 { //项目
  1345. for _, subItem := range item.HisPrescriptionProject {
  1346. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1347. total = total + (subItem.Price * cnt)
  1348. }
  1349. }
  1350. }
  1351. //allTotal := fmt.Sprintf("%.2f", total)
  1352. var allTotal string
  1353. if record.OutHospitalStatus == 0 && order.ID == 0 {
  1354. orders, _ := service.GetHisOrderInfoByNumberFour(record.Number)
  1355. var total float64
  1356. for _, item := range orders {
  1357. total = total + item.DetItemFeeSumamt
  1358. }
  1359. allTotal = fmt.Sprintf("%.4f", total)
  1360. } else {
  1361. allTotal = fmt.Sprintf("%.4f", order.MedfeeSumamt)
  1362. }
  1363. if miConfig.MdtrtareaAdmvs == "150499" {
  1364. psn_info, _ := service.GetPsnByPatientId(patient_id)
  1365. mdtrt_cert_no := ""
  1366. if record.IdCardType == 1 {
  1367. bas := strings.Split(psn_info.CardInfo, "|")
  1368. cardNumber := bas[2]
  1369. mdtrt_cert_no = cardNumber
  1370. } else {
  1371. mdtrt_cert_no = record.Certno
  1372. }
  1373. var acct_used_flag string
  1374. if pay_way == 5 {
  1375. acct_used_flag = "1"
  1376. } else {
  1377. acct_used_flag = "0"
  1378. }
  1379. //请求内网数据
  1380. api := "http://172.16.13.254:9532/" + "nmyb/2304?psn_no=" + record.PsnNo + "&mdtrt_id=" + record.Number + "&chrg_bchno=" + chrg_bchno +
  1381. "&insutype_type=" + record.InsutypeType + "&total=" + allTotal +
  1382. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1383. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(record.IdCardType, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(record.Certificates, 10) + "&name=" + record.Name + "&cert_no=" + mdtrt_cert_no + "&fapiao_number=" + fapiao_number + "&acct_used_flag=" + acct_used_flag
  1384. resp, requestErr := http.Get(api)
  1385. if requestErr != nil {
  1386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1387. return
  1388. }
  1389. body, ioErr := ioutil.ReadAll(resp.Body)
  1390. if ioErr != nil {
  1391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1393. return
  1394. }
  1395. var respJSON map[string]interface{}
  1396. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1397. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1399. return
  1400. }
  1401. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1402. result_byte, _ := json.Marshal(respJSON)
  1403. result = string(result_byte)
  1404. } else {
  1405. result, src_resquest = service.ZHGdyb2304(record.PsnNo, record.Number, chrg_bchno, cert_no, record.InsutypeType, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "0", record.IdCardType, 0, 0, 0, 0, record.Certificates, "", "1")
  1406. saveLog(result, src_resquest, "2304", "住院结算")
  1407. }
  1408. var dat map[string]interface{}
  1409. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1410. fmt.Println(dat)
  1411. } else {
  1412. fmt.Println(err)
  1413. }
  1414. userJSONBytes, _ := json.Marshal(dat)
  1415. var res ResultSeven
  1416. var resSeven10265 ResultSeven10265
  1417. if miConfig.Code == "H15049901371" {
  1418. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  1419. utils.ErrorLog("解析失败:%v", err)
  1420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1421. return
  1422. }
  1423. Infcode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  1424. res.Infcode = Infcode
  1425. res.InfRefmsgid = resSeven10265.InfRefmsgid
  1426. res.RespondTime = resSeven10265.RespondTime
  1427. res.ErrMsg = resSeven10265.ErrMsg
  1428. res.Output = resSeven10265.Output
  1429. res.WarnMsg = resSeven10265.WarnMsg
  1430. res.Cainfo = resSeven10265.Cainfo
  1431. } else {
  1432. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1433. utils.ErrorLog("解析失败:%v", err)
  1434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1435. return
  1436. }
  1437. }
  1438. if res.Infcode != 0 {
  1439. errlog := &models.HisOrderError{
  1440. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1441. Ctime: time.Now().Unix(),
  1442. Mtime: time.Now().Unix(),
  1443. Number: chrg_bchno,
  1444. ErrMsg: res.ErrMsg,
  1445. Status: 1,
  1446. PatientId: patient_id,
  1447. RecordTime: time.Now().Unix(),
  1448. Stage: 6,
  1449. }
  1450. service.CreateErrMsgLog(errlog)
  1451. c.ServeSuccessJSON(map[string]interface{}{
  1452. "failed_code": -10,
  1453. "msg": res.ErrMsg,
  1454. })
  1455. return
  1456. } else {
  1457. //order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  1458. order.OrderStatus = 2
  1459. order.DiscountPrice = discount_price
  1460. order.MedicalInsurancePrice = medical_insurance_price
  1461. order.FaPiaoNumber = fapiao_number
  1462. order.FaPiaoCode = fapiao_code
  1463. order.PayWay = pay_way
  1464. order.PayPrice = pay_price
  1465. order.PayCardNo = pay_card_no
  1466. order.PreferentialPrice = preferential_price
  1467. order.RealityPrice = reality_price
  1468. order.FoundPrice = found_price
  1469. order.PrivatePrice = private_price
  1470. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  1471. order.SetlId = res.Output.Setlinfo.SetlID
  1472. order.PsnNo = res.Output.Setlinfo.PsnNo
  1473. order.PsnName = res.Output.Setlinfo.PsnName
  1474. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  1475. order.Certno = res.Output.Setlinfo.Certno
  1476. order.Gend = res.Output.Setlinfo.Gend
  1477. order.Naty = res.Output.Setlinfo.Naty
  1478. order.Age = res.Output.Setlinfo.Age
  1479. order.Insutype = res.Output.Setlinfo.Insutype
  1480. order.PsnType = res.Output.Setlinfo.PsnType
  1481. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  1482. order.SetlTime = res.Output.Setlinfo.SetlTime
  1483. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  1484. if res.Output.Setlinfo.MedType == "140104" {
  1485. order.MedType = "14"
  1486. } else {
  1487. order.MedType = res.Output.Setlinfo.MedType
  1488. }
  1489. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  1490. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  1491. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  1492. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  1493. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  1494. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  1495. order.HifpPay = res.Output.Setlinfo.HifpPay
  1496. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  1497. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  1498. order.HifesPay = res.Output.Setlinfo.HifesPay
  1499. order.HifobPay = res.Output.Setlinfo.HifobPay
  1500. order.MafPay = res.Output.Setlinfo.MafPay
  1501. order.OthPay = res.Output.Setlinfo.OthPay
  1502. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  1503. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  1504. order.AcctPay = res.Output.Setlinfo.AcctPay
  1505. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  1506. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  1507. order.Balc = res.Output.Setlinfo.Balc
  1508. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  1509. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  1510. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  1511. order.ClrWay = res.Output.Setlinfo.ClrWay
  1512. order.Creator = order.Creator
  1513. order.Modify = roles.AdminUserId
  1514. order.RequestLog = src_resquest
  1515. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  1516. detailStr := string(setlDetail)
  1517. order.SetlDetail = detailStr
  1518. err := service.UpdataOrderStatusTwo(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId)
  1519. err = service.UpDateOrder(order)
  1520. if err == nil {
  1521. //判断是否使用了押金
  1522. if dec_way == "true" {
  1523. tmpstring := strconv.FormatInt(order.ID, 10)
  1524. order.Decimal = decimal
  1525. err = service.UpDateOrder(order)
  1526. //扣押金
  1527. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, patient_id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  1528. if errmsg != nil {
  1529. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  1530. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  1531. return
  1532. }
  1533. }
  1534. c.ServeSuccessJSON(map[string]interface{}{
  1535. "msg": "结算成功",
  1536. })
  1537. } else {
  1538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  1539. return
  1540. }
  1541. }
  1542. }
  1543. func (c *ZHHisApiController) GetPreSettleInfo() {
  1544. order_id, _ := c.GetInt64("order_id")
  1545. patient_id, _ := c.GetInt64("patient_id")
  1546. in_hospital_id, _ := c.GetInt64("in_hospital_id")
  1547. admin_user_id, _ := c.GetInt64("admin_user_id")
  1548. record, _ := service.GetInHospitalRecord(in_hospital_id)
  1549. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1550. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1551. order, _ := service.GetHisOrderByID(order_id)
  1552. var allTotal string
  1553. if record.OutHospitalStatus == 0 && order.ID == 0 {
  1554. orders, _ := service.GetHisOrderInfoByNumberFour(record.Number)
  1555. var total float64
  1556. for _, item := range orders {
  1557. total = total + item.DetItemFeeSumamt
  1558. }
  1559. allTotal = fmt.Sprintf("%.4f", total)
  1560. } else {
  1561. allTotal = fmt.Sprintf("%.4f", order.MedfeeSumamt)
  1562. }
  1563. var rf []*ResultFive
  1564. json.Unmarshal([]byte(record.Iinfo), &rf)
  1565. chrg_bchno := order.Number
  1566. cert_no := record.Certno
  1567. if record.ID == 0 {
  1568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1569. return
  1570. }
  1571. //if record.InHospitalStatus == 1 && record.OutHospitalStatus == 0 {
  1572. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalNoExistDataException)
  1573. // return
  1574. //}
  1575. psn_info, _ := service.GetPsnByPatientId(patient_id)
  1576. if record.IdCardType == 1 {
  1577. bas := strings.Split(psn_info.CardInfo, "|")
  1578. cardNumber := bas[2]
  1579. cert_no = cardNumber
  1580. } else {
  1581. cert_no = record.Certno
  1582. }
  1583. var result string
  1584. var src_resquest string
  1585. if miConfig.MdtrtareaAdmvs == "150499" {
  1586. //请求内网数据
  1587. api := "http://172.16.13.254:9532/" + "nmyb/2303?psn_no=" + record.PsnNo + "&mdtrt_id=" + record.Number + "&chrg_bchno=" + chrg_bchno +
  1588. "&insutype_type=" + record.InsutypeType + "&total=" + allTotal +
  1589. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1590. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(record.IdCardType, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(record.Certificates, 10) + "&name=" + record.Name + "&cert_no=" + cert_no
  1591. resp, requestErr := http.Get(api)
  1592. if requestErr != nil {
  1593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1594. return
  1595. }
  1596. body, ioErr := ioutil.ReadAll(resp.Body)
  1597. if ioErr != nil {
  1598. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1600. return
  1601. }
  1602. var respJSON map[string]interface{}
  1603. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1604. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1606. return
  1607. }
  1608. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1609. result_byte, _ := json.Marshal(respJSON)
  1610. result = string(result_byte)
  1611. } else {
  1612. result, src_resquest = service.ZHGdyb2303(record.PsnNo, record.Number, chrg_bchno, cert_no, record.InsutypeType, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "0", record.IdCardType, 0, 0, 0, 0, record.Certificates)
  1613. saveLog(result, src_resquest, "2303", "住院预结算")
  1614. }
  1615. var dat map[string]interface{}
  1616. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1617. fmt.Println(dat)
  1618. } else {
  1619. fmt.Println(err)
  1620. }
  1621. userJSONBytes, _ := json.Marshal(dat)
  1622. var res ResultSeven
  1623. var resSeven10265 ResultSeven10265
  1624. if miConfig.Code == "H15049901371" {
  1625. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  1626. utils.ErrorLog("解析失败:%v", err)
  1627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1628. return
  1629. }
  1630. Infcode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  1631. res.Infcode = Infcode
  1632. res.InfRefmsgid = resSeven10265.InfRefmsgid
  1633. res.RespondTime = resSeven10265.RespondTime
  1634. res.ErrMsg = resSeven10265.ErrMsg
  1635. res.Output = resSeven10265.Output
  1636. res.WarnMsg = resSeven10265.WarnMsg
  1637. res.Cainfo = resSeven10265.Cainfo
  1638. } else {
  1639. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1640. utils.ErrorLog("解析失败:%v", err)
  1641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1642. return
  1643. }
  1644. }
  1645. if res.Infcode != 0 {
  1646. errlog := &models.HisOrderError{
  1647. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1648. Ctime: time.Now().Unix(),
  1649. Mtime: time.Now().Unix(),
  1650. Number: chrg_bchno,
  1651. ErrMsg: res.ErrMsg,
  1652. Status: 1,
  1653. PatientId: patient_id,
  1654. RecordTime: time.Now().Unix(),
  1655. Stage: 6,
  1656. }
  1657. service.CreateErrMsgLog(errlog)
  1658. c.ServeSuccessJSON(map[string]interface{}{
  1659. "failed_code": -10,
  1660. "msg": res.ErrMsg,
  1661. })
  1662. return
  1663. } else {
  1664. //order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  1665. order.OrderStatus = 1
  1666. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  1667. order.SetlId = res.Output.Setlinfo.SetlID
  1668. order.PsnNo = res.Output.Setlinfo.PsnNo
  1669. order.PsnName = res.Output.Setlinfo.PsnName
  1670. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  1671. order.Certno = res.Output.Setlinfo.Certno
  1672. order.Gend = res.Output.Setlinfo.Gend
  1673. order.Naty = res.Output.Setlinfo.Naty
  1674. order.Age = res.Output.Setlinfo.Age
  1675. order.Insutype = res.Output.Setlinfo.Insutype
  1676. order.PsnType = res.Output.Setlinfo.PsnType
  1677. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  1678. order.SetlTime = res.Output.Setlinfo.SetlTime
  1679. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  1680. if res.Output.Setlinfo.MedType == "140104" {
  1681. order.MedType = "14"
  1682. } else {
  1683. order.MedType = res.Output.Setlinfo.MedType
  1684. }
  1685. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  1686. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  1687. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  1688. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  1689. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  1690. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  1691. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  1692. order.HifpPay = res.Output.Setlinfo.HifpPay
  1693. order.HifesPay = res.Output.Setlinfo.HifesPay
  1694. order.HifobPay = res.Output.Setlinfo.HifobPay
  1695. order.MafPay = res.Output.Setlinfo.MafPay
  1696. order.OthPay = res.Output.Setlinfo.OthPay
  1697. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  1698. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  1699. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  1700. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  1701. order.AcctPay = res.Output.Setlinfo.AcctPay
  1702. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  1703. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  1704. order.Balc = res.Output.Setlinfo.Balc
  1705. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  1706. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  1707. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  1708. order.ClrWay = res.Output.Setlinfo.ClrWay
  1709. order.Creator = order.Creator
  1710. order.Modify = roles.AdminUserId
  1711. order.RequestLog = src_resquest
  1712. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  1713. detailStr := string(setlDetail)
  1714. order.SetlDetail = detailStr
  1715. //err := service.UpdataOrderStatusTwo(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId)
  1716. if record.OutHospitalStatus == 1 && order.ID > 0 {
  1717. err := service.UpDateOrder(order)
  1718. if err == nil {
  1719. c.ServeSuccessJSON(map[string]interface{}{
  1720. "msg": "预结算成功",
  1721. "order_way": 1,
  1722. })
  1723. } else {
  1724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  1725. return
  1726. }
  1727. } else if record.OutHospitalStatus == 0 && order.ID == 0 {
  1728. c.ServeSuccessJSON(map[string]interface{}{
  1729. "msg": "预结算成功",
  1730. "order": order,
  1731. "order_way": 2,
  1732. })
  1733. }
  1734. }
  1735. }
  1736. func (c *ZHHisApiController) GetUploadInfo() {
  1737. id, _ := c.GetInt64("id")
  1738. record_time := c.GetString("record_time")
  1739. in_hospital_id, _ := c.GetInt64("in_hospital_id")
  1740. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1741. admin_user_id, _ := c.GetInt64("admin_user_id")
  1742. timeLayout := "2006-01-02"
  1743. loc, _ := time.LoadLocation("Local")
  1744. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1745. if err != nil {
  1746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1747. return
  1748. }
  1749. recordDateTime := theTime.Unix()
  1750. adminUser := c.GetAdminUserInfo()
  1751. var prescriptions []*models.HisPrescription
  1752. data := make(map[string]interface{})
  1753. if settle_accounts_type == 1 { //日结
  1754. prescriptions, _ = service.GetZHHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  1755. } else { //月结
  1756. start_time_str := c.GetString("start_time")
  1757. end_time_str := c.GetString("end_time")
  1758. timeLayout := "2006-01-02"
  1759. loc, _ := time.LoadLocation("Local")
  1760. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  1761. if err != nil {
  1762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1763. return
  1764. }
  1765. recordStartTime := theStartTime.Unix()
  1766. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  1767. if err != nil {
  1768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1769. return
  1770. }
  1771. recordEndTime := theEndTime.Unix()
  1772. prescriptions, _ = service.GetZHMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  1773. }
  1774. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1775. record, _ := service.GetInHospitalRecord(in_hospital_id)
  1776. if record.ID == 0 {
  1777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1778. return
  1779. }
  1780. timestamp := time.Now().Unix()
  1781. tempTime := time.Unix(timestamp, 0)
  1782. timeFormat := tempTime.Format("20060102150405")
  1783. chrgBchno := rand.Intn(100000) + 10000
  1784. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(record.PatientId, 10)
  1785. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1786. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1787. department, _ := service.GetDepartMentDetail(record.Departments)
  1788. strconv.FormatInt(record.PatientId, 10)
  1789. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, record.Doctor)
  1790. //client := &http.Client{}
  1791. data["psn_no"] = record.PsnNo
  1792. data["mdtrt_id"] = record.Number
  1793. data["chrg_bchno"] = chrg_bchno
  1794. data["org_name"] = miConfig.OrgName
  1795. data["doctor"] = roles.UserName
  1796. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  1797. data["dept"] = strconv.FormatInt(department.ID, 10)
  1798. data["fixmedins_code"] = miConfig.Code
  1799. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  1800. data["dept_code"] = "15"
  1801. } else {
  1802. data["dept_code"] = department.Number
  1803. }
  1804. if miConfig.Code == "H15049901371" {
  1805. if record.MedType == 14 {
  1806. if record.InsutypeType == "390" {
  1807. data["med_type"] = "9933"
  1808. } else if record.InsutypeType == "310" {
  1809. data["med_type"] = "990502"
  1810. }
  1811. } else if record.MedType == 11 {
  1812. data["med_type"] = strconv.FormatInt(record.MedType, 10)
  1813. }
  1814. } else {
  1815. if record.MedType == 1112 {
  1816. data["med_type"] = strconv.FormatInt(11, 10)
  1817. } else {
  1818. data["med_type"] = strconv.FormatInt(record.MedType, 10)
  1819. }
  1820. }
  1821. data["insuplc_admdvs"] = record.InsuplcAdmdvs
  1822. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1823. data["secret_key"] = miConfig.SecretKey
  1824. var ids []int64
  1825. fmt.Println(data)
  1826. for _, item := range prescriptions {
  1827. ids = append(ids, item.ID)
  1828. }
  1829. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1830. if config.IsOpen == 1 { //对接了医保,走医保流程
  1831. var pagesize int = 100
  1832. var start int = 1
  1833. var stop int
  1834. var pagecount int
  1835. var curpage int
  1836. var isSuccess bool = true
  1837. var customs []*models.NewCustom
  1838. for _, item := range prescriptions {
  1839. tm := time.Unix(item.PreTime, 0)
  1840. if item.Type == 1 { //药品
  1841. for _, subItem := range item.HisDoctorAdviceInfo {
  1842. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
  1843. //var randNum int
  1844. //randNum = rand.Intn(10000) + 1000
  1845. cus := &models.NewCustom{
  1846. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  1847. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  1848. FeedetlSn: subItem.FeedetlSn,
  1849. Price: fmt.Sprintf("%.4f", subItem.Price),
  1850. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  1851. HospApprFlag: subItem.BaseDrugLib.HospApprFlag,
  1852. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1853. }
  1854. customs = append(customs, cus)
  1855. }
  1856. }
  1857. }
  1858. if item.Type == 2 { //项目
  1859. for _, subItem := range item.HisPrescriptionProject {
  1860. //var randNum int
  1861. //randNum = rand.Intn(10000) + 1000
  1862. if subItem.Type == 2 {
  1863. if len(subItem.HisProject.MedicalCode) > 0 {
  1864. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1865. cus := &models.NewCustom{
  1866. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1867. Cut: fmt.Sprintf("%.4f", cnt),
  1868. FeedetlSn: subItem.FeedetlSn,
  1869. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1870. MedListCodg: subItem.HisProject.MedicalCode,
  1871. HospApprFlag: -1,
  1872. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1873. }
  1874. customs = append(customs, cus)
  1875. }
  1876. } else if subItem.Type == 3 {
  1877. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 && subItem.GoodInfo.IsUser != 1 {
  1878. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1879. cus := &models.NewCustom{
  1880. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1881. Cut: fmt.Sprintf("%.4f", cnt),
  1882. FeedetlSn: subItem.FeedetlSn,
  1883. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1884. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  1885. HospApprFlag: -1,
  1886. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1887. }
  1888. customs = append(customs, cus)
  1889. }
  1890. }
  1891. }
  1892. }
  1893. }
  1894. //总页数,向上取整,注意除之前要先转换类型为float64
  1895. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  1896. var ress []*ResultFour
  1897. for curpage = 1; curpage <= pagecount; curpage++ {
  1898. if curpage == 1 {
  1899. start = 1
  1900. } else {
  1901. start = (curpage-1)*pagesize + 1
  1902. }
  1903. stop = curpage * pagesize
  1904. if stop > len(customs) {
  1905. stop = len(customs)
  1906. }
  1907. var result string
  1908. var requestLog string
  1909. if miConfig.MdtrtareaAdmvs == "150499" {
  1910. data := make(map[string]interface{})
  1911. if record.MedType == 14 {
  1912. if record.InsutypeType == "390" {
  1913. data["med_type"] = "9933"
  1914. } else if record.InsutypeType == "310" {
  1915. data["med_type"] = "990502"
  1916. }
  1917. } else if record.MedType == 11 {
  1918. data["med_type"] = strconv.FormatInt(record.MedType, 10)
  1919. }
  1920. data["psn_no"] = record.PsnNo
  1921. data["number"] = record.Number
  1922. data["customs"] = customs[start-1 : stop]
  1923. data["chrg_bchno"] = chrg_bchno
  1924. data["dept"] = strconv.FormatInt(department.ID, 10)
  1925. data["dept_code"] = department.Number
  1926. data["doctor_code"] = strconv.FormatInt(doctor_info.ID, 10)
  1927. data["doctor_name"] = doctor_info.UserName
  1928. data["org_name"] = miConfig.OrgName
  1929. data["opertor"] = roles.UserName
  1930. data["fixmedins_code"] = miConfig.Code
  1931. data["insuplc_admdvs"] = record.InsuplcAdmdvs
  1932. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1933. data["secret_key"] = miConfig.SecretKey
  1934. var req *http.Request
  1935. bytesData, _ := json.Marshal(data)
  1936. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2301", bytes.NewReader(bytesData))
  1937. client := &http.Client{}
  1938. resp, _ := client.Do(req)
  1939. defer resp.Body.Close()
  1940. body, ioErr := ioutil.ReadAll(resp.Body)
  1941. if ioErr != nil {
  1942. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1944. return
  1945. }
  1946. var respJSON map[string]interface{}
  1947. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1948. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1950. return
  1951. }
  1952. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1953. result_byte, _ := json.Marshal(respJSON)
  1954. result = string(result_byte)
  1955. } else {
  1956. result, requestLog = service.ZHGdyb2301(record.PsnNo, record.Number, customs[start-1:stop], chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(department.ID, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["med_type"].(string))
  1957. saveLog(result, requestLog, "2301", "上传明细")
  1958. }
  1959. var dat map[string]interface{}
  1960. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1961. fmt.Println(dat)
  1962. } else {
  1963. fmt.Println(err)
  1964. }
  1965. userJSONBytes, _ := json.Marshal(dat)
  1966. var res ResultFour
  1967. var resFour10265 ResultFour10265
  1968. if miConfig.Code == "H15049901371" {
  1969. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  1970. utils.ErrorLog("解析失败:%v", err)
  1971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1972. return
  1973. }
  1974. res.WarnMsg = resFour10265.WarnMsg
  1975. res.Output = resFour10265.Output
  1976. res.ErrMsg = resFour10265.ErrMsg
  1977. res.RespondTime = resFour10265.RespondTime
  1978. res.InfRefmsgid = resFour10265.InfRefmsgid
  1979. Infcode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  1980. res.Infcode = Infcode
  1981. } else {
  1982. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1983. utils.ErrorLog("解析失败:%v", err)
  1984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1985. return
  1986. }
  1987. }
  1988. if res.Infcode == 0 {
  1989. ress = append(ress, &res)
  1990. } else {
  1991. isSuccess = false
  1992. errlog := &models.HisOrderError{
  1993. UserOrgId: adminUser.CurrentOrgId,
  1994. Ctime: time.Now().Unix(),
  1995. Mtime: time.Now().Unix(),
  1996. Number: chrg_bchno,
  1997. ErrMsg: "",
  1998. Status: 1,
  1999. PatientId: id,
  2000. RecordTime: recordDateTime,
  2001. Stage: 4,
  2002. }
  2003. service.CreateErrMsgLog(errlog)
  2004. c.ServeSuccessJSON(map[string]interface{}{
  2005. "failed_code": -10,
  2006. "msg": "上传明细错误,请联系his厂商",
  2007. })
  2008. return
  2009. }
  2010. }
  2011. if isSuccess == true {
  2012. if settle_accounts_type == 1 {
  2013. for _, subItem := range ress {
  2014. for _, item := range subItem.Output.Result {
  2015. temp := strings.Split(item.FeedetlSn, "-")
  2016. var advice_id int64 = 0
  2017. var project_id int64 = 0
  2018. var types int64 = 0
  2019. id, _ := strconv.ParseInt(temp[2], 10, 64)
  2020. types, _ = strconv.ParseInt(temp[1], 10, 64)
  2021. if temp[1] == "1" {
  2022. advice_id = id
  2023. project_id = 0
  2024. } else if temp[1] == "2" {
  2025. advice_id = 0
  2026. project_id = id
  2027. }
  2028. info := &models.HisOrderInfo{
  2029. OrderNumber: record.Number,
  2030. FeedetlSn: item.FeedetlSn,
  2031. UploadDate: recordDateTime,
  2032. AdviceId: advice_id,
  2033. DetItemFeeSumamt: item.DetItemFeeSumamt,
  2034. Cnt: item.Cnt,
  2035. Pric: float64(item.Pric),
  2036. PatientId: record.PatientId,
  2037. PricUplmtAmt: item.PricUplmtAmt,
  2038. SelfpayProp: item.SelfpayProp,
  2039. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  2040. OverlmtAmt: item.OverlmtAmt,
  2041. PreselfpayAmt: item.PreselfpayAmt,
  2042. BasMednFlag: item.BasMednFlag,
  2043. MedChrgitmType: item.MedChrgitmType,
  2044. HiNegoDrugFlag: item.HiNegoDrugFlag,
  2045. Status: 1,
  2046. Memo: item.Memo,
  2047. Mtime: time.Now().Unix(),
  2048. InscpScpAmt: item.InscpScpAmt,
  2049. DrtReimFlag: item.DrtReimFlag,
  2050. Ctime: time.Now().Unix(),
  2051. ListSpItemFlag: item.ListSpItemFlag,
  2052. ChldMedcFlag: item.ChldMedcFlag,
  2053. LmtUsedFlag: item.LmtUsedFlag,
  2054. ChrgitmLv: item.ChrgitmLv,
  2055. UserOrgId: adminUser.CurrentOrgId,
  2056. HisPatientId: record.ID,
  2057. OrderId: 0,
  2058. ProjectId: project_id,
  2059. Type: types,
  2060. SettleType: settle_accounts_type,
  2061. }
  2062. service.CreateOrderInfo(info)
  2063. }
  2064. }
  2065. err := service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
  2066. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
  2067. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, record.Number, recordDateTime)
  2068. if err == nil {
  2069. c.ServeSuccessJSON(map[string]interface{}{
  2070. "msg": "上传费用明细成功",
  2071. })
  2072. return
  2073. } else {
  2074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2075. return
  2076. }
  2077. } else {
  2078. for _, subItem := range ress {
  2079. for _, item := range subItem.Output.Result {
  2080. temp := strings.Split(item.FeedetlSn, "-")
  2081. var advice_id int64 = 0
  2082. var project_id int64 = 0
  2083. var types int64 = 0
  2084. id, _ := strconv.ParseInt(temp[2], 10, 64)
  2085. types, _ = strconv.ParseInt(temp[1], 10, 64)
  2086. if temp[1] == "1" {
  2087. advice_id = id
  2088. project_id = 0
  2089. } else if temp[1] == "2" {
  2090. advice_id = 0
  2091. project_id = id
  2092. }
  2093. info := &models.HisOrderInfo{
  2094. OrderNumber: record.Number,
  2095. FeedetlSn: item.FeedetlSn,
  2096. UploadDate: time.Now().Unix(),
  2097. AdviceId: advice_id,
  2098. DetItemFeeSumamt: item.DetItemFeeSumamt,
  2099. Cnt: item.Cnt,
  2100. Pric: float64(item.Pric),
  2101. PatientId: record.PatientId,
  2102. PricUplmtAmt: item.PricUplmtAmt,
  2103. SelfpayProp: item.SelfpayProp,
  2104. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  2105. OverlmtAmt: item.OverlmtAmt,
  2106. PreselfpayAmt: item.PreselfpayAmt,
  2107. BasMednFlag: item.BasMednFlag,
  2108. MedChrgitmType: item.MedChrgitmType,
  2109. HiNegoDrugFlag: item.HiNegoDrugFlag,
  2110. Status: 1,
  2111. Memo: item.Memo,
  2112. Mtime: time.Now().Unix(),
  2113. InscpScpAmt: item.InscpScpAmt,
  2114. DrtReimFlag: item.DrtReimFlag,
  2115. Ctime: time.Now().Unix(),
  2116. ListSpItemFlag: item.ListSpItemFlag,
  2117. ChldMedcFlag: item.ChldMedcFlag,
  2118. LmtUsedFlag: item.LmtUsedFlag,
  2119. ChrgitmLv: item.ChrgitmLv,
  2120. UserOrgId: adminUser.CurrentOrgId,
  2121. HisPatientId: record.ID,
  2122. ProjectId: project_id,
  2123. Type: types,
  2124. SettleType: settle_accounts_type,
  2125. }
  2126. service.CreateOrderInfo(info)
  2127. }
  2128. }
  2129. service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
  2130. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
  2131. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, record.Number, recordDateTime)
  2132. c.ServeSuccessJSON(map[string]interface{}{
  2133. "msg": "上传费用明细成功",
  2134. })
  2135. }
  2136. }
  2137. }
  2138. }
  2139. func (c *ZHHisApiController) ZHRefund() {
  2140. order_id, _ := c.GetInt64("order_id")
  2141. admin_user_id, _ := c.GetInt64("admin_user_id")
  2142. adminUser := c.GetAdminUserInfo()
  2143. var order models.HisOrder
  2144. order, _ = service.GetHisOrderByID(order_id)
  2145. record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2146. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2147. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2148. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2149. if config.IsOpen == 1 { //对接了医保,走医保流程
  2150. var result string
  2151. var requestLog string
  2152. if miConfig.MdtrtareaAdmvs == "150499" {
  2153. //请求内网数据
  2154. api := "http://172.16.13.254:9532/" + "nmyb/2305?mdtrt_id=" + record.Number + "&psn_no=" + record.PsnNo + "&setl_id=" + order.SetlId +
  2155. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2156. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  2157. resp, requestErr := http.Get(api)
  2158. if requestErr != nil {
  2159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2160. return
  2161. }
  2162. body, ioErr := ioutil.ReadAll(resp.Body)
  2163. if ioErr != nil {
  2164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2166. return
  2167. }
  2168. var respJSON map[string]interface{}
  2169. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2172. return
  2173. }
  2174. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2175. result_byte, _ := json.Marshal(respJSON)
  2176. result = string(result_byte)
  2177. //saveLog(result, requestLog, "2404", "入院登记撤销")
  2178. saveLog(result, requestLog, "2305", "退费")
  2179. } else {
  2180. result, requestLog := service.Gdyb2305(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  2181. saveLog(result, requestLog, "2305", "退费")
  2182. }
  2183. var dat map[string]interface{}
  2184. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2185. fmt.Println(dat)
  2186. } else {
  2187. fmt.Println(err)
  2188. }
  2189. userJSONBytes, _ := json.Marshal(dat)
  2190. var res ResultSixteen
  2191. var resSixteen ResultSixteen10265
  2192. if miConfig.Code == "H15049901371" {
  2193. if err := json.Unmarshal(userJSONBytes, &resSixteen); err != nil {
  2194. utils.ErrorLog("解析失败:%v", err)
  2195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2196. return
  2197. }
  2198. res.Cainfo = resSixteen.Cainfo
  2199. res.WarnMsg = resSixteen.WarnMsg
  2200. res.Output = resSixteen.Output
  2201. res.ErrMsg = resSixteen.ErrMsg
  2202. res.RespondTime = resSixteen.RespondTime
  2203. Infcode, _ := strconv.ParseInt(resSixteen.Infcode, 10, 64)
  2204. res.Infcode = Infcode
  2205. } else {
  2206. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2207. utils.ErrorLog("解析失败:%v", err)
  2208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2209. return
  2210. }
  2211. }
  2212. if res.Infcode == 0 {
  2213. err := service.UpdataOrderStatusThree(order_id, order.Number, adminUser.CurrentOrgId, "", result)
  2214. ////不同地区退费流程不一样,肇庆那边退费就包括撤销出院,内蒙古退费不包括撤销明细,所以下面需要根据不同情况进行判断
  2215. //if miConfig.UserOrgId == 10215 {
  2216. // record.OutHospitalStatus = 0
  2217. // service.CreateHospitalRecord(&record)
  2218. //}
  2219. service.UpdataOrderStatusByNumber(record.Number)
  2220. if err == nil {
  2221. ////当押金不为零时产生退费记录
  2222. if order.Decimal != 0 {
  2223. tmp := strconv.FormatInt(order.ID, 10)
  2224. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  2225. if err != nil {
  2226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2227. return
  2228. }
  2229. }
  2230. c.ServeSuccessJSON(map[string]interface{}{
  2231. "msg": "退费成功",
  2232. })
  2233. } else {
  2234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2235. return
  2236. }
  2237. } else {
  2238. c.ServeSuccessJSON(map[string]interface{}{
  2239. "code": -10,
  2240. "msg": res.ErrMsg,
  2241. })
  2242. }
  2243. } else {
  2244. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
  2245. if err == nil {
  2246. c.ServeSuccessJSON(map[string]interface{}{
  2247. "msg": "退费成功",
  2248. })
  2249. } else {
  2250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2251. return
  2252. }
  2253. }
  2254. }
  2255. func (c *ZHHisApiController) ZHRefundDetail() {
  2256. patient_id, _ := c.GetInt64("patient_id")
  2257. his_patient_id, _ := c.GetInt64("his_patient_id")
  2258. record_time := c.GetString("record_time")
  2259. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2260. //order_id, _ := c.GetInt64("order_id")
  2261. admin_user_id, _ := c.GetInt64("admin_user_id")
  2262. timeLayout := "2006-01-02"
  2263. loc, _ := time.LoadLocation("Local")
  2264. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2265. if err != nil {
  2266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2267. return
  2268. }
  2269. recordDateTime := theTime.Unix()
  2270. adminUser := c.GetAdminUserInfo()
  2271. theTimeTwo, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 23:59:59", loc)
  2272. if err != nil {
  2273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2274. return
  2275. }
  2276. recordDateTimeTwo := theTimeTwo.Unix()
  2277. //var prescriptions []*models.HisPrescription
  2278. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2279. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2280. if settle_accounts_type == 1 { //日结
  2281. record, _ := service.GetInHospitalRecord(his_patient_id)
  2282. infos, _ := service.GetZHHisUploadOrderInfo(adminUser.CurrentOrgId, patient_id, recordDateTime, recordDateTimeTwo, record.Number)
  2283. var isSuccess bool = true
  2284. for _, item := range infos {
  2285. var result string
  2286. var requestLog string
  2287. if miConfig.MdtrtareaAdmvs == "150499" {
  2288. //请求内网数据
  2289. api := "http://172.16.13.254:9532/" + "nmyb/2302?psn_no=" + record.PsnNo + "&mdtrtId=" + record.Number + "&feedetl_sn=" + item.FeedetlSn +
  2290. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2291. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&refund_type=" + "1"
  2292. resp, requestErr := http.Get(api)
  2293. if requestErr != nil {
  2294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2295. return
  2296. }
  2297. body, ioErr := ioutil.ReadAll(resp.Body)
  2298. if ioErr != nil {
  2299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2301. return
  2302. }
  2303. var respJSON map[string]interface{}
  2304. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2307. return
  2308. }
  2309. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2310. result_byte, _ := json.Marshal(respJSON)
  2311. result = string(result_byte)
  2312. saveLog(result, requestLog, "2302", "日结退明细")
  2313. } else {
  2314. result, requestLog := service.Gdyb2302(record.PsnNo, record.Number, miConfig.OrgName, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, item.FeedetlSn, 1)
  2315. saveLog(result, requestLog, "2302", "日结退明细")
  2316. }
  2317. var dat map[string]interface{}
  2318. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2319. fmt.Println(dat)
  2320. } else {
  2321. fmt.Println(err)
  2322. }
  2323. userJSONBytes, _ := json.Marshal(dat)
  2324. var res2 ResultEmpty
  2325. var resEmpty10265 ResultEmpty10265
  2326. if miConfig.Code == "H15049901371" {
  2327. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  2328. utils.ErrorLog("解析失败:%v", err)
  2329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2330. return
  2331. }
  2332. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  2333. res2.Infcode = Infcode
  2334. res2.RespondTime = resEmpty10265.RespondTime
  2335. res2.ErrMsg = resEmpty10265.ErrMsg
  2336. res2.Output = resEmpty10265.Output
  2337. res2.WarnMsg = resEmpty10265.WarnMsg
  2338. } else {
  2339. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  2340. utils.ErrorLog("解析失败:%v", err)
  2341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2342. return
  2343. }
  2344. }
  2345. if res2.Infcode == -1 {
  2346. isSuccess = false
  2347. }
  2348. }
  2349. if isSuccess {
  2350. err := service.UpDateOrderInfoStatus(patient_id, recordDateTime, adminUser.CurrentOrgId, recordDateTimeTwo)
  2351. if err != nil {
  2352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2353. return
  2354. }
  2355. err1 := service.UpDatePrescriptionOrderStatusTwo(patient_id, recordDateTime, adminUser.CurrentOrgId)
  2356. if err1 != nil {
  2357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2358. return
  2359. }
  2360. c.ServeSuccessJSON(map[string]interface{}{
  2361. "msg": "撤销明细成功",
  2362. })
  2363. }
  2364. } else {
  2365. //prescriptions, _ = service.GetZHMonthHisUploadPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2366. //var order models.HisOrder
  2367. //order, _ = service.GetHisOrderByID(order_id)
  2368. //record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2369. var result string
  2370. var requestLog string
  2371. record, _ := service.GetInHospitalRecord(his_patient_id)
  2372. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2373. if config.IsOpen == 1 { //对接了医保,走医保流程
  2374. if miConfig.MdtrtareaAdmvs == "150499" {
  2375. //请求内网数据
  2376. api := "http://172.16.13.254:9532/" + "nmyb/2302?psn_no=" + record.PsnNo + "&mdtrtId=" + record.Number + "&number=0000" +
  2377. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2378. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&refund_type=" + "1"
  2379. resp, requestErr := http.Get(api)
  2380. if requestErr != nil {
  2381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2382. return
  2383. }
  2384. body, ioErr := ioutil.ReadAll(resp.Body)
  2385. if ioErr != nil {
  2386. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2388. return
  2389. }
  2390. var respJSON map[string]interface{}
  2391. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2392. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2394. return
  2395. }
  2396. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2397. result_byte, _ := json.Marshal(respJSON)
  2398. result = string(result_byte)
  2399. //saveLog(result, requestLog, "2302", "日结退明细")
  2400. } else {
  2401. result, requestLog = service.Gdyb2302(record.PsnNo, record.Number, miConfig.OrgName, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, "0000", 0)
  2402. saveLog(result, requestLog, "2302", "月结退明细")
  2403. }
  2404. var dat map[string]interface{}
  2405. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2406. fmt.Println(dat)
  2407. } else {
  2408. fmt.Println(err)
  2409. }
  2410. userJSONBytes, _ := json.Marshal(dat)
  2411. var res2 ResultEmpty
  2412. var resEmpty10265 ResultEmpty10265
  2413. if miConfig.Code == "H15049901371" {
  2414. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  2415. utils.ErrorLog("解析失败:%v", err)
  2416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2417. return
  2418. }
  2419. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  2420. res2.Infcode = Infcode
  2421. res2.RespondTime = resEmpty10265.RespondTime
  2422. res2.ErrMsg = resEmpty10265.ErrMsg
  2423. res2.Output = resEmpty10265.Output
  2424. res2.WarnMsg = resEmpty10265.WarnMsg
  2425. } else {
  2426. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  2427. utils.ErrorLog("解析失败:%v", err)
  2428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2429. return
  2430. }
  2431. }
  2432. if res2.Infcode == 0 {
  2433. err := service.UpdataHospitalOrderStatus(record.Number, adminUser.CurrentOrgId)
  2434. if err == nil {
  2435. c.ServeSuccessJSON(map[string]interface{}{
  2436. "msg": "撤销明细成功",
  2437. })
  2438. } else {
  2439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2440. return
  2441. }
  2442. } else {
  2443. c.ServeSuccessJSON(map[string]interface{}{
  2444. "code": -10,
  2445. "msg": res2.ErrMsg,
  2446. })
  2447. }
  2448. }
  2449. }
  2450. }
  2451. func (this *ZHHisApiController) GetZHOutHospitalUnCheck() {
  2452. id, _ := this.GetInt64("id")
  2453. admin_user_id, _ := this.GetInt64("admin_user_id")
  2454. adminInfo := this.GetAdminUserInfo()
  2455. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2456. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  2457. record, _ := service.GetInHospitalRecord(id)
  2458. if record.ID == 0 {
  2459. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  2460. return
  2461. }
  2462. var result string
  2463. var requestLog string
  2464. if miConfig.MdtrtareaAdmvs == "150499" {
  2465. //请求内网数据
  2466. api := "http://172.16.13.254:9532/" + "nmyb/2405?mdtrt_id=" + record.Number + "&psn_no=" + record.PsnNo +
  2467. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  2468. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  2469. fmt.Println(api)
  2470. resp, requestErr := http.Get(api)
  2471. if requestErr != nil {
  2472. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2473. return
  2474. }
  2475. body, ioErr := ioutil.ReadAll(resp.Body)
  2476. if ioErr != nil {
  2477. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2478. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2479. return
  2480. }
  2481. var respJSON map[string]interface{}
  2482. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2483. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2484. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2485. return
  2486. }
  2487. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2488. result_byte, _ := json.Marshal(respJSON)
  2489. result = string(result_byte)
  2490. } else {
  2491. result, requestLog = service.ZHGdyb2405(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  2492. saveLog(result, requestLog, "2405", "出院登记撤销")
  2493. }
  2494. var dat map[string]interface{}
  2495. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2496. fmt.Println(dat)
  2497. } else {
  2498. fmt.Println(err)
  2499. }
  2500. userJSONBytes, _ := json.Marshal(dat)
  2501. var res ResultEmpty
  2502. var resEmpty10265 ResultEmpty10265
  2503. if miConfig.Code == "H15049901371" {
  2504. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  2505. utils.ErrorLog("解析失败:%v", err)
  2506. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2507. return
  2508. }
  2509. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  2510. res.Infcode = Infcode
  2511. res.RespondTime = resEmpty10265.RespondTime
  2512. res.ErrMsg = resEmpty10265.ErrMsg
  2513. res.Output = resEmpty10265.Output
  2514. res.WarnMsg = resEmpty10265.WarnMsg
  2515. } else {
  2516. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2517. utils.ErrorLog("解析失败:%v", err)
  2518. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2519. return
  2520. }
  2521. }
  2522. if res.Infcode == 0 {
  2523. record.OutHospitalStatus = 0
  2524. service.CreateHospitalRecord(&record)
  2525. service.UpdataOrderStatusByNumber(record.Number)
  2526. this.ServeSuccessJSON(map[string]interface{}{
  2527. "msg": "撤销出院成功",
  2528. })
  2529. } else {
  2530. this.ServeSuccessJSON(map[string]interface{}{
  2531. "failed_code": -10,
  2532. "msg": res.ErrMsg,
  2533. })
  2534. }
  2535. }
  2536. func (this *ZHHisApiController) GetZHInHospitalUnCheck() {
  2537. id, _ := this.GetInt64("id")
  2538. admin_user_id, _ := this.GetInt64("admin_user_id")
  2539. adminInfo := this.GetAdminUserInfo()
  2540. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2541. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  2542. record, _ := service.GetInHospitalRecord(id)
  2543. if record.ID == 0 {
  2544. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  2545. return
  2546. }
  2547. var result string
  2548. var requestLog string
  2549. if miConfig.MdtrtareaAdmvs == "150499" {
  2550. //请求内网数据
  2551. api := "http://172.16.13.254:9532/" + "nmyb/2302?psn_no=" + record.PsnNo + "&mdtrtId=" + record.Number + "&number=" + "0000" +
  2552. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  2553. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&refund_type=0"
  2554. resp, requestErr := http.Get(api)
  2555. if requestErr != nil {
  2556. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2557. return
  2558. }
  2559. body, ioErr := ioutil.ReadAll(resp.Body)
  2560. if ioErr != nil {
  2561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2562. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2563. return
  2564. }
  2565. var respJSON map[string]interface{}
  2566. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2568. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2569. return
  2570. }
  2571. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2572. result_byte, _ := json.Marshal(respJSON)
  2573. result = string(result_byte)
  2574. saveLog(result, requestLog, "2302", "月结退明细")
  2575. } else {
  2576. result, requestLog = service.Gdyb2302(record.PsnNo, record.Number, miConfig.OrgName, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, "0000", 0)
  2577. saveLog(result, requestLog, "2302", "月结退明细")
  2578. }
  2579. var dat map[string]interface{}
  2580. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2581. fmt.Println(dat)
  2582. } else {
  2583. fmt.Println(err)
  2584. }
  2585. userJSONBytes, _ := json.Marshal(dat)
  2586. var res2 ResultEmpty
  2587. var resEmpty10265 ResultEmpty10265
  2588. if miConfig.Code == "H15049901371" {
  2589. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  2590. utils.ErrorLog("解析失败:%v", err)
  2591. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2592. return
  2593. }
  2594. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  2595. res2.Infcode = Infcode
  2596. res2.RespondTime = resEmpty10265.RespondTime
  2597. res2.ErrMsg = resEmpty10265.ErrMsg
  2598. res2.Output = resEmpty10265.Output
  2599. res2.WarnMsg = resEmpty10265.WarnMsg
  2600. } else {
  2601. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  2602. utils.ErrorLog("解析失败:%v", err)
  2603. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2604. return
  2605. }
  2606. }
  2607. if res2.Infcode == 0 {
  2608. service.UpdataHospitalOrderStatus(record.Number, adminInfo.CurrentOrgId)
  2609. var result string
  2610. var requestLog string
  2611. if miConfig.MdtrtareaAdmvs == "150499" {
  2612. //请求内网数据
  2613. api := "http://172.16.13.254:9532/" + "nmyb/2404?mdtrt_id=" + record.Number + "&psn_no=" + record.PsnNo +
  2614. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  2615. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  2616. resp, requestErr := http.Get(api)
  2617. if requestErr != nil {
  2618. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2619. return
  2620. }
  2621. body, ioErr := ioutil.ReadAll(resp.Body)
  2622. if ioErr != nil {
  2623. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2624. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2625. return
  2626. }
  2627. var respJSON map[string]interface{}
  2628. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2630. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2631. return
  2632. }
  2633. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2634. result_byte, _ := json.Marshal(respJSON)
  2635. result = string(result_byte)
  2636. } else {
  2637. result, requestLog = service.ZHGdyb2404(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  2638. saveLog(result, requestLog, "2404", "入院登记撤销")
  2639. }
  2640. var dat map[string]interface{}
  2641. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2642. fmt.Println(dat)
  2643. } else {
  2644. fmt.Println(err)
  2645. }
  2646. userJSONBytes, _ := json.Marshal(dat)
  2647. var res ResultEmpty
  2648. var resEmpty10265 ResultEmpty10265
  2649. if miConfig.Code == "H15049901371" {
  2650. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  2651. utils.ErrorLog("解析失败:%v", err)
  2652. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2653. return
  2654. }
  2655. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  2656. res.Infcode = Infcode
  2657. res.RespondTime = resEmpty10265.RespondTime
  2658. res.ErrMsg = resEmpty10265.ErrMsg
  2659. res.Output = resEmpty10265.Output
  2660. res.WarnMsg = resEmpty10265.WarnMsg
  2661. } else {
  2662. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2663. utils.ErrorLog("解析失败:%v", err)
  2664. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2665. return
  2666. }
  2667. }
  2668. if res.Infcode == 0 {
  2669. record.Status = 0
  2670. service.CreateHospitalRecord(&record)
  2671. this.ServeSuccessJSON(map[string]interface{}{
  2672. "msg": "撤销入院成功",
  2673. })
  2674. } else {
  2675. this.ServeSuccessJSON(map[string]interface{}{
  2676. "failed_code": -10,
  2677. "msg": res.ErrMsg,
  2678. })
  2679. }
  2680. } else {
  2681. this.ServeSuccessJSON(map[string]interface{}{
  2682. "code": -10,
  2683. "msg": res2.ErrMsg,
  2684. })
  2685. }
  2686. }
  2687. func saveLog(result string, request string, infno string, desc string) {
  2688. org_id, _ := beego.AppConfig.Int64("org_id")
  2689. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  2690. dir := miConfig.OrgName + "日志"
  2691. utils.Mkdir(dir)
  2692. month := time.Unix(1557042972, 0).Format("1")
  2693. year := time.Now().Format("2006")
  2694. month = time.Now().Format("01")
  2695. day := time.Now().Format("02")
  2696. hour := time.Now().Format("15")
  2697. min := time.Now().Format("04")
  2698. sec := time.Now().Format("05")
  2699. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  2700. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  2701. file_name := file + ".txt"
  2702. file_path := miConfig.OrgName + "日志" + "/" + file_name
  2703. exist, _ := utils.PathExists(file_path)
  2704. if exist { //存在
  2705. fmt.Println("存在")
  2706. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  2707. if err != nil {
  2708. fmt.Println("read fail")
  2709. }
  2710. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  2711. n, _ := f.Seek(0, 2)
  2712. _, err = f.WriteAt([]byte(content), n)
  2713. } else { //不存在
  2714. fmt.Println("文件不存在,创建文件")
  2715. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  2716. defer f.Close()
  2717. if err != nil {
  2718. } else {
  2719. _, err = f.Write([]byte("记录日志"))
  2720. }
  2721. }
  2722. }
  2723. type Charset string
  2724. const (
  2725. UTF8 = Charset("UTF-8")
  2726. GB18030 = Charset("GB18030")
  2727. )
  2728. func ConvertToString(src string, srcCode string, tagCode string) string {
  2729. srcCoder := mahonia.NewDecoder(srcCode)
  2730. srcResult := srcCoder.ConvertString(src)
  2731. tagCoder := mahonia.NewDecoder(tagCode)
  2732. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  2733. result := string(cdata)
  2734. return result
  2735. }
  2736. type ELeData struct {
  2737. Data struct {
  2738. IdNo string `json:"idNo"`
  2739. IdType string `json:"idType"`
  2740. UserName string `json:"userName"`
  2741. EcToken string `json:"ecToken"`
  2742. InsuOrg string `json:"insuOrg"`
  2743. Gender string `json:"gender"`
  2744. Birthday string `json:"birthday"`
  2745. Nationality string `json:"nationality"`
  2746. Email string `json:"email"`
  2747. Extra string `json:"extra"`
  2748. } `json:"data"`
  2749. Code int `json:"code"`
  2750. Message string `json:"message"`
  2751. }
  2752. func (c *ZHHisApiController) ReadCard() {
  2753. id_card_type, _ := c.GetInt64("id_card_type")
  2754. admin_user_id, _ := c.GetInt64("admin_user_id")
  2755. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2756. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2757. var api string
  2758. api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  2759. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  2760. fmt.Println(api)
  2761. resp, requestErr := http.Get(api)
  2762. if requestErr != nil {
  2763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2764. return
  2765. }
  2766. body, ioErr := ioutil.ReadAll(resp.Body)
  2767. if ioErr != nil {
  2768. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2770. return
  2771. }
  2772. var respJSON map[string]interface{}
  2773. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2774. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2776. return
  2777. }
  2778. var status string
  2779. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2780. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2781. //console.log()
  2782. fmt.Println("type===")
  2783. fmt.Println(card_type)
  2784. var token string
  2785. var res ResultTwo //1101结果
  2786. var res10265 ResultTwo10265 //1101结果
  2787. var card_info string //卡信息
  2788. var busi_card_info string
  2789. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2790. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2791. if status == "0" { //读卡成功
  2792. if card_type == "1" {
  2793. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2794. result, _ := json.Marshal(respJSON)
  2795. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2796. utils.ErrorLog("解析失败:%v", err)
  2797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2798. return
  2799. }
  2800. res.ErrMsg = res10265.ErrMsg
  2801. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2802. res.Infcode = infocode
  2803. res.Output = res10265.Output
  2804. res.InfRefmsgid = res10265.InfRefmsgid
  2805. } else {
  2806. //var card_info string //卡信息
  2807. //var busi_card_info string
  2808. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2809. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2810. //fmt.Println(card_info)
  2811. //fmt.Println(busi_card_info)
  2812. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2813. result, _ := json.Marshal(respJSON)
  2814. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2815. utils.ErrorLog("解析失败:%v", err)
  2816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2817. return
  2818. }
  2819. res.ErrMsg = res10265.ErrMsg
  2820. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2821. res.Infcode = infocode
  2822. res.Output = res10265.Output
  2823. res.InfRefmsgid = res10265.InfRefmsgid
  2824. }
  2825. if res.Infcode == 0 {
  2826. var insutypes []string
  2827. var insutype string
  2828. var is390 int = 0
  2829. var is310 int = 0
  2830. for _, item := range res.Output.Iinfo {
  2831. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2832. insutypes = append(insutypes, item.Insutype)
  2833. }
  2834. }
  2835. if len(insutypes) == 1 {
  2836. insutype = insutypes[0]
  2837. } else {
  2838. for _, i := range insutypes {
  2839. if i == "390" {
  2840. is390 = 1
  2841. }
  2842. if i == "310" {
  2843. is310 = 1
  2844. }
  2845. }
  2846. }
  2847. if is390 == 1 {
  2848. insutype = "390"
  2849. }
  2850. if is310 == 1 {
  2851. insutype = "310"
  2852. }
  2853. if len(insutypes) == 0 {
  2854. insutype = "310"
  2855. }
  2856. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2857. if err == gorm.ErrRecordNotFound {
  2858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2859. return
  2860. } else if err != nil {
  2861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2862. return
  2863. } else {
  2864. if card_type == "1" {
  2865. bas := strings.Split(card_info, "|")
  2866. basNumber := bas[2]
  2867. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2868. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2869. infoStr := string(Iinfos)
  2870. idetinfoStr := string(Idetinfos)
  2871. psn := &models.HisPsn{
  2872. PsnNo: res.Output.Baseinfo.PsnNo,
  2873. Age: res.Output.Baseinfo.Age,
  2874. PatientId: patient.ID,
  2875. Certno: res.Output.Baseinfo.Certno,
  2876. Brdy: res.Output.Baseinfo.Brdy,
  2877. Gend: res.Output.Baseinfo.Gend,
  2878. Naty: res.Output.Baseinfo.Naty,
  2879. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2880. PsnName: res.Output.Baseinfo.PsnName,
  2881. Idetinfo: idetinfoStr,
  2882. Insuinfo: infoStr,
  2883. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2884. CardInfo: card_info,
  2885. VerifyNumber: busi_card_info,
  2886. }
  2887. service.CreateHisPsn(psn)
  2888. c.ServeSuccessJSON(map[string]interface{}{
  2889. "patient": patient,
  2890. "number": basNumber,
  2891. "info": res,
  2892. "insutype": insutype,
  2893. })
  2894. } else {
  2895. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2896. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2897. infoStr := string(Iinfos)
  2898. idetinfoStr := string(Idetinfos)
  2899. psn := &models.HisPsn{
  2900. PsnNo: res.Output.Baseinfo.PsnNo,
  2901. Age: res.Output.Baseinfo.Age,
  2902. PatientId: patient.ID,
  2903. Certno: res.Output.Baseinfo.Certno,
  2904. Brdy: res.Output.Baseinfo.Brdy,
  2905. Gend: res.Output.Baseinfo.Gend,
  2906. Naty: res.Output.Baseinfo.Naty,
  2907. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2908. PsnName: res.Output.Baseinfo.PsnName,
  2909. Idetinfo: idetinfoStr,
  2910. Insuinfo: infoStr,
  2911. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2912. CardInfo: card_info,
  2913. VerifyNumber: token,
  2914. }
  2915. service.CreateHisPsn(psn)
  2916. c.ServeSuccessJSON(map[string]interface{}{
  2917. "patient": patient,
  2918. "number": token,
  2919. "info": res,
  2920. "insutype": insutype,
  2921. })
  2922. }
  2923. }
  2924. } else {
  2925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2926. return
  2927. }
  2928. } else { //读卡失败
  2929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2930. return
  2931. }
  2932. }
  2933. var initFlag int64 = 0
  2934. func (c *ZHHisApiController) TestGetBasBaseInit() {
  2935. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  2936. Iinit := DllDef.MustFindProc("Init")
  2937. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2938. str := make([]byte, 2048)
  2939. inputData := make(map[string]interface{})
  2940. inputData["IP"] = "10.144.211.75"
  2941. inputData["PORT"] = 7021
  2942. inputData["TIMEOUT"] = 180
  2943. inputData["LOG_PATH"] = "C:\\log\\"
  2944. //inputData["SFZ_DRIVER_TYPE"] = 0
  2945. inputData["URL"] = "/call1"
  2946. bytesData, _ := json.Marshal(inputData)
  2947. fmt.Println(inputData)
  2948. fmt.Println(bytesData)
  2949. ret, _, err := Iinit.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str[0])))
  2950. if ret != 0 {
  2951. fmt.Println("SSCard的报错原因:", err)
  2952. fmt.Println("SSCard的运算结果为:", ret)
  2953. fmt.Println("SSCard的返回结果为:", string(str))
  2954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2955. return
  2956. }
  2957. fmt.Println("SSCard的返回结果为:", string(str))
  2958. result := int(ret)
  2959. fmt.Println("SSCard的运算结果为1:", result)
  2960. //initFlag = 1
  2961. return
  2962. }
  2963. func (c *ZHHisApiController) GetSFZBaseInfo() string {
  2964. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2965. readCard := DllDef.MustFindProc("ReadSFZ")
  2966. if readCard == nil {
  2967. fmt.Println("readcard is nil")
  2968. readCard = DllDef.MustFindProc("ReadSFZ")
  2969. }
  2970. str := make([]byte, 256)
  2971. str1 := make([]byte, 256)
  2972. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2973. fmt.Println(r)
  2974. return string(str)
  2975. }
  2976. func (c *ZHHisApiController) GetBasBaseInfo(fixmedins_code string, mdtrtarea_admvs string, opter_name string, opter_id string, fixmedins_name string) string {
  2977. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  2978. readCard := DllDef.MustFindProc("ReadCardBas")
  2979. fmt.Println(readCard)
  2980. fmt.Println("!!!!!")
  2981. month := time.Unix(1557042972, 0).Format("1")
  2982. year := time.Now().Format("2006")
  2983. month = time.Now().Format("01")
  2984. day := time.Now().Format("02")
  2985. hour := time.Now().Format("15")
  2986. min := time.Now().Format("04")
  2987. sec := time.Now().Format("05")
  2988. msec := time.Now().Format("000")
  2989. timestamp := time.Now().Unix()
  2990. tempTime := time.Unix(timestamp, 0)
  2991. //timeFormat := tempTime.Format("20060102150405")
  2992. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2993. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  2994. inputData := make(map[string]interface{})
  2995. inputData["infno"] = "1199"
  2996. //inputData["msgid"] = "7021"
  2997. inputData["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  2998. inputData["mdtrtarea_admvs"] = mdtrtarea_admvs // 发送方报文 ID
  2999. inputData["recer_sys_code"] = "01"
  3000. inputData["infver"] = "V1.0"
  3001. inputData["opter_type"] = "1"
  3002. inputData["opter"] = opter_id
  3003. inputData["opter_name"] = opter_name
  3004. inputData["inf_time"] = timeFormatOne
  3005. inputData["fixmedins_code"] = fixmedins_code
  3006. inputData["fixmedins_name"] = fixmedins_name
  3007. inputData["dev_no"] = ""
  3008. inputData["dev_safe_info"] = ""
  3009. inputData["cainfo"] = ""
  3010. inputData["signtype"] = ""
  3011. inputData["sign_no"] = ""
  3012. bytesData, _ := json.Marshal(inputData)
  3013. fmt.Println(string(bytesData))
  3014. pBusiCardInfo := make([]byte, 8192)
  3015. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  3016. fmt.Println(ret2)
  3017. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  3018. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  3019. if ret2 != 0 {
  3020. return ""
  3021. }
  3022. return DeleteExtraSpace(string(pBusiCardInfo))
  3023. }
  3024. func DeleteExtraSpace(s string) string {
  3025. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  3026. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  3027. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  3028. reg, _ := regexp.Compile(regstr) //编译正则表达式
  3029. s2 := make([]byte, len(s1)) //定义字符数组切片
  3030. copy(s2, s1) //将字符串复制到切片
  3031. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  3032. for len(spc_index) > 0 { //找到适配项
  3033. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  3034. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  3035. }
  3036. return string(s2)
  3037. }
  3038. func (c *ZHHisApiController) GetELeInfo(code string, operator_id string, operator_name string) (string, string) {
  3039. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  3040. readCard := DllDef.MustFindProc("NationEcTrans")
  3041. fmt.Println(readCard)
  3042. fmt.Println("!!!!!")
  3043. pBusiCardInfo := make([]byte, 8192)
  3044. input := make(map[string]interface{})
  3045. inputData := make(map[string]interface{})
  3046. inputData["orgId"] = code
  3047. inputData["businessType"] = "01101"
  3048. inputData["operatorId"] = operator_id
  3049. inputData["operatorName"] = operator_name
  3050. inputData["officeId"] = "001"
  3051. inputData["officeName"] = "血透室"
  3052. inputData["deviceType"] = ""
  3053. input["data"] = inputData
  3054. input["orgId"] = code
  3055. input["transType"] = "ec.query"
  3056. bytesData, _ := json.Marshal(input)
  3057. gdyb_url := beego.AppConfig.String("gdyb_url")
  3058. url := gdyb_url + "/localcfc/api/hsecfc/localQrCodeQuery"
  3059. ret2, _, _ := readCard.Call(StrPtr(url), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  3060. fmt.Println(ret2)
  3061. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  3062. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  3063. if ret2 != 0 {
  3064. return "", ""
  3065. }
  3066. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  3067. }
  3068. func StrPtr(s string) uintptr {
  3069. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3070. }
  3071. func Remove0000(s string) string {
  3072. str := make([]rune, 0, len(s))
  3073. for _, v := range []rune(s) {
  3074. if v == 0 {
  3075. continue
  3076. }
  3077. str = append(str, v)
  3078. }
  3079. return string(str)
  3080. }
  3081. func IntPtr(n int) uintptr {
  3082. return uintptr(n)
  3083. }