sz_his_api_controller.go 214KB

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