his_api_controller.go 270KB

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