his_api_controller.go 355KB

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