his_api_controller.go 348KB

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