his_api_controller.go 380KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443
  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/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. }
  73. func (c *HisApiController) GetPsnNcdsInfo() {
  74. admin_user_id, _ := c.GetInt64("admin_user_id")
  75. patient_id, _ := c.GetInt64("patient_id")
  76. id, _ := c.GetInt64("id")
  77. adminUser := c.GetAdminUserInfo()
  78. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  79. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  80. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  81. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  82. psn_record, _ := service.GetPsnNCDSRecordById(id)
  83. //
  84. //if psn_record.ID == 0 {
  85. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  86. // return
  87. //}
  88. var res Result5301
  89. var res10265 Result5301For10265
  90. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  91. psn_info, _ := service.GetPsnByPatientId(patient_id)
  92. var api string
  93. if miConfig.MdtrtareaAdmvs == "320921" {
  94. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  95. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  96. } else {
  97. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  98. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  99. }
  100. resp, requestErr := http.Get(api)
  101. if requestErr != nil {
  102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  103. return
  104. }
  105. body, ioErr := ioutil.ReadAll(resp.Body)
  106. if ioErr != nil {
  107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  109. return
  110. }
  111. var respJSON map[string]interface{}
  112. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  115. return
  116. }
  117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  118. result, _ := json.Marshal(respJSON)
  119. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  120. utils.ErrorLog("解析失败:%v", err)
  121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  122. return
  123. }
  124. res.ErrMsg = res10265.ErrMsg
  125. res.Output = res10265.Output
  126. res.InfRefmsgid = res10265.InfRefmsgid
  127. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  128. res.Infcode = infocode
  129. } else {
  130. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  131. var dat map[string]interface{}
  132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  133. fmt.Println(dat)
  134. } else {
  135. fmt.Println(err)
  136. }
  137. userJSONBytes, _ := json.Marshal(dat)
  138. if miConfig.Code == "H15049901371" {
  139. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  140. utils.ErrorLog("解析失败:%v", err)
  141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  142. return
  143. }
  144. res.InfRefmsgid = res10265.InfRefmsgid
  145. res.Output = res10265.Output
  146. res.ErrMsg = res10265.ErrMsg
  147. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  148. res.Infcode = infocode
  149. } else {
  150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  151. utils.ErrorLog("解析失败:%v", err)
  152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  153. return
  154. }
  155. }
  156. }
  157. if res.Infcode == 0 {
  158. c.ServeSuccessJSON(map[string]interface{}{
  159. "result": res.Output.Result,
  160. })
  161. }
  162. }
  163. func (c *HisApiController) CheckInsutype() {
  164. his_patient_id, _ := c.GetInt64("his_patient_id")
  165. admin_user_id, _ := c.GetInt64("admin_user_id")
  166. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  167. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  168. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  169. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  170. var dat map[string]interface{}
  171. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  172. fmt.Println(dat)
  173. } else {
  174. fmt.Println(err)
  175. }
  176. userJSONBytes, _ := json.Marshal(dat)
  177. var res Result90100
  178. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  179. utils.ErrorLog("解析失败:%v", err)
  180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  181. return
  182. }
  183. if res.Infcode != 0 {
  184. c.ServeSuccessJSON(map[string]interface{}{
  185. "failed_code": -10,
  186. "msg": res.ErrMsg,
  187. })
  188. return
  189. } else {
  190. fmt.Println(res)
  191. }
  192. }
  193. func (c *HisApiController) CheckCardPWD() {
  194. card_pwd := c.GetString("card_pwd")
  195. his_patient_id, _ := c.GetInt64("his_patient_id")
  196. admin_user_id, _ := c.GetInt64("admin_user_id")
  197. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  198. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  199. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  200. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  201. var dat map[string]interface{}
  202. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  203. fmt.Println(dat)
  204. } else {
  205. fmt.Println(err)
  206. }
  207. userJSONBytes, _ := json.Marshal(dat)
  208. var res Result90991
  209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  210. utils.ErrorLog("解析失败:%v", err)
  211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  212. return
  213. }
  214. if res.Infcode != 0 {
  215. c.ServeSuccessJSON(map[string]interface{}{
  216. "failed_code": -10,
  217. "msg": res.ErrMsg,
  218. })
  219. return
  220. } else {
  221. if res.Output.Result.CheckStat == "0" {
  222. var msg string
  223. switch res.Output.Result.CardStat {
  224. case "00":
  225. msg = "未激活"
  226. break
  227. case "10":
  228. msg = "激活"
  229. break
  230. case "20":
  231. msg = "窗口挂失"
  232. break
  233. case "21":
  234. msg = "电话挂失"
  235. break
  236. case "22":
  237. msg = "单位网上申报挂失"
  238. break
  239. case "23":
  240. msg = "保健办挂失"
  241. break
  242. case "24":
  243. msg = "个人网上挂失"
  244. break
  245. case "25":
  246. msg = "网上服务大厅挂失"
  247. break
  248. case "30":
  249. msg = "注销"
  250. break
  251. case "40":
  252. msg = "回收"
  253. break
  254. case "99":
  255. msg = "制卡中(无效卡)"
  256. break
  257. }
  258. c.ServeSuccessJSON(map[string]interface{}{
  259. "failed_code": -10,
  260. "msg": msg,
  261. })
  262. return
  263. } else {
  264. c.ServeSuccessJSON(map[string]interface{}{
  265. "msg": "校验成功",
  266. })
  267. return
  268. }
  269. }
  270. }
  271. func (c *HisApiController) ReadCard() {
  272. id_card_type, _ := c.GetInt64("id_card_type")
  273. admin_user_id, _ := c.GetInt64("admin_user_id")
  274. certificates, _ := c.GetInt64("certificates")
  275. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  276. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  277. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  278. switch id_card_type {
  279. case 1:
  280. if miConfig.MdtrtareaAdmvs == "421300" {
  281. var res ResultTwo
  282. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  283. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  284. "&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)
  285. resp, requestErr := http.Get(api)
  286. if requestErr != nil {
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  288. return
  289. }
  290. body, ioErr := ioutil.ReadAll(resp.Body)
  291. if ioErr != nil {
  292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  294. return
  295. }
  296. var respJSON map[string]interface{}
  297. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  300. return
  301. }
  302. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  303. result, _ := json.Marshal(respJSON)
  304. fmt.Println("log")
  305. fmt.Println(string(result))
  306. if err := json.Unmarshal([]byte(result), &res); err != nil {
  307. utils.ErrorLog("解析失败:%v", err)
  308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  309. return
  310. }
  311. if res.Infcode == 0 {
  312. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  313. if err == gorm.ErrRecordNotFound {
  314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  315. return
  316. } else if err != nil {
  317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  318. return
  319. } else {
  320. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  321. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  322. infoStr := string(Iinfos)
  323. idetinfoStr := string(Idetinfos)
  324. psn := &models.HisPsn{
  325. PsnNo: res.Output.Baseinfo.PsnNo,
  326. Age: res.Output.Baseinfo.Age,
  327. PatientId: patient.ID,
  328. Certno: res.Output.Baseinfo.Certno,
  329. Brdy: res.Output.Baseinfo.Brdy,
  330. Gend: res.Output.Baseinfo.Gend,
  331. Naty: res.Output.Baseinfo.Naty,
  332. PsnCertType: res.Output.Baseinfo.PsnCertType,
  333. PsnName: res.Output.Baseinfo.PsnName,
  334. Idetinfo: idetinfoStr,
  335. Insuinfo: infoStr,
  336. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  337. }
  338. service.CreateHisPsn(psn)
  339. c.ServeSuccessJSON(map[string]interface{}{
  340. "patient": patient,
  341. "number": res.Output.Baseinfo.Certno,
  342. })
  343. }
  344. } else {
  345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  346. return
  347. }
  348. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  349. var api string
  350. if miConfig.MdtrtareaAdmvs == "320921" {
  351. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  352. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  353. } else {
  354. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  355. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  356. }
  357. resp, requestErr := http.Get(api)
  358. if requestErr != nil {
  359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  360. return
  361. }
  362. body, ioErr := ioutil.ReadAll(resp.Body)
  363. if ioErr != nil {
  364. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  366. return
  367. }
  368. var respJSON map[string]interface{}
  369. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  370. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  372. return
  373. }
  374. var status string
  375. status = respJSON["data"].(map[string]interface{})["status"].(string)
  376. if status == "0" { //读卡成功
  377. var card_info string //卡信息
  378. var busi_card_info string
  379. var res ResultTwo //1101结果
  380. var res10265 ResultTwo10265 //1101结果
  381. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  382. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  383. fmt.Println(card_info)
  384. fmt.Println(busi_card_info)
  385. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  386. result, _ := json.Marshal(respJSON)
  387. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  388. utils.ErrorLog("解析失败:%v", err)
  389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  390. return
  391. }
  392. res.ErrMsg = res10265.ErrMsg
  393. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  394. res.Infcode = infocode
  395. res.Output = res10265.Output
  396. res.InfRefmsgid = res10265.InfRefmsgid
  397. if res.Infcode == 0 {
  398. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  399. if err == gorm.ErrRecordNotFound {
  400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  401. return
  402. } else if err != nil {
  403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  404. return
  405. } else {
  406. bas := strings.Split(card_info, "|")
  407. basNumber := bas[2]
  408. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  409. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  410. infoStr := string(Iinfos)
  411. idetinfoStr := string(Idetinfos)
  412. psn := &models.HisPsn{
  413. PsnNo: res.Output.Baseinfo.PsnNo,
  414. Age: res.Output.Baseinfo.Age,
  415. PatientId: patient.ID,
  416. Certno: res.Output.Baseinfo.Certno,
  417. Brdy: res.Output.Baseinfo.Brdy,
  418. Gend: res.Output.Baseinfo.Gend,
  419. Naty: res.Output.Baseinfo.Naty,
  420. PsnCertType: res.Output.Baseinfo.PsnCertType,
  421. PsnName: res.Output.Baseinfo.PsnName,
  422. Idetinfo: idetinfoStr,
  423. Insuinfo: infoStr,
  424. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  425. CardInfo: card_info,
  426. VerifyNumber: busi_card_info,
  427. }
  428. service.CreateHisPsn(psn)
  429. c.ServeSuccessJSON(map[string]interface{}{
  430. "patient": patient,
  431. "number": basNumber,
  432. })
  433. }
  434. } else {
  435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  436. return
  437. }
  438. } else { //读卡失败
  439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  440. return
  441. }
  442. } else {
  443. if initFlag == 0 {
  444. c.TestGetBasBaseInit()
  445. }
  446. basStr := c.GetBasBaseInfo()
  447. if len(basStr) == 0 {
  448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  449. return
  450. }
  451. fmt.Println(basStr)
  452. bas := strings.Split(basStr, "|")
  453. basNumber := bas[1]
  454. fmt.Println(basNumber)
  455. card_sn := bas[3]
  456. fmt.Println(card_sn)
  457. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  458. var dat map[string]interface{}
  459. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  460. fmt.Println(dat)
  461. } else {
  462. fmt.Println(err)
  463. }
  464. userJSONBytes, _ := json.Marshal(dat)
  465. var res ResultTwo
  466. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  467. utils.ErrorLog("解析失败:%v", err)
  468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  469. return
  470. }
  471. if res.Infcode == 0 {
  472. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  473. if err == gorm.ErrRecordNotFound {
  474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  475. return
  476. } else if err != nil {
  477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  478. return
  479. } else {
  480. c.ServeSuccessJSON(map[string]interface{}{
  481. "patient": patient,
  482. "number": basNumber,
  483. })
  484. }
  485. } else {
  486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  487. return
  488. }
  489. break
  490. }
  491. case 2:
  492. SFZStr := c.GetSFZBaseInfo()
  493. id_card_str := strings.Split(SFZStr, "^")
  494. id_card_number := id_card_str[0]
  495. card_sn := ""
  496. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  497. var dat map[string]interface{}
  498. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  499. fmt.Println(dat)
  500. } else {
  501. fmt.Println(err)
  502. }
  503. userJSONBytes, _ := json.Marshal(dat)
  504. var res ResultTwo
  505. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  506. utils.ErrorLog("解析失败:%v", err)
  507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  508. return
  509. }
  510. if res.Infcode == 0 {
  511. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  512. if err == gorm.ErrRecordNotFound {
  513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  514. return
  515. } else if err != nil {
  516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  517. return
  518. } else {
  519. c.ServeSuccessJSON(map[string]interface{}{
  520. "patient": patient,
  521. "number": id_card_number,
  522. })
  523. }
  524. } else {
  525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  526. return
  527. }
  528. break
  529. case 3:
  530. break
  531. }
  532. }
  533. var initFlag int64 = 0
  534. func (c *HisApiController) TestGetBasBaseInit() {
  535. DllDef := syscall.MustLoadDLL("SSCard.dll")
  536. Iinit := DllDef.MustFindProc("Init")
  537. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  538. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  539. if ret != 0 {
  540. fmt.Println("SSCard的报错原因:", err)
  541. fmt.Println("SSCard的运算结果为:", ret)
  542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  543. return
  544. }
  545. result := int(ret)
  546. fmt.Println("SSCard的运算结果为1:", result)
  547. initFlag = 1
  548. return
  549. }
  550. func (c *HisApiController) GetSFZBaseInfo() string {
  551. DllDef := syscall.MustLoadDLL("SSCard.dll")
  552. readCard := DllDef.MustFindProc("ReadSFZ")
  553. if readCard == nil {
  554. fmt.Println("readcard is nil")
  555. readCard = DllDef.MustFindProc("ReadSFZ")
  556. }
  557. str := make([]byte, 256)
  558. str1 := make([]byte, 256)
  559. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  560. fmt.Println(r)
  561. return string(str)
  562. }
  563. func (c *HisApiController) GetBasBaseInfo() string {
  564. DllDef := syscall.MustLoadDLL("SSCard.dll")
  565. readCard := DllDef.MustFindProc("ReadCardBas")
  566. if readCard == nil {
  567. fmt.Println("readcard is nil")
  568. readCard = DllDef.MustFindProc("ReadCardBas")
  569. }
  570. str := make([]byte, 1024)
  571. str1 := make([]byte, 1024)
  572. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  573. fmt.Println(string(str1))
  574. fmt.Println(string(str))
  575. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  576. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  577. if ret2 != 0 {
  578. return ""
  579. }
  580. return string(str)
  581. }
  582. type CustomFundPay struct {
  583. FundPayType string `json:"fund_pay_type"`
  584. FundPayamt float64 `json:"fund_payamt"`
  585. }
  586. func (c *HisApiController) GetSettleList() {
  587. order_id, _ := c.GetInt64("order_id")
  588. admin_user_id, _ := c.GetInt64("admin_user_id")
  589. order, _ := service.GetHisOrderByIDTwo(order_id)
  590. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  591. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  592. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  593. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  594. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  595. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  596. if order.ID == 0 {
  597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  598. return
  599. }
  600. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  601. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  602. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  603. fmt.Println(count)
  604. var zero string
  605. number := count + 1
  606. if number >= 1000 {
  607. zero = "0000" + strconv.FormatInt(number, 10)
  608. } else if number >= 10000 {
  609. zero = "000" + strconv.FormatInt(number, 10)
  610. } else if number >= 100000 {
  611. zero = "00" + strconv.FormatInt(number, 10)
  612. } else if number >= 1000000 {
  613. zero = "0" + strconv.FormatInt(number, 10)
  614. } else {
  615. zero = strconv.FormatInt(number, 10)
  616. }
  617. fmt.Println(zero)
  618. struct4101 := service.Struct4101{
  619. PsnNo: order.PsnNo,
  620. MdtrtId: order.MdtrtId,
  621. SetlId: order.SetlId,
  622. PsnName: order.PsnName,
  623. Gend: order.Gend,
  624. Brdy: his.Brdy,
  625. Age: his.Age,
  626. Naty: order.Naty,
  627. PatnCertType: "01",
  628. Certno: order.Certno,
  629. Prfs: "90",
  630. ConerName: roles[0].UserName,
  631. PatnRlts: "99",
  632. ConerAddr: miConfig.OrgName,
  633. ConerTel: admin.Mobile,
  634. HiType: order.Insutype,
  635. Insuplc: miConfig.InsuplcAdmdvs,
  636. MaindiagFlag: "1",
  637. BillCode: last_order.FaPiaoCode,
  638. BillNo: zero,
  639. BizSn: order.Number,
  640. PsnSelfPay: order.PsnPartAmt,
  641. PsnOwnPay: order.PsnPartAmt,
  642. AcctPay: order.AcctPay,
  643. PsnCashpay: order.PsnCashPay,
  644. HiPaymtd: "1",
  645. Hsorg: miConfig.InsuplcAdmdvs,
  646. HsorgOpter: miConfig.InsuplcAdmdvs,
  647. MedinsFillPsn: curRoles.UserName,
  648. MedinsFillDept: depart.Name,
  649. IptMedType: "2",
  650. }
  651. struct4101.SetlBegnDate = order.SetlTime
  652. struct4101.SetlEndDate = order.SetlTime
  653. time_arr := strings.Split(order.SetlTime, " ")
  654. struct4101.AdmTime = time_arr[0]
  655. struct4101.AdmEndTime = time_arr[0]
  656. var rf []CustomFundPay
  657. json.Unmarshal([]byte(order.SetlDetail), &rf)
  658. var tempFunPays []service.CustomStruct
  659. for _, item := range rf {
  660. var tempFunPay service.CustomStruct
  661. tempFunPay.FundPayamt = item.FundPayamt
  662. tempFunPay.FundPayType = item.FundPayType
  663. tempFunPays = append(tempFunPays, tempFunPay)
  664. }
  665. struct4101.CustomStruct = tempFunPays
  666. var tempDiaginfos []service.DiaginfoStructTwo
  667. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  668. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  669. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  670. var config []*models.HisXtDiagnoseConfig
  671. for _, item := range diagnosis_ids {
  672. id, _ := strconv.ParseInt(item, 10, 64)
  673. diagnosisConfig, _ := service.FindDiagnoseById(id)
  674. config = append(config, &diagnosisConfig)
  675. }
  676. for index, item := range config {
  677. if index == 0 {
  678. var tempDiaginfo service.DiaginfoStructTwo
  679. tempDiaginfo.DiagCode = item.CountryCode
  680. tempDiaginfo.DiagName = item.CountryContentName
  681. tempDiaginfo.DiagType = "1"
  682. tempDiaginfo.MaindiagFlag = "1"
  683. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  684. } else {
  685. var tempDiaginfo service.DiaginfoStructTwo
  686. tempDiaginfo.DiagCode = item.CountryCode
  687. tempDiaginfo.DiagName = item.CountryContentName
  688. tempDiaginfo.DiagType = "2"
  689. tempDiaginfo.MaindiagFlag = "0"
  690. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  691. }
  692. }
  693. sickConfigTwo, _ := service.FindSickById(his.SickType)
  694. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  695. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  696. tempOpspdiseinfo2.OprnOprtCode = ""
  697. tempOpspdiseinfo2.OprnOprtName = ""
  698. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  699. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  700. var iteminfo service.IteminfoStruct
  701. var bedCostTotal float64 = 0 //床位总费
  702. var bedCostSelfTotal float64 = 0 //床位自费
  703. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  704. var operationCostTotal float64 = 0 //手术费
  705. var operationCostSelfTotal float64 = 0 //手术费
  706. var operationCostPartSelfTotal float64 = 0 //手术费
  707. var otherCostTotal float64 = 0 //其他费用
  708. var otherCostSelfTotal float64 = 0 //其他费用
  709. var otherCostPartSelfTotal float64 = 0 //其他费用
  710. var materialCostTotal float64 = 0 //材料费
  711. var materialCostSelfTotal float64 = 0 //材料费
  712. var materialCostPartSelfTotal float64 = 0 //材料费
  713. var westernMedicineCostTotal float64 = 0 //西药费
  714. var westernMedicineCostSelfTotal float64 = 0 //西药费
  715. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  716. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  717. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  718. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  719. var checkCostTotal float64 = 0 //检查费
  720. var checkCostSelfTotal float64 = 0 //检查费
  721. var checkCostPartSelfTotal float64 = 0 //检查费
  722. var laboratoryCostTotal float64 = 0 //化验费
  723. var laboratoryCostSelfTotal float64 = 0 //化验费
  724. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  725. var treatCostTotal float64 = 0 //治疗费用
  726. var treatCostSelfTotal float64 = 0 //治疗费用
  727. var treatCostPartSelfTotal float64 = 0 //治疗费用
  728. decimal.DivisionPrecision = 2
  729. var bed_fulamt_ownpay_amt float64 = 0
  730. var operation_fulamt_ownpay_amt float64 = 0
  731. var other_fulamt_ownpay_amt float64 = 0
  732. var westernMedicine_fulamt_ownpay_amt float64 = 0
  733. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  734. var check_fulamt_ownpay_amt float64 = 0
  735. var material_fulamt_ownpay_amt float64 = 0
  736. var laboratory_fulamt_ownpay_amt float64 = 0
  737. var treat_fulamt_ownpay_amt float64 = 0
  738. var bed_claa_sunmfee float64 = 0
  739. var bed_clab_amt float64 = 0
  740. var bed_other_amt float64 = 0
  741. var operation_claa_sunmfee float64 = 0
  742. var operation_clab_amt float64 = 0
  743. var operation_other_amt float64 = 0
  744. var other_claa_sunmfee float64 = 0
  745. var other_clab_amt float64 = 0
  746. var other_other_amt float64 = 0
  747. var westernMedicine_claa_sunmfee float64 = 0
  748. var westernMedicine_clab_amt float64 = 0
  749. var westernMedicine_other_amt float64 = 0
  750. var chineseTraditional_claa_sunmfee float64 = 0
  751. var chineseTraditional_clab_amt float64 = 0
  752. var chineseTraditional_other_amt float64 = 0
  753. var check_claa_sunmfee float64 = 0
  754. var check_clab_amt float64 = 0
  755. var check_other_amt float64 = 0
  756. var material_claa_sunmfee float64 = 0
  757. var material_clab_amt float64 = 0
  758. var material_other_amt float64 = 0
  759. var laboratory_claa_sunmfee float64 = 0
  760. var laboratory_clab_amt float64 = 0
  761. var laboratory_other_amt float64 = 0
  762. var treat_claa_sunmfee float64 = 0
  763. var treat_clab_amt float64 = 0
  764. var treat_other_amt float64 = 0
  765. for _, item := range order.HisOrderInfo {
  766. if item.MedChrgitmType == "01" { //床位费
  767. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  768. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  769. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  770. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  771. if item.ChrgitmLv == "1" {
  772. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  773. }
  774. if item.ChrgitmLv == "2" {
  775. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  776. }
  777. if item.ChrgitmLv == "3" {
  778. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  779. }
  780. }
  781. if item.MedChrgitmType == "03" { //检查费
  782. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  783. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  784. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  785. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  786. if item.ChrgitmLv == "1" {
  787. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  788. }
  789. if item.ChrgitmLv == "2" {
  790. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  791. }
  792. if item.ChrgitmLv == "3" {
  793. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  794. }
  795. }
  796. if item.MedChrgitmType == "04" { //化验费
  797. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  798. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  799. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  800. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  801. if item.ChrgitmLv == "1" {
  802. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  803. }
  804. if item.ChrgitmLv == "2" {
  805. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  806. }
  807. if item.ChrgitmLv == "3" {
  808. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  809. }
  810. }
  811. if item.MedChrgitmType == "05" { //治疗费
  812. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  813. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  814. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  815. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  816. if item.ChrgitmLv == "1" {
  817. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  818. }
  819. if item.ChrgitmLv == "2" {
  820. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  821. }
  822. if item.ChrgitmLv == "3" {
  823. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  824. }
  825. }
  826. if item.MedChrgitmType == "06" { //手术费
  827. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  828. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  829. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  830. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  831. if item.ChrgitmLv == "1" {
  832. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  833. }
  834. if item.ChrgitmLv == "2" {
  835. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  836. }
  837. if item.ChrgitmLv == "3" {
  838. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  839. }
  840. }
  841. if item.MedChrgitmType == "08" { //材料费
  842. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  843. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  844. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  845. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  846. if item.ChrgitmLv == "1" {
  847. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  848. }
  849. if item.ChrgitmLv == "2" {
  850. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  851. }
  852. if item.ChrgitmLv == "3" {
  853. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  854. }
  855. }
  856. if item.MedChrgitmType == "09" { //西药费
  857. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  858. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  859. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  860. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  861. if item.ChrgitmLv == "1" {
  862. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  863. }
  864. if item.ChrgitmLv == "2" {
  865. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  866. }
  867. if item.ChrgitmLv == "3" {
  868. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  869. }
  870. }
  871. if item.MedChrgitmType == "11" { //中成费
  872. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  873. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  874. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  875. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  876. if item.ChrgitmLv == "1" {
  877. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  878. }
  879. if item.ChrgitmLv == "2" {
  880. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  881. }
  882. if item.ChrgitmLv == "3" {
  883. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  884. }
  885. }
  886. if item.MedChrgitmType == "14" { //其他费
  887. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  888. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  889. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  890. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  891. if item.ChrgitmLv == "1" {
  892. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  893. }
  894. if item.ChrgitmLv == "2" {
  895. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  896. }
  897. if item.ChrgitmLv == "3" {
  898. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  899. }
  900. }
  901. }
  902. var iteminfoStructs []service.IteminfoStruct
  903. if bedCostTotal != 0 {
  904. iteminfo.MedChrgitm = "01"
  905. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  906. iteminfo.Amt = bedCostTotal
  907. iteminfo.ClaaSumfee = bed_claa_sunmfee
  908. iteminfo.ClabAmt = bed_clab_amt
  909. iteminfo.OthAmt = bed_other_amt
  910. iteminfoStructs = append(iteminfoStructs, iteminfo)
  911. }
  912. if checkCostTotal != 0 {
  913. iteminfo.MedChrgitm = "03"
  914. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  915. iteminfo.Amt = checkCostTotal
  916. iteminfo.ClaaSumfee = check_claa_sunmfee
  917. iteminfo.ClabAmt = check_clab_amt
  918. iteminfo.OthAmt = check_other_amt
  919. iteminfoStructs = append(iteminfoStructs, iteminfo)
  920. }
  921. if laboratoryCostTotal != 0 {
  922. iteminfo.MedChrgitm = "04"
  923. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  924. iteminfo.Amt = laboratoryCostTotal
  925. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  926. iteminfo.ClabAmt = laboratory_clab_amt
  927. iteminfo.OthAmt = laboratory_other_amt
  928. iteminfoStructs = append(iteminfoStructs, iteminfo)
  929. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  930. }
  931. if treatCostTotal != 0 {
  932. iteminfo.MedChrgitm = "05"
  933. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  934. iteminfo.Amt = treatCostTotal
  935. iteminfo.ClaaSumfee = treat_claa_sunmfee
  936. iteminfo.ClabAmt = treat_clab_amt
  937. iteminfo.OthAmt = treat_other_amt
  938. iteminfoStructs = append(iteminfoStructs, iteminfo)
  939. //(struct4101.IteminfoStruct, iteminfo)
  940. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  941. }
  942. if operationCostTotal != 0 {
  943. iteminfo.MedChrgitm = "06"
  944. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  945. iteminfo.Amt = operationCostTotal
  946. iteminfo.ClaaSumfee = operation_claa_sunmfee
  947. iteminfo.ClabAmt = operation_clab_amt
  948. iteminfo.OthAmt = operation_other_amt
  949. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  950. iteminfoStructs = append(iteminfoStructs, iteminfo)
  951. }
  952. if materialCostTotal != 0 {
  953. iteminfo.MedChrgitm = "08"
  954. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  955. iteminfo.Amt = materialCostTotal
  956. iteminfo.ClaaSumfee = material_claa_sunmfee
  957. iteminfo.ClabAmt = material_clab_amt
  958. iteminfo.OthAmt = material_other_amt
  959. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  960. iteminfoStructs = append(iteminfoStructs, iteminfo)
  961. }
  962. if westernMedicineCostTotal != 0 {
  963. iteminfo.MedChrgitm = "09"
  964. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  965. iteminfo.Amt = westernMedicineCostTotal
  966. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  967. iteminfo.ClabAmt = westernMedicine_clab_amt
  968. iteminfo.OthAmt = westernMedicine_other_amt
  969. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  970. iteminfoStructs = append(iteminfoStructs, iteminfo)
  971. }
  972. if chineseTraditionalMedicineCostTotal != 0 {
  973. iteminfo.MedChrgitm = "11"
  974. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  975. iteminfo.Amt = westernMedicineCostTotal
  976. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  977. iteminfo.ClabAmt = westernMedicine_clab_amt
  978. iteminfo.OthAmt = westernMedicine_other_amt
  979. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  980. iteminfoStructs = append(iteminfoStructs, iteminfo)
  981. }
  982. if otherCostTotal != 0 {
  983. iteminfo.MedChrgitm = "14"
  984. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  985. iteminfo.Amt = otherCostTotal
  986. iteminfo.ClaaSumfee = other_claa_sunmfee
  987. iteminfo.ClabAmt = other_clab_amt
  988. iteminfo.OthAmt = other_other_amt
  989. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  990. iteminfoStructs = append(iteminfoStructs, iteminfo)
  991. }
  992. struct4101.IteminfoStruct = iteminfoStructs
  993. struct4101.Ntly = "中国"
  994. struct4101.AdmCaty = "A03.06"
  995. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  996. fmt.Println(result)
  997. var dat map[string]interface{}
  998. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  999. fmt.Println(dat)
  1000. } else {
  1001. fmt.Println(err)
  1002. }
  1003. userJSONBytes, _ := json.Marshal(dat)
  1004. var res ResultSeventeen
  1005. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1006. utils.ErrorLog("解析失败:%v", err)
  1007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1008. return
  1009. }
  1010. if res.Infcode != 0 {
  1011. c.ServeSuccessJSON(map[string]interface{}{
  1012. "failed_code": -10,
  1013. "msg": res.ErrMsg,
  1014. })
  1015. return
  1016. } else {
  1017. order.FaPiaoNumber = zero
  1018. order.FaPiaoCode = last_order.FaPiaoCode
  1019. service.UpdateOrder(order)
  1020. hisFundSettleListResult := &models.HisFundSettleListResult{
  1021. Number: res.Output.SetlListId,
  1022. Status: 1,
  1023. Ctime: time.Now().Unix(),
  1024. Mtime: time.Now().Unix(),
  1025. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1026. IsUpload: 1,
  1027. OrderId: order_id,
  1028. }
  1029. service.CreateUploadRecord(hisFundSettleListResult)
  1030. c.ServeSuccessJSON(map[string]interface{}{
  1031. "msg": "上传成功",
  1032. "result": hisFundSettleListResult,
  1033. })
  1034. return
  1035. }
  1036. }
  1037. func (c *HisApiController) GetSettleListHospital() {
  1038. order_id, _ := c.GetInt64("order_id")
  1039. admin_user_id, _ := c.GetInt64("admin_user_id")
  1040. order, _ := service.GetHisOrderByIDTwo(order_id)
  1041. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1042. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1043. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1044. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1045. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1046. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1047. if order.ID == 0 {
  1048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1049. return
  1050. }
  1051. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1052. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1053. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1054. fmt.Println(count)
  1055. var zero string
  1056. number := count + 1
  1057. if number >= 1000 {
  1058. zero = "0000" + strconv.FormatInt(number, 10)
  1059. } else if number >= 10000 {
  1060. zero = "000" + strconv.FormatInt(number, 10)
  1061. } else if number >= 100000 {
  1062. zero = "00" + strconv.FormatInt(number, 10)
  1063. } else if number >= 1000000 {
  1064. zero = "0" + strconv.FormatInt(number, 10)
  1065. } else {
  1066. zero = strconv.FormatInt(number, 10)
  1067. }
  1068. fmt.Println(zero)
  1069. struct4101 := service.Struct4101{
  1070. PsnNo: order.PsnNo,
  1071. MdtrtId: order.MdtrtId,
  1072. SetlId: order.SetlId,
  1073. PsnName: order.PsnName,
  1074. Gend: order.Gend,
  1075. Brdy: his.Brdy,
  1076. Age: int64(order.Age),
  1077. Naty: order.Naty,
  1078. PatnCertType: "01",
  1079. Certno: order.Certno,
  1080. Prfs: "90",
  1081. ConerName: roles[0].UserName,
  1082. PatnRlts: "99",
  1083. ConerAddr: miConfig.OrgName,
  1084. ConerTel: admin.Mobile,
  1085. HiType: order.Insutype,
  1086. Insuplc: miConfig.InsuplcAdmdvs,
  1087. MaindiagFlag: "1",
  1088. BillCode: last_order.FaPiaoCode,
  1089. BillNo: zero,
  1090. BizSn: order.Number,
  1091. PsnSelfPay: order.PsnPartAmt,
  1092. PsnOwnPay: order.PsnPartAmt,
  1093. AcctPay: order.AcctPay,
  1094. PsnCashpay: order.PsnCashPay,
  1095. HiPaymtd: "1",
  1096. Hsorg: miConfig.InsuplcAdmdvs,
  1097. HsorgOpter: miConfig.InsuplcAdmdvs,
  1098. MedinsFillPsn: curRoles.UserName,
  1099. MedinsFillDept: depart.Name,
  1100. IptMedType: "2",
  1101. }
  1102. struct4101.SetlBegnDate = order.SetlTime
  1103. struct4101.SetlEndDate = order.SetlTime
  1104. var rf []CustomFundPay
  1105. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1106. var tempFunPays []service.CustomStruct
  1107. for _, item := range rf {
  1108. var tempFunPay service.CustomStruct
  1109. tempFunPay.FundPayamt = item.FundPayamt
  1110. tempFunPay.FundPayType = item.FundPayType
  1111. tempFunPays = append(tempFunPays, tempFunPay)
  1112. }
  1113. struct4101.CustomStruct = tempFunPays
  1114. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1115. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1116. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  1117. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1118. var config []*models.HisXtDiagnoseConfig
  1119. for _, item := range diagnosis_ids {
  1120. id, _ := strconv.ParseInt(item, 10, 64)
  1121. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1122. config = append(config, &diagnosisConfig)
  1123. }
  1124. for _, item := range config {
  1125. var tempOpspdiseinfo service.OpspdiseinfoStruct
  1126. tempOpspdiseinfo.DiagCode = item.CountryCode
  1127. tempOpspdiseinfo.DiagName = item.CountryContentName
  1128. tempOpspdiseinfo.MaindiagFlag = "1"
  1129. tempOpspdiseinfo.OprnOprtCode = ""
  1130. tempOpspdiseinfo.OprnOprtName = ""
  1131. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  1132. }
  1133. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1134. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1135. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1136. tempOpspdiseinfo2.MaindiagFlag = "2"
  1137. tempOpspdiseinfo2.OprnOprtCode = ""
  1138. tempOpspdiseinfo2.OprnOprtName = ""
  1139. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1140. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1141. var iteminfo service.IteminfoStruct
  1142. var bedCostTotal float64 = 0 //床位总费
  1143. var bedCostSelfTotal float64 = 0 //床位自费
  1144. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1145. var operationCostTotal float64 = 0 //手术费
  1146. var operationCostSelfTotal float64 = 0 //手术费
  1147. var operationCostPartSelfTotal float64 = 0 //手术费
  1148. var otherCostTotal float64 = 0 //其他费用
  1149. var otherCostSelfTotal float64 = 0 //其他费用
  1150. var otherCostPartSelfTotal float64 = 0 //其他费用
  1151. var materialCostTotal float64 = 0 //材料费
  1152. var materialCostSelfTotal float64 = 0 //材料费
  1153. var materialCostPartSelfTotal float64 = 0 //材料费
  1154. var westernMedicineCostTotal float64 = 0 //西药费
  1155. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1156. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1157. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1158. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1159. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1160. var checkCostTotal float64 = 0 //检查费
  1161. var checkCostSelfTotal float64 = 0 //检查费
  1162. var checkCostPartSelfTotal float64 = 0 //检查费
  1163. var laboratoryCostTotal float64 = 0 //化验费
  1164. var laboratoryCostSelfTotal float64 = 0 //化验费
  1165. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1166. var treatCostTotal float64 = 0 //治疗费用
  1167. var treatCostSelfTotal float64 = 0 //治疗费用
  1168. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1169. decimal.DivisionPrecision = 2
  1170. var bed_fulamt_ownpay_amt float64 = 0
  1171. var operation_fulamt_ownpay_amt float64 = 0
  1172. var other_fulamt_ownpay_amt float64 = 0
  1173. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1174. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1175. var check_fulamt_ownpay_amt float64 = 0
  1176. var material_fulamt_ownpay_amt float64 = 0
  1177. var laboratory_fulamt_ownpay_amt float64 = 0
  1178. var treat_fulamt_ownpay_amt float64 = 0
  1179. var bed_claa_sunmfee float64 = 0
  1180. var bed_clab_amt float64 = 0
  1181. var bed_other_amt float64 = 0
  1182. var operation_claa_sunmfee float64 = 0
  1183. var operation_clab_amt float64 = 0
  1184. var operation_other_amt float64 = 0
  1185. var other_claa_sunmfee float64 = 0
  1186. var other_clab_amt float64 = 0
  1187. var other_other_amt float64 = 0
  1188. var westernMedicine_claa_sunmfee float64 = 0
  1189. var westernMedicine_clab_amt float64 = 0
  1190. var westernMedicine_other_amt float64 = 0
  1191. var chineseTraditional_claa_sunmfee float64 = 0
  1192. var chineseTraditional_clab_amt float64 = 0
  1193. var chineseTraditional_other_amt float64 = 0
  1194. var check_claa_sunmfee float64 = 0
  1195. var check_clab_amt float64 = 0
  1196. var check_other_amt float64 = 0
  1197. var material_claa_sunmfee float64 = 0
  1198. var material_clab_amt float64 = 0
  1199. var material_other_amt float64 = 0
  1200. var laboratory_claa_sunmfee float64 = 0
  1201. var laboratory_clab_amt float64 = 0
  1202. var laboratory_other_amt float64 = 0
  1203. var treat_claa_sunmfee float64 = 0
  1204. var treat_clab_amt float64 = 0
  1205. var treat_other_amt float64 = 0
  1206. for _, item := range order.HisOrderInfo {
  1207. if item.MedChrgitmType == "01" { //床位费
  1208. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1209. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1210. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1211. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1212. if item.ChrgitmLv == "1" {
  1213. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1214. }
  1215. if item.ChrgitmLv == "2" {
  1216. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1217. }
  1218. if item.ChrgitmLv == "3" {
  1219. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1220. }
  1221. }
  1222. if item.MedChrgitmType == "03" { //检查费
  1223. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1224. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1225. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1226. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1227. if item.ChrgitmLv == "1" {
  1228. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1229. }
  1230. if item.ChrgitmLv == "2" {
  1231. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1232. }
  1233. if item.ChrgitmLv == "3" {
  1234. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1235. }
  1236. }
  1237. if item.MedChrgitmType == "04" { //化验费
  1238. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1239. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1240. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1241. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1242. if item.ChrgitmLv == "1" {
  1243. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1244. }
  1245. if item.ChrgitmLv == "2" {
  1246. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1247. }
  1248. if item.ChrgitmLv == "3" {
  1249. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1250. }
  1251. }
  1252. if item.MedChrgitmType == "05" { //治疗费
  1253. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1254. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1255. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1256. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1257. if item.ChrgitmLv == "1" {
  1258. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1259. }
  1260. if item.ChrgitmLv == "2" {
  1261. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1262. }
  1263. if item.ChrgitmLv == "3" {
  1264. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1265. }
  1266. }
  1267. if item.MedChrgitmType == "06" { //手术费
  1268. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1269. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1270. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1271. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1272. if item.ChrgitmLv == "1" {
  1273. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1274. }
  1275. if item.ChrgitmLv == "2" {
  1276. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1277. }
  1278. if item.ChrgitmLv == "3" {
  1279. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1280. }
  1281. }
  1282. if item.MedChrgitmType == "08" { //材料费
  1283. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1284. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1285. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1286. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1287. if item.ChrgitmLv == "1" {
  1288. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1289. }
  1290. if item.ChrgitmLv == "2" {
  1291. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1292. }
  1293. if item.ChrgitmLv == "3" {
  1294. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1295. }
  1296. }
  1297. if item.MedChrgitmType == "09" { //西药费
  1298. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1299. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1300. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1301. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1302. if item.ChrgitmLv == "1" {
  1303. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1304. }
  1305. if item.ChrgitmLv == "2" {
  1306. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1307. }
  1308. if item.ChrgitmLv == "3" {
  1309. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1310. }
  1311. }
  1312. if item.MedChrgitmType == "11" { //中成费
  1313. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1314. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1315. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1316. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1317. if item.ChrgitmLv == "1" {
  1318. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1319. }
  1320. if item.ChrgitmLv == "2" {
  1321. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1322. }
  1323. if item.ChrgitmLv == "3" {
  1324. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1325. }
  1326. }
  1327. if item.MedChrgitmType == "14" { //其他费
  1328. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1329. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1330. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1331. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1332. if item.ChrgitmLv == "1" {
  1333. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1334. }
  1335. if item.ChrgitmLv == "2" {
  1336. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1337. }
  1338. if item.ChrgitmLv == "3" {
  1339. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1340. }
  1341. }
  1342. }
  1343. var iteminfoStructs []service.IteminfoStruct
  1344. if bedCostTotal != 0 {
  1345. iteminfo.MedChrgitm = "01"
  1346. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1347. iteminfo.Amt = bedCostTotal
  1348. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1349. iteminfo.ClabAmt = bed_clab_amt
  1350. iteminfo.OthAmt = bed_other_amt
  1351. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1352. }
  1353. if checkCostTotal != 0 {
  1354. iteminfo.MedChrgitm = "03"
  1355. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1356. iteminfo.Amt = checkCostTotal
  1357. iteminfo.ClaaSumfee = check_claa_sunmfee
  1358. iteminfo.ClabAmt = check_clab_amt
  1359. iteminfo.OthAmt = check_other_amt
  1360. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1361. }
  1362. if laboratoryCostTotal != 0 {
  1363. iteminfo.MedChrgitm = "04"
  1364. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1365. iteminfo.Amt = laboratoryCostTotal
  1366. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1367. iteminfo.ClabAmt = laboratory_clab_amt
  1368. iteminfo.OthAmt = laboratory_other_amt
  1369. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1370. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1371. }
  1372. if treatCostTotal != 0 {
  1373. iteminfo.MedChrgitm = "05"
  1374. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1375. iteminfo.Amt = treatCostTotal
  1376. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1377. iteminfo.ClabAmt = treat_clab_amt
  1378. iteminfo.OthAmt = treat_other_amt
  1379. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1380. //(struct4101.IteminfoStruct, iteminfo)
  1381. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1382. }
  1383. if operationCostTotal != 0 {
  1384. iteminfo.MedChrgitm = "06"
  1385. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1386. iteminfo.Amt = operationCostTotal
  1387. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1388. iteminfo.ClabAmt = operation_clab_amt
  1389. iteminfo.OthAmt = operation_other_amt
  1390. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1391. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1392. }
  1393. if materialCostTotal != 0 {
  1394. iteminfo.MedChrgitm = "08"
  1395. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1396. iteminfo.Amt = materialCostTotal
  1397. iteminfo.ClaaSumfee = material_claa_sunmfee
  1398. iteminfo.ClabAmt = material_clab_amt
  1399. iteminfo.OthAmt = material_other_amt
  1400. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1401. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1402. }
  1403. if westernMedicineCostTotal != 0 {
  1404. iteminfo.MedChrgitm = "09"
  1405. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1406. iteminfo.Amt = westernMedicineCostTotal
  1407. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1408. iteminfo.ClabAmt = westernMedicine_clab_amt
  1409. iteminfo.OthAmt = westernMedicine_other_amt
  1410. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1411. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1412. }
  1413. if chineseTraditionalMedicineCostTotal != 0 {
  1414. iteminfo.MedChrgitm = "11"
  1415. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1416. iteminfo.Amt = westernMedicineCostTotal
  1417. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1418. iteminfo.ClabAmt = westernMedicine_clab_amt
  1419. iteminfo.OthAmt = westernMedicine_other_amt
  1420. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1421. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1422. }
  1423. if otherCostTotal != 0 {
  1424. iteminfo.MedChrgitm = "14"
  1425. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1426. iteminfo.Amt = otherCostTotal
  1427. iteminfo.ClaaSumfee = other_claa_sunmfee
  1428. iteminfo.ClabAmt = other_clab_amt
  1429. iteminfo.OthAmt = other_other_amt
  1430. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1431. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1432. }
  1433. struct4101.IteminfoStruct = iteminfoStructs
  1434. struct4101.Ntly = "中国"
  1435. struct4101.AdmCaty = "A03.06"
  1436. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1437. fmt.Println(result)
  1438. var dat map[string]interface{}
  1439. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1440. fmt.Println(dat)
  1441. } else {
  1442. fmt.Println(err)
  1443. }
  1444. userJSONBytes, _ := json.Marshal(dat)
  1445. var res ResultSeventeen
  1446. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1447. utils.ErrorLog("解析失败:%v", err)
  1448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1449. return
  1450. }
  1451. if res.Infcode != 0 {
  1452. c.ServeSuccessJSON(map[string]interface{}{
  1453. "failed_code": -10,
  1454. "msg": res.ErrMsg,
  1455. })
  1456. return
  1457. } else {
  1458. order.FaPiaoNumber = zero
  1459. order.FaPiaoCode = last_order.FaPiaoCode
  1460. service.UpdateOrder(order)
  1461. hisFundSettleListResult := &models.HisFundSettleListResult{
  1462. Number: res.Output.SetlListId,
  1463. Status: 1,
  1464. Ctime: time.Now().Unix(),
  1465. Mtime: time.Now().Unix(),
  1466. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1467. IsUpload: 1,
  1468. OrderId: order_id,
  1469. }
  1470. service.CreateUploadRecord(hisFundSettleListResult)
  1471. c.ServeSuccessJSON(map[string]interface{}{
  1472. "msg": "上传成功",
  1473. "result": hisFundSettleListResult,
  1474. })
  1475. return
  1476. }
  1477. }
  1478. func (c *HisApiController) GetBatchSettleList() {
  1479. org_id, _ := beego.AppConfig.Int64("org_id")
  1480. //stage, _ := c.GetInt64("stage")
  1481. orders, _ := service.GetAllHisOrder(org_id)
  1482. for _, item := range orders {
  1483. order_id := item.ID
  1484. order, _ := service.GetHisOrderByIDTwo(order_id)
  1485. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1486. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1487. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1488. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2185)
  1489. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1490. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1491. if order.ID == 0 {
  1492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1493. return
  1494. }
  1495. if his.BalanceAccountsType == 2 {
  1496. continue
  1497. }
  1498. struct4101 := service.Struct4101{
  1499. PsnNo: order.PsnNo,
  1500. MdtrtId: order.MdtrtId,
  1501. SetlId: order.SetlId,
  1502. PsnName: order.PsnName,
  1503. Gend: order.Gend,
  1504. Brdy: his.Brdy,
  1505. Age: his.Age,
  1506. Naty: order.Naty,
  1507. PatnCertType: "01",
  1508. Certno: order.Certno,
  1509. Prfs: "90",
  1510. ConerName: roles[0].UserName,
  1511. PatnRlts: "99",
  1512. ConerAddr: miConfig.OrgName,
  1513. ConerTel: admin.Mobile,
  1514. HiType: order.Insutype,
  1515. Insuplc: his.InsuplcAdmdvs,
  1516. MaindiagFlag: "1",
  1517. BillCode: order.FaPiaoCode,
  1518. BillNo: order.FaPiaoNumber,
  1519. BizSn: order.Number,
  1520. PsnSelfPay: order.PsnPartAmt,
  1521. PsnOwnPay: order.PsnPartAmt,
  1522. AcctPay: order.AcctPay,
  1523. PsnCashpay: order.PsnCashPay,
  1524. HiPaymtd: "1",
  1525. Hsorg: his.InsuplcAdmdvs,
  1526. HsorgOpter: his.InsuplcAdmdvs,
  1527. MedinsFillPsn: curRoles.UserName,
  1528. MedinsFillDept: depart.Name,
  1529. IptMedType: "2",
  1530. }
  1531. struct4101.SetlBegnDate = order.SetlTime
  1532. struct4101.SetlEndDate = order.SetlTime
  1533. //if order.SettleType == 1 {
  1534. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  1535. // dateStr := t.Format("2006-01-02")
  1536. // struct4101.SetlBegnDate = dateStr
  1537. // struct4101.SetlEndDate = dateStr
  1538. //} else {
  1539. // t := time.Unix(int64(order.SettleStartTime), 0)
  1540. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  1541. // dateStartStr := t.Format("2006-01-02")
  1542. // dateEndStr := t2.Format("2006-01-02")
  1543. // struct4101.SetlBegnDate = dateStartStr
  1544. // struct4101.SetlEndDate = dateEndStr
  1545. //}
  1546. var rf []CustomFundPay
  1547. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1548. var tempFunPays []service.CustomStruct
  1549. var tempFunPay610100 service.CustomStruct
  1550. for _, item := range rf {
  1551. if item.FundPayType == "610100" {
  1552. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  1553. tempFunPay610100.FundPayType = item.FundPayType
  1554. } else {
  1555. var tempFunPay service.CustomStruct
  1556. tempFunPay.FundPayamt = item.FundPayamt
  1557. tempFunPay.FundPayType = item.FundPayType
  1558. tempFunPays = append(tempFunPays, tempFunPay)
  1559. }
  1560. }
  1561. tempFunPays = append(tempFunPays, tempFunPay610100)
  1562. struct4101.CustomStruct = tempFunPays
  1563. var tempDiaginfos []service.DiaginfoStructTwo
  1564. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1565. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1566. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1567. var config []*models.HisXtDiagnoseConfig
  1568. for _, item := range diagnosis_ids {
  1569. id, _ := strconv.ParseInt(item, 10, 64)
  1570. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1571. config = append(config, &diagnosisConfig)
  1572. }
  1573. for index, item := range config {
  1574. if index == 0 {
  1575. var tempDiaginfo service.DiaginfoStructTwo
  1576. tempDiaginfo.DiagCode = item.CountryCode
  1577. tempDiaginfo.DiagName = item.CountryContentName
  1578. tempDiaginfo.DiagType = "1"
  1579. tempDiaginfo.MaindiagFlag = "1"
  1580. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1581. } else {
  1582. var tempDiaginfo service.DiaginfoStructTwo
  1583. tempDiaginfo.DiagCode = item.CountryCode
  1584. tempDiaginfo.DiagName = item.CountryContentName
  1585. tempDiaginfo.DiagType = "2"
  1586. tempDiaginfo.MaindiagFlag = "0"
  1587. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1588. }
  1589. }
  1590. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1591. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1592. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1593. tempOpspdiseinfo2.OprnOprtCode = ""
  1594. tempOpspdiseinfo2.OprnOprtName = ""
  1595. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1596. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1597. var iteminfo service.IteminfoStruct
  1598. var bedCostTotal float64 = 0 //床位总费
  1599. var bedCostSelfTotal float64 = 0 //床位自费
  1600. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1601. var examineCostTotal float64 = 0 //诊查总费
  1602. var examineCostSelfTotal float64 = 0 //诊查自费
  1603. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  1604. var nursingCostTotal float64 = 0 //护理总费
  1605. var nursingCostSelfTotal float64 = 0 //护理自费
  1606. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  1607. var chineseMedicineCostTotal float64 = 0 //中成药
  1608. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  1609. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  1610. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  1611. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  1612. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  1613. var registerCostTotal float64 = 0 //一般诊疗费
  1614. var registerCostSelfTotal float64 = 0 //一般诊疗费
  1615. var registerPartSelfTotal float64 = 0 //一般诊疗费
  1616. var operationCostTotal float64 = 0 //手术费
  1617. var operationCostSelfTotal float64 = 0 //手术费
  1618. var operationCostPartSelfTotal float64 = 0 //手术费
  1619. var otherCostTotal float64 = 0 //其他费用
  1620. var otherCostSelfTotal float64 = 0 //其他费用
  1621. var otherCostPartSelfTotal float64 = 0 //其他费用
  1622. var materialCostTotal float64 = 0 //材料费
  1623. var materialCostSelfTotal float64 = 0 //材料费
  1624. var materialCostPartSelfTotal float64 = 0 //材料费
  1625. var westernMedicineCostTotal float64 = 0 //西药费
  1626. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1627. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1628. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1629. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1630. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1631. var checkCostTotal float64 = 0 //检查费
  1632. var checkCostSelfTotal float64 = 0 //检查费
  1633. var checkCostPartSelfTotal float64 = 0 //检查费
  1634. var laboratoryCostTotal float64 = 0 //化验费
  1635. var laboratoryCostSelfTotal float64 = 0 //化验费
  1636. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1637. var treatCostTotal float64 = 0 //治疗费用
  1638. var treatCostSelfTotal float64 = 0 //治疗费用
  1639. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1640. decimal.DivisionPrecision = 2
  1641. var bed_fulamt_ownpay_amt float64 = 0
  1642. var examine_fulamt_ownpay_amt float64 = 0
  1643. var nursing_fulamt_ownpay_amt float64 = 0
  1644. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1645. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1646. var register_fulamt_ownpay_amt float64 = 0
  1647. var operation_fulamt_ownpay_amt float64 = 0
  1648. var other_fulamt_ownpay_amt float64 = 0
  1649. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1650. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1651. var check_fulamt_ownpay_amt float64 = 0
  1652. var material_fulamt_ownpay_amt float64 = 0
  1653. var laboratory_fulamt_ownpay_amt float64 = 0
  1654. var treat_fulamt_ownpay_amt float64 = 0
  1655. var bed_claa_sunmfee float64 = 0
  1656. var bed_clab_amt float64 = 0
  1657. var bed_other_amt float64 = 0
  1658. var examine_claa_sunmfee float64 = 0
  1659. var examine_clab_amt float64 = 0
  1660. var examine_other_amt float64 = 0
  1661. var nursing_claa_sunmfee float64 = 0
  1662. var nursing_clab_amt float64 = 0
  1663. var nursing_other_amt float64 = 0
  1664. var chinese_medicine_claa_sunmfee float64 = 0
  1665. var chinese_medicine_clab_amt float64 = 0
  1666. var chinese_medicine_other_amt float64 = 0
  1667. var commonly_treatment_claa_sunmfee float64 = 0
  1668. var commonly_treatment_clab_amt float64 = 0
  1669. var commonly_treatment_other_amt float64 = 0
  1670. var operation_claa_sunmfee float64 = 0
  1671. var operation_clab_amt float64 = 0
  1672. var operation_other_amt float64 = 0
  1673. var other_claa_sunmfee float64 = 0
  1674. var other_clab_amt float64 = 0
  1675. var other_other_amt float64 = 0
  1676. var westernMedicine_claa_sunmfee float64 = 0
  1677. var westernMedicine_clab_amt float64 = 0
  1678. var westernMedicine_other_amt float64 = 0
  1679. var chineseTraditional_claa_sunmfee float64 = 0
  1680. var chineseTraditional_clab_amt float64 = 0
  1681. var chineseTraditional_other_amt float64 = 0
  1682. var check_claa_sunmfee float64 = 0
  1683. var check_clab_amt float64 = 0
  1684. var check_other_amt float64 = 0
  1685. var material_claa_sunmfee float64 = 0
  1686. var material_clab_amt float64 = 0
  1687. var material_other_amt float64 = 0
  1688. var laboratory_claa_sunmfee float64 = 0
  1689. var laboratory_clab_amt float64 = 0
  1690. var laboratory_other_amt float64 = 0
  1691. var treat_claa_sunmfee float64 = 0
  1692. var treat_clab_amt float64 = 0
  1693. var treat_other_amt float64 = 0
  1694. var register_claa_sunmfee float64 = 0
  1695. var register_clab_amt float64 = 0
  1696. var register_other_amt float64 = 0
  1697. for _, item := range order.HisOrderInfo {
  1698. if item.MedChrgitmType == "01" { //床位费
  1699. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1700. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1701. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1702. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1703. if item.ChrgitmLv == "1" {
  1704. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1705. }
  1706. if item.ChrgitmLv == "2" {
  1707. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1708. }
  1709. if item.ChrgitmLv == "3" {
  1710. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1711. }
  1712. }
  1713. if item.MedChrgitmType == "02" { //诊查
  1714. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1715. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1716. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1717. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1718. if item.ChrgitmLv == "1" {
  1719. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1720. }
  1721. if item.ChrgitmLv == "2" {
  1722. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1723. }
  1724. if item.ChrgitmLv == "3" {
  1725. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1726. }
  1727. }
  1728. if item.MedChrgitmType == "03" { //检查费
  1729. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1730. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1731. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1732. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1733. if item.ChrgitmLv == "1" {
  1734. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1735. }
  1736. if item.ChrgitmLv == "2" {
  1737. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1738. }
  1739. if item.ChrgitmLv == "3" {
  1740. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1741. }
  1742. }
  1743. if item.MedChrgitmType == "04" { //化验费
  1744. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1745. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1746. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1747. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1748. if item.ChrgitmLv == "1" {
  1749. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1750. }
  1751. if item.ChrgitmLv == "2" {
  1752. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1753. }
  1754. if item.ChrgitmLv == "3" {
  1755. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1756. }
  1757. }
  1758. if item.MedChrgitmType == "05" { //治疗费
  1759. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1760. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1761. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1762. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1763. if item.ChrgitmLv == "1" {
  1764. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1765. }
  1766. if item.ChrgitmLv == "2" {
  1767. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1768. }
  1769. if item.ChrgitmLv == "3" {
  1770. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1771. }
  1772. }
  1773. if item.MedChrgitmType == "06" { //手术费
  1774. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1775. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1776. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1777. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1778. if item.ChrgitmLv == "1" {
  1779. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1780. }
  1781. if item.ChrgitmLv == "2" {
  1782. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1783. }
  1784. if item.ChrgitmLv == "3" {
  1785. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1786. }
  1787. }
  1788. if item.MedChrgitmType == "07" { //手术费
  1789. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1790. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1791. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1792. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1793. if item.ChrgitmLv == "1" {
  1794. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1795. }
  1796. if item.ChrgitmLv == "2" {
  1797. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1798. }
  1799. if item.ChrgitmLv == "3" {
  1800. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1801. }
  1802. }
  1803. if item.MedChrgitmType == "08" { //材料费
  1804. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1805. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1806. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1807. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1808. if item.ChrgitmLv == "1" {
  1809. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1810. }
  1811. if item.ChrgitmLv == "2" {
  1812. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1813. }
  1814. if item.ChrgitmLv == "3" {
  1815. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1816. }
  1817. }
  1818. if item.MedChrgitmType == "09" { //西药费
  1819. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1820. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1821. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1822. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1823. if item.ChrgitmLv == "1" {
  1824. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1825. }
  1826. if item.ChrgitmLv == "2" {
  1827. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1828. }
  1829. if item.ChrgitmLv == "3" {
  1830. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1831. }
  1832. }
  1833. if item.MedChrgitmType == "10" { //中药饮片
  1834. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1835. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1836. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1837. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1838. if item.ChrgitmLv == "1" {
  1839. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1840. }
  1841. if item.ChrgitmLv == "2" {
  1842. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1843. }
  1844. if item.ChrgitmLv == "3" {
  1845. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1846. }
  1847. }
  1848. if item.MedChrgitmType == "11" { //中成费
  1849. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1850. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1851. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1852. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1853. if item.ChrgitmLv == "1" {
  1854. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1855. }
  1856. if item.ChrgitmLv == "2" {
  1857. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1858. }
  1859. if item.ChrgitmLv == "3" {
  1860. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1861. }
  1862. }
  1863. if item.MedChrgitmType == "12" { //中成费
  1864. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1865. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1866. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1867. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1868. if item.ChrgitmLv == "1" {
  1869. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1870. }
  1871. if item.ChrgitmLv == "2" {
  1872. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1873. }
  1874. if item.ChrgitmLv == "3" {
  1875. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1876. }
  1877. }
  1878. if item.MedChrgitmType == "13" { //中成费
  1879. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1880. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1881. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1882. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1883. if item.ChrgitmLv == "1" {
  1884. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1885. }
  1886. if item.ChrgitmLv == "2" {
  1887. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1888. }
  1889. if item.ChrgitmLv == "3" {
  1890. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1891. }
  1892. }
  1893. if item.MedChrgitmType == "14" { //其他费
  1894. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1895. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1896. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1897. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1898. if item.ChrgitmLv == "1" {
  1899. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1900. }
  1901. if item.ChrgitmLv == "2" {
  1902. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1903. }
  1904. if item.ChrgitmLv == "3" {
  1905. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1906. }
  1907. }
  1908. }
  1909. var iteminfoStructs []service.IteminfoStruct
  1910. if bedCostTotal != 0 {
  1911. iteminfo.MedChrgitm = "01"
  1912. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1913. iteminfo.Amt = bedCostTotal
  1914. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1915. iteminfo.ClabAmt = bed_clab_amt
  1916. iteminfo.OthAmt = bed_other_amt
  1917. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1918. }
  1919. if examineCostTotal != 0 {
  1920. iteminfo.MedChrgitm = "02"
  1921. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  1922. iteminfo.Amt = examineCostTotal
  1923. iteminfo.ClaaSumfee = examine_claa_sunmfee
  1924. iteminfo.ClabAmt = examine_clab_amt
  1925. iteminfo.OthAmt = examine_other_amt
  1926. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1927. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1928. }
  1929. if checkCostTotal != 0 {
  1930. iteminfo.MedChrgitm = "03"
  1931. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1932. iteminfo.Amt = checkCostTotal
  1933. iteminfo.ClaaSumfee = check_claa_sunmfee
  1934. iteminfo.ClabAmt = check_clab_amt
  1935. iteminfo.OthAmt = check_other_amt
  1936. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1937. }
  1938. if laboratoryCostTotal != 0 {
  1939. iteminfo.MedChrgitm = "04"
  1940. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1941. iteminfo.Amt = laboratoryCostTotal
  1942. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1943. iteminfo.ClabAmt = laboratory_clab_amt
  1944. iteminfo.OthAmt = laboratory_other_amt
  1945. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1946. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1947. }
  1948. if treatCostTotal != 0 {
  1949. iteminfo.MedChrgitm = "05"
  1950. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1951. iteminfo.Amt = treatCostTotal
  1952. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1953. iteminfo.ClabAmt = treat_clab_amt
  1954. iteminfo.OthAmt = treat_other_amt
  1955. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1956. //(struct4101.IteminfoStruct, iteminfo)
  1957. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1958. }
  1959. if operationCostTotal != 0 {
  1960. iteminfo.MedChrgitm = "06"
  1961. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1962. iteminfo.Amt = operationCostTotal
  1963. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1964. iteminfo.ClabAmt = operation_clab_amt
  1965. iteminfo.OthAmt = operation_other_amt
  1966. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1967. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1968. }
  1969. if nursingCostTotal != 0 {
  1970. iteminfo.MedChrgitm = "07"
  1971. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  1972. iteminfo.Amt = nursingCostTotal
  1973. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  1974. iteminfo.ClabAmt = nursing_clab_amt
  1975. iteminfo.OthAmt = nursing_other_amt
  1976. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1977. }
  1978. if materialCostTotal != 0 {
  1979. iteminfo.MedChrgitm = "08"
  1980. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1981. iteminfo.Amt = materialCostTotal
  1982. iteminfo.ClaaSumfee = material_claa_sunmfee
  1983. iteminfo.ClabAmt = material_clab_amt
  1984. iteminfo.OthAmt = material_other_amt
  1985. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1986. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1987. }
  1988. if westernMedicineCostTotal != 0 {
  1989. iteminfo.MedChrgitm = "09"
  1990. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1991. iteminfo.Amt = westernMedicineCostTotal
  1992. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1993. iteminfo.ClabAmt = westernMedicine_clab_amt
  1994. iteminfo.OthAmt = westernMedicine_other_amt
  1995. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1996. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1997. }
  1998. if chineseMedicineCostTotal != 0 {
  1999. iteminfo.MedChrgitm = "10"
  2000. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2001. iteminfo.Amt = chineseMedicineCostTotal
  2002. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2003. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2004. iteminfo.OthAmt = chinese_medicine_other_amt
  2005. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2006. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2007. }
  2008. if chineseTraditionalMedicineCostTotal != 0 {
  2009. iteminfo.MedChrgitm = "11"
  2010. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2011. iteminfo.Amt = westernMedicineCostTotal
  2012. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2013. iteminfo.ClabAmt = westernMedicine_clab_amt
  2014. iteminfo.OthAmt = westernMedicine_other_amt
  2015. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2016. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2017. }
  2018. if commonlyTreatmentCostTotal != 0 {
  2019. iteminfo.MedChrgitm = "12"
  2020. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2021. iteminfo.Amt = commonlyTreatmentCostTotal
  2022. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2023. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2024. iteminfo.OthAmt = commonly_treatment_other_amt
  2025. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2026. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2027. }
  2028. if registerCostTotal != 0 {
  2029. iteminfo.MedChrgitm = "13"
  2030. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2031. iteminfo.Amt = registerCostTotal
  2032. iteminfo.ClaaSumfee = register_claa_sunmfee
  2033. iteminfo.ClabAmt = register_clab_amt
  2034. iteminfo.OthAmt = register_other_amt
  2035. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2036. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2037. }
  2038. if otherCostTotal != 0 {
  2039. iteminfo.MedChrgitm = "14"
  2040. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2041. iteminfo.Amt = otherCostTotal
  2042. iteminfo.ClaaSumfee = other_claa_sunmfee
  2043. iteminfo.ClabAmt = other_clab_amt
  2044. iteminfo.OthAmt = other_other_amt
  2045. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2046. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2047. }
  2048. struct4101.IteminfoStruct = iteminfoStructs
  2049. struct4101.Ntly = "中国"
  2050. struct4101.AdmCaty = "A03.06"
  2051. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, org_id)
  2052. fmt.Println(result)
  2053. var dat map[string]interface{}
  2054. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2055. fmt.Println(dat)
  2056. } else {
  2057. fmt.Println(err)
  2058. }
  2059. userJSONBytes, _ := json.Marshal(dat)
  2060. var res ResultSeventeen
  2061. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2062. utils.ErrorLog("解析失败:%v", err)
  2063. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2064. adminUser := c.GetAdminUserInfo()
  2065. errlog := &models.HisOrderError{
  2066. UserOrgId: adminUser.CurrentOrgId,
  2067. Ctime: time.Now().Unix(),
  2068. Mtime: time.Now().Unix(),
  2069. ErrMsg: res.ErrMsg + "解析失败",
  2070. Status: 1,
  2071. PatientId: order_id,
  2072. Stage: 1000,
  2073. }
  2074. service.CreateErrMsgLog(errlog)
  2075. continue
  2076. }
  2077. if res.Infcode != 0 {
  2078. adminUser := c.GetAdminUserInfo()
  2079. errlog := &models.HisOrderError{
  2080. UserOrgId: adminUser.CurrentOrgId,
  2081. Ctime: time.Now().Unix(),
  2082. Mtime: time.Now().Unix(),
  2083. ErrMsg: res.ErrMsg,
  2084. Status: 1,
  2085. PatientId: order_id,
  2086. Stage: 1000,
  2087. }
  2088. service.CreateErrMsgLog(errlog)
  2089. continue
  2090. } else {
  2091. hisFundSettleListResult := &models.HisFundSettleListResult{
  2092. Number: res.Output.SetlListId,
  2093. Status: 1,
  2094. Ctime: time.Now().Unix(),
  2095. Mtime: time.Now().Unix(),
  2096. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2097. IsUpload: 1,
  2098. OrderId: order_id,
  2099. }
  2100. service.CreateUploadRecord(hisFundSettleListResult)
  2101. continue
  2102. }
  2103. }
  2104. }
  2105. func (c *HisApiController) GetOrgInfo() {
  2106. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2107. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2108. }
  2109. func (c *HisApiController) GetHisPatientInfo() {
  2110. medical_insurance_card := c.GetString("medical_insurance_card")
  2111. id_card_type, _ := c.GetInt64("id_card_type")
  2112. id_card := c.GetString("id_card")
  2113. adminInfo := c.GetAdminUserInfo()
  2114. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2115. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2116. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2117. IdCardNo := ""
  2118. if id_card_type == 1 {
  2119. IdCardNo = medical_insurance_card
  2120. } else if id_card_type == 2 {
  2121. IdCardNo = id_card
  2122. }
  2123. if config.IsOpen == 1 {
  2124. 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
  2125. resp, requestErr := http.Get(api)
  2126. if requestErr != nil {
  2127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2128. return
  2129. }
  2130. defer resp.Body.Close()
  2131. body, ioErr := ioutil.ReadAll(resp.Body)
  2132. if ioErr != nil {
  2133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2135. return
  2136. }
  2137. var respJSON map[string]interface{}
  2138. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2141. return
  2142. }
  2143. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2144. userJSONBytes, _ := json.Marshal(userJSON)
  2145. var res ResultTwo
  2146. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2147. utils.ErrorLog("解析失败:%v", err)
  2148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2149. return
  2150. }
  2151. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2152. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2153. infoStr := string(Iinfos)
  2154. idetinfoStr := string(Idetinfos)
  2155. if res.Infcode == 0 {
  2156. his := models.VMHisPatient{
  2157. Status: 1,
  2158. Ctime: time.Now().Unix(),
  2159. Mtime: time.Now().Unix(),
  2160. PsnNo: res.Output.Baseinfo.PsnNo,
  2161. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2162. Certno: res.Output.Baseinfo.Certno,
  2163. PsnName: res.Output.Baseinfo.PsnName,
  2164. Gend: res.Output.Baseinfo.Gend,
  2165. Naty: res.Output.Baseinfo.Naty,
  2166. Brdy: res.Output.Baseinfo.Brdy,
  2167. Age: res.Output.Baseinfo.Age,
  2168. Iinfo: infoStr,
  2169. Idetinfo: idetinfoStr,
  2170. UserOrgId: adminInfo.CurrentOrgId,
  2171. IsReturn: 1,
  2172. IdCardType: id_card_type,
  2173. }
  2174. c.ServeSuccessJSON(map[string]interface{}{
  2175. "info": his,
  2176. })
  2177. } else {
  2178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2179. return
  2180. }
  2181. }
  2182. }
  2183. //func GetBasBaseInfo() (jsonStr string, err error) {
  2184. //
  2185. // handle := syscall.NewLazyDLL("SSCard.dll")
  2186. // add := handle.NewProc("ReadCardBas")
  2187. // str := make([]byte, 1024)
  2188. // str1 := make([]byte, 1024)
  2189. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2190. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  2191. //
  2192. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  2193. //
  2194. // fmt.Println("> Add(4,5)的结果为:", ret)
  2195. // handle.Release()
  2196. //
  2197. // return "", nil
  2198. //
  2199. //}
  2200. //func GetQRBaseInfo() (jsonStr string, err error) {
  2201. // handle := syscall.LoadDLL("SSCard.dll")
  2202. // ReadCardBas := handle.FindProc("GetQRBase")
  2203. //
  2204. // str := make([]byte, 256)
  2205. // str1 := make([]byte, 256)
  2206. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2207. //
  2208. // fmt.Println(string(str))
  2209. // fmt.Println(r)
  2210. // return string(str), nil
  2211. //}
  2212. //func CardInit() int {
  2213. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  2214. // add := DllTestDef.MustFindProc("Init")
  2215. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2216. // if err != nil {
  2217. // fmt.Println("SSCard的运算结果为:", ret)
  2218. // }
  2219. // result := int(ret)
  2220. // return result
  2221. //}
  2222. //func CardInit() int {
  2223. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2224. // if err != nil {
  2225. // fmt.Println("SSCard的运算结果为:", ret)
  2226. // }
  2227. // fmt.Println(err)
  2228. // result := int(ret)
  2229. // return result
  2230. //}
  2231. func IntPtr(n int) uintptr {
  2232. return uintptr(n)
  2233. }
  2234. func StrPtr(s string) uintptr {
  2235. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  2236. }
  2237. type Result2001 struct {
  2238. Cainfo interface{} `json:"cainfo"`
  2239. ErrMsg string `json:"err_msg"`
  2240. InfRefmsgid string `json:"inf_refmsgid"`
  2241. Infcode int64 `json:"infcode"`
  2242. Output struct {
  2243. Trtinfo struct {
  2244. PsnNo string `json:"psn_no"`
  2245. TrtChkType string `json:"trt_chk_type"`
  2246. FundPayType string `json:"fund_pay_type"`
  2247. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2248. Begndate string `json:"begndate"`
  2249. Enddate string `json:"enddate"`
  2250. TrtChkRslt string `json:"trt_chk_rslt"`
  2251. } `json:"trtinfo"`
  2252. } `json:"output"`
  2253. RefmsgTime string `json:"refmsg_time"`
  2254. RespondTime string `json:"respond_time"`
  2255. Signtype interface{} `json:"signtype"`
  2256. WarnMsg interface{} `json:"warn_msg"`
  2257. }
  2258. type Result2001Org10265 struct {
  2259. Cainfo interface{} `json:"cainfo"`
  2260. ErrMsg string `json:"err_msg"`
  2261. InfRefmsgid string `json:"inf_refmsgid"`
  2262. Infcode string `json:"infcode"`
  2263. Output struct {
  2264. Trtinfo struct {
  2265. PsnNo string `json:"psn_no"`
  2266. TrtChkType string `json:"trt_chk_type"`
  2267. FundPayType string `json:"fund_pay_type"`
  2268. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2269. Begndate string `json:"begndate"`
  2270. Enddate string `json:"enddate"`
  2271. TrtChkRslt string `json:"trt_chk_rslt"`
  2272. } `json:"trtinfo"`
  2273. } `json:"output"`
  2274. RefmsgTime string `json:"refmsg_time"`
  2275. RespondTime string `json:"respond_time"`
  2276. Signtype interface{} `json:"signtype"`
  2277. WarnMsg interface{} `json:"warn_msg"`
  2278. }
  2279. type ResultTwo struct {
  2280. ErrMsg string `json:"err_msg"`
  2281. InfRefmsgid string `json:"inf_refmsgid"`
  2282. Infcode int64 `json:"infcode"`
  2283. Output struct {
  2284. Baseinfo struct {
  2285. Age float64 `json:"age"`
  2286. Brdy string `json:"brdy"`
  2287. Certno string `json:"certno"`
  2288. Gend string `json:"gend"`
  2289. Naty string `json:"naty"`
  2290. PsnCertType string `json:"psn_cert_type"`
  2291. PsnName string `json:"psn_name"`
  2292. PsnNo string `json:"psn_no"`
  2293. } `json:"baseinfo"`
  2294. Idetinfo []interface{} `json:"idetinfo"`
  2295. Iinfo []struct {
  2296. Balc float64 `json:"balc"`
  2297. CvlservFlag string `json:"cvlserv_flag"`
  2298. EmpName string `json:"emp_name"`
  2299. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2300. Insutype string `json:"insutype"`
  2301. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2302. PausInsuDate string `json:"paus_insu_date"`
  2303. PsnInsuDate string `json:"psn_insu_date"`
  2304. PsnInsuStas string `json:"psn_insu_stas"`
  2305. PsnType string `json:"psn_type"`
  2306. } `json:"insuinfo"`
  2307. } `json:"output"`
  2308. RefmsgTime string `json:"refmsg_time"`
  2309. RespondTime string `json:"respond_time"`
  2310. Signtype interface{} `json:"signtype"`
  2311. WarnInfo interface{} `json:"warn_info"`
  2312. }
  2313. type ResultTwo10265 struct {
  2314. ErrMsg string `json:"err_msg"`
  2315. InfRefmsgid string `json:"inf_refmsgid"`
  2316. Infcode string `json:"infcode"`
  2317. Output struct {
  2318. Baseinfo struct {
  2319. Age float64 `json:"age"`
  2320. Brdy string `json:"brdy"`
  2321. Certno string `json:"certno"`
  2322. Gend string `json:"gend"`
  2323. Naty string `json:"naty"`
  2324. PsnCertType string `json:"psn_cert_type"`
  2325. PsnName string `json:"psn_name"`
  2326. PsnNo string `json:"psn_no"`
  2327. } `json:"baseinfo"`
  2328. Idetinfo []interface{} `json:"idetinfo"`
  2329. Iinfo []struct {
  2330. Balc float64 `json:"balc"`
  2331. CvlservFlag string `json:"cvlserv_flag"`
  2332. EmpName string `json:"emp_name"`
  2333. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2334. Insutype string `json:"insutype"`
  2335. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2336. PausInsuDate string `json:"paus_insu_date"`
  2337. PsnInsuDate string `json:"psn_insu_date"`
  2338. PsnInsuStas string `json:"psn_insu_stas"`
  2339. PsnType string `json:"psn_type"`
  2340. } `json:"insuinfo"`
  2341. } `json:"output"`
  2342. RefmsgTime string `json:"refmsg_time"`
  2343. RespondTime string `json:"respond_time"`
  2344. Signtype interface{} `json:"signtype"`
  2345. WarnInfo interface{} `json:"warn_info"`
  2346. }
  2347. type ResultThree struct {
  2348. Cainfo interface{} `json:"cainfo"`
  2349. ErrMsg string `json:"err_msg"`
  2350. InfRefmsgid string `json:"inf_refmsgid"`
  2351. Infcode int64 `json:"infcode"`
  2352. Output struct {
  2353. Data struct {
  2354. IptOtpNo string `json:"ipt_otp_no"`
  2355. MdtrtID string `json:"mdtrt_id"`
  2356. PsnNo string `json:"psn_no"`
  2357. } `json:"data"`
  2358. } `json:"output"`
  2359. RefmsgTime string `json:"refmsg_time"`
  2360. RespondTime string `json:"respond_time"`
  2361. Signtype interface{} `json:"signtype"`
  2362. WarnMsg interface{} `json:"warn_msg"`
  2363. }
  2364. type ResultThree10265 struct {
  2365. Cainfo interface{} `json:"cainfo"`
  2366. ErrMsg string `json:"err_msg"`
  2367. InfRefmsgid string `json:"inf_refmsgid"`
  2368. Infcode string `json:"infcode"`
  2369. Output struct {
  2370. Data struct {
  2371. IptOtpNo string `json:"ipt_otp_no"`
  2372. MdtrtID string `json:"mdtrt_id"`
  2373. PsnNo string `json:"psn_no"`
  2374. } `json:"data"`
  2375. } `json:"output"`
  2376. RefmsgTime string `json:"refmsg_time"`
  2377. RespondTime string `json:"respond_time"`
  2378. Signtype interface{} `json:"signtype"`
  2379. WarnMsg interface{} `json:"warn_msg"`
  2380. }
  2381. type ResultFour struct {
  2382. Cainfo string `json:"cainfo"`
  2383. ErrMsg string `json:"err_msg"`
  2384. InfRefmsgid string `json:"inf_refmsgid"`
  2385. Infcode int64 `json:"infcode"`
  2386. Output struct {
  2387. Result []struct {
  2388. BasMednFlag string `json:"bas_medn_flag"`
  2389. ChldMedcFlag string `json:"chld_medc_flag"`
  2390. ChrgitmLv string `json:"chrgitm_lv"`
  2391. Cnt float64 `json:"cnt"`
  2392. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2393. DrtReimFlag string `json:"drt_reim_flag"`
  2394. FeedetlSn string `json:"feedetl_sn"`
  2395. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2396. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2397. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2398. ListSpItemFlag string `json:"list_sp_item_flag"`
  2399. LmtUsedFlag string `json:"lmt_used_flag"`
  2400. MedChrgitmType string `json:"med_chrgitm_type"`
  2401. Memo string `json:"memo"`
  2402. OverlmtAmt float64 `json:"overlmt_amt"`
  2403. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2404. Pric float64 `json:"pric"`
  2405. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2406. SelfpayProp float64 `json:"selfpay_prop"`
  2407. } `json:"result"`
  2408. } `json:"output"`
  2409. RefmsgTime string `json:"refmsg_time"`
  2410. RespondTime string `json:"respond_time"`
  2411. Signtype string `json:"signtype"`
  2412. WarnMsg string `json:"warn_msg"`
  2413. }
  2414. type ResultFour10265 struct {
  2415. Cainfo string `json:"cainfo"`
  2416. ErrMsg string `json:"err_msg"`
  2417. InfRefmsgid string `json:"inf_refmsgid"`
  2418. Infcode string `json:"infcode"`
  2419. Output struct {
  2420. Result []struct {
  2421. BasMednFlag string `json:"bas_medn_flag"`
  2422. ChldMedcFlag string `json:"chld_medc_flag"`
  2423. ChrgitmLv string `json:"chrgitm_lv"`
  2424. Cnt float64 `json:"cnt"`
  2425. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2426. DrtReimFlag string `json:"drt_reim_flag"`
  2427. FeedetlSn string `json:"feedetl_sn"`
  2428. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2429. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2430. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2431. ListSpItemFlag string `json:"list_sp_item_flag"`
  2432. LmtUsedFlag string `json:"lmt_used_flag"`
  2433. MedChrgitmType string `json:"med_chrgitm_type"`
  2434. Memo string `json:"memo"`
  2435. OverlmtAmt float64 `json:"overlmt_amt"`
  2436. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2437. Pric float64 `json:"pric"`
  2438. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2439. SelfpayProp float64 `json:"selfpay_prop"`
  2440. } `json:"result"`
  2441. } `json:"output"`
  2442. RefmsgTime string `json:"refmsg_time"`
  2443. RespondTime string `json:"respond_time"`
  2444. Signtype string `json:"signtype"`
  2445. WarnMsg string `json:"warn_msg"`
  2446. }
  2447. type ResultFive struct {
  2448. Balc float64 `json:"balc"`
  2449. CvlservFlag string `json:"cvlserv_flag"`
  2450. EmpName string `json:"emp_name"`
  2451. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2452. Insutype string `json:"insutype"`
  2453. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2454. PausInsuDate string `json:"paus_insu_date"`
  2455. PsnInsuDate string `json:"psn_insu_date"`
  2456. PsnInsuStas string `json:"psn_insu_stas"`
  2457. PsnType string `json:"psn_type"`
  2458. }
  2459. type ResultSix struct {
  2460. Cainfo interface{} `json:"cainfo"`
  2461. ErrMsg string `json:"err_msg"`
  2462. InfRefmsgid string `json:"inf_refmsgid"`
  2463. Infcode int64 `json:"infcode"`
  2464. Output struct {
  2465. } `json:"output"`
  2466. RefmsgTime string `json:"refmsg_time"`
  2467. RespondTime string `json:"respond_time"`
  2468. Signtype interface{} `json:"signtype"`
  2469. WarnMsg interface{} `json:"warn_msg"`
  2470. }
  2471. type ResultSix10265 struct {
  2472. Cainfo interface{} `json:"cainfo"`
  2473. ErrMsg string `json:"err_msg"`
  2474. InfRefmsgid string `json:"inf_refmsgid"`
  2475. Infcode string `json:"infcode"`
  2476. Output struct {
  2477. } `json:"output"`
  2478. RefmsgTime string `json:"refmsg_time"`
  2479. RespondTime string `json:"respond_time"`
  2480. Signtype interface{} `json:"signtype"`
  2481. WarnMsg interface{} `json:"warn_msg"`
  2482. }
  2483. type ResultSeven struct {
  2484. Cainfo string `json:"cainfo"`
  2485. ErrMsg string `json:"err_msg"`
  2486. InfRefmsgid string `json:"inf_refmsgid"`
  2487. Infcode int64 `json:"infcode"`
  2488. Output struct {
  2489. Setldetail []interface{} `json:"setldetail"`
  2490. Setlinfo struct {
  2491. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2492. AcctPay float64 `json:"acct_pay"`
  2493. ActPayDedc float64 `json:"act_pay_dedc"`
  2494. Age float64 `json:"age"`
  2495. Balc float64 `json:"balc"`
  2496. Brdy string `json:"brdy"`
  2497. Certno string `json:"certno"`
  2498. ClrOptins string `json:"clr_optins"`
  2499. ClrType string `json:"clr_type"`
  2500. ClrWay string `json:"clr_way"`
  2501. CvlservFlag string `json:"cvlserv_flag"`
  2502. CvlservPay float64 `json:"cvlserv_pay"`
  2503. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2504. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2505. Gend string `json:"gend"`
  2506. HifesPay float64 `json:"hifes_pay"`
  2507. HifmiPay float64 `json:"hifmi_pay"`
  2508. HifpPay float64 `json:"hifp_pay"`
  2509. HospPartAmt float64 `json:"hosp_part_amt"`
  2510. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2511. Insutype string `json:"insutype"`
  2512. MafPay float64 `json:"maf_pay"`
  2513. MdtrtCertType string `json:"mdtrt_cert_type"`
  2514. HifobPay float64 `json:"hifob_pay"`
  2515. MdtrtID string `json:"mdtrt_id"`
  2516. MedType string `json:"med_type"`
  2517. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2518. MedinsSetlID string `json:"medins_setl_id"`
  2519. Naty string `json:"naty"`
  2520. OthPay float64 `json:"oth_pay"`
  2521. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2522. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2523. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2524. PsnCashPay float64 `json:"psn_cash_pay"`
  2525. PsnCertType string `json:"psn_cert_type"`
  2526. PsnName string `json:"psn_name"`
  2527. PsnNo string `json:"psn_no"`
  2528. PsnPartAmt float64 `json:"psn_part_amt"`
  2529. PsnType string `json:"psn_type"`
  2530. SetlID string `json:"setl_id"`
  2531. SetlTime string `json:"setl_time"`
  2532. } `json:"setlinfo"`
  2533. } `json:"output"`
  2534. RefmsgTime string `json:"refmsg_time"`
  2535. RespondTime string `json:"respond_time"`
  2536. Signtype interface{} `json:"signtype"`
  2537. WarnMsg interface{} `json:"warn_msg"`
  2538. }
  2539. type ResultSeven10265 struct {
  2540. Cainfo string `json:"cainfo"`
  2541. ErrMsg string `json:"err_msg"`
  2542. InfRefmsgid string `json:"inf_refmsgid"`
  2543. Infcode string `json:"infcode"`
  2544. Output struct {
  2545. Setldetail []interface{} `json:"setldetail"`
  2546. Setlinfo struct {
  2547. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2548. AcctPay float64 `json:"acct_pay"`
  2549. ActPayDedc float64 `json:"act_pay_dedc"`
  2550. Age float64 `json:"age"`
  2551. Balc float64 `json:"balc"`
  2552. Brdy string `json:"brdy"`
  2553. Certno string `json:"certno"`
  2554. ClrOptins string `json:"clr_optins"`
  2555. ClrType string `json:"clr_type"`
  2556. ClrWay string `json:"clr_way"`
  2557. CvlservFlag string `json:"cvlserv_flag"`
  2558. CvlservPay float64 `json:"cvlserv_pay"`
  2559. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2560. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2561. Gend string `json:"gend"`
  2562. HifesPay float64 `json:"hifes_pay"`
  2563. HifmiPay float64 `json:"hifmi_pay"`
  2564. HifpPay float64 `json:"hifp_pay"`
  2565. HospPartAmt float64 `json:"hosp_part_amt"`
  2566. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2567. Insutype string `json:"insutype"`
  2568. MafPay float64 `json:"maf_pay"`
  2569. MdtrtCertType string `json:"mdtrt_cert_type"`
  2570. HifobPay float64 `json:"hifob_pay"`
  2571. MdtrtID string `json:"mdtrt_id"`
  2572. MedType string `json:"med_type"`
  2573. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2574. MedinsSetlID string `json:"medins_setl_id"`
  2575. Naty string `json:"naty"`
  2576. OthPay float64 `json:"oth_pay"`
  2577. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2578. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2579. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2580. PsnCashPay float64 `json:"psn_cash_pay"`
  2581. PsnCertType string `json:"psn_cert_type"`
  2582. PsnName string `json:"psn_name"`
  2583. PsnNo string `json:"psn_no"`
  2584. PsnPartAmt float64 `json:"psn_part_amt"`
  2585. PsnType string `json:"psn_type"`
  2586. SetlID string `json:"setl_id"`
  2587. SetlTime string `json:"setl_time"`
  2588. } `json:"setlinfo"`
  2589. } `json:"output"`
  2590. RefmsgTime string `json:"refmsg_time"`
  2591. RespondTime string `json:"respond_time"`
  2592. Signtype interface{} `json:"signtype"`
  2593. WarnMsg interface{} `json:"warn_msg"`
  2594. }
  2595. type ResultEight struct {
  2596. Cainfo string `json:"cainfo"`
  2597. ErrMsg string `json:"err_msg"`
  2598. InfRefmsgid string `json:"inf_refmsgid"`
  2599. Infcode int64 `json:"infcode"`
  2600. Output struct {
  2601. Stmtinfo struct {
  2602. SetlOptins string `json:"setl_optins"`
  2603. StmtRslt string `json:"stmt_rslt"`
  2604. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2605. } `json:"stmtinfo"`
  2606. } `json:"output"`
  2607. RefmsgTime string `json:"refmsg_time"`
  2608. RespondTime string `json:"respond_time"`
  2609. Signtype interface{} `json:"signtype"`
  2610. WarnMsg interface{} `json:"warn_msg"`
  2611. }
  2612. type ResultEightFor10188 struct {
  2613. Cainfo string `json:"cainfo"`
  2614. ErrMsg string `json:"err_msg"`
  2615. InfRefmsgid string `json:"inf_refmsgid"`
  2616. Infcode string `json:"infcode"`
  2617. Output struct {
  2618. Stmtinfo struct {
  2619. SetlOptins string `json:"setl_optins"`
  2620. StmtRslt string `json:"stmt_rslt"`
  2621. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2622. } `json:"stmtinfo"`
  2623. } `json:"output"`
  2624. RefmsgTime string `json:"refmsg_time"`
  2625. RespondTime string `json:"respond_time"`
  2626. Signtype interface{} `json:"signtype"`
  2627. WarnMsg interface{} `json:"warn_msg"`
  2628. }
  2629. type ResultNine struct {
  2630. Cainfo string `json:"cainfo"`
  2631. ErrMsg string `json:"err_msg"`
  2632. InfRefmsgid string `json:"inf_refmsgid"`
  2633. Infcode int64 `json:"infcode"`
  2634. Output struct {
  2635. FileQuryNo string `json:"file_qury_no"`
  2636. } `json:"output"`
  2637. RefmsgTime string `json:"refmsg_time"`
  2638. RespondTime string `json:"respond_time"`
  2639. Signtype interface{} `json:"signtype"`
  2640. WarnMsg interface{} `json:"warn_msg"`
  2641. }
  2642. type ResultTen struct {
  2643. Cainfo string `json:"cainfo"`
  2644. ErrMsg string `json:"err_msg"`
  2645. InfRefmsgid string `json:"inf_refmsgid"`
  2646. Infcode int64 `json:"infcode"`
  2647. Output struct {
  2648. DldEndtime string `json:"dld_endtime"`
  2649. FileQuryNo string `json:"file_qury_no"`
  2650. Filename string `json:"filename"`
  2651. } `json:"output"`
  2652. RefmsgTime string `json:"refmsg_time"`
  2653. RespondTime string `json:"respond_time"`
  2654. Signtype interface{} `json:"signtype"`
  2655. WarnMsg interface{} `json:"warn_msg"`
  2656. }
  2657. //type Autogenerated struct {
  2658. // Output struct {
  2659. // Setlinfo struct {
  2660. // SetlTime string `json:"setl_time"`
  2661. // CvlservPay float64 `json:"cvlserv_pay"`
  2662. // Year string `json:"year"`
  2663. // MedType string `json:"med_type"`
  2664. // PsnPay float64 `json:"psn_pay"`
  2665. // OpterID string `json:"opter_id"`
  2666. // Begndate string `json:"begndate"`
  2667. // FlxempeFlag string `json:"flxempe_flag"`
  2668. // HifmiPay float64 `json:"hifmi_pay"`
  2669. // PsnNo string `json:"psn_no"`
  2670. // ActPayDedc float64 `json:"act_pay_dedc"`
  2671. // MedinsSetlID interface{} `json:"medins_setl_id"`
  2672. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2673. // ClrWay string `json:"clr_way"`
  2674. // OthPay float64 `json:"oth_pay"`
  2675. // Gend string `json:"gend"`
  2676. // MdtrtID string `json:"mdtrt_id"`
  2677. // AcctPay float64 `json:"acct_pay"`
  2678. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  2679. // Insutype string `json:"insutype"`
  2680. // Invono interface{} `json:"invono"`
  2681. // Enddate string `json:"enddate"`
  2682. // CashPayamt float64 `json:"cash_payamt"`
  2683. // PsnType string `json:"psn_type"`
  2684. // FixmedinsName string `json:"fixmedins_name"`
  2685. // HifpPay float64 `json:"hifp_pay"`
  2686. // NewFlag interface{} `json:"new_flag"`
  2687. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2688. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  2689. // PayLoc string `json:"pay_loc"`
  2690. // ClrType string `json:"clr_type"`
  2691. // RefdSetlFlag string `json:"refd_setl_flag"`
  2692. // CvlservFlag string `json:"cvlserv_flag"`
  2693. // EmpName string `json:"emp_name"`
  2694. // Brdy string `json:"brdy"`
  2695. // Naty string `json:"naty"`
  2696. // Certno string `json:"certno"`
  2697. // DiseCode string `json:"dise_code"`
  2698. // FixmedinsCode string `json:"fixmedins_code"`
  2699. // DedcHospLv string `json:"dedc_hosp_lv"`
  2700. // OpterName string `json:"opter_name"`
  2701. // Balc float64 `json:"balc"`
  2702. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2703. // PsnCertType string `json:"psn_cert_type"`
  2704. // HifobPay float64 `json:"hifob_pay"`
  2705. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  2706. // HifesPay float64 `json:"hifes_pay"`
  2707. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2708. // OptTime string `json:"opt_time"`
  2709. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2710. // SetlID string `json:"setl_id"`
  2711. // MafPay float64 `json:"maf_pay"`
  2712. // PsnName string `json:"psn_name"`
  2713. // InsuOptins interface{} `json:"insu_optins"`
  2714. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2715. // ClrOptins string `json:"clr_optins"`
  2716. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2717. // DiseName string `json:"dise_name"`
  2718. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2719. // Age float64 `json:"age"`
  2720. // DtrtCertType string `json:"dtrt_cert_type"`
  2721. // HospLv string `json:"hosp_lv"`
  2722. // } `json:"setlinfo"`
  2723. // Setldetail []struct {
  2724. // FundPayType string `json:"fund_pay_type"`
  2725. // FundPayamt float64 `json:"fund_payamt"`
  2726. // SetlProcInfo interface{} `json:"setl_proc_info"`
  2727. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  2728. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  2729. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  2730. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2731. // } `json:"setldetail"`
  2732. // } `json:"output"`
  2733. // Infcode int `json:"infcode"`
  2734. // WarnMsg interface{} `json:"warn_msg"`
  2735. // Cainfo interface{} `json:"cainfo"`
  2736. // ErrMsg interface{} `json:"err_msg"`
  2737. // RefmsgTime string `json:"refmsg_time"`
  2738. // Signtype interface{} `json:"signtype"`
  2739. // RespondTime string `json:"respond_time"`
  2740. // InfRefmsgid string `json:"inf_refmsgid"`
  2741. //}
  2742. type ResultEleven struct {
  2743. Cainfo string `json:"cainfo"`
  2744. ErrMsg string `json:"err_msg"`
  2745. InfRefmsgid string `json:"inf_refmsgid"`
  2746. Infcode int64 `json:"infcode"`
  2747. Output struct {
  2748. Setlinfo struct {
  2749. SetlTime string `json:"setl_time"`
  2750. CvlservPay float64 `json:"cvlserv_pay"`
  2751. Year string `json:"year"`
  2752. MedType string `json:"med_type"`
  2753. PsnPay float64 `json:"psn_pay"`
  2754. OpterID string `json:"opter_id"`
  2755. Begndate string `json:"begndate"`
  2756. FlxempeFlag string `json:"flxempe_flag"`
  2757. HifmiPay float64 `json:"hifmi_pay"`
  2758. PsnNo string `json:"psn_no"`
  2759. ActPayDedc float64 `json:"act_pay_dedc"`
  2760. MedinsSetlID interface{} `json:"medins_setl_id"`
  2761. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2762. ClrWay string `json:"clr_way"`
  2763. OthPay float64 `json:"oth_pay"`
  2764. Gend string `json:"gend"`
  2765. MdtrtID string `json:"mdtrt_id"`
  2766. AcctPay float64 `json:"acct_pay"`
  2767. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2768. Insutype string `json:"insutype"`
  2769. Invono interface{} `json:"invono"`
  2770. Enddate string `json:"enddate"`
  2771. CashPayamt float64 `json:"cash_payamt"`
  2772. PsnType string `json:"psn_type"`
  2773. FixmedinsName string `json:"fixmedins_name"`
  2774. HifpPay float64 `json:"hifp_pay"`
  2775. NewFlag interface{} `json:"new_flag"`
  2776. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2777. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2778. PayLoc string `json:"pay_loc"`
  2779. ClrType string `json:"clr_type"`
  2780. RefdSetlFlag string `json:"refd_setl_flag"`
  2781. CvlservFlag string `json:"cvlserv_flag"`
  2782. EmpName string `json:"emp_name"`
  2783. Brdy string `json:"brdy"`
  2784. Naty string `json:"naty"`
  2785. Certno string `json:"certno"`
  2786. DiseCode string `json:"dise_code"`
  2787. FixmedinsCode string `json:"fixmedins_code"`
  2788. DedcHospLv string `json:"dedc_hosp_lv"`
  2789. OpterName string `json:"opter_name"`
  2790. Balc float64 `json:"balc"`
  2791. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2792. PsnCertType string `json:"psn_cert_type"`
  2793. HifobPay float64 `json:"hifob_pay"`
  2794. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2795. HifesPay float64 `json:"hifes_pay"`
  2796. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2797. OptTime string `json:"opt_time"`
  2798. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2799. SetlID string `json:"setl_id"`
  2800. MafPay float64 `json:"maf_pay"`
  2801. PsnName string `json:"psn_name"`
  2802. InsuOptins interface{} `json:"insu_optins"`
  2803. PrefFundPay interface{} `json:"pref_fund_pay"`
  2804. ClrOptins string `json:"clr_optins"`
  2805. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2806. DiseName string `json:"dise_name"`
  2807. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2808. Age float64 `json:"age"`
  2809. DtrtCertType string `json:"dtrt_cert_type"`
  2810. HospLv string `json:"hosp_lv"`
  2811. } `json:"setlinfo"`
  2812. } `json:"output"`
  2813. RefmsgTime string `json:"refmsg_time"`
  2814. RespondTime string `json:"respond_time"`
  2815. Signtype interface{} `json:"signtype"`
  2816. WarnMsg interface{} `json:"warn_msg"`
  2817. }
  2818. type ResultEleven10265 struct {
  2819. Cainfo string `json:"cainfo"`
  2820. ErrMsg string `json:"err_msg"`
  2821. InfRefmsgid string `json:"inf_refmsgid"`
  2822. Infcode string `json:"infcode"`
  2823. Output struct {
  2824. Setlinfo struct {
  2825. SetlTime string `json:"setl_time"`
  2826. CvlservPay float64 `json:"cvlserv_pay"`
  2827. Year string `json:"year"`
  2828. MedType string `json:"med_type"`
  2829. PsnPay float64 `json:"psn_pay"`
  2830. OpterID string `json:"opter_id"`
  2831. Begndate string `json:"begndate"`
  2832. FlxempeFlag string `json:"flxempe_flag"`
  2833. HifmiPay float64 `json:"hifmi_pay"`
  2834. PsnNo string `json:"psn_no"`
  2835. ActPayDedc float64 `json:"act_pay_dedc"`
  2836. MedinsSetlID interface{} `json:"medins_setl_id"`
  2837. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2838. ClrWay string `json:"clr_way"`
  2839. OthPay float64 `json:"oth_pay"`
  2840. Gend string `json:"gend"`
  2841. MdtrtID string `json:"mdtrt_id"`
  2842. AcctPay float64 `json:"acct_pay"`
  2843. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2844. Insutype string `json:"insutype"`
  2845. Invono interface{} `json:"invono"`
  2846. Enddate string `json:"enddate"`
  2847. CashPayamt float64 `json:"cash_payamt"`
  2848. PsnType string `json:"psn_type"`
  2849. FixmedinsName string `json:"fixmedins_name"`
  2850. HifpPay float64 `json:"hifp_pay"`
  2851. NewFlag interface{} `json:"new_flag"`
  2852. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2853. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2854. PayLoc string `json:"pay_loc"`
  2855. ClrType string `json:"clr_type"`
  2856. RefdSetlFlag string `json:"refd_setl_flag"`
  2857. CvlservFlag string `json:"cvlserv_flag"`
  2858. EmpName string `json:"emp_name"`
  2859. Brdy string `json:"brdy"`
  2860. Naty string `json:"naty"`
  2861. Certno string `json:"certno"`
  2862. DiseCode string `json:"dise_code"`
  2863. FixmedinsCode string `json:"fixmedins_code"`
  2864. DedcHospLv string `json:"dedc_hosp_lv"`
  2865. OpterName string `json:"opter_name"`
  2866. Balc float64 `json:"balc"`
  2867. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2868. PsnCertType string `json:"psn_cert_type"`
  2869. HifobPay float64 `json:"hifob_pay"`
  2870. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2871. HifesPay float64 `json:"hifes_pay"`
  2872. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2873. OptTime string `json:"opt_time"`
  2874. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2875. SetlID string `json:"setl_id"`
  2876. MafPay float64 `json:"maf_pay"`
  2877. PsnName string `json:"psn_name"`
  2878. InsuOptins interface{} `json:"insu_optins"`
  2879. PrefFundPay interface{} `json:"pref_fund_pay"`
  2880. ClrOptins string `json:"clr_optins"`
  2881. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2882. DiseName string `json:"dise_name"`
  2883. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2884. Age float64 `json:"age"`
  2885. DtrtCertType string `json:"dtrt_cert_type"`
  2886. HospLv string `json:"hosp_lv"`
  2887. } `json:"setlinfo"`
  2888. } `json:"output"`
  2889. RefmsgTime string `json:"refmsg_time"`
  2890. RespondTime string `json:"respond_time"`
  2891. Signtype interface{} `json:"signtype"`
  2892. WarnMsg interface{} `json:"warn_msg"`
  2893. }
  2894. type ResultTwelve struct {
  2895. Cainfo string `json:"cainfo"`
  2896. ErrMsg string `json:"err_msg"`
  2897. InfRefmsgid string `json:"inf_refmsgid"`
  2898. Infcode int64 `json:"infcode"`
  2899. Output struct {
  2900. MdtrtId string `json:"mdtrt_id"`
  2901. ChrgBchno string `json:"chrg_bchno"`
  2902. PsnNo string `json:"psn_no"`
  2903. } `json:"output"`
  2904. RefmsgTime string `json:"refmsg_time"`
  2905. RespondTime string `json:"respond_time"`
  2906. Signtype interface{} `json:"signtype"`
  2907. WarnMsg interface{} `json:"warn_msg"`
  2908. }
  2909. type ResultThirteen struct {
  2910. ErrMsg string `json:"err_msg"`
  2911. InfRefmsgid string `json:"inf_refmsgid"`
  2912. Infcode int64 `json:"infcode"`
  2913. Output struct {
  2914. Result struct {
  2915. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2916. } `json:"result"`
  2917. } `json:"output"`
  2918. RefmsgTime string `json:"refmsg_time"`
  2919. RespondTime string `json:"respond_time"`
  2920. Signtype interface{} `json:"signtype"`
  2921. WarnInfo interface{} `json:"warn_info"`
  2922. }
  2923. type ResultThirteen10265 struct {
  2924. ErrMsg string `json:"err_msg"`
  2925. InfRefmsgid string `json:"inf_refmsgid"`
  2926. Infcode string `json:"infcode"`
  2927. Output struct {
  2928. Result struct {
  2929. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2930. } `json:"result"`
  2931. } `json:"output"`
  2932. RefmsgTime string `json:"refmsg_time"`
  2933. RespondTime string `json:"respond_time"`
  2934. Signtype interface{} `json:"signtype"`
  2935. WarnInfo interface{} `json:"warn_info"`
  2936. }
  2937. type ResultFourteen struct {
  2938. ErrMsg string `json:"err_msg"`
  2939. InfRefmsgid string `json:"inf_refmsgid"`
  2940. Infcode int64 `json:"infcode"`
  2941. Output struct {
  2942. } `json:"output"`
  2943. RefmsgTime string `json:"refmsg_time"`
  2944. RespondTime string `json:"respond_time"`
  2945. Signtype interface{} `json:"signtype"`
  2946. WarnInfo interface{} `json:"warn_info"`
  2947. }
  2948. type ResultFourteen10265 struct {
  2949. ErrMsg string `json:"err_msg"`
  2950. InfRefmsgid string `json:"inf_refmsgid"`
  2951. Infcode string `json:"infcode"`
  2952. Output struct {
  2953. } `json:"output"`
  2954. RefmsgTime string `json:"refmsg_time"`
  2955. RespondTime string `json:"respond_time"`
  2956. Signtype interface{} `json:"signtype"`
  2957. WarnInfo interface{} `json:"warn_info"`
  2958. }
  2959. type ResultSixteen struct {
  2960. Cainfo string `json:"cainfo"`
  2961. ErrMsg string `json:"err_msg"`
  2962. InfRefmsgid string `json:"inf_refmsgid"`
  2963. Infcode int64 `json:"infcode"`
  2964. Output struct {
  2965. Setldetail []interface{} `json:"setldetail"`
  2966. Setlinfo struct {
  2967. MdtrtID string `json:"mdtrt_id"`
  2968. SetlID string `json:"setl_id"`
  2969. ClrOptins string `json:"clr_optins"`
  2970. SetlTime string `json:"setl_time"`
  2971. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2972. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2973. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2974. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2975. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2976. ActPayDedc float64 `json:"act_pay_dedc"`
  2977. HifpPay float64 `json:"hifp_pay"`
  2978. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2979. Lfpay float64 `json:"selfpay"`
  2980. CvlservPay float64 `json:"cvlserv_pay"`
  2981. HifesPay float64 `json:"hifes_pay"`
  2982. HifmiPay float64 `json:"hifmi_pay"`
  2983. HifobPay float64 `json:"hifob_pay"`
  2984. MafPay float64 `json:"maf_pay"`
  2985. OthPay float64 `json:"oth_pay"`
  2986. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2987. PsnPartAmt float64 `json:"psn_part_amt"`
  2988. AcctPay float64 `json:"acct_pay"`
  2989. Balc float64 `json:"balc"`
  2990. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2991. HospPartAmt float64 `json:"hosp_part_amt"`
  2992. MedinsSetlID string `json:"medins_setl_id"`
  2993. PdnCashPay string `json:"pdn_cash_pay"`
  2994. } `json:"setlinfo"`
  2995. } `json:"output"`
  2996. RefmsgTime string `json:"refmsg_time"`
  2997. RespondTime string `json:"respond_time"`
  2998. Signtype interface{} `json:"signtype"`
  2999. WarnMsg interface{} `json:"warn_msg"`
  3000. }
  3001. type ResultSixteen10265 struct {
  3002. Cainfo string `json:"cainfo"`
  3003. ErrMsg string `json:"err_msg"`
  3004. InfRefmsgid string `json:"inf_refmsgid"`
  3005. Infcode string `json:"infcode"`
  3006. Output struct {
  3007. Setldetail []interface{} `json:"setldetail"`
  3008. Setlinfo struct {
  3009. MdtrtID string `json:"mdtrt_id"`
  3010. SetlID string `json:"setl_id"`
  3011. ClrOptins string `json:"clr_optins"`
  3012. SetlTime string `json:"setl_time"`
  3013. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3014. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3015. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3016. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3017. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3018. ActPayDedc float64 `json:"act_pay_dedc"`
  3019. HifpPay float64 `json:"hifp_pay"`
  3020. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3021. Lfpay float64 `json:"selfpay"`
  3022. CvlservPay float64 `json:"cvlserv_pay"`
  3023. HifesPay float64 `json:"hifes_pay"`
  3024. HifmiPay float64 `json:"hifmi_pay"`
  3025. HifobPay float64 `json:"hifob_pay"`
  3026. MafPay float64 `json:"maf_pay"`
  3027. OthPay float64 `json:"oth_pay"`
  3028. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3029. PsnPartAmt float64 `json:"psn_part_amt"`
  3030. AcctPay float64 `json:"acct_pay"`
  3031. Balc float64 `json:"balc"`
  3032. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3033. HospPartAmt float64 `json:"hosp_part_amt"`
  3034. MedinsSetlID string `json:"medins_setl_id"`
  3035. PdnCashPay string `json:"pdn_cash_pay"`
  3036. } `json:"setlinfo"`
  3037. } `json:"output"`
  3038. RefmsgTime string `json:"refmsg_time"`
  3039. RespondTime string `json:"respond_time"`
  3040. Signtype interface{} `json:"signtype"`
  3041. WarnMsg interface{} `json:"warn_msg"`
  3042. }
  3043. type ResultSeventeen struct {
  3044. ErrMsg string `json:"err_msg"`
  3045. InfRefmsgid string `json:"inf_refmsgid"`
  3046. Infcode int64 `json:"infcode"`
  3047. Output struct {
  3048. SetlListId string `json:"setl_list_id"`
  3049. } `json:"output"`
  3050. RefmsgTime string `json:"refmsg_time"`
  3051. RespondTime string `json:"respond_time"`
  3052. Signtype string `json:"signtype"`
  3053. WarnInfo string `json:"warn_info"`
  3054. }
  3055. type Result90991 struct {
  3056. ErrMsg string `json:"err_msg"`
  3057. InfRefmsgid string `json:"inf_refmsgid"`
  3058. Infcode int64 `json:"infcode"`
  3059. Output struct {
  3060. Result struct {
  3061. PsnNo string `json:"psn_no"`
  3062. CardStat string `json:"card_stat"`
  3063. Certno string `json:"certno"`
  3064. PsnName string `json:"psn_name"`
  3065. CheckStat string `json:"check_stat"`
  3066. } `json:"result"`
  3067. } `json:"output"`
  3068. RefmsgTime string `json:"refmsg_time"`
  3069. RespondTime string `json:"respond_time"`
  3070. Signtype interface{} `json:"signtype"`
  3071. WarnInfo interface{} `json:"warn_info"`
  3072. }
  3073. type Result90100 struct {
  3074. ErrMsg string `json:"err_msg"`
  3075. InfRefmsgid string `json:"inf_refmsgid"`
  3076. Infcode int64 `json:"infcode"`
  3077. Output struct {
  3078. PoolareaNo string `json:"poolarea_no"`
  3079. PoolareaNoName string `json:"poolarea_no_name"`
  3080. Insutype string `json:"insutype"`
  3081. InsutypeName string `json:"insutype_name"`
  3082. ClctType string `json:"clct_type"`
  3083. ClctTypeName string `json:"clct_type_name"`
  3084. ClctFlag string `json:"clct_flag"`
  3085. ClctFlagName string `json:"clct_flag_name"`
  3086. AccrymBegn string `json:"accrym_begn"`
  3087. AccrymEnd string `json:"accrym_end"`
  3088. ClctTime string `json:"clct_time"`
  3089. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3090. } `json:"output"`
  3091. RefmsgTime string `json:"refmsg_time"`
  3092. RespondTime string `json:"respond_time"`
  3093. Signtype interface{} `json:"signtype"`
  3094. WarnInfo interface{} `json:"warn_info"`
  3095. }
  3096. type Custom struct {
  3097. DetItemFeeSumamt string
  3098. Cut string
  3099. FeedetlSn string
  3100. Price string
  3101. MedListCodg string
  3102. Type int64
  3103. AdviceId int64
  3104. ProjectId int64
  3105. ItemId int64
  3106. }
  3107. type Result5301 struct {
  3108. ErrMsg string `json:"err_msg"`
  3109. InfRefmsgid string `json:"inf_refmsgid"`
  3110. Infcode int64 `json:"infcode"`
  3111. Output struct {
  3112. Result []struct {
  3113. OpspDiseCode string `json:"opsp_dise_code"`
  3114. OpspDiseName string `json:"opsp_dise_name"`
  3115. Begndate string `json:"begndate"`
  3116. Enddate string `json:"enddate"`
  3117. } `json:"feedetail"`
  3118. } `json:"output"`
  3119. RefmsgTime string `json:"refmsg_time"`
  3120. RespondTime string `json:"respond_time"`
  3121. Signtype interface{} `json:"signtype"`
  3122. WarnInfo interface{} `json:"warn_info"`
  3123. }
  3124. type Result5301For10265 struct {
  3125. ErrMsg string `json:"err_msg"`
  3126. InfRefmsgid string `json:"inf_refmsgid"`
  3127. Infcode string `json:"infcode"`
  3128. Output struct {
  3129. Result []struct {
  3130. OpspDiseCode string `json:"opsp_dise_code"`
  3131. OpspDiseName string `json:"opsp_dise_name"`
  3132. Begndate string `json:"begndate"`
  3133. Enddate string `json:"enddate"`
  3134. } `json:"feedetail"`
  3135. } `json:"output"`
  3136. RefmsgTime string `json:"refmsg_time"`
  3137. RespondTime string `json:"respond_time"`
  3138. Signtype interface{} `json:"signtype"`
  3139. WarnInfo interface{} `json:"warn_info"`
  3140. }
  3141. //获取个人信息----挂号-----上传就诊信息
  3142. func (c *HisApiController) GetRegisterInfo() {
  3143. id, _ := c.GetInt64("id")
  3144. record_time := c.GetString("record_time")
  3145. settlementValue, _ := c.GetInt64("settlement_value")
  3146. medical_insurance_card := c.GetString("medical_insurance_card")
  3147. name := c.GetString("name")
  3148. id_card_type, _ := c.GetInt64("id_card_type")
  3149. certificates, _ := c.GetInt64("certificates")
  3150. medical_care, _ := c.GetInt64("medical_care")
  3151. birthday := c.GetString("birthday")
  3152. id_card := c.GetString("id_card")
  3153. register_type, _ := c.GetInt64("register")
  3154. doctor, _ := c.GetInt64("doctor")
  3155. department, _ := c.GetInt64("department")
  3156. gender, _ := c.GetInt64("sex")
  3157. registration_fee, _ := c.GetFloat("registration_fee")
  3158. medical_expenses, _ := c.GetFloat("medical_expenses")
  3159. social_type, _ := c.GetInt64("social_type")
  3160. med_type := c.GetString("social_type")
  3161. admin_user_id, _ := c.GetInt64("admin_user_id")
  3162. insuplc_admdvs := c.GetString("insuplc_admdvs")
  3163. timeLayout := "2006-01-02"
  3164. loc, _ := time.LoadLocation("Local")
  3165. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  3166. birthUnix := birthdays.Unix()
  3167. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3168. if err != nil {
  3169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3170. return
  3171. }
  3172. recordDateTime := theTime.Unix()
  3173. adminInfo := c.GetAdminUserInfo()
  3174. var patient service.Patients
  3175. if id == 0 {
  3176. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  3177. } else {
  3178. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  3179. }
  3180. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3181. if patientPrescription.ID == 0 {
  3182. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3183. }
  3184. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3185. if patient.ID == 0 {
  3186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3187. return
  3188. }
  3189. if len(patient.IdCardNo) == 0 {
  3190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3191. return
  3192. }
  3193. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3194. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  3195. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  3196. //就诊结算未完成,不能进行二次挂号
  3197. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  3198. if len(his) >= 1 {
  3199. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  3200. if len(his) >= 1 && order.ID == 0 {
  3201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  3202. return
  3203. }
  3204. }
  3205. //var register_log string
  3206. if config.IsOpen == 1 {
  3207. var res ResultTwo
  3208. var res10265 ResultTwo10265
  3209. var PsnNo string
  3210. var PsnCertType string
  3211. var Certno string
  3212. var PsnName string
  3213. var Gend string
  3214. var Naty string
  3215. var Brdy string
  3216. var Age float64
  3217. var infoStr string
  3218. var idetinfoStr string
  3219. var infocode int64
  3220. var verify_number string
  3221. fmt.Println(verify_number)
  3222. if miConfig.MdtrtareaAdmvs == "421300" {
  3223. psn_info, _ := service.GetPsnByPatientId(id)
  3224. PsnNo = psn_info.PsnNo
  3225. PsnCertType = psn_info.PsnCertType
  3226. Certno = psn_info.Certno
  3227. PsnName = psn_info.PsnName
  3228. Gend = psn_info.Gend
  3229. Naty = psn_info.Naty
  3230. Brdy = psn_info.Brdy
  3231. Age = psn_info.Age
  3232. infoStr = psn_info.Insuinfo
  3233. idetinfoStr = psn_info.Idetinfo
  3234. infocode = 0
  3235. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3236. psn_info, _ := service.GetPsnByPatientId(id)
  3237. PsnNo = psn_info.PsnNo
  3238. PsnCertType = psn_info.PsnCertType
  3239. Certno = psn_info.Certno
  3240. PsnName = psn_info.PsnName
  3241. Gend = psn_info.Gend
  3242. Naty = psn_info.Naty
  3243. Brdy = psn_info.Brdy
  3244. Age = psn_info.Age
  3245. infoStr = psn_info.Insuinfo
  3246. idetinfoStr = psn_info.Idetinfo
  3247. infocode = 0
  3248. verify_number = psn_info.VerifyNumber
  3249. } else {
  3250. var result string
  3251. var requestLog string
  3252. if miConfig.UserOrgId == 10138 {
  3253. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  3254. } else {
  3255. 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)
  3256. }
  3257. saveLog(result, requestLog, "1101", "人员基本信息获取")
  3258. if miConfig.Code == "H15049901371" {
  3259. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3260. utils.ErrorLog("解析失败:%v", err)
  3261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3262. return
  3263. }
  3264. res.ErrMsg = res10265.ErrMsg
  3265. res.Output = res10265.Output
  3266. res.InfRefmsgid = res10265.InfRefmsgid
  3267. } else {
  3268. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3269. utils.ErrorLog("解析失败:%v", err)
  3270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3271. return
  3272. }
  3273. }
  3274. PsnNo = res.Output.Baseinfo.PsnNo
  3275. PsnCertType = res.Output.Baseinfo.PsnCertType
  3276. Certno = res.Output.Baseinfo.Certno
  3277. PsnName = res.Output.Baseinfo.PsnName
  3278. Gend = res.Output.Baseinfo.Gend
  3279. Naty = res.Output.Baseinfo.Naty
  3280. Brdy = res.Output.Baseinfo.Brdy
  3281. Age = res.Output.Baseinfo.Age
  3282. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3283. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3284. infoStr = string(Iinfos)
  3285. idetinfoStr = string(Idetinfos)
  3286. if miConfig.Code == "H15049901371" {
  3287. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  3288. } else {
  3289. infocode = res.Infcode
  3290. }
  3291. }
  3292. if infocode == 0 {
  3293. his := models.VMHisPatient{
  3294. Name: name,
  3295. Gender: gender,
  3296. Birthday: birthUnix,
  3297. MedicalTreatmentType: medical_care,
  3298. IdType: certificates,
  3299. IdCardNo: id_card,
  3300. BalanceAccountsType: settlementValue,
  3301. SocialType: social_type,
  3302. MedicalInsuranceNumber: medical_insurance_card,
  3303. RegisterType: register_type,
  3304. RegisterCost: registration_fee,
  3305. TreatmentCost: medical_expenses,
  3306. Status: 1,
  3307. Ctime: time.Now().Unix(),
  3308. Mtime: time.Now().Unix(),
  3309. PsnNo: PsnNo,
  3310. PsnCertType: PsnCertType,
  3311. Certno: Certno,
  3312. PsnName: PsnName,
  3313. Gend: Gend,
  3314. Naty: Naty,
  3315. Brdy: Brdy,
  3316. Age: Age,
  3317. Iinfo: infoStr,
  3318. Idetinfo: idetinfoStr,
  3319. PatientId: patient.ID,
  3320. RecordDate: theTime.Unix(),
  3321. UserOrgId: adminInfo.CurrentOrgId,
  3322. AdminUserId: admin_user_id,
  3323. IsReturn: 1,
  3324. IdCardType: id_card_type,
  3325. Doctor: doctor,
  3326. Departments: department,
  3327. }
  3328. timestamp := time.Now().Unix()
  3329. tempTime := time.Unix(timestamp, 0)
  3330. timeFormat := tempTime.Format("20060102150405")
  3331. chrgBchno := rand.Intn(100000) + 10000
  3332. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3333. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  3334. department, _ := service.GetDepartMentDetail(department)
  3335. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3336. IdCardNo := ""
  3337. if id_card_type == 1 {
  3338. // IdCardNo = medical_insurance_card
  3339. IdCardNo = patient.IdCardNo
  3340. } else {
  3341. IdCardNo = patient.IdCardNo
  3342. }
  3343. var rf []*ResultFive
  3344. json.Unmarshal([]byte(his.Iinfo), &rf)
  3345. var insutypes []*ResultFive
  3346. var insutype string
  3347. var insuplc_admdvs_temp string
  3348. var is390 int = 0
  3349. var is310 int = 0
  3350. for _, item := range rf {
  3351. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3352. insutypes = append(insutypes, item)
  3353. }
  3354. }
  3355. if len(insutypes) == 1 {
  3356. insutype = insutypes[0].Insutype
  3357. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3358. } else {
  3359. for _, i := range insutypes {
  3360. if i.Insutype == "390" {
  3361. is390 = 1
  3362. }
  3363. if i.Insutype == "310" {
  3364. is310 = 1
  3365. }
  3366. }
  3367. }
  3368. if is390 == 1 {
  3369. insutype = "390"
  3370. }
  3371. if is310 == 1 {
  3372. insutype = "310"
  3373. }
  3374. if len(insutypes) == 0 {
  3375. insutype = "310"
  3376. }
  3377. if len(insutypes) == 2 {
  3378. insutype = med_type
  3379. }
  3380. if len(med_type) > 0 {
  3381. insutype = med_type
  3382. }
  3383. //for _, item := range rf {
  3384. // if item.Insutype == insutype {
  3385. // insuplc_admdvs = item.InsuplcAdmdvs
  3386. // }
  3387. //}
  3388. var infocode int64
  3389. var resThree ResultThree
  3390. var resThree10265 ResultThree10265
  3391. if len(insuplc_admdvs) == 0 {
  3392. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  3393. } else {
  3394. insuplc_admdvs_temp = insuplc_admdvs
  3395. }
  3396. if miConfig.MdtrtareaAdmvs == "421300" {
  3397. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  3398. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3399. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&doctor_name=" + doctor_info.UserName
  3400. resp, requestErr := http.Get(api)
  3401. if requestErr != nil {
  3402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3403. return
  3404. }
  3405. body, ioErr := ioutil.ReadAll(resp.Body)
  3406. if ioErr != nil {
  3407. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3409. return
  3410. }
  3411. var respJSON map[string]interface{}
  3412. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3415. return
  3416. }
  3417. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3418. result, _ := json.Marshal(respJSON)
  3419. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3420. utils.ErrorLog("解析失败:%v", err)
  3421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3422. return
  3423. }
  3424. infocode = resThree.Infcode
  3425. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3426. psn_info, _ := service.GetPsnByPatientId(id)
  3427. bas := strings.Split(psn_info.CardInfo, "|")
  3428. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3429. var api string
  3430. if miConfig.MdtrtareaAdmvs == "320921" {
  3431. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3432. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3433. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3434. } else {
  3435. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3436. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3437. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3438. }
  3439. resp, requestErr := http.Get(api)
  3440. if requestErr != nil {
  3441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3442. return
  3443. }
  3444. body, ioErr := ioutil.ReadAll(resp.Body)
  3445. if ioErr != nil {
  3446. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3448. return
  3449. }
  3450. var respJSON map[string]interface{}
  3451. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3452. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3454. return
  3455. }
  3456. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3457. result, _ := json.Marshal(respJSON)
  3458. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3459. utils.ErrorLog("解析失败:%v", err)
  3460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3461. return
  3462. }
  3463. resThree.ErrMsg = resThree10265.ErrMsg
  3464. resThree.Output = resThree10265.Output
  3465. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3466. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3467. } else {
  3468. result, requestLog := service.Gdyb2201(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName)
  3469. saveLog(result, requestLog, "2201", "挂号")
  3470. if miConfig.Code == "H15049901371" {
  3471. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3472. utils.ErrorLog("解析失败:%v", err)
  3473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3474. return
  3475. }
  3476. resThree.ErrMsg = resThree10265.ErrMsg
  3477. resThree.Output = resThree10265.Output
  3478. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3479. } else {
  3480. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3481. utils.ErrorLog("解析失败:%v", err)
  3482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3483. return
  3484. }
  3485. }
  3486. if miConfig.Code == "H15049901371" {
  3487. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3488. } else {
  3489. infocode = resThree.Infcode
  3490. }
  3491. }
  3492. if infocode != 0 {
  3493. adminUser := c.GetAdminUserInfo()
  3494. errlog := &models.HisOrderError{
  3495. UserOrgId: adminUser.CurrentOrgId,
  3496. Ctime: time.Now().Unix(),
  3497. Mtime: time.Now().Unix(),
  3498. ErrMsg: resThree.ErrMsg,
  3499. Status: 1,
  3500. PatientId: id,
  3501. RecordTime: recordDateTime,
  3502. Stage: 2,
  3503. }
  3504. service.CreateErrMsgLog(errlog)
  3505. c.ServeSuccessJSON(map[string]interface{}{
  3506. "failed_code": -10,
  3507. "msg": resThree.ErrMsg,
  3508. })
  3509. return
  3510. }
  3511. his.Number = resThree.Output.Data.MdtrtID
  3512. his.PsnNo = resThree.Output.Data.PsnNo
  3513. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  3514. his.IdCardNo = patient.IdCardNo
  3515. his.PhoneNumber = patient.Phone
  3516. his.UserOrgId = adminInfo.CurrentOrgId
  3517. his.Insutype = insutype
  3518. his.Ctime = time.Now().Unix()
  3519. his.Mtime = time.Now().Unix()
  3520. his.InsuplcAdmdvs = insuplc_admdvs_temp
  3521. his.Status = 1
  3522. service.UpdateHisPatientStatus(&his)
  3523. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  3524. c.ServeSuccessJSON(map[string]interface{}{
  3525. "his_info": his,
  3526. })
  3527. } else {
  3528. adminUser := c.GetAdminUserInfo()
  3529. errlog := &models.HisOrderError{
  3530. UserOrgId: adminUser.CurrentOrgId,
  3531. Ctime: time.Now().Unix(),
  3532. Mtime: time.Now().Unix(),
  3533. ErrMsg: res.ErrMsg,
  3534. Status: 1,
  3535. PatientId: id,
  3536. RecordTime: recordDateTime,
  3537. Stage: 1,
  3538. }
  3539. service.CreateErrMsgLog(errlog)
  3540. c.ServeSuccessJSON(map[string]interface{}{
  3541. "failed_code": -10,
  3542. "msg": res.ErrMsg,
  3543. })
  3544. return
  3545. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3546. }
  3547. }
  3548. }
  3549. //上传明细----预结算----确认订单
  3550. func (c *HisApiController) GetUploadInfo() {
  3551. id, _ := c.GetInt64("id")
  3552. record_time := c.GetString("record_time")
  3553. his_patient_id, _ := c.GetInt64("his_patient_id")
  3554. order_id, _ := c.GetInt64("order_id")
  3555. pay_way, _ := c.GetInt64("pay_way")
  3556. pay_price, _ := c.GetFloat("pay_price")
  3557. pay_card_no := c.GetString("pay_card_no")
  3558. discount_price, _ := c.GetFloat("discount_price")
  3559. preferential_price, _ := c.GetFloat("preferential_price")
  3560. reality_price, _ := c.GetFloat("reality_price")
  3561. found_price, _ := c.GetFloat("found_price")
  3562. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3563. private_price, _ := c.GetFloat("private_price")
  3564. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3565. admin_user_id, _ := c.GetInt64("admin_user_id")
  3566. fapiao_code := c.GetString("fapiao_code")
  3567. fapiao_number := c.GetString("fapiao_number")
  3568. diagnosis_id := c.GetString("diagnosis")
  3569. sick_type, _ := c.GetInt64("sick_type")
  3570. reg_type, _ := c.GetInt64("p_type")
  3571. begin_time := c.GetString("begin_time")
  3572. id_str := c.GetString("ids")
  3573. ids_arr := strings.Split(id_str, ",")
  3574. timeLayout := "2006-01-02"
  3575. loc, _ := time.LoadLocation("Local")
  3576. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3577. if err != nil {
  3578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3579. return
  3580. }
  3581. recordDateTime := theTime.Unix()
  3582. adminUser := c.GetAdminUserInfo()
  3583. var tempOrder models.HisOrder
  3584. tempOrder, _ = service.GetHisOrderByID(order_id)
  3585. var prescriptions []*models.HisPrescription
  3586. var start_time int64
  3587. var end_time int64
  3588. //if adminUser.CurrentOrgId == 10106{
  3589. // if len(fapiao_code) == 0{
  3590. // fapiao_code = "144072080589"
  3591. // }
  3592. // if len(fapiao_number) == 0{
  3593. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3594. // if order.ID == 0{
  3595. // fapiao_number = "00001520"
  3596. // }else{
  3597. // //fapiao_code = "00001520"
  3598. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3599. // var zero string
  3600. // if fpNumber >= 1000{
  3601. // zero = "0000" + strconv.Itoa(fpNumber)
  3602. // }else if fpNumber >= 10000{
  3603. // zero = "000" + strconv.Itoa(fpNumber)
  3604. // } else if fpNumber >= 100000{
  3605. // zero = "00" + strconv.Itoa(fpNumber)
  3606. // } else if fpNumber >= 1000000{
  3607. // zero = "0" + strconv.Itoa(fpNumber)
  3608. // }else {
  3609. // zero = strconv.Itoa(fpNumber)
  3610. // }
  3611. // fapiao_number = zero
  3612. // }
  3613. // }
  3614. //}
  3615. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3616. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3617. var patientPrescription models.HisPrescriptionInfo
  3618. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3619. if patientPrescription.ID == 0 {
  3620. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3621. }
  3622. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3623. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3624. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3625. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3626. var config []*models.HisXtDiagnoseConfig
  3627. for _, item := range diagnosis_ids {
  3628. id, _ := strconv.ParseInt(item, 10, 64)
  3629. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3630. config = append(config, &diagnosisConfig)
  3631. }
  3632. sickConfig, _ := service.FindSickById(sick_type)
  3633. //if tempOrder.ID == 0 {
  3634. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3635. //}
  3636. if tempOrder.ID == 0 {
  3637. var result string
  3638. var requestLog string
  3639. var res2 ResultSix
  3640. var ressix10265 ResultSix10265
  3641. if miConfig.MdtrtareaAdmvs == "421300" {
  3642. data := make(map[string]interface{})
  3643. client := &http.Client{}
  3644. data["psn_no"] = his.PsnNo
  3645. data["mdtrt_id"] = his.Number
  3646. data["doctor"] = roles.UserName
  3647. data["department"] = department.Name
  3648. data["org_name"] = miConfig.OrgName
  3649. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3650. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3651. data["fixmedins_code"] = miConfig.Code
  3652. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3653. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3654. data["secret_key"] = miConfig.SecretKey
  3655. data["sick_code"] = sickConfig.CountryCode
  3656. data["sick_name"] = sickConfig.ClassName
  3657. data["dept"] = strconv.FormatInt(department.ID, 10)
  3658. data["config"] = config
  3659. data["begin_time"] = begin_time
  3660. bytesData, _ := json.Marshal(data)
  3661. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3662. resp, _ := client.Do(req)
  3663. defer resp.Body.Close()
  3664. body, ioErr := ioutil.ReadAll(resp.Body)
  3665. if ioErr != nil {
  3666. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3668. return
  3669. }
  3670. var respJSON map[string]interface{}
  3671. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3674. return
  3675. }
  3676. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3677. userJSONBytes, _ := json.Marshal(respJSON)
  3678. fmt.Println("log")
  3679. fmt.Println(string(userJSONBytes))
  3680. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3681. utils.ErrorLog("解析失败:%v", err)
  3682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3683. return
  3684. }
  3685. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3686. //江苏地区国家医保医疗类别
  3687. //职工透析:医疗类别选特殊情况门诊9933
  3688. //居民血透门慢: 医疗类别选门诊慢病1402
  3689. //var med_type string
  3690. //if his.Insutype == "310" {
  3691. // if reg_type == 14 {
  3692. // med_type = "9933"
  3693. // } else if reg_type == 11 {
  3694. // med_type = "11"
  3695. //
  3696. // }
  3697. //} else if his.Insutype == "390" {
  3698. // if reg_type == 14 {
  3699. // med_type = "1402"
  3700. // } else if reg_type == 11 {
  3701. // med_type = "11"
  3702. // }
  3703. //}
  3704. data := make(map[string]interface{})
  3705. client := &http.Client{}
  3706. data["psn_no"] = his.PsnNo
  3707. data["mdtrt_id"] = his.Number
  3708. data["doctor"] = roles.UserName
  3709. data["department"] = department.Name
  3710. data["org_name"] = miConfig.OrgName
  3711. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3712. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3713. data["fixmedins_code"] = miConfig.Code
  3714. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3715. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3716. data["secret_key"] = miConfig.SecretKey
  3717. data["sick_code"] = sickConfig.CountryCode
  3718. data["sick_name"] = sickConfig.ClassName
  3719. data["url"] = miConfig.Url
  3720. data["ak"] = miConfig.AccessKey
  3721. data["begin_time"] = begin_time
  3722. data["cainfo"] = miConfig.Cainfo
  3723. data["dept"] = strconv.FormatInt(department.ID, 10)
  3724. data["config"] = config
  3725. bytesData, _ := json.Marshal(data)
  3726. var req *http.Request
  3727. if miConfig.MdtrtareaAdmvs == "320921" {
  3728. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3729. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  3730. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  3731. } else {
  3732. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3733. }
  3734. resp, _ := client.Do(req)
  3735. defer resp.Body.Close()
  3736. body, ioErr := ioutil.ReadAll(resp.Body)
  3737. if ioErr != nil {
  3738. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3740. return
  3741. }
  3742. var respJSON map[string]interface{}
  3743. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3744. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3746. return
  3747. }
  3748. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3749. userJSONBytes, _ := json.Marshal(respJSON)
  3750. fmt.Println("log")
  3751. fmt.Println(string(userJSONBytes))
  3752. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  3753. utils.ErrorLog("解析失败:%v", err)
  3754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3755. return
  3756. }
  3757. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3758. res2.Output = ressix10265.Output
  3759. res2.ErrMsg = ressix10265.ErrMsg
  3760. res2.Cainfo = ressix10265.Cainfo
  3761. res2.WarnMsg = ressix10265.WarnMsg
  3762. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3763. res2.Infcode = infocode
  3764. } else {
  3765. if miConfig.MdtrtareaAdmvs == "440781" { //
  3766. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  3767. } else {
  3768. if miConfig.Code == "H15049901371" {
  3769. //赤峰地区国家医保医疗类别
  3770. //职工透析:医疗类别选特殊情况门诊990502
  3771. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3772. var med_type string
  3773. if his.Insutype == "390" {
  3774. if reg_type == 14 {
  3775. med_type = "9933"
  3776. } else if reg_type == 11 {
  3777. med_type = "11"
  3778. }
  3779. } else if his.Insutype == "310" {
  3780. if reg_type == 14 {
  3781. med_type = "990502"
  3782. } else if reg_type == 11 {
  3783. med_type = "11"
  3784. }
  3785. }
  3786. 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)
  3787. } else {
  3788. 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)
  3789. }
  3790. }
  3791. saveLog(result, requestLog, "2203", "上传就诊信息")
  3792. var respJSON2 map[string]interface{}
  3793. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3796. return
  3797. }
  3798. userJSONBytes2, _ := json.Marshal(respJSON2)
  3799. if miConfig.Code == "H15049901371" {
  3800. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  3801. utils.ErrorLog("解析失败:%v", err)
  3802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3803. return
  3804. }
  3805. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3806. res2.Output = ressix10265.Output
  3807. res2.ErrMsg = ressix10265.ErrMsg
  3808. res2.Cainfo = ressix10265.Cainfo
  3809. res2.WarnMsg = ressix10265.WarnMsg
  3810. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3811. res2.Infcode = infocode
  3812. } else {
  3813. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3814. utils.ErrorLog("解析失败:%v", err)
  3815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3816. return
  3817. }
  3818. }
  3819. }
  3820. if res2.Infcode != 0 {
  3821. adminUser := c.GetAdminUserInfo()
  3822. errlog := &models.HisOrderError{
  3823. UserOrgId: adminUser.CurrentOrgId,
  3824. Ctime: time.Now().Unix(),
  3825. Mtime: time.Now().Unix(),
  3826. ErrMsg: res2.ErrMsg,
  3827. Status: 1,
  3828. PatientId: id,
  3829. RecordTime: recordDateTime,
  3830. Stage: 3,
  3831. }
  3832. service.CreateErrMsgLog(errlog)
  3833. c.ServeSuccessJSON(map[string]interface{}{
  3834. "failed_code": -10,
  3835. "msg": res2.ErrMsg,
  3836. })
  3837. return
  3838. } else {
  3839. his.Diagnosis = diagnosis_id
  3840. his.SickType = sickConfig.ID
  3841. var p_type int64
  3842. if reg_type == 1111 || reg_type == 1112 {
  3843. p_type = 11
  3844. }
  3845. his.PType = fmt.Sprintf("%d", p_type)
  3846. service.UpdateHisPatientThree(&his)
  3847. data := make(map[string]interface{})
  3848. if settle_accounts_type == 1 { //日结
  3849. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  3850. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  3851. } else {
  3852. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  3853. }
  3854. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  3855. data["pre"] = prescriptions
  3856. } else { //月结
  3857. start_time_str := c.GetString("start_time")
  3858. end_time_str := c.GetString("end_time")
  3859. timeLayout := "2006-01-02"
  3860. loc, _ := time.LoadLocation("Local")
  3861. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3862. if err != nil {
  3863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3864. return
  3865. }
  3866. recordStartTime := theStartTime.Unix()
  3867. start_time = recordStartTime
  3868. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3869. if err != nil {
  3870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3871. return
  3872. }
  3873. recordEndTime := theEndTime.Unix()
  3874. end_time = recordEndTime
  3875. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3876. data["pre"] = prescriptions
  3877. }
  3878. timestamp := time.Now().Unix()
  3879. tempTime := time.Unix(timestamp, 0)
  3880. timeFormat := tempTime.Format("20060102150405")
  3881. chrgBchno := rand.Intn(100000) + 10000
  3882. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3883. strconv.FormatInt(his.PatientId, 10)
  3884. client := &http.Client{}
  3885. data["psn_no"] = his.PsnNo
  3886. data["mdtrt_id"] = his.Number
  3887. data["chrg_bchno"] = chrg_bchno
  3888. data["org_name"] = miConfig.OrgName
  3889. data["doctor"] = roles.UserName
  3890. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3891. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3892. data["fixmedins_code"] = miConfig.Code
  3893. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3894. // data["dept_code"] = "15"
  3895. //} else {
  3896. data["dept_code"] = department.Number
  3897. //}
  3898. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3899. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3900. data["secret_key"] = miConfig.SecretKey
  3901. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3902. data["url"] = miConfig.Url
  3903. data["ak"] = miConfig.AccessKey
  3904. data["new_doctor_name"] = patientPrescription.Doctor
  3905. data["diag_code"] = sickConfig.CountryCode
  3906. data["cainfo"] = miConfig.Cainfo
  3907. var ids []int64
  3908. for _, item := range prescriptions {
  3909. ids = append(ids, item.ID)
  3910. }
  3911. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3912. if config.IsOpen == 1 { //对接了医保,走医保流程
  3913. var res ResultFour
  3914. var resFour10265 ResultFour10265
  3915. if miConfig.MdtrtareaAdmvs == "421300" {
  3916. bytesData, _ := json.Marshal(data)
  3917. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3918. resp, _ := client.Do(req)
  3919. defer resp.Body.Close()
  3920. body, ioErr := ioutil.ReadAll(resp.Body)
  3921. if ioErr != nil {
  3922. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3924. return
  3925. }
  3926. var respJSON map[string]interface{}
  3927. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3928. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3930. return
  3931. }
  3932. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3933. userJSONBytes, _ := json.Marshal(respJSON)
  3934. fmt.Println("log")
  3935. fmt.Println(string(userJSONBytes))
  3936. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3937. utils.ErrorLog("解析失败:%v", err)
  3938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3939. return
  3940. }
  3941. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3942. bytesData, _ := json.Marshal(data)
  3943. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  3944. resp, _ := client.Do(req)
  3945. defer resp.Body.Close()
  3946. body, ioErr := ioutil.ReadAll(resp.Body)
  3947. if ioErr != nil {
  3948. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3950. return
  3951. }
  3952. var respJSON map[string]interface{}
  3953. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3954. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3956. return
  3957. }
  3958. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3959. userJSONBytes, _ := json.Marshal(respJSON)
  3960. fmt.Println("log")
  3961. fmt.Println(string(userJSONBytes))
  3962. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3963. utils.ErrorLog("解析失败:%v", err)
  3964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3965. return
  3966. }
  3967. res.InfRefmsgid = resFour10265.InfRefmsgid
  3968. res.Output = resFour10265.Output
  3969. res.ErrMsg = resFour10265.ErrMsg
  3970. res.Cainfo = resFour10265.Cainfo
  3971. res.WarnMsg = resFour10265.WarnMsg
  3972. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3973. res.Infcode = infocode
  3974. } else {
  3975. if miConfig.Code == "H15049901371" {
  3976. 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)
  3977. var dat map[string]interface{}
  3978. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3979. fmt.Println(dat)
  3980. } else {
  3981. fmt.Println(err)
  3982. }
  3983. saveLog(result, request_log, "2204", "上传费用明细")
  3984. userJSONBytes, _ := json.Marshal(dat)
  3985. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3986. utils.ErrorLog("解析失败:%v", err)
  3987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3988. return
  3989. }
  3990. res.InfRefmsgid = resFour10265.InfRefmsgid
  3991. res.Output = resFour10265.Output
  3992. res.ErrMsg = resFour10265.ErrMsg
  3993. res.Cainfo = resFour10265.Cainfo
  3994. res.WarnMsg = resFour10265.WarnMsg
  3995. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3996. res.Infcode = infocode
  3997. } else {
  3998. 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)
  3999. var dat map[string]interface{}
  4000. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4001. fmt.Println(dat)
  4002. } else {
  4003. fmt.Println(err)
  4004. }
  4005. saveLog(result, request_log, "2204", "上传费用明细")
  4006. userJSONBytes, _ := json.Marshal(dat)
  4007. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4008. utils.ErrorLog("解析失败:%v", err)
  4009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4010. return
  4011. }
  4012. }
  4013. }
  4014. if res.Infcode == 0 {
  4015. order := &models.HisOrder{
  4016. UserOrgId: adminUser.CurrentOrgId,
  4017. HisPatientId: his.ID,
  4018. PatientId: his.PatientId,
  4019. SettleAccountsDate: recordDateTime,
  4020. MdtrtId: his.Number,
  4021. PsnNo: his.PsnNo,
  4022. MedType: strconv.FormatInt(reg_type, 10),
  4023. Ctime: time.Now().Unix(),
  4024. Mtime: time.Now().Unix(),
  4025. Status: 1,
  4026. Number: chrg_bchno,
  4027. Infcode: res.Infcode,
  4028. WarnMsg: res.WarnMsg,
  4029. Cainfo: res.Cainfo,
  4030. ErrMsg: res.ErrMsg,
  4031. RespondTime: res.RefmsgTime,
  4032. InfRefmsgid: res.InfRefmsgid,
  4033. OrderStatus: 1,
  4034. PayWay: pay_way,
  4035. PayPrice: pay_price,
  4036. PayCardNo: pay_card_no,
  4037. DiscountPrice: discount_price,
  4038. PreferentialPrice: preferential_price,
  4039. RealityPrice: reality_price,
  4040. FoundPrice: found_price,
  4041. MedicalInsurancePrice: medical_insurance_price,
  4042. PrivatePrice: private_price,
  4043. IsMedicineInsurance: 1,
  4044. SettleType: settle_accounts_type,
  4045. SettleStartTime: start_time,
  4046. SettleEndTime: end_time,
  4047. Creator: roles.AdminUserId,
  4048. Modify: roles.AdminUserId,
  4049. FaPiaoNumber: fapiao_number,
  4050. FaPiaoCode: fapiao_code,
  4051. PType: 2,
  4052. Diagnosis: diagnosis_id,
  4053. }
  4054. err = service.CreateOrder(order)
  4055. if err != nil {
  4056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4057. return
  4058. }
  4059. for _, item := range res.Output.Result {
  4060. temp := strings.Split(item.FeedetlSn, "-")
  4061. var advice_id int64 = 0
  4062. var project_id int64 = 0
  4063. var types int64 = 0
  4064. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4065. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4066. if temp[1] == "1" {
  4067. advice_id = id
  4068. project_id = 0
  4069. } else if temp[1] == "2" {
  4070. advice_id = 0
  4071. project_id = id
  4072. }
  4073. info := &models.HisOrderInfo{
  4074. OrderNumber: order.Number,
  4075. FeedetlSn: item.FeedetlSn,
  4076. UploadDate: time.Now().Unix(),
  4077. AdviceId: advice_id,
  4078. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4079. Cnt: item.Cnt,
  4080. Pric: float64(item.Pric),
  4081. PatientId: his.PatientId,
  4082. PricUplmtAmt: item.PricUplmtAmt,
  4083. SelfpayProp: item.SelfpayProp,
  4084. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4085. OverlmtAmt: item.OverlmtAmt,
  4086. PreselfpayAmt: item.PreselfpayAmt,
  4087. BasMednFlag: item.BasMednFlag,
  4088. MedChrgitmType: item.MedChrgitmType,
  4089. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4090. Status: 1,
  4091. Memo: item.Memo,
  4092. Mtime: time.Now().Unix(),
  4093. InscpScpAmt: item.InscpScpAmt,
  4094. DrtReimFlag: item.DrtReimFlag,
  4095. Ctime: time.Now().Unix(),
  4096. ListSpItemFlag: item.ListSpItemFlag,
  4097. ChldMedcFlag: item.ChldMedcFlag,
  4098. LmtUsedFlag: item.LmtUsedFlag,
  4099. ChrgitmLv: item.ChrgitmLv,
  4100. UserOrgId: adminUser.CurrentOrgId,
  4101. HisPatientId: his.ID,
  4102. OrderId: order.ID,
  4103. ProjectId: project_id,
  4104. Type: types,
  4105. }
  4106. service.CreateOrderInfo(info)
  4107. }
  4108. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4109. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4110. var total float64
  4111. for _, item := range prescriptions {
  4112. if item.Type == 1 { //药品
  4113. for _, subItem := range item.HisDoctorAdviceInfo {
  4114. total = total + (subItem.Price * subItem.PrescribingNumber)
  4115. }
  4116. }
  4117. if item.Type == 2 { //项目
  4118. for _, subItem := range item.HisPrescriptionProject {
  4119. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4120. total = total + (subItem.Price * cnt)
  4121. }
  4122. }
  4123. }
  4124. for _, item := range prescriptions {
  4125. for _, subItem := range item.HisAdditionalCharge {
  4126. total = total + (subItem.Price * float64(subItem.Count))
  4127. }
  4128. }
  4129. var allTotal string
  4130. if adminUser.CurrentOrgId == 9919 {
  4131. allTotal = fmt.Sprintf("%.4f", total)
  4132. } else {
  4133. allTotal = fmt.Sprintf("%.4f", total)
  4134. }
  4135. if res.Infcode == 0 {
  4136. var rf []*ResultFive
  4137. json.Unmarshal([]byte(his.Iinfo), &rf)
  4138. chrg_bchno := chrg_bchno
  4139. cert_no := his.Certno
  4140. var insutypes []string
  4141. var insutype string
  4142. var is390 int = 0
  4143. var is310 int = 0
  4144. for _, item := range rf {
  4145. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4146. insutypes = append(insutypes, item.Insutype)
  4147. }
  4148. }
  4149. if len(insutypes) == 1 {
  4150. insutype = insutypes[0]
  4151. } else {
  4152. for _, i := range insutypes {
  4153. if i == "390" {
  4154. is390 = 1
  4155. }
  4156. if i == "310" {
  4157. is310 = 1
  4158. }
  4159. }
  4160. }
  4161. if is390 == 1 {
  4162. insutype = "390"
  4163. }
  4164. if is310 == 1 {
  4165. insutype = "310"
  4166. }
  4167. if len(insutypes) == 0 {
  4168. insutype = "310"
  4169. }
  4170. if len(insutypes) == 2 {
  4171. insutype = strconv.FormatInt(his.SocialType, 10)
  4172. }
  4173. insutype = strconv.FormatInt(his.SocialType, 10)
  4174. //insutype = "390"
  4175. if his.IdCardType == 1 {
  4176. // cert_no = his.MedicalInsuranceNumber
  4177. cert_no = his.Certno
  4178. } else {
  4179. cert_no = his.Certno
  4180. }
  4181. var res ResultSeven
  4182. var resSeven10265 ResultSeven10265
  4183. var src_resquest string
  4184. var result2 string
  4185. var acct_used_flag string
  4186. fmt.Println("pay_way")
  4187. fmt.Println(pay_way)
  4188. fmt.Println("pay_way")
  4189. if pay_way == 4 {
  4190. acct_used_flag = "1"
  4191. } else {
  4192. acct_used_flag = "0"
  4193. }
  4194. if miConfig.MdtrtareaAdmvs == "421300" {
  4195. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4196. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4197. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4198. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4199. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4200. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4201. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4202. resp, requestErr := http.Get(api)
  4203. if requestErr != nil {
  4204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4205. return
  4206. }
  4207. body, ioErr := ioutil.ReadAll(resp.Body)
  4208. if ioErr != nil {
  4209. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4211. return
  4212. }
  4213. var respJSON map[string]interface{}
  4214. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4217. return
  4218. }
  4219. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4220. result, _ := json.Marshal(respJSON)
  4221. if miConfig.Code == "H15049901371" {
  4222. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4223. utils.ErrorLog("解析失败:%v", err)
  4224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4225. return
  4226. }
  4227. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4228. res.Output = resSeven10265.Output
  4229. res.ErrMsg = resSeven10265.ErrMsg
  4230. res.Cainfo = resSeven10265.Cainfo
  4231. res.WarnMsg = resSeven10265.WarnMsg
  4232. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4233. res.Infcode = infocode
  4234. } else {
  4235. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4236. utils.ErrorLog("解析失败:%v", err)
  4237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4238. return
  4239. }
  4240. }
  4241. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4242. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4243. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4244. //psn_info, _ := service.GetPsnByPatientId(id)
  4245. bas := strings.Split(psn_info.CardInfo, "|")
  4246. if his.IdCardType == 1 {
  4247. cert_no = bas[2]
  4248. } else {
  4249. cert_no = bas[1]
  4250. }
  4251. //江苏地区国家医保医疗类别
  4252. //职工透析:医疗类别选特殊情况门诊9933
  4253. //居民血透门慢: 医疗类别选门诊慢病1402
  4254. //var med_type string
  4255. //if his.Insutype == "310" {
  4256. // if reg_type == 14 {
  4257. // med_type = "9933"
  4258. // } else if reg_type == 11 {
  4259. // med_type = "11"
  4260. //
  4261. // }
  4262. //} else if his.Insutype == "390" {
  4263. // if reg_type == 14 {
  4264. // med_type = "1402"
  4265. // } else if reg_type == 11 {
  4266. // med_type = "11"
  4267. // }
  4268. //}
  4269. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4270. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4271. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4272. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4273. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4274. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4275. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4276. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4277. resp, requestErr := http.Get(api)
  4278. if requestErr != nil {
  4279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4280. return
  4281. }
  4282. body, ioErr := ioutil.ReadAll(resp.Body)
  4283. if ioErr != nil {
  4284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4286. return
  4287. }
  4288. var respJSON map[string]interface{}
  4289. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4292. return
  4293. }
  4294. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4295. result, _ := json.Marshal(respJSON)
  4296. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4297. utils.ErrorLog("解析失败:%v", err)
  4298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4299. return
  4300. }
  4301. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4302. res.Output = resSeven10265.Output
  4303. res.ErrMsg = resSeven10265.ErrMsg
  4304. res.Cainfo = resSeven10265.Cainfo
  4305. res.WarnMsg = resSeven10265.WarnMsg
  4306. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4307. res.Infcode = infocode
  4308. } else {
  4309. if miConfig.Code == "H15049901371" {
  4310. //赤峰地区国家医保医疗类别
  4311. //职工透析:医疗类别选特殊情况门诊990502
  4312. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4313. var med_type string
  4314. if his.Insutype == "390" {
  4315. if reg_type == 14 {
  4316. med_type = "9933"
  4317. } else if reg_type == 11 {
  4318. med_type = "11"
  4319. }
  4320. } else if his.Insutype == "310" {
  4321. if reg_type == 14 {
  4322. med_type = "990502"
  4323. } else if reg_type == 11 {
  4324. med_type = "11"
  4325. }
  4326. }
  4327. 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)
  4328. } else {
  4329. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  4330. }
  4331. //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)
  4332. var dat map[string]interface{}
  4333. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4334. fmt.Println(dat)
  4335. } else {
  4336. fmt.Println(err)
  4337. }
  4338. saveLog(result2, src_resquest, "2207", "结算")
  4339. userJSONBytes, _ := json.Marshal(dat)
  4340. if miConfig.Code == "H15049901371" {
  4341. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4342. utils.ErrorLog("解析失败:%v", err)
  4343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4344. return
  4345. }
  4346. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4347. res.Output = resSeven10265.Output
  4348. res.ErrMsg = resSeven10265.ErrMsg
  4349. res.Cainfo = resSeven10265.Cainfo
  4350. res.WarnMsg = resSeven10265.WarnMsg
  4351. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4352. res.Infcode = infocode
  4353. } else {
  4354. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4355. utils.ErrorLog("解析失败:%v", err)
  4356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4357. return
  4358. }
  4359. }
  4360. }
  4361. if res.Infcode != 0 {
  4362. errlog := &models.HisOrderError{
  4363. UserOrgId: adminUser.CurrentOrgId,
  4364. Ctime: time.Now().Unix(),
  4365. Mtime: time.Now().Unix(),
  4366. Number: chrg_bchno,
  4367. ErrMsg: res.ErrMsg,
  4368. Status: 1,
  4369. PatientId: id,
  4370. RecordTime: recordDateTime,
  4371. Stage: 6,
  4372. }
  4373. service.CreateErrMsgLog(errlog)
  4374. c.ServeSuccessJSON(map[string]interface{}{
  4375. "failed_code": -10,
  4376. "msg": res.ErrMsg,
  4377. })
  4378. return
  4379. } else {
  4380. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4381. order.OrderStatus = 2
  4382. order.Status = 1
  4383. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4384. order.SetlId = res.Output.Setlinfo.SetlID
  4385. order.PsnNo = res.Output.Setlinfo.PsnNo
  4386. order.PsnName = res.Output.Setlinfo.PsnName
  4387. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4388. order.Certno = res.Output.Setlinfo.Certno
  4389. order.Gend = res.Output.Setlinfo.Gend
  4390. order.Naty = res.Output.Setlinfo.Naty
  4391. order.Age = res.Output.Setlinfo.Age
  4392. order.Insutype = res.Output.Setlinfo.Insutype
  4393. order.PsnType = res.Output.Setlinfo.PsnType
  4394. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4395. order.SetlTime = res.Output.Setlinfo.SetlTime
  4396. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4397. if res.Output.Setlinfo.MedType == "140101" {
  4398. order.MedType = "14"
  4399. } else {
  4400. order.MedType = res.Output.Setlinfo.MedType
  4401. }
  4402. if reg_type == 1112 {
  4403. order.MedType = "1112"
  4404. }
  4405. if reg_type == 1111 {
  4406. order.MedType = "1111"
  4407. }
  4408. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4409. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4410. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4411. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4412. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4413. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4414. order.HifpPay = res.Output.Setlinfo.HifpPay
  4415. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4416. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4417. order.HifesPay = res.Output.Setlinfo.HifesPay
  4418. order.HifobPay = res.Output.Setlinfo.HifobPay
  4419. order.MafPay = res.Output.Setlinfo.MafPay
  4420. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4421. order.OthPay = res.Output.Setlinfo.OthPay
  4422. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4423. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4424. order.AcctPay = res.Output.Setlinfo.AcctPay
  4425. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4426. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4427. order.Balc = res.Output.Setlinfo.Balc
  4428. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4429. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4430. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4431. order.ClrType = res.Output.Setlinfo.ClrType
  4432. order.ClrWay = res.Output.Setlinfo.ClrWay
  4433. order.Creator = order.Creator
  4434. order.Modify = roles.AdminUserId
  4435. order.RequestLog = src_resquest
  4436. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4437. detailStr := string(setlDetail)
  4438. order.SetlDetail = detailStr
  4439. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4440. err = service.UpDateOrder(order)
  4441. if err == nil {
  4442. c.ServeSuccessJSON(map[string]interface{}{
  4443. "msg": "结算成功",
  4444. })
  4445. } else {
  4446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4447. return
  4448. }
  4449. }
  4450. } else {
  4451. adminUser := c.GetAdminUserInfo()
  4452. errlog := &models.HisOrderError{
  4453. UserOrgId: adminUser.CurrentOrgId,
  4454. Ctime: time.Now().Unix(),
  4455. Mtime: time.Now().Unix(),
  4456. ErrMsg: res.ErrMsg,
  4457. Status: 1,
  4458. PatientId: id,
  4459. RecordTime: recordDateTime,
  4460. Stage: 4,
  4461. }
  4462. service.CreateErrMsgLog(errlog)
  4463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4464. return
  4465. }
  4466. } else {
  4467. adminUser := c.GetAdminUserInfo()
  4468. errlog := &models.HisOrderError{
  4469. UserOrgId: adminUser.CurrentOrgId,
  4470. Ctime: time.Now().Unix(),
  4471. Mtime: time.Now().Unix(),
  4472. ErrMsg: res.ErrMsg,
  4473. Status: 1,
  4474. PatientId: id,
  4475. RecordTime: recordDateTime,
  4476. Stage: 4,
  4477. }
  4478. service.CreateErrMsgLog(errlog)
  4479. c.ServeSuccessJSON(map[string]interface{}{
  4480. "failed_code": -10,
  4481. "msg": res.ErrMsg,
  4482. })
  4483. return
  4484. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4485. //return
  4486. }
  4487. }
  4488. }
  4489. } else if tempOrder.ID > 0 {
  4490. if tempOrder.IsPre == 1 {
  4491. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  4492. var rf []*ResultFive
  4493. json.Unmarshal([]byte(his.Iinfo), &rf)
  4494. chrg_bchno := tempOrder.Number
  4495. cert_no := his.Certno
  4496. var insutypes []string
  4497. var insutype string
  4498. var is390 int = 0
  4499. var is310 int = 0
  4500. for _, item := range rf {
  4501. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4502. insutypes = append(insutypes, item.Insutype)
  4503. }
  4504. }
  4505. if len(insutypes) == 1 {
  4506. insutype = insutypes[0]
  4507. } else {
  4508. for _, i := range insutypes {
  4509. if i == "390" {
  4510. is390 = 1
  4511. }
  4512. if i == "310" {
  4513. is310 = 1
  4514. }
  4515. }
  4516. }
  4517. if is390 == 1 {
  4518. insutype = "390"
  4519. }
  4520. if is310 == 1 {
  4521. insutype = "310"
  4522. }
  4523. if len(insutypes) == 0 {
  4524. insutype = "310"
  4525. }
  4526. if len(insutypes) == 2 {
  4527. insutype = strconv.FormatInt(his.SocialType, 64)
  4528. }
  4529. //insutype = "390"
  4530. if his.IdCardType == 1 {
  4531. // cert_no = his.MedicalInsuranceNumber
  4532. cert_no = his.Certno
  4533. } else {
  4534. cert_no = his.Certno
  4535. }
  4536. var res ResultSeven
  4537. var resSeven10265 ResultSeven10265
  4538. var src_resquest string
  4539. var result2 string
  4540. var acct_used_flag string
  4541. fmt.Println("pay_way")
  4542. fmt.Println(pay_way)
  4543. fmt.Println("pay_way")
  4544. if pay_way == 4 {
  4545. acct_used_flag = "1"
  4546. } else {
  4547. acct_used_flag = "0"
  4548. }
  4549. if miConfig.MdtrtareaAdmvs == "421300" {
  4550. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4551. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4552. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4553. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4554. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4555. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4556. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4557. resp, requestErr := http.Get(api)
  4558. if requestErr != nil {
  4559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4560. return
  4561. }
  4562. body, ioErr := ioutil.ReadAll(resp.Body)
  4563. if ioErr != nil {
  4564. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4566. return
  4567. }
  4568. var respJSON map[string]interface{}
  4569. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4572. return
  4573. }
  4574. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4575. result, _ := json.Marshal(respJSON)
  4576. fmt.Println("log")
  4577. fmt.Println(string(result))
  4578. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4579. utils.ErrorLog("解析失败:%v", err)
  4580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4581. return
  4582. }
  4583. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4584. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4585. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4586. //psn_info, _ := service.GetPsnByPatientId(id)
  4587. bas := strings.Split(psn_info.CardInfo, "|")
  4588. if his.IdCardType == 1 {
  4589. cert_no = bas[2]
  4590. } else {
  4591. cert_no = bas[1]
  4592. }
  4593. //江苏地区国家医保医疗类别
  4594. //职工透析:医疗类别选特殊情况门诊9933
  4595. //居民血透门慢: 医疗类别选门诊慢病1402
  4596. //var med_type string
  4597. //if his.Insutype == "310" {
  4598. // if reg_type == 14 {
  4599. // med_type = "9933"
  4600. // } else if reg_type == 11 {
  4601. // med_type = "11"
  4602. //
  4603. // }
  4604. //} else if his.Insutype == "390" {
  4605. // if reg_type == 14 {
  4606. // med_type = "1402"
  4607. // } else if reg_type == 11 {
  4608. // med_type = "11"
  4609. // }
  4610. //}
  4611. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4612. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4613. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4614. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4615. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4616. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4617. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4618. resp, requestErr := http.Get(api)
  4619. if requestErr != nil {
  4620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4621. return
  4622. }
  4623. body, ioErr := ioutil.ReadAll(resp.Body)
  4624. if ioErr != nil {
  4625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4627. return
  4628. }
  4629. var respJSON map[string]interface{}
  4630. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4633. return
  4634. }
  4635. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4636. result, _ := json.Marshal(respJSON)
  4637. fmt.Println("log")
  4638. fmt.Println(string(result))
  4639. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4640. utils.ErrorLog("解析失败:%v", err)
  4641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4642. return
  4643. }
  4644. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4645. res.Output = resSeven10265.Output
  4646. res.ErrMsg = resSeven10265.ErrMsg
  4647. res.Cainfo = resSeven10265.Cainfo
  4648. res.WarnMsg = resSeven10265.WarnMsg
  4649. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4650. res.Infcode = infocode
  4651. } else {
  4652. var src_resquest string
  4653. if miConfig.Code == "H15049901371" {
  4654. //赤峰地区国家医保医疗类别
  4655. //职工透析:医疗类别选特殊情况门诊990502
  4656. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4657. var med_type string
  4658. if his.Insutype == "390" {
  4659. if reg_type == 14 {
  4660. med_type = "9933"
  4661. } else if reg_type == 11 {
  4662. med_type = "11"
  4663. }
  4664. } else if his.Insutype == "310" {
  4665. if reg_type == 14 {
  4666. med_type = "990502"
  4667. } else if reg_type == 11 {
  4668. med_type = "11"
  4669. }
  4670. }
  4671. 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)
  4672. } else {
  4673. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  4674. }
  4675. var dat map[string]interface{}
  4676. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4677. fmt.Println(dat)
  4678. } else {
  4679. fmt.Println(err)
  4680. }
  4681. saveLog(result2, src_resquest, "2207", "结算")
  4682. userJSONBytes, _ := json.Marshal(dat)
  4683. if miConfig.Code == "H15049901371" {
  4684. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4685. utils.ErrorLog("解析失败:%v", err)
  4686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4687. return
  4688. }
  4689. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4690. res.Output = resSeven10265.Output
  4691. res.ErrMsg = resSeven10265.ErrMsg
  4692. res.Cainfo = resSeven10265.Cainfo
  4693. res.WarnMsg = resSeven10265.WarnMsg
  4694. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4695. res.Infcode = infocode
  4696. } else {
  4697. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4698. utils.ErrorLog("解析失败:%v", err)
  4699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4700. return
  4701. }
  4702. }
  4703. }
  4704. if res.Infcode != 0 {
  4705. errlog := &models.HisOrderError{
  4706. UserOrgId: adminUser.CurrentOrgId,
  4707. Ctime: time.Now().Unix(),
  4708. Mtime: time.Now().Unix(),
  4709. Number: chrg_bchno,
  4710. ErrMsg: res.ErrMsg,
  4711. Status: 1,
  4712. PatientId: id,
  4713. RecordTime: recordDateTime,
  4714. Stage: 6,
  4715. }
  4716. service.CreateErrMsgLog(errlog)
  4717. c.ServeSuccessJSON(map[string]interface{}{
  4718. "failed_code": -10,
  4719. "msg": res.ErrMsg,
  4720. })
  4721. return
  4722. } else {
  4723. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4724. order.OrderStatus = 2
  4725. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4726. order.SetlId = res.Output.Setlinfo.SetlID
  4727. order.PsnNo = res.Output.Setlinfo.PsnNo
  4728. order.PsnName = res.Output.Setlinfo.PsnName
  4729. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4730. order.Certno = res.Output.Setlinfo.Certno
  4731. order.Gend = res.Output.Setlinfo.Gend
  4732. order.Naty = res.Output.Setlinfo.Naty
  4733. order.Age = res.Output.Setlinfo.Age
  4734. order.Insutype = res.Output.Setlinfo.Insutype
  4735. order.PsnType = res.Output.Setlinfo.PsnType
  4736. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4737. order.SetlTime = res.Output.Setlinfo.SetlTime
  4738. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4739. //order.MedType = res.Output.Setlinfo.MedType
  4740. if reg_type == 1112 {
  4741. order.MedType = "1112"
  4742. }
  4743. if reg_type == 1111 {
  4744. order.MedType = "1111"
  4745. }
  4746. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4747. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4748. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4749. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4750. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4751. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4752. order.HifpPay = res.Output.Setlinfo.HifpPay
  4753. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4754. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4755. order.HifesPay = res.Output.Setlinfo.HifesPay
  4756. order.HifobPay = res.Output.Setlinfo.HifobPay
  4757. order.MafPay = res.Output.Setlinfo.MafPay
  4758. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4759. order.OthPay = res.Output.Setlinfo.OthPay
  4760. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4761. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4762. order.AcctPay = res.Output.Setlinfo.AcctPay
  4763. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4764. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4765. order.Balc = res.Output.Setlinfo.Balc
  4766. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4767. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4768. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4769. order.ClrWay = res.Output.Setlinfo.ClrWay
  4770. order.Creator = order.Creator
  4771. order.Modify = roles.AdminUserId
  4772. order.RequestLog = src_resquest
  4773. order.Diagnosis = diagnosis_id
  4774. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4775. detailStr := string(setlDetail)
  4776. order.SetlDetail = detailStr
  4777. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4778. err = service.UpDateOrder(order)
  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. }
  4791. //func (c *HisApiController) GetPreUploadInfo() {
  4792. // id, _ := c.GetInt64("id")
  4793. // record_time := c.GetString("record_time")
  4794. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4795. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4796. //
  4797. // timeLayout := "2006-01-02"
  4798. // loc, _ := time.LoadLocation("Local")
  4799. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4800. // if err != nil {
  4801. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4802. // return
  4803. // }
  4804. // recordDateTime := theTime.Unix()
  4805. // adminUser := c.GetAdminUserInfo()
  4806. //
  4807. // var prescriptions []*models.HisPrescription
  4808. //
  4809. // var start_time int64
  4810. // var end_time int64
  4811. //
  4812. // data := make(map[string]interface{})
  4813. // if settle_accounts_type == 1 { //日结
  4814. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4815. // data["pre"] = prescriptions
  4816. //
  4817. // } else { //月结
  4818. // start_time_str := c.GetString("start_time")
  4819. // end_time_str := c.GetString("end_time")
  4820. // timeLayout := "2006-01-02"
  4821. // loc, _ := time.LoadLocation("Local")
  4822. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4823. // if err != nil {
  4824. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4825. // return
  4826. // }
  4827. // recordStartTime := theStartTime.Unix()
  4828. // start_time = recordStartTime
  4829. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4830. // if err != nil {
  4831. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4832. // return
  4833. // }
  4834. // recordEndTime := theEndTime.Unix()
  4835. // end_time = recordEndTime
  4836. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4837. // data["pre"] = prescriptions
  4838. //
  4839. // }
  4840. //
  4841. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4842. //
  4843. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4844. // timestamp := time.Now().Unix()
  4845. // tempTime := time.Unix(timestamp, 0)
  4846. // timeFormat := tempTime.Format("20060102150405")
  4847. // chrgBchno := rand.Intn(100000) + 10000
  4848. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4849. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4850. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4851. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4852. // strconv.FormatInt(his.PatientId, 10)
  4853. // client := &http.Client{}
  4854. // data["psn_no"] = his.PsnNo
  4855. // data["mdtrt_id"] = his.Number
  4856. // data["chrg_bchno"] = chrg_bchno
  4857. // data["org_name"] = miConfig.OrgName
  4858. // data["doctor"] = roles.UserName
  4859. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4860. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4861. // data["fixmedins_code"] = miConfig.Code
  4862. // data["dept_code"] = department.Number
  4863. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4864. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4865. // data["secret_key"] = miConfig.SecretKey
  4866. // var ids []int64
  4867. //
  4868. // for _, item := range prescriptions {
  4869. // ids = append(ids, item.ID)
  4870. // }
  4871. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4872. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4873. // bytesData, _ := json.Marshal(data)
  4874. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  4875. // resp, _ := client.Do(req)
  4876. // defer resp.Body.Close()
  4877. // body, ioErr := ioutil.ReadAll(resp.Body)
  4878. // if ioErr != nil {
  4879. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4880. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4881. // return
  4882. // }
  4883. // var respJSON map[string]interface{}
  4884. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4885. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4886. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4887. // return
  4888. // }
  4889. //
  4890. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4891. // userJSONBytes, _ := json.Marshal(respJSON)
  4892. // var res ResultFour
  4893. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4894. // utils.ErrorLog("解析失败:%v", err)
  4895. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4896. // return
  4897. // }
  4898. //
  4899. // if res.Infcode == 0 {
  4900. // order := &models.HisOrder{
  4901. // UserOrgId: adminUser.CurrentOrgId,
  4902. // HisPatientId: his.ID,
  4903. // PatientId: his.PatientId,
  4904. // SettleAccountsDate: recordDateTime,
  4905. // Ctime: time.Now().Unix(),
  4906. // Mtime: time.Now().Unix(),
  4907. // Status: 1,
  4908. // Number: chrg_bchno,
  4909. // Infcode: res.Infcode,
  4910. // WarnMsg: res.WarnMsg,
  4911. // Cainfo: res.Cainfo,
  4912. // ErrMsg: res.ErrMsg,
  4913. // RespondTime: res.RefmsgTime,
  4914. // InfRefmsgid: res.InfRefmsgid,
  4915. // OrderStatus: 1,
  4916. // IsMedicineInsurance: 1,
  4917. // SettleType: settle_accounts_type,
  4918. // SettleStartTime: start_time,
  4919. // SettleEndTime: end_time,
  4920. // Creator: roles.ID,
  4921. // Modify: roles.ID,
  4922. // PType: 2,
  4923. // }
  4924. // err = service.CreateOrder(order)
  4925. // if err != nil {
  4926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4927. // return
  4928. // }
  4929. //
  4930. // for _, item := range res.Output.Result {
  4931. // temp := strings.Split(item.FeedetlSn, "-")
  4932. // var advice_id int64 = 0
  4933. // var project_id int64 = 0
  4934. // var types int64 = 0
  4935. //
  4936. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  4937. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  4938. //
  4939. // if temp[1] == "1" {
  4940. // advice_id = id
  4941. // project_id = 0
  4942. // } else if temp[1] == "2" {
  4943. // advice_id = 0
  4944. // project_id = id
  4945. // }
  4946. //
  4947. // info := &models.HisOrderInfo{
  4948. // OrderNumber: order.Number,
  4949. // FeedetlSn: item.FeedetlSn,
  4950. // UploadDate: time.Now().Unix(),
  4951. // AdviceId: advice_id,
  4952. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  4953. // Cnt: item.Cnt,
  4954. // Pric: float64(item.Pric),
  4955. // PatientId: his.PatientId,
  4956. // PricUplmtAmt: item.PricUplmtAmt,
  4957. // SelfpayProp: item.SelfpayProp,
  4958. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4959. // OverlmtAmt: item.OverlmtAmt,
  4960. // PreselfpayAmt: item.PreselfpayAmt,
  4961. // BasMednFlag: item.BasMednFlag,
  4962. // MedChrgitmType: item.MedChrgitmType,
  4963. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  4964. // Status: 1,
  4965. // Memo: item.Memo,
  4966. // Mtime: time.Now().Unix(),
  4967. // InscpScpAmt: item.InscpScpAmt,
  4968. // DrtReimFlag: item.DrtReimFlag,
  4969. // Ctime: time.Now().Unix(),
  4970. // ListSpItemFlag: item.ListSpItemFlag,
  4971. // ChldMedcFlag: item.ChldMedcFlag,
  4972. // LmtUsedFlag: item.LmtUsedFlag,
  4973. // ChrgitmLv: item.ChrgitmLv,
  4974. // UserOrgId: adminUser.CurrentOrgId,
  4975. // HisPatientId: his.ID,
  4976. // OrderId: order.ID,
  4977. // ProjectId: project_id,
  4978. // Type: types,
  4979. // }
  4980. // service.CreateOrderInfo(info)
  4981. //
  4982. // }
  4983. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4984. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  4985. //
  4986. // var total float64
  4987. // for _, item := range prescriptions {
  4988. // if item.Type == 1 { //药品
  4989. // for _, subItem := range item.HisDoctorAdviceInfo {
  4990. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4991. // }
  4992. // }
  4993. // if item.Type == 2 { //项目
  4994. // for _, subItem := range item.HisPrescriptionProject {
  4995. // total = total + (subItem.Price * float64(subItem.Count))
  4996. // }
  4997. // }
  4998. // }
  4999. //
  5000. // for _, item := range prescriptions {
  5001. // for _, subItem := range item.HisAdditionalCharge {
  5002. // total = total + (subItem.Price * float64(subItem.Count))
  5003. // }
  5004. // }
  5005. //
  5006. // allTotal := fmt.Sprintf("%.2f", total)
  5007. // if res.Infcode == 0 {
  5008. // var rf []*ResultFive
  5009. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5010. // psn_no := his.PsnNo
  5011. // mdtrt_id := his.Number
  5012. // chrg_bchno := chrg_bchno
  5013. // cert_no := his.Certno
  5014. // insutype := rf[0].Insutype
  5015. //
  5016. // if his.IdCardType == 1 {
  5017. // cert_no = his.MedicalInsuranceNumber
  5018. //
  5019. // } else {
  5020. //
  5021. // cert_no = his.Certno
  5022. //
  5023. // }
  5024. //
  5025. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5026. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5027. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5028. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5029. // resp, requestErr := http.Get(api)
  5030. // if requestErr != nil {
  5031. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5032. // return
  5033. // }
  5034. // defer resp.Body.Close()
  5035. // body, ioErr := ioutil.ReadAll(resp.Body)
  5036. // if ioErr != nil {
  5037. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5038. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5039. // return
  5040. // }
  5041. // var respJSON map[string]interface{}
  5042. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5043. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5044. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5045. // return
  5046. // }
  5047. // fmt.Println(respJSON)
  5048. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5049. // userJSONBytes, _ := json.Marshal(respJSON)
  5050. // var res ResultSeven
  5051. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5052. // utils.ErrorLog("解析失败:%v", err)
  5053. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5054. // return
  5055. // }
  5056. // if res.Infcode != 0 {
  5057. // errlog := &models.HisOrderError{
  5058. // UserOrgId: adminUser.CurrentOrgId,
  5059. // Ctime: time.Now().Unix(),
  5060. // Mtime: time.Now().Unix(),
  5061. // Number: chrg_bchno,
  5062. // ErrMsg: res.ErrMsg,
  5063. // Status: 1,
  5064. // PatientId: id,
  5065. // RecordTime: recordDateTime,
  5066. // Stage: 7,
  5067. // }
  5068. // service.CreateErrMsgLog(errlog)
  5069. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5070. // return
  5071. // } else {
  5072. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5073. // order.OrderStatus = 1
  5074. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5075. // order.SetlId = res.Output.Setlinfo.SetlID
  5076. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5077. // order.PsnName = res.Output.Setlinfo.PsnName
  5078. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5079. // order.Certno = res.Output.Setlinfo.Certno
  5080. // order.Gend = res.Output.Setlinfo.Gend
  5081. // order.Naty = res.Output.Setlinfo.Naty
  5082. // order.Age = res.Output.Setlinfo.Age
  5083. // order.Insutype = res.Output.Setlinfo.Insutype
  5084. // order.PsnType = res.Output.Setlinfo.PsnType
  5085. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5086. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5087. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5088. // order.MedType = res.Output.Setlinfo.MedType
  5089. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5090. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5091. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5092. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5093. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5094. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5095. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5096. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5097. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5098. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5099. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5100. // order.MafPay = res.Output.Setlinfo.MafPay
  5101. // order.OthPay = res.Output.Setlinfo.OthPay
  5102. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5103. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5104. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5105. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5106. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5107. // order.Balc = res.Output.Setlinfo.Balc
  5108. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5109. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5110. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5111. // order.ClrWay = res.Output.Setlinfo.ClrWay
  5112. // order.Creator = order.Creator
  5113. // order.Modify = roles.ID
  5114. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5115. // detailStr := string(setlDetail)
  5116. // order.SetlDetail = detailStr
  5117. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5118. // err = service.UpDateOrder(order)
  5119. // if err == nil {
  5120. // c.ServeSuccessJSON(map[string]interface{}{
  5121. // "msg": "预结算成功",
  5122. // })
  5123. // } else {
  5124. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5125. // return
  5126. // }
  5127. // }
  5128. // } else {
  5129. // adminUser := c.GetAdminUserInfo()
  5130. // errlog := &models.HisOrderError{
  5131. // UserOrgId: adminUser.CurrentOrgId,
  5132. // Ctime: time.Now().Unix(),
  5133. // Mtime: time.Now().Unix(),
  5134. // ErrMsg: res.ErrMsg,
  5135. // Status: 1,
  5136. // PatientId: id,
  5137. // RecordTime: recordDateTime,
  5138. // Stage: 4,
  5139. // }
  5140. // service.CreateErrMsgLog(errlog)
  5141. //
  5142. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5143. // return
  5144. // }
  5145. // } else {
  5146. // adminUser := c.GetAdminUserInfo()
  5147. // errlog := &models.HisOrderError{
  5148. // UserOrgId: adminUser.CurrentOrgId,
  5149. // Ctime: time.Now().Unix(),
  5150. // Mtime: time.Now().Unix(),
  5151. // ErrMsg: res.ErrMsg,
  5152. // Status: 1,
  5153. // PatientId: id,
  5154. // RecordTime: recordDateTime,
  5155. // Stage: 4,
  5156. // }
  5157. // service.CreateErrMsgLog(errlog)
  5158. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5159. // return
  5160. // }
  5161. //
  5162. // } else {
  5163. // var total float64
  5164. // for _, item := range prescriptions {
  5165. // if item.Type == 1 { //药品
  5166. // for _, subItem := range item.HisDoctorAdviceInfo {
  5167. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5168. // }
  5169. // }
  5170. // if item.Type == 2 { //项目
  5171. // for _, subItem := range item.HisPrescriptionProject {
  5172. // total = total + (subItem.Price * float64(subItem.Count))
  5173. // }
  5174. // }
  5175. //
  5176. // for _, subItem := range item.HisAdditionalCharge {
  5177. // total = total + (subItem.Price * float64(subItem.Count))
  5178. // }
  5179. // }
  5180. //
  5181. // allTotal := fmt.Sprintf("%.2f", total)
  5182. // totals, _ := strconv.ParseFloat(allTotal, 64)
  5183. // order := &models.HisOrder{
  5184. // UserOrgId: adminUser.CurrentOrgId,
  5185. // HisPatientId: his.ID,
  5186. // PatientId: id,
  5187. // SettleAccountsDate: recordDateTime,
  5188. // Ctime: time.Now().Unix(),
  5189. // Mtime: time.Now().Unix(),
  5190. // Status: 1,
  5191. // OrderStatus: 2,
  5192. // Number: chrg_bchno,
  5193. // MedfeeSumamt: totals,
  5194. // }
  5195. // err = service.CreateOrder(order)
  5196. // if err != nil {
  5197. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5198. // return
  5199. // }
  5200. //
  5201. // var customs []*Custom
  5202. // for _, item := range prescriptions {
  5203. //
  5204. // if item.Type == 1 { //药品
  5205. // for _, subItem := range item.HisDoctorAdviceInfo {
  5206. // cus := &Custom{
  5207. // AdviceId: subItem.ID,
  5208. // ProjectId: 0,
  5209. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  5210. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  5211. // FeedetlSn: subItem.FeedetlSn,
  5212. // Price: fmt.Sprintf("%.2f", subItem.Price),
  5213. // MedListCodg: subItem.MedListCodg,
  5214. // Type: 1,
  5215. // }
  5216. // customs = append(customs, cus)
  5217. // }
  5218. // }
  5219. //
  5220. // if item.Type == 2 { //项目
  5221. // for _, subItem := range item.HisPrescriptionProject {
  5222. //
  5223. // cus := &Custom{
  5224. // AdviceId: 0,
  5225. // ProjectId: subItem.ID,
  5226. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  5227. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  5228. // FeedetlSn: subItem.FeedetlSn,
  5229. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  5230. // MedListCodg: subItem.MedListCodg,
  5231. // Type: 2,
  5232. // }
  5233. //
  5234. // customs = append(customs, cus)
  5235. // }
  5236. // }
  5237. //
  5238. // for _, item := range item.HisAdditionalCharge {
  5239. // cus := &Custom{
  5240. // ItemId: item.ID,
  5241. // AdviceId: 0,
  5242. // ProjectId: 0,
  5243. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  5244. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  5245. // FeedetlSn: item.FeedetlSn,
  5246. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  5247. // MedListCodg: item.XtHisAddtionConfig.Code,
  5248. // Type: 3,
  5249. // }
  5250. //
  5251. // customs = append(customs, cus)
  5252. // }
  5253. //
  5254. // }
  5255. //
  5256. // for _, item := range customs {
  5257. // var advice_id int64 = 0
  5258. // var project_id int64 = 0
  5259. // var item_id int64 = 0
  5260. //
  5261. // var types int64 = 0
  5262. //
  5263. // if item.Type == 1 {
  5264. // advice_id = item.AdviceId
  5265. // project_id = 0
  5266. // item_id = 0
  5267. // } else if item.Type == 2 {
  5268. // advice_id = 0
  5269. // item_id = 0
  5270. //
  5271. // project_id = item.ProjectId
  5272. // } else if item.Type == 3 {
  5273. // advice_id = 0
  5274. // item_id = item.ItemId
  5275. // project_id = 0
  5276. // }
  5277. //
  5278. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  5279. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  5280. // pric, _ := strconv.ParseFloat(item.Price, 32)
  5281. //
  5282. // info := &models.HisOrderInfo{
  5283. // OrderNumber: order.Number,
  5284. // UploadDate: time.Now().Unix(),
  5285. // AdviceId: advice_id,
  5286. // DetItemFeeSumamt: detItemFeeSumamt,
  5287. // Cnt: cut,
  5288. // Pric: pric,
  5289. // PatientId: id,
  5290. // Status: 1,
  5291. // Mtime: time.Now().Unix(),
  5292. // Ctime: time.Now().Unix(),
  5293. // UserOrgId: adminUser.CurrentOrgId,
  5294. // HisPatientId: his.ID,
  5295. // OrderId: order.ID,
  5296. // ProjectId: project_id,
  5297. // Type: types,
  5298. // ItemId: item_id,
  5299. // }
  5300. // service.CreateOrderInfo(info)
  5301. // }
  5302. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5303. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5304. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  5305. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5306. // if err == nil {
  5307. // c.ServeSuccessJSON(map[string]interface{}{
  5308. // "msg": "结算成功",
  5309. // })
  5310. // } else {
  5311. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5312. // return
  5313. // }
  5314. // }
  5315. //}
  5316. //上传明细-预结算-
  5317. func (c *HisApiController) GetPreUploadInfo() {
  5318. id, _ := c.GetInt64("id")
  5319. record_time := c.GetString("record_time")
  5320. his_patient_id, _ := c.GetInt64("his_patient_id")
  5321. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5322. admin_user_id, _ := c.GetInt64("admin_user_id")
  5323. diagnosis_id := c.GetString("diagnosis")
  5324. sick_type, _ := c.GetInt64("sick_type")
  5325. reg_type, _ := c.GetInt64("p_type")
  5326. begin_time := c.GetString("begin_time")
  5327. id_str := c.GetString("ids")
  5328. ids_arr := strings.Split(id_str, ",")
  5329. timeLayout := "2006-01-02"
  5330. loc, _ := time.LoadLocation("Local")
  5331. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5332. if err != nil {
  5333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5334. return
  5335. }
  5336. recordDateTime := theTime.Unix()
  5337. adminUser := c.GetAdminUserInfo()
  5338. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5339. var config []*models.HisXtDiagnoseConfig
  5340. for _, item := range diagnosis_ids {
  5341. id, _ := strconv.ParseInt(item, 10, 64)
  5342. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5343. config = append(config, &diagnosisConfig)
  5344. }
  5345. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5346. sickConfig, _ := service.FindSickById(sick_type)
  5347. var prescriptions []*models.HisPrescription
  5348. var start_time int64
  5349. var end_time int64
  5350. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5351. fmt.Println(his_patient_id)
  5352. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5353. timestamp := time.Now().Unix()
  5354. tempTime := time.Unix(timestamp, 0)
  5355. timeFormat := tempTime.Format("20060102150405")
  5356. chrgBchno := rand.Intn(100000) + 10000
  5357. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5358. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5359. var patientPrescription models.HisPrescriptionInfo
  5360. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5361. if patientPrescription.ID == 0 {
  5362. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5363. }
  5364. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5365. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5366. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5367. strconv.FormatInt(his.PatientId, 10)
  5368. var res2 ResultSix
  5369. var resSix10265 ResultSix10265
  5370. var time_stamp string
  5371. if miConfig.MdtrtareaAdmvs == "421300" {
  5372. data := make(map[string]interface{})
  5373. client := &http.Client{}
  5374. data["psn_no"] = his.PsnNo
  5375. data["mdtrt_id"] = his.Number
  5376. data["doctor"] = roles.UserName
  5377. data["department"] = department.Name
  5378. data["org_name"] = miConfig.OrgName
  5379. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5380. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5381. data["fixmedins_code"] = miConfig.Code
  5382. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5383. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5384. data["secret_key"] = miConfig.SecretKey
  5385. data["sick_code"] = sickConfig.CountryCode
  5386. data["sick_name"] = sickConfig.ClassName
  5387. data["begin_time"] = begin_time
  5388. data["dept"] = strconv.FormatInt(department.ID, 10)
  5389. data["config"] = config
  5390. fmt.Println(data)
  5391. bytesData, _ := json.Marshal(data)
  5392. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5393. resp, _ := client.Do(req)
  5394. defer resp.Body.Close()
  5395. body, ioErr := ioutil.ReadAll(resp.Body)
  5396. if ioErr != nil {
  5397. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5399. return
  5400. }
  5401. var respJSON map[string]interface{}
  5402. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5403. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5405. return
  5406. }
  5407. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5408. userJSONBytes, _ := json.Marshal(respJSON)
  5409. fmt.Println("log")
  5410. fmt.Println(string(userJSONBytes))
  5411. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5412. utils.ErrorLog("解析失败:%v", err)
  5413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5414. return
  5415. }
  5416. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5417. //江苏地区国家医保医疗类别
  5418. //职工透析:医疗类别选特殊情况门诊9933
  5419. //居民血透门慢: 医疗类别选门诊慢病1402
  5420. //var med_type string
  5421. //if his.Insutype == "310" {
  5422. // if reg_type == 14 {
  5423. // med_type = "9933"
  5424. // } else if reg_type == 11 {
  5425. // med_type = "11"
  5426. //
  5427. // }
  5428. //} else if his.Insutype == "390" {
  5429. // if reg_type == 14 {
  5430. // med_type = "1402"
  5431. // } else if reg_type == 11 {
  5432. // med_type = "11"
  5433. // }
  5434. //}
  5435. data := make(map[string]interface{})
  5436. client := &http.Client{}
  5437. data["psn_no"] = his.PsnNo
  5438. data["mdtrt_id"] = his.Number
  5439. data["doctor"] = roles.UserName
  5440. data["department"] = department.Name
  5441. data["org_name"] = miConfig.OrgName
  5442. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5443. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5444. data["fixmedins_code"] = miConfig.Code
  5445. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5446. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5447. data["secret_key"] = miConfig.SecretKey
  5448. data["sick_code"] = sickConfig.CountryCode
  5449. data["sick_name"] = sickConfig.ClassName
  5450. data["begin_time"] = begin_time
  5451. data["dept"] = strconv.FormatInt(department.ID, 10)
  5452. data["config"] = config
  5453. data["url"] = miConfig.Url
  5454. data["ak"] = miConfig.AccessKey
  5455. data["cainfo"] = miConfig.Cainfo
  5456. bytesData, _ := json.Marshal(data)
  5457. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5458. resp, _ := client.Do(req)
  5459. defer resp.Body.Close()
  5460. body, ioErr := ioutil.ReadAll(resp.Body)
  5461. if ioErr != nil {
  5462. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5464. return
  5465. }
  5466. var respJSON map[string]interface{}
  5467. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5470. return
  5471. }
  5472. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  5473. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  5474. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  5475. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5476. userJSONBytes, _ := json.Marshal(respJSON)
  5477. fmt.Println("log")
  5478. fmt.Println(string(userJSONBytes))
  5479. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5480. utils.ErrorLog("解析失败:%v", err)
  5481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5482. return
  5483. }
  5484. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5485. res2.Output = resSix10265.Output
  5486. res2.ErrMsg = resSix10265.ErrMsg
  5487. res2.Cainfo = resSix10265.Cainfo
  5488. res2.WarnMsg = resSix10265.WarnMsg
  5489. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5490. res2.Infcode = infocode
  5491. } else {
  5492. var result string
  5493. var requestLog string
  5494. if miConfig.MdtrtareaAdmvs == "440781" { //
  5495. 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)
  5496. } else {
  5497. if miConfig.Code == "H15049901371" {
  5498. //赤峰地区国家医保医疗类别
  5499. //职工透析:医疗类别选特殊情况门诊990502
  5500. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5501. var med_type string
  5502. if his.Insutype == "390" {
  5503. if reg_type == 14 {
  5504. med_type = "9933"
  5505. } else if reg_type == 11 {
  5506. med_type = "11"
  5507. }
  5508. } else if his.Insutype == "310" {
  5509. if reg_type == 14 {
  5510. med_type = "990502"
  5511. } else if reg_type == 11 {
  5512. med_type = "11"
  5513. }
  5514. }
  5515. 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)
  5516. } else {
  5517. 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)
  5518. }
  5519. saveLog(result, requestLog, "2203", "上传就诊信息")
  5520. var respJSON2 map[string]interface{}
  5521. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5522. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5524. return
  5525. }
  5526. userJSONBytes2, _ := json.Marshal(respJSON2)
  5527. if miConfig.Code == "H15049901371" {
  5528. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5529. utils.ErrorLog("解析失败:%v", err)
  5530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5531. return
  5532. }
  5533. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5534. res2.Output = resSix10265.Output
  5535. res2.ErrMsg = resSix10265.ErrMsg
  5536. res2.Cainfo = resSix10265.Cainfo
  5537. res2.WarnMsg = resSix10265.WarnMsg
  5538. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5539. res2.Infcode = infocode
  5540. } else {
  5541. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5542. utils.ErrorLog("解析失败:%v", err)
  5543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5544. return
  5545. }
  5546. }
  5547. }
  5548. }
  5549. if res2.Infcode != 0 {
  5550. adminUser := c.GetAdminUserInfo()
  5551. errlog := &models.HisOrderError{
  5552. UserOrgId: adminUser.CurrentOrgId,
  5553. Ctime: time.Now().Unix(),
  5554. Mtime: time.Now().Unix(),
  5555. ErrMsg: res2.ErrMsg,
  5556. Status: 1,
  5557. PatientId: id,
  5558. RecordTime: recordDateTime,
  5559. Stage: 3,
  5560. }
  5561. service.CreateErrMsgLog(errlog)
  5562. c.ServeSuccessJSON(map[string]interface{}{
  5563. "failed_code": -10,
  5564. "msg": res2.ErrMsg,
  5565. })
  5566. return
  5567. } else {
  5568. his.Diagnosis = diagnosis_id
  5569. his.SickType = sickConfig.ID
  5570. his.PType = fmt.Sprintf("%d", reg_type)
  5571. service.UpdateHisPatientThree(&his)
  5572. data := make(map[string]interface{})
  5573. if settle_accounts_type == 1 { //日结
  5574. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5575. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5576. } else {
  5577. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5578. }
  5579. data["pre"] = prescriptions
  5580. } else { //月结
  5581. start_time_str := c.GetString("start_time")
  5582. end_time_str := c.GetString("end_time")
  5583. timeLayout := "2006-01-02"
  5584. loc, _ := time.LoadLocation("Local")
  5585. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5586. if err != nil {
  5587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5588. return
  5589. }
  5590. recordStartTime := theStartTime.Unix()
  5591. start_time = recordStartTime
  5592. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5593. if err != nil {
  5594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5595. return
  5596. }
  5597. recordEndTime := theEndTime.Unix()
  5598. end_time = recordEndTime
  5599. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5600. data["pre"] = prescriptions
  5601. }
  5602. client := &http.Client{}
  5603. data["psn_no"] = his.PsnNo
  5604. data["mdtrt_id"] = his.Number
  5605. data["chrg_bchno"] = chrg_bchno
  5606. data["org_name"] = miConfig.OrgName
  5607. data["doctor"] = roles.UserName
  5608. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5609. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5610. data["fixmedins_code"] = miConfig.Code
  5611. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5612. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5613. data["dept_code"] = "15"
  5614. } else {
  5615. data["dept_code"] = department.Number
  5616. }
  5617. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5618. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5619. data["secret_key"] = miConfig.SecretKey
  5620. data["url"] = miConfig.Url
  5621. data["ak"] = miConfig.AccessKey
  5622. data["new_doctor_name"] = patientPrescription.Doctor
  5623. data["diag_code"] = sickConfig.CountryCode
  5624. data["time_stamp"] = time_stamp
  5625. data["cainfo"] = miConfig.Cainfo
  5626. var ids []int64
  5627. for _, item := range prescriptions {
  5628. ids = append(ids, item.ID)
  5629. }
  5630. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5631. if config.IsOpen == 1 { //对接了医保,走医保流程
  5632. var res ResultFour
  5633. var resFour10265 ResultFour10265
  5634. if miConfig.MdtrtareaAdmvs == "421300" {
  5635. bytesData, _ := json.Marshal(data)
  5636. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5637. resp, _ := client.Do(req)
  5638. defer resp.Body.Close()
  5639. body, ioErr := ioutil.ReadAll(resp.Body)
  5640. if ioErr != nil {
  5641. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5643. return
  5644. }
  5645. var respJSON map[string]interface{}
  5646. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5647. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5649. return
  5650. }
  5651. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5652. userJSONBytes, _ := json.Marshal(respJSON)
  5653. fmt.Println("log")
  5654. fmt.Println(string(userJSONBytes))
  5655. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5656. utils.ErrorLog("解析失败:%v", err)
  5657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5658. return
  5659. }
  5660. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5661. bytesData, _ := json.Marshal(data)
  5662. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5663. resp, _ := client.Do(req)
  5664. defer resp.Body.Close()
  5665. body, ioErr := ioutil.ReadAll(resp.Body)
  5666. if ioErr != nil {
  5667. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5669. return
  5670. }
  5671. var respJSON map[string]interface{}
  5672. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5675. return
  5676. }
  5677. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5678. userJSONBytes, _ := json.Marshal(respJSON)
  5679. fmt.Println("log")
  5680. fmt.Println(string(userJSONBytes))
  5681. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5682. utils.ErrorLog("解析失败:%v", err)
  5683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5684. return
  5685. }
  5686. res.InfRefmsgid = resFour10265.InfRefmsgid
  5687. res.Output = resFour10265.Output
  5688. res.ErrMsg = resFour10265.ErrMsg
  5689. res.Cainfo = resFour10265.Cainfo
  5690. res.WarnMsg = resFour10265.WarnMsg
  5691. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5692. res.Infcode = infocode
  5693. } else {
  5694. if miConfig.Code == "H15049901371" {
  5695. 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)
  5696. var dat map[string]interface{}
  5697. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5698. fmt.Println(dat)
  5699. } else {
  5700. fmt.Println(err)
  5701. }
  5702. saveLog(result, request_log, "2204", "上传费用明细")
  5703. userJSONBytes, _ := json.Marshal(dat)
  5704. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5705. utils.ErrorLog("解析失败:%v", err)
  5706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5707. return
  5708. }
  5709. res.InfRefmsgid = resFour10265.InfRefmsgid
  5710. res.Output = resFour10265.Output
  5711. res.ErrMsg = resFour10265.ErrMsg
  5712. res.Cainfo = resFour10265.Cainfo
  5713. res.WarnMsg = resFour10265.WarnMsg
  5714. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5715. res.Infcode = infocode
  5716. } else {
  5717. 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)
  5718. var dat map[string]interface{}
  5719. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5720. fmt.Println(dat)
  5721. } else {
  5722. fmt.Println(err)
  5723. }
  5724. saveLog(result, request_log, "2204", "上传费用明细")
  5725. userJSONBytes, _ := json.Marshal(dat)
  5726. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5727. utils.ErrorLog("解析失败:%v", err)
  5728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5729. return
  5730. }
  5731. }
  5732. }
  5733. if res.Infcode == 0 {
  5734. order := &models.HisOrder{
  5735. UserOrgId: adminUser.CurrentOrgId,
  5736. HisPatientId: his.ID,
  5737. PatientId: his.PatientId,
  5738. SettleAccountsDate: recordDateTime,
  5739. Ctime: time.Now().Unix(),
  5740. Mtime: time.Now().Unix(),
  5741. MdtrtId: his.Number,
  5742. PsnNo: his.PsnNo,
  5743. MedType: strconv.FormatInt(reg_type, 10),
  5744. Status: 1,
  5745. Number: chrg_bchno,
  5746. Infcode: res.Infcode,
  5747. WarnMsg: res.WarnMsg,
  5748. Cainfo: res.Cainfo,
  5749. ErrMsg: res.ErrMsg,
  5750. RespondTime: res.RefmsgTime,
  5751. InfRefmsgid: res.InfRefmsgid,
  5752. OrderStatus: 1,
  5753. IsMedicineInsurance: 1,
  5754. SettleType: settle_accounts_type,
  5755. SettleStartTime: start_time,
  5756. SettleEndTime: end_time,
  5757. Creator: roles.AdminUserId,
  5758. Modify: roles.AdminUserId,
  5759. PType: 2,
  5760. Diagnosis: diagnosis_id,
  5761. }
  5762. err = service.CreateOrder(order)
  5763. if err != nil {
  5764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5765. return
  5766. }
  5767. for _, item := range res.Output.Result {
  5768. temp := strings.Split(item.FeedetlSn, "-")
  5769. var advice_id int64 = 0
  5770. var project_id int64 = 0
  5771. var types int64 = 0
  5772. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5773. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5774. if temp[1] == "1" {
  5775. advice_id = id
  5776. project_id = 0
  5777. } else if temp[1] == "2" {
  5778. advice_id = 0
  5779. project_id = id
  5780. }
  5781. info := &models.HisOrderInfo{
  5782. OrderNumber: order.Number,
  5783. FeedetlSn: item.FeedetlSn,
  5784. UploadDate: time.Now().Unix(),
  5785. AdviceId: advice_id,
  5786. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5787. Cnt: item.Cnt,
  5788. Pric: float64(item.Pric),
  5789. PatientId: his.PatientId,
  5790. PricUplmtAmt: item.PricUplmtAmt,
  5791. SelfpayProp: item.SelfpayProp,
  5792. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5793. OverlmtAmt: item.OverlmtAmt,
  5794. PreselfpayAmt: item.PreselfpayAmt,
  5795. BasMednFlag: item.BasMednFlag,
  5796. MedChrgitmType: item.MedChrgitmType,
  5797. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5798. Status: 1,
  5799. Memo: item.Memo,
  5800. Mtime: time.Now().Unix(),
  5801. InscpScpAmt: item.InscpScpAmt,
  5802. DrtReimFlag: item.DrtReimFlag,
  5803. Ctime: time.Now().Unix(),
  5804. ListSpItemFlag: item.ListSpItemFlag,
  5805. ChldMedcFlag: item.ChldMedcFlag,
  5806. LmtUsedFlag: item.LmtUsedFlag,
  5807. ChrgitmLv: item.ChrgitmLv,
  5808. UserOrgId: adminUser.CurrentOrgId,
  5809. HisPatientId: his.ID,
  5810. OrderId: order.ID,
  5811. ProjectId: project_id,
  5812. Type: types,
  5813. }
  5814. service.CreateOrderInfo(info)
  5815. }
  5816. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5817. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5818. var total float64
  5819. for _, item := range prescriptions {
  5820. if item.Type == 1 { //药品
  5821. for _, subItem := range item.HisDoctorAdviceInfo {
  5822. total = total + (subItem.Price * subItem.PrescribingNumber)
  5823. }
  5824. }
  5825. if item.Type == 2 { //项目
  5826. for _, subItem := range item.HisPrescriptionProject {
  5827. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5828. total = total + (subItem.Price * cnt)
  5829. }
  5830. }
  5831. }
  5832. for _, item := range prescriptions {
  5833. for _, subItem := range item.HisAdditionalCharge {
  5834. total = total + (subItem.Price * float64(subItem.Count))
  5835. }
  5836. }
  5837. allTotal := fmt.Sprintf("%.4f", total)
  5838. if res.Infcode == 0 {
  5839. var rf []*ResultFive
  5840. json.Unmarshal([]byte(his.Iinfo), &rf)
  5841. chrg_bchno := chrg_bchno
  5842. cert_no := his.Certno
  5843. var insutypes []string
  5844. var insutype string
  5845. var is390 int = 0
  5846. var is310 int = 0
  5847. for _, item := range rf {
  5848. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5849. insutypes = append(insutypes, item.Insutype)
  5850. }
  5851. }
  5852. if len(insutypes) == 1 {
  5853. insutype = insutypes[0]
  5854. } else {
  5855. for _, i := range insutypes {
  5856. if i == "390" {
  5857. is390 = 1
  5858. }
  5859. if i == "310" {
  5860. is310 = 1
  5861. }
  5862. }
  5863. }
  5864. if is390 == 1 {
  5865. insutype = "390"
  5866. }
  5867. if is310 == 1 {
  5868. insutype = "310"
  5869. }
  5870. if len(insutypes) == 0 {
  5871. insutype = "310"
  5872. }
  5873. if len(insutypes) == 2 {
  5874. insutype = strconv.FormatInt(his.SocialType, 64)
  5875. }
  5876. //insutype = "390"
  5877. if his.IdCardType == 1 {
  5878. cert_no = his.MedicalInsuranceNumber
  5879. } else {
  5880. cert_no = his.Certno
  5881. }
  5882. var res ResultSeven
  5883. var resSeven10265 ResultSeven10265
  5884. if miConfig.MdtrtareaAdmvs == "421300" {
  5885. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5886. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5887. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5888. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5889. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5890. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5891. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  5892. resp, requestErr := http.Get(api)
  5893. if requestErr != nil {
  5894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5895. return
  5896. }
  5897. body, ioErr := ioutil.ReadAll(resp.Body)
  5898. if ioErr != nil {
  5899. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5901. return
  5902. }
  5903. var respJSON map[string]interface{}
  5904. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5907. return
  5908. }
  5909. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5910. result, _ := json.Marshal(respJSON)
  5911. fmt.Println("log")
  5912. fmt.Println(string(result))
  5913. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5914. utils.ErrorLog("解析失败:%v", err)
  5915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5916. return
  5917. }
  5918. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5919. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5920. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5921. bas := strings.Split(psn_info.CardInfo, "|")
  5922. if his.IdCardType == 1 {
  5923. cert_no = bas[2]
  5924. } else {
  5925. cert_no = bas[1]
  5926. }
  5927. //江苏地区国家医保医疗类别
  5928. //职工透析:医疗类别选特殊情况门诊9933
  5929. //居民血透门慢: 医疗类别选门诊慢病1402
  5930. //var med_type string
  5931. //if his.Insutype == "310" {
  5932. // if reg_type == 14 {
  5933. // med_type = "9933"
  5934. // } else if reg_type == 11 {
  5935. // med_type = "11"
  5936. //
  5937. // }
  5938. //} else if his.Insutype == "390" {
  5939. // if reg_type == 14 {
  5940. // med_type = "1402"
  5941. // } else if reg_type == 11 {
  5942. // med_type = "11"
  5943. // }
  5944. //}
  5945. api := "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5946. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5947. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5948. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5949. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5950. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5951. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5952. resp, requestErr := http.Get(api)
  5953. if requestErr != nil {
  5954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5955. return
  5956. }
  5957. body, ioErr := ioutil.ReadAll(resp.Body)
  5958. if ioErr != nil {
  5959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5961. return
  5962. }
  5963. var respJSON map[string]interface{}
  5964. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5965. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5967. return
  5968. }
  5969. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5970. result, _ := json.Marshal(respJSON)
  5971. fmt.Println("log")
  5972. fmt.Println(string(result))
  5973. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5974. utils.ErrorLog("解析失败:%v", err)
  5975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5976. return
  5977. }
  5978. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5979. res.Output = resSeven10265.Output
  5980. res.ErrMsg = resSeven10265.ErrMsg
  5981. res.Cainfo = resSeven10265.Cainfo
  5982. res.WarnMsg = resSeven10265.WarnMsg
  5983. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5984. res.Infcode = infocode
  5985. } else {
  5986. var result string
  5987. var request_log string
  5988. if miConfig.Code == "H15049901371" {
  5989. //赤峰地区国家医保医疗类别
  5990. //职工透析:医疗类别选特殊情况门诊990502
  5991. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5992. var med_type string
  5993. if his.Insutype == "390" {
  5994. if reg_type == 14 {
  5995. med_type = "9933"
  5996. } else if reg_type == 11 {
  5997. med_type = "11"
  5998. }
  5999. } else if his.Insutype == "310" {
  6000. if reg_type == 14 {
  6001. med_type = "990502"
  6002. } else if reg_type == 11 {
  6003. med_type = "11"
  6004. }
  6005. }
  6006. 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)
  6007. } else {
  6008. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  6009. }
  6010. var dat map[string]interface{}
  6011. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6012. fmt.Println(dat)
  6013. } else {
  6014. fmt.Println(err)
  6015. }
  6016. saveLog(result, request_log, "2206", "预结算")
  6017. //userJSONBytes, _ := json.Marshal(dat)
  6018. //
  6019. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6020. // utils.ErrorLog("解析失败:%v", err)
  6021. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6022. // return
  6023. //}
  6024. userJSONBytes, _ := json.Marshal(dat)
  6025. if miConfig.Code == "H15049901371" {
  6026. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6027. utils.ErrorLog("解析失败:%v", err)
  6028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6029. return
  6030. }
  6031. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6032. res.Output = resSeven10265.Output
  6033. res.ErrMsg = resSeven10265.ErrMsg
  6034. res.Cainfo = resSeven10265.Cainfo
  6035. res.WarnMsg = resSeven10265.WarnMsg
  6036. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6037. res.Infcode = infocode
  6038. } else {
  6039. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6040. utils.ErrorLog("解析失败:%v", err)
  6041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6042. return
  6043. }
  6044. }
  6045. }
  6046. if res.Infcode != 0 {
  6047. errlog := &models.HisOrderError{
  6048. UserOrgId: adminUser.CurrentOrgId,
  6049. Ctime: time.Now().Unix(),
  6050. Mtime: time.Now().Unix(),
  6051. Number: chrg_bchno,
  6052. ErrMsg: res.ErrMsg,
  6053. Status: 1,
  6054. PatientId: id,
  6055. RecordTime: recordDateTime,
  6056. Stage: 20,
  6057. }
  6058. service.CreateErrMsgLog(errlog)
  6059. c.ServeSuccessJSON(map[string]interface{}{
  6060. "failed_code": -10,
  6061. "msg": res.ErrMsg,
  6062. })
  6063. return
  6064. } else {
  6065. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6066. order.OrderStatus = 1
  6067. order.IsPre = 1
  6068. order.Status = 1
  6069. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6070. order.SetlId = res.Output.Setlinfo.SetlID
  6071. order.PsnNo = res.Output.Setlinfo.PsnNo
  6072. order.PsnName = res.Output.Setlinfo.PsnName
  6073. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6074. order.Certno = res.Output.Setlinfo.Certno
  6075. order.Gend = res.Output.Setlinfo.Gend
  6076. order.Naty = res.Output.Setlinfo.Naty
  6077. order.Age = res.Output.Setlinfo.Age
  6078. order.Insutype = res.Output.Setlinfo.Insutype
  6079. order.PsnType = res.Output.Setlinfo.PsnType
  6080. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6081. order.SetlTime = res.Output.Setlinfo.SetlTime
  6082. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6083. if res.Output.Setlinfo.MedType == "140101" {
  6084. order.MedType = "14"
  6085. } else {
  6086. order.MedType = res.Output.Setlinfo.MedType
  6087. }
  6088. if reg_type == 1112 {
  6089. order.MedType = "1112"
  6090. }
  6091. if reg_type == 1111 {
  6092. order.MedType = "1111"
  6093. }
  6094. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6095. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6096. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6097. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6098. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6099. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6100. order.HifpPay = res.Output.Setlinfo.HifpPay
  6101. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6102. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6103. order.HifesPay = res.Output.Setlinfo.HifesPay
  6104. order.HifobPay = res.Output.Setlinfo.HifobPay
  6105. order.MafPay = res.Output.Setlinfo.MafPay
  6106. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6107. order.OthPay = res.Output.Setlinfo.OthPay
  6108. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6109. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6110. order.AcctPay = res.Output.Setlinfo.AcctPay
  6111. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6112. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6113. order.Balc = res.Output.Setlinfo.Balc
  6114. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6115. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6116. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6117. order.ClrWay = res.Output.Setlinfo.ClrWay
  6118. order.Creator = order.Creator
  6119. order.Modify = roles.AdminUserId
  6120. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6121. detailStr := string(setlDetail)
  6122. order.SetlDetail = detailStr
  6123. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6124. err = service.UpDateOrder(order)
  6125. if err == nil {
  6126. c.ServeSuccessJSON(map[string]interface{}{
  6127. "msg": "预结算成功",
  6128. })
  6129. } else {
  6130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6131. return
  6132. }
  6133. }
  6134. } else {
  6135. adminUser := c.GetAdminUserInfo()
  6136. errlog := &models.HisOrderError{
  6137. UserOrgId: adminUser.CurrentOrgId,
  6138. Ctime: time.Now().Unix(),
  6139. Mtime: time.Now().Unix(),
  6140. ErrMsg: res.ErrMsg,
  6141. Status: 1,
  6142. PatientId: id,
  6143. RecordTime: recordDateTime,
  6144. Stage: 4,
  6145. }
  6146. service.CreateErrMsgLog(errlog)
  6147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6148. return
  6149. }
  6150. } else {
  6151. adminUser := c.GetAdminUserInfo()
  6152. errlog := &models.HisOrderError{
  6153. UserOrgId: adminUser.CurrentOrgId,
  6154. Ctime: time.Now().Unix(),
  6155. Mtime: time.Now().Unix(),
  6156. ErrMsg: res.ErrMsg,
  6157. Status: 1,
  6158. PatientId: id,
  6159. RecordTime: recordDateTime,
  6160. Stage: 4,
  6161. }
  6162. service.CreateErrMsgLog(errlog)
  6163. c.ServeSuccessJSON(map[string]interface{}{
  6164. "failed_code": -10,
  6165. "msg": res.ErrMsg,
  6166. })
  6167. return
  6168. }
  6169. }
  6170. }
  6171. }
  6172. //func (c *HisApiController) GetSettleInfo() {
  6173. // id, _ := c.GetInt64("id")
  6174. // order_id, _ := c.GetInt64("order_id")
  6175. //
  6176. // record_time := c.GetString("record_time")
  6177. // pay_way, _ := c.GetInt64("pay_way")
  6178. // pay_price, _ := c.GetFloat("pay_price")
  6179. // pay_card_no := c.GetString("pay_card_no")
  6180. // discount_price, _ := c.GetFloat("discount_price")
  6181. // preferential_price, _ := c.GetFloat("preferential_price")
  6182. // reality_price, _ := c.GetFloat("reality_price")
  6183. // found_price, _ := c.GetFloat("found_price")
  6184. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6185. // private_price, _ := c.GetFloat("private_price")
  6186. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6187. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6188. //
  6189. // timeLayout := "2006-01-02"
  6190. // loc, _ := time.LoadLocation("Local")
  6191. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6192. // if err != nil {
  6193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6194. // return
  6195. // }
  6196. // recordDateTime := theTime.Unix()
  6197. // adminUser := c.GetAdminUserInfo()
  6198. //
  6199. // var prescriptions []*models.HisPrescription
  6200. //
  6201. // data := make(map[string]interface{})
  6202. // if settle_accounts_type == 1 { //日结
  6203. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6204. // data["pre"] = prescriptions
  6205. //
  6206. // } else { //月结
  6207. // start_time_str := c.GetString("start_time")
  6208. // end_time_str := c.GetString("end_time")
  6209. // timeLayout := "2006-01-02"
  6210. // loc, _ := time.LoadLocation("Local")
  6211. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6212. // if err != nil {
  6213. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6214. // return
  6215. // }
  6216. // recordStartTime := theStartTime.Unix()
  6217. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6218. // if err != nil {
  6219. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6220. // return
  6221. // }
  6222. // recordEndTime := theEndTime.Unix()
  6223. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6224. // data["pre"] = prescriptions
  6225. //
  6226. // }
  6227. //
  6228. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6229. //
  6230. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6231. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6232. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6233. // strconv.FormatInt(his.PatientId, 10)
  6234. //
  6235. // order_src, _ := service.GetHisOrderByID(order_id)
  6236. //
  6237. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6238. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6239. //
  6240. // var total float64
  6241. // for _, item := range prescriptions {
  6242. // if item.Type == 1 { //药品
  6243. // for _, subItem := range item.HisDoctorAdviceInfo {
  6244. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6245. // }
  6246. // }
  6247. // if item.Type == 2 { //项目
  6248. // for _, subItem := range item.HisPrescriptionProject {
  6249. // total = total + (subItem.Price * float64(subItem.Count))
  6250. // }
  6251. // }
  6252. // }
  6253. //
  6254. // for _, item := range prescriptions {
  6255. // for _, subItem := range item.HisAdditionalCharge {
  6256. // total = total + (subItem.Price * float64(subItem.Count))
  6257. // }
  6258. // }
  6259. //
  6260. // allTotal := fmt.Sprintf("%.2f", total)
  6261. // var rf []*ResultFive
  6262. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6263. // psn_no := order_src.PsnNo
  6264. // mdtrt_id := order_src.MdtrtId
  6265. // chrg_bchno := order_src.Number
  6266. // cert_no := order_src.Certno
  6267. // insutype := rf[0].Insutype
  6268. //
  6269. // if his.IdCardType == 1 {
  6270. // cert_no = his.MedicalInsuranceNumber
  6271. // } else {
  6272. // cert_no = his.Certno
  6273. // }
  6274. //
  6275. // 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)
  6276. // var dat map[string]interface{}
  6277. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6278. // fmt.Println(dat)
  6279. // } else {
  6280. // fmt.Println(err)
  6281. // }
  6282. //
  6283. // userJSONBytes, _ := json.Marshal(dat)
  6284. //
  6285. //
  6286. //
  6287. // var res ResultSeven
  6288. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6289. // utils.ErrorLog("解析失败:%v", err)
  6290. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6291. // return
  6292. // }
  6293. // if res.Infcode == -1 {
  6294. // errlog := &models.HisOrderError{
  6295. // UserOrgId: adminUser.CurrentOrgId,
  6296. // Ctime: time.Now().Unix(),
  6297. // Mtime: time.Now().Unix(),
  6298. // Number: chrg_bchno,
  6299. // ErrMsg: res.ErrMsg,
  6300. // Status: 1,
  6301. // PatientId: id,
  6302. // RecordTime: recordDateTime,
  6303. // Stage: 6,
  6304. // }
  6305. // service.CreateErrMsgLog(errlog)
  6306. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6307. // return
  6308. // } else {
  6309. // order_src.OrderStatus = 2
  6310. // order_src.PayWay = pay_way
  6311. // order_src.PayPrice = pay_price
  6312. // order_src.PayCardNo = pay_card_no
  6313. // order_src.DiscountPrice = discount_price
  6314. // order_src.PreferentialPrice = preferential_price
  6315. // order_src.RealityPrice = reality_price
  6316. // order_src.FoundPrice = found_price
  6317. // order_src.MedicalInsurancePrice = medical_insurance_price
  6318. // order_src.PrivatePrice = private_price
  6319. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  6320. // order_src.SetlId = res.Output.Setlinfo.SetlID
  6321. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  6322. // order_src.PsnName = res.Output.Setlinfo.PsnName
  6323. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  6324. // order_src.Certno = res.Output.Setlinfo.Certno
  6325. // order_src.Gend = res.Output.Setlinfo.Gend
  6326. // order_src.Naty = res.Output.Setlinfo.Naty
  6327. // order_src.Age = res.Output.Setlinfo.Age
  6328. // order_src.Insutype = res.Output.Setlinfo.Insutype
  6329. // order_src.PsnType = res.Output.Setlinfo.PsnType
  6330. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6331. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  6332. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6333. // order_src.MedType = res.Output.Setlinfo.MedType
  6334. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6335. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6336. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6337. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6338. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6339. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6340. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  6341. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  6342. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6343. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  6344. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  6345. // order_src.MafPay = res.Output.Setlinfo.MafPay
  6346. // order_src.OthPay = res.Output.Setlinfo.OthPay
  6347. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6348. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6349. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  6350. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6351. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6352. // order_src.Balc = res.Output.Setlinfo.Balc
  6353. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6354. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6355. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  6356. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  6357. // order_src.Creator = order_src.Creator
  6358. // order_src.Modify = roles.ID
  6359. // order_src.RequestLog = src_resquest
  6360. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6361. // detailStr := string(setlDetail)
  6362. // order_src.SetlDetail = detailStr
  6363. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6364. // err = service.UpDateOrder(order_src)
  6365. //
  6366. // if err == nil {
  6367. // c.ServeSuccessJSON(map[string]interface{}{
  6368. // "msg": "结算成功",
  6369. // })
  6370. // } else {
  6371. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6372. // return
  6373. // }
  6374. // }
  6375. // }
  6376. //}
  6377. //退款
  6378. func (c *HisApiController) Refund() {
  6379. order_id, _ := c.GetInt64("order_id")
  6380. admin_user_id, _ := c.GetInt64("admin_user_id")
  6381. adminUser := c.GetAdminUserInfo()
  6382. var order models.HisOrder
  6383. order, _ = service.GetHisOrderByID(order_id)
  6384. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6385. if order.ID == 0 {
  6386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6387. return
  6388. }
  6389. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6390. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6391. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6392. if config.IsOpen == 1 { //对接了医保,走医保流程
  6393. var res ResultSixteen
  6394. var resSixteen10265 ResultSixteen10265
  6395. var src_resquest string
  6396. var result string
  6397. if miConfig.MdtrtareaAdmvs == "421300" {
  6398. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  6399. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6400. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6401. resp3, requestErr3 := http.Get(api3)
  6402. if requestErr3 != nil {
  6403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6404. return
  6405. }
  6406. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6407. if ioErr3 != nil {
  6408. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6410. return
  6411. }
  6412. var respJSON3 map[string]interface{}
  6413. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6414. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6416. return
  6417. }
  6418. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6419. userJSONBytes3, _ := json.Marshal(respJSON3)
  6420. fmt.Println("log")
  6421. fmt.Println(string(userJSONBytes3))
  6422. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  6423. utils.ErrorLog("解析失败:%v", err)
  6424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6425. return
  6426. }
  6427. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6428. api3 := "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6429. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6430. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6431. resp3, requestErr3 := http.Get(api3)
  6432. if requestErr3 != nil {
  6433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6434. return
  6435. }
  6436. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6437. if ioErr3 != nil {
  6438. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6440. return
  6441. }
  6442. var respJSON3 map[string]interface{}
  6443. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6446. return
  6447. }
  6448. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6449. userJSONBytes3, _ := json.Marshal(respJSON3)
  6450. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  6451. utils.ErrorLog("解析失败:%v", err)
  6452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6453. return
  6454. }
  6455. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6456. res.Output = resSixteen10265.Output
  6457. res.ErrMsg = resSixteen10265.ErrMsg
  6458. res.Cainfo = resSixteen10265.Cainfo
  6459. res.WarnMsg = resSixteen10265.WarnMsg
  6460. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6461. res.Infcode = infocode
  6462. } else {
  6463. if miConfig.Code == "H15049901371" {
  6464. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6465. var dat map[string]interface{}
  6466. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6467. fmt.Println(dat)
  6468. } else {
  6469. fmt.Println(err)
  6470. }
  6471. saveLog(result, src_resquest, "2208", "退费")
  6472. userJSONBytes, _ := json.Marshal(dat)
  6473. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  6474. utils.ErrorLog("解析失败:%v", err)
  6475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6476. return
  6477. }
  6478. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6479. res.Output = resSixteen10265.Output
  6480. res.ErrMsg = resSixteen10265.ErrMsg
  6481. res.Cainfo = resSixteen10265.Cainfo
  6482. res.WarnMsg = resSixteen10265.WarnMsg
  6483. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6484. res.Infcode = infocode
  6485. } else {
  6486. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6487. var dat map[string]interface{}
  6488. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6489. fmt.Println(dat)
  6490. } else {
  6491. fmt.Println(err)
  6492. }
  6493. saveLog(result, src_resquest, "2208", "退费")
  6494. userJSONBytes, _ := json.Marshal(dat)
  6495. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6496. utils.ErrorLog("解析失败:%v", err)
  6497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6498. return
  6499. }
  6500. }
  6501. }
  6502. if res.Infcode == 0 {
  6503. var res2 ResultSix
  6504. var resSix10265 ResultSix10265
  6505. if miConfig.MdtrtareaAdmvs == "421300" {
  6506. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6507. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6508. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6509. resp3, requestErr3 := http.Get(api3)
  6510. if requestErr3 != nil {
  6511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6512. return
  6513. }
  6514. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6515. if ioErr3 != nil {
  6516. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6518. return
  6519. }
  6520. var respJSON3 map[string]interface{}
  6521. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6522. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6524. return
  6525. }
  6526. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6527. userJSONBytes3, _ := json.Marshal(respJSON3)
  6528. fmt.Println("log")
  6529. fmt.Println(string(userJSONBytes3))
  6530. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6531. utils.ErrorLog("解析失败:%v", err)
  6532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6533. return
  6534. }
  6535. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6536. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6537. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6538. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6539. resp3, requestErr3 := http.Get(api3)
  6540. if requestErr3 != nil {
  6541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6542. return
  6543. }
  6544. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6545. if ioErr3 != nil {
  6546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6548. return
  6549. }
  6550. var respJSON3 map[string]interface{}
  6551. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6554. return
  6555. }
  6556. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6557. userJSONBytes3, _ := json.Marshal(respJSON3)
  6558. fmt.Println("log")
  6559. fmt.Println(string(userJSONBytes3))
  6560. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6561. utils.ErrorLog("解析失败:%v", err)
  6562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6563. return
  6564. }
  6565. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6566. res2.Output = resSix10265.Output
  6567. res2.ErrMsg = resSix10265.ErrMsg
  6568. res2.Cainfo = resSix10265.Cainfo
  6569. res2.WarnMsg = resSix10265.WarnMsg
  6570. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6571. res2.Infcode = infocode
  6572. } else {
  6573. if miConfig.Code == "H15049901371" {
  6574. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6575. var dat map[string]interface{}
  6576. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6577. fmt.Println(dat)
  6578. } else {
  6579. fmt.Println(err)
  6580. }
  6581. saveLog(result2, src_request, "2205", "撤销明细")
  6582. userJSONBytes, _ := json.Marshal(dat)
  6583. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6584. utils.ErrorLog("解析失败:%v", err)
  6585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6586. return
  6587. }
  6588. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6589. res2.Output = resSix10265.Output
  6590. res2.ErrMsg = resSix10265.ErrMsg
  6591. res2.Cainfo = resSix10265.Cainfo
  6592. res2.WarnMsg = resSix10265.WarnMsg
  6593. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6594. res2.Infcode = infocode
  6595. } else {
  6596. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6597. var dat map[string]interface{}
  6598. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6599. fmt.Println(dat)
  6600. } else {
  6601. fmt.Println(err)
  6602. }
  6603. saveLog(result2, src_request, "2205", "撤销明细")
  6604. userJSONBytes, _ := json.Marshal(dat)
  6605. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6606. utils.ErrorLog("解析失败:%v", err)
  6607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6608. return
  6609. }
  6610. }
  6611. }
  6612. if res2.Infcode == 0 {
  6613. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  6614. if err == nil {
  6615. c.ServeSuccessJSON(map[string]interface{}{
  6616. "msg": "退费成功",
  6617. })
  6618. } else {
  6619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6620. return
  6621. }
  6622. } else {
  6623. c.ServeSuccessJSON(map[string]interface{}{
  6624. "code": -10,
  6625. "msg": res2.ErrMsg,
  6626. })
  6627. }
  6628. } else {
  6629. c.ServeSuccessJSON(map[string]interface{}{
  6630. "code": -10,
  6631. "msg": res.ErrMsg,
  6632. })
  6633. }
  6634. }
  6635. }
  6636. func (c *HisApiController) RefundNumber() {
  6637. record_time := c.GetString("record_time")
  6638. //patient_id, _ := c.GetInt64("patient_id")
  6639. admin_user_id, _ := c.GetInt64("admin_user_id")
  6640. his_patient_id, _ := c.GetInt64("id")
  6641. timeLayout := "2006-01-02"
  6642. loc, _ := time.LoadLocation("Local")
  6643. adminUser := c.GetAdminUserInfo()
  6644. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6645. fmt.Println(err)
  6646. if err != nil {
  6647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6648. return
  6649. }
  6650. recordDateTime := theTime.Unix()
  6651. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6652. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  6653. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6654. //order, _ := service.GetHisOrderByID(order_id)
  6655. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6656. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6657. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6658. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  6659. if count > 0 {
  6660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  6661. return
  6662. }
  6663. if config.IsOpen == 1 { //对接了医保,走医保流程
  6664. var res2 ResultSix
  6665. var resSix10265 ResultSix10265
  6666. if miConfig.MdtrtareaAdmvs == "421300" {
  6667. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  6668. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6669. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6670. resp3, requestErr3 := http.Get(api3)
  6671. if requestErr3 != nil {
  6672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6673. return
  6674. }
  6675. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6676. if ioErr3 != nil {
  6677. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6679. return
  6680. }
  6681. var respJSON3 map[string]interface{}
  6682. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6685. return
  6686. }
  6687. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6688. userJSONBytes3, _ := json.Marshal(respJSON3)
  6689. fmt.Println("log")
  6690. fmt.Println(string(userJSONBytes3))
  6691. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6692. utils.ErrorLog("解析失败:%v", err)
  6693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6694. return
  6695. }
  6696. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6697. api3 := "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6698. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6699. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6700. resp3, requestErr3 := http.Get(api3)
  6701. if requestErr3 != nil {
  6702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6703. return
  6704. }
  6705. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6706. if ioErr3 != nil {
  6707. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6709. return
  6710. }
  6711. var respJSON3 map[string]interface{}
  6712. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6713. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6715. return
  6716. }
  6717. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6718. userJSONBytes3, _ := json.Marshal(respJSON3)
  6719. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6720. utils.ErrorLog("解析失败:%v", err)
  6721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6722. return
  6723. }
  6724. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6725. res2.Output = resSix10265.Output
  6726. res2.ErrMsg = resSix10265.ErrMsg
  6727. res2.Cainfo = resSix10265.Cainfo
  6728. res2.WarnMsg = resSix10265.WarnMsg
  6729. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6730. res2.Infcode = infocode
  6731. } else {
  6732. var api3 string
  6733. if miConfig.Code == "H15049901371" {
  6734. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6735. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6736. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6737. } else {
  6738. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6739. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6740. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6741. }
  6742. resp3, requestErr3 := http.Get(api3)
  6743. if requestErr3 != nil {
  6744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6745. return
  6746. }
  6747. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6748. if ioErr3 != nil {
  6749. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6751. return
  6752. }
  6753. var respJSON3 map[string]interface{}
  6754. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6757. return
  6758. }
  6759. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6760. userJSONBytes3, _ := json.Marshal(respJSON3)
  6761. if miConfig.Code == "H15049901371" {
  6762. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6763. utils.ErrorLog("解析失败:%v", err)
  6764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6765. return
  6766. }
  6767. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6768. res2.Output = resSix10265.Output
  6769. res2.ErrMsg = resSix10265.ErrMsg
  6770. res2.Cainfo = resSix10265.Cainfo
  6771. res2.WarnMsg = resSix10265.WarnMsg
  6772. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6773. res2.Infcode = infocode
  6774. } else {
  6775. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6776. utils.ErrorLog("解析失败:%v", err)
  6777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6778. return
  6779. }
  6780. }
  6781. }
  6782. if res2.Infcode == 0 {
  6783. if err == nil {
  6784. c.ServeSuccessJSON(map[string]interface{}{
  6785. "msg": "退号成功",
  6786. })
  6787. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  6788. } else {
  6789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6790. return
  6791. }
  6792. } else {
  6793. c.ServeSuccessJSON(map[string]interface{}{
  6794. "code": -10,
  6795. "msg": res2.ErrMsg,
  6796. })
  6797. }
  6798. } else {
  6799. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  6800. //if err == nil {
  6801. // c.ServeSuccessJSON(map[string]interface{}{
  6802. // "msg": "退费成功",
  6803. // })
  6804. //} else {
  6805. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6806. // return
  6807. //}
  6808. }
  6809. }
  6810. func (c *HisApiController) RefundDetail() {
  6811. order_id, _ := c.GetInt64("order_id")
  6812. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6813. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6814. number := c.GetString("number")
  6815. record_time := c.GetString("record_time")
  6816. patient_id, _ := c.GetInt64("patient_id")
  6817. timeLayout := "2006-01-02"
  6818. loc, _ := time.LoadLocation("Local")
  6819. adminUser := c.GetAdminUserInfo()
  6820. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6821. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6822. fmt.Println(err)
  6823. if err != nil {
  6824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6825. return
  6826. }
  6827. recordDateTime := theTime.Unix()
  6828. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6829. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6830. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6831. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6832. var order models.HisOrder
  6833. order, _ = service.GetHisOrderByID(order_id)
  6834. if order.ID == 0 {
  6835. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  6836. }
  6837. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6838. if config.IsOpen == 1 { //对接了医保,走医保流程
  6839. var res2 ResultSix
  6840. if miConfig.MdtrtareaAdmvs == "421300" {
  6841. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6842. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6843. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6844. resp3, requestErr3 := http.Get(api3)
  6845. if requestErr3 != nil {
  6846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6847. return
  6848. }
  6849. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6850. if ioErr3 != nil {
  6851. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6853. return
  6854. }
  6855. var respJSON3 map[string]interface{}
  6856. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6857. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6859. return
  6860. }
  6861. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6862. userJSONBytes3, _ := json.Marshal(respJSON3)
  6863. fmt.Println("log")
  6864. fmt.Println(string(userJSONBytes3))
  6865. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6866. utils.ErrorLog("解析失败:%v", err)
  6867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6868. return
  6869. }
  6870. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6871. if err == nil {
  6872. c.ServeSuccessJSON(map[string]interface{}{
  6873. "msg": "撤销明细成功",
  6874. })
  6875. return
  6876. } else {
  6877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6878. return
  6879. }
  6880. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6881. var resSix10265 ResultSix10265
  6882. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6883. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6884. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6885. resp3, requestErr3 := http.Get(api3)
  6886. if requestErr3 != nil {
  6887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6888. return
  6889. }
  6890. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6891. if ioErr3 != nil {
  6892. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6894. return
  6895. }
  6896. var respJSON3 map[string]interface{}
  6897. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6898. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6900. return
  6901. }
  6902. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6903. userJSONBytes3, _ := json.Marshal(respJSON3)
  6904. fmt.Println("log")
  6905. fmt.Println(string(userJSONBytes3))
  6906. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6907. utils.ErrorLog("解析失败:%v", err)
  6908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6909. return
  6910. }
  6911. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6912. res2.Output = resSix10265.Output
  6913. res2.ErrMsg = resSix10265.ErrMsg
  6914. res2.Cainfo = resSix10265.Cainfo
  6915. res2.WarnMsg = resSix10265.WarnMsg
  6916. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6917. res2.Infcode = infocode
  6918. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6919. if err == nil {
  6920. c.ServeSuccessJSON(map[string]interface{}{
  6921. "msg": "撤销明细成功",
  6922. })
  6923. return
  6924. } else {
  6925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6926. return
  6927. }
  6928. } else {
  6929. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  6930. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6931. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6932. resp2, requestErr2 := http.Get(api2)
  6933. if requestErr2 != nil {
  6934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6935. return
  6936. }
  6937. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6938. if ioErr2 != nil {
  6939. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6941. return
  6942. }
  6943. var respJSON2 map[string]interface{}
  6944. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6945. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6947. return
  6948. }
  6949. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6950. if err == nil {
  6951. c.ServeSuccessJSON(map[string]interface{}{
  6952. "msg": "撤销明细成功",
  6953. })
  6954. return
  6955. } else {
  6956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6957. return
  6958. }
  6959. }
  6960. } else {
  6961. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6962. if err == nil {
  6963. c.ServeSuccessJSON(map[string]interface{}{
  6964. "msg": "退费成功",
  6965. })
  6966. } else {
  6967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6968. return
  6969. }
  6970. }
  6971. }
  6972. //对账
  6973. func (c *HisApiController) GetCheckAccount() {
  6974. start_time := c.GetString("start_time")
  6975. end_time := c.GetString("end_time")
  6976. insutype := c.GetString("insutype")
  6977. clr_type := c.GetString("clr_type")
  6978. clr_org := c.GetString("clr_optins")
  6979. admin_user_id, _ := c.GetInt64("admin_user_id")
  6980. adminUser := c.GetAdminUserInfo()
  6981. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6982. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6983. if len(clr_org) == 0 {
  6984. clr_org = miConfig.MdtrtareaAdmvs
  6985. }
  6986. timeLayout := "2006-01-02"
  6987. loc, _ := time.LoadLocation("Local")
  6988. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6989. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6990. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  6991. fixmedins_setl_cnt := int64(len(orders))
  6992. var medfee_sumamt float64
  6993. var acct_pay float64
  6994. var fund_pay_sumamt float64
  6995. for _, item := range orders {
  6996. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6997. acct_pay = acct_pay + item.AcctPay
  6998. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6999. }
  7000. var user_name string
  7001. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7002. if role.ID == 0 {
  7003. user_name = "xxx"
  7004. } else {
  7005. user_name = role.UserName
  7006. }
  7007. var res ResultEight
  7008. var res10188 ResultEightFor10188
  7009. if config.IsOpen == 1 {
  7010. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7011. api := "http://192.168.3.111:9532/" + "jsyb/3201" +
  7012. "insutype=" + insutype +
  7013. "&clr_type=" + clr_type +
  7014. "&setl_optins=" + clr_org +
  7015. "&stmt_begndate=" + start_time +
  7016. "&stm_enddate=" + end_time +
  7017. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7018. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7019. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7020. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7021. "&fixmedins_code=" + miConfig.Code +
  7022. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7023. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7024. "&secret_key=" + miConfig.SecretKey +
  7025. "&org_name=" + miConfig.OrgName +
  7026. "&doctor=" + user_name +
  7027. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7028. fmt.Println(api)
  7029. resp, requestErr := http.Get(api)
  7030. if requestErr != nil {
  7031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7032. return
  7033. }
  7034. body, ioErr := ioutil.ReadAll(resp.Body)
  7035. fmt.Println(body)
  7036. if ioErr != nil {
  7037. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7039. return
  7040. }
  7041. var respJSON map[string]interface{}
  7042. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7043. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7045. return
  7046. }
  7047. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7048. userJSONBytes, _ := json.Marshal(respJSON)
  7049. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7050. utils.ErrorLog("解析失败:%v", err)
  7051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7052. return
  7053. }
  7054. res.InfRefmsgid = res10188.InfRefmsgid
  7055. res.Output = res10188.Output
  7056. res.ErrMsg = res10188.ErrMsg
  7057. res.Cainfo = res10188.Cainfo
  7058. res.WarnMsg = res10188.WarnMsg
  7059. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  7060. res.Infcode = infocode
  7061. } else {
  7062. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7063. "insutype=" + insutype +
  7064. "&clr_type=" + clr_type +
  7065. "&setl_optins=" + clr_org +
  7066. "&stmt_begndate=" + start_time +
  7067. "&stm_enddate=" + end_time +
  7068. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7069. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7070. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7071. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7072. "&fixmedins_code=" + miConfig.Code +
  7073. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7074. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7075. "&secret_key=" + miConfig.SecretKey +
  7076. "&org_name=" + miConfig.OrgName +
  7077. "&doctor=" + user_name
  7078. fmt.Println(api)
  7079. resp, requestErr := http.Get(api)
  7080. if requestErr != nil {
  7081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7082. return
  7083. }
  7084. body, ioErr := ioutil.ReadAll(resp.Body)
  7085. fmt.Println(body)
  7086. if ioErr != nil {
  7087. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7089. return
  7090. }
  7091. var respJSON map[string]interface{}
  7092. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7095. return
  7096. }
  7097. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7098. userJSONBytes, _ := json.Marshal(respJSON)
  7099. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7100. utils.ErrorLog("解析失败:%v", err)
  7101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7102. return
  7103. }
  7104. }
  7105. if res.Infcode == 0 {
  7106. if res.Output.Stmtinfo.StmtRslt == "0" {
  7107. micc := &models.MedicalInsuranceCostCompare{
  7108. StartTime: startime.Unix(),
  7109. EndTime: endtime.Unix(),
  7110. Insutype: insutype,
  7111. CheckType: 1,
  7112. Num: fixmedins_setl_cnt,
  7113. Mtime: time.Now().Unix(),
  7114. Status: 1,
  7115. UserOrgId: adminUser.CurrentOrgId,
  7116. CostTotal: medfee_sumamt,
  7117. FuncTotal: fund_pay_sumamt,
  7118. PsnPay: acct_pay,
  7119. Creator: admin_user_id,
  7120. Ctime: time.Now().Unix(),
  7121. }
  7122. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  7123. if err == nil {
  7124. c.ServeSuccessJSON(map[string]interface{}{
  7125. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7126. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7127. })
  7128. } else {
  7129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7130. }
  7131. } else {
  7132. c.ServeSuccessJSON(map[string]interface{}{
  7133. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7134. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7135. })
  7136. }
  7137. } else {
  7138. c.ServeSuccessJSON(map[string]interface{}{
  7139. "code": -10,
  7140. "msg": res.ErrMsg,
  7141. })
  7142. }
  7143. }
  7144. }
  7145. func (c *HisApiController) Check310() {
  7146. adminUser := c.GetAdminUserInfo()
  7147. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7148. var user_name string
  7149. user_name = "高慧裕"
  7150. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7151. "insutype=" + "310" +
  7152. "&clr_type=" + "11" +
  7153. "&setl_optins=" + "441202" +
  7154. "&stmt_begndate=" + "2022-03-01" +
  7155. "&stm_enddate=" + "2022-03-31" +
  7156. "&medfee_sumamt=" + "194930.12" +
  7157. "&fund_pay_sumamt=" + "188741.46" +
  7158. "&acct_pay=" + "0" +
  7159. "&fixmedins_setl_cnt=" + "452" +
  7160. "&fixmedins_code=" + miConfig.Code +
  7161. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7162. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7163. "&secret_key=" + miConfig.SecretKey +
  7164. "&org_name=" + miConfig.OrgName +
  7165. "&doctor=" + user_name
  7166. fmt.Println(api)
  7167. resp, requestErr := http.Get(api)
  7168. if requestErr != nil {
  7169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7170. return
  7171. }
  7172. body, ioErr := ioutil.ReadAll(resp.Body)
  7173. fmt.Println(body)
  7174. if ioErr != nil {
  7175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7177. return
  7178. }
  7179. var respJSON map[string]interface{}
  7180. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7183. return
  7184. }
  7185. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7186. userJSONBytes, _ := json.Marshal(respJSON)
  7187. var res ResultEight
  7188. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7189. utils.ErrorLog("解析失败:%v", err)
  7190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7191. return
  7192. }
  7193. }
  7194. func (c *HisApiController) Check390() {
  7195. adminUser := c.GetAdminUserInfo()
  7196. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7197. var user_name string
  7198. user_name = "高慧裕"
  7199. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7200. "insutype=" + "390" +
  7201. "&clr_type=" + "11" +
  7202. "&setl_optins=" + "441202" +
  7203. "&stmt_begndate=" + "2022-03-01" +
  7204. "&stm_enddate=" + "2022-03-31" +
  7205. "&medfee_sumamt=" + "1068448.89" +
  7206. "&fund_pay_sumamt=" + "1014677.62" +
  7207. "&acct_pay=" + "0" +
  7208. "&fixmedins_setl_cnt=" + "1950" +
  7209. "&fixmedins_code=" + miConfig.Code +
  7210. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7211. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7212. "&secret_key=" + miConfig.SecretKey +
  7213. "&org_name=" + miConfig.OrgName +
  7214. "&doctor=" + user_name
  7215. fmt.Println(api)
  7216. resp, requestErr := http.Get(api)
  7217. if requestErr != nil {
  7218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7219. return
  7220. }
  7221. body, ioErr := ioutil.ReadAll(resp.Body)
  7222. fmt.Println(body)
  7223. if ioErr != nil {
  7224. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7226. return
  7227. }
  7228. var respJSON map[string]interface{}
  7229. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7230. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7232. return
  7233. }
  7234. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7235. userJSONBytes, _ := json.Marshal(respJSON)
  7236. var res ResultEight
  7237. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7238. utils.ErrorLog("解析失败:%v", err)
  7239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7240. return
  7241. }
  7242. }
  7243. //对账明细
  7244. func (c *HisApiController) GetCheckDetailAccount() {
  7245. start_time := c.GetString("start_time")
  7246. end_time := c.GetString("end_time")
  7247. admin_user_id, _ := c.GetInt64("admin_user_id")
  7248. adminUser := c.GetAdminUserInfo()
  7249. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7250. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7251. timeLayout := "2006-01-02"
  7252. loc, _ := time.LoadLocation("Local")
  7253. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7254. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7255. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  7256. Mkdir(miConfig.OrgName)
  7257. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  7258. file_name := file + ".txt"
  7259. zip_name := file + ".zip"
  7260. zip_path := miConfig.OrgName + "/" + zip_name
  7261. file_path := miConfig.OrgName + "/" + file_name
  7262. decimal.DivisionPrecision = 2
  7263. var medfee_sumamt float64
  7264. var psn_cash_pay float64
  7265. var fund_pay_sumamt float64
  7266. fixmedins_setl_cnt := int64(len(orders))
  7267. for _, item := range orders {
  7268. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7269. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  7270. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7271. }
  7272. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  7273. defer f.Close()
  7274. if err != nil {
  7275. fmt.Println(err.Error())
  7276. } else {
  7277. for _, item := range orders {
  7278. var refd_setl_flag string
  7279. if item.OrderStatus == 2 {
  7280. refd_setl_flag = "0"
  7281. var str string
  7282. str = item.SetlId + " " +
  7283. item.MdtrtId + " " +
  7284. item.PsnNo + " " +
  7285. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7286. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7287. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  7288. _, err = f.Write([]byte(str))
  7289. }
  7290. if item.OrderStatus == 3 {
  7291. var str string
  7292. str = item.SetlId + " " +
  7293. item.MdtrtId + " " +
  7294. item.PsnNo + " " +
  7295. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7296. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7297. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  7298. _, err = f.Write([]byte(str))
  7299. var str2 string
  7300. str2 = item.SetlId + " " +
  7301. item.MdtrtId + " " +
  7302. item.PsnNo + " " +
  7303. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  7304. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  7305. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  7306. _, err = f.Write([]byte(str2))
  7307. }
  7308. }
  7309. }
  7310. Zip(file_path, zip_path)
  7311. fmt.Println(ReadFile(zip_path))
  7312. fmt.Println(string(ReadFile(zip_path)))
  7313. if config.IsOpen == 1 {
  7314. var user_name string
  7315. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7316. if role.ID == 0 {
  7317. user_name = "管理员"
  7318. } else {
  7319. user_name = role.UserName
  7320. }
  7321. baseParams := models.BaseParams{
  7322. SecretKey: miConfig.SecretKey,
  7323. FixmedinsCode: miConfig.Code,
  7324. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7325. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7326. OrgName: miConfig.OrgName,
  7327. Doctor: user_name,
  7328. }
  7329. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  7330. var dat map[string]interface{}
  7331. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7332. fmt.Println(dat)
  7333. } else {
  7334. fmt.Println(err)
  7335. }
  7336. userJSONBytes, _ := json.Marshal(dat)
  7337. var res ResultNine
  7338. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7339. utils.ErrorLog("解析失败:%v", err)
  7340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7341. return
  7342. }
  7343. if res.Infcode == 0 {
  7344. fileNo := res.Output.FileQuryNo
  7345. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  7346. "file_qury_no=" + fileNo +
  7347. "&setl_optins=" + "定点医保中心" +
  7348. "&stmt_begndate=" + start_time +
  7349. "&stm_enddate=" + end_time +
  7350. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7351. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7352. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  7353. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7354. "&fixmedins_code=" + miConfig.Code +
  7355. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7356. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7357. "&secret_key=" + miConfig.SecretKey +
  7358. "&org_name=" + miConfig.OrgName +
  7359. "&doctor=" + user_name
  7360. resp, requestErr := http.Get(api)
  7361. if requestErr != nil {
  7362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7363. return
  7364. }
  7365. body, ioErr := ioutil.ReadAll(resp.Body)
  7366. if ioErr != nil {
  7367. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7369. return
  7370. }
  7371. var respJSON map[string]interface{}
  7372. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7373. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7375. return
  7376. }
  7377. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7378. userJSONBytes, _ := json.Marshal(respJSON)
  7379. var res ResultTen
  7380. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7381. utils.ErrorLog("解析失败:%v", err)
  7382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7383. return
  7384. }
  7385. if res.Infcode == 0 {
  7386. service.Gdyb9102(baseParams, zip_name, fileNo)
  7387. micc := &models.MedicalInsuranceCostCompare{
  7388. StartTime: startime.Unix(),
  7389. EndTime: endtime.Unix(),
  7390. Insutype: "0",
  7391. CheckType: 2,
  7392. Num: fixmedins_setl_cnt,
  7393. Mtime: time.Now().Unix(),
  7394. Status: 1,
  7395. UserOrgId: adminUser.CurrentOrgId,
  7396. CostTotal: medfee_sumamt,
  7397. FuncTotal: fund_pay_sumamt,
  7398. PsnPay: psn_cash_pay,
  7399. Creator: admin_user_id,
  7400. Ctime: time.Now().Unix(),
  7401. }
  7402. service.CreateMedicalInsuranceCostCompareRecord(micc)
  7403. c.ServeSuccessJSON(map[string]interface{}{
  7404. "msg": "明细对账成功",
  7405. })
  7406. }
  7407. } else {
  7408. }
  7409. }
  7410. }
  7411. type CustomOrderInfo struct {
  7412. Name string
  7413. Spec string
  7414. Unit string
  7415. Count float64
  7416. Price float64
  7417. Total float64
  7418. }
  7419. func (c *HisApiController) GetSettleAccounts() {
  7420. //id, _ := c.GetInt64("id")
  7421. //record_time := c.GetString("record_time")
  7422. order_id, _ := c.GetInt64("order_id")
  7423. admin_user_id, _ := c.GetInt64("admin_user_id")
  7424. //timeLayout := "2006-01-02"
  7425. //loc, _ := time.LoadLocation("Local")
  7426. //
  7427. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7428. //if err != nil {
  7429. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7430. // return
  7431. //}
  7432. //recordDateTime := theTime.Unix()
  7433. adminUser := c.GetAdminUserInfo()
  7434. order, _ := service.GetHisOrderByID(order_id)
  7435. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7436. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  7437. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  7438. orderInfos = append(orderInfos, orderInfos_two...)
  7439. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  7440. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7441. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  7442. //var config []*models.HisXtDiagnoseConfig
  7443. var name string
  7444. for _, item := range diagnosis_ids {
  7445. id, _ := strconv.ParseInt(item, 10, 64)
  7446. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7447. if len(name) == 0 {
  7448. name = diagnosisConfig.ClassName
  7449. } else {
  7450. name = name + "," + diagnosisConfig.ClassName
  7451. }
  7452. }
  7453. var bedCostTotal float64 = 0 //床位总费
  7454. var bedCostSelfTotal float64 = 0 //床位自费
  7455. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7456. var operationCostTotal float64 = 0 //手术费
  7457. var operationCostSelfTotal float64 = 0 //手术费
  7458. var operationCostPartSelfTotal float64 = 0 //手术费
  7459. var otherCostTotal float64 = 0 //其他费用
  7460. var otherCostSelfTotal float64 = 0 //其他费用
  7461. var otherCostPartSelfTotal float64 = 0 //其他费用
  7462. var materialCostTotal float64 = 0 //材料费
  7463. var materialCostSelfTotal float64 = 0 //材料费
  7464. var materialCostPartSelfTotal float64 = 0 //材料费
  7465. var westernMedicineCostTotal float64 = 0 //西药费
  7466. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7467. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7468. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7469. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7470. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7471. var checkCostTotal float64 = 0 //检查费
  7472. var checkCostSelfTotal float64 = 0 //检查费
  7473. var checkCostPartSelfTotal float64 = 0 //检查费
  7474. var laboratoryCostTotal float64 = 0 //化验费
  7475. var laboratoryCostSelfTotal float64 = 0 //化验费
  7476. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7477. var treatCostTotal float64 = 0 //治疗费用
  7478. var treatCostSelfTotal float64 = 0 //治疗费用
  7479. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7480. decimal.DivisionPrecision = 2
  7481. for _, item := range orderInfos {
  7482. if item.MedChrgitmType == "01" { //床位费
  7483. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7484. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7485. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7486. }
  7487. if item.MedChrgitmType == "03" { //检查费
  7488. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7489. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7490. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7491. }
  7492. if item.MedChrgitmType == "04" { //化验费
  7493. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7494. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7495. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7496. }
  7497. if item.MedChrgitmType == "05" || item.MedChrgitmType == "05" || item.MedChrgitmType == "05" { //治疗费
  7498. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7499. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7500. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7501. }
  7502. if item.MedChrgitmType == "06" { //手术费
  7503. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7504. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7505. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7506. }
  7507. if item.MedChrgitmType == "08" { //材料费
  7508. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7509. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7510. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7511. }
  7512. if item.MedChrgitmType == "09" { //西药费
  7513. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7514. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7515. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7516. }
  7517. if item.MedChrgitmType == "11" { //中成费
  7518. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7519. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7520. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7521. }
  7522. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  7523. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7524. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7525. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7526. }
  7527. }
  7528. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7529. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7530. var user_name string
  7531. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7532. if role.ID == 0 {
  7533. user_name = "管理员"
  7534. } else {
  7535. user_name = role.UserName
  7536. }
  7537. baseParams := models.BaseParams{
  7538. SecretKey: miConfig.SecretKey,
  7539. FixmedinsCode: miConfig.Code,
  7540. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7541. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7542. OrgName: miConfig.OrgName,
  7543. Doctor: user_name,
  7544. }
  7545. businessParams := models.BusinessParams{
  7546. PsnNo: order.PsnNo,
  7547. MdtrtId: order.MdtrtId,
  7548. SetlId: order.SetlId,
  7549. }
  7550. var res ResultEleven
  7551. var resEleven10265 ResultEleven10265
  7552. if config.IsOpen == 1 {
  7553. if miConfig.MdtrtareaAdmvs == "421300" {
  7554. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7555. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7556. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7557. resp, requestErr := http.Get(api)
  7558. if requestErr != nil {
  7559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7560. return
  7561. }
  7562. body, ioErr := ioutil.ReadAll(resp.Body)
  7563. if ioErr != nil {
  7564. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7566. return
  7567. }
  7568. var respJSON map[string]interface{}
  7569. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7572. return
  7573. }
  7574. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7575. result, _ := json.Marshal(respJSON)
  7576. fmt.Println("log")
  7577. fmt.Println(string(result))
  7578. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7579. utils.ErrorLog("解析失败:%v", err)
  7580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7581. return
  7582. }
  7583. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7584. api := "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7585. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7586. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7587. resp, requestErr := http.Get(api)
  7588. if requestErr != nil {
  7589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7590. return
  7591. }
  7592. body, ioErr := ioutil.ReadAll(resp.Body)
  7593. if ioErr != nil {
  7594. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7596. return
  7597. }
  7598. var respJSON map[string]interface{}
  7599. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7600. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7602. return
  7603. }
  7604. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7605. result, _ := json.Marshal(respJSON)
  7606. fmt.Println("log")
  7607. fmt.Println(string(result))
  7608. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  7609. utils.ErrorLog("解析失败:%v", err)
  7610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7611. return
  7612. }
  7613. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7614. res.Output = resEleven10265.Output
  7615. res.ErrMsg = resEleven10265.ErrMsg
  7616. res.Cainfo = resEleven10265.Cainfo
  7617. res.WarnMsg = resEleven10265.WarnMsg
  7618. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7619. res.Infcode = infocode
  7620. } else {
  7621. result2 := service.Gdyb5204(baseParams, businessParams)
  7622. saveLog(result2, "", "5204", "查询")
  7623. result := service.Gdyb5203(baseParams, businessParams)
  7624. var dat map[string]interface{}
  7625. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7626. fmt.Println(dat)
  7627. } else {
  7628. fmt.Println(err)
  7629. }
  7630. userJSONBytes, _ := json.Marshal(dat)
  7631. if miConfig.Code == "H15049901371" {
  7632. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  7633. utils.ErrorLog("解析失败:%v", err)
  7634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7635. return
  7636. }
  7637. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7638. res.Output = resEleven10265.Output
  7639. res.ErrMsg = resEleven10265.ErrMsg
  7640. res.Cainfo = resEleven10265.Cainfo
  7641. res.WarnMsg = resEleven10265.WarnMsg
  7642. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7643. res.Infcode = infocode
  7644. } else {
  7645. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7646. utils.ErrorLog("解析失败:%v", err)
  7647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7648. return
  7649. }
  7650. }
  7651. }
  7652. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7653. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  7654. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  7655. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7656. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7657. var doctor_name string
  7658. if roles.ID == 0 {
  7659. doctor_name = "管理员"
  7660. } else {
  7661. doctor_name = roles.UserName
  7662. }
  7663. yiliao_leibie := ""
  7664. switch order.MedType {
  7665. case "11":
  7666. yiliao_leibie = "普通门诊"
  7667. break
  7668. case "12":
  7669. yiliao_leibie = "门诊挂号"
  7670. break
  7671. case "13":
  7672. yiliao_leibie = "急诊"
  7673. break
  7674. case "14":
  7675. yiliao_leibie = "门诊特殊病"
  7676. break
  7677. case "15":
  7678. yiliao_leibie = "门诊统筹"
  7679. break
  7680. case "16":
  7681. yiliao_leibie = "门诊慢性病"
  7682. break
  7683. case "21":
  7684. yiliao_leibie = "普通住院"
  7685. break
  7686. }
  7687. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7688. if res.Infcode == 0 {
  7689. c.ServeSuccessJSON(map[string]interface{}{
  7690. "diagnosis": name,
  7691. "order_infos": orderInfos,
  7692. "number": order.MdtrtId,
  7693. "date": order.SettleAccountsDate,
  7694. "charge_admin": charge_admin,
  7695. "printor_admin": printor_admin,
  7696. "info": res.Output.Setlinfo,
  7697. "bedCostTotal": bedCostTotal,
  7698. "bedCostSelfTotal": bedCostSelfTotal,
  7699. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  7700. "operationCostTotal": operationCostTotal,
  7701. "operationCostSelfTotal": operationCostSelfTotal,
  7702. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  7703. "otherCostTotal": otherCostTotal,
  7704. "otherCostSelfTotal": otherCostSelfTotal,
  7705. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  7706. "materialCostTotal": materialCostTotal,
  7707. "materialCostSelfTotal": materialCostSelfTotal,
  7708. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  7709. "westernMedicineCostTotal": westernMedicineCostTotal,
  7710. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  7711. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  7712. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  7713. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  7714. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  7715. "checkCostTotal": checkCostTotal,
  7716. "checkCostSelfTotal": checkCostSelfTotal,
  7717. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  7718. "laboratoryCostTotal": laboratoryCostTotal,
  7719. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  7720. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  7721. "treatCostTotal": treatCostTotal,
  7722. "treatCostSelfTotal": treatCostSelfTotal,
  7723. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  7724. "doctor_code": adminRole_two.DoctorCode,
  7725. "doctor_name": doctor_name,
  7726. "health_card_no": order.PsnNo,
  7727. "department": departments.Name,
  7728. "yiliao_leibie": yiliao_leibie,
  7729. "after_money": order.AccountPrice,
  7730. "patient": patient,
  7731. "org_name": miConfig.OrgName,
  7732. "org_code": miConfig.Code,
  7733. "order_number": order.Number,
  7734. //"check_order_info": cus_slice,
  7735. })
  7736. }
  7737. }
  7738. }
  7739. func (c *HisApiController) CheckTreatment() {
  7740. patient_id, _ := c.GetInt64("patient_id")
  7741. id_card_no := c.GetString("id_card_no")
  7742. insutype := c.GetString("insutype")
  7743. med_type := c.GetString("med_type")
  7744. admin_user_id, _ := c.GetInt64("admin_user_id")
  7745. adminUser := c.GetAdminUserInfo()
  7746. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7747. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7748. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7749. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7750. if miConfig.MdtrtareaAdmvs == "421300" {
  7751. var res ResultTwo
  7752. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7753. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7754. "&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)
  7755. resp, requestErr := http.Get(api)
  7756. if requestErr != nil {
  7757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7758. return
  7759. }
  7760. body, ioErr := ioutil.ReadAll(resp.Body)
  7761. if ioErr != nil {
  7762. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7764. return
  7765. }
  7766. var respJSON map[string]interface{}
  7767. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7770. return
  7771. }
  7772. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7773. result, _ := json.Marshal(respJSON)
  7774. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7775. utils.ErrorLog("解析失败:%v", err)
  7776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7777. return
  7778. }
  7779. if res.Infcode == 0 {
  7780. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  7781. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7782. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  7783. resp, requestErr := http.Get(api)
  7784. if requestErr != nil {
  7785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7786. return
  7787. }
  7788. body, ioErr := ioutil.ReadAll(resp.Body)
  7789. if ioErr != nil {
  7790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7792. return
  7793. }
  7794. var respJSON map[string]interface{}
  7795. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7798. return
  7799. }
  7800. var res Result2001
  7801. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7802. result2, _ := json.Marshal(respJSON)
  7803. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  7804. utils.ErrorLog("解析失败:%v", err)
  7805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7806. return
  7807. }
  7808. if res.Infcode == 0 {
  7809. c.ServeSuccessJSON(map[string]interface{}{
  7810. "msg": res.Output.Trtinfo,
  7811. })
  7812. }
  7813. } else {
  7814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7815. return
  7816. }
  7817. } else {
  7818. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7819. var dat map[string]interface{}
  7820. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7821. fmt.Println(dat)
  7822. } else {
  7823. fmt.Println(err)
  7824. }
  7825. userJSONBytes, _ := json.Marshal(dat)
  7826. var res ResultTwo
  7827. var res10265 ResultTwo10265
  7828. if miConfig.Code == "H15049901371" {
  7829. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7830. utils.ErrorLog("解析失败:%v", err)
  7831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7832. return
  7833. }
  7834. res.ErrMsg = res10265.ErrMsg
  7835. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7836. res.Infcode = infocode
  7837. res.Output = res10265.Output
  7838. res.InfRefmsgid = res10265.InfRefmsgid
  7839. } else {
  7840. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7841. utils.ErrorLog("解析失败:%v", err)
  7842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7843. return
  7844. }
  7845. }
  7846. var user_name string
  7847. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  7848. if role.ID == 0 {
  7849. user_name = "xxx"
  7850. } else {
  7851. user_name = role.UserName
  7852. }
  7853. baseParams := models.BaseParams{
  7854. SecretKey: miConfig.SecretKey,
  7855. FixmedinsCode: miConfig.Code,
  7856. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7857. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7858. OrgName: miConfig.OrgName,
  7859. Doctor: user_name,
  7860. }
  7861. if config.IsOpen == 1 {
  7862. if miConfig.Code == "H15049901371" {
  7863. if med_type == "14" {
  7864. if insutype == "390" {
  7865. med_type = "9933"
  7866. } else if insutype == "310" {
  7867. med_type = "990502"
  7868. }
  7869. } else if med_type == "11" {
  7870. med_type = "11"
  7871. }
  7872. }
  7873. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  7874. var dat map[string]interface{}
  7875. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7876. fmt.Println(dat)
  7877. } else {
  7878. fmt.Println(err)
  7879. }
  7880. var res Result2001
  7881. var res10265 Result2001Org10265
  7882. if miConfig.Code == "H15049901371" {
  7883. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7884. utils.ErrorLog("解析失败:%v", err)
  7885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7886. return
  7887. }
  7888. res.ErrMsg = res10265.ErrMsg
  7889. res.Output = res10265.Output
  7890. res.InfRefmsgid = res10265.InfRefmsgid
  7891. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7892. res.Infcode = infocode
  7893. } else {
  7894. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7895. utils.ErrorLog("解析失败:%v", err)
  7896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7897. return
  7898. }
  7899. }
  7900. if res.Infcode == 0 {
  7901. c.ServeSuccessJSON(map[string]interface{}{
  7902. "msg": res.Output.Trtinfo,
  7903. })
  7904. }
  7905. }
  7906. }
  7907. }
  7908. //func (c *HisApiController) PutRecord() {
  7909. // id, _ := c.GetInt64("id")
  7910. // record_time := c.GetString("record_time")
  7911. // timeLayout := "2006-01-02"
  7912. // loc, _ := time.LoadLocation("Local")
  7913. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7914. // if err != nil {
  7915. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7916. // return
  7917. // }
  7918. // recordDateTime := theTime.Unix()
  7919. //
  7920. // adminInfo := c.GetAdminUserInfo()
  7921. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  7922. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7923. //
  7924. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7925. //
  7926. // fmt.Println(miConfig.SecretKey)
  7927. //
  7928. // if patient == nil {
  7929. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7930. // return
  7931. // }
  7932. // if len(patient.IdCardNo) == 0 {
  7933. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7934. // return
  7935. // }
  7936. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7937. // if config.IsOpen == 1 {
  7938. // 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
  7939. // resp, requestErr := http.Get(api)
  7940. // if requestErr != nil {
  7941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7942. // return
  7943. // }
  7944. // defer resp.Body.Close()
  7945. // body, ioErr := ioutil.ReadAll(resp.Body)
  7946. // if ioErr != nil {
  7947. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7948. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7949. // return
  7950. // }
  7951. // var respJSON map[string]interface{}
  7952. //
  7953. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7954. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7955. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7956. // return
  7957. // }
  7958. //
  7959. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7960. // userJSONBytes, _ := json.Marshal(userJSON)
  7961. // var res ResultTwo
  7962. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7963. // utils.ErrorLog("解析失败:%v", err)
  7964. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7965. // return
  7966. // }
  7967. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7968. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7969. // infoStr := string(Iinfos)
  7970. // idetinfoStr := string(Idetinfos)
  7971. //
  7972. // if res.Infcode == 0 {
  7973. // his := models.VMHisPatient{
  7974. // Status: 1,
  7975. // Ctime: time.Now().Unix(),
  7976. // Mtime: time.Now().Unix(),
  7977. // PsnNo: res.Output.Baseinfo.PsnNo,
  7978. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  7979. // Certno: res.Output.Baseinfo.Certno,
  7980. // PsnName: res.Output.Baseinfo.PsnName,
  7981. // Gend: res.Output.Baseinfo.Gend,
  7982. // Naty: res.Output.Baseinfo.Naty,
  7983. // Brdy: res.Output.Baseinfo.Brdy,
  7984. // Age: res.Output.Baseinfo.Age,
  7985. // Iinfo: infoStr,
  7986. // Idetinfo: idetinfoStr,
  7987. // PatientId: patient.ID,
  7988. // RecordDate: theTime.Unix(),
  7989. // UserOrgId: adminInfo.CurrentOrgId,
  7990. // AdminUserId: adminInfo.AdminUser.Id,
  7991. // IsReturn: 1,
  7992. // }
  7993. //
  7994. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  7995. // //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")
  7996. // //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")
  7997. //
  7998. // //var dat map[string]interface{}
  7999. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8000. // // fmt.Println(dat)
  8001. // //} else {
  8002. // // fmt.Println(err)
  8003. // //}
  8004. //
  8005. // var dat2 map[string]interface{}
  8006. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8007. // fmt.Println(dat2)
  8008. // } else {
  8009. // fmt.Println(err)
  8010. // }
  8011. //
  8012. // } else {
  8013. // adminUser := c.GetAdminUserInfo()
  8014. // errlog := &models.HisOrderError{
  8015. // UserOrgId: adminUser.CurrentOrgId,
  8016. // Ctime: time.Now().Unix(),
  8017. // Mtime: time.Now().Unix(),
  8018. // ErrMsg: res.ErrMsg,
  8019. // Status: 1,
  8020. // PatientId: id,
  8021. // RecordTime: recordDateTime,
  8022. // Stage: 1,
  8023. // }
  8024. // service.CreateErrMsgLog(errlog)
  8025. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8026. // return
  8027. // }
  8028. // }
  8029. //
  8030. //}
  8031. //func (c *HisApiController) GetUploadDiag() {
  8032. // id, _ := c.GetInt64("id")
  8033. // record_time := c.GetString("record_time")
  8034. //
  8035. // diagnosis_id, _ := c.GetInt64("diagnosis")
  8036. // sick_type, _ := c.GetInt64("sick_type")
  8037. // reg_type, _ := c.GetInt64("reg_type")
  8038. //
  8039. // timeLayout := "2006-01-02"
  8040. // loc, _ := time.LoadLocation("Local")
  8041. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8042. // if err != nil {
  8043. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8044. // return
  8045. // }
  8046. //
  8047. // var patientPrescription models.HisPrescriptionInfo
  8048. // recordDateTime := theTime.Unix()
  8049. // adminInfo := c.GetAdminUserInfo()
  8050. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8051. //
  8052. // if patientPrescription.ID == 0 {
  8053. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8054. // }
  8055. //
  8056. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8057. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8058. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8059. // sickConfig, _ := service.FindSickById(sick_type)
  8060. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8061. //
  8062. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  8063. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  8064. // "&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 +
  8065. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  8066. // resp2, requestErr2 := http.Get(api2)
  8067. // if requestErr2 != nil {
  8068. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8069. // return
  8070. // }
  8071. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8072. // if ioErr2 != nil {
  8073. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8074. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8075. // return
  8076. // }
  8077. // var respJSON2 map[string]interface{}
  8078. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8079. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8080. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8081. // return
  8082. // }
  8083. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8084. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8085. //
  8086. // var res2 ResultSix
  8087. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8088. // utils.ErrorLog("解析失败:%v", err)
  8089. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8090. // return
  8091. // }
  8092. // if res2.Infcode != 0 {
  8093. // adminUser := c.GetAdminUserInfo()
  8094. // errlog := &models.HisOrderError{
  8095. // UserOrgId: adminUser.CurrentOrgId,
  8096. // Ctime: time.Now().Unix(),
  8097. // Mtime: time.Now().Unix(),
  8098. // ErrMsg: res2.ErrMsg,
  8099. // Status: 1,
  8100. // PatientId: id,
  8101. // RecordTime: recordDateTime,
  8102. // Stage: 3,
  8103. // }
  8104. // service.CreateErrMsgLog(errlog)
  8105. //
  8106. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  8107. // return
  8108. // }
  8109. //
  8110. // c.ServeSuccessJSON(map[string]interface{}{
  8111. // "msg": "上传成功",
  8112. // })
  8113. //
  8114. //}
  8115. type QueryResult struct {
  8116. ID int64
  8117. Name string
  8118. Code string
  8119. List_type_code string
  8120. }
  8121. func (c *HisApiController) GetCheckCode() {
  8122. ids_str := c.GetString("ids")
  8123. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8124. ids_arr := strings.Split(ids_str, ",")
  8125. var queryResult []QueryResult
  8126. ids := make([]int64, 0)
  8127. for _, item := range ids_arr {
  8128. id, _ := strconv.ParseInt(item, 10, 64)
  8129. ids = append(ids, id)
  8130. }
  8131. if record_type == 1 {
  8132. drugs, _ := service.GetBatchDrugList(ids)
  8133. for _, item := range drugs {
  8134. result := QueryResult{
  8135. ID: item.ID,
  8136. Name: item.DrugName,
  8137. Code: item.MedicalInsuranceNumber,
  8138. List_type_code: "101",
  8139. }
  8140. queryResult = append(queryResult, result)
  8141. }
  8142. } else if record_type == 2 {
  8143. goods, _ := service.GetBatchGoodInformationList(ids)
  8144. for _, item := range goods {
  8145. result := QueryResult{
  8146. ID: item.ID,
  8147. Name: item.GoodName,
  8148. Code: item.MedicalInsuranceNumber,
  8149. List_type_code: "301",
  8150. }
  8151. queryResult = append(queryResult, result)
  8152. }
  8153. } else if record_type == 3 {
  8154. projects, _ := service.GetBathchMyPorjecgList(ids)
  8155. for _, item := range projects {
  8156. result := QueryResult{
  8157. ID: item.ID,
  8158. Name: item.ProjectName,
  8159. Code: item.MedicalCode,
  8160. List_type_code: "201",
  8161. }
  8162. queryResult = append(queryResult, result)
  8163. }
  8164. }
  8165. admin_user_id, _ := c.GetInt64("admin_user_id")
  8166. adminUser := c.GetAdminUserInfo()
  8167. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8168. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8169. var user_name string
  8170. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8171. if role.ID == 0 {
  8172. user_name = "xxx"
  8173. } else {
  8174. user_name = role.UserName
  8175. }
  8176. baseParams := &models.BaseParams{
  8177. SecretKey: miConfig.SecretKey,
  8178. FixmedinsCode: miConfig.Code,
  8179. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8180. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8181. OrgName: miConfig.OrgName,
  8182. Doctor: user_name,
  8183. }
  8184. if config.IsOpen == 1 {
  8185. for _, item := range queryResult {
  8186. var result string
  8187. if record_type == 1 {
  8188. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8189. } else if record_type == 2 {
  8190. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8191. } else if record_type == 3 {
  8192. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8193. }
  8194. var dat map[string]interface{}
  8195. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8196. fmt.Println(dat)
  8197. } else {
  8198. fmt.Println(err)
  8199. }
  8200. userJSONBytes, _ := json.Marshal(dat)
  8201. var res ResultSix
  8202. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8203. utils.ErrorLog("解析失败:%v", err)
  8204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8205. return
  8206. }
  8207. if res.Infcode == 0 {
  8208. if record_type == 1 {
  8209. service.UpdateBaseDrugById(item.ID)
  8210. } else if record_type == 2 {
  8211. service.UpdateGoodInformaitonByDetail(item.ID)
  8212. } else if record_type == 3 {
  8213. service.UpdateProjectById(item.ID)
  8214. }
  8215. c.ServeSuccessJSON(map[string]interface{}{
  8216. "failed_code": 0,
  8217. "msg": "目录对照成功",
  8218. })
  8219. } else {
  8220. c.ServeSuccessJSON(map[string]interface{}{
  8221. "failed_code": -10,
  8222. "msg": res.ErrMsg,
  8223. })
  8224. }
  8225. }
  8226. }
  8227. }
  8228. func (c *HisApiController) UnCheckCode() {
  8229. ids_str := c.GetString("ids")
  8230. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8231. admin_user_id, _ := c.GetInt64("admin_user_id")
  8232. ids_arr := strings.Split(ids_str, ",")
  8233. var queryResult []QueryResult
  8234. ids := make([]int64, 0)
  8235. for _, item := range ids_arr {
  8236. id, _ := strconv.ParseInt(item, 10, 64)
  8237. ids = append(ids, id)
  8238. }
  8239. if record_type == 1 {
  8240. drugs, _ := service.GetBatchDrugList(ids)
  8241. for _, item := range drugs {
  8242. result := QueryResult{
  8243. ID: item.ID,
  8244. Name: item.DrugName,
  8245. Code: item.MedicalInsuranceNumber,
  8246. List_type_code: "101",
  8247. }
  8248. queryResult = append(queryResult, result)
  8249. }
  8250. } else if record_type == 2 {
  8251. goods, _ := service.GetBatchGoodInformationList(ids)
  8252. for _, item := range goods {
  8253. result := QueryResult{
  8254. ID: item.ID,
  8255. Name: item.GoodName,
  8256. Code: item.MedicalInsuranceNumber,
  8257. List_type_code: "301",
  8258. }
  8259. queryResult = append(queryResult, result)
  8260. }
  8261. } else if record_type == 3 {
  8262. projects, _ := service.GetBathchMyPorjecgList(ids)
  8263. for _, item := range projects {
  8264. result := QueryResult{
  8265. ID: item.ID,
  8266. Name: item.ProjectName,
  8267. Code: item.MedicalCode,
  8268. List_type_code: "201",
  8269. }
  8270. queryResult = append(queryResult, result)
  8271. }
  8272. }
  8273. adminUser := c.GetAdminUserInfo()
  8274. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8275. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8276. var user_name string
  8277. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8278. if role.ID == 0 {
  8279. user_name = "xxx"
  8280. } else {
  8281. user_name = role.UserName
  8282. }
  8283. baseParams := &models.BaseParams{
  8284. SecretKey: miConfig.SecretKey,
  8285. FixmedinsCode: miConfig.Code,
  8286. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8287. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8288. OrgName: miConfig.OrgName,
  8289. Doctor: user_name,
  8290. }
  8291. if config.IsOpen == 1 {
  8292. for _, item := range queryResult {
  8293. var result string
  8294. if record_type == 1 {
  8295. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8296. } else if record_type == 2 {
  8297. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8298. } else if record_type == 3 {
  8299. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8300. }
  8301. var dat2 map[string]interface{}
  8302. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  8303. fmt.Println(dat2)
  8304. } else {
  8305. fmt.Println(err)
  8306. }
  8307. userJSONBytes, _ := json.Marshal(dat2)
  8308. var res ResultSix
  8309. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8310. utils.ErrorLog("解析失败:%v", err)
  8311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8312. return
  8313. }
  8314. if res.Infcode == 0 {
  8315. if record_type == 1 {
  8316. service.UpdateDrugByIdDetail(item.ID)
  8317. } else if record_type == 2 {
  8318. service.UpdateGoodInfoById(item.ID)
  8319. } else if record_type == 3 {
  8320. service.UpdateMyProjectById(item.ID)
  8321. }
  8322. c.ServeSuccessJSON(map[string]interface{}{
  8323. "failed_code": 0,
  8324. "msg": "撤销目录对照成功",
  8325. })
  8326. } else {
  8327. c.ServeSuccessJSON(map[string]interface{}{
  8328. "failed_code": -10,
  8329. "msg": res.ErrMsg,
  8330. })
  8331. }
  8332. }
  8333. }
  8334. }
  8335. func (c *HisApiController) GetPatientInfo() {
  8336. id_card_no := c.GetString("id_card_no")
  8337. admin_user_id, _ := c.GetInt64("admin_user_id")
  8338. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8339. if patient.ID == 0 {
  8340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8341. return
  8342. }
  8343. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8344. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8345. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  8346. if config.IsOpen == 1 {
  8347. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8348. var dat map[string]interface{}
  8349. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8350. fmt.Println(dat)
  8351. } else {
  8352. fmt.Println(err)
  8353. }
  8354. userJSONBytes, _ := json.Marshal(dat)
  8355. var res ResultTwo
  8356. var res10265 ResultTwo10265
  8357. if miConfig.Code == "H15049901371" {
  8358. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8359. utils.ErrorLog("解析失败:%v", err)
  8360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8361. return
  8362. }
  8363. res.ErrMsg = res10265.ErrMsg
  8364. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8365. res.Infcode = infocode
  8366. res.Output = res10265.Output
  8367. res.InfRefmsgid = res10265.InfRefmsgid
  8368. } else {
  8369. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8370. utils.ErrorLog("解析失败:%v", err)
  8371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8372. return
  8373. }
  8374. }
  8375. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8376. // utils.ErrorLog("解析失败:%v", err)
  8377. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8378. // return
  8379. //}
  8380. if res.Infcode != 0 {
  8381. c.ServeSuccessJSON(map[string]interface{}{
  8382. "failed_code": -10,
  8383. "msg": res.ErrMsg,
  8384. })
  8385. } else {
  8386. c.ServeSuccessJSON(map[string]interface{}{
  8387. "failed_code": 0,
  8388. "info": res,
  8389. })
  8390. }
  8391. }
  8392. }
  8393. func (c *HisApiController) PsnPutOnRecord() {
  8394. record_type, _ := c.GetInt64("type")
  8395. patient_id, _ := c.GetInt64("patient_id")
  8396. admin_user_id, _ := c.GetInt64("admin_user_id")
  8397. start_time := c.GetString("start_time")
  8398. end_time := c.GetString("end_time")
  8399. adminUser := c.GetAdminUserInfo()
  8400. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8401. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8402. var patients []*models.Patients
  8403. if record_type == 1 { //全部备案
  8404. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  8405. patients = append(patients, patient...)
  8406. } else { //单个备案
  8407. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8408. patients = append(patients, patient)
  8409. }
  8410. var user_name string
  8411. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8412. if role.ID == 0 {
  8413. user_name = "xxx"
  8414. } else {
  8415. user_name = role.UserName
  8416. }
  8417. if config.IsOpen == 1 {
  8418. for _, item := range patients {
  8419. 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
  8420. resp, requestErr := http.Get(api)
  8421. if requestErr != nil {
  8422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8423. return
  8424. }
  8425. defer resp.Body.Close()
  8426. body, ioErr := ioutil.ReadAll(resp.Body)
  8427. if ioErr != nil {
  8428. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8430. return
  8431. }
  8432. var respJSON map[string]interface{}
  8433. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8434. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8436. return
  8437. }
  8438. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8439. userJSONBytes, _ := json.Marshal(userJSON)
  8440. var res ResultTwo
  8441. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8442. utils.ErrorLog("解析失败:%v", err)
  8443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8444. return
  8445. }
  8446. if res.Infcode == 0 {
  8447. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  8448. var dat map[string]interface{}
  8449. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8450. fmt.Println(dat)
  8451. } else {
  8452. fmt.Println(err)
  8453. }
  8454. userJSONBytes, _ := json.Marshal(dat)
  8455. var res2 ResultThirteen
  8456. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8457. utils.ErrorLog("解析失败:%v", err)
  8458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8459. return
  8460. }
  8461. if res2.Infcode == 0 {
  8462. psnResult := &models.GdybPsnRecord{
  8463. UserOrgId: adminUser.CurrentOrgId,
  8464. PatientId: item.ID,
  8465. PsnNo: res.Output.Baseinfo.PsnNo,
  8466. Ctime: time.Now().Unix(),
  8467. Mtime: time.Now().Unix(),
  8468. Status: 1,
  8469. IsCancel: 1,
  8470. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8471. }
  8472. service.CreatePsnRecord(psnResult)
  8473. } else {
  8474. c.ServeSuccessJSON(map[string]interface{}{
  8475. "failed_code": -10,
  8476. "msg": res2.ErrMsg,
  8477. })
  8478. return
  8479. }
  8480. }
  8481. }
  8482. }
  8483. }
  8484. func (c *HisApiController) PsnUnPutOnRecord() {
  8485. id, _ := c.GetInt64("id")
  8486. //record_type, _ := c.GetInt64("type")
  8487. admin_user_id, _ := c.GetInt64("admin_user_id")
  8488. adminUser := c.GetAdminUserInfo()
  8489. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8490. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8491. var user_name string
  8492. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8493. if role.ID == 0 {
  8494. user_name = "xxx"
  8495. } else {
  8496. user_name = role.UserName
  8497. }
  8498. psn_record, _ := service.GetPsnRecordById(id)
  8499. if psn_record.ID == 0 {
  8500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8501. return
  8502. }
  8503. if config.IsOpen == 1 {
  8504. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8505. var dat map[string]interface{}
  8506. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8507. fmt.Println(dat)
  8508. } else {
  8509. fmt.Println(err)
  8510. }
  8511. userJSONBytes, _ := json.Marshal(dat)
  8512. var res ResultFourteen
  8513. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8514. utils.ErrorLog("解析失败:%v", err)
  8515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8516. return
  8517. }
  8518. if res.Infcode == 0 {
  8519. psn_record.IsCancel = 2
  8520. service.CreatePsnRecord(&psn_record)
  8521. } else {
  8522. c.ServeSuccessJSON(map[string]interface{}{
  8523. "failed_code": -10,
  8524. "msg": res.ErrMsg,
  8525. })
  8526. return
  8527. }
  8528. }
  8529. }
  8530. func (c *HisApiController) PsnPutNCDSOnRecord() {
  8531. patient_id, _ := c.GetInt64("patient_id")
  8532. insutype_two := c.GetString("insutype")
  8533. psn_no := c.GetString("psn_no")
  8534. doctor_id, _ := c.GetInt64("doctor_id")
  8535. sick_id, _ := c.GetInt64("sick_id")
  8536. department_id, _ := c.GetInt64("department_id")
  8537. start_time := c.GetString("start_time")
  8538. end_time := c.GetString("end_time")
  8539. check_time := c.GetString("check_time")
  8540. adminUser := c.GetAdminUserInfo()
  8541. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8542. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8543. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8544. sick, _ := service.FindSickById(sick_id)
  8545. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8546. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8547. var res ResultTwo
  8548. var res10265 ResultTwo10265
  8549. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8550. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  8551. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  8552. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8553. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(3, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  8554. resp, requestErr := http.Get(api)
  8555. if requestErr != nil {
  8556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8557. return
  8558. }
  8559. body, ioErr := ioutil.ReadAll(resp.Body)
  8560. if ioErr != nil {
  8561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8563. return
  8564. }
  8565. var respJSON map[string]interface{}
  8566. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8569. return
  8570. }
  8571. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8572. result, _ := json.Marshal(respJSON)
  8573. fmt.Println("log")
  8574. fmt.Println(string(result))
  8575. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8576. utils.ErrorLog("解析失败:%v", err)
  8577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8578. return
  8579. }
  8580. res.ErrMsg = res10265.ErrMsg
  8581. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8582. res.Infcode = infocode
  8583. res.Output = res10265.Output
  8584. res.InfRefmsgid = res10265.InfRefmsgid
  8585. } else {
  8586. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8587. if miConfig.Code == "H15049901371" {
  8588. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8589. utils.ErrorLog("解析失败:%v", err)
  8590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8591. return
  8592. }
  8593. res.ErrMsg = res10265.ErrMsg
  8594. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8595. res.Infcode = infocode
  8596. res.Output = res10265.Output
  8597. res.InfRefmsgid = res10265.InfRefmsgid
  8598. } else {
  8599. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8600. utils.ErrorLog("解析失败:%v", err)
  8601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8602. return
  8603. }
  8604. }
  8605. }
  8606. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8607. infoStr := string(Iinfos)
  8608. var rf []*ResultFive
  8609. json.Unmarshal([]byte(infoStr), &rf)
  8610. var insuplc_admdvs string
  8611. var insutype string
  8612. var is390 int = 0
  8613. var is310 int = 0
  8614. var insutypes []*ResultFive
  8615. for _, item := range rf {
  8616. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8617. insutypes = append(insutypes, item)
  8618. }
  8619. }
  8620. if len(insutypes) == 1 {
  8621. insutype = insutypes[0].Insutype
  8622. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8623. } else {
  8624. for _, i := range insutypes {
  8625. if i.Insutype == "390" {
  8626. is390 = 1
  8627. }
  8628. if i.Insutype == "310" {
  8629. is310 = 1
  8630. }
  8631. }
  8632. }
  8633. if is390 == 1 {
  8634. insutype = "390"
  8635. }
  8636. if is310 == 1 {
  8637. insutype = "310"
  8638. }
  8639. if len(insutypes) == 2 {
  8640. insutype = insutype_two
  8641. }
  8642. if len(insutypes) == 0 {
  8643. insutype = "310"
  8644. }
  8645. insutype = insutype_two
  8646. fmt.Println(insutype)
  8647. for _, item := range rf {
  8648. fmt.Println(item.Insutype)
  8649. fmt.Println(insutype)
  8650. if item.Insutype == insutype {
  8651. fmt.Println(item.Insutype)
  8652. fmt.Println(insutype)
  8653. insuplc_admdvs = item.InsuplcAdmdvs
  8654. }
  8655. }
  8656. fmt.Println(insuplc_admdvs)
  8657. var res2 ResultThirteen
  8658. var res10265_2 ResultThirteen10265
  8659. if config.IsOpen == 1 {
  8660. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8661. } else {
  8662. 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)
  8663. var dat map[string]interface{}
  8664. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8665. fmt.Println(dat)
  8666. } else {
  8667. fmt.Println(err)
  8668. }
  8669. userJSONBytes, _ := json.Marshal(dat)
  8670. if miConfig.Code == "H15049901371" {
  8671. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  8672. utils.ErrorLog("解析失败:%v", err)
  8673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8674. return
  8675. }
  8676. res2.ErrMsg = res10265_2.ErrMsg
  8677. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  8678. res2.Infcode = infocode
  8679. res2.Output = res10265_2.Output
  8680. res2.InfRefmsgid = res10265_2.InfRefmsgid
  8681. } else {
  8682. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8683. utils.ErrorLog("解析失败:%v", err)
  8684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8685. return
  8686. }
  8687. }
  8688. }
  8689. if res2.Infcode == 0 {
  8690. psnResult := &models.GdybPsnNcdsRecord{
  8691. UserOrgId: adminUser.CurrentOrgId,
  8692. PatientId: patient.ID,
  8693. PsnNo: psn_no,
  8694. DoctorId: doctor.AdminUserId,
  8695. DepartmentId: department_id,
  8696. SickType: sick_id,
  8697. Insutype: insutype,
  8698. Ctime: time.Now().Unix(),
  8699. Mtime: time.Now().Unix(),
  8700. Status: 1,
  8701. IsCancel: 1,
  8702. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8703. }
  8704. service.CreatePsnNCDSRecord(psnResult)
  8705. c.ServeSuccessJSON(map[string]interface{}{
  8706. "failed_code": 0,
  8707. "msg": "备案成功",
  8708. "result": psnResult,
  8709. })
  8710. } else {
  8711. c.ServeSuccessJSON(map[string]interface{}{
  8712. "failed_code": -10,
  8713. "msg": res2.ErrMsg,
  8714. })
  8715. return
  8716. }
  8717. }
  8718. }
  8719. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  8720. id, _ := c.GetInt64("id")
  8721. admin_user_id, _ := c.GetInt64("admin_user_id")
  8722. adminUser := c.GetAdminUserInfo()
  8723. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8724. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8725. //config, _ := service.Ge(adminUser.CurrentOrgId)
  8726. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  8727. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8728. //var user_name string
  8729. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8730. //if role.ID == 0 {
  8731. // user_name = "xxx"
  8732. //} else {
  8733. // user_name = role.UserName
  8734. //}
  8735. psn_record, _ := service.GetPsnNCDSRecordById(id)
  8736. if psn_record.ID == 0 {
  8737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8738. return
  8739. }
  8740. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8741. var res ResultTwo
  8742. var res10265 ResultTwo10265
  8743. if miConfig.Code == "H15049901371" {
  8744. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8745. utils.ErrorLog("解析失败:%v", err)
  8746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8747. return
  8748. }
  8749. res.ErrMsg = res10265.ErrMsg
  8750. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8751. res.Infcode = infocode
  8752. res.Output = res10265.Output
  8753. res.InfRefmsgid = res10265.InfRefmsgid
  8754. } else {
  8755. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8756. utils.ErrorLog("解析失败:%v", err)
  8757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8758. return
  8759. }
  8760. }
  8761. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8762. infoStr := string(Iinfos)
  8763. var rf []*ResultFive
  8764. json.Unmarshal([]byte(infoStr), &rf)
  8765. var insuplc_admdvs string
  8766. var insutype string
  8767. var is390 int = 0
  8768. var is310 int = 0
  8769. var insutypes []*ResultFive
  8770. for _, item := range rf {
  8771. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8772. insutypes = append(insutypes, item)
  8773. }
  8774. }
  8775. if len(insutypes) == 1 {
  8776. insutype = insutypes[0].Insutype
  8777. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8778. } else {
  8779. for _, i := range insutypes {
  8780. if i.Insutype == "390" {
  8781. is390 = 1
  8782. }
  8783. if i.Insutype == "310" {
  8784. is310 = 1
  8785. }
  8786. }
  8787. }
  8788. if is390 == 1 {
  8789. insutype = "390"
  8790. }
  8791. if is310 == 1 {
  8792. insutype = "310"
  8793. }
  8794. if len(insutypes) == 0 {
  8795. insutype = "310"
  8796. }
  8797. insutype = psn_record.Insutype
  8798. for _, item := range rf {
  8799. if item.Insutype == insutype {
  8800. insuplc_admdvs = item.InsuplcAdmdvs
  8801. }
  8802. }
  8803. if config.IsOpen == 1 {
  8804. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8805. var dat map[string]interface{}
  8806. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8807. fmt.Println(dat)
  8808. } else {
  8809. fmt.Println(err)
  8810. }
  8811. userJSONBytes, _ := json.Marshal(dat)
  8812. var res ResultFourteen
  8813. var res10265 ResultFourteen10265
  8814. if miConfig.Code == "H15049901371" {
  8815. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8816. utils.ErrorLog("解析失败:%v", err)
  8817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8818. return
  8819. }
  8820. res.ErrMsg = res10265.ErrMsg
  8821. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8822. res.Infcode = infocode
  8823. res.Output = res10265.Output
  8824. res.InfRefmsgid = res10265.InfRefmsgid
  8825. } else {
  8826. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8827. utils.ErrorLog("解析失败:%v", err)
  8828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8829. return
  8830. }
  8831. }
  8832. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8833. // utils.ErrorLog("解析失败:%v", err)
  8834. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8835. // return
  8836. //}
  8837. if res.Infcode == 0 {
  8838. psn_record.IsCancel = 2
  8839. service.CreatePsnNCDSRecord(&psn_record)
  8840. c.ServeSuccessJSON(map[string]interface{}{
  8841. "failed_code": 0,
  8842. "msg": "撤销备案成功",
  8843. })
  8844. } else {
  8845. c.ServeSuccessJSON(map[string]interface{}{
  8846. "failed_code": -10,
  8847. "msg": res.ErrMsg,
  8848. })
  8849. return
  8850. }
  8851. }
  8852. }
  8853. func (c *HisApiController) TestTest() {
  8854. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  8855. fmt.Println(patient.Iinfo)
  8856. }
  8857. type CustomData struct {
  8858. MsgId string
  8859. PsnNo string
  8860. Info string
  8861. }
  8862. func (c *HisApiController) ReversalData() {
  8863. var customData []*CustomData
  8864. custom := &CustomData{
  8865. MsgId: "H44022900158202103301714472004",
  8866. PsnNo: "44020000001101329945",
  8867. Info: "2207",
  8868. }
  8869. customData = append(customData, custom)
  8870. custom1 := &CustomData{
  8871. MsgId: "H4402290015820210330172057803",
  8872. PsnNo: "44020000001101161813",
  8873. Info: "2207",
  8874. }
  8875. customData = append(customData, custom1)
  8876. custom2 := &CustomData{
  8877. MsgId: "H44022900158202103301705198813",
  8878. PsnNo: "44190000133097375417",
  8879. Info: "2207",
  8880. }
  8881. customData = append(customData, custom2)
  8882. custom3 := &CustomData{
  8883. MsgId: "H44022900158202103301715524756",
  8884. PsnNo: "44020000001100187221",
  8885. Info: "2207",
  8886. }
  8887. customData = append(customData, custom3)
  8888. custom4 := &CustomData{
  8889. MsgId: "H44022900158202103301730376224",
  8890. PsnNo: "44020000001101959155",
  8891. Info: "2207",
  8892. }
  8893. customData = append(customData, custom4)
  8894. custom5 := &CustomData{
  8895. MsgId: "H44022900158202103301748008725",
  8896. PsnNo: "44020000001104246641",
  8897. Info: "2207",
  8898. }
  8899. customData = append(customData, custom5)
  8900. custom6 := &CustomData{
  8901. MsgId: "H44022900158202103301718096755",
  8902. PsnNo: "44020000001102211860",
  8903. Info: "2207",
  8904. }
  8905. customData = append(customData, custom6)
  8906. custom7 := &CustomData{
  8907. MsgId: "H44022900158202103301736551640",
  8908. PsnNo: "44020000001102687718",
  8909. Info: "2207",
  8910. }
  8911. customData = append(customData, custom7)
  8912. custom8 := &CustomData{
  8913. MsgId: "H44022900158202103301743097676",
  8914. PsnNo: "44020000001102127785",
  8915. Info: "2207",
  8916. }
  8917. customData = append(customData, custom8)
  8918. custom9 := &CustomData{
  8919. MsgId: "H44022900158202103301712304203",
  8920. PsnNo: "44020000001101518097",
  8921. Info: "2207",
  8922. }
  8923. customData = append(customData, custom9)
  8924. custom10 := &CustomData{
  8925. MsgId: "H44022900158202103301738448785",
  8926. PsnNo: "44020000001100500813",
  8927. Info: "2207",
  8928. }
  8929. customData = append(customData, custom10)
  8930. custom11 := &CustomData{
  8931. MsgId: "H44022900158202103301732455843",
  8932. PsnNo: "44020000001102690557",
  8933. Info: "2207",
  8934. }
  8935. customData = append(customData, custom11)
  8936. custom12 := &CustomData{
  8937. MsgId: "H44022900158202103301745421708",
  8938. PsnNo: "44020000001102211928",
  8939. Info: "2207",
  8940. }
  8941. customData = append(customData, custom12)
  8942. custom1212 := &CustomData{
  8943. MsgId: "H440229001582021033017351627",
  8944. PsnNo: "44020000001102481733",
  8945. Info: "2207",
  8946. }
  8947. customData = append(customData, custom1212)
  8948. custom13 := &CustomData{
  8949. MsgId: "H44022900158202103301740327951",
  8950. PsnNo: "44020000001103174866",
  8951. Info: "2207",
  8952. }
  8953. customData = append(customData, custom13)
  8954. custom14 := &CustomData{
  8955. MsgId: "H4402290015820210330174922668",
  8956. PsnNo: "44020000001102927272",
  8957. Info: "2207",
  8958. }
  8959. customData = append(customData, custom14)
  8960. custom15 := &CustomData{
  8961. MsgId: "H44022900158202103301752362273",
  8962. PsnNo: "44020000001102942890",
  8963. Info: "2207",
  8964. }
  8965. customData = append(customData, custom15)
  8966. custom16 := &CustomData{
  8967. MsgId: "H44022900158202103301751082917",
  8968. PsnNo: "44020000001101662162",
  8969. Info: "2207",
  8970. }
  8971. customData = append(customData, custom16)
  8972. custom17 := &CustomData{
  8973. MsgId: "H44022900158202103301754147728",
  8974. PsnNo: "44020000000229014511",
  8975. Info: "2207",
  8976. }
  8977. customData = append(customData, custom17)
  8978. adminUser := c.GetAdminUserInfo()
  8979. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8980. for _, item := range customData {
  8981. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8982. fmt.Println(result)
  8983. }
  8984. }
  8985. func (c *HisApiController) GetAllopatry() {
  8986. year := c.GetString("year")
  8987. month := c.GetString("month")
  8988. admin_user_id, _ := c.GetInt64("admin_user_id")
  8989. adminUser := c.GetAdminUserInfo()
  8990. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8991. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8992. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  8993. var dat map[string]interface{}
  8994. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8995. fmt.Println(dat)
  8996. } else {
  8997. fmt.Println(err)
  8998. }
  8999. userJSONBytes, _ := json.Marshal(dat)
  9000. var res models.Result9001
  9001. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9002. utils.ErrorLog("解析失败:%v", err)
  9003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9004. return
  9005. }
  9006. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9007. var dat2 map[string]interface{}
  9008. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9009. fmt.Println(dat)
  9010. } else {
  9011. fmt.Println(err)
  9012. }
  9013. userJSONBytes2, _ := json.Marshal(dat2)
  9014. var res2 models.Result3260
  9015. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9016. utils.ErrorLog("解析失败:%v", err)
  9017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9018. return
  9019. }
  9020. if res2.Infcode == 0 {
  9021. c.ServeSuccessJSON(map[string]interface{}{
  9022. "list": res2.Output.Data,
  9023. })
  9024. return
  9025. } else {
  9026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9027. return
  9028. }
  9029. }
  9030. func (c *HisApiController) ComfirmAllopatry() {
  9031. year := c.GetString("year")
  9032. month := c.GetString("month")
  9033. admin_user_id, _ := c.GetInt64("admin_user_id")
  9034. adminUser := c.GetAdminUserInfo()
  9035. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9036. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9037. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9038. var dat map[string]interface{}
  9039. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9040. fmt.Println(dat)
  9041. } else {
  9042. fmt.Println(err)
  9043. }
  9044. userJSONBytes, _ := json.Marshal(dat)
  9045. var res models.Result9001
  9046. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9047. utils.ErrorLog("解析失败:%v", err)
  9048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9049. return
  9050. }
  9051. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9052. var dat2 map[string]interface{}
  9053. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9054. fmt.Println(dat)
  9055. } else {
  9056. fmt.Println(err)
  9057. }
  9058. userJSONBytes2, _ := json.Marshal(dat2)
  9059. var res2 models.Result3260
  9060. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9061. utils.ErrorLog("解析失败:%v", err)
  9062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9063. return
  9064. }
  9065. if res2.Infcode == 0 {
  9066. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  9067. var dat map[string]interface{}
  9068. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9069. fmt.Println(dat)
  9070. } else {
  9071. fmt.Println(err)
  9072. }
  9073. userJSONBytes, _ := json.Marshal(dat)
  9074. var res3 models.Result3261
  9075. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  9076. utils.ErrorLog("解析失败:%v", err)
  9077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9078. return
  9079. }
  9080. if res3.Infcode == 0 {
  9081. record := &models.HisYidiClearRecord{
  9082. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9083. Ctime: time.Now().Unix(),
  9084. Mtime: time.Now().Unix(),
  9085. Status: 1,
  9086. MsgId: msgId,
  9087. }
  9088. service.SaveClearRecord(record)
  9089. c.ServeSuccessJSON(map[string]interface{}{
  9090. "msg": "提取成功",
  9091. })
  9092. }
  9093. }
  9094. }
  9095. func (c *HisApiController) RefundAllopatry() {
  9096. year := c.GetString("year")
  9097. month := c.GetString("month")
  9098. id, _ := c.GetInt64("id")
  9099. admin_user_id, _ := c.GetInt64("admin_user_id")
  9100. adminUser := c.GetAdminUserInfo()
  9101. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9102. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9103. record, _ := service.GetClearRecordById(id)
  9104. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  9105. var dat map[string]interface{}
  9106. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9107. fmt.Println(dat)
  9108. } else {
  9109. fmt.Println(err)
  9110. }
  9111. userJSONBytes, _ := json.Marshal(dat)
  9112. var empty ResultFourteen
  9113. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  9114. utils.ErrorLog("解析失败:%v", err)
  9115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9116. return
  9117. }
  9118. if empty.Infcode == 0 {
  9119. c.ServeSuccessJSON(map[string]interface{}{
  9120. "msg": "撤销成功",
  9121. })
  9122. return
  9123. }
  9124. }
  9125. func (c *HisApiController) ReversalOtherData() {
  9126. var customData []*CustomData
  9127. custom := &CustomData{
  9128. MsgId: "H44022900158202103301714472004",
  9129. PsnNo: "44020000001101329945",
  9130. Info: "2208",
  9131. }
  9132. customData = append(customData, custom)
  9133. custom1 := &CustomData{
  9134. MsgId: "H4402290015820210330172057803",
  9135. PsnNo: "44020000001101161813",
  9136. Info: "2208",
  9137. }
  9138. customData = append(customData, custom1)
  9139. custom2 := &CustomData{
  9140. MsgId: "H44022900158202103301705198813",
  9141. PsnNo: "44190000133097375417",
  9142. Info: "2208",
  9143. }
  9144. customData = append(customData, custom2)
  9145. custom3 := &CustomData{
  9146. MsgId: "H44022900158202103301715524756",
  9147. PsnNo: "44020000001100187221",
  9148. Info: "2208",
  9149. }
  9150. customData = append(customData, custom3)
  9151. custom4 := &CustomData{
  9152. MsgId: "H44022900158202103301730376224",
  9153. PsnNo: "44020000001101959155",
  9154. Info: "2208",
  9155. }
  9156. customData = append(customData, custom4)
  9157. custom5 := &CustomData{
  9158. MsgId: "H44022900158202103301748008725",
  9159. PsnNo: "44020000001104246641",
  9160. Info: "2208",
  9161. }
  9162. customData = append(customData, custom5)
  9163. custom6 := &CustomData{
  9164. MsgId: "H44022900158202103301718096755",
  9165. PsnNo: "44020000001102211860",
  9166. Info: "2208",
  9167. }
  9168. customData = append(customData, custom6)
  9169. custom7 := &CustomData{
  9170. MsgId: "H44022900158202103301736551640",
  9171. PsnNo: "44020000001102687718",
  9172. Info: "2208",
  9173. }
  9174. customData = append(customData, custom7)
  9175. custom8 := &CustomData{
  9176. MsgId: "H44022900158202103301743097676",
  9177. PsnNo: "44020000001102127785",
  9178. Info: "2208",
  9179. }
  9180. customData = append(customData, custom8)
  9181. custom9 := &CustomData{
  9182. MsgId: "H44022900158202103301712304203",
  9183. PsnNo: "44020000001101518097",
  9184. Info: "2208",
  9185. }
  9186. customData = append(customData, custom9)
  9187. custom10 := &CustomData{
  9188. MsgId: "H44022900158202103301738448785",
  9189. PsnNo: "44020000001100500813",
  9190. Info: "2208",
  9191. }
  9192. customData = append(customData, custom10)
  9193. custom11 := &CustomData{
  9194. MsgId: "H44022900158202103301732455843",
  9195. PsnNo: "44020000001102690557",
  9196. Info: "2208",
  9197. }
  9198. customData = append(customData, custom11)
  9199. custom12 := &CustomData{
  9200. MsgId: "H44022900158202103301745421708",
  9201. PsnNo: "44020000001102211928",
  9202. Info: "2208",
  9203. }
  9204. customData = append(customData, custom12)
  9205. custom1212 := &CustomData{
  9206. MsgId: "H440229001582021033017351627",
  9207. PsnNo: "44020000001102481733",
  9208. Info: "2208",
  9209. }
  9210. customData = append(customData, custom1212)
  9211. custom13 := &CustomData{
  9212. MsgId: "H44022900158202103301740327951",
  9213. PsnNo: "44020000001103174866",
  9214. Info: "2208",
  9215. }
  9216. customData = append(customData, custom13)
  9217. custom14 := &CustomData{
  9218. MsgId: "H4402290015820210330174922668",
  9219. PsnNo: "44020000001102927272",
  9220. Info: "2208",
  9221. }
  9222. customData = append(customData, custom14)
  9223. custom15 := &CustomData{
  9224. MsgId: "H44022900158202103301752362273",
  9225. PsnNo: "44020000001102942890",
  9226. Info: "2208",
  9227. }
  9228. customData = append(customData, custom15)
  9229. custom16 := &CustomData{
  9230. MsgId: "H44022900158202103301751082917",
  9231. PsnNo: "44020000001101662162",
  9232. Info: "2208",
  9233. }
  9234. customData = append(customData, custom16)
  9235. custom17 := &CustomData{
  9236. MsgId: "H44022900158202103301754147728",
  9237. PsnNo: "44020000000229014511",
  9238. Info: "2208",
  9239. }
  9240. customData = append(customData, custom17)
  9241. adminUser := c.GetAdminUserInfo()
  9242. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9243. for _, item := range customData {
  9244. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9245. fmt.Println(result)
  9246. }
  9247. }
  9248. func PathExists(path string) (bool, error) {
  9249. _, err := os.Stat(path)
  9250. if err == nil {
  9251. return true, nil
  9252. }
  9253. if os.IsNotExist(err) {
  9254. return false, nil
  9255. }
  9256. return false, err
  9257. }
  9258. //创建文件夹
  9259. func Mkdir(dir string) {
  9260. // 创建文件夹
  9261. exist, err := PathExists(dir)
  9262. if err != nil {
  9263. fmt.Println(err.Error())
  9264. } else {
  9265. if exist {
  9266. fmt.Println(dir + "文件夹已存在!")
  9267. } else {
  9268. // 文件夹名称,权限
  9269. err := os.Mkdir(dir, os.ModePerm)
  9270. if err != nil {
  9271. fmt.Println(dir+"文件夹创建失败:", err.Error())
  9272. } else {
  9273. fmt.Println(dir + "文件夹创建成功!")
  9274. }
  9275. }
  9276. }
  9277. }
  9278. //压缩文件
  9279. func Zip(srcFile string, destZip string) error {
  9280. zipfile, err := os.Create(destZip)
  9281. if err != nil {
  9282. return err
  9283. }
  9284. defer zipfile.Close()
  9285. archive := zip.NewWriter(zipfile)
  9286. defer archive.Close()
  9287. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  9288. if err != nil {
  9289. return err
  9290. }
  9291. header, err := zip.FileInfoHeader(info)
  9292. if err != nil {
  9293. return err
  9294. }
  9295. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  9296. // header.Name = path
  9297. if info.IsDir() {
  9298. header.Name += "/"
  9299. } else {
  9300. header.Method = zip.Deflate
  9301. }
  9302. writer, err := archive.CreateHeader(header)
  9303. if err != nil {
  9304. return err
  9305. }
  9306. if !info.IsDir() {
  9307. file, err := os.Open(path)
  9308. if err != nil {
  9309. return err
  9310. }
  9311. defer file.Close()
  9312. _, err = io.Copy(writer, file)
  9313. }
  9314. return err
  9315. })
  9316. return err
  9317. }
  9318. func ReadFile(filePath string) []byte {
  9319. f, err := os.Open(filePath)
  9320. if err != nil {
  9321. fmt.Println("read file fail", err)
  9322. return nil
  9323. }
  9324. defer f.Close()
  9325. fd, err := ioutil.ReadAll(f)
  9326. if err != nil {
  9327. fmt.Println("read to fd fail", err)
  9328. return nil
  9329. }
  9330. return fd
  9331. }
  9332. func saveLog(result string, request string, infno string, desc string) {
  9333. org_id, _ := beego.AppConfig.Int64("org_id")
  9334. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  9335. dir := miConfig.OrgName + "日志"
  9336. utils.Mkdir(dir)
  9337. month := time.Unix(1557042972, 0).Format("1")
  9338. year := time.Now().Format("2006")
  9339. month = time.Now().Format("01")
  9340. day := time.Now().Format("02")
  9341. hour := time.Now().Format("15")
  9342. min := time.Now().Format("04")
  9343. sec := time.Now().Format("05")
  9344. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  9345. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  9346. file_name := file + ".txt"
  9347. file_path := miConfig.OrgName + "日志" + "/" + file_name
  9348. exist, _ := utils.PathExists(file_path)
  9349. if exist { //存在
  9350. fmt.Println("存在")
  9351. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  9352. if err != nil {
  9353. fmt.Println("read fail")
  9354. }
  9355. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  9356. n, _ := f.Seek(0, 2)
  9357. _, err = f.WriteAt([]byte(content), n)
  9358. } else { //不存在
  9359. fmt.Println("文件不存在,创建文件")
  9360. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  9361. defer f.Close()
  9362. if err != nil {
  9363. } else {
  9364. _, err = f.Write([]byte("记录日志"))
  9365. }
  9366. }
  9367. }
  9368. type Charset string
  9369. const (
  9370. UTF8 = Charset("UTF-8")
  9371. GB18030 = Charset("GB18030")
  9372. )
  9373. func ConvertToString(src string, srcCode string, tagCode string) string {
  9374. srcCoder := mahonia.NewDecoder(srcCode)
  9375. srcResult := srcCoder.ConvertString(src)
  9376. tagCoder := mahonia.NewDecoder(tagCode)
  9377. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  9378. result := string(cdata)
  9379. return result
  9380. }