his_api_controller.go 355KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855
  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. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  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. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  65. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  66. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  67. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  68. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  69. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  70. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  71. }
  72. func (c *HisApiController) GetPsnNcdsInfo() {
  73. admin_user_id, _ := c.GetInt64("admin_user_id")
  74. patient_id, _ := c.GetInt64("patient_id")
  75. id, _ := c.GetInt64("id")
  76. adminUser := c.GetAdminUserInfo()
  77. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  78. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  79. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  80. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  81. psn_record, _ := service.GetPsnNCDSRecordById(id)
  82. //
  83. //if psn_record.ID == 0 {
  84. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  85. // return
  86. //}
  87. var res Result5301
  88. var res10265 Result5301For10265
  89. if miConfig.MdtrtareaAdmvs == "320921" {
  90. psn_info, _ := service.GetPsnByPatientId(patient_id)
  91. api := "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  92. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  93. resp, requestErr := http.Get(api)
  94. if requestErr != nil {
  95. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  96. return
  97. }
  98. body, ioErr := ioutil.ReadAll(resp.Body)
  99. if ioErr != nil {
  100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  102. return
  103. }
  104. var respJSON map[string]interface{}
  105. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  108. return
  109. }
  110. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  111. result, _ := json.Marshal(respJSON)
  112. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  113. utils.ErrorLog("解析失败:%v", err)
  114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  115. return
  116. }
  117. res.ErrMsg = res10265.ErrMsg
  118. res.Output = res10265.Output
  119. res.InfRefmsgid = res10265.InfRefmsgid
  120. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  121. res.Infcode = infocode
  122. } else {
  123. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  124. var dat map[string]interface{}
  125. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  126. fmt.Println(dat)
  127. } else {
  128. fmt.Println(err)
  129. }
  130. userJSONBytes, _ := json.Marshal(dat)
  131. if miConfig.Code == "H15049901371" {
  132. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  133. utils.ErrorLog("解析失败:%v", err)
  134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  135. return
  136. }
  137. res.InfRefmsgid = res10265.InfRefmsgid
  138. res.Output = res10265.Output
  139. res.ErrMsg = res10265.ErrMsg
  140. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  141. res.Infcode = infocode
  142. } else {
  143. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  144. utils.ErrorLog("解析失败:%v", err)
  145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  146. return
  147. }
  148. }
  149. }
  150. if res.Infcode == 0 {
  151. c.ServeSuccessJSON(map[string]interface{}{
  152. "result": res.Output.Result,
  153. })
  154. }
  155. }
  156. func (c *HisApiController) CheckInsutype() {
  157. his_patient_id, _ := c.GetInt64("his_patient_id")
  158. admin_user_id, _ := c.GetInt64("admin_user_id")
  159. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  160. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  161. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  162. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  163. var dat map[string]interface{}
  164. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  165. fmt.Println(dat)
  166. } else {
  167. fmt.Println(err)
  168. }
  169. userJSONBytes, _ := json.Marshal(dat)
  170. var res Result90100
  171. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  172. utils.ErrorLog("解析失败:%v", err)
  173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  174. return
  175. }
  176. if res.Infcode != 0 {
  177. c.ServeSuccessJSON(map[string]interface{}{
  178. "failed_code": -10,
  179. "msg": res.ErrMsg,
  180. })
  181. return
  182. } else {
  183. fmt.Println(res)
  184. }
  185. }
  186. func (c *HisApiController) CheckCardPWD() {
  187. card_pwd := c.GetString("card_pwd")
  188. his_patient_id, _ := c.GetInt64("his_patient_id")
  189. admin_user_id, _ := c.GetInt64("admin_user_id")
  190. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  191. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  192. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  193. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  194. var dat map[string]interface{}
  195. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  196. fmt.Println(dat)
  197. } else {
  198. fmt.Println(err)
  199. }
  200. userJSONBytes, _ := json.Marshal(dat)
  201. var res Result90991
  202. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  203. utils.ErrorLog("解析失败:%v", err)
  204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  205. return
  206. }
  207. if res.Infcode != 0 {
  208. c.ServeSuccessJSON(map[string]interface{}{
  209. "failed_code": -10,
  210. "msg": res.ErrMsg,
  211. })
  212. return
  213. } else {
  214. if res.Output.Result.CheckStat == "0" {
  215. var msg string
  216. switch res.Output.Result.CardStat {
  217. case "00":
  218. msg = "未激活"
  219. break
  220. case "10":
  221. msg = "激活"
  222. break
  223. case "20":
  224. msg = "窗口挂失"
  225. break
  226. case "21":
  227. msg = "电话挂失"
  228. break
  229. case "22":
  230. msg = "单位网上申报挂失"
  231. break
  232. case "23":
  233. msg = "保健办挂失"
  234. break
  235. case "24":
  236. msg = "个人网上挂失"
  237. break
  238. case "25":
  239. msg = "网上服务大厅挂失"
  240. break
  241. case "30":
  242. msg = "注销"
  243. break
  244. case "40":
  245. msg = "回收"
  246. break
  247. case "99":
  248. msg = "制卡中(无效卡)"
  249. break
  250. }
  251. c.ServeSuccessJSON(map[string]interface{}{
  252. "failed_code": -10,
  253. "msg": msg,
  254. })
  255. return
  256. } else {
  257. c.ServeSuccessJSON(map[string]interface{}{
  258. "msg": "校验成功",
  259. })
  260. return
  261. }
  262. }
  263. }
  264. func (c *HisApiController) ReadCard() {
  265. id_card_type, _ := c.GetInt64("id_card_type")
  266. admin_user_id, _ := c.GetInt64("admin_user_id")
  267. certificates, _ := c.GetInt64("certificates")
  268. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  269. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  270. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  271. switch id_card_type {
  272. case 1:
  273. if miConfig.MdtrtareaAdmvs == "421300" {
  274. var res ResultTwo
  275. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  276. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  277. "&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)
  278. resp, requestErr := http.Get(api)
  279. if requestErr != nil {
  280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  281. return
  282. }
  283. body, ioErr := ioutil.ReadAll(resp.Body)
  284. if ioErr != nil {
  285. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  287. return
  288. }
  289. var respJSON map[string]interface{}
  290. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  291. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  293. return
  294. }
  295. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  296. result, _ := json.Marshal(respJSON)
  297. fmt.Println("log")
  298. fmt.Println(string(result))
  299. if err := json.Unmarshal([]byte(result), &res); err != nil {
  300. utils.ErrorLog("解析失败:%v", err)
  301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  302. return
  303. }
  304. if res.Infcode == 0 {
  305. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  306. if err == gorm.ErrRecordNotFound {
  307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  308. return
  309. } else if err != nil {
  310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  311. return
  312. } else {
  313. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  314. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  315. infoStr := string(Iinfos)
  316. idetinfoStr := string(Idetinfos)
  317. psn := &models.HisPsn{
  318. PsnNo: res.Output.Baseinfo.PsnNo,
  319. Age: res.Output.Baseinfo.Age,
  320. PatientId: patient.ID,
  321. Certno: res.Output.Baseinfo.Certno,
  322. Brdy: res.Output.Baseinfo.Brdy,
  323. Gend: res.Output.Baseinfo.Gend,
  324. Naty: res.Output.Baseinfo.Naty,
  325. PsnCertType: res.Output.Baseinfo.PsnCertType,
  326. PsnName: res.Output.Baseinfo.PsnName,
  327. Idetinfo: idetinfoStr,
  328. Insuinfo: infoStr,
  329. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  330. }
  331. service.CreateHisPsn(psn)
  332. c.ServeSuccessJSON(map[string]interface{}{
  333. "patient": patient,
  334. "number": res.Output.Baseinfo.Certno,
  335. })
  336. }
  337. } else {
  338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  339. return
  340. }
  341. } else if miConfig.MdtrtareaAdmvs == "320921" {
  342. api := "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  343. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  344. resp, requestErr := http.Get(api)
  345. if requestErr != nil {
  346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  347. return
  348. }
  349. body, ioErr := ioutil.ReadAll(resp.Body)
  350. if ioErr != nil {
  351. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  353. return
  354. }
  355. var respJSON map[string]interface{}
  356. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  359. return
  360. }
  361. var status string
  362. status = respJSON["data"].(map[string]interface{})["status"].(string)
  363. if status == "0" { //读卡成功
  364. var card_info string //卡信息
  365. var busi_card_info string
  366. var res ResultTwo //1101结果
  367. var res10265 ResultTwo10265 //1101结果
  368. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  369. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  370. fmt.Println(card_info)
  371. fmt.Println(busi_card_info)
  372. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  373. result, _ := json.Marshal(respJSON)
  374. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  375. utils.ErrorLog("解析失败:%v", err)
  376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  377. return
  378. }
  379. res.ErrMsg = res10265.ErrMsg
  380. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  381. res.Infcode = infocode
  382. res.Output = res10265.Output
  383. res.InfRefmsgid = res10265.InfRefmsgid
  384. if res.Infcode == 0 {
  385. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  386. if err == gorm.ErrRecordNotFound {
  387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  388. return
  389. } else if err != nil {
  390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  391. return
  392. } else {
  393. bas := strings.Split(card_info, "|")
  394. basNumber := bas[2]
  395. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  396. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  397. infoStr := string(Iinfos)
  398. idetinfoStr := string(Idetinfos)
  399. psn := &models.HisPsn{
  400. PsnNo: res.Output.Baseinfo.PsnNo,
  401. Age: res.Output.Baseinfo.Age,
  402. PatientId: patient.ID,
  403. Certno: res.Output.Baseinfo.Certno,
  404. Brdy: res.Output.Baseinfo.Brdy,
  405. Gend: res.Output.Baseinfo.Gend,
  406. Naty: res.Output.Baseinfo.Naty,
  407. PsnCertType: res.Output.Baseinfo.PsnCertType,
  408. PsnName: res.Output.Baseinfo.PsnName,
  409. Idetinfo: idetinfoStr,
  410. Insuinfo: infoStr,
  411. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  412. CardInfo: card_info,
  413. VerifyNumber: busi_card_info,
  414. }
  415. service.CreateHisPsn(psn)
  416. c.ServeSuccessJSON(map[string]interface{}{
  417. "patient": patient,
  418. "number": basNumber,
  419. })
  420. }
  421. } else {
  422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  423. return
  424. }
  425. } else { //读卡失败
  426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  427. return
  428. }
  429. } else {
  430. if initFlag == 0 {
  431. c.TestGetBasBaseInit()
  432. }
  433. basStr := c.GetBasBaseInfo()
  434. if len(basStr) == 0 {
  435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  436. return
  437. }
  438. fmt.Println(basStr)
  439. bas := strings.Split(basStr, "|")
  440. basNumber := bas[1]
  441. fmt.Println(basNumber)
  442. card_sn := bas[3]
  443. fmt.Println(card_sn)
  444. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  445. var dat map[string]interface{}
  446. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  447. fmt.Println(dat)
  448. } else {
  449. fmt.Println(err)
  450. }
  451. userJSONBytes, _ := json.Marshal(dat)
  452. var res ResultTwo
  453. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  454. utils.ErrorLog("解析失败:%v", err)
  455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  456. return
  457. }
  458. if res.Infcode == 0 {
  459. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  460. if err == gorm.ErrRecordNotFound {
  461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  462. return
  463. } else if err != nil {
  464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  465. return
  466. } else {
  467. c.ServeSuccessJSON(map[string]interface{}{
  468. "patient": patient,
  469. "number": basNumber,
  470. })
  471. }
  472. } else {
  473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  474. return
  475. }
  476. break
  477. }
  478. case 2:
  479. SFZStr := c.GetSFZBaseInfo()
  480. id_card_str := strings.Split(SFZStr, "^")
  481. id_card_number := id_card_str[0]
  482. card_sn := ""
  483. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  484. var dat map[string]interface{}
  485. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  486. fmt.Println(dat)
  487. } else {
  488. fmt.Println(err)
  489. }
  490. userJSONBytes, _ := json.Marshal(dat)
  491. var res ResultTwo
  492. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  493. utils.ErrorLog("解析失败:%v", err)
  494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  495. return
  496. }
  497. if res.Infcode == 0 {
  498. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  499. if err == gorm.ErrRecordNotFound {
  500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  501. return
  502. } else if err != nil {
  503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  504. return
  505. } else {
  506. c.ServeSuccessJSON(map[string]interface{}{
  507. "patient": patient,
  508. "number": id_card_number,
  509. })
  510. }
  511. } else {
  512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  513. return
  514. }
  515. break
  516. case 3:
  517. break
  518. }
  519. }
  520. var initFlag int64 = 0
  521. func (c *HisApiController) TestGetBasBaseInit() {
  522. DllDef := syscall.MustLoadDLL("SSCard.dll")
  523. Iinit := DllDef.MustFindProc("Init")
  524. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  525. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  526. if ret != 0 {
  527. fmt.Println("SSCard的报错原因:", err)
  528. fmt.Println("SSCard的运算结果为:", ret)
  529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  530. return
  531. }
  532. result := int(ret)
  533. fmt.Println("SSCard的运算结果为1:", result)
  534. initFlag = 1
  535. return
  536. }
  537. func (c *HisApiController) GetSFZBaseInfo() string {
  538. DllDef := syscall.MustLoadDLL("SSCard.dll")
  539. readCard := DllDef.MustFindProc("ReadSFZ")
  540. if readCard == nil {
  541. fmt.Println("readcard is nil")
  542. readCard = DllDef.MustFindProc("ReadSFZ")
  543. }
  544. str := make([]byte, 256)
  545. str1 := make([]byte, 256)
  546. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  547. fmt.Println(r)
  548. return string(str)
  549. }
  550. func (c *HisApiController) GetBasBaseInfo() string {
  551. DllDef := syscall.MustLoadDLL("SSCard.dll")
  552. readCard := DllDef.MustFindProc("ReadCardBas")
  553. if readCard == nil {
  554. fmt.Println("readcard is nil")
  555. readCard = DllDef.MustFindProc("ReadCardBas")
  556. }
  557. str := make([]byte, 1024)
  558. str1 := make([]byte, 1024)
  559. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  560. fmt.Println(string(str1))
  561. fmt.Println(string(str))
  562. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  563. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  564. if ret2 != 0 {
  565. return ""
  566. }
  567. return string(str)
  568. }
  569. type CustomFundPay struct {
  570. FundPayType string `json:"fund_pay_type"`
  571. FundPayamt float64 `json:"fund_payamt"`
  572. }
  573. func (c *HisApiController) GetSettleList() {
  574. order_id, _ := c.GetInt64("order_id")
  575. admin_user_id, _ := c.GetInt64("admin_user_id")
  576. order, _ := service.GetHisOrderByIDTwo(order_id)
  577. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  578. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  579. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  580. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  581. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  582. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  583. if order.ID == 0 {
  584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  585. return
  586. }
  587. last_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  588. count, _ := strconv.ParseInt(last_order.FaPiaoNumber, 10, 64)
  589. fmt.Println(count)
  590. var zero string
  591. number := count + 1
  592. if number >= 1000 {
  593. zero = "0000" + strconv.FormatInt(number, 10)
  594. } else if number >= 10000 {
  595. zero = "000" + strconv.FormatInt(number, 10)
  596. } else if number >= 100000 {
  597. zero = "00" + strconv.FormatInt(number, 10)
  598. } else if number >= 1000000 {
  599. zero = "0" + strconv.FormatInt(number, 10)
  600. } else {
  601. zero = strconv.FormatInt(number, 10)
  602. }
  603. fmt.Println(zero)
  604. struct4101 := service.Struct4101{
  605. PsnNo: order.PsnNo,
  606. MdtrtId: order.MdtrtId,
  607. SetlId: order.SetlId,
  608. PsnName: order.PsnName,
  609. Gend: order.Gend,
  610. Brdy: his.Brdy,
  611. Age: his.Age,
  612. Naty: order.Naty,
  613. PatnCertType: "01",
  614. Certno: order.Certno,
  615. Prfs: "90",
  616. ConerName: roles[0].UserName,
  617. PatnRlts: "99",
  618. ConerAddr: miConfig.OrgName,
  619. ConerTel: admin.Mobile,
  620. HiType: order.Insutype,
  621. Insuplc: miConfig.InsuplcAdmdvs,
  622. MaindiagFlag: "1",
  623. BillCode: last_order.FaPiaoCode,
  624. BillNo: order.FaPiaoNumber,
  625. BizSn: zero,
  626. PsnSelfPay: order.PsnPartAmt,
  627. PsnOwnPay: order.PsnPartAmt,
  628. AcctPay: order.AcctPay,
  629. PsnCashpay: order.PsnCashPay,
  630. HiPaymtd: "1",
  631. Hsorg: miConfig.InsuplcAdmdvs,
  632. HsorgOpter: miConfig.InsuplcAdmdvs,
  633. MedinsFillPsn: curRoles.UserName,
  634. MedinsFillDept: depart.Name,
  635. IptMedType: "2",
  636. }
  637. struct4101.SetlBegnDate = order.SetlTime
  638. struct4101.SetlEndDate = order.SetlTime
  639. var rf []CustomFundPay
  640. json.Unmarshal([]byte(order.SetlDetail), &rf)
  641. var tempFunPays []service.CustomStruct
  642. for _, item := range rf {
  643. var tempFunPay service.CustomStruct
  644. tempFunPay.FundPayamt = item.FundPayamt
  645. tempFunPay.FundPayType = item.FundPayType
  646. tempFunPays = append(tempFunPays, tempFunPay)
  647. }
  648. struct4101.CustomStruct = tempFunPays
  649. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  650. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  651. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  652. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  653. var config []*models.HisXtDiagnoseConfig
  654. for _, item := range diagnosis_ids {
  655. id, _ := strconv.ParseInt(item, 10, 64)
  656. diagnosisConfig, _ := service.FindDiagnoseById(id)
  657. config = append(config, &diagnosisConfig)
  658. }
  659. for _, item := range config {
  660. var tempOpspdiseinfo service.OpspdiseinfoStruct
  661. tempOpspdiseinfo.DiagCode = item.CountryCode
  662. tempOpspdiseinfo.DiagName = item.CountryContentName
  663. tempOpspdiseinfo.MaindiagFlag = "1"
  664. tempOpspdiseinfo.OprnOprtCode = ""
  665. tempOpspdiseinfo.OprnOprtName = ""
  666. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  667. }
  668. sickConfigTwo, _ := service.FindSickById(his.SickType)
  669. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  670. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  671. tempOpspdiseinfo2.MaindiagFlag = "2"
  672. tempOpspdiseinfo2.OprnOprtCode = ""
  673. tempOpspdiseinfo2.OprnOprtName = ""
  674. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  675. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  676. var iteminfo service.IteminfoStruct
  677. var bedCostTotal float64 = 0 //床位总费
  678. var bedCostSelfTotal float64 = 0 //床位自费
  679. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  680. var operationCostTotal float64 = 0 //手术费
  681. var operationCostSelfTotal float64 = 0 //手术费
  682. var operationCostPartSelfTotal float64 = 0 //手术费
  683. var otherCostTotal float64 = 0 //其他费用
  684. var otherCostSelfTotal float64 = 0 //其他费用
  685. var otherCostPartSelfTotal float64 = 0 //其他费用
  686. var materialCostTotal float64 = 0 //材料费
  687. var materialCostSelfTotal float64 = 0 //材料费
  688. var materialCostPartSelfTotal float64 = 0 //材料费
  689. var westernMedicineCostTotal float64 = 0 //西药费
  690. var westernMedicineCostSelfTotal float64 = 0 //西药费
  691. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  692. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  693. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  694. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  695. var checkCostTotal float64 = 0 //检查费
  696. var checkCostSelfTotal float64 = 0 //检查费
  697. var checkCostPartSelfTotal float64 = 0 //检查费
  698. var laboratoryCostTotal float64 = 0 //化验费
  699. var laboratoryCostSelfTotal float64 = 0 //化验费
  700. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  701. var treatCostTotal float64 = 0 //治疗费用
  702. var treatCostSelfTotal float64 = 0 //治疗费用
  703. var treatCostPartSelfTotal float64 = 0 //治疗费用
  704. decimal.DivisionPrecision = 2
  705. var bed_fulamt_ownpay_amt float64 = 0
  706. var operation_fulamt_ownpay_amt float64 = 0
  707. var other_fulamt_ownpay_amt float64 = 0
  708. var westernMedicine_fulamt_ownpay_amt float64 = 0
  709. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  710. var check_fulamt_ownpay_amt float64 = 0
  711. var material_fulamt_ownpay_amt float64 = 0
  712. var laboratory_fulamt_ownpay_amt float64 = 0
  713. var treat_fulamt_ownpay_amt float64 = 0
  714. var bed_claa_sunmfee float64 = 0
  715. var bed_clab_amt float64 = 0
  716. var bed_other_amt float64 = 0
  717. var operation_claa_sunmfee float64 = 0
  718. var operation_clab_amt float64 = 0
  719. var operation_other_amt float64 = 0
  720. var other_claa_sunmfee float64 = 0
  721. var other_clab_amt float64 = 0
  722. var other_other_amt float64 = 0
  723. var westernMedicine_claa_sunmfee float64 = 0
  724. var westernMedicine_clab_amt float64 = 0
  725. var westernMedicine_other_amt float64 = 0
  726. var chineseTraditional_claa_sunmfee float64 = 0
  727. var chineseTraditional_clab_amt float64 = 0
  728. var chineseTraditional_other_amt float64 = 0
  729. var check_claa_sunmfee float64 = 0
  730. var check_clab_amt float64 = 0
  731. var check_other_amt float64 = 0
  732. var material_claa_sunmfee float64 = 0
  733. var material_clab_amt float64 = 0
  734. var material_other_amt float64 = 0
  735. var laboratory_claa_sunmfee float64 = 0
  736. var laboratory_clab_amt float64 = 0
  737. var laboratory_other_amt float64 = 0
  738. var treat_claa_sunmfee float64 = 0
  739. var treat_clab_amt float64 = 0
  740. var treat_other_amt float64 = 0
  741. for _, item := range order.HisOrderInfo {
  742. if item.MedChrgitmType == "01" { //床位费
  743. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  744. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  745. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  746. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  747. if item.ChrgitmLv == "1" {
  748. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  749. }
  750. if item.ChrgitmLv == "2" {
  751. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  752. }
  753. if item.ChrgitmLv == "3" {
  754. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  755. }
  756. }
  757. if item.MedChrgitmType == "03" { //检查费
  758. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  759. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  760. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  761. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  762. if item.ChrgitmLv == "1" {
  763. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  764. }
  765. if item.ChrgitmLv == "2" {
  766. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  767. }
  768. if item.ChrgitmLv == "3" {
  769. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  770. }
  771. }
  772. if item.MedChrgitmType == "04" { //化验费
  773. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  774. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  775. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  776. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  777. if item.ChrgitmLv == "1" {
  778. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  779. }
  780. if item.ChrgitmLv == "2" {
  781. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  782. }
  783. if item.ChrgitmLv == "3" {
  784. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  785. }
  786. }
  787. if item.MedChrgitmType == "05" { //治疗费
  788. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  789. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  790. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  791. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  792. if item.ChrgitmLv == "1" {
  793. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  794. }
  795. if item.ChrgitmLv == "2" {
  796. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  797. }
  798. if item.ChrgitmLv == "3" {
  799. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  800. }
  801. }
  802. if item.MedChrgitmType == "06" { //手术费
  803. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  804. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  805. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  806. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  807. if item.ChrgitmLv == "1" {
  808. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  809. }
  810. if item.ChrgitmLv == "2" {
  811. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  812. }
  813. if item.ChrgitmLv == "3" {
  814. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  815. }
  816. }
  817. if item.MedChrgitmType == "08" { //材料费
  818. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  819. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  820. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  821. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  822. if item.ChrgitmLv == "1" {
  823. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  824. }
  825. if item.ChrgitmLv == "2" {
  826. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  827. }
  828. if item.ChrgitmLv == "3" {
  829. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  830. }
  831. }
  832. if item.MedChrgitmType == "09" { //西药费
  833. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  834. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  835. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  836. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  837. if item.ChrgitmLv == "1" {
  838. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  839. }
  840. if item.ChrgitmLv == "2" {
  841. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  842. }
  843. if item.ChrgitmLv == "3" {
  844. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  845. }
  846. }
  847. if item.MedChrgitmType == "11" { //中成费
  848. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  849. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  850. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  851. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  852. if item.ChrgitmLv == "1" {
  853. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  854. }
  855. if item.ChrgitmLv == "2" {
  856. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  857. }
  858. if item.ChrgitmLv == "3" {
  859. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  860. }
  861. }
  862. if item.MedChrgitmType == "14" { //其他费
  863. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  864. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  865. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  866. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  867. if item.ChrgitmLv == "1" {
  868. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  869. }
  870. if item.ChrgitmLv == "2" {
  871. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  872. }
  873. if item.ChrgitmLv == "3" {
  874. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  875. }
  876. }
  877. }
  878. var iteminfoStructs []service.IteminfoStruct
  879. if bedCostTotal != 0 {
  880. iteminfo.MedChrgitm = "01"
  881. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  882. iteminfo.Amt = bedCostTotal
  883. iteminfo.ClaaSumfee = bed_claa_sunmfee
  884. iteminfo.ClabAmt = bed_clab_amt
  885. iteminfo.OthAmt = bed_other_amt
  886. iteminfoStructs = append(iteminfoStructs, iteminfo)
  887. }
  888. if checkCostTotal != 0 {
  889. iteminfo.MedChrgitm = "03"
  890. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  891. iteminfo.Amt = checkCostTotal
  892. iteminfo.ClaaSumfee = check_claa_sunmfee
  893. iteminfo.ClabAmt = check_clab_amt
  894. iteminfo.OthAmt = check_other_amt
  895. iteminfoStructs = append(iteminfoStructs, iteminfo)
  896. }
  897. if laboratoryCostTotal != 0 {
  898. iteminfo.MedChrgitm = "04"
  899. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  900. iteminfo.Amt = laboratoryCostTotal
  901. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  902. iteminfo.ClabAmt = laboratory_clab_amt
  903. iteminfo.OthAmt = laboratory_other_amt
  904. iteminfoStructs = append(iteminfoStructs, iteminfo)
  905. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  906. }
  907. if treatCostTotal != 0 {
  908. iteminfo.MedChrgitm = "05"
  909. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  910. iteminfo.Amt = treatCostTotal
  911. iteminfo.ClaaSumfee = treat_claa_sunmfee
  912. iteminfo.ClabAmt = treat_clab_amt
  913. iteminfo.OthAmt = treat_other_amt
  914. iteminfoStructs = append(iteminfoStructs, iteminfo)
  915. //(struct4101.IteminfoStruct, iteminfo)
  916. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  917. }
  918. if operationCostTotal != 0 {
  919. iteminfo.MedChrgitm = "06"
  920. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  921. iteminfo.Amt = operationCostTotal
  922. iteminfo.ClaaSumfee = operation_claa_sunmfee
  923. iteminfo.ClabAmt = operation_clab_amt
  924. iteminfo.OthAmt = operation_other_amt
  925. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  926. iteminfoStructs = append(iteminfoStructs, iteminfo)
  927. }
  928. if materialCostTotal != 0 {
  929. iteminfo.MedChrgitm = "08"
  930. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  931. iteminfo.Amt = materialCostTotal
  932. iteminfo.ClaaSumfee = material_claa_sunmfee
  933. iteminfo.ClabAmt = material_clab_amt
  934. iteminfo.OthAmt = material_other_amt
  935. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  936. iteminfoStructs = append(iteminfoStructs, iteminfo)
  937. }
  938. if westernMedicineCostTotal != 0 {
  939. iteminfo.MedChrgitm = "09"
  940. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  941. iteminfo.Amt = westernMedicineCostTotal
  942. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  943. iteminfo.ClabAmt = westernMedicine_clab_amt
  944. iteminfo.OthAmt = westernMedicine_other_amt
  945. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  946. iteminfoStructs = append(iteminfoStructs, iteminfo)
  947. }
  948. if chineseTraditionalMedicineCostTotal != 0 {
  949. iteminfo.MedChrgitm = "11"
  950. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  951. iteminfo.Amt = westernMedicineCostTotal
  952. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  953. iteminfo.ClabAmt = westernMedicine_clab_amt
  954. iteminfo.OthAmt = westernMedicine_other_amt
  955. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  956. iteminfoStructs = append(iteminfoStructs, iteminfo)
  957. }
  958. if otherCostTotal != 0 {
  959. iteminfo.MedChrgitm = "14"
  960. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  961. iteminfo.Amt = otherCostTotal
  962. iteminfo.ClaaSumfee = other_claa_sunmfee
  963. iteminfo.ClabAmt = other_clab_amt
  964. iteminfo.OthAmt = other_other_amt
  965. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  966. iteminfoStructs = append(iteminfoStructs, iteminfo)
  967. }
  968. struct4101.IteminfoStruct = iteminfoStructs
  969. struct4101.Ntly = "中国"
  970. struct4101.AdmCaty = "A03.06"
  971. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  972. fmt.Println(result)
  973. var dat map[string]interface{}
  974. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  975. fmt.Println(dat)
  976. } else {
  977. fmt.Println(err)
  978. }
  979. userJSONBytes, _ := json.Marshal(dat)
  980. var res ResultSeventeen
  981. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  982. utils.ErrorLog("解析失败:%v", err)
  983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  984. return
  985. }
  986. if res.Infcode != 0 {
  987. order.FaPiaoNumber = zero
  988. order.FaPiaoCode = last_order.FaPiaoCode
  989. err := service.UpdateOrder(order)
  990. if err != nil {
  991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  992. return
  993. }
  994. c.ServeSuccessJSON(map[string]interface{}{
  995. "failed_code": -10,
  996. "msg": res.ErrMsg,
  997. })
  998. return
  999. } else {
  1000. hisFundSettleListResult := &models.HisFundSettleListResult{
  1001. Number: res.Output.SetlListId,
  1002. Status: 1,
  1003. Ctime: time.Now().Unix(),
  1004. Mtime: time.Now().Unix(),
  1005. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1006. IsUpload: 1,
  1007. OrderId: order_id,
  1008. }
  1009. service.CreateUploadRecord(hisFundSettleListResult)
  1010. c.ServeSuccessJSON(map[string]interface{}{
  1011. "msg": "上传成功",
  1012. "result": hisFundSettleListResult,
  1013. })
  1014. return
  1015. }
  1016. }
  1017. func (c *HisApiController) GetBatchSettleList() {
  1018. org_id, _ := beego.AppConfig.Int64("org_id")
  1019. //stage, _ := c.GetInt64("stage")
  1020. orders, _ := service.GetAllHisOrder(org_id)
  1021. for _, item := range orders {
  1022. order_id := item.ID
  1023. order, _ := service.GetHisOrderByIDTwo(order_id)
  1024. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1025. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1026. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1027. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2500)
  1028. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1029. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1030. if order.ID == 0 {
  1031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1032. return
  1033. }
  1034. if his.BalanceAccountsType == 2 {
  1035. continue
  1036. }
  1037. struct4101 := service.Struct4101{
  1038. PsnNo: order.PsnNo,
  1039. MdtrtId: order.MdtrtId,
  1040. SetlId: order.SetlId,
  1041. PsnName: order.PsnName,
  1042. Gend: order.Gend,
  1043. Brdy: his.Brdy,
  1044. Age: his.Age,
  1045. Naty: order.Naty,
  1046. PatnCertType: "01",
  1047. Certno: order.Certno,
  1048. Prfs: "90",
  1049. ConerName: roles[0].UserName,
  1050. PatnRlts: "99",
  1051. ConerAddr: miConfig.OrgName,
  1052. ConerTel: admin.Mobile,
  1053. HiType: order.Insutype,
  1054. Insuplc: his.InsuplcAdmdvs,
  1055. MaindiagFlag: "1",
  1056. BillCode: order.FaPiaoCode,
  1057. BillNo: order.FaPiaoNumber,
  1058. BizSn: order.Number,
  1059. PsnSelfPay: order.PsnPartAmt,
  1060. PsnOwnPay: order.PsnPartAmt,
  1061. AcctPay: order.AcctPay,
  1062. PsnCashpay: order.PsnCashPay,
  1063. HiPaymtd: "1",
  1064. Hsorg: his.InsuplcAdmdvs,
  1065. HsorgOpter: his.InsuplcAdmdvs,
  1066. MedinsFillPsn: curRoles.UserName,
  1067. MedinsFillDept: depart.Name,
  1068. IptMedType: "2",
  1069. }
  1070. struct4101.SetlBegnDate = order.SetlTime
  1071. struct4101.SetlEndDate = order.SetlTime
  1072. //if order.SettleType == 1 {
  1073. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  1074. // dateStr := t.Format("2006-01-02")
  1075. // struct4101.SetlBegnDate = dateStr
  1076. // struct4101.SetlEndDate = dateStr
  1077. //} else {
  1078. // t := time.Unix(int64(order.SettleStartTime), 0)
  1079. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  1080. // dateStartStr := t.Format("2006-01-02")
  1081. // dateEndStr := t2.Format("2006-01-02")
  1082. // struct4101.SetlBegnDate = dateStartStr
  1083. // struct4101.SetlEndDate = dateEndStr
  1084. //}
  1085. var rf []CustomFundPay
  1086. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1087. var tempFunPays []service.CustomStruct
  1088. var tempFunPay610100 service.CustomStruct
  1089. for _, item := range rf {
  1090. if item.FundPayType == "610100" {
  1091. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  1092. tempFunPay610100.FundPayType = item.FundPayType
  1093. } else {
  1094. var tempFunPay service.CustomStruct
  1095. tempFunPay.FundPayamt = item.FundPayamt
  1096. tempFunPay.FundPayType = item.FundPayType
  1097. tempFunPays = append(tempFunPays, tempFunPay)
  1098. }
  1099. }
  1100. tempFunPays = append(tempFunPays, tempFunPay610100)
  1101. struct4101.CustomStruct = tempFunPays
  1102. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1103. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1104. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  1105. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1106. var config []*models.HisXtDiagnoseConfig
  1107. for _, item := range diagnosis_ids {
  1108. id, _ := strconv.ParseInt(item, 10, 64)
  1109. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1110. config = append(config, &diagnosisConfig)
  1111. }
  1112. for _, item := range config {
  1113. var tempOpspdiseinfo service.OpspdiseinfoStruct
  1114. tempOpspdiseinfo.DiagCode = item.CountryCode
  1115. tempOpspdiseinfo.DiagName = item.CountryContentName
  1116. tempOpspdiseinfo.MaindiagFlag = "1"
  1117. tempOpspdiseinfo.OprnOprtCode = ""
  1118. tempOpspdiseinfo.OprnOprtName = ""
  1119. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  1120. }
  1121. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1122. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1123. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1124. tempOpspdiseinfo2.MaindiagFlag = "2"
  1125. tempOpspdiseinfo2.OprnOprtCode = ""
  1126. tempOpspdiseinfo2.OprnOprtName = ""
  1127. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1128. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1129. var iteminfo service.IteminfoStruct
  1130. var bedCostTotal float64 = 0 //床位总费
  1131. var bedCostSelfTotal float64 = 0 //床位自费
  1132. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1133. var examineCostTotal float64 = 0 //诊查总费
  1134. var examineCostSelfTotal float64 = 0 //诊查自费
  1135. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  1136. var nursingCostTotal float64 = 0 //护理总费
  1137. var nursingCostSelfTotal float64 = 0 //护理自费
  1138. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  1139. var chineseMedicineCostTotal float64 = 0 //中成药
  1140. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  1141. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  1142. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  1143. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  1144. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  1145. var registerCostTotal float64 = 0 //一般诊疗费
  1146. var registerCostSelfTotal float64 = 0 //一般诊疗费
  1147. var registerPartSelfTotal float64 = 0 //一般诊疗费
  1148. var operationCostTotal float64 = 0 //手术费
  1149. var operationCostSelfTotal float64 = 0 //手术费
  1150. var operationCostPartSelfTotal float64 = 0 //手术费
  1151. var otherCostTotal float64 = 0 //其他费用
  1152. var otherCostSelfTotal float64 = 0 //其他费用
  1153. var otherCostPartSelfTotal float64 = 0 //其他费用
  1154. var materialCostTotal float64 = 0 //材料费
  1155. var materialCostSelfTotal float64 = 0 //材料费
  1156. var materialCostPartSelfTotal float64 = 0 //材料费
  1157. var westernMedicineCostTotal float64 = 0 //西药费
  1158. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1159. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1160. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1161. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1162. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1163. var checkCostTotal float64 = 0 //检查费
  1164. var checkCostSelfTotal float64 = 0 //检查费
  1165. var checkCostPartSelfTotal float64 = 0 //检查费
  1166. var laboratoryCostTotal float64 = 0 //化验费
  1167. var laboratoryCostSelfTotal float64 = 0 //化验费
  1168. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1169. var treatCostTotal float64 = 0 //治疗费用
  1170. var treatCostSelfTotal float64 = 0 //治疗费用
  1171. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1172. decimal.DivisionPrecision = 2
  1173. var bed_fulamt_ownpay_amt float64 = 0
  1174. var examine_fulamt_ownpay_amt float64 = 0
  1175. var nursing_fulamt_ownpay_amt float64 = 0
  1176. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1177. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1178. var register_fulamt_ownpay_amt float64 = 0
  1179. var operation_fulamt_ownpay_amt float64 = 0
  1180. var other_fulamt_ownpay_amt float64 = 0
  1181. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1182. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1183. var check_fulamt_ownpay_amt float64 = 0
  1184. var material_fulamt_ownpay_amt float64 = 0
  1185. var laboratory_fulamt_ownpay_amt float64 = 0
  1186. var treat_fulamt_ownpay_amt float64 = 0
  1187. var bed_claa_sunmfee float64 = 0
  1188. var bed_clab_amt float64 = 0
  1189. var bed_other_amt float64 = 0
  1190. var examine_claa_sunmfee float64 = 0
  1191. var examine_clab_amt float64 = 0
  1192. var examine_other_amt float64 = 0
  1193. var nursing_claa_sunmfee float64 = 0
  1194. var nursing_clab_amt float64 = 0
  1195. var nursing_other_amt float64 = 0
  1196. var chinese_medicine_claa_sunmfee float64 = 0
  1197. var chinese_medicine_clab_amt float64 = 0
  1198. var chinese_medicine_other_amt float64 = 0
  1199. var commonly_treatment_claa_sunmfee float64 = 0
  1200. var commonly_treatment_clab_amt float64 = 0
  1201. var commonly_treatment_other_amt float64 = 0
  1202. var operation_claa_sunmfee float64 = 0
  1203. var operation_clab_amt float64 = 0
  1204. var operation_other_amt float64 = 0
  1205. var other_claa_sunmfee float64 = 0
  1206. var other_clab_amt float64 = 0
  1207. var other_other_amt float64 = 0
  1208. var westernMedicine_claa_sunmfee float64 = 0
  1209. var westernMedicine_clab_amt float64 = 0
  1210. var westernMedicine_other_amt float64 = 0
  1211. var chineseTraditional_claa_sunmfee float64 = 0
  1212. var chineseTraditional_clab_amt float64 = 0
  1213. var chineseTraditional_other_amt float64 = 0
  1214. var check_claa_sunmfee float64 = 0
  1215. var check_clab_amt float64 = 0
  1216. var check_other_amt float64 = 0
  1217. var material_claa_sunmfee float64 = 0
  1218. var material_clab_amt float64 = 0
  1219. var material_other_amt float64 = 0
  1220. var laboratory_claa_sunmfee float64 = 0
  1221. var laboratory_clab_amt float64 = 0
  1222. var laboratory_other_amt float64 = 0
  1223. var treat_claa_sunmfee float64 = 0
  1224. var treat_clab_amt float64 = 0
  1225. var treat_other_amt float64 = 0
  1226. var register_claa_sunmfee float64 = 0
  1227. var register_clab_amt float64 = 0
  1228. var register_other_amt float64 = 0
  1229. for _, item := range order.HisOrderInfo {
  1230. if item.MedChrgitmType == "01" { //床位费
  1231. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1232. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1233. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1234. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1235. if item.ChrgitmLv == "1" {
  1236. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1237. }
  1238. if item.ChrgitmLv == "2" {
  1239. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1240. }
  1241. if item.ChrgitmLv == "3" {
  1242. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1243. }
  1244. }
  1245. if item.MedChrgitmType == "02" { //诊查
  1246. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1247. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1248. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1249. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1250. if item.ChrgitmLv == "1" {
  1251. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1252. }
  1253. if item.ChrgitmLv == "2" {
  1254. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1255. }
  1256. if item.ChrgitmLv == "3" {
  1257. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1258. }
  1259. }
  1260. if item.MedChrgitmType == "03" { //检查费
  1261. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1262. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1263. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1264. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1265. if item.ChrgitmLv == "1" {
  1266. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1267. }
  1268. if item.ChrgitmLv == "2" {
  1269. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1270. }
  1271. if item.ChrgitmLv == "3" {
  1272. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1273. }
  1274. }
  1275. if item.MedChrgitmType == "04" { //化验费
  1276. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1277. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1278. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1279. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1280. if item.ChrgitmLv == "1" {
  1281. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1282. }
  1283. if item.ChrgitmLv == "2" {
  1284. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1285. }
  1286. if item.ChrgitmLv == "3" {
  1287. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1288. }
  1289. }
  1290. if item.MedChrgitmType == "05" { //治疗费
  1291. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1292. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1293. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1294. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1295. if item.ChrgitmLv == "1" {
  1296. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1297. }
  1298. if item.ChrgitmLv == "2" {
  1299. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1300. }
  1301. if item.ChrgitmLv == "3" {
  1302. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1303. }
  1304. }
  1305. if item.MedChrgitmType == "06" { //手术费
  1306. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1307. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1308. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1309. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1310. if item.ChrgitmLv == "1" {
  1311. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1312. }
  1313. if item.ChrgitmLv == "2" {
  1314. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1315. }
  1316. if item.ChrgitmLv == "3" {
  1317. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1318. }
  1319. }
  1320. if item.MedChrgitmType == "07" { //手术费
  1321. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1322. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1323. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1324. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1325. if item.ChrgitmLv == "1" {
  1326. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1327. }
  1328. if item.ChrgitmLv == "2" {
  1329. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1330. }
  1331. if item.ChrgitmLv == "3" {
  1332. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1333. }
  1334. }
  1335. if item.MedChrgitmType == "08" { //材料费
  1336. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1337. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1338. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1339. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1340. if item.ChrgitmLv == "1" {
  1341. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1342. }
  1343. if item.ChrgitmLv == "2" {
  1344. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1345. }
  1346. if item.ChrgitmLv == "3" {
  1347. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1348. }
  1349. }
  1350. if item.MedChrgitmType == "09" { //西药费
  1351. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1352. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1353. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1354. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1355. if item.ChrgitmLv == "1" {
  1356. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1357. }
  1358. if item.ChrgitmLv == "2" {
  1359. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1360. }
  1361. if item.ChrgitmLv == "3" {
  1362. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1363. }
  1364. }
  1365. if item.MedChrgitmType == "10" { //中药饮片
  1366. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1367. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1368. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1369. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1370. if item.ChrgitmLv == "1" {
  1371. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1372. }
  1373. if item.ChrgitmLv == "2" {
  1374. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1375. }
  1376. if item.ChrgitmLv == "3" {
  1377. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1378. }
  1379. }
  1380. if item.MedChrgitmType == "11" { //中成费
  1381. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1382. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1383. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1384. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1385. if item.ChrgitmLv == "1" {
  1386. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1387. }
  1388. if item.ChrgitmLv == "2" {
  1389. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1390. }
  1391. if item.ChrgitmLv == "3" {
  1392. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1393. }
  1394. }
  1395. if item.MedChrgitmType == "12" { //中成费
  1396. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1397. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1398. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1399. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1400. if item.ChrgitmLv == "1" {
  1401. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1402. }
  1403. if item.ChrgitmLv == "2" {
  1404. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1405. }
  1406. if item.ChrgitmLv == "3" {
  1407. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1408. }
  1409. }
  1410. if item.MedChrgitmType == "13" { //中成费
  1411. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1412. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1413. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1414. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1415. if item.ChrgitmLv == "1" {
  1416. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1417. }
  1418. if item.ChrgitmLv == "2" {
  1419. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1420. }
  1421. if item.ChrgitmLv == "3" {
  1422. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1423. }
  1424. }
  1425. if item.MedChrgitmType == "14" { //其他费
  1426. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1427. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1428. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1429. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1430. if item.ChrgitmLv == "1" {
  1431. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1432. }
  1433. if item.ChrgitmLv == "2" {
  1434. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1435. }
  1436. if item.ChrgitmLv == "3" {
  1437. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1438. }
  1439. }
  1440. }
  1441. var iteminfoStructs []service.IteminfoStruct
  1442. if bedCostTotal != 0 {
  1443. iteminfo.MedChrgitm = "01"
  1444. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1445. iteminfo.Amt = bedCostTotal
  1446. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1447. iteminfo.ClabAmt = bed_clab_amt
  1448. iteminfo.OthAmt = bed_other_amt
  1449. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1450. }
  1451. if examineCostTotal != 0 {
  1452. iteminfo.MedChrgitm = "02"
  1453. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  1454. iteminfo.Amt = examineCostTotal
  1455. iteminfo.ClaaSumfee = examine_claa_sunmfee
  1456. iteminfo.ClabAmt = examine_clab_amt
  1457. iteminfo.OthAmt = examine_other_amt
  1458. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1459. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1460. }
  1461. if checkCostTotal != 0 {
  1462. iteminfo.MedChrgitm = "03"
  1463. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1464. iteminfo.Amt = checkCostTotal
  1465. iteminfo.ClaaSumfee = check_claa_sunmfee
  1466. iteminfo.ClabAmt = check_clab_amt
  1467. iteminfo.OthAmt = check_other_amt
  1468. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1469. }
  1470. if laboratoryCostTotal != 0 {
  1471. iteminfo.MedChrgitm = "04"
  1472. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1473. iteminfo.Amt = laboratoryCostTotal
  1474. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1475. iteminfo.ClabAmt = laboratory_clab_amt
  1476. iteminfo.OthAmt = laboratory_other_amt
  1477. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1478. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1479. }
  1480. if treatCostTotal != 0 {
  1481. iteminfo.MedChrgitm = "05"
  1482. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1483. iteminfo.Amt = treatCostTotal
  1484. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1485. iteminfo.ClabAmt = treat_clab_amt
  1486. iteminfo.OthAmt = treat_other_amt
  1487. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1488. //(struct4101.IteminfoStruct, iteminfo)
  1489. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1490. }
  1491. if operationCostTotal != 0 {
  1492. iteminfo.MedChrgitm = "06"
  1493. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1494. iteminfo.Amt = operationCostTotal
  1495. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1496. iteminfo.ClabAmt = operation_clab_amt
  1497. iteminfo.OthAmt = operation_other_amt
  1498. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1499. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1500. }
  1501. if nursingCostTotal != 0 {
  1502. iteminfo.MedChrgitm = "07"
  1503. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  1504. iteminfo.Amt = nursingCostTotal
  1505. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  1506. iteminfo.ClabAmt = nursing_clab_amt
  1507. iteminfo.OthAmt = nursing_other_amt
  1508. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1509. }
  1510. if materialCostTotal != 0 {
  1511. iteminfo.MedChrgitm = "08"
  1512. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1513. iteminfo.Amt = materialCostTotal
  1514. iteminfo.ClaaSumfee = material_claa_sunmfee
  1515. iteminfo.ClabAmt = material_clab_amt
  1516. iteminfo.OthAmt = material_other_amt
  1517. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1518. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1519. }
  1520. if westernMedicineCostTotal != 0 {
  1521. iteminfo.MedChrgitm = "09"
  1522. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1523. iteminfo.Amt = westernMedicineCostTotal
  1524. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1525. iteminfo.ClabAmt = westernMedicine_clab_amt
  1526. iteminfo.OthAmt = westernMedicine_other_amt
  1527. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1528. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1529. }
  1530. if chineseMedicineCostTotal != 0 {
  1531. iteminfo.MedChrgitm = "10"
  1532. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  1533. iteminfo.Amt = chineseMedicineCostTotal
  1534. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  1535. iteminfo.ClabAmt = chinese_medicine_clab_amt
  1536. iteminfo.OthAmt = chinese_medicine_other_amt
  1537. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1538. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1539. }
  1540. if chineseTraditionalMedicineCostTotal != 0 {
  1541. iteminfo.MedChrgitm = "11"
  1542. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1543. iteminfo.Amt = westernMedicineCostTotal
  1544. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1545. iteminfo.ClabAmt = westernMedicine_clab_amt
  1546. iteminfo.OthAmt = westernMedicine_other_amt
  1547. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1548. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1549. }
  1550. if commonlyTreatmentCostTotal != 0 {
  1551. iteminfo.MedChrgitm = "12"
  1552. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  1553. iteminfo.Amt = commonlyTreatmentCostTotal
  1554. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  1555. iteminfo.ClabAmt = commonly_treatment_clab_amt
  1556. iteminfo.OthAmt = commonly_treatment_other_amt
  1557. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1558. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1559. }
  1560. if registerCostTotal != 0 {
  1561. iteminfo.MedChrgitm = "13"
  1562. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  1563. iteminfo.Amt = registerCostTotal
  1564. iteminfo.ClaaSumfee = register_claa_sunmfee
  1565. iteminfo.ClabAmt = register_clab_amt
  1566. iteminfo.OthAmt = register_other_amt
  1567. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1568. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1569. }
  1570. if otherCostTotal != 0 {
  1571. iteminfo.MedChrgitm = "14"
  1572. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1573. iteminfo.Amt = otherCostTotal
  1574. iteminfo.ClaaSumfee = other_claa_sunmfee
  1575. iteminfo.ClabAmt = other_clab_amt
  1576. iteminfo.OthAmt = other_other_amt
  1577. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1578. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1579. }
  1580. struct4101.IteminfoStruct = iteminfoStructs
  1581. struct4101.Ntly = "中国"
  1582. struct4101.AdmCaty = "A03.06"
  1583. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, org_id)
  1584. fmt.Println(result)
  1585. var dat map[string]interface{}
  1586. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1587. fmt.Println(dat)
  1588. } else {
  1589. fmt.Println(err)
  1590. }
  1591. userJSONBytes, _ := json.Marshal(dat)
  1592. var res ResultSeventeen
  1593. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1594. utils.ErrorLog("解析失败:%v", err)
  1595. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1596. adminUser := c.GetAdminUserInfo()
  1597. errlog := &models.HisOrderError{
  1598. UserOrgId: adminUser.CurrentOrgId,
  1599. Ctime: time.Now().Unix(),
  1600. Mtime: time.Now().Unix(),
  1601. ErrMsg: res.ErrMsg + "解析失败",
  1602. Status: 1,
  1603. PatientId: order_id,
  1604. Stage: 120,
  1605. }
  1606. service.CreateErrMsgLog(errlog)
  1607. continue
  1608. }
  1609. if res.Infcode != 0 {
  1610. adminUser := c.GetAdminUserInfo()
  1611. errlog := &models.HisOrderError{
  1612. UserOrgId: adminUser.CurrentOrgId,
  1613. Ctime: time.Now().Unix(),
  1614. Mtime: time.Now().Unix(),
  1615. ErrMsg: res.ErrMsg,
  1616. Status: 1,
  1617. PatientId: order_id,
  1618. Stage: 200,
  1619. }
  1620. service.CreateErrMsgLog(errlog)
  1621. continue
  1622. } else {
  1623. hisFundSettleListResult := &models.HisFundSettleListResult{
  1624. Number: res.Output.SetlListId,
  1625. Status: 1,
  1626. Ctime: time.Now().Unix(),
  1627. Mtime: time.Now().Unix(),
  1628. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1629. IsUpload: 1,
  1630. OrderId: order_id,
  1631. }
  1632. service.CreateUploadRecord(hisFundSettleListResult)
  1633. continue
  1634. }
  1635. }
  1636. }
  1637. func (c *HisApiController) GetOrgInfo() {
  1638. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  1639. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  1640. }
  1641. func (c *HisApiController) GetHisPatientInfo() {
  1642. medical_insurance_card := c.GetString("medical_insurance_card")
  1643. id_card_type, _ := c.GetInt64("id_card_type")
  1644. id_card := c.GetString("id_card")
  1645. adminInfo := c.GetAdminUserInfo()
  1646. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  1647. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1648. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  1649. IdCardNo := ""
  1650. if id_card_type == 1 {
  1651. IdCardNo = medical_insurance_card
  1652. } else if id_card_type == 2 {
  1653. IdCardNo = id_card
  1654. }
  1655. if config.IsOpen == 1 {
  1656. 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
  1657. resp, requestErr := http.Get(api)
  1658. if requestErr != nil {
  1659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1660. return
  1661. }
  1662. defer resp.Body.Close()
  1663. body, ioErr := ioutil.ReadAll(resp.Body)
  1664. if ioErr != nil {
  1665. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1667. return
  1668. }
  1669. var respJSON map[string]interface{}
  1670. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1673. return
  1674. }
  1675. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1676. userJSONBytes, _ := json.Marshal(userJSON)
  1677. var res ResultTwo
  1678. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1679. utils.ErrorLog("解析失败:%v", err)
  1680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1681. return
  1682. }
  1683. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1684. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1685. infoStr := string(Iinfos)
  1686. idetinfoStr := string(Idetinfos)
  1687. if res.Infcode == 0 {
  1688. his := models.VMHisPatient{
  1689. Status: 1,
  1690. Ctime: time.Now().Unix(),
  1691. Mtime: time.Now().Unix(),
  1692. PsnNo: res.Output.Baseinfo.PsnNo,
  1693. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1694. Certno: res.Output.Baseinfo.Certno,
  1695. PsnName: res.Output.Baseinfo.PsnName,
  1696. Gend: res.Output.Baseinfo.Gend,
  1697. Naty: res.Output.Baseinfo.Naty,
  1698. Brdy: res.Output.Baseinfo.Brdy,
  1699. Age: res.Output.Baseinfo.Age,
  1700. Iinfo: infoStr,
  1701. Idetinfo: idetinfoStr,
  1702. UserOrgId: adminInfo.CurrentOrgId,
  1703. IsReturn: 1,
  1704. IdCardType: id_card_type,
  1705. }
  1706. c.ServeSuccessJSON(map[string]interface{}{
  1707. "info": his,
  1708. })
  1709. } else {
  1710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1711. return
  1712. }
  1713. }
  1714. }
  1715. //func GetBasBaseInfo() (jsonStr string, err error) {
  1716. //
  1717. // handle := syscall.NewLazyDLL("SSCard.dll")
  1718. // add := handle.NewProc("ReadCardBas")
  1719. // str := make([]byte, 1024)
  1720. // str1 := make([]byte, 1024)
  1721. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1722. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  1723. //
  1724. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  1725. //
  1726. // fmt.Println("> Add(4,5)的结果为:", ret)
  1727. // handle.Release()
  1728. //
  1729. // return "", nil
  1730. //
  1731. //}
  1732. //func GetQRBaseInfo() (jsonStr string, err error) {
  1733. // handle := syscall.LoadDLL("SSCard.dll")
  1734. // ReadCardBas := handle.FindProc("GetQRBase")
  1735. //
  1736. // str := make([]byte, 256)
  1737. // str1 := make([]byte, 256)
  1738. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1739. //
  1740. // fmt.Println(string(str))
  1741. // fmt.Println(r)
  1742. // return string(str), nil
  1743. //}
  1744. //func CardInit() int {
  1745. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  1746. // add := DllTestDef.MustFindProc("Init")
  1747. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  1748. // if err != nil {
  1749. // fmt.Println("SSCard的运算结果为:", ret)
  1750. // }
  1751. // result := int(ret)
  1752. // return result
  1753. //}
  1754. //func CardInit() int {
  1755. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  1756. // if err != nil {
  1757. // fmt.Println("SSCard的运算结果为:", ret)
  1758. // }
  1759. // fmt.Println(err)
  1760. // result := int(ret)
  1761. // return result
  1762. //}
  1763. func IntPtr(n int) uintptr {
  1764. return uintptr(n)
  1765. }
  1766. func StrPtr(s string) uintptr {
  1767. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  1768. }
  1769. type Result2001 struct {
  1770. Cainfo interface{} `json:"cainfo"`
  1771. ErrMsg string `json:"err_msg"`
  1772. InfRefmsgid string `json:"inf_refmsgid"`
  1773. Infcode int64 `json:"infcode"`
  1774. Output struct {
  1775. Trtinfo struct {
  1776. PsnNo string `json:"psn_no"`
  1777. TrtChkType string `json:"trt_chk_type"`
  1778. FundPayType string `json:"fund_pay_type"`
  1779. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  1780. Begndate string `json:"begndate"`
  1781. Enddate string `json:"enddate"`
  1782. TrtChkRslt string `json:"trt_chk_rslt"`
  1783. } `json:"trtinfo"`
  1784. } `json:"output"`
  1785. RefmsgTime string `json:"refmsg_time"`
  1786. RespondTime string `json:"respond_time"`
  1787. Signtype interface{} `json:"signtype"`
  1788. WarnMsg interface{} `json:"warn_msg"`
  1789. }
  1790. type Result2001Org10265 struct {
  1791. Cainfo interface{} `json:"cainfo"`
  1792. ErrMsg string `json:"err_msg"`
  1793. InfRefmsgid string `json:"inf_refmsgid"`
  1794. Infcode string `json:"infcode"`
  1795. Output struct {
  1796. Trtinfo struct {
  1797. PsnNo string `json:"psn_no"`
  1798. TrtChkType string `json:"trt_chk_type"`
  1799. FundPayType string `json:"fund_pay_type"`
  1800. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  1801. Begndate string `json:"begndate"`
  1802. Enddate string `json:"enddate"`
  1803. TrtChkRslt string `json:"trt_chk_rslt"`
  1804. } `json:"trtinfo"`
  1805. } `json:"output"`
  1806. RefmsgTime string `json:"refmsg_time"`
  1807. RespondTime string `json:"respond_time"`
  1808. Signtype interface{} `json:"signtype"`
  1809. WarnMsg interface{} `json:"warn_msg"`
  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 ResultTwo10265 struct {
  1846. ErrMsg string `json:"err_msg"`
  1847. InfRefmsgid string `json:"inf_refmsgid"`
  1848. Infcode string `json:"infcode"`
  1849. Output struct {
  1850. Baseinfo struct {
  1851. Age float64 `json:"age"`
  1852. Brdy string `json:"brdy"`
  1853. Certno string `json:"certno"`
  1854. Gend string `json:"gend"`
  1855. Naty string `json:"naty"`
  1856. PsnCertType string `json:"psn_cert_type"`
  1857. PsnName string `json:"psn_name"`
  1858. PsnNo string `json:"psn_no"`
  1859. } `json:"baseinfo"`
  1860. Idetinfo []interface{} `json:"idetinfo"`
  1861. Iinfo []struct {
  1862. Balc float64 `json:"balc"`
  1863. CvlservFlag string `json:"cvlserv_flag"`
  1864. EmpName string `json:"emp_name"`
  1865. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1866. Insutype string `json:"insutype"`
  1867. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  1868. PausInsuDate string `json:"paus_insu_date"`
  1869. PsnInsuDate string `json:"psn_insu_date"`
  1870. PsnInsuStas string `json:"psn_insu_stas"`
  1871. PsnType string `json:"psn_type"`
  1872. } `json:"insuinfo"`
  1873. } `json:"output"`
  1874. RefmsgTime string `json:"refmsg_time"`
  1875. RespondTime string `json:"respond_time"`
  1876. Signtype interface{} `json:"signtype"`
  1877. WarnInfo interface{} `json:"warn_info"`
  1878. }
  1879. type ResultThree struct {
  1880. Cainfo interface{} `json:"cainfo"`
  1881. ErrMsg string `json:"err_msg"`
  1882. InfRefmsgid string `json:"inf_refmsgid"`
  1883. Infcode int64 `json:"infcode"`
  1884. Output struct {
  1885. Data struct {
  1886. IptOtpNo string `json:"ipt_otp_no"`
  1887. MdtrtID string `json:"mdtrt_id"`
  1888. PsnNo string `json:"psn_no"`
  1889. } `json:"data"`
  1890. } `json:"output"`
  1891. RefmsgTime string `json:"refmsg_time"`
  1892. RespondTime string `json:"respond_time"`
  1893. Signtype interface{} `json:"signtype"`
  1894. WarnMsg interface{} `json:"warn_msg"`
  1895. }
  1896. type ResultThree10265 struct {
  1897. Cainfo interface{} `json:"cainfo"`
  1898. ErrMsg string `json:"err_msg"`
  1899. InfRefmsgid string `json:"inf_refmsgid"`
  1900. Infcode string `json:"infcode"`
  1901. Output struct {
  1902. Data struct {
  1903. IptOtpNo string `json:"ipt_otp_no"`
  1904. MdtrtID string `json:"mdtrt_id"`
  1905. PsnNo string `json:"psn_no"`
  1906. } `json:"data"`
  1907. } `json:"output"`
  1908. RefmsgTime string `json:"refmsg_time"`
  1909. RespondTime string `json:"respond_time"`
  1910. Signtype interface{} `json:"signtype"`
  1911. WarnMsg interface{} `json:"warn_msg"`
  1912. }
  1913. type ResultFour struct {
  1914. Cainfo string `json:"cainfo"`
  1915. ErrMsg string `json:"err_msg"`
  1916. InfRefmsgid string `json:"inf_refmsgid"`
  1917. Infcode int64 `json:"infcode"`
  1918. Output struct {
  1919. Result []struct {
  1920. BasMednFlag string `json:"bas_medn_flag"`
  1921. ChldMedcFlag string `json:"chld_medc_flag"`
  1922. ChrgitmLv string `json:"chrgitm_lv"`
  1923. Cnt float64 `json:"cnt"`
  1924. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  1925. DrtReimFlag string `json:"drt_reim_flag"`
  1926. FeedetlSn string `json:"feedetl_sn"`
  1927. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1928. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  1929. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1930. ListSpItemFlag string `json:"list_sp_item_flag"`
  1931. LmtUsedFlag string `json:"lmt_used_flag"`
  1932. MedChrgitmType string `json:"med_chrgitm_type"`
  1933. Memo string `json:"memo"`
  1934. OverlmtAmt float64 `json:"overlmt_amt"`
  1935. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1936. Pric float64 `json:"pric"`
  1937. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  1938. SelfpayProp float64 `json:"selfpay_prop"`
  1939. } `json:"result"`
  1940. } `json:"output"`
  1941. RefmsgTime string `json:"refmsg_time"`
  1942. RespondTime string `json:"respond_time"`
  1943. Signtype string `json:"signtype"`
  1944. WarnMsg string `json:"warn_msg"`
  1945. }
  1946. type ResultFour10265 struct {
  1947. Cainfo string `json:"cainfo"`
  1948. ErrMsg string `json:"err_msg"`
  1949. InfRefmsgid string `json:"inf_refmsgid"`
  1950. Infcode string `json:"infcode"`
  1951. Output struct {
  1952. Result []struct {
  1953. BasMednFlag string `json:"bas_medn_flag"`
  1954. ChldMedcFlag string `json:"chld_medc_flag"`
  1955. ChrgitmLv string `json:"chrgitm_lv"`
  1956. Cnt float64 `json:"cnt"`
  1957. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  1958. DrtReimFlag string `json:"drt_reim_flag"`
  1959. FeedetlSn string `json:"feedetl_sn"`
  1960. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1961. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  1962. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1963. ListSpItemFlag string `json:"list_sp_item_flag"`
  1964. LmtUsedFlag string `json:"lmt_used_flag"`
  1965. MedChrgitmType string `json:"med_chrgitm_type"`
  1966. Memo string `json:"memo"`
  1967. OverlmtAmt float64 `json:"overlmt_amt"`
  1968. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1969. Pric float64 `json:"pric"`
  1970. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  1971. SelfpayProp float64 `json:"selfpay_prop"`
  1972. } `json:"result"`
  1973. } `json:"output"`
  1974. RefmsgTime string `json:"refmsg_time"`
  1975. RespondTime string `json:"respond_time"`
  1976. Signtype string `json:"signtype"`
  1977. WarnMsg string `json:"warn_msg"`
  1978. }
  1979. type ResultFive struct {
  1980. Balc float64 `json:"balc"`
  1981. CvlservFlag string `json:"cvlserv_flag"`
  1982. EmpName string `json:"emp_name"`
  1983. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1984. Insutype string `json:"insutype"`
  1985. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  1986. PausInsuDate string `json:"paus_insu_date"`
  1987. PsnInsuDate string `json:"psn_insu_date"`
  1988. PsnInsuStas string `json:"psn_insu_stas"`
  1989. PsnType string `json:"psn_type"`
  1990. }
  1991. type ResultSix struct {
  1992. Cainfo interface{} `json:"cainfo"`
  1993. ErrMsg string `json:"err_msg"`
  1994. InfRefmsgid string `json:"inf_refmsgid"`
  1995. Infcode int64 `json:"infcode"`
  1996. Output struct {
  1997. } `json:"output"`
  1998. RefmsgTime string `json:"refmsg_time"`
  1999. RespondTime string `json:"respond_time"`
  2000. Signtype interface{} `json:"signtype"`
  2001. WarnMsg interface{} `json:"warn_msg"`
  2002. }
  2003. type ResultSix10265 struct {
  2004. Cainfo interface{} `json:"cainfo"`
  2005. ErrMsg string `json:"err_msg"`
  2006. InfRefmsgid string `json:"inf_refmsgid"`
  2007. Infcode string `json:"infcode"`
  2008. Output struct {
  2009. } `json:"output"`
  2010. RefmsgTime string `json:"refmsg_time"`
  2011. RespondTime string `json:"respond_time"`
  2012. Signtype interface{} `json:"signtype"`
  2013. WarnMsg interface{} `json:"warn_msg"`
  2014. }
  2015. type ResultSeven struct {
  2016. Cainfo string `json:"cainfo"`
  2017. ErrMsg string `json:"err_msg"`
  2018. InfRefmsgid string `json:"inf_refmsgid"`
  2019. Infcode int64 `json:"infcode"`
  2020. Output struct {
  2021. Setldetail []interface{} `json:"setldetail"`
  2022. Setlinfo struct {
  2023. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2024. AcctPay float64 `json:"acct_pay"`
  2025. ActPayDedc float64 `json:"act_pay_dedc"`
  2026. Age float64 `json:"age"`
  2027. Balc float64 `json:"balc"`
  2028. Brdy string `json:"brdy"`
  2029. Certno string `json:"certno"`
  2030. ClrOptins string `json:"clr_optins"`
  2031. ClrType string `json:"clr_type"`
  2032. ClrWay string `json:"clr_way"`
  2033. CvlservFlag string `json:"cvlserv_flag"`
  2034. CvlservPay float64 `json:"cvlserv_pay"`
  2035. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2036. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2037. Gend string `json:"gend"`
  2038. HifesPay float64 `json:"hifes_pay"`
  2039. HifmiPay float64 `json:"hifmi_pay"`
  2040. HifpPay float64 `json:"hifp_pay"`
  2041. HospPartAmt float64 `json:"hosp_part_amt"`
  2042. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2043. Insutype string `json:"insutype"`
  2044. MafPay float64 `json:"maf_pay"`
  2045. MdtrtCertType string `json:"mdtrt_cert_type"`
  2046. HifobPay float64 `json:"hifob_pay"`
  2047. MdtrtID string `json:"mdtrt_id"`
  2048. MedType string `json:"med_type"`
  2049. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2050. MedinsSetlID string `json:"medins_setl_id"`
  2051. Naty string `json:"naty"`
  2052. OthPay float64 `json:"oth_pay"`
  2053. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2054. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2055. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2056. PsnCashPay float64 `json:"psn_cash_pay"`
  2057. PsnCertType string `json:"psn_cert_type"`
  2058. PsnName string `json:"psn_name"`
  2059. PsnNo string `json:"psn_no"`
  2060. PsnPartAmt float64 `json:"psn_part_amt"`
  2061. PsnType string `json:"psn_type"`
  2062. SetlID string `json:"setl_id"`
  2063. SetlTime string `json:"setl_time"`
  2064. } `json:"setlinfo"`
  2065. } `json:"output"`
  2066. RefmsgTime string `json:"refmsg_time"`
  2067. RespondTime string `json:"respond_time"`
  2068. Signtype interface{} `json:"signtype"`
  2069. WarnMsg interface{} `json:"warn_msg"`
  2070. }
  2071. type ResultSeven10265 struct {
  2072. Cainfo string `json:"cainfo"`
  2073. ErrMsg string `json:"err_msg"`
  2074. InfRefmsgid string `json:"inf_refmsgid"`
  2075. Infcode string `json:"infcode"`
  2076. Output struct {
  2077. Setldetail []interface{} `json:"setldetail"`
  2078. Setlinfo struct {
  2079. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2080. AcctPay float64 `json:"acct_pay"`
  2081. ActPayDedc float64 `json:"act_pay_dedc"`
  2082. Age float64 `json:"age"`
  2083. Balc float64 `json:"balc"`
  2084. Brdy string `json:"brdy"`
  2085. Certno string `json:"certno"`
  2086. ClrOptins string `json:"clr_optins"`
  2087. ClrType string `json:"clr_type"`
  2088. ClrWay string `json:"clr_way"`
  2089. CvlservFlag string `json:"cvlserv_flag"`
  2090. CvlservPay float64 `json:"cvlserv_pay"`
  2091. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2092. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2093. Gend string `json:"gend"`
  2094. HifesPay float64 `json:"hifes_pay"`
  2095. HifmiPay float64 `json:"hifmi_pay"`
  2096. HifpPay float64 `json:"hifp_pay"`
  2097. HospPartAmt float64 `json:"hosp_part_amt"`
  2098. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2099. Insutype string `json:"insutype"`
  2100. MafPay float64 `json:"maf_pay"`
  2101. MdtrtCertType string `json:"mdtrt_cert_type"`
  2102. HifobPay float64 `json:"hifob_pay"`
  2103. MdtrtID string `json:"mdtrt_id"`
  2104. MedType string `json:"med_type"`
  2105. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2106. MedinsSetlID string `json:"medins_setl_id"`
  2107. Naty string `json:"naty"`
  2108. OthPay float64 `json:"oth_pay"`
  2109. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2110. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2111. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2112. PsnCashPay float64 `json:"psn_cash_pay"`
  2113. PsnCertType string `json:"psn_cert_type"`
  2114. PsnName string `json:"psn_name"`
  2115. PsnNo string `json:"psn_no"`
  2116. PsnPartAmt float64 `json:"psn_part_amt"`
  2117. PsnType string `json:"psn_type"`
  2118. SetlID string `json:"setl_id"`
  2119. SetlTime string `json:"setl_time"`
  2120. } `json:"setlinfo"`
  2121. } `json:"output"`
  2122. RefmsgTime string `json:"refmsg_time"`
  2123. RespondTime string `json:"respond_time"`
  2124. Signtype interface{} `json:"signtype"`
  2125. WarnMsg interface{} `json:"warn_msg"`
  2126. }
  2127. type ResultEight struct {
  2128. Cainfo string `json:"cainfo"`
  2129. ErrMsg string `json:"err_msg"`
  2130. InfRefmsgid string `json:"inf_refmsgid"`
  2131. Infcode int64 `json:"infcode"`
  2132. Output struct {
  2133. Stmtinfo struct {
  2134. SetlOptins string `json:"setl_optins"`
  2135. StmtRslt string `json:"stmt_rslt"`
  2136. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2137. } `json:"stmtinfo"`
  2138. } `json:"output"`
  2139. RefmsgTime string `json:"refmsg_time"`
  2140. RespondTime string `json:"respond_time"`
  2141. Signtype interface{} `json:"signtype"`
  2142. WarnMsg interface{} `json:"warn_msg"`
  2143. }
  2144. type ResultEightFor10188 struct {
  2145. Cainfo string `json:"cainfo"`
  2146. ErrMsg string `json:"err_msg"`
  2147. InfRefmsgid string `json:"inf_refmsgid"`
  2148. Infcode string `json:"infcode"`
  2149. Output struct {
  2150. Stmtinfo struct {
  2151. SetlOptins string `json:"setl_optins"`
  2152. StmtRslt string `json:"stmt_rslt"`
  2153. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2154. } `json:"stmtinfo"`
  2155. } `json:"output"`
  2156. RefmsgTime string `json:"refmsg_time"`
  2157. RespondTime string `json:"respond_time"`
  2158. Signtype interface{} `json:"signtype"`
  2159. WarnMsg interface{} `json:"warn_msg"`
  2160. }
  2161. type ResultNine struct {
  2162. Cainfo string `json:"cainfo"`
  2163. ErrMsg string `json:"err_msg"`
  2164. InfRefmsgid string `json:"inf_refmsgid"`
  2165. Infcode int64 `json:"infcode"`
  2166. Output struct {
  2167. FileQuryNo string `json:"file_qury_no"`
  2168. } `json:"output"`
  2169. RefmsgTime string `json:"refmsg_time"`
  2170. RespondTime string `json:"respond_time"`
  2171. Signtype interface{} `json:"signtype"`
  2172. WarnMsg interface{} `json:"warn_msg"`
  2173. }
  2174. type ResultTen struct {
  2175. Cainfo string `json:"cainfo"`
  2176. ErrMsg string `json:"err_msg"`
  2177. InfRefmsgid string `json:"inf_refmsgid"`
  2178. Infcode int64 `json:"infcode"`
  2179. Output struct {
  2180. DldEndtime string `json:"dld_endtime"`
  2181. FileQuryNo string `json:"file_qury_no"`
  2182. Filename string `json:"filename"`
  2183. } `json:"output"`
  2184. RefmsgTime string `json:"refmsg_time"`
  2185. RespondTime string `json:"respond_time"`
  2186. Signtype interface{} `json:"signtype"`
  2187. WarnMsg interface{} `json:"warn_msg"`
  2188. }
  2189. //type Autogenerated struct {
  2190. // Output struct {
  2191. // Setlinfo struct {
  2192. // SetlTime string `json:"setl_time"`
  2193. // CvlservPay float64 `json:"cvlserv_pay"`
  2194. // Year string `json:"year"`
  2195. // MedType string `json:"med_type"`
  2196. // PsnPay float64 `json:"psn_pay"`
  2197. // OpterID string `json:"opter_id"`
  2198. // Begndate string `json:"begndate"`
  2199. // FlxempeFlag string `json:"flxempe_flag"`
  2200. // HifmiPay float64 `json:"hifmi_pay"`
  2201. // PsnNo string `json:"psn_no"`
  2202. // ActPayDedc float64 `json:"act_pay_dedc"`
  2203. // MedinsSetlID interface{} `json:"medins_setl_id"`
  2204. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2205. // ClrWay string `json:"clr_way"`
  2206. // OthPay float64 `json:"oth_pay"`
  2207. // Gend string `json:"gend"`
  2208. // MdtrtID string `json:"mdtrt_id"`
  2209. // AcctPay float64 `json:"acct_pay"`
  2210. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  2211. // Insutype string `json:"insutype"`
  2212. // Invono interface{} `json:"invono"`
  2213. // Enddate string `json:"enddate"`
  2214. // CashPayamt float64 `json:"cash_payamt"`
  2215. // PsnType string `json:"psn_type"`
  2216. // FixmedinsName string `json:"fixmedins_name"`
  2217. // HifpPay float64 `json:"hifp_pay"`
  2218. // NewFlag interface{} `json:"new_flag"`
  2219. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2220. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  2221. // PayLoc string `json:"pay_loc"`
  2222. // ClrType string `json:"clr_type"`
  2223. // RefdSetlFlag string `json:"refd_setl_flag"`
  2224. // CvlservFlag string `json:"cvlserv_flag"`
  2225. // EmpName string `json:"emp_name"`
  2226. // Brdy string `json:"brdy"`
  2227. // Naty string `json:"naty"`
  2228. // Certno string `json:"certno"`
  2229. // DiseCode string `json:"dise_code"`
  2230. // FixmedinsCode string `json:"fixmedins_code"`
  2231. // DedcHospLv string `json:"dedc_hosp_lv"`
  2232. // OpterName string `json:"opter_name"`
  2233. // Balc float64 `json:"balc"`
  2234. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2235. // PsnCertType string `json:"psn_cert_type"`
  2236. // HifobPay float64 `json:"hifob_pay"`
  2237. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  2238. // HifesPay float64 `json:"hifes_pay"`
  2239. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2240. // OptTime string `json:"opt_time"`
  2241. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2242. // SetlID string `json:"setl_id"`
  2243. // MafPay float64 `json:"maf_pay"`
  2244. // PsnName string `json:"psn_name"`
  2245. // InsuOptins interface{} `json:"insu_optins"`
  2246. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2247. // ClrOptins string `json:"clr_optins"`
  2248. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2249. // DiseName string `json:"dise_name"`
  2250. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2251. // Age float64 `json:"age"`
  2252. // DtrtCertType string `json:"dtrt_cert_type"`
  2253. // HospLv string `json:"hosp_lv"`
  2254. // } `json:"setlinfo"`
  2255. // Setldetail []struct {
  2256. // FundPayType string `json:"fund_pay_type"`
  2257. // FundPayamt float64 `json:"fund_payamt"`
  2258. // SetlProcInfo interface{} `json:"setl_proc_info"`
  2259. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  2260. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  2261. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  2262. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2263. // } `json:"setldetail"`
  2264. // } `json:"output"`
  2265. // Infcode int `json:"infcode"`
  2266. // WarnMsg interface{} `json:"warn_msg"`
  2267. // Cainfo interface{} `json:"cainfo"`
  2268. // ErrMsg interface{} `json:"err_msg"`
  2269. // RefmsgTime string `json:"refmsg_time"`
  2270. // Signtype interface{} `json:"signtype"`
  2271. // RespondTime string `json:"respond_time"`
  2272. // InfRefmsgid string `json:"inf_refmsgid"`
  2273. //}
  2274. type ResultEleven struct {
  2275. Cainfo string `json:"cainfo"`
  2276. ErrMsg string `json:"err_msg"`
  2277. InfRefmsgid string `json:"inf_refmsgid"`
  2278. Infcode int64 `json:"infcode"`
  2279. Output struct {
  2280. Setlinfo struct {
  2281. SetlTime string `json:"setl_time"`
  2282. CvlservPay float64 `json:"cvlserv_pay"`
  2283. Year string `json:"year"`
  2284. MedType string `json:"med_type"`
  2285. PsnPay float64 `json:"psn_pay"`
  2286. OpterID string `json:"opter_id"`
  2287. Begndate string `json:"begndate"`
  2288. FlxempeFlag string `json:"flxempe_flag"`
  2289. HifmiPay float64 `json:"hifmi_pay"`
  2290. PsnNo string `json:"psn_no"`
  2291. ActPayDedc float64 `json:"act_pay_dedc"`
  2292. MedinsSetlID interface{} `json:"medins_setl_id"`
  2293. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2294. ClrWay string `json:"clr_way"`
  2295. OthPay float64 `json:"oth_pay"`
  2296. Gend string `json:"gend"`
  2297. MdtrtID string `json:"mdtrt_id"`
  2298. AcctPay float64 `json:"acct_pay"`
  2299. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2300. Insutype string `json:"insutype"`
  2301. Invono interface{} `json:"invono"`
  2302. Enddate string `json:"enddate"`
  2303. CashPayamt float64 `json:"cash_payamt"`
  2304. PsnType string `json:"psn_type"`
  2305. FixmedinsName string `json:"fixmedins_name"`
  2306. HifpPay float64 `json:"hifp_pay"`
  2307. NewFlag interface{} `json:"new_flag"`
  2308. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2309. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2310. PayLoc string `json:"pay_loc"`
  2311. ClrType string `json:"clr_type"`
  2312. RefdSetlFlag string `json:"refd_setl_flag"`
  2313. CvlservFlag string `json:"cvlserv_flag"`
  2314. EmpName string `json:"emp_name"`
  2315. Brdy string `json:"brdy"`
  2316. Naty string `json:"naty"`
  2317. Certno string `json:"certno"`
  2318. DiseCode string `json:"dise_code"`
  2319. FixmedinsCode string `json:"fixmedins_code"`
  2320. DedcHospLv string `json:"dedc_hosp_lv"`
  2321. OpterName string `json:"opter_name"`
  2322. Balc float64 `json:"balc"`
  2323. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2324. PsnCertType string `json:"psn_cert_type"`
  2325. HifobPay float64 `json:"hifob_pay"`
  2326. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2327. HifesPay float64 `json:"hifes_pay"`
  2328. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2329. OptTime string `json:"opt_time"`
  2330. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2331. SetlID string `json:"setl_id"`
  2332. MafPay float64 `json:"maf_pay"`
  2333. PsnName string `json:"psn_name"`
  2334. InsuOptins interface{} `json:"insu_optins"`
  2335. PrefFundPay interface{} `json:"pref_fund_pay"`
  2336. ClrOptins string `json:"clr_optins"`
  2337. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2338. DiseName string `json:"dise_name"`
  2339. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2340. Age float64 `json:"age"`
  2341. DtrtCertType string `json:"dtrt_cert_type"`
  2342. HospLv string `json:"hosp_lv"`
  2343. } `json:"setlinfo"`
  2344. } `json:"output"`
  2345. RefmsgTime string `json:"refmsg_time"`
  2346. RespondTime string `json:"respond_time"`
  2347. Signtype interface{} `json:"signtype"`
  2348. WarnMsg interface{} `json:"warn_msg"`
  2349. }
  2350. type ResultEleven10265 struct {
  2351. Cainfo string `json:"cainfo"`
  2352. ErrMsg string `json:"err_msg"`
  2353. InfRefmsgid string `json:"inf_refmsgid"`
  2354. Infcode string `json:"infcode"`
  2355. Output struct {
  2356. Setlinfo struct {
  2357. SetlTime string `json:"setl_time"`
  2358. CvlservPay float64 `json:"cvlserv_pay"`
  2359. Year string `json:"year"`
  2360. MedType string `json:"med_type"`
  2361. PsnPay float64 `json:"psn_pay"`
  2362. OpterID string `json:"opter_id"`
  2363. Begndate string `json:"begndate"`
  2364. FlxempeFlag string `json:"flxempe_flag"`
  2365. HifmiPay float64 `json:"hifmi_pay"`
  2366. PsnNo string `json:"psn_no"`
  2367. ActPayDedc float64 `json:"act_pay_dedc"`
  2368. MedinsSetlID interface{} `json:"medins_setl_id"`
  2369. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2370. ClrWay string `json:"clr_way"`
  2371. OthPay float64 `json:"oth_pay"`
  2372. Gend string `json:"gend"`
  2373. MdtrtID string `json:"mdtrt_id"`
  2374. AcctPay float64 `json:"acct_pay"`
  2375. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2376. Insutype string `json:"insutype"`
  2377. Invono interface{} `json:"invono"`
  2378. Enddate string `json:"enddate"`
  2379. CashPayamt float64 `json:"cash_payamt"`
  2380. PsnType string `json:"psn_type"`
  2381. FixmedinsName string `json:"fixmedins_name"`
  2382. HifpPay float64 `json:"hifp_pay"`
  2383. NewFlag interface{} `json:"new_flag"`
  2384. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2385. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2386. PayLoc string `json:"pay_loc"`
  2387. ClrType string `json:"clr_type"`
  2388. RefdSetlFlag string `json:"refd_setl_flag"`
  2389. CvlservFlag string `json:"cvlserv_flag"`
  2390. EmpName string `json:"emp_name"`
  2391. Brdy string `json:"brdy"`
  2392. Naty string `json:"naty"`
  2393. Certno string `json:"certno"`
  2394. DiseCode string `json:"dise_code"`
  2395. FixmedinsCode string `json:"fixmedins_code"`
  2396. DedcHospLv string `json:"dedc_hosp_lv"`
  2397. OpterName string `json:"opter_name"`
  2398. Balc float64 `json:"balc"`
  2399. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2400. PsnCertType string `json:"psn_cert_type"`
  2401. HifobPay float64 `json:"hifob_pay"`
  2402. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2403. HifesPay float64 `json:"hifes_pay"`
  2404. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2405. OptTime string `json:"opt_time"`
  2406. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2407. SetlID string `json:"setl_id"`
  2408. MafPay float64 `json:"maf_pay"`
  2409. PsnName string `json:"psn_name"`
  2410. InsuOptins interface{} `json:"insu_optins"`
  2411. PrefFundPay interface{} `json:"pref_fund_pay"`
  2412. ClrOptins string `json:"clr_optins"`
  2413. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2414. DiseName string `json:"dise_name"`
  2415. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2416. Age float64 `json:"age"`
  2417. DtrtCertType string `json:"dtrt_cert_type"`
  2418. HospLv string `json:"hosp_lv"`
  2419. } `json:"setlinfo"`
  2420. } `json:"output"`
  2421. RefmsgTime string `json:"refmsg_time"`
  2422. RespondTime string `json:"respond_time"`
  2423. Signtype interface{} `json:"signtype"`
  2424. WarnMsg interface{} `json:"warn_msg"`
  2425. }
  2426. type ResultTwelve struct {
  2427. Cainfo string `json:"cainfo"`
  2428. ErrMsg string `json:"err_msg"`
  2429. InfRefmsgid string `json:"inf_refmsgid"`
  2430. Infcode int64 `json:"infcode"`
  2431. Output struct {
  2432. MdtrtId string `json:"mdtrt_id"`
  2433. ChrgBchno string `json:"chrg_bchno"`
  2434. PsnNo string `json:"psn_no"`
  2435. } `json:"output"`
  2436. RefmsgTime string `json:"refmsg_time"`
  2437. RespondTime string `json:"respond_time"`
  2438. Signtype interface{} `json:"signtype"`
  2439. WarnMsg interface{} `json:"warn_msg"`
  2440. }
  2441. type ResultThirteen struct {
  2442. ErrMsg string `json:"err_msg"`
  2443. InfRefmsgid string `json:"inf_refmsgid"`
  2444. Infcode int64 `json:"infcode"`
  2445. Output struct {
  2446. Result struct {
  2447. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2448. } `json:"result"`
  2449. } `json:"output"`
  2450. RefmsgTime string `json:"refmsg_time"`
  2451. RespondTime string `json:"respond_time"`
  2452. Signtype interface{} `json:"signtype"`
  2453. WarnInfo interface{} `json:"warn_info"`
  2454. }
  2455. type ResultThirteen10265 struct {
  2456. ErrMsg string `json:"err_msg"`
  2457. InfRefmsgid string `json:"inf_refmsgid"`
  2458. Infcode string `json:"infcode"`
  2459. Output struct {
  2460. Result struct {
  2461. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2462. } `json:"result"`
  2463. } `json:"output"`
  2464. RefmsgTime string `json:"refmsg_time"`
  2465. RespondTime string `json:"respond_time"`
  2466. Signtype interface{} `json:"signtype"`
  2467. WarnInfo interface{} `json:"warn_info"`
  2468. }
  2469. type ResultFourteen struct {
  2470. ErrMsg string `json:"err_msg"`
  2471. InfRefmsgid string `json:"inf_refmsgid"`
  2472. Infcode int64 `json:"infcode"`
  2473. Output struct {
  2474. } `json:"output"`
  2475. RefmsgTime string `json:"refmsg_time"`
  2476. RespondTime string `json:"respond_time"`
  2477. Signtype interface{} `json:"signtype"`
  2478. WarnInfo interface{} `json:"warn_info"`
  2479. }
  2480. type ResultFourteen10265 struct {
  2481. ErrMsg string `json:"err_msg"`
  2482. InfRefmsgid string `json:"inf_refmsgid"`
  2483. Infcode string `json:"infcode"`
  2484. Output struct {
  2485. } `json:"output"`
  2486. RefmsgTime string `json:"refmsg_time"`
  2487. RespondTime string `json:"respond_time"`
  2488. Signtype interface{} `json:"signtype"`
  2489. WarnInfo interface{} `json:"warn_info"`
  2490. }
  2491. type ResultSixteen struct {
  2492. Cainfo string `json:"cainfo"`
  2493. ErrMsg string `json:"err_msg"`
  2494. InfRefmsgid string `json:"inf_refmsgid"`
  2495. Infcode int64 `json:"infcode"`
  2496. Output struct {
  2497. Setldetail []interface{} `json:"setldetail"`
  2498. Setlinfo struct {
  2499. MdtrtID string `json:"mdtrt_id"`
  2500. SetlID string `json:"setl_id"`
  2501. ClrOptins string `json:"clr_optins"`
  2502. SetlTime string `json:"setl_time"`
  2503. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2504. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2505. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2506. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2507. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2508. ActPayDedc float64 `json:"act_pay_dedc"`
  2509. HifpPay float64 `json:"hifp_pay"`
  2510. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2511. Lfpay float64 `json:"selfpay"`
  2512. CvlservPay float64 `json:"cvlserv_pay"`
  2513. HifesPay float64 `json:"hifes_pay"`
  2514. HifmiPay float64 `json:"hifmi_pay"`
  2515. HifobPay float64 `json:"hifob_pay"`
  2516. MafPay float64 `json:"maf_pay"`
  2517. OthPay float64 `json:"oth_pay"`
  2518. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2519. PsnPartAmt float64 `json:"psn_part_amt"`
  2520. AcctPay float64 `json:"acct_pay"`
  2521. Balc float64 `json:"balc"`
  2522. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2523. HospPartAmt float64 `json:"hosp_part_amt"`
  2524. MedinsSetlID string `json:"medins_setl_id"`
  2525. PdnCashPay string `json:"pdn_cash_pay"`
  2526. } `json:"setlinfo"`
  2527. } `json:"output"`
  2528. RefmsgTime string `json:"refmsg_time"`
  2529. RespondTime string `json:"respond_time"`
  2530. Signtype interface{} `json:"signtype"`
  2531. WarnMsg interface{} `json:"warn_msg"`
  2532. }
  2533. type ResultSixteen10265 struct {
  2534. Cainfo string `json:"cainfo"`
  2535. ErrMsg string `json:"err_msg"`
  2536. InfRefmsgid string `json:"inf_refmsgid"`
  2537. Infcode string `json:"infcode"`
  2538. Output struct {
  2539. Setldetail []interface{} `json:"setldetail"`
  2540. Setlinfo struct {
  2541. MdtrtID string `json:"mdtrt_id"`
  2542. SetlID string `json:"setl_id"`
  2543. ClrOptins string `json:"clr_optins"`
  2544. SetlTime string `json:"setl_time"`
  2545. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2546. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2547. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2548. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2549. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2550. ActPayDedc float64 `json:"act_pay_dedc"`
  2551. HifpPay float64 `json:"hifp_pay"`
  2552. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2553. Lfpay float64 `json:"selfpay"`
  2554. CvlservPay float64 `json:"cvlserv_pay"`
  2555. HifesPay float64 `json:"hifes_pay"`
  2556. HifmiPay float64 `json:"hifmi_pay"`
  2557. HifobPay float64 `json:"hifob_pay"`
  2558. MafPay float64 `json:"maf_pay"`
  2559. OthPay float64 `json:"oth_pay"`
  2560. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2561. PsnPartAmt float64 `json:"psn_part_amt"`
  2562. AcctPay float64 `json:"acct_pay"`
  2563. Balc float64 `json:"balc"`
  2564. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2565. HospPartAmt float64 `json:"hosp_part_amt"`
  2566. MedinsSetlID string `json:"medins_setl_id"`
  2567. PdnCashPay string `json:"pdn_cash_pay"`
  2568. } `json:"setlinfo"`
  2569. } `json:"output"`
  2570. RefmsgTime string `json:"refmsg_time"`
  2571. RespondTime string `json:"respond_time"`
  2572. Signtype interface{} `json:"signtype"`
  2573. WarnMsg interface{} `json:"warn_msg"`
  2574. }
  2575. type ResultSeventeen struct {
  2576. ErrMsg string `json:"err_msg"`
  2577. InfRefmsgid string `json:"inf_refmsgid"`
  2578. Infcode int64 `json:"infcode"`
  2579. Output struct {
  2580. SetlListId string `json:"setl_list_id"`
  2581. } `json:"output"`
  2582. RefmsgTime string `json:"refmsg_time"`
  2583. RespondTime string `json:"respond_time"`
  2584. Signtype string `json:"signtype"`
  2585. WarnInfo string `json:"warn_info"`
  2586. }
  2587. type Result90991 struct {
  2588. ErrMsg string `json:"err_msg"`
  2589. InfRefmsgid string `json:"inf_refmsgid"`
  2590. Infcode int64 `json:"infcode"`
  2591. Output struct {
  2592. Result struct {
  2593. PsnNo string `json:"psn_no"`
  2594. CardStat string `json:"card_stat"`
  2595. Certno string `json:"certno"`
  2596. PsnName string `json:"psn_name"`
  2597. CheckStat string `json:"check_stat"`
  2598. } `json:"result"`
  2599. } `json:"output"`
  2600. RefmsgTime string `json:"refmsg_time"`
  2601. RespondTime string `json:"respond_time"`
  2602. Signtype interface{} `json:"signtype"`
  2603. WarnInfo interface{} `json:"warn_info"`
  2604. }
  2605. type Result90100 struct {
  2606. ErrMsg string `json:"err_msg"`
  2607. InfRefmsgid string `json:"inf_refmsgid"`
  2608. Infcode int64 `json:"infcode"`
  2609. Output struct {
  2610. PoolareaNo string `json:"poolarea_no"`
  2611. PoolareaNoName string `json:"poolarea_no_name"`
  2612. Insutype string `json:"insutype"`
  2613. InsutypeName string `json:"insutype_name"`
  2614. ClctType string `json:"clct_type"`
  2615. ClctTypeName string `json:"clct_type_name"`
  2616. ClctFlag string `json:"clct_flag"`
  2617. ClctFlagName string `json:"clct_flag_name"`
  2618. AccrymBegn string `json:"accrym_begn"`
  2619. AccrymEnd string `json:"accrym_end"`
  2620. ClctTime string `json:"clct_time"`
  2621. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  2622. } `json:"output"`
  2623. RefmsgTime string `json:"refmsg_time"`
  2624. RespondTime string `json:"respond_time"`
  2625. Signtype interface{} `json:"signtype"`
  2626. WarnInfo interface{} `json:"warn_info"`
  2627. }
  2628. type Custom struct {
  2629. DetItemFeeSumamt string
  2630. Cut string
  2631. FeedetlSn string
  2632. Price string
  2633. MedListCodg string
  2634. Type int64
  2635. AdviceId int64
  2636. ProjectId int64
  2637. ItemId int64
  2638. }
  2639. type Result5301 struct {
  2640. ErrMsg string `json:"err_msg"`
  2641. InfRefmsgid string `json:"inf_refmsgid"`
  2642. Infcode int64 `json:"infcode"`
  2643. Output struct {
  2644. Result []struct {
  2645. OpspDiseCode string `json:"opsp_dise_code"`
  2646. OpspDiseName string `json:"opsp_dise_name"`
  2647. Begndate string `json:"begndate"`
  2648. Enddate string `json:"enddate"`
  2649. } `json:"feedetail"`
  2650. } `json:"output"`
  2651. RefmsgTime string `json:"refmsg_time"`
  2652. RespondTime string `json:"respond_time"`
  2653. Signtype interface{} `json:"signtype"`
  2654. WarnInfo interface{} `json:"warn_info"`
  2655. }
  2656. type Result5301For10265 struct {
  2657. ErrMsg string `json:"err_msg"`
  2658. InfRefmsgid string `json:"inf_refmsgid"`
  2659. Infcode string `json:"infcode"`
  2660. Output struct {
  2661. Result []struct {
  2662. OpspDiseCode string `json:"opsp_dise_code"`
  2663. OpspDiseName string `json:"opsp_dise_name"`
  2664. Begndate string `json:"begndate"`
  2665. Enddate string `json:"enddate"`
  2666. } `json:"feedetail"`
  2667. } `json:"output"`
  2668. RefmsgTime string `json:"refmsg_time"`
  2669. RespondTime string `json:"respond_time"`
  2670. Signtype interface{} `json:"signtype"`
  2671. WarnInfo interface{} `json:"warn_info"`
  2672. }
  2673. //获取个人信息----挂号-----上传就诊信息
  2674. func (c *HisApiController) GetRegisterInfo() {
  2675. id, _ := c.GetInt64("id")
  2676. record_time := c.GetString("record_time")
  2677. settlementValue, _ := c.GetInt64("settlement_value")
  2678. medical_insurance_card := c.GetString("medical_insurance_card")
  2679. name := c.GetString("name")
  2680. id_card_type, _ := c.GetInt64("id_card_type")
  2681. certificates, _ := c.GetInt64("certificates")
  2682. medical_care, _ := c.GetInt64("medical_care")
  2683. birthday := c.GetString("birthday")
  2684. id_card := c.GetString("id_card")
  2685. register_type, _ := c.GetInt64("register")
  2686. doctor, _ := c.GetInt64("doctor")
  2687. department, _ := c.GetInt64("department")
  2688. gender, _ := c.GetInt64("sex")
  2689. registration_fee, _ := c.GetFloat("registration_fee")
  2690. medical_expenses, _ := c.GetFloat("medical_expenses")
  2691. social_type, _ := c.GetInt64("social_type")
  2692. med_type := c.GetString("social_type")
  2693. admin_user_id, _ := c.GetInt64("admin_user_id")
  2694. insuplc_admdvs := c.GetString("insuplc_admdvs")
  2695. timeLayout := "2006-01-02"
  2696. loc, _ := time.LoadLocation("Local")
  2697. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  2698. birthUnix := birthdays.Unix()
  2699. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2700. if err != nil {
  2701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2702. return
  2703. }
  2704. recordDateTime := theTime.Unix()
  2705. adminInfo := c.GetAdminUserInfo()
  2706. var patient service.Patients
  2707. if id == 0 {
  2708. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  2709. } else {
  2710. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  2711. }
  2712. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  2713. if patientPrescription.ID == 0 {
  2714. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  2715. }
  2716. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2717. if patient.ID == 0 {
  2718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  2719. return
  2720. }
  2721. if len(patient.IdCardNo) == 0 {
  2722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  2723. return
  2724. }
  2725. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2726. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  2727. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  2728. //就诊结算未完成,不能进行二次挂号
  2729. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  2730. if len(his) >= 1 {
  2731. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  2732. if len(his) >= 1 && order.ID == 0 {
  2733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  2734. return
  2735. }
  2736. }
  2737. //var register_log string
  2738. if config.IsOpen == 1 {
  2739. var res ResultTwo
  2740. var res10265 ResultTwo10265
  2741. var PsnNo string
  2742. var PsnCertType string
  2743. var Certno string
  2744. var PsnName string
  2745. var Gend string
  2746. var Naty string
  2747. var Brdy string
  2748. var Age float64
  2749. var infoStr string
  2750. var idetinfoStr string
  2751. var infocode int64
  2752. var verify_number string
  2753. fmt.Println(verify_number)
  2754. if miConfig.MdtrtareaAdmvs == "421300" {
  2755. psn_info, _ := service.GetPsnByPatientId(id)
  2756. PsnNo = psn_info.PsnNo
  2757. PsnCertType = psn_info.PsnCertType
  2758. Certno = psn_info.Certno
  2759. PsnName = psn_info.PsnName
  2760. Gend = psn_info.Gend
  2761. Naty = psn_info.Naty
  2762. Brdy = psn_info.Brdy
  2763. Age = psn_info.Age
  2764. infoStr = psn_info.Insuinfo
  2765. idetinfoStr = psn_info.Idetinfo
  2766. infocode = 0
  2767. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2768. psn_info, _ := service.GetPsnByPatientId(id)
  2769. PsnNo = psn_info.PsnNo
  2770. PsnCertType = psn_info.PsnCertType
  2771. Certno = psn_info.Certno
  2772. PsnName = psn_info.PsnName
  2773. Gend = psn_info.Gend
  2774. Naty = psn_info.Naty
  2775. Brdy = psn_info.Brdy
  2776. Age = psn_info.Age
  2777. infoStr = psn_info.Insuinfo
  2778. idetinfoStr = psn_info.Idetinfo
  2779. infocode = 0
  2780. verify_number = psn_info.VerifyNumber
  2781. } else {
  2782. 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), name)
  2783. saveLog(result, requestLog, "1101", "人员基本信息获取")
  2784. if miConfig.Code == "H15049901371" {
  2785. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2786. utils.ErrorLog("解析失败:%v", err)
  2787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2788. return
  2789. }
  2790. res.ErrMsg = res10265.ErrMsg
  2791. res.Output = res10265.Output
  2792. res.InfRefmsgid = res10265.InfRefmsgid
  2793. } else {
  2794. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2795. utils.ErrorLog("解析失败:%v", err)
  2796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2797. return
  2798. }
  2799. }
  2800. PsnNo = res.Output.Baseinfo.PsnNo
  2801. PsnCertType = res.Output.Baseinfo.PsnCertType
  2802. Certno = res.Output.Baseinfo.Certno
  2803. PsnName = res.Output.Baseinfo.PsnName
  2804. Gend = res.Output.Baseinfo.Gend
  2805. Naty = res.Output.Baseinfo.Naty
  2806. Brdy = res.Output.Baseinfo.Brdy
  2807. Age = res.Output.Baseinfo.Age
  2808. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2809. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2810. infoStr = string(Iinfos)
  2811. idetinfoStr = string(Idetinfos)
  2812. if miConfig.Code == "H15049901371" {
  2813. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  2814. } else {
  2815. infocode = res.Infcode
  2816. }
  2817. }
  2818. if infocode == 0 {
  2819. his := models.VMHisPatient{
  2820. Name: name,
  2821. Gender: gender,
  2822. Birthday: birthUnix,
  2823. MedicalTreatmentType: medical_care,
  2824. IdType: certificates,
  2825. IdCardNo: id_card,
  2826. BalanceAccountsType: settlementValue,
  2827. SocialType: social_type,
  2828. MedicalInsuranceNumber: medical_insurance_card,
  2829. RegisterType: register_type,
  2830. RegisterCost: registration_fee,
  2831. TreatmentCost: medical_expenses,
  2832. Status: 1,
  2833. Ctime: time.Now().Unix(),
  2834. Mtime: time.Now().Unix(),
  2835. PsnNo: PsnNo,
  2836. PsnCertType: PsnCertType,
  2837. Certno: Certno,
  2838. PsnName: PsnName,
  2839. Gend: Gend,
  2840. Naty: Naty,
  2841. Brdy: Brdy,
  2842. Age: Age,
  2843. Iinfo: infoStr,
  2844. Idetinfo: idetinfoStr,
  2845. PatientId: patient.ID,
  2846. RecordDate: theTime.Unix(),
  2847. UserOrgId: adminInfo.CurrentOrgId,
  2848. AdminUserId: admin_user_id,
  2849. IsReturn: 1,
  2850. IdCardType: id_card_type,
  2851. Doctor: doctor,
  2852. Departments: department,
  2853. }
  2854. timestamp := time.Now().Unix()
  2855. tempTime := time.Unix(timestamp, 0)
  2856. timeFormat := tempTime.Format("20060102150405")
  2857. chrgBchno := rand.Intn(100000) + 10000
  2858. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2859. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  2860. department, _ := service.GetDepartMentDetail(department)
  2861. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  2862. IdCardNo := ""
  2863. if id_card_type == 1 {
  2864. // IdCardNo = medical_insurance_card
  2865. IdCardNo = patient.IdCardNo
  2866. } else {
  2867. IdCardNo = patient.IdCardNo
  2868. }
  2869. var rf []*ResultFive
  2870. json.Unmarshal([]byte(his.Iinfo), &rf)
  2871. var insutypes []*ResultFive
  2872. var insutype string
  2873. var insuplc_admdvs_temp string
  2874. var is390 int = 0
  2875. var is310 int = 0
  2876. for _, item := range rf {
  2877. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2878. insutypes = append(insutypes, item)
  2879. }
  2880. }
  2881. if len(insutypes) == 1 {
  2882. insutype = insutypes[0].Insutype
  2883. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2884. } else {
  2885. for _, i := range insutypes {
  2886. if i.Insutype == "390" {
  2887. is390 = 1
  2888. }
  2889. if i.Insutype == "310" {
  2890. is310 = 1
  2891. }
  2892. }
  2893. }
  2894. if is390 == 1 {
  2895. insutype = "390"
  2896. }
  2897. if is310 == 1 {
  2898. insutype = "310"
  2899. }
  2900. if len(insutypes) == 0 {
  2901. insutype = "310"
  2902. }
  2903. if len(insutypes) == 2 {
  2904. insutype = med_type
  2905. }
  2906. if len(med_type) > 0 {
  2907. insutype = med_type
  2908. }
  2909. //for _, item := range rf {
  2910. // if item.Insutype == insutype {
  2911. // insuplc_admdvs = item.InsuplcAdmdvs
  2912. // }
  2913. //}
  2914. var infocode int64
  2915. var resThree ResultThree
  2916. var resThree10265 ResultThree10265
  2917. if len(insuplc_admdvs) == 0 {
  2918. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  2919. } else {
  2920. insuplc_admdvs_temp = insuplc_admdvs
  2921. }
  2922. if miConfig.MdtrtareaAdmvs == "421300" {
  2923. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  2924. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2925. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&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 + "&doctor_name=" + doctor_info.UserName
  2926. resp, requestErr := http.Get(api)
  2927. if requestErr != nil {
  2928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2929. return
  2930. }
  2931. body, ioErr := ioutil.ReadAll(resp.Body)
  2932. if ioErr != nil {
  2933. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2935. return
  2936. }
  2937. var respJSON map[string]interface{}
  2938. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2939. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2941. return
  2942. }
  2943. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2944. result, _ := json.Marshal(respJSON)
  2945. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  2946. utils.ErrorLog("解析失败:%v", err)
  2947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2948. return
  2949. }
  2950. infocode = resThree.Infcode
  2951. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2952. psn_info, _ := service.GetPsnByPatientId(id)
  2953. bas := strings.Split(psn_info.CardInfo, "|")
  2954. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  2955. api := "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  2956. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2957. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&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 + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  2958. resp, requestErr := http.Get(api)
  2959. if requestErr != nil {
  2960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2961. return
  2962. }
  2963. body, ioErr := ioutil.ReadAll(resp.Body)
  2964. if ioErr != nil {
  2965. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2967. return
  2968. }
  2969. var respJSON map[string]interface{}
  2970. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2973. return
  2974. }
  2975. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2976. result, _ := json.Marshal(respJSON)
  2977. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  2978. utils.ErrorLog("解析失败:%v", err)
  2979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2980. return
  2981. }
  2982. resThree.ErrMsg = resThree10265.ErrMsg
  2983. resThree.Output = resThree10265.Output
  2984. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  2985. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  2986. } else {
  2987. 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_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName)
  2988. saveLog(result, requestLog, "2201", "挂号")
  2989. if miConfig.Code == "H15049901371" {
  2990. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  2991. utils.ErrorLog("解析失败:%v", err)
  2992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2993. return
  2994. }
  2995. resThree.ErrMsg = resThree10265.ErrMsg
  2996. resThree.Output = resThree10265.Output
  2997. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  2998. } else {
  2999. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3000. utils.ErrorLog("解析失败:%v", err)
  3001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3002. return
  3003. }
  3004. }
  3005. if miConfig.Code == "H15049901371" {
  3006. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3007. } else {
  3008. infocode = resThree.Infcode
  3009. }
  3010. }
  3011. if infocode != 0 {
  3012. adminUser := c.GetAdminUserInfo()
  3013. errlog := &models.HisOrderError{
  3014. UserOrgId: adminUser.CurrentOrgId,
  3015. Ctime: time.Now().Unix(),
  3016. Mtime: time.Now().Unix(),
  3017. ErrMsg: resThree.ErrMsg,
  3018. Status: 1,
  3019. PatientId: id,
  3020. RecordTime: recordDateTime,
  3021. Stage: 2,
  3022. }
  3023. service.CreateErrMsgLog(errlog)
  3024. c.ServeSuccessJSON(map[string]interface{}{
  3025. "failed_code": -10,
  3026. "msg": resThree.ErrMsg,
  3027. })
  3028. return
  3029. }
  3030. his.Number = resThree.Output.Data.MdtrtID
  3031. his.PsnNo = resThree.Output.Data.PsnNo
  3032. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  3033. his.IdCardNo = patient.IdCardNo
  3034. his.PhoneNumber = patient.Phone
  3035. his.UserOrgId = adminInfo.CurrentOrgId
  3036. his.Insutype = insutype
  3037. his.Ctime = time.Now().Unix()
  3038. his.Mtime = time.Now().Unix()
  3039. his.InsuplcAdmdvs = insuplc_admdvs_temp
  3040. his.Status = 1
  3041. service.UpdateHisPatientStatus(&his)
  3042. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  3043. c.ServeSuccessJSON(map[string]interface{}{
  3044. "his_info": his,
  3045. })
  3046. } else {
  3047. adminUser := c.GetAdminUserInfo()
  3048. errlog := &models.HisOrderError{
  3049. UserOrgId: adminUser.CurrentOrgId,
  3050. Ctime: time.Now().Unix(),
  3051. Mtime: time.Now().Unix(),
  3052. ErrMsg: res.ErrMsg,
  3053. Status: 1,
  3054. PatientId: id,
  3055. RecordTime: recordDateTime,
  3056. Stage: 1,
  3057. }
  3058. service.CreateErrMsgLog(errlog)
  3059. c.ServeSuccessJSON(map[string]interface{}{
  3060. "failed_code": -10,
  3061. "msg": res.ErrMsg,
  3062. })
  3063. return
  3064. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3065. }
  3066. }
  3067. }
  3068. //上传明细----预结算----确认订单
  3069. func (c *HisApiController) GetUploadInfo() {
  3070. id, _ := c.GetInt64("id")
  3071. record_time := c.GetString("record_time")
  3072. his_patient_id, _ := c.GetInt64("his_patient_id")
  3073. order_id, _ := c.GetInt64("order_id")
  3074. pay_way, _ := c.GetInt64("pay_way")
  3075. pay_price, _ := c.GetFloat("pay_price")
  3076. pay_card_no := c.GetString("pay_card_no")
  3077. discount_price, _ := c.GetFloat("discount_price")
  3078. preferential_price, _ := c.GetFloat("preferential_price")
  3079. reality_price, _ := c.GetFloat("reality_price")
  3080. found_price, _ := c.GetFloat("found_price")
  3081. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3082. private_price, _ := c.GetFloat("private_price")
  3083. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3084. admin_user_id, _ := c.GetInt64("admin_user_id")
  3085. fapiao_code := c.GetString("fapiao_code")
  3086. fapiao_number := c.GetString("fapiao_number")
  3087. diagnosis_id := c.GetString("diagnosis")
  3088. sick_type, _ := c.GetInt64("sick_type")
  3089. reg_type, _ := c.GetInt64("p_type")
  3090. begin_time := c.GetString("begin_time")
  3091. id_str := c.GetString("ids")
  3092. ids_arr := strings.Split(id_str, ",")
  3093. timeLayout := "2006-01-02"
  3094. loc, _ := time.LoadLocation("Local")
  3095. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3096. if err != nil {
  3097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3098. return
  3099. }
  3100. recordDateTime := theTime.Unix()
  3101. adminUser := c.GetAdminUserInfo()
  3102. var tempOrder models.HisOrder
  3103. tempOrder, _ = service.GetHisOrderByID(order_id)
  3104. var prescriptions []*models.HisPrescription
  3105. var start_time int64
  3106. var end_time int64
  3107. //if adminUser.CurrentOrgId == 10106{
  3108. // if len(fapiao_code) == 0{
  3109. // fapiao_code = "144072080589"
  3110. // }
  3111. // if len(fapiao_number) == 0{
  3112. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3113. // if order.ID == 0{
  3114. // fapiao_number = "00001520"
  3115. // }else{
  3116. // //fapiao_code = "00001520"
  3117. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3118. // var zero string
  3119. // if fpNumber >= 1000{
  3120. // zero = "0000" + strconv.Itoa(fpNumber)
  3121. // }else if fpNumber >= 10000{
  3122. // zero = "000" + strconv.Itoa(fpNumber)
  3123. // } else if fpNumber >= 100000{
  3124. // zero = "00" + strconv.Itoa(fpNumber)
  3125. // } else if fpNumber >= 1000000{
  3126. // zero = "0" + strconv.Itoa(fpNumber)
  3127. // }else {
  3128. // zero = strconv.Itoa(fpNumber)
  3129. // }
  3130. // fapiao_number = zero
  3131. // }
  3132. // }
  3133. //}
  3134. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3135. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3136. var patientPrescription models.HisPrescriptionInfo
  3137. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3138. if patientPrescription.ID == 0 {
  3139. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3140. }
  3141. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3142. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3143. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3144. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3145. var config []*models.HisXtDiagnoseConfig
  3146. for _, item := range diagnosis_ids {
  3147. id, _ := strconv.ParseInt(item, 10, 64)
  3148. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3149. config = append(config, &diagnosisConfig)
  3150. }
  3151. sickConfig, _ := service.FindSickById(sick_type)
  3152. if tempOrder.ID == 0 {
  3153. tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3154. }
  3155. if tempOrder.ID == 0 {
  3156. var result string
  3157. var requestLog string
  3158. var res2 ResultSix
  3159. var ressix10265 ResultSix10265
  3160. if miConfig.MdtrtareaAdmvs == "421300" {
  3161. data := make(map[string]interface{})
  3162. client := &http.Client{}
  3163. data["psn_no"] = his.PsnNo
  3164. data["mdtrt_id"] = his.Number
  3165. data["doctor"] = roles.UserName
  3166. data["department"] = department.Name
  3167. data["org_name"] = miConfig.OrgName
  3168. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3169. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3170. data["fixmedins_code"] = miConfig.Code
  3171. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3172. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3173. data["secret_key"] = miConfig.SecretKey
  3174. data["sick_code"] = sickConfig.CountryCode
  3175. data["sick_name"] = sickConfig.ClassName
  3176. data["dept"] = strconv.FormatInt(department.ID, 10)
  3177. data["config"] = config
  3178. data["begin_time"] = begin_time
  3179. bytesData, _ := json.Marshal(data)
  3180. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3181. resp, _ := client.Do(req)
  3182. defer resp.Body.Close()
  3183. body, ioErr := ioutil.ReadAll(resp.Body)
  3184. if ioErr != nil {
  3185. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3187. return
  3188. }
  3189. var respJSON map[string]interface{}
  3190. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3191. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3193. return
  3194. }
  3195. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3196. userJSONBytes, _ := json.Marshal(respJSON)
  3197. fmt.Println("log")
  3198. fmt.Println(string(userJSONBytes))
  3199. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3200. utils.ErrorLog("解析失败:%v", err)
  3201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3202. return
  3203. }
  3204. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3205. //江苏地区国家医保医疗类别
  3206. //职工透析:医疗类别选特殊情况门诊9933
  3207. //居民血透门慢: 医疗类别选门诊慢病1402
  3208. //var med_type string
  3209. //if his.Insutype == "310" {
  3210. // if reg_type == 14 {
  3211. // med_type = "9933"
  3212. // } else if reg_type == 11 {
  3213. // med_type = "11"
  3214. //
  3215. // }
  3216. //} else if his.Insutype == "390" {
  3217. // if reg_type == 14 {
  3218. // med_type = "1402"
  3219. // } else if reg_type == 11 {
  3220. // med_type = "11"
  3221. // }
  3222. //}
  3223. data := make(map[string]interface{})
  3224. client := &http.Client{}
  3225. data["psn_no"] = his.PsnNo
  3226. data["mdtrt_id"] = his.Number
  3227. data["doctor"] = roles.UserName
  3228. data["department"] = department.Name
  3229. data["org_name"] = miConfig.OrgName
  3230. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3231. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3232. data["fixmedins_code"] = miConfig.Code
  3233. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3234. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3235. data["secret_key"] = miConfig.SecretKey
  3236. data["sick_code"] = sickConfig.CountryCode
  3237. data["sick_name"] = sickConfig.ClassName
  3238. data["url"] = miConfig.Url
  3239. data["ak"] = miConfig.AccessKey
  3240. data["begin_time"] = begin_time
  3241. data["cainfo"] = miConfig.Cainfo
  3242. data["dept"] = strconv.FormatInt(department.ID, 10)
  3243. data["config"] = config
  3244. bytesData, _ := json.Marshal(data)
  3245. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3246. resp, _ := client.Do(req)
  3247. defer resp.Body.Close()
  3248. body, ioErr := ioutil.ReadAll(resp.Body)
  3249. if ioErr != nil {
  3250. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3252. return
  3253. }
  3254. var respJSON map[string]interface{}
  3255. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3256. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3258. return
  3259. }
  3260. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3261. userJSONBytes, _ := json.Marshal(respJSON)
  3262. fmt.Println("log")
  3263. fmt.Println(string(userJSONBytes))
  3264. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  3265. utils.ErrorLog("解析失败:%v", err)
  3266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3267. return
  3268. }
  3269. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3270. res2.Output = ressix10265.Output
  3271. res2.ErrMsg = ressix10265.ErrMsg
  3272. res2.Cainfo = ressix10265.Cainfo
  3273. res2.WarnMsg = ressix10265.WarnMsg
  3274. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3275. res2.Infcode = infocode
  3276. } else {
  3277. if miConfig.MdtrtareaAdmvs == "440781" { //
  3278. 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, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  3279. } else {
  3280. if miConfig.Code == "H15049901371" {
  3281. //赤峰地区国家医保医疗类别
  3282. //职工透析:医疗类别选特殊情况门诊990502
  3283. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3284. var med_type string
  3285. if his.Insutype == "390" {
  3286. if reg_type == 14 {
  3287. med_type = "9933"
  3288. } else if reg_type == 11 {
  3289. med_type = "11"
  3290. }
  3291. } else if his.Insutype == "310" {
  3292. if reg_type == 14 {
  3293. med_type = "990502"
  3294. } else if reg_type == 11 {
  3295. med_type = "11"
  3296. }
  3297. }
  3298. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, med_type, doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  3299. } else {
  3300. 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, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  3301. }
  3302. }
  3303. saveLog(result, requestLog, "2203", "上传就诊信息")
  3304. var respJSON2 map[string]interface{}
  3305. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3306. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3308. return
  3309. }
  3310. userJSONBytes2, _ := json.Marshal(respJSON2)
  3311. if miConfig.Code == "H15049901371" {
  3312. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  3313. utils.ErrorLog("解析失败:%v", err)
  3314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3315. return
  3316. }
  3317. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3318. res2.Output = ressix10265.Output
  3319. res2.ErrMsg = ressix10265.ErrMsg
  3320. res2.Cainfo = ressix10265.Cainfo
  3321. res2.WarnMsg = ressix10265.WarnMsg
  3322. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3323. res2.Infcode = infocode
  3324. } else {
  3325. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3326. utils.ErrorLog("解析失败:%v", err)
  3327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3328. return
  3329. }
  3330. }
  3331. }
  3332. if res2.Infcode != 0 {
  3333. adminUser := c.GetAdminUserInfo()
  3334. errlog := &models.HisOrderError{
  3335. UserOrgId: adminUser.CurrentOrgId,
  3336. Ctime: time.Now().Unix(),
  3337. Mtime: time.Now().Unix(),
  3338. ErrMsg: res2.ErrMsg,
  3339. Status: 1,
  3340. PatientId: id,
  3341. RecordTime: recordDateTime,
  3342. Stage: 3,
  3343. }
  3344. service.CreateErrMsgLog(errlog)
  3345. c.ServeSuccessJSON(map[string]interface{}{
  3346. "failed_code": -10,
  3347. "msg": res2.ErrMsg,
  3348. })
  3349. return
  3350. } else {
  3351. his.Diagnosis = diagnosis_id
  3352. his.SickType = sickConfig.ID
  3353. var p_type int64
  3354. if reg_type == 1111 || reg_type == 1112 {
  3355. p_type = 11
  3356. }
  3357. his.PType = fmt.Sprintf("%d", p_type)
  3358. service.UpdateHisPatientThree(&his)
  3359. data := make(map[string]interface{})
  3360. if settle_accounts_type == 1 { //日结
  3361. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  3362. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  3363. } else {
  3364. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  3365. }
  3366. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  3367. data["pre"] = prescriptions
  3368. } else { //月结
  3369. start_time_str := c.GetString("start_time")
  3370. end_time_str := c.GetString("end_time")
  3371. timeLayout := "2006-01-02"
  3372. loc, _ := time.LoadLocation("Local")
  3373. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3374. if err != nil {
  3375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3376. return
  3377. }
  3378. recordStartTime := theStartTime.Unix()
  3379. start_time = recordStartTime
  3380. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3381. if err != nil {
  3382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3383. return
  3384. }
  3385. recordEndTime := theEndTime.Unix()
  3386. end_time = recordEndTime
  3387. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3388. data["pre"] = prescriptions
  3389. }
  3390. timestamp := time.Now().Unix()
  3391. tempTime := time.Unix(timestamp, 0)
  3392. timeFormat := tempTime.Format("20060102150405")
  3393. chrgBchno := rand.Intn(100000) + 10000
  3394. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3395. strconv.FormatInt(his.PatientId, 10)
  3396. client := &http.Client{}
  3397. data["psn_no"] = his.PsnNo
  3398. data["mdtrt_id"] = his.Number
  3399. data["chrg_bchno"] = chrg_bchno
  3400. data["org_name"] = miConfig.OrgName
  3401. data["doctor"] = roles.UserName
  3402. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3403. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3404. data["fixmedins_code"] = miConfig.Code
  3405. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3406. // data["dept_code"] = "15"
  3407. //} else {
  3408. data["dept_code"] = department.Number
  3409. //}
  3410. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3411. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3412. data["secret_key"] = miConfig.SecretKey
  3413. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3414. data["url"] = miConfig.Url
  3415. data["ak"] = miConfig.AccessKey
  3416. data["new_doctor_name"] = patientPrescription.Doctor
  3417. data["diag_code"] = sickConfig.CountryCode
  3418. data["cainfo"] = miConfig.Cainfo
  3419. var ids []int64
  3420. for _, item := range prescriptions {
  3421. ids = append(ids, item.ID)
  3422. }
  3423. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3424. if config.IsOpen == 1 { //对接了医保,走医保流程
  3425. var res ResultFour
  3426. var resFour10265 ResultFour10265
  3427. if miConfig.MdtrtareaAdmvs == "421300" {
  3428. bytesData, _ := json.Marshal(data)
  3429. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3430. resp, _ := client.Do(req)
  3431. defer resp.Body.Close()
  3432. body, ioErr := ioutil.ReadAll(resp.Body)
  3433. if ioErr != nil {
  3434. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3436. return
  3437. }
  3438. var respJSON map[string]interface{}
  3439. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3440. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3442. return
  3443. }
  3444. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3445. userJSONBytes, _ := json.Marshal(respJSON)
  3446. fmt.Println("log")
  3447. fmt.Println(string(userJSONBytes))
  3448. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3449. utils.ErrorLog("解析失败:%v", err)
  3450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3451. return
  3452. }
  3453. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3454. bytesData, _ := json.Marshal(data)
  3455. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  3456. resp, _ := client.Do(req)
  3457. defer resp.Body.Close()
  3458. body, ioErr := ioutil.ReadAll(resp.Body)
  3459. if ioErr != nil {
  3460. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3462. return
  3463. }
  3464. var respJSON map[string]interface{}
  3465. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3466. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3468. return
  3469. }
  3470. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3471. userJSONBytes, _ := json.Marshal(respJSON)
  3472. fmt.Println("log")
  3473. fmt.Println(string(userJSONBytes))
  3474. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3475. utils.ErrorLog("解析失败:%v", err)
  3476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3477. return
  3478. }
  3479. res.InfRefmsgid = resFour10265.InfRefmsgid
  3480. res.Output = resFour10265.Output
  3481. res.ErrMsg = resFour10265.ErrMsg
  3482. res.Cainfo = resFour10265.Cainfo
  3483. res.WarnMsg = resFour10265.WarnMsg
  3484. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3485. res.Infcode = infocode
  3486. } else {
  3487. if miConfig.Code == "H15049901371" {
  3488. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), patientPrescription.DoctorId, sickConfig.CountryCode)
  3489. var dat map[string]interface{}
  3490. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3491. fmt.Println(dat)
  3492. } else {
  3493. fmt.Println(err)
  3494. }
  3495. saveLog(result, request_log, "2204", "上传费用明细")
  3496. userJSONBytes, _ := json.Marshal(dat)
  3497. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3498. utils.ErrorLog("解析失败:%v", err)
  3499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3500. return
  3501. }
  3502. res.InfRefmsgid = resFour10265.InfRefmsgid
  3503. res.Output = resFour10265.Output
  3504. res.ErrMsg = resFour10265.ErrMsg
  3505. res.Cainfo = resFour10265.Cainfo
  3506. res.WarnMsg = resFour10265.WarnMsg
  3507. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3508. res.Infcode = infocode
  3509. } else {
  3510. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), patientPrescription.DoctorId, sickConfig.CountryCode)
  3511. var dat map[string]interface{}
  3512. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3513. fmt.Println(dat)
  3514. } else {
  3515. fmt.Println(err)
  3516. }
  3517. saveLog(result, request_log, "2204", "上传费用明细")
  3518. userJSONBytes, _ := json.Marshal(dat)
  3519. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3520. utils.ErrorLog("解析失败:%v", err)
  3521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3522. return
  3523. }
  3524. }
  3525. }
  3526. if res.Infcode == 0 {
  3527. order := &models.HisOrder{
  3528. UserOrgId: adminUser.CurrentOrgId,
  3529. HisPatientId: his.ID,
  3530. PatientId: his.PatientId,
  3531. SettleAccountsDate: recordDateTime,
  3532. MdtrtId: his.Number,
  3533. PsnNo: his.PsnNo,
  3534. MedType: strconv.FormatInt(reg_type, 10),
  3535. Ctime: time.Now().Unix(),
  3536. Mtime: time.Now().Unix(),
  3537. Status: 1,
  3538. Number: chrg_bchno,
  3539. Infcode: res.Infcode,
  3540. WarnMsg: res.WarnMsg,
  3541. Cainfo: res.Cainfo,
  3542. ErrMsg: res.ErrMsg,
  3543. RespondTime: res.RefmsgTime,
  3544. InfRefmsgid: res.InfRefmsgid,
  3545. OrderStatus: 1,
  3546. PayWay: pay_way,
  3547. PayPrice: pay_price,
  3548. PayCardNo: pay_card_no,
  3549. DiscountPrice: discount_price,
  3550. PreferentialPrice: preferential_price,
  3551. RealityPrice: reality_price,
  3552. FoundPrice: found_price,
  3553. MedicalInsurancePrice: medical_insurance_price,
  3554. PrivatePrice: private_price,
  3555. IsMedicineInsurance: 1,
  3556. SettleType: settle_accounts_type,
  3557. SettleStartTime: start_time,
  3558. SettleEndTime: end_time,
  3559. Creator: roles.AdminUserId,
  3560. Modify: roles.AdminUserId,
  3561. FaPiaoNumber: fapiao_number,
  3562. FaPiaoCode: fapiao_code,
  3563. PType: 2,
  3564. Diagnosis: diagnosis_id,
  3565. }
  3566. err = service.CreateOrder(order)
  3567. if err != nil {
  3568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3569. return
  3570. }
  3571. for _, item := range res.Output.Result {
  3572. temp := strings.Split(item.FeedetlSn, "-")
  3573. var advice_id int64 = 0
  3574. var project_id int64 = 0
  3575. var types int64 = 0
  3576. id, _ := strconv.ParseInt(temp[2], 10, 64)
  3577. types, _ = strconv.ParseInt(temp[1], 10, 64)
  3578. if temp[1] == "1" {
  3579. advice_id = id
  3580. project_id = 0
  3581. } else if temp[1] == "2" {
  3582. advice_id = 0
  3583. project_id = id
  3584. }
  3585. info := &models.HisOrderInfo{
  3586. OrderNumber: order.Number,
  3587. FeedetlSn: item.FeedetlSn,
  3588. UploadDate: time.Now().Unix(),
  3589. AdviceId: advice_id,
  3590. DetItemFeeSumamt: item.DetItemFeeSumamt,
  3591. Cnt: item.Cnt,
  3592. Pric: float64(item.Pric),
  3593. PatientId: his.PatientId,
  3594. PricUplmtAmt: item.PricUplmtAmt,
  3595. SelfpayProp: item.SelfpayProp,
  3596. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3597. OverlmtAmt: item.OverlmtAmt,
  3598. PreselfpayAmt: item.PreselfpayAmt,
  3599. BasMednFlag: item.BasMednFlag,
  3600. MedChrgitmType: item.MedChrgitmType,
  3601. HiNegoDrugFlag: item.HiNegoDrugFlag,
  3602. Status: 1,
  3603. Memo: item.Memo,
  3604. Mtime: time.Now().Unix(),
  3605. InscpScpAmt: item.InscpScpAmt,
  3606. DrtReimFlag: item.DrtReimFlag,
  3607. Ctime: time.Now().Unix(),
  3608. ListSpItemFlag: item.ListSpItemFlag,
  3609. ChldMedcFlag: item.ChldMedcFlag,
  3610. LmtUsedFlag: item.LmtUsedFlag,
  3611. ChrgitmLv: item.ChrgitmLv,
  3612. UserOrgId: adminUser.CurrentOrgId,
  3613. HisPatientId: his.ID,
  3614. OrderId: order.ID,
  3615. ProjectId: project_id,
  3616. Type: types,
  3617. }
  3618. service.CreateOrderInfo(info)
  3619. }
  3620. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3621. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  3622. var total float64
  3623. for _, item := range prescriptions {
  3624. if item.Type == 1 { //药品
  3625. for _, subItem := range item.HisDoctorAdviceInfo {
  3626. total = total + (subItem.Price * subItem.PrescribingNumber)
  3627. }
  3628. }
  3629. if item.Type == 2 { //项目
  3630. for _, subItem := range item.HisPrescriptionProject {
  3631. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3632. total = total + (subItem.Price * cnt)
  3633. }
  3634. }
  3635. }
  3636. for _, item := range prescriptions {
  3637. for _, subItem := range item.HisAdditionalCharge {
  3638. total = total + (subItem.Price * float64(subItem.Count))
  3639. }
  3640. }
  3641. var allTotal string
  3642. if adminUser.CurrentOrgId == 9919 {
  3643. allTotal = fmt.Sprintf("%.4f", total)
  3644. } else {
  3645. allTotal = fmt.Sprintf("%.4f", total)
  3646. }
  3647. if res.Infcode == 0 {
  3648. var rf []*ResultFive
  3649. json.Unmarshal([]byte(his.Iinfo), &rf)
  3650. chrg_bchno := chrg_bchno
  3651. cert_no := his.Certno
  3652. var insutypes []string
  3653. var insutype string
  3654. var is390 int = 0
  3655. var is310 int = 0
  3656. for _, item := range rf {
  3657. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3658. insutypes = append(insutypes, item.Insutype)
  3659. }
  3660. }
  3661. if len(insutypes) == 1 {
  3662. insutype = insutypes[0]
  3663. } else {
  3664. for _, i := range insutypes {
  3665. if i == "390" {
  3666. is390 = 1
  3667. }
  3668. if i == "310" {
  3669. is310 = 1
  3670. }
  3671. }
  3672. }
  3673. if is390 == 1 {
  3674. insutype = "390"
  3675. }
  3676. if is310 == 1 {
  3677. insutype = "310"
  3678. }
  3679. if len(insutypes) == 0 {
  3680. insutype = "310"
  3681. }
  3682. if len(insutypes) == 2 {
  3683. insutype = strconv.FormatInt(his.SocialType, 10)
  3684. }
  3685. insutype = strconv.FormatInt(his.SocialType, 10)
  3686. //insutype = "390"
  3687. if his.IdCardType == 1 {
  3688. // cert_no = his.MedicalInsuranceNumber
  3689. cert_no = his.Certno
  3690. } else {
  3691. cert_no = his.Certno
  3692. }
  3693. var res ResultSeven
  3694. var resSeven10265 ResultSeven10265
  3695. var src_resquest string
  3696. var result2 string
  3697. var acct_used_flag string
  3698. fmt.Println("pay_way")
  3699. fmt.Println(pay_way)
  3700. fmt.Println("pay_way")
  3701. if pay_way == 4 {
  3702. acct_used_flag = "1"
  3703. } else {
  3704. acct_used_flag = "0"
  3705. }
  3706. if miConfig.MdtrtareaAdmvs == "421300" {
  3707. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3708. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3709. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3710. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3711. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3712. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3713. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3714. resp, requestErr := http.Get(api)
  3715. if requestErr != nil {
  3716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3717. return
  3718. }
  3719. body, ioErr := ioutil.ReadAll(resp.Body)
  3720. if ioErr != nil {
  3721. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3723. return
  3724. }
  3725. var respJSON map[string]interface{}
  3726. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3727. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3729. return
  3730. }
  3731. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3732. result, _ := json.Marshal(respJSON)
  3733. if miConfig.Code == "H15049901371" {
  3734. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  3735. utils.ErrorLog("解析失败:%v", err)
  3736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3737. return
  3738. }
  3739. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3740. res.Output = resSeven10265.Output
  3741. res.ErrMsg = resSeven10265.ErrMsg
  3742. res.Cainfo = resSeven10265.Cainfo
  3743. res.WarnMsg = resSeven10265.WarnMsg
  3744. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3745. res.Infcode = infocode
  3746. } else {
  3747. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3748. utils.ErrorLog("解析失败:%v", err)
  3749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3750. return
  3751. }
  3752. }
  3753. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3754. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  3755. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3756. //psn_info, _ := service.GetPsnByPatientId(id)
  3757. bas := strings.Split(psn_info.CardInfo, "|")
  3758. if his.IdCardType == 1 {
  3759. cert_no = bas[2]
  3760. } else {
  3761. cert_no = bas[1]
  3762. }
  3763. //江苏地区国家医保医疗类别
  3764. //职工透析:医疗类别选特殊情况门诊9933
  3765. //居民血透门慢: 医疗类别选门诊慢病1402
  3766. //var med_type string
  3767. //if his.Insutype == "310" {
  3768. // if reg_type == 14 {
  3769. // med_type = "9933"
  3770. // } else if reg_type == 11 {
  3771. // med_type = "11"
  3772. //
  3773. // }
  3774. //} else if his.Insutype == "390" {
  3775. // if reg_type == 14 {
  3776. // med_type = "1402"
  3777. // } else if reg_type == 11 {
  3778. // med_type = "11"
  3779. // }
  3780. //}
  3781. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3782. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3783. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3784. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3785. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3786. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3787. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3788. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3789. resp, requestErr := http.Get(api)
  3790. if requestErr != nil {
  3791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3792. return
  3793. }
  3794. body, ioErr := ioutil.ReadAll(resp.Body)
  3795. if ioErr != nil {
  3796. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3798. return
  3799. }
  3800. var respJSON map[string]interface{}
  3801. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3802. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3804. return
  3805. }
  3806. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3807. result, _ := json.Marshal(respJSON)
  3808. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  3809. utils.ErrorLog("解析失败:%v", err)
  3810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3811. return
  3812. }
  3813. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3814. res.Output = resSeven10265.Output
  3815. res.ErrMsg = resSeven10265.ErrMsg
  3816. res.Cainfo = resSeven10265.Cainfo
  3817. res.WarnMsg = resSeven10265.WarnMsg
  3818. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3819. res.Infcode = infocode
  3820. } else {
  3821. if miConfig.Code == "H15049901371" {
  3822. //赤峰地区国家医保医疗类别
  3823. //职工透析:医疗类别选特殊情况门诊990502
  3824. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3825. var med_type string
  3826. if his.Insutype == "390" {
  3827. if reg_type == 14 {
  3828. med_type = "9933"
  3829. } else if reg_type == 11 {
  3830. med_type = "11"
  3831. }
  3832. } else if his.Insutype == "310" {
  3833. if reg_type == 14 {
  3834. med_type = "990502"
  3835. } else if reg_type == 11 {
  3836. med_type = "11"
  3837. }
  3838. }
  3839. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  3840. } else {
  3841. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.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)
  3842. }
  3843. //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)
  3844. var dat map[string]interface{}
  3845. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3846. fmt.Println(dat)
  3847. } else {
  3848. fmt.Println(err)
  3849. }
  3850. saveLog(result2, src_resquest, "2207", "结算")
  3851. userJSONBytes, _ := json.Marshal(dat)
  3852. if miConfig.Code == "H15049901371" {
  3853. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  3854. utils.ErrorLog("解析失败:%v", err)
  3855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3856. return
  3857. }
  3858. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3859. res.Output = resSeven10265.Output
  3860. res.ErrMsg = resSeven10265.ErrMsg
  3861. res.Cainfo = resSeven10265.Cainfo
  3862. res.WarnMsg = resSeven10265.WarnMsg
  3863. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3864. res.Infcode = infocode
  3865. } else {
  3866. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3867. utils.ErrorLog("解析失败:%v", err)
  3868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3869. return
  3870. }
  3871. }
  3872. }
  3873. if res.Infcode != 0 {
  3874. errlog := &models.HisOrderError{
  3875. UserOrgId: adminUser.CurrentOrgId,
  3876. Ctime: time.Now().Unix(),
  3877. Mtime: time.Now().Unix(),
  3878. Number: chrg_bchno,
  3879. ErrMsg: res.ErrMsg,
  3880. Status: 1,
  3881. PatientId: id,
  3882. RecordTime: recordDateTime,
  3883. Stage: 6,
  3884. }
  3885. service.CreateErrMsgLog(errlog)
  3886. c.ServeSuccessJSON(map[string]interface{}{
  3887. "failed_code": -10,
  3888. "msg": res.ErrMsg,
  3889. })
  3890. return
  3891. } else {
  3892. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3893. order.OrderStatus = 2
  3894. order.Status = 1
  3895. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3896. order.SetlId = res.Output.Setlinfo.SetlID
  3897. order.PsnNo = res.Output.Setlinfo.PsnNo
  3898. order.PsnName = res.Output.Setlinfo.PsnName
  3899. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3900. order.Certno = res.Output.Setlinfo.Certno
  3901. order.Gend = res.Output.Setlinfo.Gend
  3902. order.Naty = res.Output.Setlinfo.Naty
  3903. order.Age = res.Output.Setlinfo.Age
  3904. order.Insutype = res.Output.Setlinfo.Insutype
  3905. order.PsnType = res.Output.Setlinfo.PsnType
  3906. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3907. order.SetlTime = res.Output.Setlinfo.SetlTime
  3908. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3909. if res.Output.Setlinfo.MedType == "140101" {
  3910. order.MedType = "14"
  3911. } else {
  3912. order.MedType = res.Output.Setlinfo.MedType
  3913. }
  3914. if reg_type == 1112 {
  3915. order.MedType = "1112"
  3916. }
  3917. if reg_type == 1111 {
  3918. order.MedType = "1111"
  3919. }
  3920. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3921. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3922. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3923. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3924. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3925. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3926. order.HifpPay = res.Output.Setlinfo.HifpPay
  3927. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3928. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3929. order.HifesPay = res.Output.Setlinfo.HifesPay
  3930. order.HifobPay = res.Output.Setlinfo.HifobPay
  3931. order.MafPay = res.Output.Setlinfo.MafPay
  3932. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3933. order.OthPay = res.Output.Setlinfo.OthPay
  3934. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3935. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3936. order.AcctPay = res.Output.Setlinfo.AcctPay
  3937. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3938. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3939. order.Balc = res.Output.Setlinfo.Balc
  3940. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3941. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3942. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3943. order.ClrType = res.Output.Setlinfo.ClrType
  3944. order.ClrWay = res.Output.Setlinfo.ClrWay
  3945. order.Creator = order.Creator
  3946. order.Modify = roles.AdminUserId
  3947. order.RequestLog = src_resquest
  3948. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3949. detailStr := string(setlDetail)
  3950. order.SetlDetail = detailStr
  3951. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3952. err = service.UpDateOrder(order)
  3953. if err == nil {
  3954. c.ServeSuccessJSON(map[string]interface{}{
  3955. "msg": "结算成功",
  3956. })
  3957. } else {
  3958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3959. return
  3960. }
  3961. }
  3962. } else {
  3963. adminUser := c.GetAdminUserInfo()
  3964. errlog := &models.HisOrderError{
  3965. UserOrgId: adminUser.CurrentOrgId,
  3966. Ctime: time.Now().Unix(),
  3967. Mtime: time.Now().Unix(),
  3968. ErrMsg: res.ErrMsg,
  3969. Status: 1,
  3970. PatientId: id,
  3971. RecordTime: recordDateTime,
  3972. Stage: 4,
  3973. }
  3974. service.CreateErrMsgLog(errlog)
  3975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3976. return
  3977. }
  3978. } else {
  3979. adminUser := c.GetAdminUserInfo()
  3980. errlog := &models.HisOrderError{
  3981. UserOrgId: adminUser.CurrentOrgId,
  3982. Ctime: time.Now().Unix(),
  3983. Mtime: time.Now().Unix(),
  3984. ErrMsg: res.ErrMsg,
  3985. Status: 1,
  3986. PatientId: id,
  3987. RecordTime: recordDateTime,
  3988. Stage: 4,
  3989. }
  3990. service.CreateErrMsgLog(errlog)
  3991. c.ServeSuccessJSON(map[string]interface{}{
  3992. "failed_code": -10,
  3993. "msg": res.ErrMsg,
  3994. })
  3995. return
  3996. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  3997. //return
  3998. }
  3999. }
  4000. }
  4001. } else if tempOrder.ID > 0 {
  4002. if tempOrder.IsPre == 1 {
  4003. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  4004. var rf []*ResultFive
  4005. json.Unmarshal([]byte(his.Iinfo), &rf)
  4006. chrg_bchno := tempOrder.Number
  4007. cert_no := his.Certno
  4008. var insutypes []string
  4009. var insutype string
  4010. var is390 int = 0
  4011. var is310 int = 0
  4012. for _, item := range rf {
  4013. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4014. insutypes = append(insutypes, item.Insutype)
  4015. }
  4016. }
  4017. if len(insutypes) == 1 {
  4018. insutype = insutypes[0]
  4019. } else {
  4020. for _, i := range insutypes {
  4021. if i == "390" {
  4022. is390 = 1
  4023. }
  4024. if i == "310" {
  4025. is310 = 1
  4026. }
  4027. }
  4028. }
  4029. if is390 == 1 {
  4030. insutype = "390"
  4031. }
  4032. if is310 == 1 {
  4033. insutype = "310"
  4034. }
  4035. if len(insutypes) == 0 {
  4036. insutype = "310"
  4037. }
  4038. if len(insutypes) == 2 {
  4039. insutype = strconv.FormatInt(his.SocialType, 64)
  4040. }
  4041. //insutype = "390"
  4042. if his.IdCardType == 1 {
  4043. // cert_no = his.MedicalInsuranceNumber
  4044. cert_no = his.Certno
  4045. } else {
  4046. cert_no = his.Certno
  4047. }
  4048. var res ResultSeven
  4049. var resSeven10265 ResultSeven10265
  4050. var src_resquest string
  4051. var result2 string
  4052. var acct_used_flag string
  4053. fmt.Println("pay_way")
  4054. fmt.Println(pay_way)
  4055. fmt.Println("pay_way")
  4056. if pay_way == 4 {
  4057. acct_used_flag = "1"
  4058. } else {
  4059. acct_used_flag = "0"
  4060. }
  4061. if miConfig.MdtrtareaAdmvs == "421300" {
  4062. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4063. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4064. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4065. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4066. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4067. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4068. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4069. resp, requestErr := http.Get(api)
  4070. if requestErr != nil {
  4071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4072. return
  4073. }
  4074. body, ioErr := ioutil.ReadAll(resp.Body)
  4075. if ioErr != nil {
  4076. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4078. return
  4079. }
  4080. var respJSON map[string]interface{}
  4081. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4082. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4084. return
  4085. }
  4086. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4087. result, _ := json.Marshal(respJSON)
  4088. fmt.Println("log")
  4089. fmt.Println(string(result))
  4090. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4091. utils.ErrorLog("解析失败:%v", err)
  4092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4093. return
  4094. }
  4095. } else if miConfig.MdtrtareaAdmvs == "320921" {
  4096. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4097. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4098. //psn_info, _ := service.GetPsnByPatientId(id)
  4099. bas := strings.Split(psn_info.CardInfo, "|")
  4100. if his.IdCardType == 1 {
  4101. cert_no = bas[2]
  4102. } else {
  4103. cert_no = bas[1]
  4104. }
  4105. //江苏地区国家医保医疗类别
  4106. //职工透析:医疗类别选特殊情况门诊9933
  4107. //居民血透门慢: 医疗类别选门诊慢病1402
  4108. //var med_type string
  4109. //if his.Insutype == "310" {
  4110. // if reg_type == 14 {
  4111. // med_type = "9933"
  4112. // } else if reg_type == 11 {
  4113. // med_type = "11"
  4114. //
  4115. // }
  4116. //} else if his.Insutype == "390" {
  4117. // if reg_type == 14 {
  4118. // med_type = "1402"
  4119. // } else if reg_type == 11 {
  4120. // med_type = "11"
  4121. // }
  4122. //}
  4123. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4124. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4125. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4126. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4127. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4128. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4129. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4130. resp, requestErr := http.Get(api)
  4131. if requestErr != nil {
  4132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4133. return
  4134. }
  4135. body, ioErr := ioutil.ReadAll(resp.Body)
  4136. if ioErr != nil {
  4137. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4139. return
  4140. }
  4141. var respJSON map[string]interface{}
  4142. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4143. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4145. return
  4146. }
  4147. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4148. result, _ := json.Marshal(respJSON)
  4149. fmt.Println("log")
  4150. fmt.Println(string(result))
  4151. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4152. utils.ErrorLog("解析失败:%v", err)
  4153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4154. return
  4155. }
  4156. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4157. res.Output = resSeven10265.Output
  4158. res.ErrMsg = resSeven10265.ErrMsg
  4159. res.Cainfo = resSeven10265.Cainfo
  4160. res.WarnMsg = resSeven10265.WarnMsg
  4161. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4162. res.Infcode = infocode
  4163. } else {
  4164. var src_resquest string
  4165. if miConfig.Code == "H15049901371" {
  4166. //赤峰地区国家医保医疗类别
  4167. //职工透析:医疗类别选特殊情况门诊990502
  4168. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4169. var med_type string
  4170. if his.Insutype == "390" {
  4171. if reg_type == 14 {
  4172. med_type = "9933"
  4173. } else if reg_type == 11 {
  4174. med_type = "11"
  4175. }
  4176. } else if his.Insutype == "310" {
  4177. if reg_type == 14 {
  4178. med_type = "990502"
  4179. } else if reg_type == 11 {
  4180. med_type = "11"
  4181. }
  4182. }
  4183. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  4184. } else {
  4185. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.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)
  4186. }
  4187. var dat map[string]interface{}
  4188. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4189. fmt.Println(dat)
  4190. } else {
  4191. fmt.Println(err)
  4192. }
  4193. saveLog(result2, src_resquest, "2207", "结算")
  4194. userJSONBytes, _ := json.Marshal(dat)
  4195. if miConfig.Code == "H15049901371" {
  4196. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4197. utils.ErrorLog("解析失败:%v", err)
  4198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4199. return
  4200. }
  4201. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4202. res.Output = resSeven10265.Output
  4203. res.ErrMsg = resSeven10265.ErrMsg
  4204. res.Cainfo = resSeven10265.Cainfo
  4205. res.WarnMsg = resSeven10265.WarnMsg
  4206. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4207. res.Infcode = infocode
  4208. } else {
  4209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4210. utils.ErrorLog("解析失败:%v", err)
  4211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4212. return
  4213. }
  4214. }
  4215. }
  4216. if res.Infcode != 0 {
  4217. errlog := &models.HisOrderError{
  4218. UserOrgId: adminUser.CurrentOrgId,
  4219. Ctime: time.Now().Unix(),
  4220. Mtime: time.Now().Unix(),
  4221. Number: chrg_bchno,
  4222. ErrMsg: res.ErrMsg,
  4223. Status: 1,
  4224. PatientId: id,
  4225. RecordTime: recordDateTime,
  4226. Stage: 6,
  4227. }
  4228. service.CreateErrMsgLog(errlog)
  4229. c.ServeSuccessJSON(map[string]interface{}{
  4230. "failed_code": -10,
  4231. "msg": res.ErrMsg,
  4232. })
  4233. return
  4234. } else {
  4235. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4236. order.OrderStatus = 2
  4237. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4238. order.SetlId = res.Output.Setlinfo.SetlID
  4239. order.PsnNo = res.Output.Setlinfo.PsnNo
  4240. order.PsnName = res.Output.Setlinfo.PsnName
  4241. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4242. order.Certno = res.Output.Setlinfo.Certno
  4243. order.Gend = res.Output.Setlinfo.Gend
  4244. order.Naty = res.Output.Setlinfo.Naty
  4245. order.Age = res.Output.Setlinfo.Age
  4246. order.Insutype = res.Output.Setlinfo.Insutype
  4247. order.PsnType = res.Output.Setlinfo.PsnType
  4248. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4249. order.SetlTime = res.Output.Setlinfo.SetlTime
  4250. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4251. //order.MedType = res.Output.Setlinfo.MedType
  4252. if reg_type == 1112 {
  4253. order.MedType = "1112"
  4254. }
  4255. if reg_type == 1111 {
  4256. order.MedType = "1111"
  4257. }
  4258. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4259. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4260. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4261. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4262. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4263. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4264. order.HifpPay = res.Output.Setlinfo.HifpPay
  4265. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4266. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4267. order.HifesPay = res.Output.Setlinfo.HifesPay
  4268. order.HifobPay = res.Output.Setlinfo.HifobPay
  4269. order.MafPay = res.Output.Setlinfo.MafPay
  4270. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4271. order.OthPay = res.Output.Setlinfo.OthPay
  4272. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4273. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4274. order.AcctPay = res.Output.Setlinfo.AcctPay
  4275. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4276. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4277. order.Balc = res.Output.Setlinfo.Balc
  4278. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4279. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4280. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4281. order.ClrWay = res.Output.Setlinfo.ClrWay
  4282. order.Creator = order.Creator
  4283. order.Modify = roles.AdminUserId
  4284. order.RequestLog = src_resquest
  4285. order.Diagnosis = diagnosis_id
  4286. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4287. detailStr := string(setlDetail)
  4288. order.SetlDetail = detailStr
  4289. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4290. err = service.UpDateOrder(order)
  4291. if err == nil {
  4292. c.ServeSuccessJSON(map[string]interface{}{
  4293. "msg": "结算成功",
  4294. })
  4295. } else {
  4296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4297. return
  4298. }
  4299. }
  4300. }
  4301. }
  4302. }
  4303. //func (c *HisApiController) GetPreUploadInfo() {
  4304. // id, _ := c.GetInt64("id")
  4305. // record_time := c.GetString("record_time")
  4306. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4307. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4308. //
  4309. // timeLayout := "2006-01-02"
  4310. // loc, _ := time.LoadLocation("Local")
  4311. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4312. // if err != nil {
  4313. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4314. // return
  4315. // }
  4316. // recordDateTime := theTime.Unix()
  4317. // adminUser := c.GetAdminUserInfo()
  4318. //
  4319. // var prescriptions []*models.HisPrescription
  4320. //
  4321. // var start_time int64
  4322. // var end_time int64
  4323. //
  4324. // data := make(map[string]interface{})
  4325. // if settle_accounts_type == 1 { //日结
  4326. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4327. // data["pre"] = prescriptions
  4328. //
  4329. // } else { //月结
  4330. // start_time_str := c.GetString("start_time")
  4331. // end_time_str := c.GetString("end_time")
  4332. // timeLayout := "2006-01-02"
  4333. // loc, _ := time.LoadLocation("Local")
  4334. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4335. // if err != nil {
  4336. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4337. // return
  4338. // }
  4339. // recordStartTime := theStartTime.Unix()
  4340. // start_time = recordStartTime
  4341. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4342. // if err != nil {
  4343. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4344. // return
  4345. // }
  4346. // recordEndTime := theEndTime.Unix()
  4347. // end_time = recordEndTime
  4348. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4349. // data["pre"] = prescriptions
  4350. //
  4351. // }
  4352. //
  4353. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4354. //
  4355. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4356. // timestamp := time.Now().Unix()
  4357. // tempTime := time.Unix(timestamp, 0)
  4358. // timeFormat := tempTime.Format("20060102150405")
  4359. // chrgBchno := rand.Intn(100000) + 10000
  4360. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4361. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4362. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4363. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4364. // strconv.FormatInt(his.PatientId, 10)
  4365. // client := &http.Client{}
  4366. // data["psn_no"] = his.PsnNo
  4367. // data["mdtrt_id"] = his.Number
  4368. // data["chrg_bchno"] = chrg_bchno
  4369. // data["org_name"] = miConfig.OrgName
  4370. // data["doctor"] = roles.UserName
  4371. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4372. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4373. // data["fixmedins_code"] = miConfig.Code
  4374. // data["dept_code"] = department.Number
  4375. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4376. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4377. // data["secret_key"] = miConfig.SecretKey
  4378. // var ids []int64
  4379. //
  4380. // for _, item := range prescriptions {
  4381. // ids = append(ids, item.ID)
  4382. // }
  4383. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4384. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4385. // bytesData, _ := json.Marshal(data)
  4386. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  4387. // resp, _ := client.Do(req)
  4388. // defer resp.Body.Close()
  4389. // body, ioErr := ioutil.ReadAll(resp.Body)
  4390. // if ioErr != nil {
  4391. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4392. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4393. // return
  4394. // }
  4395. // var respJSON map[string]interface{}
  4396. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4397. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4398. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4399. // return
  4400. // }
  4401. //
  4402. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4403. // userJSONBytes, _ := json.Marshal(respJSON)
  4404. // var res ResultFour
  4405. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4406. // utils.ErrorLog("解析失败:%v", err)
  4407. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4408. // return
  4409. // }
  4410. //
  4411. // if res.Infcode == 0 {
  4412. // order := &models.HisOrder{
  4413. // UserOrgId: adminUser.CurrentOrgId,
  4414. // HisPatientId: his.ID,
  4415. // PatientId: his.PatientId,
  4416. // SettleAccountsDate: recordDateTime,
  4417. // Ctime: time.Now().Unix(),
  4418. // Mtime: time.Now().Unix(),
  4419. // Status: 1,
  4420. // Number: chrg_bchno,
  4421. // Infcode: res.Infcode,
  4422. // WarnMsg: res.WarnMsg,
  4423. // Cainfo: res.Cainfo,
  4424. // ErrMsg: res.ErrMsg,
  4425. // RespondTime: res.RefmsgTime,
  4426. // InfRefmsgid: res.InfRefmsgid,
  4427. // OrderStatus: 1,
  4428. // IsMedicineInsurance: 1,
  4429. // SettleType: settle_accounts_type,
  4430. // SettleStartTime: start_time,
  4431. // SettleEndTime: end_time,
  4432. // Creator: roles.ID,
  4433. // Modify: roles.ID,
  4434. // PType: 2,
  4435. // }
  4436. // err = service.CreateOrder(order)
  4437. // if err != nil {
  4438. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4439. // return
  4440. // }
  4441. //
  4442. // for _, item := range res.Output.Result {
  4443. // temp := strings.Split(item.FeedetlSn, "-")
  4444. // var advice_id int64 = 0
  4445. // var project_id int64 = 0
  4446. // var types int64 = 0
  4447. //
  4448. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  4449. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  4450. //
  4451. // if temp[1] == "1" {
  4452. // advice_id = id
  4453. // project_id = 0
  4454. // } else if temp[1] == "2" {
  4455. // advice_id = 0
  4456. // project_id = id
  4457. // }
  4458. //
  4459. // info := &models.HisOrderInfo{
  4460. // OrderNumber: order.Number,
  4461. // FeedetlSn: item.FeedetlSn,
  4462. // UploadDate: time.Now().Unix(),
  4463. // AdviceId: advice_id,
  4464. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  4465. // Cnt: item.Cnt,
  4466. // Pric: float64(item.Pric),
  4467. // PatientId: his.PatientId,
  4468. // PricUplmtAmt: item.PricUplmtAmt,
  4469. // SelfpayProp: item.SelfpayProp,
  4470. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4471. // OverlmtAmt: item.OverlmtAmt,
  4472. // PreselfpayAmt: item.PreselfpayAmt,
  4473. // BasMednFlag: item.BasMednFlag,
  4474. // MedChrgitmType: item.MedChrgitmType,
  4475. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  4476. // Status: 1,
  4477. // Memo: item.Memo,
  4478. // Mtime: time.Now().Unix(),
  4479. // InscpScpAmt: item.InscpScpAmt,
  4480. // DrtReimFlag: item.DrtReimFlag,
  4481. // Ctime: time.Now().Unix(),
  4482. // ListSpItemFlag: item.ListSpItemFlag,
  4483. // ChldMedcFlag: item.ChldMedcFlag,
  4484. // LmtUsedFlag: item.LmtUsedFlag,
  4485. // ChrgitmLv: item.ChrgitmLv,
  4486. // UserOrgId: adminUser.CurrentOrgId,
  4487. // HisPatientId: his.ID,
  4488. // OrderId: order.ID,
  4489. // ProjectId: project_id,
  4490. // Type: types,
  4491. // }
  4492. // service.CreateOrderInfo(info)
  4493. //
  4494. // }
  4495. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4496. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  4497. //
  4498. // var total float64
  4499. // for _, item := range prescriptions {
  4500. // if item.Type == 1 { //药品
  4501. // for _, subItem := range item.HisDoctorAdviceInfo {
  4502. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4503. // }
  4504. // }
  4505. // if item.Type == 2 { //项目
  4506. // for _, subItem := range item.HisPrescriptionProject {
  4507. // total = total + (subItem.Price * float64(subItem.Count))
  4508. // }
  4509. // }
  4510. // }
  4511. //
  4512. // for _, item := range prescriptions {
  4513. // for _, subItem := range item.HisAdditionalCharge {
  4514. // total = total + (subItem.Price * float64(subItem.Count))
  4515. // }
  4516. // }
  4517. //
  4518. // allTotal := fmt.Sprintf("%.2f", total)
  4519. // if res.Infcode == 0 {
  4520. // var rf []*ResultFive
  4521. // json.Unmarshal([]byte(his.Iinfo), &rf)
  4522. // psn_no := his.PsnNo
  4523. // mdtrt_id := his.Number
  4524. // chrg_bchno := chrg_bchno
  4525. // cert_no := his.Certno
  4526. // insutype := rf[0].Insutype
  4527. //
  4528. // if his.IdCardType == 1 {
  4529. // cert_no = his.MedicalInsuranceNumber
  4530. //
  4531. // } else {
  4532. //
  4533. // cert_no = his.Certno
  4534. //
  4535. // }
  4536. //
  4537. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  4538. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  4539. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  4540. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  4541. // resp, requestErr := http.Get(api)
  4542. // if requestErr != nil {
  4543. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4544. // return
  4545. // }
  4546. // defer resp.Body.Close()
  4547. // body, ioErr := ioutil.ReadAll(resp.Body)
  4548. // if ioErr != nil {
  4549. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4550. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4551. // return
  4552. // }
  4553. // var respJSON map[string]interface{}
  4554. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4555. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4556. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4557. // return
  4558. // }
  4559. // fmt.Println(respJSON)
  4560. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4561. // userJSONBytes, _ := json.Marshal(respJSON)
  4562. // var res ResultSeven
  4563. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4564. // utils.ErrorLog("解析失败:%v", err)
  4565. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4566. // return
  4567. // }
  4568. // if res.Infcode != 0 {
  4569. // errlog := &models.HisOrderError{
  4570. // UserOrgId: adminUser.CurrentOrgId,
  4571. // Ctime: time.Now().Unix(),
  4572. // Mtime: time.Now().Unix(),
  4573. // Number: chrg_bchno,
  4574. // ErrMsg: res.ErrMsg,
  4575. // Status: 1,
  4576. // PatientId: id,
  4577. // RecordTime: recordDateTime,
  4578. // Stage: 7,
  4579. // }
  4580. // service.CreateErrMsgLog(errlog)
  4581. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4582. // return
  4583. // } else {
  4584. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4585. // order.OrderStatus = 1
  4586. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4587. // order.SetlId = res.Output.Setlinfo.SetlID
  4588. // order.PsnNo = res.Output.Setlinfo.PsnNo
  4589. // order.PsnName = res.Output.Setlinfo.PsnName
  4590. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4591. // order.Certno = res.Output.Setlinfo.Certno
  4592. // order.Gend = res.Output.Setlinfo.Gend
  4593. // order.Naty = res.Output.Setlinfo.Naty
  4594. // order.Age = res.Output.Setlinfo.Age
  4595. // order.Insutype = res.Output.Setlinfo.Insutype
  4596. // order.PsnType = res.Output.Setlinfo.PsnType
  4597. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4598. // order.SetlTime = res.Output.Setlinfo.SetlTime
  4599. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4600. // order.MedType = res.Output.Setlinfo.MedType
  4601. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4602. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4603. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4604. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4605. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4606. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4607. // order.HifpPay = res.Output.Setlinfo.HifpPay
  4608. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4609. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4610. // order.HifesPay = res.Output.Setlinfo.HifesPay
  4611. // order.HifobPay = res.Output.Setlinfo.HifobPay
  4612. // order.MafPay = res.Output.Setlinfo.MafPay
  4613. // order.OthPay = res.Output.Setlinfo.OthPay
  4614. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4615. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4616. // order.AcctPay = res.Output.Setlinfo.AcctPay
  4617. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4618. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4619. // order.Balc = res.Output.Setlinfo.Balc
  4620. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4621. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4622. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4623. // order.ClrWay = res.Output.Setlinfo.ClrWay
  4624. // order.Creator = order.Creator
  4625. // order.Modify = roles.ID
  4626. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4627. // detailStr := string(setlDetail)
  4628. // order.SetlDetail = detailStr
  4629. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4630. // err = service.UpDateOrder(order)
  4631. // if err == nil {
  4632. // c.ServeSuccessJSON(map[string]interface{}{
  4633. // "msg": "预结算成功",
  4634. // })
  4635. // } else {
  4636. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4637. // return
  4638. // }
  4639. // }
  4640. // } else {
  4641. // adminUser := c.GetAdminUserInfo()
  4642. // errlog := &models.HisOrderError{
  4643. // UserOrgId: adminUser.CurrentOrgId,
  4644. // Ctime: time.Now().Unix(),
  4645. // Mtime: time.Now().Unix(),
  4646. // ErrMsg: res.ErrMsg,
  4647. // Status: 1,
  4648. // PatientId: id,
  4649. // RecordTime: recordDateTime,
  4650. // Stage: 4,
  4651. // }
  4652. // service.CreateErrMsgLog(errlog)
  4653. //
  4654. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4655. // return
  4656. // }
  4657. // } else {
  4658. // adminUser := c.GetAdminUserInfo()
  4659. // errlog := &models.HisOrderError{
  4660. // UserOrgId: adminUser.CurrentOrgId,
  4661. // Ctime: time.Now().Unix(),
  4662. // Mtime: time.Now().Unix(),
  4663. // ErrMsg: res.ErrMsg,
  4664. // Status: 1,
  4665. // PatientId: id,
  4666. // RecordTime: recordDateTime,
  4667. // Stage: 4,
  4668. // }
  4669. // service.CreateErrMsgLog(errlog)
  4670. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4671. // return
  4672. // }
  4673. //
  4674. // } else {
  4675. // var total float64
  4676. // for _, item := range prescriptions {
  4677. // if item.Type == 1 { //药品
  4678. // for _, subItem := range item.HisDoctorAdviceInfo {
  4679. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4680. // }
  4681. // }
  4682. // if item.Type == 2 { //项目
  4683. // for _, subItem := range item.HisPrescriptionProject {
  4684. // total = total + (subItem.Price * float64(subItem.Count))
  4685. // }
  4686. // }
  4687. //
  4688. // for _, subItem := range item.HisAdditionalCharge {
  4689. // total = total + (subItem.Price * float64(subItem.Count))
  4690. // }
  4691. // }
  4692. //
  4693. // allTotal := fmt.Sprintf("%.2f", total)
  4694. // totals, _ := strconv.ParseFloat(allTotal, 64)
  4695. // order := &models.HisOrder{
  4696. // UserOrgId: adminUser.CurrentOrgId,
  4697. // HisPatientId: his.ID,
  4698. // PatientId: id,
  4699. // SettleAccountsDate: recordDateTime,
  4700. // Ctime: time.Now().Unix(),
  4701. // Mtime: time.Now().Unix(),
  4702. // Status: 1,
  4703. // OrderStatus: 2,
  4704. // Number: chrg_bchno,
  4705. // MedfeeSumamt: totals,
  4706. // }
  4707. // err = service.CreateOrder(order)
  4708. // if err != nil {
  4709. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4710. // return
  4711. // }
  4712. //
  4713. // var customs []*Custom
  4714. // for _, item := range prescriptions {
  4715. //
  4716. // if item.Type == 1 { //药品
  4717. // for _, subItem := range item.HisDoctorAdviceInfo {
  4718. // cus := &Custom{
  4719. // AdviceId: subItem.ID,
  4720. // ProjectId: 0,
  4721. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  4722. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  4723. // FeedetlSn: subItem.FeedetlSn,
  4724. // Price: fmt.Sprintf("%.2f", subItem.Price),
  4725. // MedListCodg: subItem.MedListCodg,
  4726. // Type: 1,
  4727. // }
  4728. // customs = append(customs, cus)
  4729. // }
  4730. // }
  4731. //
  4732. // if item.Type == 2 { //项目
  4733. // for _, subItem := range item.HisPrescriptionProject {
  4734. //
  4735. // cus := &Custom{
  4736. // AdviceId: 0,
  4737. // ProjectId: subItem.ID,
  4738. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  4739. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  4740. // FeedetlSn: subItem.FeedetlSn,
  4741. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  4742. // MedListCodg: subItem.MedListCodg,
  4743. // Type: 2,
  4744. // }
  4745. //
  4746. // customs = append(customs, cus)
  4747. // }
  4748. // }
  4749. //
  4750. // for _, item := range item.HisAdditionalCharge {
  4751. // cus := &Custom{
  4752. // ItemId: item.ID,
  4753. // AdviceId: 0,
  4754. // ProjectId: 0,
  4755. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  4756. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  4757. // FeedetlSn: item.FeedetlSn,
  4758. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  4759. // MedListCodg: item.XtHisAddtionConfig.Code,
  4760. // Type: 3,
  4761. // }
  4762. //
  4763. // customs = append(customs, cus)
  4764. // }
  4765. //
  4766. // }
  4767. //
  4768. // for _, item := range customs {
  4769. // var advice_id int64 = 0
  4770. // var project_id int64 = 0
  4771. // var item_id int64 = 0
  4772. //
  4773. // var types int64 = 0
  4774. //
  4775. // if item.Type == 1 {
  4776. // advice_id = item.AdviceId
  4777. // project_id = 0
  4778. // item_id = 0
  4779. // } else if item.Type == 2 {
  4780. // advice_id = 0
  4781. // item_id = 0
  4782. //
  4783. // project_id = item.ProjectId
  4784. // } else if item.Type == 3 {
  4785. // advice_id = 0
  4786. // item_id = item.ItemId
  4787. // project_id = 0
  4788. // }
  4789. //
  4790. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  4791. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  4792. // pric, _ := strconv.ParseFloat(item.Price, 32)
  4793. //
  4794. // info := &models.HisOrderInfo{
  4795. // OrderNumber: order.Number,
  4796. // UploadDate: time.Now().Unix(),
  4797. // AdviceId: advice_id,
  4798. // DetItemFeeSumamt: detItemFeeSumamt,
  4799. // Cnt: cut,
  4800. // Pric: pric,
  4801. // PatientId: id,
  4802. // Status: 1,
  4803. // Mtime: time.Now().Unix(),
  4804. // Ctime: time.Now().Unix(),
  4805. // UserOrgId: adminUser.CurrentOrgId,
  4806. // HisPatientId: his.ID,
  4807. // OrderId: order.ID,
  4808. // ProjectId: project_id,
  4809. // Type: types,
  4810. // ItemId: item_id,
  4811. // }
  4812. // service.CreateOrderInfo(info)
  4813. // }
  4814. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4815. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4816. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  4817. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4818. // if err == nil {
  4819. // c.ServeSuccessJSON(map[string]interface{}{
  4820. // "msg": "结算成功",
  4821. // })
  4822. // } else {
  4823. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4824. // return
  4825. // }
  4826. // }
  4827. //}
  4828. //上传明细-预结算-
  4829. func (c *HisApiController) GetPreUploadInfo() {
  4830. id, _ := c.GetInt64("id")
  4831. record_time := c.GetString("record_time")
  4832. his_patient_id, _ := c.GetInt64("his_patient_id")
  4833. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4834. admin_user_id, _ := c.GetInt64("admin_user_id")
  4835. diagnosis_id := c.GetString("diagnosis")
  4836. sick_type, _ := c.GetInt64("sick_type")
  4837. reg_type, _ := c.GetInt64("p_type")
  4838. begin_time := c.GetString("begin_time")
  4839. id_str := c.GetString("ids")
  4840. ids_arr := strings.Split(id_str, ",")
  4841. timeLayout := "2006-01-02"
  4842. loc, _ := time.LoadLocation("Local")
  4843. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4844. if err != nil {
  4845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4846. return
  4847. }
  4848. recordDateTime := theTime.Unix()
  4849. adminUser := c.GetAdminUserInfo()
  4850. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4851. var config []*models.HisXtDiagnoseConfig
  4852. for _, item := range diagnosis_ids {
  4853. id, _ := strconv.ParseInt(item, 10, 64)
  4854. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4855. config = append(config, &diagnosisConfig)
  4856. }
  4857. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  4858. sickConfig, _ := service.FindSickById(sick_type)
  4859. var prescriptions []*models.HisPrescription
  4860. var start_time int64
  4861. var end_time int64
  4862. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4863. fmt.Println(his_patient_id)
  4864. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4865. timestamp := time.Now().Unix()
  4866. tempTime := time.Unix(timestamp, 0)
  4867. timeFormat := tempTime.Format("20060102150405")
  4868. chrgBchno := rand.Intn(100000) + 10000
  4869. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4870. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4871. var patientPrescription models.HisPrescriptionInfo
  4872. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4873. if patientPrescription.ID == 0 {
  4874. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4875. }
  4876. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4877. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4878. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4879. strconv.FormatInt(his.PatientId, 10)
  4880. var res2 ResultSix
  4881. var resSix10265 ResultSix10265
  4882. var time_stamp string
  4883. if miConfig.MdtrtareaAdmvs == "421300" {
  4884. data := make(map[string]interface{})
  4885. client := &http.Client{}
  4886. data["psn_no"] = his.PsnNo
  4887. data["mdtrt_id"] = his.Number
  4888. data["doctor"] = roles.UserName
  4889. data["department"] = department.Name
  4890. data["org_name"] = miConfig.OrgName
  4891. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4892. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4893. data["fixmedins_code"] = miConfig.Code
  4894. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4895. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4896. data["secret_key"] = miConfig.SecretKey
  4897. data["sick_code"] = sickConfig.CountryCode
  4898. data["sick_name"] = sickConfig.ClassName
  4899. data["begin_time"] = begin_time
  4900. data["dept"] = strconv.FormatInt(department.ID, 10)
  4901. data["config"] = config
  4902. fmt.Println(data)
  4903. bytesData, _ := json.Marshal(data)
  4904. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4905. resp, _ := client.Do(req)
  4906. defer resp.Body.Close()
  4907. body, ioErr := ioutil.ReadAll(resp.Body)
  4908. if ioErr != nil {
  4909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4911. return
  4912. }
  4913. var respJSON map[string]interface{}
  4914. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4917. return
  4918. }
  4919. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4920. userJSONBytes, _ := json.Marshal(respJSON)
  4921. fmt.Println("log")
  4922. fmt.Println(string(userJSONBytes))
  4923. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4924. utils.ErrorLog("解析失败:%v", err)
  4925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4926. return
  4927. }
  4928. } else if miConfig.MdtrtareaAdmvs == "320921" {
  4929. //江苏地区国家医保医疗类别
  4930. //职工透析:医疗类别选特殊情况门诊9933
  4931. //居民血透门慢: 医疗类别选门诊慢病1402
  4932. //var med_type string
  4933. //if his.Insutype == "310" {
  4934. // if reg_type == 14 {
  4935. // med_type = "9933"
  4936. // } else if reg_type == 11 {
  4937. // med_type = "11"
  4938. //
  4939. // }
  4940. //} else if his.Insutype == "390" {
  4941. // if reg_type == 14 {
  4942. // med_type = "1402"
  4943. // } else if reg_type == 11 {
  4944. // med_type = "11"
  4945. // }
  4946. //}
  4947. data := make(map[string]interface{})
  4948. client := &http.Client{}
  4949. data["psn_no"] = his.PsnNo
  4950. data["mdtrt_id"] = his.Number
  4951. data["doctor"] = roles.UserName
  4952. data["department"] = department.Name
  4953. data["org_name"] = miConfig.OrgName
  4954. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4955. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4956. data["fixmedins_code"] = miConfig.Code
  4957. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4958. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4959. data["secret_key"] = miConfig.SecretKey
  4960. data["sick_code"] = sickConfig.CountryCode
  4961. data["sick_name"] = sickConfig.ClassName
  4962. data["begin_time"] = begin_time
  4963. data["dept"] = strconv.FormatInt(department.ID, 10)
  4964. data["config"] = config
  4965. data["url"] = miConfig.Url
  4966. data["ak"] = miConfig.AccessKey
  4967. data["cainfo"] = miConfig.Cainfo
  4968. bytesData, _ := json.Marshal(data)
  4969. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4970. resp, _ := client.Do(req)
  4971. defer resp.Body.Close()
  4972. body, ioErr := ioutil.ReadAll(resp.Body)
  4973. if ioErr != nil {
  4974. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4976. return
  4977. }
  4978. var respJSON map[string]interface{}
  4979. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4982. return
  4983. }
  4984. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  4985. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  4986. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  4987. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4988. userJSONBytes, _ := json.Marshal(respJSON)
  4989. fmt.Println("log")
  4990. fmt.Println(string(userJSONBytes))
  4991. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  4992. utils.ErrorLog("解析失败:%v", err)
  4993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4994. return
  4995. }
  4996. res2.InfRefmsgid = resSix10265.InfRefmsgid
  4997. res2.Output = resSix10265.Output
  4998. res2.ErrMsg = resSix10265.ErrMsg
  4999. res2.Cainfo = resSix10265.Cainfo
  5000. res2.WarnMsg = resSix10265.WarnMsg
  5001. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5002. res2.Infcode = infocode
  5003. } else {
  5004. var result string
  5005. var requestLog string
  5006. if miConfig.MdtrtareaAdmvs == "440781" { //
  5007. 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, begin_time)
  5008. } else {
  5009. if miConfig.Code == "H15049901371" {
  5010. //赤峰地区国家医保医疗类别
  5011. //职工透析:医疗类别选特殊情况门诊990502
  5012. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5013. var med_type string
  5014. if his.Insutype == "390" {
  5015. if reg_type == 14 {
  5016. med_type = "9933"
  5017. } else if reg_type == 11 {
  5018. med_type = "11"
  5019. }
  5020. } else if his.Insutype == "310" {
  5021. if reg_type == 14 {
  5022. med_type = "990502"
  5023. } else if reg_type == 11 {
  5024. med_type = "11"
  5025. }
  5026. }
  5027. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, med_type, doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  5028. } else {
  5029. 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, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  5030. }
  5031. saveLog(result, requestLog, "2203", "上传就诊信息")
  5032. var respJSON2 map[string]interface{}
  5033. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5036. return
  5037. }
  5038. userJSONBytes2, _ := json.Marshal(respJSON2)
  5039. if miConfig.Code == "H15049901371" {
  5040. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5041. utils.ErrorLog("解析失败:%v", err)
  5042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5043. return
  5044. }
  5045. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5046. res2.Output = resSix10265.Output
  5047. res2.ErrMsg = resSix10265.ErrMsg
  5048. res2.Cainfo = resSix10265.Cainfo
  5049. res2.WarnMsg = resSix10265.WarnMsg
  5050. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5051. res2.Infcode = infocode
  5052. } else {
  5053. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5054. utils.ErrorLog("解析失败:%v", err)
  5055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5056. return
  5057. }
  5058. }
  5059. }
  5060. }
  5061. if res2.Infcode != 0 {
  5062. adminUser := c.GetAdminUserInfo()
  5063. errlog := &models.HisOrderError{
  5064. UserOrgId: adminUser.CurrentOrgId,
  5065. Ctime: time.Now().Unix(),
  5066. Mtime: time.Now().Unix(),
  5067. ErrMsg: res2.ErrMsg,
  5068. Status: 1,
  5069. PatientId: id,
  5070. RecordTime: recordDateTime,
  5071. Stage: 3,
  5072. }
  5073. service.CreateErrMsgLog(errlog)
  5074. c.ServeSuccessJSON(map[string]interface{}{
  5075. "failed_code": -10,
  5076. "msg": res2.ErrMsg,
  5077. })
  5078. return
  5079. } else {
  5080. his.Diagnosis = diagnosis_id
  5081. his.SickType = sickConfig.ID
  5082. his.PType = fmt.Sprintf("%d", reg_type)
  5083. service.UpdateHisPatientThree(&his)
  5084. data := make(map[string]interface{})
  5085. if settle_accounts_type == 1 { //日结
  5086. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5087. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5088. } else {
  5089. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5090. }
  5091. data["pre"] = prescriptions
  5092. } else { //月结
  5093. start_time_str := c.GetString("start_time")
  5094. end_time_str := c.GetString("end_time")
  5095. timeLayout := "2006-01-02"
  5096. loc, _ := time.LoadLocation("Local")
  5097. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5098. if err != nil {
  5099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5100. return
  5101. }
  5102. recordStartTime := theStartTime.Unix()
  5103. start_time = recordStartTime
  5104. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5105. if err != nil {
  5106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5107. return
  5108. }
  5109. recordEndTime := theEndTime.Unix()
  5110. end_time = recordEndTime
  5111. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5112. data["pre"] = prescriptions
  5113. }
  5114. client := &http.Client{}
  5115. data["psn_no"] = his.PsnNo
  5116. data["mdtrt_id"] = his.Number
  5117. data["chrg_bchno"] = chrg_bchno
  5118. data["org_name"] = miConfig.OrgName
  5119. data["doctor"] = roles.UserName
  5120. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5121. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5122. data["fixmedins_code"] = miConfig.Code
  5123. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5124. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5125. data["dept_code"] = "15"
  5126. } else {
  5127. data["dept_code"] = department.Number
  5128. }
  5129. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5130. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5131. data["secret_key"] = miConfig.SecretKey
  5132. data["url"] = miConfig.Url
  5133. data["ak"] = miConfig.AccessKey
  5134. data["new_doctor_name"] = patientPrescription.Doctor
  5135. data["diag_code"] = sickConfig.CountryCode
  5136. data["time_stamp"] = time_stamp
  5137. data["cainfo"] = miConfig.Cainfo
  5138. var ids []int64
  5139. for _, item := range prescriptions {
  5140. ids = append(ids, item.ID)
  5141. }
  5142. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5143. if config.IsOpen == 1 { //对接了医保,走医保流程
  5144. var res ResultFour
  5145. var resFour10265 ResultFour10265
  5146. if miConfig.MdtrtareaAdmvs == "421300" {
  5147. bytesData, _ := json.Marshal(data)
  5148. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5149. resp, _ := client.Do(req)
  5150. defer resp.Body.Close()
  5151. body, ioErr := ioutil.ReadAll(resp.Body)
  5152. if ioErr != nil {
  5153. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5155. return
  5156. }
  5157. var respJSON map[string]interface{}
  5158. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5161. return
  5162. }
  5163. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5164. userJSONBytes, _ := json.Marshal(respJSON)
  5165. fmt.Println("log")
  5166. fmt.Println(string(userJSONBytes))
  5167. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5168. utils.ErrorLog("解析失败:%v", err)
  5169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5170. return
  5171. }
  5172. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5173. bytesData, _ := json.Marshal(data)
  5174. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5175. resp, _ := client.Do(req)
  5176. defer resp.Body.Close()
  5177. body, ioErr := ioutil.ReadAll(resp.Body)
  5178. if ioErr != nil {
  5179. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5181. return
  5182. }
  5183. var respJSON map[string]interface{}
  5184. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5185. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5187. return
  5188. }
  5189. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5190. userJSONBytes, _ := json.Marshal(respJSON)
  5191. fmt.Println("log")
  5192. fmt.Println(string(userJSONBytes))
  5193. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5194. utils.ErrorLog("解析失败:%v", err)
  5195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5196. return
  5197. }
  5198. res.InfRefmsgid = resFour10265.InfRefmsgid
  5199. res.Output = resFour10265.Output
  5200. res.ErrMsg = resFour10265.ErrMsg
  5201. res.Cainfo = resFour10265.Cainfo
  5202. res.WarnMsg = resFour10265.WarnMsg
  5203. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5204. res.Infcode = infocode
  5205. } else {
  5206. if miConfig.Code == "H15049901371" {
  5207. 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), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), patientPrescription.DoctorId, sickConfig.CountryCode)
  5208. var dat map[string]interface{}
  5209. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5210. fmt.Println(dat)
  5211. } else {
  5212. fmt.Println(err)
  5213. }
  5214. saveLog(result, request_log, "2204", "上传费用明细")
  5215. userJSONBytes, _ := json.Marshal(dat)
  5216. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5217. utils.ErrorLog("解析失败:%v", err)
  5218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5219. return
  5220. }
  5221. res.InfRefmsgid = resFour10265.InfRefmsgid
  5222. res.Output = resFour10265.Output
  5223. res.ErrMsg = resFour10265.ErrMsg
  5224. res.Cainfo = resFour10265.Cainfo
  5225. res.WarnMsg = resFour10265.WarnMsg
  5226. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5227. res.Infcode = infocode
  5228. } else {
  5229. 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), patientPrescription.DoctorId, sickConfig.CountryCode)
  5230. var dat map[string]interface{}
  5231. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5232. fmt.Println(dat)
  5233. } else {
  5234. fmt.Println(err)
  5235. }
  5236. saveLog(result, request_log, "2204", "上传费用明细")
  5237. userJSONBytes, _ := json.Marshal(dat)
  5238. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5239. utils.ErrorLog("解析失败:%v", err)
  5240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5241. return
  5242. }
  5243. }
  5244. }
  5245. if res.Infcode == 0 {
  5246. order := &models.HisOrder{
  5247. UserOrgId: adminUser.CurrentOrgId,
  5248. HisPatientId: his.ID,
  5249. PatientId: his.PatientId,
  5250. SettleAccountsDate: recordDateTime,
  5251. Ctime: time.Now().Unix(),
  5252. Mtime: time.Now().Unix(),
  5253. MdtrtId: his.Number,
  5254. PsnNo: his.PsnNo,
  5255. MedType: strconv.FormatInt(reg_type, 10),
  5256. Status: 1,
  5257. Number: chrg_bchno,
  5258. Infcode: res.Infcode,
  5259. WarnMsg: res.WarnMsg,
  5260. Cainfo: res.Cainfo,
  5261. ErrMsg: res.ErrMsg,
  5262. RespondTime: res.RefmsgTime,
  5263. InfRefmsgid: res.InfRefmsgid,
  5264. OrderStatus: 1,
  5265. IsMedicineInsurance: 1,
  5266. SettleType: settle_accounts_type,
  5267. SettleStartTime: start_time,
  5268. SettleEndTime: end_time,
  5269. Creator: roles.AdminUserId,
  5270. Modify: roles.AdminUserId,
  5271. PType: 2,
  5272. Diagnosis: diagnosis_id,
  5273. }
  5274. err = service.CreateOrder(order)
  5275. if err != nil {
  5276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5277. return
  5278. }
  5279. for _, item := range res.Output.Result {
  5280. temp := strings.Split(item.FeedetlSn, "-")
  5281. var advice_id int64 = 0
  5282. var project_id int64 = 0
  5283. var types int64 = 0
  5284. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5285. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5286. if temp[1] == "1" {
  5287. advice_id = id
  5288. project_id = 0
  5289. } else if temp[1] == "2" {
  5290. advice_id = 0
  5291. project_id = id
  5292. }
  5293. info := &models.HisOrderInfo{
  5294. OrderNumber: order.Number,
  5295. FeedetlSn: item.FeedetlSn,
  5296. UploadDate: time.Now().Unix(),
  5297. AdviceId: advice_id,
  5298. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5299. Cnt: item.Cnt,
  5300. Pric: float64(item.Pric),
  5301. PatientId: his.PatientId,
  5302. PricUplmtAmt: item.PricUplmtAmt,
  5303. SelfpayProp: item.SelfpayProp,
  5304. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5305. OverlmtAmt: item.OverlmtAmt,
  5306. PreselfpayAmt: item.PreselfpayAmt,
  5307. BasMednFlag: item.BasMednFlag,
  5308. MedChrgitmType: item.MedChrgitmType,
  5309. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5310. Status: 1,
  5311. Memo: item.Memo,
  5312. Mtime: time.Now().Unix(),
  5313. InscpScpAmt: item.InscpScpAmt,
  5314. DrtReimFlag: item.DrtReimFlag,
  5315. Ctime: time.Now().Unix(),
  5316. ListSpItemFlag: item.ListSpItemFlag,
  5317. ChldMedcFlag: item.ChldMedcFlag,
  5318. LmtUsedFlag: item.LmtUsedFlag,
  5319. ChrgitmLv: item.ChrgitmLv,
  5320. UserOrgId: adminUser.CurrentOrgId,
  5321. HisPatientId: his.ID,
  5322. OrderId: order.ID,
  5323. ProjectId: project_id,
  5324. Type: types,
  5325. }
  5326. service.CreateOrderInfo(info)
  5327. }
  5328. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5329. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5330. var total float64
  5331. for _, item := range prescriptions {
  5332. if item.Type == 1 { //药品
  5333. for _, subItem := range item.HisDoctorAdviceInfo {
  5334. total = total + (subItem.Price * subItem.PrescribingNumber)
  5335. }
  5336. }
  5337. if item.Type == 2 { //项目
  5338. for _, subItem := range item.HisPrescriptionProject {
  5339. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5340. total = total + (subItem.Price * cnt)
  5341. }
  5342. }
  5343. }
  5344. for _, item := range prescriptions {
  5345. for _, subItem := range item.HisAdditionalCharge {
  5346. total = total + (subItem.Price * float64(subItem.Count))
  5347. }
  5348. }
  5349. allTotal := fmt.Sprintf("%.4f", total)
  5350. if res.Infcode == 0 {
  5351. var rf []*ResultFive
  5352. json.Unmarshal([]byte(his.Iinfo), &rf)
  5353. chrg_bchno := chrg_bchno
  5354. cert_no := his.Certno
  5355. var insutypes []string
  5356. var insutype string
  5357. var is390 int = 0
  5358. var is310 int = 0
  5359. for _, item := range rf {
  5360. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5361. insutypes = append(insutypes, item.Insutype)
  5362. }
  5363. }
  5364. if len(insutypes) == 1 {
  5365. insutype = insutypes[0]
  5366. } else {
  5367. for _, i := range insutypes {
  5368. if i == "390" {
  5369. is390 = 1
  5370. }
  5371. if i == "310" {
  5372. is310 = 1
  5373. }
  5374. }
  5375. }
  5376. if is390 == 1 {
  5377. insutype = "390"
  5378. }
  5379. if is310 == 1 {
  5380. insutype = "310"
  5381. }
  5382. if len(insutypes) == 0 {
  5383. insutype = "310"
  5384. }
  5385. if len(insutypes) == 2 {
  5386. insutype = strconv.FormatInt(his.SocialType, 64)
  5387. }
  5388. //insutype = "390"
  5389. if his.IdCardType == 1 {
  5390. cert_no = his.MedicalInsuranceNumber
  5391. } else {
  5392. cert_no = his.Certno
  5393. }
  5394. var res ResultSeven
  5395. var resSeven10265 ResultSeven10265
  5396. if miConfig.MdtrtareaAdmvs == "421300" {
  5397. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5398. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5399. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5400. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5401. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5402. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5403. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  5404. resp, requestErr := http.Get(api)
  5405. if requestErr != nil {
  5406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5407. return
  5408. }
  5409. body, ioErr := ioutil.ReadAll(resp.Body)
  5410. if ioErr != nil {
  5411. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5413. return
  5414. }
  5415. var respJSON map[string]interface{}
  5416. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5417. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5419. return
  5420. }
  5421. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5422. result, _ := json.Marshal(respJSON)
  5423. fmt.Println("log")
  5424. fmt.Println(string(result))
  5425. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5426. utils.ErrorLog("解析失败:%v", err)
  5427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5428. return
  5429. }
  5430. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5431. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5432. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5433. bas := strings.Split(psn_info.CardInfo, "|")
  5434. if his.IdCardType == 1 {
  5435. cert_no = bas[2]
  5436. } else {
  5437. cert_no = bas[1]
  5438. }
  5439. //江苏地区国家医保医疗类别
  5440. //职工透析:医疗类别选特殊情况门诊9933
  5441. //居民血透门慢: 医疗类别选门诊慢病1402
  5442. //var med_type string
  5443. //if his.Insutype == "310" {
  5444. // if reg_type == 14 {
  5445. // med_type = "9933"
  5446. // } else if reg_type == 11 {
  5447. // med_type = "11"
  5448. //
  5449. // }
  5450. //} else if his.Insutype == "390" {
  5451. // if reg_type == 14 {
  5452. // med_type = "1402"
  5453. // } else if reg_type == 11 {
  5454. // med_type = "11"
  5455. // }
  5456. //}
  5457. api := "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5458. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5459. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5460. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5461. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5462. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5463. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5464. resp, requestErr := http.Get(api)
  5465. if requestErr != nil {
  5466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5467. return
  5468. }
  5469. body, ioErr := ioutil.ReadAll(resp.Body)
  5470. if ioErr != nil {
  5471. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5473. return
  5474. }
  5475. var respJSON map[string]interface{}
  5476. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5477. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5479. return
  5480. }
  5481. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5482. result, _ := json.Marshal(respJSON)
  5483. fmt.Println("log")
  5484. fmt.Println(string(result))
  5485. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5486. utils.ErrorLog("解析失败:%v", err)
  5487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5488. return
  5489. }
  5490. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5491. res.Output = resSeven10265.Output
  5492. res.ErrMsg = resSeven10265.ErrMsg
  5493. res.Cainfo = resSeven10265.Cainfo
  5494. res.WarnMsg = resSeven10265.WarnMsg
  5495. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5496. res.Infcode = infocode
  5497. } else {
  5498. var result string
  5499. var request_log string
  5500. if miConfig.Code == "H15049901371" {
  5501. //赤峰地区国家医保医疗类别
  5502. //职工透析:医疗类别选特殊情况门诊990502
  5503. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5504. var med_type string
  5505. if his.Insutype == "390" {
  5506. if reg_type == 14 {
  5507. med_type = "9933"
  5508. } else if reg_type == 11 {
  5509. med_type = "11"
  5510. }
  5511. } else if his.Insutype == "310" {
  5512. if reg_type == 14 {
  5513. med_type = "990502"
  5514. } else if reg_type == 11 {
  5515. med_type = "11"
  5516. }
  5517. }
  5518. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, 0, 0, 0, 0, his.IdType)
  5519. } else {
  5520. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  5521. }
  5522. var dat map[string]interface{}
  5523. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5524. fmt.Println(dat)
  5525. } else {
  5526. fmt.Println(err)
  5527. }
  5528. saveLog(result, request_log, "2206", "预结算")
  5529. //userJSONBytes, _ := json.Marshal(dat)
  5530. //
  5531. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5532. // utils.ErrorLog("解析失败:%v", err)
  5533. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5534. // return
  5535. //}
  5536. userJSONBytes, _ := json.Marshal(dat)
  5537. if miConfig.Code == "H15049901371" {
  5538. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5539. utils.ErrorLog("解析失败:%v", err)
  5540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5541. return
  5542. }
  5543. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5544. res.Output = resSeven10265.Output
  5545. res.ErrMsg = resSeven10265.ErrMsg
  5546. res.Cainfo = resSeven10265.Cainfo
  5547. res.WarnMsg = resSeven10265.WarnMsg
  5548. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5549. res.Infcode = infocode
  5550. } else {
  5551. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5552. utils.ErrorLog("解析失败:%v", err)
  5553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5554. return
  5555. }
  5556. }
  5557. }
  5558. if res.Infcode != 0 {
  5559. errlog := &models.HisOrderError{
  5560. UserOrgId: adminUser.CurrentOrgId,
  5561. Ctime: time.Now().Unix(),
  5562. Mtime: time.Now().Unix(),
  5563. Number: chrg_bchno,
  5564. ErrMsg: res.ErrMsg,
  5565. Status: 1,
  5566. PatientId: id,
  5567. RecordTime: recordDateTime,
  5568. Stage: 20,
  5569. }
  5570. service.CreateErrMsgLog(errlog)
  5571. c.ServeSuccessJSON(map[string]interface{}{
  5572. "failed_code": -10,
  5573. "msg": res.ErrMsg,
  5574. })
  5575. return
  5576. } else {
  5577. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5578. order.OrderStatus = 1
  5579. order.IsPre = 1
  5580. order.Status = 1
  5581. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5582. order.SetlId = res.Output.Setlinfo.SetlID
  5583. order.PsnNo = res.Output.Setlinfo.PsnNo
  5584. order.PsnName = res.Output.Setlinfo.PsnName
  5585. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5586. order.Certno = res.Output.Setlinfo.Certno
  5587. order.Gend = res.Output.Setlinfo.Gend
  5588. order.Naty = res.Output.Setlinfo.Naty
  5589. order.Age = res.Output.Setlinfo.Age
  5590. order.Insutype = res.Output.Setlinfo.Insutype
  5591. order.PsnType = res.Output.Setlinfo.PsnType
  5592. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5593. order.SetlTime = res.Output.Setlinfo.SetlTime
  5594. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5595. if res.Output.Setlinfo.MedType == "140101" {
  5596. order.MedType = "14"
  5597. } else {
  5598. order.MedType = res.Output.Setlinfo.MedType
  5599. }
  5600. if reg_type == 1112 {
  5601. order.MedType = "1112"
  5602. }
  5603. if reg_type == 1111 {
  5604. order.MedType = "1111"
  5605. }
  5606. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5607. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5608. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5609. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5610. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5611. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5612. order.HifpPay = res.Output.Setlinfo.HifpPay
  5613. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5614. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5615. order.HifesPay = res.Output.Setlinfo.HifesPay
  5616. order.HifobPay = res.Output.Setlinfo.HifobPay
  5617. order.MafPay = res.Output.Setlinfo.MafPay
  5618. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5619. order.OthPay = res.Output.Setlinfo.OthPay
  5620. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5621. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5622. order.AcctPay = res.Output.Setlinfo.AcctPay
  5623. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5624. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5625. order.Balc = res.Output.Setlinfo.Balc
  5626. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5627. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5628. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5629. order.ClrWay = res.Output.Setlinfo.ClrWay
  5630. order.Creator = order.Creator
  5631. order.Modify = roles.AdminUserId
  5632. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5633. detailStr := string(setlDetail)
  5634. order.SetlDetail = detailStr
  5635. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5636. err = service.UpDateOrder(order)
  5637. if err == nil {
  5638. c.ServeSuccessJSON(map[string]interface{}{
  5639. "msg": "预结算成功",
  5640. })
  5641. } else {
  5642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5643. return
  5644. }
  5645. }
  5646. } else {
  5647. adminUser := c.GetAdminUserInfo()
  5648. errlog := &models.HisOrderError{
  5649. UserOrgId: adminUser.CurrentOrgId,
  5650. Ctime: time.Now().Unix(),
  5651. Mtime: time.Now().Unix(),
  5652. ErrMsg: res.ErrMsg,
  5653. Status: 1,
  5654. PatientId: id,
  5655. RecordTime: recordDateTime,
  5656. Stage: 4,
  5657. }
  5658. service.CreateErrMsgLog(errlog)
  5659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5660. return
  5661. }
  5662. } else {
  5663. adminUser := c.GetAdminUserInfo()
  5664. errlog := &models.HisOrderError{
  5665. UserOrgId: adminUser.CurrentOrgId,
  5666. Ctime: time.Now().Unix(),
  5667. Mtime: time.Now().Unix(),
  5668. ErrMsg: res.ErrMsg,
  5669. Status: 1,
  5670. PatientId: id,
  5671. RecordTime: recordDateTime,
  5672. Stage: 4,
  5673. }
  5674. service.CreateErrMsgLog(errlog)
  5675. c.ServeSuccessJSON(map[string]interface{}{
  5676. "failed_code": -10,
  5677. "msg": res.ErrMsg,
  5678. })
  5679. return
  5680. }
  5681. }
  5682. }
  5683. }
  5684. //func (c *HisApiController) GetSettleInfo() {
  5685. // id, _ := c.GetInt64("id")
  5686. // order_id, _ := c.GetInt64("order_id")
  5687. //
  5688. // record_time := c.GetString("record_time")
  5689. // pay_way, _ := c.GetInt64("pay_way")
  5690. // pay_price, _ := c.GetFloat("pay_price")
  5691. // pay_card_no := c.GetString("pay_card_no")
  5692. // discount_price, _ := c.GetFloat("discount_price")
  5693. // preferential_price, _ := c.GetFloat("preferential_price")
  5694. // reality_price, _ := c.GetFloat("reality_price")
  5695. // found_price, _ := c.GetFloat("found_price")
  5696. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5697. // private_price, _ := c.GetFloat("private_price")
  5698. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5699. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5700. //
  5701. // timeLayout := "2006-01-02"
  5702. // loc, _ := time.LoadLocation("Local")
  5703. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5704. // if err != nil {
  5705. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5706. // return
  5707. // }
  5708. // recordDateTime := theTime.Unix()
  5709. // adminUser := c.GetAdminUserInfo()
  5710. //
  5711. // var prescriptions []*models.HisPrescription
  5712. //
  5713. // data := make(map[string]interface{})
  5714. // if settle_accounts_type == 1 { //日结
  5715. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5716. // data["pre"] = prescriptions
  5717. //
  5718. // } else { //月结
  5719. // start_time_str := c.GetString("start_time")
  5720. // end_time_str := c.GetString("end_time")
  5721. // timeLayout := "2006-01-02"
  5722. // loc, _ := time.LoadLocation("Local")
  5723. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5724. // if err != nil {
  5725. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5726. // return
  5727. // }
  5728. // recordStartTime := theStartTime.Unix()
  5729. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5730. // if err != nil {
  5731. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5732. // return
  5733. // }
  5734. // recordEndTime := theEndTime.Unix()
  5735. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5736. // data["pre"] = prescriptions
  5737. //
  5738. // }
  5739. //
  5740. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5741. //
  5742. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5743. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5744. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5745. // strconv.FormatInt(his.PatientId, 10)
  5746. //
  5747. // order_src, _ := service.GetHisOrderByID(order_id)
  5748. //
  5749. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5750. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5751. //
  5752. // var total float64
  5753. // for _, item := range prescriptions {
  5754. // if item.Type == 1 { //药品
  5755. // for _, subItem := range item.HisDoctorAdviceInfo {
  5756. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5757. // }
  5758. // }
  5759. // if item.Type == 2 { //项目
  5760. // for _, subItem := range item.HisPrescriptionProject {
  5761. // total = total + (subItem.Price * float64(subItem.Count))
  5762. // }
  5763. // }
  5764. // }
  5765. //
  5766. // for _, item := range prescriptions {
  5767. // for _, subItem := range item.HisAdditionalCharge {
  5768. // total = total + (subItem.Price * float64(subItem.Count))
  5769. // }
  5770. // }
  5771. //
  5772. // allTotal := fmt.Sprintf("%.2f", total)
  5773. // var rf []*ResultFive
  5774. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5775. // psn_no := order_src.PsnNo
  5776. // mdtrt_id := order_src.MdtrtId
  5777. // chrg_bchno := order_src.Number
  5778. // cert_no := order_src.Certno
  5779. // insutype := rf[0].Insutype
  5780. //
  5781. // if his.IdCardType == 1 {
  5782. // cert_no = his.MedicalInsuranceNumber
  5783. // } else {
  5784. // cert_no = his.Certno
  5785. // }
  5786. //
  5787. // 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)
  5788. // var dat map[string]interface{}
  5789. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5790. // fmt.Println(dat)
  5791. // } else {
  5792. // fmt.Println(err)
  5793. // }
  5794. //
  5795. // userJSONBytes, _ := json.Marshal(dat)
  5796. //
  5797. //
  5798. //
  5799. // var res ResultSeven
  5800. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5801. // utils.ErrorLog("解析失败:%v", err)
  5802. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5803. // return
  5804. // }
  5805. // if res.Infcode == -1 {
  5806. // errlog := &models.HisOrderError{
  5807. // UserOrgId: adminUser.CurrentOrgId,
  5808. // Ctime: time.Now().Unix(),
  5809. // Mtime: time.Now().Unix(),
  5810. // Number: chrg_bchno,
  5811. // ErrMsg: res.ErrMsg,
  5812. // Status: 1,
  5813. // PatientId: id,
  5814. // RecordTime: recordDateTime,
  5815. // Stage: 6,
  5816. // }
  5817. // service.CreateErrMsgLog(errlog)
  5818. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5819. // return
  5820. // } else {
  5821. // order_src.OrderStatus = 2
  5822. // order_src.PayWay = pay_way
  5823. // order_src.PayPrice = pay_price
  5824. // order_src.PayCardNo = pay_card_no
  5825. // order_src.DiscountPrice = discount_price
  5826. // order_src.PreferentialPrice = preferential_price
  5827. // order_src.RealityPrice = reality_price
  5828. // order_src.FoundPrice = found_price
  5829. // order_src.MedicalInsurancePrice = medical_insurance_price
  5830. // order_src.PrivatePrice = private_price
  5831. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  5832. // order_src.SetlId = res.Output.Setlinfo.SetlID
  5833. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  5834. // order_src.PsnName = res.Output.Setlinfo.PsnName
  5835. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  5836. // order_src.Certno = res.Output.Setlinfo.Certno
  5837. // order_src.Gend = res.Output.Setlinfo.Gend
  5838. // order_src.Naty = res.Output.Setlinfo.Naty
  5839. // order_src.Age = res.Output.Setlinfo.Age
  5840. // order_src.Insutype = res.Output.Setlinfo.Insutype
  5841. // order_src.PsnType = res.Output.Setlinfo.PsnType
  5842. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5843. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  5844. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5845. // order_src.MedType = res.Output.Setlinfo.MedType
  5846. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5847. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5848. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5849. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5850. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5851. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5852. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  5853. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  5854. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5855. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  5856. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  5857. // order_src.MafPay = res.Output.Setlinfo.MafPay
  5858. // order_src.OthPay = res.Output.Setlinfo.OthPay
  5859. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5860. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5861. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  5862. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5863. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5864. // order_src.Balc = res.Output.Setlinfo.Balc
  5865. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5866. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5867. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  5868. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  5869. // order_src.Creator = order_src.Creator
  5870. // order_src.Modify = roles.ID
  5871. // order_src.RequestLog = src_resquest
  5872. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5873. // detailStr := string(setlDetail)
  5874. // order_src.SetlDetail = detailStr
  5875. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5876. // err = service.UpDateOrder(order_src)
  5877. //
  5878. // if err == nil {
  5879. // c.ServeSuccessJSON(map[string]interface{}{
  5880. // "msg": "结算成功",
  5881. // })
  5882. // } else {
  5883. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5884. // return
  5885. // }
  5886. // }
  5887. // }
  5888. //}
  5889. //退款
  5890. func (c *HisApiController) Refund() {
  5891. order_id, _ := c.GetInt64("order_id")
  5892. admin_user_id, _ := c.GetInt64("admin_user_id")
  5893. adminUser := c.GetAdminUserInfo()
  5894. var order models.HisOrder
  5895. order, _ = service.GetHisOrderByID(order_id)
  5896. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5897. if order.ID == 0 {
  5898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5899. return
  5900. }
  5901. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5902. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5903. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5904. if config.IsOpen == 1 { //对接了医保,走医保流程
  5905. var res ResultSixteen
  5906. var resSixteen10265 ResultSixteen10265
  5907. var src_resquest string
  5908. var result string
  5909. if miConfig.MdtrtareaAdmvs == "421300" {
  5910. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  5911. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5912. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5913. resp3, requestErr3 := http.Get(api3)
  5914. if requestErr3 != nil {
  5915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5916. return
  5917. }
  5918. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5919. if ioErr3 != nil {
  5920. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5922. return
  5923. }
  5924. var respJSON3 map[string]interface{}
  5925. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5928. return
  5929. }
  5930. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5931. userJSONBytes3, _ := json.Marshal(respJSON3)
  5932. fmt.Println("log")
  5933. fmt.Println(string(userJSONBytes3))
  5934. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  5935. utils.ErrorLog("解析失败:%v", err)
  5936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5937. return
  5938. }
  5939. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5940. api3 := "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  5941. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5942. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5943. resp3, requestErr3 := http.Get(api3)
  5944. if requestErr3 != nil {
  5945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5946. return
  5947. }
  5948. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5949. if ioErr3 != nil {
  5950. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5952. return
  5953. }
  5954. var respJSON3 map[string]interface{}
  5955. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5958. return
  5959. }
  5960. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5961. userJSONBytes3, _ := json.Marshal(respJSON3)
  5962. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  5963. utils.ErrorLog("解析失败:%v", err)
  5964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5965. return
  5966. }
  5967. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  5968. res.Output = resSixteen10265.Output
  5969. res.ErrMsg = resSixteen10265.ErrMsg
  5970. res.Cainfo = resSixteen10265.Cainfo
  5971. res.WarnMsg = resSixteen10265.WarnMsg
  5972. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  5973. res.Infcode = infocode
  5974. } else {
  5975. if miConfig.Code == "H15049901371" {
  5976. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5977. var dat map[string]interface{}
  5978. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5979. fmt.Println(dat)
  5980. } else {
  5981. fmt.Println(err)
  5982. }
  5983. saveLog(result, src_resquest, "2208", "退费")
  5984. userJSONBytes, _ := json.Marshal(dat)
  5985. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  5986. utils.ErrorLog("解析失败:%v", err)
  5987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5988. return
  5989. }
  5990. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  5991. res.Output = resSixteen10265.Output
  5992. res.ErrMsg = resSixteen10265.ErrMsg
  5993. res.Cainfo = resSixteen10265.Cainfo
  5994. res.WarnMsg = resSixteen10265.WarnMsg
  5995. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  5996. res.Infcode = infocode
  5997. } else {
  5998. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5999. var dat map[string]interface{}
  6000. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6001. fmt.Println(dat)
  6002. } else {
  6003. fmt.Println(err)
  6004. }
  6005. saveLog(result, src_resquest, "2208", "退费")
  6006. userJSONBytes, _ := json.Marshal(dat)
  6007. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6008. utils.ErrorLog("解析失败:%v", err)
  6009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6010. return
  6011. }
  6012. }
  6013. }
  6014. if res.Infcode == 0 {
  6015. var res2 ResultSix
  6016. var resSix10265 ResultSix10265
  6017. if miConfig.MdtrtareaAdmvs == "421300" {
  6018. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6019. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6020. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6021. resp3, requestErr3 := http.Get(api3)
  6022. if requestErr3 != nil {
  6023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6024. return
  6025. }
  6026. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6027. if ioErr3 != nil {
  6028. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6030. return
  6031. }
  6032. var respJSON3 map[string]interface{}
  6033. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6036. return
  6037. }
  6038. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6039. userJSONBytes3, _ := json.Marshal(respJSON3)
  6040. fmt.Println("log")
  6041. fmt.Println(string(userJSONBytes3))
  6042. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6043. utils.ErrorLog("解析失败:%v", err)
  6044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6045. return
  6046. }
  6047. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6048. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6049. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6050. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6051. resp3, requestErr3 := http.Get(api3)
  6052. if requestErr3 != nil {
  6053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6054. return
  6055. }
  6056. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6057. if ioErr3 != nil {
  6058. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6060. return
  6061. }
  6062. var respJSON3 map[string]interface{}
  6063. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6064. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6066. return
  6067. }
  6068. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6069. userJSONBytes3, _ := json.Marshal(respJSON3)
  6070. fmt.Println("log")
  6071. fmt.Println(string(userJSONBytes3))
  6072. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6073. utils.ErrorLog("解析失败:%v", err)
  6074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6075. return
  6076. }
  6077. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6078. res2.Output = resSix10265.Output
  6079. res2.ErrMsg = resSix10265.ErrMsg
  6080. res2.Cainfo = resSix10265.Cainfo
  6081. res2.WarnMsg = resSix10265.WarnMsg
  6082. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6083. res2.Infcode = infocode
  6084. } else {
  6085. if miConfig.Code == "H15049901371" {
  6086. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6087. var dat map[string]interface{}
  6088. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6089. fmt.Println(dat)
  6090. } else {
  6091. fmt.Println(err)
  6092. }
  6093. saveLog(result2, src_request, "2205", "撤销明细")
  6094. userJSONBytes, _ := json.Marshal(dat)
  6095. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6096. utils.ErrorLog("解析失败:%v", err)
  6097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6098. return
  6099. }
  6100. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6101. res2.Output = resSix10265.Output
  6102. res2.ErrMsg = resSix10265.ErrMsg
  6103. res2.Cainfo = resSix10265.Cainfo
  6104. res2.WarnMsg = resSix10265.WarnMsg
  6105. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6106. res2.Infcode = infocode
  6107. } else {
  6108. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6109. var dat map[string]interface{}
  6110. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6111. fmt.Println(dat)
  6112. } else {
  6113. fmt.Println(err)
  6114. }
  6115. saveLog(result2, src_request, "2205", "撤销明细")
  6116. userJSONBytes, _ := json.Marshal(dat)
  6117. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6118. utils.ErrorLog("解析失败:%v", err)
  6119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6120. return
  6121. }
  6122. }
  6123. }
  6124. if res2.Infcode == 0 {
  6125. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  6126. if err == nil {
  6127. c.ServeSuccessJSON(map[string]interface{}{
  6128. "msg": "退费成功",
  6129. })
  6130. } else {
  6131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6132. return
  6133. }
  6134. } else {
  6135. c.ServeSuccessJSON(map[string]interface{}{
  6136. "code": -10,
  6137. "msg": res2.ErrMsg,
  6138. })
  6139. }
  6140. } else {
  6141. c.ServeSuccessJSON(map[string]interface{}{
  6142. "code": -10,
  6143. "msg": res.ErrMsg,
  6144. })
  6145. }
  6146. }
  6147. }
  6148. func (c *HisApiController) RefundNumber() {
  6149. record_time := c.GetString("record_time")
  6150. //patient_id, _ := c.GetInt64("patient_id")
  6151. admin_user_id, _ := c.GetInt64("admin_user_id")
  6152. his_patient_id, _ := c.GetInt64("id")
  6153. timeLayout := "2006-01-02"
  6154. loc, _ := time.LoadLocation("Local")
  6155. adminUser := c.GetAdminUserInfo()
  6156. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6157. fmt.Println(err)
  6158. if err != nil {
  6159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6160. return
  6161. }
  6162. recordDateTime := theTime.Unix()
  6163. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6164. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  6165. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6166. //order, _ := service.GetHisOrderByID(order_id)
  6167. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6168. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6169. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6170. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  6171. if count > 0 {
  6172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  6173. return
  6174. }
  6175. if config.IsOpen == 1 { //对接了医保,走医保流程
  6176. var res2 ResultSix
  6177. var resSix10265 ResultSix10265
  6178. if miConfig.MdtrtareaAdmvs == "421300" {
  6179. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  6180. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6181. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6182. resp3, requestErr3 := http.Get(api3)
  6183. if requestErr3 != nil {
  6184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6185. return
  6186. }
  6187. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6188. if ioErr3 != nil {
  6189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6191. return
  6192. }
  6193. var respJSON3 map[string]interface{}
  6194. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6197. return
  6198. }
  6199. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6200. userJSONBytes3, _ := json.Marshal(respJSON3)
  6201. fmt.Println("log")
  6202. fmt.Println(string(userJSONBytes3))
  6203. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6204. utils.ErrorLog("解析失败:%v", err)
  6205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6206. return
  6207. }
  6208. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6209. api3 := "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6210. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6211. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6212. resp3, requestErr3 := http.Get(api3)
  6213. if requestErr3 != nil {
  6214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6215. return
  6216. }
  6217. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6218. if ioErr3 != nil {
  6219. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6221. return
  6222. }
  6223. var respJSON3 map[string]interface{}
  6224. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6225. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6227. return
  6228. }
  6229. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6230. userJSONBytes3, _ := json.Marshal(respJSON3)
  6231. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6232. utils.ErrorLog("解析失败:%v", err)
  6233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6234. return
  6235. }
  6236. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6237. res2.Output = resSix10265.Output
  6238. res2.ErrMsg = resSix10265.ErrMsg
  6239. res2.Cainfo = resSix10265.Cainfo
  6240. res2.WarnMsg = resSix10265.WarnMsg
  6241. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6242. res2.Infcode = infocode
  6243. } else {
  6244. var api3 string
  6245. if miConfig.Code == "H15049901371" {
  6246. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6247. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6248. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6249. } else {
  6250. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6251. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6252. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6253. }
  6254. resp3, requestErr3 := http.Get(api3)
  6255. if requestErr3 != nil {
  6256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6257. return
  6258. }
  6259. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6260. if ioErr3 != nil {
  6261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6263. return
  6264. }
  6265. var respJSON3 map[string]interface{}
  6266. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6269. return
  6270. }
  6271. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6272. userJSONBytes3, _ := json.Marshal(respJSON3)
  6273. if miConfig.Code == "H15049901371" {
  6274. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6275. utils.ErrorLog("解析失败:%v", err)
  6276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6277. return
  6278. }
  6279. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6280. res2.Output = resSix10265.Output
  6281. res2.ErrMsg = resSix10265.ErrMsg
  6282. res2.Cainfo = resSix10265.Cainfo
  6283. res2.WarnMsg = resSix10265.WarnMsg
  6284. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6285. res2.Infcode = infocode
  6286. } else {
  6287. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6288. utils.ErrorLog("解析失败:%v", err)
  6289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6290. return
  6291. }
  6292. }
  6293. }
  6294. if res2.Infcode == 0 {
  6295. if err == nil {
  6296. c.ServeSuccessJSON(map[string]interface{}{
  6297. "msg": "退号成功",
  6298. })
  6299. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  6300. } else {
  6301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6302. return
  6303. }
  6304. } else {
  6305. c.ServeSuccessJSON(map[string]interface{}{
  6306. "code": -10,
  6307. "msg": res2.ErrMsg,
  6308. })
  6309. }
  6310. } else {
  6311. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  6312. //if err == nil {
  6313. // c.ServeSuccessJSON(map[string]interface{}{
  6314. // "msg": "退费成功",
  6315. // })
  6316. //} else {
  6317. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6318. // return
  6319. //}
  6320. }
  6321. }
  6322. func (c *HisApiController) RefundDetail() {
  6323. order_id, _ := c.GetInt64("order_id")
  6324. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6325. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6326. number := c.GetString("number")
  6327. record_time := c.GetString("record_time")
  6328. patient_id, _ := c.GetInt64("patient_id")
  6329. timeLayout := "2006-01-02"
  6330. loc, _ := time.LoadLocation("Local")
  6331. adminUser := c.GetAdminUserInfo()
  6332. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6333. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6334. fmt.Println(err)
  6335. if err != nil {
  6336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6337. return
  6338. }
  6339. recordDateTime := theTime.Unix()
  6340. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6341. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6342. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6343. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6344. var order models.HisOrder
  6345. order, _ = service.GetHisOrderByID(order_id)
  6346. if order.ID == 0 {
  6347. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  6348. }
  6349. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6350. if config.IsOpen == 1 { //对接了医保,走医保流程
  6351. var res2 ResultSix
  6352. if miConfig.MdtrtareaAdmvs == "421300" {
  6353. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6354. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6355. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6356. resp3, requestErr3 := http.Get(api3)
  6357. if requestErr3 != nil {
  6358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6359. return
  6360. }
  6361. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6362. if ioErr3 != nil {
  6363. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6365. return
  6366. }
  6367. var respJSON3 map[string]interface{}
  6368. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6371. return
  6372. }
  6373. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6374. userJSONBytes3, _ := json.Marshal(respJSON3)
  6375. fmt.Println("log")
  6376. fmt.Println(string(userJSONBytes3))
  6377. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6378. utils.ErrorLog("解析失败:%v", err)
  6379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6380. return
  6381. }
  6382. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6383. if err == nil {
  6384. c.ServeSuccessJSON(map[string]interface{}{
  6385. "msg": "撤销明细成功",
  6386. })
  6387. return
  6388. } else {
  6389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6390. return
  6391. }
  6392. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6393. var resSix10265 ResultSix10265
  6394. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6395. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6396. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6397. resp3, requestErr3 := http.Get(api3)
  6398. if requestErr3 != nil {
  6399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6400. return
  6401. }
  6402. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6403. if ioErr3 != nil {
  6404. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6406. return
  6407. }
  6408. var respJSON3 map[string]interface{}
  6409. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6410. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6412. return
  6413. }
  6414. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6415. userJSONBytes3, _ := json.Marshal(respJSON3)
  6416. fmt.Println("log")
  6417. fmt.Println(string(userJSONBytes3))
  6418. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6419. utils.ErrorLog("解析失败:%v", err)
  6420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6421. return
  6422. }
  6423. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6424. res2.Output = resSix10265.Output
  6425. res2.ErrMsg = resSix10265.ErrMsg
  6426. res2.Cainfo = resSix10265.Cainfo
  6427. res2.WarnMsg = resSix10265.WarnMsg
  6428. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6429. res2.Infcode = infocode
  6430. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6431. if err == nil {
  6432. c.ServeSuccessJSON(map[string]interface{}{
  6433. "msg": "撤销明细成功",
  6434. })
  6435. return
  6436. } else {
  6437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6438. return
  6439. }
  6440. } else {
  6441. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  6442. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6443. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6444. resp2, requestErr2 := http.Get(api2)
  6445. if requestErr2 != nil {
  6446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6447. return
  6448. }
  6449. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6450. if ioErr2 != nil {
  6451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6453. return
  6454. }
  6455. var respJSON2 map[string]interface{}
  6456. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6459. return
  6460. }
  6461. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6462. if err == nil {
  6463. c.ServeSuccessJSON(map[string]interface{}{
  6464. "msg": "撤销明细成功",
  6465. })
  6466. return
  6467. } else {
  6468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6469. return
  6470. }
  6471. }
  6472. } else {
  6473. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6474. if err == nil {
  6475. c.ServeSuccessJSON(map[string]interface{}{
  6476. "msg": "退费成功",
  6477. })
  6478. } else {
  6479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6480. return
  6481. }
  6482. }
  6483. }
  6484. //对账
  6485. func (c *HisApiController) GetCheckAccount() {
  6486. start_time := c.GetString("start_time")
  6487. end_time := c.GetString("end_time")
  6488. insutype := c.GetString("insutype")
  6489. clr_type := c.GetString("clr_type")
  6490. clr_org := c.GetString("clr_optins")
  6491. admin_user_id, _ := c.GetInt64("admin_user_id")
  6492. adminUser := c.GetAdminUserInfo()
  6493. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6494. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6495. if len(clr_org) == 0 {
  6496. clr_org = miConfig.MdtrtareaAdmvs
  6497. }
  6498. timeLayout := "2006-01-02"
  6499. loc, _ := time.LoadLocation("Local")
  6500. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6501. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6502. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  6503. fixmedins_setl_cnt := int64(len(orders))
  6504. var medfee_sumamt float64
  6505. var acct_pay float64
  6506. var fund_pay_sumamt float64
  6507. for _, item := range orders {
  6508. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6509. acct_pay = acct_pay + item.AcctPay
  6510. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6511. }
  6512. var user_name string
  6513. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6514. if role.ID == 0 {
  6515. user_name = "xxx"
  6516. } else {
  6517. user_name = role.UserName
  6518. }
  6519. var res ResultEight
  6520. var res10188 ResultEightFor10188
  6521. if config.IsOpen == 1 {
  6522. if miConfig.MdtrtareaAdmvs == "320921" {
  6523. api := "http://192.168.3.111:9532/" + "jsyb/3201" +
  6524. "insutype=" + insutype +
  6525. "&clr_type=" + clr_type +
  6526. "&setl_optins=" + clr_org +
  6527. "&stmt_begndate=" + start_time +
  6528. "&stm_enddate=" + end_time +
  6529. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6530. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6531. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  6532. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6533. "&fixmedins_code=" + miConfig.Code +
  6534. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6535. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6536. "&secret_key=" + miConfig.SecretKey +
  6537. "&org_name=" + miConfig.OrgName +
  6538. "&doctor=" + user_name +
  6539. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6540. fmt.Println(api)
  6541. resp, requestErr := http.Get(api)
  6542. if requestErr != nil {
  6543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6544. return
  6545. }
  6546. body, ioErr := ioutil.ReadAll(resp.Body)
  6547. fmt.Println(body)
  6548. if ioErr != nil {
  6549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6551. return
  6552. }
  6553. var respJSON map[string]interface{}
  6554. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6557. return
  6558. }
  6559. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6560. userJSONBytes, _ := json.Marshal(respJSON)
  6561. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6562. utils.ErrorLog("解析失败:%v", err)
  6563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6564. return
  6565. }
  6566. res.InfRefmsgid = res10188.InfRefmsgid
  6567. res.Output = res10188.Output
  6568. res.ErrMsg = res10188.ErrMsg
  6569. res.Cainfo = res10188.Cainfo
  6570. res.WarnMsg = res10188.WarnMsg
  6571. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  6572. res.Infcode = infocode
  6573. } else {
  6574. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6575. "insutype=" + insutype +
  6576. "&clr_type=" + clr_type +
  6577. "&setl_optins=" + clr_org +
  6578. "&stmt_begndate=" + start_time +
  6579. "&stm_enddate=" + end_time +
  6580. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6581. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6582. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  6583. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6584. "&fixmedins_code=" + miConfig.Code +
  6585. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6586. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6587. "&secret_key=" + miConfig.SecretKey +
  6588. "&org_name=" + miConfig.OrgName +
  6589. "&doctor=" + user_name
  6590. fmt.Println(api)
  6591. resp, requestErr := http.Get(api)
  6592. if requestErr != nil {
  6593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6594. return
  6595. }
  6596. body, ioErr := ioutil.ReadAll(resp.Body)
  6597. fmt.Println(body)
  6598. if ioErr != nil {
  6599. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6601. return
  6602. }
  6603. var respJSON map[string]interface{}
  6604. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6605. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6607. return
  6608. }
  6609. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6610. userJSONBytes, _ := json.Marshal(respJSON)
  6611. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6612. utils.ErrorLog("解析失败:%v", err)
  6613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6614. return
  6615. }
  6616. }
  6617. if res.Infcode == 0 {
  6618. if res.Output.Stmtinfo.StmtRslt == "0" {
  6619. micc := &models.MedicalInsuranceCostCompare{
  6620. StartTime: startime.Unix(),
  6621. EndTime: endtime.Unix(),
  6622. Insutype: insutype,
  6623. CheckType: 1,
  6624. Num: fixmedins_setl_cnt,
  6625. Mtime: time.Now().Unix(),
  6626. Status: 1,
  6627. UserOrgId: adminUser.CurrentOrgId,
  6628. CostTotal: medfee_sumamt,
  6629. FuncTotal: fund_pay_sumamt,
  6630. PsnPay: acct_pay,
  6631. Creator: admin_user_id,
  6632. Ctime: time.Now().Unix(),
  6633. }
  6634. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  6635. if err == nil {
  6636. c.ServeSuccessJSON(map[string]interface{}{
  6637. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  6638. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  6639. })
  6640. } else {
  6641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6642. }
  6643. } else {
  6644. c.ServeSuccessJSON(map[string]interface{}{
  6645. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  6646. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  6647. })
  6648. }
  6649. } else {
  6650. c.ServeSuccessJSON(map[string]interface{}{
  6651. "code": -10,
  6652. "msg": res.ErrMsg,
  6653. })
  6654. }
  6655. }
  6656. }
  6657. func (c *HisApiController) Check310() {
  6658. adminUser := c.GetAdminUserInfo()
  6659. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6660. var user_name string
  6661. user_name = "高慧裕"
  6662. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6663. "insutype=" + "310" +
  6664. "&clr_type=" + "11" +
  6665. "&setl_optins=" + "441202" +
  6666. "&stmt_begndate=" + "2022-02-01" +
  6667. "&stm_enddate=" + "2022-02-28" +
  6668. "&medfee_sumamt=" + "155812.88" +
  6669. "&fund_pay_sumamt=" + "151026.15" +
  6670. "&acct_pay=" + "0" +
  6671. "&fixmedins_setl_cnt=" + "73" +
  6672. "&fixmedins_code=" + miConfig.Code +
  6673. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6674. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6675. "&secret_key=" + miConfig.SecretKey +
  6676. "&org_name=" + miConfig.OrgName +
  6677. "&doctor=" + user_name
  6678. fmt.Println(api)
  6679. resp, requestErr := http.Get(api)
  6680. if requestErr != nil {
  6681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6682. return
  6683. }
  6684. body, ioErr := ioutil.ReadAll(resp.Body)
  6685. fmt.Println(body)
  6686. if ioErr != nil {
  6687. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6689. return
  6690. }
  6691. var respJSON map[string]interface{}
  6692. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6693. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6695. return
  6696. }
  6697. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6698. userJSONBytes, _ := json.Marshal(respJSON)
  6699. var res ResultEight
  6700. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6701. utils.ErrorLog("解析失败:%v", err)
  6702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6703. return
  6704. }
  6705. }
  6706. func (c *HisApiController) Check390() {
  6707. adminUser := c.GetAdminUserInfo()
  6708. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6709. var user_name string
  6710. user_name = "高慧裕"
  6711. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6712. "insutype=" + "390" +
  6713. "&clr_type=" + "11" +
  6714. "&setl_optins=" + "441202" +
  6715. "&stmt_begndate=" + "2022-02-01" +
  6716. "&stm_enddate=" + "2022-02-28" +
  6717. "&medfee_sumamt=" + "933920.08" +
  6718. "&fund_pay_sumamt=" + "887153.34" +
  6719. "&acct_pay=" + "0" +
  6720. "&fixmedins_setl_cnt=" + "396" +
  6721. "&fixmedins_code=" + miConfig.Code +
  6722. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6723. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6724. "&secret_key=" + miConfig.SecretKey +
  6725. "&org_name=" + miConfig.OrgName +
  6726. "&doctor=" + user_name
  6727. fmt.Println(api)
  6728. resp, requestErr := http.Get(api)
  6729. if requestErr != nil {
  6730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6731. return
  6732. }
  6733. body, ioErr := ioutil.ReadAll(resp.Body)
  6734. fmt.Println(body)
  6735. if ioErr != nil {
  6736. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6738. return
  6739. }
  6740. var respJSON map[string]interface{}
  6741. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6742. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6744. return
  6745. }
  6746. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6747. userJSONBytes, _ := json.Marshal(respJSON)
  6748. var res ResultEight
  6749. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6750. utils.ErrorLog("解析失败:%v", err)
  6751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6752. return
  6753. }
  6754. }
  6755. //对账明细
  6756. func (c *HisApiController) GetCheckDetailAccount() {
  6757. start_time := c.GetString("start_time")
  6758. end_time := c.GetString("end_time")
  6759. admin_user_id, _ := c.GetInt64("admin_user_id")
  6760. adminUser := c.GetAdminUserInfo()
  6761. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6762. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6763. timeLayout := "2006-01-02"
  6764. loc, _ := time.LoadLocation("Local")
  6765. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6766. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6767. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  6768. Mkdir(miConfig.OrgName)
  6769. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  6770. file_name := file + ".txt"
  6771. zip_name := file + ".zip"
  6772. zip_path := miConfig.OrgName + "/" + zip_name
  6773. file_path := miConfig.OrgName + "/" + file_name
  6774. decimal.DivisionPrecision = 2
  6775. var medfee_sumamt float64
  6776. var psn_cash_pay float64
  6777. var fund_pay_sumamt float64
  6778. fixmedins_setl_cnt := int64(len(orders))
  6779. for _, item := range orders {
  6780. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6781. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  6782. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6783. }
  6784. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  6785. defer f.Close()
  6786. if err != nil {
  6787. fmt.Println(err.Error())
  6788. } else {
  6789. for _, item := range orders {
  6790. var refd_setl_flag string
  6791. if item.OrderStatus == 2 {
  6792. refd_setl_flag = "0"
  6793. var str string
  6794. str = item.SetlId + " " +
  6795. item.MdtrtId + " " +
  6796. item.PsnNo + " " +
  6797. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  6798. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  6799. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  6800. _, err = f.Write([]byte(str))
  6801. }
  6802. if item.OrderStatus == 3 {
  6803. var str string
  6804. str = item.SetlId + " " +
  6805. item.MdtrtId + " " +
  6806. item.PsnNo + " " +
  6807. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  6808. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  6809. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  6810. _, err = f.Write([]byte(str))
  6811. var str2 string
  6812. str2 = item.SetlId + " " +
  6813. item.MdtrtId + " " +
  6814. item.PsnNo + " " +
  6815. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  6816. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  6817. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  6818. _, err = f.Write([]byte(str2))
  6819. }
  6820. }
  6821. }
  6822. Zip(file_path, zip_path)
  6823. fmt.Println(ReadFile(zip_path))
  6824. fmt.Println(string(ReadFile(zip_path)))
  6825. if config.IsOpen == 1 {
  6826. var user_name string
  6827. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6828. if role.ID == 0 {
  6829. user_name = "管理员"
  6830. } else {
  6831. user_name = role.UserName
  6832. }
  6833. baseParams := models.BaseParams{
  6834. SecretKey: miConfig.SecretKey,
  6835. FixmedinsCode: miConfig.Code,
  6836. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6837. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6838. OrgName: miConfig.OrgName,
  6839. Doctor: user_name,
  6840. }
  6841. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  6842. var dat map[string]interface{}
  6843. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6844. fmt.Println(dat)
  6845. } else {
  6846. fmt.Println(err)
  6847. }
  6848. userJSONBytes, _ := json.Marshal(dat)
  6849. var res ResultNine
  6850. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6851. utils.ErrorLog("解析失败:%v", err)
  6852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6853. return
  6854. }
  6855. if res.Infcode == 0 {
  6856. fileNo := res.Output.FileQuryNo
  6857. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  6858. "file_qury_no=" + fileNo +
  6859. "&setl_optins=" + "定点医保中心" +
  6860. "&stmt_begndate=" + start_time +
  6861. "&stm_enddate=" + end_time +
  6862. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6863. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6864. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  6865. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6866. "&fixmedins_code=" + miConfig.Code +
  6867. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6868. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6869. "&secret_key=" + miConfig.SecretKey +
  6870. "&org_name=" + miConfig.OrgName +
  6871. "&doctor=" + user_name
  6872. resp, requestErr := http.Get(api)
  6873. if requestErr != nil {
  6874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6875. return
  6876. }
  6877. body, ioErr := ioutil.ReadAll(resp.Body)
  6878. if ioErr != nil {
  6879. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6881. return
  6882. }
  6883. var respJSON map[string]interface{}
  6884. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6885. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6887. return
  6888. }
  6889. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6890. userJSONBytes, _ := json.Marshal(respJSON)
  6891. var res ResultTen
  6892. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6893. utils.ErrorLog("解析失败:%v", err)
  6894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6895. return
  6896. }
  6897. if res.Infcode == 0 {
  6898. service.Gdyb9102(baseParams, zip_name, fileNo)
  6899. micc := &models.MedicalInsuranceCostCompare{
  6900. StartTime: startime.Unix(),
  6901. EndTime: endtime.Unix(),
  6902. Insutype: "0",
  6903. CheckType: 2,
  6904. Num: fixmedins_setl_cnt,
  6905. Mtime: time.Now().Unix(),
  6906. Status: 1,
  6907. UserOrgId: adminUser.CurrentOrgId,
  6908. CostTotal: medfee_sumamt,
  6909. FuncTotal: fund_pay_sumamt,
  6910. PsnPay: psn_cash_pay,
  6911. Creator: admin_user_id,
  6912. Ctime: time.Now().Unix(),
  6913. }
  6914. service.CreateMedicalInsuranceCostCompareRecord(micc)
  6915. c.ServeSuccessJSON(map[string]interface{}{
  6916. "msg": "明细对账成功",
  6917. })
  6918. }
  6919. } else {
  6920. }
  6921. }
  6922. }
  6923. type CustomOrderInfo struct {
  6924. Name string
  6925. Spec string
  6926. Unit string
  6927. Count float64
  6928. Price float64
  6929. Total float64
  6930. }
  6931. func (c *HisApiController) GetSettleAccounts() {
  6932. //id, _ := c.GetInt64("id")
  6933. //record_time := c.GetString("record_time")
  6934. order_id, _ := c.GetInt64("order_id")
  6935. admin_user_id, _ := c.GetInt64("admin_user_id")
  6936. //timeLayout := "2006-01-02"
  6937. //loc, _ := time.LoadLocation("Local")
  6938. //
  6939. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6940. //if err != nil {
  6941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6942. // return
  6943. //}
  6944. //recordDateTime := theTime.Unix()
  6945. adminUser := c.GetAdminUserInfo()
  6946. order, _ := service.GetHisOrderByID(order_id)
  6947. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6948. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  6949. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  6950. orderInfos = append(orderInfos, orderInfos_two...)
  6951. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  6952. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6953. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  6954. //var config []*models.HisXtDiagnoseConfig
  6955. var name string
  6956. for _, item := range diagnosis_ids {
  6957. id, _ := strconv.ParseInt(item, 10, 64)
  6958. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6959. if len(name) == 0 {
  6960. name = diagnosisConfig.ClassName
  6961. } else {
  6962. name = name + "," + diagnosisConfig.ClassName
  6963. }
  6964. }
  6965. var bedCostTotal float64 = 0 //床位总费
  6966. var bedCostSelfTotal float64 = 0 //床位自费
  6967. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  6968. var operationCostTotal float64 = 0 //手术费
  6969. var operationCostSelfTotal float64 = 0 //手术费
  6970. var operationCostPartSelfTotal float64 = 0 //手术费
  6971. var otherCostTotal float64 = 0 //其他费用
  6972. var otherCostSelfTotal float64 = 0 //其他费用
  6973. var otherCostPartSelfTotal float64 = 0 //其他费用
  6974. var materialCostTotal float64 = 0 //材料费
  6975. var materialCostSelfTotal float64 = 0 //材料费
  6976. var materialCostPartSelfTotal float64 = 0 //材料费
  6977. var westernMedicineCostTotal float64 = 0 //西药费
  6978. var westernMedicineCostSelfTotal float64 = 0 //西药费
  6979. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  6980. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  6981. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  6982. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  6983. var checkCostTotal float64 = 0 //检查费
  6984. var checkCostSelfTotal float64 = 0 //检查费
  6985. var checkCostPartSelfTotal float64 = 0 //检查费
  6986. var laboratoryCostTotal float64 = 0 //化验费
  6987. var laboratoryCostSelfTotal float64 = 0 //化验费
  6988. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  6989. var treatCostTotal float64 = 0 //治疗费用
  6990. var treatCostSelfTotal float64 = 0 //治疗费用
  6991. var treatCostPartSelfTotal float64 = 0 //治疗费用
  6992. decimal.DivisionPrecision = 2
  6993. for _, item := range orderInfos {
  6994. if item.MedChrgitmType == "01" { //床位费
  6995. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6996. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6997. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6998. }
  6999. if item.MedChrgitmType == "03" { //检查费
  7000. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7001. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7002. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7003. }
  7004. if item.MedChrgitmType == "04" { //化验费
  7005. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7006. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7007. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7008. }
  7009. if item.MedChrgitmType == "05" { //治疗费
  7010. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7011. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7012. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7013. }
  7014. if item.MedChrgitmType == "06" { //手术费
  7015. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7016. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7017. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7018. }
  7019. if item.MedChrgitmType == "08" { //材料费
  7020. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7021. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7022. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7023. }
  7024. if item.MedChrgitmType == "09" { //西药费
  7025. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7026. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7027. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7028. }
  7029. if item.MedChrgitmType == "11" { //中成费
  7030. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7031. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7032. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7033. }
  7034. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  7035. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7036. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7037. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7038. }
  7039. }
  7040. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7041. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7042. var user_name string
  7043. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7044. if role.ID == 0 {
  7045. user_name = "管理员"
  7046. } else {
  7047. user_name = role.UserName
  7048. }
  7049. baseParams := models.BaseParams{
  7050. SecretKey: miConfig.SecretKey,
  7051. FixmedinsCode: miConfig.Code,
  7052. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7053. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7054. OrgName: miConfig.OrgName,
  7055. Doctor: user_name,
  7056. }
  7057. businessParams := models.BusinessParams{
  7058. PsnNo: order.PsnNo,
  7059. MdtrtId: order.MdtrtId,
  7060. SetlId: order.SetlId,
  7061. }
  7062. var res ResultEleven
  7063. var resEleven10265 ResultEleven10265
  7064. if config.IsOpen == 1 {
  7065. if miConfig.MdtrtareaAdmvs == "421300" {
  7066. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7067. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7068. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7069. resp, requestErr := http.Get(api)
  7070. if requestErr != nil {
  7071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7072. return
  7073. }
  7074. body, ioErr := ioutil.ReadAll(resp.Body)
  7075. if ioErr != nil {
  7076. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7078. return
  7079. }
  7080. var respJSON map[string]interface{}
  7081. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7082. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7084. return
  7085. }
  7086. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7087. result, _ := json.Marshal(respJSON)
  7088. fmt.Println("log")
  7089. fmt.Println(string(result))
  7090. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7091. utils.ErrorLog("解析失败:%v", err)
  7092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7093. return
  7094. }
  7095. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7096. api := "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7097. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7098. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7099. resp, requestErr := http.Get(api)
  7100. if requestErr != nil {
  7101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7102. return
  7103. }
  7104. body, ioErr := ioutil.ReadAll(resp.Body)
  7105. if ioErr != nil {
  7106. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7108. return
  7109. }
  7110. var respJSON map[string]interface{}
  7111. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7114. return
  7115. }
  7116. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7117. result, _ := json.Marshal(respJSON)
  7118. fmt.Println("log")
  7119. fmt.Println(string(result))
  7120. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  7121. utils.ErrorLog("解析失败:%v", err)
  7122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7123. return
  7124. }
  7125. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7126. res.Output = resEleven10265.Output
  7127. res.ErrMsg = resEleven10265.ErrMsg
  7128. res.Cainfo = resEleven10265.Cainfo
  7129. res.WarnMsg = resEleven10265.WarnMsg
  7130. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7131. res.Infcode = infocode
  7132. } else {
  7133. result2 := service.Gdyb5204(baseParams, businessParams)
  7134. saveLog(result2, "", "5204", "查询")
  7135. result := service.Gdyb5203(baseParams, businessParams)
  7136. var dat map[string]interface{}
  7137. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7138. fmt.Println(dat)
  7139. } else {
  7140. fmt.Println(err)
  7141. }
  7142. userJSONBytes, _ := json.Marshal(dat)
  7143. if miConfig.Code == "H15049901371" {
  7144. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  7145. utils.ErrorLog("解析失败:%v", err)
  7146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7147. return
  7148. }
  7149. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7150. res.Output = resEleven10265.Output
  7151. res.ErrMsg = resEleven10265.ErrMsg
  7152. res.Cainfo = resEleven10265.Cainfo
  7153. res.WarnMsg = resEleven10265.WarnMsg
  7154. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7155. res.Infcode = infocode
  7156. } else {
  7157. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7158. utils.ErrorLog("解析失败:%v", err)
  7159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7160. return
  7161. }
  7162. }
  7163. }
  7164. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7165. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  7166. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  7167. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7168. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7169. var doctor_name string
  7170. if roles.ID == 0 {
  7171. doctor_name = "管理员"
  7172. } else {
  7173. doctor_name = roles.UserName
  7174. }
  7175. yiliao_leibie := ""
  7176. switch order.MedType {
  7177. case "11":
  7178. yiliao_leibie = "普通门诊"
  7179. break
  7180. case "12":
  7181. yiliao_leibie = "门诊挂号"
  7182. break
  7183. case "13":
  7184. yiliao_leibie = "急诊"
  7185. break
  7186. case "14":
  7187. yiliao_leibie = "门诊特殊病"
  7188. break
  7189. case "15":
  7190. yiliao_leibie = "门诊统筹"
  7191. break
  7192. case "16":
  7193. yiliao_leibie = "门诊慢性病"
  7194. break
  7195. case "21":
  7196. yiliao_leibie = "普通住院"
  7197. break
  7198. }
  7199. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7200. if res.Infcode == 0 {
  7201. c.ServeSuccessJSON(map[string]interface{}{
  7202. "diagnosis": name,
  7203. "order_infos": orderInfos,
  7204. "number": order.MdtrtId,
  7205. "date": order.SettleAccountsDate,
  7206. "charge_admin": charge_admin,
  7207. "printor_admin": printor_admin,
  7208. "info": res.Output.Setlinfo,
  7209. "bedCostTotal": bedCostTotal,
  7210. "bedCostSelfTotal": bedCostSelfTotal,
  7211. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  7212. "operationCostTotal": operationCostTotal,
  7213. "operationCostSelfTotal": operationCostSelfTotal,
  7214. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  7215. "otherCostTotal": otherCostTotal,
  7216. "otherCostSelfTotal": otherCostSelfTotal,
  7217. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  7218. "materialCostTotal": materialCostTotal,
  7219. "materialCostSelfTotal": materialCostSelfTotal,
  7220. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  7221. "westernMedicineCostTotal": westernMedicineCostTotal,
  7222. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  7223. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  7224. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  7225. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  7226. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  7227. "checkCostTotal": checkCostTotal,
  7228. "checkCostSelfTotal": checkCostSelfTotal,
  7229. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  7230. "laboratoryCostTotal": laboratoryCostTotal,
  7231. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  7232. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  7233. "treatCostTotal": treatCostTotal,
  7234. "treatCostSelfTotal": treatCostSelfTotal,
  7235. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  7236. "doctor_code": adminRole_two.DoctorCode,
  7237. "doctor_name": doctor_name,
  7238. "health_card_no": order.PsnNo,
  7239. "department": departments.Name,
  7240. "yiliao_leibie": yiliao_leibie,
  7241. "after_money": order.AccountPrice,
  7242. "patient": patient,
  7243. "org_name": miConfig.OrgName,
  7244. "org_code": miConfig.Code,
  7245. "order_number": order.Number,
  7246. //"check_order_info": cus_slice,
  7247. })
  7248. }
  7249. }
  7250. }
  7251. func (c *HisApiController) CheckTreatment() {
  7252. patient_id, _ := c.GetInt64("patient_id")
  7253. id_card_no := c.GetString("id_card_no")
  7254. insutype := c.GetString("insutype")
  7255. med_type := c.GetString("med_type")
  7256. admin_user_id, _ := c.GetInt64("admin_user_id")
  7257. adminUser := c.GetAdminUserInfo()
  7258. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7259. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7260. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7261. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7262. if miConfig.MdtrtareaAdmvs == "421300" {
  7263. var res ResultTwo
  7264. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7265. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7266. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(2, 10)
  7267. resp, requestErr := http.Get(api)
  7268. if requestErr != nil {
  7269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7270. return
  7271. }
  7272. body, ioErr := ioutil.ReadAll(resp.Body)
  7273. if ioErr != nil {
  7274. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7276. return
  7277. }
  7278. var respJSON map[string]interface{}
  7279. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7280. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7282. return
  7283. }
  7284. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7285. result, _ := json.Marshal(respJSON)
  7286. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7287. utils.ErrorLog("解析失败:%v", err)
  7288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7289. return
  7290. }
  7291. if res.Infcode == 0 {
  7292. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  7293. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7294. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  7295. resp, requestErr := http.Get(api)
  7296. if requestErr != nil {
  7297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7298. return
  7299. }
  7300. body, ioErr := ioutil.ReadAll(resp.Body)
  7301. if ioErr != nil {
  7302. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7304. return
  7305. }
  7306. var respJSON map[string]interface{}
  7307. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7308. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7310. return
  7311. }
  7312. var res Result2001
  7313. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7314. result2, _ := json.Marshal(respJSON)
  7315. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  7316. utils.ErrorLog("解析失败:%v", err)
  7317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7318. return
  7319. }
  7320. if res.Infcode == 0 {
  7321. c.ServeSuccessJSON(map[string]interface{}{
  7322. "msg": res.Output.Trtinfo,
  7323. })
  7324. }
  7325. } else {
  7326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7327. return
  7328. }
  7329. } else {
  7330. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7331. var dat map[string]interface{}
  7332. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7333. fmt.Println(dat)
  7334. } else {
  7335. fmt.Println(err)
  7336. }
  7337. userJSONBytes, _ := json.Marshal(dat)
  7338. var res ResultTwo
  7339. var res10265 ResultTwo10265
  7340. if miConfig.Code == "H15049901371" {
  7341. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7342. utils.ErrorLog("解析失败:%v", err)
  7343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7344. return
  7345. }
  7346. res.ErrMsg = res10265.ErrMsg
  7347. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7348. res.Infcode = infocode
  7349. res.Output = res10265.Output
  7350. res.InfRefmsgid = res10265.InfRefmsgid
  7351. } else {
  7352. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7353. utils.ErrorLog("解析失败:%v", err)
  7354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7355. return
  7356. }
  7357. }
  7358. var user_name string
  7359. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  7360. if role.ID == 0 {
  7361. user_name = "xxx"
  7362. } else {
  7363. user_name = role.UserName
  7364. }
  7365. baseParams := models.BaseParams{
  7366. SecretKey: miConfig.SecretKey,
  7367. FixmedinsCode: miConfig.Code,
  7368. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7369. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7370. OrgName: miConfig.OrgName,
  7371. Doctor: user_name,
  7372. }
  7373. if config.IsOpen == 1 {
  7374. if miConfig.Code == "H15049901371" {
  7375. if med_type == "14" {
  7376. if insutype == "390" {
  7377. med_type = "9933"
  7378. } else if insutype == "310" {
  7379. med_type = "990502"
  7380. }
  7381. } else if med_type == "11" {
  7382. med_type = "11"
  7383. }
  7384. }
  7385. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  7386. var dat map[string]interface{}
  7387. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7388. fmt.Println(dat)
  7389. } else {
  7390. fmt.Println(err)
  7391. }
  7392. var res Result2001
  7393. var res10265 Result2001Org10265
  7394. if miConfig.Code == "H15049901371" {
  7395. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7396. utils.ErrorLog("解析失败:%v", err)
  7397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7398. return
  7399. }
  7400. res.ErrMsg = res10265.ErrMsg
  7401. res.Output = res10265.Output
  7402. res.InfRefmsgid = res10265.InfRefmsgid
  7403. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7404. res.Infcode = infocode
  7405. } else {
  7406. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7407. utils.ErrorLog("解析失败:%v", err)
  7408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7409. return
  7410. }
  7411. }
  7412. if res.Infcode == 0 {
  7413. c.ServeSuccessJSON(map[string]interface{}{
  7414. "msg": res.Output.Trtinfo,
  7415. })
  7416. }
  7417. }
  7418. }
  7419. }
  7420. //func (c *HisApiController) PutRecord() {
  7421. // id, _ := c.GetInt64("id")
  7422. // record_time := c.GetString("record_time")
  7423. // timeLayout := "2006-01-02"
  7424. // loc, _ := time.LoadLocation("Local")
  7425. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7426. // if err != nil {
  7427. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7428. // return
  7429. // }
  7430. // recordDateTime := theTime.Unix()
  7431. //
  7432. // adminInfo := c.GetAdminUserInfo()
  7433. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  7434. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7435. //
  7436. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7437. //
  7438. // fmt.Println(miConfig.SecretKey)
  7439. //
  7440. // if patient == nil {
  7441. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7442. // return
  7443. // }
  7444. // if len(patient.IdCardNo) == 0 {
  7445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7446. // return
  7447. // }
  7448. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7449. // if config.IsOpen == 1 {
  7450. // 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
  7451. // resp, requestErr := http.Get(api)
  7452. // if requestErr != nil {
  7453. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7454. // return
  7455. // }
  7456. // defer resp.Body.Close()
  7457. // body, ioErr := ioutil.ReadAll(resp.Body)
  7458. // if ioErr != nil {
  7459. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7460. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7461. // return
  7462. // }
  7463. // var respJSON map[string]interface{}
  7464. //
  7465. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7466. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7467. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7468. // return
  7469. // }
  7470. //
  7471. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7472. // userJSONBytes, _ := json.Marshal(userJSON)
  7473. // var res ResultTwo
  7474. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7475. // utils.ErrorLog("解析失败:%v", err)
  7476. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7477. // return
  7478. // }
  7479. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7480. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7481. // infoStr := string(Iinfos)
  7482. // idetinfoStr := string(Idetinfos)
  7483. //
  7484. // if res.Infcode == 0 {
  7485. // his := models.VMHisPatient{
  7486. // Status: 1,
  7487. // Ctime: time.Now().Unix(),
  7488. // Mtime: time.Now().Unix(),
  7489. // PsnNo: res.Output.Baseinfo.PsnNo,
  7490. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  7491. // Certno: res.Output.Baseinfo.Certno,
  7492. // PsnName: res.Output.Baseinfo.PsnName,
  7493. // Gend: res.Output.Baseinfo.Gend,
  7494. // Naty: res.Output.Baseinfo.Naty,
  7495. // Brdy: res.Output.Baseinfo.Brdy,
  7496. // Age: res.Output.Baseinfo.Age,
  7497. // Iinfo: infoStr,
  7498. // Idetinfo: idetinfoStr,
  7499. // PatientId: patient.ID,
  7500. // RecordDate: theTime.Unix(),
  7501. // UserOrgId: adminInfo.CurrentOrgId,
  7502. // AdminUserId: adminInfo.AdminUser.Id,
  7503. // IsReturn: 1,
  7504. // }
  7505. //
  7506. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  7507. // //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")
  7508. // //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")
  7509. //
  7510. // //var dat map[string]interface{}
  7511. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7512. // // fmt.Println(dat)
  7513. // //} else {
  7514. // // fmt.Println(err)
  7515. // //}
  7516. //
  7517. // var dat2 map[string]interface{}
  7518. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  7519. // fmt.Println(dat2)
  7520. // } else {
  7521. // fmt.Println(err)
  7522. // }
  7523. //
  7524. // } else {
  7525. // adminUser := c.GetAdminUserInfo()
  7526. // errlog := &models.HisOrderError{
  7527. // UserOrgId: adminUser.CurrentOrgId,
  7528. // Ctime: time.Now().Unix(),
  7529. // Mtime: time.Now().Unix(),
  7530. // ErrMsg: res.ErrMsg,
  7531. // Status: 1,
  7532. // PatientId: id,
  7533. // RecordTime: recordDateTime,
  7534. // Stage: 1,
  7535. // }
  7536. // service.CreateErrMsgLog(errlog)
  7537. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  7538. // return
  7539. // }
  7540. // }
  7541. //
  7542. //}
  7543. //func (c *HisApiController) GetUploadDiag() {
  7544. // id, _ := c.GetInt64("id")
  7545. // record_time := c.GetString("record_time")
  7546. //
  7547. // diagnosis_id, _ := c.GetInt64("diagnosis")
  7548. // sick_type, _ := c.GetInt64("sick_type")
  7549. // reg_type, _ := c.GetInt64("reg_type")
  7550. //
  7551. // timeLayout := "2006-01-02"
  7552. // loc, _ := time.LoadLocation("Local")
  7553. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7554. // if err != nil {
  7555. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7556. // return
  7557. // }
  7558. //
  7559. // var patientPrescription models.HisPrescriptionInfo
  7560. // recordDateTime := theTime.Unix()
  7561. // adminInfo := c.GetAdminUserInfo()
  7562. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7563. //
  7564. // if patientPrescription.ID == 0 {
  7565. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7566. // }
  7567. //
  7568. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7569. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  7570. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7571. // sickConfig, _ := service.FindSickById(sick_type)
  7572. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7573. //
  7574. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  7575. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  7576. // "&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 +
  7577. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  7578. // resp2, requestErr2 := http.Get(api2)
  7579. // if requestErr2 != nil {
  7580. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7581. // return
  7582. // }
  7583. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7584. // if ioErr2 != nil {
  7585. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7586. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7587. // return
  7588. // }
  7589. // var respJSON2 map[string]interface{}
  7590. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7591. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7592. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7593. // return
  7594. // }
  7595. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7596. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7597. //
  7598. // var res2 ResultSix
  7599. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7600. // utils.ErrorLog("解析失败:%v", err)
  7601. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7602. // return
  7603. // }
  7604. // if res2.Infcode != 0 {
  7605. // adminUser := c.GetAdminUserInfo()
  7606. // errlog := &models.HisOrderError{
  7607. // UserOrgId: adminUser.CurrentOrgId,
  7608. // Ctime: time.Now().Unix(),
  7609. // Mtime: time.Now().Unix(),
  7610. // ErrMsg: res2.ErrMsg,
  7611. // Status: 1,
  7612. // PatientId: id,
  7613. // RecordTime: recordDateTime,
  7614. // Stage: 3,
  7615. // }
  7616. // service.CreateErrMsgLog(errlog)
  7617. //
  7618. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  7619. // return
  7620. // }
  7621. //
  7622. // c.ServeSuccessJSON(map[string]interface{}{
  7623. // "msg": "上传成功",
  7624. // })
  7625. //
  7626. //}
  7627. type QueryResult struct {
  7628. ID int64
  7629. Name string
  7630. Code string
  7631. List_type_code string
  7632. }
  7633. func (c *HisApiController) GetCheckCode() {
  7634. ids_str := c.GetString("ids")
  7635. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  7636. ids_arr := strings.Split(ids_str, ",")
  7637. var queryResult []QueryResult
  7638. ids := make([]int64, 0)
  7639. for _, item := range ids_arr {
  7640. id, _ := strconv.ParseInt(item, 10, 64)
  7641. ids = append(ids, id)
  7642. }
  7643. if record_type == 1 {
  7644. drugs, _ := service.GetBatchDrugList(ids)
  7645. for _, item := range drugs {
  7646. result := QueryResult{
  7647. ID: item.ID,
  7648. Name: item.DrugName,
  7649. Code: item.MedicalInsuranceNumber,
  7650. List_type_code: "101",
  7651. }
  7652. queryResult = append(queryResult, result)
  7653. }
  7654. } else if record_type == 2 {
  7655. goods, _ := service.GetBatchGoodInformationList(ids)
  7656. for _, item := range goods {
  7657. result := QueryResult{
  7658. ID: item.ID,
  7659. Name: item.GoodName,
  7660. Code: item.MedicalInsuranceNumber,
  7661. List_type_code: "301",
  7662. }
  7663. queryResult = append(queryResult, result)
  7664. }
  7665. } else if record_type == 3 {
  7666. projects, _ := service.GetBathchMyPorjecgList(ids)
  7667. for _, item := range projects {
  7668. result := QueryResult{
  7669. ID: item.ID,
  7670. Name: item.ProjectName,
  7671. Code: item.MedicalCode,
  7672. List_type_code: "201",
  7673. }
  7674. queryResult = append(queryResult, result)
  7675. }
  7676. }
  7677. admin_user_id, _ := c.GetInt64("admin_user_id")
  7678. adminUser := c.GetAdminUserInfo()
  7679. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7680. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7681. var user_name string
  7682. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7683. if role.ID == 0 {
  7684. user_name = "xxx"
  7685. } else {
  7686. user_name = role.UserName
  7687. }
  7688. baseParams := &models.BaseParams{
  7689. SecretKey: miConfig.SecretKey,
  7690. FixmedinsCode: miConfig.Code,
  7691. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7692. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7693. OrgName: miConfig.OrgName,
  7694. Doctor: user_name,
  7695. }
  7696. if config.IsOpen == 1 {
  7697. for _, item := range queryResult {
  7698. var result string
  7699. if record_type == 1 {
  7700. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7701. } else if record_type == 2 {
  7702. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7703. } else if record_type == 3 {
  7704. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7705. }
  7706. var dat map[string]interface{}
  7707. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7708. fmt.Println(dat)
  7709. } else {
  7710. fmt.Println(err)
  7711. }
  7712. userJSONBytes, _ := json.Marshal(dat)
  7713. var res ResultSix
  7714. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7715. utils.ErrorLog("解析失败:%v", err)
  7716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7717. return
  7718. }
  7719. if res.Infcode == 0 {
  7720. if record_type == 1 {
  7721. service.UpdateBaseDrugById(item.ID)
  7722. } else if record_type == 2 {
  7723. service.UpdateGoodInformaitonByDetail(item.ID)
  7724. } else if record_type == 3 {
  7725. service.UpdateProjectById(item.ID)
  7726. }
  7727. c.ServeSuccessJSON(map[string]interface{}{
  7728. "failed_code": 0,
  7729. "msg": "目录对照成功",
  7730. })
  7731. } else {
  7732. c.ServeSuccessJSON(map[string]interface{}{
  7733. "failed_code": -10,
  7734. "msg": res.ErrMsg,
  7735. })
  7736. }
  7737. }
  7738. }
  7739. }
  7740. func (c *HisApiController) UnCheckCode() {
  7741. ids_str := c.GetString("ids")
  7742. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  7743. admin_user_id, _ := c.GetInt64("admin_user_id")
  7744. ids_arr := strings.Split(ids_str, ",")
  7745. var queryResult []QueryResult
  7746. ids := make([]int64, 0)
  7747. for _, item := range ids_arr {
  7748. id, _ := strconv.ParseInt(item, 10, 64)
  7749. ids = append(ids, id)
  7750. }
  7751. if record_type == 1 {
  7752. drugs, _ := service.GetBatchDrugList(ids)
  7753. for _, item := range drugs {
  7754. result := QueryResult{
  7755. ID: item.ID,
  7756. Name: item.DrugName,
  7757. Code: item.MedicalInsuranceNumber,
  7758. List_type_code: "101",
  7759. }
  7760. queryResult = append(queryResult, result)
  7761. }
  7762. } else if record_type == 2 {
  7763. goods, _ := service.GetBatchGoodInformationList(ids)
  7764. for _, item := range goods {
  7765. result := QueryResult{
  7766. ID: item.ID,
  7767. Name: item.GoodName,
  7768. Code: item.MedicalInsuranceNumber,
  7769. List_type_code: "301",
  7770. }
  7771. queryResult = append(queryResult, result)
  7772. }
  7773. } else if record_type == 3 {
  7774. projects, _ := service.GetBathchMyPorjecgList(ids)
  7775. for _, item := range projects {
  7776. result := QueryResult{
  7777. ID: item.ID,
  7778. Name: item.ProjectName,
  7779. Code: item.MedicalCode,
  7780. List_type_code: "201",
  7781. }
  7782. queryResult = append(queryResult, result)
  7783. }
  7784. }
  7785. adminUser := c.GetAdminUserInfo()
  7786. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7787. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7788. var user_name string
  7789. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7790. if role.ID == 0 {
  7791. user_name = "xxx"
  7792. } else {
  7793. user_name = role.UserName
  7794. }
  7795. baseParams := &models.BaseParams{
  7796. SecretKey: miConfig.SecretKey,
  7797. FixmedinsCode: miConfig.Code,
  7798. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7799. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7800. OrgName: miConfig.OrgName,
  7801. Doctor: user_name,
  7802. }
  7803. if config.IsOpen == 1 {
  7804. for _, item := range queryResult {
  7805. var result string
  7806. if record_type == 1 {
  7807. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7808. } else if record_type == 2 {
  7809. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7810. } else if record_type == 3 {
  7811. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7812. }
  7813. var dat2 map[string]interface{}
  7814. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  7815. fmt.Println(dat2)
  7816. } else {
  7817. fmt.Println(err)
  7818. }
  7819. userJSONBytes, _ := json.Marshal(dat2)
  7820. var res ResultSix
  7821. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7822. utils.ErrorLog("解析失败:%v", err)
  7823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7824. return
  7825. }
  7826. if res.Infcode == 0 {
  7827. if record_type == 1 {
  7828. service.UpdateDrugByIdDetail(item.ID)
  7829. } else if record_type == 2 {
  7830. service.UpdateGoodInfoById(item.ID)
  7831. } else if record_type == 3 {
  7832. service.UpdateMyProjectById(item.ID)
  7833. }
  7834. c.ServeSuccessJSON(map[string]interface{}{
  7835. "failed_code": 0,
  7836. "msg": "撤销目录对照成功",
  7837. })
  7838. } else {
  7839. c.ServeSuccessJSON(map[string]interface{}{
  7840. "failed_code": -10,
  7841. "msg": res.ErrMsg,
  7842. })
  7843. }
  7844. }
  7845. }
  7846. }
  7847. func (c *HisApiController) GetPatientInfo() {
  7848. id_card_no := c.GetString("id_card_no")
  7849. admin_user_id, _ := c.GetInt64("admin_user_id")
  7850. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  7851. if patient.ID == 0 {
  7852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7853. return
  7854. }
  7855. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7856. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7857. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  7858. if config.IsOpen == 1 {
  7859. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7860. var dat map[string]interface{}
  7861. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7862. fmt.Println(dat)
  7863. } else {
  7864. fmt.Println(err)
  7865. }
  7866. userJSONBytes, _ := json.Marshal(dat)
  7867. var res ResultTwo
  7868. var res10265 ResultTwo10265
  7869. if miConfig.Code == "H15049901371" {
  7870. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7871. utils.ErrorLog("解析失败:%v", err)
  7872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7873. return
  7874. }
  7875. res.ErrMsg = res10265.ErrMsg
  7876. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7877. res.Infcode = infocode
  7878. res.Output = res10265.Output
  7879. res.InfRefmsgid = res10265.InfRefmsgid
  7880. } else {
  7881. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7882. utils.ErrorLog("解析失败:%v", err)
  7883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7884. return
  7885. }
  7886. }
  7887. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7888. // utils.ErrorLog("解析失败:%v", err)
  7889. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7890. // return
  7891. //}
  7892. if res.Infcode != 0 {
  7893. c.ServeSuccessJSON(map[string]interface{}{
  7894. "failed_code": -10,
  7895. "msg": res.ErrMsg,
  7896. })
  7897. } else {
  7898. c.ServeSuccessJSON(map[string]interface{}{
  7899. "failed_code": 0,
  7900. "info": res,
  7901. })
  7902. }
  7903. }
  7904. }
  7905. func (c *HisApiController) PsnPutOnRecord() {
  7906. record_type, _ := c.GetInt64("type")
  7907. patient_id, _ := c.GetInt64("patient_id")
  7908. admin_user_id, _ := c.GetInt64("admin_user_id")
  7909. start_time := c.GetString("start_time")
  7910. end_time := c.GetString("end_time")
  7911. adminUser := c.GetAdminUserInfo()
  7912. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7913. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7914. var patients []*models.Patients
  7915. if record_type == 1 { //全部备案
  7916. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  7917. patients = append(patients, patient...)
  7918. } else { //单个备案
  7919. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7920. patients = append(patients, patient)
  7921. }
  7922. var user_name string
  7923. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7924. if role.ID == 0 {
  7925. user_name = "xxx"
  7926. } else {
  7927. user_name = role.UserName
  7928. }
  7929. if config.IsOpen == 1 {
  7930. for _, item := range patients {
  7931. 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
  7932. resp, requestErr := http.Get(api)
  7933. if requestErr != nil {
  7934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7935. return
  7936. }
  7937. defer resp.Body.Close()
  7938. body, ioErr := ioutil.ReadAll(resp.Body)
  7939. if ioErr != nil {
  7940. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7942. return
  7943. }
  7944. var respJSON map[string]interface{}
  7945. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7948. return
  7949. }
  7950. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7951. userJSONBytes, _ := json.Marshal(userJSON)
  7952. var res ResultTwo
  7953. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7954. utils.ErrorLog("解析失败:%v", err)
  7955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7956. return
  7957. }
  7958. if res.Infcode == 0 {
  7959. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  7960. var dat map[string]interface{}
  7961. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7962. fmt.Println(dat)
  7963. } else {
  7964. fmt.Println(err)
  7965. }
  7966. userJSONBytes, _ := json.Marshal(dat)
  7967. var res2 ResultThirteen
  7968. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7969. utils.ErrorLog("解析失败:%v", err)
  7970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7971. return
  7972. }
  7973. if res2.Infcode == 0 {
  7974. psnResult := &models.GdybPsnRecord{
  7975. UserOrgId: adminUser.CurrentOrgId,
  7976. PatientId: item.ID,
  7977. PsnNo: res.Output.Baseinfo.PsnNo,
  7978. Ctime: time.Now().Unix(),
  7979. Mtime: time.Now().Unix(),
  7980. Status: 1,
  7981. IsCancel: 1,
  7982. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  7983. }
  7984. service.CreatePsnRecord(psnResult)
  7985. } else {
  7986. c.ServeSuccessJSON(map[string]interface{}{
  7987. "failed_code": -10,
  7988. "msg": res2.ErrMsg,
  7989. })
  7990. return
  7991. }
  7992. }
  7993. }
  7994. }
  7995. }
  7996. func (c *HisApiController) PsnUnPutOnRecord() {
  7997. id, _ := c.GetInt64("id")
  7998. //record_type, _ := c.GetInt64("type")
  7999. admin_user_id, _ := c.GetInt64("admin_user_id")
  8000. adminUser := c.GetAdminUserInfo()
  8001. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8002. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8003. var user_name string
  8004. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8005. if role.ID == 0 {
  8006. user_name = "xxx"
  8007. } else {
  8008. user_name = role.UserName
  8009. }
  8010. psn_record, _ := service.GetPsnRecordById(id)
  8011. if psn_record.ID == 0 {
  8012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8013. return
  8014. }
  8015. if config.IsOpen == 1 {
  8016. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8017. var dat map[string]interface{}
  8018. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8019. fmt.Println(dat)
  8020. } else {
  8021. fmt.Println(err)
  8022. }
  8023. userJSONBytes, _ := json.Marshal(dat)
  8024. var res ResultFourteen
  8025. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8026. utils.ErrorLog("解析失败:%v", err)
  8027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8028. return
  8029. }
  8030. if res.Infcode == 0 {
  8031. psn_record.IsCancel = 2
  8032. service.CreatePsnRecord(&psn_record)
  8033. } else {
  8034. c.ServeSuccessJSON(map[string]interface{}{
  8035. "failed_code": -10,
  8036. "msg": res.ErrMsg,
  8037. })
  8038. return
  8039. }
  8040. }
  8041. }
  8042. func (c *HisApiController) PsnPutNCDSOnRecord() {
  8043. patient_id, _ := c.GetInt64("patient_id")
  8044. insutype_two := c.GetString("insutype")
  8045. psn_no := c.GetString("psn_no")
  8046. doctor_id, _ := c.GetInt64("doctor_id")
  8047. sick_id, _ := c.GetInt64("sick_id")
  8048. department_id, _ := c.GetInt64("department_id")
  8049. start_time := c.GetString("start_time")
  8050. end_time := c.GetString("end_time")
  8051. check_time := c.GetString("check_time")
  8052. adminUser := c.GetAdminUserInfo()
  8053. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8054. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8055. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8056. sick, _ := service.FindSickById(sick_id)
  8057. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8058. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8059. var res ResultTwo
  8060. var res10265 ResultTwo10265
  8061. if miConfig.MdtrtareaAdmvs == "320921" {
  8062. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  8063. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  8064. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8065. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(3, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  8066. resp, requestErr := http.Get(api)
  8067. if requestErr != nil {
  8068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8069. return
  8070. }
  8071. body, ioErr := ioutil.ReadAll(resp.Body)
  8072. if ioErr != nil {
  8073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8075. return
  8076. }
  8077. var respJSON map[string]interface{}
  8078. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8081. return
  8082. }
  8083. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8084. result, _ := json.Marshal(respJSON)
  8085. fmt.Println("log")
  8086. fmt.Println(string(result))
  8087. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8088. utils.ErrorLog("解析失败:%v", err)
  8089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8090. return
  8091. }
  8092. res.ErrMsg = res10265.ErrMsg
  8093. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8094. res.Infcode = infocode
  8095. res.Output = res10265.Output
  8096. res.InfRefmsgid = res10265.InfRefmsgid
  8097. } else {
  8098. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8099. if miConfig.Code == "H15049901371" {
  8100. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8101. utils.ErrorLog("解析失败:%v", err)
  8102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8103. return
  8104. }
  8105. res.ErrMsg = res10265.ErrMsg
  8106. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8107. res.Infcode = infocode
  8108. res.Output = res10265.Output
  8109. res.InfRefmsgid = res10265.InfRefmsgid
  8110. } else {
  8111. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8112. utils.ErrorLog("解析失败:%v", err)
  8113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8114. return
  8115. }
  8116. }
  8117. }
  8118. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8119. infoStr := string(Iinfos)
  8120. var rf []*ResultFive
  8121. json.Unmarshal([]byte(infoStr), &rf)
  8122. var insuplc_admdvs string
  8123. var insutype string
  8124. var is390 int = 0
  8125. var is310 int = 0
  8126. var insutypes []*ResultFive
  8127. for _, item := range rf {
  8128. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8129. insutypes = append(insutypes, item)
  8130. }
  8131. }
  8132. if len(insutypes) == 1 {
  8133. insutype = insutypes[0].Insutype
  8134. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8135. } else {
  8136. for _, i := range insutypes {
  8137. if i.Insutype == "390" {
  8138. is390 = 1
  8139. }
  8140. if i.Insutype == "310" {
  8141. is310 = 1
  8142. }
  8143. }
  8144. }
  8145. if is390 == 1 {
  8146. insutype = "390"
  8147. }
  8148. if is310 == 1 {
  8149. insutype = "310"
  8150. }
  8151. if len(insutypes) == 2 {
  8152. insutype = insutype_two
  8153. }
  8154. if len(insutypes) == 0 {
  8155. insutype = "310"
  8156. }
  8157. insutype = insutype_two
  8158. fmt.Println(insutype)
  8159. for _, item := range rf {
  8160. fmt.Println(item.Insutype)
  8161. fmt.Println(insutype)
  8162. if item.Insutype == insutype {
  8163. fmt.Println(item.Insutype)
  8164. fmt.Println(insutype)
  8165. insuplc_admdvs = item.InsuplcAdmdvs
  8166. }
  8167. }
  8168. fmt.Println(insuplc_admdvs)
  8169. var res2 ResultThirteen
  8170. var res10265_2 ResultThirteen10265
  8171. if config.IsOpen == 1 {
  8172. if miConfig.MdtrtareaAdmvs == "320921" {
  8173. } else {
  8174. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time)
  8175. var dat map[string]interface{}
  8176. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8177. fmt.Println(dat)
  8178. } else {
  8179. fmt.Println(err)
  8180. }
  8181. userJSONBytes, _ := json.Marshal(dat)
  8182. if miConfig.Code == "H15049901371" {
  8183. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  8184. utils.ErrorLog("解析失败:%v", err)
  8185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8186. return
  8187. }
  8188. res2.ErrMsg = res10265_2.ErrMsg
  8189. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  8190. res2.Infcode = infocode
  8191. res2.Output = res10265_2.Output
  8192. res2.InfRefmsgid = res10265_2.InfRefmsgid
  8193. } else {
  8194. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8195. utils.ErrorLog("解析失败:%v", err)
  8196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8197. return
  8198. }
  8199. }
  8200. }
  8201. if res2.Infcode == 0 {
  8202. psnResult := &models.GdybPsnNcdsRecord{
  8203. UserOrgId: adminUser.CurrentOrgId,
  8204. PatientId: patient.ID,
  8205. PsnNo: psn_no,
  8206. DoctorId: doctor.AdminUserId,
  8207. DepartmentId: department_id,
  8208. SickType: sick_id,
  8209. Insutype: insutype,
  8210. Ctime: time.Now().Unix(),
  8211. Mtime: time.Now().Unix(),
  8212. Status: 1,
  8213. IsCancel: 1,
  8214. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8215. }
  8216. service.CreatePsnNCDSRecord(psnResult)
  8217. c.ServeSuccessJSON(map[string]interface{}{
  8218. "failed_code": 0,
  8219. "msg": "备案成功",
  8220. "result": psnResult,
  8221. })
  8222. } else {
  8223. c.ServeSuccessJSON(map[string]interface{}{
  8224. "failed_code": -10,
  8225. "msg": res2.ErrMsg,
  8226. })
  8227. return
  8228. }
  8229. }
  8230. }
  8231. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  8232. id, _ := c.GetInt64("id")
  8233. admin_user_id, _ := c.GetInt64("admin_user_id")
  8234. adminUser := c.GetAdminUserInfo()
  8235. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8236. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8237. //config, _ := service.Ge(adminUser.CurrentOrgId)
  8238. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  8239. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8240. //var user_name string
  8241. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8242. //if role.ID == 0 {
  8243. // user_name = "xxx"
  8244. //} else {
  8245. // user_name = role.UserName
  8246. //}
  8247. psn_record, _ := service.GetPsnNCDSRecordById(id)
  8248. if psn_record.ID == 0 {
  8249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8250. return
  8251. }
  8252. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8253. var res ResultTwo
  8254. var res10265 ResultTwo10265
  8255. if miConfig.Code == "H15049901371" {
  8256. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8257. utils.ErrorLog("解析失败:%v", err)
  8258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8259. return
  8260. }
  8261. res.ErrMsg = res10265.ErrMsg
  8262. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8263. res.Infcode = infocode
  8264. res.Output = res10265.Output
  8265. res.InfRefmsgid = res10265.InfRefmsgid
  8266. } else {
  8267. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8268. utils.ErrorLog("解析失败:%v", err)
  8269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8270. return
  8271. }
  8272. }
  8273. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8274. infoStr := string(Iinfos)
  8275. var rf []*ResultFive
  8276. json.Unmarshal([]byte(infoStr), &rf)
  8277. var insuplc_admdvs string
  8278. var insutype string
  8279. var is390 int = 0
  8280. var is310 int = 0
  8281. var insutypes []*ResultFive
  8282. for _, item := range rf {
  8283. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8284. insutypes = append(insutypes, item)
  8285. }
  8286. }
  8287. if len(insutypes) == 1 {
  8288. insutype = insutypes[0].Insutype
  8289. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8290. } else {
  8291. for _, i := range insutypes {
  8292. if i.Insutype == "390" {
  8293. is390 = 1
  8294. }
  8295. if i.Insutype == "310" {
  8296. is310 = 1
  8297. }
  8298. }
  8299. }
  8300. if is390 == 1 {
  8301. insutype = "390"
  8302. }
  8303. if is310 == 1 {
  8304. insutype = "310"
  8305. }
  8306. if len(insutypes) == 0 {
  8307. insutype = "310"
  8308. }
  8309. insutype = psn_record.Insutype
  8310. for _, item := range rf {
  8311. if item.Insutype == insutype {
  8312. insuplc_admdvs = item.InsuplcAdmdvs
  8313. }
  8314. }
  8315. if config.IsOpen == 1 {
  8316. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8317. var dat map[string]interface{}
  8318. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8319. fmt.Println(dat)
  8320. } else {
  8321. fmt.Println(err)
  8322. }
  8323. userJSONBytes, _ := json.Marshal(dat)
  8324. var res ResultFourteen
  8325. var res10265 ResultFourteen10265
  8326. if miConfig.Code == "H15049901371" {
  8327. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8328. utils.ErrorLog("解析失败:%v", err)
  8329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8330. return
  8331. }
  8332. res.ErrMsg = res10265.ErrMsg
  8333. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8334. res.Infcode = infocode
  8335. res.Output = res10265.Output
  8336. res.InfRefmsgid = res10265.InfRefmsgid
  8337. } else {
  8338. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8339. utils.ErrorLog("解析失败:%v", err)
  8340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8341. return
  8342. }
  8343. }
  8344. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8345. // utils.ErrorLog("解析失败:%v", err)
  8346. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8347. // return
  8348. //}
  8349. if res.Infcode == 0 {
  8350. psn_record.IsCancel = 2
  8351. service.CreatePsnNCDSRecord(&psn_record)
  8352. c.ServeSuccessJSON(map[string]interface{}{
  8353. "failed_code": 0,
  8354. "msg": "撤销备案成功",
  8355. })
  8356. } else {
  8357. c.ServeSuccessJSON(map[string]interface{}{
  8358. "failed_code": -10,
  8359. "msg": res.ErrMsg,
  8360. })
  8361. return
  8362. }
  8363. }
  8364. }
  8365. func (c *HisApiController) TestTest() {
  8366. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  8367. fmt.Println(patient.Iinfo)
  8368. }
  8369. type CustomData struct {
  8370. MsgId string
  8371. PsnNo string
  8372. Info string
  8373. }
  8374. func (c *HisApiController) ReversalData() {
  8375. var customData []*CustomData
  8376. custom := &CustomData{
  8377. MsgId: "H44022900158202103301714472004",
  8378. PsnNo: "44020000001101329945",
  8379. Info: "2207",
  8380. }
  8381. customData = append(customData, custom)
  8382. custom1 := &CustomData{
  8383. MsgId: "H4402290015820210330172057803",
  8384. PsnNo: "44020000001101161813",
  8385. Info: "2207",
  8386. }
  8387. customData = append(customData, custom1)
  8388. custom2 := &CustomData{
  8389. MsgId: "H44022900158202103301705198813",
  8390. PsnNo: "44190000133097375417",
  8391. Info: "2207",
  8392. }
  8393. customData = append(customData, custom2)
  8394. custom3 := &CustomData{
  8395. MsgId: "H44022900158202103301715524756",
  8396. PsnNo: "44020000001100187221",
  8397. Info: "2207",
  8398. }
  8399. customData = append(customData, custom3)
  8400. custom4 := &CustomData{
  8401. MsgId: "H44022900158202103301730376224",
  8402. PsnNo: "44020000001101959155",
  8403. Info: "2207",
  8404. }
  8405. customData = append(customData, custom4)
  8406. custom5 := &CustomData{
  8407. MsgId: "H44022900158202103301748008725",
  8408. PsnNo: "44020000001104246641",
  8409. Info: "2207",
  8410. }
  8411. customData = append(customData, custom5)
  8412. custom6 := &CustomData{
  8413. MsgId: "H44022900158202103301718096755",
  8414. PsnNo: "44020000001102211860",
  8415. Info: "2207",
  8416. }
  8417. customData = append(customData, custom6)
  8418. custom7 := &CustomData{
  8419. MsgId: "H44022900158202103301736551640",
  8420. PsnNo: "44020000001102687718",
  8421. Info: "2207",
  8422. }
  8423. customData = append(customData, custom7)
  8424. custom8 := &CustomData{
  8425. MsgId: "H44022900158202103301743097676",
  8426. PsnNo: "44020000001102127785",
  8427. Info: "2207",
  8428. }
  8429. customData = append(customData, custom8)
  8430. custom9 := &CustomData{
  8431. MsgId: "H44022900158202103301712304203",
  8432. PsnNo: "44020000001101518097",
  8433. Info: "2207",
  8434. }
  8435. customData = append(customData, custom9)
  8436. custom10 := &CustomData{
  8437. MsgId: "H44022900158202103301738448785",
  8438. PsnNo: "44020000001100500813",
  8439. Info: "2207",
  8440. }
  8441. customData = append(customData, custom10)
  8442. custom11 := &CustomData{
  8443. MsgId: "H44022900158202103301732455843",
  8444. PsnNo: "44020000001102690557",
  8445. Info: "2207",
  8446. }
  8447. customData = append(customData, custom11)
  8448. custom12 := &CustomData{
  8449. MsgId: "H44022900158202103301745421708",
  8450. PsnNo: "44020000001102211928",
  8451. Info: "2207",
  8452. }
  8453. customData = append(customData, custom12)
  8454. custom1212 := &CustomData{
  8455. MsgId: "H440229001582021033017351627",
  8456. PsnNo: "44020000001102481733",
  8457. Info: "2207",
  8458. }
  8459. customData = append(customData, custom1212)
  8460. custom13 := &CustomData{
  8461. MsgId: "H44022900158202103301740327951",
  8462. PsnNo: "44020000001103174866",
  8463. Info: "2207",
  8464. }
  8465. customData = append(customData, custom13)
  8466. custom14 := &CustomData{
  8467. MsgId: "H4402290015820210330174922668",
  8468. PsnNo: "44020000001102927272",
  8469. Info: "2207",
  8470. }
  8471. customData = append(customData, custom14)
  8472. custom15 := &CustomData{
  8473. MsgId: "H44022900158202103301752362273",
  8474. PsnNo: "44020000001102942890",
  8475. Info: "2207",
  8476. }
  8477. customData = append(customData, custom15)
  8478. custom16 := &CustomData{
  8479. MsgId: "H44022900158202103301751082917",
  8480. PsnNo: "44020000001101662162",
  8481. Info: "2207",
  8482. }
  8483. customData = append(customData, custom16)
  8484. custom17 := &CustomData{
  8485. MsgId: "H44022900158202103301754147728",
  8486. PsnNo: "44020000000229014511",
  8487. Info: "2207",
  8488. }
  8489. customData = append(customData, custom17)
  8490. adminUser := c.GetAdminUserInfo()
  8491. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8492. for _, item := range customData {
  8493. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8494. fmt.Println(result)
  8495. }
  8496. }
  8497. func (c *HisApiController) GetAllopatry() {
  8498. year := c.GetString("year")
  8499. month := c.GetString("month")
  8500. admin_user_id, _ := c.GetInt64("admin_user_id")
  8501. adminUser := c.GetAdminUserInfo()
  8502. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8503. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8504. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  8505. var dat map[string]interface{}
  8506. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8507. fmt.Println(dat)
  8508. } else {
  8509. fmt.Println(err)
  8510. }
  8511. userJSONBytes, _ := json.Marshal(dat)
  8512. var res models.Result9001
  8513. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8514. utils.ErrorLog("解析失败:%v", err)
  8515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8516. return
  8517. }
  8518. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  8519. var dat2 map[string]interface{}
  8520. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8521. fmt.Println(dat)
  8522. } else {
  8523. fmt.Println(err)
  8524. }
  8525. userJSONBytes2, _ := json.Marshal(dat2)
  8526. var res2 models.Result3260
  8527. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8528. utils.ErrorLog("解析失败:%v", err)
  8529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8530. return
  8531. }
  8532. if res2.Infcode == 0 {
  8533. c.ServeSuccessJSON(map[string]interface{}{
  8534. "list": res2.Output.Data,
  8535. })
  8536. return
  8537. } else {
  8538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8539. return
  8540. }
  8541. }
  8542. func (c *HisApiController) ComfirmAllopatry() {
  8543. year := c.GetString("year")
  8544. month := c.GetString("month")
  8545. admin_user_id, _ := c.GetInt64("admin_user_id")
  8546. adminUser := c.GetAdminUserInfo()
  8547. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8548. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8549. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  8550. var dat map[string]interface{}
  8551. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8552. fmt.Println(dat)
  8553. } else {
  8554. fmt.Println(err)
  8555. }
  8556. userJSONBytes, _ := json.Marshal(dat)
  8557. var res models.Result9001
  8558. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8559. utils.ErrorLog("解析失败:%v", err)
  8560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8561. return
  8562. }
  8563. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  8564. var dat2 map[string]interface{}
  8565. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8566. fmt.Println(dat)
  8567. } else {
  8568. fmt.Println(err)
  8569. }
  8570. userJSONBytes2, _ := json.Marshal(dat2)
  8571. var res2 models.Result3260
  8572. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8573. utils.ErrorLog("解析失败:%v", err)
  8574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8575. return
  8576. }
  8577. if res2.Infcode == 0 {
  8578. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  8579. var dat map[string]interface{}
  8580. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8581. fmt.Println(dat)
  8582. } else {
  8583. fmt.Println(err)
  8584. }
  8585. userJSONBytes, _ := json.Marshal(dat)
  8586. var res3 models.Result3261
  8587. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  8588. utils.ErrorLog("解析失败:%v", err)
  8589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8590. return
  8591. }
  8592. if res3.Infcode == 0 {
  8593. record := &models.HisYidiClearRecord{
  8594. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8595. Ctime: time.Now().Unix(),
  8596. Mtime: time.Now().Unix(),
  8597. Status: 1,
  8598. MsgId: msgId,
  8599. }
  8600. service.SaveClearRecord(record)
  8601. c.ServeSuccessJSON(map[string]interface{}{
  8602. "msg": "提取成功",
  8603. })
  8604. }
  8605. }
  8606. }
  8607. func (c *HisApiController) RefundAllopatry() {
  8608. year := c.GetString("year")
  8609. month := c.GetString("month")
  8610. id, _ := c.GetInt64("id")
  8611. admin_user_id, _ := c.GetInt64("admin_user_id")
  8612. adminUser := c.GetAdminUserInfo()
  8613. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8614. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8615. record, _ := service.GetClearRecordById(id)
  8616. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  8617. var dat map[string]interface{}
  8618. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8619. fmt.Println(dat)
  8620. } else {
  8621. fmt.Println(err)
  8622. }
  8623. userJSONBytes, _ := json.Marshal(dat)
  8624. var empty ResultFourteen
  8625. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  8626. utils.ErrorLog("解析失败:%v", err)
  8627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8628. return
  8629. }
  8630. if empty.Infcode == 0 {
  8631. c.ServeSuccessJSON(map[string]interface{}{
  8632. "msg": "撤销成功",
  8633. })
  8634. return
  8635. }
  8636. }
  8637. func (c *HisApiController) ReversalOtherData() {
  8638. var customData []*CustomData
  8639. custom := &CustomData{
  8640. MsgId: "H44022900158202103301714472004",
  8641. PsnNo: "44020000001101329945",
  8642. Info: "2208",
  8643. }
  8644. customData = append(customData, custom)
  8645. custom1 := &CustomData{
  8646. MsgId: "H4402290015820210330172057803",
  8647. PsnNo: "44020000001101161813",
  8648. Info: "2208",
  8649. }
  8650. customData = append(customData, custom1)
  8651. custom2 := &CustomData{
  8652. MsgId: "H44022900158202103301705198813",
  8653. PsnNo: "44190000133097375417",
  8654. Info: "2208",
  8655. }
  8656. customData = append(customData, custom2)
  8657. custom3 := &CustomData{
  8658. MsgId: "H44022900158202103301715524756",
  8659. PsnNo: "44020000001100187221",
  8660. Info: "2208",
  8661. }
  8662. customData = append(customData, custom3)
  8663. custom4 := &CustomData{
  8664. MsgId: "H44022900158202103301730376224",
  8665. PsnNo: "44020000001101959155",
  8666. Info: "2208",
  8667. }
  8668. customData = append(customData, custom4)
  8669. custom5 := &CustomData{
  8670. MsgId: "H44022900158202103301748008725",
  8671. PsnNo: "44020000001104246641",
  8672. Info: "2208",
  8673. }
  8674. customData = append(customData, custom5)
  8675. custom6 := &CustomData{
  8676. MsgId: "H44022900158202103301718096755",
  8677. PsnNo: "44020000001102211860",
  8678. Info: "2208",
  8679. }
  8680. customData = append(customData, custom6)
  8681. custom7 := &CustomData{
  8682. MsgId: "H44022900158202103301736551640",
  8683. PsnNo: "44020000001102687718",
  8684. Info: "2208",
  8685. }
  8686. customData = append(customData, custom7)
  8687. custom8 := &CustomData{
  8688. MsgId: "H44022900158202103301743097676",
  8689. PsnNo: "44020000001102127785",
  8690. Info: "2208",
  8691. }
  8692. customData = append(customData, custom8)
  8693. custom9 := &CustomData{
  8694. MsgId: "H44022900158202103301712304203",
  8695. PsnNo: "44020000001101518097",
  8696. Info: "2208",
  8697. }
  8698. customData = append(customData, custom9)
  8699. custom10 := &CustomData{
  8700. MsgId: "H44022900158202103301738448785",
  8701. PsnNo: "44020000001100500813",
  8702. Info: "2208",
  8703. }
  8704. customData = append(customData, custom10)
  8705. custom11 := &CustomData{
  8706. MsgId: "H44022900158202103301732455843",
  8707. PsnNo: "44020000001102690557",
  8708. Info: "2208",
  8709. }
  8710. customData = append(customData, custom11)
  8711. custom12 := &CustomData{
  8712. MsgId: "H44022900158202103301745421708",
  8713. PsnNo: "44020000001102211928",
  8714. Info: "2208",
  8715. }
  8716. customData = append(customData, custom12)
  8717. custom1212 := &CustomData{
  8718. MsgId: "H440229001582021033017351627",
  8719. PsnNo: "44020000001102481733",
  8720. Info: "2208",
  8721. }
  8722. customData = append(customData, custom1212)
  8723. custom13 := &CustomData{
  8724. MsgId: "H44022900158202103301740327951",
  8725. PsnNo: "44020000001103174866",
  8726. Info: "2208",
  8727. }
  8728. customData = append(customData, custom13)
  8729. custom14 := &CustomData{
  8730. MsgId: "H4402290015820210330174922668",
  8731. PsnNo: "44020000001102927272",
  8732. Info: "2208",
  8733. }
  8734. customData = append(customData, custom14)
  8735. custom15 := &CustomData{
  8736. MsgId: "H44022900158202103301752362273",
  8737. PsnNo: "44020000001102942890",
  8738. Info: "2208",
  8739. }
  8740. customData = append(customData, custom15)
  8741. custom16 := &CustomData{
  8742. MsgId: "H44022900158202103301751082917",
  8743. PsnNo: "44020000001101662162",
  8744. Info: "2208",
  8745. }
  8746. customData = append(customData, custom16)
  8747. custom17 := &CustomData{
  8748. MsgId: "H44022900158202103301754147728",
  8749. PsnNo: "44020000000229014511",
  8750. Info: "2208",
  8751. }
  8752. customData = append(customData, custom17)
  8753. adminUser := c.GetAdminUserInfo()
  8754. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8755. for _, item := range customData {
  8756. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8757. fmt.Println(result)
  8758. }
  8759. }
  8760. func PathExists(path string) (bool, error) {
  8761. _, err := os.Stat(path)
  8762. if err == nil {
  8763. return true, nil
  8764. }
  8765. if os.IsNotExist(err) {
  8766. return false, nil
  8767. }
  8768. return false, err
  8769. }
  8770. //创建文件夹
  8771. func Mkdir(dir string) {
  8772. // 创建文件夹
  8773. exist, err := PathExists(dir)
  8774. if err != nil {
  8775. fmt.Println(err.Error())
  8776. } else {
  8777. if exist {
  8778. fmt.Println(dir + "文件夹已存在!")
  8779. } else {
  8780. // 文件夹名称,权限
  8781. err := os.Mkdir(dir, os.ModePerm)
  8782. if err != nil {
  8783. fmt.Println(dir+"文件夹创建失败:", err.Error())
  8784. } else {
  8785. fmt.Println(dir + "文件夹创建成功!")
  8786. }
  8787. }
  8788. }
  8789. }
  8790. //压缩文件
  8791. func Zip(srcFile string, destZip string) error {
  8792. zipfile, err := os.Create(destZip)
  8793. if err != nil {
  8794. return err
  8795. }
  8796. defer zipfile.Close()
  8797. archive := zip.NewWriter(zipfile)
  8798. defer archive.Close()
  8799. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  8800. if err != nil {
  8801. return err
  8802. }
  8803. header, err := zip.FileInfoHeader(info)
  8804. if err != nil {
  8805. return err
  8806. }
  8807. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  8808. // header.Name = path
  8809. if info.IsDir() {
  8810. header.Name += "/"
  8811. } else {
  8812. header.Method = zip.Deflate
  8813. }
  8814. writer, err := archive.CreateHeader(header)
  8815. if err != nil {
  8816. return err
  8817. }
  8818. if !info.IsDir() {
  8819. file, err := os.Open(path)
  8820. if err != nil {
  8821. return err
  8822. }
  8823. defer file.Close()
  8824. _, err = io.Copy(writer, file)
  8825. }
  8826. return err
  8827. })
  8828. return err
  8829. }
  8830. func ReadFile(filePath string) []byte {
  8831. f, err := os.Open(filePath)
  8832. if err != nil {
  8833. fmt.Println("read file fail", err)
  8834. return nil
  8835. }
  8836. defer f.Close()
  8837. fd, err := ioutil.ReadAll(f)
  8838. if err != nil {
  8839. fmt.Println("read to fd fail", err)
  8840. return nil
  8841. }
  8842. return fd
  8843. }
  8844. func saveLog(result string, request string, infno string, desc string) {
  8845. org_id, _ := beego.AppConfig.Int64("org_id")
  8846. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  8847. dir := miConfig.OrgName + "日志"
  8848. utils.Mkdir(dir)
  8849. month := time.Unix(1557042972, 0).Format("1")
  8850. year := time.Now().Format("2006")
  8851. month = time.Now().Format("01")
  8852. day := time.Now().Format("02")
  8853. hour := time.Now().Format("15")
  8854. min := time.Now().Format("04")
  8855. sec := time.Now().Format("05")
  8856. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  8857. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  8858. file_name := file + ".txt"
  8859. file_path := miConfig.OrgName + "日志" + "/" + file_name
  8860. exist, _ := utils.PathExists(file_path)
  8861. if exist { //存在
  8862. fmt.Println("存在")
  8863. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  8864. if err != nil {
  8865. fmt.Println("read fail")
  8866. }
  8867. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  8868. n, _ := f.Seek(0, 2)
  8869. _, err = f.WriteAt([]byte(content), n)
  8870. } else { //不存在
  8871. fmt.Println("文件不存在,创建文件")
  8872. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  8873. defer f.Close()
  8874. if err != nil {
  8875. } else {
  8876. _, err = f.Write([]byte("记录日志"))
  8877. }
  8878. }
  8879. }
  8880. type Charset string
  8881. const (
  8882. UTF8 = Charset("UTF-8")
  8883. GB18030 = Charset("GB18030")
  8884. )
  8885. func ConvertToString(src string, srcCode string, tagCode string) string {
  8886. srcCoder := mahonia.NewDecoder(srcCode)
  8887. srcResult := srcCoder.ConvertString(src)
  8888. tagCoder := mahonia.NewDecoder(tagCode)
  8889. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  8890. result := string(cdata)
  8891. return result
  8892. }