sz_his_api_controller.go 176KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037
  1. package sz
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "gdyb/controllers"
  6. "gdyb/enums"
  7. "gdyb/models"
  8. "gdyb/service"
  9. "gdyb/utils"
  10. "github.com/astaxie/beego"
  11. "github.com/axgle/mahonia"
  12. "math/rand"
  13. //"github.com/axgle/mahonia"
  14. "math"
  15. //"math/rand"
  16. "strconv"
  17. "strings"
  18. //"strings"
  19. "syscall"
  20. "time"
  21. "unsafe"
  22. )
  23. type Result struct {
  24. Transtime string `json:"transTime"`
  25. Transtype string `json:"transType"`
  26. Transreturncode string `json:"transReturnCode"`
  27. Transreturnmessage string `json:"transReturnMessage"`
  28. Transversion string `json:"transVersion"`
  29. Serialnumber string `json:"serialNumber"`
  30. Cardarea string `json:"cardArea"`
  31. Hospitalcode string `json:"hospitalCode"`
  32. Operatorcode string `json:"operatorCode"`
  33. Operatorname string `json:"operatorName"`
  34. Operatorpass string `json:"operatorPass"`
  35. Transbody struct {
  36. Akc190 string `json:"akc190"`
  37. Listsize int `json:"listsize"`
  38. Outputlist []struct {
  39. Aae072 string `json:"aae072"`
  40. Bkc369 string `json:"bkc369"`
  41. Bkf500 string `json:"bkf500"`
  42. Aka111 string `json:"aka111"`
  43. Ake001 string `json:"ake001"`
  44. Ake002 string `json:"ake002"`
  45. Bkm017 string `json:"bkm017"`
  46. Ake005 string `json:"ake005"`
  47. Ake006 string `json:"ake006"`
  48. Akc225 float64 `json:"akc225"`
  49. Akc226 float64 `json:"akc226"`
  50. Akc264 float64 `json:"akc264"`
  51. Aka065 string `json:"aka065"`
  52. Cka319 float64 `json:"cka319"`
  53. Akc268 float64 `json:"akc268"`
  54. } `json:"outputlist"`
  55. } `json:"transBody"`
  56. Verifycode string `json:"verifyCode"`
  57. Extenddeviceid string `json:"extendDeviceId"`
  58. Transchannel string `json:"transChannel"`
  59. Extenduserid string `json:"extendUserId"`
  60. Extendserialnumber string `json:"extendSerialNumber"`
  61. Caz055 string `json:"caz055"`
  62. Aae501 string `json:"aae501"`
  63. }
  64. type ResultOne struct {
  65. Transtime string `json:"transTime"`
  66. Transtype string `json:"transType"`
  67. Transreturncode string `json:"transReturnCode"`
  68. Transreturnmessage string `json:"transReturnMessage"`
  69. Transversion string `json:"transVersion"`
  70. Serialnumber string `json:"serialNumber"`
  71. Cardarea string `json:"cardArea"`
  72. Hospitalcode string `json:"hospitalCode"`
  73. Operatorcode string `json:"operatorCode"`
  74. Operatorname string `json:"operatorName"`
  75. Operatorpass string `json:"operatorPass"`
  76. Transbody struct {
  77. Ckc618 string `json:"ckc618"`
  78. Akc264 float64 `json:"akc264"`
  79. Akb068 int `json:"akb068"`
  80. Akb066 float64 `json:"akb066"`
  81. Akb067 int `json:"akb067"`
  82. Aae240 float64 `json:"aae240"`
  83. Outputlist []struct {
  84. Aaa036 string `json:"aaa036"`
  85. Aae019 float64 `json:"aae019"`
  86. } `json:"outputlist"`
  87. Outputlist2 []interface{} `json:"outputlist2"`
  88. } `json:"transBody"`
  89. Verifycode string `json:"verifyCode"`
  90. Extenddeviceid string `json:"extendDeviceId"`
  91. Transchannel string `json:"transChannel"`
  92. Extenduserid string `json:"extendUserId"`
  93. Extendserialnumber string `json:"extendSerialNumber"`
  94. Caz055 string `json:"caz055"`
  95. Aae501 string `json:"aae501"`
  96. }
  97. type ResultTwo struct {
  98. Transtime string `json:"transTime"`
  99. Transtype string `json:"transType"`
  100. Transreturncode string `json:"transReturnCode"`
  101. Transreturnmessage string `json:"transReturnMessage"`
  102. Transversion string `json:"transVersion"`
  103. Serialnumber string `json:"serialNumber"`
  104. Cardarea string `json:"cardArea"`
  105. Hospitalcode string `json:"hospitalCode"`
  106. Operatorcode string `json:"operatorCode"`
  107. Operatorname string `json:"operatorName"`
  108. Operatorpass string `json:"operatorPass"`
  109. Transbody struct {
  110. Ckc618 string `json:"ckc618"`
  111. Akc264 float64 `json:"akc264"`
  112. Akb068 float64 `json:"akb068"`
  113. Akb066 float64 `json:"akb066"`
  114. Akb067 float64 `json:"akb067"`
  115. Aae240 float64 `json:"aae240"`
  116. Outputlist1 []struct {
  117. Aka111 string `json:"aka111"`
  118. Bka058 float64 `json:"bka058"`
  119. } `json:"outputlist1"`
  120. Outputlist2 []struct {
  121. Aaa036 string `json:"aaa036"`
  122. Aae019 float64 `json:"aae019"`
  123. } `json:"outputlist2"`
  124. Outputlist3 []interface{} `json:"outputlist3"`
  125. } `json:"transBody"`
  126. Verifycode string `json:"verifyCode"`
  127. Extenddeviceid string `json:"extendDeviceId"`
  128. Transchannel string `json:"transChannel"`
  129. Extenduserid string `json:"extendUserId"`
  130. Extendserialnumber string `json:"extendSerialNumber"`
  131. Caz055 string `json:"caz055"`
  132. Aae501 string `json:"aae501"`
  133. }
  134. type ResultThree struct {
  135. Transtime string `json:"transTime"`
  136. Transtype string `json:"transType"`
  137. Transreturncode string `json:"transReturnCode"`
  138. Transreturnmessage string `json:"transReturnMessage"`
  139. Transversion string `json:"transVersion"`
  140. Serialnumber string `json:"serialNumber"`
  141. Cardarea string `json:"cardArea"`
  142. Hospitalcode string `json:"hospitalCode"`
  143. Operatorcode string `json:"operatorCode"`
  144. Operatorname string `json:"operatorName"`
  145. Operatorpass string `json:"operatorPass"`
  146. Transbody struct {
  147. Baz700 string `json:"baz700"`
  148. Ckc618 string `json:"ckc618"`
  149. } `json:"transBody"`
  150. Verifycode string `json:"verifyCode"`
  151. Extenddeviceid string `json:"extendDeviceId"`
  152. Transchannel string `json:"transChannel"`
  153. Extenduserid string `json:"extendUserId"`
  154. Extendserialnumber string `json:"extendSerialNumber"`
  155. Caz055 string `json:"caz055"`
  156. Aae501 string `json:"aae501"`
  157. }
  158. type ResultFive struct {
  159. Transtime string `json:"transTime"`
  160. Transtype string `json:"transType"`
  161. Transreturncode string `json:"transReturnCode"`
  162. Transreturnmessage string `json:"transReturnMessage"`
  163. Transversion string `json:"transVersion"`
  164. Serialnumber string `json:"serialNumber"`
  165. Cardarea string `json:"cardArea"`
  166. Hospitalcode string `json:"hospitalCode"`
  167. Operatorcode string `json:"operatorCode"`
  168. Operatorname string `json:"operatorName"`
  169. Operatorpass string `json:"operatorPass"`
  170. Transbody struct {
  171. Akc190 string `json:"akc190"`
  172. Listsize int `json:"listsize"`
  173. Outputlist []struct {
  174. Aae072 string `json:"aae072"`
  175. Bkf500 string `json:"bkf500"`
  176. Baz700 string `json:"baz700"`
  177. Bce574 string `json:"bce574"`
  178. } `json:"outputlist"`
  179. } `json:"transBody"`
  180. Verifycode string `json:"verifyCode"`
  181. Extenddeviceid string `json:"extendDeviceId"`
  182. Transchannel string `json:"transChannel"`
  183. Extenduserid string `json:"extendUserId"`
  184. Extendserialnumber string `json:"extendSerialNumber"`
  185. Caz055 string `json:"caz055"`
  186. Aae501 string `json:"aae501"`
  187. }
  188. type ResultFour struct {
  189. Transtime string `json:"transTime"`
  190. Transtype string `json:"transType"`
  191. Transreturncode string `json:"transReturnCode"`
  192. Transreturnmessage string `json:"transReturnMessage"`
  193. Transversion string `json:"transVersion"`
  194. Serialnumber string `json:"serialNumber"`
  195. Cardarea string `json:"cardArea"`
  196. Hospitalcode string `json:"hospitalCode"`
  197. Operatorcode string `json:"operatorCode"`
  198. Operatorname string `json:"operatorName"`
  199. Operatorpass string `json:"operatorPass"`
  200. Transbody struct {
  201. Akc190 string `json:"akc190"`
  202. Akc194 int `json:"akc194"`
  203. Bae917 int64 `json:"bae917"`
  204. Aka018 string `json:"aka018"`
  205. Aka030 string `json:"aka030"`
  206. Ckc618 string `json:"ckc618"`
  207. Akc264 float64 `json:"akc264"`
  208. Akb068 float64 `json:"akb068"`
  209. Akb066 float64 `json:"akb066"`
  210. Akb067 float64 `json:"akb067"`
  211. Cke298 float64 `json:"cke298"`
  212. Aae240 float64 `json:"aae240"`
  213. Outputlist1 []struct {
  214. Aae072 string `json:"aae072"`
  215. Bkc369 string `json:"bkc369"`
  216. Bkf500 string `json:"bkf500"`
  217. Aka111 string `json:"aka111"`
  218. Ake001 string `json:"ake001"`
  219. Ake002 string `json:"ake002"`
  220. Bkm017 string `json:"bkm017"`
  221. Ake005 string `json:"ake005"`
  222. Ake006 string `json:"ake006"`
  223. Ala026 string `json:"ala026"`
  224. Aka070 string `json:"aka070"`
  225. Aka074 string `json:"aka074"`
  226. Akc226 float64 `json:"akc226"`
  227. Akc225 float64 `json:"akc225"`
  228. Akc264 float64 `json:"akc264"`
  229. Aka067 string `json:"aka067"`
  230. Akc271 int `json:"akc271"`
  231. Bkc320 string `json:"bkc320"`
  232. Cke400 string `json:"cke400"`
  233. Ckc618 string `json:"ckc618"`
  234. Bka069 int64 `json:"bka069"`
  235. Aka018 string `json:"aka018"`
  236. Aka030 string `json:"aka030"`
  237. Aka065 string `json:"aka065"`
  238. Cka319 float64 `json:"cka319"`
  239. Akc268 float64 `json:"akc268"`
  240. } `json:"outputlist1"`
  241. Outputlist2 []struct {
  242. Aka111 string `json:"aka111"`
  243. Bka058 float64 `json:"bka058"`
  244. } `json:"outputlist2"`
  245. Outputlist3 []struct {
  246. Aaa036 string `json:"aaa036"`
  247. Aae019 float64 `json:"aae019"`
  248. } `json:"outputlist3"`
  249. } `json:"transBody"`
  250. Verifycode string `json:"verifyCode"`
  251. Extenddeviceid string `json:"extendDeviceId"`
  252. Transchannel string `json:"transChannel"`
  253. Extenduserid string `json:"extendUserId"`
  254. Extendserialnumber string `json:"extendSerialNumber"`
  255. Caz055 string `json:"caz055"`
  256. Aae501 string `json:"aae501"`
  257. }
  258. type ResultMZ001 struct {
  259. Transtime string `json:"transTime"`
  260. Transtype string `json:"transType"`
  261. Transreturncode string `json:"transReturnCode"`
  262. Transreturnmessage string `json:"transReturnMessage"`
  263. Transversion string `json:"transVersion"`
  264. Serialnumber string `json:"serialNumber"`
  265. Cardarea string `json:"cardArea"`
  266. Hospitalcode string `json:"hospitalCode"`
  267. Operatorcode string `json:"operatorCode"`
  268. Operatorname string `json:"operatorName"`
  269. Operatorpass string `json:"operatorPass"`
  270. Transbody struct {
  271. Aaz515 string `json:"aaz515"`
  272. Aaz500 string `json:"aaz500"`
  273. Aac001 float64 `json:"aac001"`
  274. Aac999 string `json:"aac999"`
  275. Aac002 string `json:"aac002"`
  276. Aac058 string `json:"aac058"`
  277. Aac147 string `json:"aac147"`
  278. Aac003 string `json:"aac003"`
  279. Aac004 string `json:"aac004"`
  280. Aac006 float64 `json:"aac006"`
  281. Bae093 float64 `json:"bae093"`
  282. Cac215 string `json:"cac215"`
  283. Aac066 string `json:"aac066"`
  284. Aac008 string `json:"aac008"`
  285. Bke404 string `json:"bke404"`
  286. Aae240 float64 `json:"aae240"`
  287. Bkc346 string `json:"bkc346"`
  288. Ckc601 string `json:"ckc601"`
  289. Caz574 string `json:"caz574"`
  290. Caz654 string `json:"caz654"`
  291. Ckc403 string `json:"ckc403"`
  292. Ckc362 string `json:"ckc362"`
  293. Ckc363 string `json:"ckc363"`
  294. Outputlist1 []struct {
  295. Aab001 float64 `json:"aab001"`
  296. Aab999 string `json:"aab999"`
  297. Aab004 string `json:"aab004"`
  298. Aab019 string `json:"aab019"`
  299. Aae140 string `json:"aae140"`
  300. Aae030 float64 `json:"aae030"`
  301. Aae031 string `json:"aae031"`
  302. Bcc334 string `json:"bcc334"`
  303. Aac031 string `json:"aac031"`
  304. } `json:"outputlist1"`
  305. } `json:"transBody"`
  306. Verifycode string `json:"verifyCode"`
  307. Extenddeviceid string `json:"extendDeviceId"`
  308. Transchannel string `json:"transChannel"`
  309. Extenduserid string `json:"extendUserId"`
  310. Extendserialnumber string `json:"extendSerialNumber"`
  311. Caz055 string `json:"caz055"`
  312. Aae501 string `json:"aae501"`
  313. }
  314. type SZHisApiController struct {
  315. controllers.BaseAuthAPIController
  316. }
  317. func SZHisManagerApiRegistRouters() {
  318. //挂号
  319. beego.Router("/sz/api/register/get", &SZHisApiController{}, "get:GetRegisterInfo")
  320. //上传明细,预结算
  321. //beego.Router("/sz/api/upload/get", &SZHisApiController{}, "get:GetUploadInfo")
  322. //结算
  323. beego.Router("/sz/api/settle/get", &SZHisApiController{}, "get:GetSettleInfo")
  324. //退费
  325. beego.Router("/sz/api/refund/get", &SZHisApiController{}, "get:Refund")
  326. beego.Router("/sz/api/readcard", &SZHisApiController{}, "get:ReadCard")
  327. beego.Router("sz/api/refundnumber/get", &SZHisApiController{}, "get:RefundNumber")
  328. beego.Router("/sz/api/monthrefund/get", &SZHisApiController{}, "get:MonthRefund")
  329. //查询交易
  330. beego.Router("/sz/api/settle/query", &SZHisApiController{}, "get:GetSettleAccounts")
  331. //beego.Router("/sz/api/detail/upload", &SZHisApiController{}, "get:GetUploadDetail")
  332. beego.Router("/sz/api/detail/cancel", &SZHisApiController{}, "get:CancelOrderDetail")
  333. //
  334. ////机构药品目录备案
  335. beego.Router("/sz/api/drug/get", &SZHisApiController{}, "get:GetDrugList")
  336. ////协议机构诊疗项目
  337. beego.Router("/sz/api/treatment/get", &SZHisApiController{}, "get:GetTreatmentProject")
  338. ////协议机构目录备案撤销
  339. beego.Router("/sz/api/revocation/get", &SZHisApiController{}, "get:GetRevocation")
  340. //
  341. ////定点机构约定信息查询
  342. //beego.Router("/sz/api/information/query/get",&SZHisApiController{},"get:GetInformationQuery")
  343. ////-医药师信息登记
  344. beego.Router("/sz/api/doctor/get", &SZHisApiController{}, "get:GetDoctorList")
  345. ////医药师执业状态变更
  346. beego.Router("/sz/api/medical/get", &SZHisApiController{}, "get:GetMedicalList")
  347. ////医药师信息更新
  348. //beego.Router("/sz/api/update/medical/get", &SZHisApiController{}, "get:GetUpdateMedicalList")
  349. ////协议机构材料目录备案
  350. //
  351. beego.Router("/sz/api/goods/get", &SZHisApiController{}, "get:GetGoodsList")
  352. }
  353. func IntPtr(n int) uintptr {
  354. return uintptr(n)
  355. }
  356. func StrPtr(s string) uintptr {
  357. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  358. }
  359. type Custom struct {
  360. DetItemFeeSumamt string
  361. Cut string
  362. FeedetlSn string
  363. Price string
  364. MedListCodg string
  365. Type int64
  366. AdviceId int64
  367. ProjectId int64
  368. ItemId int64
  369. }
  370. func (c *SZHisApiController) ReadCard() {
  371. id_card_type, _ := c.GetInt64("id_card_type")
  372. adminInfo := c.GetAdminUserInfo()
  373. if id_card_type != 1 {
  374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorNoReadCardException)
  375. return
  376. }
  377. month := time.Unix(1557042972, 0).Format("1")
  378. year := time.Now().Format("2006")
  379. month = time.Now().Format("01")
  380. day := time.Now().Format("02")
  381. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  382. number := miConfig.Code + year + month + day +
  383. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  384. id_card_number, health_card_no, _, ret4 := ReadBasCard("MZ002" + "|" + number + "|" + miConfig.Code + "|")
  385. if ret4 == 0 {
  386. patient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  387. if patient.ID == 0 {
  388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  389. return
  390. } else {
  391. c.ServeSuccessJSON(map[string]interface{}{
  392. "patient": patient,
  393. "health_card_no": health_card_no,
  394. })
  395. }
  396. } else {
  397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  398. return
  399. }
  400. }
  401. //获取读卡信息 -- 门诊挂号
  402. //func (c *SZHisApiController) GetRegisterInfo() {
  403. // adminInfo := c.GetAdminUserInfo()
  404. // admin_user_id, _ := c.GetInt64("admin_user_id")
  405. // patient_id, _ := c.GetInt64("id")
  406. // record_time := c.GetString("record_time")
  407. // settlementValue, _ := c.GetInt64("settlement_value")
  408. // medical_insurance_card := c.GetString("medical_insurance_card")
  409. // name := c.GetString("name")
  410. // id_card_type, _ := c.GetInt64("id_card_type")
  411. // certificates, _ := c.GetInt64("certificates")
  412. // medical_care, _ := c.GetInt64("medical_care")
  413. // birthday := c.GetString("birthday")
  414. // id_card := c.GetString("id_card")
  415. // register_type, _ := c.GetInt64("register")
  416. // doctor, _ := c.GetInt64("doctor")
  417. // department, _ := c.GetInt64("department")
  418. // gender, _ := c.GetInt64("sex")
  419. // registration_fee, _ := c.GetFloat("registration_fee")
  420. // medical_expenses, _ := c.GetFloat("medical_expenses")
  421. // social_type, _ := c.GetInt64("social_type")
  422. //
  423. // is_yidi, _ := c.GetInt64("is_yidi")
  424. //
  425. // timeLayout := "2006-01-02"
  426. // loc, _ := time.LoadLocation("Local")
  427. // birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  428. // birthUnix := birthdays.Unix()
  429. //
  430. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  431. // if err != nil {
  432. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  433. // return
  434. // }
  435. //
  436. // var patient service.Patients
  437. // if patient_id == 0 {
  438. // patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  439. // } else {
  440. // patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
  441. // }
  442. //
  443. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  444. // if patient.ID == 0 {
  445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  446. // return
  447. // }
  448. // if len(patient.IdCardNo) == 0 {
  449. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  450. // return
  451. // }
  452. //
  453. // adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  454. // his, _ := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient_id, theTime.Unix())
  455. //
  456. // var custom_code string
  457. // var custom_project_name string
  458. // var allPrice float64
  459. //
  460. // switch register_type {
  461. // case 1:
  462. // custom_code = "110100002"
  463. // custom_project_name = "普通门诊"
  464. // allPrice = 10
  465. // break
  466. // case 3:
  467. // custom_code = "110200002-2"
  468. // custom_project_name = "主任医师"
  469. // allPrice = 10
  470. //
  471. // break
  472. // case 2:
  473. // custom_code = "110200002-3"
  474. // custom_project_name = "副主任医师"
  475. // allPrice = 10
  476. //
  477. // break
  478. // case 4:
  479. // custom_code = "0"
  480. // custom_project_name = "免受诊金"
  481. // allPrice = 0
  482. // break
  483. // case 5:
  484. // custom_code = "110200002-1"
  485. // custom_project_name = "专家"
  486. // allPrice = 10
  487. //
  488. // break
  489. // }
  490. //
  491. // if his.ID == 0 {
  492. //
  493. // var doctor_name string
  494. // var doctor_code string
  495. // if adminRole.ID == 0 {
  496. //
  497. // doctor_name = ""
  498. // doctor_code = "1001"
  499. // doctor_name = ""
  500. // doctor_code = ""
  501. //
  502. // } else {
  503. // doctor_name = adminRole.UserName
  504. // doctor_code = strconv.FormatInt(admin_user_id, 10)
  505. //
  506. // }
  507. // month := time.Unix(1557042972, 0).Format("1")
  508. // year := time.Now().Format("2006")
  509. // month = time.Now().Format("01")
  510. // day := time.Now().Format("02")
  511. //
  512. // //流水号
  513. // //
  514. // number := miConfig.Code + year + month + day +
  515. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  516. // mz_number := year + month + day + strconv.FormatInt(patient_id, 10) +
  517. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
  518. // //1.判断读卡类型
  519. // //2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
  520. // yiliao_number, id_card_number, verifyCode, version_code, _, ret4 := ReadBasCardGetNumber("MZ002" + "|" + number + "|" + miConfig.Code + "|")
  521. // fmt.Println(yiliao_number)
  522. // fmt.Println(id_card_number)
  523. // fmt.Println(verifyCode)
  524. // fmt.Println(version_code)
  525. // fmt.Println(ret4)
  526. //
  527. // dept_code := "0305"
  528. // is_yidi = 1
  529. // tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  530. // //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  531. // if tempPatient.ID == patient_id {
  532. // if ret4 == 0 { //本地卡流程
  533. // if is_yidi == 1 {
  534. // //本地就医流程
  535. // //挂号
  536. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, dept_code, yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice,medical_care)
  537. // var dat map[string]interface{}
  538. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  539. // fmt.Println(dat)
  540. // } else {
  541. // fmt.Println(err)
  542. // }
  543. // userJSONBytes, _ := json.Marshal(dat)
  544. // var res ResultOne
  545. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  546. // utils.ErrorLog("解析失败:%v", err)
  547. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  548. // return
  549. // }
  550. // if res.Transreturncode == "00000000" {
  551. // his := models.VMHisPatient{
  552. // Name: name,
  553. // Gender: gender,
  554. // Birthday: birthUnix,
  555. // MedicalTreatmentType: medical_care,
  556. // IdType: certificates,
  557. // IdCardNo: id_card,
  558. // BalanceAccountsType: settlementValue,
  559. // SocialType: social_type,
  560. // MedicalInsuranceNumber: medical_insurance_card,
  561. // RegisterType: register_type,
  562. // RegisterCost: registration_fee,
  563. // TreatmentCost: medical_expenses,
  564. // Status: 1,
  565. // Ctime: time.Now().Unix(),
  566. // Mtime: time.Now().Unix(),
  567. // Iinfo: resp_result,
  568. // PatientId: patient.ID,
  569. // RecordDate: theTime.Unix(),
  570. // UserOrgId: adminInfo.CurrentOrgId,
  571. // AdminUserId: admin_user_id,
  572. // IsReturn: 1,
  573. // IdCardType: id_card_type,
  574. // Doctor: doctor,
  575. // Departments: department,
  576. // YiliaoNumber: yiliao_number,
  577. // MzNumber: number,
  578. // Number: mz_number,
  579. // }
  580. // service.CreateHisPatientTwo(&his)
  581. // c.ServeSuccessJSON(map[string]interface{}{
  582. // "msg": "挂号成功",
  583. // })
  584. // } else {
  585. // c.ServeSuccessJSON(map[string]interface{}{
  586. // "failed_code": -10,
  587. // "msg": res.Transreturnmessage,
  588. // })
  589. // return
  590. // }
  591. //
  592. // } else {
  593. // //异地就医流程
  594. // //异地走鉴权流程
  595. // //authResult := CardAuth(number)
  596. // //fmt.Println(authResult)
  597. //
  598. // //tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  599. // //if tempPatient.ID == patient_id {
  600. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  601. // var dat map[string]interface{}
  602. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  603. // fmt.Println(dat)
  604. // } else {
  605. // fmt.Println(err)
  606. // }
  607. //
  608. // userJSONBytes, _ := json.Marshal(dat)
  609. //
  610. // var res ResultOne
  611. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  612. // utils.ErrorLog("解析失败:%v", err)
  613. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  614. // return
  615. // }
  616. // if res.Transreturncode == "00000000" {
  617. // his := models.VMHisPatient{
  618. // Name: name,
  619. // Gender: gender,
  620. // Birthday: birthUnix,
  621. // MedicalTreatmentType: medical_care,
  622. // IdType: certificates,
  623. // IdCardNo: id_card,
  624. // BalanceAccountsType: settlementValue,
  625. // SocialType: social_type,
  626. // MedicalInsuranceNumber: medical_insurance_card,
  627. // RegisterType: register_type,
  628. // RegisterCost: registration_fee,
  629. // TreatmentCost: medical_expenses,
  630. // Status: 1,
  631. // Ctime: time.Now().Unix(),
  632. // Mtime: time.Now().Unix(),
  633. // Iinfo: resp_result,
  634. // PatientId: patient.ID,
  635. // RecordDate: theTime.Unix(),
  636. // UserOrgId: adminInfo.CurrentOrgId,
  637. // AdminUserId: admin_user_id,
  638. // IsReturn: 1,
  639. // IdCardType: id_card_type,
  640. // Doctor: doctor,
  641. // Departments: department,
  642. // YiliaoNumber: yiliao_number,
  643. // MzNumber: number,
  644. // Number: mz_number,
  645. // }
  646. // service.CreateHisPatientTwo(&his)
  647. // c.ServeSuccessJSON(map[string]interface{}{
  648. // "msg": "挂号成功",
  649. // })
  650. // } else {
  651. // c.ServeSuccessJSON(map[string]interface{}{
  652. // "failed_code": -10,
  653. // "msg": res.Transreturnmessage,
  654. // })
  655. // return
  656. // }
  657. //
  658. // }
  659. //
  660. // } else { //异地卡流程
  661. // //readCardBasResult := ReadCardBasHSM(number)
  662. // //fmt.Println(readCardBasResult)
  663. // //是否异地就医,是的话走鉴权流程,不是的话走门诊挂号
  664. // if is_yidi == 1 { //1本地就医
  665. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  666. // var dat map[string]interface{}
  667. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  668. // fmt.Println(dat)
  669. // } else {
  670. // fmt.Println(err)
  671. // }
  672. //
  673. // userJSONBytes, _ := json.Marshal(dat)
  674. //
  675. // var res ResultOne
  676. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  677. // utils.ErrorLog("解析失败:%v", err)
  678. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  679. // return
  680. // }
  681. // if res.Transreturncode == "00000000" {
  682. // his := models.VMHisPatient{
  683. // Name: name,
  684. // Gender: gender,
  685. // Birthday: birthUnix,
  686. // MedicalTreatmentType: medical_care,
  687. // IdType: certificates,
  688. // IdCardNo: id_card,
  689. // BalanceAccountsType: settlementValue,
  690. // SocialType: social_type,
  691. // MedicalInsuranceNumber: medical_insurance_card,
  692. // RegisterType: register_type,
  693. // RegisterCost: registration_fee,
  694. // TreatmentCost: medical_expenses,
  695. // Status: 1,
  696. // Ctime: time.Now().Unix(),
  697. // Mtime: time.Now().Unix(),
  698. // Iinfo: resp_result,
  699. // PatientId: patient.ID,
  700. // RecordDate: theTime.Unix(),
  701. // UserOrgId: adminInfo.CurrentOrgId,
  702. // AdminUserId: admin_user_id,
  703. // IsReturn: 1,
  704. // IdCardType: id_card_type,
  705. // Doctor: doctor,
  706. // Departments: department,
  707. // YiliaoNumber: yiliao_number,
  708. // MzNumber: number,
  709. // Number: mz_number,
  710. // }
  711. // service.CreateHisPatientTwo(&his)
  712. // c.ServeSuccessJSON(map[string]interface{}{
  713. // "msg": "挂号成功",
  714. // })
  715. // } else {
  716. // c.ServeSuccessJSON(map[string]interface{}{
  717. // "failed_code": -10,
  718. // "msg": res.Transreturnmessage,
  719. // })
  720. // return
  721. // }
  722. //
  723. // } else { //异地就医需要走鉴权流程
  724. // //authResult := CardAuth(number)
  725. // //fmt.Println(authResult)
  726. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  727. // var dat map[string]interface{}
  728. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  729. // fmt.Println(dat)
  730. // } else {
  731. // fmt.Println(err)
  732. // }
  733. //
  734. // userJSONBytes, _ := json.Marshal(dat)
  735. //
  736. // var res ResultOne
  737. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  738. // utils.ErrorLog("解析失败:%v", err)
  739. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  740. // return
  741. // }
  742. // if res.Transreturncode == "00000000" {
  743. // his := models.VMHisPatient{
  744. // Name: name,
  745. // Gender: gender,
  746. // Birthday: birthUnix,
  747. // MedicalTreatmentType: medical_care,
  748. // IdType: certificates,
  749. // IdCardNo: id_card,
  750. // BalanceAccountsType: settlementValue,
  751. // SocialType: social_type,
  752. // MedicalInsuranceNumber: medical_insurance_card,
  753. // RegisterType: register_type,
  754. // RegisterCost: registration_fee,
  755. // TreatmentCost: medical_expenses,
  756. // Status: 1,
  757. // Ctime: time.Now().Unix(),
  758. // Mtime: time.Now().Unix(),
  759. // Iinfo: resp_result,
  760. // PatientId: patient.ID,
  761. // RecordDate: theTime.Unix(),
  762. // UserOrgId: adminInfo.CurrentOrgId,
  763. // AdminUserId: admin_user_id,
  764. // IsReturn: 1,
  765. // IdCardType: id_card_type,
  766. // Doctor: doctor,
  767. // Departments: department,
  768. // YiliaoNumber: yiliao_number,
  769. // MzNumber: number,
  770. // Number: mz_number,
  771. // }
  772. // service.CreateHisPatientTwo(&his)
  773. // c.ServeSuccessJSON(map[string]interface{}{
  774. // "msg": "挂号成功",
  775. // })
  776. // } else {
  777. // c.ServeSuccessJSON(map[string]interface{}{
  778. // "failed_code": -10,
  779. // "msg": res.Transreturnmessage,
  780. // })
  781. // return
  782. // }
  783. //
  784. // }
  785. // }
  786. // } else {
  787. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  788. // return
  789. // }
  790. // } else {
  791. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  792. // return
  793. // }
  794. //}
  795. func (c *SZHisApiController) GetRegisterInfo() {
  796. adminInfo := c.GetAdminUserInfo()
  797. admin_user_id, _ := c.GetInt64("admin_user_id")
  798. patient_id, _ := c.GetInt64("id")
  799. record_time := c.GetString("record_time")
  800. settlementValue, _ := c.GetInt64("settlement_value")
  801. medical_insurance_card := c.GetString("medical_insurance_card")
  802. name := c.GetString("name")
  803. id_card_type, _ := c.GetInt64("id_card_type")
  804. certificates, _ := c.GetInt64("certificates")
  805. medical_care, _ := c.GetInt64("medical_care")
  806. birthday := c.GetString("birthday")
  807. id_card := c.GetString("id_card")
  808. register_type, _ := c.GetInt64("register")
  809. doctor, _ := c.GetInt64("doctor")
  810. department, _ := c.GetInt64("department")
  811. gender, _ := c.GetInt64("sex")
  812. registration_fee, _ := c.GetFloat("registration_fee")
  813. medical_expenses, _ := c.GetFloat("medical_expenses")
  814. social_type, _ := c.GetInt64("social_type")
  815. is_yidi, _ := c.GetInt64("is_yidi")
  816. timeLayout := "2006-01-02"
  817. loc, _ := time.LoadLocation("Local")
  818. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  819. birthUnix := birthdays.Unix()
  820. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  821. if err != nil {
  822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  823. return
  824. }
  825. var patient service.Patients
  826. if patient_id == 0 {
  827. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  828. } else {
  829. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
  830. }
  831. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  832. if patient.ID == 0 {
  833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  834. return
  835. }
  836. if len(patient.IdCardNo) == 0 {
  837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  838. return
  839. }
  840. //doctorInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  841. doctorDepartment, _ := service.GetDepartMentDetail(department)
  842. adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  843. his, _ := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient_id, theTime.Unix())
  844. var custom_code string
  845. var custom_project_name string
  846. var allPrice float64
  847. switch register_type {
  848. case 1:
  849. custom_code = "110100002"
  850. custom_project_name = "普通门诊"
  851. allPrice = 10
  852. break
  853. case 3:
  854. custom_code = "110200002-2"
  855. custom_project_name = "主任医师"
  856. allPrice = 10
  857. break
  858. case 2:
  859. custom_code = "110200002-3"
  860. custom_project_name = "副主任医师"
  861. allPrice = 10
  862. break
  863. case 4:
  864. custom_code = "0"
  865. custom_project_name = "免受诊金"
  866. allPrice = 0
  867. break
  868. case 5:
  869. custom_code = "110200002-1"
  870. custom_project_name = "专家"
  871. allPrice = 10
  872. break
  873. }
  874. if his.ID == 0 {
  875. var opera_name string
  876. var opera_code string
  877. if adminRole.ID == 0 {
  878. opera_name = "管理员"
  879. opera_code = "01"
  880. } else {
  881. opera_name = adminRole.UserName
  882. opera_code = strconv.FormatInt(admin_user_id, 10)
  883. }
  884. month := time.Unix(1557042972, 0).Format("1")
  885. year := time.Now().Format("2006")
  886. month = time.Now().Format("01")
  887. day := time.Now().Format("02")
  888. //流水号
  889. number := miConfig.Code + year + month + day +
  890. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  891. mz_number := miConfig.Code + year + month + day +
  892. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
  893. //1.判断读卡类型
  894. //2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
  895. yiliao_number, id_card_number, verifyCode, version_code, health_card_no, _, ret4 := ReadBasCardGetNumber("MZ002" + "|" + number + "|" + miConfig.Code + "|")
  896. fmt.Println(yiliao_number)
  897. fmt.Println(id_card_number)
  898. fmt.Println(verifyCode)
  899. fmt.Println(version_code)
  900. fmt.Println(ret4)
  901. dept_code := doctorDepartment.Number
  902. is_yidi = 1
  903. tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  904. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  905. fmt.Println(tempPatient.ID)
  906. fmt.Println(patient_id)
  907. if tempPatient.ID == patient_id {
  908. temp_mz_number := miConfig.Code + year + month + day +
  909. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
  910. tempVerifyCode, tempVersionCode := ReadCardGetCode("XX001" + "|" + temp_mz_number + "|" + miConfig.Code)
  911. result001 := service.SzybXX001(opera_name, opera_code, miConfig.Code, yiliao_number, tempVerifyCode, temp_mz_number, tempVersionCode)
  912. if ret4 == 0 { //本地卡流程
  913. if is_yidi == 1 {
  914. //var dat2 map[string]interface{}
  915. //if err := json.Unmarshal([]byte(result001), &dat2); err == nil {
  916. // fmt.Println(dat2)
  917. //} else {
  918. // fmt.Println(err)
  919. //}
  920. //userJSONBytes2, _ := json.Marshal(dat2)
  921. //var res2 ResultMZ001
  922. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  923. // utils.ErrorLog("解析失败:%v", err)
  924. //}
  925. //本地就医流程
  926. //挂号
  927. resp_result := service.SzybMZ002(opera_name, opera_code, miConfig.Code, dept_code, yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  928. var dat map[string]interface{}
  929. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  930. fmt.Println(dat)
  931. } else {
  932. fmt.Println(err)
  933. }
  934. userJSONBytes, _ := json.Marshal(dat)
  935. var res ResultOne
  936. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  937. utils.ErrorLog("解析失败:%v", err)
  938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  939. return
  940. }
  941. if res.Transreturncode == "00000000" {
  942. his := models.VMHisPatient{
  943. Name: name,
  944. Gender: gender,
  945. Birthday: birthUnix,
  946. MedicalTreatmentType: medical_care,
  947. IdType: certificates,
  948. IdCardNo: id_card,
  949. BalanceAccountsType: settlementValue,
  950. SocialType: social_type,
  951. MedicalInsuranceNumber: medical_insurance_card,
  952. RegisterType: register_type,
  953. RegisterCost: registration_fee,
  954. TreatmentCost: medical_expenses,
  955. Status: 1,
  956. Ctime: time.Now().Unix(),
  957. Mtime: time.Now().Unix(),
  958. Iinfo: resp_result,
  959. PatientId: patient.ID,
  960. RecordDate: theTime.Unix(),
  961. UserOrgId: adminInfo.CurrentOrgId,
  962. AdminUserId: admin_user_id,
  963. IsReturn: 1,
  964. IdCardType: id_card_type,
  965. Doctor: doctor,
  966. Departments: department,
  967. YiliaoNumber: yiliao_number,
  968. MzNumber: number,
  969. Number: mz_number,
  970. PsnNo: health_card_no,
  971. PatientInfo: result001,
  972. }
  973. service.CreateHisPatientTwo(&his)
  974. c.ServeSuccessJSON(map[string]interface{}{
  975. "msg": "挂号成功",
  976. })
  977. } else {
  978. c.ServeSuccessJSON(map[string]interface{}{
  979. "failed_code": -10,
  980. "msg": res.Transreturnmessage,
  981. })
  982. return
  983. }
  984. } else {
  985. //异地就医流程
  986. //异地走鉴权流程
  987. //authResult := CardAuth(number)
  988. //fmt.Println(authResult)
  989. //tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  990. //if tempPatient.ID == patient_id {
  991. resp_result := service.SzybMZ002(opera_name, opera_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  992. var dat map[string]interface{}
  993. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  994. fmt.Println(dat)
  995. } else {
  996. fmt.Println(err)
  997. }
  998. userJSONBytes, _ := json.Marshal(dat)
  999. var res ResultOne
  1000. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1001. utils.ErrorLog("解析失败:%v", err)
  1002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1003. return
  1004. }
  1005. if res.Transreturncode == "00000000" {
  1006. his := models.VMHisPatient{
  1007. Name: name,
  1008. Gender: gender,
  1009. Birthday: birthUnix,
  1010. MedicalTreatmentType: medical_care,
  1011. IdType: certificates,
  1012. IdCardNo: id_card,
  1013. BalanceAccountsType: settlementValue,
  1014. SocialType: social_type,
  1015. MedicalInsuranceNumber: medical_insurance_card,
  1016. RegisterType: register_type,
  1017. RegisterCost: registration_fee,
  1018. TreatmentCost: medical_expenses,
  1019. Status: 1,
  1020. Ctime: time.Now().Unix(),
  1021. Mtime: time.Now().Unix(),
  1022. Iinfo: resp_result,
  1023. PatientId: patient.ID,
  1024. RecordDate: theTime.Unix(),
  1025. UserOrgId: adminInfo.CurrentOrgId,
  1026. AdminUserId: admin_user_id,
  1027. IsReturn: 1,
  1028. IdCardType: id_card_type,
  1029. Doctor: doctor,
  1030. Departments: department,
  1031. YiliaoNumber: yiliao_number,
  1032. MzNumber: number,
  1033. Number: mz_number,
  1034. PsnNo: health_card_no,
  1035. PatientInfo: result001,
  1036. }
  1037. service.CreateHisPatientTwo(&his)
  1038. c.ServeSuccessJSON(map[string]interface{}{
  1039. "msg": "挂号成功",
  1040. })
  1041. } else {
  1042. c.ServeSuccessJSON(map[string]interface{}{
  1043. "failed_code": -10,
  1044. "msg": res.Transreturnmessage,
  1045. })
  1046. return
  1047. }
  1048. }
  1049. } else { //异地卡流程
  1050. //readCardBasResult := ReadCardBasHSM(number)
  1051. //fmt.Println(readCardBasResult)
  1052. //是否异地就医,是的话走鉴权流程,不是的话走门诊挂号
  1053. if is_yidi == 1 { //1本地就医
  1054. resp_result := service.SzybMZ002(opera_name, opera_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  1055. var dat map[string]interface{}
  1056. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1057. fmt.Println(dat)
  1058. } else {
  1059. fmt.Println(err)
  1060. }
  1061. userJSONBytes, _ := json.Marshal(dat)
  1062. var res ResultOne
  1063. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1064. utils.ErrorLog("解析失败:%v", err)
  1065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1066. return
  1067. }
  1068. if res.Transreturncode == "00000000" {
  1069. his := models.VMHisPatient{
  1070. Name: name,
  1071. Gender: gender,
  1072. Birthday: birthUnix,
  1073. MedicalTreatmentType: medical_care,
  1074. IdType: certificates,
  1075. IdCardNo: id_card,
  1076. BalanceAccountsType: settlementValue,
  1077. SocialType: social_type,
  1078. MedicalInsuranceNumber: medical_insurance_card,
  1079. RegisterType: register_type,
  1080. RegisterCost: registration_fee,
  1081. TreatmentCost: medical_expenses,
  1082. Status: 1,
  1083. Ctime: time.Now().Unix(),
  1084. Mtime: time.Now().Unix(),
  1085. Iinfo: resp_result,
  1086. PatientId: patient.ID,
  1087. RecordDate: theTime.Unix(),
  1088. UserOrgId: adminInfo.CurrentOrgId,
  1089. AdminUserId: admin_user_id,
  1090. IsReturn: 1,
  1091. IdCardType: id_card_type,
  1092. Doctor: doctor,
  1093. Departments: department,
  1094. YiliaoNumber: yiliao_number,
  1095. MzNumber: number,
  1096. Number: mz_number,
  1097. PsnNo: health_card_no,
  1098. PatientInfo: result001,
  1099. }
  1100. service.CreateHisPatientTwo(&his)
  1101. c.ServeSuccessJSON(map[string]interface{}{
  1102. "msg": "挂号成功",
  1103. })
  1104. } else {
  1105. c.ServeSuccessJSON(map[string]interface{}{
  1106. "failed_code": -10,
  1107. "msg": res.Transreturnmessage,
  1108. })
  1109. return
  1110. }
  1111. } else { //异地就医需要走鉴权流程
  1112. //authResult := CardAuth(number)
  1113. //fmt.Println(authResult)
  1114. resp_result := service.SzybMZ002(opera_name, opera_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  1115. var dat map[string]interface{}
  1116. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1117. fmt.Println(dat)
  1118. } else {
  1119. fmt.Println(err)
  1120. }
  1121. userJSONBytes, _ := json.Marshal(dat)
  1122. var res ResultOne
  1123. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1124. utils.ErrorLog("解析失败:%v", err)
  1125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1126. return
  1127. }
  1128. if res.Transreturncode == "00000000" {
  1129. his := models.VMHisPatient{
  1130. Name: name,
  1131. Gender: gender,
  1132. Birthday: birthUnix,
  1133. MedicalTreatmentType: medical_care,
  1134. IdType: certificates,
  1135. IdCardNo: id_card,
  1136. BalanceAccountsType: settlementValue,
  1137. SocialType: social_type,
  1138. MedicalInsuranceNumber: medical_insurance_card,
  1139. RegisterType: register_type,
  1140. RegisterCost: registration_fee,
  1141. TreatmentCost: medical_expenses,
  1142. Status: 1,
  1143. Ctime: time.Now().Unix(),
  1144. Mtime: time.Now().Unix(),
  1145. Iinfo: resp_result,
  1146. PatientId: patient.ID,
  1147. RecordDate: theTime.Unix(),
  1148. UserOrgId: adminInfo.CurrentOrgId,
  1149. AdminUserId: admin_user_id,
  1150. IsReturn: 1,
  1151. IdCardType: id_card_type,
  1152. Doctor: doctor,
  1153. Departments: department,
  1154. YiliaoNumber: yiliao_number,
  1155. MzNumber: number,
  1156. Number: mz_number,
  1157. PsnNo: health_card_no,
  1158. PatientInfo: result001,
  1159. }
  1160. service.CreateHisPatientTwo(&his)
  1161. c.ServeSuccessJSON(map[string]interface{}{
  1162. "msg": "挂号成功",
  1163. })
  1164. } else {
  1165. c.ServeSuccessJSON(map[string]interface{}{
  1166. "failed_code": -10,
  1167. "msg": res.Transreturnmessage,
  1168. })
  1169. return
  1170. }
  1171. }
  1172. }
  1173. } else {
  1174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1175. return
  1176. }
  1177. } else {
  1178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  1179. return
  1180. }
  1181. }
  1182. //func (c *SZHisApiController) GetInfo() {
  1183. //func (c *SZHisApiController) GetRegisterInfo() {
  1184. // adminInfo := c.GetAdminUserInfo()
  1185. // admin_user_id, _ := c.GetInt64("admin_user_id")
  1186. // patient_id, _ := c.GetInt64("id")
  1187. // record_time := c.GetString("record_time")
  1188. // settlementValue, _ := c.GetInt64("settlement_value")
  1189. // medical_insurance_card := c.GetString("medical_insurance_card")
  1190. // name := c.GetString("name")
  1191. // id_card_type, _ := c.GetInt64("id_card_type")
  1192. // certificates, _ := c.GetInt64("certificates")
  1193. // medical_care, _ := c.GetInt64("medical_care")
  1194. // birthday := c.GetString("birthday")
  1195. // id_card := c.GetString("id_card")
  1196. // register_type, _ := c.GetInt64("register")
  1197. // doctor, _ := c.GetInt64("doctor")
  1198. // department, _ := c.GetInt64("department")
  1199. // gender, _ := c.GetInt64("sex")
  1200. // registration_fee, _ := c.GetFloat("registration_fee")
  1201. // medical_expenses, _ := c.GetFloat("medical_expenses")
  1202. // social_type, _ := c.GetInt64("social_type")
  1203. //
  1204. // is_yidi, _ := c.GetInt64("is_yidi")
  1205. //
  1206. // timeLayout := "2006-01-02"
  1207. // loc, _ := time.LoadLocation("Local")
  1208. // birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  1209. // birthUnix := birthdays.Unix()
  1210. //
  1211. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1212. // if err != nil {
  1213. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1214. // return
  1215. // }
  1216. //
  1217. // var patient service.Patients
  1218. // if patient_id == 0 {
  1219. // patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  1220. // } else {
  1221. // patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
  1222. // }
  1223. //
  1224. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1225. // if patient.ID == 0 {
  1226. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  1227. // return
  1228. // }
  1229. // if len(patient.IdCardNo) == 0 {
  1230. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  1231. // return
  1232. // }
  1233. //
  1234. // adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1235. // his, _ := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient_id, theTime.Unix())
  1236. //
  1237. // var custom_code string
  1238. // var custom_project_name string
  1239. // var allPrice float64
  1240. //
  1241. // switch register_type {
  1242. // case 1:
  1243. // custom_code = "110100002"
  1244. // custom_project_name = "普通门诊"
  1245. // allPrice = 10
  1246. // break
  1247. // case 3:
  1248. // custom_code = "110200002-2"
  1249. // custom_project_name = "主任医师"
  1250. // allPrice = 10
  1251. //
  1252. // break
  1253. // case 2:
  1254. // custom_code = "110200002-3"
  1255. // custom_project_name = "副主任医师"
  1256. // allPrice = 10
  1257. //
  1258. // break
  1259. // case 4:
  1260. // custom_code = "0"
  1261. // custom_project_name = "免受诊金"
  1262. // allPrice = 0
  1263. // break
  1264. // case 5:
  1265. // custom_code = "110200002-1"
  1266. // custom_project_name = "专家"
  1267. // allPrice = 10
  1268. //
  1269. // break
  1270. // }
  1271. //
  1272. // if his.ID == 0 {
  1273. //
  1274. // var doctor_name string
  1275. // var doctor_code string
  1276. // if adminRole.ID == 0 {
  1277. //
  1278. // doctor_name = ""
  1279. // doctor_code = "1001"
  1280. // doctor_name = ""
  1281. // doctor_code = ""
  1282. //
  1283. // } else {
  1284. // doctor_name = adminRole.UserName
  1285. // doctor_code = strconv.FormatInt(admin_user_id, 10)
  1286. //
  1287. // }
  1288. // month := time.Unix(1557042972, 0).Format("1")
  1289. // year := time.Now().Format("2006")
  1290. // month = time.Now().Format("01")
  1291. // day := time.Now().Format("02")
  1292. //
  1293. // //流水号
  1294. // //
  1295. // number := miConfig.Code + year + month + day +
  1296. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  1297. // mz_number := year + month + day + strconv.FormatInt(patient_id, 10) +
  1298. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
  1299. // //1.判断读卡类型
  1300. // //2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
  1301. // yiliao_number, id_card_number, verifyCode, version_code, _, ret4 := ReadBasCardGetNumber("MZ002" + "|" + number + "|" + miConfig.Code + "|")
  1302. // fmt.Println(yiliao_number)
  1303. // fmt.Println(id_card_number)
  1304. // fmt.Println(verifyCode)
  1305. // fmt.Println(version_code)
  1306. // fmt.Println(ret4)
  1307. //
  1308. // dept_code := "0305"
  1309. // is_yidi = 1
  1310. // tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  1311. // //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  1312. // if tempPatient.ID == patient_id {
  1313. // if ret4 == 0 { //本地卡流程
  1314. // if is_yidi == 1 {
  1315. // //本地就医流程
  1316. // //挂号
  1317. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, dept_code, yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  1318. // var dat map[string]interface{}
  1319. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1320. // fmt.Println(dat)
  1321. // } else {
  1322. // fmt.Println(err)
  1323. // }
  1324. // userJSONBytes, _ := json.Marshal(dat)
  1325. // var res ResultOne
  1326. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1327. // utils.ErrorLog("解析失败:%v", err)
  1328. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1329. // return
  1330. // }
  1331. // if res.Transreturncode == "00000000" {
  1332. // his := models.VMHisPatient{
  1333. // Name: name,
  1334. // Gender: gender,
  1335. // Birthday: birthUnix,
  1336. // MedicalTreatmentType: medical_care,
  1337. // IdType: certificates,
  1338. // IdCardNo: id_card,
  1339. // BalanceAccountsType: settlementValue,
  1340. // SocialType: social_type,
  1341. // MedicalInsuranceNumber: medical_insurance_card,
  1342. // RegisterType: register_type,
  1343. // RegisterCost: registration_fee,
  1344. // TreatmentCost: medical_expenses,
  1345. // Status: 1,
  1346. // Ctime: time.Now().Unix(),
  1347. // Mtime: time.Now().Unix(),
  1348. // Iinfo: resp_result,
  1349. // PatientId: patient.ID,
  1350. // RecordDate: theTime.Unix(),
  1351. // UserOrgId: adminInfo.CurrentOrgId,
  1352. // AdminUserId: admin_user_id,
  1353. // IsReturn: 1,
  1354. // IdCardType: id_card_type,
  1355. // Doctor: doctor,
  1356. // Departments: department,
  1357. // YiliaoNumber: yiliao_number,
  1358. // MzNumber: number,
  1359. // Number: mz_number,
  1360. // }
  1361. // service.CreateHisPatientTwo(&his)
  1362. // c.ServeSuccessJSON(map[string]interface{}{
  1363. // "msg": "挂号成功",
  1364. // })
  1365. // } else {
  1366. // c.ServeSuccessJSON(map[string]interface{}{
  1367. // "failed_code": -10,
  1368. // "msg": res.Transreturnmessage,
  1369. // })
  1370. // return
  1371. // }
  1372. //
  1373. // } else {
  1374. // //异地就医流程
  1375. // //异地走鉴权流程
  1376. // //authResult := CardAuth(number)
  1377. // //fmt.Println(authResult)
  1378. //
  1379. // //tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  1380. // //if tempPatient.ID == patient_id {
  1381. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  1382. // var dat map[string]interface{}
  1383. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1384. // fmt.Println(dat)
  1385. // } else {
  1386. // fmt.Println(err)
  1387. // }
  1388. //
  1389. // userJSONBytes, _ := json.Marshal(dat)
  1390. //
  1391. // var res ResultOne
  1392. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1393. // utils.ErrorLog("解析失败:%v", err)
  1394. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1395. // return
  1396. // }
  1397. // if res.Transreturncode == "00000000" {
  1398. // his := models.VMHisPatient{
  1399. // Name: name,
  1400. // Gender: gender,
  1401. // Birthday: birthUnix,
  1402. // MedicalTreatmentType: medical_care,
  1403. // IdType: certificates,
  1404. // IdCardNo: id_card,
  1405. // BalanceAccountsType: settlementValue,
  1406. // SocialType: social_type,
  1407. // MedicalInsuranceNumber: medical_insurance_card,
  1408. // RegisterType: register_type,
  1409. // RegisterCost: registration_fee,
  1410. // TreatmentCost: medical_expenses,
  1411. // Status: 1,
  1412. // Ctime: time.Now().Unix(),
  1413. // Mtime: time.Now().Unix(),
  1414. // Iinfo: resp_result,
  1415. // PatientId: patient.ID,
  1416. // RecordDate: theTime.Unix(),
  1417. // UserOrgId: adminInfo.CurrentOrgId,
  1418. // AdminUserId: admin_user_id,
  1419. // IsReturn: 1,
  1420. // IdCardType: id_card_type,
  1421. // Doctor: doctor,
  1422. // Departments: department,
  1423. // YiliaoNumber: yiliao_number,
  1424. // MzNumber: number,
  1425. // Number: mz_number,
  1426. // }
  1427. // service.CreateHisPatientTwo(&his)
  1428. // c.ServeSuccessJSON(map[string]interface{}{
  1429. // "msg": "挂号成功",
  1430. // })
  1431. // } else {
  1432. // c.ServeSuccessJSON(map[string]interface{}{
  1433. // "failed_code": -10,
  1434. // "msg": res.Transreturnmessage,
  1435. // })
  1436. // return
  1437. // }
  1438. //
  1439. // }
  1440. //
  1441. // } else { //异地卡流程
  1442. // //readCardBasResult := ReadCardBasHSM(number)
  1443. // //fmt.Println(readCardBasResult)
  1444. // //是否异地就医,是的话走鉴权流程,不是的话走门诊挂号
  1445. // if is_yidi == 1 { //1本地就医
  1446. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  1447. // var dat map[string]interface{}
  1448. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1449. // fmt.Println(dat)
  1450. // } else {
  1451. // fmt.Println(err)
  1452. // }
  1453. //
  1454. // userJSONBytes, _ := json.Marshal(dat)
  1455. //
  1456. // var res ResultOne
  1457. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1458. // utils.ErrorLog("解析失败:%v", err)
  1459. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1460. // return
  1461. // }
  1462. // if res.Transreturncode == "00000000" {
  1463. // his := models.VMHisPatient{
  1464. // Name: name,
  1465. // Gender: gender,
  1466. // Birthday: birthUnix,
  1467. // MedicalTreatmentType: medical_care,
  1468. // IdType: certificates,
  1469. // IdCardNo: id_card,
  1470. // BalanceAccountsType: settlementValue,
  1471. // SocialType: social_type,
  1472. // MedicalInsuranceNumber: medical_insurance_card,
  1473. // RegisterType: register_type,
  1474. // RegisterCost: registration_fee,
  1475. // TreatmentCost: medical_expenses,
  1476. // Status: 1,
  1477. // Ctime: time.Now().Unix(),
  1478. // Mtime: time.Now().Unix(),
  1479. // Iinfo: resp_result,
  1480. // PatientId: patient.ID,
  1481. // RecordDate: theTime.Unix(),
  1482. // UserOrgId: adminInfo.CurrentOrgId,
  1483. // AdminUserId: admin_user_id,
  1484. // IsReturn: 1,
  1485. // IdCardType: id_card_type,
  1486. // Doctor: doctor,
  1487. // Departments: department,
  1488. // YiliaoNumber: yiliao_number,
  1489. // MzNumber: number,
  1490. // Number: mz_number,
  1491. // }
  1492. // service.CreateHisPatientTwo(&his)
  1493. // c.ServeSuccessJSON(map[string]interface{}{
  1494. // "msg": "挂号成功",
  1495. // })
  1496. // } else {
  1497. // c.ServeSuccessJSON(map[string]interface{}{
  1498. // "failed_code": -10,
  1499. // "msg": res.Transreturnmessage,
  1500. // })
  1501. // return
  1502. // }
  1503. //
  1504. // } else { //异地就医需要走鉴权流程
  1505. // //authResult := CardAuth(number)
  1506. // //fmt.Println(authResult)
  1507. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  1508. // var dat map[string]interface{}
  1509. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1510. // fmt.Println(dat)
  1511. // } else {
  1512. // fmt.Println(err)
  1513. // }
  1514. //
  1515. // userJSONBytes, _ := json.Marshal(dat)
  1516. //
  1517. // var res ResultOne
  1518. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1519. // utils.ErrorLog("解析失败:%v", err)
  1520. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1521. // return
  1522. // }
  1523. // if res.Transreturncode == "00000000" {
  1524. // his := models.VMHisPatient{
  1525. // Name: name,
  1526. // Gender: gender,
  1527. // Birthday: birthUnix,
  1528. // MedicalTreatmentType: medical_care,
  1529. // IdType: certificates,
  1530. // IdCardNo: id_card,
  1531. // BalanceAccountsType: settlementValue,
  1532. // SocialType: social_type,
  1533. // MedicalInsuranceNumber: medical_insurance_card,
  1534. // RegisterType: register_type,
  1535. // RegisterCost: registration_fee,
  1536. // TreatmentCost: medical_expenses,
  1537. // Status: 1,
  1538. // Ctime: time.Now().Unix(),
  1539. // Mtime: time.Now().Unix(),
  1540. // Iinfo: resp_result,
  1541. // PatientId: patient.ID,
  1542. // RecordDate: theTime.Unix(),
  1543. // UserOrgId: adminInfo.CurrentOrgId,
  1544. // AdminUserId: admin_user_id,
  1545. // IsReturn: 1,
  1546. // IdCardType: id_card_type,
  1547. // Doctor: doctor,
  1548. // Departments: department,
  1549. // YiliaoNumber: yiliao_number,
  1550. // MzNumber: number,
  1551. // Number: mz_number,
  1552. // }
  1553. // service.CreateHisPatientTwo(&his)
  1554. // c.ServeSuccessJSON(map[string]interface{}{
  1555. // "msg": "挂号成功",
  1556. // })
  1557. // } else {
  1558. // c.ServeSuccessJSON(map[string]interface{}{
  1559. // "failed_code": -10,
  1560. // "msg": res.Transreturnmessage,
  1561. // })
  1562. // return
  1563. // }
  1564. //
  1565. // }
  1566. // }
  1567. // } else {
  1568. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1569. // return
  1570. // }
  1571. // } else {
  1572. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  1573. // return
  1574. // }
  1575. //}
  1576. //func (c *SZHisApiController) GetRegisterInfo() {
  1577. // adminInfo := c.GetAdminUserInfo()
  1578. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1579. // month := time.Unix(1557042972, 0).Format("1")
  1580. // year := time.Now().Format("2006")
  1581. // month = time.Now().Format("01")
  1582. // day := time.Now().Format("02")
  1583. // //流水号
  1584. // number := miConfig.Code + year + month + day +
  1585. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  1586. // //1.判断读卡类型
  1587. // //2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
  1588. // yiliao_number, _, verifyCode, version_code, _, _, _ := ReadBasCardGetNumber("XX001" + "|" + number + "|" + miConfig.Code + "|")
  1589. // fmt.Println(result)
  1590. //
  1591. //}
  1592. func (c *SZHisApiController) RefundNumber() {
  1593. record_time := c.GetString("record_time")
  1594. patient_id, _ := c.GetInt64("patient_id")
  1595. admin_user_id, _ := c.GetInt64("admin_user_id")
  1596. timeLayout := "2006-01-02"
  1597. loc, _ := time.LoadLocation("Local")
  1598. adminUser := c.GetAdminUserInfo()
  1599. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1600. fmt.Println(err)
  1601. if err != nil {
  1602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1603. return
  1604. }
  1605. recordDateTime := theTime.Unix()
  1606. fmt.Println(recordDateTime)
  1607. his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, theTime.Unix())
  1608. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1609. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1610. //结算流程
  1611. var doctor_name string
  1612. var doctor_code string
  1613. if roles.ID == 0 {
  1614. doctor_name = "管理员"
  1615. doctor_code = "01"
  1616. } else {
  1617. doctor_name = roles.UserName
  1618. doctor_code = strconv.FormatInt(admin_user_id, 10)
  1619. }
  1620. month := time.Unix(1557042972, 0).Format("1")
  1621. year := time.Now().Format("2006")
  1622. month = time.Now().Format("01")
  1623. day := time.Now().Format("02")
  1624. //number := miConfig.Code + year + month + day + "1367866"
  1625. number := miConfig.Code + year + month + day +
  1626. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  1627. //number := miConfig.Code + year + month + day + "1590003"
  1628. //流水号
  1629. //number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  1630. verifyCode, version_code := ReadCardGetCode("JY002" + "|" + number + "|" + miConfig.Code)
  1631. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1632. if config.IsOpen == 1 { //对接了医保,走医保流程
  1633. result := service.SzybJY002(doctor_name, doctor_code, miConfig.Code, his.MzNumber, his.Number, verifyCode, number, version_code)
  1634. var dat map[string]interface{}
  1635. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1636. fmt.Println(dat)
  1637. } else {
  1638. fmt.Println(err)
  1639. }
  1640. userJSONBytes, _ := json.Marshal(dat)
  1641. var res ResultThree
  1642. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1643. utils.ErrorLog("解析失败:%v", err)
  1644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1645. return
  1646. }
  1647. if res.Transreturncode == "00000000" {
  1648. service.UpdataHisStatusSZ(adminUser.CurrentOrgId, his.MzNumber, his.Number, result)
  1649. c.ServeSuccessJSON(map[string]interface{}{
  1650. "msg": "退号成功",
  1651. })
  1652. } else {
  1653. c.ServeSuccessJSON(map[string]interface{}{
  1654. "failed_code": -10,
  1655. "msg": res.Transreturnmessage,
  1656. })
  1657. }
  1658. }
  1659. }
  1660. //func (c *SZHisApiController) GetRegisterInfo() {
  1661. // adminInfo := c.GetAdminUserInfo()
  1662. // admin_user_id, _ := c.GetInt64("admin_user_id")
  1663. // patient_id, _ := c.GetInt64("id")
  1664. // record_time := c.GetString("record_time")
  1665. // settlementValue, _ := c.GetInt64("settlement_value")
  1666. // medical_insurance_card := c.GetString("medical_insurance_card")
  1667. // name := c.GetString("name")
  1668. // id_card_type, _ := c.GetInt64("id_card_type")
  1669. // certificates, _ := c.GetInt64("certificates")
  1670. // medical_care, _ := c.GetInt64("medical_care")
  1671. // birthday := c.GetString("birthday")
  1672. // id_card := c.GetString("id_card")
  1673. // register_type, _ := c.GetInt64("register")
  1674. // doctor, _ := c.GetInt64("doctor")
  1675. // department, _ := c.GetInt64("department")
  1676. // gender, _ := c.GetInt64("sex")
  1677. // registration_fee, _ := c.GetFloat("registration_fee")
  1678. // medical_expenses, _ := c.GetFloat("medical_expenses")
  1679. // social_type, _ := c.GetInt64("social_type")
  1680. //
  1681. // is_yidi, _ := c.GetInt64("is_yidi")
  1682. //
  1683. // timeLayout := "2006-01-02"
  1684. // loc, _ := time.LoadLocation("Local")
  1685. // birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  1686. // birthUnix := birthdays.Unix()
  1687. //
  1688. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1689. // if err != nil {
  1690. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1691. // return
  1692. // }
  1693. //
  1694. // var patient service.Patients
  1695. // if patient_id == 0 {
  1696. // patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  1697. // } else {
  1698. // patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
  1699. // }
  1700. //
  1701. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1702. // if patient.ID == 0 {
  1703. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  1704. // return
  1705. // }
  1706. // if len(patient.IdCardNo) == 0 {
  1707. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  1708. // return
  1709. // }
  1710. //
  1711. // adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1712. // his, _ := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient_id, theTime.Unix())
  1713. //
  1714. // var custom_code string
  1715. // var custom_project_name string
  1716. // var allPrice float64
  1717. //
  1718. // switch register_type {
  1719. // case 1:
  1720. // custom_code = "110100002"
  1721. // custom_project_name = "普通门诊"
  1722. // allPrice = 10
  1723. // break
  1724. // case 3:
  1725. // custom_code = "110200002-2"
  1726. // custom_project_name = "主任医师"
  1727. // allPrice = 10
  1728. //
  1729. // break
  1730. // case 2:
  1731. // custom_code = "110200002-3"
  1732. // custom_project_name = "副主任医师"
  1733. // allPrice = 10
  1734. //
  1735. // break
  1736. // case 4:
  1737. // custom_code = "0"
  1738. // custom_project_name = "免受诊金"
  1739. // allPrice = 0
  1740. // break
  1741. // case 5:
  1742. // custom_code = "110200002-1"
  1743. // custom_project_name = "专家"
  1744. // allPrice = 10
  1745. //
  1746. // break
  1747. // }
  1748. //
  1749. // if his.ID == 0 {
  1750. //
  1751. // var doctor_name string
  1752. // var doctor_code string
  1753. // if adminRole.ID == 0 {
  1754. //
  1755. // doctor_name = "管理员"
  1756. // doctor_code = "01"
  1757. //
  1758. // } else {
  1759. // doctor_name = adminRole.UserName
  1760. // doctor_code = strconv.FormatInt(admin_user_id, 10)
  1761. //
  1762. // }
  1763. // month := time.Unix(1557042972, 0).Format("1")
  1764. // year := time.Now().Format("2006")
  1765. // month = time.Now().Format("01")
  1766. // day := time.Now().Format("02")
  1767. //
  1768. // //流水号
  1769. // //
  1770. // number := miConfig.Code + year + month + day +
  1771. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  1772. // mz_number := miConfig.Code + year + month + day +
  1773. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
  1774. // //1.判断读卡类型
  1775. // //2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
  1776. // yiliao_number, id_card_number, verifyCode, version_code, _, ret4 := ReadBasCardGetNumber("MZ002" + "|" + number + "|" + miConfig.Code + "|")
  1777. // fmt.Println(yiliao_number)
  1778. // fmt.Println(id_card_number)
  1779. // fmt.Println(verifyCode)
  1780. // fmt.Println(version_code)
  1781. // fmt.Println(ret4)
  1782. //
  1783. // dept_code := "0306"
  1784. // is_yidi = 1
  1785. // tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  1786. // //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  1787. // fmt.Println(tempPatient.ID)
  1788. // fmt.Println(patient_id)
  1789. //
  1790. // if tempPatient.ID == patient_id {
  1791. // if ret4 == 0 { //本地卡流程
  1792. // if is_yidi == 1 {
  1793. // //本地就医流程
  1794. // //挂号
  1795. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, dept_code, yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  1796. // var dat map[string]interface{}
  1797. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1798. // fmt.Println(dat)
  1799. // } else {
  1800. // fmt.Println(err)
  1801. // }
  1802. // userJSONBytes, _ := json.Marshal(dat)
  1803. // var res ResultOne
  1804. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1805. // utils.ErrorLog("解析失败:%v", err)
  1806. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1807. // return
  1808. // }
  1809. // if res.Transreturncode == "00000000" {
  1810. // his := models.VMHisPatient{
  1811. // Name: name,
  1812. // Gender: gender,
  1813. // Birthday: birthUnix,
  1814. // MedicalTreatmentType: medical_care,
  1815. // IdType: certificates,
  1816. // IdCardNo: id_card,
  1817. // BalanceAccountsType: settlementValue,
  1818. // SocialType: social_type,
  1819. // MedicalInsuranceNumber: medical_insurance_card,
  1820. // RegisterType: register_type,
  1821. // RegisterCost: registration_fee,
  1822. // TreatmentCost: medical_expenses,
  1823. // Status: 1,
  1824. // Ctime: time.Now().Unix(),
  1825. // Mtime: time.Now().Unix(),
  1826. // Iinfo: resp_result,
  1827. // PatientId: patient.ID,
  1828. // RecordDate: theTime.Unix(),
  1829. // UserOrgId: adminInfo.CurrentOrgId,
  1830. // AdminUserId: admin_user_id,
  1831. // IsReturn: 1,
  1832. // IdCardType: id_card_type,
  1833. // Doctor: doctor,
  1834. // Departments: department,
  1835. // YiliaoNumber: yiliao_number,
  1836. // MzNumber: number,
  1837. // Number: mz_number,
  1838. // }
  1839. // service.CreateHisPatientTwo(&his)
  1840. // c.ServeSuccessJSON(map[string]interface{}{
  1841. // "msg": "挂号成功",
  1842. // })
  1843. // } else {
  1844. // c.ServeSuccessJSON(map[string]interface{}{
  1845. // "failed_code": -10,
  1846. // "msg": res.Transreturnmessage,
  1847. // })
  1848. // return
  1849. // }
  1850. //
  1851. // } else {
  1852. // //异地就医流程
  1853. // //异地走鉴权流程
  1854. // //authResult := CardAuth(number)
  1855. // //fmt.Println(authResult)
  1856. //
  1857. // //tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  1858. // //if tempPatient.ID == patient_id {
  1859. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  1860. // var dat map[string]interface{}
  1861. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1862. // fmt.Println(dat)
  1863. // } else {
  1864. // fmt.Println(err)
  1865. // }
  1866. //
  1867. // userJSONBytes, _ := json.Marshal(dat)
  1868. //
  1869. // var res ResultOne
  1870. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1871. // utils.ErrorLog("解析失败:%v", err)
  1872. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1873. // return
  1874. // }
  1875. // if res.Transreturncode == "00000000" {
  1876. // his := models.VMHisPatient{
  1877. // Name: name,
  1878. // Gender: gender,
  1879. // Birthday: birthUnix,
  1880. // MedicalTreatmentType: medical_care,
  1881. // IdType: certificates,
  1882. // IdCardNo: id_card,
  1883. // BalanceAccountsType: settlementValue,
  1884. // SocialType: social_type,
  1885. // MedicalInsuranceNumber: medical_insurance_card,
  1886. // RegisterType: register_type,
  1887. // RegisterCost: registration_fee,
  1888. // TreatmentCost: medical_expenses,
  1889. // Status: 1,
  1890. // Ctime: time.Now().Unix(),
  1891. // Mtime: time.Now().Unix(),
  1892. // Iinfo: resp_result,
  1893. // PatientId: patient.ID,
  1894. // RecordDate: theTime.Unix(),
  1895. // UserOrgId: adminInfo.CurrentOrgId,
  1896. // AdminUserId: admin_user_id,
  1897. // IsReturn: 1,
  1898. // IdCardType: id_card_type,
  1899. // Doctor: doctor,
  1900. // Departments: department,
  1901. // YiliaoNumber: yiliao_number,
  1902. // MzNumber: number,
  1903. // Number: mz_number,
  1904. // }
  1905. // service.CreateHisPatientTwo(&his)
  1906. // c.ServeSuccessJSON(map[string]interface{}{
  1907. // "msg": "挂号成功",
  1908. // })
  1909. // } else {
  1910. // c.ServeSuccessJSON(map[string]interface{}{
  1911. // "failed_code": -10,
  1912. // "msg": res.Transreturnmessage,
  1913. // })
  1914. // return
  1915. // }
  1916. //
  1917. // }
  1918. //
  1919. // } else { //异地卡流程
  1920. // //readCardBasResult := ReadCardBasHSM(number)
  1921. // //fmt.Println(readCardBasResult)
  1922. // //是否异地就医,是的话走鉴权流程,不是的话走门诊挂号
  1923. // if is_yidi == 1 { //1本地就医
  1924. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  1925. // var dat map[string]interface{}
  1926. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1927. // fmt.Println(dat)
  1928. // } else {
  1929. // fmt.Println(err)
  1930. // }
  1931. //
  1932. // userJSONBytes, _ := json.Marshal(dat)
  1933. //
  1934. // var res ResultOne
  1935. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1936. // utils.ErrorLog("解析失败:%v", err)
  1937. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1938. // return
  1939. // }
  1940. // if res.Transreturncode == "00000000" {
  1941. // his := models.VMHisPatient{
  1942. // Name: name,
  1943. // Gender: gender,
  1944. // Birthday: birthUnix,
  1945. // MedicalTreatmentType: medical_care,
  1946. // IdType: certificates,
  1947. // IdCardNo: id_card,
  1948. // BalanceAccountsType: settlementValue,
  1949. // SocialType: social_type,
  1950. // MedicalInsuranceNumber: medical_insurance_card,
  1951. // RegisterType: register_type,
  1952. // RegisterCost: registration_fee,
  1953. // TreatmentCost: medical_expenses,
  1954. // Status: 1,
  1955. // Ctime: time.Now().Unix(),
  1956. // Mtime: time.Now().Unix(),
  1957. // Iinfo: resp_result,
  1958. // PatientId: patient.ID,
  1959. // RecordDate: theTime.Unix(),
  1960. // UserOrgId: adminInfo.CurrentOrgId,
  1961. // AdminUserId: admin_user_id,
  1962. // IsReturn: 1,
  1963. // IdCardType: id_card_type,
  1964. // Doctor: doctor,
  1965. // Departments: department,
  1966. // YiliaoNumber: yiliao_number,
  1967. // MzNumber: number,
  1968. // Number: mz_number,
  1969. // }
  1970. // service.CreateHisPatientTwo(&his)
  1971. // c.ServeSuccessJSON(map[string]interface{}{
  1972. // "msg": "挂号成功",
  1973. // })
  1974. // } else {
  1975. // c.ServeSuccessJSON(map[string]interface{}{
  1976. // "failed_code": -10,
  1977. // "msg": res.Transreturnmessage,
  1978. // })
  1979. // return
  1980. // }
  1981. //
  1982. // } else { //异地就医需要走鉴权流程
  1983. // //authResult := CardAuth(number)
  1984. // //fmt.Println(authResult)
  1985. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  1986. // var dat map[string]interface{}
  1987. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1988. // fmt.Println(dat)
  1989. // } else {
  1990. // fmt.Println(err)
  1991. // }
  1992. //
  1993. // userJSONBytes, _ := json.Marshal(dat)
  1994. //
  1995. // var res ResultOne
  1996. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1997. // utils.ErrorLog("解析失败:%v", err)
  1998. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1999. // return
  2000. // }
  2001. // if res.Transreturncode == "00000000" {
  2002. // his := models.VMHisPatient{
  2003. // Name: name,
  2004. // Gender: gender,
  2005. // Birthday: birthUnix,
  2006. // MedicalTreatmentType: medical_care,
  2007. // IdType: certificates,
  2008. // IdCardNo: id_card,
  2009. // BalanceAccountsType: settlementValue,
  2010. // SocialType: social_type,
  2011. // MedicalInsuranceNumber: medical_insurance_card,
  2012. // RegisterType: register_type,
  2013. // RegisterCost: registration_fee,
  2014. // TreatmentCost: medical_expenses,
  2015. // Status: 1,
  2016. // Ctime: time.Now().Unix(),
  2017. // Mtime: time.Now().Unix(),
  2018. // Iinfo: resp_result,
  2019. // PatientId: patient.ID,
  2020. // RecordDate: theTime.Unix(),
  2021. // UserOrgId: adminInfo.CurrentOrgId,
  2022. // AdminUserId: admin_user_id,
  2023. // IsReturn: 1,
  2024. // IdCardType: id_card_type,
  2025. // Doctor: doctor,
  2026. // Departments: department,
  2027. // YiliaoNumber: yiliao_number,
  2028. // MzNumber: number,
  2029. // Number: mz_number,
  2030. // }
  2031. // service.CreateHisPatientTwo(&his)
  2032. // c.ServeSuccessJSON(map[string]interface{}{
  2033. // "msg": "挂号成功",
  2034. // })
  2035. // } else {
  2036. // c.ServeSuccessJSON(map[string]interface{}{
  2037. // "failed_code": -10,
  2038. // "msg": res.Transreturnmessage,
  2039. // })
  2040. // return
  2041. // }
  2042. //
  2043. // }
  2044. // }
  2045. // } else {
  2046. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2047. // return
  2048. // }
  2049. // } else {
  2050. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2051. // return
  2052. // }
  2053. //}
  2054. //上传明细----结算----确认订单
  2055. func (c *SZHisApiController) GetSettleInfo() {
  2056. pay_way, _ := c.GetInt64("pay_way")
  2057. pay_price, _ := c.GetFloat("pay_price")
  2058. pay_card_no := c.GetString("pay_card_no")
  2059. discount_price, _ := c.GetFloat("discount_price")
  2060. preferential_price, _ := c.GetFloat("preferential_price")
  2061. reality_price, _ := c.GetFloat("reality_price")
  2062. found_price, _ := c.GetFloat("found_price")
  2063. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  2064. private_price, _ := c.GetFloat("private_price")
  2065. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2066. patient_id, _ := c.GetInt64("id")
  2067. record_time := c.GetString("record_time")
  2068. admin_user_id, _ := c.GetInt64("admin_user_id")
  2069. timestamp := time.Now().Unix()
  2070. tempTime := time.Unix(timestamp, 0)
  2071. timeFormat := tempTime.Format("20060102150405")
  2072. chrgBchno := rand.Intn(10000) + 1000
  2073. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(1, 10)
  2074. adminUser := c.GetAdminUserInfo()
  2075. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2076. month := time.Unix(1557042972, 0).Format("1")
  2077. year := time.Now().Format("2006")
  2078. month = time.Now().Format("01")
  2079. day := time.Now().Format("02")
  2080. timeLayout := "2006-01-02"
  2081. loc, _ := time.LoadLocation("Local")
  2082. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2083. fmt.Println(err)
  2084. if err != nil {
  2085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2086. return
  2087. }
  2088. recordDateTime := theTime.Unix()
  2089. var prescriptions []*models.HisPrescription
  2090. var start_time int64
  2091. var end_time int64
  2092. if settle_accounts_type == 1 { //日结
  2093. prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2094. } else { //月结
  2095. start_time_str := c.GetString("start_time")
  2096. end_time_str := c.GetString("end_time")
  2097. timeLayout := "2006-01-02"
  2098. loc, _ := time.LoadLocation("Local")
  2099. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2100. if err != nil {
  2101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2102. return
  2103. }
  2104. recordStartTime := theStartTime.Unix()
  2105. start_time = recordStartTime
  2106. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2107. if err != nil {
  2108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2109. return
  2110. }
  2111. recordEndTime := theEndTime.Unix()
  2112. end_time = recordEndTime
  2113. prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  2114. }
  2115. var ids []int64
  2116. for _, item := range prescriptions {
  2117. ids = append(ids, item.ID)
  2118. }
  2119. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2120. sick, _ := service.FindSickById(patientPrescription.SickType)
  2121. if sick.ID == 0 {
  2122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamSickTypeWrong)
  2123. return
  2124. }
  2125. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2126. adminRole, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2127. his, err := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2128. mz_number := his.Number
  2129. number := miConfig.Code + year + month + day +
  2130. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  2131. var doctor_name string
  2132. var doctor_code string
  2133. var drug_doctor_code string
  2134. drug_doctor_code = adminRole_two.DoctorCode
  2135. drug_doctor_name := adminRole_two.UserName
  2136. if adminRole.ID == 0 {
  2137. doctor_name = "管理员"
  2138. doctor_code = "01"
  2139. } else {
  2140. doctor_name = adminRole.UserName
  2141. doctor_code = strconv.FormatInt(admin_user_id, 10)
  2142. }
  2143. verifyCode, version_code := ReadCardGetCode("FY001" + "|" + number + "|" + miConfig.Code)
  2144. //verifyCode := "000000|bf885fa312a7f92861d6b61542a637fa"
  2145. //version_code := "V0.3"
  2146. var customs []*models.CustomDetail
  2147. for _, item := range prescriptions {
  2148. if item.Type == 1 { //药品
  2149. for _, subItem := range item.HisDoctorAdviceInfo {
  2150. fmt.Println(subItem.BaseDrugLib.MedicalInsuranceNumber)
  2151. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2152. _, dose_code := service.GetDoseCode(subItem.BaseDrugLib.DrugDosageForm, adminUser.CurrentOrgId)
  2153. detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber), 64)
  2154. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  2155. temp := strings.Split(subItem.FeedetlSn, "-")
  2156. newFl := fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) + "-" + temp[1] + "-" + temp[2]
  2157. cus := &models.CustomDetail{
  2158. PrescriptionNumber: chrg_bchno,
  2159. OrderType: "1",
  2160. ChargeSerialNumber: newFl,
  2161. Code: subItem.BaseDrugLib.MedicalInsuranceNumber,
  2162. CodeName: subItem.BaseDrugLib.DrugName,
  2163. Flag: "1",
  2164. Price: price,
  2165. Count: subItem.PrescribingNumber,
  2166. ChargeOrderDate: year + month + day,
  2167. DoctorCode: doctor_code,
  2168. Total: detItemFeeSumamt,
  2169. DoseCode: dose_code,
  2170. Spec: subItem.BaseDrugLib.DrugSpec,
  2171. }
  2172. customs = append(customs, cus)
  2173. }
  2174. }
  2175. }
  2176. if item.Type == 2 { //项目
  2177. for _, subItem := range item.HisPrescriptionProject {
  2178. if len(subItem.HisProject.MedicalCode) > 0 {
  2179. detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  2180. //count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  2181. count, _ := strconv.ParseFloat(strconv.FormatInt(subItem.Count, 10), 64)
  2182. temp := strings.Split(subItem.FeedetlSn, "-")
  2183. newFl := fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) + "-" + temp[1] + "-" + temp[2]
  2184. cus := &models.CustomDetail{
  2185. PrescriptionNumber: chrg_bchno,
  2186. OrderType: "1",
  2187. ChargeSerialNumber: newFl,
  2188. Code: subItem.HisProject.MedicalCode,
  2189. CodeName: subItem.HisProject.ProjectName,
  2190. Flag: "1",
  2191. Price: subItem.Price,
  2192. Count: count,
  2193. ChargeOrderDate: year + month + day,
  2194. DoctorCode: doctor_code,
  2195. Total: detItemFeeSumamt,
  2196. DoseCode: "",
  2197. Spec: "次",
  2198. }
  2199. customs = append(customs, cus)
  2200. }
  2201. }
  2202. }
  2203. //
  2204. //for _, subItem := range item.HisAdditionalCharge {
  2205. // if len(subItem.XtHisAddtionConfig.Code) > 0 {
  2206. // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  2207. //
  2208. // count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  2209. // cus := &models.CustomDetail{
  2210. // PrescriptionNumber: chrg_bchno,
  2211. // OrderType: "1",
  2212. // ChargeSerialNumber: subItem.FeedetlSn,
  2213. // Code: subItem.XtHisAddtionConfig.Code,
  2214. // CodeName: subItem.XtHisAddtionConfig.Name,
  2215. // Flag: "1",
  2216. // Price: subItem.Price,
  2217. // Count: count,
  2218. // ChargeOrderDate: year + month + day,
  2219. // DoctorCode: doctor_code,
  2220. // Total: detItemFeeSumamt,
  2221. // DoseCode: "",
  2222. // Spec: subItem.XtHisAddtionConfig.,
  2223. // }
  2224. // customs = append(customs, cus)
  2225. // }
  2226. //}
  2227. }
  2228. var pagesize int = 50
  2229. var start int = 1
  2230. var stop int
  2231. var pagecount int
  2232. var curpage int
  2233. var isSuccess bool = true
  2234. //总页数,向上取整,注意除之前要先转换类型为float64
  2235. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  2236. var ress []*Result
  2237. for curpage = 1; curpage <= pagecount; curpage++ {
  2238. if curpage == 1 {
  2239. start = 1
  2240. } else {
  2241. start = (curpage-1)*pagesize + 1
  2242. }
  2243. stop = curpage * pagesize
  2244. if stop > len(customs) {
  2245. stop = len(customs)
  2246. }
  2247. result := service.SzybFY001(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, number, mz_number, version_code, drug_doctor_code)
  2248. fmt.Println(result)
  2249. var dat map[string]interface{}
  2250. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2251. fmt.Println(dat)
  2252. } else {
  2253. fmt.Println(err)
  2254. }
  2255. userJSONBytes, _ := json.Marshal(dat)
  2256. var res Result
  2257. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2258. utils.ErrorLog("解析失败:%v", err)
  2259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2260. return
  2261. }
  2262. if res.Transreturncode == "00000000" {
  2263. ress = append(ress, &res)
  2264. } else {
  2265. isSuccess = false
  2266. errlog := &models.HisOrderError{
  2267. UserOrgId: adminUser.CurrentOrgId,
  2268. Ctime: time.Now().Unix(),
  2269. Mtime: time.Now().Unix(),
  2270. Number: chrg_bchno,
  2271. ErrMsg: res.Transreturnmessage,
  2272. Status: 1,
  2273. PatientId: patient_id,
  2274. RecordTime: recordDateTime,
  2275. Stage: 4,
  2276. }
  2277. service.CreateErrMsgLog(errlog)
  2278. c.ServeSuccessJSON(map[string]interface{}{
  2279. "failed_code": -10,
  2280. "msg": res.Transreturnmessage,
  2281. })
  2282. return
  2283. }
  2284. //设置变量,根据变量的值来判断上传是否成功
  2285. }
  2286. if isSuccess == true {
  2287. order := &models.HisOrder{
  2288. UserOrgId: adminUser.CurrentOrgId,
  2289. HisPatientId: 0,
  2290. PatientId: patient_id,
  2291. SettleAccountsDate: recordDateTime,
  2292. Ctime: time.Now().Unix(),
  2293. Mtime: time.Now().Unix(),
  2294. Status: 1,
  2295. Number: chrg_bchno,
  2296. Infcode: 0,
  2297. WarnMsg: "",
  2298. Cainfo: "",
  2299. ErrMsg: "",
  2300. RespondTime: "",
  2301. InfRefmsgid: "",
  2302. OrderStatus: 1,
  2303. IsMedicineInsurance: 1,
  2304. SettleType: settle_accounts_type,
  2305. SettleStartTime: start_time,
  2306. SettleEndTime: end_time,
  2307. Creator: admin_user_id,
  2308. Modify: admin_user_id,
  2309. OrgSetlNumber: number,
  2310. }
  2311. data, _ := json.Marshal(ress)
  2312. order.DetailLog = string(data)
  2313. err = service.CreateOrder(order)
  2314. if err != nil {
  2315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2316. return
  2317. }
  2318. for _, subItem := range ress {
  2319. for _, item := range subItem.Transbody.Outputlist {
  2320. temp := strings.Split(item.Bkf500, "-")
  2321. var advice_id int64 = 0
  2322. var project_id int64 = 0
  2323. var types int64 = 0
  2324. id, _ := strconv.ParseInt(temp[2], 10, 64)
  2325. types, _ = strconv.ParseInt(temp[1], 10, 64)
  2326. if temp[1] == "1" {
  2327. advice_id = id
  2328. project_id = 0
  2329. } else if temp[1] == "2" {
  2330. advice_id = 0
  2331. project_id = id
  2332. }
  2333. info := &models.HisOrderInfo{
  2334. OrderNumber: order.Number,
  2335. FeedetlSn: item.Bkf500,
  2336. UploadDate: time.Now().Unix(),
  2337. AdviceId: advice_id,
  2338. DetItemFeeSumamt: item.Akc264,
  2339. Cnt: item.Akc226,
  2340. Pric: float64(item.Akc225),
  2341. PatientId: patient_id,
  2342. Status: 1,
  2343. ChrgitmLv: item.Aka065,
  2344. Mtime: time.Now().Unix(),
  2345. Ctime: time.Now().Unix(),
  2346. UserOrgId: adminUser.CurrentOrgId,
  2347. OrderId: order.ID,
  2348. ProjectId: project_id,
  2349. Type: types,
  2350. OverPricPsnPay: item.Akc268,
  2351. AllowReimburse: item.Cka319,
  2352. }
  2353. service.CreateOrderInfo(info)
  2354. }
  2355. }
  2356. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2357. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patient_id, chrg_bchno, recordDateTime)
  2358. var total float64
  2359. for _, item := range prescriptions {
  2360. if item.Type == 1 { //药品
  2361. for _, subItem := range item.HisDoctorAdviceInfo {
  2362. total = total + (subItem.Price * subItem.PrescribingNumber)
  2363. }
  2364. }
  2365. if item.Type == 2 { //项目
  2366. for _, subItem := range item.HisPrescriptionProject {
  2367. total = total + (subItem.Price * float64(subItem.Count))
  2368. }
  2369. }
  2370. }
  2371. for _, item := range prescriptions {
  2372. for _, subItem := range item.HisAdditionalCharge {
  2373. total = total + (subItem.Price * float64(subItem.Count))
  2374. }
  2375. }
  2376. yiliao_number, id_card_number, verifyCode, version_code, health_card_no, _, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code + "|")
  2377. if ret4 == 0 {
  2378. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  2379. tempPatient, _ := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
  2380. if tempPatient.ID == patient_id {
  2381. result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor_code, drug_doctor_name, his.MedicalTreatmentType, sick.CountryCode)
  2382. var dat map[string]interface{}
  2383. if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
  2384. fmt.Println(dat)
  2385. } else {
  2386. fmt.Println(err)
  2387. }
  2388. userJSONBytes, _ := json.Marshal(dat)
  2389. var res ResultTwo
  2390. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2391. utils.ErrorLog("解析失败:%v", err)
  2392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2393. return
  2394. }
  2395. if res.Transreturncode == "00000000" {
  2396. order.OrderStatus = 2
  2397. order.PayWay = pay_way
  2398. order.PayPrice = pay_price
  2399. order.PayCardNo = pay_card_no
  2400. order.PsnNo = health_card_no
  2401. order.DiscountPrice = discount_price
  2402. order.PreferentialPrice = preferential_price
  2403. order.RealityPrice = reality_price
  2404. order.FoundPrice = found_price
  2405. order.MedicalInsurancePrice = medical_insurance_price
  2406. order.PrivatePrice = private_price
  2407. order.Modify = admin_user_id
  2408. order.MedfeeSumamt = res.Transbody.Akc264
  2409. order.SetlId = res.Transbody.Ckc618
  2410. order.FundPaySumamt = res.Transbody.Akb068
  2411. order.AcctPay = res.Transbody.Akb066
  2412. order.PsnCashPay = res.Transbody.Akb067
  2413. order.PsnPartAmt = res.Transbody.Akb067
  2414. order.AccountPrice = res.Transbody.Aae240
  2415. order.MzNumber = mz_number
  2416. order.YiliaoNumber = yiliao_number
  2417. setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
  2418. detailStrOne := string(setlDetailOne)
  2419. order.SzChargeInfo = detailStrOne
  2420. setlDetailTwo, _ := json.Marshal(res.Transbody.Outputlist2)
  2421. detailStrTwo := string(setlDetailTwo)
  2422. order.SzProjectInfo = detailStrTwo
  2423. setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
  2424. detailStrThree := string(setlDetailThree)
  2425. order.SzMedicineInsuranceInfo = detailStrThree
  2426. order.Cainfo = result_three
  2427. err = service.UpdataOrderStatusTwo(order.Number, adminUser.CurrentOrgId)
  2428. err = service.UpDateOrderTwo(order)
  2429. c.ServeSuccessJSON(map[string]interface{}{
  2430. "msg": "结算成功",
  2431. })
  2432. } else {
  2433. //结算报错
  2434. errlog := &models.HisOrderError{
  2435. UserOrgId: adminUser.CurrentOrgId,
  2436. Ctime: time.Now().Unix(),
  2437. Mtime: time.Now().Unix(),
  2438. Number: chrg_bchno,
  2439. ErrMsg: res.Transreturnmessage,
  2440. Status: 1,
  2441. PatientId: patient_id,
  2442. RecordTime: recordDateTime,
  2443. Stage: 6,
  2444. }
  2445. service.CreateErrMsgLog(errlog)
  2446. c.ServeSuccessJSON(map[string]interface{}{
  2447. "failed_code": -10,
  2448. "msg": res.Transreturnmessage,
  2449. })
  2450. }
  2451. } else {
  2452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2453. return
  2454. }
  2455. } else {
  2456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2457. return
  2458. }
  2459. } else {
  2460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  2461. return
  2462. }
  2463. }
  2464. //func (c *SZHisApiController) GetSettleInfo() {
  2465. // pay_way, _ := c.GetInt64("pay_way")
  2466. // pay_price, _ := c.GetFloat("pay_price")
  2467. // pay_card_no := c.GetString("pay_card_no")
  2468. // discount_price, _ := c.GetFloat("discount_price")
  2469. // preferential_price, _ := c.GetFloat("preferential_price")
  2470. // reality_price, _ := c.GetFloat("reality_price")
  2471. // found_price, _ := c.GetFloat("found_price")
  2472. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  2473. // private_price, _ := c.GetFloat("private_price")
  2474. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2475. // patient_id, _ := c.GetInt64("id")
  2476. // record_time := c.GetString("record_time")
  2477. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2478. // timestamp := time.Now().Unix()
  2479. // tempTime := time.Unix(timestamp, 0)
  2480. // timeFormat := tempTime.Format("20060102150405")
  2481. // chrgBchno := rand.Intn(10000) + 1000
  2482. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(1, 10)
  2483. // adminUser := c.GetAdminUserInfo()
  2484. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2485. // month := time.Unix(1557042972, 0).Format("1")
  2486. // year := time.Now().Format("2006")
  2487. // month = time.Now().Format("01")
  2488. // day := time.Now().Format("02")
  2489. //
  2490. // timeLayout := "2006-01-02"
  2491. // loc, _ := time.LoadLocation("Local")
  2492. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2493. // fmt.Println(err)
  2494. // if err != nil {
  2495. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2496. // return
  2497. // }
  2498. // recordDateTime := theTime.Unix()
  2499. //
  2500. // var prescriptions []*models.HisPrescription
  2501. //
  2502. // var start_time int64
  2503. // var end_time int64
  2504. //
  2505. // if settle_accounts_type == 1 { //日结
  2506. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2507. //
  2508. // } else { //月结
  2509. // start_time_str := c.GetString("start_time")
  2510. // end_time_str := c.GetString("end_time")
  2511. // timeLayout := "2006-01-02"
  2512. // loc, _ := time.LoadLocation("Local")
  2513. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2514. // if err != nil {
  2515. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2516. // return
  2517. // }
  2518. // recordStartTime := theStartTime.Unix()
  2519. // start_time = recordStartTime
  2520. //
  2521. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2522. // if err != nil {
  2523. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2524. // return
  2525. // }
  2526. // recordEndTime := theEndTime.Unix()
  2527. // end_time = recordEndTime
  2528. //
  2529. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  2530. // }
  2531. //
  2532. // var ids []int64
  2533. // for _, item := range prescriptions {
  2534. // ids = append(ids, item.ID)
  2535. // }
  2536. //
  2537. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2538. //
  2539. // adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2540. //
  2541. // adminRole, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2542. // his, err := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2543. // mz_number := his.Number
  2544. // number := miConfig.Code + year + month + day +
  2545. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  2546. // var doctor_name string
  2547. // var doctor_code string
  2548. // var drug_doctor_code string
  2549. // drug_doctor_code = adminRole_two.DoctorCode
  2550. // drug_doctor_name := adminRole_two.UserName
  2551. //
  2552. // if adminRole.ID == 0 {
  2553. // doctor_name = "黄亦轩"
  2554. // doctor_code = "1"
  2555. // } else {
  2556. // doctor_name = adminRole.UserName
  2557. // doctor_code = strconv.FormatInt(admin_user_id, 10)
  2558. // }
  2559. //
  2560. // verifyCode, version_code := ReadCardGetCode("FY001" + "|" + number + "|" + miConfig.Code)
  2561. // //verifyCode := "000000|bf885fa312a7f92861d6b61542a637fa"
  2562. // //version_code := "V0.3"
  2563. // var customs []*models.CustomDetail
  2564. // for _, item := range prescriptions {
  2565. // if item.Type == 1 { //药品
  2566. // for _, subItem := range item.HisDoctorAdviceInfo {
  2567. // fmt.Println(subItem.BaseDrugLib.MedicalInsuranceNumber)
  2568. //
  2569. // if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2570. // _, dose_code := service.GetDoseCode(subItem.BaseDrugLib.DrugDosageForm, adminUser.CurrentOrgId)
  2571. // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber), 64)
  2572. // price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  2573. // temp := strings.Split(subItem.FeedetlSn, "-")
  2574. // newFl := fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) + "-" + temp[1] + "-" + temp[2]
  2575. //
  2576. // cus := &models.CustomDetail{
  2577. // PrescriptionNumber: chrg_bchno,
  2578. // OrderType: "1",
  2579. // ChargeSerialNumber: newFl,
  2580. // Code: subItem.BaseDrugLib.MedicalInsuranceNumber,
  2581. // CodeName: subItem.BaseDrugLib.DrugName,
  2582. // Flag: "1",
  2583. // Price: price,
  2584. // Count: subItem.PrescribingNumber,
  2585. // ChargeOrderDate: year + month + day,
  2586. // DoctorCode: doctor_code,
  2587. // Total: detItemFeeSumamt,
  2588. // DoseCode: dose_code,
  2589. // Spec: subItem.BaseDrugLib.DrugSpec,
  2590. // }
  2591. // customs = append(customs, cus)
  2592. // }
  2593. // }
  2594. // }
  2595. //
  2596. // if item.Type == 2 { //项目
  2597. // for _, subItem := range item.HisPrescriptionProject {
  2598. // if len(subItem.HisProject.MedicalCode) > 0 {
  2599. // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  2600. //
  2601. // count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  2602. // temp := strings.Split(subItem.FeedetlSn, "-")
  2603. // newFl := fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) + "-" + temp[1] + "-" + temp[2]
  2604. //
  2605. // cus := &models.CustomDetail{
  2606. // PrescriptionNumber: chrg_bchno,
  2607. // OrderType: "1",
  2608. // ChargeSerialNumber: newFl,
  2609. // Code: subItem.HisProject.MedicalCode,
  2610. // CodeName: subItem.HisProject.ProjectName,
  2611. // Flag: "1",
  2612. // Price: subItem.Price,
  2613. // Count: count,
  2614. // ChargeOrderDate: year + month + day,
  2615. // DoctorCode: doctor_code,
  2616. // Total: detItemFeeSumamt,
  2617. // DoseCode: "",
  2618. // Spec: "次",
  2619. // }
  2620. // customs = append(customs, cus)
  2621. // }
  2622. // }
  2623. // }
  2624. // //
  2625. // //for _, subItem := range item.HisAdditionalCharge {
  2626. // // if len(subItem.XtHisAddtionConfig.Code) > 0 {
  2627. // // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  2628. // //
  2629. // // count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  2630. // // cus := &models.CustomDetail{
  2631. // // PrescriptionNumber: chrg_bchno,
  2632. // // OrderType: "1",
  2633. // // ChargeSerialNumber: subItem.FeedetlSn,
  2634. // // Code: subItem.XtHisAddtionConfig.Code,
  2635. // // CodeName: subItem.XtHisAddtionConfig.Name,
  2636. // // Flag: "1",
  2637. // // Price: subItem.Price,
  2638. // // Count: count,
  2639. // // ChargeOrderDate: year + month + day,
  2640. // // DoctorCode: doctor_code,
  2641. // // Total: detItemFeeSumamt,
  2642. // // DoseCode: "",
  2643. // // Spec: subItem.XtHisAddtionConfig.,
  2644. // // }
  2645. // // customs = append(customs, cus)
  2646. // // }
  2647. // //}
  2648. // }
  2649. //
  2650. // var pagesize int = 50
  2651. // var start int = 1
  2652. // var stop int
  2653. // var pagecount int
  2654. // var curpage int
  2655. // var isSuccess bool = true
  2656. // //总页数,向上取整,注意除之前要先转换类型为float64
  2657. // pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  2658. //
  2659. // var ress []*Result
  2660. // for curpage = 1; curpage <= pagecount; curpage++ {
  2661. // if curpage == 1 {
  2662. // start = 1
  2663. // } else {
  2664. // start = (curpage-1)*pagesize + 1
  2665. // }
  2666. // stop = curpage * pagesize
  2667. // if stop > len(customs) {
  2668. // stop = len(customs)
  2669. // }
  2670. // result := service.SzybFY001(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, number, mz_number, version_code, drug_doctor_code)
  2671. // fmt.Println(result)
  2672. //
  2673. // var dat map[string]interface{}
  2674. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2675. // fmt.Println(dat)
  2676. // } else {
  2677. // fmt.Println(err)
  2678. // }
  2679. //
  2680. // userJSONBytes, _ := json.Marshal(dat)
  2681. //
  2682. // var res Result
  2683. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2684. // utils.ErrorLog("解析失败:%v", err)
  2685. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2686. // return
  2687. // }
  2688. // if res.Transreturncode == "00000000" {
  2689. // ress = append(ress, &res)
  2690. // } else {
  2691. // isSuccess = false
  2692. // errlog := &models.HisOrderError{
  2693. // UserOrgId: adminUser.CurrentOrgId,
  2694. // Ctime: time.Now().Unix(),
  2695. // Mtime: time.Now().Unix(),
  2696. // Number: chrg_bchno,
  2697. // ErrMsg: res.Transreturnmessage,
  2698. // Status: 1,
  2699. // PatientId: patient_id,
  2700. // RecordTime: recordDateTime,
  2701. // Stage: 4,
  2702. // }
  2703. // service.CreateErrMsgLog(errlog)
  2704. // c.ServeSuccessJSON(map[string]interface{}{
  2705. // "failed_code": -10,
  2706. // "msg": res.Transreturnmessage,
  2707. // })
  2708. // return
  2709. // }
  2710. // //设置变量,根据变量的值来判断上传是否成功
  2711. // }
  2712. // if isSuccess == true {
  2713. // order := &models.HisOrder{
  2714. // UserOrgId: adminUser.CurrentOrgId,
  2715. // HisPatientId: 0,
  2716. // PatientId: patient_id,
  2717. // SettleAccountsDate: recordDateTime,
  2718. // Ctime: time.Now().Unix(),
  2719. // Mtime: time.Now().Unix(),
  2720. // Status: 1,
  2721. // Number: chrg_bchno,
  2722. // Infcode: 0,
  2723. // WarnMsg: "",
  2724. // Cainfo: "",
  2725. // ErrMsg: "",
  2726. // RespondTime: "",
  2727. // InfRefmsgid: "",
  2728. // OrderStatus: 1,
  2729. // IsMedicineInsurance: 1,
  2730. // SettleType: settle_accounts_type,
  2731. // SettleStartTime: start_time,
  2732. // SettleEndTime: end_time,
  2733. // Creator: admin_user_id,
  2734. // Modify: admin_user_id,
  2735. // OrgSetlNumber: number,
  2736. // }
  2737. // data, _ := json.Marshal(ress)
  2738. // order.DetailLog = string(data)
  2739. //
  2740. // err = service.CreateOrder(order)
  2741. // if err != nil {
  2742. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2743. // return
  2744. // }
  2745. //
  2746. // for _, subItem := range ress {
  2747. // for _, item := range subItem.Transbody.Outputlist {
  2748. //
  2749. // temp := strings.Split(item.Bkf500, "-")
  2750. // var advice_id int64 = 0
  2751. // var project_id int64 = 0
  2752. // var types int64 = 0
  2753. //
  2754. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  2755. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  2756. //
  2757. // if temp[1] == "1" {
  2758. // advice_id = id
  2759. // project_id = 0
  2760. // } else if temp[1] == "2" {
  2761. // advice_id = 0
  2762. // project_id = id
  2763. // }
  2764. //
  2765. // info := &models.HisOrderInfo{
  2766. // OrderNumber: order.Number,
  2767. // FeedetlSn: item.Bkf500,
  2768. // UploadDate: time.Now().Unix(),
  2769. // AdviceId: advice_id,
  2770. // DetItemFeeSumamt: item.Akc264,
  2771. // Cnt: item.Akc226,
  2772. // Pric: float64(item.Akc225),
  2773. // PatientId: patient_id,
  2774. // Status: 1,
  2775. // ChrgitmLv: item.Aka065,
  2776. // Mtime: time.Now().Unix(),
  2777. // Ctime: time.Now().Unix(),
  2778. // UserOrgId: adminUser.CurrentOrgId,
  2779. // OrderId: order.ID,
  2780. // ProjectId: project_id,
  2781. // Type: types,
  2782. //
  2783. // OverPricPsnPay: item.Akc268,
  2784. // AllowReimburse: item.Cka319,
  2785. // }
  2786. // service.CreateOrderInfo(info)
  2787. //
  2788. // }
  2789. // }
  2790. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2791. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patient_id, chrg_bchno, recordDateTime)
  2792. // var total float64
  2793. // for _, item := range prescriptions {
  2794. // if item.Type == 1 { //药品
  2795. // for _, subItem := range item.HisDoctorAdviceInfo {
  2796. // total = total + (subItem.Price * subItem.PrescribingNumber)
  2797. // }
  2798. // }
  2799. // if item.Type == 2 { //项目
  2800. // for _, subItem := range item.HisPrescriptionProject {
  2801. // total = total + (subItem.Price * float64(subItem.Count))
  2802. // }
  2803. // }
  2804. // }
  2805. // for _, item := range prescriptions {
  2806. // for _, subItem := range item.HisAdditionalCharge {
  2807. // total = total + (subItem.Price * float64(subItem.Count))
  2808. // }
  2809. // }
  2810. //
  2811. // yiliao_number, id_card_number, verifyCode, version_code, _, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code + "|")
  2812. // if ret4 == 0 {
  2813. // //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  2814. // tempPatient, _ := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
  2815. // if tempPatient.ID == patient_id {
  2816. //
  2817. // result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor_code, drug_doctor_name, his.MedicalTreatmentType)
  2818. // var dat map[string]interface{}
  2819. // if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
  2820. // fmt.Println(dat)
  2821. // } else {
  2822. // fmt.Println(err)
  2823. // }
  2824. // userJSONBytes, _ := json.Marshal(dat)
  2825. // var res ResultTwo
  2826. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2827. // utils.ErrorLog("解析失败:%v", err)
  2828. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2829. // return
  2830. // }
  2831. //
  2832. // if res.Transreturncode == "00000000" {
  2833. // order.OrderStatus = 2
  2834. // order.PayWay = pay_way
  2835. // order.PayPrice = pay_price
  2836. // order.PayCardNo = pay_card_no
  2837. // order.DiscountPrice = discount_price
  2838. // order.PreferentialPrice = preferential_price
  2839. // order.RealityPrice = reality_price
  2840. // order.FoundPrice = found_price
  2841. // order.MedicalInsurancePrice = medical_insurance_price
  2842. // order.PrivatePrice = private_price
  2843. // order.Modify = admin_user_id
  2844. // order.MedfeeSumamt = res.Transbody.Akc264
  2845. // order.SetlId = res.Transbody.Ckc618
  2846. // order.FundPaySumamt = res.Transbody.Akb068
  2847. // order.AcctPay = res.Transbody.Akb066
  2848. // order.PsnCashPay = res.Transbody.Akb067
  2849. // order.PsnPartAmt = res.Transbody.Akb067
  2850. // order.AccountPrice = res.Transbody.Aae240
  2851. // order.MzNumber = mz_number
  2852. // order.YiliaoNumber = yiliao_number
  2853. // setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
  2854. // detailStrOne := string(setlDetailOne)
  2855. // order.SzChargeInfo = detailStrOne
  2856. // setlDetailTwo, _ := json.Marshal(res.Transbody.Outputlist2)
  2857. // detailStrTwo := string(setlDetailTwo)
  2858. // order.SzProjectInfo = detailStrTwo
  2859. // setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
  2860. // detailStrThree := string(setlDetailThree)
  2861. // order.SzMedicineInsuranceInfo = detailStrThree
  2862. // order.Cainfo = result_three
  2863. // err = service.UpdataOrderStatusTwo(order.Number, adminUser.CurrentOrgId)
  2864. // err = service.UpDateOrderTwo(order)
  2865. // c.ServeSuccessJSON(map[string]interface{}{
  2866. // "msg": "结算成功",
  2867. // })
  2868. // } else {
  2869. // //结算报错
  2870. // errlog := &models.HisOrderError{
  2871. // UserOrgId: adminUser.CurrentOrgId,
  2872. // Ctime: time.Now().Unix(),
  2873. // Mtime: time.Now().Unix(),
  2874. // Number: chrg_bchno,
  2875. // ErrMsg: res.Transreturnmessage,
  2876. // Status: 1,
  2877. // PatientId: patient_id,
  2878. // RecordTime: recordDateTime,
  2879. // Stage: 6,
  2880. // }
  2881. // service.CreateErrMsgLog(errlog)
  2882. // c.ServeSuccessJSON(map[string]interface{}{
  2883. // "failed_code": -10,
  2884. // "msg": res.Transreturnmessage,
  2885. // })
  2886. // }
  2887. // } else {
  2888. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2889. // return
  2890. // }
  2891. // } else {
  2892. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2893. // return
  2894. // }
  2895. // } else {
  2896. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  2897. // return
  2898. // }
  2899. //}
  2900. //结算
  2901. //func (c *SZHisApiController) GetSettleInfo() {
  2902. // patient_id, _ := c.GetInt64("id")
  2903. // order_id, _ := c.GetInt64("order_id")
  2904. // record_time := c.GetString("record_time")
  2905. // pay_way, _ := c.GetInt64("pay_way")
  2906. // pay_price, _ := c.GetFloat("pay_price")
  2907. // pay_card_no := c.GetString("pay_card_no")
  2908. // discount_price, _ := c.GetFloat("discount_price")
  2909. // preferential_price, _ := c.GetFloat("preferential_price")
  2910. // reality_price, _ := c.GetFloat("reality_price")
  2911. // found_price, _ := c.GetFloat("found_price")
  2912. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  2913. // private_price, _ := c.GetFloat("private_price")
  2914. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2915. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2916. //
  2917. // timeLayout := "2006-01-02"
  2918. // loc, _ := time.LoadLocation("Local")
  2919. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2920. // if err != nil {
  2921. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2922. // return
  2923. // }
  2924. // recordDateTime := theTime.Unix()
  2925. // adminUser := c.GetAdminUserInfo()
  2926. //
  2927. // var prescriptions []*models.HisPrescription
  2928. //
  2929. // data := make(map[string]interface{})
  2930. // if settle_accounts_type == 1 { //日结
  2931. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2932. // data["pre"] = prescriptions
  2933. //
  2934. // } else { //月结
  2935. // start_time_str := c.GetString("start_time")
  2936. // end_time_str := c.GetString("end_time")
  2937. // timeLayout := "2006-01-02"
  2938. // loc, _ := time.LoadLocation("Local")
  2939. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2940. // if err != nil {
  2941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2942. // return
  2943. // }
  2944. // recordStartTime := theStartTime.Unix()
  2945. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2946. // if err != nil {
  2947. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2948. // return
  2949. // }
  2950. // recordEndTime := theEndTime.Unix()
  2951. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  2952. // data["pre"] = prescriptions
  2953. //
  2954. // }
  2955. //
  2956. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2957. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2958. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2959. // strconv.FormatInt(his.PatientId, 10)
  2960. //
  2961. // order_src, _ := service.GetHisOrderByID(order_id)
  2962. //
  2963. // if order_src.ID == 0 {
  2964. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2965. // return
  2966. // }
  2967. //
  2968. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2969. // if config.IsOpen == 1 { //对接了医保,走医保流程
  2970. // if order_src.OrderStatus != 2 {
  2971. // var total float64
  2972. // for _, item := range prescriptions {
  2973. // if item.Type == 1 { //药品
  2974. // for _, subItem := range item.HisDoctorAdviceInfo {
  2975. // total = total + (subItem.Price * subItem.PrescribingNumber)
  2976. // }
  2977. // }
  2978. // if item.Type == 2 { //项目
  2979. // for _, subItem := range item.HisPrescriptionProject {
  2980. // total = total + (subItem.Price * float64(subItem.Count))
  2981. // }
  2982. // }
  2983. // }
  2984. //
  2985. // for _, item := range prescriptions {
  2986. // for _, subItem := range item.HisAdditionalCharge {
  2987. // total = total + (subItem.Price * float64(subItem.Count))
  2988. // }
  2989. // }
  2990. //
  2991. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2992. //
  2993. // adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2994. //
  2995. // var drug_doctor string
  2996. // drug_doctor = adminRole_two.DoctorCode
  2997. // drug_doctor_name := adminRole_two.UserName
  2998. // //结算流程
  2999. // var doctor_name string
  3000. // var doctor_code string
  3001. // if roles.ID == 0 {
  3002. // doctor_name = "黄亦轩"
  3003. // doctor_code = "1010"
  3004. // } else {
  3005. // doctor_name = roles.UserName
  3006. // doctor_code = strconv.FormatInt(admin_user_id, 10)
  3007. // }
  3008. // number := order_src.OrgSetlNumber
  3009. // mz_number := his.Number
  3010. // verifyCode, version_code := ReadCardGetCode("FY005" + "|" + number + "|" + miConfig.Code)
  3011. //
  3012. // //verifyCode := "000000|707c35a62c2f0609d7b0a811649f3913"
  3013. // //version_code := "V0.3"
  3014. // yiliao_number, id_card_number, verifyCode, version_code, err, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code)
  3015. // yiliao_number := his.YiliaoNumber
  3016. // result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor, drug_doctor_name)
  3017. // var dat map[string]interface{}
  3018. // if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
  3019. // fmt.Println(dat)
  3020. // } else {
  3021. // fmt.Println(err)
  3022. // }
  3023. // userJSONBytes, _ := json.Marshal(dat)
  3024. // var res ResultTwo
  3025. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3026. // utils.ErrorLog("解析失败:%v", err)
  3027. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3028. // return
  3029. // }
  3030. //
  3031. // if res.Transreturncode == "00000000" {
  3032. // order_src.OrderStatus = 2
  3033. // order_src.PayWay = pay_way
  3034. // order_src.PayPrice = pay_price
  3035. // order_src.PayCardNo = pay_card_no
  3036. // order_src.DiscountPrice = discount_price
  3037. // order_src.PreferentialPrice = preferential_price
  3038. // order_src.RealityPrice = reality_price
  3039. // order_src.FoundPrice = found_price
  3040. // order_src.MedicalInsurancePrice = medical_insurance_price
  3041. // order_src.PrivatePrice = private_price
  3042. // order_src.Creator = order_src.Creator
  3043. // order_src.Modify = roles.ID
  3044. // order_src.MedfeeSumamt = res.Transbody.Akc264
  3045. // order_src.SetlId = res.Transbody.Ckc618
  3046. // order_src.FundPaySumamt = res.Transbody.Akb068
  3047. // order_src.AcctPay = res.Transbody.Akb066
  3048. // order_src.PsnCashPay = res.Transbody.Akb067
  3049. // order_src.PsnPartAmt = res.Transbody.Akb067
  3050. // order_src.AccountPrice = res.Transbody.Aae240
  3051. // order_src.MzNumber = mz_number
  3052. // order_src.YiliaoNumber = yiliao_number
  3053. // setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
  3054. // detailStrOne := string(setlDetailOne)
  3055. // order_src.SzChargeInfo = detailStrOne
  3056. // setlDetailTwo, _ := json.Marshal(res.Transbody.Outputlist2)
  3057. // detailStrTwo := string(setlDetailTwo)
  3058. // order_src.SzProjectInfo = detailStrTwo
  3059. // setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
  3060. // detailStrThree := string(setlDetailThree)
  3061. // order_src.SzMedicineInsuranceInfo = detailStrThree
  3062. // order_src.Cainfo = result_three
  3063. //
  3064. // err = service.UpdataOrderStatusTwo(order_src.Number, adminUser.CurrentOrgId)
  3065. // err = service.UpDateOrder(order_src)
  3066. //
  3067. // c.ServeSuccessJSON(map[string]interface{}{
  3068. // "msg": "结算成功",
  3069. // })
  3070. // } else {
  3071. // //version_code := "0.03"
  3072. // c.ServeSuccessJSON(map[string]interface{}{
  3073. // "failed_code": -10,
  3074. // "msg": res.Transreturnmessage,
  3075. // })
  3076. //
  3077. // }
  3078. // } else {
  3079. //
  3080. // //错误提示
  3081. //
  3082. // }
  3083. // } else {
  3084. // //错误提示
  3085. //
  3086. // }
  3087. //}
  3088. //当月退费
  3089. func (c *SZHisApiController) Refund() {
  3090. order_id, _ := c.GetInt64("order_id")
  3091. record_time := c.GetString("record_time")
  3092. patient_id, _ := c.GetInt64("patient_id")
  3093. admin_user_id, _ := c.GetInt64("admin_user_id")
  3094. timeLayout := "2006-01-02"
  3095. loc, _ := time.LoadLocation("Local")
  3096. adminUser := c.GetAdminUserInfo()
  3097. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3098. fmt.Println(err)
  3099. if err != nil {
  3100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3101. return
  3102. }
  3103. recordDateTime := theTime.Unix()
  3104. fmt.Println(recordDateTime)
  3105. var order models.HisOrder
  3106. order, _ = service.GetHisOrderByID(order_id)
  3107. if order.ID == 0 {
  3108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3109. return
  3110. }
  3111. his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, theTime.Unix())
  3112. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3113. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3114. //结算流程
  3115. var doctor_name string
  3116. var doctor_code string
  3117. if roles.ID == 0 {
  3118. doctor_name = "管理员"
  3119. doctor_code = "01"
  3120. } else {
  3121. doctor_name = roles.UserName
  3122. doctor_code = strconv.FormatInt(admin_user_id, 10)
  3123. }
  3124. month := time.Unix(1557042972, 0).Format("1")
  3125. year := time.Now().Format("2006")
  3126. month = time.Now().Format("01")
  3127. day := time.Now().Format("02")
  3128. //number := miConfig.Code + year + month + day + "1367866"
  3129. number := miConfig.Code + year + month + day +
  3130. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  3131. //number := miConfig.Code + year + month + day + "1590003"
  3132. //流水号
  3133. //number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  3134. verifyCode, version_code := ReadCardGetCode("JY002" + "|" + number + "|" + miConfig.Code)
  3135. //version_code := "V0.3"
  3136. //
  3137. //verifyCode := "000000|9972fca7ba9471c7dbe08324b2e31f70"
  3138. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3139. order_infos, _ := service.GetHisOrderInfoByNumber(order.Number)
  3140. var customs []*models.CustomDetail
  3141. for _, item := range order_infos {
  3142. cus := &models.CustomDetail{
  3143. PrescriptionNumber: item.OrderNumber,
  3144. ChargeSerialNumber: item.FeedetlSn,
  3145. }
  3146. customs = append(customs, cus)
  3147. }
  3148. if config.IsOpen == 1 { //对接了医保,走医保流程
  3149. result := service.SzybJY002(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, number, version_code)
  3150. fmt.Println(result)
  3151. var dat map[string]interface{}
  3152. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3153. fmt.Println(dat)
  3154. } else {
  3155. fmt.Println(err)
  3156. }
  3157. userJSONBytes, _ := json.Marshal(dat)
  3158. var res ResultThree
  3159. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3160. utils.ErrorLog("解析失败:%v", err)
  3161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3162. return
  3163. }
  3164. if res.Transreturncode == "00000000" {
  3165. service.UpdataOrderlog(order_id, adminUser.CurrentOrgId, result)
  3166. service.UpdataOrderStatusSZ(order_id, order.Number, adminUser.CurrentOrgId, his.MzNumber, his.Number)
  3167. service.UpdataOrderInfoStatus(order.ID, order.Number, adminUser.CurrentOrgId)
  3168. c.ServeSuccessJSON(map[string]interface{}{
  3169. "msg": "退费成功",
  3170. })
  3171. } else {
  3172. c.ServeSuccessJSON(map[string]interface{}{
  3173. "failed_code": -10,
  3174. "msg": res.Transreturnmessage,
  3175. })
  3176. }
  3177. }
  3178. }
  3179. //跨月退费
  3180. func (c *SZHisApiController) MonthRefund() {
  3181. order_id, _ := c.GetInt64("order_id")
  3182. record_time := c.GetString("record_time")
  3183. patient_id, _ := c.GetInt64("patient_id")
  3184. admin_user_id, _ := c.GetInt64("admin_user_id")
  3185. timeLayout := "2006-01-02"
  3186. loc, _ := time.LoadLocation("Local")
  3187. adminUser := c.GetAdminUserInfo()
  3188. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3189. fmt.Println(err)
  3190. if err != nil {
  3191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3192. return
  3193. }
  3194. recordDateTime := theTime.Unix()
  3195. var order models.HisOrder
  3196. order, _ = service.GetHisOrderByID(order_id)
  3197. if order.ID == 0 {
  3198. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3199. }
  3200. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3201. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3202. //结算流程
  3203. var doctor_name string
  3204. var doctor_code string
  3205. if roles.ID == 0 {
  3206. doctor_name = "管理员"
  3207. doctor_code = "01"
  3208. } else {
  3209. doctor_name = roles.UserName
  3210. doctor_code = strconv.FormatInt(admin_user_id, 10)
  3211. }
  3212. month := time.Unix(1557042972, 0).Format("1")
  3213. year := time.Now().Format("2006")
  3214. month = time.Now().Format("01")
  3215. day := time.Now().Format("02")
  3216. //流水号
  3217. number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  3218. //verifyCode,version_code := ReadCardGetCode("JY002" + "|" + number_two + "|" + miConfig.Code)
  3219. version_code := "0.03"
  3220. fmt.Println(number_two)
  3221. verifyCode := "000000|0872038667cc34efdc35ce4668589a5f"
  3222. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3223. if config.IsOpen == 1 { //对接了医保,走医保流程
  3224. result := service.SzybJY003(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, version_code)
  3225. fmt.Println(result)
  3226. var dat map[string]interface{}
  3227. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3228. fmt.Println(dat)
  3229. } else {
  3230. fmt.Println(err)
  3231. }
  3232. userJSONBytes, _ := json.Marshal(dat)
  3233. var res ResultThree
  3234. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3235. utils.ErrorLog("解析失败:%v", err)
  3236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3237. return
  3238. }
  3239. if res.Transreturncode == "00000000" {
  3240. c.ServeSuccessJSON(map[string]interface{}{
  3241. "msg": "退费成功",
  3242. })
  3243. } else {
  3244. }
  3245. }
  3246. }
  3247. //查询
  3248. func (c *SZHisApiController) GetSettleAccounts() {
  3249. order_id, _ := c.GetInt64("order_id")
  3250. record_time := c.GetString("record_time")
  3251. patient_id, _ := c.GetInt64("patient_id")
  3252. admin_user_id, _ := c.GetInt64("admin_user_id")
  3253. timeLayout := "2006-01-02"
  3254. loc, _ := time.LoadLocation("Local")
  3255. adminUser := c.GetAdminUserInfo()
  3256. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3257. fmt.Println(err)
  3258. if err != nil {
  3259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3260. return
  3261. }
  3262. recordDateTime := theTime.Unix()
  3263. fmt.Println(recordDateTime)
  3264. var order models.HisOrder
  3265. order, _ = service.GetHisOrderByID(order_id)
  3266. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  3267. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, order.SettleAccountsDate)
  3268. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3269. his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, order.SettleAccountsDate)
  3270. yiliao_leibie := ""
  3271. switch his.MedicalTreatmentType {
  3272. case 11:
  3273. yiliao_leibie = "普通门诊"
  3274. break
  3275. case 12:
  3276. yiliao_leibie = "家庭通道"
  3277. break
  3278. case 13:
  3279. yiliao_leibie = "门诊大病"
  3280. break
  3281. case 14:
  3282. yiliao_leibie = "重疾特药"
  3283. break
  3284. case 15:
  3285. yiliao_leibie = "门诊慢病"
  3286. break
  3287. case 16:
  3288. yiliao_leibie = "门诊特检"
  3289. break
  3290. case 17:
  3291. yiliao_leibie = "健康体检"
  3292. break
  3293. case 18:
  3294. yiliao_leibie = "预防接种"
  3295. break
  3296. case 19:
  3297. yiliao_leibie = "门诊输血"
  3298. break
  3299. case 91:
  3300. yiliao_leibie = "新冠肺炎门诊"
  3301. break
  3302. }
  3303. //departments, _ := service.Get(patientPrescription.Departments)
  3304. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3305. if order.ID == 0 {
  3306. //order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3308. return
  3309. }
  3310. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3311. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3312. //结算流程
  3313. var doctor_name string
  3314. var doctor_code string
  3315. if roles.ID == 0 {
  3316. doctor_name = "管理员"
  3317. doctor_code = "01"
  3318. } else {
  3319. doctor_name = roles.UserName
  3320. doctor_code = strconv.FormatInt(admin_user_id, 10)
  3321. }
  3322. //month := time.Unix(1557042972, 0).Format("1")
  3323. //year := time.Now().Format("2006")
  3324. //month = time.Now().Format("01")
  3325. //day := time.Now().Format("02")
  3326. //流水号
  3327. //number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  3328. //fmt.Println(number_two)
  3329. verifyCode, version_code := ReadCardGetCode("JY001" + "|" + order.OrgSetlNumber + "|" + miConfig.Code)
  3330. //version_code := "V0.3"
  3331. //verifyCode := "000000|2c9854287e7c3cbc34439ab8e5157816"
  3332. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3333. if config.IsOpen == 1 { //对接了医保,走医保流程
  3334. result := service.SzybJY001(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, version_code)
  3335. fmt.Println(result)
  3336. var dat map[string]interface{}
  3337. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3338. fmt.Println(dat)
  3339. } else {
  3340. fmt.Println(err)
  3341. }
  3342. userJSONBytes, _ := json.Marshal(dat)
  3343. var res ResultFour
  3344. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3345. utils.ErrorLog("解析失败:%v", err)
  3346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3347. return
  3348. }
  3349. if res.Transreturncode == "00000000" {
  3350. var dat2 map[string]interface{}
  3351. if err := json.Unmarshal([]byte(his.PatientInfo), &dat2); err == nil {
  3352. fmt.Println(dat2)
  3353. } else {
  3354. fmt.Println(err)
  3355. }
  3356. userJSONBytes2, _ := json.Marshal(dat2)
  3357. var res2 ResultMZ001
  3358. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3359. utils.ErrorLog("解析失败:%v", err)
  3360. }
  3361. c.ServeSuccessJSON(map[string]interface{}{
  3362. "result": res,
  3363. "org_name": miConfig.OrgName,
  3364. "org_code": miConfig.Code,
  3365. "patient_name": patient.Name,
  3366. "doctor_code": adminRole_two.DoctorCode,
  3367. "doctor_name": doctor_name,
  3368. "health_card_no": order.PsnNo,
  3369. "health_card_no_two": res2.Transbody.Aaz500,
  3370. "order_number": order.Number,
  3371. "department": departments.Name,
  3372. "yiliao_leibie": yiliao_leibie,
  3373. "before_money": res2.Transbody.Aae240,
  3374. "after_money": order.AccountPrice,
  3375. })
  3376. } else {
  3377. c.ServeSuccessJSON(map[string]interface{}{
  3378. "failed_code": -10,
  3379. "msg": res.Transreturnmessage,
  3380. })
  3381. }
  3382. }
  3383. }
  3384. //费用录入取消
  3385. func (c *SZHisApiController) CancelOrderDetail() {
  3386. order_id, _ := c.GetInt64("order_id")
  3387. record_time := c.GetString("record_time")
  3388. patient_id, _ := c.GetInt64("patient_id")
  3389. admin_user_id, _ := c.GetInt64("admin_user_id")
  3390. timeLayout := "2006-01-02"
  3391. loc, _ := time.LoadLocation("Local")
  3392. adminUser := c.GetAdminUserInfo()
  3393. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3394. fmt.Println(err)
  3395. if err != nil {
  3396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3397. return
  3398. }
  3399. recordDateTime := theTime.Unix()
  3400. var order models.HisOrder
  3401. order, _ = service.GetHisOrderByID(order_id)
  3402. if order.ID == 0 {
  3403. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3404. }
  3405. order_infos, _ := service.GetHisOrderInfoByNumber(order.Number)
  3406. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3407. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3408. //结算流程
  3409. var doctor_name string
  3410. var doctor_code string
  3411. if roles.ID == 0 {
  3412. doctor_name = "管理员"
  3413. doctor_code = "1001"
  3414. } else {
  3415. doctor_name = roles.UserName
  3416. doctor_code = strconv.FormatInt(admin_user_id, 10)
  3417. }
  3418. var customs []*models.CustomDetail
  3419. for _, item := range order_infos {
  3420. cus := &models.CustomDetail{
  3421. PrescriptionNumber: item.OrderNumber,
  3422. ChargeSerialNumber: item.FeedetlSn,
  3423. }
  3424. customs = append(customs, cus)
  3425. }
  3426. his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3427. verifyCode, version_code := ReadCardGetCode("FY002" + "|" + order.OrgSetlNumber + "|" + miConfig.Code)
  3428. var pagesize int = 50
  3429. var start int = 1
  3430. var stop int
  3431. var pagecount int
  3432. var curpage int
  3433. var isSuccess bool = true
  3434. var ress []*ResultFive
  3435. //总页数,向上取整,注意除之前要先转换类型为float64
  3436. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  3437. for curpage = 1; curpage <= pagecount; curpage++ {
  3438. if curpage == 1 {
  3439. start = 1
  3440. } else {
  3441. start = (curpage-1)*pagesize + 1
  3442. }
  3443. stop = curpage * pagesize
  3444. if stop > len(customs) {
  3445. stop = len(customs)
  3446. }
  3447. result := service.SzybFY002(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, order.OrgSetlNumber, his.Number, version_code)
  3448. fmt.Println(result)
  3449. var dat map[string]interface{}
  3450. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3451. fmt.Println(dat)
  3452. } else {
  3453. fmt.Println(err)
  3454. }
  3455. userJSONBytes, _ := json.Marshal(dat)
  3456. var res ResultFive
  3457. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3458. utils.ErrorLog("解析失败:%v", err)
  3459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3460. return
  3461. }
  3462. if res.Transreturncode == "00000000" {
  3463. ress = append(ress, &res)
  3464. } else {
  3465. isSuccess = false
  3466. //预结算报错
  3467. errlog := &models.HisOrderError{
  3468. UserOrgId: adminUser.CurrentOrgId,
  3469. Ctime: time.Now().Unix(),
  3470. Mtime: time.Now().Unix(),
  3471. ErrMsg: res.Transreturnmessage,
  3472. Status: 1,
  3473. PatientId: patient_id,
  3474. RecordTime: recordDateTime,
  3475. Stage: 11,
  3476. }
  3477. service.CreateErrMsgLog(errlog)
  3478. c.ServeSuccessJSON(map[string]interface{}{
  3479. "faild_code": -10,
  3480. "msg": res.Transreturnmessage,
  3481. })
  3482. return
  3483. }
  3484. }
  3485. if isSuccess == true {
  3486. service.UpdataOrderInfoStatus(order.ID, order.Number, adminUser.CurrentOrgId)
  3487. c.ServeSuccessJSON(map[string]interface{}{
  3488. "msg": "撤销成功",
  3489. })
  3490. }
  3491. }
  3492. //获取verifyCode
  3493. func ReadCardGetCode(request string) (string, string) {
  3494. request = request + "|"
  3495. DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
  3496. readCards := DllDef2.MustFindProc("iVerifyCode")
  3497. str := request
  3498. str3 := make([]byte, 256)
  3499. ret4, _, _ := readCards.Call(StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  3500. fmt.Println(":", string(str3))
  3501. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3502. if ret4 == 0 {
  3503. result := string(str3)
  3504. fmt.Println(result)
  3505. result_arr := strings.Split(result, "|")
  3506. verifyCode := result_arr[0] + "|" + result_arr[1]
  3507. versionCode := result_arr[2]
  3508. return verifyCode, versionCode
  3509. }
  3510. return "", ""
  3511. }
  3512. ////获取卡信息
  3513. func ReadBasCardGetNumber(request string) (string, string, string, string, string, error, int64) {
  3514. DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
  3515. readCards := DllDef2.MustFindProc("iReadCardBas")
  3516. str := request
  3517. str3 := make([]byte, 1024)
  3518. fmt.Println(":", request)
  3519. fmt.Println(":", StrPtr(str))
  3520. ret4, _, err := readCards.Call(IntPtr(1), StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  3521. fmt.Println(":", string(str3))
  3522. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3523. if ret4 == 0 {
  3524. result := string(str3)
  3525. fmt.Println(result)
  3526. result_arr := strings.Split(result, "|")
  3527. //医疗证号
  3528. yiliao_number := result_arr[12]
  3529. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  3530. id_card_number := result_arr[1]
  3531. verifyCode := result_arr[11] + "|" + result_arr[13]
  3532. versionCode := result_arr[14]
  3533. health_card_no := result_arr[2]
  3534. return yiliao_number, id_card_number, verifyCode, versionCode, health_card_no, err, 0
  3535. }
  3536. return "", "", "", "", "", err, -10
  3537. }
  3538. //读卡
  3539. func ReadBasCard(request string) (string, string, error, int64) {
  3540. DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
  3541. readCards := DllDef2.MustFindProc("iReadCardBas")
  3542. str := request
  3543. str3 := make([]byte, 1024)
  3544. ret4, _, err := readCards.Call(IntPtr(1), StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  3545. fmt.Println(":", string(str3))
  3546. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3547. if ret4 == 0 {
  3548. result := string(str3)
  3549. result_arr := strings.Split(result, "|")
  3550. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  3551. id_card_number := result_arr[1]
  3552. health_card_no := result_arr[2]
  3553. return id_card_number, health_card_no, err, 0
  3554. }
  3555. return "", "", err, -10
  3556. }
  3557. //
  3558. ////iReadCardBas_HSM_Step1 ---- 1903 iCardInnerAuthentication --- iReadCardBas_HSM_Step2
  3559. //func ReadCardBasHSM(number string) string {
  3560. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  3561. // readCards := DllDef2.MustFindProc("iReadCardBas_HSM_Step1")
  3562. // str := make([]byte, 256)
  3563. // ret, _, _ := readCards.Call(IntPtr(3), (uintptr)(unsafe.Pointer(&str[0])))
  3564. // fmt.Println(":", string(str))
  3565. //
  3566. // result_arr := strings.Split(string(str), "|")
  3567. //
  3568. // if ret == 0 {
  3569. // readCards := DllDef2.MustFindProc("iCardInnerAuthentication")
  3570. // str2 := make([]byte, 256)
  3571. // str3 := "" + "|" + "" + "|" + "440300" + "|" + "" + "|" + "" + "|" + result_arr[1] + "|" + result_arr[2] + "|" + result_arr[3] + "|" + result_arr[4] + "|" + result_arr[5] + "|" + "" + "|" + "" + "|"
  3572. // ret2, _, _ := readCards.Call(StrPtr(str3), (uintptr)(unsafe.Pointer(&str2[0])))
  3573. // fmt.Println(":", string(str2))
  3574. //
  3575. // if ret2 == 0 {
  3576. // result_arr := strings.Split(string(str2), "|")
  3577. //
  3578. // if result_arr[2] == "0" {
  3579. // readCards := DllDef2.MustFindProc("iReadCardBas_HSM_Step2")
  3580. // str4 := result_arr[4] + "|" + result_arr[5]
  3581. // str5 := make([]byte, 256)
  3582. // ret3, _, _ := readCards.Call(StrPtr(str4), StrPtr(number), (uintptr)(unsafe.Pointer(&str5[0])))
  3583. //
  3584. // if ret3 == 0 {
  3585. // return string(str5)
  3586. //
  3587. // } else {
  3588. // return ""
  3589. // }
  3590. // } else {
  3591. // return ""
  3592. // }
  3593. // }
  3594. // return ""
  3595. // }
  3596. // return ""
  3597. //
  3598. //}
  3599. //
  3600. ////1904卡鉴权
  3601. //func CardAuth(request string) string {
  3602. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  3603. // readCards := DllDef2.MustFindProc("iCardAuthentication")
  3604. // str := request
  3605. // str3 := make([]byte, 256)
  3606. // ret4, _, _ := readCards.Call(StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  3607. // fmt.Println(":", string(str3))
  3608. //
  3609. // if ret4 == 0 {
  3610. // return string(str3)
  3611. // }
  3612. // return ""
  3613. //}
  3614. func (c *SZHisApiController) GetDrugList() {
  3615. adminUserInfo := c.GetAdminUserInfo()
  3616. orgId := adminUserInfo.CurrentOrgId
  3617. admin_user_id, _ := c.GetInt64("admin_user_id")
  3618. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  3619. ids := c.GetString("ids")
  3620. stringarr := strings.Split(ids, ",")
  3621. idss := make([]int64, 0)
  3622. for _, item := range stringarr {
  3623. itemsss, _ := strconv.ParseInt(item, 10, 64)
  3624. id := int64(itemsss)
  3625. idss = append(idss, id)
  3626. }
  3627. //批量获取
  3628. list, _ := service.GetBatchDrugList(idss)
  3629. //获取药品剂型
  3630. drugs, _ := service.GetDrugDosageForm(orgId)
  3631. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3632. var doctor_name string
  3633. var doctor_code string
  3634. doctor_name = roles.UserName
  3635. doctor_code = "1001"
  3636. var isSuccess bool = true
  3637. timeLayout := "20060102"
  3638. //这里就可以查看开始和结束了
  3639. for _, item := range list {
  3640. recordDate := time.Unix(item.RecordDate, 0).Format(timeLayout)
  3641. detail := &models.DrugDetail{
  3642. MedicalInsuranceNumber: item.SocialSecurityDirectoryCode,
  3643. Code: item.Code,
  3644. DrugName: item.DrugName,
  3645. DrugSpec: item.DrugSpec,
  3646. DrugDosageName: item.DrugDosageName,
  3647. ManufacturerName: item.ManufacturerName,
  3648. MinUnit: item.MinUnit,
  3649. RetailPrice: item.RetailPrice,
  3650. LastPrice: item.LastPrice,
  3651. LimitRemark: item.LimitRemark,
  3652. PrescriptionMark: strconv.FormatInt(item.PrescriptionMark, 10),
  3653. RecordDate: recordDate,
  3654. }
  3655. for _, it := range drugs {
  3656. if item.DrugDosageForm == it.Value {
  3657. detail.DrugDosageName = it.Code
  3658. }
  3659. }
  3660. result := service.SzybML008(doctor_name, doctor_code, miConfig.Code, detail)
  3661. var dat map[string]interface{}
  3662. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3663. //fmt.Println(dat)
  3664. } else {
  3665. //fmt.Println(err)
  3666. }
  3667. userJSONBytes, _ := json.Marshal(dat)
  3668. var res Result
  3669. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3670. utils.ErrorLog("解析失败:%v", err)
  3671. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3672. c.ServeSuccessJSON(map[string]interface{}{
  3673. "failed_code": -10,
  3674. "msg": res.Transreturnmessage,
  3675. })
  3676. return
  3677. }
  3678. if res.Transreturncode == "00000000" {
  3679. //更新备案状态
  3680. _, err := service.UpdateBaseDrugById(item.ID)
  3681. fmt.Println("err", err)
  3682. c.ServeSuccessJSON(map[string]interface{}{
  3683. "failed_code": -10,
  3684. "msg": res.Transreturnmessage,
  3685. })
  3686. return
  3687. }
  3688. fmt.Println(isSuccess)
  3689. c.ServeSuccessJSON(map[string]interface{}{
  3690. "failed_code": -10,
  3691. "msg": res.Transreturnmessage,
  3692. })
  3693. return
  3694. }
  3695. }
  3696. func (c *SZHisApiController) GetTreatmentProject() {
  3697. adminUserInfo := c.GetAdminUserInfo()
  3698. orgId := adminUserInfo.CurrentOrgId
  3699. ids := c.GetString("ids")
  3700. stringarr := strings.Split(ids, ",")
  3701. idss := make([]int64, 0)
  3702. admin_user_id, _ := c.GetInt64("admin_user_id")
  3703. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  3704. for _, item := range stringarr {
  3705. itemsss, _ := strconv.ParseInt(item, 10, 64)
  3706. id := int64(itemsss)
  3707. idss = append(idss, id)
  3708. }
  3709. //获取项目库数据
  3710. list, _ := service.GetBathchMyPorjecgList(idss)
  3711. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3712. var doctor_name string
  3713. var doctor_code string
  3714. doctor_name = roles.UserName
  3715. doctor_code = "1001"
  3716. var isSuccess bool = true
  3717. for _, item := range list {
  3718. detail := &models.MyHisProject{
  3719. MedicalCode: item.MedicalCode, //社保目录
  3720. ProjectName: item.ProjectName,
  3721. Price: item.Price,
  3722. Category: item.Category,
  3723. Remark: item.Remark,
  3724. SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  3725. SpecailProject: item.SpecailProject,
  3726. RecordDate: item.RecordDate,
  3727. }
  3728. result := service.SzybML009(doctor_name, doctor_code, miConfig.Code, detail)
  3729. var dat map[string]interface{}
  3730. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3731. fmt.Println(dat)
  3732. } else {
  3733. fmt.Println(err)
  3734. }
  3735. userJSONBytes, _ := json.Marshal(dat)
  3736. var res Result
  3737. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3738. utils.ErrorLog("解析失败:%v", err)
  3739. c.ServeSuccessJSON(map[string]interface{}{
  3740. "failed_code": -10,
  3741. "msg": res.Transreturnmessage,
  3742. })
  3743. return
  3744. }
  3745. if res.Transreturncode == "00000000" {
  3746. //备案成功返回状态值
  3747. _, err := service.UpdateProjectById(item.ID)
  3748. fmt.Println("err", err)
  3749. } else {
  3750. isSuccess = false
  3751. //失败
  3752. c.ServeSuccessJSON(map[string]interface{}{
  3753. "failed_code": -10,
  3754. "msg": res.Transreturnmessage,
  3755. })
  3756. return
  3757. }
  3758. fmt.Println(isSuccess)
  3759. c.ServeSuccessJSON(map[string]interface{}{
  3760. "failed_code": -10,
  3761. "msg": res.Transreturnmessage,
  3762. })
  3763. return
  3764. }
  3765. }
  3766. func (c *SZHisApiController) GetRevocation() {
  3767. adminUserInfo := c.GetAdminUserInfo()
  3768. orgId := adminUserInfo.CurrentOrgId
  3769. id, _ := c.GetInt64("id")
  3770. admin_user_id, _ := c.GetInt64("admin_user_id")
  3771. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  3772. //用来区分是药品的撤销还是耗材的撤销 1.药品 2.诊疗项目 3.材料 5.辅助器具项目
  3773. is_mark, _ := c.GetInt64("is_mark")
  3774. type_id, _ := c.GetInt64("type_id")
  3775. if type_id == 1 {
  3776. //撤销
  3777. if is_mark == 1 {
  3778. //获取药品库数据
  3779. list, _ := service.GetDrugListByDetail(orgId, id)
  3780. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3781. var doctor_name string
  3782. var doctor_code string
  3783. doctor_name = roles.UserName
  3784. doctor_code = "1001"
  3785. var pagesize int = 50
  3786. var start int = 1
  3787. var stop int
  3788. var pagecount int
  3789. var curpage int
  3790. var isSuccess bool = true
  3791. //总页数,向上取整,注意除之前要先转换类型为float64
  3792. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  3793. for curpage = 1; curpage <= pagecount; curpage++ {
  3794. if curpage == 1 {
  3795. start = 1
  3796. } else {
  3797. start = (curpage-1)*pagesize + 1
  3798. }
  3799. stop = curpage * pagesize
  3800. if stop > len(list) {
  3801. stop = len(list)
  3802. }
  3803. //这里就可以查看开始和结束了
  3804. fmt.Println(list[start-1 : stop])
  3805. var customs []*models.DrugDetail
  3806. for _, item := range list {
  3807. detail := &models.DrugDetail{
  3808. SocialSecurityDirectoryCode: item.MedicalInsuranceNumber, //社保目录
  3809. Code: item.Code, //协议机构内部目录编码
  3810. DrugName: item.DrugName, //协议机构内部目录名称
  3811. DrugSpec: item.DrugSpec,
  3812. ManufacturerName: item.ManufacturerName,
  3813. MinUnit: item.MinUnit,
  3814. RetailPrice: item.RetailPrice, //协议机构内部项目收费价格
  3815. LimitRemark: item.LimitRemark,
  3816. MedicalInsuranceNumber: item.MedicalInsuranceNumber, //社保目录
  3817. }
  3818. customs = append(customs, detail)
  3819. }
  3820. result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs, type_id)
  3821. fmt.Println("reuslt", result)
  3822. var dat map[string]interface{}
  3823. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3824. fmt.Println(dat)
  3825. } else {
  3826. fmt.Println(err)
  3827. }
  3828. userJSONBytes, _ := json.Marshal(dat)
  3829. var res Result
  3830. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3831. utils.ErrorLog("解析失败:%v", err)
  3832. c.ServeSuccessJSON(map[string]interface{}{
  3833. "failed_code": -10,
  3834. "msg": res.Transreturnmessage,
  3835. })
  3836. return
  3837. }
  3838. if res.Transreturncode == "00000000" {
  3839. //撤销成功
  3840. _, err := service.UpdateDrugByIdDetail(id)
  3841. fmt.Println("err", err)
  3842. } else {
  3843. isSuccess = false
  3844. //失败
  3845. c.ServeSuccessJSON(map[string]interface{}{
  3846. "failed_code": -10,
  3847. "msg": res.Transreturnmessage,
  3848. })
  3849. return
  3850. }
  3851. fmt.Println(isSuccess)
  3852. c.ServeSuccessJSON(map[string]interface{}{
  3853. "failed_code": -10,
  3854. "msg": res.Transreturnmessage,
  3855. })
  3856. return
  3857. }
  3858. }
  3859. // 备案
  3860. if is_mark == 0 {
  3861. adminUserInfo := c.GetAdminUserInfo()
  3862. orgId := adminUserInfo.CurrentOrgId
  3863. //获取药品库数据
  3864. list, _ := service.GetDrugListByDetail(orgId, id)
  3865. //获取药品剂型
  3866. drugs, _ := service.GetDrugDosageForm(orgId)
  3867. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3868. var doctor_name string
  3869. var doctor_code string
  3870. doctor_name = roles.UserName
  3871. doctor_code = "1001"
  3872. var isSuccess bool = true
  3873. //这里就可以查看开始和结束了
  3874. for _, item := range list {
  3875. detail := &models.DrugDetail{
  3876. MedicalInsuranceNumber: item.MedicalInsuranceNumber,
  3877. SocialSecurityDirectoryCode: item.MedicalInsuranceNumber,
  3878. Code: item.Code,
  3879. DrugName: item.DrugName,
  3880. DrugSpec: item.DrugSpec,
  3881. DrugDosageName: item.DrugDosageName,
  3882. ManufacturerName: item.ManufacturerName,
  3883. MinUnit: item.MinUnit,
  3884. RetailPrice: item.RetailPrice,
  3885. LastPrice: item.LastPrice,
  3886. LimitRemark: item.LimitRemark,
  3887. }
  3888. for _, it := range drugs {
  3889. if item.DrugDosageForm == it.Value {
  3890. detail.DrugDosageName = it.Code
  3891. }
  3892. }
  3893. result := service.SzybML008(doctor_name, doctor_code, miConfig.Code, detail)
  3894. var dat map[string]interface{}
  3895. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3896. //fmt.Println(dat)
  3897. } else {
  3898. //fmt.Println(err)
  3899. }
  3900. userJSONBytes, _ := json.Marshal(dat)
  3901. var res Result
  3902. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3903. utils.ErrorLog("解析失败:%v", err)
  3904. c.ServeSuccessJSON(map[string]interface{}{
  3905. "failed_code": -10,
  3906. "msg": res.Transreturnmessage,
  3907. })
  3908. return
  3909. }
  3910. if res.Transreturncode == "00000000" {
  3911. //更新备案状态
  3912. _, err := service.UpdateBaseDrugById(item.ID)
  3913. fmt.Println("err", err)
  3914. }
  3915. fmt.Println(isSuccess)
  3916. c.ServeSuccessJSON(map[string]interface{}{
  3917. "failed_code": -10,
  3918. "msg": res.Transreturnmessage,
  3919. })
  3920. return
  3921. }
  3922. }
  3923. }
  3924. if type_id == 2 {
  3925. //撤销
  3926. if is_mark == 1 {
  3927. //获取药品库数据
  3928. list, _ := service.GetMyPorjecgListDetail(orgId, id)
  3929. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3930. var doctor_name string
  3931. var doctor_code string
  3932. doctor_name = roles.UserName
  3933. doctor_code = "1001"
  3934. var pagesize int = 50
  3935. var start int = 1
  3936. var stop int
  3937. var pagecount int
  3938. var curpage int
  3939. var isSuccess bool = true
  3940. //总页数,向上取整,注意除之前要先转换类型为float64
  3941. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  3942. for curpage = 1; curpage <= pagecount; curpage++ {
  3943. if curpage == 1 {
  3944. start = 1
  3945. } else {
  3946. start = (curpage-1)*pagesize + 1
  3947. }
  3948. stop = curpage * pagesize
  3949. if stop > len(list) {
  3950. stop = len(list)
  3951. }
  3952. //这里就可以查看开始和结束了
  3953. fmt.Println(list[start-1 : stop])
  3954. var customs []*models.DrugDetail
  3955. for _, item := range list {
  3956. detail := &models.DrugDetail{
  3957. SocialSecurityDirectoryCode: item.MedicalCode,
  3958. }
  3959. customs = append(customs, detail)
  3960. }
  3961. result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs, type_id)
  3962. fmt.Println("reuslt", result)
  3963. var dat map[string]interface{}
  3964. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3965. fmt.Println(dat)
  3966. } else {
  3967. fmt.Println(err)
  3968. }
  3969. userJSONBytes, _ := json.Marshal(dat)
  3970. var res Result
  3971. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3972. utils.ErrorLog("解析失败:%v", err)
  3973. c.ServeSuccessJSON(map[string]interface{}{
  3974. "failed_code": -10,
  3975. "msg": res.Transreturnmessage,
  3976. })
  3977. return
  3978. }
  3979. if res.Transreturncode == "00000000" {
  3980. //核销成功返回状态码
  3981. _, err := service.UpdateMyProjectById(id)
  3982. fmt.Println("err", err)
  3983. } else {
  3984. isSuccess = false
  3985. //失败
  3986. c.ServeSuccessJSON(map[string]interface{}{
  3987. "failed_code": -10,
  3988. "msg": res.Transreturnmessage,
  3989. })
  3990. return
  3991. }
  3992. fmt.Println(isSuccess)
  3993. c.ServeSuccessJSON(map[string]interface{}{
  3994. "failed_code": -10,
  3995. "msg": res.Transreturnmessage,
  3996. })
  3997. return
  3998. }
  3999. }
  4000. //备案
  4001. if is_mark == 0 {
  4002. adminUserInfo := c.GetAdminUserInfo()
  4003. orgId := adminUserInfo.CurrentOrgId
  4004. //获取药品库数据
  4005. list, _ := service.GetMyPorjecgListDetail(orgId, id)
  4006. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4007. var doctor_name string
  4008. var doctor_code string
  4009. doctor_name = roles.UserName
  4010. doctor_code = "1001"
  4011. var isSuccess bool = true
  4012. for _, item := range list {
  4013. detail := &models.MyHisProject{
  4014. MedicalCode: item.MedicalCode, //社保目录
  4015. ProjectName: item.ProjectName,
  4016. Price: item.Price,
  4017. Category: item.Category,
  4018. Remark: item.Remark,
  4019. }
  4020. result := service.SzybML009(doctor_name, doctor_code, miConfig.Code, detail)
  4021. fmt.Println("reuslt", result)
  4022. var dat map[string]interface{}
  4023. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4024. fmt.Println(dat)
  4025. } else {
  4026. fmt.Println(err)
  4027. }
  4028. userJSONBytes, _ := json.Marshal(dat)
  4029. var res Result
  4030. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4031. utils.ErrorLog("解析失败:%v", err)
  4032. c.ServeSuccessJSON(map[string]interface{}{
  4033. "failed_code": -10,
  4034. "msg": res.Transreturnmessage,
  4035. })
  4036. return
  4037. }
  4038. if res.Transreturncode == "00000000" {
  4039. //备案成功返回状态值
  4040. _, err := service.UpdateProjectById(item.ID)
  4041. fmt.Println("err", err)
  4042. } else {
  4043. isSuccess = false
  4044. //失败
  4045. c.ServeSuccessJSON(map[string]interface{}{
  4046. "failed_code": -10,
  4047. "msg": res.Transreturnmessage,
  4048. })
  4049. return
  4050. }
  4051. fmt.Println(isSuccess)
  4052. c.ServeSuccessJSON(map[string]interface{}{
  4053. "failed_code": -10,
  4054. "msg": res.Transreturnmessage,
  4055. })
  4056. return
  4057. }
  4058. }
  4059. }
  4060. if type_id == 3 {
  4061. //撤销
  4062. if is_mark == 1 {
  4063. //获取药品库数据
  4064. list, _ := service.GetGoodListByDetail(orgId, id)
  4065. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4066. var doctor_name string
  4067. var doctor_code string
  4068. doctor_name = roles.UserName
  4069. doctor_code = "1001"
  4070. var pagesize int = 50
  4071. var start int = 1
  4072. var stop int
  4073. var pagecount int
  4074. var curpage int
  4075. var isSuccess bool = true
  4076. //总页数,向上取整,注意除之前要先转换类型为float64
  4077. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  4078. for curpage = 1; curpage <= pagecount; curpage++ {
  4079. if curpage == 1 {
  4080. start = 1
  4081. } else {
  4082. start = (curpage-1)*pagesize + 1
  4083. }
  4084. stop = curpage * pagesize
  4085. if stop > len(list) {
  4086. stop = len(list)
  4087. }
  4088. //这里就可以查看开始和结束了
  4089. fmt.Println(list[start-1 : stop])
  4090. var customs []*models.DrugDetail
  4091. for _, item := range list {
  4092. fmt.Println("医疗机构编码", item.SocialSecurityDirectoryCode)
  4093. detail := &models.DrugDetail{
  4094. SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  4095. ManufacturerName: item.ManufacturerName,
  4096. }
  4097. customs = append(customs, detail)
  4098. }
  4099. result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs, type_id)
  4100. fmt.Println("reuslt", result)
  4101. var dat map[string]interface{}
  4102. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4103. fmt.Println(dat)
  4104. } else {
  4105. fmt.Println(err)
  4106. }
  4107. userJSONBytes, _ := json.Marshal(dat)
  4108. var res Result
  4109. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4110. utils.ErrorLog("解析失败:%v", err)
  4111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4112. return
  4113. }
  4114. if res.Transreturncode == "00000000" {
  4115. //撤销成功后改变状态
  4116. _, err := service.UpdateGoodInfoById(id)
  4117. fmt.Println("err", err)
  4118. } else {
  4119. isSuccess = false
  4120. //失败
  4121. c.ServeSuccessJSON(map[string]interface{}{
  4122. "failed_code": -10,
  4123. "msg": res.Transreturnmessage,
  4124. })
  4125. return
  4126. }
  4127. fmt.Println(isSuccess)
  4128. c.ServeSuccessJSON(map[string]interface{}{
  4129. "failed_code": -10,
  4130. "msg": res.Transreturnmessage,
  4131. })
  4132. return
  4133. }
  4134. }
  4135. //备案
  4136. if is_mark == 0 {
  4137. adminUserInfo := c.GetAdminUserInfo()
  4138. orgId := adminUserInfo.CurrentOrgId
  4139. //获取所有耗材信息
  4140. list, _ := service.GetGoodListByDetail(orgId, id)
  4141. //获取单位
  4142. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4143. var doctor_name string
  4144. var doctor_code string
  4145. doctor_name = roles.UserName
  4146. doctor_code = "1001"
  4147. var isSuccess bool = true
  4148. for _, item := range list {
  4149. detail := &models.XtGoodInformation{
  4150. GoodName: item.GoodName,
  4151. SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  4152. ManufacturerName: item.ManufacturerName,
  4153. ProductionType: item.ProductionType,
  4154. SpecialMedical: item.SpecialMedical,
  4155. BuyPrice: item.BuyPrice,
  4156. SellPrice: item.SellPrice,
  4157. Remark: item.Remark,
  4158. SpecificationName: item.SpecificationName,
  4159. }
  4160. result := service.SzybYML007(doctor_name, doctor_code, miConfig.Code, detail)
  4161. fmt.Println("reuslt", result)
  4162. var dat map[string]interface{}
  4163. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4164. fmt.Println(dat)
  4165. } else {
  4166. fmt.Println(err)
  4167. }
  4168. userJSONBytes, _ := json.Marshal(dat)
  4169. var res Result
  4170. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4171. utils.ErrorLog("解析失败:%v", err)
  4172. c.ServeSuccessJSON(map[string]interface{}{
  4173. "failed_code": -10,
  4174. "msg": res.Transreturnmessage,
  4175. })
  4176. return
  4177. }
  4178. if res.Transreturncode == "00000000" {
  4179. //备案成功返回状态
  4180. _, err := service.UpdateGoodInformaitonByDetail(item.ID)
  4181. fmt.Println("err", err)
  4182. } else {
  4183. isSuccess = false
  4184. //失败
  4185. c.ServeSuccessJSON(map[string]interface{}{
  4186. "failed_code": -10,
  4187. "msg": res.Transreturnmessage,
  4188. })
  4189. return
  4190. }
  4191. fmt.Println(isSuccess)
  4192. c.ServeSuccessJSON(map[string]interface{}{
  4193. "failed_code": -10,
  4194. "msg": res.Transreturnmessage,
  4195. })
  4196. return
  4197. }
  4198. }
  4199. }
  4200. }
  4201. func (c *SZHisApiController) GetDoctorList() {
  4202. adminUserInfo := c.GetAdminUserInfo()
  4203. orgid := adminUserInfo.CurrentOrgId
  4204. ids := c.GetString("ids")
  4205. admin_user_id, _ := c.GetInt64("admin_user_id")
  4206. roles, _ := service.GetAdminUserInfoByID(orgid, admin_user_id)
  4207. stringarr := strings.Split(ids, ",")
  4208. idss := make([]int64, 0)
  4209. for _, item := range stringarr {
  4210. itemsss, _ := strconv.ParseInt(item, 10, 64)
  4211. id := int64(itemsss)
  4212. idss = append(idss, id)
  4213. }
  4214. //获取所有医生护士信息
  4215. //list, _ := service.GetDoctorList(orgid)
  4216. //批量查询
  4217. list, _ := service.GetBatchDoctorList(idss)
  4218. //获取所有角色名称
  4219. roleList, _ := service.GetRoleList(orgid)
  4220. miConfig, _ := service.FindMedicalInsuranceInfo(orgid)
  4221. for _, item := range list {
  4222. for _, it := range roleList {
  4223. if item.RoleId == it.ID {
  4224. item.Name = it.RoleName
  4225. }
  4226. }
  4227. }
  4228. var doctor_name string
  4229. var doctor_code string
  4230. doctor_name = roles.UserName
  4231. doctor_code = "1001"
  4232. var isSuccess bool = true
  4233. for _, item := range list {
  4234. detail := &models.DocDetail{
  4235. UserName: item.UserName, //医护姓名
  4236. RoleId: item.Name, //医护人员类别
  4237. Sex: strconv.FormatInt(item.Sex, 10), //性别
  4238. CardType: strconv.FormatInt(item.CardType, 10), //证件类型
  4239. IdCard: item.IdCard, //证件号码
  4240. Phone: item.Mobile, //联系电话
  4241. WorkMajorName: item.WorkMajorName, // 现从事专业名称
  4242. Nation: "1", //民族
  4243. BirthDay: 20201022, // 出生日期
  4244. WorkTime: 20201022, //参加工作日期
  4245. Education: strconv.FormatInt(item.Education, 10), //学历
  4246. StudyMajorName: item.StudyMajorName, //所学的专业名称
  4247. CertificateCode: item.MedicalCode, //医(药)师执业证书编码
  4248. MedicalCode: item.DoctorCode, //医(药)师资格证编码
  4249. MedicalRangeCode: strconv.FormatInt(item.DoctorRangeCode, 10), //医师执业范围代码
  4250. MedicalLevel: strconv.FormatInt(item.DoctorLevel, 10), //医生执业资格证中的医师级别
  4251. TypeJob: strconv.FormatInt(item.DoctorTypeJob, 10), //医生执业资格证中的执业类别
  4252. DoctorNumber: item.DoctorNumber, //医保医师编号
  4253. Licensing: strconv.FormatInt(item.Licensing, 10), //多点执业标志
  4254. DoctorServiceStatus: "", //医师医保服务资格状态
  4255. MonitoringLevel: "", //监控等级
  4256. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  4257. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  4258. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  4259. PharmacistType: "", //药师类别
  4260. PharmacistPracticeCategory: "", //药师执业类别
  4261. PharmacistsLicensing: "", //药师执业范围
  4262. PharmacistRegistrationNumber: "", //执业药师注册证编号
  4263. OfficeCode: "", //科室编码
  4264. JobNumber: item.JobNumber, //工号
  4265. PostName: "", //职位名称
  4266. TechnicalJobLevelCode: "", //专业技术职务级别编码
  4267. IsActive: strconv.FormatInt(item.IsActive, 10), //在职与否
  4268. PrescriptionQualificationIdentification: strconv.FormatInt(item.PrescriptionQualificationIdentification, 10), //处方资格标识
  4269. IdentificationOutpatients: strconv.FormatInt(item.IdentificationOutpatients, 10), //门诊大病医师标识
  4270. OutpatientIllnessCategory: item.OutpatientIllnessCategory, //门诊大病类别
  4271. StartTime: 20201010, //开始日期
  4272. StaffCode: "", //医护人员编码
  4273. EndTime: 0, // 结束日期
  4274. }
  4275. result := service.SzybYS001(doctor_name, doctor_code, miConfig.Code, detail)
  4276. fmt.Println("reuslt", result)
  4277. var dat map[string]interface{}
  4278. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4279. fmt.Println(dat)
  4280. } else {
  4281. fmt.Println(err)
  4282. }
  4283. userJSONBytes, _ := json.Marshal(dat)
  4284. var res Result
  4285. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4286. utils.ErrorLog("解析失败:%v", err)
  4287. c.ServeSuccessJSON(map[string]interface{}{
  4288. "failed_code": -10,
  4289. "msg": res.Transreturnmessage,
  4290. })
  4291. return
  4292. }
  4293. if res.Transreturncode == "00000000" {
  4294. //批量插入数据
  4295. _, err := service.UpdateAdminUserRoleById(item.AdminUserId, orgid)
  4296. fmt.Println("err", err)
  4297. } else {
  4298. isSuccess = false
  4299. //失败
  4300. c.ServeSuccessJSON(map[string]interface{}{
  4301. "failed_code": -10,
  4302. "msg": res.Transreturnmessage,
  4303. })
  4304. return
  4305. }
  4306. fmt.Println(isSuccess)
  4307. c.ServeSuccessJSON(map[string]interface{}{
  4308. "failed_code": -10,
  4309. "msg": res.Transreturnmessage,
  4310. })
  4311. return
  4312. }
  4313. }
  4314. func (c *SZHisApiController) GetMedicalList() {
  4315. adminUserInfo := c.GetAdminUserInfo()
  4316. orgId := adminUserInfo.CurrentOrgId
  4317. id, _ := c.GetInt64("id")
  4318. is_mark, _ := c.GetInt64("is_mark")
  4319. admin_user_id, _ := c.GetInt64("admin_user_id")
  4320. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  4321. //去登记
  4322. if is_mark == 0 {
  4323. list, _ := service.GetDoctorListByDetail(orgId, id)
  4324. //获取所有角色名称
  4325. roleList, _ := service.GetRoleList(orgId)
  4326. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4327. for _, item := range list {
  4328. for _, it := range roleList {
  4329. if item.RoleId == it.ID {
  4330. item.Name = it.RoleName
  4331. }
  4332. }
  4333. }
  4334. var doctor_name string
  4335. var doctor_code string
  4336. doctor_name = roles.UserName
  4337. doctor_code = "1001"
  4338. var isSuccess bool = true
  4339. for _, item := range list {
  4340. detail := &models.DocDetail{
  4341. UserName: item.UserName, //医护姓名
  4342. RoleId: item.Name, //医护人员类别
  4343. Sex: strconv.FormatInt(item.Sex, 10), //性别
  4344. CardType: strconv.FormatInt(item.CardType, 10), //证件类型
  4345. IdCard: item.IdCard, //证件号码
  4346. Phone: item.Mobile, //联系电话
  4347. WorkMajorName: item.WorkMajorName, // 现从事专业名称
  4348. Nation: item.Nation, //民族
  4349. BirthDay: 20201022, // 出生日期
  4350. WorkTime: 20201022, //参加工作日期
  4351. Education: strconv.FormatInt(item.Education, 10), //学历
  4352. StudyMajorName: item.StudyMajorName, //所学的专业名称
  4353. CertificateCode: item.MedicalCode, //医(药)师执业证书编码
  4354. MedicalCode: item.DoctorCode, //医(药)师资格证编码
  4355. MedicalRangeCode: strconv.FormatInt(item.DoctorRangeCode, 10), //医师执业范围代码
  4356. MedicalLevel: strconv.FormatInt(item.DoctorLevel, 10), //医生执业资格证中的医师级别
  4357. TypeJob: strconv.FormatInt(item.DoctorTypeJob, 10), //医生执业资格证中的执业类别
  4358. DoctorNumber: item.DoctorNumber, //医保医师编号
  4359. Licensing: strconv.FormatInt(item.Licensing, 10), //多点执业标志
  4360. DoctorServiceStatus: "", //医师医保服务资格状态
  4361. MonitoringLevel: "", //监控等级
  4362. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  4363. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  4364. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  4365. PharmacistType: "", //药师类别
  4366. PharmacistPracticeCategory: "", //药师执业类别
  4367. PharmacistsLicensing: "", //药师执业范围
  4368. PharmacistRegistrationNumber: "", //执业药师注册证编号
  4369. OfficeCode: "", //科室编码
  4370. JobNumber: item.JobNumber, //工号
  4371. PostName: "", //职位名称
  4372. TechnicalJobLevelCode: "", //专业技术职务级别编码
  4373. IsActive: strconv.FormatInt(item.IsActive, 10), //在职与否
  4374. PrescriptionQualificationIdentification: strconv.FormatInt(item.PrescriptionQualificationIdentification, 10), //处方资格标识
  4375. IdentificationOutpatients: strconv.FormatInt(item.IdentificationOutpatients, 10), //门诊大病医师标识
  4376. OutpatientIllnessCategory: item.OutpatientIllnessCategory, //门诊大病类别
  4377. StartTime: 20201010, //开始日期
  4378. StaffCode: "", //医护人员编码
  4379. EndTime: 0, // 结束日期
  4380. }
  4381. result := service.SzybYS001(doctor_name, doctor_code, miConfig.Code, detail)
  4382. var dat map[string]interface{}
  4383. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4384. fmt.Println(dat)
  4385. } else {
  4386. fmt.Println(err)
  4387. }
  4388. userJSONBytes, _ := json.Marshal(dat)
  4389. var res Result
  4390. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4391. utils.ErrorLog("解析失败:%v", err)
  4392. c.ServeSuccessJSON(map[string]interface{}{
  4393. "failed_code": -10,
  4394. "msg": res.Transreturnmessage,
  4395. })
  4396. return
  4397. }
  4398. if res.Transreturncode == "00000000" {
  4399. //登记成功
  4400. service.UpdateAdminUserRoleById(item.ID, orgId)
  4401. } else {
  4402. isSuccess = false
  4403. //失败
  4404. c.ServeSuccessJSON(map[string]interface{}{
  4405. "failed_code": -10,
  4406. "msg": res.Transreturnmessage,
  4407. })
  4408. return
  4409. }
  4410. fmt.Println(isSuccess)
  4411. c.ServeSuccessJSON(map[string]interface{}{
  4412. "failed_code": -10,
  4413. "msg": res.Transreturnmessage,
  4414. })
  4415. return
  4416. }
  4417. }
  4418. //去撤销
  4419. if is_mark == 1 {
  4420. //获取所有医生护士信息
  4421. list, _ := service.GetDoctorListByDetail(orgId, id)
  4422. //获取所有角色名称
  4423. roleList, _ := service.GetRoleList(orgId)
  4424. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4425. for _, item := range list {
  4426. for _, it := range roleList {
  4427. if item.RoleId == it.ID {
  4428. item.Name = it.RoleName
  4429. }
  4430. }
  4431. }
  4432. var doctor_name string
  4433. var doctor_code string
  4434. doctor_name = "黄亦轩"
  4435. doctor_code = "1001"
  4436. var isSuccess bool = true
  4437. for _, item := range list {
  4438. detail := &models.DocDetail{
  4439. UserName: item.UserName, //医护姓名
  4440. RoleId: item.Name, //医护人员类别
  4441. Sex: strconv.FormatInt(item.Sex, 10), //性别
  4442. CardType: strconv.FormatInt(item.CardType, 10), //证件类型
  4443. IdCard: item.IdCard, //证件号码
  4444. Phone: item.Mobile, //联系电话
  4445. WorkMajorName: item.WorkMajorName, // 现从事专业名称
  4446. Nation: item.Nation, //民族
  4447. BirthDay: 20201022, // 出生日期
  4448. WorkTime: 20201022, //参加工作日期
  4449. Education: strconv.FormatInt(item.Education, 10), //学历
  4450. StudyMajorName: item.StudyMajorName, //所学的专业名称
  4451. CertificateCode: item.MedicalCode, //医(药)师执业证书编码
  4452. MedicalCode: item.DoctorCode, //医(药)师资格证编码
  4453. MedicalRangeCode: strconv.FormatInt(item.DoctorRangeCode, 10), //医师执业范围代码
  4454. MedicalLevel: strconv.FormatInt(item.DoctorLevel, 10), //医生执业资格证中的医师级别
  4455. TypeJob: strconv.FormatInt(item.DoctorTypeJob, 10), //医生执业资格证中的执业类别
  4456. DoctorNumber: item.DoctorNumber, //医保医师编号
  4457. Licensing: strconv.FormatInt(item.Licensing, 10), //多点执业标志
  4458. DoctorServiceStatus: "", //医师医保服务资格状态
  4459. MonitoringLevel: "", //监控等级
  4460. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  4461. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  4462. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  4463. PharmacistType: "", //药师类别
  4464. PharmacistPracticeCategory: "", //药师执业类别
  4465. PharmacistsLicensing: "", //药师执业范围
  4466. PharmacistRegistrationNumber: "", //执业药师注册证编号
  4467. OfficeCode: "", //科室编码
  4468. JobNumber: item.JobNumber, //工号
  4469. PostName: "", //职位名称
  4470. TechnicalJobLevelCode: "", //专业技术职务级别编码
  4471. IsActive: strconv.FormatInt(item.IsActive, 10), //在职与否
  4472. PrescriptionQualificationIdentification: strconv.FormatInt(item.PrescriptionQualificationIdentification, 10), //处方资格标识
  4473. IdentificationOutpatients: strconv.FormatInt(item.IdentificationOutpatients, 10), //门诊大病医师标识
  4474. OutpatientIllnessCategory: item.OutpatientIllnessCategory, //门诊大病类别
  4475. StartTime: 20201010, //开始日期
  4476. StaffCode: "", //医护人员编码
  4477. EndTime: 0, // 结束日期
  4478. }
  4479. result := service.SzybYS002(doctor_name, doctor_code, miConfig.Code, detail)
  4480. var dat map[string]interface{}
  4481. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4482. fmt.Println(dat)
  4483. } else {
  4484. fmt.Println(err)
  4485. }
  4486. userJSONBytes, _ := json.Marshal(dat)
  4487. var res Result
  4488. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4489. utils.ErrorLog("解析失败:%v", err)
  4490. c.ServeSuccessJSON(map[string]interface{}{
  4491. "failed_code": -10,
  4492. "msg": res.Transreturnmessage,
  4493. })
  4494. return
  4495. }
  4496. if res.Transreturncode == "00000000" {
  4497. //去撤销
  4498. service.UpdateAdminUserRoleById(item.ID, orgId)
  4499. } else {
  4500. isSuccess = false
  4501. //失败
  4502. c.ServeSuccessJSON(map[string]interface{}{
  4503. "failed_code": -10,
  4504. "msg": res.Transreturnmessage,
  4505. })
  4506. return
  4507. }
  4508. fmt.Println(isSuccess)
  4509. c.ServeSuccessJSON(map[string]interface{}{
  4510. "failed_code": -10,
  4511. "msg": res.Transreturnmessage,
  4512. })
  4513. return
  4514. }
  4515. }
  4516. }
  4517. func (c *SZHisApiController) GetUpdateMedicalList() {
  4518. adminUserInfo := c.GetAdminUserInfo()
  4519. orgId := adminUserInfo.CurrentOrgId
  4520. //获取所有医生护士信息
  4521. list, _ := service.GetDoctorList(orgId)
  4522. //获取所有角色名称
  4523. roleList, _ := service.GetRoleList(orgId)
  4524. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4525. for _, item := range list {
  4526. for _, it := range roleList {
  4527. if item.RoleId == it.ID {
  4528. item.Name = it.RoleName
  4529. }
  4530. }
  4531. }
  4532. var doctor_name string
  4533. var doctor_code string
  4534. doctor_name = "黄亦轩"
  4535. doctor_code = "1001"
  4536. var pagesize int = 50
  4537. var start int = 1
  4538. var stop int
  4539. var pagecount int
  4540. var curpage int
  4541. var isSuccess bool = true
  4542. //总页数,向上取整,注意除之前要先转换类型为float64
  4543. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  4544. var ress []*Result
  4545. for curpage = 1; curpage <= pagecount; curpage++ {
  4546. if curpage == 1 {
  4547. start = 1
  4548. } else {
  4549. start = (curpage-1)*pagesize + 1
  4550. }
  4551. stop = curpage * pagesize
  4552. if stop > len(list) {
  4553. stop = len(list)
  4554. }
  4555. //这里就可以查看开始和结束了
  4556. fmt.Println(list[start-1 : stop])
  4557. var customs []*models.DocDetail
  4558. for _, item := range list {
  4559. detail := &models.DocDetail{
  4560. StaffCode: "", //医护人员编码
  4561. UserName: item.UserName, //医护人员姓名
  4562. RoleId: item.Name, //医护人员类别
  4563. Sex: "", //性别
  4564. CardType: "", //证件类型
  4565. IdCard: "", //证件号码
  4566. Phone: "", //联系电话
  4567. WorkMajorName: "", //现从事专业名称
  4568. Nation: "", //民族
  4569. BirthDay: 20201022, //出生日期
  4570. WorkTime: 20201022, //参加工作日期
  4571. Education: "", //学历
  4572. StudyMajorName: "", //所学的专业名称
  4573. CertificateCode: "", //证书编码
  4574. MedicalCode: "", //医师资格编码
  4575. MedicalRangeCode: "", //医师执业范围代码
  4576. MedicalLevel: "", //医生级别
  4577. TypeJob: "", //职业类别
  4578. DoctorNumber: "", //医师编号
  4579. Licensing: "", //职业标志
  4580. DoctorServiceStatus: "", //医师医保服务资格状态
  4581. MonitoringLevel: "", //监控等级
  4582. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  4583. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  4584. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  4585. PharmacistType: "", //药师类别
  4586. PharmacistPracticeCategory: "", //药师执业类别
  4587. PharmacistsLicensing: "", //药师执业范围
  4588. PharmacistRegistrationNumber: "", //执业药师注册证编号
  4589. OfficeCode: "", //科室编码
  4590. JobNumber: "", //工号
  4591. PostName: "", //职位名称
  4592. TechnicalJobLevelCode: "", //专业技术职务级别编码
  4593. IsActive: "", //在职与否
  4594. PrescriptionQualificationIdentification: "", //处方资格标识
  4595. IdentificationOutpatients: "", //门诊大病医师标识
  4596. OutpatientIllnessCategory: "", //门诊大病类别
  4597. StartTime: 20201022, //开始日期
  4598. EndTime: 20201022,
  4599. }
  4600. customs = append(customs, detail)
  4601. }
  4602. result := service.SzybYS003(doctor_name, doctor_code, miConfig.Code, customs)
  4603. var dat map[string]interface{}
  4604. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4605. fmt.Println(dat)
  4606. } else {
  4607. fmt.Println(err)
  4608. }
  4609. userJSONBytes, _ := json.Marshal(dat)
  4610. var res Result
  4611. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4612. utils.ErrorLog("解析失败:%v", err)
  4613. c.ServeSuccessJSON(map[string]interface{}{
  4614. "failed_code": -10,
  4615. "msg": res.Transreturnmessage,
  4616. })
  4617. return
  4618. }
  4619. if res.Transreturncode == "00000000" {
  4620. ress = append(ress, &res)
  4621. } else {
  4622. isSuccess = false
  4623. //失败
  4624. c.ServeSuccessJSON(map[string]interface{}{
  4625. "failed_code": -10,
  4626. "msg": res.Transreturnmessage,
  4627. })
  4628. return
  4629. }
  4630. fmt.Println(isSuccess)
  4631. c.ServeSuccessJSON(map[string]interface{}{
  4632. "failed_code": -10,
  4633. "msg": res.Transreturnmessage,
  4634. })
  4635. return
  4636. }
  4637. }
  4638. func (c *SZHisApiController) GetGoodsList() {
  4639. adminUserInfo := c.GetAdminUserInfo()
  4640. orgId := adminUserInfo.CurrentOrgId
  4641. ids := c.GetString("ids")
  4642. admin_user_id, _ := c.GetInt64("admin_user_id")
  4643. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  4644. stringarr := strings.Split(ids, ",")
  4645. idss := make([]int64, 0)
  4646. for _, item := range stringarr {
  4647. itemsss, _ := strconv.ParseInt(item, 10, 64)
  4648. id := int64(itemsss)
  4649. idss = append(idss, id)
  4650. }
  4651. //批量获取所有耗材信息
  4652. list, _ := service.GetBatchGoodInformationList(idss)
  4653. //获取单位
  4654. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4655. var doctor_name string
  4656. var doctor_code string
  4657. doctor_name = roles.UserName
  4658. doctor_code = "1001"
  4659. var isSuccess bool = true
  4660. for _, item := range list {
  4661. detail := &models.XtGoodInformation{
  4662. GoodName: item.GoodName,
  4663. SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  4664. ManufacturerName: item.ManufacturerName,
  4665. ProductionType: item.ProductionType,
  4666. SpecialMedical: item.SpecialMedical,
  4667. BuyPrice: item.BuyPrice,
  4668. SellPrice: item.SellPrice,
  4669. Remark: item.Remark,
  4670. SpecificationName: item.SpecificationName,
  4671. }
  4672. result := service.SzybYML007(doctor_name, doctor_code, miConfig.Code, detail)
  4673. fmt.Println("reuslt", result)
  4674. var dat map[string]interface{}
  4675. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4676. fmt.Println(dat)
  4677. } else {
  4678. fmt.Println(err)
  4679. }
  4680. userJSONBytes, _ := json.Marshal(dat)
  4681. var res Result
  4682. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4683. utils.ErrorLog("解析失败:%v", err)
  4684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4685. return
  4686. }
  4687. if res.Transreturncode == "00000000" {
  4688. //备案成功返回状态
  4689. _, err := service.UpdateGoodInformaitonByDetail(item.ID)
  4690. fmt.Println("err", err)
  4691. } else {
  4692. isSuccess = false
  4693. //失败
  4694. c.ServeSuccessJSON(map[string]interface{}{
  4695. "failed_code": -10,
  4696. "msg": res.Transreturnmessage,
  4697. })
  4698. return
  4699. }
  4700. fmt.Println(isSuccess)
  4701. c.ServeSuccessJSON(map[string]interface{}{
  4702. "failed_code": -10,
  4703. "msg": res.Transreturnmessage,
  4704. })
  4705. return
  4706. }
  4707. }
  4708. type Charset string
  4709. const (
  4710. UTF8 = Charset("UTF-8")
  4711. GB18030 = Charset("GB18030")
  4712. )
  4713. func ConvertToString(src string, srcCode string, tagCode string) string {
  4714. srcCoder := mahonia.NewDecoder(srcCode)
  4715. srcResult := srcCoder.ConvertString(src)
  4716. tagCoder := mahonia.NewDecoder(tagCode)
  4717. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  4718. result := string(cdata)
  4719. return result
  4720. }