his_api_controller.go 210KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/jinzhu/gorm"
  14. //"github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  33. beego.Router("/api/diag/upload", &HisApiController{}, "get:GetUploadDiag")
  34. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  35. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  36. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  37. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  38. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  39. //beego.Router("/api/sscard", &HisApiController{}, "get:Sscard")
  40. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  41. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  42. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  43. beego.Router("/api/record/put", &HisApiController{}, "get:PutRecord")
  44. //beego.Router("/api/patient/info", &HisApiController{}, "get:GetHisPatientInfo")
  45. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  46. //beego.Router("/api/testcard", &HisApiController{}, "get:TestGetBasBaseInfo")
  47. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  48. //beego.Router("/api/testpay", &HisApiController{}, "get:TestPay")
  49. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  50. //beego.Router("/api/settle/get", &HisApiController{}, "get:GetSettleInfo")
  51. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  52. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  53. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  54. //备案撤销相关接口
  55. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. //beego.Router("/api/reversal/one", &HisApiController{}, "get:ReversalOtherOneData")
  64. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. //beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  68. //beego.Router("/api/testinit", &HisApiController{}, "get:TestGetBasBaseInit")
  69. //beego.Router("/api/test", &HisApiController{}, "get:TestGetBasBaseInfo")
  70. }
  71. func (c *HisApiController) CheckInsutype() {
  72. his_patient_id, _ := c.GetInt64("his_patient_id")
  73. admin_user_id, _ := c.GetInt64("admin_user_id")
  74. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  75. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  76. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  77. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  78. var dat map[string]interface{}
  79. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  80. fmt.Println(dat)
  81. } else {
  82. fmt.Println(err)
  83. }
  84. userJSONBytes, _ := json.Marshal(dat)
  85. var res Result90100
  86. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  87. utils.ErrorLog("解析失败:%v", err)
  88. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  89. return
  90. }
  91. if res.Infcode != 0 {
  92. c.ServeSuccessJSON(map[string]interface{}{
  93. "failed_code": -10,
  94. "msg": res.ErrMsg,
  95. })
  96. return
  97. } else {
  98. fmt.Println(res)
  99. }
  100. }
  101. func (c *HisApiController) CheckCardPWD() {
  102. card_pwd := c.GetString("card_pwd")
  103. his_patient_id, _ := c.GetInt64("his_patient_id")
  104. admin_user_id, _ := c.GetInt64("admin_user_id")
  105. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  106. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  107. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  108. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  109. var dat map[string]interface{}
  110. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  111. fmt.Println(dat)
  112. } else {
  113. fmt.Println(err)
  114. }
  115. userJSONBytes, _ := json.Marshal(dat)
  116. var res Result90991
  117. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  118. utils.ErrorLog("解析失败:%v", err)
  119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  120. return
  121. }
  122. if res.Infcode != 0 {
  123. c.ServeSuccessJSON(map[string]interface{}{
  124. "failed_code": -10,
  125. "msg": res.ErrMsg,
  126. })
  127. return
  128. } else {
  129. if res.Output.Result.CheckStat == "0" {
  130. var msg string
  131. switch res.Output.Result.CardStat {
  132. case "00":
  133. msg = "未激活"
  134. break
  135. case "10":
  136. msg = "激活"
  137. break
  138. case "20":
  139. msg = "窗口挂失"
  140. break
  141. case "21":
  142. msg = "电话挂失"
  143. break
  144. case "22":
  145. msg = "单位网上申报挂失"
  146. break
  147. case "23":
  148. msg = "保健办挂失"
  149. break
  150. case "24":
  151. msg = "个人网上挂失"
  152. break
  153. case "25":
  154. msg = "网上服务大厅挂失"
  155. break
  156. case "30":
  157. msg = "注销"
  158. break
  159. case "40":
  160. msg = "回收"
  161. break
  162. case "99":
  163. msg = "制卡中(无效卡)"
  164. break
  165. }
  166. c.ServeSuccessJSON(map[string]interface{}{
  167. "failed_code": -10,
  168. "msg": msg,
  169. })
  170. return
  171. } else {
  172. c.ServeSuccessJSON(map[string]interface{}{
  173. "msg": "校验成功",
  174. })
  175. return
  176. }
  177. }
  178. }
  179. func (c *HisApiController) ReadCard() {
  180. id_card_type, _ := c.GetInt64("id_card_type")
  181. admin_user_id, _ := c.GetInt64("admin_user_id")
  182. certificates, _ := c.GetInt64("certificates")
  183. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  184. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  185. if initFlag == 0 {
  186. c.TestGetBasBaseInit()
  187. }
  188. switch id_card_type {
  189. case 1:
  190. basStr := c.GetBasBaseInfo()
  191. if len(basStr) == 0 {
  192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  193. return
  194. }
  195. fmt.Println(basStr)
  196. bas := strings.Split(basStr, "|")
  197. basNumber := bas[1]
  198. fmt.Println(basNumber)
  199. card_sn := bas[3]
  200. fmt.Println(card_sn)
  201. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  202. var dat map[string]interface{}
  203. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  204. fmt.Println(dat)
  205. } else {
  206. fmt.Println(err)
  207. }
  208. userJSONBytes, _ := json.Marshal(dat)
  209. var res ResultTwo
  210. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  211. utils.ErrorLog("解析失败:%v", err)
  212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  213. return
  214. }
  215. if res.Infcode == 0 {
  216. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  217. if err == gorm.ErrRecordNotFound {
  218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  219. return
  220. } else if err != nil {
  221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  222. return
  223. } else {
  224. c.ServeSuccessJSON(map[string]interface{}{
  225. "patient": patient,
  226. "number": basNumber,
  227. })
  228. }
  229. } else {
  230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  231. return
  232. }
  233. break
  234. case 2:
  235. SFZStr := c.GetSFZBaseInfo()
  236. id_card_str := strings.Split(SFZStr, "^")
  237. id_card_number := id_card_str[0]
  238. card_sn := ""
  239. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  240. var dat map[string]interface{}
  241. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  242. fmt.Println(dat)
  243. } else {
  244. fmt.Println(err)
  245. }
  246. userJSONBytes, _ := json.Marshal(dat)
  247. var res ResultTwo
  248. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  249. utils.ErrorLog("解析失败:%v", err)
  250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  251. return
  252. }
  253. if res.Infcode == 0 {
  254. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  255. if err == gorm.ErrRecordNotFound {
  256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  257. return
  258. } else if err != nil {
  259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  260. return
  261. } else {
  262. c.ServeSuccessJSON(map[string]interface{}{
  263. "patient": patient,
  264. "number": id_card_number,
  265. })
  266. }
  267. } else {
  268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  269. return
  270. }
  271. break
  272. case 3:
  273. break
  274. }
  275. }
  276. var initFlag int64 = 0
  277. func (c *HisApiController) TestGetBasBaseInit() {
  278. DllDef := syscall.MustLoadDLL("SSCard.dll")
  279. Iinit := DllDef.MustFindProc("Init")
  280. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  281. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  282. if ret != 0 {
  283. fmt.Println("SSCard的报错原因:", err)
  284. fmt.Println("SSCard的运算结果为:", ret)
  285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  286. return
  287. }
  288. result := int(ret)
  289. fmt.Println("SSCard的运算结果为1:", result)
  290. initFlag = 1
  291. return
  292. }
  293. func (c *HisApiController) GetSFZBaseInfo() string {
  294. DllDef := syscall.MustLoadDLL("SSCard.dll")
  295. readCard := DllDef.MustFindProc("ReadSFZ")
  296. if readCard == nil {
  297. fmt.Println("readcard is nil")
  298. readCard = DllDef.MustFindProc("ReadSFZ")
  299. }
  300. str := make([]byte, 256)
  301. str1 := make([]byte, 256)
  302. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  303. fmt.Println(r)
  304. return string(str)
  305. }
  306. func (c *HisApiController) GetBasBaseInfo() string {
  307. DllDef := syscall.MustLoadDLL("SSCard.dll")
  308. readCard := DllDef.MustFindProc("ReadCardBas")
  309. if readCard == nil {
  310. fmt.Println("readcard is nil")
  311. readCard = DllDef.MustFindProc("ReadCardBas")
  312. }
  313. str := make([]byte, 1024)
  314. str1 := make([]byte, 1024)
  315. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  316. fmt.Println(string(str1))
  317. fmt.Println(string(str))
  318. if ret2 != 0 {
  319. return ""
  320. }
  321. return string(str)
  322. }
  323. func prttostr(vcode uintptr) string {
  324. var vbyte []byte
  325. for i := 0; i < 10; i++ {
  326. sbyte := *((*byte)(unsafe.Pointer(vcode)))
  327. if sbyte == 0 {
  328. break
  329. }
  330. vbyte = append(vbyte, sbyte)
  331. vcode += 1
  332. }
  333. return string(vbyte)
  334. }
  335. type CustomFundPay struct {
  336. FundPayType string `json:"fund_pay_type"`
  337. FundPayamt float64 `json:"fund_payamt"`
  338. }
  339. func (c *HisApiController) GetSettleList() {
  340. order_id, _ := c.GetInt64("order_id")
  341. admin_user_id, _ := c.GetInt64("admin_user_id")
  342. order, _ := service.GetHisOrderByIDTwo(order_id)
  343. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  344. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  345. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  346. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  347. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  348. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  349. if order.ID == 0 {
  350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  351. return
  352. }
  353. struct4101 := service.Struct4101{
  354. PsnNo: order.PsnNo,
  355. MdtrtId: order.MdtrtId,
  356. SetlId: order.SetlId,
  357. PsnName: order.PsnName,
  358. Gend: order.Gend,
  359. Brdy: his.Brdy,
  360. Age: his.Age,
  361. Naty: order.Naty,
  362. PatnCertType: "01",
  363. Certno: order.Certno,
  364. Prfs: "90",
  365. ConerName: roles[0].UserName,
  366. PatnRlts: "99",
  367. ConerAddr: miConfig.OrgName,
  368. ConerTel: admin.Mobile,
  369. HiType: order.Insutype,
  370. Insuplc: miConfig.InsuplcAdmdvs,
  371. MaindiagFlag: "1",
  372. BillCode: order.FaPiaoCode,
  373. BillNo: order.FaPiaoNumber,
  374. BizSn: order.Number,
  375. PsnSelfPay: order.PsnPartAmt,
  376. PsnOwnPay: order.PsnPartAmt,
  377. AcctPay: order.AcctPay,
  378. PsnCashpay: order.PsnCashPay,
  379. HiPaymtd: "1",
  380. Hsorg: miConfig.InsuplcAdmdvs,
  381. HsorgOpter: miConfig.InsuplcAdmdvs,
  382. MedinsFillPsn: curRoles.UserName,
  383. MedinsFillDept: depart.Name,
  384. IptMedType: "2",
  385. }
  386. if order.SettleType == 1 {
  387. t := time.Unix(int64(order.SettleAccountsDate), 0)
  388. dateStr := t.Format("2006-01-02")
  389. struct4101.SetlBegnDate = dateStr
  390. struct4101.SetlEndDate = dateStr
  391. } else {
  392. t := time.Unix(int64(order.SettleStartTime), 0)
  393. t2 := time.Unix(int64(order.SettleEndTime), 0)
  394. dateStartStr := t.Format("2006-01-02")
  395. dateEndStr := t2.Format("2006-01-02")
  396. struct4101.SetlBegnDate = dateStartStr
  397. struct4101.SetlEndDate = dateEndStr
  398. }
  399. var rf []CustomFundPay
  400. json.Unmarshal([]byte(order.SetlDetail), &rf)
  401. var tempFunPays []service.CustomStruct
  402. for _, item := range rf {
  403. var tempFunPay service.CustomStruct
  404. tempFunPay.FundPayamt = item.FundPayamt
  405. tempFunPay.FundPayType = item.FundPayType
  406. tempFunPays = append(tempFunPays, tempFunPay)
  407. }
  408. struct4101.CustomStruct = tempFunPays
  409. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  410. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  411. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  412. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  413. var config []*models.HisXtDiagnoseConfig
  414. for _, item := range diagnosis_ids {
  415. id, _ := strconv.ParseInt(item, 10, 64)
  416. diagnosisConfig, _ := service.FindDiagnoseById(id)
  417. config = append(config, diagnosisConfig)
  418. }
  419. for _, item := range config {
  420. var tempOpspdiseinfo service.OpspdiseinfoStruct
  421. tempOpspdiseinfo.DiagCode = item.CountryCode
  422. tempOpspdiseinfo.DiagName = item.CountryContentName
  423. tempOpspdiseinfo.MaindiagFlag = "1"
  424. tempOpspdiseinfo.OprnOprtCode = ""
  425. tempOpspdiseinfo.OprnOprtName = ""
  426. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  427. }
  428. sickConfigTwo, _ := service.FindSickById(his.SickType)
  429. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  430. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  431. tempOpspdiseinfo2.MaindiagFlag = "2"
  432. tempOpspdiseinfo2.OprnOprtCode = ""
  433. tempOpspdiseinfo2.OprnOprtName = ""
  434. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  435. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  436. var iteminfo service.IteminfoStruct
  437. var bedCostTotal float64 = 0 //床位总费
  438. var bedCostSelfTotal float64 = 0 //床位自费
  439. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  440. var operationCostTotal float64 = 0 //手术费
  441. var operationCostSelfTotal float64 = 0 //手术费
  442. var operationCostPartSelfTotal float64 = 0 //手术费
  443. var otherCostTotal float64 = 0 //其他费用
  444. var otherCostSelfTotal float64 = 0 //其他费用
  445. var otherCostPartSelfTotal float64 = 0 //其他费用
  446. var materialCostTotal float64 = 0 //材料费
  447. var materialCostSelfTotal float64 = 0 //材料费
  448. var materialCostPartSelfTotal float64 = 0 //材料费
  449. var westernMedicineCostTotal float64 = 0 //西药费
  450. var westernMedicineCostSelfTotal float64 = 0 //西药费
  451. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  452. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  453. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  454. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  455. var checkCostTotal float64 = 0 //检查费
  456. var checkCostSelfTotal float64 = 0 //检查费
  457. var checkCostPartSelfTotal float64 = 0 //检查费
  458. var laboratoryCostTotal float64 = 0 //化验费
  459. var laboratoryCostSelfTotal float64 = 0 //化验费
  460. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  461. var treatCostTotal float64 = 0 //治疗费用
  462. var treatCostSelfTotal float64 = 0 //治疗费用
  463. var treatCostPartSelfTotal float64 = 0 //治疗费用
  464. decimal.DivisionPrecision = 2
  465. var bed_fulamt_ownpay_amt float64 = 0
  466. var operation_fulamt_ownpay_amt float64 = 0
  467. var other_fulamt_ownpay_amt float64 = 0
  468. var westernMedicine_fulamt_ownpay_amt float64 = 0
  469. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  470. var check_fulamt_ownpay_amt float64 = 0
  471. var material_fulamt_ownpay_amt float64 = 0
  472. var laboratory_fulamt_ownpay_amt float64 = 0
  473. var treat_fulamt_ownpay_amt float64 = 0
  474. var bed_claa_sunmfee float64 = 0
  475. var bed_clab_amt float64 = 0
  476. var bed_other_amt float64 = 0
  477. var operation_claa_sunmfee float64 = 0
  478. var operation_clab_amt float64 = 0
  479. var operation_other_amt float64 = 0
  480. var other_claa_sunmfee float64 = 0
  481. var other_clab_amt float64 = 0
  482. var other_other_amt float64 = 0
  483. var westernMedicine_claa_sunmfee float64 = 0
  484. var westernMedicine_clab_amt float64 = 0
  485. var westernMedicine_other_amt float64 = 0
  486. var chineseTraditional_claa_sunmfee float64 = 0
  487. var chineseTraditional_clab_amt float64 = 0
  488. var chineseTraditional_other_amt float64 = 0
  489. var check_claa_sunmfee float64 = 0
  490. var check_clab_amt float64 = 0
  491. var check_other_amt float64 = 0
  492. var material_claa_sunmfee float64 = 0
  493. var material_clab_amt float64 = 0
  494. var material_other_amt float64 = 0
  495. var laboratory_claa_sunmfee float64 = 0
  496. var laboratory_clab_amt float64 = 0
  497. var laboratory_other_amt float64 = 0
  498. var treat_claa_sunmfee float64 = 0
  499. var treat_clab_amt float64 = 0
  500. var treat_other_amt float64 = 0
  501. for _, item := range order.HisOrderInfo {
  502. if item.MedChrgitmType == "01" { //床位费
  503. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  504. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  505. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  506. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  507. if item.ChrgitmLv == "1" {
  508. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  509. }
  510. if item.ChrgitmLv == "2" {
  511. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  512. }
  513. if item.ChrgitmLv == "3" {
  514. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  515. }
  516. }
  517. if item.MedChrgitmType == "03" { //检查费
  518. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  519. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  520. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  521. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  522. if item.ChrgitmLv == "1" {
  523. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  524. }
  525. if item.ChrgitmLv == "2" {
  526. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  527. }
  528. if item.ChrgitmLv == "3" {
  529. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  530. }
  531. }
  532. if item.MedChrgitmType == "04" { //化验费
  533. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  534. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  535. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  536. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  537. if item.ChrgitmLv == "1" {
  538. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  539. }
  540. if item.ChrgitmLv == "2" {
  541. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  542. }
  543. if item.ChrgitmLv == "3" {
  544. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  545. }
  546. }
  547. if item.MedChrgitmType == "05" { //治疗费
  548. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  549. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  550. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  551. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  552. if item.ChrgitmLv == "1" {
  553. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  554. }
  555. if item.ChrgitmLv == "2" {
  556. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  557. }
  558. if item.ChrgitmLv == "3" {
  559. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  560. }
  561. }
  562. if item.MedChrgitmType == "06" { //手术费
  563. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  564. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  565. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  566. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  567. if item.ChrgitmLv == "1" {
  568. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  569. }
  570. if item.ChrgitmLv == "2" {
  571. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  572. }
  573. if item.ChrgitmLv == "3" {
  574. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  575. }
  576. }
  577. if item.MedChrgitmType == "08" { //材料费
  578. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  579. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  580. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  581. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  582. if item.ChrgitmLv == "1" {
  583. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  584. }
  585. if item.ChrgitmLv == "2" {
  586. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  587. }
  588. if item.ChrgitmLv == "3" {
  589. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  590. }
  591. }
  592. if item.MedChrgitmType == "09" { //西药费
  593. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  594. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  595. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  596. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  597. if item.ChrgitmLv == "1" {
  598. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  599. }
  600. if item.ChrgitmLv == "2" {
  601. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  602. }
  603. if item.ChrgitmLv == "3" {
  604. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  605. }
  606. }
  607. if item.MedChrgitmType == "11" { //中成费
  608. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  609. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  610. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  611. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  612. if item.ChrgitmLv == "1" {
  613. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  614. }
  615. if item.ChrgitmLv == "2" {
  616. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  617. }
  618. if item.ChrgitmLv == "3" {
  619. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  620. }
  621. }
  622. if item.MedChrgitmType == "14" { //其他费
  623. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  624. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  625. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  626. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  627. if item.ChrgitmLv == "1" {
  628. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  629. }
  630. if item.ChrgitmLv == "2" {
  631. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  632. }
  633. if item.ChrgitmLv == "3" {
  634. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  635. }
  636. }
  637. }
  638. var iteminfoStructs []service.IteminfoStruct
  639. if bedCostTotal != 0 {
  640. iteminfo.MedChrgitm = "01"
  641. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  642. iteminfo.Amt = bedCostTotal
  643. iteminfo.ClaaSumfee = bed_claa_sunmfee
  644. iteminfo.ClabAmt = bed_clab_amt
  645. iteminfo.OthAmt = bed_other_amt
  646. iteminfoStructs = append(iteminfoStructs, iteminfo)
  647. }
  648. if checkCostTotal != 0 {
  649. iteminfo.MedChrgitm = "03"
  650. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  651. iteminfo.Amt = checkCostTotal
  652. iteminfo.ClaaSumfee = check_claa_sunmfee
  653. iteminfo.ClabAmt = check_clab_amt
  654. iteminfo.OthAmt = check_other_amt
  655. iteminfoStructs = append(iteminfoStructs, iteminfo)
  656. }
  657. if laboratoryCostTotal != 0 {
  658. iteminfo.MedChrgitm = "04"
  659. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  660. iteminfo.Amt = laboratoryCostTotal
  661. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  662. iteminfo.ClabAmt = laboratory_clab_amt
  663. iteminfo.OthAmt = laboratory_other_amt
  664. iteminfoStructs = append(iteminfoStructs, iteminfo)
  665. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  666. }
  667. if treatCostTotal != 0 {
  668. iteminfo.MedChrgitm = "05"
  669. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  670. iteminfo.Amt = treatCostTotal
  671. iteminfo.ClaaSumfee = treat_claa_sunmfee
  672. iteminfo.ClabAmt = treat_clab_amt
  673. iteminfo.OthAmt = treat_other_amt
  674. iteminfoStructs = append(iteminfoStructs, iteminfo)
  675. // (struct4101.IteminfoStruct, iteminfo)
  676. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  677. }
  678. if operationCostTotal != 0 {
  679. iteminfo.MedChrgitm = "06"
  680. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  681. iteminfo.Amt = operationCostTotal
  682. iteminfo.ClaaSumfee = operation_claa_sunmfee
  683. iteminfo.ClabAmt = operation_clab_amt
  684. iteminfo.OthAmt = operation_other_amt
  685. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  686. iteminfoStructs = append(iteminfoStructs, iteminfo)
  687. }
  688. if materialCostTotal != 0 {
  689. iteminfo.MedChrgitm = "08"
  690. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  691. iteminfo.Amt = materialCostTotal
  692. iteminfo.ClaaSumfee = material_claa_sunmfee
  693. iteminfo.ClabAmt = material_clab_amt
  694. iteminfo.OthAmt = material_other_amt
  695. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  696. iteminfoStructs = append(iteminfoStructs, iteminfo)
  697. }
  698. if westernMedicineCostTotal != 0 {
  699. iteminfo.MedChrgitm = "09"
  700. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  701. iteminfo.Amt = westernMedicineCostTotal
  702. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  703. iteminfo.ClabAmt = westernMedicine_clab_amt
  704. iteminfo.OthAmt = westernMedicine_other_amt
  705. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  706. iteminfoStructs = append(iteminfoStructs, iteminfo)
  707. }
  708. if chineseTraditionalMedicineCostTotal != 0 {
  709. iteminfo.MedChrgitm = "11"
  710. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  711. iteminfo.Amt = westernMedicineCostTotal
  712. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  713. iteminfo.ClabAmt = westernMedicine_clab_amt
  714. iteminfo.OthAmt = westernMedicine_other_amt
  715. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  716. iteminfoStructs = append(iteminfoStructs, iteminfo)
  717. }
  718. if otherCostTotal != 0 {
  719. iteminfo.MedChrgitm = "14"
  720. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  721. iteminfo.Amt = otherCostTotal
  722. iteminfo.ClaaSumfee = other_claa_sunmfee
  723. iteminfo.ClabAmt = other_clab_amt
  724. iteminfo.OthAmt = other_other_amt
  725. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  726. iteminfoStructs = append(iteminfoStructs, iteminfo)
  727. }
  728. struct4101.IteminfoStruct = iteminfoStructs
  729. struct4101.Ntly = "中国"
  730. struct4101.AdmCaty = "A03.06"
  731. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  732. fmt.Println(result)
  733. var dat map[string]interface{}
  734. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  735. fmt.Println(dat)
  736. } else {
  737. fmt.Println(err)
  738. }
  739. userJSONBytes, _ := json.Marshal(dat)
  740. var res ResultSeventeen
  741. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  742. utils.ErrorLog("解析失败:%v", err)
  743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  744. return
  745. }
  746. if res.Infcode != 0 {
  747. c.ServeSuccessJSON(map[string]interface{}{
  748. "failed_code": -10,
  749. "msg": res.ErrMsg,
  750. })
  751. return
  752. } else {
  753. hisFundSettleListResult := &models.HisFundSettleListResult{
  754. Number: res.Output.SetlListId,
  755. Status: 1,
  756. Ctime: time.Now().Unix(),
  757. Mtime: time.Now().Unix(),
  758. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  759. IsUpload: 1,
  760. OrderId: order_id,
  761. }
  762. service.CreateUploadRecord(hisFundSettleListResult)
  763. c.ServeSuccessJSON(map[string]interface{}{
  764. "msg": "上传成功",
  765. "result": hisFundSettleListResult,
  766. })
  767. return
  768. }
  769. }
  770. //func (c *HisApiController) TestPay() {
  771. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  772. // readCards := DllDef2.MustFindProc("BankTrans")
  773. // inputData := make(map[string]interface{})
  774. // inputData["transId"] = "05"
  775. // inputData["amount"] = "0.01"
  776. // inputData["traceNo"] = "20210227093601325405377"
  777. // inputData["cardNo"] = "F36084348"
  778. // inputData["id"] = "44022919620927046X"
  779. // //jsonStr := `
  780. // // {
  781. // // "transId": "05",
  782. // // "amount":"1.00",
  783. // // "traceNo":"20210227093601325405377",
  784. // // "cardNo":"F36084348",
  785. // // "id":"44022919620927046X"
  786. // //
  787. // // }
  788. // //`
  789. //
  790. // bytes_arr, _ := json.Marshal(inputData)
  791. // str3 := make([]byte, 256)
  792. // ret4, _, err4 := readCards.Call(StrPtr(string(bytes_arr)), (uintptr)(unsafe.Pointer(&str3[0])))
  793. // fmt.Println(":", string(str3))
  794. //
  795. // if err4 != nil {
  796. // fmt.Println("SSCard的运算结果为:", ret4)
  797. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  798. // return
  799. // }
  800. //
  801. //}
  802. //func (c *HisApiController) TestGetBasBaseInfo() {
  803. //
  804. // //result := C.Init(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  805. // //fmt.Println(result)
  806. // //cs1 := C.CString("")
  807. // //cs2 := C.CString("")
  808. // //C.ReadCardBas(cs1, IntPtr(1024), cs2, IntPtr(1024))
  809. // //fmt.Println(cs1)
  810. // //fmt.Println(cs2)
  811. // //C.free(unsafe.Pointer(cs1))
  812. // //C.free(unsafe.Pointer(cs2))
  813. //
  814. // //
  815. //
  816. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  817. // Iinit := DllDef.MustFindProc("Init")
  818. // readCard := DllDef.MustFindProc("ReadCardBas")
  819. // ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  820. // if ret != 0 {
  821. // fmt.Println("SSCard的报错原因:", err)
  822. // fmt.Println("SSCard的运算结果为:", ret)
  823. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  824. // return
  825. // }
  826. //
  827. // result := int(ret)
  828. // fmt.Println("SSCard的运算结果为1:", result)
  829. //
  830. // //path := ""
  831. // //bytePath := []byte( "\x00")
  832. // //bytePath2 := []byte( "\x00")
  833. // //ssss
  834. //
  835. // str := make([]byte, 256)
  836. // str1 := make([]byte, 256)
  837. // s2 := []byte(string(str))
  838. // s3 := []byte(string(str1))
  839. // ret2, _, err2 := readCard.Call((uintptr)(unsafe.Pointer(&s2[0])), IntPtr(256), (uintptr)(unsafe.Pointer(&s3[0])), IntPtr(256))
  840. // fmt.Println(" Add(4,5)的结果为:", ret2)
  841. // fmt.Println(" str:", s2)
  842. // fmt.Println(" str1:", s3)
  843. // if err2 != nil {
  844. // fmt.Println("SSCard的运算结果为:", ret2)
  845. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  846. // return
  847. // }
  848. //
  849. // //DllDef := syscall.MustLoadDLL("SSCard.dll")
  850. //
  851. //}
  852. func (c *HisApiController) GetOrgInfo() {
  853. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  854. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  855. }
  856. func (c *HisApiController) GetHisPatientInfo() {
  857. medical_insurance_card := c.GetString("medical_insurance_card")
  858. id_card_type, _ := c.GetInt64("id_card_type")
  859. id_card := c.GetString("id_card")
  860. adminInfo := c.GetAdminUserInfo()
  861. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  862. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  863. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  864. IdCardNo := ""
  865. if id_card_type == 1 {
  866. IdCardNo = medical_insurance_card
  867. } else if id_card_type == 2 {
  868. IdCardNo = id_card
  869. }
  870. if config.IsOpen == 1 {
  871. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  872. resp, requestErr := http.Get(api)
  873. if requestErr != nil {
  874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  875. return
  876. }
  877. defer resp.Body.Close()
  878. body, ioErr := ioutil.ReadAll(resp.Body)
  879. if ioErr != nil {
  880. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  882. return
  883. }
  884. var respJSON map[string]interface{}
  885. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  888. return
  889. }
  890. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  891. userJSONBytes, _ := json.Marshal(userJSON)
  892. var res ResultTwo
  893. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  894. utils.ErrorLog("解析失败:%v", err)
  895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  896. return
  897. }
  898. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  899. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  900. infoStr := string(Iinfos)
  901. idetinfoStr := string(Idetinfos)
  902. if res.Infcode == 0 {
  903. his := models.VMHisPatient{
  904. Status: 1,
  905. Ctime: time.Now().Unix(),
  906. Mtime: time.Now().Unix(),
  907. PsnNo: res.Output.Baseinfo.PsnNo,
  908. PsnCertType: res.Output.Baseinfo.PsnCertType,
  909. Certno: res.Output.Baseinfo.Certno,
  910. PsnName: res.Output.Baseinfo.PsnName,
  911. Gend: res.Output.Baseinfo.Gend,
  912. Naty: res.Output.Baseinfo.Naty,
  913. Brdy: res.Output.Baseinfo.Brdy,
  914. Age: res.Output.Baseinfo.Age,
  915. Iinfo: infoStr,
  916. Idetinfo: idetinfoStr,
  917. UserOrgId: adminInfo.CurrentOrgId,
  918. IsReturn: 1,
  919. IdCardType: id_card_type,
  920. }
  921. c.ServeSuccessJSON(map[string]interface{}{
  922. "info": his,
  923. })
  924. } else {
  925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  926. return
  927. }
  928. }
  929. }
  930. //func GetBasBaseInfo() (jsonStr string, err error) {
  931. //
  932. // handle := syscall.NewLazyDLL("SSCard.dll")
  933. // add := handle.NewProc("ReadCardBas")
  934. // str := make([]byte, 1024)
  935. // str1 := make([]byte, 1024)
  936. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  937. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  938. //
  939. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  940. //
  941. // fmt.Println("> Add(4,5)的结果为:", ret)
  942. // handle.Release()
  943. //
  944. // return "", nil
  945. //
  946. //}
  947. //func GetQRBaseInfo() (jsonStr string, err error) {
  948. // handle := syscall.LoadDLL("SSCard.dll")
  949. // ReadCardBas := handle.FindProc("GetQRBase")
  950. //
  951. // str := make([]byte, 256)
  952. // str1 := make([]byte, 256)
  953. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  954. //
  955. // fmt.Println(string(str))
  956. // fmt.Println(r)
  957. // return string(str), nil
  958. //}
  959. //func CardInit() int {
  960. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  961. // add := DllTestDef.MustFindProc("Init")
  962. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  963. // if err != nil {
  964. // fmt.Println("SSCard的运算结果为:", ret)
  965. // }
  966. // result := int(ret)
  967. // return result
  968. //}
  969. //func CardInit() int {
  970. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  971. // if err != nil {
  972. // fmt.Println("SSCard的运算结果为:", ret)
  973. // }
  974. // fmt.Println(err)
  975. // result := int(ret)
  976. // return result
  977. //}
  978. func IntPtr(n int) uintptr {
  979. return uintptr(n)
  980. }
  981. func StrPtr(s string) uintptr {
  982. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  983. }
  984. type ResultTwo struct {
  985. ErrMsg string `json:"err_msg"`
  986. InfRefmsgid string `json:"inf_refmsgid"`
  987. Infcode int64 `json:"infcode"`
  988. Output struct {
  989. Baseinfo struct {
  990. Age float64 `json:"age"`
  991. Brdy string `json:"brdy"`
  992. Certno string `json:"certno"`
  993. Gend string `json:"gend"`
  994. Naty string `json:"naty"`
  995. PsnCertType string `json:"psn_cert_type"`
  996. PsnName string `json:"psn_name"`
  997. PsnNo string `json:"psn_no"`
  998. } `json:"baseinfo"`
  999. Idetinfo []interface{} `json:"idetinfo"`
  1000. Iinfo []struct {
  1001. Balc float64 `json:"balc"`
  1002. CvlservFlag string `json:"cvlserv_flag"`
  1003. EmpName string `json:"emp_name"`
  1004. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1005. Insutype string `json:"insutype"`
  1006. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  1007. PausInsuDate string `json:"paus_insu_date"`
  1008. PsnInsuDate string `json:"psn_insu_date"`
  1009. PsnInsuStas string `json:"psn_insu_stas"`
  1010. PsnType string `json:"psn_type"`
  1011. } `json:"insuinfo"`
  1012. } `json:"output"`
  1013. RefmsgTime string `json:"refmsg_time"`
  1014. RespondTime string `json:"respond_time"`
  1015. Signtype interface{} `json:"signtype"`
  1016. WarnInfo interface{} `json:"warn_info"`
  1017. }
  1018. type ResultThree struct {
  1019. Cainfo interface{} `json:"cainfo"`
  1020. ErrMsg string `json:"err_msg"`
  1021. InfRefmsgid string `json:"inf_refmsgid"`
  1022. Infcode int64 `json:"infcode"`
  1023. Output struct {
  1024. Data struct {
  1025. IptOtpNo string `json:"ipt_otp_no"`
  1026. MdtrtID string `json:"mdtrt_id"`
  1027. PsnNo string `json:"psn_no"`
  1028. } `json:"data"`
  1029. } `json:"output"`
  1030. RefmsgTime string `json:"refmsg_time"`
  1031. RespondTime string `json:"respond_time"`
  1032. Signtype interface{} `json:"signtype"`
  1033. WarnMsg interface{} `json:"warn_msg"`
  1034. }
  1035. type ResultFour struct {
  1036. Cainfo string `json:"cainfo"`
  1037. ErrMsg string `json:"err_msg"`
  1038. InfRefmsgid string `json:"inf_refmsgid"`
  1039. Infcode int64 `json:"infcode"`
  1040. Output struct {
  1041. Result []struct {
  1042. BasMednFlag string `json:"bas_medn_flag"`
  1043. ChldMedcFlag string `json:"chld_medc_flag"`
  1044. ChrgitmLv string `json:"chrgitm_lv"`
  1045. Cnt float64 `json:"cnt"`
  1046. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  1047. DrtReimFlag string `json:"drt_reim_flag"`
  1048. FeedetlSn string `json:"feedetl_sn"`
  1049. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1050. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  1051. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1052. ListSpItemFlag string `json:"list_sp_item_flag"`
  1053. LmtUsedFlag string `json:"lmt_used_flag"`
  1054. MedChrgitmType string `json:"med_chrgitm_type"`
  1055. Memo string `json:"memo"`
  1056. OverlmtAmt float64 `json:"overlmt_amt"`
  1057. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1058. Pric float64 `json:"pric"`
  1059. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  1060. SelfpayProp float64 `json:"selfpay_prop"`
  1061. } `json:"result"`
  1062. } `json:"output"`
  1063. RefmsgTime string `json:"refmsg_time"`
  1064. RespondTime string `json:"respond_time"`
  1065. Signtype string `json:"signtype"`
  1066. WarnMsg string `json:"warn_msg"`
  1067. }
  1068. type ResultFive struct {
  1069. Balc float64 `json:"balc"`
  1070. CvlservFlag string `json:"cvlserv_flag"`
  1071. EmpName string `json:"emp_name"`
  1072. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1073. Insutype string `json:"insutype"`
  1074. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  1075. PausInsuDate string `json:"paus_insu_date"`
  1076. PsnInsuDate string `json:"psn_insu_date"`
  1077. PsnInsuStas string `json:"psn_insu_stas"`
  1078. PsnType string `json:"psn_type"`
  1079. }
  1080. type ResultSix struct {
  1081. Cainfo interface{} `json:"cainfo"`
  1082. ErrMsg string `json:"err_msg"`
  1083. InfRefmsgid string `json:"inf_refmsgid"`
  1084. Infcode int64 `json:"infcode"`
  1085. Output struct {
  1086. } `json:"output"`
  1087. RefmsgTime string `json:"refmsg_time"`
  1088. RespondTime string `json:"respond_time"`
  1089. Signtype interface{} `json:"signtype"`
  1090. WarnMsg interface{} `json:"warn_msg"`
  1091. }
  1092. type ResultSeven struct {
  1093. Cainfo string `json:"cainfo"`
  1094. ErrMsg string `json:"err_msg"`
  1095. InfRefmsgid string `json:"inf_refmsgid"`
  1096. Infcode int64 `json:"infcode"`
  1097. Output struct {
  1098. Setldetail []interface{} `json:"setldetail"`
  1099. Setlinfo struct {
  1100. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  1101. AcctPay float64 `json:"acct_pay"`
  1102. ActPayDedc float64 `json:"act_pay_dedc"`
  1103. Age float64 `json:"age"`
  1104. Balc float64 `json:"balc"`
  1105. Brdy string `json:"brdy"`
  1106. Certno string `json:"certno"`
  1107. ClrOptins string `json:"clr_optins"`
  1108. ClrType string `json:"clr_type"`
  1109. ClrWay string `json:"clr_way"`
  1110. CvlservFlag string `json:"cvlserv_flag"`
  1111. CvlservPay float64 `json:"cvlserv_pay"`
  1112. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1113. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1114. Gend string `json:"gend"`
  1115. HifesPay float64 `json:"hifes_pay"`
  1116. HifmiPay float64 `json:"hifmi_pay"`
  1117. HifpPay float64 `json:"hifp_pay"`
  1118. HospPartAmt float64 `json:"hosp_part_amt"`
  1119. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1120. Insutype string `json:"insutype"`
  1121. MafPay float64 `json:"maf_pay"`
  1122. MdtrtCertType string `json:"mdtrt_cert_type"`
  1123. HifobPay float64 `json:"hifob_pay"`
  1124. MdtrtID string `json:"mdtrt_id"`
  1125. MedType string `json:"med_type"`
  1126. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1127. MedinsSetlID string `json:"medins_setl_id"`
  1128. Naty string `json:"naty"`
  1129. OthPay float64 `json:"oth_pay"`
  1130. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1131. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1132. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1133. PsnCashPay float64 `json:"psn_cash_pay"`
  1134. PsnCertType string `json:"psn_cert_type"`
  1135. PsnName string `json:"psn_name"`
  1136. PsnNo string `json:"psn_no"`
  1137. PsnPartAmt float64 `json:"psn_part_amt"`
  1138. PsnType string `json:"psn_type"`
  1139. SetlID string `json:"setl_id"`
  1140. SetlTime string `json:"setl_time"`
  1141. } `json:"setlinfo"`
  1142. } `json:"output"`
  1143. RefmsgTime string `json:"refmsg_time"`
  1144. RespondTime string `json:"respond_time"`
  1145. Signtype interface{} `json:"signtype"`
  1146. WarnMsg interface{} `json:"warn_msg"`
  1147. }
  1148. type ResultEight struct {
  1149. Cainfo string `json:"cainfo"`
  1150. ErrMsg string `json:"err_msg"`
  1151. InfRefmsgid string `json:"inf_refmsgid"`
  1152. Infcode int64 `json:"infcode"`
  1153. Output struct {
  1154. Stmtinfo struct {
  1155. SetlOptins string `json:"setl_optins"`
  1156. StmtRslt string `json:"stmt_rslt"`
  1157. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  1158. } `json:"stmtinfo"`
  1159. } `json:"output"`
  1160. RefmsgTime string `json:"refmsg_time"`
  1161. RespondTime string `json:"respond_time"`
  1162. Signtype interface{} `json:"signtype"`
  1163. WarnMsg interface{} `json:"warn_msg"`
  1164. }
  1165. type ResultNine struct {
  1166. Cainfo string `json:"cainfo"`
  1167. ErrMsg string `json:"err_msg"`
  1168. InfRefmsgid string `json:"inf_refmsgid"`
  1169. Infcode int64 `json:"infcode"`
  1170. Output struct {
  1171. FileQuryNo string `json:"file_qury_no"`
  1172. } `json:"output"`
  1173. RefmsgTime string `json:"refmsg_time"`
  1174. RespondTime string `json:"respond_time"`
  1175. Signtype interface{} `json:"signtype"`
  1176. WarnMsg interface{} `json:"warn_msg"`
  1177. }
  1178. type ResultTen struct {
  1179. Cainfo string `json:"cainfo"`
  1180. ErrMsg string `json:"err_msg"`
  1181. InfRefmsgid string `json:"inf_refmsgid"`
  1182. Infcode int64 `json:"infcode"`
  1183. Output struct {
  1184. DldEndtime string `json:"dld_endtime"`
  1185. FileQuryNo string `json:"file_qury_no"`
  1186. Filename string `json:"filename"`
  1187. } `json:"output"`
  1188. RefmsgTime string `json:"refmsg_time"`
  1189. RespondTime string `json:"respond_time"`
  1190. Signtype interface{} `json:"signtype"`
  1191. WarnMsg interface{} `json:"warn_msg"`
  1192. }
  1193. //type Autogenerated struct {
  1194. // Output struct {
  1195. // Setlinfo struct {
  1196. // SetlTime string `json:"setl_time"`
  1197. // CvlservPay float64 `json:"cvlserv_pay"`
  1198. // Year string `json:"year"`
  1199. // MedType string `json:"med_type"`
  1200. // PsnPay float64 `json:"psn_pay"`
  1201. // OpterID string `json:"opter_id"`
  1202. // Begndate string `json:"begndate"`
  1203. // FlxempeFlag string `json:"flxempe_flag"`
  1204. // HifmiPay float64 `json:"hifmi_pay"`
  1205. // PsnNo string `json:"psn_no"`
  1206. // ActPayDedc float64 `json:"act_pay_dedc"`
  1207. // MedinsSetlID interface{} `json:"medins_setl_id"`
  1208. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  1209. // ClrWay string `json:"clr_way"`
  1210. // OthPay float64 `json:"oth_pay"`
  1211. // Gend string `json:"gend"`
  1212. // MdtrtID string `json:"mdtrt_id"`
  1213. // AcctPay float64 `json:"acct_pay"`
  1214. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  1215. // Insutype string `json:"insutype"`
  1216. // Invono interface{} `json:"invono"`
  1217. // Enddate string `json:"enddate"`
  1218. // CashPayamt float64 `json:"cash_payamt"`
  1219. // PsnType string `json:"psn_type"`
  1220. // FixmedinsName string `json:"fixmedins_name"`
  1221. // HifpPay float64 `json:"hifp_pay"`
  1222. // NewFlag interface{} `json:"new_flag"`
  1223. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1224. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  1225. // PayLoc string `json:"pay_loc"`
  1226. // ClrType string `json:"clr_type"`
  1227. // RefdSetlFlag string `json:"refd_setl_flag"`
  1228. // CvlservFlag string `json:"cvlserv_flag"`
  1229. // EmpName string `json:"emp_name"`
  1230. // Brdy string `json:"brdy"`
  1231. // Naty string `json:"naty"`
  1232. // Certno string `json:"certno"`
  1233. // DiseCode string `json:"dise_code"`
  1234. // FixmedinsCode string `json:"fixmedins_code"`
  1235. // DedcHospLv string `json:"dedc_hosp_lv"`
  1236. // OpterName string `json:"opter_name"`
  1237. // Balc float64 `json:"balc"`
  1238. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  1239. // PsnCertType string `json:"psn_cert_type"`
  1240. // HifobPay float64 `json:"hifob_pay"`
  1241. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  1242. // HifesPay float64 `json:"hifes_pay"`
  1243. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1244. // OptTime string `json:"opt_time"`
  1245. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1246. // SetlID string `json:"setl_id"`
  1247. // MafPay float64 `json:"maf_pay"`
  1248. // PsnName string `json:"psn_name"`
  1249. // InsuOptins interface{} `json:"insu_optins"`
  1250. // PrefFundPay interface{} `json:"pref_fund_pay"`
  1251. // ClrOptins string `json:"clr_optins"`
  1252. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1253. // DiseName string `json:"dise_name"`
  1254. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  1255. // Age float64 `json:"age"`
  1256. // DtrtCertType string `json:"dtrt_cert_type"`
  1257. // HospLv string `json:"hosp_lv"`
  1258. // } `json:"setlinfo"`
  1259. // Setldetail []struct {
  1260. // FundPayType string `json:"fund_pay_type"`
  1261. // FundPayamt float64 `json:"fund_payamt"`
  1262. // SetlProcInfo interface{} `json:"setl_proc_info"`
  1263. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  1264. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  1265. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  1266. // PrefFundPay interface{} `json:"pref_fund_pay"`
  1267. // } `json:"setldetail"`
  1268. // } `json:"output"`
  1269. // Infcode int `json:"infcode"`
  1270. // WarnMsg interface{} `json:"warn_msg"`
  1271. // Cainfo interface{} `json:"cainfo"`
  1272. // ErrMsg interface{} `json:"err_msg"`
  1273. // RefmsgTime string `json:"refmsg_time"`
  1274. // Signtype interface{} `json:"signtype"`
  1275. // RespondTime string `json:"respond_time"`
  1276. // InfRefmsgid string `json:"inf_refmsgid"`
  1277. //}
  1278. type ResultEleven struct {
  1279. Cainfo string `json:"cainfo"`
  1280. ErrMsg string `json:"err_msg"`
  1281. InfRefmsgid string `json:"inf_refmsgid"`
  1282. Infcode int64 `json:"infcode"`
  1283. Output struct {
  1284. Setlinfo struct {
  1285. SetlTime string `json:"setl_time"`
  1286. CvlservPay float64 `json:"cvlserv_pay"`
  1287. Year string `json:"year"`
  1288. MedType string `json:"med_type"`
  1289. PsnPay float64 `json:"psn_pay"`
  1290. OpterID string `json:"opter_id"`
  1291. Begndate string `json:"begndate"`
  1292. FlxempeFlag string `json:"flxempe_flag"`
  1293. HifmiPay float64 `json:"hifmi_pay"`
  1294. PsnNo string `json:"psn_no"`
  1295. ActPayDedc float64 `json:"act_pay_dedc"`
  1296. MedinsSetlID interface{} `json:"medins_setl_id"`
  1297. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  1298. ClrWay string `json:"clr_way"`
  1299. OthPay float64 `json:"oth_pay"`
  1300. Gend string `json:"gend"`
  1301. MdtrtID string `json:"mdtrt_id"`
  1302. AcctPay float64 `json:"acct_pay"`
  1303. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1304. Insutype string `json:"insutype"`
  1305. Invono interface{} `json:"invono"`
  1306. Enddate string `json:"enddate"`
  1307. CashPayamt float64 `json:"cash_payamt"`
  1308. PsnType string `json:"psn_type"`
  1309. FixmedinsName string `json:"fixmedins_name"`
  1310. HifpPay float64 `json:"hifp_pay"`
  1311. NewFlag interface{} `json:"new_flag"`
  1312. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1313. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1314. PayLoc string `json:"pay_loc"`
  1315. ClrType string `json:"clr_type"`
  1316. RefdSetlFlag string `json:"refd_setl_flag"`
  1317. CvlservFlag string `json:"cvlserv_flag"`
  1318. EmpName string `json:"emp_name"`
  1319. Brdy string `json:"brdy"`
  1320. Naty string `json:"naty"`
  1321. Certno string `json:"certno"`
  1322. DiseCode string `json:"dise_code"`
  1323. FixmedinsCode string `json:"fixmedins_code"`
  1324. DedcHospLv string `json:"dedc_hosp_lv"`
  1325. OpterName string `json:"opter_name"`
  1326. Balc float64 `json:"balc"`
  1327. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  1328. PsnCertType string `json:"psn_cert_type"`
  1329. HifobPay float64 `json:"hifob_pay"`
  1330. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1331. HifesPay float64 `json:"hifes_pay"`
  1332. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1333. OptTime string `json:"opt_time"`
  1334. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1335. SetlID string `json:"setl_id"`
  1336. MafPay float64 `json:"maf_pay"`
  1337. PsnName string `json:"psn_name"`
  1338. InsuOptins interface{} `json:"insu_optins"`
  1339. PrefFundPay interface{} `json:"pref_fund_pay"`
  1340. ClrOptins string `json:"clr_optins"`
  1341. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1342. DiseName string `json:"dise_name"`
  1343. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  1344. Age float64 `json:"age"`
  1345. DtrtCertType string `json:"dtrt_cert_type"`
  1346. HospLv string `json:"hosp_lv"`
  1347. } `json:"setlinfo"`
  1348. } `json:"output"`
  1349. RefmsgTime string `json:"refmsg_time"`
  1350. RespondTime string `json:"respond_time"`
  1351. Signtype interface{} `json:"signtype"`
  1352. WarnMsg interface{} `json:"warn_msg"`
  1353. }
  1354. type ResultTwelve struct {
  1355. Cainfo string `json:"cainfo"`
  1356. ErrMsg string `json:"err_msg"`
  1357. InfRefmsgid string `json:"inf_refmsgid"`
  1358. Infcode int64 `json:"infcode"`
  1359. Output struct {
  1360. MdtrtId string `json:"mdtrt_id"`
  1361. ChrgBchno string `json:"chrg_bchno"`
  1362. PsnNo string `json:"psn_no"`
  1363. } `json:"output"`
  1364. RefmsgTime string `json:"refmsg_time"`
  1365. RespondTime string `json:"respond_time"`
  1366. Signtype interface{} `json:"signtype"`
  1367. WarnMsg interface{} `json:"warn_msg"`
  1368. }
  1369. type ResultThirteen struct {
  1370. ErrMsg string `json:"err_msg"`
  1371. InfRefmsgid string `json:"inf_refmsgid"`
  1372. Infcode int64 `json:"infcode"`
  1373. Output struct {
  1374. Result struct {
  1375. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  1376. } `json:"result"`
  1377. } `json:"output"`
  1378. RefmsgTime string `json:"refmsg_time"`
  1379. RespondTime string `json:"respond_time"`
  1380. Signtype interface{} `json:"signtype"`
  1381. WarnInfo interface{} `json:"warn_info"`
  1382. }
  1383. type ResultFourteen struct {
  1384. ErrMsg string `json:"err_msg"`
  1385. InfRefmsgid string `json:"inf_refmsgid"`
  1386. Infcode int64 `json:"infcode"`
  1387. Output struct {
  1388. } `json:"output"`
  1389. RefmsgTime string `json:"refmsg_time"`
  1390. RespondTime string `json:"respond_time"`
  1391. Signtype interface{} `json:"signtype"`
  1392. WarnInfo interface{} `json:"warn_info"`
  1393. }
  1394. type ResultSixteen struct {
  1395. Cainfo string `json:"cainfo"`
  1396. ErrMsg string `json:"err_msg"`
  1397. InfRefmsgid string `json:"inf_refmsgid"`
  1398. Infcode int64 `json:"infcode"`
  1399. Output struct {
  1400. Setldetail []interface{} `json:"setldetail"`
  1401. Setlinfo struct {
  1402. MdtrtID string `json:"mdtrt_id"`
  1403. SetlID string `json:"setl_id"`
  1404. ClrOptins string `json:"clr_optins"`
  1405. SetlTime string `json:"setl_time"`
  1406. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1407. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1408. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1409. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1410. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1411. ActPayDedc float64 `json:"act_pay_dedc"`
  1412. HifpPay float64 `json:"hifp_pay"`
  1413. PoolPropSe float64 `json:"pool_prop_selfpay"`
  1414. Lfpay float64 `json:"selfpay"`
  1415. CvlservPay float64 `json:"cvlserv_pay"`
  1416. HifesPay float64 `json:"hifes_pay"`
  1417. HifmiPay float64 `json:"hifmi_pay"`
  1418. HifobPay float64 `json:"hifob_pay"`
  1419. MafPay float64 `json:"maf_pay"`
  1420. OthPay float64 `json:"oth_pay"`
  1421. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1422. PsnPartAmt float64 `json:"psn_part_amt"`
  1423. AcctPay float64 `json:"acct_pay"`
  1424. Balc float64 `json:"balc"`
  1425. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  1426. HospPartAmt float64 `json:"hosp_part_amt"`
  1427. MedinsSetlID string `json:"medins_setl_id"`
  1428. PdnCashPay string `json:"pdn_cash_pay"`
  1429. } `json:"setlinfo"`
  1430. } `json:"output"`
  1431. RefmsgTime string `json:"refmsg_time"`
  1432. RespondTime string `json:"respond_time"`
  1433. Signtype interface{} `json:"signtype"`
  1434. WarnMsg interface{} `json:"warn_msg"`
  1435. }
  1436. type ResultSeventeen struct {
  1437. ErrMsg string `json:"err_msg"`
  1438. InfRefmsgid string `json:"inf_refmsgid"`
  1439. Infcode int64 `json:"infcode"`
  1440. Output struct {
  1441. SetlListId string `json:"setl_list_id"`
  1442. } `json:"output"`
  1443. RefmsgTime string `json:"refmsg_time"`
  1444. RespondTime string `json:"respond_time"`
  1445. Signtype string `json:"signtype"`
  1446. WarnInfo string `json:"warn_info"`
  1447. }
  1448. type Result90991 struct {
  1449. ErrMsg string `json:"err_msg"`
  1450. InfRefmsgid string `json:"inf_refmsgid"`
  1451. Infcode int64 `json:"infcode"`
  1452. Output struct {
  1453. Result struct {
  1454. PsnNo string `json:"psn_no"`
  1455. CardStat string `json:"card_stat"`
  1456. Certno string `json:"certno"`
  1457. PsnName string `json:"psn_name"`
  1458. CheckStat string `json:"check_stat"`
  1459. } `json:"result"`
  1460. } `json:"output"`
  1461. RefmsgTime string `json:"refmsg_time"`
  1462. RespondTime string `json:"respond_time"`
  1463. Signtype interface{} `json:"signtype"`
  1464. WarnInfo interface{} `json:"warn_info"`
  1465. }
  1466. type Result90100 struct {
  1467. ErrMsg string `json:"err_msg"`
  1468. InfRefmsgid string `json:"inf_refmsgid"`
  1469. Infcode int64 `json:"infcode"`
  1470. Output struct {
  1471. PoolareaNo string `json:"poolarea_no"`
  1472. PoolareaNoName string `json:"poolarea_no_name"`
  1473. Insutype string `json:"insutype"`
  1474. InsutypeName string `json:"insutype_name"`
  1475. ClctType string `json:"clct_type"`
  1476. ClctTypeName string `json:"clct_type_name"`
  1477. ClctFlag string `json:"clct_flag"`
  1478. ClctFlagName string `json:"clct_flag_name"`
  1479. AccrymBegn string `json:"accrym_begn"`
  1480. AccrymEnd string `json:"accrym_end"`
  1481. ClctTime string `json:"clct_time"`
  1482. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  1483. } `json:"output"`
  1484. RefmsgTime string `json:"refmsg_time"`
  1485. RespondTime string `json:"respond_time"`
  1486. Signtype interface{} `json:"signtype"`
  1487. WarnInfo interface{} `json:"warn_info"`
  1488. }
  1489. type Custom struct {
  1490. DetItemFeeSumamt string
  1491. Cut string
  1492. FeedetlSn string
  1493. Price string
  1494. MedListCodg string
  1495. Type int64
  1496. AdviceId int64
  1497. ProjectId int64
  1498. ItemId int64
  1499. }
  1500. //获取个人信息----挂号-----上传就诊信息
  1501. func (c *HisApiController) GetRegisterInfo() {
  1502. id, _ := c.GetInt64("id")
  1503. record_time := c.GetString("record_time")
  1504. settlementValue, _ := c.GetInt64("settlement_value")
  1505. medical_insurance_card := c.GetString("medical_insurance_card")
  1506. name := c.GetString("name")
  1507. id_card_type, _ := c.GetInt64("id_card_type")
  1508. certificates, _ := c.GetInt64("certificates")
  1509. medical_care, _ := c.GetInt64("medical_care")
  1510. birthday := c.GetString("birthday")
  1511. //age, _ := c.GetInt64("age")
  1512. id_card := c.GetString("id_card")
  1513. register_type, _ := c.GetInt64("register")
  1514. doctor, _ := c.GetInt64("doctor")
  1515. department, _ := c.GetInt64("department")
  1516. gender, _ := c.GetInt64("sex")
  1517. //phone := c.GetString("phone")
  1518. registration_fee, _ := c.GetFloat("registration_fee")
  1519. medical_expenses, _ := c.GetFloat("medical_expenses")
  1520. social_type, _ := c.GetInt64("social_type")
  1521. admin_user_id, _ := c.GetInt64("admin_user_id")
  1522. timeLayout := "2006-01-02"
  1523. loc, _ := time.LoadLocation("Local")
  1524. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  1525. birthUnix := birthdays.Unix()
  1526. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1527. if err != nil {
  1528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1529. return
  1530. }
  1531. recordDateTime := theTime.Unix()
  1532. adminInfo := c.GetAdminUserInfo()
  1533. var patient service.Patients
  1534. if id == 0 {
  1535. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  1536. } else {
  1537. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  1538. }
  1539. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  1540. if patientPrescription.ID == 0 {
  1541. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  1542. }
  1543. //adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
  1544. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  1545. //sickConfig, _ := service.FindSickById(sick_type)
  1546. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1547. if patient.ID == 0 {
  1548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  1549. return
  1550. }
  1551. if len(patient.IdCardNo) == 0 {
  1552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  1553. return
  1554. }
  1555. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  1556. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1557. //就诊结算未完成,不能进行二次挂号
  1558. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  1559. if len(his) >= 1 {
  1560. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  1561. if len(his) >= 1 && order.ID == 0 {
  1562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  1563. return
  1564. }
  1565. }
  1566. if config.IsOpen == 1 {
  1567. //service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  1568. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&certificates=" + strconv.FormatInt(certificates, 10)
  1569. resp, requestErr := http.Get(api)
  1570. if requestErr != nil {
  1571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1572. return
  1573. }
  1574. defer resp.Body.Close()
  1575. body, ioErr := ioutil.ReadAll(resp.Body)
  1576. if ioErr != nil {
  1577. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1579. return
  1580. }
  1581. var respJSON map[string]interface{}
  1582. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1585. return
  1586. }
  1587. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1588. userJSONBytes, _ := json.Marshal(userJSON)
  1589. var res ResultTwo
  1590. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1591. utils.ErrorLog("解析失败:%v", err)
  1592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1593. return
  1594. }
  1595. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1596. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1597. infoStr := string(Iinfos)
  1598. idetinfoStr := string(Idetinfos)
  1599. if res.Infcode == 0 {
  1600. his := models.VMHisPatient{
  1601. Name: name,
  1602. Gender: gender,
  1603. Birthday: birthUnix,
  1604. MedicalTreatmentType: medical_care,
  1605. IdType: certificates,
  1606. IdCardNo: id_card,
  1607. BalanceAccountsType: settlementValue,
  1608. SocialType: social_type,
  1609. MedicalInsuranceNumber: medical_insurance_card,
  1610. RegisterType: register_type,
  1611. RegisterCost: registration_fee,
  1612. TreatmentCost: medical_expenses,
  1613. Status: 1,
  1614. Ctime: time.Now().Unix(),
  1615. Mtime: time.Now().Unix(),
  1616. PsnNo: res.Output.Baseinfo.PsnNo,
  1617. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1618. Certno: res.Output.Baseinfo.Certno,
  1619. PsnName: res.Output.Baseinfo.PsnName,
  1620. Gend: res.Output.Baseinfo.Gend,
  1621. Naty: res.Output.Baseinfo.Naty,
  1622. Brdy: res.Output.Baseinfo.Brdy,
  1623. Age: res.Output.Baseinfo.Age,
  1624. Iinfo: infoStr,
  1625. Idetinfo: idetinfoStr,
  1626. PatientId: patient.ID,
  1627. RecordDate: theTime.Unix(),
  1628. UserOrgId: adminInfo.CurrentOrgId,
  1629. AdminUserId: admin_user_id,
  1630. IsReturn: 1,
  1631. IdCardType: id_card_type,
  1632. Doctor: doctor,
  1633. Departments: department,
  1634. }
  1635. timestamp := time.Now().Unix()
  1636. tempTime := time.Unix(timestamp, 0)
  1637. timeFormat := tempTime.Format("20060102150405")
  1638. chrgBchno := rand.Intn(100000) + 10000
  1639. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  1640. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  1641. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1642. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  1643. IdCardNo := ""
  1644. if id_card_type == 1 {
  1645. // IdCardNo = medical_insurance_card
  1646. IdCardNo = patient.IdCardNo
  1647. } else {
  1648. IdCardNo = patient.IdCardNo
  1649. }
  1650. var insutypes []string
  1651. var insutype string
  1652. var is390 int = 0
  1653. var is310 int = 0
  1654. for _, item := range res.Output.Iinfo {
  1655. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1656. insutypes = append(insutypes, item.Insutype)
  1657. }
  1658. }
  1659. if len(insutypes) == 1 {
  1660. insutype = insutypes[0]
  1661. } else {
  1662. for _, i := range insutypes {
  1663. if i == "390" {
  1664. is390 = 1
  1665. }
  1666. if i == "310" {
  1667. is310 = 1
  1668. }
  1669. }
  1670. }
  1671. if is390 == 1 {
  1672. insutype = "390"
  1673. }
  1674. if is310 == 1 {
  1675. insutype = "310"
  1676. }
  1677. if len(insutypes) == 0 {
  1678. insutype = "310"
  1679. }
  1680. //insutype = "390"
  1681. //if count == 1 {
  1682. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  1683. // return
  1684. //}
  1685. api := "http://127.0.0.1:9532/" + "gdyb/two?cert_no=" + IdCardNo + "&insutype=" +
  1686. insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
  1687. "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
  1688. "&dept=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&dept_code=" + department.Number + "&doctor_id=" + doctor_id + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10)
  1689. resp, requestErr := http.Get(api)
  1690. if requestErr != nil {
  1691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1692. return
  1693. }
  1694. defer resp.Body.Close()
  1695. body, ioErr := ioutil.ReadAll(resp.Body)
  1696. if ioErr != nil {
  1697. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1699. return
  1700. }
  1701. var respJSON map[string]interface{}
  1702. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1705. return
  1706. }
  1707. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1708. userJSONBytes, _ := json.Marshal(respJSON)
  1709. var res ResultThree
  1710. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1711. utils.ErrorLog("解析失败:%v", err)
  1712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1713. return
  1714. }
  1715. if res.Infcode != 0 {
  1716. adminUser := c.GetAdminUserInfo()
  1717. errlog := &models.HisOrderError{
  1718. UserOrgId: adminUser.CurrentOrgId,
  1719. Ctime: time.Now().Unix(),
  1720. Mtime: time.Now().Unix(),
  1721. ErrMsg: res.ErrMsg,
  1722. Status: 1,
  1723. PatientId: id,
  1724. RecordTime: recordDateTime,
  1725. Stage: 2,
  1726. }
  1727. service.CreateErrMsgLog(errlog)
  1728. c.ServeSuccessJSON(map[string]interface{}{
  1729. "failed_code": -10,
  1730. "msg": res.ErrMsg,
  1731. })
  1732. return
  1733. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
  1734. //return
  1735. }
  1736. his.Number = res.Output.Data.MdtrtID
  1737. his.PsnNo = res.Output.Data.PsnNo
  1738. his.IptOtpNo = res.Output.Data.IptOtpNo
  1739. his.IdCardNo = patient.IdCardNo
  1740. his.PhoneNumber = patient.Phone
  1741. his.UserOrgId = adminInfo.CurrentOrgId
  1742. his.Ctime = time.Now().Unix()
  1743. his.Mtime = time.Now().Unix()
  1744. his.Status = 1
  1745. service.UpdateHisPatientStatus(&his)
  1746. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  1747. c.ServeSuccessJSON(map[string]interface{}{
  1748. "his_info": his,
  1749. })
  1750. } else {
  1751. adminUser := c.GetAdminUserInfo()
  1752. errlog := &models.HisOrderError{
  1753. UserOrgId: adminUser.CurrentOrgId,
  1754. Ctime: time.Now().Unix(),
  1755. Mtime: time.Now().Unix(),
  1756. ErrMsg: res.ErrMsg,
  1757. Status: 1,
  1758. PatientId: id,
  1759. RecordTime: recordDateTime,
  1760. Stage: 1,
  1761. }
  1762. service.CreateErrMsgLog(errlog)
  1763. c.ServeSuccessJSON(map[string]interface{}{
  1764. "failed_code": -10,
  1765. "msg": res.ErrMsg,
  1766. })
  1767. return
  1768. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  1769. }
  1770. }
  1771. }
  1772. //上传明细----预结算----确认订单
  1773. func (c *HisApiController) GetUploadInfo() {
  1774. id, _ := c.GetInt64("id")
  1775. record_time := c.GetString("record_time")
  1776. his_patient_id, _ := c.GetInt64("his_patient_id")
  1777. order_id, _ := c.GetInt64("order_id")
  1778. pay_way, _ := c.GetInt64("pay_way")
  1779. pay_price, _ := c.GetFloat("pay_price")
  1780. pay_card_no := c.GetString("pay_card_no")
  1781. discount_price, _ := c.GetFloat("discount_price")
  1782. preferential_price, _ := c.GetFloat("preferential_price")
  1783. reality_price, _ := c.GetFloat("reality_price")
  1784. found_price, _ := c.GetFloat("found_price")
  1785. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  1786. private_price, _ := c.GetFloat("private_price")
  1787. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1788. admin_user_id, _ := c.GetInt64("admin_user_id")
  1789. fapiao_code := c.GetString("fapiao_code")
  1790. fapiao_number := c.GetString("fapiao_number")
  1791. diagnosis_id := c.GetString("diagnosis")
  1792. sick_type, _ := c.GetInt64("sick_type")
  1793. reg_type, _ := c.GetInt64("p_type")
  1794. id_str := c.GetString("ids")
  1795. ids_arr := strings.Split(id_str, ",")
  1796. timeLayout := "2006-01-02"
  1797. loc, _ := time.LoadLocation("Local")
  1798. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1799. if err != nil {
  1800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1801. return
  1802. }
  1803. recordDateTime := theTime.Unix()
  1804. adminUser := c.GetAdminUserInfo()
  1805. var tempOrder models.HisOrder
  1806. tempOrder, _ = service.GetHisOrderByID(order_id)
  1807. var prescriptions []*models.HisPrescription
  1808. var start_time int64
  1809. var end_time int64
  1810. //if adminUser.CurrentOrgId == 10106{
  1811. // if len(fapiao_code) == 0{
  1812. // fapiao_code = "144072080589"
  1813. // }
  1814. // if len(fapiao_number) == 0{
  1815. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  1816. // if order.ID == 0{
  1817. // fapiao_number = "00001520"
  1818. // }else{
  1819. // //fapiao_code = "00001520"
  1820. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  1821. // var zero string
  1822. // if fpNumber >= 1000{
  1823. // zero = "0000" + strconv.Itoa(fpNumber)
  1824. // }else if fpNumber >= 10000{
  1825. // zero = "000" + strconv.Itoa(fpNumber)
  1826. // } else if fpNumber >= 100000{
  1827. // zero = "00" + strconv.Itoa(fpNumber)
  1828. // } else if fpNumber >= 1000000{
  1829. // zero = "0" + strconv.Itoa(fpNumber)
  1830. // }else {
  1831. // zero = strconv.Itoa(fpNumber)
  1832. // }
  1833. // fapiao_number = zero
  1834. // }
  1835. // }
  1836. //}
  1837. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1838. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1839. var patientPrescription models.HisPrescriptionInfo
  1840. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1841. if patientPrescription.ID == 0 {
  1842. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1843. }
  1844. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1845. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1846. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1847. diagnosis_ids := strings.Split(diagnosis_id, ",")
  1848. var config []*models.HisXtDiagnoseConfig
  1849. for _, item := range diagnosis_ids {
  1850. id, _ := strconv.ParseInt(item, 10, 64)
  1851. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1852. config = append(config, diagnosisConfig)
  1853. }
  1854. sickConfig, _ := service.FindSickById(sick_type)
  1855. if tempOrder.ID == 0 {
  1856. tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  1857. }
  1858. if tempOrder.ID == 0 {
  1859. var result string
  1860. if miConfig.InsuplcAdmdvs == "440781" { //
  1861. result = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.AdminUserId, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config)
  1862. } else {
  1863. result = service.Gdyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.AdminUserId, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config)
  1864. }
  1865. var respJSON2 map[string]interface{}
  1866. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1869. return
  1870. }
  1871. userJSONBytes2, _ := json.Marshal(respJSON2)
  1872. var res2 ResultSix
  1873. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1874. utils.ErrorLog("解析失败:%v", err)
  1875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1876. return
  1877. }
  1878. if res2.Infcode != 0 {
  1879. adminUser := c.GetAdminUserInfo()
  1880. errlog := &models.HisOrderError{
  1881. UserOrgId: adminUser.CurrentOrgId,
  1882. Ctime: time.Now().Unix(),
  1883. Mtime: time.Now().Unix(),
  1884. ErrMsg: res2.ErrMsg,
  1885. Status: 1,
  1886. PatientId: id,
  1887. RecordTime: recordDateTime,
  1888. Stage: 3,
  1889. }
  1890. service.CreateErrMsgLog(errlog)
  1891. c.ServeSuccessJSON(map[string]interface{}{
  1892. "failed_code": -10,
  1893. "msg": res2.ErrMsg,
  1894. })
  1895. return
  1896. } else {
  1897. his.Diagnosis = diagnosis_id
  1898. his.SickType = sickConfig.ID
  1899. his.PType = fmt.Sprintf("%d", reg_type)
  1900. service.UpdateHisPatientThree(&his)
  1901. data := make(map[string]interface{})
  1902. if settle_accounts_type == 1 { //日结
  1903. if reg_type == 11 {
  1904. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  1905. } else {
  1906. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  1907. }
  1908. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  1909. data["pre"] = prescriptions
  1910. } else { //月结
  1911. start_time_str := c.GetString("start_time")
  1912. end_time_str := c.GetString("end_time")
  1913. timeLayout := "2006-01-02"
  1914. loc, _ := time.LoadLocation("Local")
  1915. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  1916. if err != nil {
  1917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1918. return
  1919. }
  1920. recordStartTime := theStartTime.Unix()
  1921. start_time = recordStartTime
  1922. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  1923. if err != nil {
  1924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1925. return
  1926. }
  1927. recordEndTime := theEndTime.Unix()
  1928. end_time = recordEndTime
  1929. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  1930. data["pre"] = prescriptions
  1931. }
  1932. if reg_type == 1111 || reg_type == 1112 {
  1933. reg_type = 11
  1934. }
  1935. timestamp := time.Now().Unix()
  1936. tempTime := time.Unix(timestamp, 0)
  1937. timeFormat := tempTime.Format("20060102150405")
  1938. chrgBchno := rand.Intn(100000) + 10000
  1939. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  1940. strconv.FormatInt(his.PatientId, 10)
  1941. client := &http.Client{}
  1942. data["psn_no"] = his.PsnNo
  1943. data["mdtrt_id"] = his.Number
  1944. data["chrg_bchno"] = chrg_bchno
  1945. data["org_name"] = miConfig.OrgName
  1946. data["doctor"] = roles.UserName
  1947. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  1948. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  1949. data["fixmedins_code"] = miConfig.Code
  1950. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  1951. data["dept_code"] = "15"
  1952. } else {
  1953. data["dept_code"] = department.Number
  1954. }
  1955. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1956. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1957. data["secret_key"] = miConfig.SecretKey
  1958. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  1959. var ids []int64
  1960. for _, item := range prescriptions {
  1961. ids = append(ids, item.ID)
  1962. }
  1963. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1964. if config.IsOpen == 1 { //对接了医保,走医保流程
  1965. bytesData, _ := json.Marshal(data)
  1966. req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  1967. resp, _ := client.Do(req)
  1968. defer resp.Body.Close()
  1969. body, ioErr := ioutil.ReadAll(resp.Body)
  1970. if ioErr != nil {
  1971. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1973. return
  1974. }
  1975. var respJSON map[string]interface{}
  1976. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1977. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1979. return
  1980. }
  1981. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1982. userJSONBytes, _ := json.Marshal(respJSON)
  1983. var res ResultFour
  1984. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1985. utils.ErrorLog("解析失败:%v", err)
  1986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1987. return
  1988. }
  1989. if res.Infcode == 0 {
  1990. order := &models.HisOrder{
  1991. UserOrgId: adminUser.CurrentOrgId,
  1992. HisPatientId: his.ID,
  1993. PatientId: his.PatientId,
  1994. SettleAccountsDate: recordDateTime,
  1995. Ctime: time.Now().Unix(),
  1996. Mtime: time.Now().Unix(),
  1997. Status: 0,
  1998. Number: chrg_bchno,
  1999. Infcode: res.Infcode,
  2000. WarnMsg: res.WarnMsg,
  2001. Cainfo: res.Cainfo,
  2002. ErrMsg: res.ErrMsg,
  2003. RespondTime: res.RefmsgTime,
  2004. InfRefmsgid: res.InfRefmsgid,
  2005. OrderStatus: 1,
  2006. PayWay: pay_way,
  2007. PayPrice: pay_price,
  2008. PayCardNo: pay_card_no,
  2009. DiscountPrice: discount_price,
  2010. PreferentialPrice: preferential_price,
  2011. RealityPrice: reality_price,
  2012. FoundPrice: found_price,
  2013. MedicalInsurancePrice: medical_insurance_price,
  2014. PrivatePrice: private_price,
  2015. IsMedicineInsurance: 1,
  2016. SettleType: settle_accounts_type,
  2017. SettleStartTime: start_time,
  2018. SettleEndTime: end_time,
  2019. Creator: roles.AdminUserId,
  2020. Modify: roles.AdminUserId,
  2021. FaPiaoNumber: fapiao_number,
  2022. FaPiaoCode: fapiao_code,
  2023. PType: 2,
  2024. Diagnosis: diagnosis_id,
  2025. }
  2026. err = service.CreateOrder(order)
  2027. if err != nil {
  2028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2029. return
  2030. }
  2031. for _, item := range res.Output.Result {
  2032. temp := strings.Split(item.FeedetlSn, "-")
  2033. var advice_id int64 = 0
  2034. var project_id int64 = 0
  2035. var types int64 = 0
  2036. id, _ := strconv.ParseInt(temp[2], 10, 64)
  2037. types, _ = strconv.ParseInt(temp[1], 10, 64)
  2038. if temp[1] == "1" {
  2039. advice_id = id
  2040. project_id = 0
  2041. } else if temp[1] == "2" {
  2042. advice_id = 0
  2043. project_id = id
  2044. }
  2045. info := &models.HisOrderInfo{
  2046. OrderNumber: order.Number,
  2047. FeedetlSn: item.FeedetlSn,
  2048. UploadDate: time.Now().Unix(),
  2049. AdviceId: advice_id,
  2050. DetItemFeeSumamt: item.DetItemFeeSumamt,
  2051. Cnt: item.Cnt,
  2052. Pric: float64(item.Pric),
  2053. PatientId: his.PatientId,
  2054. PricUplmtAmt: item.PricUplmtAmt,
  2055. SelfpayProp: item.SelfpayProp,
  2056. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  2057. OverlmtAmt: item.OverlmtAmt,
  2058. PreselfpayAmt: item.PreselfpayAmt,
  2059. BasMednFlag: item.BasMednFlag,
  2060. MedChrgitmType: item.MedChrgitmType,
  2061. HiNegoDrugFlag: item.HiNegoDrugFlag,
  2062. Status: 1,
  2063. Memo: item.Memo,
  2064. Mtime: time.Now().Unix(),
  2065. InscpScpAmt: item.InscpScpAmt,
  2066. DrtReimFlag: item.DrtReimFlag,
  2067. Ctime: time.Now().Unix(),
  2068. ListSpItemFlag: item.ListSpItemFlag,
  2069. ChldMedcFlag: item.ChldMedcFlag,
  2070. LmtUsedFlag: item.LmtUsedFlag,
  2071. ChrgitmLv: item.ChrgitmLv,
  2072. UserOrgId: adminUser.CurrentOrgId,
  2073. HisPatientId: his.ID,
  2074. OrderId: order.ID,
  2075. ProjectId: project_id,
  2076. Type: types,
  2077. }
  2078. service.CreateOrderInfo(info)
  2079. }
  2080. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2081. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  2082. var total float64
  2083. for _, item := range prescriptions {
  2084. if item.Type == 1 { //药品
  2085. for _, subItem := range item.HisDoctorAdviceInfo {
  2086. total = total + (subItem.Price * subItem.PrescribingNumber)
  2087. }
  2088. }
  2089. if item.Type == 2 { //项目
  2090. for _, subItem := range item.HisPrescriptionProject {
  2091. total = total + (subItem.Price * float64(subItem.Count))
  2092. }
  2093. }
  2094. }
  2095. for _, item := range prescriptions {
  2096. for _, subItem := range item.HisAdditionalCharge {
  2097. total = total + (subItem.Price * float64(subItem.Count))
  2098. }
  2099. }
  2100. allTotal := fmt.Sprintf("%.2f", total)
  2101. if res.Infcode == 0 {
  2102. var rf []*ResultFive
  2103. json.Unmarshal([]byte(his.Iinfo), &rf)
  2104. chrg_bchno := chrg_bchno
  2105. cert_no := his.Certno
  2106. var insutypes []string
  2107. var insutype string
  2108. var is390 int = 0
  2109. var is310 int = 0
  2110. for _, item := range rf {
  2111. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2112. insutypes = append(insutypes, item.Insutype)
  2113. }
  2114. }
  2115. if len(insutypes) == 1 {
  2116. insutype = insutypes[0]
  2117. } else {
  2118. for _, i := range insutypes {
  2119. if i == "390" {
  2120. is390 = 1
  2121. }
  2122. if i == "310" {
  2123. is310 = 1
  2124. }
  2125. }
  2126. }
  2127. if is390 == 1 {
  2128. insutype = "390"
  2129. }
  2130. if is310 == 1 {
  2131. insutype = "310"
  2132. }
  2133. if len(insutypes) == 0 {
  2134. insutype = "310"
  2135. }
  2136. //insutype = "390"
  2137. if his.IdCardType == 1 {
  2138. // cert_no = his.MedicalInsuranceNumber
  2139. cert_no = his.Certno
  2140. } else {
  2141. cert_no = his.Certno
  2142. }
  2143. result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  2144. var dat map[string]interface{}
  2145. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2146. fmt.Println(dat)
  2147. } else {
  2148. fmt.Println(err)
  2149. }
  2150. userJSONBytes, _ := json.Marshal(dat)
  2151. var res ResultSeven
  2152. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2153. utils.ErrorLog("解析失败:%v", err)
  2154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2155. return
  2156. }
  2157. if res.Infcode != 0 {
  2158. errlog := &models.HisOrderError{
  2159. UserOrgId: adminUser.CurrentOrgId,
  2160. Ctime: time.Now().Unix(),
  2161. Mtime: time.Now().Unix(),
  2162. Number: chrg_bchno,
  2163. ErrMsg: res.ErrMsg,
  2164. Status: 1,
  2165. PatientId: id,
  2166. RecordTime: recordDateTime,
  2167. Stage: 6,
  2168. }
  2169. service.CreateErrMsgLog(errlog)
  2170. c.ServeSuccessJSON(map[string]interface{}{
  2171. "failed_code": -10,
  2172. "msg": res.ErrMsg,
  2173. })
  2174. return
  2175. } else {
  2176. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  2177. order.OrderStatus = 2
  2178. order.Status = 1
  2179. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  2180. order.SetlId = res.Output.Setlinfo.SetlID
  2181. order.PsnNo = res.Output.Setlinfo.PsnNo
  2182. order.PsnName = res.Output.Setlinfo.PsnName
  2183. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  2184. order.Certno = res.Output.Setlinfo.Certno
  2185. order.Gend = res.Output.Setlinfo.Gend
  2186. order.Naty = res.Output.Setlinfo.Naty
  2187. order.Age = res.Output.Setlinfo.Age
  2188. order.Insutype = res.Output.Setlinfo.Insutype
  2189. order.PsnType = res.Output.Setlinfo.PsnType
  2190. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2191. order.SetlTime = res.Output.Setlinfo.SetlTime
  2192. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2193. order.MedType = res.Output.Setlinfo.MedType
  2194. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2195. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2196. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2197. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2198. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2199. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2200. order.HifpPay = res.Output.Setlinfo.HifpPay
  2201. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  2202. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2203. order.HifesPay = res.Output.Setlinfo.HifesPay
  2204. order.HifobPay = res.Output.Setlinfo.HifobPay
  2205. order.MafPay = res.Output.Setlinfo.MafPay
  2206. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  2207. order.OthPay = res.Output.Setlinfo.OthPay
  2208. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2209. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2210. order.AcctPay = res.Output.Setlinfo.AcctPay
  2211. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2212. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2213. order.Balc = res.Output.Setlinfo.Balc
  2214. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2215. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2216. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  2217. order.ClrWay = res.Output.Setlinfo.ClrWay
  2218. order.Creator = order.Creator
  2219. order.Modify = roles.AdminUserId
  2220. order.RequestLog = src_resquest
  2221. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2222. detailStr := string(setlDetail)
  2223. order.SetlDetail = detailStr
  2224. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2225. err = service.UpDateOrder(order)
  2226. if err == nil {
  2227. c.ServeSuccessJSON(map[string]interface{}{
  2228. "msg": "结算成功",
  2229. })
  2230. } else {
  2231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2232. return
  2233. }
  2234. }
  2235. } else {
  2236. adminUser := c.GetAdminUserInfo()
  2237. errlog := &models.HisOrderError{
  2238. UserOrgId: adminUser.CurrentOrgId,
  2239. Ctime: time.Now().Unix(),
  2240. Mtime: time.Now().Unix(),
  2241. ErrMsg: res.ErrMsg,
  2242. Status: 1,
  2243. PatientId: id,
  2244. RecordTime: recordDateTime,
  2245. Stage: 4,
  2246. }
  2247. service.CreateErrMsgLog(errlog)
  2248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2249. return
  2250. }
  2251. } else {
  2252. adminUser := c.GetAdminUserInfo()
  2253. errlog := &models.HisOrderError{
  2254. UserOrgId: adminUser.CurrentOrgId,
  2255. Ctime: time.Now().Unix(),
  2256. Mtime: time.Now().Unix(),
  2257. ErrMsg: res.ErrMsg,
  2258. Status: 1,
  2259. PatientId: id,
  2260. RecordTime: recordDateTime,
  2261. Stage: 4,
  2262. }
  2263. service.CreateErrMsgLog(errlog)
  2264. c.ServeSuccessJSON(map[string]interface{}{
  2265. "failed_code": -10,
  2266. "msg": res.ErrMsg,
  2267. })
  2268. return
  2269. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  2270. //return
  2271. }
  2272. }
  2273. }
  2274. } else if tempOrder.ID > 0 {
  2275. if tempOrder.IsPre == 1 {
  2276. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  2277. var rf []*ResultFive
  2278. json.Unmarshal([]byte(his.Iinfo), &rf)
  2279. chrg_bchno := tempOrder.Number
  2280. cert_no := his.Certno
  2281. var insutypes []string
  2282. var insutype string
  2283. var is390 int = 0
  2284. var is310 int = 0
  2285. for _, item := range rf {
  2286. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2287. insutypes = append(insutypes, item.Insutype)
  2288. }
  2289. }
  2290. if len(insutypes) == 1 {
  2291. insutype = insutypes[0]
  2292. } else {
  2293. for _, i := range insutypes {
  2294. if i == "390" {
  2295. is390 = 1
  2296. }
  2297. if i == "310" {
  2298. is310 = 1
  2299. }
  2300. }
  2301. }
  2302. if is390 == 1 {
  2303. insutype = "390"
  2304. }
  2305. if is310 == 1 {
  2306. insutype = "310"
  2307. }
  2308. if len(insutypes) == 0 {
  2309. insutype = "310"
  2310. }
  2311. //insutype = "390"
  2312. if his.IdCardType == 1 {
  2313. // cert_no = his.MedicalInsuranceNumber
  2314. cert_no = his.Certno
  2315. } else {
  2316. cert_no = his.Certno
  2317. }
  2318. result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType)
  2319. var dat map[string]interface{}
  2320. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2321. fmt.Println(dat)
  2322. } else {
  2323. fmt.Println(err)
  2324. }
  2325. userJSONBytes, _ := json.Marshal(dat)
  2326. var res ResultSeven
  2327. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2328. utils.ErrorLog("解析失败:%v", err)
  2329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2330. return
  2331. }
  2332. if res.Infcode != 0 {
  2333. errlog := &models.HisOrderError{
  2334. UserOrgId: adminUser.CurrentOrgId,
  2335. Ctime: time.Now().Unix(),
  2336. Mtime: time.Now().Unix(),
  2337. Number: chrg_bchno,
  2338. ErrMsg: res.ErrMsg,
  2339. Status: 1,
  2340. PatientId: id,
  2341. RecordTime: recordDateTime,
  2342. Stage: 6,
  2343. }
  2344. service.CreateErrMsgLog(errlog)
  2345. c.ServeSuccessJSON(map[string]interface{}{
  2346. "failed_code": -10,
  2347. "msg": res.ErrMsg,
  2348. })
  2349. return
  2350. } else {
  2351. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  2352. order.OrderStatus = 2
  2353. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  2354. order.SetlId = res.Output.Setlinfo.SetlID
  2355. order.PsnNo = res.Output.Setlinfo.PsnNo
  2356. order.PsnName = res.Output.Setlinfo.PsnName
  2357. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  2358. order.Certno = res.Output.Setlinfo.Certno
  2359. order.Gend = res.Output.Setlinfo.Gend
  2360. order.Naty = res.Output.Setlinfo.Naty
  2361. order.Age = res.Output.Setlinfo.Age
  2362. order.Insutype = res.Output.Setlinfo.Insutype
  2363. order.PsnType = res.Output.Setlinfo.PsnType
  2364. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2365. order.SetlTime = res.Output.Setlinfo.SetlTime
  2366. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2367. order.MedType = res.Output.Setlinfo.MedType
  2368. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2369. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2370. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2371. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2372. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2373. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2374. order.HifpPay = res.Output.Setlinfo.HifpPay
  2375. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  2376. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2377. order.HifesPay = res.Output.Setlinfo.HifesPay
  2378. order.HifobPay = res.Output.Setlinfo.HifobPay
  2379. order.MafPay = res.Output.Setlinfo.MafPay
  2380. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  2381. order.OthPay = res.Output.Setlinfo.OthPay
  2382. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2383. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2384. order.AcctPay = res.Output.Setlinfo.AcctPay
  2385. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2386. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2387. order.Balc = res.Output.Setlinfo.Balc
  2388. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2389. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2390. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  2391. order.ClrWay = res.Output.Setlinfo.ClrWay
  2392. order.Creator = order.Creator
  2393. order.Modify = roles.AdminUserId
  2394. order.RequestLog = src_resquest
  2395. order.Diagnosis = diagnosis_id
  2396. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2397. detailStr := string(setlDetail)
  2398. order.SetlDetail = detailStr
  2399. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2400. err = service.UpDateOrder(order)
  2401. if err == nil {
  2402. c.ServeSuccessJSON(map[string]interface{}{
  2403. "msg": "结算成功",
  2404. })
  2405. } else {
  2406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2407. return
  2408. }
  2409. }
  2410. }
  2411. }
  2412. }
  2413. //func (c *HisApiController) GetPreUploadInfo() {
  2414. // id, _ := c.GetInt64("id")
  2415. // record_time := c.GetString("record_time")
  2416. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2417. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2418. //
  2419. // timeLayout := "2006-01-02"
  2420. // loc, _ := time.LoadLocation("Local")
  2421. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2422. // if err != nil {
  2423. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2424. // return
  2425. // }
  2426. // recordDateTime := theTime.Unix()
  2427. // adminUser := c.GetAdminUserInfo()
  2428. //
  2429. // var prescriptions []*models.HisPrescription
  2430. //
  2431. // var start_time int64
  2432. // var end_time int64
  2433. //
  2434. // data := make(map[string]interface{})
  2435. // if settle_accounts_type == 1 { //日结
  2436. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  2437. // data["pre"] = prescriptions
  2438. //
  2439. // } else { //月结
  2440. // start_time_str := c.GetString("start_time")
  2441. // end_time_str := c.GetString("end_time")
  2442. // timeLayout := "2006-01-02"
  2443. // loc, _ := time.LoadLocation("Local")
  2444. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2445. // if err != nil {
  2446. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2447. // return
  2448. // }
  2449. // recordStartTime := theStartTime.Unix()
  2450. // start_time = recordStartTime
  2451. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2452. // if err != nil {
  2453. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2454. // return
  2455. // }
  2456. // recordEndTime := theEndTime.Unix()
  2457. // end_time = recordEndTime
  2458. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  2459. // data["pre"] = prescriptions
  2460. //
  2461. // }
  2462. //
  2463. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2464. //
  2465. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2466. // timestamp := time.Now().Unix()
  2467. // tempTime := time.Unix(timestamp, 0)
  2468. // timeFormat := tempTime.Format("20060102150405")
  2469. // chrgBchno := rand.Intn(100000) + 10000
  2470. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2471. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2472. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2473. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2474. // strconv.FormatInt(his.PatientId, 10)
  2475. // client := &http.Client{}
  2476. // data["psn_no"] = his.PsnNo
  2477. // data["mdtrt_id"] = his.Number
  2478. // data["chrg_bchno"] = chrg_bchno
  2479. // data["org_name"] = miConfig.OrgName
  2480. // data["doctor"] = roles.UserName
  2481. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  2482. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  2483. // data["fixmedins_code"] = miConfig.Code
  2484. // data["dept_code"] = department.Number
  2485. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2486. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2487. // data["secret_key"] = miConfig.SecretKey
  2488. // var ids []int64
  2489. //
  2490. // for _, item := range prescriptions {
  2491. // ids = append(ids, item.ID)
  2492. // }
  2493. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2494. // if config.IsOpen == 1 { //对接了医保,走医保流程
  2495. // bytesData, _ := json.Marshal(data)
  2496. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  2497. // resp, _ := client.Do(req)
  2498. // defer resp.Body.Close()
  2499. // body, ioErr := ioutil.ReadAll(resp.Body)
  2500. // if ioErr != nil {
  2501. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2502. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2503. // return
  2504. // }
  2505. // var respJSON map[string]interface{}
  2506. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2507. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2508. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2509. // return
  2510. // }
  2511. //
  2512. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2513. // userJSONBytes, _ := json.Marshal(respJSON)
  2514. // var res ResultFour
  2515. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2516. // utils.ErrorLog("解析失败:%v", err)
  2517. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2518. // return
  2519. // }
  2520. //
  2521. // if res.Infcode == 0 {
  2522. // order := &models.HisOrder{
  2523. // UserOrgId: adminUser.CurrentOrgId,
  2524. // HisPatientId: his.ID,
  2525. // PatientId: his.PatientId,
  2526. // SettleAccountsDate: recordDateTime,
  2527. // Ctime: time.Now().Unix(),
  2528. // Mtime: time.Now().Unix(),
  2529. // Status: 1,
  2530. // Number: chrg_bchno,
  2531. // Infcode: res.Infcode,
  2532. // WarnMsg: res.WarnMsg,
  2533. // Cainfo: res.Cainfo,
  2534. // ErrMsg: res.ErrMsg,
  2535. // RespondTime: res.RefmsgTime,
  2536. // InfRefmsgid: res.InfRefmsgid,
  2537. // OrderStatus: 1,
  2538. // IsMedicineInsurance: 1,
  2539. // SettleType: settle_accounts_type,
  2540. // SettleStartTime: start_time,
  2541. // SettleEndTime: end_time,
  2542. // Creator: roles.ID,
  2543. // Modify: roles.ID,
  2544. // PType: 2,
  2545. // }
  2546. // err = service.CreateOrder(order)
  2547. // if err != nil {
  2548. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2549. // return
  2550. // }
  2551. //
  2552. // for _, item := range res.Output.Result {
  2553. // temp := strings.Split(item.FeedetlSn, "-")
  2554. // var advice_id int64 = 0
  2555. // var project_id int64 = 0
  2556. // var types int64 = 0
  2557. //
  2558. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  2559. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  2560. //
  2561. // if temp[1] == "1" {
  2562. // advice_id = id
  2563. // project_id = 0
  2564. // } else if temp[1] == "2" {
  2565. // advice_id = 0
  2566. // project_id = id
  2567. // }
  2568. //
  2569. // info := &models.HisOrderInfo{
  2570. // OrderNumber: order.Number,
  2571. // FeedetlSn: item.FeedetlSn,
  2572. // UploadDate: time.Now().Unix(),
  2573. // AdviceId: advice_id,
  2574. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  2575. // Cnt: item.Cnt,
  2576. // Pric: float64(item.Pric),
  2577. // PatientId: his.PatientId,
  2578. // PricUplmtAmt: item.PricUplmtAmt,
  2579. // SelfpayProp: item.SelfpayProp,
  2580. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  2581. // OverlmtAmt: item.OverlmtAmt,
  2582. // PreselfpayAmt: item.PreselfpayAmt,
  2583. // BasMednFlag: item.BasMednFlag,
  2584. // MedChrgitmType: item.MedChrgitmType,
  2585. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  2586. // Status: 1,
  2587. // Memo: item.Memo,
  2588. // Mtime: time.Now().Unix(),
  2589. // InscpScpAmt: item.InscpScpAmt,
  2590. // DrtReimFlag: item.DrtReimFlag,
  2591. // Ctime: time.Now().Unix(),
  2592. // ListSpItemFlag: item.ListSpItemFlag,
  2593. // ChldMedcFlag: item.ChldMedcFlag,
  2594. // LmtUsedFlag: item.LmtUsedFlag,
  2595. // ChrgitmLv: item.ChrgitmLv,
  2596. // UserOrgId: adminUser.CurrentOrgId,
  2597. // HisPatientId: his.ID,
  2598. // OrderId: order.ID,
  2599. // ProjectId: project_id,
  2600. // Type: types,
  2601. // }
  2602. // service.CreateOrderInfo(info)
  2603. //
  2604. // }
  2605. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2606. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  2607. //
  2608. // var total float64
  2609. // for _, item := range prescriptions {
  2610. // if item.Type == 1 { //药品
  2611. // for _, subItem := range item.HisDoctorAdviceInfo {
  2612. // total = total + (subItem.Price * subItem.PrescribingNumber)
  2613. // }
  2614. // }
  2615. // if item.Type == 2 { //项目
  2616. // for _, subItem := range item.HisPrescriptionProject {
  2617. // total = total + (subItem.Price * float64(subItem.Count))
  2618. // }
  2619. // }
  2620. // }
  2621. //
  2622. // for _, item := range prescriptions {
  2623. // for _, subItem := range item.HisAdditionalCharge {
  2624. // total = total + (subItem.Price * float64(subItem.Count))
  2625. // }
  2626. // }
  2627. //
  2628. // allTotal := fmt.Sprintf("%.2f", total)
  2629. // if res.Infcode == 0 {
  2630. // var rf []*ResultFive
  2631. // json.Unmarshal([]byte(his.Iinfo), &rf)
  2632. // psn_no := his.PsnNo
  2633. // mdtrt_id := his.Number
  2634. // chrg_bchno := chrg_bchno
  2635. // cert_no := his.Certno
  2636. // insutype := rf[0].Insutype
  2637. //
  2638. // if his.IdCardType == 1 {
  2639. // cert_no = his.MedicalInsuranceNumber
  2640. //
  2641. // } else {
  2642. //
  2643. // cert_no = his.Certno
  2644. //
  2645. // }
  2646. //
  2647. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  2648. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  2649. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  2650. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  2651. // resp, requestErr := http.Get(api)
  2652. // if requestErr != nil {
  2653. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2654. // return
  2655. // }
  2656. // defer resp.Body.Close()
  2657. // body, ioErr := ioutil.ReadAll(resp.Body)
  2658. // if ioErr != nil {
  2659. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2660. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2661. // return
  2662. // }
  2663. // var respJSON map[string]interface{}
  2664. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2665. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2666. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2667. // return
  2668. // }
  2669. // fmt.Println(respJSON)
  2670. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2671. // userJSONBytes, _ := json.Marshal(respJSON)
  2672. // var res ResultSeven
  2673. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2674. // utils.ErrorLog("解析失败:%v", err)
  2675. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2676. // return
  2677. // }
  2678. // if res.Infcode != 0 {
  2679. // errlog := &models.HisOrderError{
  2680. // UserOrgId: adminUser.CurrentOrgId,
  2681. // Ctime: time.Now().Unix(),
  2682. // Mtime: time.Now().Unix(),
  2683. // Number: chrg_bchno,
  2684. // ErrMsg: res.ErrMsg,
  2685. // Status: 1,
  2686. // PatientId: id,
  2687. // RecordTime: recordDateTime,
  2688. // Stage: 7,
  2689. // }
  2690. // service.CreateErrMsgLog(errlog)
  2691. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2692. // return
  2693. // } else {
  2694. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  2695. // order.OrderStatus = 1
  2696. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  2697. // order.SetlId = res.Output.Setlinfo.SetlID
  2698. // order.PsnNo = res.Output.Setlinfo.PsnNo
  2699. // order.PsnName = res.Output.Setlinfo.PsnName
  2700. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  2701. // order.Certno = res.Output.Setlinfo.Certno
  2702. // order.Gend = res.Output.Setlinfo.Gend
  2703. // order.Naty = res.Output.Setlinfo.Naty
  2704. // order.Age = res.Output.Setlinfo.Age
  2705. // order.Insutype = res.Output.Setlinfo.Insutype
  2706. // order.PsnType = res.Output.Setlinfo.PsnType
  2707. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2708. // order.SetlTime = res.Output.Setlinfo.SetlTime
  2709. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2710. // order.MedType = res.Output.Setlinfo.MedType
  2711. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2712. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2713. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2714. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2715. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2716. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2717. // order.HifpPay = res.Output.Setlinfo.HifpPay
  2718. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  2719. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2720. // order.HifesPay = res.Output.Setlinfo.HifesPay
  2721. // order.HifobPay = res.Output.Setlinfo.HifobPay
  2722. // order.MafPay = res.Output.Setlinfo.MafPay
  2723. // order.OthPay = res.Output.Setlinfo.OthPay
  2724. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2725. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2726. // order.AcctPay = res.Output.Setlinfo.AcctPay
  2727. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2728. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2729. // order.Balc = res.Output.Setlinfo.Balc
  2730. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2731. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2732. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  2733. // order.ClrWay = res.Output.Setlinfo.ClrWay
  2734. // order.Creator = order.Creator
  2735. // order.Modify = roles.ID
  2736. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2737. // detailStr := string(setlDetail)
  2738. // order.SetlDetail = detailStr
  2739. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2740. // err = service.UpDateOrder(order)
  2741. // if err == nil {
  2742. // c.ServeSuccessJSON(map[string]interface{}{
  2743. // "msg": "预结算成功",
  2744. // })
  2745. // } else {
  2746. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2747. // return
  2748. // }
  2749. // }
  2750. // } else {
  2751. // adminUser := c.GetAdminUserInfo()
  2752. // errlog := &models.HisOrderError{
  2753. // UserOrgId: adminUser.CurrentOrgId,
  2754. // Ctime: time.Now().Unix(),
  2755. // Mtime: time.Now().Unix(),
  2756. // ErrMsg: res.ErrMsg,
  2757. // Status: 1,
  2758. // PatientId: id,
  2759. // RecordTime: recordDateTime,
  2760. // Stage: 4,
  2761. // }
  2762. // service.CreateErrMsgLog(errlog)
  2763. //
  2764. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2765. // return
  2766. // }
  2767. // } else {
  2768. // adminUser := c.GetAdminUserInfo()
  2769. // errlog := &models.HisOrderError{
  2770. // UserOrgId: adminUser.CurrentOrgId,
  2771. // Ctime: time.Now().Unix(),
  2772. // Mtime: time.Now().Unix(),
  2773. // ErrMsg: res.ErrMsg,
  2774. // Status: 1,
  2775. // PatientId: id,
  2776. // RecordTime: recordDateTime,
  2777. // Stage: 4,
  2778. // }
  2779. // service.CreateErrMsgLog(errlog)
  2780. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  2781. // return
  2782. // }
  2783. //
  2784. // } else {
  2785. // var total float64
  2786. // for _, item := range prescriptions {
  2787. // if item.Type == 1 { //药品
  2788. // for _, subItem := range item.HisDoctorAdviceInfo {
  2789. // total = total + (subItem.Price * subItem.PrescribingNumber)
  2790. // }
  2791. // }
  2792. // if item.Type == 2 { //项目
  2793. // for _, subItem := range item.HisPrescriptionProject {
  2794. // total = total + (subItem.Price * float64(subItem.Count))
  2795. // }
  2796. // }
  2797. //
  2798. // for _, subItem := range item.HisAdditionalCharge {
  2799. // total = total + (subItem.Price * float64(subItem.Count))
  2800. // }
  2801. // }
  2802. //
  2803. // allTotal := fmt.Sprintf("%.2f", total)
  2804. // totals, _ := strconv.ParseFloat(allTotal, 64)
  2805. // order := &models.HisOrder{
  2806. // UserOrgId: adminUser.CurrentOrgId,
  2807. // HisPatientId: his.ID,
  2808. // PatientId: id,
  2809. // SettleAccountsDate: recordDateTime,
  2810. // Ctime: time.Now().Unix(),
  2811. // Mtime: time.Now().Unix(),
  2812. // Status: 1,
  2813. // OrderStatus: 2,
  2814. // Number: chrg_bchno,
  2815. // MedfeeSumamt: totals,
  2816. // }
  2817. // err = service.CreateOrder(order)
  2818. // if err != nil {
  2819. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2820. // return
  2821. // }
  2822. //
  2823. // var customs []*Custom
  2824. // for _, item := range prescriptions {
  2825. //
  2826. // if item.Type == 1 { //药品
  2827. // for _, subItem := range item.HisDoctorAdviceInfo {
  2828. // cus := &Custom{
  2829. // AdviceId: subItem.ID,
  2830. // ProjectId: 0,
  2831. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  2832. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  2833. // FeedetlSn: subItem.FeedetlSn,
  2834. // Price: fmt.Sprintf("%.2f", subItem.Price),
  2835. // MedListCodg: subItem.MedListCodg,
  2836. // Type: 1,
  2837. // }
  2838. // customs = append(customs, cus)
  2839. // }
  2840. // }
  2841. //
  2842. // if item.Type == 2 { //项目
  2843. // for _, subItem := range item.HisPrescriptionProject {
  2844. //
  2845. // cus := &Custom{
  2846. // AdviceId: 0,
  2847. // ProjectId: subItem.ID,
  2848. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  2849. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  2850. // FeedetlSn: subItem.FeedetlSn,
  2851. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  2852. // MedListCodg: subItem.MedListCodg,
  2853. // Type: 2,
  2854. // }
  2855. //
  2856. // customs = append(customs, cus)
  2857. // }
  2858. // }
  2859. //
  2860. // for _, item := range item.HisAdditionalCharge {
  2861. // cus := &Custom{
  2862. // ItemId: item.ID,
  2863. // AdviceId: 0,
  2864. // ProjectId: 0,
  2865. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  2866. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  2867. // FeedetlSn: item.FeedetlSn,
  2868. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  2869. // MedListCodg: item.XtHisAddtionConfig.Code,
  2870. // Type: 3,
  2871. // }
  2872. //
  2873. // customs = append(customs, cus)
  2874. // }
  2875. //
  2876. // }
  2877. //
  2878. // for _, item := range customs {
  2879. // var advice_id int64 = 0
  2880. // var project_id int64 = 0
  2881. // var item_id int64 = 0
  2882. //
  2883. // var types int64 = 0
  2884. //
  2885. // if item.Type == 1 {
  2886. // advice_id = item.AdviceId
  2887. // project_id = 0
  2888. // item_id = 0
  2889. // } else if item.Type == 2 {
  2890. // advice_id = 0
  2891. // item_id = 0
  2892. //
  2893. // project_id = item.ProjectId
  2894. // } else if item.Type == 3 {
  2895. // advice_id = 0
  2896. // item_id = item.ItemId
  2897. // project_id = 0
  2898. // }
  2899. //
  2900. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  2901. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  2902. // pric, _ := strconv.ParseFloat(item.Price, 32)
  2903. //
  2904. // info := &models.HisOrderInfo{
  2905. // OrderNumber: order.Number,
  2906. // UploadDate: time.Now().Unix(),
  2907. // AdviceId: advice_id,
  2908. // DetItemFeeSumamt: detItemFeeSumamt,
  2909. // Cnt: cut,
  2910. // Pric: pric,
  2911. // PatientId: id,
  2912. // Status: 1,
  2913. // Mtime: time.Now().Unix(),
  2914. // Ctime: time.Now().Unix(),
  2915. // UserOrgId: adminUser.CurrentOrgId,
  2916. // HisPatientId: his.ID,
  2917. // OrderId: order.ID,
  2918. // ProjectId: project_id,
  2919. // Type: types,
  2920. // ItemId: item_id,
  2921. // }
  2922. // service.CreateOrderInfo(info)
  2923. // }
  2924. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2925. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2926. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  2927. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2928. // if err == nil {
  2929. // c.ServeSuccessJSON(map[string]interface{}{
  2930. // "msg": "结算成功",
  2931. // })
  2932. // } else {
  2933. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2934. // return
  2935. // }
  2936. // }
  2937. //}
  2938. //上传明细-预结算-
  2939. func (c *HisApiController) GetPreUploadInfo() {
  2940. id, _ := c.GetInt64("id")
  2941. record_time := c.GetString("record_time")
  2942. his_patient_id, _ := c.GetInt64("his_patient_id")
  2943. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2944. admin_user_id, _ := c.GetInt64("admin_user_id")
  2945. diagnosis_id := c.GetString("diagnosis")
  2946. sick_type, _ := c.GetInt64("sick_type")
  2947. reg_type, _ := c.GetInt64("p_type")
  2948. id_str := c.GetString("ids")
  2949. ids_arr := strings.Split(id_str, ",")
  2950. timeLayout := "2006-01-02"
  2951. loc, _ := time.LoadLocation("Local")
  2952. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2953. if err != nil {
  2954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2955. return
  2956. }
  2957. recordDateTime := theTime.Unix()
  2958. adminUser := c.GetAdminUserInfo()
  2959. diagnosis_ids := strings.Split(diagnosis_id, ",")
  2960. var config []*models.HisXtDiagnoseConfig
  2961. for _, item := range diagnosis_ids {
  2962. id, _ := strconv.ParseInt(item, 10, 64)
  2963. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2964. config = append(config, diagnosisConfig)
  2965. }
  2966. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  2967. sickConfig, _ := service.FindSickById(sick_type)
  2968. var prescriptions []*models.HisPrescription
  2969. var start_time int64
  2970. var end_time int64
  2971. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2972. fmt.Println(his_patient_id)
  2973. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2974. timestamp := time.Now().Unix()
  2975. tempTime := time.Unix(timestamp, 0)
  2976. timeFormat := tempTime.Format("20060102150405")
  2977. chrgBchno := rand.Intn(100000) + 10000
  2978. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2979. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2980. var patientPrescription models.HisPrescriptionInfo
  2981. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2982. if patientPrescription.ID == 0 {
  2983. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2984. }
  2985. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2986. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2987. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2988. strconv.FormatInt(his.PatientId, 10)
  2989. var result string
  2990. if miConfig.InsuplcAdmdvs == "440781" { //
  2991. result = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.AdminUserId, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config)
  2992. } else {
  2993. result = service.Gdyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.AdminUserId, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.CountryCode, sickConfig.ClassName, roles.UserName, config)
  2994. }
  2995. var respJSON2 map[string]interface{}
  2996. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2999. return
  3000. }
  3001. userJSONBytes2, _ := json.Marshal(respJSON2)
  3002. var res2 ResultSix
  3003. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3004. utils.ErrorLog("解析失败:%v", err)
  3005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3006. return
  3007. }
  3008. if res2.Infcode != 0 {
  3009. adminUser := c.GetAdminUserInfo()
  3010. errlog := &models.HisOrderError{
  3011. UserOrgId: adminUser.CurrentOrgId,
  3012. Ctime: time.Now().Unix(),
  3013. Mtime: time.Now().Unix(),
  3014. ErrMsg: res2.ErrMsg,
  3015. Status: 1,
  3016. PatientId: id,
  3017. RecordTime: recordDateTime,
  3018. Stage: 3,
  3019. }
  3020. service.CreateErrMsgLog(errlog)
  3021. c.ServeSuccessJSON(map[string]interface{}{
  3022. "failed_code": -10,
  3023. "msg": res2.ErrMsg,
  3024. })
  3025. return
  3026. } else {
  3027. his.Diagnosis = diagnosis_id
  3028. his.SickType = sickConfig.ID
  3029. his.PType = fmt.Sprintf("%d", reg_type)
  3030. service.UpdateHisPatientThree(&his)
  3031. data := make(map[string]interface{})
  3032. if settle_accounts_type == 1 { //日结
  3033. if reg_type == 11 {
  3034. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  3035. } else {
  3036. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  3037. }
  3038. data["pre"] = prescriptions
  3039. } else { //月结
  3040. start_time_str := c.GetString("start_time")
  3041. end_time_str := c.GetString("end_time")
  3042. timeLayout := "2006-01-02"
  3043. loc, _ := time.LoadLocation("Local")
  3044. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3045. if err != nil {
  3046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3047. return
  3048. }
  3049. recordStartTime := theStartTime.Unix()
  3050. start_time = recordStartTime
  3051. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3052. if err != nil {
  3053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3054. return
  3055. }
  3056. recordEndTime := theEndTime.Unix()
  3057. end_time = recordEndTime
  3058. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3059. data["pre"] = prescriptions
  3060. }
  3061. if reg_type == 1111 || reg_type == 1112 {
  3062. reg_type = 11
  3063. }
  3064. client := &http.Client{}
  3065. data["psn_no"] = his.PsnNo
  3066. data["mdtrt_id"] = his.Number
  3067. data["chrg_bchno"] = chrg_bchno
  3068. data["org_name"] = miConfig.OrgName
  3069. data["doctor"] = roles.UserName
  3070. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3071. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3072. data["fixmedins_code"] = miConfig.Code
  3073. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3074. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3075. data["dept_code"] = "15"
  3076. } else {
  3077. data["dept_code"] = department.Number
  3078. }
  3079. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3080. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3081. data["secret_key"] = miConfig.SecretKey
  3082. var ids []int64
  3083. for _, item := range prescriptions {
  3084. ids = append(ids, item.ID)
  3085. }
  3086. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3087. if config.IsOpen == 1 { //对接了医保,走医保流程
  3088. bytesData, _ := json.Marshal(data)
  3089. req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  3090. resp, _ := client.Do(req)
  3091. defer resp.Body.Close()
  3092. body, ioErr := ioutil.ReadAll(resp.Body)
  3093. if ioErr != nil {
  3094. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3096. return
  3097. }
  3098. var respJSON map[string]interface{}
  3099. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3100. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3102. return
  3103. }
  3104. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3105. userJSONBytes, _ := json.Marshal(respJSON)
  3106. var res ResultFour
  3107. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3108. utils.ErrorLog("解析失败:%v", err)
  3109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3110. return
  3111. }
  3112. if res.Infcode == 0 {
  3113. order := &models.HisOrder{
  3114. UserOrgId: adminUser.CurrentOrgId,
  3115. HisPatientId: his.ID,
  3116. PatientId: his.PatientId,
  3117. SettleAccountsDate: recordDateTime,
  3118. Ctime: time.Now().Unix(),
  3119. Mtime: time.Now().Unix(),
  3120. Status: 0,
  3121. Number: chrg_bchno,
  3122. Infcode: res.Infcode,
  3123. WarnMsg: res.WarnMsg,
  3124. Cainfo: res.Cainfo,
  3125. ErrMsg: res.ErrMsg,
  3126. RespondTime: res.RefmsgTime,
  3127. InfRefmsgid: res.InfRefmsgid,
  3128. OrderStatus: 1,
  3129. IsMedicineInsurance: 1,
  3130. SettleType: settle_accounts_type,
  3131. SettleStartTime: start_time,
  3132. SettleEndTime: end_time,
  3133. Creator: roles.AdminUserId,
  3134. Modify: roles.AdminUserId,
  3135. PType: 2,
  3136. Diagnosis: diagnosis_id,
  3137. }
  3138. err = service.CreateOrder(order)
  3139. if err != nil {
  3140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3141. return
  3142. }
  3143. for _, item := range res.Output.Result {
  3144. temp := strings.Split(item.FeedetlSn, "-")
  3145. var advice_id int64 = 0
  3146. var project_id int64 = 0
  3147. var types int64 = 0
  3148. id, _ := strconv.ParseInt(temp[2], 10, 64)
  3149. types, _ = strconv.ParseInt(temp[1], 10, 64)
  3150. if temp[1] == "1" {
  3151. advice_id = id
  3152. project_id = 0
  3153. } else if temp[1] == "2" {
  3154. advice_id = 0
  3155. project_id = id
  3156. }
  3157. info := &models.HisOrderInfo{
  3158. OrderNumber: order.Number,
  3159. FeedetlSn: item.FeedetlSn,
  3160. UploadDate: time.Now().Unix(),
  3161. AdviceId: advice_id,
  3162. DetItemFeeSumamt: item.DetItemFeeSumamt,
  3163. Cnt: item.Cnt,
  3164. Pric: float64(item.Pric),
  3165. PatientId: his.PatientId,
  3166. PricUplmtAmt: item.PricUplmtAmt,
  3167. SelfpayProp: item.SelfpayProp,
  3168. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3169. OverlmtAmt: item.OverlmtAmt,
  3170. PreselfpayAmt: item.PreselfpayAmt,
  3171. BasMednFlag: item.BasMednFlag,
  3172. MedChrgitmType: item.MedChrgitmType,
  3173. HiNegoDrugFlag: item.HiNegoDrugFlag,
  3174. Status: 1,
  3175. Memo: item.Memo,
  3176. Mtime: time.Now().Unix(),
  3177. InscpScpAmt: item.InscpScpAmt,
  3178. DrtReimFlag: item.DrtReimFlag,
  3179. Ctime: time.Now().Unix(),
  3180. ListSpItemFlag: item.ListSpItemFlag,
  3181. ChldMedcFlag: item.ChldMedcFlag,
  3182. LmtUsedFlag: item.LmtUsedFlag,
  3183. ChrgitmLv: item.ChrgitmLv,
  3184. UserOrgId: adminUser.CurrentOrgId,
  3185. HisPatientId: his.ID,
  3186. OrderId: order.ID,
  3187. ProjectId: project_id,
  3188. Type: types,
  3189. }
  3190. service.CreateOrderInfo(info)
  3191. }
  3192. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3193. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  3194. var total float64
  3195. for _, item := range prescriptions {
  3196. if item.Type == 1 { //药品
  3197. for _, subItem := range item.HisDoctorAdviceInfo {
  3198. total = total + (subItem.Price * subItem.PrescribingNumber)
  3199. }
  3200. }
  3201. if item.Type == 2 { //项目
  3202. for _, subItem := range item.HisPrescriptionProject {
  3203. total = total + (subItem.Price * float64(subItem.Count))
  3204. }
  3205. }
  3206. }
  3207. for _, item := range prescriptions {
  3208. for _, subItem := range item.HisAdditionalCharge {
  3209. total = total + (subItem.Price * float64(subItem.Count))
  3210. }
  3211. }
  3212. allTotal := fmt.Sprintf("%.2f", total)
  3213. if res.Infcode == 0 {
  3214. var rf []*ResultFive
  3215. json.Unmarshal([]byte(his.Iinfo), &rf)
  3216. chrg_bchno := chrg_bchno
  3217. cert_no := his.Certno
  3218. var insutypes []string
  3219. var insutype string
  3220. var is390 int = 0
  3221. var is310 int = 0
  3222. for _, item := range rf {
  3223. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3224. insutypes = append(insutypes, item.Insutype)
  3225. }
  3226. }
  3227. if len(insutypes) == 1 {
  3228. insutype = insutypes[0]
  3229. } else {
  3230. for _, i := range insutypes {
  3231. if i == "390" {
  3232. is390 = 1
  3233. }
  3234. if i == "310" {
  3235. is310 = 1
  3236. }
  3237. }
  3238. }
  3239. if is390 == 1 {
  3240. insutype = "390"
  3241. }
  3242. if is310 == 1 {
  3243. insutype = "310"
  3244. }
  3245. if len(insutypes) == 0 {
  3246. insutype = "310"
  3247. }
  3248. //insutype = "390"
  3249. if his.IdCardType == 1 {
  3250. cert_no = his.MedicalInsuranceNumber
  3251. } else {
  3252. cert_no = his.Certno
  3253. }
  3254. result := service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  3255. var dat map[string]interface{}
  3256. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3257. fmt.Println(dat)
  3258. } else {
  3259. fmt.Println(err)
  3260. }
  3261. userJSONBytes, _ := json.Marshal(dat)
  3262. var res ResultSeven
  3263. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3264. utils.ErrorLog("解析失败:%v", err)
  3265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3266. return
  3267. }
  3268. if res.Infcode != 0 {
  3269. errlog := &models.HisOrderError{
  3270. UserOrgId: adminUser.CurrentOrgId,
  3271. Ctime: time.Now().Unix(),
  3272. Mtime: time.Now().Unix(),
  3273. Number: chrg_bchno,
  3274. ErrMsg: res.ErrMsg,
  3275. Status: 1,
  3276. PatientId: id,
  3277. RecordTime: recordDateTime,
  3278. Stage: 20,
  3279. }
  3280. service.CreateErrMsgLog(errlog)
  3281. c.ServeSuccessJSON(map[string]interface{}{
  3282. "failed_code": -10,
  3283. "msg": res.ErrMsg,
  3284. })
  3285. return
  3286. } else {
  3287. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3288. order.OrderStatus = 1
  3289. order.IsPre = 1
  3290. order.Status = 1
  3291. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3292. order.SetlId = res.Output.Setlinfo.SetlID
  3293. order.PsnNo = res.Output.Setlinfo.PsnNo
  3294. order.PsnName = res.Output.Setlinfo.PsnName
  3295. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3296. order.Certno = res.Output.Setlinfo.Certno
  3297. order.Gend = res.Output.Setlinfo.Gend
  3298. order.Naty = res.Output.Setlinfo.Naty
  3299. order.Age = res.Output.Setlinfo.Age
  3300. order.Insutype = res.Output.Setlinfo.Insutype
  3301. order.PsnType = res.Output.Setlinfo.PsnType
  3302. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3303. order.SetlTime = res.Output.Setlinfo.SetlTime
  3304. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3305. order.MedType = res.Output.Setlinfo.MedType
  3306. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3307. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3308. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3309. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3310. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3311. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3312. order.HifpPay = res.Output.Setlinfo.HifpPay
  3313. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3314. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3315. order.HifesPay = res.Output.Setlinfo.HifesPay
  3316. order.HifobPay = res.Output.Setlinfo.HifobPay
  3317. order.MafPay = res.Output.Setlinfo.MafPay
  3318. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3319. order.OthPay = res.Output.Setlinfo.OthPay
  3320. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3321. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3322. order.AcctPay = res.Output.Setlinfo.AcctPay
  3323. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3324. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3325. order.Balc = res.Output.Setlinfo.Balc
  3326. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3327. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3328. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3329. order.ClrWay = res.Output.Setlinfo.ClrWay
  3330. order.Creator = order.Creator
  3331. order.Modify = roles.AdminUserId
  3332. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3333. detailStr := string(setlDetail)
  3334. order.SetlDetail = detailStr
  3335. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3336. err = service.UpDateOrder(order)
  3337. if err == nil {
  3338. c.ServeSuccessJSON(map[string]interface{}{
  3339. "msg": "预结算成功",
  3340. })
  3341. } else {
  3342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3343. return
  3344. }
  3345. }
  3346. } else {
  3347. adminUser := c.GetAdminUserInfo()
  3348. errlog := &models.HisOrderError{
  3349. UserOrgId: adminUser.CurrentOrgId,
  3350. Ctime: time.Now().Unix(),
  3351. Mtime: time.Now().Unix(),
  3352. ErrMsg: res.ErrMsg,
  3353. Status: 1,
  3354. PatientId: id,
  3355. RecordTime: recordDateTime,
  3356. Stage: 4,
  3357. }
  3358. service.CreateErrMsgLog(errlog)
  3359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3360. return
  3361. }
  3362. } else {
  3363. adminUser := c.GetAdminUserInfo()
  3364. errlog := &models.HisOrderError{
  3365. UserOrgId: adminUser.CurrentOrgId,
  3366. Ctime: time.Now().Unix(),
  3367. Mtime: time.Now().Unix(),
  3368. ErrMsg: res.ErrMsg,
  3369. Status: 1,
  3370. PatientId: id,
  3371. RecordTime: recordDateTime,
  3372. Stage: 4,
  3373. }
  3374. service.CreateErrMsgLog(errlog)
  3375. c.ServeSuccessJSON(map[string]interface{}{
  3376. "failed_code": -10,
  3377. "msg": res.ErrMsg,
  3378. })
  3379. return
  3380. }
  3381. }
  3382. }
  3383. }
  3384. //func (c *HisApiController) GetSettleInfo() {
  3385. // id, _ := c.GetInt64("id")
  3386. // order_id, _ := c.GetInt64("order_id")
  3387. //
  3388. // record_time := c.GetString("record_time")
  3389. // pay_way, _ := c.GetInt64("pay_way")
  3390. // pay_price, _ := c.GetFloat("pay_price")
  3391. // pay_card_no := c.GetString("pay_card_no")
  3392. // discount_price, _ := c.GetFloat("discount_price")
  3393. // preferential_price, _ := c.GetFloat("preferential_price")
  3394. // reality_price, _ := c.GetFloat("reality_price")
  3395. // found_price, _ := c.GetFloat("found_price")
  3396. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3397. // private_price, _ := c.GetFloat("private_price")
  3398. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3399. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3400. //
  3401. // timeLayout := "2006-01-02"
  3402. // loc, _ := time.LoadLocation("Local")
  3403. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3404. // if err != nil {
  3405. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3406. // return
  3407. // }
  3408. // recordDateTime := theTime.Unix()
  3409. // adminUser := c.GetAdminUserInfo()
  3410. //
  3411. // var prescriptions []*models.HisPrescription
  3412. //
  3413. // data := make(map[string]interface{})
  3414. // if settle_accounts_type == 1 { //日结
  3415. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  3416. // data["pre"] = prescriptions
  3417. //
  3418. // } else { //月结
  3419. // start_time_str := c.GetString("start_time")
  3420. // end_time_str := c.GetString("end_time")
  3421. // timeLayout := "2006-01-02"
  3422. // loc, _ := time.LoadLocation("Local")
  3423. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3424. // if err != nil {
  3425. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3426. // return
  3427. // }
  3428. // recordStartTime := theStartTime.Unix()
  3429. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3430. // if err != nil {
  3431. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3432. // return
  3433. // }
  3434. // recordEndTime := theEndTime.Unix()
  3435. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  3436. // data["pre"] = prescriptions
  3437. //
  3438. // }
  3439. //
  3440. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3441. //
  3442. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3443. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3444. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3445. // strconv.FormatInt(his.PatientId, 10)
  3446. //
  3447. // order_src, _ := service.GetHisOrderByID(order_id)
  3448. //
  3449. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3450. // if config.IsOpen == 1 { //对接了医保,走医保流程
  3451. //
  3452. // var total float64
  3453. // for _, item := range prescriptions {
  3454. // if item.Type == 1 { //药品
  3455. // for _, subItem := range item.HisDoctorAdviceInfo {
  3456. // total = total + (subItem.Price * subItem.PrescribingNumber)
  3457. // }
  3458. // }
  3459. // if item.Type == 2 { //项目
  3460. // for _, subItem := range item.HisPrescriptionProject {
  3461. // total = total + (subItem.Price * float64(subItem.Count))
  3462. // }
  3463. // }
  3464. // }
  3465. //
  3466. // for _, item := range prescriptions {
  3467. // for _, subItem := range item.HisAdditionalCharge {
  3468. // total = total + (subItem.Price * float64(subItem.Count))
  3469. // }
  3470. // }
  3471. //
  3472. // allTotal := fmt.Sprintf("%.2f", total)
  3473. // var rf []*ResultFive
  3474. // json.Unmarshal([]byte(his.Iinfo), &rf)
  3475. // psn_no := order_src.PsnNo
  3476. // mdtrt_id := order_src.MdtrtId
  3477. // chrg_bchno := order_src.Number
  3478. // cert_no := order_src.Certno
  3479. // insutype := rf[0].Insutype
  3480. //
  3481. // if his.IdCardType == 1 {
  3482. // cert_no = his.MedicalInsuranceNumber
  3483. // } else {
  3484. // cert_no = his.Certno
  3485. // }
  3486. //
  3487. // result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, strconv.FormatFloat(total, 'E', -1, 64) ,miConfig.OrgName,roles.UserName,miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(patientPrescription.RegisterType, 10),his.IdCardType, order_src.FulamtOwnpayAmt,order_src.OverlmtSelfPay,order_src.PreselfpayAmt,order_src.InscpScpAmt)
  3488. // var dat map[string]interface{}
  3489. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3490. // fmt.Println(dat)
  3491. // } else {
  3492. // fmt.Println(err)
  3493. // }
  3494. //
  3495. // userJSONBytes, _ := json.Marshal(dat)
  3496. //
  3497. //
  3498. //
  3499. // var res ResultSeven
  3500. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3501. // utils.ErrorLog("解析失败:%v", err)
  3502. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3503. // return
  3504. // }
  3505. // if res.Infcode == -1 {
  3506. // errlog := &models.HisOrderError{
  3507. // UserOrgId: adminUser.CurrentOrgId,
  3508. // Ctime: time.Now().Unix(),
  3509. // Mtime: time.Now().Unix(),
  3510. // Number: chrg_bchno,
  3511. // ErrMsg: res.ErrMsg,
  3512. // Status: 1,
  3513. // PatientId: id,
  3514. // RecordTime: recordDateTime,
  3515. // Stage: 6,
  3516. // }
  3517. // service.CreateErrMsgLog(errlog)
  3518. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3519. // return
  3520. // } else {
  3521. // order_src.OrderStatus = 2
  3522. // order_src.PayWay = pay_way
  3523. // order_src.PayPrice = pay_price
  3524. // order_src.PayCardNo = pay_card_no
  3525. // order_src.DiscountPrice = discount_price
  3526. // order_src.PreferentialPrice = preferential_price
  3527. // order_src.RealityPrice = reality_price
  3528. // order_src.FoundPrice = found_price
  3529. // order_src.MedicalInsurancePrice = medical_insurance_price
  3530. // order_src.PrivatePrice = private_price
  3531. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  3532. // order_src.SetlId = res.Output.Setlinfo.SetlID
  3533. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  3534. // order_src.PsnName = res.Output.Setlinfo.PsnName
  3535. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  3536. // order_src.Certno = res.Output.Setlinfo.Certno
  3537. // order_src.Gend = res.Output.Setlinfo.Gend
  3538. // order_src.Naty = res.Output.Setlinfo.Naty
  3539. // order_src.Age = res.Output.Setlinfo.Age
  3540. // order_src.Insutype = res.Output.Setlinfo.Insutype
  3541. // order_src.PsnType = res.Output.Setlinfo.PsnType
  3542. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3543. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  3544. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3545. // order_src.MedType = res.Output.Setlinfo.MedType
  3546. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3547. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3548. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3549. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3550. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3551. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3552. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  3553. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  3554. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3555. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  3556. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  3557. // order_src.MafPay = res.Output.Setlinfo.MafPay
  3558. // order_src.OthPay = res.Output.Setlinfo.OthPay
  3559. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3560. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3561. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  3562. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3563. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3564. // order_src.Balc = res.Output.Setlinfo.Balc
  3565. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3566. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3567. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  3568. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  3569. // order_src.Creator = order_src.Creator
  3570. // order_src.Modify = roles.ID
  3571. // order_src.RequestLog = src_resquest
  3572. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3573. // detailStr := string(setlDetail)
  3574. // order_src.SetlDetail = detailStr
  3575. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3576. // err = service.UpDateOrder(order_src)
  3577. //
  3578. // if err == nil {
  3579. // c.ServeSuccessJSON(map[string]interface{}{
  3580. // "msg": "结算成功",
  3581. // })
  3582. // } else {
  3583. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3584. // return
  3585. // }
  3586. // }
  3587. // }
  3588. //}
  3589. //退款
  3590. func (c *HisApiController) Refund() {
  3591. order_id, _ := c.GetInt64("order_id")
  3592. admin_user_id, _ := c.GetInt64("admin_user_id")
  3593. //record_time := c.GetString("record_time")
  3594. //patient_id, _ := c.GetInt64("patient_id")
  3595. //timeLayout := "2006-01-02"
  3596. //loc, _ := time.LoadLocation("Local")
  3597. adminUser := c.GetAdminUserInfo()
  3598. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3599. //if err != nil {
  3600. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3601. // return
  3602. //}
  3603. //recordDateTime := theTime.Unix()
  3604. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3605. var order models.HisOrder
  3606. order, _ = service.GetHisOrderByID(order_id)
  3607. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3608. if order.ID == 0 {
  3609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3610. return
  3611. //order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3612. }
  3613. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3614. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3615. if config.IsOpen == 1 { //对接了医保,走医保流程
  3616. result, src_resquest := service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  3617. var dat map[string]interface{}
  3618. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3619. fmt.Println(dat)
  3620. } else {
  3621. fmt.Println(err)
  3622. }
  3623. userJSONBytes, _ := json.Marshal(dat)
  3624. var res ResultSixteen
  3625. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3626. utils.ErrorLog("解析失败:%v", err)
  3627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3628. return
  3629. }
  3630. if res.Infcode == 0 {
  3631. result := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  3632. var dat map[string]interface{}
  3633. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3634. fmt.Println(dat)
  3635. } else {
  3636. fmt.Println(err)
  3637. }
  3638. userJSONBytes, _ := json.Marshal(dat)
  3639. var res2 ResultSix
  3640. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3641. utils.ErrorLog("解析失败:%v", err)
  3642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3643. return
  3644. }
  3645. if res2.Infcode == 0 {
  3646. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  3647. if err == nil {
  3648. c.ServeSuccessJSON(map[string]interface{}{
  3649. "msg": "退费成功",
  3650. })
  3651. } else {
  3652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3653. return
  3654. }
  3655. } else {
  3656. c.ServeSuccessJSON(map[string]interface{}{
  3657. "code": -10,
  3658. "msg": res2.ErrMsg,
  3659. })
  3660. }
  3661. } else {
  3662. c.ServeSuccessJSON(map[string]interface{}{
  3663. "code": -10,
  3664. "msg": res.ErrMsg,
  3665. })
  3666. }
  3667. }
  3668. }
  3669. func (c *HisApiController) RefundNumber() {
  3670. record_time := c.GetString("record_time")
  3671. //patient_id, _ := c.GetInt64("patient_id")
  3672. admin_user_id, _ := c.GetInt64("admin_user_id")
  3673. his_patient_id, _ := c.GetInt64("id")
  3674. timeLayout := "2006-01-02"
  3675. loc, _ := time.LoadLocation("Local")
  3676. adminUser := c.GetAdminUserInfo()
  3677. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3678. fmt.Println(err)
  3679. if err != nil {
  3680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3681. return
  3682. }
  3683. recordDateTime := theTime.Unix()
  3684. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3685. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  3686. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3687. //order, _ := service.GetHisOrderByID(order_id)
  3688. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3689. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3690. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3691. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  3692. if count > 0 {
  3693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  3694. return
  3695. }
  3696. if config.IsOpen == 1 { //对接了医保,走医保流程
  3697. api3 := "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  3698. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  3699. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  3700. resp3, requestErr3 := http.Get(api3)
  3701. if requestErr3 != nil {
  3702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3703. return
  3704. }
  3705. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  3706. if ioErr3 != nil {
  3707. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  3708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3709. return
  3710. }
  3711. var respJSON3 map[string]interface{}
  3712. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  3713. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3715. return
  3716. }
  3717. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3718. userJSONBytes3, _ := json.Marshal(respJSON3)
  3719. var res2 ResultSix
  3720. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  3721. utils.ErrorLog("解析失败:%v", err)
  3722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3723. return
  3724. }
  3725. if res2.Infcode == 0 {
  3726. if err == nil {
  3727. c.ServeSuccessJSON(map[string]interface{}{
  3728. "msg": "退号成功",
  3729. })
  3730. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  3731. } else {
  3732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3733. return
  3734. }
  3735. } else {
  3736. c.ServeSuccessJSON(map[string]interface{}{
  3737. "code": -10,
  3738. "msg": res2.ErrMsg,
  3739. })
  3740. }
  3741. } else {
  3742. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  3743. //if err == nil {
  3744. // c.ServeSuccessJSON(map[string]interface{}{
  3745. // "msg": "退费成功",
  3746. // })
  3747. //} else {
  3748. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3749. // return
  3750. //}
  3751. }
  3752. }
  3753. func (c *HisApiController) RefundDetail() {
  3754. order_id, _ := c.GetInt64("order_id")
  3755. his_patient_id, _ := c.GetInt64("his_patient_id")
  3756. number := c.GetString("number")
  3757. record_time := c.GetString("record_time")
  3758. patient_id, _ := c.GetInt64("patient_id")
  3759. timeLayout := "2006-01-02"
  3760. loc, _ := time.LoadLocation("Local")
  3761. adminUser := c.GetAdminUserInfo()
  3762. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3763. fmt.Println(err)
  3764. if err != nil {
  3765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3766. return
  3767. }
  3768. recordDateTime := theTime.Unix()
  3769. his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3770. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3771. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3772. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3773. var order models.HisOrder
  3774. order, _ = service.GetHisOrderByID(order_id)
  3775. if order.ID == 0 {
  3776. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3777. }
  3778. if config.IsOpen == 1 { //对接了医保,走医保流程
  3779. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  3780. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  3781. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  3782. resp2, requestErr2 := http.Get(api2)
  3783. if requestErr2 != nil {
  3784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3785. return
  3786. }
  3787. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  3788. if ioErr2 != nil {
  3789. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  3790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3791. return
  3792. }
  3793. var respJSON2 map[string]interface{}
  3794. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  3795. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3797. return
  3798. }
  3799. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  3800. if err == nil {
  3801. c.ServeSuccessJSON(map[string]interface{}{
  3802. "msg": "退费成功",
  3803. })
  3804. } else {
  3805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3806. return
  3807. }
  3808. } else {
  3809. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  3810. if err == nil {
  3811. c.ServeSuccessJSON(map[string]interface{}{
  3812. "msg": "退费成功",
  3813. })
  3814. } else {
  3815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3816. return
  3817. }
  3818. }
  3819. }
  3820. //对账
  3821. func (c *HisApiController) GetCheckAccount() {
  3822. start_time := c.GetString("start_time")
  3823. end_time := c.GetString("end_time")
  3824. insutype := c.GetString("insutype")
  3825. clr_type := c.GetString("clr_type")
  3826. admin_user_id, _ := c.GetInt64("admin_user_id")
  3827. adminUser := c.GetAdminUserInfo()
  3828. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3829. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3830. timeLayout := "2006-01-02"
  3831. loc, _ := time.LoadLocation("Local")
  3832. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3833. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  3834. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  3835. //orders_two, _ := service.GetOrderByTimeThree(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  3836. fixmedins_setl_cnt := int64(len(orders))
  3837. //
  3838. ////撤销的算2条数据为一笔
  3839. //for _, item := range orders_two {
  3840. // if item.OrderStatus == 3 {
  3841. // fixmedins_setl_cnt = fixmedins_setl_cnt + 1
  3842. // }
  3843. //}
  3844. var medfee_sumamt float64
  3845. var acct_pay float64
  3846. var fund_pay_sumamt float64
  3847. for _, item := range orders {
  3848. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  3849. acct_pay = acct_pay + item.AcctPay
  3850. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  3851. }
  3852. var user_name string
  3853. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3854. if role.ID == 0 {
  3855. user_name = "xxx"
  3856. } else {
  3857. user_name = role.UserName
  3858. }
  3859. if config.IsOpen == 1 {
  3860. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  3861. "insutype=" + insutype +
  3862. "&clr_type=" + clr_type +
  3863. "&setl_optins=" + "定点医保中心" +
  3864. "&stmt_begndate=" + start_time +
  3865. "&stm_enddate=" + end_time +
  3866. "&medfee_sumamt=" + fmt.Sprintf("%.2f", medfee_sumamt) +
  3867. "&fund_pay_sumamt=" + fmt.Sprintf("%.2f", fund_pay_sumamt) +
  3868. "&acct_pay=" + fmt.Sprintf("%.2f", acct_pay) +
  3869. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  3870. "&fixmedins_code=" + miConfig.Code +
  3871. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3872. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3873. "&secret_key=" + miConfig.SecretKey +
  3874. "&org_name=" + miConfig.OrgName +
  3875. "&doctor=" + user_name
  3876. fmt.Println(api)
  3877. resp, requestErr := http.Get(api)
  3878. if requestErr != nil {
  3879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3880. return
  3881. }
  3882. body, ioErr := ioutil.ReadAll(resp.Body)
  3883. fmt.Println(body)
  3884. if ioErr != nil {
  3885. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3887. return
  3888. }
  3889. var respJSON map[string]interface{}
  3890. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3893. return
  3894. }
  3895. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3896. userJSONBytes, _ := json.Marshal(respJSON)
  3897. var res ResultEight
  3898. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3899. utils.ErrorLog("解析失败:%v", err)
  3900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3901. return
  3902. }
  3903. if res.Infcode == 0 {
  3904. if res.Output.Stmtinfo.StmtRslt == "0" {
  3905. micc := &models.MedicalInsuranceCostCompare{
  3906. StartTime: startime.Unix(),
  3907. EndTime: endtime.Unix(),
  3908. Insutype: insutype,
  3909. CheckType: 1,
  3910. Num: fixmedins_setl_cnt,
  3911. Mtime: time.Now().Unix(),
  3912. Status: 1,
  3913. UserOrgId: adminUser.CurrentOrgId,
  3914. CostTotal: medfee_sumamt,
  3915. FuncTotal: fund_pay_sumamt,
  3916. PsnPay: acct_pay,
  3917. Creator: admin_user_id,
  3918. Ctime: time.Now().Unix(),
  3919. }
  3920. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  3921. if err == nil {
  3922. c.ServeSuccessJSON(map[string]interface{}{
  3923. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  3924. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  3925. })
  3926. } else {
  3927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3928. }
  3929. } else {
  3930. c.ServeSuccessJSON(map[string]interface{}{
  3931. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  3932. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  3933. })
  3934. }
  3935. } else {
  3936. c.ServeSuccessJSON(map[string]interface{}{
  3937. "code": -10,
  3938. "msg": res.ErrMsg,
  3939. })
  3940. }
  3941. }
  3942. }
  3943. func (c *HisApiController) Check310() {
  3944. adminUser := c.GetAdminUserInfo()
  3945. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3946. var user_name string
  3947. user_name = "xxx"
  3948. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  3949. "insutype=" + "310" +
  3950. "&clr_type=" + "11" +
  3951. "&setl_optins=" + "定点医保中心" +
  3952. "&stmt_begndate=" + "2021-03-01" +
  3953. "&stm_enddate=" + "2021-03-31" +
  3954. "&medfee_sumamt=" + "11521" +
  3955. "&fund_pay_sumamt=" + "10166.66" +
  3956. "&acct_pay=" + "0" +
  3957. "&fixmedins_setl_cnt=" + "7" +
  3958. "&fixmedins_code=" + miConfig.Code +
  3959. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3960. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3961. "&secret_key=" + miConfig.SecretKey +
  3962. "&org_name=" + miConfig.OrgName +
  3963. "&doctor=" + user_name
  3964. fmt.Println(api)
  3965. resp, requestErr := http.Get(api)
  3966. if requestErr != nil {
  3967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3968. return
  3969. }
  3970. body, ioErr := ioutil.ReadAll(resp.Body)
  3971. fmt.Println(body)
  3972. if ioErr != nil {
  3973. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3975. return
  3976. }
  3977. var respJSON map[string]interface{}
  3978. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3979. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3981. return
  3982. }
  3983. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3984. userJSONBytes, _ := json.Marshal(respJSON)
  3985. var res ResultEight
  3986. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3987. utils.ErrorLog("解析失败:%v", err)
  3988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3989. return
  3990. }
  3991. }
  3992. func (c *HisApiController) Check390() {
  3993. adminUser := c.GetAdminUserInfo()
  3994. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3995. var user_name string
  3996. user_name = "张俊杰"
  3997. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  3998. "insutype=" + "390" +
  3999. "&clr_type=" + "11" +
  4000. "&setl_optins=" + "定点医保中心" +
  4001. "&stmt_begndate=" + "2021-03-01" +
  4002. "&stm_enddate=" + "2021-03-31" +
  4003. "&medfee_sumamt=" + "209318.43" +
  4004. "&fund_pay_sumamt=" + "188029.12" +
  4005. "&acct_pay=" + "0" +
  4006. "&fixmedins_setl_cnt=" + "48" +
  4007. "&fixmedins_code=" + miConfig.Code +
  4008. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  4009. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4010. "&secret_key=" + miConfig.SecretKey +
  4011. "&org_name=" + miConfig.OrgName +
  4012. "&doctor=" + user_name
  4013. fmt.Println(api)
  4014. resp, requestErr := http.Get(api)
  4015. if requestErr != nil {
  4016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4017. return
  4018. }
  4019. body, ioErr := ioutil.ReadAll(resp.Body)
  4020. fmt.Println(body)
  4021. if ioErr != nil {
  4022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4024. return
  4025. }
  4026. var respJSON map[string]interface{}
  4027. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4030. return
  4031. }
  4032. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4033. userJSONBytes, _ := json.Marshal(respJSON)
  4034. var res ResultEight
  4035. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4036. utils.ErrorLog("解析失败:%v", err)
  4037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4038. return
  4039. }
  4040. }
  4041. //对账明细
  4042. func (c *HisApiController) GetCheckDetailAccount() {
  4043. start_time := c.GetString("start_time")
  4044. end_time := c.GetString("end_time")
  4045. admin_user_id, _ := c.GetInt64("admin_user_id")
  4046. adminUser := c.GetAdminUserInfo()
  4047. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4048. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4049. timeLayout := "2006-01-02"
  4050. loc, _ := time.LoadLocation("Local")
  4051. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  4052. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  4053. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  4054. Mkdir(miConfig.OrgName)
  4055. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  4056. file_name := file + ".txt"
  4057. zip_name := file + ".zip"
  4058. zip_path := miConfig.OrgName + "/" + zip_name
  4059. file_path := miConfig.OrgName + "/" + file_name
  4060. decimal.DivisionPrecision = 2
  4061. var medfee_sumamt float64
  4062. var psn_cash_pay float64
  4063. var fund_pay_sumamt float64
  4064. fixmedins_setl_cnt := int64(len(orders))
  4065. for _, item := range orders {
  4066. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  4067. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  4068. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  4069. }
  4070. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  4071. defer f.Close()
  4072. if err != nil {
  4073. fmt.Println(err.Error())
  4074. } else {
  4075. for _, item := range orders {
  4076. var refd_setl_flag string
  4077. if item.OrderStatus == 2 {
  4078. refd_setl_flag = "0"
  4079. var str string
  4080. str = item.SetlId + " " +
  4081. item.MdtrtId + " " +
  4082. item.PsnNo + " " +
  4083. fmt.Sprintf("%.2f", item.MedfeeSumamt) + " " +
  4084. fmt.Sprintf("%.2f", item.FundPaySumamt) + " " +
  4085. fmt.Sprintf("%.2f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  4086. _, err = f.Write([]byte(str))
  4087. }
  4088. if item.OrderStatus == 3 {
  4089. var str string
  4090. str = item.SetlId + " " +
  4091. item.MdtrtId + " " +
  4092. item.PsnNo + " " +
  4093. fmt.Sprintf("%.2f", item.MedfeeSumamt) + " " +
  4094. fmt.Sprintf("%.2f", item.FundPaySumamt) + " " +
  4095. fmt.Sprintf("%.2f", item.AcctPay) + " " + "1" + "\r\n"
  4096. _, err = f.Write([]byte(str))
  4097. var str2 string
  4098. str2 = item.SetlId + " " +
  4099. item.MdtrtId + " " +
  4100. item.PsnNo + " " +
  4101. fmt.Sprintf("%.2f", 0-item.MedfeeSumamt) + " " +
  4102. fmt.Sprintf("%.2f", 0-item.FundPaySumamt) + " " +
  4103. fmt.Sprintf("%.2f", 0-item.AcctPay) + " " + "1" + "\r\n"
  4104. _, err = f.Write([]byte(str2))
  4105. }
  4106. }
  4107. }
  4108. Zip(file_path, zip_path)
  4109. fmt.Println(ReadFile(zip_path))
  4110. fmt.Println(string(ReadFile(zip_path)))
  4111. if config.IsOpen == 1 {
  4112. var user_name string
  4113. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4114. if role.ID == 0 {
  4115. user_name = "管理员"
  4116. } else {
  4117. user_name = role.UserName
  4118. }
  4119. baseParams := models.BaseParams{
  4120. SecretKey: miConfig.SecretKey,
  4121. FixmedinsCode: miConfig.Code,
  4122. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4123. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4124. OrgName: miConfig.OrgName,
  4125. Doctor: user_name,
  4126. }
  4127. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  4128. var dat map[string]interface{}
  4129. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4130. fmt.Println(dat)
  4131. } else {
  4132. fmt.Println(err)
  4133. }
  4134. userJSONBytes, _ := json.Marshal(dat)
  4135. var res ResultNine
  4136. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4137. utils.ErrorLog("解析失败:%v", err)
  4138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4139. return
  4140. }
  4141. if res.Infcode == 0 {
  4142. fileNo := res.Output.FileQuryNo
  4143. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  4144. "file_qury_no=" + fileNo +
  4145. "&setl_optins=" + "定点医保中心" +
  4146. "&stmt_begndate=" + start_time +
  4147. "&stm_enddate=" + end_time +
  4148. "&medfee_sumamt=" + fmt.Sprintf("%.2f", medfee_sumamt) +
  4149. "&fund_pay_sumamt=" + fmt.Sprintf("%.2f", fund_pay_sumamt) +
  4150. "&cash_payamt=" + fmt.Sprintf("%.2f", psn_cash_pay) +
  4151. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  4152. "&fixmedins_code=" + miConfig.Code +
  4153. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  4154. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4155. "&secret_key=" + miConfig.SecretKey +
  4156. "&org_name=" + miConfig.OrgName +
  4157. "&doctor=" + user_name
  4158. resp, requestErr := http.Get(api)
  4159. if requestErr != nil {
  4160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4161. return
  4162. }
  4163. body, ioErr := ioutil.ReadAll(resp.Body)
  4164. if ioErr != nil {
  4165. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4167. return
  4168. }
  4169. var respJSON map[string]interface{}
  4170. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4171. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4173. return
  4174. }
  4175. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4176. userJSONBytes, _ := json.Marshal(respJSON)
  4177. var res ResultTen
  4178. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4179. utils.ErrorLog("解析失败:%v", err)
  4180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4181. return
  4182. }
  4183. if res.Infcode == 0 {
  4184. service.Gdyb9102(baseParams, zip_name, fileNo)
  4185. micc := &models.MedicalInsuranceCostCompare{
  4186. StartTime: startime.Unix(),
  4187. EndTime: endtime.Unix(),
  4188. Insutype: "0",
  4189. CheckType: 2,
  4190. Num: fixmedins_setl_cnt,
  4191. Mtime: time.Now().Unix(),
  4192. Status: 1,
  4193. UserOrgId: adminUser.CurrentOrgId,
  4194. CostTotal: medfee_sumamt,
  4195. FuncTotal: fund_pay_sumamt,
  4196. PsnPay: psn_cash_pay,
  4197. Creator: admin_user_id,
  4198. Ctime: time.Now().Unix(),
  4199. }
  4200. service.CreateMedicalInsuranceCostCompareRecord(micc)
  4201. c.ServeSuccessJSON(map[string]interface{}{
  4202. "msg": "明细对账成功",
  4203. })
  4204. }
  4205. } else {
  4206. }
  4207. }
  4208. }
  4209. func (c *HisApiController) GetSettleAccounts() {
  4210. //id, _ := c.GetInt64("id")
  4211. //record_time := c.GetString("record_time")
  4212. order_id, _ := c.GetInt64("order_id")
  4213. admin_user_id, _ := c.GetInt64("admin_user_id")
  4214. //timeLayout := "2006-01-02"
  4215. //loc, _ := time.LoadLocation("Local")
  4216. //
  4217. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4218. //if err != nil {
  4219. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4220. // return
  4221. //}
  4222. //recordDateTime := theTime.Unix()
  4223. adminUser := c.GetAdminUserInfo()
  4224. order, _ := service.GetHisOrderByID(order_id)
  4225. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4226. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  4227. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  4228. orderInfos = append(orderInfos, orderInfos_two...)
  4229. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  4230. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4231. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  4232. //var config []*models.HisXtDiagnoseConfig
  4233. var name string
  4234. for _, item := range diagnosis_ids {
  4235. id, _ := strconv.ParseInt(item, 10, 64)
  4236. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4237. if len(name) == 0 {
  4238. name = diagnosisConfig.ClassName
  4239. } else {
  4240. name = name + "," + diagnosisConfig.ClassName
  4241. }
  4242. }
  4243. var bedCostTotal float64 = 0 //床位总费
  4244. var bedCostSelfTotal float64 = 0 //床位自费
  4245. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4246. var operationCostTotal float64 = 0 //手术费
  4247. var operationCostSelfTotal float64 = 0 //手术费
  4248. var operationCostPartSelfTotal float64 = 0 //手术费
  4249. var otherCostTotal float64 = 0 //其他费用
  4250. var otherCostSelfTotal float64 = 0 //其他费用
  4251. var otherCostPartSelfTotal float64 = 0 //其他费用
  4252. var materialCostTotal float64 = 0 //材料费
  4253. var materialCostSelfTotal float64 = 0 //材料费
  4254. var materialCostPartSelfTotal float64 = 0 //材料费
  4255. var westernMedicineCostTotal float64 = 0 //西药费
  4256. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4257. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4258. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4259. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4260. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4261. var checkCostTotal float64 = 0 //检查费
  4262. var checkCostSelfTotal float64 = 0 //检查费
  4263. var checkCostPartSelfTotal float64 = 0 //检查费
  4264. var laboratoryCostTotal float64 = 0 //化验费
  4265. var laboratoryCostSelfTotal float64 = 0 //化验费
  4266. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4267. var treatCostTotal float64 = 0 //治疗费用
  4268. var treatCostSelfTotal float64 = 0 //治疗费用
  4269. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4270. decimal.DivisionPrecision = 2
  4271. for _, item := range orderInfos {
  4272. if item.MedChrgitmType == "01" { //床位费
  4273. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4274. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4275. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4276. }
  4277. if item.MedChrgitmType == "03" { //检查费
  4278. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4279. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4280. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4281. }
  4282. if item.MedChrgitmType == "04" { //化验费
  4283. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4284. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4285. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4286. }
  4287. if item.MedChrgitmType == "05" { //治疗费
  4288. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4289. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4290. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4291. }
  4292. if item.MedChrgitmType == "06" { //手术费
  4293. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4294. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4295. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4296. }
  4297. if item.MedChrgitmType == "08" { //材料费
  4298. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4299. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4300. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4301. }
  4302. if item.MedChrgitmType == "09" { //西药费
  4303. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4304. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4305. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4306. }
  4307. if item.MedChrgitmType == "11" { //中成费
  4308. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4309. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4310. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4311. }
  4312. if item.MedChrgitmType == "14" { //其他费
  4313. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4314. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4315. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4316. }
  4317. }
  4318. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4319. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4320. var user_name string
  4321. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4322. if role.ID == 0 {
  4323. user_name = "管理员"
  4324. } else {
  4325. user_name = role.UserName
  4326. }
  4327. baseParams := models.BaseParams{
  4328. SecretKey: miConfig.SecretKey,
  4329. FixmedinsCode: miConfig.Code,
  4330. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4331. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4332. OrgName: miConfig.OrgName,
  4333. Doctor: user_name,
  4334. }
  4335. businessParams := models.BusinessParams{
  4336. PsnNo: order.PsnNo,
  4337. MdtrtId: order.MdtrtId,
  4338. SetlId: order.SetlId,
  4339. }
  4340. if config.IsOpen == 1 {
  4341. result := service.Gdyb5203(baseParams, businessParams)
  4342. var dat map[string]interface{}
  4343. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4344. fmt.Println(dat)
  4345. } else {
  4346. fmt.Println(err)
  4347. }
  4348. userJSONBytes, _ := json.Marshal(dat)
  4349. var res ResultEleven
  4350. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4351. utils.ErrorLog("解析失败:%v", err)
  4352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4353. return
  4354. }
  4355. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4356. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  4357. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  4358. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4359. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4360. var doctor_name string
  4361. if roles.ID == 0 {
  4362. doctor_name = "管理员"
  4363. } else {
  4364. doctor_name = roles.UserName
  4365. }
  4366. yiliao_leibie := ""
  4367. switch order.MedType {
  4368. case "11":
  4369. yiliao_leibie = "普通门诊"
  4370. break
  4371. case "12":
  4372. yiliao_leibie = "门诊挂号"
  4373. break
  4374. case "13":
  4375. yiliao_leibie = "急诊"
  4376. break
  4377. case "14":
  4378. yiliao_leibie = "门诊特殊病"
  4379. break
  4380. case "15":
  4381. yiliao_leibie = "门诊统筹"
  4382. break
  4383. case "16":
  4384. yiliao_leibie = "门诊慢性病"
  4385. break
  4386. case "21":
  4387. yiliao_leibie = "普通住院"
  4388. break
  4389. }
  4390. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4391. if res.Infcode == 0 {
  4392. c.ServeSuccessJSON(map[string]interface{}{
  4393. "diagnosis": name,
  4394. "order_infos": orderInfos,
  4395. "number": order.MdtrtId,
  4396. "date": order.SettleAccountsDate,
  4397. "charge_admin": charge_admin,
  4398. "printor_admin": printor_admin,
  4399. "info": res.Output.Setlinfo,
  4400. "bedCostTotal": bedCostTotal,
  4401. "bedCostSelfTotal": bedCostSelfTotal,
  4402. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  4403. "operationCostTotal": operationCostTotal,
  4404. "operationCostSelfTotal": operationCostSelfTotal,
  4405. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  4406. "otherCostTotal": otherCostTotal,
  4407. "otherCostSelfTotal": otherCostSelfTotal,
  4408. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  4409. "materialCostTotal": materialCostTotal,
  4410. "materialCostSelfTotal": materialCostSelfTotal,
  4411. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  4412. "westernMedicineCostTotal": westernMedicineCostTotal,
  4413. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  4414. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  4415. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  4416. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  4417. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  4418. "checkCostTotal": checkCostTotal,
  4419. "checkCostSelfTotal": checkCostSelfTotal,
  4420. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  4421. "laboratoryCostTotal": laboratoryCostTotal,
  4422. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  4423. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  4424. "treatCostTotal": treatCostTotal,
  4425. "treatCostSelfTotal": treatCostSelfTotal,
  4426. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  4427. "doctor_code": adminRole_two.DoctorCode,
  4428. "doctor_name": doctor_name,
  4429. "health_card_no": order.PsnNo,
  4430. "department": departments.Name,
  4431. "yiliao_leibie": yiliao_leibie,
  4432. "after_money": order.AccountPrice,
  4433. "patient": patient,
  4434. "org_name": miConfig.OrgName,
  4435. "org_code": miConfig.Code,
  4436. "order_number": order.Number,
  4437. })
  4438. }
  4439. }
  4440. }
  4441. func (c *HisApiController) CheckTreatment() {
  4442. patient_id, _ := c.GetInt64("patient_id", 0)
  4443. record_time := c.GetString("record_time")
  4444. insutype := c.GetString("insutype")
  4445. timeLayout := "2006-01-02"
  4446. loc, _ := time.LoadLocation("Local")
  4447. adminUser := c.GetAdminUserInfo()
  4448. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4449. fmt.Println(err)
  4450. if err != nil {
  4451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4452. return
  4453. }
  4454. recordDateTime := theTime.Unix()
  4455. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4456. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4457. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4458. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4459. var user_name string
  4460. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  4461. if role.ID == 0 {
  4462. user_name = "xxx"
  4463. } else {
  4464. user_name = role.UserName
  4465. }
  4466. baseParams := models.BaseParams{
  4467. SecretKey: miConfig.SecretKey,
  4468. FixmedinsCode: miConfig.Code,
  4469. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4470. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4471. OrgName: miConfig.OrgName,
  4472. Doctor: user_name,
  4473. }
  4474. if config.IsOpen == 1 {
  4475. result := service.Gdyb2001(baseParams, his.PsnNo, insutype, strconv.FormatInt(patientPrescription.RegisterType, 10))
  4476. var dat map[string]interface{}
  4477. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4478. fmt.Println(dat)
  4479. } else {
  4480. fmt.Println(err)
  4481. }
  4482. }
  4483. }
  4484. func (c *HisApiController) PutRecord() {
  4485. id, _ := c.GetInt64("id")
  4486. record_time := c.GetString("record_time")
  4487. timeLayout := "2006-01-02"
  4488. loc, _ := time.LoadLocation("Local")
  4489. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4490. if err != nil {
  4491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4492. return
  4493. }
  4494. recordDateTime := theTime.Unix()
  4495. adminInfo := c.GetAdminUserInfo()
  4496. patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  4497. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4498. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4499. fmt.Println(miConfig.SecretKey)
  4500. if patient == nil {
  4501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4502. return
  4503. }
  4504. if len(patient.IdCardNo) == 0 {
  4505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4506. return
  4507. }
  4508. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4509. if config.IsOpen == 1 {
  4510. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4511. resp, requestErr := http.Get(api)
  4512. if requestErr != nil {
  4513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4514. return
  4515. }
  4516. defer resp.Body.Close()
  4517. body, ioErr := ioutil.ReadAll(resp.Body)
  4518. if ioErr != nil {
  4519. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4521. return
  4522. }
  4523. var respJSON map[string]interface{}
  4524. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4525. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4527. return
  4528. }
  4529. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4530. userJSONBytes, _ := json.Marshal(userJSON)
  4531. var res ResultTwo
  4532. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4533. utils.ErrorLog("解析失败:%v", err)
  4534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4535. return
  4536. }
  4537. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4538. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4539. infoStr := string(Iinfos)
  4540. idetinfoStr := string(Idetinfos)
  4541. if res.Infcode == 0 {
  4542. his := models.VMHisPatient{
  4543. Status: 1,
  4544. Ctime: time.Now().Unix(),
  4545. Mtime: time.Now().Unix(),
  4546. PsnNo: res.Output.Baseinfo.PsnNo,
  4547. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4548. Certno: res.Output.Baseinfo.Certno,
  4549. PsnName: res.Output.Baseinfo.PsnName,
  4550. Gend: res.Output.Baseinfo.Gend,
  4551. Naty: res.Output.Baseinfo.Naty,
  4552. Brdy: res.Output.Baseinfo.Brdy,
  4553. Age: res.Output.Baseinfo.Age,
  4554. Iinfo: infoStr,
  4555. Idetinfo: idetinfoStr,
  4556. PatientId: patient.ID,
  4557. RecordDate: theTime.Unix(),
  4558. UserOrgId: adminInfo.CurrentOrgId,
  4559. AdminUserId: adminInfo.AdminUser.Id,
  4560. IsReturn: 1,
  4561. }
  4562. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4563. result := service.Gdyb2503(his.PsnNo, res.Output.Iinfo[0].Insutype, miConfig.OrgName, patientPrescription.Doctor, miConfig.Code, doctor_id, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "重症尿毒症透析(血透)", "M07801")
  4564. result2 := service.Gdyb5301(his.PsnNo, res.Output.Iinfo[0].Insutype, miConfig.OrgName, patientPrescription.Doctor, miConfig.Code, doctor_id, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "重症尿毒症透析(血透)", "M07801")
  4565. var dat map[string]interface{}
  4566. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4567. fmt.Println(dat)
  4568. } else {
  4569. fmt.Println(err)
  4570. }
  4571. var dat2 map[string]interface{}
  4572. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  4573. fmt.Println(dat2)
  4574. } else {
  4575. fmt.Println(err)
  4576. }
  4577. } else {
  4578. adminUser := c.GetAdminUserInfo()
  4579. errlog := &models.HisOrderError{
  4580. UserOrgId: adminUser.CurrentOrgId,
  4581. Ctime: time.Now().Unix(),
  4582. Mtime: time.Now().Unix(),
  4583. ErrMsg: res.ErrMsg,
  4584. Status: 1,
  4585. PatientId: id,
  4586. RecordTime: recordDateTime,
  4587. Stage: 1,
  4588. }
  4589. service.CreateErrMsgLog(errlog)
  4590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4591. return
  4592. }
  4593. }
  4594. }
  4595. func (c *HisApiController) GetUploadDiag() {
  4596. id, _ := c.GetInt64("id")
  4597. record_time := c.GetString("record_time")
  4598. diagnosis_id, _ := c.GetInt64("diagnosis")
  4599. sick_type, _ := c.GetInt64("sick_type")
  4600. reg_type, _ := c.GetInt64("reg_type")
  4601. timeLayout := "2006-01-02"
  4602. loc, _ := time.LoadLocation("Local")
  4603. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4604. if err != nil {
  4605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4606. return
  4607. }
  4608. var patientPrescription models.HisPrescriptionInfo
  4609. recordDateTime := theTime.Unix()
  4610. adminInfo := c.GetAdminUserInfo()
  4611. patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4612. if patientPrescription.ID == 0 {
  4613. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4614. }
  4615. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4616. diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  4617. his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4618. sickConfig, _ := service.FindSickById(sick_type)
  4619. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4620. api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  4621. "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  4622. "&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
  4623. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  4624. resp2, requestErr2 := http.Get(api2)
  4625. if requestErr2 != nil {
  4626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4627. return
  4628. }
  4629. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  4630. if ioErr2 != nil {
  4631. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  4632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4633. return
  4634. }
  4635. var respJSON2 map[string]interface{}
  4636. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  4637. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4639. return
  4640. }
  4641. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4642. userJSONBytes2, _ := json.Marshal(respJSON2)
  4643. var res2 ResultSix
  4644. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4645. utils.ErrorLog("解析失败:%v", err)
  4646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4647. return
  4648. }
  4649. if res2.Infcode != 0 {
  4650. adminUser := c.GetAdminUserInfo()
  4651. errlog := &models.HisOrderError{
  4652. UserOrgId: adminUser.CurrentOrgId,
  4653. Ctime: time.Now().Unix(),
  4654. Mtime: time.Now().Unix(),
  4655. ErrMsg: res2.ErrMsg,
  4656. Status: 1,
  4657. PatientId: id,
  4658. RecordTime: recordDateTime,
  4659. Stage: 3,
  4660. }
  4661. service.CreateErrMsgLog(errlog)
  4662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  4663. return
  4664. }
  4665. c.ServeSuccessJSON(map[string]interface{}{
  4666. "msg": "上传成功",
  4667. })
  4668. }
  4669. type QueryResult struct {
  4670. ID int64
  4671. Name string
  4672. Code string
  4673. List_type_code string
  4674. }
  4675. func (c *HisApiController) GetCheckCode() {
  4676. ids_str := c.GetString("ids")
  4677. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  4678. ids_arr := strings.Split(ids_str, ",")
  4679. var queryResult []QueryResult
  4680. ids := make([]int64, 0)
  4681. for _, item := range ids_arr {
  4682. id, _ := strconv.ParseInt(item, 10, 64)
  4683. ids = append(ids, id)
  4684. }
  4685. if record_type == 1 {
  4686. drugs, _ := service.GetBatchDrugList(ids)
  4687. for _, item := range drugs {
  4688. result := QueryResult{
  4689. ID: item.ID,
  4690. Name: item.DrugName,
  4691. Code: item.MedicalInsuranceNumber,
  4692. List_type_code: "101",
  4693. }
  4694. queryResult = append(queryResult, result)
  4695. }
  4696. } else if record_type == 2 {
  4697. goods, _ := service.GetBatchGoodInformationList(ids)
  4698. for _, item := range goods {
  4699. result := QueryResult{
  4700. ID: item.ID,
  4701. Name: item.GoodName,
  4702. Code: item.MedicalInsuranceNumber,
  4703. List_type_code: "301",
  4704. }
  4705. queryResult = append(queryResult, result)
  4706. }
  4707. } else if record_type == 3 {
  4708. projects, _ := service.GetBathchMyPorjecgList(ids)
  4709. for _, item := range projects {
  4710. result := QueryResult{
  4711. ID: item.ID,
  4712. Name: item.ProjectName,
  4713. Code: item.MedicalCode,
  4714. List_type_code: "201",
  4715. }
  4716. queryResult = append(queryResult, result)
  4717. }
  4718. }
  4719. admin_user_id, _ := c.GetInt64("admin_user_id")
  4720. adminUser := c.GetAdminUserInfo()
  4721. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4722. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4723. var user_name string
  4724. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4725. if role.ID == 0 {
  4726. user_name = "xxx"
  4727. } else {
  4728. user_name = role.UserName
  4729. }
  4730. baseParams := &models.BaseParams{
  4731. SecretKey: miConfig.SecretKey,
  4732. FixmedinsCode: miConfig.Code,
  4733. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4734. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4735. OrgName: miConfig.OrgName,
  4736. Doctor: user_name,
  4737. }
  4738. if config.IsOpen == 1 {
  4739. for _, item := range queryResult {
  4740. var result string
  4741. if record_type == 1 {
  4742. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  4743. } else if record_type == 2 {
  4744. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  4745. } else if record_type == 3 {
  4746. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  4747. }
  4748. var dat map[string]interface{}
  4749. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4750. fmt.Println(dat)
  4751. } else {
  4752. fmt.Println(err)
  4753. }
  4754. userJSONBytes, _ := json.Marshal(dat)
  4755. var res ResultSix
  4756. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4757. utils.ErrorLog("解析失败:%v", err)
  4758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4759. return
  4760. }
  4761. if res.Infcode == 0 {
  4762. if record_type == 1 {
  4763. service.UpdateBaseDrugById(item.ID)
  4764. } else if record_type == 2 {
  4765. service.UpdateGoodInformaitonByDetail(item.ID)
  4766. } else if record_type == 3 {
  4767. service.UpdateProjectById(item.ID)
  4768. }
  4769. c.ServeSuccessJSON(map[string]interface{}{
  4770. "failed_code": 0,
  4771. "msg": "目录对照成功",
  4772. })
  4773. } else {
  4774. c.ServeSuccessJSON(map[string]interface{}{
  4775. "failed_code": -10,
  4776. "msg": res.ErrMsg,
  4777. })
  4778. }
  4779. }
  4780. }
  4781. }
  4782. func (c *HisApiController) UnCheckCode() {
  4783. ids_str := c.GetString("ids")
  4784. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  4785. admin_user_id, _ := c.GetInt64("admin_user_id")
  4786. ids_arr := strings.Split(ids_str, ",")
  4787. var queryResult []QueryResult
  4788. ids := make([]int64, 0)
  4789. for _, item := range ids_arr {
  4790. id, _ := strconv.ParseInt(item, 10, 64)
  4791. ids = append(ids, id)
  4792. }
  4793. if record_type == 1 {
  4794. drugs, _ := service.GetBatchDrugList(ids)
  4795. for _, item := range drugs {
  4796. result := QueryResult{
  4797. ID: item.ID,
  4798. Name: item.DrugName,
  4799. Code: item.MedicalInsuranceNumber,
  4800. List_type_code: "101",
  4801. }
  4802. queryResult = append(queryResult, result)
  4803. }
  4804. } else if record_type == 2 {
  4805. goods, _ := service.GetBatchGoodInformationList(ids)
  4806. for _, item := range goods {
  4807. result := QueryResult{
  4808. ID: item.ID,
  4809. Name: item.GoodName,
  4810. Code: item.MedicalInsuranceNumber,
  4811. List_type_code: "301",
  4812. }
  4813. queryResult = append(queryResult, result)
  4814. }
  4815. } else if record_type == 3 {
  4816. projects, _ := service.GetBathchMyPorjecgList(ids)
  4817. for _, item := range projects {
  4818. result := QueryResult{
  4819. ID: item.ID,
  4820. Name: item.ProjectName,
  4821. Code: item.MedicalCode,
  4822. List_type_code: "201",
  4823. }
  4824. queryResult = append(queryResult, result)
  4825. }
  4826. }
  4827. adminUser := c.GetAdminUserInfo()
  4828. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4829. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4830. var user_name string
  4831. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4832. if role.ID == 0 {
  4833. user_name = "xxx"
  4834. } else {
  4835. user_name = role.UserName
  4836. }
  4837. baseParams := &models.BaseParams{
  4838. SecretKey: miConfig.SecretKey,
  4839. FixmedinsCode: miConfig.Code,
  4840. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4841. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4842. OrgName: miConfig.OrgName,
  4843. Doctor: user_name,
  4844. }
  4845. if config.IsOpen == 1 {
  4846. for _, item := range queryResult {
  4847. var result string
  4848. if record_type == 1 {
  4849. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  4850. } else if record_type == 2 {
  4851. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  4852. } else if record_type == 3 {
  4853. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  4854. }
  4855. var dat2 map[string]interface{}
  4856. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  4857. fmt.Println(dat2)
  4858. } else {
  4859. fmt.Println(err)
  4860. }
  4861. userJSONBytes, _ := json.Marshal(dat2)
  4862. var res ResultSix
  4863. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4864. utils.ErrorLog("解析失败:%v", err)
  4865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4866. return
  4867. }
  4868. if res.Infcode == 0 {
  4869. if record_type == 1 {
  4870. service.UpdateDrugByIdDetail(item.ID)
  4871. } else if record_type == 2 {
  4872. service.UpdateGoodInfoById(item.ID)
  4873. } else if record_type == 3 {
  4874. service.UpdateMyProjectById(item.ID)
  4875. }
  4876. c.ServeSuccessJSON(map[string]interface{}{
  4877. "failed_code": 0,
  4878. "msg": "撤销目录对照成功",
  4879. })
  4880. } else {
  4881. c.ServeSuccessJSON(map[string]interface{}{
  4882. "failed_code": -10,
  4883. "msg": res.ErrMsg,
  4884. })
  4885. }
  4886. }
  4887. }
  4888. }
  4889. func (c *HisApiController) GetPatientInfo() {
  4890. id_card_no := c.GetString("id_card_no")
  4891. admin_user_id, _ := c.GetInt64("admin_user_id")
  4892. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  4893. if patient.ID == 0 {
  4894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4895. return
  4896. }
  4897. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4898. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4899. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  4900. if config.IsOpen == 1 {
  4901. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  4902. var dat map[string]interface{}
  4903. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4904. fmt.Println(dat)
  4905. } else {
  4906. fmt.Println(err)
  4907. }
  4908. userJSONBytes, _ := json.Marshal(dat)
  4909. var res ResultTwo
  4910. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4911. utils.ErrorLog("解析失败:%v", err)
  4912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4913. return
  4914. }
  4915. if res.Infcode != 0 {
  4916. c.ServeSuccessJSON(map[string]interface{}{
  4917. "failed_code": -10,
  4918. "msg": res.ErrMsg,
  4919. })
  4920. } else {
  4921. c.ServeSuccessJSON(map[string]interface{}{
  4922. "failed_code": 0,
  4923. "info": res,
  4924. })
  4925. }
  4926. }
  4927. }
  4928. func (c *HisApiController) PsnPutOnRecord() {
  4929. record_type, _ := c.GetInt64("type")
  4930. patient_id, _ := c.GetInt64("patient_id")
  4931. admin_user_id, _ := c.GetInt64("admin_user_id")
  4932. start_time := c.GetString("start_time")
  4933. end_time := c.GetString("end_time")
  4934. adminUser := c.GetAdminUserInfo()
  4935. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4936. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4937. var patients []*models.Patients
  4938. if record_type == 1 { //全部备案
  4939. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  4940. patients = append(patients, patient...)
  4941. } else { //单个备案
  4942. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  4943. patients = append(patients, patient)
  4944. }
  4945. var user_name string
  4946. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4947. if role.ID == 0 {
  4948. user_name = "xxx"
  4949. } else {
  4950. user_name = role.UserName
  4951. }
  4952. if config.IsOpen == 1 {
  4953. for _, item := range patients {
  4954. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + item.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + user_name + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4955. resp, requestErr := http.Get(api)
  4956. if requestErr != nil {
  4957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4958. return
  4959. }
  4960. defer resp.Body.Close()
  4961. body, ioErr := ioutil.ReadAll(resp.Body)
  4962. if ioErr != nil {
  4963. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4965. return
  4966. }
  4967. var respJSON map[string]interface{}
  4968. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4969. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4971. return
  4972. }
  4973. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4974. userJSONBytes, _ := json.Marshal(userJSON)
  4975. var res ResultTwo
  4976. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4977. utils.ErrorLog("解析失败:%v", err)
  4978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4979. return
  4980. }
  4981. if res.Infcode == 0 {
  4982. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  4983. var dat map[string]interface{}
  4984. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4985. fmt.Println(dat)
  4986. } else {
  4987. fmt.Println(err)
  4988. }
  4989. userJSONBytes, _ := json.Marshal(dat)
  4990. var res2 ResultThirteen
  4991. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4992. utils.ErrorLog("解析失败:%v", err)
  4993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4994. return
  4995. }
  4996. if res2.Infcode == 0 {
  4997. psnResult := &models.GdybPsnRecord{
  4998. UserOrgId: adminUser.CurrentOrgId,
  4999. PatientId: item.ID,
  5000. PsnNo: res.Output.Baseinfo.PsnNo,
  5001. Ctime: time.Now().Unix(),
  5002. Mtime: time.Now().Unix(),
  5003. Status: 1,
  5004. IsCancel: 1,
  5005. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  5006. }
  5007. service.CreatePsnRecord(psnResult)
  5008. } else {
  5009. c.ServeSuccessJSON(map[string]interface{}{
  5010. "failed_code": -10,
  5011. "msg": res2.ErrMsg,
  5012. })
  5013. return
  5014. }
  5015. }
  5016. }
  5017. }
  5018. }
  5019. func (c *HisApiController) PsnUnPutOnRecord() {
  5020. id, _ := c.GetInt64("id")
  5021. //record_type, _ := c.GetInt64("type")
  5022. admin_user_id, _ := c.GetInt64("admin_user_id")
  5023. adminUser := c.GetAdminUserInfo()
  5024. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5025. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5026. var user_name string
  5027. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5028. if role.ID == 0 {
  5029. user_name = "xxx"
  5030. } else {
  5031. user_name = role.UserName
  5032. }
  5033. psn_record, _ := service.GetPsnRecordById(id)
  5034. if psn_record.ID == 0 {
  5035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  5036. return
  5037. }
  5038. if config.IsOpen == 1 {
  5039. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  5040. var dat map[string]interface{}
  5041. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5042. fmt.Println(dat)
  5043. } else {
  5044. fmt.Println(err)
  5045. }
  5046. userJSONBytes, _ := json.Marshal(dat)
  5047. var res ResultFourteen
  5048. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5049. utils.ErrorLog("解析失败:%v", err)
  5050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5051. return
  5052. }
  5053. if res.Infcode == 0 {
  5054. psn_record.IsCancel = 2
  5055. service.CreatePsnRecord(&psn_record)
  5056. } else {
  5057. c.ServeSuccessJSON(map[string]interface{}{
  5058. "failed_code": -10,
  5059. "msg": res.ErrMsg,
  5060. })
  5061. return
  5062. }
  5063. }
  5064. }
  5065. func (c *HisApiController) PsnPutNCDSOnRecord() {
  5066. patient_id, _ := c.GetInt64("patient_id")
  5067. insutype := c.GetString("insutype")
  5068. psn_no := c.GetString("psn_no")
  5069. doctor_id, _ := c.GetInt64("doctor_id")
  5070. sick_id, _ := c.GetInt64("sick_id")
  5071. department_id, _ := c.GetInt64("department_id")
  5072. adminUser := c.GetAdminUserInfo()
  5073. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  5074. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5075. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5076. sick, _ := service.FindSickById(sick_id)
  5077. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  5078. if config.IsOpen == 1 {
  5079. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode)
  5080. var dat map[string]interface{}
  5081. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5082. fmt.Println(dat)
  5083. } else {
  5084. fmt.Println(err)
  5085. }
  5086. userJSONBytes, _ := json.Marshal(dat)
  5087. var res2 ResultThirteen
  5088. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5089. utils.ErrorLog("解析失败:%v", err)
  5090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5091. return
  5092. }
  5093. if res2.Infcode == 0 {
  5094. psnResult := &models.GdybPsnNcdsRecord{
  5095. UserOrgId: adminUser.CurrentOrgId,
  5096. PatientId: patient.ID,
  5097. PsnNo: psn_no,
  5098. DoctorId: doctor.AdminUserId,
  5099. DepartmentId: department_id,
  5100. SickType: sick_id,
  5101. Insutype: insutype,
  5102. Ctime: time.Now().Unix(),
  5103. Mtime: time.Now().Unix(),
  5104. Status: 1,
  5105. IsCancel: 1,
  5106. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  5107. }
  5108. service.CreatePsnNCDSRecord(psnResult)
  5109. c.ServeSuccessJSON(map[string]interface{}{
  5110. "failed_code": 0,
  5111. "msg": "备案成功",
  5112. "result": psnResult,
  5113. })
  5114. } else {
  5115. c.ServeSuccessJSON(map[string]interface{}{
  5116. "failed_code": -10,
  5117. "msg": res2.ErrMsg,
  5118. })
  5119. return
  5120. }
  5121. }
  5122. }
  5123. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  5124. id, _ := c.GetInt64("id")
  5125. admin_user_id, _ := c.GetInt64("admin_user_id")
  5126. adminUser := c.GetAdminUserInfo()
  5127. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5128. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5129. var user_name string
  5130. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5131. if role.ID == 0 {
  5132. user_name = "xxx"
  5133. } else {
  5134. user_name = role.UserName
  5135. }
  5136. psn_record, _ := service.GetPsnNCDSRecordById(id)
  5137. if psn_record.ID == 0 {
  5138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  5139. return
  5140. }
  5141. if config.IsOpen == 1 {
  5142. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, user_name, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  5143. var dat map[string]interface{}
  5144. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5145. fmt.Println(dat)
  5146. } else {
  5147. fmt.Println(err)
  5148. }
  5149. userJSONBytes, _ := json.Marshal(dat)
  5150. var res ResultFourteen
  5151. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5152. utils.ErrorLog("解析失败:%v", err)
  5153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5154. return
  5155. }
  5156. if res.Infcode == 0 {
  5157. psn_record.IsCancel = 2
  5158. service.CreatePsnNCDSRecord(&psn_record)
  5159. c.ServeSuccessJSON(map[string]interface{}{
  5160. "failed_code": 0,
  5161. "msg": "撤销备案成功",
  5162. })
  5163. } else {
  5164. c.ServeSuccessJSON(map[string]interface{}{
  5165. "failed_code": -10,
  5166. "msg": res.ErrMsg,
  5167. })
  5168. return
  5169. }
  5170. }
  5171. }
  5172. func (c *HisApiController) TestTest() {
  5173. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  5174. fmt.Println(patient.Iinfo)
  5175. }
  5176. type CustomData struct {
  5177. MsgId string
  5178. PsnNo string
  5179. Info string
  5180. }
  5181. func (c *HisApiController) ReversalData() {
  5182. var customData []*CustomData
  5183. custom := &CustomData{
  5184. MsgId: "H44022900158202103301714472004",
  5185. PsnNo: "44020000001101329945",
  5186. Info: "2207",
  5187. }
  5188. customData = append(customData, custom)
  5189. custom1 := &CustomData{
  5190. MsgId: "H4402290015820210330172057803",
  5191. PsnNo: "44020000001101161813",
  5192. Info: "2207",
  5193. }
  5194. customData = append(customData, custom1)
  5195. custom2 := &CustomData{
  5196. MsgId: "H44022900158202103301705198813",
  5197. PsnNo: "44190000133097375417",
  5198. Info: "2207",
  5199. }
  5200. customData = append(customData, custom2)
  5201. custom3 := &CustomData{
  5202. MsgId: "H44022900158202103301715524756",
  5203. PsnNo: "44020000001100187221",
  5204. Info: "2207",
  5205. }
  5206. customData = append(customData, custom3)
  5207. custom4 := &CustomData{
  5208. MsgId: "H44022900158202103301730376224",
  5209. PsnNo: "44020000001101959155",
  5210. Info: "2207",
  5211. }
  5212. customData = append(customData, custom4)
  5213. custom5 := &CustomData{
  5214. MsgId: "H44022900158202103301748008725",
  5215. PsnNo: "44020000001104246641",
  5216. Info: "2207",
  5217. }
  5218. customData = append(customData, custom5)
  5219. custom6 := &CustomData{
  5220. MsgId: "H44022900158202103301718096755",
  5221. PsnNo: "44020000001102211860",
  5222. Info: "2207",
  5223. }
  5224. customData = append(customData, custom6)
  5225. custom7 := &CustomData{
  5226. MsgId: "H44022900158202103301736551640",
  5227. PsnNo: "44020000001102687718",
  5228. Info: "2207",
  5229. }
  5230. customData = append(customData, custom7)
  5231. custom8 := &CustomData{
  5232. MsgId: "H44022900158202103301743097676",
  5233. PsnNo: "44020000001102127785",
  5234. Info: "2207",
  5235. }
  5236. customData = append(customData, custom8)
  5237. custom9 := &CustomData{
  5238. MsgId: "H44022900158202103301712304203",
  5239. PsnNo: "44020000001101518097",
  5240. Info: "2207",
  5241. }
  5242. customData = append(customData, custom9)
  5243. custom10 := &CustomData{
  5244. MsgId: "H44022900158202103301738448785",
  5245. PsnNo: "44020000001100500813",
  5246. Info: "2207",
  5247. }
  5248. customData = append(customData, custom10)
  5249. custom11 := &CustomData{
  5250. MsgId: "H44022900158202103301732455843",
  5251. PsnNo: "44020000001102690557",
  5252. Info: "2207",
  5253. }
  5254. customData = append(customData, custom11)
  5255. custom12 := &CustomData{
  5256. MsgId: "H44022900158202103301745421708",
  5257. PsnNo: "44020000001102211928",
  5258. Info: "2207",
  5259. }
  5260. customData = append(customData, custom12)
  5261. custom1212 := &CustomData{
  5262. MsgId: "H440229001582021033017351627",
  5263. PsnNo: "44020000001102481733",
  5264. Info: "2207",
  5265. }
  5266. customData = append(customData, custom1212)
  5267. custom13 := &CustomData{
  5268. MsgId: "H44022900158202103301740327951",
  5269. PsnNo: "44020000001103174866",
  5270. Info: "2207",
  5271. }
  5272. customData = append(customData, custom13)
  5273. custom14 := &CustomData{
  5274. MsgId: "H4402290015820210330174922668",
  5275. PsnNo: "44020000001102927272",
  5276. Info: "2207",
  5277. }
  5278. customData = append(customData, custom14)
  5279. custom15 := &CustomData{
  5280. MsgId: "H44022900158202103301752362273",
  5281. PsnNo: "44020000001102942890",
  5282. Info: "2207",
  5283. }
  5284. customData = append(customData, custom15)
  5285. custom16 := &CustomData{
  5286. MsgId: "H44022900158202103301751082917",
  5287. PsnNo: "44020000001101662162",
  5288. Info: "2207",
  5289. }
  5290. customData = append(customData, custom16)
  5291. custom17 := &CustomData{
  5292. MsgId: "H44022900158202103301754147728",
  5293. PsnNo: "44020000000229014511",
  5294. Info: "2207",
  5295. }
  5296. customData = append(customData, custom17)
  5297. adminUser := c.GetAdminUserInfo()
  5298. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5299. for _, item := range customData {
  5300. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  5301. fmt.Println(result)
  5302. }
  5303. }
  5304. func (c *HisApiController) ReversalOtherData() {
  5305. var customData []*CustomData
  5306. custom := &CustomData{
  5307. MsgId: "H44022900158202103301714472004",
  5308. PsnNo: "44020000001101329945",
  5309. Info: "2208",
  5310. }
  5311. customData = append(customData, custom)
  5312. custom1 := &CustomData{
  5313. MsgId: "H4402290015820210330172057803",
  5314. PsnNo: "44020000001101161813",
  5315. Info: "2208",
  5316. }
  5317. customData = append(customData, custom1)
  5318. custom2 := &CustomData{
  5319. MsgId: "H44022900158202103301705198813",
  5320. PsnNo: "44190000133097375417",
  5321. Info: "2208",
  5322. }
  5323. customData = append(customData, custom2)
  5324. custom3 := &CustomData{
  5325. MsgId: "H44022900158202103301715524756",
  5326. PsnNo: "44020000001100187221",
  5327. Info: "2208",
  5328. }
  5329. customData = append(customData, custom3)
  5330. custom4 := &CustomData{
  5331. MsgId: "H44022900158202103301730376224",
  5332. PsnNo: "44020000001101959155",
  5333. Info: "2208",
  5334. }
  5335. customData = append(customData, custom4)
  5336. custom5 := &CustomData{
  5337. MsgId: "H44022900158202103301748008725",
  5338. PsnNo: "44020000001104246641",
  5339. Info: "2208",
  5340. }
  5341. customData = append(customData, custom5)
  5342. custom6 := &CustomData{
  5343. MsgId: "H44022900158202103301718096755",
  5344. PsnNo: "44020000001102211860",
  5345. Info: "2208",
  5346. }
  5347. customData = append(customData, custom6)
  5348. custom7 := &CustomData{
  5349. MsgId: "H44022900158202103301736551640",
  5350. PsnNo: "44020000001102687718",
  5351. Info: "2208",
  5352. }
  5353. customData = append(customData, custom7)
  5354. custom8 := &CustomData{
  5355. MsgId: "H44022900158202103301743097676",
  5356. PsnNo: "44020000001102127785",
  5357. Info: "2208",
  5358. }
  5359. customData = append(customData, custom8)
  5360. custom9 := &CustomData{
  5361. MsgId: "H44022900158202103301712304203",
  5362. PsnNo: "44020000001101518097",
  5363. Info: "2208",
  5364. }
  5365. customData = append(customData, custom9)
  5366. custom10 := &CustomData{
  5367. MsgId: "H44022900158202103301738448785",
  5368. PsnNo: "44020000001100500813",
  5369. Info: "2208",
  5370. }
  5371. customData = append(customData, custom10)
  5372. custom11 := &CustomData{
  5373. MsgId: "H44022900158202103301732455843",
  5374. PsnNo: "44020000001102690557",
  5375. Info: "2208",
  5376. }
  5377. customData = append(customData, custom11)
  5378. custom12 := &CustomData{
  5379. MsgId: "H44022900158202103301745421708",
  5380. PsnNo: "44020000001102211928",
  5381. Info: "2208",
  5382. }
  5383. customData = append(customData, custom12)
  5384. custom1212 := &CustomData{
  5385. MsgId: "H440229001582021033017351627",
  5386. PsnNo: "44020000001102481733",
  5387. Info: "2208",
  5388. }
  5389. customData = append(customData, custom1212)
  5390. custom13 := &CustomData{
  5391. MsgId: "H44022900158202103301740327951",
  5392. PsnNo: "44020000001103174866",
  5393. Info: "2208",
  5394. }
  5395. customData = append(customData, custom13)
  5396. custom14 := &CustomData{
  5397. MsgId: "H4402290015820210330174922668",
  5398. PsnNo: "44020000001102927272",
  5399. Info: "2208",
  5400. }
  5401. customData = append(customData, custom14)
  5402. custom15 := &CustomData{
  5403. MsgId: "H44022900158202103301752362273",
  5404. PsnNo: "44020000001102942890",
  5405. Info: "2208",
  5406. }
  5407. customData = append(customData, custom15)
  5408. custom16 := &CustomData{
  5409. MsgId: "H44022900158202103301751082917",
  5410. PsnNo: "44020000001101662162",
  5411. Info: "2208",
  5412. }
  5413. customData = append(customData, custom16)
  5414. custom17 := &CustomData{
  5415. MsgId: "H44022900158202103301754147728",
  5416. PsnNo: "44020000000229014511",
  5417. Info: "2208",
  5418. }
  5419. customData = append(customData, custom17)
  5420. adminUser := c.GetAdminUserInfo()
  5421. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5422. for _, item := range customData {
  5423. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  5424. fmt.Println(result)
  5425. }
  5426. }
  5427. func PathExists(path string) (bool, error) {
  5428. _, err := os.Stat(path)
  5429. if err == nil {
  5430. return true, nil
  5431. }
  5432. if os.IsNotExist(err) {
  5433. return false, nil
  5434. }
  5435. return false, err
  5436. }
  5437. //创建文件夹
  5438. func Mkdir(dir string) {
  5439. // 创建文件夹
  5440. exist, err := PathExists(dir)
  5441. if err != nil {
  5442. fmt.Println(err.Error())
  5443. } else {
  5444. if exist {
  5445. fmt.Println(dir + "文件夹已存在!")
  5446. } else {
  5447. // 文件夹名称,权限
  5448. err := os.Mkdir(dir, os.ModePerm)
  5449. if err != nil {
  5450. fmt.Println(dir+"文件夹创建失败:", err.Error())
  5451. } else {
  5452. fmt.Println(dir + "文件夹创建成功!")
  5453. }
  5454. }
  5455. }
  5456. }
  5457. //压缩文件
  5458. func Zip(srcFile string, destZip string) error {
  5459. zipfile, err := os.Create(destZip)
  5460. if err != nil {
  5461. return err
  5462. }
  5463. defer zipfile.Close()
  5464. archive := zip.NewWriter(zipfile)
  5465. defer archive.Close()
  5466. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  5467. if err != nil {
  5468. return err
  5469. }
  5470. header, err := zip.FileInfoHeader(info)
  5471. if err != nil {
  5472. return err
  5473. }
  5474. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  5475. // header.Name = path
  5476. if info.IsDir() {
  5477. header.Name += "/"
  5478. } else {
  5479. header.Method = zip.Deflate
  5480. }
  5481. writer, err := archive.CreateHeader(header)
  5482. if err != nil {
  5483. return err
  5484. }
  5485. if !info.IsDir() {
  5486. file, err := os.Open(path)
  5487. if err != nil {
  5488. return err
  5489. }
  5490. defer file.Close()
  5491. _, err = io.Copy(writer, file)
  5492. }
  5493. return err
  5494. })
  5495. return err
  5496. }
  5497. func ReadFile(filePath string) []byte {
  5498. f, err := os.Open(filePath)
  5499. if err != nil {
  5500. fmt.Println("read file fail", err)
  5501. return nil
  5502. }
  5503. defer f.Close()
  5504. fd, err := ioutil.ReadAll(f)
  5505. if err != nil {
  5506. fmt.Println("read to fd fail", err)
  5507. return nil
  5508. }
  5509. return fd
  5510. }
  5511. func RemoveRepeatedCode(arr []string) (newArr []string) {
  5512. newArr = make([]string, 0)
  5513. for i := 0; i < len(arr); i++ {
  5514. repeat := false
  5515. for j := i + 1; j < len(arr); j++ {
  5516. if arr[i] == arr[j] {
  5517. repeat = true
  5518. break
  5519. }
  5520. }
  5521. if !repeat {
  5522. newArr = append(newArr, arr[i])
  5523. }
  5524. }
  5525. return
  5526. }