his_api_controller.go 349KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690
  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. // }
  3182. //} else if his.Insutype == "390" {
  3183. // if reg_type == 14 {
  3184. // med_type = "1402"
  3185. // } else if reg_type == 11 {
  3186. // med_type = "11"
  3187. // }
  3188. //}
  3189. data := make(map[string]interface{})
  3190. client := &http.Client{}
  3191. data["psn_no"] = his.PsnNo
  3192. data["mdtrt_id"] = his.Number
  3193. data["doctor"] = roles.UserName
  3194. data["department"] = department.Name
  3195. data["org_name"] = miConfig.OrgName
  3196. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3197. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3198. data["fixmedins_code"] = miConfig.Code
  3199. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3200. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3201. data["secret_key"] = miConfig.SecretKey
  3202. data["sick_code"] = sickConfig.CountryCode
  3203. data["sick_name"] = sickConfig.ClassName
  3204. data["url"] = miConfig.Url
  3205. data["ak"] = miConfig.ChannelNumber
  3206. data["begin_time"] = begin_time
  3207. data["dept"] = strconv.FormatInt(department.ID, 10)
  3208. data["config"] = config
  3209. bytesData, _ := json.Marshal(data)
  3210. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3211. resp, _ := client.Do(req)
  3212. defer resp.Body.Close()
  3213. body, ioErr := ioutil.ReadAll(resp.Body)
  3214. if ioErr != nil {
  3215. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3217. return
  3218. }
  3219. var respJSON map[string]interface{}
  3220. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3223. return
  3224. }
  3225. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3226. userJSONBytes, _ := json.Marshal(respJSON)
  3227. fmt.Println("log")
  3228. fmt.Println(string(userJSONBytes))
  3229. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  3230. utils.ErrorLog("解析失败:%v", err)
  3231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3232. return
  3233. }
  3234. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3235. res2.Output = ressix10265.Output
  3236. res2.ErrMsg = ressix10265.ErrMsg
  3237. res2.Cainfo = ressix10265.Cainfo
  3238. res2.WarnMsg = ressix10265.WarnMsg
  3239. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3240. res2.Infcode = infocode
  3241. } else {
  3242. if miConfig.MdtrtareaAdmvs == "440781" { //
  3243. 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)
  3244. } else {
  3245. if miConfig.Code == "H15049901371" {
  3246. //赤峰地区国家医保医疗类别
  3247. //职工透析:医疗类别选特殊情况门诊990502
  3248. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3249. var med_type string
  3250. if his.Insutype == "390" {
  3251. if reg_type == 14 {
  3252. med_type = "9933"
  3253. } else if reg_type == 11 {
  3254. med_type = "11"
  3255. }
  3256. } else if his.Insutype == "310" {
  3257. if reg_type == 14 {
  3258. med_type = "990502"
  3259. } else if reg_type == 11 {
  3260. med_type = "11"
  3261. }
  3262. }
  3263. 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)
  3264. } else {
  3265. 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)
  3266. }
  3267. }
  3268. saveLog(result, requestLog, "2203", "上传就诊信息")
  3269. var respJSON2 map[string]interface{}
  3270. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3273. return
  3274. }
  3275. userJSONBytes2, _ := json.Marshal(respJSON2)
  3276. if miConfig.Code == "H15049901371" {
  3277. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  3278. utils.ErrorLog("解析失败:%v", err)
  3279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3280. return
  3281. }
  3282. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3283. res2.Output = ressix10265.Output
  3284. res2.ErrMsg = ressix10265.ErrMsg
  3285. res2.Cainfo = ressix10265.Cainfo
  3286. res2.WarnMsg = ressix10265.WarnMsg
  3287. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3288. res2.Infcode = infocode
  3289. } else {
  3290. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3291. utils.ErrorLog("解析失败:%v", err)
  3292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3293. return
  3294. }
  3295. }
  3296. }
  3297. if res2.Infcode != 0 {
  3298. adminUser := c.GetAdminUserInfo()
  3299. errlog := &models.HisOrderError{
  3300. UserOrgId: adminUser.CurrentOrgId,
  3301. Ctime: time.Now().Unix(),
  3302. Mtime: time.Now().Unix(),
  3303. ErrMsg: res2.ErrMsg,
  3304. Status: 1,
  3305. PatientId: id,
  3306. RecordTime: recordDateTime,
  3307. Stage: 3,
  3308. }
  3309. service.CreateErrMsgLog(errlog)
  3310. c.ServeSuccessJSON(map[string]interface{}{
  3311. "failed_code": -10,
  3312. "msg": res2.ErrMsg,
  3313. })
  3314. return
  3315. } else {
  3316. his.Diagnosis = diagnosis_id
  3317. his.SickType = sickConfig.ID
  3318. var p_type int64
  3319. if reg_type == 1111 || reg_type == 1112 {
  3320. p_type = 11
  3321. }
  3322. his.PType = fmt.Sprintf("%d", p_type)
  3323. service.UpdateHisPatientThree(&his)
  3324. data := make(map[string]interface{})
  3325. if settle_accounts_type == 1 { //日结
  3326. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  3327. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  3328. } else {
  3329. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  3330. }
  3331. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  3332. data["pre"] = prescriptions
  3333. } else { //月结
  3334. start_time_str := c.GetString("start_time")
  3335. end_time_str := c.GetString("end_time")
  3336. timeLayout := "2006-01-02"
  3337. loc, _ := time.LoadLocation("Local")
  3338. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3339. if err != nil {
  3340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3341. return
  3342. }
  3343. recordStartTime := theStartTime.Unix()
  3344. start_time = recordStartTime
  3345. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3346. if err != nil {
  3347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3348. return
  3349. }
  3350. recordEndTime := theEndTime.Unix()
  3351. end_time = recordEndTime
  3352. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3353. data["pre"] = prescriptions
  3354. }
  3355. timestamp := time.Now().Unix()
  3356. tempTime := time.Unix(timestamp, 0)
  3357. timeFormat := tempTime.Format("20060102150405")
  3358. chrgBchno := rand.Intn(100000) + 10000
  3359. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3360. strconv.FormatInt(his.PatientId, 10)
  3361. client := &http.Client{}
  3362. data["psn_no"] = his.PsnNo
  3363. data["mdtrt_id"] = his.Number
  3364. data["chrg_bchno"] = chrg_bchno
  3365. data["org_name"] = miConfig.OrgName
  3366. data["doctor"] = roles.UserName
  3367. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3368. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3369. data["fixmedins_code"] = miConfig.Code
  3370. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3371. data["dept_code"] = "15"
  3372. } else {
  3373. data["dept_code"] = department.Number
  3374. }
  3375. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3376. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3377. data["secret_key"] = miConfig.SecretKey
  3378. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3379. data["url"] = miConfig.Url
  3380. data["ak"] = miConfig.ChannelNumber
  3381. data["new_doctor_name"] = patientPrescription.Doctor
  3382. data["diag_code"] = sickConfig.CountryCode
  3383. var ids []int64
  3384. for _, item := range prescriptions {
  3385. ids = append(ids, item.ID)
  3386. }
  3387. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3388. if config.IsOpen == 1 { //对接了医保,走医保流程
  3389. var res ResultFour
  3390. var resFour10265 ResultFour10265
  3391. if miConfig.MdtrtareaAdmvs == "421300" {
  3392. bytesData, _ := json.Marshal(data)
  3393. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3394. resp, _ := client.Do(req)
  3395. defer resp.Body.Close()
  3396. body, ioErr := ioutil.ReadAll(resp.Body)
  3397. if ioErr != nil {
  3398. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3400. return
  3401. }
  3402. var respJSON map[string]interface{}
  3403. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3406. return
  3407. }
  3408. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3409. userJSONBytes, _ := json.Marshal(respJSON)
  3410. fmt.Println("log")
  3411. fmt.Println(string(userJSONBytes))
  3412. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3413. utils.ErrorLog("解析失败:%v", err)
  3414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3415. return
  3416. }
  3417. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3418. bytesData, _ := json.Marshal(data)
  3419. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  3420. resp, _ := client.Do(req)
  3421. defer resp.Body.Close()
  3422. body, ioErr := ioutil.ReadAll(resp.Body)
  3423. if ioErr != nil {
  3424. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3426. return
  3427. }
  3428. var respJSON map[string]interface{}
  3429. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3432. return
  3433. }
  3434. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3435. userJSONBytes, _ := json.Marshal(respJSON)
  3436. fmt.Println("log")
  3437. fmt.Println(string(userJSONBytes))
  3438. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3439. utils.ErrorLog("解析失败:%v", err)
  3440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3441. return
  3442. }
  3443. res.InfRefmsgid = resFour10265.InfRefmsgid
  3444. res.Output = resFour10265.Output
  3445. res.ErrMsg = resFour10265.ErrMsg
  3446. res.Cainfo = resFour10265.Cainfo
  3447. res.WarnMsg = resFour10265.WarnMsg
  3448. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3449. res.Infcode = infocode
  3450. } else {
  3451. if miConfig.Code == "H15049901371" {
  3452. 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)
  3453. var dat map[string]interface{}
  3454. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3455. fmt.Println(dat)
  3456. } else {
  3457. fmt.Println(err)
  3458. }
  3459. saveLog(result, request_log, "2204", "上传费用明细")
  3460. userJSONBytes, _ := json.Marshal(dat)
  3461. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3462. utils.ErrorLog("解析失败:%v", err)
  3463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3464. return
  3465. }
  3466. res.InfRefmsgid = resFour10265.InfRefmsgid
  3467. res.Output = resFour10265.Output
  3468. res.ErrMsg = resFour10265.ErrMsg
  3469. res.Cainfo = resFour10265.Cainfo
  3470. res.WarnMsg = resFour10265.WarnMsg
  3471. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3472. res.Infcode = infocode
  3473. } else {
  3474. 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)
  3475. var dat map[string]interface{}
  3476. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3477. fmt.Println(dat)
  3478. } else {
  3479. fmt.Println(err)
  3480. }
  3481. saveLog(result, request_log, "2204", "上传费用明细")
  3482. userJSONBytes, _ := json.Marshal(dat)
  3483. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3484. utils.ErrorLog("解析失败:%v", err)
  3485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3486. return
  3487. }
  3488. }
  3489. }
  3490. if res.Infcode == 0 {
  3491. order := &models.HisOrder{
  3492. UserOrgId: adminUser.CurrentOrgId,
  3493. HisPatientId: his.ID,
  3494. PatientId: his.PatientId,
  3495. SettleAccountsDate: recordDateTime,
  3496. Ctime: time.Now().Unix(),
  3497. Mtime: time.Now().Unix(),
  3498. Status: 1,
  3499. Number: chrg_bchno,
  3500. Infcode: res.Infcode,
  3501. WarnMsg: res.WarnMsg,
  3502. Cainfo: res.Cainfo,
  3503. ErrMsg: res.ErrMsg,
  3504. RespondTime: res.RefmsgTime,
  3505. InfRefmsgid: res.InfRefmsgid,
  3506. OrderStatus: 1,
  3507. PayWay: pay_way,
  3508. PayPrice: pay_price,
  3509. PayCardNo: pay_card_no,
  3510. DiscountPrice: discount_price,
  3511. PreferentialPrice: preferential_price,
  3512. RealityPrice: reality_price,
  3513. FoundPrice: found_price,
  3514. MedicalInsurancePrice: medical_insurance_price,
  3515. PrivatePrice: private_price,
  3516. IsMedicineInsurance: 1,
  3517. SettleType: settle_accounts_type,
  3518. SettleStartTime: start_time,
  3519. SettleEndTime: end_time,
  3520. Creator: roles.AdminUserId,
  3521. Modify: roles.AdminUserId,
  3522. FaPiaoNumber: fapiao_number,
  3523. FaPiaoCode: fapiao_code,
  3524. PType: 2,
  3525. Diagnosis: diagnosis_id,
  3526. }
  3527. err = service.CreateOrder(order)
  3528. if err != nil {
  3529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3530. return
  3531. }
  3532. for _, item := range res.Output.Result {
  3533. temp := strings.Split(item.FeedetlSn, "-")
  3534. var advice_id int64 = 0
  3535. var project_id int64 = 0
  3536. var types int64 = 0
  3537. id, _ := strconv.ParseInt(temp[2], 10, 64)
  3538. types, _ = strconv.ParseInt(temp[1], 10, 64)
  3539. if temp[1] == "1" {
  3540. advice_id = id
  3541. project_id = 0
  3542. } else if temp[1] == "2" {
  3543. advice_id = 0
  3544. project_id = id
  3545. }
  3546. info := &models.HisOrderInfo{
  3547. OrderNumber: order.Number,
  3548. FeedetlSn: item.FeedetlSn,
  3549. UploadDate: time.Now().Unix(),
  3550. AdviceId: advice_id,
  3551. DetItemFeeSumamt: item.DetItemFeeSumamt,
  3552. Cnt: item.Cnt,
  3553. Pric: float64(item.Pric),
  3554. PatientId: his.PatientId,
  3555. PricUplmtAmt: item.PricUplmtAmt,
  3556. SelfpayProp: item.SelfpayProp,
  3557. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3558. OverlmtAmt: item.OverlmtAmt,
  3559. PreselfpayAmt: item.PreselfpayAmt,
  3560. BasMednFlag: item.BasMednFlag,
  3561. MedChrgitmType: item.MedChrgitmType,
  3562. HiNegoDrugFlag: item.HiNegoDrugFlag,
  3563. Status: 1,
  3564. Memo: item.Memo,
  3565. Mtime: time.Now().Unix(),
  3566. InscpScpAmt: item.InscpScpAmt,
  3567. DrtReimFlag: item.DrtReimFlag,
  3568. Ctime: time.Now().Unix(),
  3569. ListSpItemFlag: item.ListSpItemFlag,
  3570. ChldMedcFlag: item.ChldMedcFlag,
  3571. LmtUsedFlag: item.LmtUsedFlag,
  3572. ChrgitmLv: item.ChrgitmLv,
  3573. UserOrgId: adminUser.CurrentOrgId,
  3574. HisPatientId: his.ID,
  3575. OrderId: order.ID,
  3576. ProjectId: project_id,
  3577. Type: types,
  3578. }
  3579. service.CreateOrderInfo(info)
  3580. }
  3581. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3582. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  3583. var total float64
  3584. for _, item := range prescriptions {
  3585. if item.Type == 1 { //药品
  3586. for _, subItem := range item.HisDoctorAdviceInfo {
  3587. total = total + (subItem.Price * subItem.PrescribingNumber)
  3588. }
  3589. }
  3590. if item.Type == 2 { //项目
  3591. for _, subItem := range item.HisPrescriptionProject {
  3592. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3593. total = total + (subItem.Price * cnt)
  3594. }
  3595. }
  3596. }
  3597. for _, item := range prescriptions {
  3598. for _, subItem := range item.HisAdditionalCharge {
  3599. total = total + (subItem.Price * float64(subItem.Count))
  3600. }
  3601. }
  3602. var allTotal string
  3603. if adminUser.CurrentOrgId == 9919 {
  3604. allTotal = fmt.Sprintf("%.4f", total)
  3605. } else {
  3606. allTotal = fmt.Sprintf("%.4f", total)
  3607. }
  3608. if res.Infcode == 0 {
  3609. var rf []*ResultFive
  3610. json.Unmarshal([]byte(his.Iinfo), &rf)
  3611. chrg_bchno := chrg_bchno
  3612. cert_no := his.Certno
  3613. var insutypes []string
  3614. var insutype string
  3615. var is390 int = 0
  3616. var is310 int = 0
  3617. for _, item := range rf {
  3618. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3619. insutypes = append(insutypes, item.Insutype)
  3620. }
  3621. }
  3622. if len(insutypes) == 1 {
  3623. insutype = insutypes[0]
  3624. } else {
  3625. for _, i := range insutypes {
  3626. if i == "390" {
  3627. is390 = 1
  3628. }
  3629. if i == "310" {
  3630. is310 = 1
  3631. }
  3632. }
  3633. }
  3634. if is390 == 1 {
  3635. insutype = "390"
  3636. }
  3637. if is310 == 1 {
  3638. insutype = "310"
  3639. }
  3640. if len(insutypes) == 0 {
  3641. insutype = "310"
  3642. }
  3643. if len(insutypes) == 2 {
  3644. insutype = strconv.FormatInt(his.SocialType, 10)
  3645. }
  3646. insutype = strconv.FormatInt(his.SocialType, 10)
  3647. //insutype = "390"
  3648. if his.IdCardType == 1 {
  3649. // cert_no = his.MedicalInsuranceNumber
  3650. cert_no = his.Certno
  3651. } else {
  3652. cert_no = his.Certno
  3653. }
  3654. var res ResultSeven
  3655. var resSeven10265 ResultSeven10265
  3656. var src_resquest string
  3657. var result2 string
  3658. var acct_used_flag string
  3659. fmt.Println("pay_way")
  3660. fmt.Println(pay_way)
  3661. fmt.Println("pay_way")
  3662. if pay_way == 4 {
  3663. acct_used_flag = "1"
  3664. } else {
  3665. acct_used_flag = "0"
  3666. }
  3667. if miConfig.MdtrtareaAdmvs == "421300" {
  3668. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3669. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3670. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3671. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3672. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3673. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3674. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3675. resp, requestErr := http.Get(api)
  3676. if requestErr != nil {
  3677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3678. return
  3679. }
  3680. body, ioErr := ioutil.ReadAll(resp.Body)
  3681. if ioErr != nil {
  3682. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3684. return
  3685. }
  3686. var respJSON map[string]interface{}
  3687. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3688. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3690. return
  3691. }
  3692. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3693. result, _ := json.Marshal(respJSON)
  3694. if miConfig.Code == "H15049901371" {
  3695. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  3696. utils.ErrorLog("解析失败:%v", err)
  3697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3698. return
  3699. }
  3700. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3701. res.Output = resSeven10265.Output
  3702. res.ErrMsg = resSeven10265.ErrMsg
  3703. res.Cainfo = resSeven10265.Cainfo
  3704. res.WarnMsg = resSeven10265.WarnMsg
  3705. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3706. res.Infcode = infocode
  3707. } else {
  3708. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3709. utils.ErrorLog("解析失败:%v", err)
  3710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3711. return
  3712. }
  3713. }
  3714. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3715. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  3716. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3717. //psn_info, _ := service.GetPsnByPatientId(id)
  3718. bas := strings.Split(psn_info.CardInfo, "|")
  3719. if his.IdCardType == 1 {
  3720. cert_no = bas[2]
  3721. } else {
  3722. cert_no = bas[1]
  3723. }
  3724. //江苏地区国家医保医疗类别
  3725. //职工透析:医疗类别选特殊情况门诊9933
  3726. //居民血透门慢: 医疗类别选门诊慢病1402
  3727. //var med_type string
  3728. //if his.Insutype == "310" {
  3729. // if reg_type == 14 {
  3730. // med_type = "9933"
  3731. // } else if reg_type == 11 {
  3732. // med_type = "11"
  3733. //
  3734. // }
  3735. //} else if his.Insutype == "390" {
  3736. // if reg_type == 14 {
  3737. // med_type = "1402"
  3738. // } else if reg_type == 11 {
  3739. // med_type = "11"
  3740. // }
  3741. //}
  3742. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3743. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3744. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3745. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3746. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3747. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3748. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3749. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber + "&verify_number=" + psn_info.VerifyNumber
  3750. resp, requestErr := http.Get(api)
  3751. if requestErr != nil {
  3752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3753. return
  3754. }
  3755. body, ioErr := ioutil.ReadAll(resp.Body)
  3756. if ioErr != nil {
  3757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3759. return
  3760. }
  3761. var respJSON map[string]interface{}
  3762. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3765. return
  3766. }
  3767. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3768. result, _ := json.Marshal(respJSON)
  3769. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  3770. utils.ErrorLog("解析失败:%v", err)
  3771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3772. return
  3773. }
  3774. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3775. res.Output = resSeven10265.Output
  3776. res.ErrMsg = resSeven10265.ErrMsg
  3777. res.Cainfo = resSeven10265.Cainfo
  3778. res.WarnMsg = resSeven10265.WarnMsg
  3779. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3780. res.Infcode = infocode
  3781. } else {
  3782. if miConfig.Code == "H15049901371" {
  3783. //赤峰地区国家医保医疗类别
  3784. //职工透析:医疗类别选特殊情况门诊990502
  3785. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3786. var med_type string
  3787. if his.Insutype == "390" {
  3788. if reg_type == 14 {
  3789. med_type = "9933"
  3790. } else if reg_type == 11 {
  3791. med_type = "11"
  3792. }
  3793. } else if his.Insutype == "310" {
  3794. if reg_type == 14 {
  3795. med_type = "990502"
  3796. } else if reg_type == 11 {
  3797. med_type = "11"
  3798. }
  3799. }
  3800. 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)
  3801. } else {
  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, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  3803. }
  3804. //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)
  3805. var dat map[string]interface{}
  3806. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3807. fmt.Println(dat)
  3808. } else {
  3809. fmt.Println(err)
  3810. }
  3811. saveLog(result2, src_resquest, "2207", "结算")
  3812. userJSONBytes, _ := json.Marshal(dat)
  3813. if miConfig.Code == "H15049901371" {
  3814. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  3815. utils.ErrorLog("解析失败:%v", err)
  3816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3817. return
  3818. }
  3819. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3820. res.Output = resSeven10265.Output
  3821. res.ErrMsg = resSeven10265.ErrMsg
  3822. res.Cainfo = resSeven10265.Cainfo
  3823. res.WarnMsg = resSeven10265.WarnMsg
  3824. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3825. res.Infcode = infocode
  3826. } else {
  3827. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3828. utils.ErrorLog("解析失败:%v", err)
  3829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3830. return
  3831. }
  3832. }
  3833. }
  3834. if res.Infcode != 0 {
  3835. errlog := &models.HisOrderError{
  3836. UserOrgId: adminUser.CurrentOrgId,
  3837. Ctime: time.Now().Unix(),
  3838. Mtime: time.Now().Unix(),
  3839. Number: chrg_bchno,
  3840. ErrMsg: res.ErrMsg,
  3841. Status: 1,
  3842. PatientId: id,
  3843. RecordTime: recordDateTime,
  3844. Stage: 6,
  3845. }
  3846. service.CreateErrMsgLog(errlog)
  3847. c.ServeSuccessJSON(map[string]interface{}{
  3848. "failed_code": -10,
  3849. "msg": res.ErrMsg,
  3850. })
  3851. return
  3852. } else {
  3853. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3854. order.OrderStatus = 2
  3855. order.Status = 1
  3856. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3857. order.SetlId = res.Output.Setlinfo.SetlID
  3858. order.PsnNo = res.Output.Setlinfo.PsnNo
  3859. order.PsnName = res.Output.Setlinfo.PsnName
  3860. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3861. order.Certno = res.Output.Setlinfo.Certno
  3862. order.Gend = res.Output.Setlinfo.Gend
  3863. order.Naty = res.Output.Setlinfo.Naty
  3864. order.Age = res.Output.Setlinfo.Age
  3865. order.Insutype = res.Output.Setlinfo.Insutype
  3866. order.PsnType = res.Output.Setlinfo.PsnType
  3867. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3868. order.SetlTime = res.Output.Setlinfo.SetlTime
  3869. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3870. if res.Output.Setlinfo.MedType == "140101" {
  3871. order.MedType = "14"
  3872. } else {
  3873. order.MedType = res.Output.Setlinfo.MedType
  3874. }
  3875. if reg_type == 1112 {
  3876. order.MedType = "1112"
  3877. }
  3878. if reg_type == 1111 {
  3879. order.MedType = "1111"
  3880. }
  3881. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3882. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3883. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3884. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3885. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3886. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3887. order.HifpPay = res.Output.Setlinfo.HifpPay
  3888. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3889. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3890. order.HifesPay = res.Output.Setlinfo.HifesPay
  3891. order.HifobPay = res.Output.Setlinfo.HifobPay
  3892. order.MafPay = res.Output.Setlinfo.MafPay
  3893. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3894. order.OthPay = res.Output.Setlinfo.OthPay
  3895. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3896. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3897. order.AcctPay = res.Output.Setlinfo.AcctPay
  3898. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3899. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3900. order.Balc = res.Output.Setlinfo.Balc
  3901. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3902. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3903. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3904. order.ClrType = res.Output.Setlinfo.ClrType
  3905. order.ClrWay = res.Output.Setlinfo.ClrWay
  3906. order.Creator = order.Creator
  3907. order.Modify = roles.AdminUserId
  3908. order.RequestLog = src_resquest
  3909. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3910. detailStr := string(setlDetail)
  3911. order.SetlDetail = detailStr
  3912. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3913. err = service.UpDateOrder(order)
  3914. if err == nil {
  3915. c.ServeSuccessJSON(map[string]interface{}{
  3916. "msg": "结算成功",
  3917. })
  3918. } else {
  3919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3920. return
  3921. }
  3922. }
  3923. } else {
  3924. adminUser := c.GetAdminUserInfo()
  3925. errlog := &models.HisOrderError{
  3926. UserOrgId: adminUser.CurrentOrgId,
  3927. Ctime: time.Now().Unix(),
  3928. Mtime: time.Now().Unix(),
  3929. ErrMsg: res.ErrMsg,
  3930. Status: 1,
  3931. PatientId: id,
  3932. RecordTime: recordDateTime,
  3933. Stage: 4,
  3934. }
  3935. service.CreateErrMsgLog(errlog)
  3936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3937. return
  3938. }
  3939. } else {
  3940. adminUser := c.GetAdminUserInfo()
  3941. errlog := &models.HisOrderError{
  3942. UserOrgId: adminUser.CurrentOrgId,
  3943. Ctime: time.Now().Unix(),
  3944. Mtime: time.Now().Unix(),
  3945. ErrMsg: res.ErrMsg,
  3946. Status: 1,
  3947. PatientId: id,
  3948. RecordTime: recordDateTime,
  3949. Stage: 4,
  3950. }
  3951. service.CreateErrMsgLog(errlog)
  3952. c.ServeSuccessJSON(map[string]interface{}{
  3953. "failed_code": -10,
  3954. "msg": res.ErrMsg,
  3955. })
  3956. return
  3957. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  3958. //return
  3959. }
  3960. }
  3961. }
  3962. } else if tempOrder.ID > 0 {
  3963. if tempOrder.IsPre == 1 {
  3964. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  3965. var rf []*ResultFive
  3966. json.Unmarshal([]byte(his.Iinfo), &rf)
  3967. chrg_bchno := tempOrder.Number
  3968. cert_no := his.Certno
  3969. var insutypes []string
  3970. var insutype string
  3971. var is390 int = 0
  3972. var is310 int = 0
  3973. for _, item := range rf {
  3974. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3975. insutypes = append(insutypes, item.Insutype)
  3976. }
  3977. }
  3978. if len(insutypes) == 1 {
  3979. insutype = insutypes[0]
  3980. } else {
  3981. for _, i := range insutypes {
  3982. if i == "390" {
  3983. is390 = 1
  3984. }
  3985. if i == "310" {
  3986. is310 = 1
  3987. }
  3988. }
  3989. }
  3990. if is390 == 1 {
  3991. insutype = "390"
  3992. }
  3993. if is310 == 1 {
  3994. insutype = "310"
  3995. }
  3996. if len(insutypes) == 0 {
  3997. insutype = "310"
  3998. }
  3999. if len(insutypes) == 2 {
  4000. insutype = strconv.FormatInt(his.SocialType, 64)
  4001. }
  4002. //insutype = "390"
  4003. if his.IdCardType == 1 {
  4004. // cert_no = his.MedicalInsuranceNumber
  4005. cert_no = his.Certno
  4006. } else {
  4007. cert_no = his.Certno
  4008. }
  4009. var res ResultSeven
  4010. var resSeven10265 ResultSeven10265
  4011. var src_resquest string
  4012. var result2 string
  4013. var acct_used_flag string
  4014. fmt.Println("pay_way")
  4015. fmt.Println(pay_way)
  4016. fmt.Println("pay_way")
  4017. if pay_way == 4 {
  4018. acct_used_flag = "1"
  4019. } else {
  4020. acct_used_flag = "0"
  4021. }
  4022. if miConfig.MdtrtareaAdmvs == "421300" {
  4023. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4024. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4025. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4026. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4027. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4028. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4029. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4030. resp, requestErr := http.Get(api)
  4031. if requestErr != nil {
  4032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4033. return
  4034. }
  4035. body, ioErr := ioutil.ReadAll(resp.Body)
  4036. if ioErr != nil {
  4037. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4039. return
  4040. }
  4041. var respJSON map[string]interface{}
  4042. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4043. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4045. return
  4046. }
  4047. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4048. result, _ := json.Marshal(respJSON)
  4049. fmt.Println("log")
  4050. fmt.Println(string(result))
  4051. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4052. utils.ErrorLog("解析失败:%v", err)
  4053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4054. return
  4055. }
  4056. } else if miConfig.MdtrtareaAdmvs == "320921" {
  4057. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4058. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4059. //psn_info, _ := service.GetPsnByPatientId(id)
  4060. bas := strings.Split(psn_info.CardInfo, "|")
  4061. if his.IdCardType == 1 {
  4062. cert_no = bas[2]
  4063. } else {
  4064. cert_no = bas[1]
  4065. }
  4066. //江苏地区国家医保医疗类别
  4067. //职工透析:医疗类别选特殊情况门诊9933
  4068. //居民血透门慢: 医疗类别选门诊慢病1402
  4069. //var med_type string
  4070. //if his.Insutype == "310" {
  4071. // if reg_type == 14 {
  4072. // med_type = "9933"
  4073. // } else if reg_type == 11 {
  4074. // med_type = "11"
  4075. //
  4076. // }
  4077. //} else if his.Insutype == "390" {
  4078. // if reg_type == 14 {
  4079. // med_type = "1402"
  4080. // } else if reg_type == 11 {
  4081. // med_type = "11"
  4082. // }
  4083. //}
  4084. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4085. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4086. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4087. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4088. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4089. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4090. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber + "&verify_number=" + psn_info.VerifyNumber
  4091. resp, requestErr := http.Get(api)
  4092. if requestErr != nil {
  4093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4094. return
  4095. }
  4096. body, ioErr := ioutil.ReadAll(resp.Body)
  4097. if ioErr != nil {
  4098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4100. return
  4101. }
  4102. var respJSON map[string]interface{}
  4103. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4104. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4106. return
  4107. }
  4108. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4109. result, _ := json.Marshal(respJSON)
  4110. fmt.Println("log")
  4111. fmt.Println(string(result))
  4112. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4113. utils.ErrorLog("解析失败:%v", err)
  4114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4115. return
  4116. }
  4117. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4118. res.Output = resSeven10265.Output
  4119. res.ErrMsg = resSeven10265.ErrMsg
  4120. res.Cainfo = resSeven10265.Cainfo
  4121. res.WarnMsg = resSeven10265.WarnMsg
  4122. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4123. res.Infcode = infocode
  4124. } else {
  4125. var src_resquest string
  4126. if miConfig.Code == "H15049901371" {
  4127. //赤峰地区国家医保医疗类别
  4128. //职工透析:医疗类别选特殊情况门诊990502
  4129. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4130. var med_type string
  4131. if his.Insutype == "390" {
  4132. if reg_type == 14 {
  4133. med_type = "9933"
  4134. } else if reg_type == 11 {
  4135. med_type = "11"
  4136. }
  4137. } else if his.Insutype == "310" {
  4138. if reg_type == 14 {
  4139. med_type = "990502"
  4140. } else if reg_type == 11 {
  4141. med_type = "11"
  4142. }
  4143. }
  4144. 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)
  4145. } else {
  4146. 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)
  4147. }
  4148. var dat map[string]interface{}
  4149. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4150. fmt.Println(dat)
  4151. } else {
  4152. fmt.Println(err)
  4153. }
  4154. saveLog(result2, src_resquest, "2207", "结算")
  4155. userJSONBytes, _ := json.Marshal(dat)
  4156. if miConfig.Code == "H15049901371" {
  4157. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4158. utils.ErrorLog("解析失败:%v", err)
  4159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4160. return
  4161. }
  4162. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4163. res.Output = resSeven10265.Output
  4164. res.ErrMsg = resSeven10265.ErrMsg
  4165. res.Cainfo = resSeven10265.Cainfo
  4166. res.WarnMsg = resSeven10265.WarnMsg
  4167. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4168. res.Infcode = infocode
  4169. } else {
  4170. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4171. utils.ErrorLog("解析失败:%v", err)
  4172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4173. return
  4174. }
  4175. }
  4176. }
  4177. if res.Infcode != 0 {
  4178. errlog := &models.HisOrderError{
  4179. UserOrgId: adminUser.CurrentOrgId,
  4180. Ctime: time.Now().Unix(),
  4181. Mtime: time.Now().Unix(),
  4182. Number: chrg_bchno,
  4183. ErrMsg: res.ErrMsg,
  4184. Status: 1,
  4185. PatientId: id,
  4186. RecordTime: recordDateTime,
  4187. Stage: 6,
  4188. }
  4189. service.CreateErrMsgLog(errlog)
  4190. c.ServeSuccessJSON(map[string]interface{}{
  4191. "failed_code": -10,
  4192. "msg": res.ErrMsg,
  4193. })
  4194. return
  4195. } else {
  4196. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4197. order.OrderStatus = 2
  4198. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4199. order.SetlId = res.Output.Setlinfo.SetlID
  4200. order.PsnNo = res.Output.Setlinfo.PsnNo
  4201. order.PsnName = res.Output.Setlinfo.PsnName
  4202. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4203. order.Certno = res.Output.Setlinfo.Certno
  4204. order.Gend = res.Output.Setlinfo.Gend
  4205. order.Naty = res.Output.Setlinfo.Naty
  4206. order.Age = res.Output.Setlinfo.Age
  4207. order.Insutype = res.Output.Setlinfo.Insutype
  4208. order.PsnType = res.Output.Setlinfo.PsnType
  4209. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4210. order.SetlTime = res.Output.Setlinfo.SetlTime
  4211. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4212. //order.MedType = res.Output.Setlinfo.MedType
  4213. if reg_type == 1112 {
  4214. order.MedType = "1112"
  4215. }
  4216. if reg_type == 1111 {
  4217. order.MedType = "1111"
  4218. }
  4219. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4220. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4221. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4222. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4223. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4224. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4225. order.HifpPay = res.Output.Setlinfo.HifpPay
  4226. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4227. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4228. order.HifesPay = res.Output.Setlinfo.HifesPay
  4229. order.HifobPay = res.Output.Setlinfo.HifobPay
  4230. order.MafPay = res.Output.Setlinfo.MafPay
  4231. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4232. order.OthPay = res.Output.Setlinfo.OthPay
  4233. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4234. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4235. order.AcctPay = res.Output.Setlinfo.AcctPay
  4236. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4237. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4238. order.Balc = res.Output.Setlinfo.Balc
  4239. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4240. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4241. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4242. order.ClrWay = res.Output.Setlinfo.ClrWay
  4243. order.Creator = order.Creator
  4244. order.Modify = roles.AdminUserId
  4245. order.RequestLog = src_resquest
  4246. order.Diagnosis = diagnosis_id
  4247. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4248. detailStr := string(setlDetail)
  4249. order.SetlDetail = detailStr
  4250. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4251. err = service.UpDateOrder(order)
  4252. if err == nil {
  4253. c.ServeSuccessJSON(map[string]interface{}{
  4254. "msg": "结算成功",
  4255. })
  4256. } else {
  4257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4258. return
  4259. }
  4260. }
  4261. }
  4262. }
  4263. }
  4264. //func (c *HisApiController) GetPreUploadInfo() {
  4265. // id, _ := c.GetInt64("id")
  4266. // record_time := c.GetString("record_time")
  4267. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4268. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4269. //
  4270. // timeLayout := "2006-01-02"
  4271. // loc, _ := time.LoadLocation("Local")
  4272. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4273. // if err != nil {
  4274. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4275. // return
  4276. // }
  4277. // recordDateTime := theTime.Unix()
  4278. // adminUser := c.GetAdminUserInfo()
  4279. //
  4280. // var prescriptions []*models.HisPrescription
  4281. //
  4282. // var start_time int64
  4283. // var end_time int64
  4284. //
  4285. // data := make(map[string]interface{})
  4286. // if settle_accounts_type == 1 { //日结
  4287. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4288. // data["pre"] = prescriptions
  4289. //
  4290. // } else { //月结
  4291. // start_time_str := c.GetString("start_time")
  4292. // end_time_str := c.GetString("end_time")
  4293. // timeLayout := "2006-01-02"
  4294. // loc, _ := time.LoadLocation("Local")
  4295. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4296. // if err != nil {
  4297. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4298. // return
  4299. // }
  4300. // recordStartTime := theStartTime.Unix()
  4301. // start_time = recordStartTime
  4302. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4303. // if err != nil {
  4304. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4305. // return
  4306. // }
  4307. // recordEndTime := theEndTime.Unix()
  4308. // end_time = recordEndTime
  4309. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4310. // data["pre"] = prescriptions
  4311. //
  4312. // }
  4313. //
  4314. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4315. //
  4316. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4317. // timestamp := time.Now().Unix()
  4318. // tempTime := time.Unix(timestamp, 0)
  4319. // timeFormat := tempTime.Format("20060102150405")
  4320. // chrgBchno := rand.Intn(100000) + 10000
  4321. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4322. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4323. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4324. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4325. // strconv.FormatInt(his.PatientId, 10)
  4326. // client := &http.Client{}
  4327. // data["psn_no"] = his.PsnNo
  4328. // data["mdtrt_id"] = his.Number
  4329. // data["chrg_bchno"] = chrg_bchno
  4330. // data["org_name"] = miConfig.OrgName
  4331. // data["doctor"] = roles.UserName
  4332. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4333. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4334. // data["fixmedins_code"] = miConfig.Code
  4335. // data["dept_code"] = department.Number
  4336. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4337. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4338. // data["secret_key"] = miConfig.SecretKey
  4339. // var ids []int64
  4340. //
  4341. // for _, item := range prescriptions {
  4342. // ids = append(ids, item.ID)
  4343. // }
  4344. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4345. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4346. // bytesData, _ := json.Marshal(data)
  4347. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  4348. // resp, _ := client.Do(req)
  4349. // defer resp.Body.Close()
  4350. // body, ioErr := ioutil.ReadAll(resp.Body)
  4351. // if ioErr != nil {
  4352. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4353. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4354. // return
  4355. // }
  4356. // var respJSON map[string]interface{}
  4357. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4358. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4359. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4360. // return
  4361. // }
  4362. //
  4363. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4364. // userJSONBytes, _ := json.Marshal(respJSON)
  4365. // var res ResultFour
  4366. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4367. // utils.ErrorLog("解析失败:%v", err)
  4368. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4369. // return
  4370. // }
  4371. //
  4372. // if res.Infcode == 0 {
  4373. // order := &models.HisOrder{
  4374. // UserOrgId: adminUser.CurrentOrgId,
  4375. // HisPatientId: his.ID,
  4376. // PatientId: his.PatientId,
  4377. // SettleAccountsDate: recordDateTime,
  4378. // Ctime: time.Now().Unix(),
  4379. // Mtime: time.Now().Unix(),
  4380. // Status: 1,
  4381. // Number: chrg_bchno,
  4382. // Infcode: res.Infcode,
  4383. // WarnMsg: res.WarnMsg,
  4384. // Cainfo: res.Cainfo,
  4385. // ErrMsg: res.ErrMsg,
  4386. // RespondTime: res.RefmsgTime,
  4387. // InfRefmsgid: res.InfRefmsgid,
  4388. // OrderStatus: 1,
  4389. // IsMedicineInsurance: 1,
  4390. // SettleType: settle_accounts_type,
  4391. // SettleStartTime: start_time,
  4392. // SettleEndTime: end_time,
  4393. // Creator: roles.ID,
  4394. // Modify: roles.ID,
  4395. // PType: 2,
  4396. // }
  4397. // err = service.CreateOrder(order)
  4398. // if err != nil {
  4399. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4400. // return
  4401. // }
  4402. //
  4403. // for _, item := range res.Output.Result {
  4404. // temp := strings.Split(item.FeedetlSn, "-")
  4405. // var advice_id int64 = 0
  4406. // var project_id int64 = 0
  4407. // var types int64 = 0
  4408. //
  4409. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  4410. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  4411. //
  4412. // if temp[1] == "1" {
  4413. // advice_id = id
  4414. // project_id = 0
  4415. // } else if temp[1] == "2" {
  4416. // advice_id = 0
  4417. // project_id = id
  4418. // }
  4419. //
  4420. // info := &models.HisOrderInfo{
  4421. // OrderNumber: order.Number,
  4422. // FeedetlSn: item.FeedetlSn,
  4423. // UploadDate: time.Now().Unix(),
  4424. // AdviceId: advice_id,
  4425. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  4426. // Cnt: item.Cnt,
  4427. // Pric: float64(item.Pric),
  4428. // PatientId: his.PatientId,
  4429. // PricUplmtAmt: item.PricUplmtAmt,
  4430. // SelfpayProp: item.SelfpayProp,
  4431. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4432. // OverlmtAmt: item.OverlmtAmt,
  4433. // PreselfpayAmt: item.PreselfpayAmt,
  4434. // BasMednFlag: item.BasMednFlag,
  4435. // MedChrgitmType: item.MedChrgitmType,
  4436. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  4437. // Status: 1,
  4438. // Memo: item.Memo,
  4439. // Mtime: time.Now().Unix(),
  4440. // InscpScpAmt: item.InscpScpAmt,
  4441. // DrtReimFlag: item.DrtReimFlag,
  4442. // Ctime: time.Now().Unix(),
  4443. // ListSpItemFlag: item.ListSpItemFlag,
  4444. // ChldMedcFlag: item.ChldMedcFlag,
  4445. // LmtUsedFlag: item.LmtUsedFlag,
  4446. // ChrgitmLv: item.ChrgitmLv,
  4447. // UserOrgId: adminUser.CurrentOrgId,
  4448. // HisPatientId: his.ID,
  4449. // OrderId: order.ID,
  4450. // ProjectId: project_id,
  4451. // Type: types,
  4452. // }
  4453. // service.CreateOrderInfo(info)
  4454. //
  4455. // }
  4456. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4457. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  4458. //
  4459. // var total float64
  4460. // for _, item := range prescriptions {
  4461. // if item.Type == 1 { //药品
  4462. // for _, subItem := range item.HisDoctorAdviceInfo {
  4463. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4464. // }
  4465. // }
  4466. // if item.Type == 2 { //项目
  4467. // for _, subItem := range item.HisPrescriptionProject {
  4468. // total = total + (subItem.Price * float64(subItem.Count))
  4469. // }
  4470. // }
  4471. // }
  4472. //
  4473. // for _, item := range prescriptions {
  4474. // for _, subItem := range item.HisAdditionalCharge {
  4475. // total = total + (subItem.Price * float64(subItem.Count))
  4476. // }
  4477. // }
  4478. //
  4479. // allTotal := fmt.Sprintf("%.2f", total)
  4480. // if res.Infcode == 0 {
  4481. // var rf []*ResultFive
  4482. // json.Unmarshal([]byte(his.Iinfo), &rf)
  4483. // psn_no := his.PsnNo
  4484. // mdtrt_id := his.Number
  4485. // chrg_bchno := chrg_bchno
  4486. // cert_no := his.Certno
  4487. // insutype := rf[0].Insutype
  4488. //
  4489. // if his.IdCardType == 1 {
  4490. // cert_no = his.MedicalInsuranceNumber
  4491. //
  4492. // } else {
  4493. //
  4494. // cert_no = his.Certno
  4495. //
  4496. // }
  4497. //
  4498. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  4499. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  4500. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  4501. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  4502. // resp, requestErr := http.Get(api)
  4503. // if requestErr != nil {
  4504. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4505. // return
  4506. // }
  4507. // defer resp.Body.Close()
  4508. // body, ioErr := ioutil.ReadAll(resp.Body)
  4509. // if ioErr != nil {
  4510. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4511. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4512. // return
  4513. // }
  4514. // var respJSON map[string]interface{}
  4515. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4516. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4517. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4518. // return
  4519. // }
  4520. // fmt.Println(respJSON)
  4521. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4522. // userJSONBytes, _ := json.Marshal(respJSON)
  4523. // var res ResultSeven
  4524. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4525. // utils.ErrorLog("解析失败:%v", err)
  4526. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4527. // return
  4528. // }
  4529. // if res.Infcode != 0 {
  4530. // errlog := &models.HisOrderError{
  4531. // UserOrgId: adminUser.CurrentOrgId,
  4532. // Ctime: time.Now().Unix(),
  4533. // Mtime: time.Now().Unix(),
  4534. // Number: chrg_bchno,
  4535. // ErrMsg: res.ErrMsg,
  4536. // Status: 1,
  4537. // PatientId: id,
  4538. // RecordTime: recordDateTime,
  4539. // Stage: 7,
  4540. // }
  4541. // service.CreateErrMsgLog(errlog)
  4542. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4543. // return
  4544. // } else {
  4545. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4546. // order.OrderStatus = 1
  4547. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4548. // order.SetlId = res.Output.Setlinfo.SetlID
  4549. // order.PsnNo = res.Output.Setlinfo.PsnNo
  4550. // order.PsnName = res.Output.Setlinfo.PsnName
  4551. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4552. // order.Certno = res.Output.Setlinfo.Certno
  4553. // order.Gend = res.Output.Setlinfo.Gend
  4554. // order.Naty = res.Output.Setlinfo.Naty
  4555. // order.Age = res.Output.Setlinfo.Age
  4556. // order.Insutype = res.Output.Setlinfo.Insutype
  4557. // order.PsnType = res.Output.Setlinfo.PsnType
  4558. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4559. // order.SetlTime = res.Output.Setlinfo.SetlTime
  4560. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4561. // order.MedType = res.Output.Setlinfo.MedType
  4562. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4563. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4564. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4565. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4566. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4567. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4568. // order.HifpPay = res.Output.Setlinfo.HifpPay
  4569. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4570. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4571. // order.HifesPay = res.Output.Setlinfo.HifesPay
  4572. // order.HifobPay = res.Output.Setlinfo.HifobPay
  4573. // order.MafPay = res.Output.Setlinfo.MafPay
  4574. // order.OthPay = res.Output.Setlinfo.OthPay
  4575. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4576. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4577. // order.AcctPay = res.Output.Setlinfo.AcctPay
  4578. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4579. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4580. // order.Balc = res.Output.Setlinfo.Balc
  4581. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4582. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4583. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4584. // order.ClrWay = res.Output.Setlinfo.ClrWay
  4585. // order.Creator = order.Creator
  4586. // order.Modify = roles.ID
  4587. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4588. // detailStr := string(setlDetail)
  4589. // order.SetlDetail = detailStr
  4590. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4591. // err = service.UpDateOrder(order)
  4592. // if err == nil {
  4593. // c.ServeSuccessJSON(map[string]interface{}{
  4594. // "msg": "预结算成功",
  4595. // })
  4596. // } else {
  4597. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4598. // return
  4599. // }
  4600. // }
  4601. // } else {
  4602. // adminUser := c.GetAdminUserInfo()
  4603. // errlog := &models.HisOrderError{
  4604. // UserOrgId: adminUser.CurrentOrgId,
  4605. // Ctime: time.Now().Unix(),
  4606. // Mtime: time.Now().Unix(),
  4607. // ErrMsg: res.ErrMsg,
  4608. // Status: 1,
  4609. // PatientId: id,
  4610. // RecordTime: recordDateTime,
  4611. // Stage: 4,
  4612. // }
  4613. // service.CreateErrMsgLog(errlog)
  4614. //
  4615. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4616. // return
  4617. // }
  4618. // } else {
  4619. // adminUser := c.GetAdminUserInfo()
  4620. // errlog := &models.HisOrderError{
  4621. // UserOrgId: adminUser.CurrentOrgId,
  4622. // Ctime: time.Now().Unix(),
  4623. // Mtime: time.Now().Unix(),
  4624. // ErrMsg: res.ErrMsg,
  4625. // Status: 1,
  4626. // PatientId: id,
  4627. // RecordTime: recordDateTime,
  4628. // Stage: 4,
  4629. // }
  4630. // service.CreateErrMsgLog(errlog)
  4631. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4632. // return
  4633. // }
  4634. //
  4635. // } else {
  4636. // var total float64
  4637. // for _, item := range prescriptions {
  4638. // if item.Type == 1 { //药品
  4639. // for _, subItem := range item.HisDoctorAdviceInfo {
  4640. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4641. // }
  4642. // }
  4643. // if item.Type == 2 { //项目
  4644. // for _, subItem := range item.HisPrescriptionProject {
  4645. // total = total + (subItem.Price * float64(subItem.Count))
  4646. // }
  4647. // }
  4648. //
  4649. // for _, subItem := range item.HisAdditionalCharge {
  4650. // total = total + (subItem.Price * float64(subItem.Count))
  4651. // }
  4652. // }
  4653. //
  4654. // allTotal := fmt.Sprintf("%.2f", total)
  4655. // totals, _ := strconv.ParseFloat(allTotal, 64)
  4656. // order := &models.HisOrder{
  4657. // UserOrgId: adminUser.CurrentOrgId,
  4658. // HisPatientId: his.ID,
  4659. // PatientId: id,
  4660. // SettleAccountsDate: recordDateTime,
  4661. // Ctime: time.Now().Unix(),
  4662. // Mtime: time.Now().Unix(),
  4663. // Status: 1,
  4664. // OrderStatus: 2,
  4665. // Number: chrg_bchno,
  4666. // MedfeeSumamt: totals,
  4667. // }
  4668. // err = service.CreateOrder(order)
  4669. // if err != nil {
  4670. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4671. // return
  4672. // }
  4673. //
  4674. // var customs []*Custom
  4675. // for _, item := range prescriptions {
  4676. //
  4677. // if item.Type == 1 { //药品
  4678. // for _, subItem := range item.HisDoctorAdviceInfo {
  4679. // cus := &Custom{
  4680. // AdviceId: subItem.ID,
  4681. // ProjectId: 0,
  4682. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  4683. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  4684. // FeedetlSn: subItem.FeedetlSn,
  4685. // Price: fmt.Sprintf("%.2f", subItem.Price),
  4686. // MedListCodg: subItem.MedListCodg,
  4687. // Type: 1,
  4688. // }
  4689. // customs = append(customs, cus)
  4690. // }
  4691. // }
  4692. //
  4693. // if item.Type == 2 { //项目
  4694. // for _, subItem := range item.HisPrescriptionProject {
  4695. //
  4696. // cus := &Custom{
  4697. // AdviceId: 0,
  4698. // ProjectId: subItem.ID,
  4699. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  4700. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  4701. // FeedetlSn: subItem.FeedetlSn,
  4702. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  4703. // MedListCodg: subItem.MedListCodg,
  4704. // Type: 2,
  4705. // }
  4706. //
  4707. // customs = append(customs, cus)
  4708. // }
  4709. // }
  4710. //
  4711. // for _, item := range item.HisAdditionalCharge {
  4712. // cus := &Custom{
  4713. // ItemId: item.ID,
  4714. // AdviceId: 0,
  4715. // ProjectId: 0,
  4716. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  4717. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  4718. // FeedetlSn: item.FeedetlSn,
  4719. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  4720. // MedListCodg: item.XtHisAddtionConfig.Code,
  4721. // Type: 3,
  4722. // }
  4723. //
  4724. // customs = append(customs, cus)
  4725. // }
  4726. //
  4727. // }
  4728. //
  4729. // for _, item := range customs {
  4730. // var advice_id int64 = 0
  4731. // var project_id int64 = 0
  4732. // var item_id int64 = 0
  4733. //
  4734. // var types int64 = 0
  4735. //
  4736. // if item.Type == 1 {
  4737. // advice_id = item.AdviceId
  4738. // project_id = 0
  4739. // item_id = 0
  4740. // } else if item.Type == 2 {
  4741. // advice_id = 0
  4742. // item_id = 0
  4743. //
  4744. // project_id = item.ProjectId
  4745. // } else if item.Type == 3 {
  4746. // advice_id = 0
  4747. // item_id = item.ItemId
  4748. // project_id = 0
  4749. // }
  4750. //
  4751. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  4752. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  4753. // pric, _ := strconv.ParseFloat(item.Price, 32)
  4754. //
  4755. // info := &models.HisOrderInfo{
  4756. // OrderNumber: order.Number,
  4757. // UploadDate: time.Now().Unix(),
  4758. // AdviceId: advice_id,
  4759. // DetItemFeeSumamt: detItemFeeSumamt,
  4760. // Cnt: cut,
  4761. // Pric: pric,
  4762. // PatientId: id,
  4763. // Status: 1,
  4764. // Mtime: time.Now().Unix(),
  4765. // Ctime: time.Now().Unix(),
  4766. // UserOrgId: adminUser.CurrentOrgId,
  4767. // HisPatientId: his.ID,
  4768. // OrderId: order.ID,
  4769. // ProjectId: project_id,
  4770. // Type: types,
  4771. // ItemId: item_id,
  4772. // }
  4773. // service.CreateOrderInfo(info)
  4774. // }
  4775. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4776. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4777. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  4778. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4779. // if err == nil {
  4780. // c.ServeSuccessJSON(map[string]interface{}{
  4781. // "msg": "结算成功",
  4782. // })
  4783. // } else {
  4784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4785. // return
  4786. // }
  4787. // }
  4788. //}
  4789. //上传明细-预结算-
  4790. func (c *HisApiController) GetPreUploadInfo() {
  4791. id, _ := c.GetInt64("id")
  4792. record_time := c.GetString("record_time")
  4793. his_patient_id, _ := c.GetInt64("his_patient_id")
  4794. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4795. admin_user_id, _ := c.GetInt64("admin_user_id")
  4796. diagnosis_id := c.GetString("diagnosis")
  4797. sick_type, _ := c.GetInt64("sick_type")
  4798. reg_type, _ := c.GetInt64("p_type")
  4799. begin_time := c.GetString("begin_time")
  4800. id_str := c.GetString("ids")
  4801. ids_arr := strings.Split(id_str, ",")
  4802. timeLayout := "2006-01-02"
  4803. loc, _ := time.LoadLocation("Local")
  4804. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4805. if err != nil {
  4806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4807. return
  4808. }
  4809. recordDateTime := theTime.Unix()
  4810. adminUser := c.GetAdminUserInfo()
  4811. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4812. var config []*models.HisXtDiagnoseConfig
  4813. for _, item := range diagnosis_ids {
  4814. id, _ := strconv.ParseInt(item, 10, 64)
  4815. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4816. config = append(config, &diagnosisConfig)
  4817. }
  4818. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  4819. sickConfig, _ := service.FindSickById(sick_type)
  4820. var prescriptions []*models.HisPrescription
  4821. var start_time int64
  4822. var end_time int64
  4823. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4824. fmt.Println(his_patient_id)
  4825. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4826. timestamp := time.Now().Unix()
  4827. tempTime := time.Unix(timestamp, 0)
  4828. timeFormat := tempTime.Format("20060102150405")
  4829. chrgBchno := rand.Intn(100000) + 10000
  4830. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4831. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4832. var patientPrescription models.HisPrescriptionInfo
  4833. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4834. if patientPrescription.ID == 0 {
  4835. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4836. }
  4837. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4838. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4839. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4840. strconv.FormatInt(his.PatientId, 10)
  4841. var res2 ResultSix
  4842. var resSix10265 ResultSix10265
  4843. var time_stamp string
  4844. if miConfig.InsuplcAdmdvs == "421300" {
  4845. data := make(map[string]interface{})
  4846. client := &http.Client{}
  4847. data["psn_no"] = his.PsnNo
  4848. data["mdtrt_id"] = his.Number
  4849. data["doctor"] = roles.UserName
  4850. data["department"] = department.Name
  4851. data["org_name"] = miConfig.OrgName
  4852. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4853. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4854. data["fixmedins_code"] = miConfig.Code
  4855. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4856. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4857. data["secret_key"] = miConfig.SecretKey
  4858. data["sick_code"] = sickConfig.CountryCode
  4859. data["sick_name"] = sickConfig.ClassName
  4860. data["begin_time"] = begin_time
  4861. data["dept"] = strconv.FormatInt(department.ID, 10)
  4862. data["config"] = config
  4863. fmt.Println(data)
  4864. bytesData, _ := json.Marshal(data)
  4865. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4866. resp, _ := client.Do(req)
  4867. defer resp.Body.Close()
  4868. body, ioErr := ioutil.ReadAll(resp.Body)
  4869. if ioErr != nil {
  4870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4872. return
  4873. }
  4874. var respJSON map[string]interface{}
  4875. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4876. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4878. return
  4879. }
  4880. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4881. userJSONBytes, _ := json.Marshal(respJSON)
  4882. fmt.Println("log")
  4883. fmt.Println(string(userJSONBytes))
  4884. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4885. utils.ErrorLog("解析失败:%v", err)
  4886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4887. return
  4888. }
  4889. } else if miConfig.InsuplcAdmdvs == "320921" {
  4890. //江苏地区国家医保医疗类别
  4891. //职工透析:医疗类别选特殊情况门诊9933
  4892. //居民血透门慢: 医疗类别选门诊慢病1402
  4893. //var med_type string
  4894. //if his.Insutype == "310" {
  4895. // if reg_type == 14 {
  4896. // med_type = "9933"
  4897. // } else if reg_type == 11 {
  4898. // med_type = "11"
  4899. //
  4900. // }
  4901. //} else if his.Insutype == "390" {
  4902. // if reg_type == 14 {
  4903. // med_type = "1402"
  4904. // } else if reg_type == 11 {
  4905. // med_type = "11"
  4906. // }
  4907. //}
  4908. data := make(map[string]interface{})
  4909. client := &http.Client{}
  4910. data["psn_no"] = his.PsnNo
  4911. data["mdtrt_id"] = his.Number
  4912. data["doctor"] = roles.UserName
  4913. data["department"] = department.Name
  4914. data["org_name"] = miConfig.OrgName
  4915. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4916. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4917. data["fixmedins_code"] = miConfig.Code
  4918. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4919. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4920. data["secret_key"] = miConfig.SecretKey
  4921. data["sick_code"] = sickConfig.CountryCode
  4922. data["sick_name"] = sickConfig.ClassName
  4923. data["begin_time"] = begin_time
  4924. data["dept"] = strconv.FormatInt(department.ID, 10)
  4925. data["config"] = config
  4926. data["url"] = miConfig.Url
  4927. data["ak"] = miConfig.ChannelNumber
  4928. fmt.Println(data)
  4929. bytesData, _ := json.Marshal(data)
  4930. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4931. resp, _ := client.Do(req)
  4932. defer resp.Body.Close()
  4933. body, ioErr := ioutil.ReadAll(resp.Body)
  4934. if ioErr != nil {
  4935. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4937. return
  4938. }
  4939. var respJSON map[string]interface{}
  4940. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4943. return
  4944. }
  4945. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  4946. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  4947. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  4948. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4949. userJSONBytes, _ := json.Marshal(respJSON)
  4950. fmt.Println("log")
  4951. fmt.Println(string(userJSONBytes))
  4952. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  4953. utils.ErrorLog("解析失败:%v", err)
  4954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4955. return
  4956. }
  4957. res2.InfRefmsgid = resSix10265.InfRefmsgid
  4958. res2.Output = resSix10265.Output
  4959. res2.ErrMsg = resSix10265.ErrMsg
  4960. res2.Cainfo = resSix10265.Cainfo
  4961. res2.WarnMsg = resSix10265.WarnMsg
  4962. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  4963. res2.Infcode = infocode
  4964. } else {
  4965. var result string
  4966. var requestLog string
  4967. if miConfig.InsuplcAdmdvs == "440781" { //
  4968. 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)
  4969. } else {
  4970. if miConfig.Code == "H15049901371" {
  4971. //赤峰地区国家医保医疗类别
  4972. //职工透析:医疗类别选特殊情况门诊990502
  4973. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4974. var med_type string
  4975. if his.Insutype == "390" {
  4976. if reg_type == 14 {
  4977. med_type = "9933"
  4978. } else if reg_type == 11 {
  4979. med_type = "11"
  4980. }
  4981. } else if his.Insutype == "310" {
  4982. if reg_type == 14 {
  4983. med_type = "990502"
  4984. } else if reg_type == 11 {
  4985. med_type = "11"
  4986. }
  4987. }
  4988. 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)
  4989. } else {
  4990. 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)
  4991. }
  4992. saveLog(result, requestLog, "2203", "上传就诊信息")
  4993. var respJSON2 map[string]interface{}
  4994. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4995. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4997. return
  4998. }
  4999. userJSONBytes2, _ := json.Marshal(respJSON2)
  5000. if miConfig.Code == "H15049901371" {
  5001. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5002. utils.ErrorLog("解析失败:%v", err)
  5003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5004. return
  5005. }
  5006. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5007. res2.Output = resSix10265.Output
  5008. res2.ErrMsg = resSix10265.ErrMsg
  5009. res2.Cainfo = resSix10265.Cainfo
  5010. res2.WarnMsg = resSix10265.WarnMsg
  5011. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5012. res2.Infcode = infocode
  5013. } else {
  5014. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5015. utils.ErrorLog("解析失败:%v", err)
  5016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5017. return
  5018. }
  5019. }
  5020. }
  5021. }
  5022. if res2.Infcode != 0 {
  5023. adminUser := c.GetAdminUserInfo()
  5024. errlog := &models.HisOrderError{
  5025. UserOrgId: adminUser.CurrentOrgId,
  5026. Ctime: time.Now().Unix(),
  5027. Mtime: time.Now().Unix(),
  5028. ErrMsg: res2.ErrMsg,
  5029. Status: 1,
  5030. PatientId: id,
  5031. RecordTime: recordDateTime,
  5032. Stage: 3,
  5033. }
  5034. service.CreateErrMsgLog(errlog)
  5035. c.ServeSuccessJSON(map[string]interface{}{
  5036. "failed_code": -10,
  5037. "msg": res2.ErrMsg,
  5038. })
  5039. return
  5040. } else {
  5041. his.Diagnosis = diagnosis_id
  5042. his.SickType = sickConfig.ID
  5043. his.PType = fmt.Sprintf("%d", reg_type)
  5044. service.UpdateHisPatientThree(&his)
  5045. data := make(map[string]interface{})
  5046. if settle_accounts_type == 1 { //日结
  5047. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5048. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5049. } else {
  5050. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5051. }
  5052. data["pre"] = prescriptions
  5053. } else { //月结
  5054. start_time_str := c.GetString("start_time")
  5055. end_time_str := c.GetString("end_time")
  5056. timeLayout := "2006-01-02"
  5057. loc, _ := time.LoadLocation("Local")
  5058. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5059. if err != nil {
  5060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5061. return
  5062. }
  5063. recordStartTime := theStartTime.Unix()
  5064. start_time = recordStartTime
  5065. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5066. if err != nil {
  5067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5068. return
  5069. }
  5070. recordEndTime := theEndTime.Unix()
  5071. end_time = recordEndTime
  5072. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5073. data["pre"] = prescriptions
  5074. }
  5075. client := &http.Client{}
  5076. data["psn_no"] = his.PsnNo
  5077. data["mdtrt_id"] = his.Number
  5078. data["chrg_bchno"] = chrg_bchno
  5079. data["org_name"] = miConfig.OrgName
  5080. data["doctor"] = roles.UserName
  5081. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5082. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5083. data["fixmedins_code"] = miConfig.Code
  5084. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5085. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5086. data["dept_code"] = "15"
  5087. } else {
  5088. data["dept_code"] = department.Number
  5089. }
  5090. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5091. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5092. data["secret_key"] = miConfig.SecretKey
  5093. data["url"] = miConfig.Url
  5094. data["ak"] = miConfig.ChannelNumber
  5095. data["new_doctor_name"] = patientPrescription.Doctor
  5096. data["diag_code"] = sickConfig.CountryCode
  5097. data["time_stamp"] = time_stamp
  5098. var ids []int64
  5099. for _, item := range prescriptions {
  5100. ids = append(ids, item.ID)
  5101. }
  5102. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5103. if config.IsOpen == 1 { //对接了医保,走医保流程
  5104. var res ResultFour
  5105. var resFour10265 ResultFour10265
  5106. if miConfig.MdtrtareaAdmvs == "421300" {
  5107. bytesData, _ := json.Marshal(data)
  5108. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5109. resp, _ := client.Do(req)
  5110. defer resp.Body.Close()
  5111. body, ioErr := ioutil.ReadAll(resp.Body)
  5112. if ioErr != nil {
  5113. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5115. return
  5116. }
  5117. var respJSON map[string]interface{}
  5118. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5119. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5121. return
  5122. }
  5123. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5124. userJSONBytes, _ := json.Marshal(respJSON)
  5125. fmt.Println("log")
  5126. fmt.Println(string(userJSONBytes))
  5127. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5128. utils.ErrorLog("解析失败:%v", err)
  5129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5130. return
  5131. }
  5132. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5133. bytesData, _ := json.Marshal(data)
  5134. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5135. resp, _ := client.Do(req)
  5136. defer resp.Body.Close()
  5137. body, ioErr := ioutil.ReadAll(resp.Body)
  5138. if ioErr != nil {
  5139. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5141. return
  5142. }
  5143. var respJSON map[string]interface{}
  5144. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5145. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5147. return
  5148. }
  5149. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5150. userJSONBytes, _ := json.Marshal(respJSON)
  5151. fmt.Println("log")
  5152. fmt.Println(string(userJSONBytes))
  5153. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5154. utils.ErrorLog("解析失败:%v", err)
  5155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5156. return
  5157. }
  5158. res.InfRefmsgid = resFour10265.InfRefmsgid
  5159. res.Output = resFour10265.Output
  5160. res.ErrMsg = resFour10265.ErrMsg
  5161. res.Cainfo = resFour10265.Cainfo
  5162. res.WarnMsg = resFour10265.WarnMsg
  5163. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5164. res.Infcode = infocode
  5165. } else {
  5166. if miConfig.Code == "H15049901371" {
  5167. 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)
  5168. var dat map[string]interface{}
  5169. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5170. fmt.Println(dat)
  5171. } else {
  5172. fmt.Println(err)
  5173. }
  5174. saveLog(result, request_log, "2204", "上传费用明细")
  5175. userJSONBytes, _ := json.Marshal(dat)
  5176. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5177. utils.ErrorLog("解析失败:%v", err)
  5178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5179. return
  5180. }
  5181. res.InfRefmsgid = resFour10265.InfRefmsgid
  5182. res.Output = resFour10265.Output
  5183. res.ErrMsg = resFour10265.ErrMsg
  5184. res.Cainfo = resFour10265.Cainfo
  5185. res.WarnMsg = resFour10265.WarnMsg
  5186. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5187. res.Infcode = infocode
  5188. } else {
  5189. 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)
  5190. var dat map[string]interface{}
  5191. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5192. fmt.Println(dat)
  5193. } else {
  5194. fmt.Println(err)
  5195. }
  5196. saveLog(result, request_log, "2204", "上传费用明细")
  5197. userJSONBytes, _ := json.Marshal(dat)
  5198. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5199. utils.ErrorLog("解析失败:%v", err)
  5200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5201. return
  5202. }
  5203. }
  5204. }
  5205. if res.Infcode == 0 {
  5206. order := &models.HisOrder{
  5207. UserOrgId: adminUser.CurrentOrgId,
  5208. HisPatientId: his.ID,
  5209. PatientId: his.PatientId,
  5210. SettleAccountsDate: recordDateTime,
  5211. Ctime: time.Now().Unix(),
  5212. Mtime: time.Now().Unix(),
  5213. Status: 1,
  5214. Number: chrg_bchno,
  5215. Infcode: res.Infcode,
  5216. WarnMsg: res.WarnMsg,
  5217. Cainfo: res.Cainfo,
  5218. ErrMsg: res.ErrMsg,
  5219. RespondTime: res.RefmsgTime,
  5220. InfRefmsgid: res.InfRefmsgid,
  5221. OrderStatus: 1,
  5222. IsMedicineInsurance: 1,
  5223. SettleType: settle_accounts_type,
  5224. SettleStartTime: start_time,
  5225. SettleEndTime: end_time,
  5226. Creator: roles.AdminUserId,
  5227. Modify: roles.AdminUserId,
  5228. PType: 2,
  5229. Diagnosis: diagnosis_id,
  5230. }
  5231. err = service.CreateOrder(order)
  5232. if err != nil {
  5233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5234. return
  5235. }
  5236. for _, item := range res.Output.Result {
  5237. temp := strings.Split(item.FeedetlSn, "-")
  5238. var advice_id int64 = 0
  5239. var project_id int64 = 0
  5240. var types int64 = 0
  5241. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5242. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5243. if temp[1] == "1" {
  5244. advice_id = id
  5245. project_id = 0
  5246. } else if temp[1] == "2" {
  5247. advice_id = 0
  5248. project_id = id
  5249. }
  5250. info := &models.HisOrderInfo{
  5251. OrderNumber: order.Number,
  5252. FeedetlSn: item.FeedetlSn,
  5253. UploadDate: time.Now().Unix(),
  5254. AdviceId: advice_id,
  5255. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5256. Cnt: item.Cnt,
  5257. Pric: float64(item.Pric),
  5258. PatientId: his.PatientId,
  5259. PricUplmtAmt: item.PricUplmtAmt,
  5260. SelfpayProp: item.SelfpayProp,
  5261. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5262. OverlmtAmt: item.OverlmtAmt,
  5263. PreselfpayAmt: item.PreselfpayAmt,
  5264. BasMednFlag: item.BasMednFlag,
  5265. MedChrgitmType: item.MedChrgitmType,
  5266. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5267. Status: 1,
  5268. Memo: item.Memo,
  5269. Mtime: time.Now().Unix(),
  5270. InscpScpAmt: item.InscpScpAmt,
  5271. DrtReimFlag: item.DrtReimFlag,
  5272. Ctime: time.Now().Unix(),
  5273. ListSpItemFlag: item.ListSpItemFlag,
  5274. ChldMedcFlag: item.ChldMedcFlag,
  5275. LmtUsedFlag: item.LmtUsedFlag,
  5276. ChrgitmLv: item.ChrgitmLv,
  5277. UserOrgId: adminUser.CurrentOrgId,
  5278. HisPatientId: his.ID,
  5279. OrderId: order.ID,
  5280. ProjectId: project_id,
  5281. Type: types,
  5282. }
  5283. service.CreateOrderInfo(info)
  5284. }
  5285. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5286. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5287. var total float64
  5288. for _, item := range prescriptions {
  5289. if item.Type == 1 { //药品
  5290. for _, subItem := range item.HisDoctorAdviceInfo {
  5291. total = total + (subItem.Price * subItem.PrescribingNumber)
  5292. }
  5293. }
  5294. if item.Type == 2 { //项目
  5295. for _, subItem := range item.HisPrescriptionProject {
  5296. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5297. total = total + (subItem.Price * cnt)
  5298. }
  5299. }
  5300. }
  5301. for _, item := range prescriptions {
  5302. for _, subItem := range item.HisAdditionalCharge {
  5303. total = total + (subItem.Price * float64(subItem.Count))
  5304. }
  5305. }
  5306. allTotal := fmt.Sprintf("%.4f", total)
  5307. if res.Infcode == 0 {
  5308. var rf []*ResultFive
  5309. json.Unmarshal([]byte(his.Iinfo), &rf)
  5310. chrg_bchno := chrg_bchno
  5311. cert_no := his.Certno
  5312. var insutypes []string
  5313. var insutype string
  5314. var is390 int = 0
  5315. var is310 int = 0
  5316. for _, item := range rf {
  5317. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5318. insutypes = append(insutypes, item.Insutype)
  5319. }
  5320. }
  5321. if len(insutypes) == 1 {
  5322. insutype = insutypes[0]
  5323. } else {
  5324. for _, i := range insutypes {
  5325. if i == "390" {
  5326. is390 = 1
  5327. }
  5328. if i == "310" {
  5329. is310 = 1
  5330. }
  5331. }
  5332. }
  5333. if is390 == 1 {
  5334. insutype = "390"
  5335. }
  5336. if is310 == 1 {
  5337. insutype = "310"
  5338. }
  5339. if len(insutypes) == 0 {
  5340. insutype = "310"
  5341. }
  5342. if len(insutypes) == 2 {
  5343. insutype = strconv.FormatInt(his.SocialType, 64)
  5344. }
  5345. //insutype = "390"
  5346. if his.IdCardType == 1 {
  5347. cert_no = his.MedicalInsuranceNumber
  5348. } else {
  5349. cert_no = his.Certno
  5350. }
  5351. var res ResultSeven
  5352. var resSeven10265 ResultSeven10265
  5353. if miConfig.MdtrtareaAdmvs == "421300" {
  5354. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5355. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5356. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5357. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5358. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5359. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5360. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  5361. resp, requestErr := http.Get(api)
  5362. if requestErr != nil {
  5363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5364. return
  5365. }
  5366. body, ioErr := ioutil.ReadAll(resp.Body)
  5367. if ioErr != nil {
  5368. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5370. return
  5371. }
  5372. var respJSON map[string]interface{}
  5373. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5374. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5376. return
  5377. }
  5378. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5379. result, _ := json.Marshal(respJSON)
  5380. fmt.Println("log")
  5381. fmt.Println(string(result))
  5382. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5383. utils.ErrorLog("解析失败:%v", err)
  5384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5385. return
  5386. }
  5387. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5388. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5389. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5390. bas := strings.Split(psn_info.CardInfo, "|")
  5391. if his.IdCardType == 1 {
  5392. cert_no = bas[2]
  5393. } else {
  5394. cert_no = bas[1]
  5395. }
  5396. //江苏地区国家医保医疗类别
  5397. //职工透析:医疗类别选特殊情况门诊9933
  5398. //居民血透门慢: 医疗类别选门诊慢病1402
  5399. //var med_type string
  5400. //if his.Insutype == "310" {
  5401. // if reg_type == 14 {
  5402. // med_type = "9933"
  5403. // } else if reg_type == 11 {
  5404. // med_type = "11"
  5405. //
  5406. // }
  5407. //} else if his.Insutype == "390" {
  5408. // if reg_type == 14 {
  5409. // med_type = "1402"
  5410. // } else if reg_type == 11 {
  5411. // med_type = "11"
  5412. // }
  5413. //}
  5414. api := "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5415. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5416. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5417. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5418. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5419. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5420. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  5421. resp, requestErr := http.Get(api)
  5422. if requestErr != nil {
  5423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5424. return
  5425. }
  5426. body, ioErr := ioutil.ReadAll(resp.Body)
  5427. if ioErr != nil {
  5428. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5430. return
  5431. }
  5432. var respJSON map[string]interface{}
  5433. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5434. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5436. return
  5437. }
  5438. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5439. result, _ := json.Marshal(respJSON)
  5440. fmt.Println("log")
  5441. fmt.Println(string(result))
  5442. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5443. utils.ErrorLog("解析失败:%v", err)
  5444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5445. return
  5446. }
  5447. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5448. res.Output = resSeven10265.Output
  5449. res.ErrMsg = resSeven10265.ErrMsg
  5450. res.Cainfo = resSeven10265.Cainfo
  5451. res.WarnMsg = resSeven10265.WarnMsg
  5452. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5453. res.Infcode = infocode
  5454. } else {
  5455. var result string
  5456. var request_log string
  5457. if miConfig.Code == "H15049901371" {
  5458. //赤峰地区国家医保医疗类别
  5459. //职工透析:医疗类别选特殊情况门诊990502
  5460. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5461. var med_type string
  5462. if his.Insutype == "390" {
  5463. if reg_type == 14 {
  5464. med_type = "9933"
  5465. } else if reg_type == 11 {
  5466. med_type = "11"
  5467. }
  5468. } else if his.Insutype == "310" {
  5469. if reg_type == 14 {
  5470. med_type = "990502"
  5471. } else if reg_type == 11 {
  5472. med_type = "11"
  5473. }
  5474. }
  5475. 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)
  5476. } else {
  5477. 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)
  5478. }
  5479. var dat map[string]interface{}
  5480. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5481. fmt.Println(dat)
  5482. } else {
  5483. fmt.Println(err)
  5484. }
  5485. saveLog(result, request_log, "2206", "预结算")
  5486. //userJSONBytes, _ := json.Marshal(dat)
  5487. //
  5488. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5489. // utils.ErrorLog("解析失败:%v", err)
  5490. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5491. // return
  5492. //}
  5493. userJSONBytes, _ := json.Marshal(dat)
  5494. if miConfig.Code == "H15049901371" {
  5495. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5496. utils.ErrorLog("解析失败:%v", err)
  5497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5498. return
  5499. }
  5500. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5501. res.Output = resSeven10265.Output
  5502. res.ErrMsg = resSeven10265.ErrMsg
  5503. res.Cainfo = resSeven10265.Cainfo
  5504. res.WarnMsg = resSeven10265.WarnMsg
  5505. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5506. res.Infcode = infocode
  5507. } else {
  5508. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5509. utils.ErrorLog("解析失败:%v", err)
  5510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5511. return
  5512. }
  5513. }
  5514. }
  5515. if res.Infcode != 0 {
  5516. errlog := &models.HisOrderError{
  5517. UserOrgId: adminUser.CurrentOrgId,
  5518. Ctime: time.Now().Unix(),
  5519. Mtime: time.Now().Unix(),
  5520. Number: chrg_bchno,
  5521. ErrMsg: res.ErrMsg,
  5522. Status: 1,
  5523. PatientId: id,
  5524. RecordTime: recordDateTime,
  5525. Stage: 20,
  5526. }
  5527. service.CreateErrMsgLog(errlog)
  5528. c.ServeSuccessJSON(map[string]interface{}{
  5529. "failed_code": -10,
  5530. "msg": res.ErrMsg,
  5531. })
  5532. return
  5533. } else {
  5534. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5535. order.OrderStatus = 1
  5536. order.IsPre = 1
  5537. order.Status = 1
  5538. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5539. order.SetlId = res.Output.Setlinfo.SetlID
  5540. order.PsnNo = res.Output.Setlinfo.PsnNo
  5541. order.PsnName = res.Output.Setlinfo.PsnName
  5542. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5543. order.Certno = res.Output.Setlinfo.Certno
  5544. order.Gend = res.Output.Setlinfo.Gend
  5545. order.Naty = res.Output.Setlinfo.Naty
  5546. order.Age = res.Output.Setlinfo.Age
  5547. order.Insutype = res.Output.Setlinfo.Insutype
  5548. order.PsnType = res.Output.Setlinfo.PsnType
  5549. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5550. order.SetlTime = res.Output.Setlinfo.SetlTime
  5551. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5552. if res.Output.Setlinfo.MedType == "140101" {
  5553. order.MedType = "14"
  5554. } else {
  5555. order.MedType = res.Output.Setlinfo.MedType
  5556. }
  5557. if reg_type == 1112 {
  5558. order.MedType = "1112"
  5559. }
  5560. if reg_type == 1111 {
  5561. order.MedType = "1111"
  5562. }
  5563. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5564. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5565. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5566. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5567. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5568. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5569. order.HifpPay = res.Output.Setlinfo.HifpPay
  5570. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5571. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5572. order.HifesPay = res.Output.Setlinfo.HifesPay
  5573. order.HifobPay = res.Output.Setlinfo.HifobPay
  5574. order.MafPay = res.Output.Setlinfo.MafPay
  5575. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5576. order.OthPay = res.Output.Setlinfo.OthPay
  5577. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5578. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5579. order.AcctPay = res.Output.Setlinfo.AcctPay
  5580. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5581. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5582. order.Balc = res.Output.Setlinfo.Balc
  5583. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5584. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5585. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5586. order.ClrWay = res.Output.Setlinfo.ClrWay
  5587. order.Creator = order.Creator
  5588. order.Modify = roles.AdminUserId
  5589. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5590. detailStr := string(setlDetail)
  5591. order.SetlDetail = detailStr
  5592. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5593. err = service.UpDateOrder(order)
  5594. if err == nil {
  5595. c.ServeSuccessJSON(map[string]interface{}{
  5596. "msg": "预结算成功",
  5597. })
  5598. } else {
  5599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5600. return
  5601. }
  5602. }
  5603. } else {
  5604. adminUser := c.GetAdminUserInfo()
  5605. errlog := &models.HisOrderError{
  5606. UserOrgId: adminUser.CurrentOrgId,
  5607. Ctime: time.Now().Unix(),
  5608. Mtime: time.Now().Unix(),
  5609. ErrMsg: res.ErrMsg,
  5610. Status: 1,
  5611. PatientId: id,
  5612. RecordTime: recordDateTime,
  5613. Stage: 4,
  5614. }
  5615. service.CreateErrMsgLog(errlog)
  5616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5617. return
  5618. }
  5619. } else {
  5620. adminUser := c.GetAdminUserInfo()
  5621. errlog := &models.HisOrderError{
  5622. UserOrgId: adminUser.CurrentOrgId,
  5623. Ctime: time.Now().Unix(),
  5624. Mtime: time.Now().Unix(),
  5625. ErrMsg: res.ErrMsg,
  5626. Status: 1,
  5627. PatientId: id,
  5628. RecordTime: recordDateTime,
  5629. Stage: 4,
  5630. }
  5631. service.CreateErrMsgLog(errlog)
  5632. c.ServeSuccessJSON(map[string]interface{}{
  5633. "failed_code": -10,
  5634. "msg": res.ErrMsg,
  5635. })
  5636. return
  5637. }
  5638. }
  5639. }
  5640. }
  5641. //func (c *HisApiController) GetSettleInfo() {
  5642. // id, _ := c.GetInt64("id")
  5643. // order_id, _ := c.GetInt64("order_id")
  5644. //
  5645. // record_time := c.GetString("record_time")
  5646. // pay_way, _ := c.GetInt64("pay_way")
  5647. // pay_price, _ := c.GetFloat("pay_price")
  5648. // pay_card_no := c.GetString("pay_card_no")
  5649. // discount_price, _ := c.GetFloat("discount_price")
  5650. // preferential_price, _ := c.GetFloat("preferential_price")
  5651. // reality_price, _ := c.GetFloat("reality_price")
  5652. // found_price, _ := c.GetFloat("found_price")
  5653. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5654. // private_price, _ := c.GetFloat("private_price")
  5655. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5656. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5657. //
  5658. // timeLayout := "2006-01-02"
  5659. // loc, _ := time.LoadLocation("Local")
  5660. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5661. // if err != nil {
  5662. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5663. // return
  5664. // }
  5665. // recordDateTime := theTime.Unix()
  5666. // adminUser := c.GetAdminUserInfo()
  5667. //
  5668. // var prescriptions []*models.HisPrescription
  5669. //
  5670. // data := make(map[string]interface{})
  5671. // if settle_accounts_type == 1 { //日结
  5672. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5673. // data["pre"] = prescriptions
  5674. //
  5675. // } else { //月结
  5676. // start_time_str := c.GetString("start_time")
  5677. // end_time_str := c.GetString("end_time")
  5678. // timeLayout := "2006-01-02"
  5679. // loc, _ := time.LoadLocation("Local")
  5680. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5681. // if err != nil {
  5682. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5683. // return
  5684. // }
  5685. // recordStartTime := theStartTime.Unix()
  5686. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5687. // if err != nil {
  5688. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5689. // return
  5690. // }
  5691. // recordEndTime := theEndTime.Unix()
  5692. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5693. // data["pre"] = prescriptions
  5694. //
  5695. // }
  5696. //
  5697. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5698. //
  5699. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5700. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5701. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5702. // strconv.FormatInt(his.PatientId, 10)
  5703. //
  5704. // order_src, _ := service.GetHisOrderByID(order_id)
  5705. //
  5706. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5707. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5708. //
  5709. // var total float64
  5710. // for _, item := range prescriptions {
  5711. // if item.Type == 1 { //药品
  5712. // for _, subItem := range item.HisDoctorAdviceInfo {
  5713. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5714. // }
  5715. // }
  5716. // if item.Type == 2 { //项目
  5717. // for _, subItem := range item.HisPrescriptionProject {
  5718. // total = total + (subItem.Price * float64(subItem.Count))
  5719. // }
  5720. // }
  5721. // }
  5722. //
  5723. // for _, item := range prescriptions {
  5724. // for _, subItem := range item.HisAdditionalCharge {
  5725. // total = total + (subItem.Price * float64(subItem.Count))
  5726. // }
  5727. // }
  5728. //
  5729. // allTotal := fmt.Sprintf("%.2f", total)
  5730. // var rf []*ResultFive
  5731. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5732. // psn_no := order_src.PsnNo
  5733. // mdtrt_id := order_src.MdtrtId
  5734. // chrg_bchno := order_src.Number
  5735. // cert_no := order_src.Certno
  5736. // insutype := rf[0].Insutype
  5737. //
  5738. // if his.IdCardType == 1 {
  5739. // cert_no = his.MedicalInsuranceNumber
  5740. // } else {
  5741. // cert_no = his.Certno
  5742. // }
  5743. //
  5744. // 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)
  5745. // var dat map[string]interface{}
  5746. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5747. // fmt.Println(dat)
  5748. // } else {
  5749. // fmt.Println(err)
  5750. // }
  5751. //
  5752. // userJSONBytes, _ := json.Marshal(dat)
  5753. //
  5754. //
  5755. //
  5756. // var res ResultSeven
  5757. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5758. // utils.ErrorLog("解析失败:%v", err)
  5759. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5760. // return
  5761. // }
  5762. // if res.Infcode == -1 {
  5763. // errlog := &models.HisOrderError{
  5764. // UserOrgId: adminUser.CurrentOrgId,
  5765. // Ctime: time.Now().Unix(),
  5766. // Mtime: time.Now().Unix(),
  5767. // Number: chrg_bchno,
  5768. // ErrMsg: res.ErrMsg,
  5769. // Status: 1,
  5770. // PatientId: id,
  5771. // RecordTime: recordDateTime,
  5772. // Stage: 6,
  5773. // }
  5774. // service.CreateErrMsgLog(errlog)
  5775. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5776. // return
  5777. // } else {
  5778. // order_src.OrderStatus = 2
  5779. // order_src.PayWay = pay_way
  5780. // order_src.PayPrice = pay_price
  5781. // order_src.PayCardNo = pay_card_no
  5782. // order_src.DiscountPrice = discount_price
  5783. // order_src.PreferentialPrice = preferential_price
  5784. // order_src.RealityPrice = reality_price
  5785. // order_src.FoundPrice = found_price
  5786. // order_src.MedicalInsurancePrice = medical_insurance_price
  5787. // order_src.PrivatePrice = private_price
  5788. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  5789. // order_src.SetlId = res.Output.Setlinfo.SetlID
  5790. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  5791. // order_src.PsnName = res.Output.Setlinfo.PsnName
  5792. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  5793. // order_src.Certno = res.Output.Setlinfo.Certno
  5794. // order_src.Gend = res.Output.Setlinfo.Gend
  5795. // order_src.Naty = res.Output.Setlinfo.Naty
  5796. // order_src.Age = res.Output.Setlinfo.Age
  5797. // order_src.Insutype = res.Output.Setlinfo.Insutype
  5798. // order_src.PsnType = res.Output.Setlinfo.PsnType
  5799. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5800. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  5801. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5802. // order_src.MedType = res.Output.Setlinfo.MedType
  5803. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5804. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5805. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5806. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5807. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5808. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5809. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  5810. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  5811. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5812. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  5813. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  5814. // order_src.MafPay = res.Output.Setlinfo.MafPay
  5815. // order_src.OthPay = res.Output.Setlinfo.OthPay
  5816. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5817. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5818. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  5819. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5820. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5821. // order_src.Balc = res.Output.Setlinfo.Balc
  5822. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5823. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5824. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  5825. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  5826. // order_src.Creator = order_src.Creator
  5827. // order_src.Modify = roles.ID
  5828. // order_src.RequestLog = src_resquest
  5829. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5830. // detailStr := string(setlDetail)
  5831. // order_src.SetlDetail = detailStr
  5832. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5833. // err = service.UpDateOrder(order_src)
  5834. //
  5835. // if err == nil {
  5836. // c.ServeSuccessJSON(map[string]interface{}{
  5837. // "msg": "结算成功",
  5838. // })
  5839. // } else {
  5840. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5841. // return
  5842. // }
  5843. // }
  5844. // }
  5845. //}
  5846. //退款
  5847. func (c *HisApiController) Refund() {
  5848. order_id, _ := c.GetInt64("order_id")
  5849. admin_user_id, _ := c.GetInt64("admin_user_id")
  5850. adminUser := c.GetAdminUserInfo()
  5851. var order models.HisOrder
  5852. order, _ = service.GetHisOrderByID(order_id)
  5853. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5854. if order.ID == 0 {
  5855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5856. return
  5857. }
  5858. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5859. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5860. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5861. if config.IsOpen == 1 { //对接了医保,走医保流程
  5862. var res ResultSixteen
  5863. var resSixteen10265 ResultSixteen10265
  5864. var src_resquest string
  5865. var result string
  5866. if miConfig.MdtrtareaAdmvs == "421300" {
  5867. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  5868. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5869. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5870. resp3, requestErr3 := http.Get(api3)
  5871. if requestErr3 != nil {
  5872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5873. return
  5874. }
  5875. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5876. if ioErr3 != nil {
  5877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5879. return
  5880. }
  5881. var respJSON3 map[string]interface{}
  5882. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5885. return
  5886. }
  5887. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5888. userJSONBytes3, _ := json.Marshal(respJSON3)
  5889. fmt.Println("log")
  5890. fmt.Println(string(userJSONBytes3))
  5891. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  5892. utils.ErrorLog("解析失败:%v", err)
  5893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5894. return
  5895. }
  5896. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5897. api3 := "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  5898. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5899. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  5900. resp3, requestErr3 := http.Get(api3)
  5901. if requestErr3 != nil {
  5902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5903. return
  5904. }
  5905. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5906. if ioErr3 != nil {
  5907. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5909. return
  5910. }
  5911. var respJSON3 map[string]interface{}
  5912. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5915. return
  5916. }
  5917. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5918. userJSONBytes3, _ := json.Marshal(respJSON3)
  5919. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  5920. utils.ErrorLog("解析失败:%v", err)
  5921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5922. return
  5923. }
  5924. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  5925. res.Output = resSixteen10265.Output
  5926. res.ErrMsg = resSixteen10265.ErrMsg
  5927. res.Cainfo = resSixteen10265.Cainfo
  5928. res.WarnMsg = resSixteen10265.WarnMsg
  5929. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  5930. res.Infcode = infocode
  5931. } else {
  5932. if miConfig.Code == "H15049901371" {
  5933. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5934. var dat map[string]interface{}
  5935. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5936. fmt.Println(dat)
  5937. } else {
  5938. fmt.Println(err)
  5939. }
  5940. saveLog(result, src_resquest, "2208", "退费")
  5941. userJSONBytes, _ := json.Marshal(dat)
  5942. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  5943. utils.ErrorLog("解析失败:%v", err)
  5944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5945. return
  5946. }
  5947. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  5948. res.Output = resSixteen10265.Output
  5949. res.ErrMsg = resSixteen10265.ErrMsg
  5950. res.Cainfo = resSixteen10265.Cainfo
  5951. res.WarnMsg = resSixteen10265.WarnMsg
  5952. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  5953. res.Infcode = infocode
  5954. } else {
  5955. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5956. var dat map[string]interface{}
  5957. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5958. fmt.Println(dat)
  5959. } else {
  5960. fmt.Println(err)
  5961. }
  5962. saveLog(result, src_resquest, "2208", "退费")
  5963. userJSONBytes, _ := json.Marshal(dat)
  5964. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5965. utils.ErrorLog("解析失败:%v", err)
  5966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5967. return
  5968. }
  5969. }
  5970. }
  5971. if res.Infcode == 0 {
  5972. var res2 ResultSix
  5973. var resSix10265 ResultSix10265
  5974. if miConfig.MdtrtareaAdmvs == "421300" {
  5975. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  5976. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5977. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5978. resp3, requestErr3 := http.Get(api3)
  5979. if requestErr3 != nil {
  5980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5981. return
  5982. }
  5983. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5984. if ioErr3 != nil {
  5985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5987. return
  5988. }
  5989. var respJSON3 map[string]interface{}
  5990. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5993. return
  5994. }
  5995. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5996. userJSONBytes3, _ := json.Marshal(respJSON3)
  5997. fmt.Println("log")
  5998. fmt.Println(string(userJSONBytes3))
  5999. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6000. utils.ErrorLog("解析失败:%v", err)
  6001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6002. return
  6003. }
  6004. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6005. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6006. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6007. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  6008. resp3, requestErr3 := http.Get(api3)
  6009. if requestErr3 != nil {
  6010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6011. return
  6012. }
  6013. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6014. if ioErr3 != nil {
  6015. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6017. return
  6018. }
  6019. var respJSON3 map[string]interface{}
  6020. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6021. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6023. return
  6024. }
  6025. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6026. userJSONBytes3, _ := json.Marshal(respJSON3)
  6027. fmt.Println("log")
  6028. fmt.Println(string(userJSONBytes3))
  6029. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6030. utils.ErrorLog("解析失败:%v", err)
  6031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6032. return
  6033. }
  6034. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6035. res2.Output = resSix10265.Output
  6036. res2.ErrMsg = resSix10265.ErrMsg
  6037. res2.Cainfo = resSix10265.Cainfo
  6038. res2.WarnMsg = resSix10265.WarnMsg
  6039. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6040. res2.Infcode = infocode
  6041. } else {
  6042. if miConfig.Code == "H15049901371" {
  6043. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6044. var dat map[string]interface{}
  6045. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6046. fmt.Println(dat)
  6047. } else {
  6048. fmt.Println(err)
  6049. }
  6050. saveLog(result2, src_request, "2205", "撤销明细")
  6051. userJSONBytes, _ := json.Marshal(dat)
  6052. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6053. utils.ErrorLog("解析失败:%v", err)
  6054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6055. return
  6056. }
  6057. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6058. res2.Output = resSix10265.Output
  6059. res2.ErrMsg = resSix10265.ErrMsg
  6060. res2.Cainfo = resSix10265.Cainfo
  6061. res2.WarnMsg = resSix10265.WarnMsg
  6062. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6063. res2.Infcode = infocode
  6064. } else {
  6065. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6066. var dat map[string]interface{}
  6067. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6068. fmt.Println(dat)
  6069. } else {
  6070. fmt.Println(err)
  6071. }
  6072. saveLog(result2, src_request, "2205", "撤销明细")
  6073. userJSONBytes, _ := json.Marshal(dat)
  6074. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6075. utils.ErrorLog("解析失败:%v", err)
  6076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6077. return
  6078. }
  6079. }
  6080. }
  6081. if res2.Infcode == 0 {
  6082. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  6083. if err == nil {
  6084. c.ServeSuccessJSON(map[string]interface{}{
  6085. "msg": "退费成功",
  6086. })
  6087. } else {
  6088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6089. return
  6090. }
  6091. } else {
  6092. c.ServeSuccessJSON(map[string]interface{}{
  6093. "code": -10,
  6094. "msg": res2.ErrMsg,
  6095. })
  6096. }
  6097. } else {
  6098. c.ServeSuccessJSON(map[string]interface{}{
  6099. "code": -10,
  6100. "msg": res.ErrMsg,
  6101. })
  6102. }
  6103. }
  6104. }
  6105. func (c *HisApiController) RefundNumber() {
  6106. record_time := c.GetString("record_time")
  6107. //patient_id, _ := c.GetInt64("patient_id")
  6108. admin_user_id, _ := c.GetInt64("admin_user_id")
  6109. his_patient_id, _ := c.GetInt64("id")
  6110. timeLayout := "2006-01-02"
  6111. loc, _ := time.LoadLocation("Local")
  6112. adminUser := c.GetAdminUserInfo()
  6113. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6114. fmt.Println(err)
  6115. if err != nil {
  6116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6117. return
  6118. }
  6119. recordDateTime := theTime.Unix()
  6120. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6121. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  6122. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6123. //order, _ := service.GetHisOrderByID(order_id)
  6124. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6125. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6126. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6127. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  6128. if count > 0 {
  6129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  6130. return
  6131. }
  6132. if config.IsOpen == 1 { //对接了医保,走医保流程
  6133. var res2 ResultSix
  6134. var resSix10265 ResultSix10265
  6135. if miConfig.MdtrtareaAdmvs == "421300" {
  6136. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  6137. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6138. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6139. resp3, requestErr3 := http.Get(api3)
  6140. if requestErr3 != nil {
  6141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6142. return
  6143. }
  6144. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6145. if ioErr3 != nil {
  6146. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6148. return
  6149. }
  6150. var respJSON3 map[string]interface{}
  6151. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6152. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6154. return
  6155. }
  6156. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6157. userJSONBytes3, _ := json.Marshal(respJSON3)
  6158. fmt.Println("log")
  6159. fmt.Println(string(userJSONBytes3))
  6160. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6161. utils.ErrorLog("解析失败:%v", err)
  6162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6163. return
  6164. }
  6165. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6166. api3 := "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6167. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6168. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  6169. resp3, requestErr3 := http.Get(api3)
  6170. if requestErr3 != nil {
  6171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6172. return
  6173. }
  6174. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6175. if ioErr3 != nil {
  6176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6178. return
  6179. }
  6180. var respJSON3 map[string]interface{}
  6181. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6184. return
  6185. }
  6186. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6187. userJSONBytes3, _ := json.Marshal(respJSON3)
  6188. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6189. utils.ErrorLog("解析失败:%v", err)
  6190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6191. return
  6192. }
  6193. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6194. res2.Output = resSix10265.Output
  6195. res2.ErrMsg = resSix10265.ErrMsg
  6196. res2.Cainfo = resSix10265.Cainfo
  6197. res2.WarnMsg = resSix10265.WarnMsg
  6198. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6199. res2.Infcode = infocode
  6200. } else {
  6201. var api3 string
  6202. if miConfig.Code == "H15049901371" {
  6203. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6204. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6205. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6206. } else {
  6207. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6208. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6209. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6210. }
  6211. resp3, requestErr3 := http.Get(api3)
  6212. if requestErr3 != nil {
  6213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6214. return
  6215. }
  6216. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6217. if ioErr3 != nil {
  6218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6220. return
  6221. }
  6222. var respJSON3 map[string]interface{}
  6223. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6226. return
  6227. }
  6228. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6229. userJSONBytes3, _ := json.Marshal(respJSON3)
  6230. if miConfig.Code == "H15049901371" {
  6231. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6232. utils.ErrorLog("解析失败:%v", err)
  6233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6234. return
  6235. }
  6236. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6237. res2.Output = resSix10265.Output
  6238. res2.ErrMsg = resSix10265.ErrMsg
  6239. res2.Cainfo = resSix10265.Cainfo
  6240. res2.WarnMsg = resSix10265.WarnMsg
  6241. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6242. res2.Infcode = infocode
  6243. } else {
  6244. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6245. utils.ErrorLog("解析失败:%v", err)
  6246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6247. return
  6248. }
  6249. }
  6250. }
  6251. if res2.Infcode == 0 {
  6252. if err == nil {
  6253. c.ServeSuccessJSON(map[string]interface{}{
  6254. "msg": "退号成功",
  6255. })
  6256. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  6257. } else {
  6258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6259. return
  6260. }
  6261. } else {
  6262. c.ServeSuccessJSON(map[string]interface{}{
  6263. "code": -10,
  6264. "msg": res2.ErrMsg,
  6265. })
  6266. }
  6267. } else {
  6268. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  6269. //if err == nil {
  6270. // c.ServeSuccessJSON(map[string]interface{}{
  6271. // "msg": "退费成功",
  6272. // })
  6273. //} else {
  6274. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6275. // return
  6276. //}
  6277. }
  6278. }
  6279. func (c *HisApiController) RefundDetail() {
  6280. order_id, _ := c.GetInt64("order_id")
  6281. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6282. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6283. number := c.GetString("number")
  6284. record_time := c.GetString("record_time")
  6285. patient_id, _ := c.GetInt64("patient_id")
  6286. timeLayout := "2006-01-02"
  6287. loc, _ := time.LoadLocation("Local")
  6288. adminUser := c.GetAdminUserInfo()
  6289. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6290. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6291. fmt.Println(err)
  6292. if err != nil {
  6293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6294. return
  6295. }
  6296. recordDateTime := theTime.Unix()
  6297. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6298. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6299. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6300. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6301. var order models.HisOrder
  6302. order, _ = service.GetHisOrderByID(order_id)
  6303. if order.ID == 0 {
  6304. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  6305. }
  6306. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6307. if config.IsOpen == 1 { //对接了医保,走医保流程
  6308. var res2 ResultSix
  6309. if miConfig.MdtrtareaAdmvs == "421300" {
  6310. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6311. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6312. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6313. resp3, requestErr3 := http.Get(api3)
  6314. if requestErr3 != nil {
  6315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6316. return
  6317. }
  6318. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6319. if ioErr3 != nil {
  6320. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6322. return
  6323. }
  6324. var respJSON3 map[string]interface{}
  6325. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6326. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6328. return
  6329. }
  6330. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6331. userJSONBytes3, _ := json.Marshal(respJSON3)
  6332. fmt.Println("log")
  6333. fmt.Println(string(userJSONBytes3))
  6334. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6335. utils.ErrorLog("解析失败:%v", err)
  6336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6337. return
  6338. }
  6339. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6340. if err == nil {
  6341. c.ServeSuccessJSON(map[string]interface{}{
  6342. "msg": "撤销明细成功",
  6343. })
  6344. return
  6345. } else {
  6346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6347. return
  6348. }
  6349. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6350. var resSix10265 ResultSix10265
  6351. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6352. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6353. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  6354. resp3, requestErr3 := http.Get(api3)
  6355. if requestErr3 != nil {
  6356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6357. return
  6358. }
  6359. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6360. if ioErr3 != nil {
  6361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6363. return
  6364. }
  6365. var respJSON3 map[string]interface{}
  6366. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6369. return
  6370. }
  6371. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6372. userJSONBytes3, _ := json.Marshal(respJSON3)
  6373. fmt.Println("log")
  6374. fmt.Println(string(userJSONBytes3))
  6375. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6376. utils.ErrorLog("解析失败:%v", err)
  6377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6378. return
  6379. }
  6380. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6381. res2.Output = resSix10265.Output
  6382. res2.ErrMsg = resSix10265.ErrMsg
  6383. res2.Cainfo = resSix10265.Cainfo
  6384. res2.WarnMsg = resSix10265.WarnMsg
  6385. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6386. res2.Infcode = infocode
  6387. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6388. if err == nil {
  6389. c.ServeSuccessJSON(map[string]interface{}{
  6390. "msg": "撤销明细成功",
  6391. })
  6392. return
  6393. } else {
  6394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6395. return
  6396. }
  6397. } else {
  6398. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  6399. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6400. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6401. resp2, requestErr2 := http.Get(api2)
  6402. if requestErr2 != nil {
  6403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6404. return
  6405. }
  6406. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6407. if ioErr2 != nil {
  6408. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6410. return
  6411. }
  6412. var respJSON2 map[string]interface{}
  6413. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6414. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6416. return
  6417. }
  6418. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6419. if err == nil {
  6420. c.ServeSuccessJSON(map[string]interface{}{
  6421. "msg": "撤销明细成功",
  6422. })
  6423. return
  6424. } else {
  6425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6426. return
  6427. }
  6428. }
  6429. } else {
  6430. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6431. if err == nil {
  6432. c.ServeSuccessJSON(map[string]interface{}{
  6433. "msg": "退费成功",
  6434. })
  6435. } else {
  6436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6437. return
  6438. }
  6439. }
  6440. }
  6441. //对账
  6442. func (c *HisApiController) GetCheckAccount() {
  6443. start_time := c.GetString("start_time")
  6444. end_time := c.GetString("end_time")
  6445. insutype := c.GetString("insutype")
  6446. clr_type := c.GetString("clr_type")
  6447. clr_org := c.GetString("clr_optins")
  6448. admin_user_id, _ := c.GetInt64("admin_user_id")
  6449. adminUser := c.GetAdminUserInfo()
  6450. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6451. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6452. if len(clr_org) == 0 {
  6453. clr_org = miConfig.MdtrtareaAdmvs
  6454. }
  6455. timeLayout := "2006-01-02"
  6456. loc, _ := time.LoadLocation("Local")
  6457. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6458. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6459. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  6460. fixmedins_setl_cnt := int64(len(orders))
  6461. var medfee_sumamt float64
  6462. var acct_pay float64
  6463. var fund_pay_sumamt float64
  6464. for _, item := range orders {
  6465. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6466. acct_pay = acct_pay + item.AcctPay
  6467. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6468. }
  6469. var user_name string
  6470. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6471. if role.ID == 0 {
  6472. user_name = "xxx"
  6473. } else {
  6474. user_name = role.UserName
  6475. }
  6476. if config.IsOpen == 1 {
  6477. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6478. "insutype=" + insutype +
  6479. "&clr_type=" + clr_type +
  6480. "&setl_optins=" + clr_org +
  6481. "&stmt_begndate=" + start_time +
  6482. "&stm_enddate=" + end_time +
  6483. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6484. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6485. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  6486. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6487. "&fixmedins_code=" + miConfig.Code +
  6488. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6489. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6490. "&secret_key=" + miConfig.SecretKey +
  6491. "&org_name=" + miConfig.OrgName +
  6492. "&doctor=" + user_name
  6493. fmt.Println(api)
  6494. resp, requestErr := http.Get(api)
  6495. if requestErr != nil {
  6496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6497. return
  6498. }
  6499. body, ioErr := ioutil.ReadAll(resp.Body)
  6500. fmt.Println(body)
  6501. if ioErr != nil {
  6502. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6504. return
  6505. }
  6506. var respJSON map[string]interface{}
  6507. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6510. return
  6511. }
  6512. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6513. userJSONBytes, _ := json.Marshal(respJSON)
  6514. var res ResultEight
  6515. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6516. utils.ErrorLog("解析失败:%v", err)
  6517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6518. return
  6519. }
  6520. if res.Infcode == 0 {
  6521. if res.Output.Stmtinfo.StmtRslt == "0" {
  6522. micc := &models.MedicalInsuranceCostCompare{
  6523. StartTime: startime.Unix(),
  6524. EndTime: endtime.Unix(),
  6525. Insutype: insutype,
  6526. CheckType: 1,
  6527. Num: fixmedins_setl_cnt,
  6528. Mtime: time.Now().Unix(),
  6529. Status: 1,
  6530. UserOrgId: adminUser.CurrentOrgId,
  6531. CostTotal: medfee_sumamt,
  6532. FuncTotal: fund_pay_sumamt,
  6533. PsnPay: acct_pay,
  6534. Creator: admin_user_id,
  6535. Ctime: time.Now().Unix(),
  6536. }
  6537. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  6538. if err == nil {
  6539. c.ServeSuccessJSON(map[string]interface{}{
  6540. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  6541. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  6542. })
  6543. } else {
  6544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6545. }
  6546. } else {
  6547. c.ServeSuccessJSON(map[string]interface{}{
  6548. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  6549. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  6550. })
  6551. }
  6552. } else {
  6553. c.ServeSuccessJSON(map[string]interface{}{
  6554. "code": -10,
  6555. "msg": res.ErrMsg,
  6556. })
  6557. }
  6558. }
  6559. }
  6560. func (c *HisApiController) Check310() {
  6561. adminUser := c.GetAdminUserInfo()
  6562. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6563. var user_name string
  6564. user_name = "高慧裕"
  6565. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6566. "insutype=" + "310" +
  6567. "&clr_type=" + "11" +
  6568. "&setl_optins=" + "441202" +
  6569. "&stmt_begndate=" + "2022-02-01" +
  6570. "&stm_enddate=" + "2022-02-28" +
  6571. "&medfee_sumamt=" + "155812.88" +
  6572. "&fund_pay_sumamt=" + "151026.15" +
  6573. "&acct_pay=" + "0" +
  6574. "&fixmedins_setl_cnt=" + "73" +
  6575. "&fixmedins_code=" + miConfig.Code +
  6576. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6577. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6578. "&secret_key=" + miConfig.SecretKey +
  6579. "&org_name=" + miConfig.OrgName +
  6580. "&doctor=" + user_name
  6581. fmt.Println(api)
  6582. resp, requestErr := http.Get(api)
  6583. if requestErr != nil {
  6584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6585. return
  6586. }
  6587. body, ioErr := ioutil.ReadAll(resp.Body)
  6588. fmt.Println(body)
  6589. if ioErr != nil {
  6590. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6592. return
  6593. }
  6594. var respJSON map[string]interface{}
  6595. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6596. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6598. return
  6599. }
  6600. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6601. userJSONBytes, _ := json.Marshal(respJSON)
  6602. var res ResultEight
  6603. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6604. utils.ErrorLog("解析失败:%v", err)
  6605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6606. return
  6607. }
  6608. }
  6609. func (c *HisApiController) Check390() {
  6610. adminUser := c.GetAdminUserInfo()
  6611. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6612. var user_name string
  6613. user_name = "高慧裕"
  6614. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6615. "insutype=" + "390" +
  6616. "&clr_type=" + "11" +
  6617. "&setl_optins=" + "441202" +
  6618. "&stmt_begndate=" + "2022-02-01" +
  6619. "&stm_enddate=" + "2022-02-28" +
  6620. "&medfee_sumamt=" + "933920.08" +
  6621. "&fund_pay_sumamt=" + "887153.34" +
  6622. "&acct_pay=" + "0" +
  6623. "&fixmedins_setl_cnt=" + "396" +
  6624. "&fixmedins_code=" + miConfig.Code +
  6625. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6626. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6627. "&secret_key=" + miConfig.SecretKey +
  6628. "&org_name=" + miConfig.OrgName +
  6629. "&doctor=" + user_name
  6630. fmt.Println(api)
  6631. resp, requestErr := http.Get(api)
  6632. if requestErr != nil {
  6633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6634. return
  6635. }
  6636. body, ioErr := ioutil.ReadAll(resp.Body)
  6637. fmt.Println(body)
  6638. if ioErr != nil {
  6639. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6641. return
  6642. }
  6643. var respJSON map[string]interface{}
  6644. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6645. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6647. return
  6648. }
  6649. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6650. userJSONBytes, _ := json.Marshal(respJSON)
  6651. var res ResultEight
  6652. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6653. utils.ErrorLog("解析失败:%v", err)
  6654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6655. return
  6656. }
  6657. }
  6658. //对账明细
  6659. func (c *HisApiController) GetCheckDetailAccount() {
  6660. start_time := c.GetString("start_time")
  6661. end_time := c.GetString("end_time")
  6662. admin_user_id, _ := c.GetInt64("admin_user_id")
  6663. adminUser := c.GetAdminUserInfo()
  6664. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6665. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6666. timeLayout := "2006-01-02"
  6667. loc, _ := time.LoadLocation("Local")
  6668. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6669. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6670. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  6671. Mkdir(miConfig.OrgName)
  6672. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  6673. file_name := file + ".txt"
  6674. zip_name := file + ".zip"
  6675. zip_path := miConfig.OrgName + "/" + zip_name
  6676. file_path := miConfig.OrgName + "/" + file_name
  6677. decimal.DivisionPrecision = 2
  6678. var medfee_sumamt float64
  6679. var psn_cash_pay float64
  6680. var fund_pay_sumamt float64
  6681. fixmedins_setl_cnt := int64(len(orders))
  6682. for _, item := range orders {
  6683. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6684. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  6685. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6686. }
  6687. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  6688. defer f.Close()
  6689. if err != nil {
  6690. fmt.Println(err.Error())
  6691. } else {
  6692. for _, item := range orders {
  6693. var refd_setl_flag string
  6694. if item.OrderStatus == 2 {
  6695. refd_setl_flag = "0"
  6696. var str string
  6697. str = item.SetlId + " " +
  6698. item.MdtrtId + " " +
  6699. item.PsnNo + " " +
  6700. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  6701. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  6702. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  6703. _, err = f.Write([]byte(str))
  6704. }
  6705. if item.OrderStatus == 3 {
  6706. var str string
  6707. str = item.SetlId + " " +
  6708. item.MdtrtId + " " +
  6709. item.PsnNo + " " +
  6710. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  6711. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  6712. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  6713. _, err = f.Write([]byte(str))
  6714. var str2 string
  6715. str2 = item.SetlId + " " +
  6716. item.MdtrtId + " " +
  6717. item.PsnNo + " " +
  6718. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  6719. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  6720. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  6721. _, err = f.Write([]byte(str2))
  6722. }
  6723. }
  6724. }
  6725. Zip(file_path, zip_path)
  6726. fmt.Println(ReadFile(zip_path))
  6727. fmt.Println(string(ReadFile(zip_path)))
  6728. if config.IsOpen == 1 {
  6729. var user_name string
  6730. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6731. if role.ID == 0 {
  6732. user_name = "管理员"
  6733. } else {
  6734. user_name = role.UserName
  6735. }
  6736. baseParams := models.BaseParams{
  6737. SecretKey: miConfig.SecretKey,
  6738. FixmedinsCode: miConfig.Code,
  6739. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6740. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6741. OrgName: miConfig.OrgName,
  6742. Doctor: user_name,
  6743. }
  6744. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  6745. var dat map[string]interface{}
  6746. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6747. fmt.Println(dat)
  6748. } else {
  6749. fmt.Println(err)
  6750. }
  6751. userJSONBytes, _ := json.Marshal(dat)
  6752. var res ResultNine
  6753. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6754. utils.ErrorLog("解析失败:%v", err)
  6755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6756. return
  6757. }
  6758. if res.Infcode == 0 {
  6759. fileNo := res.Output.FileQuryNo
  6760. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  6761. "file_qury_no=" + fileNo +
  6762. "&setl_optins=" + "定点医保中心" +
  6763. "&stmt_begndate=" + start_time +
  6764. "&stm_enddate=" + end_time +
  6765. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6766. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6767. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  6768. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6769. "&fixmedins_code=" + miConfig.Code +
  6770. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6771. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6772. "&secret_key=" + miConfig.SecretKey +
  6773. "&org_name=" + miConfig.OrgName +
  6774. "&doctor=" + user_name
  6775. resp, requestErr := http.Get(api)
  6776. if requestErr != nil {
  6777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6778. return
  6779. }
  6780. body, ioErr := ioutil.ReadAll(resp.Body)
  6781. if ioErr != nil {
  6782. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6784. return
  6785. }
  6786. var respJSON map[string]interface{}
  6787. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6788. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6790. return
  6791. }
  6792. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6793. userJSONBytes, _ := json.Marshal(respJSON)
  6794. var res ResultTen
  6795. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6796. utils.ErrorLog("解析失败:%v", err)
  6797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6798. return
  6799. }
  6800. if res.Infcode == 0 {
  6801. service.Gdyb9102(baseParams, zip_name, fileNo)
  6802. micc := &models.MedicalInsuranceCostCompare{
  6803. StartTime: startime.Unix(),
  6804. EndTime: endtime.Unix(),
  6805. Insutype: "0",
  6806. CheckType: 2,
  6807. Num: fixmedins_setl_cnt,
  6808. Mtime: time.Now().Unix(),
  6809. Status: 1,
  6810. UserOrgId: adminUser.CurrentOrgId,
  6811. CostTotal: medfee_sumamt,
  6812. FuncTotal: fund_pay_sumamt,
  6813. PsnPay: psn_cash_pay,
  6814. Creator: admin_user_id,
  6815. Ctime: time.Now().Unix(),
  6816. }
  6817. service.CreateMedicalInsuranceCostCompareRecord(micc)
  6818. c.ServeSuccessJSON(map[string]interface{}{
  6819. "msg": "明细对账成功",
  6820. })
  6821. }
  6822. } else {
  6823. }
  6824. }
  6825. }
  6826. type CustomOrderInfo struct {
  6827. Name string
  6828. Spec string
  6829. Unit string
  6830. Count float64
  6831. Price float64
  6832. Total float64
  6833. }
  6834. func (c *HisApiController) GetSettleAccounts() {
  6835. //id, _ := c.GetInt64("id")
  6836. //record_time := c.GetString("record_time")
  6837. order_id, _ := c.GetInt64("order_id")
  6838. admin_user_id, _ := c.GetInt64("admin_user_id")
  6839. //timeLayout := "2006-01-02"
  6840. //loc, _ := time.LoadLocation("Local")
  6841. //
  6842. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6843. //if err != nil {
  6844. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6845. // return
  6846. //}
  6847. //recordDateTime := theTime.Unix()
  6848. adminUser := c.GetAdminUserInfo()
  6849. order, _ := service.GetHisOrderByID(order_id)
  6850. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6851. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  6852. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  6853. orderInfos = append(orderInfos, orderInfos_two...)
  6854. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  6855. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6856. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  6857. //var config []*models.HisXtDiagnoseConfig
  6858. var name string
  6859. for _, item := range diagnosis_ids {
  6860. id, _ := strconv.ParseInt(item, 10, 64)
  6861. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6862. if len(name) == 0 {
  6863. name = diagnosisConfig.ClassName
  6864. } else {
  6865. name = name + "," + diagnosisConfig.ClassName
  6866. }
  6867. }
  6868. var bedCostTotal float64 = 0 //床位总费
  6869. var bedCostSelfTotal float64 = 0 //床位自费
  6870. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  6871. var operationCostTotal float64 = 0 //手术费
  6872. var operationCostSelfTotal float64 = 0 //手术费
  6873. var operationCostPartSelfTotal float64 = 0 //手术费
  6874. var otherCostTotal float64 = 0 //其他费用
  6875. var otherCostSelfTotal float64 = 0 //其他费用
  6876. var otherCostPartSelfTotal float64 = 0 //其他费用
  6877. var materialCostTotal float64 = 0 //材料费
  6878. var materialCostSelfTotal float64 = 0 //材料费
  6879. var materialCostPartSelfTotal float64 = 0 //材料费
  6880. var westernMedicineCostTotal float64 = 0 //西药费
  6881. var westernMedicineCostSelfTotal float64 = 0 //西药费
  6882. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  6883. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  6884. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  6885. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  6886. var checkCostTotal float64 = 0 //检查费
  6887. var checkCostSelfTotal float64 = 0 //检查费
  6888. var checkCostPartSelfTotal float64 = 0 //检查费
  6889. var laboratoryCostTotal float64 = 0 //化验费
  6890. var laboratoryCostSelfTotal float64 = 0 //化验费
  6891. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  6892. var treatCostTotal float64 = 0 //治疗费用
  6893. var treatCostSelfTotal float64 = 0 //治疗费用
  6894. var treatCostPartSelfTotal float64 = 0 //治疗费用
  6895. decimal.DivisionPrecision = 2
  6896. for _, item := range orderInfos {
  6897. if item.MedChrgitmType == "01" { //床位费
  6898. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6899. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6900. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6901. }
  6902. if item.MedChrgitmType == "03" { //检查费
  6903. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6904. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6905. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6906. }
  6907. if item.MedChrgitmType == "04" { //化验费
  6908. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6909. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6910. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6911. }
  6912. if item.MedChrgitmType == "05" { //治疗费
  6913. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6914. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6915. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6916. }
  6917. if item.MedChrgitmType == "06" { //手术费
  6918. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6919. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6920. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6921. }
  6922. if item.MedChrgitmType == "08" { //材料费
  6923. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6924. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6925. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6926. }
  6927. if item.MedChrgitmType == "09" { //西药费
  6928. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6929. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6930. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6931. }
  6932. if item.MedChrgitmType == "11" { //中成费
  6933. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6934. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6935. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6936. }
  6937. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  6938. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6939. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6940. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6941. }
  6942. }
  6943. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6944. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6945. var user_name string
  6946. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6947. if role.ID == 0 {
  6948. user_name = "管理员"
  6949. } else {
  6950. user_name = role.UserName
  6951. }
  6952. baseParams := models.BaseParams{
  6953. SecretKey: miConfig.SecretKey,
  6954. FixmedinsCode: miConfig.Code,
  6955. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6956. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6957. OrgName: miConfig.OrgName,
  6958. Doctor: user_name,
  6959. }
  6960. businessParams := models.BusinessParams{
  6961. PsnNo: order.PsnNo,
  6962. MdtrtId: order.MdtrtId,
  6963. SetlId: order.SetlId,
  6964. }
  6965. var res ResultEleven
  6966. var resEleven10265 ResultEleven10265
  6967. if config.IsOpen == 1 {
  6968. if miConfig.MdtrtareaAdmvs == "421300" {
  6969. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  6970. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  6971. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6972. resp, requestErr := http.Get(api)
  6973. if requestErr != nil {
  6974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6975. return
  6976. }
  6977. body, ioErr := ioutil.ReadAll(resp.Body)
  6978. if ioErr != nil {
  6979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6981. return
  6982. }
  6983. var respJSON map[string]interface{}
  6984. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6987. return
  6988. }
  6989. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6990. result, _ := json.Marshal(respJSON)
  6991. fmt.Println("log")
  6992. fmt.Println(string(result))
  6993. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6994. utils.ErrorLog("解析失败:%v", err)
  6995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6996. return
  6997. }
  6998. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6999. api := "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7000. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7001. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  7002. resp, requestErr := http.Get(api)
  7003. if requestErr != nil {
  7004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7005. return
  7006. }
  7007. body, ioErr := ioutil.ReadAll(resp.Body)
  7008. if ioErr != nil {
  7009. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7011. return
  7012. }
  7013. var respJSON map[string]interface{}
  7014. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7017. return
  7018. }
  7019. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7020. result, _ := json.Marshal(respJSON)
  7021. fmt.Println("log")
  7022. fmt.Println(string(result))
  7023. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  7024. utils.ErrorLog("解析失败:%v", err)
  7025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7026. return
  7027. }
  7028. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7029. res.Output = resEleven10265.Output
  7030. res.ErrMsg = resEleven10265.ErrMsg
  7031. res.Cainfo = resEleven10265.Cainfo
  7032. res.WarnMsg = resEleven10265.WarnMsg
  7033. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7034. res.Infcode = infocode
  7035. } else {
  7036. result2 := service.Gdyb5204(baseParams, businessParams)
  7037. saveLog(result2, "", "5204", "查询")
  7038. result := service.Gdyb5203(baseParams, businessParams)
  7039. var dat map[string]interface{}
  7040. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7041. fmt.Println(dat)
  7042. } else {
  7043. fmt.Println(err)
  7044. }
  7045. userJSONBytes, _ := json.Marshal(dat)
  7046. if miConfig.Code == "H15049901371" {
  7047. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  7048. utils.ErrorLog("解析失败:%v", err)
  7049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7050. return
  7051. }
  7052. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7053. res.Output = resEleven10265.Output
  7054. res.ErrMsg = resEleven10265.ErrMsg
  7055. res.Cainfo = resEleven10265.Cainfo
  7056. res.WarnMsg = resEleven10265.WarnMsg
  7057. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7058. res.Infcode = infocode
  7059. } else {
  7060. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7061. utils.ErrorLog("解析失败:%v", err)
  7062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7063. return
  7064. }
  7065. }
  7066. }
  7067. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7068. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  7069. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  7070. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7071. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7072. var doctor_name string
  7073. if roles.ID == 0 {
  7074. doctor_name = "管理员"
  7075. } else {
  7076. doctor_name = roles.UserName
  7077. }
  7078. yiliao_leibie := ""
  7079. switch order.MedType {
  7080. case "11":
  7081. yiliao_leibie = "普通门诊"
  7082. break
  7083. case "12":
  7084. yiliao_leibie = "门诊挂号"
  7085. break
  7086. case "13":
  7087. yiliao_leibie = "急诊"
  7088. break
  7089. case "14":
  7090. yiliao_leibie = "门诊特殊病"
  7091. break
  7092. case "15":
  7093. yiliao_leibie = "门诊统筹"
  7094. break
  7095. case "16":
  7096. yiliao_leibie = "门诊慢性病"
  7097. break
  7098. case "21":
  7099. yiliao_leibie = "普通住院"
  7100. break
  7101. }
  7102. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7103. if res.Infcode == 0 {
  7104. c.ServeSuccessJSON(map[string]interface{}{
  7105. "diagnosis": name,
  7106. "order_infos": orderInfos,
  7107. "number": order.MdtrtId,
  7108. "date": order.SettleAccountsDate,
  7109. "charge_admin": charge_admin,
  7110. "printor_admin": printor_admin,
  7111. "info": res.Output.Setlinfo,
  7112. "bedCostTotal": bedCostTotal,
  7113. "bedCostSelfTotal": bedCostSelfTotal,
  7114. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  7115. "operationCostTotal": operationCostTotal,
  7116. "operationCostSelfTotal": operationCostSelfTotal,
  7117. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  7118. "otherCostTotal": otherCostTotal,
  7119. "otherCostSelfTotal": otherCostSelfTotal,
  7120. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  7121. "materialCostTotal": materialCostTotal,
  7122. "materialCostSelfTotal": materialCostSelfTotal,
  7123. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  7124. "westernMedicineCostTotal": westernMedicineCostTotal,
  7125. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  7126. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  7127. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  7128. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  7129. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  7130. "checkCostTotal": checkCostTotal,
  7131. "checkCostSelfTotal": checkCostSelfTotal,
  7132. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  7133. "laboratoryCostTotal": laboratoryCostTotal,
  7134. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  7135. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  7136. "treatCostTotal": treatCostTotal,
  7137. "treatCostSelfTotal": treatCostSelfTotal,
  7138. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  7139. "doctor_code": adminRole_two.DoctorCode,
  7140. "doctor_name": doctor_name,
  7141. "health_card_no": order.PsnNo,
  7142. "department": departments.Name,
  7143. "yiliao_leibie": yiliao_leibie,
  7144. "after_money": order.AccountPrice,
  7145. "patient": patient,
  7146. "org_name": miConfig.OrgName,
  7147. "org_code": miConfig.Code,
  7148. "order_number": order.Number,
  7149. //"check_order_info": cus_slice,
  7150. })
  7151. }
  7152. }
  7153. }
  7154. func (c *HisApiController) CheckTreatment() {
  7155. patient_id, _ := c.GetInt64("patient_id")
  7156. id_card_no := c.GetString("id_card_no")
  7157. insutype := c.GetString("insutype")
  7158. med_type := c.GetString("med_type")
  7159. admin_user_id, _ := c.GetInt64("admin_user_id")
  7160. adminUser := c.GetAdminUserInfo()
  7161. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7162. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7163. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7164. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7165. if miConfig.MdtrtareaAdmvs == "421300" {
  7166. var res ResultTwo
  7167. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7168. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7169. "&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)
  7170. resp, requestErr := http.Get(api)
  7171. if requestErr != nil {
  7172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7173. return
  7174. }
  7175. body, ioErr := ioutil.ReadAll(resp.Body)
  7176. if ioErr != nil {
  7177. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7179. return
  7180. }
  7181. var respJSON map[string]interface{}
  7182. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7185. return
  7186. }
  7187. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7188. result, _ := json.Marshal(respJSON)
  7189. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7190. utils.ErrorLog("解析失败:%v", err)
  7191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7192. return
  7193. }
  7194. if res.Infcode == 0 {
  7195. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  7196. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7197. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  7198. resp, requestErr := http.Get(api)
  7199. if requestErr != nil {
  7200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7201. return
  7202. }
  7203. body, ioErr := ioutil.ReadAll(resp.Body)
  7204. if ioErr != nil {
  7205. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7207. return
  7208. }
  7209. var respJSON map[string]interface{}
  7210. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7211. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7213. return
  7214. }
  7215. var res Result2001
  7216. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7217. result2, _ := json.Marshal(respJSON)
  7218. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  7219. utils.ErrorLog("解析失败:%v", err)
  7220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7221. return
  7222. }
  7223. if res.Infcode == 0 {
  7224. c.ServeSuccessJSON(map[string]interface{}{
  7225. "msg": res.Output.Trtinfo,
  7226. })
  7227. }
  7228. } else {
  7229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7230. return
  7231. }
  7232. } else {
  7233. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7234. var dat map[string]interface{}
  7235. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7236. fmt.Println(dat)
  7237. } else {
  7238. fmt.Println(err)
  7239. }
  7240. userJSONBytes, _ := json.Marshal(dat)
  7241. var res ResultTwo
  7242. var res10265 ResultTwo10265
  7243. if miConfig.Code == "H15049901371" {
  7244. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7245. utils.ErrorLog("解析失败:%v", err)
  7246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7247. return
  7248. }
  7249. res.ErrMsg = res10265.ErrMsg
  7250. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7251. res.Infcode = infocode
  7252. res.Output = res10265.Output
  7253. res.InfRefmsgid = res10265.InfRefmsgid
  7254. } else {
  7255. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7256. utils.ErrorLog("解析失败:%v", err)
  7257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7258. return
  7259. }
  7260. }
  7261. var user_name string
  7262. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  7263. if role.ID == 0 {
  7264. user_name = "xxx"
  7265. } else {
  7266. user_name = role.UserName
  7267. }
  7268. baseParams := models.BaseParams{
  7269. SecretKey: miConfig.SecretKey,
  7270. FixmedinsCode: miConfig.Code,
  7271. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7272. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7273. OrgName: miConfig.OrgName,
  7274. Doctor: user_name,
  7275. }
  7276. if config.IsOpen == 1 {
  7277. if miConfig.Code == "H15049901371" {
  7278. if med_type == "14" {
  7279. if insutype == "390" {
  7280. med_type = "9933"
  7281. } else if insutype == "310" {
  7282. med_type = "990502"
  7283. }
  7284. } else if med_type == "11" {
  7285. med_type = "11"
  7286. }
  7287. }
  7288. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  7289. var dat map[string]interface{}
  7290. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7291. fmt.Println(dat)
  7292. } else {
  7293. fmt.Println(err)
  7294. }
  7295. var res Result2001
  7296. var res10265 Result2001Org10265
  7297. if miConfig.Code == "H15049901371" {
  7298. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7299. utils.ErrorLog("解析失败:%v", err)
  7300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7301. return
  7302. }
  7303. res.ErrMsg = res10265.ErrMsg
  7304. res.Output = res10265.Output
  7305. res.InfRefmsgid = res10265.InfRefmsgid
  7306. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7307. res.Infcode = infocode
  7308. } else {
  7309. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7310. utils.ErrorLog("解析失败:%v", err)
  7311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7312. return
  7313. }
  7314. }
  7315. if res.Infcode == 0 {
  7316. c.ServeSuccessJSON(map[string]interface{}{
  7317. "msg": res.Output.Trtinfo,
  7318. })
  7319. }
  7320. }
  7321. }
  7322. }
  7323. //func (c *HisApiController) PutRecord() {
  7324. // id, _ := c.GetInt64("id")
  7325. // record_time := c.GetString("record_time")
  7326. // timeLayout := "2006-01-02"
  7327. // loc, _ := time.LoadLocation("Local")
  7328. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7329. // if err != nil {
  7330. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7331. // return
  7332. // }
  7333. // recordDateTime := theTime.Unix()
  7334. //
  7335. // adminInfo := c.GetAdminUserInfo()
  7336. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  7337. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7338. //
  7339. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7340. //
  7341. // fmt.Println(miConfig.SecretKey)
  7342. //
  7343. // if patient == nil {
  7344. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7345. // return
  7346. // }
  7347. // if len(patient.IdCardNo) == 0 {
  7348. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7349. // return
  7350. // }
  7351. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7352. // if config.IsOpen == 1 {
  7353. // 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
  7354. // resp, requestErr := http.Get(api)
  7355. // if requestErr != nil {
  7356. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7357. // return
  7358. // }
  7359. // defer resp.Body.Close()
  7360. // body, ioErr := ioutil.ReadAll(resp.Body)
  7361. // if ioErr != nil {
  7362. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7363. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7364. // return
  7365. // }
  7366. // var respJSON map[string]interface{}
  7367. //
  7368. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7369. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7370. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7371. // return
  7372. // }
  7373. //
  7374. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7375. // userJSONBytes, _ := json.Marshal(userJSON)
  7376. // var res ResultTwo
  7377. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7378. // utils.ErrorLog("解析失败:%v", err)
  7379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7380. // return
  7381. // }
  7382. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7383. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7384. // infoStr := string(Iinfos)
  7385. // idetinfoStr := string(Idetinfos)
  7386. //
  7387. // if res.Infcode == 0 {
  7388. // his := models.VMHisPatient{
  7389. // Status: 1,
  7390. // Ctime: time.Now().Unix(),
  7391. // Mtime: time.Now().Unix(),
  7392. // PsnNo: res.Output.Baseinfo.PsnNo,
  7393. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  7394. // Certno: res.Output.Baseinfo.Certno,
  7395. // PsnName: res.Output.Baseinfo.PsnName,
  7396. // Gend: res.Output.Baseinfo.Gend,
  7397. // Naty: res.Output.Baseinfo.Naty,
  7398. // Brdy: res.Output.Baseinfo.Brdy,
  7399. // Age: res.Output.Baseinfo.Age,
  7400. // Iinfo: infoStr,
  7401. // Idetinfo: idetinfoStr,
  7402. // PatientId: patient.ID,
  7403. // RecordDate: theTime.Unix(),
  7404. // UserOrgId: adminInfo.CurrentOrgId,
  7405. // AdminUserId: adminInfo.AdminUser.Id,
  7406. // IsReturn: 1,
  7407. // }
  7408. //
  7409. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  7410. // //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")
  7411. // //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")
  7412. //
  7413. // //var dat map[string]interface{}
  7414. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7415. // // fmt.Println(dat)
  7416. // //} else {
  7417. // // fmt.Println(err)
  7418. // //}
  7419. //
  7420. // var dat2 map[string]interface{}
  7421. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  7422. // fmt.Println(dat2)
  7423. // } else {
  7424. // fmt.Println(err)
  7425. // }
  7426. //
  7427. // } else {
  7428. // adminUser := c.GetAdminUserInfo()
  7429. // errlog := &models.HisOrderError{
  7430. // UserOrgId: adminUser.CurrentOrgId,
  7431. // Ctime: time.Now().Unix(),
  7432. // Mtime: time.Now().Unix(),
  7433. // ErrMsg: res.ErrMsg,
  7434. // Status: 1,
  7435. // PatientId: id,
  7436. // RecordTime: recordDateTime,
  7437. // Stage: 1,
  7438. // }
  7439. // service.CreateErrMsgLog(errlog)
  7440. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  7441. // return
  7442. // }
  7443. // }
  7444. //
  7445. //}
  7446. //func (c *HisApiController) GetUploadDiag() {
  7447. // id, _ := c.GetInt64("id")
  7448. // record_time := c.GetString("record_time")
  7449. //
  7450. // diagnosis_id, _ := c.GetInt64("diagnosis")
  7451. // sick_type, _ := c.GetInt64("sick_type")
  7452. // reg_type, _ := c.GetInt64("reg_type")
  7453. //
  7454. // timeLayout := "2006-01-02"
  7455. // loc, _ := time.LoadLocation("Local")
  7456. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7457. // if err != nil {
  7458. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7459. // return
  7460. // }
  7461. //
  7462. // var patientPrescription models.HisPrescriptionInfo
  7463. // recordDateTime := theTime.Unix()
  7464. // adminInfo := c.GetAdminUserInfo()
  7465. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7466. //
  7467. // if patientPrescription.ID == 0 {
  7468. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7469. // }
  7470. //
  7471. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7472. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  7473. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7474. // sickConfig, _ := service.FindSickById(sick_type)
  7475. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7476. //
  7477. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  7478. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  7479. // "&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 +
  7480. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  7481. // resp2, requestErr2 := http.Get(api2)
  7482. // if requestErr2 != nil {
  7483. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7484. // return
  7485. // }
  7486. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7487. // if ioErr2 != nil {
  7488. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7489. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7490. // return
  7491. // }
  7492. // var respJSON2 map[string]interface{}
  7493. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7494. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7495. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7496. // return
  7497. // }
  7498. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7499. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7500. //
  7501. // var res2 ResultSix
  7502. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7503. // utils.ErrorLog("解析失败:%v", err)
  7504. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7505. // return
  7506. // }
  7507. // if res2.Infcode != 0 {
  7508. // adminUser := c.GetAdminUserInfo()
  7509. // errlog := &models.HisOrderError{
  7510. // UserOrgId: adminUser.CurrentOrgId,
  7511. // Ctime: time.Now().Unix(),
  7512. // Mtime: time.Now().Unix(),
  7513. // ErrMsg: res2.ErrMsg,
  7514. // Status: 1,
  7515. // PatientId: id,
  7516. // RecordTime: recordDateTime,
  7517. // Stage: 3,
  7518. // }
  7519. // service.CreateErrMsgLog(errlog)
  7520. //
  7521. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  7522. // return
  7523. // }
  7524. //
  7525. // c.ServeSuccessJSON(map[string]interface{}{
  7526. // "msg": "上传成功",
  7527. // })
  7528. //
  7529. //}
  7530. type QueryResult struct {
  7531. ID int64
  7532. Name string
  7533. Code string
  7534. List_type_code string
  7535. }
  7536. func (c *HisApiController) GetCheckCode() {
  7537. ids_str := c.GetString("ids")
  7538. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  7539. ids_arr := strings.Split(ids_str, ",")
  7540. var queryResult []QueryResult
  7541. ids := make([]int64, 0)
  7542. for _, item := range ids_arr {
  7543. id, _ := strconv.ParseInt(item, 10, 64)
  7544. ids = append(ids, id)
  7545. }
  7546. if record_type == 1 {
  7547. drugs, _ := service.GetBatchDrugList(ids)
  7548. for _, item := range drugs {
  7549. result := QueryResult{
  7550. ID: item.ID,
  7551. Name: item.DrugName,
  7552. Code: item.MedicalInsuranceNumber,
  7553. List_type_code: "101",
  7554. }
  7555. queryResult = append(queryResult, result)
  7556. }
  7557. } else if record_type == 2 {
  7558. goods, _ := service.GetBatchGoodInformationList(ids)
  7559. for _, item := range goods {
  7560. result := QueryResult{
  7561. ID: item.ID,
  7562. Name: item.GoodName,
  7563. Code: item.MedicalInsuranceNumber,
  7564. List_type_code: "301",
  7565. }
  7566. queryResult = append(queryResult, result)
  7567. }
  7568. } else if record_type == 3 {
  7569. projects, _ := service.GetBathchMyPorjecgList(ids)
  7570. for _, item := range projects {
  7571. result := QueryResult{
  7572. ID: item.ID,
  7573. Name: item.ProjectName,
  7574. Code: item.MedicalCode,
  7575. List_type_code: "201",
  7576. }
  7577. queryResult = append(queryResult, result)
  7578. }
  7579. }
  7580. admin_user_id, _ := c.GetInt64("admin_user_id")
  7581. adminUser := c.GetAdminUserInfo()
  7582. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7583. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7584. var user_name string
  7585. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7586. if role.ID == 0 {
  7587. user_name = "xxx"
  7588. } else {
  7589. user_name = role.UserName
  7590. }
  7591. baseParams := &models.BaseParams{
  7592. SecretKey: miConfig.SecretKey,
  7593. FixmedinsCode: miConfig.Code,
  7594. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7595. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7596. OrgName: miConfig.OrgName,
  7597. Doctor: user_name,
  7598. }
  7599. if config.IsOpen == 1 {
  7600. for _, item := range queryResult {
  7601. var result string
  7602. if record_type == 1 {
  7603. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7604. } else if record_type == 2 {
  7605. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7606. } else if record_type == 3 {
  7607. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7608. }
  7609. var dat map[string]interface{}
  7610. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7611. fmt.Println(dat)
  7612. } else {
  7613. fmt.Println(err)
  7614. }
  7615. userJSONBytes, _ := json.Marshal(dat)
  7616. var res ResultSix
  7617. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7618. utils.ErrorLog("解析失败:%v", err)
  7619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7620. return
  7621. }
  7622. if res.Infcode == 0 {
  7623. if record_type == 1 {
  7624. service.UpdateBaseDrugById(item.ID)
  7625. } else if record_type == 2 {
  7626. service.UpdateGoodInformaitonByDetail(item.ID)
  7627. } else if record_type == 3 {
  7628. service.UpdateProjectById(item.ID)
  7629. }
  7630. c.ServeSuccessJSON(map[string]interface{}{
  7631. "failed_code": 0,
  7632. "msg": "目录对照成功",
  7633. })
  7634. } else {
  7635. c.ServeSuccessJSON(map[string]interface{}{
  7636. "failed_code": -10,
  7637. "msg": res.ErrMsg,
  7638. })
  7639. }
  7640. }
  7641. }
  7642. }
  7643. func (c *HisApiController) UnCheckCode() {
  7644. ids_str := c.GetString("ids")
  7645. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  7646. admin_user_id, _ := c.GetInt64("admin_user_id")
  7647. ids_arr := strings.Split(ids_str, ",")
  7648. var queryResult []QueryResult
  7649. ids := make([]int64, 0)
  7650. for _, item := range ids_arr {
  7651. id, _ := strconv.ParseInt(item, 10, 64)
  7652. ids = append(ids, id)
  7653. }
  7654. if record_type == 1 {
  7655. drugs, _ := service.GetBatchDrugList(ids)
  7656. for _, item := range drugs {
  7657. result := QueryResult{
  7658. ID: item.ID,
  7659. Name: item.DrugName,
  7660. Code: item.MedicalInsuranceNumber,
  7661. List_type_code: "101",
  7662. }
  7663. queryResult = append(queryResult, result)
  7664. }
  7665. } else if record_type == 2 {
  7666. goods, _ := service.GetBatchGoodInformationList(ids)
  7667. for _, item := range goods {
  7668. result := QueryResult{
  7669. ID: item.ID,
  7670. Name: item.GoodName,
  7671. Code: item.MedicalInsuranceNumber,
  7672. List_type_code: "301",
  7673. }
  7674. queryResult = append(queryResult, result)
  7675. }
  7676. } else if record_type == 3 {
  7677. projects, _ := service.GetBathchMyPorjecgList(ids)
  7678. for _, item := range projects {
  7679. result := QueryResult{
  7680. ID: item.ID,
  7681. Name: item.ProjectName,
  7682. Code: item.MedicalCode,
  7683. List_type_code: "201",
  7684. }
  7685. queryResult = append(queryResult, result)
  7686. }
  7687. }
  7688. adminUser := c.GetAdminUserInfo()
  7689. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7690. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7691. var user_name string
  7692. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7693. if role.ID == 0 {
  7694. user_name = "xxx"
  7695. } else {
  7696. user_name = role.UserName
  7697. }
  7698. baseParams := &models.BaseParams{
  7699. SecretKey: miConfig.SecretKey,
  7700. FixmedinsCode: miConfig.Code,
  7701. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7702. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7703. OrgName: miConfig.OrgName,
  7704. Doctor: user_name,
  7705. }
  7706. if config.IsOpen == 1 {
  7707. for _, item := range queryResult {
  7708. var result string
  7709. if record_type == 1 {
  7710. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7711. } else if record_type == 2 {
  7712. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7713. } else if record_type == 3 {
  7714. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7715. }
  7716. var dat2 map[string]interface{}
  7717. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  7718. fmt.Println(dat2)
  7719. } else {
  7720. fmt.Println(err)
  7721. }
  7722. userJSONBytes, _ := json.Marshal(dat2)
  7723. var res ResultSix
  7724. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7725. utils.ErrorLog("解析失败:%v", err)
  7726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7727. return
  7728. }
  7729. if res.Infcode == 0 {
  7730. if record_type == 1 {
  7731. service.UpdateDrugByIdDetail(item.ID)
  7732. } else if record_type == 2 {
  7733. service.UpdateGoodInfoById(item.ID)
  7734. } else if record_type == 3 {
  7735. service.UpdateMyProjectById(item.ID)
  7736. }
  7737. c.ServeSuccessJSON(map[string]interface{}{
  7738. "failed_code": 0,
  7739. "msg": "撤销目录对照成功",
  7740. })
  7741. } else {
  7742. c.ServeSuccessJSON(map[string]interface{}{
  7743. "failed_code": -10,
  7744. "msg": res.ErrMsg,
  7745. })
  7746. }
  7747. }
  7748. }
  7749. }
  7750. func (c *HisApiController) GetPatientInfo() {
  7751. id_card_no := c.GetString("id_card_no")
  7752. admin_user_id, _ := c.GetInt64("admin_user_id")
  7753. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  7754. if patient.ID == 0 {
  7755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7756. return
  7757. }
  7758. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7759. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7760. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  7761. if config.IsOpen == 1 {
  7762. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7763. var dat map[string]interface{}
  7764. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7765. fmt.Println(dat)
  7766. } else {
  7767. fmt.Println(err)
  7768. }
  7769. userJSONBytes, _ := json.Marshal(dat)
  7770. var res ResultTwo
  7771. var res10265 ResultTwo10265
  7772. if miConfig.Code == "H15049901371" {
  7773. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7774. utils.ErrorLog("解析失败:%v", err)
  7775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7776. return
  7777. }
  7778. res.ErrMsg = res10265.ErrMsg
  7779. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7780. res.Infcode = infocode
  7781. res.Output = res10265.Output
  7782. res.InfRefmsgid = res10265.InfRefmsgid
  7783. } else {
  7784. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7785. utils.ErrorLog("解析失败:%v", err)
  7786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7787. return
  7788. }
  7789. }
  7790. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7791. // utils.ErrorLog("解析失败:%v", err)
  7792. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7793. // return
  7794. //}
  7795. if res.Infcode != 0 {
  7796. c.ServeSuccessJSON(map[string]interface{}{
  7797. "failed_code": -10,
  7798. "msg": res.ErrMsg,
  7799. })
  7800. } else {
  7801. c.ServeSuccessJSON(map[string]interface{}{
  7802. "failed_code": 0,
  7803. "info": res,
  7804. })
  7805. }
  7806. }
  7807. }
  7808. func (c *HisApiController) PsnPutOnRecord() {
  7809. record_type, _ := c.GetInt64("type")
  7810. patient_id, _ := c.GetInt64("patient_id")
  7811. admin_user_id, _ := c.GetInt64("admin_user_id")
  7812. start_time := c.GetString("start_time")
  7813. end_time := c.GetString("end_time")
  7814. adminUser := c.GetAdminUserInfo()
  7815. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7816. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7817. var patients []*models.Patients
  7818. if record_type == 1 { //全部备案
  7819. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  7820. patients = append(patients, patient...)
  7821. } else { //单个备案
  7822. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7823. patients = append(patients, patient)
  7824. }
  7825. var user_name string
  7826. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7827. if role.ID == 0 {
  7828. user_name = "xxx"
  7829. } else {
  7830. user_name = role.UserName
  7831. }
  7832. if config.IsOpen == 1 {
  7833. for _, item := range patients {
  7834. 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
  7835. resp, requestErr := http.Get(api)
  7836. if requestErr != nil {
  7837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7838. return
  7839. }
  7840. defer resp.Body.Close()
  7841. body, ioErr := ioutil.ReadAll(resp.Body)
  7842. if ioErr != nil {
  7843. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7845. return
  7846. }
  7847. var respJSON map[string]interface{}
  7848. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7849. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7851. return
  7852. }
  7853. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7854. userJSONBytes, _ := json.Marshal(userJSON)
  7855. var res ResultTwo
  7856. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7857. utils.ErrorLog("解析失败:%v", err)
  7858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7859. return
  7860. }
  7861. if res.Infcode == 0 {
  7862. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  7863. var dat map[string]interface{}
  7864. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7865. fmt.Println(dat)
  7866. } else {
  7867. fmt.Println(err)
  7868. }
  7869. userJSONBytes, _ := json.Marshal(dat)
  7870. var res2 ResultThirteen
  7871. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7872. utils.ErrorLog("解析失败:%v", err)
  7873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7874. return
  7875. }
  7876. if res2.Infcode == 0 {
  7877. psnResult := &models.GdybPsnRecord{
  7878. UserOrgId: adminUser.CurrentOrgId,
  7879. PatientId: item.ID,
  7880. PsnNo: res.Output.Baseinfo.PsnNo,
  7881. Ctime: time.Now().Unix(),
  7882. Mtime: time.Now().Unix(),
  7883. Status: 1,
  7884. IsCancel: 1,
  7885. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  7886. }
  7887. service.CreatePsnRecord(psnResult)
  7888. } else {
  7889. c.ServeSuccessJSON(map[string]interface{}{
  7890. "failed_code": -10,
  7891. "msg": res2.ErrMsg,
  7892. })
  7893. return
  7894. }
  7895. }
  7896. }
  7897. }
  7898. }
  7899. func (c *HisApiController) PsnUnPutOnRecord() {
  7900. id, _ := c.GetInt64("id")
  7901. //record_type, _ := c.GetInt64("type")
  7902. admin_user_id, _ := c.GetInt64("admin_user_id")
  7903. adminUser := c.GetAdminUserInfo()
  7904. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7905. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7906. var user_name string
  7907. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7908. if role.ID == 0 {
  7909. user_name = "xxx"
  7910. } else {
  7911. user_name = role.UserName
  7912. }
  7913. psn_record, _ := service.GetPsnRecordById(id)
  7914. if psn_record.ID == 0 {
  7915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7916. return
  7917. }
  7918. if config.IsOpen == 1 {
  7919. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  7920. var dat map[string]interface{}
  7921. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7922. fmt.Println(dat)
  7923. } else {
  7924. fmt.Println(err)
  7925. }
  7926. userJSONBytes, _ := json.Marshal(dat)
  7927. var res ResultFourteen
  7928. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7929. utils.ErrorLog("解析失败:%v", err)
  7930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7931. return
  7932. }
  7933. if res.Infcode == 0 {
  7934. psn_record.IsCancel = 2
  7935. service.CreatePsnRecord(&psn_record)
  7936. } else {
  7937. c.ServeSuccessJSON(map[string]interface{}{
  7938. "failed_code": -10,
  7939. "msg": res.ErrMsg,
  7940. })
  7941. return
  7942. }
  7943. }
  7944. }
  7945. func (c *HisApiController) PsnPutNCDSOnRecord() {
  7946. patient_id, _ := c.GetInt64("patient_id")
  7947. insutype_two := c.GetString("insutype")
  7948. psn_no := c.GetString("psn_no")
  7949. doctor_id, _ := c.GetInt64("doctor_id")
  7950. sick_id, _ := c.GetInt64("sick_id")
  7951. department_id, _ := c.GetInt64("department_id")
  7952. start_time := c.GetString("start_time")
  7953. end_time := c.GetString("end_time")
  7954. check_time := c.GetString("check_time")
  7955. adminUser := c.GetAdminUserInfo()
  7956. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7957. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7958. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7959. sick, _ := service.FindSickById(sick_id)
  7960. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  7961. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  7962. var res ResultTwo
  7963. var res10265 ResultTwo10265
  7964. if miConfig.MdtrtareaAdmvs == "320921" {
  7965. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  7966. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  7967. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7968. "&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
  7969. resp, requestErr := http.Get(api)
  7970. if requestErr != nil {
  7971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7972. return
  7973. }
  7974. body, ioErr := ioutil.ReadAll(resp.Body)
  7975. if ioErr != nil {
  7976. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7978. return
  7979. }
  7980. var respJSON map[string]interface{}
  7981. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7982. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7984. return
  7985. }
  7986. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7987. result, _ := json.Marshal(respJSON)
  7988. fmt.Println("log")
  7989. fmt.Println(string(result))
  7990. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7991. utils.ErrorLog("解析失败:%v", err)
  7992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7993. return
  7994. }
  7995. res.ErrMsg = res10265.ErrMsg
  7996. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7997. res.Infcode = infocode
  7998. res.Output = res10265.Output
  7999. res.InfRefmsgid = res10265.InfRefmsgid
  8000. } else {
  8001. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8002. if miConfig.Code == "H15049901371" {
  8003. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8004. utils.ErrorLog("解析失败:%v", err)
  8005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8006. return
  8007. }
  8008. res.ErrMsg = res10265.ErrMsg
  8009. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8010. res.Infcode = infocode
  8011. res.Output = res10265.Output
  8012. res.InfRefmsgid = res10265.InfRefmsgid
  8013. } else {
  8014. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8015. utils.ErrorLog("解析失败:%v", err)
  8016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8017. return
  8018. }
  8019. }
  8020. }
  8021. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8022. infoStr := string(Iinfos)
  8023. var rf []*ResultFive
  8024. json.Unmarshal([]byte(infoStr), &rf)
  8025. var insuplc_admdvs string
  8026. var insutype string
  8027. var is390 int = 0
  8028. var is310 int = 0
  8029. var insutypes []*ResultFive
  8030. for _, item := range rf {
  8031. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8032. insutypes = append(insutypes, item)
  8033. }
  8034. }
  8035. if len(insutypes) == 1 {
  8036. insutype = insutypes[0].Insutype
  8037. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8038. } else {
  8039. for _, i := range insutypes {
  8040. if i.Insutype == "390" {
  8041. is390 = 1
  8042. }
  8043. if i.Insutype == "310" {
  8044. is310 = 1
  8045. }
  8046. }
  8047. }
  8048. if is390 == 1 {
  8049. insutype = "390"
  8050. }
  8051. if is310 == 1 {
  8052. insutype = "310"
  8053. }
  8054. if len(insutypes) == 2 {
  8055. insutype = insutype_two
  8056. }
  8057. if len(insutypes) == 0 {
  8058. insutype = "310"
  8059. }
  8060. insutype = insutype_two
  8061. fmt.Println(insutype)
  8062. for _, item := range rf {
  8063. fmt.Println(item.Insutype)
  8064. fmt.Println(insutype)
  8065. if item.Insutype == insutype {
  8066. fmt.Println(item.Insutype)
  8067. fmt.Println(insutype)
  8068. insuplc_admdvs = item.InsuplcAdmdvs
  8069. }
  8070. }
  8071. fmt.Println(insuplc_admdvs)
  8072. var res2 ResultThirteen
  8073. var res10265_2 ResultThirteen10265
  8074. if config.IsOpen == 1 {
  8075. if miConfig.MdtrtareaAdmvs == "320921" {
  8076. } else {
  8077. 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)
  8078. var dat map[string]interface{}
  8079. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8080. fmt.Println(dat)
  8081. } else {
  8082. fmt.Println(err)
  8083. }
  8084. userJSONBytes, _ := json.Marshal(dat)
  8085. if miConfig.Code == "H15049901371" {
  8086. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  8087. utils.ErrorLog("解析失败:%v", err)
  8088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8089. return
  8090. }
  8091. res2.ErrMsg = res10265_2.ErrMsg
  8092. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  8093. res2.Infcode = infocode
  8094. res2.Output = res10265_2.Output
  8095. res2.InfRefmsgid = res10265_2.InfRefmsgid
  8096. } else {
  8097. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8098. utils.ErrorLog("解析失败:%v", err)
  8099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8100. return
  8101. }
  8102. }
  8103. }
  8104. if res2.Infcode == 0 {
  8105. psnResult := &models.GdybPsnNcdsRecord{
  8106. UserOrgId: adminUser.CurrentOrgId,
  8107. PatientId: patient.ID,
  8108. PsnNo: psn_no,
  8109. DoctorId: doctor.AdminUserId,
  8110. DepartmentId: department_id,
  8111. SickType: sick_id,
  8112. Insutype: insutype,
  8113. Ctime: time.Now().Unix(),
  8114. Mtime: time.Now().Unix(),
  8115. Status: 1,
  8116. IsCancel: 1,
  8117. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8118. }
  8119. service.CreatePsnNCDSRecord(psnResult)
  8120. c.ServeSuccessJSON(map[string]interface{}{
  8121. "failed_code": 0,
  8122. "msg": "备案成功",
  8123. "result": psnResult,
  8124. })
  8125. } else {
  8126. c.ServeSuccessJSON(map[string]interface{}{
  8127. "failed_code": -10,
  8128. "msg": res2.ErrMsg,
  8129. })
  8130. return
  8131. }
  8132. }
  8133. }
  8134. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  8135. id, _ := c.GetInt64("id")
  8136. admin_user_id, _ := c.GetInt64("admin_user_id")
  8137. adminUser := c.GetAdminUserInfo()
  8138. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8139. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8140. //config, _ := service.Ge(adminUser.CurrentOrgId)
  8141. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  8142. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8143. //var user_name string
  8144. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8145. //if role.ID == 0 {
  8146. // user_name = "xxx"
  8147. //} else {
  8148. // user_name = role.UserName
  8149. //}
  8150. psn_record, _ := service.GetPsnNCDSRecordById(id)
  8151. if psn_record.ID == 0 {
  8152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8153. return
  8154. }
  8155. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8156. var res ResultTwo
  8157. var res10265 ResultTwo10265
  8158. if miConfig.Code == "H15049901371" {
  8159. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8160. utils.ErrorLog("解析失败:%v", err)
  8161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8162. return
  8163. }
  8164. res.ErrMsg = res10265.ErrMsg
  8165. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8166. res.Infcode = infocode
  8167. res.Output = res10265.Output
  8168. res.InfRefmsgid = res10265.InfRefmsgid
  8169. } else {
  8170. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8171. utils.ErrorLog("解析失败:%v", err)
  8172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8173. return
  8174. }
  8175. }
  8176. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8177. infoStr := string(Iinfos)
  8178. var rf []*ResultFive
  8179. json.Unmarshal([]byte(infoStr), &rf)
  8180. var insuplc_admdvs string
  8181. var insutype string
  8182. var is390 int = 0
  8183. var is310 int = 0
  8184. var insutypes []*ResultFive
  8185. for _, item := range rf {
  8186. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8187. insutypes = append(insutypes, item)
  8188. }
  8189. }
  8190. if len(insutypes) == 1 {
  8191. insutype = insutypes[0].Insutype
  8192. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8193. } else {
  8194. for _, i := range insutypes {
  8195. if i.Insutype == "390" {
  8196. is390 = 1
  8197. }
  8198. if i.Insutype == "310" {
  8199. is310 = 1
  8200. }
  8201. }
  8202. }
  8203. if is390 == 1 {
  8204. insutype = "390"
  8205. }
  8206. if is310 == 1 {
  8207. insutype = "310"
  8208. }
  8209. if len(insutypes) == 0 {
  8210. insutype = "310"
  8211. }
  8212. insutype = psn_record.Insutype
  8213. for _, item := range rf {
  8214. if item.Insutype == insutype {
  8215. insuplc_admdvs = item.InsuplcAdmdvs
  8216. }
  8217. }
  8218. if config.IsOpen == 1 {
  8219. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8220. var dat map[string]interface{}
  8221. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8222. fmt.Println(dat)
  8223. } else {
  8224. fmt.Println(err)
  8225. }
  8226. userJSONBytes, _ := json.Marshal(dat)
  8227. var res ResultFourteen
  8228. var res10265 ResultFourteen10265
  8229. if miConfig.Code == "H15049901371" {
  8230. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8231. utils.ErrorLog("解析失败:%v", err)
  8232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8233. return
  8234. }
  8235. res.ErrMsg = res10265.ErrMsg
  8236. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8237. res.Infcode = infocode
  8238. res.Output = res10265.Output
  8239. res.InfRefmsgid = res10265.InfRefmsgid
  8240. } else {
  8241. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8242. utils.ErrorLog("解析失败:%v", err)
  8243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8244. return
  8245. }
  8246. }
  8247. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8248. // utils.ErrorLog("解析失败:%v", err)
  8249. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8250. // return
  8251. //}
  8252. if res.Infcode == 0 {
  8253. psn_record.IsCancel = 2
  8254. service.CreatePsnNCDSRecord(&psn_record)
  8255. c.ServeSuccessJSON(map[string]interface{}{
  8256. "failed_code": 0,
  8257. "msg": "撤销备案成功",
  8258. })
  8259. } else {
  8260. c.ServeSuccessJSON(map[string]interface{}{
  8261. "failed_code": -10,
  8262. "msg": res.ErrMsg,
  8263. })
  8264. return
  8265. }
  8266. }
  8267. }
  8268. func (c *HisApiController) TestTest() {
  8269. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  8270. fmt.Println(patient.Iinfo)
  8271. }
  8272. type CustomData struct {
  8273. MsgId string
  8274. PsnNo string
  8275. Info string
  8276. }
  8277. func (c *HisApiController) ReversalData() {
  8278. var customData []*CustomData
  8279. custom := &CustomData{
  8280. MsgId: "H44022900158202103301714472004",
  8281. PsnNo: "44020000001101329945",
  8282. Info: "2207",
  8283. }
  8284. customData = append(customData, custom)
  8285. custom1 := &CustomData{
  8286. MsgId: "H4402290015820210330172057803",
  8287. PsnNo: "44020000001101161813",
  8288. Info: "2207",
  8289. }
  8290. customData = append(customData, custom1)
  8291. custom2 := &CustomData{
  8292. MsgId: "H44022900158202103301705198813",
  8293. PsnNo: "44190000133097375417",
  8294. Info: "2207",
  8295. }
  8296. customData = append(customData, custom2)
  8297. custom3 := &CustomData{
  8298. MsgId: "H44022900158202103301715524756",
  8299. PsnNo: "44020000001100187221",
  8300. Info: "2207",
  8301. }
  8302. customData = append(customData, custom3)
  8303. custom4 := &CustomData{
  8304. MsgId: "H44022900158202103301730376224",
  8305. PsnNo: "44020000001101959155",
  8306. Info: "2207",
  8307. }
  8308. customData = append(customData, custom4)
  8309. custom5 := &CustomData{
  8310. MsgId: "H44022900158202103301748008725",
  8311. PsnNo: "44020000001104246641",
  8312. Info: "2207",
  8313. }
  8314. customData = append(customData, custom5)
  8315. custom6 := &CustomData{
  8316. MsgId: "H44022900158202103301718096755",
  8317. PsnNo: "44020000001102211860",
  8318. Info: "2207",
  8319. }
  8320. customData = append(customData, custom6)
  8321. custom7 := &CustomData{
  8322. MsgId: "H44022900158202103301736551640",
  8323. PsnNo: "44020000001102687718",
  8324. Info: "2207",
  8325. }
  8326. customData = append(customData, custom7)
  8327. custom8 := &CustomData{
  8328. MsgId: "H44022900158202103301743097676",
  8329. PsnNo: "44020000001102127785",
  8330. Info: "2207",
  8331. }
  8332. customData = append(customData, custom8)
  8333. custom9 := &CustomData{
  8334. MsgId: "H44022900158202103301712304203",
  8335. PsnNo: "44020000001101518097",
  8336. Info: "2207",
  8337. }
  8338. customData = append(customData, custom9)
  8339. custom10 := &CustomData{
  8340. MsgId: "H44022900158202103301738448785",
  8341. PsnNo: "44020000001100500813",
  8342. Info: "2207",
  8343. }
  8344. customData = append(customData, custom10)
  8345. custom11 := &CustomData{
  8346. MsgId: "H44022900158202103301732455843",
  8347. PsnNo: "44020000001102690557",
  8348. Info: "2207",
  8349. }
  8350. customData = append(customData, custom11)
  8351. custom12 := &CustomData{
  8352. MsgId: "H44022900158202103301745421708",
  8353. PsnNo: "44020000001102211928",
  8354. Info: "2207",
  8355. }
  8356. customData = append(customData, custom12)
  8357. custom1212 := &CustomData{
  8358. MsgId: "H440229001582021033017351627",
  8359. PsnNo: "44020000001102481733",
  8360. Info: "2207",
  8361. }
  8362. customData = append(customData, custom1212)
  8363. custom13 := &CustomData{
  8364. MsgId: "H44022900158202103301740327951",
  8365. PsnNo: "44020000001103174866",
  8366. Info: "2207",
  8367. }
  8368. customData = append(customData, custom13)
  8369. custom14 := &CustomData{
  8370. MsgId: "H4402290015820210330174922668",
  8371. PsnNo: "44020000001102927272",
  8372. Info: "2207",
  8373. }
  8374. customData = append(customData, custom14)
  8375. custom15 := &CustomData{
  8376. MsgId: "H44022900158202103301752362273",
  8377. PsnNo: "44020000001102942890",
  8378. Info: "2207",
  8379. }
  8380. customData = append(customData, custom15)
  8381. custom16 := &CustomData{
  8382. MsgId: "H44022900158202103301751082917",
  8383. PsnNo: "44020000001101662162",
  8384. Info: "2207",
  8385. }
  8386. customData = append(customData, custom16)
  8387. custom17 := &CustomData{
  8388. MsgId: "H44022900158202103301754147728",
  8389. PsnNo: "44020000000229014511",
  8390. Info: "2207",
  8391. }
  8392. customData = append(customData, custom17)
  8393. adminUser := c.GetAdminUserInfo()
  8394. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8395. for _, item := range customData {
  8396. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8397. fmt.Println(result)
  8398. }
  8399. }
  8400. func (c *HisApiController) GetAllopatry() {
  8401. year := c.GetString("year")
  8402. month := c.GetString("month")
  8403. admin_user_id, _ := c.GetInt64("admin_user_id")
  8404. adminUser := c.GetAdminUserInfo()
  8405. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8406. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8407. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  8408. var dat map[string]interface{}
  8409. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8410. fmt.Println(dat)
  8411. } else {
  8412. fmt.Println(err)
  8413. }
  8414. userJSONBytes, _ := json.Marshal(dat)
  8415. var res models.Result9001
  8416. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8417. utils.ErrorLog("解析失败:%v", err)
  8418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8419. return
  8420. }
  8421. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  8422. var dat2 map[string]interface{}
  8423. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8424. fmt.Println(dat)
  8425. } else {
  8426. fmt.Println(err)
  8427. }
  8428. userJSONBytes2, _ := json.Marshal(dat2)
  8429. var res2 models.Result3260
  8430. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8431. utils.ErrorLog("解析失败:%v", err)
  8432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8433. return
  8434. }
  8435. fmt.Println(res2)
  8436. //result2, _ := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  8437. //fmt.Println(result2)
  8438. }
  8439. //func (c *HisApiController) ComfirmAllopatry() {
  8440. // year := c.GetString("year")
  8441. // month := c.GetString("month")
  8442. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8443. // adminUser := c.GetAdminUserInfo()
  8444. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8445. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8446. // result, _ := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month)
  8447. // var dat map[string]interface{}
  8448. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8449. // fmt.Println(dat)
  8450. // } else {
  8451. // fmt.Println(err)
  8452. // }
  8453. // userJSONBytes, _ := json.Marshal(dat)
  8454. // var res2 models.Result3261
  8455. // if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8456. // utils.ErrorLog("解析失败:%v", err)
  8457. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8458. // return
  8459. // }
  8460. // c.ServeSuccessJSON(map[string]interface{}{
  8461. // "result": res2,
  8462. // })
  8463. //
  8464. //}
  8465. func (c *HisApiController) RefundAllopatry() {
  8466. //year := c.GetString("year")
  8467. //month := c.GetString("month")
  8468. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8469. //adminUser := c.GetAdminUserInfo()
  8470. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8471. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8472. }
  8473. func (c *HisApiController) ReversalOtherData() {
  8474. var customData []*CustomData
  8475. custom := &CustomData{
  8476. MsgId: "H44022900158202103301714472004",
  8477. PsnNo: "44020000001101329945",
  8478. Info: "2208",
  8479. }
  8480. customData = append(customData, custom)
  8481. custom1 := &CustomData{
  8482. MsgId: "H4402290015820210330172057803",
  8483. PsnNo: "44020000001101161813",
  8484. Info: "2208",
  8485. }
  8486. customData = append(customData, custom1)
  8487. custom2 := &CustomData{
  8488. MsgId: "H44022900158202103301705198813",
  8489. PsnNo: "44190000133097375417",
  8490. Info: "2208",
  8491. }
  8492. customData = append(customData, custom2)
  8493. custom3 := &CustomData{
  8494. MsgId: "H44022900158202103301715524756",
  8495. PsnNo: "44020000001100187221",
  8496. Info: "2208",
  8497. }
  8498. customData = append(customData, custom3)
  8499. custom4 := &CustomData{
  8500. MsgId: "H44022900158202103301730376224",
  8501. PsnNo: "44020000001101959155",
  8502. Info: "2208",
  8503. }
  8504. customData = append(customData, custom4)
  8505. custom5 := &CustomData{
  8506. MsgId: "H44022900158202103301748008725",
  8507. PsnNo: "44020000001104246641",
  8508. Info: "2208",
  8509. }
  8510. customData = append(customData, custom5)
  8511. custom6 := &CustomData{
  8512. MsgId: "H44022900158202103301718096755",
  8513. PsnNo: "44020000001102211860",
  8514. Info: "2208",
  8515. }
  8516. customData = append(customData, custom6)
  8517. custom7 := &CustomData{
  8518. MsgId: "H44022900158202103301736551640",
  8519. PsnNo: "44020000001102687718",
  8520. Info: "2208",
  8521. }
  8522. customData = append(customData, custom7)
  8523. custom8 := &CustomData{
  8524. MsgId: "H44022900158202103301743097676",
  8525. PsnNo: "44020000001102127785",
  8526. Info: "2208",
  8527. }
  8528. customData = append(customData, custom8)
  8529. custom9 := &CustomData{
  8530. MsgId: "H44022900158202103301712304203",
  8531. PsnNo: "44020000001101518097",
  8532. Info: "2208",
  8533. }
  8534. customData = append(customData, custom9)
  8535. custom10 := &CustomData{
  8536. MsgId: "H44022900158202103301738448785",
  8537. PsnNo: "44020000001100500813",
  8538. Info: "2208",
  8539. }
  8540. customData = append(customData, custom10)
  8541. custom11 := &CustomData{
  8542. MsgId: "H44022900158202103301732455843",
  8543. PsnNo: "44020000001102690557",
  8544. Info: "2208",
  8545. }
  8546. customData = append(customData, custom11)
  8547. custom12 := &CustomData{
  8548. MsgId: "H44022900158202103301745421708",
  8549. PsnNo: "44020000001102211928",
  8550. Info: "2208",
  8551. }
  8552. customData = append(customData, custom12)
  8553. custom1212 := &CustomData{
  8554. MsgId: "H440229001582021033017351627",
  8555. PsnNo: "44020000001102481733",
  8556. Info: "2208",
  8557. }
  8558. customData = append(customData, custom1212)
  8559. custom13 := &CustomData{
  8560. MsgId: "H44022900158202103301740327951",
  8561. PsnNo: "44020000001103174866",
  8562. Info: "2208",
  8563. }
  8564. customData = append(customData, custom13)
  8565. custom14 := &CustomData{
  8566. MsgId: "H4402290015820210330174922668",
  8567. PsnNo: "44020000001102927272",
  8568. Info: "2208",
  8569. }
  8570. customData = append(customData, custom14)
  8571. custom15 := &CustomData{
  8572. MsgId: "H44022900158202103301752362273",
  8573. PsnNo: "44020000001102942890",
  8574. Info: "2208",
  8575. }
  8576. customData = append(customData, custom15)
  8577. custom16 := &CustomData{
  8578. MsgId: "H44022900158202103301751082917",
  8579. PsnNo: "44020000001101662162",
  8580. Info: "2208",
  8581. }
  8582. customData = append(customData, custom16)
  8583. custom17 := &CustomData{
  8584. MsgId: "H44022900158202103301754147728",
  8585. PsnNo: "44020000000229014511",
  8586. Info: "2208",
  8587. }
  8588. customData = append(customData, custom17)
  8589. adminUser := c.GetAdminUserInfo()
  8590. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8591. for _, item := range customData {
  8592. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8593. fmt.Println(result)
  8594. }
  8595. }
  8596. func PathExists(path string) (bool, error) {
  8597. _, err := os.Stat(path)
  8598. if err == nil {
  8599. return true, nil
  8600. }
  8601. if os.IsNotExist(err) {
  8602. return false, nil
  8603. }
  8604. return false, err
  8605. }
  8606. //创建文件夹
  8607. func Mkdir(dir string) {
  8608. // 创建文件夹
  8609. exist, err := PathExists(dir)
  8610. if err != nil {
  8611. fmt.Println(err.Error())
  8612. } else {
  8613. if exist {
  8614. fmt.Println(dir + "文件夹已存在!")
  8615. } else {
  8616. // 文件夹名称,权限
  8617. err := os.Mkdir(dir, os.ModePerm)
  8618. if err != nil {
  8619. fmt.Println(dir+"文件夹创建失败:", err.Error())
  8620. } else {
  8621. fmt.Println(dir + "文件夹创建成功!")
  8622. }
  8623. }
  8624. }
  8625. }
  8626. //压缩文件
  8627. func Zip(srcFile string, destZip string) error {
  8628. zipfile, err := os.Create(destZip)
  8629. if err != nil {
  8630. return err
  8631. }
  8632. defer zipfile.Close()
  8633. archive := zip.NewWriter(zipfile)
  8634. defer archive.Close()
  8635. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  8636. if err != nil {
  8637. return err
  8638. }
  8639. header, err := zip.FileInfoHeader(info)
  8640. if err != nil {
  8641. return err
  8642. }
  8643. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  8644. // header.Name = path
  8645. if info.IsDir() {
  8646. header.Name += "/"
  8647. } else {
  8648. header.Method = zip.Deflate
  8649. }
  8650. writer, err := archive.CreateHeader(header)
  8651. if err != nil {
  8652. return err
  8653. }
  8654. if !info.IsDir() {
  8655. file, err := os.Open(path)
  8656. if err != nil {
  8657. return err
  8658. }
  8659. defer file.Close()
  8660. _, err = io.Copy(writer, file)
  8661. }
  8662. return err
  8663. })
  8664. return err
  8665. }
  8666. func ReadFile(filePath string) []byte {
  8667. f, err := os.Open(filePath)
  8668. if err != nil {
  8669. fmt.Println("read file fail", err)
  8670. return nil
  8671. }
  8672. defer f.Close()
  8673. fd, err := ioutil.ReadAll(f)
  8674. if err != nil {
  8675. fmt.Println("read to fd fail", err)
  8676. return nil
  8677. }
  8678. return fd
  8679. }
  8680. func saveLog(result string, request string, infno string, desc string) {
  8681. org_id, _ := beego.AppConfig.Int64("org_id")
  8682. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  8683. dir := miConfig.OrgName + "日志"
  8684. utils.Mkdir(dir)
  8685. month := time.Unix(1557042972, 0).Format("1")
  8686. year := time.Now().Format("2006")
  8687. month = time.Now().Format("01")
  8688. day := time.Now().Format("02")
  8689. hour := time.Now().Format("15")
  8690. min := time.Now().Format("04")
  8691. sec := time.Now().Format("05")
  8692. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  8693. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  8694. file_name := file + ".txt"
  8695. file_path := miConfig.OrgName + "日志" + "/" + file_name
  8696. exist, _ := utils.PathExists(file_path)
  8697. if exist { //存在
  8698. fmt.Println("存在")
  8699. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  8700. if err != nil {
  8701. fmt.Println("read fail")
  8702. }
  8703. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  8704. n, _ := f.Seek(0, 2)
  8705. _, err = f.WriteAt([]byte(content), n)
  8706. } else { //不存在
  8707. fmt.Println("文件不存在,创建文件")
  8708. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  8709. defer f.Close()
  8710. if err != nil {
  8711. } else {
  8712. _, err = f.Write([]byte("记录日志"))
  8713. }
  8714. }
  8715. }
  8716. type Charset string
  8717. const (
  8718. UTF8 = Charset("UTF-8")
  8719. GB18030 = Charset("GB18030")
  8720. )
  8721. func ConvertToString(src string, srcCode string, tagCode string) string {
  8722. srcCoder := mahonia.NewDecoder(srcCode)
  8723. srcResult := srcCoder.ConvertString(src)
  8724. tagCoder := mahonia.NewDecoder(tagCode)
  8725. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  8726. result := string(cdata)
  8727. return result
  8728. }