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