his_api_controller.go 397KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. }
  73. func (c *HisApiController) GetPsnNcdsInfo() {
  74. admin_user_id, _ := c.GetInt64("admin_user_id")
  75. patient_id, _ := c.GetInt64("patient_id")
  76. id, _ := c.GetInt64("id")
  77. adminUser := c.GetAdminUserInfo()
  78. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  79. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  80. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  81. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  82. psn_record, _ := service.GetPsnNCDSRecordById(id)
  83. //
  84. //if psn_record.ID == 0 {
  85. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  86. // return
  87. //}
  88. var res Result5301
  89. var res10265 Result5301For10265
  90. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  91. psn_info, _ := service.GetPsnByPatientId(patient_id)
  92. var api string
  93. if miConfig.MdtrtareaAdmvs == "320921" {
  94. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  95. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  96. } else {
  97. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  98. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  99. }
  100. resp, requestErr := http.Get(api)
  101. if requestErr != nil {
  102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  103. return
  104. }
  105. body, ioErr := ioutil.ReadAll(resp.Body)
  106. if ioErr != nil {
  107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  109. return
  110. }
  111. var respJSON map[string]interface{}
  112. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  115. return
  116. }
  117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  118. result, _ := json.Marshal(respJSON)
  119. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  120. utils.ErrorLog("解析失败:%v", err)
  121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  122. return
  123. }
  124. res.ErrMsg = res10265.ErrMsg
  125. res.Output = res10265.Output
  126. res.InfRefmsgid = res10265.InfRefmsgid
  127. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  128. res.Infcode = infocode
  129. } else {
  130. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  131. var dat map[string]interface{}
  132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  133. fmt.Println(dat)
  134. } else {
  135. fmt.Println(err)
  136. }
  137. userJSONBytes, _ := json.Marshal(dat)
  138. if miConfig.Code == "H15049901371" {
  139. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  140. utils.ErrorLog("解析失败:%v", err)
  141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  142. return
  143. }
  144. res.InfRefmsgid = res10265.InfRefmsgid
  145. res.Output = res10265.Output
  146. res.ErrMsg = res10265.ErrMsg
  147. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  148. res.Infcode = infocode
  149. } else {
  150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  151. utils.ErrorLog("解析失败:%v", err)
  152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  153. return
  154. }
  155. }
  156. }
  157. if res.Infcode == 0 {
  158. c.ServeSuccessJSON(map[string]interface{}{
  159. "result": res.Output.Result,
  160. })
  161. }
  162. }
  163. func (c *HisApiController) CheckInsutype() {
  164. his_patient_id, _ := c.GetInt64("his_patient_id")
  165. admin_user_id, _ := c.GetInt64("admin_user_id")
  166. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  167. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  168. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  169. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  170. var dat map[string]interface{}
  171. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  172. fmt.Println(dat)
  173. } else {
  174. fmt.Println(err)
  175. }
  176. userJSONBytes, _ := json.Marshal(dat)
  177. var res Result90100
  178. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  179. utils.ErrorLog("解析失败:%v", err)
  180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  181. return
  182. }
  183. if res.Infcode != 0 {
  184. c.ServeSuccessJSON(map[string]interface{}{
  185. "failed_code": -10,
  186. "msg": res.ErrMsg,
  187. })
  188. return
  189. } else {
  190. fmt.Println(res)
  191. }
  192. }
  193. func (c *HisApiController) CheckCardPWD() {
  194. card_pwd := c.GetString("card_pwd")
  195. his_patient_id, _ := c.GetInt64("his_patient_id")
  196. admin_user_id, _ := c.GetInt64("admin_user_id")
  197. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  198. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  199. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  200. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  201. var dat map[string]interface{}
  202. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  203. fmt.Println(dat)
  204. } else {
  205. fmt.Println(err)
  206. }
  207. userJSONBytes, _ := json.Marshal(dat)
  208. var res Result90991
  209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  210. utils.ErrorLog("解析失败:%v", err)
  211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  212. return
  213. }
  214. if res.Infcode != 0 {
  215. c.ServeSuccessJSON(map[string]interface{}{
  216. "failed_code": -10,
  217. "msg": res.ErrMsg,
  218. })
  219. return
  220. } else {
  221. if res.Output.Result.CheckStat == "0" {
  222. var msg string
  223. switch res.Output.Result.CardStat {
  224. case "00":
  225. msg = "未激活"
  226. break
  227. case "10":
  228. msg = "激活"
  229. break
  230. case "20":
  231. msg = "窗口挂失"
  232. break
  233. case "21":
  234. msg = "电话挂失"
  235. break
  236. case "22":
  237. msg = "单位网上申报挂失"
  238. break
  239. case "23":
  240. msg = "保健办挂失"
  241. break
  242. case "24":
  243. msg = "个人网上挂失"
  244. break
  245. case "25":
  246. msg = "网上服务大厅挂失"
  247. break
  248. case "30":
  249. msg = "注销"
  250. break
  251. case "40":
  252. msg = "回收"
  253. break
  254. case "99":
  255. msg = "制卡中(无效卡)"
  256. break
  257. }
  258. c.ServeSuccessJSON(map[string]interface{}{
  259. "failed_code": -10,
  260. "msg": msg,
  261. })
  262. return
  263. } else {
  264. c.ServeSuccessJSON(map[string]interface{}{
  265. "msg": "校验成功",
  266. })
  267. return
  268. }
  269. }
  270. }
  271. func (c *HisApiController) ReadCard() {
  272. id_card_type, _ := c.GetInt64("id_card_type")
  273. admin_user_id, _ := c.GetInt64("admin_user_id")
  274. certificates, _ := c.GetInt64("certificates")
  275. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  276. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  277. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  278. switch id_card_type {
  279. case 1:
  280. if miConfig.MdtrtareaAdmvs == "421300" {
  281. var res ResultTwo
  282. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  283. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  284. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10)
  285. resp, requestErr := http.Get(api)
  286. if requestErr != nil {
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  288. return
  289. }
  290. body, ioErr := ioutil.ReadAll(resp.Body)
  291. if ioErr != nil {
  292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  294. return
  295. }
  296. var respJSON map[string]interface{}
  297. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  300. return
  301. }
  302. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  303. result, _ := json.Marshal(respJSON)
  304. fmt.Println("log")
  305. fmt.Println(string(result))
  306. if err := json.Unmarshal([]byte(result), &res); err != nil {
  307. utils.ErrorLog("解析失败:%v", err)
  308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  309. return
  310. }
  311. if res.Infcode == 0 {
  312. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  313. if err == gorm.ErrRecordNotFound {
  314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  315. return
  316. } else if err != nil {
  317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  318. return
  319. } else {
  320. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  321. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  322. infoStr := string(Iinfos)
  323. idetinfoStr := string(Idetinfos)
  324. psn := &models.HisPsn{
  325. PsnNo: res.Output.Baseinfo.PsnNo,
  326. Age: res.Output.Baseinfo.Age,
  327. PatientId: patient.ID,
  328. Certno: res.Output.Baseinfo.Certno,
  329. Brdy: res.Output.Baseinfo.Brdy,
  330. Gend: res.Output.Baseinfo.Gend,
  331. Naty: res.Output.Baseinfo.Naty,
  332. PsnCertType: res.Output.Baseinfo.PsnCertType,
  333. PsnName: res.Output.Baseinfo.PsnName,
  334. Idetinfo: idetinfoStr,
  335. Insuinfo: infoStr,
  336. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  337. }
  338. service.CreateHisPsn(psn)
  339. c.ServeSuccessJSON(map[string]interface{}{
  340. "patient": patient,
  341. "number": res.Output.Baseinfo.Certno,
  342. })
  343. }
  344. } else {
  345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  346. return
  347. }
  348. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  349. var api string
  350. if miConfig.MdtrtareaAdmvs == "320921" {
  351. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  352. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "operator_id=" + strconv.FormatInt(admin_user_id, 10) + "operator=" + roles.UserName
  353. } else {
  354. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  355. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  356. }
  357. resp, requestErr := http.Get(api)
  358. if requestErr != nil {
  359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  360. return
  361. }
  362. body, ioErr := ioutil.ReadAll(resp.Body)
  363. if ioErr != nil {
  364. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  366. return
  367. }
  368. var respJSON map[string]interface{}
  369. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  370. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  372. return
  373. }
  374. var status string
  375. status = respJSON["data"].(map[string]interface{})["status"].(string)
  376. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  377. //console.log()
  378. fmt.Println("type===")
  379. fmt.Println(card_type)
  380. var token string
  381. var res ResultTwo //1101结果
  382. var res10265 ResultTwo10265 //1101结果
  383. var card_info string //卡信息
  384. var busi_card_info string
  385. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  386. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  387. if status == "0" { //读卡成功
  388. if card_type == "1" {
  389. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  390. result, _ := json.Marshal(respJSON)
  391. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  392. utils.ErrorLog("解析失败:%v", err)
  393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  394. return
  395. }
  396. res.ErrMsg = res10265.ErrMsg
  397. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  398. res.Infcode = infocode
  399. res.Output = res10265.Output
  400. res.InfRefmsgid = res10265.InfRefmsgid
  401. } else {
  402. //var card_info string //卡信息
  403. //var busi_card_info string
  404. token = respJSON["data"].(map[string]interface{})["token"].(string)
  405. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  406. //fmt.Println(card_info)
  407. //fmt.Println(busi_card_info)
  408. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  409. result, _ := json.Marshal(respJSON)
  410. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  411. utils.ErrorLog("解析失败:%v", err)
  412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  413. return
  414. }
  415. res.ErrMsg = res10265.ErrMsg
  416. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  417. res.Infcode = infocode
  418. res.Output = res10265.Output
  419. res.InfRefmsgid = res10265.InfRefmsgid
  420. }
  421. if res.Infcode == 0 {
  422. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  423. if err == gorm.ErrRecordNotFound {
  424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  425. return
  426. } else if err != nil {
  427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  428. return
  429. } else {
  430. if card_type == "1" {
  431. bas := strings.Split(card_info, "|")
  432. basNumber := bas[2]
  433. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  434. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  435. infoStr := string(Iinfos)
  436. idetinfoStr := string(Idetinfos)
  437. psn := &models.HisPsn{
  438. PsnNo: res.Output.Baseinfo.PsnNo,
  439. Age: res.Output.Baseinfo.Age,
  440. PatientId: patient.ID,
  441. Certno: res.Output.Baseinfo.Certno,
  442. Brdy: res.Output.Baseinfo.Brdy,
  443. Gend: res.Output.Baseinfo.Gend,
  444. Naty: res.Output.Baseinfo.Naty,
  445. PsnCertType: res.Output.Baseinfo.PsnCertType,
  446. PsnName: res.Output.Baseinfo.PsnName,
  447. Idetinfo: idetinfoStr,
  448. Insuinfo: infoStr,
  449. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  450. CardInfo: card_info,
  451. VerifyNumber: busi_card_info,
  452. }
  453. service.CreateHisPsn(psn)
  454. c.ServeSuccessJSON(map[string]interface{}{
  455. "patient": patient,
  456. "number": basNumber,
  457. })
  458. } else {
  459. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  460. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  461. infoStr := string(Iinfos)
  462. idetinfoStr := string(Idetinfos)
  463. psn := &models.HisPsn{
  464. PsnNo: res.Output.Baseinfo.PsnNo,
  465. Age: res.Output.Baseinfo.Age,
  466. PatientId: patient.ID,
  467. Certno: res.Output.Baseinfo.Certno,
  468. Brdy: res.Output.Baseinfo.Brdy,
  469. Gend: res.Output.Baseinfo.Gend,
  470. Naty: res.Output.Baseinfo.Naty,
  471. PsnCertType: res.Output.Baseinfo.PsnCertType,
  472. PsnName: res.Output.Baseinfo.PsnName,
  473. Idetinfo: idetinfoStr,
  474. Insuinfo: infoStr,
  475. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  476. CardInfo: card_info,
  477. VerifyNumber: token,
  478. }
  479. service.CreateHisPsn(psn)
  480. c.ServeSuccessJSON(map[string]interface{}{
  481. "patient": patient,
  482. "number": token,
  483. })
  484. }
  485. }
  486. } else {
  487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  488. return
  489. }
  490. } else { //读卡失败
  491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  492. return
  493. }
  494. } else {
  495. if initFlag == 0 {
  496. c.TestGetBasBaseInit()
  497. }
  498. basStr := c.GetBasBaseInfo()
  499. if len(basStr) == 0 {
  500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  501. return
  502. }
  503. fmt.Println(basStr)
  504. bas := strings.Split(basStr, "|")
  505. basNumber := bas[1]
  506. fmt.Println(basNumber)
  507. card_sn := bas[3]
  508. fmt.Println(card_sn)
  509. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  510. var dat map[string]interface{}
  511. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  512. fmt.Println(dat)
  513. } else {
  514. fmt.Println(err)
  515. }
  516. userJSONBytes, _ := json.Marshal(dat)
  517. var res ResultTwo
  518. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  519. utils.ErrorLog("解析失败:%v", err)
  520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  521. return
  522. }
  523. if res.Infcode == 0 {
  524. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  525. if err == gorm.ErrRecordNotFound {
  526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  527. return
  528. } else if err != nil {
  529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  530. return
  531. } else {
  532. c.ServeSuccessJSON(map[string]interface{}{
  533. "patient": patient,
  534. "number": basNumber,
  535. })
  536. }
  537. } else {
  538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  539. return
  540. }
  541. break
  542. }
  543. case 2:
  544. SFZStr := c.GetSFZBaseInfo()
  545. id_card_str := strings.Split(SFZStr, "^")
  546. id_card_number := id_card_str[0]
  547. card_sn := ""
  548. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  549. var dat map[string]interface{}
  550. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  551. fmt.Println(dat)
  552. } else {
  553. fmt.Println(err)
  554. }
  555. userJSONBytes, _ := json.Marshal(dat)
  556. var res ResultTwo
  557. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  558. utils.ErrorLog("解析失败:%v", err)
  559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  560. return
  561. }
  562. if res.Infcode == 0 {
  563. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  564. if err == gorm.ErrRecordNotFound {
  565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  566. return
  567. } else if err != nil {
  568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  569. return
  570. } else {
  571. c.ServeSuccessJSON(map[string]interface{}{
  572. "patient": patient,
  573. "number": id_card_number,
  574. })
  575. }
  576. } else {
  577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  578. return
  579. }
  580. break
  581. case 3:
  582. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  583. var api string
  584. if miConfig.MdtrtareaAdmvs == "320921" {
  585. 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 +
  586. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "operator_id=" + strconv.FormatInt(admin_user_id, 10) + "operator=" + roles.UserName
  587. } else {
  588. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  589. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  590. }
  591. resp, requestErr := http.Get(api)
  592. if requestErr != nil {
  593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  594. return
  595. }
  596. body, ioErr := ioutil.ReadAll(resp.Body)
  597. if ioErr != nil {
  598. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  600. return
  601. }
  602. var respJSON map[string]interface{}
  603. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  604. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  606. return
  607. }
  608. var status string
  609. status = respJSON["data"].(map[string]interface{})["status"].(string)
  610. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  611. var token string
  612. var res ResultTwo //1101结果
  613. var res10265 ResultTwo10265 //1101结果
  614. var card_info string //卡信息
  615. var busi_card_info string
  616. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  617. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  618. if status == "0" { //读卡成功
  619. if card_type == "1" {
  620. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  621. result, _ := json.Marshal(respJSON)
  622. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  623. utils.ErrorLog("解析失败:%v", err)
  624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  625. return
  626. }
  627. res.ErrMsg = res10265.ErrMsg
  628. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  629. res.Infcode = infocode
  630. res.Output = res10265.Output
  631. res.InfRefmsgid = res10265.InfRefmsgid
  632. } else {
  633. //var card_info string //卡信息
  634. //var busi_card_info string
  635. token = respJSON["data"].(map[string]interface{})["token"].(string)
  636. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  637. //fmt.Println(card_info)
  638. //fmt.Println(busi_card_info)
  639. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  640. result, _ := json.Marshal(respJSON)
  641. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  642. utils.ErrorLog("解析失败:%v", err)
  643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  644. return
  645. }
  646. res.ErrMsg = res10265.ErrMsg
  647. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  648. res.Infcode = infocode
  649. res.Output = res10265.Output
  650. res.InfRefmsgid = res10265.InfRefmsgid
  651. }
  652. if res.Infcode == 0 {
  653. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  654. if err == gorm.ErrRecordNotFound {
  655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  656. return
  657. } else if err != nil {
  658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  659. return
  660. } else {
  661. if card_type == "1" {
  662. bas := strings.Split(card_info, "|")
  663. basNumber := bas[2]
  664. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  665. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  666. infoStr := string(Iinfos)
  667. idetinfoStr := string(Idetinfos)
  668. psn := &models.HisPsn{
  669. PsnNo: res.Output.Baseinfo.PsnNo,
  670. Age: res.Output.Baseinfo.Age,
  671. PatientId: patient.ID,
  672. Certno: res.Output.Baseinfo.Certno,
  673. Brdy: res.Output.Baseinfo.Brdy,
  674. Gend: res.Output.Baseinfo.Gend,
  675. Naty: res.Output.Baseinfo.Naty,
  676. PsnCertType: res.Output.Baseinfo.PsnCertType,
  677. PsnName: res.Output.Baseinfo.PsnName,
  678. Idetinfo: idetinfoStr,
  679. Insuinfo: infoStr,
  680. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  681. CardInfo: card_info,
  682. VerifyNumber: busi_card_info,
  683. }
  684. service.CreateHisPsn(psn)
  685. c.ServeSuccessJSON(map[string]interface{}{
  686. "patient": patient,
  687. "number": basNumber,
  688. })
  689. } else {
  690. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  691. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  692. infoStr := string(Iinfos)
  693. idetinfoStr := string(Idetinfos)
  694. psn := &models.HisPsn{
  695. PsnNo: res.Output.Baseinfo.PsnNo,
  696. Age: res.Output.Baseinfo.Age,
  697. PatientId: patient.ID,
  698. Certno: res.Output.Baseinfo.Certno,
  699. Brdy: res.Output.Baseinfo.Brdy,
  700. Gend: res.Output.Baseinfo.Gend,
  701. Naty: res.Output.Baseinfo.Naty,
  702. PsnCertType: res.Output.Baseinfo.PsnCertType,
  703. PsnName: res.Output.Baseinfo.PsnName,
  704. Idetinfo: idetinfoStr,
  705. Insuinfo: infoStr,
  706. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  707. CardInfo: card_info,
  708. VerifyNumber: token,
  709. }
  710. service.CreateHisPsn(psn)
  711. c.ServeSuccessJSON(map[string]interface{}{
  712. "patient": patient,
  713. "number": token,
  714. })
  715. }
  716. }
  717. } else {
  718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  719. return
  720. }
  721. } else { //读卡失败
  722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  723. return
  724. }
  725. }
  726. break
  727. }
  728. }
  729. var initFlag int64 = 0
  730. func (c *HisApiController) TestGetBasBaseInit() {
  731. DllDef := syscall.MustLoadDLL("SSCard.dll")
  732. Iinit := DllDef.MustFindProc("Init")
  733. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  734. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  735. if ret != 0 {
  736. fmt.Println("SSCard的报错原因:", err)
  737. fmt.Println("SSCard的运算结果为:", ret)
  738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  739. return
  740. }
  741. result := int(ret)
  742. fmt.Println("SSCard的运算结果为1:", result)
  743. initFlag = 1
  744. return
  745. }
  746. func (c *HisApiController) GetSFZBaseInfo() string {
  747. DllDef := syscall.MustLoadDLL("SSCard.dll")
  748. readCard := DllDef.MustFindProc("ReadSFZ")
  749. if readCard == nil {
  750. fmt.Println("readcard is nil")
  751. readCard = DllDef.MustFindProc("ReadSFZ")
  752. }
  753. str := make([]byte, 256)
  754. str1 := make([]byte, 256)
  755. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  756. fmt.Println(r)
  757. return string(str)
  758. }
  759. func (c *HisApiController) GetBasBaseInfo() string {
  760. DllDef := syscall.MustLoadDLL("SSCard.dll")
  761. readCard := DllDef.MustFindProc("ReadCardBas")
  762. if readCard == nil {
  763. fmt.Println("readcard is nil")
  764. readCard = DllDef.MustFindProc("ReadCardBas")
  765. }
  766. str := make([]byte, 1024)
  767. str1 := make([]byte, 1024)
  768. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  769. fmt.Println(string(str1))
  770. fmt.Println(string(str))
  771. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  772. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  773. if ret2 != 0 {
  774. return ""
  775. }
  776. return string(str)
  777. }
  778. type CustomFundPay struct {
  779. FundPayType string `json:"fund_pay_type"`
  780. FundPayamt float64 `json:"fund_payamt"`
  781. }
  782. func (c *HisApiController) GetSettleList() {
  783. order_id, _ := c.GetInt64("order_id")
  784. admin_user_id, _ := c.GetInt64("admin_user_id")
  785. order, _ := service.GetHisOrderByIDTwo(order_id)
  786. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  787. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  788. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  789. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  790. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  791. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  792. if order.ID == 0 {
  793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  794. return
  795. }
  796. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  797. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  798. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  799. fmt.Println(count)
  800. var zero string
  801. number := count + 1
  802. if number >= 1000 {
  803. zero = "0000" + strconv.FormatInt(number, 10)
  804. } else if number >= 10000 {
  805. zero = "000" + strconv.FormatInt(number, 10)
  806. } else if number >= 100000 {
  807. zero = "00" + strconv.FormatInt(number, 10)
  808. } else if number >= 1000000 {
  809. zero = "0" + strconv.FormatInt(number, 10)
  810. } else {
  811. zero = strconv.FormatInt(number, 10)
  812. }
  813. fmt.Println(zero)
  814. struct4101 := service.Struct4101{
  815. PsnNo: order.PsnNo,
  816. MdtrtId: order.MdtrtId,
  817. SetlId: order.SetlId,
  818. PsnName: order.PsnName,
  819. Gend: order.Gend,
  820. Brdy: his.Brdy,
  821. Age: his.Age,
  822. Naty: order.Naty,
  823. PatnCertType: "01",
  824. Certno: order.Certno,
  825. Prfs: "90",
  826. ConerName: roles[0].UserName,
  827. PatnRlts: "99",
  828. ConerAddr: miConfig.OrgName,
  829. ConerTel: admin.Mobile,
  830. HiType: order.Insutype,
  831. Insuplc: miConfig.InsuplcAdmdvs,
  832. MaindiagFlag: "1",
  833. BillCode: last_order.FaPiaoCode,
  834. BillNo: zero,
  835. BizSn: order.Number,
  836. PsnSelfPay: order.PsnPartAmt,
  837. PsnOwnPay: order.PsnPartAmt,
  838. AcctPay: order.AcctPay,
  839. PsnCashpay: order.PsnCashPay,
  840. HiPaymtd: "1",
  841. Hsorg: miConfig.InsuplcAdmdvs,
  842. HsorgOpter: miConfig.InsuplcAdmdvs,
  843. MedinsFillPsn: curRoles.UserName,
  844. MedinsFillDept: depart.Name,
  845. IptMedType: "2",
  846. }
  847. struct4101.SetlBegnDate = order.SetlTime
  848. struct4101.SetlEndDate = order.SetlTime
  849. time_arr := strings.Split(order.SetlTime, " ")
  850. struct4101.AdmTime = time_arr[0]
  851. struct4101.AdmEndTime = time_arr[0]
  852. var rf []CustomFundPay
  853. json.Unmarshal([]byte(order.SetlDetail), &rf)
  854. var tempFunPays []service.CustomStruct
  855. for _, item := range rf {
  856. var tempFunPay service.CustomStruct
  857. tempFunPay.FundPayamt = item.FundPayamt
  858. tempFunPay.FundPayType = item.FundPayType
  859. tempFunPays = append(tempFunPays, tempFunPay)
  860. }
  861. struct4101.CustomStruct = tempFunPays
  862. var tempDiaginfos []service.DiaginfoStructTwo
  863. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  864. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  865. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  866. var config []*models.HisXtDiagnoseConfig
  867. for _, item := range diagnosis_ids {
  868. id, _ := strconv.ParseInt(item, 10, 64)
  869. diagnosisConfig, _ := service.FindDiagnoseById(id)
  870. config = append(config, &diagnosisConfig)
  871. }
  872. for index, item := range config {
  873. if index == 0 {
  874. var tempDiaginfo service.DiaginfoStructTwo
  875. tempDiaginfo.DiagCode = item.CountryCode
  876. tempDiaginfo.DiagName = item.CountryContentName
  877. tempDiaginfo.DiagType = "1"
  878. tempDiaginfo.MaindiagFlag = "1"
  879. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  880. } else {
  881. var tempDiaginfo service.DiaginfoStructTwo
  882. tempDiaginfo.DiagCode = item.CountryCode
  883. tempDiaginfo.DiagName = item.CountryContentName
  884. tempDiaginfo.DiagType = "2"
  885. tempDiaginfo.MaindiagFlag = "0"
  886. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  887. }
  888. }
  889. struct4101.Diseinfo = tempDiaginfos
  890. sickConfigTwo, _ := service.FindSickById(his.SickType)
  891. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  892. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  893. tempOpspdiseinfo2.OprnOprtCode = ""
  894. tempOpspdiseinfo2.OprnOprtName = ""
  895. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  896. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  897. var iteminfo service.IteminfoStruct
  898. var bedCostTotal float64 = 0 //床位总费
  899. var bedCostSelfTotal float64 = 0 //床位自费
  900. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  901. var operationCostTotal float64 = 0 //手术费
  902. var operationCostSelfTotal float64 = 0 //手术费
  903. var operationCostPartSelfTotal float64 = 0 //手术费
  904. var otherCostTotal float64 = 0 //其他费用
  905. var otherCostSelfTotal float64 = 0 //其他费用
  906. var otherCostPartSelfTotal float64 = 0 //其他费用
  907. var materialCostTotal float64 = 0 //材料费
  908. var materialCostSelfTotal float64 = 0 //材料费
  909. var materialCostPartSelfTotal float64 = 0 //材料费
  910. var westernMedicineCostTotal float64 = 0 //西药费
  911. var westernMedicineCostSelfTotal float64 = 0 //西药费
  912. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  913. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  914. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  915. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  916. var checkCostTotal float64 = 0 //检查费
  917. var checkCostSelfTotal float64 = 0 //检查费
  918. var checkCostPartSelfTotal float64 = 0 //检查费
  919. var laboratoryCostTotal float64 = 0 //化验费
  920. var laboratoryCostSelfTotal float64 = 0 //化验费
  921. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  922. var treatCostTotal float64 = 0 //治疗费用
  923. var treatCostSelfTotal float64 = 0 //治疗费用
  924. var treatCostPartSelfTotal float64 = 0 //治疗费用
  925. decimal.DivisionPrecision = 2
  926. var bed_fulamt_ownpay_amt float64 = 0
  927. var operation_fulamt_ownpay_amt float64 = 0
  928. var other_fulamt_ownpay_amt float64 = 0
  929. var westernMedicine_fulamt_ownpay_amt float64 = 0
  930. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  931. var check_fulamt_ownpay_amt float64 = 0
  932. var material_fulamt_ownpay_amt float64 = 0
  933. var laboratory_fulamt_ownpay_amt float64 = 0
  934. var treat_fulamt_ownpay_amt float64 = 0
  935. var bed_claa_sunmfee float64 = 0
  936. var bed_clab_amt float64 = 0
  937. var bed_other_amt float64 = 0
  938. var operation_claa_sunmfee float64 = 0
  939. var operation_clab_amt float64 = 0
  940. var operation_other_amt float64 = 0
  941. var other_claa_sunmfee float64 = 0
  942. var other_clab_amt float64 = 0
  943. var other_other_amt float64 = 0
  944. var westernMedicine_claa_sunmfee float64 = 0
  945. var westernMedicine_clab_amt float64 = 0
  946. var westernMedicine_other_amt float64 = 0
  947. var chineseTraditional_claa_sunmfee float64 = 0
  948. var chineseTraditional_clab_amt float64 = 0
  949. var chineseTraditional_other_amt float64 = 0
  950. var check_claa_sunmfee float64 = 0
  951. var check_clab_amt float64 = 0
  952. var check_other_amt float64 = 0
  953. var material_claa_sunmfee float64 = 0
  954. var material_clab_amt float64 = 0
  955. var material_other_amt float64 = 0
  956. var laboratory_claa_sunmfee float64 = 0
  957. var laboratory_clab_amt float64 = 0
  958. var laboratory_other_amt float64 = 0
  959. var treat_claa_sunmfee float64 = 0
  960. var treat_clab_amt float64 = 0
  961. var treat_other_amt float64 = 0
  962. for _, item := range order.HisOrderInfo {
  963. if item.MedChrgitmType == "01" { //床位费
  964. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  965. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  966. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  967. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  968. if item.ChrgitmLv == "1" {
  969. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  970. }
  971. if item.ChrgitmLv == "2" {
  972. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  973. }
  974. if item.ChrgitmLv == "3" {
  975. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  976. }
  977. }
  978. if item.MedChrgitmType == "03" { //检查费
  979. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  980. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  981. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  982. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  983. if item.ChrgitmLv == "1" {
  984. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  985. }
  986. if item.ChrgitmLv == "2" {
  987. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  988. }
  989. if item.ChrgitmLv == "3" {
  990. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  991. }
  992. }
  993. if item.MedChrgitmType == "04" { //化验费
  994. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  995. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  996. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  997. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  998. if item.ChrgitmLv == "1" {
  999. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1000. }
  1001. if item.ChrgitmLv == "2" {
  1002. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1003. }
  1004. if item.ChrgitmLv == "3" {
  1005. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1006. }
  1007. }
  1008. if item.MedChrgitmType == "05" { //治疗费
  1009. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1010. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1011. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1012. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1013. if item.ChrgitmLv == "1" {
  1014. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1015. }
  1016. if item.ChrgitmLv == "2" {
  1017. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1018. }
  1019. if item.ChrgitmLv == "3" {
  1020. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1021. }
  1022. }
  1023. if item.MedChrgitmType == "06" { //手术费
  1024. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1025. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1026. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1027. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1028. if item.ChrgitmLv == "1" {
  1029. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1030. }
  1031. if item.ChrgitmLv == "2" {
  1032. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1033. }
  1034. if item.ChrgitmLv == "3" {
  1035. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1036. }
  1037. }
  1038. if item.MedChrgitmType == "08" { //材料费
  1039. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1040. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1041. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1042. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1043. if item.ChrgitmLv == "1" {
  1044. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1045. }
  1046. if item.ChrgitmLv == "2" {
  1047. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1048. }
  1049. if item.ChrgitmLv == "3" {
  1050. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1051. }
  1052. }
  1053. if item.MedChrgitmType == "09" { //西药费
  1054. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1055. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1056. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1057. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1058. if item.ChrgitmLv == "1" {
  1059. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1060. }
  1061. if item.ChrgitmLv == "2" {
  1062. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1063. }
  1064. if item.ChrgitmLv == "3" {
  1065. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1066. }
  1067. }
  1068. if item.MedChrgitmType == "11" { //中成费
  1069. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1070. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1071. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1072. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1073. if item.ChrgitmLv == "1" {
  1074. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1075. }
  1076. if item.ChrgitmLv == "2" {
  1077. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1078. }
  1079. if item.ChrgitmLv == "3" {
  1080. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1081. }
  1082. }
  1083. if item.MedChrgitmType == "14" { //其他费
  1084. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1085. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1086. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1087. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1088. if item.ChrgitmLv == "1" {
  1089. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1090. }
  1091. if item.ChrgitmLv == "2" {
  1092. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1093. }
  1094. if item.ChrgitmLv == "3" {
  1095. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1096. }
  1097. }
  1098. }
  1099. var iteminfoStructs []service.IteminfoStruct
  1100. if bedCostTotal != 0 {
  1101. iteminfo.MedChrgitm = "01"
  1102. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1103. iteminfo.Amt = bedCostTotal
  1104. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1105. iteminfo.ClabAmt = bed_clab_amt
  1106. iteminfo.OthAmt = bed_other_amt
  1107. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1108. }
  1109. if checkCostTotal != 0 {
  1110. iteminfo.MedChrgitm = "03"
  1111. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1112. iteminfo.Amt = checkCostTotal
  1113. iteminfo.ClaaSumfee = check_claa_sunmfee
  1114. iteminfo.ClabAmt = check_clab_amt
  1115. iteminfo.OthAmt = check_other_amt
  1116. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1117. }
  1118. if laboratoryCostTotal != 0 {
  1119. iteminfo.MedChrgitm = "04"
  1120. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1121. iteminfo.Amt = laboratoryCostTotal
  1122. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1123. iteminfo.ClabAmt = laboratory_clab_amt
  1124. iteminfo.OthAmt = laboratory_other_amt
  1125. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1126. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1127. }
  1128. if treatCostTotal != 0 {
  1129. iteminfo.MedChrgitm = "05"
  1130. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1131. iteminfo.Amt = treatCostTotal
  1132. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1133. iteminfo.ClabAmt = treat_clab_amt
  1134. iteminfo.OthAmt = treat_other_amt
  1135. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1136. //(struct4101.IteminfoStruct, iteminfo)
  1137. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1138. }
  1139. if operationCostTotal != 0 {
  1140. iteminfo.MedChrgitm = "06"
  1141. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1142. iteminfo.Amt = operationCostTotal
  1143. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1144. iteminfo.ClabAmt = operation_clab_amt
  1145. iteminfo.OthAmt = operation_other_amt
  1146. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1147. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1148. }
  1149. if materialCostTotal != 0 {
  1150. iteminfo.MedChrgitm = "08"
  1151. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1152. iteminfo.Amt = materialCostTotal
  1153. iteminfo.ClaaSumfee = material_claa_sunmfee
  1154. iteminfo.ClabAmt = material_clab_amt
  1155. iteminfo.OthAmt = material_other_amt
  1156. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1157. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1158. }
  1159. if westernMedicineCostTotal != 0 {
  1160. iteminfo.MedChrgitm = "09"
  1161. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1162. iteminfo.Amt = westernMedicineCostTotal
  1163. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1164. iteminfo.ClabAmt = westernMedicine_clab_amt
  1165. iteminfo.OthAmt = westernMedicine_other_amt
  1166. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1167. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1168. }
  1169. if chineseTraditionalMedicineCostTotal != 0 {
  1170. iteminfo.MedChrgitm = "11"
  1171. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1172. iteminfo.Amt = westernMedicineCostTotal
  1173. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1174. iteminfo.ClabAmt = westernMedicine_clab_amt
  1175. iteminfo.OthAmt = westernMedicine_other_amt
  1176. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1177. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1178. }
  1179. if otherCostTotal != 0 {
  1180. iteminfo.MedChrgitm = "14"
  1181. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1182. iteminfo.Amt = otherCostTotal
  1183. iteminfo.ClaaSumfee = other_claa_sunmfee
  1184. iteminfo.ClabAmt = other_clab_amt
  1185. iteminfo.OthAmt = other_other_amt
  1186. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1187. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1188. }
  1189. struct4101.IteminfoStruct = iteminfoStructs
  1190. struct4101.Ntly = "中国"
  1191. struct4101.AdmCaty = "A03.06"
  1192. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1193. fmt.Println(result)
  1194. var dat map[string]interface{}
  1195. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1196. fmt.Println(dat)
  1197. } else {
  1198. fmt.Println(err)
  1199. }
  1200. userJSONBytes, _ := json.Marshal(dat)
  1201. var res ResultSeventeen
  1202. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1203. utils.ErrorLog("解析失败:%v", err)
  1204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1205. return
  1206. }
  1207. if res.Infcode != 0 {
  1208. c.ServeSuccessJSON(map[string]interface{}{
  1209. "failed_code": -10,
  1210. "msg": res.ErrMsg,
  1211. })
  1212. return
  1213. } else {
  1214. order.FaPiaoNumber = zero
  1215. order.FaPiaoCode = last_order.FaPiaoCode
  1216. service.UpdateOrder(order)
  1217. hisFundSettleListResult := &models.HisFundSettleListResult{
  1218. Number: res.Output.SetlListId,
  1219. Status: 1,
  1220. Ctime: time.Now().Unix(),
  1221. Mtime: time.Now().Unix(),
  1222. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1223. IsUpload: 1,
  1224. OrderId: order_id,
  1225. }
  1226. service.CreateUploadRecord(hisFundSettleListResult)
  1227. c.ServeSuccessJSON(map[string]interface{}{
  1228. "msg": "上传成功",
  1229. "result": hisFundSettleListResult,
  1230. })
  1231. return
  1232. }
  1233. }
  1234. func (c *HisApiController) GetSettleListHospital() {
  1235. order_id, _ := c.GetInt64("order_id")
  1236. admin_user_id, _ := c.GetInt64("admin_user_id")
  1237. order, _ := service.GetHisOrderByIDTwo(order_id)
  1238. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1239. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1240. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1241. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1242. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1243. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1244. if order.ID == 0 {
  1245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1246. return
  1247. }
  1248. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1249. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1250. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1251. fmt.Println(count)
  1252. var zero string
  1253. number := count + 1
  1254. if number >= 1000 {
  1255. zero = "0000" + strconv.FormatInt(number, 10)
  1256. } else if number >= 10000 {
  1257. zero = "000" + strconv.FormatInt(number, 10)
  1258. } else if number >= 100000 {
  1259. zero = "00" + strconv.FormatInt(number, 10)
  1260. } else if number >= 1000000 {
  1261. zero = "0" + strconv.FormatInt(number, 10)
  1262. } else {
  1263. zero = strconv.FormatInt(number, 10)
  1264. }
  1265. fmt.Println(zero)
  1266. struct4101 := service.Struct4101{
  1267. PsnNo: order.PsnNo,
  1268. MdtrtId: order.MdtrtId,
  1269. SetlId: order.SetlId,
  1270. PsnName: order.PsnName,
  1271. Gend: order.Gend,
  1272. Brdy: his.Brdy,
  1273. Age: int64(order.Age),
  1274. Naty: order.Naty,
  1275. PatnCertType: "01",
  1276. Certno: order.Certno,
  1277. Prfs: "90",
  1278. ConerName: roles[0].UserName,
  1279. PatnRlts: "99",
  1280. ConerAddr: miConfig.OrgName,
  1281. ConerTel: admin.Mobile,
  1282. HiType: order.Insutype,
  1283. Insuplc: miConfig.InsuplcAdmdvs,
  1284. MaindiagFlag: "1",
  1285. BillCode: last_order.FaPiaoCode,
  1286. BillNo: zero,
  1287. BizSn: order.Number,
  1288. PsnSelfPay: order.PsnPartAmt,
  1289. PsnOwnPay: order.PsnPartAmt,
  1290. AcctPay: order.AcctPay,
  1291. PsnCashpay: order.PsnCashPay,
  1292. HiPaymtd: "1",
  1293. Hsorg: miConfig.InsuplcAdmdvs,
  1294. HsorgOpter: miConfig.InsuplcAdmdvs,
  1295. MedinsFillPsn: curRoles.UserName,
  1296. MedinsFillDept: depart.Name,
  1297. IptMedType: "2",
  1298. AdmTime: his.InHosptialTime,
  1299. AdmEndTime: his.OutHosptialTime,
  1300. }
  1301. struct4101.SetlBegnDate = order.SetlTime
  1302. struct4101.SetlEndDate = order.SetlTime
  1303. var rf []CustomFundPay
  1304. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1305. var tempFunPays []service.CustomStruct
  1306. for _, item := range rf {
  1307. var tempFunPay service.CustomStruct
  1308. tempFunPay.FundPayamt = item.FundPayamt
  1309. tempFunPay.FundPayType = item.FundPayType
  1310. tempFunPays = append(tempFunPays, tempFunPay)
  1311. }
  1312. struct4101.CustomStruct = tempFunPays
  1313. var tempDiaginfos []service.DiaginfoStructTwo
  1314. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1315. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1316. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1317. var config []*models.HisXtDiagnoseConfig
  1318. for _, item := range diagnosis_ids {
  1319. id, _ := strconv.ParseInt(item, 10, 64)
  1320. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1321. config = append(config, &diagnosisConfig)
  1322. }
  1323. for index, item := range config {
  1324. if index == 0 {
  1325. var tempDiaginfo service.DiaginfoStructTwo
  1326. tempDiaginfo.DiagCode = item.CountryCode
  1327. tempDiaginfo.DiagName = item.CountryContentName
  1328. tempDiaginfo.DiagType = "1"
  1329. tempDiaginfo.MaindiagFlag = "1"
  1330. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1331. } else {
  1332. var tempDiaginfo service.DiaginfoStructTwo
  1333. tempDiaginfo.DiagCode = item.CountryCode
  1334. tempDiaginfo.DiagName = item.CountryContentName
  1335. tempDiaginfo.DiagType = "2"
  1336. tempDiaginfo.MaindiagFlag = "0"
  1337. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1338. }
  1339. }
  1340. struct4101.Diseinfo = tempDiaginfos
  1341. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1342. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1343. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1344. tempOpspdiseinfo2.OprnOprtCode = ""
  1345. tempOpspdiseinfo2.OprnOprtName = ""
  1346. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1347. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1348. var iteminfo service.IteminfoStruct
  1349. var bedCostTotal float64 = 0 //床位总费
  1350. var bedCostSelfTotal float64 = 0 //床位自费
  1351. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1352. var operationCostTotal float64 = 0 //手术费
  1353. var operationCostSelfTotal float64 = 0 //手术费
  1354. var operationCostPartSelfTotal float64 = 0 //手术费
  1355. var otherCostTotal float64 = 0 //其他费用
  1356. var otherCostSelfTotal float64 = 0 //其他费用
  1357. var otherCostPartSelfTotal float64 = 0 //其他费用
  1358. var materialCostTotal float64 = 0 //材料费
  1359. var materialCostSelfTotal float64 = 0 //材料费
  1360. var materialCostPartSelfTotal float64 = 0 //材料费
  1361. var westernMedicineCostTotal float64 = 0 //西药费
  1362. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1363. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1364. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1365. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1366. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1367. var checkCostTotal float64 = 0 //检查费
  1368. var checkCostSelfTotal float64 = 0 //检查费
  1369. var checkCostPartSelfTotal float64 = 0 //检查费
  1370. var laboratoryCostTotal float64 = 0 //化验费
  1371. var laboratoryCostSelfTotal float64 = 0 //化验费
  1372. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1373. var treatCostTotal float64 = 0 //治疗费用
  1374. var treatCostSelfTotal float64 = 0 //治疗费用
  1375. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1376. decimal.DivisionPrecision = 2
  1377. var bed_fulamt_ownpay_amt float64 = 0
  1378. var operation_fulamt_ownpay_amt float64 = 0
  1379. var other_fulamt_ownpay_amt float64 = 0
  1380. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1381. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1382. var check_fulamt_ownpay_amt float64 = 0
  1383. var material_fulamt_ownpay_amt float64 = 0
  1384. var laboratory_fulamt_ownpay_amt float64 = 0
  1385. var treat_fulamt_ownpay_amt float64 = 0
  1386. var bed_claa_sunmfee float64 = 0
  1387. var bed_clab_amt float64 = 0
  1388. var bed_other_amt float64 = 0
  1389. var operation_claa_sunmfee float64 = 0
  1390. var operation_clab_amt float64 = 0
  1391. var operation_other_amt float64 = 0
  1392. var other_claa_sunmfee float64 = 0
  1393. var other_clab_amt float64 = 0
  1394. var other_other_amt float64 = 0
  1395. var westernMedicine_claa_sunmfee float64 = 0
  1396. var westernMedicine_clab_amt float64 = 0
  1397. var westernMedicine_other_amt float64 = 0
  1398. var chineseTraditional_claa_sunmfee float64 = 0
  1399. var chineseTraditional_clab_amt float64 = 0
  1400. var chineseTraditional_other_amt float64 = 0
  1401. var check_claa_sunmfee float64 = 0
  1402. var check_clab_amt float64 = 0
  1403. var check_other_amt float64 = 0
  1404. var material_claa_sunmfee float64 = 0
  1405. var material_clab_amt float64 = 0
  1406. var material_other_amt float64 = 0
  1407. var laboratory_claa_sunmfee float64 = 0
  1408. var laboratory_clab_amt float64 = 0
  1409. var laboratory_other_amt float64 = 0
  1410. var treat_claa_sunmfee float64 = 0
  1411. var treat_clab_amt float64 = 0
  1412. var treat_other_amt float64 = 0
  1413. for _, item := range order.HisOrderInfo {
  1414. if item.MedChrgitmType == "01" { //床位费
  1415. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1416. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1417. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1418. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1419. if item.ChrgitmLv == "1" {
  1420. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1421. }
  1422. if item.ChrgitmLv == "2" {
  1423. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1424. }
  1425. if item.ChrgitmLv == "3" {
  1426. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1427. }
  1428. }
  1429. if item.MedChrgitmType == "03" { //检查费
  1430. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1431. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1432. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1433. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1434. if item.ChrgitmLv == "1" {
  1435. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1436. }
  1437. if item.ChrgitmLv == "2" {
  1438. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1439. }
  1440. if item.ChrgitmLv == "3" {
  1441. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1442. }
  1443. }
  1444. if item.MedChrgitmType == "04" { //化验费
  1445. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1446. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1447. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1448. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1449. if item.ChrgitmLv == "1" {
  1450. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1451. }
  1452. if item.ChrgitmLv == "2" {
  1453. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1454. }
  1455. if item.ChrgitmLv == "3" {
  1456. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1457. }
  1458. }
  1459. if item.MedChrgitmType == "05" { //治疗费
  1460. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1461. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1462. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1463. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1464. if item.ChrgitmLv == "1" {
  1465. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1466. }
  1467. if item.ChrgitmLv == "2" {
  1468. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1469. }
  1470. if item.ChrgitmLv == "3" {
  1471. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1472. }
  1473. }
  1474. if item.MedChrgitmType == "06" { //手术费
  1475. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1476. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1477. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1478. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1479. if item.ChrgitmLv == "1" {
  1480. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1481. }
  1482. if item.ChrgitmLv == "2" {
  1483. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1484. }
  1485. if item.ChrgitmLv == "3" {
  1486. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1487. }
  1488. }
  1489. if item.MedChrgitmType == "08" { //材料费
  1490. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1491. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1492. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1493. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1494. if item.ChrgitmLv == "1" {
  1495. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1496. }
  1497. if item.ChrgitmLv == "2" {
  1498. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1499. }
  1500. if item.ChrgitmLv == "3" {
  1501. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1502. }
  1503. }
  1504. if item.MedChrgitmType == "09" { //西药费
  1505. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1506. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1507. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1508. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1509. if item.ChrgitmLv == "1" {
  1510. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1511. }
  1512. if item.ChrgitmLv == "2" {
  1513. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1514. }
  1515. if item.ChrgitmLv == "3" {
  1516. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1517. }
  1518. }
  1519. if item.MedChrgitmType == "11" { //中成费
  1520. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1521. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1522. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1523. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1524. if item.ChrgitmLv == "1" {
  1525. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1526. }
  1527. if item.ChrgitmLv == "2" {
  1528. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1529. }
  1530. if item.ChrgitmLv == "3" {
  1531. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1532. }
  1533. }
  1534. if item.MedChrgitmType == "14" { //其他费
  1535. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1536. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1537. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1538. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1539. if item.ChrgitmLv == "1" {
  1540. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1541. }
  1542. if item.ChrgitmLv == "2" {
  1543. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1544. }
  1545. if item.ChrgitmLv == "3" {
  1546. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1547. }
  1548. }
  1549. }
  1550. var iteminfoStructs []service.IteminfoStruct
  1551. if bedCostTotal != 0 {
  1552. iteminfo.MedChrgitm = "01"
  1553. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1554. iteminfo.Amt = bedCostTotal
  1555. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1556. iteminfo.ClabAmt = bed_clab_amt
  1557. iteminfo.OthAmt = bed_other_amt
  1558. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1559. }
  1560. if checkCostTotal != 0 {
  1561. iteminfo.MedChrgitm = "03"
  1562. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1563. iteminfo.Amt = checkCostTotal
  1564. iteminfo.ClaaSumfee = check_claa_sunmfee
  1565. iteminfo.ClabAmt = check_clab_amt
  1566. iteminfo.OthAmt = check_other_amt
  1567. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1568. }
  1569. if laboratoryCostTotal != 0 {
  1570. iteminfo.MedChrgitm = "04"
  1571. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1572. iteminfo.Amt = laboratoryCostTotal
  1573. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1574. iteminfo.ClabAmt = laboratory_clab_amt
  1575. iteminfo.OthAmt = laboratory_other_amt
  1576. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1577. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1578. }
  1579. if treatCostTotal != 0 {
  1580. iteminfo.MedChrgitm = "05"
  1581. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1582. iteminfo.Amt = treatCostTotal
  1583. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1584. iteminfo.ClabAmt = treat_clab_amt
  1585. iteminfo.OthAmt = treat_other_amt
  1586. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1587. //(struct4101.IteminfoStruct, iteminfo)
  1588. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1589. }
  1590. if operationCostTotal != 0 {
  1591. iteminfo.MedChrgitm = "06"
  1592. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1593. iteminfo.Amt = operationCostTotal
  1594. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1595. iteminfo.ClabAmt = operation_clab_amt
  1596. iteminfo.OthAmt = operation_other_amt
  1597. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1598. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1599. }
  1600. if materialCostTotal != 0 {
  1601. iteminfo.MedChrgitm = "08"
  1602. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1603. iteminfo.Amt = materialCostTotal
  1604. iteminfo.ClaaSumfee = material_claa_sunmfee
  1605. iteminfo.ClabAmt = material_clab_amt
  1606. iteminfo.OthAmt = material_other_amt
  1607. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1608. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1609. }
  1610. if westernMedicineCostTotal != 0 {
  1611. iteminfo.MedChrgitm = "09"
  1612. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1613. iteminfo.Amt = westernMedicineCostTotal
  1614. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1615. iteminfo.ClabAmt = westernMedicine_clab_amt
  1616. iteminfo.OthAmt = westernMedicine_other_amt
  1617. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1618. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1619. }
  1620. if chineseTraditionalMedicineCostTotal != 0 {
  1621. iteminfo.MedChrgitm = "11"
  1622. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1623. iteminfo.Amt = westernMedicineCostTotal
  1624. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1625. iteminfo.ClabAmt = westernMedicine_clab_amt
  1626. iteminfo.OthAmt = westernMedicine_other_amt
  1627. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1628. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1629. }
  1630. if otherCostTotal != 0 {
  1631. iteminfo.MedChrgitm = "14"
  1632. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1633. iteminfo.Amt = otherCostTotal
  1634. iteminfo.ClaaSumfee = other_claa_sunmfee
  1635. iteminfo.ClabAmt = other_clab_amt
  1636. iteminfo.OthAmt = other_other_amt
  1637. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1638. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1639. }
  1640. struct4101.IteminfoStruct = iteminfoStructs
  1641. struct4101.Ntly = "中国"
  1642. struct4101.AdmCaty = "A03.06"
  1643. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1644. fmt.Println(result)
  1645. var dat map[string]interface{}
  1646. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1647. fmt.Println(dat)
  1648. } else {
  1649. fmt.Println(err)
  1650. }
  1651. userJSONBytes, _ := json.Marshal(dat)
  1652. var res ResultSeventeen
  1653. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1654. utils.ErrorLog("解析失败:%v", err)
  1655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1656. return
  1657. }
  1658. if res.Infcode != 0 {
  1659. c.ServeSuccessJSON(map[string]interface{}{
  1660. "failed_code": -10,
  1661. "msg": res.ErrMsg,
  1662. })
  1663. return
  1664. } else {
  1665. order.FaPiaoNumber = zero
  1666. order.FaPiaoCode = last_order.FaPiaoCode
  1667. service.UpdateOrder(order)
  1668. hisFundSettleListResult := &models.HisFundSettleListResult{
  1669. Number: res.Output.SetlListId,
  1670. Status: 1,
  1671. Ctime: time.Now().Unix(),
  1672. Mtime: time.Now().Unix(),
  1673. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1674. IsUpload: 1,
  1675. OrderId: order_id,
  1676. }
  1677. service.CreateUploadRecord(hisFundSettleListResult)
  1678. c.ServeSuccessJSON(map[string]interface{}{
  1679. "msg": "上传成功",
  1680. "result": hisFundSettleListResult,
  1681. })
  1682. return
  1683. }
  1684. }
  1685. func (c *HisApiController) GetBatchSettleList() {
  1686. orders, _ := service.GetAllHisOrder(10106)
  1687. for _, item := range orders {
  1688. order_id := item.ID
  1689. order, _ := service.GetHisOrderByIDTwo(order_id)
  1690. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1691. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1692. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1693. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  1694. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1695. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1696. if order.ID == 0 {
  1697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1698. return
  1699. }
  1700. if his.BalanceAccountsType == 2 {
  1701. continue
  1702. }
  1703. struct4101 := service.Struct4101{
  1704. PsnNo: order.PsnNo,
  1705. MdtrtId: order.MdtrtId,
  1706. SetlId: order.SetlId,
  1707. PsnName: order.PsnName,
  1708. Gend: order.Gend,
  1709. Brdy: his.Brdy,
  1710. Age: his.Age,
  1711. Naty: order.Naty,
  1712. PatnCertType: "01",
  1713. Certno: order.Certno,
  1714. Prfs: "90",
  1715. ConerName: roles[0].UserName,
  1716. PatnRlts: "99",
  1717. ConerAddr: miConfig.OrgName,
  1718. ConerTel: admin.Mobile,
  1719. HiType: order.Insutype,
  1720. Insuplc: his.InsuplcAdmdvs,
  1721. MaindiagFlag: "1",
  1722. BillCode: order.FaPiaoCode,
  1723. BillNo: order.FaPiaoNumber,
  1724. BizSn: order.Number,
  1725. PsnSelfPay: order.PsnPartAmt,
  1726. PsnOwnPay: order.PsnPartAmt,
  1727. AcctPay: order.AcctPay,
  1728. PsnCashpay: order.PsnCashPay,
  1729. HiPaymtd: "1",
  1730. Hsorg: his.InsuplcAdmdvs,
  1731. HsorgOpter: his.InsuplcAdmdvs,
  1732. MedinsFillPsn: curRoles.UserName,
  1733. MedinsFillDept: depart.Name,
  1734. IptMedType: "2",
  1735. }
  1736. struct4101.SetlBegnDate = order.SetlTime
  1737. struct4101.SetlEndDate = order.SetlTime
  1738. //if order.SettleType == 1 {
  1739. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  1740. // dateStr := t.Format("2006-01-02")
  1741. // struct4101.SetlBegnDate = dateStr
  1742. // struct4101.SetlEndDate = dateStr
  1743. //} else {
  1744. // t := time.Unix(int64(order.SettleStartTime), 0)
  1745. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  1746. // dateStartStr := t.Format("2006-01-02")
  1747. // dateEndStr := t2.Format("2006-01-02")
  1748. // struct4101.SetlBegnDate = dateStartStr
  1749. // struct4101.SetlEndDate = dateEndStr
  1750. //}
  1751. var rf []CustomFundPay
  1752. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1753. var tempFunPays []service.CustomStruct
  1754. var tempFunPay610100 service.CustomStruct
  1755. for _, item := range rf {
  1756. if item.FundPayType == "610100" {
  1757. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  1758. tempFunPay610100.FundPayType = item.FundPayType
  1759. } else {
  1760. var tempFunPay service.CustomStruct
  1761. tempFunPay.FundPayamt = item.FundPayamt
  1762. tempFunPay.FundPayType = item.FundPayType
  1763. tempFunPays = append(tempFunPays, tempFunPay)
  1764. }
  1765. }
  1766. tempFunPays = append(tempFunPays, tempFunPay610100)
  1767. struct4101.CustomStruct = tempFunPays
  1768. var tempDiaginfos []service.DiaginfoStructTwo
  1769. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1770. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1771. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1772. var config []*models.HisXtDiagnoseConfig
  1773. for _, item := range diagnosis_ids {
  1774. id, _ := strconv.ParseInt(item, 10, 64)
  1775. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1776. config = append(config, &diagnosisConfig)
  1777. }
  1778. for index, item := range config {
  1779. if index == 0 {
  1780. var tempDiaginfo service.DiaginfoStructTwo
  1781. tempDiaginfo.DiagCode = item.CountryCode
  1782. tempDiaginfo.DiagName = item.CountryContentName
  1783. tempDiaginfo.DiagType = "1"
  1784. tempDiaginfo.MaindiagFlag = "1"
  1785. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1786. } else {
  1787. var tempDiaginfo service.DiaginfoStructTwo
  1788. tempDiaginfo.DiagCode = item.CountryCode
  1789. tempDiaginfo.DiagName = item.CountryContentName
  1790. tempDiaginfo.DiagType = "2"
  1791. tempDiaginfo.MaindiagFlag = "0"
  1792. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1793. }
  1794. }
  1795. struct4101.Diseinfo = tempDiaginfos
  1796. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1797. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1798. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1799. tempOpspdiseinfo2.OprnOprtCode = ""
  1800. tempOpspdiseinfo2.OprnOprtName = ""
  1801. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1802. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1803. var iteminfo service.IteminfoStruct
  1804. var bedCostTotal float64 = 0 //床位总费
  1805. var bedCostSelfTotal float64 = 0 //床位自费
  1806. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1807. var examineCostTotal float64 = 0 //诊查总费
  1808. var examineCostSelfTotal float64 = 0 //诊查自费
  1809. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  1810. var nursingCostTotal float64 = 0 //护理总费
  1811. var nursingCostSelfTotal float64 = 0 //护理自费
  1812. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  1813. var chineseMedicineCostTotal float64 = 0 //中成药
  1814. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  1815. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  1816. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  1817. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  1818. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  1819. var registerCostTotal float64 = 0 //一般诊疗费
  1820. var registerCostSelfTotal float64 = 0 //一般诊疗费
  1821. var registerPartSelfTotal float64 = 0 //一般诊疗费
  1822. var operationCostTotal float64 = 0 //手术费
  1823. var operationCostSelfTotal float64 = 0 //手术费
  1824. var operationCostPartSelfTotal float64 = 0 //手术费
  1825. var otherCostTotal float64 = 0 //其他费用
  1826. var otherCostSelfTotal float64 = 0 //其他费用
  1827. var otherCostPartSelfTotal float64 = 0 //其他费用
  1828. var materialCostTotal float64 = 0 //材料费
  1829. var materialCostSelfTotal float64 = 0 //材料费
  1830. var materialCostPartSelfTotal float64 = 0 //材料费
  1831. var westernMedicineCostTotal float64 = 0 //西药费
  1832. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1833. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1834. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1835. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1836. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1837. var checkCostTotal float64 = 0 //检查费
  1838. var checkCostSelfTotal float64 = 0 //检查费
  1839. var checkCostPartSelfTotal float64 = 0 //检查费
  1840. var laboratoryCostTotal float64 = 0 //化验费
  1841. var laboratoryCostSelfTotal float64 = 0 //化验费
  1842. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1843. var treatCostTotal float64 = 0 //治疗费用
  1844. var treatCostSelfTotal float64 = 0 //治疗费用
  1845. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1846. decimal.DivisionPrecision = 2
  1847. var bed_fulamt_ownpay_amt float64 = 0
  1848. var examine_fulamt_ownpay_amt float64 = 0
  1849. var nursing_fulamt_ownpay_amt float64 = 0
  1850. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1851. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1852. var register_fulamt_ownpay_amt float64 = 0
  1853. var operation_fulamt_ownpay_amt float64 = 0
  1854. var other_fulamt_ownpay_amt float64 = 0
  1855. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1856. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1857. var check_fulamt_ownpay_amt float64 = 0
  1858. var material_fulamt_ownpay_amt float64 = 0
  1859. var laboratory_fulamt_ownpay_amt float64 = 0
  1860. var treat_fulamt_ownpay_amt float64 = 0
  1861. var bed_claa_sunmfee float64 = 0
  1862. var bed_clab_amt float64 = 0
  1863. var bed_other_amt float64 = 0
  1864. var examine_claa_sunmfee float64 = 0
  1865. var examine_clab_amt float64 = 0
  1866. var examine_other_amt float64 = 0
  1867. var nursing_claa_sunmfee float64 = 0
  1868. var nursing_clab_amt float64 = 0
  1869. var nursing_other_amt float64 = 0
  1870. var chinese_medicine_claa_sunmfee float64 = 0
  1871. var chinese_medicine_clab_amt float64 = 0
  1872. var chinese_medicine_other_amt float64 = 0
  1873. var commonly_treatment_claa_sunmfee float64 = 0
  1874. var commonly_treatment_clab_amt float64 = 0
  1875. var commonly_treatment_other_amt float64 = 0
  1876. var operation_claa_sunmfee float64 = 0
  1877. var operation_clab_amt float64 = 0
  1878. var operation_other_amt float64 = 0
  1879. var other_claa_sunmfee float64 = 0
  1880. var other_clab_amt float64 = 0
  1881. var other_other_amt float64 = 0
  1882. var westernMedicine_claa_sunmfee float64 = 0
  1883. var westernMedicine_clab_amt float64 = 0
  1884. var westernMedicine_other_amt float64 = 0
  1885. var chineseTraditional_claa_sunmfee float64 = 0
  1886. var chineseTraditional_clab_amt float64 = 0
  1887. var chineseTraditional_other_amt float64 = 0
  1888. var check_claa_sunmfee float64 = 0
  1889. var check_clab_amt float64 = 0
  1890. var check_other_amt float64 = 0
  1891. var material_claa_sunmfee float64 = 0
  1892. var material_clab_amt float64 = 0
  1893. var material_other_amt float64 = 0
  1894. var laboratory_claa_sunmfee float64 = 0
  1895. var laboratory_clab_amt float64 = 0
  1896. var laboratory_other_amt float64 = 0
  1897. var treat_claa_sunmfee float64 = 0
  1898. var treat_clab_amt float64 = 0
  1899. var treat_other_amt float64 = 0
  1900. var register_claa_sunmfee float64 = 0
  1901. var register_clab_amt float64 = 0
  1902. var register_other_amt float64 = 0
  1903. for _, item := range order.HisOrderInfo {
  1904. if item.MedChrgitmType == "01" { //床位费
  1905. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1906. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1907. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1908. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1909. if item.ChrgitmLv == "1" {
  1910. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1911. }
  1912. if item.ChrgitmLv == "2" {
  1913. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1914. }
  1915. if item.ChrgitmLv == "3" {
  1916. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1917. }
  1918. }
  1919. if item.MedChrgitmType == "02" { //诊查
  1920. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1921. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1922. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1923. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1924. if item.ChrgitmLv == "1" {
  1925. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1926. }
  1927. if item.ChrgitmLv == "2" {
  1928. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1929. }
  1930. if item.ChrgitmLv == "3" {
  1931. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1932. }
  1933. }
  1934. if item.MedChrgitmType == "03" { //检查费
  1935. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1936. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1937. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1938. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1939. if item.ChrgitmLv == "1" {
  1940. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1941. }
  1942. if item.ChrgitmLv == "2" {
  1943. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1944. }
  1945. if item.ChrgitmLv == "3" {
  1946. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1947. }
  1948. }
  1949. if item.MedChrgitmType == "04" { //化验费
  1950. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1951. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1952. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1953. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1954. if item.ChrgitmLv == "1" {
  1955. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1956. }
  1957. if item.ChrgitmLv == "2" {
  1958. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1959. }
  1960. if item.ChrgitmLv == "3" {
  1961. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1962. }
  1963. }
  1964. if item.MedChrgitmType == "05" { //治疗费
  1965. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1966. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1967. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1968. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1969. if item.ChrgitmLv == "1" {
  1970. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1971. }
  1972. if item.ChrgitmLv == "2" {
  1973. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1974. }
  1975. if item.ChrgitmLv == "3" {
  1976. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1977. }
  1978. }
  1979. if item.MedChrgitmType == "06" { //手术费
  1980. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1981. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1982. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1983. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1984. if item.ChrgitmLv == "1" {
  1985. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1986. }
  1987. if item.ChrgitmLv == "2" {
  1988. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1989. }
  1990. if item.ChrgitmLv == "3" {
  1991. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1992. }
  1993. }
  1994. if item.MedChrgitmType == "07" { //手术费
  1995. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1996. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1997. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1998. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1999. if item.ChrgitmLv == "1" {
  2000. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2001. }
  2002. if item.ChrgitmLv == "2" {
  2003. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2004. }
  2005. if item.ChrgitmLv == "3" {
  2006. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2007. }
  2008. }
  2009. if item.MedChrgitmType == "08" { //材料费
  2010. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2011. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2012. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2013. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2014. if item.ChrgitmLv == "1" {
  2015. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2016. }
  2017. if item.ChrgitmLv == "2" {
  2018. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2019. }
  2020. if item.ChrgitmLv == "3" {
  2021. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2022. }
  2023. }
  2024. if item.MedChrgitmType == "09" { //西药费
  2025. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2026. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2027. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2028. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2029. if item.ChrgitmLv == "1" {
  2030. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2031. }
  2032. if item.ChrgitmLv == "2" {
  2033. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2034. }
  2035. if item.ChrgitmLv == "3" {
  2036. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2037. }
  2038. }
  2039. if item.MedChrgitmType == "10" { //中药饮片
  2040. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2041. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2042. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2043. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2044. if item.ChrgitmLv == "1" {
  2045. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2046. }
  2047. if item.ChrgitmLv == "2" {
  2048. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2049. }
  2050. if item.ChrgitmLv == "3" {
  2051. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2052. }
  2053. }
  2054. if item.MedChrgitmType == "11" { //中成费
  2055. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2056. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2057. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2058. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2059. if item.ChrgitmLv == "1" {
  2060. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2061. }
  2062. if item.ChrgitmLv == "2" {
  2063. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2064. }
  2065. if item.ChrgitmLv == "3" {
  2066. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2067. }
  2068. }
  2069. if item.MedChrgitmType == "12" { //中成费
  2070. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2071. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2072. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2073. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2074. if item.ChrgitmLv == "1" {
  2075. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2076. }
  2077. if item.ChrgitmLv == "2" {
  2078. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2079. }
  2080. if item.ChrgitmLv == "3" {
  2081. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2082. }
  2083. }
  2084. if item.MedChrgitmType == "13" { //中成费
  2085. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2086. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2087. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2088. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2089. if item.ChrgitmLv == "1" {
  2090. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2091. }
  2092. if item.ChrgitmLv == "2" {
  2093. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2094. }
  2095. if item.ChrgitmLv == "3" {
  2096. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2097. }
  2098. }
  2099. if item.MedChrgitmType == "14" { //其他费
  2100. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2101. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2102. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2103. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2104. if item.ChrgitmLv == "1" {
  2105. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2106. }
  2107. if item.ChrgitmLv == "2" {
  2108. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2109. }
  2110. if item.ChrgitmLv == "3" {
  2111. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2112. }
  2113. }
  2114. }
  2115. var iteminfoStructs []service.IteminfoStruct
  2116. if bedCostTotal != 0 {
  2117. iteminfo.MedChrgitm = "01"
  2118. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2119. iteminfo.Amt = bedCostTotal
  2120. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2121. iteminfo.ClabAmt = bed_clab_amt
  2122. iteminfo.OthAmt = bed_other_amt
  2123. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2124. }
  2125. if examineCostTotal != 0 {
  2126. iteminfo.MedChrgitm = "02"
  2127. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2128. iteminfo.Amt = examineCostTotal
  2129. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2130. iteminfo.ClabAmt = examine_clab_amt
  2131. iteminfo.OthAmt = examine_other_amt
  2132. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2133. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2134. }
  2135. if checkCostTotal != 0 {
  2136. iteminfo.MedChrgitm = "03"
  2137. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2138. iteminfo.Amt = checkCostTotal
  2139. iteminfo.ClaaSumfee = check_claa_sunmfee
  2140. iteminfo.ClabAmt = check_clab_amt
  2141. iteminfo.OthAmt = check_other_amt
  2142. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2143. }
  2144. if laboratoryCostTotal != 0 {
  2145. iteminfo.MedChrgitm = "04"
  2146. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2147. iteminfo.Amt = laboratoryCostTotal
  2148. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2149. iteminfo.ClabAmt = laboratory_clab_amt
  2150. iteminfo.OthAmt = laboratory_other_amt
  2151. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2152. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2153. }
  2154. if treatCostTotal != 0 {
  2155. iteminfo.MedChrgitm = "05"
  2156. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2157. iteminfo.Amt = treatCostTotal
  2158. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2159. iteminfo.ClabAmt = treat_clab_amt
  2160. iteminfo.OthAmt = treat_other_amt
  2161. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2162. //(struct4101.IteminfoStruct, iteminfo)
  2163. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2164. }
  2165. if operationCostTotal != 0 {
  2166. iteminfo.MedChrgitm = "06"
  2167. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2168. iteminfo.Amt = operationCostTotal
  2169. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2170. iteminfo.ClabAmt = operation_clab_amt
  2171. iteminfo.OthAmt = operation_other_amt
  2172. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2173. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2174. }
  2175. if nursingCostTotal != 0 {
  2176. iteminfo.MedChrgitm = "07"
  2177. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2178. iteminfo.Amt = nursingCostTotal
  2179. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2180. iteminfo.ClabAmt = nursing_clab_amt
  2181. iteminfo.OthAmt = nursing_other_amt
  2182. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2183. }
  2184. if materialCostTotal != 0 {
  2185. iteminfo.MedChrgitm = "08"
  2186. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2187. iteminfo.Amt = materialCostTotal
  2188. iteminfo.ClaaSumfee = material_claa_sunmfee
  2189. iteminfo.ClabAmt = material_clab_amt
  2190. iteminfo.OthAmt = material_other_amt
  2191. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2192. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2193. }
  2194. if westernMedicineCostTotal != 0 {
  2195. iteminfo.MedChrgitm = "09"
  2196. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2197. iteminfo.Amt = westernMedicineCostTotal
  2198. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2199. iteminfo.ClabAmt = westernMedicine_clab_amt
  2200. iteminfo.OthAmt = westernMedicine_other_amt
  2201. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2202. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2203. }
  2204. if chineseMedicineCostTotal != 0 {
  2205. iteminfo.MedChrgitm = "10"
  2206. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2207. iteminfo.Amt = chineseMedicineCostTotal
  2208. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2209. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2210. iteminfo.OthAmt = chinese_medicine_other_amt
  2211. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2212. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2213. }
  2214. if chineseTraditionalMedicineCostTotal != 0 {
  2215. iteminfo.MedChrgitm = "11"
  2216. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2217. iteminfo.Amt = westernMedicineCostTotal
  2218. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2219. iteminfo.ClabAmt = westernMedicine_clab_amt
  2220. iteminfo.OthAmt = westernMedicine_other_amt
  2221. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2222. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2223. }
  2224. if commonlyTreatmentCostTotal != 0 {
  2225. iteminfo.MedChrgitm = "12"
  2226. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2227. iteminfo.Amt = commonlyTreatmentCostTotal
  2228. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2229. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2230. iteminfo.OthAmt = commonly_treatment_other_amt
  2231. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2232. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2233. }
  2234. if registerCostTotal != 0 {
  2235. iteminfo.MedChrgitm = "13"
  2236. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2237. iteminfo.Amt = registerCostTotal
  2238. iteminfo.ClaaSumfee = register_claa_sunmfee
  2239. iteminfo.ClabAmt = register_clab_amt
  2240. iteminfo.OthAmt = register_other_amt
  2241. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2242. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2243. }
  2244. if otherCostTotal != 0 {
  2245. iteminfo.MedChrgitm = "14"
  2246. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2247. iteminfo.Amt = otherCostTotal
  2248. iteminfo.ClaaSumfee = other_claa_sunmfee
  2249. iteminfo.ClabAmt = other_clab_amt
  2250. iteminfo.OthAmt = other_other_amt
  2251. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2252. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2253. }
  2254. struct4101.IteminfoStruct = iteminfoStructs
  2255. struct4101.Ntly = "中国"
  2256. struct4101.AdmCaty = "A03.06"
  2257. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  2258. fmt.Println(result)
  2259. var dat map[string]interface{}
  2260. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2261. fmt.Println(dat)
  2262. } else {
  2263. fmt.Println(err)
  2264. }
  2265. userJSONBytes, _ := json.Marshal(dat)
  2266. var res ResultSeventeen
  2267. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2268. utils.ErrorLog("解析失败:%v", err)
  2269. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2270. adminUser := c.GetAdminUserInfo()
  2271. errlog := &models.HisOrderError{
  2272. UserOrgId: adminUser.CurrentOrgId,
  2273. Ctime: time.Now().Unix(),
  2274. Mtime: time.Now().Unix(),
  2275. ErrMsg: res.ErrMsg + "解析失败",
  2276. Status: 1,
  2277. PatientId: order_id,
  2278. Stage: 10106,
  2279. }
  2280. service.CreateErrMsgLog(errlog)
  2281. continue
  2282. }
  2283. if res.Infcode != 0 {
  2284. adminUser := c.GetAdminUserInfo()
  2285. errlog := &models.HisOrderError{
  2286. UserOrgId: adminUser.CurrentOrgId,
  2287. Ctime: time.Now().Unix(),
  2288. Mtime: time.Now().Unix(),
  2289. ErrMsg: res.ErrMsg,
  2290. Status: 1,
  2291. PatientId: order_id,
  2292. Stage: 10106,
  2293. }
  2294. service.CreateErrMsgLog(errlog)
  2295. continue
  2296. } else {
  2297. hisFundSettleListResult := &models.HisFundSettleListResult{
  2298. Number: res.Output.SetlListId,
  2299. Status: 1,
  2300. Ctime: time.Now().Unix(),
  2301. Mtime: time.Now().Unix(),
  2302. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2303. IsUpload: 1,
  2304. OrderId: order_id,
  2305. }
  2306. service.CreateUploadRecord(hisFundSettleListResult)
  2307. continue
  2308. }
  2309. }
  2310. }
  2311. func (c *HisApiController) GetOrgInfo() {
  2312. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2313. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2314. }
  2315. func (c *HisApiController) GetHisPatientInfo() {
  2316. medical_insurance_card := c.GetString("medical_insurance_card")
  2317. id_card_type, _ := c.GetInt64("id_card_type")
  2318. id_card := c.GetString("id_card")
  2319. adminInfo := c.GetAdminUserInfo()
  2320. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2321. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2322. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2323. IdCardNo := ""
  2324. if id_card_type == 1 {
  2325. IdCardNo = medical_insurance_card
  2326. } else if id_card_type == 2 {
  2327. IdCardNo = id_card
  2328. }
  2329. if config.IsOpen == 1 {
  2330. 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
  2331. resp, requestErr := http.Get(api)
  2332. if requestErr != nil {
  2333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2334. return
  2335. }
  2336. defer resp.Body.Close()
  2337. body, ioErr := ioutil.ReadAll(resp.Body)
  2338. if ioErr != nil {
  2339. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2341. return
  2342. }
  2343. var respJSON map[string]interface{}
  2344. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2345. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2347. return
  2348. }
  2349. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2350. userJSONBytes, _ := json.Marshal(userJSON)
  2351. var res ResultTwo
  2352. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2353. utils.ErrorLog("解析失败:%v", err)
  2354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2355. return
  2356. }
  2357. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2358. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2359. infoStr := string(Iinfos)
  2360. idetinfoStr := string(Idetinfos)
  2361. if res.Infcode == 0 {
  2362. his := models.VMHisPatient{
  2363. Status: 1,
  2364. Ctime: time.Now().Unix(),
  2365. Mtime: time.Now().Unix(),
  2366. PsnNo: res.Output.Baseinfo.PsnNo,
  2367. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2368. Certno: res.Output.Baseinfo.Certno,
  2369. PsnName: res.Output.Baseinfo.PsnName,
  2370. Gend: res.Output.Baseinfo.Gend,
  2371. Naty: res.Output.Baseinfo.Naty,
  2372. Brdy: res.Output.Baseinfo.Brdy,
  2373. Age: res.Output.Baseinfo.Age,
  2374. Iinfo: infoStr,
  2375. Idetinfo: idetinfoStr,
  2376. UserOrgId: adminInfo.CurrentOrgId,
  2377. IsReturn: 1,
  2378. IdCardType: id_card_type,
  2379. }
  2380. c.ServeSuccessJSON(map[string]interface{}{
  2381. "info": his,
  2382. })
  2383. } else {
  2384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2385. return
  2386. }
  2387. }
  2388. }
  2389. //func GetBasBaseInfo() (jsonStr string, err error) {
  2390. //
  2391. // handle := syscall.NewLazyDLL("SSCard.dll")
  2392. // add := handle.NewProc("ReadCardBas")
  2393. // str := make([]byte, 1024)
  2394. // str1 := make([]byte, 1024)
  2395. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2396. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  2397. //
  2398. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  2399. //
  2400. // fmt.Println("> Add(4,5)的结果为:", ret)
  2401. // handle.Release()
  2402. //
  2403. // return "", nil
  2404. //
  2405. //}
  2406. //func GetQRBaseInfo() (jsonStr string, err error) {
  2407. // handle := syscall.LoadDLL("SSCard.dll")
  2408. // ReadCardBas := handle.FindProc("GetQRBase")
  2409. //
  2410. // str := make([]byte, 256)
  2411. // str1 := make([]byte, 256)
  2412. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2413. //
  2414. // fmt.Println(string(str))
  2415. // fmt.Println(r)
  2416. // return string(str), nil
  2417. //}
  2418. //func CardInit() int {
  2419. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  2420. // add := DllTestDef.MustFindProc("Init")
  2421. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2422. // if err != nil {
  2423. // fmt.Println("SSCard的运算结果为:", ret)
  2424. // }
  2425. // result := int(ret)
  2426. // return result
  2427. //}
  2428. //func CardInit() int {
  2429. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2430. // if err != nil {
  2431. // fmt.Println("SSCard的运算结果为:", ret)
  2432. // }
  2433. // fmt.Println(err)
  2434. // result := int(ret)
  2435. // return result
  2436. //}
  2437. func IntPtr(n int) uintptr {
  2438. return uintptr(n)
  2439. }
  2440. func StrPtr(s string) uintptr {
  2441. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  2442. }
  2443. type Result2001 struct {
  2444. Cainfo interface{} `json:"cainfo"`
  2445. ErrMsg string `json:"err_msg"`
  2446. InfRefmsgid string `json:"inf_refmsgid"`
  2447. Infcode int64 `json:"infcode"`
  2448. Output struct {
  2449. Trtinfo struct {
  2450. PsnNo string `json:"psn_no"`
  2451. TrtChkType string `json:"trt_chk_type"`
  2452. FundPayType string `json:"fund_pay_type"`
  2453. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2454. Begndate string `json:"begndate"`
  2455. Enddate string `json:"enddate"`
  2456. TrtChkRslt string `json:"trt_chk_rslt"`
  2457. } `json:"trtinfo"`
  2458. } `json:"output"`
  2459. RefmsgTime string `json:"refmsg_time"`
  2460. RespondTime string `json:"respond_time"`
  2461. Signtype interface{} `json:"signtype"`
  2462. WarnMsg interface{} `json:"warn_msg"`
  2463. }
  2464. type Result2001Org10265 struct {
  2465. Cainfo interface{} `json:"cainfo"`
  2466. ErrMsg string `json:"err_msg"`
  2467. InfRefmsgid string `json:"inf_refmsgid"`
  2468. Infcode string `json:"infcode"`
  2469. Output struct {
  2470. Trtinfo struct {
  2471. PsnNo string `json:"psn_no"`
  2472. TrtChkType string `json:"trt_chk_type"`
  2473. FundPayType string `json:"fund_pay_type"`
  2474. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2475. Begndate string `json:"begndate"`
  2476. Enddate string `json:"enddate"`
  2477. TrtChkRslt string `json:"trt_chk_rslt"`
  2478. } `json:"trtinfo"`
  2479. } `json:"output"`
  2480. RefmsgTime string `json:"refmsg_time"`
  2481. RespondTime string `json:"respond_time"`
  2482. Signtype interface{} `json:"signtype"`
  2483. WarnMsg interface{} `json:"warn_msg"`
  2484. }
  2485. type ResultTwo struct {
  2486. ErrMsg string `json:"err_msg"`
  2487. InfRefmsgid string `json:"inf_refmsgid"`
  2488. Infcode int64 `json:"infcode"`
  2489. Output struct {
  2490. Baseinfo struct {
  2491. Age float64 `json:"age"`
  2492. Brdy string `json:"brdy"`
  2493. Certno string `json:"certno"`
  2494. Gend string `json:"gend"`
  2495. Naty string `json:"naty"`
  2496. PsnCertType string `json:"psn_cert_type"`
  2497. PsnName string `json:"psn_name"`
  2498. PsnNo string `json:"psn_no"`
  2499. } `json:"baseinfo"`
  2500. Idetinfo []interface{} `json:"idetinfo"`
  2501. Iinfo []struct {
  2502. Balc float64 `json:"balc"`
  2503. CvlservFlag string `json:"cvlserv_flag"`
  2504. EmpName string `json:"emp_name"`
  2505. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2506. Insutype string `json:"insutype"`
  2507. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2508. PausInsuDate string `json:"paus_insu_date"`
  2509. PsnInsuDate string `json:"psn_insu_date"`
  2510. PsnInsuStas string `json:"psn_insu_stas"`
  2511. PsnType string `json:"psn_type"`
  2512. } `json:"insuinfo"`
  2513. } `json:"output"`
  2514. RefmsgTime string `json:"refmsg_time"`
  2515. RespondTime string `json:"respond_time"`
  2516. Signtype interface{} `json:"signtype"`
  2517. WarnInfo interface{} `json:"warn_info"`
  2518. }
  2519. type ResultTwo10265 struct {
  2520. ErrMsg string `json:"err_msg"`
  2521. InfRefmsgid string `json:"inf_refmsgid"`
  2522. Infcode string `json:"infcode"`
  2523. Output struct {
  2524. Baseinfo struct {
  2525. Age float64 `json:"age"`
  2526. Brdy string `json:"brdy"`
  2527. Certno string `json:"certno"`
  2528. Gend string `json:"gend"`
  2529. Naty string `json:"naty"`
  2530. PsnCertType string `json:"psn_cert_type"`
  2531. PsnName string `json:"psn_name"`
  2532. PsnNo string `json:"psn_no"`
  2533. } `json:"baseinfo"`
  2534. Idetinfo []interface{} `json:"idetinfo"`
  2535. Iinfo []struct {
  2536. Balc float64 `json:"balc"`
  2537. CvlservFlag string `json:"cvlserv_flag"`
  2538. EmpName string `json:"emp_name"`
  2539. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2540. Insutype string `json:"insutype"`
  2541. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2542. PausInsuDate string `json:"paus_insu_date"`
  2543. PsnInsuDate string `json:"psn_insu_date"`
  2544. PsnInsuStas string `json:"psn_insu_stas"`
  2545. PsnType string `json:"psn_type"`
  2546. } `json:"insuinfo"`
  2547. } `json:"output"`
  2548. RefmsgTime string `json:"refmsg_time"`
  2549. RespondTime string `json:"respond_time"`
  2550. Signtype interface{} `json:"signtype"`
  2551. WarnInfo interface{} `json:"warn_info"`
  2552. }
  2553. type ResultThree struct {
  2554. Cainfo interface{} `json:"cainfo"`
  2555. ErrMsg string `json:"err_msg"`
  2556. InfRefmsgid string `json:"inf_refmsgid"`
  2557. Infcode int64 `json:"infcode"`
  2558. Output struct {
  2559. Data struct {
  2560. IptOtpNo string `json:"ipt_otp_no"`
  2561. MdtrtID string `json:"mdtrt_id"`
  2562. PsnNo string `json:"psn_no"`
  2563. } `json:"data"`
  2564. } `json:"output"`
  2565. RefmsgTime string `json:"refmsg_time"`
  2566. RespondTime string `json:"respond_time"`
  2567. Signtype interface{} `json:"signtype"`
  2568. WarnMsg interface{} `json:"warn_msg"`
  2569. }
  2570. type ResultThree10265 struct {
  2571. Cainfo interface{} `json:"cainfo"`
  2572. ErrMsg string `json:"err_msg"`
  2573. InfRefmsgid string `json:"inf_refmsgid"`
  2574. Infcode string `json:"infcode"`
  2575. Output struct {
  2576. Data struct {
  2577. IptOtpNo string `json:"ipt_otp_no"`
  2578. MdtrtID string `json:"mdtrt_id"`
  2579. PsnNo string `json:"psn_no"`
  2580. } `json:"data"`
  2581. } `json:"output"`
  2582. RefmsgTime string `json:"refmsg_time"`
  2583. RespondTime string `json:"respond_time"`
  2584. Signtype interface{} `json:"signtype"`
  2585. WarnMsg interface{} `json:"warn_msg"`
  2586. }
  2587. type ResultFour struct {
  2588. Cainfo string `json:"cainfo"`
  2589. ErrMsg string `json:"err_msg"`
  2590. InfRefmsgid string `json:"inf_refmsgid"`
  2591. Infcode int64 `json:"infcode"`
  2592. Output struct {
  2593. Result []struct {
  2594. BasMednFlag string `json:"bas_medn_flag"`
  2595. ChldMedcFlag string `json:"chld_medc_flag"`
  2596. ChrgitmLv string `json:"chrgitm_lv"`
  2597. Cnt float64 `json:"cnt"`
  2598. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2599. DrtReimFlag string `json:"drt_reim_flag"`
  2600. FeedetlSn string `json:"feedetl_sn"`
  2601. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2602. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2603. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2604. ListSpItemFlag string `json:"list_sp_item_flag"`
  2605. LmtUsedFlag string `json:"lmt_used_flag"`
  2606. MedChrgitmType string `json:"med_chrgitm_type"`
  2607. Memo string `json:"memo"`
  2608. OverlmtAmt float64 `json:"overlmt_amt"`
  2609. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2610. Pric float64 `json:"pric"`
  2611. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2612. SelfpayProp float64 `json:"selfpay_prop"`
  2613. } `json:"result"`
  2614. } `json:"output"`
  2615. RefmsgTime string `json:"refmsg_time"`
  2616. RespondTime string `json:"respond_time"`
  2617. Signtype string `json:"signtype"`
  2618. WarnMsg string `json:"warn_msg"`
  2619. }
  2620. type ResultFour10265 struct {
  2621. Cainfo string `json:"cainfo"`
  2622. ErrMsg string `json:"err_msg"`
  2623. InfRefmsgid string `json:"inf_refmsgid"`
  2624. Infcode string `json:"infcode"`
  2625. Output struct {
  2626. Result []struct {
  2627. BasMednFlag string `json:"bas_medn_flag"`
  2628. ChldMedcFlag string `json:"chld_medc_flag"`
  2629. ChrgitmLv string `json:"chrgitm_lv"`
  2630. Cnt float64 `json:"cnt"`
  2631. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2632. DrtReimFlag string `json:"drt_reim_flag"`
  2633. FeedetlSn string `json:"feedetl_sn"`
  2634. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2635. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2636. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2637. ListSpItemFlag string `json:"list_sp_item_flag"`
  2638. LmtUsedFlag string `json:"lmt_used_flag"`
  2639. MedChrgitmType string `json:"med_chrgitm_type"`
  2640. Memo string `json:"memo"`
  2641. OverlmtAmt float64 `json:"overlmt_amt"`
  2642. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2643. Pric float64 `json:"pric"`
  2644. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2645. SelfpayProp float64 `json:"selfpay_prop"`
  2646. } `json:"result"`
  2647. } `json:"output"`
  2648. RefmsgTime string `json:"refmsg_time"`
  2649. RespondTime string `json:"respond_time"`
  2650. Signtype string `json:"signtype"`
  2651. WarnMsg string `json:"warn_msg"`
  2652. }
  2653. type ResultFive struct {
  2654. Balc float64 `json:"balc"`
  2655. CvlservFlag string `json:"cvlserv_flag"`
  2656. EmpName string `json:"emp_name"`
  2657. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2658. Insutype string `json:"insutype"`
  2659. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2660. PausInsuDate string `json:"paus_insu_date"`
  2661. PsnInsuDate string `json:"psn_insu_date"`
  2662. PsnInsuStas string `json:"psn_insu_stas"`
  2663. PsnType string `json:"psn_type"`
  2664. }
  2665. type ResultSix struct {
  2666. Cainfo interface{} `json:"cainfo"`
  2667. ErrMsg string `json:"err_msg"`
  2668. InfRefmsgid string `json:"inf_refmsgid"`
  2669. Infcode int64 `json:"infcode"`
  2670. Output struct {
  2671. } `json:"output"`
  2672. RefmsgTime string `json:"refmsg_time"`
  2673. RespondTime string `json:"respond_time"`
  2674. Signtype interface{} `json:"signtype"`
  2675. WarnMsg interface{} `json:"warn_msg"`
  2676. }
  2677. type ResultSix10265 struct {
  2678. Cainfo interface{} `json:"cainfo"`
  2679. ErrMsg string `json:"err_msg"`
  2680. InfRefmsgid string `json:"inf_refmsgid"`
  2681. Infcode string `json:"infcode"`
  2682. Output struct {
  2683. } `json:"output"`
  2684. RefmsgTime string `json:"refmsg_time"`
  2685. RespondTime string `json:"respond_time"`
  2686. Signtype interface{} `json:"signtype"`
  2687. WarnMsg interface{} `json:"warn_msg"`
  2688. }
  2689. type ResultSeven struct {
  2690. Cainfo string `json:"cainfo"`
  2691. ErrMsg string `json:"err_msg"`
  2692. InfRefmsgid string `json:"inf_refmsgid"`
  2693. Infcode int64 `json:"infcode"`
  2694. Output struct {
  2695. Setldetail []interface{} `json:"setldetail"`
  2696. Setlinfo struct {
  2697. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2698. AcctPay float64 `json:"acct_pay"`
  2699. ActPayDedc float64 `json:"act_pay_dedc"`
  2700. Age float64 `json:"age"`
  2701. Balc float64 `json:"balc"`
  2702. Brdy string `json:"brdy"`
  2703. Certno string `json:"certno"`
  2704. ClrOptins string `json:"clr_optins"`
  2705. ClrType string `json:"clr_type"`
  2706. ClrWay string `json:"clr_way"`
  2707. CvlservFlag string `json:"cvlserv_flag"`
  2708. CvlservPay float64 `json:"cvlserv_pay"`
  2709. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2710. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2711. Gend string `json:"gend"`
  2712. HifesPay float64 `json:"hifes_pay"`
  2713. HifmiPay float64 `json:"hifmi_pay"`
  2714. HifpPay float64 `json:"hifp_pay"`
  2715. HospPartAmt float64 `json:"hosp_part_amt"`
  2716. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2717. Insutype string `json:"insutype"`
  2718. MafPay float64 `json:"maf_pay"`
  2719. MdtrtCertType string `json:"mdtrt_cert_type"`
  2720. HifobPay float64 `json:"hifob_pay"`
  2721. MdtrtID string `json:"mdtrt_id"`
  2722. MedType string `json:"med_type"`
  2723. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2724. MedinsSetlID string `json:"medins_setl_id"`
  2725. Naty string `json:"naty"`
  2726. OthPay float64 `json:"oth_pay"`
  2727. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2728. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2729. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2730. PsnCashPay float64 `json:"psn_cash_pay"`
  2731. PsnCertType string `json:"psn_cert_type"`
  2732. PsnName string `json:"psn_name"`
  2733. PsnNo string `json:"psn_no"`
  2734. PsnPartAmt float64 `json:"psn_part_amt"`
  2735. PsnType string `json:"psn_type"`
  2736. SetlID string `json:"setl_id"`
  2737. SetlTime string `json:"setl_time"`
  2738. } `json:"setlinfo"`
  2739. } `json:"output"`
  2740. RefmsgTime string `json:"refmsg_time"`
  2741. RespondTime string `json:"respond_time"`
  2742. Signtype interface{} `json:"signtype"`
  2743. WarnMsg interface{} `json:"warn_msg"`
  2744. }
  2745. type ResultSeven10265 struct {
  2746. Cainfo string `json:"cainfo"`
  2747. ErrMsg string `json:"err_msg"`
  2748. InfRefmsgid string `json:"inf_refmsgid"`
  2749. Infcode string `json:"infcode"`
  2750. Output struct {
  2751. Setldetail []interface{} `json:"setldetail"`
  2752. Setlinfo struct {
  2753. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2754. AcctPay float64 `json:"acct_pay"`
  2755. ActPayDedc float64 `json:"act_pay_dedc"`
  2756. Age float64 `json:"age"`
  2757. Balc float64 `json:"balc"`
  2758. Brdy string `json:"brdy"`
  2759. Certno string `json:"certno"`
  2760. ClrOptins string `json:"clr_optins"`
  2761. ClrType string `json:"clr_type"`
  2762. ClrWay string `json:"clr_way"`
  2763. CvlservFlag string `json:"cvlserv_flag"`
  2764. CvlservPay float64 `json:"cvlserv_pay"`
  2765. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2766. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2767. Gend string `json:"gend"`
  2768. HifesPay float64 `json:"hifes_pay"`
  2769. HifmiPay float64 `json:"hifmi_pay"`
  2770. HifpPay float64 `json:"hifp_pay"`
  2771. HospPartAmt float64 `json:"hosp_part_amt"`
  2772. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2773. Insutype string `json:"insutype"`
  2774. MafPay float64 `json:"maf_pay"`
  2775. MdtrtCertType string `json:"mdtrt_cert_type"`
  2776. HifobPay float64 `json:"hifob_pay"`
  2777. MdtrtID string `json:"mdtrt_id"`
  2778. MedType string `json:"med_type"`
  2779. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2780. MedinsSetlID string `json:"medins_setl_id"`
  2781. Naty string `json:"naty"`
  2782. OthPay float64 `json:"oth_pay"`
  2783. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2784. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2785. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2786. PsnCashPay float64 `json:"psn_cash_pay"`
  2787. PsnCertType string `json:"psn_cert_type"`
  2788. PsnName string `json:"psn_name"`
  2789. PsnNo string `json:"psn_no"`
  2790. PsnPartAmt float64 `json:"psn_part_amt"`
  2791. PsnType string `json:"psn_type"`
  2792. SetlID string `json:"setl_id"`
  2793. SetlTime string `json:"setl_time"`
  2794. } `json:"setlinfo"`
  2795. } `json:"output"`
  2796. RefmsgTime string `json:"refmsg_time"`
  2797. RespondTime string `json:"respond_time"`
  2798. Signtype interface{} `json:"signtype"`
  2799. WarnMsg interface{} `json:"warn_msg"`
  2800. }
  2801. type ResultEight struct {
  2802. Cainfo string `json:"cainfo"`
  2803. ErrMsg string `json:"err_msg"`
  2804. InfRefmsgid string `json:"inf_refmsgid"`
  2805. Infcode int64 `json:"infcode"`
  2806. Output struct {
  2807. Stmtinfo struct {
  2808. SetlOptins string `json:"setl_optins"`
  2809. StmtRslt string `json:"stmt_rslt"`
  2810. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2811. } `json:"stmtinfo"`
  2812. } `json:"output"`
  2813. RefmsgTime string `json:"refmsg_time"`
  2814. RespondTime string `json:"respond_time"`
  2815. Signtype interface{} `json:"signtype"`
  2816. WarnMsg interface{} `json:"warn_msg"`
  2817. }
  2818. type ResultEightFor10188 struct {
  2819. Cainfo string `json:"cainfo"`
  2820. ErrMsg string `json:"err_msg"`
  2821. InfRefmsgid string `json:"inf_refmsgid"`
  2822. Infcode string `json:"infcode"`
  2823. Output struct {
  2824. Stmtinfo struct {
  2825. SetlOptins string `json:"setl_optins"`
  2826. StmtRslt string `json:"stmt_rslt"`
  2827. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2828. } `json:"stmtinfo"`
  2829. } `json:"output"`
  2830. RefmsgTime string `json:"refmsg_time"`
  2831. RespondTime string `json:"respond_time"`
  2832. Signtype interface{} `json:"signtype"`
  2833. WarnMsg interface{} `json:"warn_msg"`
  2834. }
  2835. type ResultNine struct {
  2836. Cainfo string `json:"cainfo"`
  2837. ErrMsg string `json:"err_msg"`
  2838. InfRefmsgid string `json:"inf_refmsgid"`
  2839. Infcode int64 `json:"infcode"`
  2840. Output struct {
  2841. FileQuryNo string `json:"file_qury_no"`
  2842. } `json:"output"`
  2843. RefmsgTime string `json:"refmsg_time"`
  2844. RespondTime string `json:"respond_time"`
  2845. Signtype interface{} `json:"signtype"`
  2846. WarnMsg interface{} `json:"warn_msg"`
  2847. }
  2848. type ResultTen struct {
  2849. Cainfo string `json:"cainfo"`
  2850. ErrMsg string `json:"err_msg"`
  2851. InfRefmsgid string `json:"inf_refmsgid"`
  2852. Infcode int64 `json:"infcode"`
  2853. Output struct {
  2854. DldEndtime string `json:"dld_endtime"`
  2855. FileQuryNo string `json:"file_qury_no"`
  2856. Filename string `json:"filename"`
  2857. } `json:"output"`
  2858. RefmsgTime string `json:"refmsg_time"`
  2859. RespondTime string `json:"respond_time"`
  2860. Signtype interface{} `json:"signtype"`
  2861. WarnMsg interface{} `json:"warn_msg"`
  2862. }
  2863. //type Autogenerated struct {
  2864. // Output struct {
  2865. // Setlinfo struct {
  2866. // SetlTime string `json:"setl_time"`
  2867. // CvlservPay float64 `json:"cvlserv_pay"`
  2868. // Year string `json:"year"`
  2869. // MedType string `json:"med_type"`
  2870. // PsnPay float64 `json:"psn_pay"`
  2871. // OpterID string `json:"opter_id"`
  2872. // Begndate string `json:"begndate"`
  2873. // FlxempeFlag string `json:"flxempe_flag"`
  2874. // HifmiPay float64 `json:"hifmi_pay"`
  2875. // PsnNo string `json:"psn_no"`
  2876. // ActPayDedc float64 `json:"act_pay_dedc"`
  2877. // MedinsSetlID interface{} `json:"medins_setl_id"`
  2878. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2879. // ClrWay string `json:"clr_way"`
  2880. // OthPay float64 `json:"oth_pay"`
  2881. // Gend string `json:"gend"`
  2882. // MdtrtID string `json:"mdtrt_id"`
  2883. // AcctPay float64 `json:"acct_pay"`
  2884. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  2885. // Insutype string `json:"insutype"`
  2886. // Invono interface{} `json:"invono"`
  2887. // Enddate string `json:"enddate"`
  2888. // CashPayamt float64 `json:"cash_payamt"`
  2889. // PsnType string `json:"psn_type"`
  2890. // FixmedinsName string `json:"fixmedins_name"`
  2891. // HifpPay float64 `json:"hifp_pay"`
  2892. // NewFlag interface{} `json:"new_flag"`
  2893. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2894. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  2895. // PayLoc string `json:"pay_loc"`
  2896. // ClrType string `json:"clr_type"`
  2897. // RefdSetlFlag string `json:"refd_setl_flag"`
  2898. // CvlservFlag string `json:"cvlserv_flag"`
  2899. // EmpName string `json:"emp_name"`
  2900. // Brdy string `json:"brdy"`
  2901. // Naty string `json:"naty"`
  2902. // Certno string `json:"certno"`
  2903. // DiseCode string `json:"dise_code"`
  2904. // FixmedinsCode string `json:"fixmedins_code"`
  2905. // DedcHospLv string `json:"dedc_hosp_lv"`
  2906. // OpterName string `json:"opter_name"`
  2907. // Balc float64 `json:"balc"`
  2908. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2909. // PsnCertType string `json:"psn_cert_type"`
  2910. // HifobPay float64 `json:"hifob_pay"`
  2911. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  2912. // HifesPay float64 `json:"hifes_pay"`
  2913. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2914. // OptTime string `json:"opt_time"`
  2915. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2916. // SetlID string `json:"setl_id"`
  2917. // MafPay float64 `json:"maf_pay"`
  2918. // PsnName string `json:"psn_name"`
  2919. // InsuOptins interface{} `json:"insu_optins"`
  2920. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2921. // ClrOptins string `json:"clr_optins"`
  2922. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2923. // DiseName string `json:"dise_name"`
  2924. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2925. // Age float64 `json:"age"`
  2926. // DtrtCertType string `json:"dtrt_cert_type"`
  2927. // HospLv string `json:"hosp_lv"`
  2928. // } `json:"setlinfo"`
  2929. // Setldetail []struct {
  2930. // FundPayType string `json:"fund_pay_type"`
  2931. // FundPayamt float64 `json:"fund_payamt"`
  2932. // SetlProcInfo interface{} `json:"setl_proc_info"`
  2933. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  2934. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  2935. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  2936. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2937. // } `json:"setldetail"`
  2938. // } `json:"output"`
  2939. // Infcode int `json:"infcode"`
  2940. // WarnMsg interface{} `json:"warn_msg"`
  2941. // Cainfo interface{} `json:"cainfo"`
  2942. // ErrMsg interface{} `json:"err_msg"`
  2943. // RefmsgTime string `json:"refmsg_time"`
  2944. // Signtype interface{} `json:"signtype"`
  2945. // RespondTime string `json:"respond_time"`
  2946. // InfRefmsgid string `json:"inf_refmsgid"`
  2947. //}
  2948. type ResultEleven struct {
  2949. Cainfo string `json:"cainfo"`
  2950. ErrMsg string `json:"err_msg"`
  2951. InfRefmsgid string `json:"inf_refmsgid"`
  2952. Infcode int64 `json:"infcode"`
  2953. Output struct {
  2954. Setlinfo struct {
  2955. SetlTime string `json:"setl_time"`
  2956. CvlservPay float64 `json:"cvlserv_pay"`
  2957. Year string `json:"year"`
  2958. MedType string `json:"med_type"`
  2959. PsnPay float64 `json:"psn_pay"`
  2960. OpterID string `json:"opter_id"`
  2961. Begndate string `json:"begndate"`
  2962. FlxempeFlag string `json:"flxempe_flag"`
  2963. HifmiPay float64 `json:"hifmi_pay"`
  2964. PsnNo string `json:"psn_no"`
  2965. ActPayDedc float64 `json:"act_pay_dedc"`
  2966. MedinsSetlID interface{} `json:"medins_setl_id"`
  2967. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2968. ClrWay string `json:"clr_way"`
  2969. OthPay float64 `json:"oth_pay"`
  2970. Gend string `json:"gend"`
  2971. MdtrtID string `json:"mdtrt_id"`
  2972. AcctPay float64 `json:"acct_pay"`
  2973. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2974. Insutype string `json:"insutype"`
  2975. Invono interface{} `json:"invono"`
  2976. Enddate string `json:"enddate"`
  2977. CashPayamt float64 `json:"cash_payamt"`
  2978. PsnType string `json:"psn_type"`
  2979. FixmedinsName string `json:"fixmedins_name"`
  2980. HifpPay float64 `json:"hifp_pay"`
  2981. NewFlag interface{} `json:"new_flag"`
  2982. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2983. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2984. PayLoc string `json:"pay_loc"`
  2985. ClrType string `json:"clr_type"`
  2986. RefdSetlFlag string `json:"refd_setl_flag"`
  2987. CvlservFlag string `json:"cvlserv_flag"`
  2988. EmpName string `json:"emp_name"`
  2989. Brdy string `json:"brdy"`
  2990. Naty string `json:"naty"`
  2991. Certno string `json:"certno"`
  2992. DiseCode string `json:"dise_code"`
  2993. FixmedinsCode string `json:"fixmedins_code"`
  2994. DedcHospLv string `json:"dedc_hosp_lv"`
  2995. OpterName string `json:"opter_name"`
  2996. Balc float64 `json:"balc"`
  2997. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2998. PsnCertType string `json:"psn_cert_type"`
  2999. HifobPay float64 `json:"hifob_pay"`
  3000. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3001. HifesPay float64 `json:"hifes_pay"`
  3002. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3003. OptTime string `json:"opt_time"`
  3004. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3005. SetlID string `json:"setl_id"`
  3006. MafPay float64 `json:"maf_pay"`
  3007. PsnName string `json:"psn_name"`
  3008. InsuOptins interface{} `json:"insu_optins"`
  3009. PrefFundPay interface{} `json:"pref_fund_pay"`
  3010. ClrOptins string `json:"clr_optins"`
  3011. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3012. DiseName string `json:"dise_name"`
  3013. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3014. Age float64 `json:"age"`
  3015. DtrtCertType string `json:"dtrt_cert_type"`
  3016. HospLv string `json:"hosp_lv"`
  3017. } `json:"setlinfo"`
  3018. } `json:"output"`
  3019. RefmsgTime string `json:"refmsg_time"`
  3020. RespondTime string `json:"respond_time"`
  3021. Signtype interface{} `json:"signtype"`
  3022. WarnMsg interface{} `json:"warn_msg"`
  3023. }
  3024. type ResultEleven10265 struct {
  3025. Cainfo string `json:"cainfo"`
  3026. ErrMsg string `json:"err_msg"`
  3027. InfRefmsgid string `json:"inf_refmsgid"`
  3028. Infcode string `json:"infcode"`
  3029. Output struct {
  3030. Setlinfo struct {
  3031. SetlTime string `json:"setl_time"`
  3032. CvlservPay float64 `json:"cvlserv_pay"`
  3033. Year string `json:"year"`
  3034. MedType string `json:"med_type"`
  3035. PsnPay float64 `json:"psn_pay"`
  3036. OpterID string `json:"opter_id"`
  3037. Begndate string `json:"begndate"`
  3038. FlxempeFlag string `json:"flxempe_flag"`
  3039. HifmiPay float64 `json:"hifmi_pay"`
  3040. PsnNo string `json:"psn_no"`
  3041. ActPayDedc float64 `json:"act_pay_dedc"`
  3042. MedinsSetlID interface{} `json:"medins_setl_id"`
  3043. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3044. ClrWay string `json:"clr_way"`
  3045. OthPay float64 `json:"oth_pay"`
  3046. Gend string `json:"gend"`
  3047. MdtrtID string `json:"mdtrt_id"`
  3048. AcctPay float64 `json:"acct_pay"`
  3049. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3050. Insutype string `json:"insutype"`
  3051. Invono interface{} `json:"invono"`
  3052. Enddate string `json:"enddate"`
  3053. CashPayamt float64 `json:"cash_payamt"`
  3054. PsnType string `json:"psn_type"`
  3055. FixmedinsName string `json:"fixmedins_name"`
  3056. HifpPay float64 `json:"hifp_pay"`
  3057. NewFlag interface{} `json:"new_flag"`
  3058. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3059. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3060. PayLoc string `json:"pay_loc"`
  3061. ClrType string `json:"clr_type"`
  3062. RefdSetlFlag string `json:"refd_setl_flag"`
  3063. CvlservFlag string `json:"cvlserv_flag"`
  3064. EmpName string `json:"emp_name"`
  3065. Brdy string `json:"brdy"`
  3066. Naty string `json:"naty"`
  3067. Certno string `json:"certno"`
  3068. DiseCode string `json:"dise_code"`
  3069. FixmedinsCode string `json:"fixmedins_code"`
  3070. DedcHospLv string `json:"dedc_hosp_lv"`
  3071. OpterName string `json:"opter_name"`
  3072. Balc float64 `json:"balc"`
  3073. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3074. PsnCertType string `json:"psn_cert_type"`
  3075. HifobPay float64 `json:"hifob_pay"`
  3076. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3077. HifesPay float64 `json:"hifes_pay"`
  3078. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3079. OptTime string `json:"opt_time"`
  3080. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3081. SetlID string `json:"setl_id"`
  3082. MafPay float64 `json:"maf_pay"`
  3083. PsnName string `json:"psn_name"`
  3084. InsuOptins interface{} `json:"insu_optins"`
  3085. PrefFundPay interface{} `json:"pref_fund_pay"`
  3086. ClrOptins string `json:"clr_optins"`
  3087. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3088. DiseName string `json:"dise_name"`
  3089. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3090. Age float64 `json:"age"`
  3091. DtrtCertType string `json:"dtrt_cert_type"`
  3092. HospLv string `json:"hosp_lv"`
  3093. } `json:"setlinfo"`
  3094. } `json:"output"`
  3095. RefmsgTime string `json:"refmsg_time"`
  3096. RespondTime string `json:"respond_time"`
  3097. Signtype interface{} `json:"signtype"`
  3098. WarnMsg interface{} `json:"warn_msg"`
  3099. }
  3100. type ResultTwelve struct {
  3101. Cainfo string `json:"cainfo"`
  3102. ErrMsg string `json:"err_msg"`
  3103. InfRefmsgid string `json:"inf_refmsgid"`
  3104. Infcode int64 `json:"infcode"`
  3105. Output struct {
  3106. MdtrtId string `json:"mdtrt_id"`
  3107. ChrgBchno string `json:"chrg_bchno"`
  3108. PsnNo string `json:"psn_no"`
  3109. } `json:"output"`
  3110. RefmsgTime string `json:"refmsg_time"`
  3111. RespondTime string `json:"respond_time"`
  3112. Signtype interface{} `json:"signtype"`
  3113. WarnMsg interface{} `json:"warn_msg"`
  3114. }
  3115. type ResultThirteen struct {
  3116. ErrMsg string `json:"err_msg"`
  3117. InfRefmsgid string `json:"inf_refmsgid"`
  3118. Infcode int64 `json:"infcode"`
  3119. Output struct {
  3120. Result struct {
  3121. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3122. } `json:"result"`
  3123. } `json:"output"`
  3124. RefmsgTime string `json:"refmsg_time"`
  3125. RespondTime string `json:"respond_time"`
  3126. Signtype interface{} `json:"signtype"`
  3127. WarnInfo interface{} `json:"warn_info"`
  3128. }
  3129. type ResultThirteen10265 struct {
  3130. ErrMsg string `json:"err_msg"`
  3131. InfRefmsgid string `json:"inf_refmsgid"`
  3132. Infcode string `json:"infcode"`
  3133. Output struct {
  3134. Result struct {
  3135. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3136. } `json:"result"`
  3137. } `json:"output"`
  3138. RefmsgTime string `json:"refmsg_time"`
  3139. RespondTime string `json:"respond_time"`
  3140. Signtype interface{} `json:"signtype"`
  3141. WarnInfo interface{} `json:"warn_info"`
  3142. }
  3143. type ResultFourteen struct {
  3144. ErrMsg string `json:"err_msg"`
  3145. InfRefmsgid string `json:"inf_refmsgid"`
  3146. Infcode int64 `json:"infcode"`
  3147. Output struct {
  3148. } `json:"output"`
  3149. RefmsgTime string `json:"refmsg_time"`
  3150. RespondTime string `json:"respond_time"`
  3151. Signtype interface{} `json:"signtype"`
  3152. WarnInfo interface{} `json:"warn_info"`
  3153. }
  3154. type ResultFourteen10265 struct {
  3155. ErrMsg string `json:"err_msg"`
  3156. InfRefmsgid string `json:"inf_refmsgid"`
  3157. Infcode string `json:"infcode"`
  3158. Output struct {
  3159. } `json:"output"`
  3160. RefmsgTime string `json:"refmsg_time"`
  3161. RespondTime string `json:"respond_time"`
  3162. Signtype interface{} `json:"signtype"`
  3163. WarnInfo interface{} `json:"warn_info"`
  3164. }
  3165. type ResultSixteen struct {
  3166. Cainfo string `json:"cainfo"`
  3167. ErrMsg string `json:"err_msg"`
  3168. InfRefmsgid string `json:"inf_refmsgid"`
  3169. Infcode int64 `json:"infcode"`
  3170. Output struct {
  3171. Setldetail []interface{} `json:"setldetail"`
  3172. Setlinfo struct {
  3173. MdtrtID string `json:"mdtrt_id"`
  3174. SetlID string `json:"setl_id"`
  3175. ClrOptins string `json:"clr_optins"`
  3176. SetlTime string `json:"setl_time"`
  3177. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3178. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3179. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3180. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3181. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3182. ActPayDedc float64 `json:"act_pay_dedc"`
  3183. HifpPay float64 `json:"hifp_pay"`
  3184. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3185. Lfpay float64 `json:"selfpay"`
  3186. CvlservPay float64 `json:"cvlserv_pay"`
  3187. HifesPay float64 `json:"hifes_pay"`
  3188. HifmiPay float64 `json:"hifmi_pay"`
  3189. HifobPay float64 `json:"hifob_pay"`
  3190. MafPay float64 `json:"maf_pay"`
  3191. OthPay float64 `json:"oth_pay"`
  3192. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3193. PsnPartAmt float64 `json:"psn_part_amt"`
  3194. AcctPay float64 `json:"acct_pay"`
  3195. Balc float64 `json:"balc"`
  3196. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3197. HospPartAmt float64 `json:"hosp_part_amt"`
  3198. MedinsSetlID string `json:"medins_setl_id"`
  3199. PdnCashPay string `json:"pdn_cash_pay"`
  3200. } `json:"setlinfo"`
  3201. } `json:"output"`
  3202. RefmsgTime string `json:"refmsg_time"`
  3203. RespondTime string `json:"respond_time"`
  3204. Signtype interface{} `json:"signtype"`
  3205. WarnMsg interface{} `json:"warn_msg"`
  3206. }
  3207. type ResultSixteen10265 struct {
  3208. Cainfo string `json:"cainfo"`
  3209. ErrMsg string `json:"err_msg"`
  3210. InfRefmsgid string `json:"inf_refmsgid"`
  3211. Infcode string `json:"infcode"`
  3212. Output struct {
  3213. Setldetail []interface{} `json:"setldetail"`
  3214. Setlinfo struct {
  3215. MdtrtID string `json:"mdtrt_id"`
  3216. SetlID string `json:"setl_id"`
  3217. ClrOptins string `json:"clr_optins"`
  3218. SetlTime string `json:"setl_time"`
  3219. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3220. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3221. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3222. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3223. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3224. ActPayDedc float64 `json:"act_pay_dedc"`
  3225. HifpPay float64 `json:"hifp_pay"`
  3226. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3227. Lfpay float64 `json:"selfpay"`
  3228. CvlservPay float64 `json:"cvlserv_pay"`
  3229. HifesPay float64 `json:"hifes_pay"`
  3230. HifmiPay float64 `json:"hifmi_pay"`
  3231. HifobPay float64 `json:"hifob_pay"`
  3232. MafPay float64 `json:"maf_pay"`
  3233. OthPay float64 `json:"oth_pay"`
  3234. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3235. PsnPartAmt float64 `json:"psn_part_amt"`
  3236. AcctPay float64 `json:"acct_pay"`
  3237. Balc float64 `json:"balc"`
  3238. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3239. HospPartAmt float64 `json:"hosp_part_amt"`
  3240. MedinsSetlID string `json:"medins_setl_id"`
  3241. PdnCashPay string `json:"pdn_cash_pay"`
  3242. } `json:"setlinfo"`
  3243. } `json:"output"`
  3244. RefmsgTime string `json:"refmsg_time"`
  3245. RespondTime string `json:"respond_time"`
  3246. Signtype interface{} `json:"signtype"`
  3247. WarnMsg interface{} `json:"warn_msg"`
  3248. }
  3249. type ResultSeventeen struct {
  3250. ErrMsg string `json:"err_msg"`
  3251. InfRefmsgid string `json:"inf_refmsgid"`
  3252. Infcode int64 `json:"infcode"`
  3253. Output struct {
  3254. SetlListId string `json:"setl_list_id"`
  3255. } `json:"output"`
  3256. RefmsgTime string `json:"refmsg_time"`
  3257. RespondTime string `json:"respond_time"`
  3258. Signtype string `json:"signtype"`
  3259. WarnInfo string `json:"warn_info"`
  3260. }
  3261. type Result90991 struct {
  3262. ErrMsg string `json:"err_msg"`
  3263. InfRefmsgid string `json:"inf_refmsgid"`
  3264. Infcode int64 `json:"infcode"`
  3265. Output struct {
  3266. Result struct {
  3267. PsnNo string `json:"psn_no"`
  3268. CardStat string `json:"card_stat"`
  3269. Certno string `json:"certno"`
  3270. PsnName string `json:"psn_name"`
  3271. CheckStat string `json:"check_stat"`
  3272. } `json:"result"`
  3273. } `json:"output"`
  3274. RefmsgTime string `json:"refmsg_time"`
  3275. RespondTime string `json:"respond_time"`
  3276. Signtype interface{} `json:"signtype"`
  3277. WarnInfo interface{} `json:"warn_info"`
  3278. }
  3279. type Result90100 struct {
  3280. ErrMsg string `json:"err_msg"`
  3281. InfRefmsgid string `json:"inf_refmsgid"`
  3282. Infcode int64 `json:"infcode"`
  3283. Output struct {
  3284. PoolareaNo string `json:"poolarea_no"`
  3285. PoolareaNoName string `json:"poolarea_no_name"`
  3286. Insutype string `json:"insutype"`
  3287. InsutypeName string `json:"insutype_name"`
  3288. ClctType string `json:"clct_type"`
  3289. ClctTypeName string `json:"clct_type_name"`
  3290. ClctFlag string `json:"clct_flag"`
  3291. ClctFlagName string `json:"clct_flag_name"`
  3292. AccrymBegn string `json:"accrym_begn"`
  3293. AccrymEnd string `json:"accrym_end"`
  3294. ClctTime string `json:"clct_time"`
  3295. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3296. } `json:"output"`
  3297. RefmsgTime string `json:"refmsg_time"`
  3298. RespondTime string `json:"respond_time"`
  3299. Signtype interface{} `json:"signtype"`
  3300. WarnInfo interface{} `json:"warn_info"`
  3301. }
  3302. type Custom struct {
  3303. DetItemFeeSumamt string
  3304. Cut string
  3305. FeedetlSn string
  3306. Price string
  3307. MedListCodg string
  3308. Type int64
  3309. AdviceId int64
  3310. ProjectId int64
  3311. ItemId int64
  3312. }
  3313. type Result5301 struct {
  3314. ErrMsg string `json:"err_msg"`
  3315. InfRefmsgid string `json:"inf_refmsgid"`
  3316. Infcode int64 `json:"infcode"`
  3317. Output struct {
  3318. Result []struct {
  3319. OpspDiseCode string `json:"opsp_dise_code"`
  3320. OpspDiseName string `json:"opsp_dise_name"`
  3321. Begndate string `json:"begndate"`
  3322. Enddate string `json:"enddate"`
  3323. } `json:"feedetail"`
  3324. } `json:"output"`
  3325. RefmsgTime string `json:"refmsg_time"`
  3326. RespondTime string `json:"respond_time"`
  3327. Signtype interface{} `json:"signtype"`
  3328. WarnInfo interface{} `json:"warn_info"`
  3329. }
  3330. type Result5301For10265 struct {
  3331. ErrMsg string `json:"err_msg"`
  3332. InfRefmsgid string `json:"inf_refmsgid"`
  3333. Infcode string `json:"infcode"`
  3334. Output struct {
  3335. Result []struct {
  3336. OpspDiseCode string `json:"opsp_dise_code"`
  3337. OpspDiseName string `json:"opsp_dise_name"`
  3338. Begndate string `json:"begndate"`
  3339. Enddate string `json:"enddate"`
  3340. } `json:"feedetail"`
  3341. } `json:"output"`
  3342. RefmsgTime string `json:"refmsg_time"`
  3343. RespondTime string `json:"respond_time"`
  3344. Signtype interface{} `json:"signtype"`
  3345. WarnInfo interface{} `json:"warn_info"`
  3346. }
  3347. //获取个人信息----挂号-----上传就诊信息
  3348. func (c *HisApiController) GetRegisterInfo() {
  3349. id, _ := c.GetInt64("id")
  3350. record_time := c.GetString("record_time")
  3351. settlementValue, _ := c.GetInt64("settlement_value")
  3352. medical_insurance_card := c.GetString("medical_insurance_card")
  3353. name := c.GetString("name")
  3354. id_card_type, _ := c.GetInt64("id_card_type")
  3355. certificates, _ := c.GetInt64("certificates")
  3356. medical_care, _ := c.GetInt64("medical_care")
  3357. birthday := c.GetString("birthday")
  3358. id_card := c.GetString("id_card")
  3359. register_type, _ := c.GetInt64("register")
  3360. doctor, _ := c.GetInt64("doctor")
  3361. department, _ := c.GetInt64("department")
  3362. gender, _ := c.GetInt64("sex")
  3363. registration_fee, _ := c.GetFloat("registration_fee")
  3364. medical_expenses, _ := c.GetFloat("medical_expenses")
  3365. social_type, _ := c.GetInt64("social_type")
  3366. med_type := c.GetString("social_type")
  3367. admin_user_id, _ := c.GetInt64("admin_user_id")
  3368. insuplc_admdvs := c.GetString("insuplc_admdvs")
  3369. timeLayout := "2006-01-02"
  3370. loc, _ := time.LoadLocation("Local")
  3371. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  3372. birthUnix := birthdays.Unix()
  3373. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3374. if err != nil {
  3375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3376. return
  3377. }
  3378. recordDateTime := theTime.Unix()
  3379. adminInfo := c.GetAdminUserInfo()
  3380. var patient service.Patients
  3381. if id == 0 {
  3382. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  3383. } else {
  3384. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  3385. }
  3386. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3387. if patientPrescription.ID == 0 {
  3388. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3389. }
  3390. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3391. if patient.ID == 0 {
  3392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3393. return
  3394. }
  3395. if len(patient.IdCardNo) == 0 {
  3396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3397. return
  3398. }
  3399. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3400. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  3401. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  3402. //就诊结算未完成,不能进行二次挂号
  3403. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  3404. if len(his) >= 1 {
  3405. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  3406. if len(his) >= 1 && order.ID == 0 {
  3407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  3408. return
  3409. }
  3410. }
  3411. //var register_log string
  3412. if config.IsOpen == 1 {
  3413. var res ResultTwo
  3414. var res10265 ResultTwo10265
  3415. var PsnNo string
  3416. var PsnCertType string
  3417. var Certno string
  3418. var PsnName string
  3419. var Gend string
  3420. var Naty string
  3421. var Brdy string
  3422. var Age float64
  3423. var infoStr string
  3424. var idetinfoStr string
  3425. var infocode int64
  3426. var verify_number string
  3427. fmt.Println(verify_number)
  3428. if miConfig.MdtrtareaAdmvs == "421300" {
  3429. psn_info, _ := service.GetPsnByPatientId(id)
  3430. PsnNo = psn_info.PsnNo
  3431. PsnCertType = psn_info.PsnCertType
  3432. Certno = psn_info.Certno
  3433. PsnName = psn_info.PsnName
  3434. Gend = psn_info.Gend
  3435. Naty = psn_info.Naty
  3436. Brdy = psn_info.Brdy
  3437. Age = psn_info.Age
  3438. infoStr = psn_info.Insuinfo
  3439. idetinfoStr = psn_info.Idetinfo
  3440. infocode = 0
  3441. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3442. psn_info, _ := service.GetPsnByPatientId(id)
  3443. PsnNo = psn_info.PsnNo
  3444. PsnCertType = psn_info.PsnCertType
  3445. Certno = psn_info.Certno
  3446. PsnName = psn_info.PsnName
  3447. Gend = psn_info.Gend
  3448. Naty = psn_info.Naty
  3449. Brdy = psn_info.Brdy
  3450. Age = psn_info.Age
  3451. infoStr = psn_info.Insuinfo
  3452. idetinfoStr = psn_info.Idetinfo
  3453. infocode = 0
  3454. verify_number = psn_info.VerifyNumber
  3455. } else {
  3456. var result string
  3457. var requestLog string
  3458. if miConfig.UserOrgId == 10138 {
  3459. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  3460. } else {
  3461. 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)
  3462. }
  3463. saveLog(result, requestLog, "1101", "人员基本信息获取")
  3464. if miConfig.Code == "H15049901371" {
  3465. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3466. utils.ErrorLog("解析失败:%v", err)
  3467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3468. return
  3469. }
  3470. res.ErrMsg = res10265.ErrMsg
  3471. res.Output = res10265.Output
  3472. res.InfRefmsgid = res10265.InfRefmsgid
  3473. } else {
  3474. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3475. utils.ErrorLog("解析失败:%v", err)
  3476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3477. return
  3478. }
  3479. }
  3480. PsnNo = res.Output.Baseinfo.PsnNo
  3481. PsnCertType = res.Output.Baseinfo.PsnCertType
  3482. Certno = res.Output.Baseinfo.Certno
  3483. PsnName = res.Output.Baseinfo.PsnName
  3484. Gend = res.Output.Baseinfo.Gend
  3485. Naty = res.Output.Baseinfo.Naty
  3486. Brdy = res.Output.Baseinfo.Brdy
  3487. Age = res.Output.Baseinfo.Age
  3488. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3489. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3490. infoStr = string(Iinfos)
  3491. idetinfoStr = string(Idetinfos)
  3492. if miConfig.Code == "H15049901371" {
  3493. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  3494. } else {
  3495. infocode = res.Infcode
  3496. }
  3497. }
  3498. if infocode == 0 {
  3499. his := models.VMHisPatient{
  3500. Name: name,
  3501. Gender: gender,
  3502. Birthday: birthUnix,
  3503. MedicalTreatmentType: medical_care,
  3504. IdType: certificates,
  3505. IdCardNo: id_card,
  3506. BalanceAccountsType: settlementValue,
  3507. SocialType: social_type,
  3508. MedicalInsuranceNumber: medical_insurance_card,
  3509. RegisterType: register_type,
  3510. RegisterCost: registration_fee,
  3511. TreatmentCost: medical_expenses,
  3512. Status: 1,
  3513. Ctime: time.Now().Unix(),
  3514. Mtime: time.Now().Unix(),
  3515. PsnNo: PsnNo,
  3516. PsnCertType: PsnCertType,
  3517. Certno: Certno,
  3518. PsnName: PsnName,
  3519. Gend: Gend,
  3520. Naty: Naty,
  3521. Brdy: Brdy,
  3522. Age: Age,
  3523. Iinfo: infoStr,
  3524. Idetinfo: idetinfoStr,
  3525. PatientId: patient.ID,
  3526. RecordDate: theTime.Unix(),
  3527. UserOrgId: adminInfo.CurrentOrgId,
  3528. AdminUserId: admin_user_id,
  3529. IsReturn: 1,
  3530. IdCardType: id_card_type,
  3531. Doctor: doctor,
  3532. Departments: department,
  3533. }
  3534. timestamp := time.Now().Unix()
  3535. tempTime := time.Unix(timestamp, 0)
  3536. timeFormat := tempTime.Format("20060102150405")
  3537. chrgBchno := rand.Intn(100000) + 10000
  3538. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3539. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  3540. department, _ := service.GetDepartMentDetail(department)
  3541. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3542. IdCardNo := ""
  3543. if id_card_type == 1 {
  3544. // IdCardNo = medical_insurance_card
  3545. IdCardNo = patient.IdCardNo
  3546. } else {
  3547. IdCardNo = patient.IdCardNo
  3548. }
  3549. var rf []*ResultFive
  3550. json.Unmarshal([]byte(his.Iinfo), &rf)
  3551. var insutypes []*ResultFive
  3552. var insutype string
  3553. var insuplc_admdvs_temp string
  3554. var is390 int = 0
  3555. var is310 int = 0
  3556. for _, item := range rf {
  3557. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3558. insutypes = append(insutypes, item)
  3559. }
  3560. }
  3561. if len(insutypes) == 1 {
  3562. insutype = insutypes[0].Insutype
  3563. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3564. } else {
  3565. for _, i := range insutypes {
  3566. if i.Insutype == "390" {
  3567. is390 = 1
  3568. }
  3569. if i.Insutype == "310" {
  3570. is310 = 1
  3571. }
  3572. }
  3573. }
  3574. if is390 == 1 {
  3575. insutype = "390"
  3576. }
  3577. if is310 == 1 {
  3578. insutype = "310"
  3579. }
  3580. if len(insutypes) == 0 {
  3581. insutype = "310"
  3582. }
  3583. if len(insutypes) == 2 {
  3584. insutype = med_type
  3585. }
  3586. if len(med_type) > 0 {
  3587. insutype = med_type
  3588. }
  3589. //for _, item := range rf {
  3590. // if item.Insutype == insutype {
  3591. // insuplc_admdvs = item.InsuplcAdmdvs
  3592. // }
  3593. //}
  3594. var infocode int64
  3595. var resThree ResultThree
  3596. var resThree10265 ResultThree10265
  3597. if len(insuplc_admdvs) == 0 {
  3598. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  3599. } else {
  3600. insuplc_admdvs_temp = insuplc_admdvs
  3601. }
  3602. if miConfig.MdtrtareaAdmvs == "421300" {
  3603. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  3604. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3605. "&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
  3606. resp, requestErr := http.Get(api)
  3607. if requestErr != nil {
  3608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3609. return
  3610. }
  3611. body, ioErr := ioutil.ReadAll(resp.Body)
  3612. if ioErr != nil {
  3613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3615. return
  3616. }
  3617. var respJSON map[string]interface{}
  3618. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3621. return
  3622. }
  3623. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3624. result, _ := json.Marshal(respJSON)
  3625. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3626. utils.ErrorLog("解析失败:%v", err)
  3627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3628. return
  3629. }
  3630. infocode = resThree.Infcode
  3631. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3632. psn_info, _ := service.GetPsnByPatientId(id)
  3633. bas := strings.Split(psn_info.CardInfo, "|")
  3634. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3635. var api string
  3636. if miConfig.MdtrtareaAdmvs == "320921" {
  3637. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3638. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3639. "&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
  3640. } else {
  3641. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3642. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3643. "&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
  3644. }
  3645. resp, requestErr := http.Get(api)
  3646. if requestErr != nil {
  3647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3648. return
  3649. }
  3650. body, ioErr := ioutil.ReadAll(resp.Body)
  3651. if ioErr != nil {
  3652. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3654. return
  3655. }
  3656. var respJSON map[string]interface{}
  3657. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3658. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3660. return
  3661. }
  3662. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3663. result, _ := json.Marshal(respJSON)
  3664. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3665. utils.ErrorLog("解析失败:%v", err)
  3666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3667. return
  3668. }
  3669. resThree.ErrMsg = resThree10265.ErrMsg
  3670. resThree.Output = resThree10265.Output
  3671. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3672. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3673. } else {
  3674. 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)
  3675. saveLog(result, requestLog, "2201", "挂号")
  3676. if miConfig.Code == "H15049901371" {
  3677. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3678. utils.ErrorLog("解析失败:%v", err)
  3679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3680. return
  3681. }
  3682. resThree.ErrMsg = resThree10265.ErrMsg
  3683. resThree.Output = resThree10265.Output
  3684. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3685. } else {
  3686. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3687. utils.ErrorLog("解析失败:%v", err)
  3688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3689. return
  3690. }
  3691. }
  3692. if miConfig.Code == "H15049901371" {
  3693. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3694. } else {
  3695. infocode = resThree.Infcode
  3696. }
  3697. }
  3698. if infocode != 0 {
  3699. adminUser := c.GetAdminUserInfo()
  3700. errlog := &models.HisOrderError{
  3701. UserOrgId: adminUser.CurrentOrgId,
  3702. Ctime: time.Now().Unix(),
  3703. Mtime: time.Now().Unix(),
  3704. ErrMsg: resThree.ErrMsg,
  3705. Status: 1,
  3706. PatientId: id,
  3707. RecordTime: recordDateTime,
  3708. Stage: 2,
  3709. }
  3710. service.CreateErrMsgLog(errlog)
  3711. c.ServeSuccessJSON(map[string]interface{}{
  3712. "failed_code": -10,
  3713. "msg": resThree.ErrMsg,
  3714. })
  3715. return
  3716. }
  3717. his.Number = resThree.Output.Data.MdtrtID
  3718. his.PsnNo = resThree.Output.Data.PsnNo
  3719. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  3720. his.IdCardNo = patient.IdCardNo
  3721. his.PhoneNumber = patient.Phone
  3722. his.UserOrgId = adminInfo.CurrentOrgId
  3723. his.Insutype = insutype
  3724. his.Ctime = time.Now().Unix()
  3725. his.Mtime = time.Now().Unix()
  3726. his.InsuplcAdmdvs = insuplc_admdvs_temp
  3727. his.Status = 1
  3728. service.UpdateHisPatientStatus(&his)
  3729. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  3730. c.ServeSuccessJSON(map[string]interface{}{
  3731. "his_info": his,
  3732. })
  3733. } else {
  3734. adminUser := c.GetAdminUserInfo()
  3735. errlog := &models.HisOrderError{
  3736. UserOrgId: adminUser.CurrentOrgId,
  3737. Ctime: time.Now().Unix(),
  3738. Mtime: time.Now().Unix(),
  3739. ErrMsg: res.ErrMsg,
  3740. Status: 1,
  3741. PatientId: id,
  3742. RecordTime: recordDateTime,
  3743. Stage: 1,
  3744. }
  3745. service.CreateErrMsgLog(errlog)
  3746. c.ServeSuccessJSON(map[string]interface{}{
  3747. "failed_code": -10,
  3748. "msg": res.ErrMsg,
  3749. })
  3750. return
  3751. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3752. }
  3753. }
  3754. }
  3755. //上传明细----预结算----确认订单
  3756. func (c *HisApiController) GetUploadInfo() {
  3757. id, _ := c.GetInt64("id")
  3758. record_time := c.GetString("record_time")
  3759. his_patient_id, _ := c.GetInt64("his_patient_id")
  3760. order_id, _ := c.GetInt64("order_id")
  3761. pay_way, _ := c.GetInt64("pay_way")
  3762. pay_price, _ := c.GetFloat("pay_price")
  3763. pay_card_no := c.GetString("pay_card_no")
  3764. discount_price, _ := c.GetFloat("discount_price")
  3765. preferential_price, _ := c.GetFloat("preferential_price")
  3766. reality_price, _ := c.GetFloat("reality_price")
  3767. found_price, _ := c.GetFloat("found_price")
  3768. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3769. private_price, _ := c.GetFloat("private_price")
  3770. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3771. admin_user_id, _ := c.GetInt64("admin_user_id")
  3772. fapiao_code := c.GetString("fapiao_code")
  3773. fapiao_number := c.GetString("fapiao_number")
  3774. diagnosis_id := c.GetString("diagnosis")
  3775. sick_type, _ := c.GetInt64("sick_type")
  3776. reg_type, _ := c.GetInt64("p_type")
  3777. begin_time := c.GetString("begin_time")
  3778. id_str := c.GetString("ids")
  3779. ids_arr := strings.Split(id_str, ",")
  3780. timeLayout := "2006-01-02"
  3781. loc, _ := time.LoadLocation("Local")
  3782. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3783. if err != nil {
  3784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3785. return
  3786. }
  3787. recordDateTime := theTime.Unix()
  3788. adminUser := c.GetAdminUserInfo()
  3789. var tempOrder models.HisOrder
  3790. tempOrder, _ = service.GetHisOrderByID(order_id)
  3791. var prescriptions []*models.HisPrescription
  3792. var start_time int64
  3793. var end_time int64
  3794. //if adminUser.CurrentOrgId == 10106{
  3795. // if len(fapiao_code) == 0{
  3796. // fapiao_code = "144072080589"
  3797. // }
  3798. // if len(fapiao_number) == 0{
  3799. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3800. // if order.ID == 0{
  3801. // fapiao_number = "00001520"
  3802. // }else{
  3803. // //fapiao_code = "00001520"
  3804. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3805. // var zero string
  3806. // if fpNumber >= 1000{
  3807. // zero = "0000" + strconv.Itoa(fpNumber)
  3808. // }else if fpNumber >= 10000{
  3809. // zero = "000" + strconv.Itoa(fpNumber)
  3810. // } else if fpNumber >= 100000{
  3811. // zero = "00" + strconv.Itoa(fpNumber)
  3812. // } else if fpNumber >= 1000000{
  3813. // zero = "0" + strconv.Itoa(fpNumber)
  3814. // }else {
  3815. // zero = strconv.Itoa(fpNumber)
  3816. // }
  3817. // fapiao_number = zero
  3818. // }
  3819. // }
  3820. //}
  3821. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3822. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3823. var patientPrescription models.HisPrescriptionInfo
  3824. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3825. if patientPrescription.ID == 0 {
  3826. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3827. }
  3828. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3829. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3830. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3831. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3832. var config []*models.HisXtDiagnoseConfig
  3833. for _, item := range diagnosis_ids {
  3834. id, _ := strconv.ParseInt(item, 10, 64)
  3835. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3836. config = append(config, &diagnosisConfig)
  3837. }
  3838. sickConfig, _ := service.FindSickById(sick_type)
  3839. //if tempOrder.ID == 0 {
  3840. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3841. //}
  3842. if tempOrder.ID == 0 {
  3843. var result string
  3844. var requestLog string
  3845. var res2 ResultSix
  3846. var ressix10265 ResultSix10265
  3847. if miConfig.MdtrtareaAdmvs == "421300" {
  3848. data := make(map[string]interface{})
  3849. client := &http.Client{}
  3850. data["psn_no"] = his.PsnNo
  3851. data["mdtrt_id"] = his.Number
  3852. data["doctor"] = roles.UserName
  3853. data["department"] = department.Name
  3854. data["org_name"] = miConfig.OrgName
  3855. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3856. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3857. data["fixmedins_code"] = miConfig.Code
  3858. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3859. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3860. data["secret_key"] = miConfig.SecretKey
  3861. data["sick_code"] = sickConfig.CountryCode
  3862. data["sick_name"] = sickConfig.ClassName
  3863. data["dept"] = strconv.FormatInt(department.ID, 10)
  3864. data["config"] = config
  3865. data["begin_time"] = begin_time
  3866. bytesData, _ := json.Marshal(data)
  3867. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3868. resp, _ := client.Do(req)
  3869. defer resp.Body.Close()
  3870. body, ioErr := ioutil.ReadAll(resp.Body)
  3871. if ioErr != nil {
  3872. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3874. return
  3875. }
  3876. var respJSON map[string]interface{}
  3877. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3880. return
  3881. }
  3882. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3883. userJSONBytes, _ := json.Marshal(respJSON)
  3884. fmt.Println("log")
  3885. fmt.Println(string(userJSONBytes))
  3886. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3887. utils.ErrorLog("解析失败:%v", err)
  3888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3889. return
  3890. }
  3891. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3892. //江苏地区国家医保医疗类别
  3893. //职工透析:医疗类别选特殊情况门诊9933
  3894. //居民血透门慢: 医疗类别选门诊慢病1402
  3895. //var med_type string
  3896. //if his.Insutype == "310" {
  3897. // if reg_type == 14 {
  3898. // med_type = "9933"
  3899. // } else if reg_type == 11 {
  3900. // med_type = "11"
  3901. //
  3902. // }
  3903. //} else if his.Insutype == "390" {
  3904. // if reg_type == 14 {
  3905. // med_type = "1402"
  3906. // } else if reg_type == 11 {
  3907. // med_type = "11"
  3908. // }
  3909. //}
  3910. data := make(map[string]interface{})
  3911. client := &http.Client{}
  3912. data["psn_no"] = his.PsnNo
  3913. data["mdtrt_id"] = his.Number
  3914. data["doctor"] = roles.UserName
  3915. data["department"] = department.Name
  3916. data["org_name"] = miConfig.OrgName
  3917. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3918. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3919. data["fixmedins_code"] = miConfig.Code
  3920. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3921. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3922. data["secret_key"] = miConfig.SecretKey
  3923. data["sick_code"] = sickConfig.CountryCode
  3924. data["sick_name"] = sickConfig.ClassName
  3925. data["url"] = miConfig.Url
  3926. data["ak"] = miConfig.AccessKey
  3927. data["begin_time"] = begin_time
  3928. data["cainfo"] = miConfig.Cainfo
  3929. data["dept"] = strconv.FormatInt(department.ID, 10)
  3930. data["config"] = config
  3931. bytesData, _ := json.Marshal(data)
  3932. var req *http.Request
  3933. if miConfig.MdtrtareaAdmvs == "320921" {
  3934. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3935. //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 +
  3936. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  3937. } else {
  3938. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3939. }
  3940. resp, _ := client.Do(req)
  3941. defer resp.Body.Close()
  3942. body, ioErr := ioutil.ReadAll(resp.Body)
  3943. if ioErr != nil {
  3944. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3946. return
  3947. }
  3948. var respJSON map[string]interface{}
  3949. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3950. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3952. return
  3953. }
  3954. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3955. userJSONBytes, _ := json.Marshal(respJSON)
  3956. fmt.Println("log")
  3957. fmt.Println(string(userJSONBytes))
  3958. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  3959. utils.ErrorLog("解析失败:%v", err)
  3960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3961. return
  3962. }
  3963. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3964. res2.Output = ressix10265.Output
  3965. res2.ErrMsg = ressix10265.ErrMsg
  3966. res2.Cainfo = ressix10265.Cainfo
  3967. res2.WarnMsg = ressix10265.WarnMsg
  3968. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3969. res2.Infcode = infocode
  3970. } else {
  3971. if miConfig.MdtrtareaAdmvs == "440781" { //
  3972. 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)
  3973. } else {
  3974. if miConfig.Code == "H15049901371" {
  3975. //赤峰地区国家医保医疗类别
  3976. //职工透析:医疗类别选特殊情况门诊990502
  3977. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3978. var med_type string
  3979. if his.Insutype == "390" {
  3980. if reg_type == 14 {
  3981. med_type = "9933"
  3982. } else if reg_type == 11 {
  3983. med_type = "11"
  3984. }
  3985. } else if his.Insutype == "310" {
  3986. if reg_type == 14 {
  3987. med_type = "990502"
  3988. } else if reg_type == 11 {
  3989. med_type = "11"
  3990. }
  3991. }
  3992. 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)
  3993. } else {
  3994. 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)
  3995. }
  3996. }
  3997. saveLog(result, requestLog, "2203", "上传就诊信息")
  3998. var respJSON2 map[string]interface{}
  3999. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4002. return
  4003. }
  4004. userJSONBytes2, _ := json.Marshal(respJSON2)
  4005. if miConfig.Code == "H15049901371" {
  4006. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4007. utils.ErrorLog("解析失败:%v", err)
  4008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4009. return
  4010. }
  4011. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4012. res2.Output = ressix10265.Output
  4013. res2.ErrMsg = ressix10265.ErrMsg
  4014. res2.Cainfo = ressix10265.Cainfo
  4015. res2.WarnMsg = ressix10265.WarnMsg
  4016. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4017. res2.Infcode = infocode
  4018. } else {
  4019. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4020. utils.ErrorLog("解析失败:%v", err)
  4021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4022. return
  4023. }
  4024. }
  4025. }
  4026. if res2.Infcode != 0 {
  4027. adminUser := c.GetAdminUserInfo()
  4028. errlog := &models.HisOrderError{
  4029. UserOrgId: adminUser.CurrentOrgId,
  4030. Ctime: time.Now().Unix(),
  4031. Mtime: time.Now().Unix(),
  4032. ErrMsg: res2.ErrMsg,
  4033. Status: 1,
  4034. PatientId: id,
  4035. RecordTime: recordDateTime,
  4036. Stage: 3,
  4037. }
  4038. service.CreateErrMsgLog(errlog)
  4039. c.ServeSuccessJSON(map[string]interface{}{
  4040. "failed_code": -10,
  4041. "msg": res2.ErrMsg,
  4042. })
  4043. return
  4044. } else {
  4045. his.Diagnosis = diagnosis_id
  4046. his.SickType = sickConfig.ID
  4047. var p_type int64
  4048. if reg_type == 1111 || reg_type == 1112 {
  4049. p_type = 11
  4050. }
  4051. his.PType = fmt.Sprintf("%d", p_type)
  4052. service.UpdateHisPatientThree(&his)
  4053. data := make(map[string]interface{})
  4054. if settle_accounts_type == 1 { //日结
  4055. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4056. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4057. } else {
  4058. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4059. }
  4060. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4061. data["pre"] = prescriptions
  4062. } else { //月结
  4063. start_time_str := c.GetString("start_time")
  4064. end_time_str := c.GetString("end_time")
  4065. timeLayout := "2006-01-02"
  4066. loc, _ := time.LoadLocation("Local")
  4067. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4068. if err != nil {
  4069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4070. return
  4071. }
  4072. recordStartTime := theStartTime.Unix()
  4073. start_time = recordStartTime
  4074. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4075. if err != nil {
  4076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4077. return
  4078. }
  4079. recordEndTime := theEndTime.Unix()
  4080. end_time = recordEndTime
  4081. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4082. data["pre"] = prescriptions
  4083. }
  4084. timestamp := time.Now().Unix()
  4085. tempTime := time.Unix(timestamp, 0)
  4086. timeFormat := tempTime.Format("20060102150405")
  4087. chrgBchno := rand.Intn(100000) + 10000
  4088. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4089. strconv.FormatInt(his.PatientId, 10)
  4090. client := &http.Client{}
  4091. data["psn_no"] = his.PsnNo
  4092. data["mdtrt_id"] = his.Number
  4093. data["chrg_bchno"] = chrg_bchno
  4094. data["org_name"] = miConfig.OrgName
  4095. data["doctor"] = roles.UserName
  4096. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4097. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4098. data["fixmedins_code"] = miConfig.Code
  4099. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4100. // data["dept_code"] = "15"
  4101. //} else {
  4102. data["dept_code"] = department.Number
  4103. //}
  4104. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4105. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4106. data["secret_key"] = miConfig.SecretKey
  4107. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4108. data["url"] = miConfig.Url
  4109. data["ak"] = miConfig.AccessKey
  4110. data["new_doctor_name"] = patientPrescription.Doctor
  4111. data["diag_code"] = sickConfig.CountryCode
  4112. data["cainfo"] = miConfig.Cainfo
  4113. var ids []int64
  4114. for _, item := range prescriptions {
  4115. ids = append(ids, item.ID)
  4116. }
  4117. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4118. if config.IsOpen == 1 { //对接了医保,走医保流程
  4119. var res ResultFour
  4120. var resFour10265 ResultFour10265
  4121. if miConfig.MdtrtareaAdmvs == "421300" {
  4122. bytesData, _ := json.Marshal(data)
  4123. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4124. resp, _ := client.Do(req)
  4125. defer resp.Body.Close()
  4126. body, ioErr := ioutil.ReadAll(resp.Body)
  4127. if ioErr != nil {
  4128. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4130. return
  4131. }
  4132. var respJSON map[string]interface{}
  4133. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4136. return
  4137. }
  4138. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4139. userJSONBytes, _ := json.Marshal(respJSON)
  4140. fmt.Println("log")
  4141. fmt.Println(string(userJSONBytes))
  4142. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4143. utils.ErrorLog("解析失败:%v", err)
  4144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4145. return
  4146. }
  4147. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4148. bytesData, _ := json.Marshal(data)
  4149. var req *http.Request
  4150. if miConfig.MdtrtareaAdmvs == "320921" {
  4151. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4152. } else {
  4153. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4154. }
  4155. resp, _ := client.Do(req)
  4156. defer resp.Body.Close()
  4157. body, ioErr := ioutil.ReadAll(resp.Body)
  4158. if ioErr != nil {
  4159. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4161. return
  4162. }
  4163. var respJSON map[string]interface{}
  4164. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4167. return
  4168. }
  4169. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4170. userJSONBytes, _ := json.Marshal(respJSON)
  4171. fmt.Println("log")
  4172. fmt.Println(string(userJSONBytes))
  4173. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4174. utils.ErrorLog("解析失败:%v", err)
  4175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4176. return
  4177. }
  4178. res.InfRefmsgid = resFour10265.InfRefmsgid
  4179. res.Output = resFour10265.Output
  4180. res.ErrMsg = resFour10265.ErrMsg
  4181. res.Cainfo = resFour10265.Cainfo
  4182. res.WarnMsg = resFour10265.WarnMsg
  4183. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4184. res.Infcode = infocode
  4185. } else {
  4186. if miConfig.Code == "H15049901371" {
  4187. 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)
  4188. var dat map[string]interface{}
  4189. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4190. fmt.Println(dat)
  4191. } else {
  4192. fmt.Println(err)
  4193. }
  4194. saveLog(result, request_log, "2204", "上传费用明细")
  4195. userJSONBytes, _ := json.Marshal(dat)
  4196. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4197. utils.ErrorLog("解析失败:%v", err)
  4198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4199. return
  4200. }
  4201. res.InfRefmsgid = resFour10265.InfRefmsgid
  4202. res.Output = resFour10265.Output
  4203. res.ErrMsg = resFour10265.ErrMsg
  4204. res.Cainfo = resFour10265.Cainfo
  4205. res.WarnMsg = resFour10265.WarnMsg
  4206. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4207. res.Infcode = infocode
  4208. } else {
  4209. 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)
  4210. var dat map[string]interface{}
  4211. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4212. fmt.Println(dat)
  4213. } else {
  4214. fmt.Println(err)
  4215. }
  4216. saveLog(result, request_log, "2204", "上传费用明细")
  4217. userJSONBytes, _ := json.Marshal(dat)
  4218. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4219. utils.ErrorLog("解析失败:%v", err)
  4220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4221. return
  4222. }
  4223. }
  4224. }
  4225. if res.Infcode == 0 {
  4226. order := &models.HisOrder{
  4227. UserOrgId: adminUser.CurrentOrgId,
  4228. HisPatientId: his.ID,
  4229. PatientId: his.PatientId,
  4230. SettleAccountsDate: recordDateTime,
  4231. MdtrtId: his.Number,
  4232. PsnNo: his.PsnNo,
  4233. MedType: strconv.FormatInt(reg_type, 10),
  4234. Ctime: time.Now().Unix(),
  4235. Mtime: time.Now().Unix(),
  4236. Status: 1,
  4237. Number: chrg_bchno,
  4238. Infcode: res.Infcode,
  4239. WarnMsg: res.WarnMsg,
  4240. Cainfo: res.Cainfo,
  4241. ErrMsg: res.ErrMsg,
  4242. RespondTime: res.RefmsgTime,
  4243. InfRefmsgid: res.InfRefmsgid,
  4244. OrderStatus: 1,
  4245. PayWay: pay_way,
  4246. PayPrice: pay_price,
  4247. PayCardNo: pay_card_no,
  4248. DiscountPrice: discount_price,
  4249. PreferentialPrice: preferential_price,
  4250. RealityPrice: reality_price,
  4251. FoundPrice: found_price,
  4252. MedicalInsurancePrice: medical_insurance_price,
  4253. PrivatePrice: private_price,
  4254. IsMedicineInsurance: 1,
  4255. SettleType: settle_accounts_type,
  4256. SettleStartTime: start_time,
  4257. SettleEndTime: end_time,
  4258. Creator: roles.AdminUserId,
  4259. Modify: roles.AdminUserId,
  4260. FaPiaoNumber: fapiao_number,
  4261. FaPiaoCode: fapiao_code,
  4262. PType: 2,
  4263. Diagnosis: diagnosis_id,
  4264. }
  4265. err = service.CreateOrder(order)
  4266. if err != nil {
  4267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4268. return
  4269. }
  4270. for _, item := range res.Output.Result {
  4271. temp := strings.Split(item.FeedetlSn, "-")
  4272. var advice_id int64 = 0
  4273. var project_id int64 = 0
  4274. var types int64 = 0
  4275. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4276. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4277. if temp[1] == "1" {
  4278. advice_id = id
  4279. project_id = 0
  4280. } else if temp[1] == "2" {
  4281. advice_id = 0
  4282. project_id = id
  4283. }
  4284. info := &models.HisOrderInfo{
  4285. OrderNumber: order.Number,
  4286. FeedetlSn: item.FeedetlSn,
  4287. UploadDate: time.Now().Unix(),
  4288. AdviceId: advice_id,
  4289. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4290. Cnt: item.Cnt,
  4291. Pric: float64(item.Pric),
  4292. PatientId: his.PatientId,
  4293. PricUplmtAmt: item.PricUplmtAmt,
  4294. SelfpayProp: item.SelfpayProp,
  4295. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4296. OverlmtAmt: item.OverlmtAmt,
  4297. PreselfpayAmt: item.PreselfpayAmt,
  4298. BasMednFlag: item.BasMednFlag,
  4299. MedChrgitmType: item.MedChrgitmType,
  4300. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4301. Status: 1,
  4302. Memo: item.Memo,
  4303. Mtime: time.Now().Unix(),
  4304. InscpScpAmt: item.InscpScpAmt,
  4305. DrtReimFlag: item.DrtReimFlag,
  4306. Ctime: time.Now().Unix(),
  4307. ListSpItemFlag: item.ListSpItemFlag,
  4308. ChldMedcFlag: item.ChldMedcFlag,
  4309. LmtUsedFlag: item.LmtUsedFlag,
  4310. ChrgitmLv: item.ChrgitmLv,
  4311. UserOrgId: adminUser.CurrentOrgId,
  4312. HisPatientId: his.ID,
  4313. OrderId: order.ID,
  4314. ProjectId: project_id,
  4315. Type: types,
  4316. }
  4317. service.CreateOrderInfo(info)
  4318. }
  4319. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4320. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4321. var total float64
  4322. for _, item := range prescriptions {
  4323. if item.Type == 1 { //药品
  4324. for _, subItem := range item.HisDoctorAdviceInfo {
  4325. total = total + (subItem.Price * subItem.PrescribingNumber)
  4326. }
  4327. }
  4328. if item.Type == 2 { //项目
  4329. for _, subItem := range item.HisPrescriptionProject {
  4330. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4331. total = total + (subItem.Price * cnt)
  4332. }
  4333. }
  4334. }
  4335. for _, item := range prescriptions {
  4336. for _, subItem := range item.HisAdditionalCharge {
  4337. total = total + (subItem.Price * float64(subItem.Count))
  4338. }
  4339. }
  4340. var allTotal string
  4341. if adminUser.CurrentOrgId == 9919 {
  4342. allTotal = fmt.Sprintf("%.4f", total)
  4343. } else {
  4344. allTotal = fmt.Sprintf("%.4f", total)
  4345. }
  4346. if res.Infcode == 0 {
  4347. var rf []*ResultFive
  4348. json.Unmarshal([]byte(his.Iinfo), &rf)
  4349. chrg_bchno := chrg_bchno
  4350. cert_no := his.Certno
  4351. var insutypes []string
  4352. var insutype string
  4353. var is390 int = 0
  4354. var is310 int = 0
  4355. for _, item := range rf {
  4356. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4357. insutypes = append(insutypes, item.Insutype)
  4358. }
  4359. }
  4360. if len(insutypes) == 1 {
  4361. insutype = insutypes[0]
  4362. } else {
  4363. for _, i := range insutypes {
  4364. if i == "390" {
  4365. is390 = 1
  4366. }
  4367. if i == "310" {
  4368. is310 = 1
  4369. }
  4370. }
  4371. }
  4372. if is390 == 1 {
  4373. insutype = "390"
  4374. }
  4375. if is310 == 1 {
  4376. insutype = "310"
  4377. }
  4378. if len(insutypes) == 0 {
  4379. insutype = "310"
  4380. }
  4381. if len(insutypes) == 2 {
  4382. insutype = strconv.FormatInt(his.SocialType, 10)
  4383. }
  4384. insutype = strconv.FormatInt(his.SocialType, 10)
  4385. //insutype = "390"
  4386. if his.IdCardType == 1 {
  4387. // cert_no = his.MedicalInsuranceNumber
  4388. cert_no = his.Certno
  4389. } else {
  4390. cert_no = his.Certno
  4391. }
  4392. var res ResultSeven
  4393. var resSeven10265 ResultSeven10265
  4394. var src_resquest string
  4395. var result2 string
  4396. var acct_used_flag string
  4397. fmt.Println("pay_way")
  4398. fmt.Println(pay_way)
  4399. fmt.Println("pay_way")
  4400. if pay_way == 4 {
  4401. acct_used_flag = "1"
  4402. } else {
  4403. acct_used_flag = "0"
  4404. }
  4405. if miConfig.MdtrtareaAdmvs == "421300" {
  4406. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4407. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4408. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4409. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4410. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4411. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4412. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4413. resp, requestErr := http.Get(api)
  4414. if requestErr != nil {
  4415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4416. return
  4417. }
  4418. body, ioErr := ioutil.ReadAll(resp.Body)
  4419. if ioErr != nil {
  4420. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4422. return
  4423. }
  4424. var respJSON map[string]interface{}
  4425. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4426. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4428. return
  4429. }
  4430. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4431. result, _ := json.Marshal(respJSON)
  4432. if miConfig.Code == "H15049901371" {
  4433. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4434. utils.ErrorLog("解析失败:%v", err)
  4435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4436. return
  4437. }
  4438. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4439. res.Output = resSeven10265.Output
  4440. res.ErrMsg = resSeven10265.ErrMsg
  4441. res.Cainfo = resSeven10265.Cainfo
  4442. res.WarnMsg = resSeven10265.WarnMsg
  4443. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4444. res.Infcode = infocode
  4445. } else {
  4446. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4447. utils.ErrorLog("解析失败:%v", err)
  4448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4449. return
  4450. }
  4451. }
  4452. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4453. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4454. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4455. //psn_info, _ := service.GetPsnByPatientId(id)
  4456. bas := strings.Split(psn_info.CardInfo, "|")
  4457. if his.IdCardType == 1 {
  4458. cert_no = bas[2]
  4459. } else {
  4460. cert_no = bas[1]
  4461. }
  4462. //江苏地区国家医保医疗类别
  4463. //职工透析:医疗类别选特殊情况门诊9933
  4464. //居民血透门慢: 医疗类别选门诊慢病1402
  4465. //var med_type string
  4466. //if his.Insutype == "310" {
  4467. // if reg_type == 14 {
  4468. // med_type = "9933"
  4469. // } else if reg_type == 11 {
  4470. // med_type = "11"
  4471. //
  4472. // }
  4473. //} else if his.Insutype == "390" {
  4474. // if reg_type == 14 {
  4475. // med_type = "1402"
  4476. // } else if reg_type == 11 {
  4477. // med_type = "11"
  4478. // }
  4479. //}
  4480. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4481. var api string
  4482. if miConfig.MdtrtareaAdmvs == "320921" {
  4483. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4484. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4485. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4486. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4487. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4488. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4489. "&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
  4490. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4491. } else {
  4492. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4493. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4494. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4495. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4496. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4497. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4498. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4499. "&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
  4500. }
  4501. resp, requestErr := http.Get(api)
  4502. if requestErr != nil {
  4503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4504. return
  4505. }
  4506. body, ioErr := ioutil.ReadAll(resp.Body)
  4507. if ioErr != nil {
  4508. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4510. return
  4511. }
  4512. var respJSON map[string]interface{}
  4513. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4514. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4516. return
  4517. }
  4518. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4519. result, _ := json.Marshal(respJSON)
  4520. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4521. utils.ErrorLog("解析失败:%v", err)
  4522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4523. return
  4524. }
  4525. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4526. res.Output = resSeven10265.Output
  4527. res.ErrMsg = resSeven10265.ErrMsg
  4528. res.Cainfo = resSeven10265.Cainfo
  4529. res.WarnMsg = resSeven10265.WarnMsg
  4530. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4531. res.Infcode = infocode
  4532. } else {
  4533. if miConfig.Code == "H15049901371" {
  4534. //赤峰地区国家医保医疗类别
  4535. //职工透析:医疗类别选特殊情况门诊990502
  4536. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4537. var med_type string
  4538. if his.Insutype == "390" {
  4539. if reg_type == 14 {
  4540. med_type = "9933"
  4541. } else if reg_type == 11 {
  4542. med_type = "11"
  4543. }
  4544. } else if his.Insutype == "310" {
  4545. if reg_type == 14 {
  4546. med_type = "990502"
  4547. } else if reg_type == 11 {
  4548. med_type = "11"
  4549. }
  4550. }
  4551. 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)
  4552. } else {
  4553. 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)
  4554. }
  4555. //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)
  4556. var dat map[string]interface{}
  4557. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4558. fmt.Println(dat)
  4559. } else {
  4560. fmt.Println(err)
  4561. }
  4562. saveLog(result2, src_resquest, "2207", "结算")
  4563. userJSONBytes, _ := json.Marshal(dat)
  4564. if miConfig.Code == "H15049901371" {
  4565. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4566. utils.ErrorLog("解析失败:%v", err)
  4567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4568. return
  4569. }
  4570. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4571. res.Output = resSeven10265.Output
  4572. res.ErrMsg = resSeven10265.ErrMsg
  4573. res.Cainfo = resSeven10265.Cainfo
  4574. res.WarnMsg = resSeven10265.WarnMsg
  4575. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4576. res.Infcode = infocode
  4577. } else {
  4578. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4579. utils.ErrorLog("解析失败:%v", err)
  4580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4581. return
  4582. }
  4583. }
  4584. }
  4585. if res.Infcode != 0 {
  4586. errlog := &models.HisOrderError{
  4587. UserOrgId: adminUser.CurrentOrgId,
  4588. Ctime: time.Now().Unix(),
  4589. Mtime: time.Now().Unix(),
  4590. Number: chrg_bchno,
  4591. ErrMsg: res.ErrMsg,
  4592. Status: 1,
  4593. PatientId: id,
  4594. RecordTime: recordDateTime,
  4595. Stage: 6,
  4596. }
  4597. service.CreateErrMsgLog(errlog)
  4598. c.ServeSuccessJSON(map[string]interface{}{
  4599. "failed_code": -10,
  4600. "msg": res.ErrMsg,
  4601. })
  4602. return
  4603. } else {
  4604. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4605. order.OrderStatus = 2
  4606. order.Status = 1
  4607. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4608. order.SetlId = res.Output.Setlinfo.SetlID
  4609. order.PsnNo = res.Output.Setlinfo.PsnNo
  4610. order.PsnName = res.Output.Setlinfo.PsnName
  4611. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4612. order.Certno = res.Output.Setlinfo.Certno
  4613. order.Gend = res.Output.Setlinfo.Gend
  4614. order.Naty = res.Output.Setlinfo.Naty
  4615. order.Age = res.Output.Setlinfo.Age
  4616. order.Insutype = res.Output.Setlinfo.Insutype
  4617. order.PsnType = res.Output.Setlinfo.PsnType
  4618. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4619. order.SetlTime = res.Output.Setlinfo.SetlTime
  4620. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4621. if res.Output.Setlinfo.MedType == "140101" {
  4622. order.MedType = "14"
  4623. } else {
  4624. order.MedType = res.Output.Setlinfo.MedType
  4625. }
  4626. if reg_type == 1112 {
  4627. order.MedType = "1112"
  4628. }
  4629. if reg_type == 1111 {
  4630. order.MedType = "1111"
  4631. }
  4632. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4633. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4634. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4635. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4636. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4637. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4638. order.HifpPay = res.Output.Setlinfo.HifpPay
  4639. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4640. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4641. order.HifesPay = res.Output.Setlinfo.HifesPay
  4642. order.HifobPay = res.Output.Setlinfo.HifobPay
  4643. order.MafPay = res.Output.Setlinfo.MafPay
  4644. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4645. order.OthPay = res.Output.Setlinfo.OthPay
  4646. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4647. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4648. order.AcctPay = res.Output.Setlinfo.AcctPay
  4649. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4650. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4651. order.Balc = res.Output.Setlinfo.Balc
  4652. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4653. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4654. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4655. order.ClrType = res.Output.Setlinfo.ClrType
  4656. order.ClrWay = res.Output.Setlinfo.ClrWay
  4657. order.Creator = order.Creator
  4658. order.Modify = roles.AdminUserId
  4659. order.RequestLog = src_resquest
  4660. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4661. detailStr := string(setlDetail)
  4662. order.SetlDetail = detailStr
  4663. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4664. err = service.UpDateOrder(order)
  4665. if err == nil {
  4666. c.ServeSuccessJSON(map[string]interface{}{
  4667. "msg": "结算成功",
  4668. })
  4669. } else {
  4670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4671. return
  4672. }
  4673. }
  4674. } else {
  4675. adminUser := c.GetAdminUserInfo()
  4676. errlog := &models.HisOrderError{
  4677. UserOrgId: adminUser.CurrentOrgId,
  4678. Ctime: time.Now().Unix(),
  4679. Mtime: time.Now().Unix(),
  4680. ErrMsg: res.ErrMsg,
  4681. Status: 1,
  4682. PatientId: id,
  4683. RecordTime: recordDateTime,
  4684. Stage: 4,
  4685. }
  4686. service.CreateErrMsgLog(errlog)
  4687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4688. return
  4689. }
  4690. } else {
  4691. adminUser := c.GetAdminUserInfo()
  4692. errlog := &models.HisOrderError{
  4693. UserOrgId: adminUser.CurrentOrgId,
  4694. Ctime: time.Now().Unix(),
  4695. Mtime: time.Now().Unix(),
  4696. ErrMsg: res.ErrMsg,
  4697. Status: 1,
  4698. PatientId: id,
  4699. RecordTime: recordDateTime,
  4700. Stage: 4,
  4701. }
  4702. service.CreateErrMsgLog(errlog)
  4703. c.ServeSuccessJSON(map[string]interface{}{
  4704. "failed_code": -10,
  4705. "msg": res.ErrMsg,
  4706. })
  4707. return
  4708. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4709. //return
  4710. }
  4711. }
  4712. }
  4713. } else if tempOrder.ID > 0 {
  4714. if tempOrder.IsPre == 1 {
  4715. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  4716. var rf []*ResultFive
  4717. json.Unmarshal([]byte(his.Iinfo), &rf)
  4718. chrg_bchno := tempOrder.Number
  4719. cert_no := his.Certno
  4720. var insutypes []string
  4721. var insutype string
  4722. var is390 int = 0
  4723. var is310 int = 0
  4724. for _, item := range rf {
  4725. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4726. insutypes = append(insutypes, item.Insutype)
  4727. }
  4728. }
  4729. if len(insutypes) == 1 {
  4730. insutype = insutypes[0]
  4731. } else {
  4732. for _, i := range insutypes {
  4733. if i == "390" {
  4734. is390 = 1
  4735. }
  4736. if i == "310" {
  4737. is310 = 1
  4738. }
  4739. }
  4740. }
  4741. if is390 == 1 {
  4742. insutype = "390"
  4743. }
  4744. if is310 == 1 {
  4745. insutype = "310"
  4746. }
  4747. if len(insutypes) == 0 {
  4748. insutype = "310"
  4749. }
  4750. if len(insutypes) == 2 {
  4751. insutype = strconv.FormatInt(his.SocialType, 64)
  4752. }
  4753. //insutype = "390"
  4754. if his.IdCardType == 1 {
  4755. // cert_no = his.MedicalInsuranceNumber
  4756. cert_no = his.Certno
  4757. } else {
  4758. cert_no = his.Certno
  4759. }
  4760. var res ResultSeven
  4761. var resSeven10265 ResultSeven10265
  4762. var src_resquest string
  4763. var result2 string
  4764. var acct_used_flag string
  4765. fmt.Println("pay_way")
  4766. fmt.Println(pay_way)
  4767. fmt.Println("pay_way")
  4768. if pay_way == 4 {
  4769. acct_used_flag = "1"
  4770. } else {
  4771. acct_used_flag = "0"
  4772. }
  4773. if miConfig.MdtrtareaAdmvs == "421300" {
  4774. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4775. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4776. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4777. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4778. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4779. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4780. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4781. resp, requestErr := http.Get(api)
  4782. if requestErr != nil {
  4783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4784. return
  4785. }
  4786. body, ioErr := ioutil.ReadAll(resp.Body)
  4787. if ioErr != nil {
  4788. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4790. return
  4791. }
  4792. var respJSON map[string]interface{}
  4793. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4796. return
  4797. }
  4798. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4799. result, _ := json.Marshal(respJSON)
  4800. fmt.Println("log")
  4801. fmt.Println(string(result))
  4802. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4803. utils.ErrorLog("解析失败:%v", err)
  4804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4805. return
  4806. }
  4807. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4808. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4809. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4810. //psn_info, _ := service.GetPsnByPatientId(id)
  4811. bas := strings.Split(psn_info.CardInfo, "|")
  4812. if his.IdCardType == 1 {
  4813. cert_no = bas[2]
  4814. } else {
  4815. cert_no = bas[1]
  4816. }
  4817. //江苏地区国家医保医疗类别
  4818. //职工透析:医疗类别选特殊情况门诊9933
  4819. //居民血透门慢: 医疗类别选门诊慢病1402
  4820. //var med_type string
  4821. //if his.Insutype == "310" {
  4822. // if reg_type == 14 {
  4823. // med_type = "9933"
  4824. // } else if reg_type == 11 {
  4825. // med_type = "11"
  4826. //
  4827. // }
  4828. //} else if his.Insutype == "390" {
  4829. // if reg_type == 14 {
  4830. // med_type = "1402"
  4831. // } else if reg_type == 11 {
  4832. // med_type = "11"
  4833. // }
  4834. //}
  4835. var api string
  4836. if miConfig.MdtrtareaAdmvs == "320921" {
  4837. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4838. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4839. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4840. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4841. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4842. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4843. "&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
  4844. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4845. } else {
  4846. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4847. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4848. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4849. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4850. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4851. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4852. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4853. "&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
  4854. }
  4855. resp, requestErr := http.Get(api)
  4856. if requestErr != nil {
  4857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4858. return
  4859. }
  4860. body, ioErr := ioutil.ReadAll(resp.Body)
  4861. if ioErr != nil {
  4862. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4864. return
  4865. }
  4866. var respJSON map[string]interface{}
  4867. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4868. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4870. return
  4871. }
  4872. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4873. result, _ := json.Marshal(respJSON)
  4874. fmt.Println("log")
  4875. fmt.Println(string(result))
  4876. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4877. utils.ErrorLog("解析失败:%v", err)
  4878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4879. return
  4880. }
  4881. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4882. res.Output = resSeven10265.Output
  4883. res.ErrMsg = resSeven10265.ErrMsg
  4884. res.Cainfo = resSeven10265.Cainfo
  4885. res.WarnMsg = resSeven10265.WarnMsg
  4886. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4887. res.Infcode = infocode
  4888. } else {
  4889. var src_resquest string
  4890. if miConfig.Code == "H15049901371" {
  4891. //赤峰地区国家医保医疗类别
  4892. //职工透析:医疗类别选特殊情况门诊990502
  4893. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4894. var med_type string
  4895. if his.Insutype == "390" {
  4896. if reg_type == 14 {
  4897. med_type = "9933"
  4898. } else if reg_type == 11 {
  4899. med_type = "11"
  4900. }
  4901. } else if his.Insutype == "310" {
  4902. if reg_type == 14 {
  4903. med_type = "990502"
  4904. } else if reg_type == 11 {
  4905. med_type = "11"
  4906. }
  4907. }
  4908. 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)
  4909. } else {
  4910. 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)
  4911. }
  4912. var dat map[string]interface{}
  4913. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4914. fmt.Println(dat)
  4915. } else {
  4916. fmt.Println(err)
  4917. }
  4918. saveLog(result2, src_resquest, "2207", "结算")
  4919. userJSONBytes, _ := json.Marshal(dat)
  4920. if miConfig.Code == "H15049901371" {
  4921. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4922. utils.ErrorLog("解析失败:%v", err)
  4923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4924. return
  4925. }
  4926. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4927. res.Output = resSeven10265.Output
  4928. res.ErrMsg = resSeven10265.ErrMsg
  4929. res.Cainfo = resSeven10265.Cainfo
  4930. res.WarnMsg = resSeven10265.WarnMsg
  4931. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4932. res.Infcode = infocode
  4933. } else {
  4934. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4935. utils.ErrorLog("解析失败:%v", err)
  4936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4937. return
  4938. }
  4939. }
  4940. }
  4941. if res.Infcode != 0 {
  4942. errlog := &models.HisOrderError{
  4943. UserOrgId: adminUser.CurrentOrgId,
  4944. Ctime: time.Now().Unix(),
  4945. Mtime: time.Now().Unix(),
  4946. Number: chrg_bchno,
  4947. ErrMsg: res.ErrMsg,
  4948. Status: 1,
  4949. PatientId: id,
  4950. RecordTime: recordDateTime,
  4951. Stage: 6,
  4952. }
  4953. service.CreateErrMsgLog(errlog)
  4954. c.ServeSuccessJSON(map[string]interface{}{
  4955. "failed_code": -10,
  4956. "msg": res.ErrMsg,
  4957. })
  4958. return
  4959. } else {
  4960. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4961. order.OrderStatus = 2
  4962. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4963. order.SetlId = res.Output.Setlinfo.SetlID
  4964. order.PsnNo = res.Output.Setlinfo.PsnNo
  4965. order.PsnName = res.Output.Setlinfo.PsnName
  4966. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4967. order.Certno = res.Output.Setlinfo.Certno
  4968. order.Gend = res.Output.Setlinfo.Gend
  4969. order.Naty = res.Output.Setlinfo.Naty
  4970. order.Age = res.Output.Setlinfo.Age
  4971. order.Insutype = res.Output.Setlinfo.Insutype
  4972. order.PsnType = res.Output.Setlinfo.PsnType
  4973. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4974. order.SetlTime = res.Output.Setlinfo.SetlTime
  4975. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4976. //order.MedType = res.Output.Setlinfo.MedType
  4977. if reg_type == 1112 {
  4978. order.MedType = "1112"
  4979. }
  4980. if reg_type == 1111 {
  4981. order.MedType = "1111"
  4982. }
  4983. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4984. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4985. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4986. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4987. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4988. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4989. order.HifpPay = res.Output.Setlinfo.HifpPay
  4990. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4991. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4992. order.HifesPay = res.Output.Setlinfo.HifesPay
  4993. order.HifobPay = res.Output.Setlinfo.HifobPay
  4994. order.MafPay = res.Output.Setlinfo.MafPay
  4995. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4996. order.OthPay = res.Output.Setlinfo.OthPay
  4997. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4998. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4999. order.AcctPay = res.Output.Setlinfo.AcctPay
  5000. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5001. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5002. order.Balc = res.Output.Setlinfo.Balc
  5003. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5004. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5005. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5006. order.ClrWay = res.Output.Setlinfo.ClrWay
  5007. order.Creator = order.Creator
  5008. order.Modify = roles.AdminUserId
  5009. order.RequestLog = src_resquest
  5010. order.Diagnosis = diagnosis_id
  5011. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5012. detailStr := string(setlDetail)
  5013. order.SetlDetail = detailStr
  5014. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5015. err = service.UpDateOrder(order)
  5016. if err == nil {
  5017. c.ServeSuccessJSON(map[string]interface{}{
  5018. "msg": "结算成功",
  5019. })
  5020. } else {
  5021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5022. return
  5023. }
  5024. }
  5025. }
  5026. }
  5027. }
  5028. //func (c *HisApiController) GetPreUploadInfo() {
  5029. // id, _ := c.GetInt64("id")
  5030. // record_time := c.GetString("record_time")
  5031. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5032. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5033. //
  5034. // timeLayout := "2006-01-02"
  5035. // loc, _ := time.LoadLocation("Local")
  5036. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5037. // if err != nil {
  5038. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5039. // return
  5040. // }
  5041. // recordDateTime := theTime.Unix()
  5042. // adminUser := c.GetAdminUserInfo()
  5043. //
  5044. // var prescriptions []*models.HisPrescription
  5045. //
  5046. // var start_time int64
  5047. // var end_time int64
  5048. //
  5049. // data := make(map[string]interface{})
  5050. // if settle_accounts_type == 1 { //日结
  5051. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5052. // data["pre"] = prescriptions
  5053. //
  5054. // } else { //月结
  5055. // start_time_str := c.GetString("start_time")
  5056. // end_time_str := c.GetString("end_time")
  5057. // timeLayout := "2006-01-02"
  5058. // loc, _ := time.LoadLocation("Local")
  5059. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5060. // if err != nil {
  5061. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5062. // return
  5063. // }
  5064. // recordStartTime := theStartTime.Unix()
  5065. // start_time = recordStartTime
  5066. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5067. // if err != nil {
  5068. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5069. // return
  5070. // }
  5071. // recordEndTime := theEndTime.Unix()
  5072. // end_time = recordEndTime
  5073. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5074. // data["pre"] = prescriptions
  5075. //
  5076. // }
  5077. //
  5078. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5079. //
  5080. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5081. // timestamp := time.Now().Unix()
  5082. // tempTime := time.Unix(timestamp, 0)
  5083. // timeFormat := tempTime.Format("20060102150405")
  5084. // chrgBchno := rand.Intn(100000) + 10000
  5085. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5086. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5087. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5088. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5089. // strconv.FormatInt(his.PatientId, 10)
  5090. // client := &http.Client{}
  5091. // data["psn_no"] = his.PsnNo
  5092. // data["mdtrt_id"] = his.Number
  5093. // data["chrg_bchno"] = chrg_bchno
  5094. // data["org_name"] = miConfig.OrgName
  5095. // data["doctor"] = roles.UserName
  5096. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5097. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5098. // data["fixmedins_code"] = miConfig.Code
  5099. // data["dept_code"] = department.Number
  5100. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5101. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5102. // data["secret_key"] = miConfig.SecretKey
  5103. // var ids []int64
  5104. //
  5105. // for _, item := range prescriptions {
  5106. // ids = append(ids, item.ID)
  5107. // }
  5108. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5109. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5110. // bytesData, _ := json.Marshal(data)
  5111. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5112. // resp, _ := client.Do(req)
  5113. // defer resp.Body.Close()
  5114. // body, ioErr := ioutil.ReadAll(resp.Body)
  5115. // if ioErr != nil {
  5116. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5117. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5118. // return
  5119. // }
  5120. // var respJSON map[string]interface{}
  5121. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5122. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5123. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5124. // return
  5125. // }
  5126. //
  5127. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5128. // userJSONBytes, _ := json.Marshal(respJSON)
  5129. // var res ResultFour
  5130. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5131. // utils.ErrorLog("解析失败:%v", err)
  5132. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5133. // return
  5134. // }
  5135. //
  5136. // if res.Infcode == 0 {
  5137. // order := &models.HisOrder{
  5138. // UserOrgId: adminUser.CurrentOrgId,
  5139. // HisPatientId: his.ID,
  5140. // PatientId: his.PatientId,
  5141. // SettleAccountsDate: recordDateTime,
  5142. // Ctime: time.Now().Unix(),
  5143. // Mtime: time.Now().Unix(),
  5144. // Status: 1,
  5145. // Number: chrg_bchno,
  5146. // Infcode: res.Infcode,
  5147. // WarnMsg: res.WarnMsg,
  5148. // Cainfo: res.Cainfo,
  5149. // ErrMsg: res.ErrMsg,
  5150. // RespondTime: res.RefmsgTime,
  5151. // InfRefmsgid: res.InfRefmsgid,
  5152. // OrderStatus: 1,
  5153. // IsMedicineInsurance: 1,
  5154. // SettleType: settle_accounts_type,
  5155. // SettleStartTime: start_time,
  5156. // SettleEndTime: end_time,
  5157. // Creator: roles.ID,
  5158. // Modify: roles.ID,
  5159. // PType: 2,
  5160. // }
  5161. // err = service.CreateOrder(order)
  5162. // if err != nil {
  5163. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5164. // return
  5165. // }
  5166. //
  5167. // for _, item := range res.Output.Result {
  5168. // temp := strings.Split(item.FeedetlSn, "-")
  5169. // var advice_id int64 = 0
  5170. // var project_id int64 = 0
  5171. // var types int64 = 0
  5172. //
  5173. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  5174. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  5175. //
  5176. // if temp[1] == "1" {
  5177. // advice_id = id
  5178. // project_id = 0
  5179. // } else if temp[1] == "2" {
  5180. // advice_id = 0
  5181. // project_id = id
  5182. // }
  5183. //
  5184. // info := &models.HisOrderInfo{
  5185. // OrderNumber: order.Number,
  5186. // FeedetlSn: item.FeedetlSn,
  5187. // UploadDate: time.Now().Unix(),
  5188. // AdviceId: advice_id,
  5189. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5190. // Cnt: item.Cnt,
  5191. // Pric: float64(item.Pric),
  5192. // PatientId: his.PatientId,
  5193. // PricUplmtAmt: item.PricUplmtAmt,
  5194. // SelfpayProp: item.SelfpayProp,
  5195. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5196. // OverlmtAmt: item.OverlmtAmt,
  5197. // PreselfpayAmt: item.PreselfpayAmt,
  5198. // BasMednFlag: item.BasMednFlag,
  5199. // MedChrgitmType: item.MedChrgitmType,
  5200. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5201. // Status: 1,
  5202. // Memo: item.Memo,
  5203. // Mtime: time.Now().Unix(),
  5204. // InscpScpAmt: item.InscpScpAmt,
  5205. // DrtReimFlag: item.DrtReimFlag,
  5206. // Ctime: time.Now().Unix(),
  5207. // ListSpItemFlag: item.ListSpItemFlag,
  5208. // ChldMedcFlag: item.ChldMedcFlag,
  5209. // LmtUsedFlag: item.LmtUsedFlag,
  5210. // ChrgitmLv: item.ChrgitmLv,
  5211. // UserOrgId: adminUser.CurrentOrgId,
  5212. // HisPatientId: his.ID,
  5213. // OrderId: order.ID,
  5214. // ProjectId: project_id,
  5215. // Type: types,
  5216. // }
  5217. // service.CreateOrderInfo(info)
  5218. //
  5219. // }
  5220. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5221. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5222. //
  5223. // var total float64
  5224. // for _, item := range prescriptions {
  5225. // if item.Type == 1 { //药品
  5226. // for _, subItem := range item.HisDoctorAdviceInfo {
  5227. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5228. // }
  5229. // }
  5230. // if item.Type == 2 { //项目
  5231. // for _, subItem := range item.HisPrescriptionProject {
  5232. // total = total + (subItem.Price * float64(subItem.Count))
  5233. // }
  5234. // }
  5235. // }
  5236. //
  5237. // for _, item := range prescriptions {
  5238. // for _, subItem := range item.HisAdditionalCharge {
  5239. // total = total + (subItem.Price * float64(subItem.Count))
  5240. // }
  5241. // }
  5242. //
  5243. // allTotal := fmt.Sprintf("%.2f", total)
  5244. // if res.Infcode == 0 {
  5245. // var rf []*ResultFive
  5246. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5247. // psn_no := his.PsnNo
  5248. // mdtrt_id := his.Number
  5249. // chrg_bchno := chrg_bchno
  5250. // cert_no := his.Certno
  5251. // insutype := rf[0].Insutype
  5252. //
  5253. // if his.IdCardType == 1 {
  5254. // cert_no = his.MedicalInsuranceNumber
  5255. //
  5256. // } else {
  5257. //
  5258. // cert_no = his.Certno
  5259. //
  5260. // }
  5261. //
  5262. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5263. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5264. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5265. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5266. // resp, requestErr := http.Get(api)
  5267. // if requestErr != nil {
  5268. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5269. // return
  5270. // }
  5271. // defer resp.Body.Close()
  5272. // body, ioErr := ioutil.ReadAll(resp.Body)
  5273. // if ioErr != nil {
  5274. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5275. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5276. // return
  5277. // }
  5278. // var respJSON map[string]interface{}
  5279. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5280. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5281. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5282. // return
  5283. // }
  5284. // fmt.Println(respJSON)
  5285. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5286. // userJSONBytes, _ := json.Marshal(respJSON)
  5287. // var res ResultSeven
  5288. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5289. // utils.ErrorLog("解析失败:%v", err)
  5290. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5291. // return
  5292. // }
  5293. // if res.Infcode != 0 {
  5294. // errlog := &models.HisOrderError{
  5295. // UserOrgId: adminUser.CurrentOrgId,
  5296. // Ctime: time.Now().Unix(),
  5297. // Mtime: time.Now().Unix(),
  5298. // Number: chrg_bchno,
  5299. // ErrMsg: res.ErrMsg,
  5300. // Status: 1,
  5301. // PatientId: id,
  5302. // RecordTime: recordDateTime,
  5303. // Stage: 7,
  5304. // }
  5305. // service.CreateErrMsgLog(errlog)
  5306. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5307. // return
  5308. // } else {
  5309. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5310. // order.OrderStatus = 1
  5311. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5312. // order.SetlId = res.Output.Setlinfo.SetlID
  5313. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5314. // order.PsnName = res.Output.Setlinfo.PsnName
  5315. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5316. // order.Certno = res.Output.Setlinfo.Certno
  5317. // order.Gend = res.Output.Setlinfo.Gend
  5318. // order.Naty = res.Output.Setlinfo.Naty
  5319. // order.Age = res.Output.Setlinfo.Age
  5320. // order.Insutype = res.Output.Setlinfo.Insutype
  5321. // order.PsnType = res.Output.Setlinfo.PsnType
  5322. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5323. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5324. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5325. // order.MedType = res.Output.Setlinfo.MedType
  5326. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5327. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5328. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5329. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5330. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5331. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5332. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5333. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5334. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5335. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5336. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5337. // order.MafPay = res.Output.Setlinfo.MafPay
  5338. // order.OthPay = res.Output.Setlinfo.OthPay
  5339. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5340. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5341. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5342. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5343. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5344. // order.Balc = res.Output.Setlinfo.Balc
  5345. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5346. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5347. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5348. // order.ClrWay = res.Output.Setlinfo.ClrWay
  5349. // order.Creator = order.Creator
  5350. // order.Modify = roles.ID
  5351. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5352. // detailStr := string(setlDetail)
  5353. // order.SetlDetail = detailStr
  5354. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5355. // err = service.UpDateOrder(order)
  5356. // if err == nil {
  5357. // c.ServeSuccessJSON(map[string]interface{}{
  5358. // "msg": "预结算成功",
  5359. // })
  5360. // } else {
  5361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5362. // return
  5363. // }
  5364. // }
  5365. // } else {
  5366. // adminUser := c.GetAdminUserInfo()
  5367. // errlog := &models.HisOrderError{
  5368. // UserOrgId: adminUser.CurrentOrgId,
  5369. // Ctime: time.Now().Unix(),
  5370. // Mtime: time.Now().Unix(),
  5371. // ErrMsg: res.ErrMsg,
  5372. // Status: 1,
  5373. // PatientId: id,
  5374. // RecordTime: recordDateTime,
  5375. // Stage: 4,
  5376. // }
  5377. // service.CreateErrMsgLog(errlog)
  5378. //
  5379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5380. // return
  5381. // }
  5382. // } else {
  5383. // adminUser := c.GetAdminUserInfo()
  5384. // errlog := &models.HisOrderError{
  5385. // UserOrgId: adminUser.CurrentOrgId,
  5386. // Ctime: time.Now().Unix(),
  5387. // Mtime: time.Now().Unix(),
  5388. // ErrMsg: res.ErrMsg,
  5389. // Status: 1,
  5390. // PatientId: id,
  5391. // RecordTime: recordDateTime,
  5392. // Stage: 4,
  5393. // }
  5394. // service.CreateErrMsgLog(errlog)
  5395. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5396. // return
  5397. // }
  5398. //
  5399. // } else {
  5400. // var total float64
  5401. // for _, item := range prescriptions {
  5402. // if item.Type == 1 { //药品
  5403. // for _, subItem := range item.HisDoctorAdviceInfo {
  5404. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5405. // }
  5406. // }
  5407. // if item.Type == 2 { //项目
  5408. // for _, subItem := range item.HisPrescriptionProject {
  5409. // total = total + (subItem.Price * float64(subItem.Count))
  5410. // }
  5411. // }
  5412. //
  5413. // for _, subItem := range item.HisAdditionalCharge {
  5414. // total = total + (subItem.Price * float64(subItem.Count))
  5415. // }
  5416. // }
  5417. //
  5418. // allTotal := fmt.Sprintf("%.2f", total)
  5419. // totals, _ := strconv.ParseFloat(allTotal, 64)
  5420. // order := &models.HisOrder{
  5421. // UserOrgId: adminUser.CurrentOrgId,
  5422. // HisPatientId: his.ID,
  5423. // PatientId: id,
  5424. // SettleAccountsDate: recordDateTime,
  5425. // Ctime: time.Now().Unix(),
  5426. // Mtime: time.Now().Unix(),
  5427. // Status: 1,
  5428. // OrderStatus: 2,
  5429. // Number: chrg_bchno,
  5430. // MedfeeSumamt: totals,
  5431. // }
  5432. // err = service.CreateOrder(order)
  5433. // if err != nil {
  5434. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5435. // return
  5436. // }
  5437. //
  5438. // var customs []*Custom
  5439. // for _, item := range prescriptions {
  5440. //
  5441. // if item.Type == 1 { //药品
  5442. // for _, subItem := range item.HisDoctorAdviceInfo {
  5443. // cus := &Custom{
  5444. // AdviceId: subItem.ID,
  5445. // ProjectId: 0,
  5446. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  5447. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  5448. // FeedetlSn: subItem.FeedetlSn,
  5449. // Price: fmt.Sprintf("%.2f", subItem.Price),
  5450. // MedListCodg: subItem.MedListCodg,
  5451. // Type: 1,
  5452. // }
  5453. // customs = append(customs, cus)
  5454. // }
  5455. // }
  5456. //
  5457. // if item.Type == 2 { //项目
  5458. // for _, subItem := range item.HisPrescriptionProject {
  5459. //
  5460. // cus := &Custom{
  5461. // AdviceId: 0,
  5462. // ProjectId: subItem.ID,
  5463. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  5464. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  5465. // FeedetlSn: subItem.FeedetlSn,
  5466. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  5467. // MedListCodg: subItem.MedListCodg,
  5468. // Type: 2,
  5469. // }
  5470. //
  5471. // customs = append(customs, cus)
  5472. // }
  5473. // }
  5474. //
  5475. // for _, item := range item.HisAdditionalCharge {
  5476. // cus := &Custom{
  5477. // ItemId: item.ID,
  5478. // AdviceId: 0,
  5479. // ProjectId: 0,
  5480. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  5481. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  5482. // FeedetlSn: item.FeedetlSn,
  5483. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  5484. // MedListCodg: item.XtHisAddtionConfig.Code,
  5485. // Type: 3,
  5486. // }
  5487. //
  5488. // customs = append(customs, cus)
  5489. // }
  5490. //
  5491. // }
  5492. //
  5493. // for _, item := range customs {
  5494. // var advice_id int64 = 0
  5495. // var project_id int64 = 0
  5496. // var item_id int64 = 0
  5497. //
  5498. // var types int64 = 0
  5499. //
  5500. // if item.Type == 1 {
  5501. // advice_id = item.AdviceId
  5502. // project_id = 0
  5503. // item_id = 0
  5504. // } else if item.Type == 2 {
  5505. // advice_id = 0
  5506. // item_id = 0
  5507. //
  5508. // project_id = item.ProjectId
  5509. // } else if item.Type == 3 {
  5510. // advice_id = 0
  5511. // item_id = item.ItemId
  5512. // project_id = 0
  5513. // }
  5514. //
  5515. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  5516. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  5517. // pric, _ := strconv.ParseFloat(item.Price, 32)
  5518. //
  5519. // info := &models.HisOrderInfo{
  5520. // OrderNumber: order.Number,
  5521. // UploadDate: time.Now().Unix(),
  5522. // AdviceId: advice_id,
  5523. // DetItemFeeSumamt: detItemFeeSumamt,
  5524. // Cnt: cut,
  5525. // Pric: pric,
  5526. // PatientId: id,
  5527. // Status: 1,
  5528. // Mtime: time.Now().Unix(),
  5529. // Ctime: time.Now().Unix(),
  5530. // UserOrgId: adminUser.CurrentOrgId,
  5531. // HisPatientId: his.ID,
  5532. // OrderId: order.ID,
  5533. // ProjectId: project_id,
  5534. // Type: types,
  5535. // ItemId: item_id,
  5536. // }
  5537. // service.CreateOrderInfo(info)
  5538. // }
  5539. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5540. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5541. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  5542. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5543. // if err == nil {
  5544. // c.ServeSuccessJSON(map[string]interface{}{
  5545. // "msg": "结算成功",
  5546. // })
  5547. // } else {
  5548. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5549. // return
  5550. // }
  5551. // }
  5552. //}
  5553. //上传明细-预结算-
  5554. func (c *HisApiController) GetPreUploadInfo() {
  5555. id, _ := c.GetInt64("id")
  5556. record_time := c.GetString("record_time")
  5557. his_patient_id, _ := c.GetInt64("his_patient_id")
  5558. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5559. admin_user_id, _ := c.GetInt64("admin_user_id")
  5560. diagnosis_id := c.GetString("diagnosis")
  5561. sick_type, _ := c.GetInt64("sick_type")
  5562. reg_type, _ := c.GetInt64("p_type")
  5563. begin_time := c.GetString("begin_time")
  5564. id_str := c.GetString("ids")
  5565. ids_arr := strings.Split(id_str, ",")
  5566. timeLayout := "2006-01-02"
  5567. loc, _ := time.LoadLocation("Local")
  5568. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5569. if err != nil {
  5570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5571. return
  5572. }
  5573. recordDateTime := theTime.Unix()
  5574. adminUser := c.GetAdminUserInfo()
  5575. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5576. var config []*models.HisXtDiagnoseConfig
  5577. for _, item := range diagnosis_ids {
  5578. id, _ := strconv.ParseInt(item, 10, 64)
  5579. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5580. config = append(config, &diagnosisConfig)
  5581. }
  5582. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5583. sickConfig, _ := service.FindSickById(sick_type)
  5584. var prescriptions []*models.HisPrescription
  5585. var start_time int64
  5586. var end_time int64
  5587. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5588. fmt.Println(his_patient_id)
  5589. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5590. timestamp := time.Now().Unix()
  5591. tempTime := time.Unix(timestamp, 0)
  5592. timeFormat := tempTime.Format("20060102150405")
  5593. chrgBchno := rand.Intn(100000) + 10000
  5594. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5595. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5596. var patientPrescription models.HisPrescriptionInfo
  5597. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5598. if patientPrescription.ID == 0 {
  5599. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5600. }
  5601. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5602. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5603. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5604. strconv.FormatInt(his.PatientId, 10)
  5605. var res2 ResultSix
  5606. var resSix10265 ResultSix10265
  5607. var time_stamp string
  5608. if miConfig.MdtrtareaAdmvs == "421300" {
  5609. data := make(map[string]interface{})
  5610. client := &http.Client{}
  5611. data["psn_no"] = his.PsnNo
  5612. data["mdtrt_id"] = his.Number
  5613. data["doctor"] = roles.UserName
  5614. data["department"] = department.Name
  5615. data["org_name"] = miConfig.OrgName
  5616. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5617. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5618. data["fixmedins_code"] = miConfig.Code
  5619. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5620. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5621. data["secret_key"] = miConfig.SecretKey
  5622. data["sick_code"] = sickConfig.CountryCode
  5623. data["sick_name"] = sickConfig.ClassName
  5624. data["begin_time"] = begin_time
  5625. data["dept"] = strconv.FormatInt(department.ID, 10)
  5626. data["config"] = config
  5627. fmt.Println(data)
  5628. bytesData, _ := json.Marshal(data)
  5629. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5630. resp, _ := client.Do(req)
  5631. defer resp.Body.Close()
  5632. body, ioErr := ioutil.ReadAll(resp.Body)
  5633. if ioErr != nil {
  5634. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5636. return
  5637. }
  5638. var respJSON map[string]interface{}
  5639. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5642. return
  5643. }
  5644. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5645. userJSONBytes, _ := json.Marshal(respJSON)
  5646. fmt.Println("log")
  5647. fmt.Println(string(userJSONBytes))
  5648. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5649. utils.ErrorLog("解析失败:%v", err)
  5650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5651. return
  5652. }
  5653. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5654. //江苏地区国家医保医疗类别
  5655. //职工透析:医疗类别选特殊情况门诊9933
  5656. //居民血透门慢: 医疗类别选门诊慢病1402
  5657. //var med_type string
  5658. //if his.Insutype == "310" {
  5659. // if reg_type == 14 {
  5660. // med_type = "9933"
  5661. // } else if reg_type == 11 {
  5662. // med_type = "11"
  5663. //
  5664. // }
  5665. //} else if his.Insutype == "390" {
  5666. // if reg_type == 14 {
  5667. // med_type = "1402"
  5668. // } else if reg_type == 11 {
  5669. // med_type = "11"
  5670. // }
  5671. //}
  5672. data := make(map[string]interface{})
  5673. client := &http.Client{}
  5674. data["psn_no"] = his.PsnNo
  5675. data["mdtrt_id"] = his.Number
  5676. data["doctor"] = roles.UserName
  5677. data["department"] = department.Name
  5678. data["org_name"] = miConfig.OrgName
  5679. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5680. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5681. data["fixmedins_code"] = miConfig.Code
  5682. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5683. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5684. data["secret_key"] = miConfig.SecretKey
  5685. data["sick_code"] = sickConfig.CountryCode
  5686. data["sick_name"] = sickConfig.ClassName
  5687. data["begin_time"] = begin_time
  5688. data["dept"] = strconv.FormatInt(department.ID, 10)
  5689. data["config"] = config
  5690. data["url"] = miConfig.Url
  5691. data["ak"] = miConfig.AccessKey
  5692. data["cainfo"] = miConfig.Cainfo
  5693. bytesData, _ := json.Marshal(data)
  5694. var req *http.Request
  5695. if miConfig.MdtrtareaAdmvs == "320921" {
  5696. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5697. //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 +
  5698. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5699. } else {
  5700. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5701. }
  5702. resp, _ := client.Do(req)
  5703. defer resp.Body.Close()
  5704. body, ioErr := ioutil.ReadAll(resp.Body)
  5705. if ioErr != nil {
  5706. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5708. return
  5709. }
  5710. var respJSON map[string]interface{}
  5711. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5714. return
  5715. }
  5716. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  5717. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  5718. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  5719. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5720. userJSONBytes, _ := json.Marshal(respJSON)
  5721. fmt.Println("log")
  5722. fmt.Println(string(userJSONBytes))
  5723. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5724. utils.ErrorLog("解析失败:%v", err)
  5725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5726. return
  5727. }
  5728. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5729. res2.Output = resSix10265.Output
  5730. res2.ErrMsg = resSix10265.ErrMsg
  5731. res2.Cainfo = resSix10265.Cainfo
  5732. res2.WarnMsg = resSix10265.WarnMsg
  5733. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5734. res2.Infcode = infocode
  5735. } else {
  5736. var result string
  5737. var requestLog string
  5738. if miConfig.MdtrtareaAdmvs == "440781" { //
  5739. 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)
  5740. } else {
  5741. if miConfig.Code == "H15049901371" {
  5742. //赤峰地区国家医保医疗类别
  5743. //职工透析:医疗类别选特殊情况门诊990502
  5744. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5745. var med_type string
  5746. if his.Insutype == "390" {
  5747. if reg_type == 14 {
  5748. med_type = "9933"
  5749. } else if reg_type == 11 {
  5750. med_type = "11"
  5751. }
  5752. } else if his.Insutype == "310" {
  5753. if reg_type == 14 {
  5754. med_type = "990502"
  5755. } else if reg_type == 11 {
  5756. med_type = "11"
  5757. }
  5758. }
  5759. 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)
  5760. } else {
  5761. 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)
  5762. }
  5763. saveLog(result, requestLog, "2203", "上传就诊信息")
  5764. var respJSON2 map[string]interface{}
  5765. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5766. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5768. return
  5769. }
  5770. userJSONBytes2, _ := json.Marshal(respJSON2)
  5771. if miConfig.Code == "H15049901371" {
  5772. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5773. utils.ErrorLog("解析失败:%v", err)
  5774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5775. return
  5776. }
  5777. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5778. res2.Output = resSix10265.Output
  5779. res2.ErrMsg = resSix10265.ErrMsg
  5780. res2.Cainfo = resSix10265.Cainfo
  5781. res2.WarnMsg = resSix10265.WarnMsg
  5782. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5783. res2.Infcode = infocode
  5784. } else {
  5785. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5786. utils.ErrorLog("解析失败:%v", err)
  5787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5788. return
  5789. }
  5790. }
  5791. }
  5792. }
  5793. if res2.Infcode != 0 {
  5794. adminUser := c.GetAdminUserInfo()
  5795. errlog := &models.HisOrderError{
  5796. UserOrgId: adminUser.CurrentOrgId,
  5797. Ctime: time.Now().Unix(),
  5798. Mtime: time.Now().Unix(),
  5799. ErrMsg: res2.ErrMsg,
  5800. Status: 1,
  5801. PatientId: id,
  5802. RecordTime: recordDateTime,
  5803. Stage: 3,
  5804. }
  5805. service.CreateErrMsgLog(errlog)
  5806. c.ServeSuccessJSON(map[string]interface{}{
  5807. "failed_code": -10,
  5808. "msg": res2.ErrMsg,
  5809. })
  5810. return
  5811. } else {
  5812. his.Diagnosis = diagnosis_id
  5813. his.SickType = sickConfig.ID
  5814. his.PType = fmt.Sprintf("%d", reg_type)
  5815. service.UpdateHisPatientThree(&his)
  5816. data := make(map[string]interface{})
  5817. if settle_accounts_type == 1 { //日结
  5818. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5819. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5820. } else {
  5821. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5822. }
  5823. data["pre"] = prescriptions
  5824. } else { //月结
  5825. start_time_str := c.GetString("start_time")
  5826. end_time_str := c.GetString("end_time")
  5827. timeLayout := "2006-01-02"
  5828. loc, _ := time.LoadLocation("Local")
  5829. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5830. if err != nil {
  5831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5832. return
  5833. }
  5834. recordStartTime := theStartTime.Unix()
  5835. start_time = recordStartTime
  5836. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5837. if err != nil {
  5838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5839. return
  5840. }
  5841. recordEndTime := theEndTime.Unix()
  5842. end_time = recordEndTime
  5843. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5844. data["pre"] = prescriptions
  5845. }
  5846. client := &http.Client{}
  5847. data["psn_no"] = his.PsnNo
  5848. data["mdtrt_id"] = his.Number
  5849. data["chrg_bchno"] = chrg_bchno
  5850. data["org_name"] = miConfig.OrgName
  5851. data["doctor"] = roles.UserName
  5852. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5853. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5854. data["fixmedins_code"] = miConfig.Code
  5855. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5856. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5857. data["dept_code"] = "15"
  5858. } else {
  5859. data["dept_code"] = department.Number
  5860. }
  5861. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5862. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5863. data["secret_key"] = miConfig.SecretKey
  5864. data["url"] = miConfig.Url
  5865. data["ak"] = miConfig.AccessKey
  5866. data["new_doctor_name"] = patientPrescription.Doctor
  5867. data["diag_code"] = sickConfig.CountryCode
  5868. data["time_stamp"] = time_stamp
  5869. data["cainfo"] = miConfig.Cainfo
  5870. var ids []int64
  5871. for _, item := range prescriptions {
  5872. ids = append(ids, item.ID)
  5873. }
  5874. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5875. if config.IsOpen == 1 { //对接了医保,走医保流程
  5876. var res ResultFour
  5877. var resFour10265 ResultFour10265
  5878. if miConfig.MdtrtareaAdmvs == "421300" {
  5879. bytesData, _ := json.Marshal(data)
  5880. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5881. resp, _ := client.Do(req)
  5882. defer resp.Body.Close()
  5883. body, ioErr := ioutil.ReadAll(resp.Body)
  5884. if ioErr != nil {
  5885. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5887. return
  5888. }
  5889. var respJSON map[string]interface{}
  5890. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5893. return
  5894. }
  5895. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5896. userJSONBytes, _ := json.Marshal(respJSON)
  5897. fmt.Println("log")
  5898. fmt.Println(string(userJSONBytes))
  5899. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5900. utils.ErrorLog("解析失败:%v", err)
  5901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5902. return
  5903. }
  5904. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5905. bytesData, _ := json.Marshal(data)
  5906. var req *http.Request
  5907. if miConfig.MdtrtareaAdmvs == "320921" {
  5908. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5909. } else {
  5910. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5911. }
  5912. resp, _ := client.Do(req)
  5913. defer resp.Body.Close()
  5914. body, ioErr := ioutil.ReadAll(resp.Body)
  5915. if ioErr != nil {
  5916. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5918. return
  5919. }
  5920. var respJSON map[string]interface{}
  5921. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5922. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5924. return
  5925. }
  5926. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5927. userJSONBytes, _ := json.Marshal(respJSON)
  5928. fmt.Println("log")
  5929. fmt.Println(string(userJSONBytes))
  5930. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5931. utils.ErrorLog("解析失败:%v", err)
  5932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5933. return
  5934. }
  5935. res.InfRefmsgid = resFour10265.InfRefmsgid
  5936. res.Output = resFour10265.Output
  5937. res.ErrMsg = resFour10265.ErrMsg
  5938. res.Cainfo = resFour10265.Cainfo
  5939. res.WarnMsg = resFour10265.WarnMsg
  5940. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5941. res.Infcode = infocode
  5942. } else {
  5943. if miConfig.Code == "H15049901371" {
  5944. 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)
  5945. var dat map[string]interface{}
  5946. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5947. fmt.Println(dat)
  5948. } else {
  5949. fmt.Println(err)
  5950. }
  5951. saveLog(result, request_log, "2204", "上传费用明细")
  5952. userJSONBytes, _ := json.Marshal(dat)
  5953. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5954. utils.ErrorLog("解析失败:%v", err)
  5955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5956. return
  5957. }
  5958. res.InfRefmsgid = resFour10265.InfRefmsgid
  5959. res.Output = resFour10265.Output
  5960. res.ErrMsg = resFour10265.ErrMsg
  5961. res.Cainfo = resFour10265.Cainfo
  5962. res.WarnMsg = resFour10265.WarnMsg
  5963. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5964. res.Infcode = infocode
  5965. } else {
  5966. 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)
  5967. var dat map[string]interface{}
  5968. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5969. fmt.Println(dat)
  5970. } else {
  5971. fmt.Println(err)
  5972. }
  5973. saveLog(result, request_log, "2204", "上传费用明细")
  5974. userJSONBytes, _ := json.Marshal(dat)
  5975. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5976. utils.ErrorLog("解析失败:%v", err)
  5977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5978. return
  5979. }
  5980. }
  5981. }
  5982. if res.Infcode == 0 {
  5983. order := &models.HisOrder{
  5984. UserOrgId: adminUser.CurrentOrgId,
  5985. HisPatientId: his.ID,
  5986. PatientId: his.PatientId,
  5987. SettleAccountsDate: recordDateTime,
  5988. Ctime: time.Now().Unix(),
  5989. Mtime: time.Now().Unix(),
  5990. MdtrtId: his.Number,
  5991. PsnNo: his.PsnNo,
  5992. MedType: strconv.FormatInt(reg_type, 10),
  5993. Status: 1,
  5994. Number: chrg_bchno,
  5995. Infcode: res.Infcode,
  5996. WarnMsg: res.WarnMsg,
  5997. Cainfo: res.Cainfo,
  5998. ErrMsg: res.ErrMsg,
  5999. RespondTime: res.RefmsgTime,
  6000. InfRefmsgid: res.InfRefmsgid,
  6001. OrderStatus: 1,
  6002. IsMedicineInsurance: 1,
  6003. SettleType: settle_accounts_type,
  6004. SettleStartTime: start_time,
  6005. SettleEndTime: end_time,
  6006. Creator: roles.AdminUserId,
  6007. Modify: roles.AdminUserId,
  6008. PType: 2,
  6009. Diagnosis: diagnosis_id,
  6010. }
  6011. err = service.CreateOrder(order)
  6012. if err != nil {
  6013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6014. return
  6015. }
  6016. for _, item := range res.Output.Result {
  6017. temp := strings.Split(item.FeedetlSn, "-")
  6018. var advice_id int64 = 0
  6019. var project_id int64 = 0
  6020. var types int64 = 0
  6021. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6022. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6023. if temp[1] == "1" {
  6024. advice_id = id
  6025. project_id = 0
  6026. } else if temp[1] == "2" {
  6027. advice_id = 0
  6028. project_id = id
  6029. }
  6030. info := &models.HisOrderInfo{
  6031. OrderNumber: order.Number,
  6032. FeedetlSn: item.FeedetlSn,
  6033. UploadDate: time.Now().Unix(),
  6034. AdviceId: advice_id,
  6035. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6036. Cnt: item.Cnt,
  6037. Pric: float64(item.Pric),
  6038. PatientId: his.PatientId,
  6039. PricUplmtAmt: item.PricUplmtAmt,
  6040. SelfpayProp: item.SelfpayProp,
  6041. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6042. OverlmtAmt: item.OverlmtAmt,
  6043. PreselfpayAmt: item.PreselfpayAmt,
  6044. BasMednFlag: item.BasMednFlag,
  6045. MedChrgitmType: item.MedChrgitmType,
  6046. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6047. Status: 1,
  6048. Memo: item.Memo,
  6049. Mtime: time.Now().Unix(),
  6050. InscpScpAmt: item.InscpScpAmt,
  6051. DrtReimFlag: item.DrtReimFlag,
  6052. Ctime: time.Now().Unix(),
  6053. ListSpItemFlag: item.ListSpItemFlag,
  6054. ChldMedcFlag: item.ChldMedcFlag,
  6055. LmtUsedFlag: item.LmtUsedFlag,
  6056. ChrgitmLv: item.ChrgitmLv,
  6057. UserOrgId: adminUser.CurrentOrgId,
  6058. HisPatientId: his.ID,
  6059. OrderId: order.ID,
  6060. ProjectId: project_id,
  6061. Type: types,
  6062. }
  6063. service.CreateOrderInfo(info)
  6064. }
  6065. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6066. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6067. var total float64
  6068. for _, item := range prescriptions {
  6069. if item.Type == 1 { //药品
  6070. for _, subItem := range item.HisDoctorAdviceInfo {
  6071. total = total + (subItem.Price * subItem.PrescribingNumber)
  6072. }
  6073. }
  6074. if item.Type == 2 { //项目
  6075. for _, subItem := range item.HisPrescriptionProject {
  6076. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6077. total = total + (subItem.Price * cnt)
  6078. }
  6079. }
  6080. }
  6081. for _, item := range prescriptions {
  6082. for _, subItem := range item.HisAdditionalCharge {
  6083. total = total + (subItem.Price * float64(subItem.Count))
  6084. }
  6085. }
  6086. allTotal := fmt.Sprintf("%.4f", total)
  6087. if res.Infcode == 0 {
  6088. var rf []*ResultFive
  6089. json.Unmarshal([]byte(his.Iinfo), &rf)
  6090. chrg_bchno := chrg_bchno
  6091. cert_no := his.Certno
  6092. var insutypes []string
  6093. var insutype string
  6094. var is390 int = 0
  6095. var is310 int = 0
  6096. for _, item := range rf {
  6097. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6098. insutypes = append(insutypes, item.Insutype)
  6099. }
  6100. }
  6101. if len(insutypes) == 1 {
  6102. insutype = insutypes[0]
  6103. } else {
  6104. for _, i := range insutypes {
  6105. if i == "390" {
  6106. is390 = 1
  6107. }
  6108. if i == "310" {
  6109. is310 = 1
  6110. }
  6111. }
  6112. }
  6113. if is390 == 1 {
  6114. insutype = "390"
  6115. }
  6116. if is310 == 1 {
  6117. insutype = "310"
  6118. }
  6119. if len(insutypes) == 0 {
  6120. insutype = "310"
  6121. }
  6122. if len(insutypes) == 2 {
  6123. insutype = strconv.FormatInt(his.SocialType, 64)
  6124. }
  6125. //insutype = "390"
  6126. if his.IdCardType == 1 {
  6127. cert_no = his.MedicalInsuranceNumber
  6128. } else {
  6129. cert_no = his.Certno
  6130. }
  6131. var res ResultSeven
  6132. var resSeven10265 ResultSeven10265
  6133. if miConfig.MdtrtareaAdmvs == "421300" {
  6134. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6135. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6136. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6137. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6138. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6139. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6140. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6141. resp, requestErr := http.Get(api)
  6142. if requestErr != nil {
  6143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6144. return
  6145. }
  6146. body, ioErr := ioutil.ReadAll(resp.Body)
  6147. if ioErr != nil {
  6148. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6150. return
  6151. }
  6152. var respJSON map[string]interface{}
  6153. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6154. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6156. return
  6157. }
  6158. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6159. result, _ := json.Marshal(respJSON)
  6160. fmt.Println("log")
  6161. fmt.Println(string(result))
  6162. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6163. utils.ErrorLog("解析失败:%v", err)
  6164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6165. return
  6166. }
  6167. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6168. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6169. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6170. bas := strings.Split(psn_info.CardInfo, "|")
  6171. if his.IdCardType == 1 {
  6172. cert_no = bas[2]
  6173. } else {
  6174. cert_no = bas[1]
  6175. }
  6176. //江苏地区国家医保医疗类别
  6177. //职工透析:医疗类别选特殊情况门诊9933
  6178. //居民血透门慢: 医疗类别选门诊慢病1402
  6179. //var med_type string
  6180. //if his.Insutype == "310" {
  6181. // if reg_type == 14 {
  6182. // med_type = "9933"
  6183. // } else if reg_type == 11 {
  6184. // med_type = "11"
  6185. //
  6186. // }
  6187. //} else if his.Insutype == "390" {
  6188. // if reg_type == 14 {
  6189. // med_type = "1402"
  6190. // } else if reg_type == 11 {
  6191. // med_type = "11"
  6192. // }
  6193. //}
  6194. var api string
  6195. if miConfig.MdtrtareaAdmvs == "320921" {
  6196. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6197. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6198. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6199. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6200. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6201. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6202. "&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
  6203. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6204. } else {
  6205. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6206. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6207. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6208. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6209. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6210. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6211. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6212. "&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
  6213. }
  6214. resp, requestErr := http.Get(api)
  6215. if requestErr != nil {
  6216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6217. return
  6218. }
  6219. body, ioErr := ioutil.ReadAll(resp.Body)
  6220. if ioErr != nil {
  6221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6223. return
  6224. }
  6225. var respJSON map[string]interface{}
  6226. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6229. return
  6230. }
  6231. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6232. result, _ := json.Marshal(respJSON)
  6233. fmt.Println("log")
  6234. fmt.Println(string(result))
  6235. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6236. utils.ErrorLog("解析失败:%v", err)
  6237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6238. return
  6239. }
  6240. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6241. res.Output = resSeven10265.Output
  6242. res.ErrMsg = resSeven10265.ErrMsg
  6243. res.Cainfo = resSeven10265.Cainfo
  6244. res.WarnMsg = resSeven10265.WarnMsg
  6245. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6246. res.Infcode = infocode
  6247. } else {
  6248. var result string
  6249. var request_log string
  6250. if miConfig.Code == "H15049901371" {
  6251. //赤峰地区国家医保医疗类别
  6252. //职工透析:医疗类别选特殊情况门诊990502
  6253. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6254. var med_type string
  6255. if his.Insutype == "390" {
  6256. if reg_type == 14 {
  6257. med_type = "9933"
  6258. } else if reg_type == 11 {
  6259. med_type = "11"
  6260. }
  6261. } else if his.Insutype == "310" {
  6262. if reg_type == 14 {
  6263. med_type = "990502"
  6264. } else if reg_type == 11 {
  6265. med_type = "11"
  6266. }
  6267. }
  6268. 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)
  6269. } else {
  6270. 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)
  6271. }
  6272. var dat map[string]interface{}
  6273. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6274. fmt.Println(dat)
  6275. } else {
  6276. fmt.Println(err)
  6277. }
  6278. saveLog(result, request_log, "2206", "预结算")
  6279. //userJSONBytes, _ := json.Marshal(dat)
  6280. //
  6281. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6282. // utils.ErrorLog("解析失败:%v", err)
  6283. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6284. // return
  6285. //}
  6286. userJSONBytes, _ := json.Marshal(dat)
  6287. if miConfig.Code == "H15049901371" {
  6288. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6289. utils.ErrorLog("解析失败:%v", err)
  6290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6291. return
  6292. }
  6293. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6294. res.Output = resSeven10265.Output
  6295. res.ErrMsg = resSeven10265.ErrMsg
  6296. res.Cainfo = resSeven10265.Cainfo
  6297. res.WarnMsg = resSeven10265.WarnMsg
  6298. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6299. res.Infcode = infocode
  6300. } else {
  6301. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6302. utils.ErrorLog("解析失败:%v", err)
  6303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6304. return
  6305. }
  6306. }
  6307. }
  6308. if res.Infcode != 0 {
  6309. errlog := &models.HisOrderError{
  6310. UserOrgId: adminUser.CurrentOrgId,
  6311. Ctime: time.Now().Unix(),
  6312. Mtime: time.Now().Unix(),
  6313. Number: chrg_bchno,
  6314. ErrMsg: res.ErrMsg,
  6315. Status: 1,
  6316. PatientId: id,
  6317. RecordTime: recordDateTime,
  6318. Stage: 20,
  6319. }
  6320. service.CreateErrMsgLog(errlog)
  6321. c.ServeSuccessJSON(map[string]interface{}{
  6322. "failed_code": -10,
  6323. "msg": res.ErrMsg,
  6324. })
  6325. return
  6326. } else {
  6327. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6328. order.OrderStatus = 1
  6329. order.IsPre = 1
  6330. order.Status = 1
  6331. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6332. order.SetlId = res.Output.Setlinfo.SetlID
  6333. order.PsnNo = res.Output.Setlinfo.PsnNo
  6334. order.PsnName = res.Output.Setlinfo.PsnName
  6335. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6336. order.Certno = res.Output.Setlinfo.Certno
  6337. order.Gend = res.Output.Setlinfo.Gend
  6338. order.Naty = res.Output.Setlinfo.Naty
  6339. order.Age = res.Output.Setlinfo.Age
  6340. order.Insutype = res.Output.Setlinfo.Insutype
  6341. order.PsnType = res.Output.Setlinfo.PsnType
  6342. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6343. order.SetlTime = res.Output.Setlinfo.SetlTime
  6344. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6345. if res.Output.Setlinfo.MedType == "140101" {
  6346. order.MedType = "14"
  6347. } else {
  6348. order.MedType = res.Output.Setlinfo.MedType
  6349. }
  6350. if reg_type == 1112 {
  6351. order.MedType = "1112"
  6352. }
  6353. if reg_type == 1111 {
  6354. order.MedType = "1111"
  6355. }
  6356. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6357. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6358. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6359. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6360. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6361. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6362. order.HifpPay = res.Output.Setlinfo.HifpPay
  6363. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6364. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6365. order.HifesPay = res.Output.Setlinfo.HifesPay
  6366. order.HifobPay = res.Output.Setlinfo.HifobPay
  6367. order.MafPay = res.Output.Setlinfo.MafPay
  6368. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6369. order.OthPay = res.Output.Setlinfo.OthPay
  6370. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6371. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6372. order.AcctPay = res.Output.Setlinfo.AcctPay
  6373. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6374. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6375. order.Balc = res.Output.Setlinfo.Balc
  6376. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6377. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6378. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6379. order.ClrWay = res.Output.Setlinfo.ClrWay
  6380. order.Creator = order.Creator
  6381. order.Modify = roles.AdminUserId
  6382. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6383. detailStr := string(setlDetail)
  6384. order.SetlDetail = detailStr
  6385. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6386. err = service.UpDateOrder(order)
  6387. if err == nil {
  6388. c.ServeSuccessJSON(map[string]interface{}{
  6389. "msg": "预结算成功",
  6390. })
  6391. } else {
  6392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6393. return
  6394. }
  6395. }
  6396. } else {
  6397. adminUser := c.GetAdminUserInfo()
  6398. errlog := &models.HisOrderError{
  6399. UserOrgId: adminUser.CurrentOrgId,
  6400. Ctime: time.Now().Unix(),
  6401. Mtime: time.Now().Unix(),
  6402. ErrMsg: res.ErrMsg,
  6403. Status: 1,
  6404. PatientId: id,
  6405. RecordTime: recordDateTime,
  6406. Stage: 4,
  6407. }
  6408. service.CreateErrMsgLog(errlog)
  6409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6410. return
  6411. }
  6412. } else {
  6413. adminUser := c.GetAdminUserInfo()
  6414. errlog := &models.HisOrderError{
  6415. UserOrgId: adminUser.CurrentOrgId,
  6416. Ctime: time.Now().Unix(),
  6417. Mtime: time.Now().Unix(),
  6418. ErrMsg: res.ErrMsg,
  6419. Status: 1,
  6420. PatientId: id,
  6421. RecordTime: recordDateTime,
  6422. Stage: 4,
  6423. }
  6424. service.CreateErrMsgLog(errlog)
  6425. c.ServeSuccessJSON(map[string]interface{}{
  6426. "failed_code": -10,
  6427. "msg": res.ErrMsg,
  6428. })
  6429. return
  6430. }
  6431. }
  6432. }
  6433. }
  6434. //func (c *HisApiController) GetSettleInfo() {
  6435. // id, _ := c.GetInt64("id")
  6436. // order_id, _ := c.GetInt64("order_id")
  6437. //
  6438. // record_time := c.GetString("record_time")
  6439. // pay_way, _ := c.GetInt64("pay_way")
  6440. // pay_price, _ := c.GetFloat("pay_price")
  6441. // pay_card_no := c.GetString("pay_card_no")
  6442. // discount_price, _ := c.GetFloat("discount_price")
  6443. // preferential_price, _ := c.GetFloat("preferential_price")
  6444. // reality_price, _ := c.GetFloat("reality_price")
  6445. // found_price, _ := c.GetFloat("found_price")
  6446. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6447. // private_price, _ := c.GetFloat("private_price")
  6448. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6449. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6450. //
  6451. // timeLayout := "2006-01-02"
  6452. // loc, _ := time.LoadLocation("Local")
  6453. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6454. // if err != nil {
  6455. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6456. // return
  6457. // }
  6458. // recordDateTime := theTime.Unix()
  6459. // adminUser := c.GetAdminUserInfo()
  6460. //
  6461. // var prescriptions []*models.HisPrescription
  6462. //
  6463. // data := make(map[string]interface{})
  6464. // if settle_accounts_type == 1 { //日结
  6465. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6466. // data["pre"] = prescriptions
  6467. //
  6468. // } else { //月结
  6469. // start_time_str := c.GetString("start_time")
  6470. // end_time_str := c.GetString("end_time")
  6471. // timeLayout := "2006-01-02"
  6472. // loc, _ := time.LoadLocation("Local")
  6473. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6474. // if err != nil {
  6475. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6476. // return
  6477. // }
  6478. // recordStartTime := theStartTime.Unix()
  6479. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6480. // if err != nil {
  6481. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6482. // return
  6483. // }
  6484. // recordEndTime := theEndTime.Unix()
  6485. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6486. // data["pre"] = prescriptions
  6487. //
  6488. // }
  6489. //
  6490. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6491. //
  6492. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6493. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6494. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6495. // strconv.FormatInt(his.PatientId, 10)
  6496. //
  6497. // order_src, _ := service.GetHisOrderByID(order_id)
  6498. //
  6499. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6500. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6501. //
  6502. // var total float64
  6503. // for _, item := range prescriptions {
  6504. // if item.Type == 1 { //药品
  6505. // for _, subItem := range item.HisDoctorAdviceInfo {
  6506. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6507. // }
  6508. // }
  6509. // if item.Type == 2 { //项目
  6510. // for _, subItem := range item.HisPrescriptionProject {
  6511. // total = total + (subItem.Price * float64(subItem.Count))
  6512. // }
  6513. // }
  6514. // }
  6515. //
  6516. // for _, item := range prescriptions {
  6517. // for _, subItem := range item.HisAdditionalCharge {
  6518. // total = total + (subItem.Price * float64(subItem.Count))
  6519. // }
  6520. // }
  6521. //
  6522. // allTotal := fmt.Sprintf("%.2f", total)
  6523. // var rf []*ResultFive
  6524. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6525. // psn_no := order_src.PsnNo
  6526. // mdtrt_id := order_src.MdtrtId
  6527. // chrg_bchno := order_src.Number
  6528. // cert_no := order_src.Certno
  6529. // insutype := rf[0].Insutype
  6530. //
  6531. // if his.IdCardType == 1 {
  6532. // cert_no = his.MedicalInsuranceNumber
  6533. // } else {
  6534. // cert_no = his.Certno
  6535. // }
  6536. //
  6537. // 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)
  6538. // var dat map[string]interface{}
  6539. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6540. // fmt.Println(dat)
  6541. // } else {
  6542. // fmt.Println(err)
  6543. // }
  6544. //
  6545. // userJSONBytes, _ := json.Marshal(dat)
  6546. //
  6547. //
  6548. //
  6549. // var res ResultSeven
  6550. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6551. // utils.ErrorLog("解析失败:%v", err)
  6552. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6553. // return
  6554. // }
  6555. // if res.Infcode == -1 {
  6556. // errlog := &models.HisOrderError{
  6557. // UserOrgId: adminUser.CurrentOrgId,
  6558. // Ctime: time.Now().Unix(),
  6559. // Mtime: time.Now().Unix(),
  6560. // Number: chrg_bchno,
  6561. // ErrMsg: res.ErrMsg,
  6562. // Status: 1,
  6563. // PatientId: id,
  6564. // RecordTime: recordDateTime,
  6565. // Stage: 6,
  6566. // }
  6567. // service.CreateErrMsgLog(errlog)
  6568. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6569. // return
  6570. // } else {
  6571. // order_src.OrderStatus = 2
  6572. // order_src.PayWay = pay_way
  6573. // order_src.PayPrice = pay_price
  6574. // order_src.PayCardNo = pay_card_no
  6575. // order_src.DiscountPrice = discount_price
  6576. // order_src.PreferentialPrice = preferential_price
  6577. // order_src.RealityPrice = reality_price
  6578. // order_src.FoundPrice = found_price
  6579. // order_src.MedicalInsurancePrice = medical_insurance_price
  6580. // order_src.PrivatePrice = private_price
  6581. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  6582. // order_src.SetlId = res.Output.Setlinfo.SetlID
  6583. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  6584. // order_src.PsnName = res.Output.Setlinfo.PsnName
  6585. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  6586. // order_src.Certno = res.Output.Setlinfo.Certno
  6587. // order_src.Gend = res.Output.Setlinfo.Gend
  6588. // order_src.Naty = res.Output.Setlinfo.Naty
  6589. // order_src.Age = res.Output.Setlinfo.Age
  6590. // order_src.Insutype = res.Output.Setlinfo.Insutype
  6591. // order_src.PsnType = res.Output.Setlinfo.PsnType
  6592. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6593. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  6594. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6595. // order_src.MedType = res.Output.Setlinfo.MedType
  6596. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6597. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6598. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6599. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6600. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6601. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6602. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  6603. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  6604. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6605. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  6606. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  6607. // order_src.MafPay = res.Output.Setlinfo.MafPay
  6608. // order_src.OthPay = res.Output.Setlinfo.OthPay
  6609. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6610. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6611. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  6612. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6613. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6614. // order_src.Balc = res.Output.Setlinfo.Balc
  6615. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6616. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6617. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  6618. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  6619. // order_src.Creator = order_src.Creator
  6620. // order_src.Modify = roles.ID
  6621. // order_src.RequestLog = src_resquest
  6622. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6623. // detailStr := string(setlDetail)
  6624. // order_src.SetlDetail = detailStr
  6625. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6626. // err = service.UpDateOrder(order_src)
  6627. //
  6628. // if err == nil {
  6629. // c.ServeSuccessJSON(map[string]interface{}{
  6630. // "msg": "结算成功",
  6631. // })
  6632. // } else {
  6633. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6634. // return
  6635. // }
  6636. // }
  6637. // }
  6638. //}
  6639. //退款
  6640. func (c *HisApiController) Refund() {
  6641. order_id, _ := c.GetInt64("order_id")
  6642. admin_user_id, _ := c.GetInt64("admin_user_id")
  6643. adminUser := c.GetAdminUserInfo()
  6644. var order models.HisOrder
  6645. order, _ = service.GetHisOrderByID(order_id)
  6646. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6647. if order.ID == 0 {
  6648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6649. return
  6650. }
  6651. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6652. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6653. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6654. if config.IsOpen == 1 { //对接了医保,走医保流程
  6655. var res ResultSixteen
  6656. var resSixteen10265 ResultSixteen10265
  6657. var src_resquest string
  6658. var result string
  6659. if miConfig.MdtrtareaAdmvs == "421300" {
  6660. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  6661. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6662. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6663. resp3, requestErr3 := http.Get(api3)
  6664. if requestErr3 != nil {
  6665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6666. return
  6667. }
  6668. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6669. if ioErr3 != nil {
  6670. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6672. return
  6673. }
  6674. var respJSON3 map[string]interface{}
  6675. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6676. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6678. return
  6679. }
  6680. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6681. userJSONBytes3, _ := json.Marshal(respJSON3)
  6682. fmt.Println("log")
  6683. fmt.Println(string(userJSONBytes3))
  6684. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  6685. utils.ErrorLog("解析失败:%v", err)
  6686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6687. return
  6688. }
  6689. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6690. var api3 string
  6691. if miConfig.MdtrtareaAdmvs == "320921" {
  6692. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6693. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6694. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6695. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6696. } else {
  6697. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6698. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6699. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6700. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6701. }
  6702. resp3, requestErr3 := http.Get(api3)
  6703. if requestErr3 != nil {
  6704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6705. return
  6706. }
  6707. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6708. if ioErr3 != nil {
  6709. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6711. return
  6712. }
  6713. var respJSON3 map[string]interface{}
  6714. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6715. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6717. return
  6718. }
  6719. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6720. userJSONBytes3, _ := json.Marshal(respJSON3)
  6721. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  6722. utils.ErrorLog("解析失败:%v", err)
  6723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6724. return
  6725. }
  6726. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6727. res.Output = resSixteen10265.Output
  6728. res.ErrMsg = resSixteen10265.ErrMsg
  6729. res.Cainfo = resSixteen10265.Cainfo
  6730. res.WarnMsg = resSixteen10265.WarnMsg
  6731. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6732. res.Infcode = infocode
  6733. } else {
  6734. if miConfig.Code == "H15049901371" {
  6735. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6736. var dat map[string]interface{}
  6737. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6738. fmt.Println(dat)
  6739. } else {
  6740. fmt.Println(err)
  6741. }
  6742. saveLog(result, src_resquest, "2208", "退费")
  6743. userJSONBytes, _ := json.Marshal(dat)
  6744. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  6745. utils.ErrorLog("解析失败:%v", err)
  6746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6747. return
  6748. }
  6749. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6750. res.Output = resSixteen10265.Output
  6751. res.ErrMsg = resSixteen10265.ErrMsg
  6752. res.Cainfo = resSixteen10265.Cainfo
  6753. res.WarnMsg = resSixteen10265.WarnMsg
  6754. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6755. res.Infcode = infocode
  6756. } else {
  6757. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6758. var dat map[string]interface{}
  6759. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6760. fmt.Println(dat)
  6761. } else {
  6762. fmt.Println(err)
  6763. }
  6764. saveLog(result, src_resquest, "2208", "退费")
  6765. userJSONBytes, _ := json.Marshal(dat)
  6766. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6767. utils.ErrorLog("解析失败:%v", err)
  6768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6769. return
  6770. }
  6771. }
  6772. }
  6773. if res.Infcode == 0 {
  6774. var res2 ResultSix
  6775. var resSix10265 ResultSix10265
  6776. if miConfig.MdtrtareaAdmvs == "421300" {
  6777. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6778. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6779. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6780. resp3, requestErr3 := http.Get(api3)
  6781. if requestErr3 != nil {
  6782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6783. return
  6784. }
  6785. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6786. if ioErr3 != nil {
  6787. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6789. return
  6790. }
  6791. var respJSON3 map[string]interface{}
  6792. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6793. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6795. return
  6796. }
  6797. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6798. userJSONBytes3, _ := json.Marshal(respJSON3)
  6799. fmt.Println("log")
  6800. fmt.Println(string(userJSONBytes3))
  6801. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6802. utils.ErrorLog("解析失败:%v", err)
  6803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6804. return
  6805. }
  6806. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6807. var api3 string
  6808. if miConfig.MdtrtareaAdmvs == "320921" {
  6809. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6810. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6811. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6812. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6813. } else {
  6814. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6815. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6816. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6817. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6818. }
  6819. resp3, requestErr3 := http.Get(api3)
  6820. if requestErr3 != nil {
  6821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6822. return
  6823. }
  6824. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6825. if ioErr3 != nil {
  6826. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6828. return
  6829. }
  6830. var respJSON3 map[string]interface{}
  6831. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6834. return
  6835. }
  6836. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6837. userJSONBytes3, _ := json.Marshal(respJSON3)
  6838. fmt.Println("log")
  6839. fmt.Println(string(userJSONBytes3))
  6840. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6841. utils.ErrorLog("解析失败:%v", err)
  6842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6843. return
  6844. }
  6845. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6846. res2.Output = resSix10265.Output
  6847. res2.ErrMsg = resSix10265.ErrMsg
  6848. res2.Cainfo = resSix10265.Cainfo
  6849. res2.WarnMsg = resSix10265.WarnMsg
  6850. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6851. res2.Infcode = infocode
  6852. } else {
  6853. if miConfig.Code == "H15049901371" {
  6854. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6855. var dat map[string]interface{}
  6856. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6857. fmt.Println(dat)
  6858. } else {
  6859. fmt.Println(err)
  6860. }
  6861. saveLog(result2, src_request, "2205", "撤销明细")
  6862. userJSONBytes, _ := json.Marshal(dat)
  6863. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6864. utils.ErrorLog("解析失败:%v", err)
  6865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6866. return
  6867. }
  6868. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6869. res2.Output = resSix10265.Output
  6870. res2.ErrMsg = resSix10265.ErrMsg
  6871. res2.Cainfo = resSix10265.Cainfo
  6872. res2.WarnMsg = resSix10265.WarnMsg
  6873. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6874. res2.Infcode = infocode
  6875. } else {
  6876. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6877. var dat map[string]interface{}
  6878. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6879. fmt.Println(dat)
  6880. } else {
  6881. fmt.Println(err)
  6882. }
  6883. saveLog(result2, src_request, "2205", "撤销明细")
  6884. userJSONBytes, _ := json.Marshal(dat)
  6885. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6886. utils.ErrorLog("解析失败:%v", err)
  6887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6888. return
  6889. }
  6890. }
  6891. }
  6892. if res2.Infcode == 0 {
  6893. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  6894. if err == nil {
  6895. c.ServeSuccessJSON(map[string]interface{}{
  6896. "msg": "退费成功",
  6897. })
  6898. } else {
  6899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6900. return
  6901. }
  6902. } else {
  6903. c.ServeSuccessJSON(map[string]interface{}{
  6904. "code": -10,
  6905. "msg": res2.ErrMsg,
  6906. })
  6907. }
  6908. } else {
  6909. c.ServeSuccessJSON(map[string]interface{}{
  6910. "code": -10,
  6911. "msg": res.ErrMsg,
  6912. })
  6913. }
  6914. }
  6915. }
  6916. func (c *HisApiController) RefundNumber() {
  6917. record_time := c.GetString("record_time")
  6918. //patient_id, _ := c.GetInt64("patient_id")
  6919. admin_user_id, _ := c.GetInt64("admin_user_id")
  6920. his_patient_id, _ := c.GetInt64("id")
  6921. timeLayout := "2006-01-02"
  6922. loc, _ := time.LoadLocation("Local")
  6923. adminUser := c.GetAdminUserInfo()
  6924. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6925. fmt.Println(err)
  6926. if err != nil {
  6927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6928. return
  6929. }
  6930. recordDateTime := theTime.Unix()
  6931. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6932. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  6933. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6934. //order, _ := service.GetHisOrderByID(order_id)
  6935. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6936. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6937. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6938. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  6939. if count > 0 {
  6940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  6941. return
  6942. }
  6943. if config.IsOpen == 1 { //对接了医保,走医保流程
  6944. var res2 ResultSix
  6945. var resSix10265 ResultSix10265
  6946. if miConfig.MdtrtareaAdmvs == "421300" {
  6947. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  6948. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6949. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6950. resp3, requestErr3 := http.Get(api3)
  6951. if requestErr3 != nil {
  6952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6953. return
  6954. }
  6955. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6956. if ioErr3 != nil {
  6957. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6959. return
  6960. }
  6961. var respJSON3 map[string]interface{}
  6962. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6963. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6965. return
  6966. }
  6967. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6968. userJSONBytes3, _ := json.Marshal(respJSON3)
  6969. fmt.Println("log")
  6970. fmt.Println(string(userJSONBytes3))
  6971. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6972. utils.ErrorLog("解析失败:%v", err)
  6973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6974. return
  6975. }
  6976. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6977. var api3 string
  6978. if miConfig.MdtrtareaAdmvs == "320921" {
  6979. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6980. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6981. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6982. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6983. } else {
  6984. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6985. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6986. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6987. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6988. }
  6989. resp3, requestErr3 := http.Get(api3)
  6990. if requestErr3 != nil {
  6991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6992. return
  6993. }
  6994. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6995. if ioErr3 != nil {
  6996. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6998. return
  6999. }
  7000. var respJSON3 map[string]interface{}
  7001. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7002. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7004. return
  7005. }
  7006. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7007. userJSONBytes3, _ := json.Marshal(respJSON3)
  7008. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7009. utils.ErrorLog("解析失败:%v", err)
  7010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7011. return
  7012. }
  7013. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7014. res2.Output = resSix10265.Output
  7015. res2.ErrMsg = resSix10265.ErrMsg
  7016. res2.Cainfo = resSix10265.Cainfo
  7017. res2.WarnMsg = resSix10265.WarnMsg
  7018. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7019. res2.Infcode = infocode
  7020. } else {
  7021. var api3 string
  7022. if miConfig.Code == "H15049901371" {
  7023. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7024. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7025. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7026. } else {
  7027. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7028. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7029. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7030. }
  7031. resp3, requestErr3 := http.Get(api3)
  7032. if requestErr3 != nil {
  7033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7034. return
  7035. }
  7036. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7037. if ioErr3 != nil {
  7038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7040. return
  7041. }
  7042. var respJSON3 map[string]interface{}
  7043. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7046. return
  7047. }
  7048. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7049. userJSONBytes3, _ := json.Marshal(respJSON3)
  7050. if miConfig.Code == "H15049901371" {
  7051. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7052. utils.ErrorLog("解析失败:%v", err)
  7053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7054. return
  7055. }
  7056. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7057. res2.Output = resSix10265.Output
  7058. res2.ErrMsg = resSix10265.ErrMsg
  7059. res2.Cainfo = resSix10265.Cainfo
  7060. res2.WarnMsg = resSix10265.WarnMsg
  7061. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7062. res2.Infcode = infocode
  7063. } else {
  7064. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7065. utils.ErrorLog("解析失败:%v", err)
  7066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7067. return
  7068. }
  7069. }
  7070. }
  7071. if res2.Infcode == 0 {
  7072. if err == nil {
  7073. c.ServeSuccessJSON(map[string]interface{}{
  7074. "msg": "退号成功",
  7075. })
  7076. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7077. } else {
  7078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7079. return
  7080. }
  7081. } else {
  7082. c.ServeSuccessJSON(map[string]interface{}{
  7083. "code": -10,
  7084. "msg": res2.ErrMsg,
  7085. })
  7086. }
  7087. } else {
  7088. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7089. //if err == nil {
  7090. // c.ServeSuccessJSON(map[string]interface{}{
  7091. // "msg": "退费成功",
  7092. // })
  7093. //} else {
  7094. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7095. // return
  7096. //}
  7097. }
  7098. }
  7099. func (c *HisApiController) RefundDetail() {
  7100. order_id, _ := c.GetInt64("order_id")
  7101. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7102. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7103. number := c.GetString("number")
  7104. record_time := c.GetString("record_time")
  7105. patient_id, _ := c.GetInt64("patient_id")
  7106. timeLayout := "2006-01-02"
  7107. loc, _ := time.LoadLocation("Local")
  7108. adminUser := c.GetAdminUserInfo()
  7109. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7110. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7111. fmt.Println(err)
  7112. if err != nil {
  7113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7114. return
  7115. }
  7116. recordDateTime := theTime.Unix()
  7117. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7118. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7119. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7120. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7121. var order models.HisOrder
  7122. order, _ = service.GetHisOrderByID(order_id)
  7123. if order.ID == 0 {
  7124. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  7125. }
  7126. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7127. if config.IsOpen == 1 { //对接了医保,走医保流程
  7128. var res2 ResultSix
  7129. if miConfig.MdtrtareaAdmvs == "421300" {
  7130. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7131. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7132. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7133. resp3, requestErr3 := http.Get(api3)
  7134. if requestErr3 != nil {
  7135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7136. return
  7137. }
  7138. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7139. if ioErr3 != nil {
  7140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7142. return
  7143. }
  7144. var respJSON3 map[string]interface{}
  7145. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7148. return
  7149. }
  7150. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7151. userJSONBytes3, _ := json.Marshal(respJSON3)
  7152. fmt.Println("log")
  7153. fmt.Println(string(userJSONBytes3))
  7154. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7155. utils.ErrorLog("解析失败:%v", err)
  7156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7157. return
  7158. }
  7159. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7160. if err == nil {
  7161. c.ServeSuccessJSON(map[string]interface{}{
  7162. "msg": "撤销明细成功",
  7163. })
  7164. return
  7165. } else {
  7166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7167. return
  7168. }
  7169. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7170. var resSix10265 ResultSix10265
  7171. var api3 string
  7172. if miConfig.MdtrtareaAdmvs == "320921" {
  7173. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7174. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7175. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7176. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7177. } else {
  7178. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7179. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7180. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7181. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7182. }
  7183. resp3, requestErr3 := http.Get(api3)
  7184. if requestErr3 != nil {
  7185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7186. return
  7187. }
  7188. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7189. if ioErr3 != nil {
  7190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7192. return
  7193. }
  7194. var respJSON3 map[string]interface{}
  7195. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7198. return
  7199. }
  7200. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7201. userJSONBytes3, _ := json.Marshal(respJSON3)
  7202. fmt.Println("log")
  7203. fmt.Println(string(userJSONBytes3))
  7204. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7205. utils.ErrorLog("解析失败:%v", err)
  7206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7207. return
  7208. }
  7209. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7210. res2.Output = resSix10265.Output
  7211. res2.ErrMsg = resSix10265.ErrMsg
  7212. res2.Cainfo = resSix10265.Cainfo
  7213. res2.WarnMsg = resSix10265.WarnMsg
  7214. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7215. res2.Infcode = infocode
  7216. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7217. if err == nil {
  7218. c.ServeSuccessJSON(map[string]interface{}{
  7219. "msg": "撤销明细成功",
  7220. })
  7221. return
  7222. } else {
  7223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7224. return
  7225. }
  7226. } else {
  7227. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  7228. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7229. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7230. resp2, requestErr2 := http.Get(api2)
  7231. if requestErr2 != nil {
  7232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7233. return
  7234. }
  7235. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7236. if ioErr2 != nil {
  7237. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7239. return
  7240. }
  7241. var respJSON2 map[string]interface{}
  7242. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7243. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7245. return
  7246. }
  7247. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7248. if err == nil {
  7249. c.ServeSuccessJSON(map[string]interface{}{
  7250. "msg": "撤销明细成功",
  7251. })
  7252. return
  7253. } else {
  7254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7255. return
  7256. }
  7257. }
  7258. } else {
  7259. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7260. if err == nil {
  7261. c.ServeSuccessJSON(map[string]interface{}{
  7262. "msg": "退费成功",
  7263. })
  7264. } else {
  7265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7266. return
  7267. }
  7268. }
  7269. }
  7270. //对账
  7271. func (c *HisApiController) GetCheckAccount() {
  7272. start_time := c.GetString("start_time")
  7273. end_time := c.GetString("end_time")
  7274. insutype := c.GetString("insutype")
  7275. clr_type := c.GetString("clr_type")
  7276. clr_org := c.GetString("clr_optins")
  7277. admin_user_id, _ := c.GetInt64("admin_user_id")
  7278. adminUser := c.GetAdminUserInfo()
  7279. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7280. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7281. if len(clr_org) == 0 {
  7282. clr_org = miConfig.MdtrtareaAdmvs
  7283. }
  7284. timeLayout := "2006-01-02"
  7285. loc, _ := time.LoadLocation("Local")
  7286. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7287. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7288. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  7289. fixmedins_setl_cnt := int64(len(orders))
  7290. var medfee_sumamt float64
  7291. var acct_pay float64
  7292. var fund_pay_sumamt float64
  7293. for _, item := range orders {
  7294. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7295. acct_pay = acct_pay + item.AcctPay
  7296. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7297. }
  7298. var user_name string
  7299. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7300. if role.ID == 0 {
  7301. user_name = "xxx"
  7302. } else {
  7303. user_name = role.UserName
  7304. }
  7305. var res ResultEight
  7306. var res10188 ResultEightFor10188
  7307. if config.IsOpen == 1 {
  7308. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7309. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  7310. "insutype=" + insutype +
  7311. "&clr_type=" + "11" +
  7312. "&setl_optins=" + clr_org +
  7313. "&stmt_begndate=" + start_time +
  7314. "&stm_enddate=" + end_time +
  7315. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7316. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7317. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7318. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7319. "&fixmedins_code=" + miConfig.Code +
  7320. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7321. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7322. "&secret_key=" + miConfig.SecretKey +
  7323. "&org_name=" + miConfig.OrgName +
  7324. "&doctor=" + user_name +
  7325. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7326. fmt.Println(api)
  7327. resp, requestErr := http.Get(api)
  7328. if requestErr != nil {
  7329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7330. return
  7331. }
  7332. body, ioErr := ioutil.ReadAll(resp.Body)
  7333. fmt.Println(body)
  7334. if ioErr != nil {
  7335. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7337. return
  7338. }
  7339. var respJSON map[string]interface{}
  7340. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7343. return
  7344. }
  7345. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7346. userJSONBytes, _ := json.Marshal(respJSON)
  7347. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7348. utils.ErrorLog("解析失败:%v", err)
  7349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7350. return
  7351. }
  7352. res.InfRefmsgid = res10188.InfRefmsgid
  7353. res.Output = res10188.Output
  7354. res.ErrMsg = res10188.ErrMsg
  7355. res.Cainfo = res10188.Cainfo
  7356. res.WarnMsg = res10188.WarnMsg
  7357. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  7358. res.Infcode = infocode
  7359. } else {
  7360. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7361. "insutype=" + insutype +
  7362. "&clr_type=" + clr_type +
  7363. "&setl_optins=" + clr_org +
  7364. "&stmt_begndate=" + start_time +
  7365. "&stm_enddate=" + end_time +
  7366. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7367. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7368. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7369. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7370. "&fixmedins_code=" + miConfig.Code +
  7371. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7372. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7373. "&secret_key=" + miConfig.SecretKey +
  7374. "&org_name=" + miConfig.OrgName +
  7375. "&doctor=" + user_name
  7376. fmt.Println(api)
  7377. resp, requestErr := http.Get(api)
  7378. if requestErr != nil {
  7379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7380. return
  7381. }
  7382. body, ioErr := ioutil.ReadAll(resp.Body)
  7383. fmt.Println(body)
  7384. if ioErr != nil {
  7385. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7387. return
  7388. }
  7389. var respJSON map[string]interface{}
  7390. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7393. return
  7394. }
  7395. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7396. userJSONBytes, _ := json.Marshal(respJSON)
  7397. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7398. utils.ErrorLog("解析失败:%v", err)
  7399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7400. return
  7401. }
  7402. }
  7403. if res.Infcode == 0 {
  7404. if res.Output.Stmtinfo.StmtRslt == "0" {
  7405. micc := &models.MedicalInsuranceCostCompare{
  7406. StartTime: startime.Unix(),
  7407. EndTime: endtime.Unix(),
  7408. Insutype: insutype,
  7409. CheckType: 1,
  7410. Num: fixmedins_setl_cnt,
  7411. Mtime: time.Now().Unix(),
  7412. Status: 1,
  7413. UserOrgId: adminUser.CurrentOrgId,
  7414. CostTotal: medfee_sumamt,
  7415. FuncTotal: fund_pay_sumamt,
  7416. PsnPay: acct_pay,
  7417. Creator: admin_user_id,
  7418. Ctime: time.Now().Unix(),
  7419. ClrType: clr_type,
  7420. }
  7421. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  7422. if err == nil {
  7423. c.ServeSuccessJSON(map[string]interface{}{
  7424. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7425. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7426. })
  7427. } else {
  7428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7429. }
  7430. } else {
  7431. c.ServeSuccessJSON(map[string]interface{}{
  7432. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7433. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7434. })
  7435. }
  7436. } else {
  7437. c.ServeSuccessJSON(map[string]interface{}{
  7438. "code": -10,
  7439. "msg": res.ErrMsg,
  7440. })
  7441. }
  7442. }
  7443. }
  7444. func (c *HisApiController) Check310() {
  7445. adminUser := c.GetAdminUserInfo()
  7446. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7447. var user_name string
  7448. user_name = "高慧裕"
  7449. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7450. "insutype=" + "310" +
  7451. "&clr_type=" + "" +
  7452. "&setl_optins=" + "441202" +
  7453. "&stmt_begndate=" + "2022-03-01" +
  7454. "&stm_enddate=" + "2022-03-31" +
  7455. "&medfee_sumamt=" + "194930.12" +
  7456. "&fund_pay_sumamt=" + "188741.46" +
  7457. "&acct_pay=" + "0" +
  7458. "&fixmedins_setl_cnt=" + "452" +
  7459. "&fixmedins_code=" + miConfig.Code +
  7460. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7461. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7462. "&secret_key=" + miConfig.SecretKey +
  7463. "&org_name=" + miConfig.OrgName +
  7464. "&doctor=" + user_name
  7465. fmt.Println(api)
  7466. resp, requestErr := http.Get(api)
  7467. if requestErr != nil {
  7468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7469. return
  7470. }
  7471. body, ioErr := ioutil.ReadAll(resp.Body)
  7472. fmt.Println(body)
  7473. if ioErr != nil {
  7474. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7476. return
  7477. }
  7478. var respJSON map[string]interface{}
  7479. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7480. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7482. return
  7483. }
  7484. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7485. userJSONBytes, _ := json.Marshal(respJSON)
  7486. var res ResultEight
  7487. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7488. utils.ErrorLog("解析失败:%v", err)
  7489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7490. return
  7491. }
  7492. }
  7493. func (c *HisApiController) Check390() {
  7494. adminUser := c.GetAdminUserInfo()
  7495. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7496. var user_name string
  7497. user_name = "高慧裕"
  7498. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7499. "insutype=" + "390" +
  7500. "&clr_type=" + "" +
  7501. "&setl_optins=" + "441202" +
  7502. "&stmt_begndate=" + "2022-03-01" +
  7503. "&stm_enddate=" + "2022-03-31" +
  7504. "&medfee_sumamt=" + "1068448.89" +
  7505. "&fund_pay_sumamt=" + "1014677.62" +
  7506. "&acct_pay=" + "0" +
  7507. "&fixmedins_setl_cnt=" + "1950" +
  7508. "&fixmedins_code=" + miConfig.Code +
  7509. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7510. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7511. "&secret_key=" + miConfig.SecretKey +
  7512. "&org_name=" + miConfig.OrgName +
  7513. "&doctor=" + user_name
  7514. fmt.Println(api)
  7515. resp, requestErr := http.Get(api)
  7516. if requestErr != nil {
  7517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7518. return
  7519. }
  7520. body, ioErr := ioutil.ReadAll(resp.Body)
  7521. fmt.Println(body)
  7522. if ioErr != nil {
  7523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7525. return
  7526. }
  7527. var respJSON map[string]interface{}
  7528. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7531. return
  7532. }
  7533. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7534. userJSONBytes, _ := json.Marshal(respJSON)
  7535. var res ResultEight
  7536. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7537. utils.ErrorLog("解析失败:%v", err)
  7538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7539. return
  7540. }
  7541. }
  7542. //对账明细
  7543. func (c *HisApiController) GetCheckDetailAccount() {
  7544. start_time := c.GetString("start_time")
  7545. end_time := c.GetString("end_time")
  7546. admin_user_id, _ := c.GetInt64("admin_user_id")
  7547. adminUser := c.GetAdminUserInfo()
  7548. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7549. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7550. timeLayout := "2006-01-02"
  7551. loc, _ := time.LoadLocation("Local")
  7552. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7553. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7554. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  7555. Mkdir(miConfig.OrgName)
  7556. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  7557. file_name := file + ".txt"
  7558. zip_name := file + ".zip"
  7559. zip_path := miConfig.OrgName + "/" + zip_name
  7560. file_path := miConfig.OrgName + "/" + file_name
  7561. decimal.DivisionPrecision = 2
  7562. var medfee_sumamt float64
  7563. var psn_cash_pay float64
  7564. var fund_pay_sumamt float64
  7565. fixmedins_setl_cnt := int64(len(orders))
  7566. for _, item := range orders {
  7567. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7568. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  7569. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7570. }
  7571. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  7572. defer f.Close()
  7573. if err != nil {
  7574. fmt.Println(err.Error())
  7575. } else {
  7576. for _, item := range orders {
  7577. var refd_setl_flag string
  7578. if item.OrderStatus == 2 {
  7579. refd_setl_flag = "0"
  7580. var str string
  7581. str = item.SetlId + " " +
  7582. item.MdtrtId + " " +
  7583. item.PsnNo + " " +
  7584. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7585. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7586. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  7587. _, err = f.Write([]byte(str))
  7588. }
  7589. if item.OrderStatus == 3 {
  7590. var str string
  7591. str = item.SetlId + " " +
  7592. item.MdtrtId + " " +
  7593. item.PsnNo + " " +
  7594. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7595. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7596. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  7597. _, err = f.Write([]byte(str))
  7598. var str2 string
  7599. str2 = item.SetlId + " " +
  7600. item.MdtrtId + " " +
  7601. item.PsnNo + " " +
  7602. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  7603. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  7604. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  7605. _, err = f.Write([]byte(str2))
  7606. }
  7607. }
  7608. }
  7609. Zip(file_path, zip_path)
  7610. fmt.Println(ReadFile(zip_path))
  7611. fmt.Println(string(ReadFile(zip_path)))
  7612. if config.IsOpen == 1 {
  7613. var user_name string
  7614. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7615. if role.ID == 0 {
  7616. user_name = "管理员"
  7617. } else {
  7618. user_name = role.UserName
  7619. }
  7620. baseParams := models.BaseParams{
  7621. SecretKey: miConfig.SecretKey,
  7622. FixmedinsCode: miConfig.Code,
  7623. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7624. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7625. OrgName: miConfig.OrgName,
  7626. Doctor: user_name,
  7627. }
  7628. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  7629. var dat map[string]interface{}
  7630. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7631. fmt.Println(dat)
  7632. } else {
  7633. fmt.Println(err)
  7634. }
  7635. userJSONBytes, _ := json.Marshal(dat)
  7636. var res ResultNine
  7637. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7638. utils.ErrorLog("解析失败:%v", err)
  7639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7640. return
  7641. }
  7642. if res.Infcode == 0 {
  7643. fileNo := res.Output.FileQuryNo
  7644. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  7645. "file_qury_no=" + fileNo +
  7646. "&setl_optins=" + "定点医保中心" +
  7647. "&stmt_begndate=" + start_time +
  7648. "&stm_enddate=" + end_time +
  7649. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7650. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7651. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  7652. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7653. "&fixmedins_code=" + miConfig.Code +
  7654. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7655. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7656. "&secret_key=" + miConfig.SecretKey +
  7657. "&org_name=" + miConfig.OrgName +
  7658. "&doctor=" + user_name
  7659. resp, requestErr := http.Get(api)
  7660. if requestErr != nil {
  7661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7662. return
  7663. }
  7664. body, ioErr := ioutil.ReadAll(resp.Body)
  7665. if ioErr != nil {
  7666. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7668. return
  7669. }
  7670. var respJSON map[string]interface{}
  7671. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7674. return
  7675. }
  7676. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7677. userJSONBytes, _ := json.Marshal(respJSON)
  7678. var res ResultTen
  7679. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7680. utils.ErrorLog("解析失败:%v", err)
  7681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7682. return
  7683. }
  7684. if res.Infcode == 0 {
  7685. service.Gdyb9102(baseParams, zip_name, fileNo)
  7686. micc := &models.MedicalInsuranceCostCompare{
  7687. StartTime: startime.Unix(),
  7688. EndTime: endtime.Unix(),
  7689. Insutype: "0",
  7690. CheckType: 2,
  7691. Num: fixmedins_setl_cnt,
  7692. Mtime: time.Now().Unix(),
  7693. Status: 1,
  7694. UserOrgId: adminUser.CurrentOrgId,
  7695. CostTotal: medfee_sumamt,
  7696. FuncTotal: fund_pay_sumamt,
  7697. PsnPay: psn_cash_pay,
  7698. Creator: admin_user_id,
  7699. Ctime: time.Now().Unix(),
  7700. }
  7701. service.CreateMedicalInsuranceCostCompareRecord(micc)
  7702. c.ServeSuccessJSON(map[string]interface{}{
  7703. "msg": "明细对账成功",
  7704. })
  7705. }
  7706. } else {
  7707. }
  7708. }
  7709. }
  7710. type CustomOrderInfo struct {
  7711. Name string
  7712. Spec string
  7713. Unit string
  7714. Count float64
  7715. Price float64
  7716. Total float64
  7717. }
  7718. func (c *HisApiController) GetSettleAccounts() {
  7719. //id, _ := c.GetInt64("id")
  7720. //record_time := c.GetString("record_time")
  7721. order_id, _ := c.GetInt64("order_id")
  7722. admin_user_id, _ := c.GetInt64("admin_user_id")
  7723. //timeLayout := "2006-01-02"
  7724. //loc, _ := time.LoadLocation("Local")
  7725. //
  7726. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7727. //if err != nil {
  7728. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7729. // return
  7730. //}
  7731. //recordDateTime := theTime.Unix()
  7732. adminUser := c.GetAdminUserInfo()
  7733. order, _ := service.GetHisOrderByID(order_id)
  7734. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7735. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  7736. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  7737. orderInfos = append(orderInfos, orderInfos_two...)
  7738. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7739. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  7740. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7741. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  7742. //var config []*models.HisXtDiagnoseConfig
  7743. var name string
  7744. for _, item := range diagnosis_ids {
  7745. id, _ := strconv.ParseInt(item, 10, 64)
  7746. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7747. if len(name) == 0 {
  7748. name = diagnosisConfig.ClassName
  7749. } else {
  7750. name = name + "," + diagnosisConfig.ClassName
  7751. }
  7752. }
  7753. var bedCostTotal float64 = 0 //床位总费
  7754. var bedCostSelfTotal float64 = 0 //床位自费
  7755. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7756. var operationCostTotal float64 = 0 //手术费
  7757. var operationCostSelfTotal float64 = 0 //手术费
  7758. var operationCostPartSelfTotal float64 = 0 //手术费
  7759. var otherCostTotal float64 = 0 //其他费用
  7760. var otherCostSelfTotal float64 = 0 //其他费用
  7761. var otherCostPartSelfTotal float64 = 0 //其他费用
  7762. var materialCostTotal float64 = 0 //材料费
  7763. var materialCostSelfTotal float64 = 0 //材料费
  7764. var materialCostPartSelfTotal float64 = 0 //材料费
  7765. var westernMedicineCostTotal float64 = 0 //西药费
  7766. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7767. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7768. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7769. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7770. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7771. var checkCostTotal float64 = 0 //检查费
  7772. var checkCostSelfTotal float64 = 0 //检查费
  7773. var checkCostPartSelfTotal float64 = 0 //检查费
  7774. var laboratoryCostTotal float64 = 0 //化验费
  7775. var laboratoryCostSelfTotal float64 = 0 //化验费
  7776. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7777. var treatCostTotal float64 = 0 //治疗费用
  7778. var treatCostSelfTotal float64 = 0 //治疗费用
  7779. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7780. decimal.DivisionPrecision = 2
  7781. for _, item := range orderInfos {
  7782. if item.MedChrgitmType == "01" { //床位费
  7783. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7784. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7785. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7786. }
  7787. if item.MedChrgitmType == "03" { //检查费
  7788. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7789. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7790. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7791. }
  7792. if item.MedChrgitmType == "04" { //化验费
  7793. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7794. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7795. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7796. }
  7797. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  7798. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7799. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7800. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7801. }
  7802. if item.MedChrgitmType == "06" { //手术费
  7803. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7804. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7805. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7806. }
  7807. if item.MedChrgitmType == "08" { //材料费
  7808. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7809. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7810. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7811. }
  7812. if item.MedChrgitmType == "09" { //西药费
  7813. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7814. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7815. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7816. }
  7817. if item.MedChrgitmType == "11" { //中成费
  7818. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7819. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7820. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7821. }
  7822. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  7823. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7824. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7825. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7826. }
  7827. }
  7828. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7829. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7830. var user_name string
  7831. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7832. if role.ID == 0 {
  7833. user_name = "管理员"
  7834. } else {
  7835. user_name = role.UserName
  7836. }
  7837. baseParams := models.BaseParams{
  7838. SecretKey: miConfig.SecretKey,
  7839. FixmedinsCode: miConfig.Code,
  7840. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7841. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7842. OrgName: miConfig.OrgName,
  7843. Doctor: user_name,
  7844. }
  7845. businessParams := models.BusinessParams{
  7846. PsnNo: order.PsnNo,
  7847. MdtrtId: order.MdtrtId,
  7848. SetlId: order.SetlId,
  7849. }
  7850. var res ResultEleven
  7851. var resEleven10265 ResultEleven10265
  7852. if config.IsOpen == 1 {
  7853. if miConfig.MdtrtareaAdmvs == "421300" {
  7854. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7855. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7856. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7857. resp, requestErr := http.Get(api)
  7858. if requestErr != nil {
  7859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7860. return
  7861. }
  7862. body, ioErr := ioutil.ReadAll(resp.Body)
  7863. if ioErr != nil {
  7864. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7866. return
  7867. }
  7868. var respJSON map[string]interface{}
  7869. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7870. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7872. return
  7873. }
  7874. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7875. result, _ := json.Marshal(respJSON)
  7876. fmt.Println("log")
  7877. fmt.Println(string(result))
  7878. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7879. utils.ErrorLog("解析失败:%v", err)
  7880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7881. return
  7882. }
  7883. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7884. var api string
  7885. if miConfig.MdtrtareaAdmvs == "320921" {
  7886. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7887. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7888. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7889. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7890. } else {
  7891. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7892. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7893. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7894. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7895. }
  7896. resp, requestErr := http.Get(api)
  7897. if requestErr != nil {
  7898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7899. return
  7900. }
  7901. body, ioErr := ioutil.ReadAll(resp.Body)
  7902. if ioErr != nil {
  7903. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7905. return
  7906. }
  7907. var respJSON map[string]interface{}
  7908. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7911. return
  7912. }
  7913. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7914. result, _ := json.Marshal(respJSON)
  7915. fmt.Println("log")
  7916. fmt.Println(string(result))
  7917. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  7918. utils.ErrorLog("解析失败:%v", err)
  7919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7920. return
  7921. }
  7922. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7923. res.Output = resEleven10265.Output
  7924. res.ErrMsg = resEleven10265.ErrMsg
  7925. res.Cainfo = resEleven10265.Cainfo
  7926. res.WarnMsg = resEleven10265.WarnMsg
  7927. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7928. res.Infcode = infocode
  7929. } else {
  7930. //result2 := service.Gdyb1101()
  7931. result2 := service.Gdyb5204(baseParams, businessParams)
  7932. saveLog(result2, "", "5204", "查询")
  7933. result := service.Gdyb5203(baseParams, businessParams)
  7934. var dat map[string]interface{}
  7935. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7936. fmt.Println(dat)
  7937. } else {
  7938. fmt.Println(err)
  7939. }
  7940. userJSONBytes, _ := json.Marshal(dat)
  7941. if miConfig.Code == "H15049901371" {
  7942. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  7943. utils.ErrorLog("解析失败:%v", err)
  7944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7945. return
  7946. }
  7947. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7948. res.Output = resEleven10265.Output
  7949. res.ErrMsg = resEleven10265.ErrMsg
  7950. res.Cainfo = resEleven10265.Cainfo
  7951. res.WarnMsg = resEleven10265.WarnMsg
  7952. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7953. res.Infcode = infocode
  7954. } else {
  7955. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7956. utils.ErrorLog("解析失败:%v", err)
  7957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7958. return
  7959. }
  7960. }
  7961. }
  7962. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7963. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  7964. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  7965. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7966. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7967. var doctor_name string
  7968. if roles.ID == 0 {
  7969. doctor_name = "管理员"
  7970. } else {
  7971. doctor_name = roles.UserName
  7972. }
  7973. yiliao_leibie := ""
  7974. switch order.MedType {
  7975. case "11":
  7976. yiliao_leibie = "普通门诊"
  7977. break
  7978. case "12":
  7979. yiliao_leibie = "门诊挂号"
  7980. break
  7981. case "13":
  7982. yiliao_leibie = "急诊"
  7983. break
  7984. case "14":
  7985. yiliao_leibie = "门诊特殊病"
  7986. break
  7987. case "15":
  7988. yiliao_leibie = "门诊统筹"
  7989. break
  7990. case "16":
  7991. yiliao_leibie = "门诊慢性病"
  7992. break
  7993. case "21":
  7994. yiliao_leibie = "普通住院"
  7995. break
  7996. }
  7997. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7998. if res.Infcode == 0 {
  7999. c.ServeSuccessJSON(map[string]interface{}{
  8000. "diagnosis": name,
  8001. "order_infos": orderInfos,
  8002. "number": order.MdtrtId,
  8003. "date": order.SettleAccountsDate,
  8004. "charge_admin": charge_admin,
  8005. "printor_admin": printor_admin,
  8006. "info": res.Output.Setlinfo,
  8007. "bedCostTotal": bedCostTotal,
  8008. "bedCostSelfTotal": bedCostSelfTotal,
  8009. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8010. "operationCostTotal": operationCostTotal,
  8011. "operationCostSelfTotal": operationCostSelfTotal,
  8012. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8013. "otherCostTotal": otherCostTotal,
  8014. "otherCostSelfTotal": otherCostSelfTotal,
  8015. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8016. "materialCostTotal": materialCostTotal,
  8017. "materialCostSelfTotal": materialCostSelfTotal,
  8018. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8019. "westernMedicineCostTotal": westernMedicineCostTotal,
  8020. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8021. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8022. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8023. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8024. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8025. "checkCostTotal": checkCostTotal,
  8026. "checkCostSelfTotal": checkCostSelfTotal,
  8027. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8028. "laboratoryCostTotal": laboratoryCostTotal,
  8029. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  8030. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  8031. "treatCostTotal": treatCostTotal,
  8032. "treatCostSelfTotal": treatCostSelfTotal,
  8033. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  8034. "doctor_code": adminRole_two.DoctorCode,
  8035. "doctor_name": doctor_name,
  8036. "health_card_no": order.PsnNo,
  8037. "department": departments.Name,
  8038. "yiliao_leibie": yiliao_leibie,
  8039. "after_money": order.AccountPrice,
  8040. "patient": patient,
  8041. "org_name": miConfig.OrgName,
  8042. "org_code": miConfig.Code,
  8043. "order_number": order.Number,
  8044. "his_hospital": his_hospital,
  8045. "his": his,
  8046. //"check_order_info": cus_slice,
  8047. })
  8048. }
  8049. }
  8050. }
  8051. func (c *HisApiController) CheckTreatment() {
  8052. patient_id, _ := c.GetInt64("patient_id")
  8053. id_card_no := c.GetString("id_card_no")
  8054. insutype := c.GetString("insutype")
  8055. med_type := c.GetString("med_type")
  8056. admin_user_id, _ := c.GetInt64("admin_user_id")
  8057. adminUser := c.GetAdminUserInfo()
  8058. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8059. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8060. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8061. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8062. if miConfig.MdtrtareaAdmvs == "421300" {
  8063. var res ResultTwo
  8064. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8065. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8066. "&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)
  8067. resp, requestErr := http.Get(api)
  8068. if requestErr != nil {
  8069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8070. return
  8071. }
  8072. body, ioErr := ioutil.ReadAll(resp.Body)
  8073. if ioErr != nil {
  8074. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8076. return
  8077. }
  8078. var respJSON map[string]interface{}
  8079. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8080. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8082. return
  8083. }
  8084. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8085. result, _ := json.Marshal(respJSON)
  8086. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8087. utils.ErrorLog("解析失败:%v", err)
  8088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8089. return
  8090. }
  8091. if res.Infcode == 0 {
  8092. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  8093. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8094. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  8095. resp, requestErr := http.Get(api)
  8096. if requestErr != nil {
  8097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8098. return
  8099. }
  8100. body, ioErr := ioutil.ReadAll(resp.Body)
  8101. if ioErr != nil {
  8102. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8104. return
  8105. }
  8106. var respJSON map[string]interface{}
  8107. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8108. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8110. return
  8111. }
  8112. var res Result2001
  8113. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8114. result2, _ := json.Marshal(respJSON)
  8115. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8116. utils.ErrorLog("解析失败:%v", err)
  8117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8118. return
  8119. }
  8120. if res.Infcode == 0 {
  8121. c.ServeSuccessJSON(map[string]interface{}{
  8122. "msg": res.Output.Trtinfo,
  8123. })
  8124. }
  8125. } else {
  8126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8127. return
  8128. }
  8129. } else {
  8130. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8131. var dat map[string]interface{}
  8132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8133. fmt.Println(dat)
  8134. } else {
  8135. fmt.Println(err)
  8136. }
  8137. userJSONBytes, _ := json.Marshal(dat)
  8138. var res ResultTwo
  8139. var res10265 ResultTwo10265
  8140. if miConfig.Code == "H15049901371" {
  8141. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8142. utils.ErrorLog("解析失败:%v", err)
  8143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8144. return
  8145. }
  8146. res.ErrMsg = res10265.ErrMsg
  8147. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8148. res.Infcode = infocode
  8149. res.Output = res10265.Output
  8150. res.InfRefmsgid = res10265.InfRefmsgid
  8151. } else {
  8152. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8153. utils.ErrorLog("解析失败:%v", err)
  8154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8155. return
  8156. }
  8157. }
  8158. var user_name string
  8159. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  8160. if role.ID == 0 {
  8161. user_name = "xxx"
  8162. } else {
  8163. user_name = role.UserName
  8164. }
  8165. baseParams := models.BaseParams{
  8166. SecretKey: miConfig.SecretKey,
  8167. FixmedinsCode: miConfig.Code,
  8168. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8169. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8170. OrgName: miConfig.OrgName,
  8171. Doctor: user_name,
  8172. }
  8173. if config.IsOpen == 1 {
  8174. if miConfig.Code == "H15049901371" {
  8175. if med_type == "14" {
  8176. if insutype == "390" {
  8177. med_type = "9933"
  8178. } else if insutype == "310" {
  8179. med_type = "990502"
  8180. }
  8181. } else if med_type == "11" {
  8182. med_type = "11"
  8183. }
  8184. }
  8185. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  8186. var dat map[string]interface{}
  8187. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8188. fmt.Println(dat)
  8189. } else {
  8190. fmt.Println(err)
  8191. }
  8192. var res Result2001
  8193. var res10265 Result2001Org10265
  8194. if miConfig.Code == "H15049901371" {
  8195. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8196. utils.ErrorLog("解析失败:%v", err)
  8197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8198. return
  8199. }
  8200. res.ErrMsg = res10265.ErrMsg
  8201. res.Output = res10265.Output
  8202. res.InfRefmsgid = res10265.InfRefmsgid
  8203. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8204. res.Infcode = infocode
  8205. } else {
  8206. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8207. utils.ErrorLog("解析失败:%v", err)
  8208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8209. return
  8210. }
  8211. }
  8212. if res.Infcode == 0 {
  8213. c.ServeSuccessJSON(map[string]interface{}{
  8214. "msg": res.Output.Trtinfo,
  8215. })
  8216. }
  8217. }
  8218. }
  8219. }
  8220. //func (c *HisApiController) PutRecord() {
  8221. // id, _ := c.GetInt64("id")
  8222. // record_time := c.GetString("record_time")
  8223. // timeLayout := "2006-01-02"
  8224. // loc, _ := time.LoadLocation("Local")
  8225. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8226. // if err != nil {
  8227. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8228. // return
  8229. // }
  8230. // recordDateTime := theTime.Unix()
  8231. //
  8232. // adminInfo := c.GetAdminUserInfo()
  8233. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  8234. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8235. //
  8236. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8237. //
  8238. // fmt.Println(miConfig.SecretKey)
  8239. //
  8240. // if patient == nil {
  8241. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8242. // return
  8243. // }
  8244. // if len(patient.IdCardNo) == 0 {
  8245. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  8246. // return
  8247. // }
  8248. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8249. // if config.IsOpen == 1 {
  8250. // 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
  8251. // resp, requestErr := http.Get(api)
  8252. // if requestErr != nil {
  8253. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8254. // return
  8255. // }
  8256. // defer resp.Body.Close()
  8257. // body, ioErr := ioutil.ReadAll(resp.Body)
  8258. // if ioErr != nil {
  8259. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8260. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8261. // return
  8262. // }
  8263. // var respJSON map[string]interface{}
  8264. //
  8265. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8266. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8267. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8268. // return
  8269. // }
  8270. //
  8271. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8272. // userJSONBytes, _ := json.Marshal(userJSON)
  8273. // var res ResultTwo
  8274. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8275. // utils.ErrorLog("解析失败:%v", err)
  8276. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8277. // return
  8278. // }
  8279. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8280. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8281. // infoStr := string(Iinfos)
  8282. // idetinfoStr := string(Idetinfos)
  8283. //
  8284. // if res.Infcode == 0 {
  8285. // his := models.VMHisPatient{
  8286. // Status: 1,
  8287. // Ctime: time.Now().Unix(),
  8288. // Mtime: time.Now().Unix(),
  8289. // PsnNo: res.Output.Baseinfo.PsnNo,
  8290. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  8291. // Certno: res.Output.Baseinfo.Certno,
  8292. // PsnName: res.Output.Baseinfo.PsnName,
  8293. // Gend: res.Output.Baseinfo.Gend,
  8294. // Naty: res.Output.Baseinfo.Naty,
  8295. // Brdy: res.Output.Baseinfo.Brdy,
  8296. // Age: res.Output.Baseinfo.Age,
  8297. // Iinfo: infoStr,
  8298. // Idetinfo: idetinfoStr,
  8299. // PatientId: patient.ID,
  8300. // RecordDate: theTime.Unix(),
  8301. // UserOrgId: adminInfo.CurrentOrgId,
  8302. // AdminUserId: adminInfo.AdminUser.Id,
  8303. // IsReturn: 1,
  8304. // }
  8305. //
  8306. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  8307. // //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")
  8308. // //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")
  8309. //
  8310. // //var dat map[string]interface{}
  8311. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8312. // // fmt.Println(dat)
  8313. // //} else {
  8314. // // fmt.Println(err)
  8315. // //}
  8316. //
  8317. // var dat2 map[string]interface{}
  8318. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8319. // fmt.Println(dat2)
  8320. // } else {
  8321. // fmt.Println(err)
  8322. // }
  8323. //
  8324. // } else {
  8325. // adminUser := c.GetAdminUserInfo()
  8326. // errlog := &models.HisOrderError{
  8327. // UserOrgId: adminUser.CurrentOrgId,
  8328. // Ctime: time.Now().Unix(),
  8329. // Mtime: time.Now().Unix(),
  8330. // ErrMsg: res.ErrMsg,
  8331. // Status: 1,
  8332. // PatientId: id,
  8333. // RecordTime: recordDateTime,
  8334. // Stage: 1,
  8335. // }
  8336. // service.CreateErrMsgLog(errlog)
  8337. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8338. // return
  8339. // }
  8340. // }
  8341. //
  8342. //}
  8343. //func (c *HisApiController) GetUploadDiag() {
  8344. // id, _ := c.GetInt64("id")
  8345. // record_time := c.GetString("record_time")
  8346. //
  8347. // diagnosis_id, _ := c.GetInt64("diagnosis")
  8348. // sick_type, _ := c.GetInt64("sick_type")
  8349. // reg_type, _ := c.GetInt64("reg_type")
  8350. //
  8351. // timeLayout := "2006-01-02"
  8352. // loc, _ := time.LoadLocation("Local")
  8353. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8354. // if err != nil {
  8355. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8356. // return
  8357. // }
  8358. //
  8359. // var patientPrescription models.HisPrescriptionInfo
  8360. // recordDateTime := theTime.Unix()
  8361. // adminInfo := c.GetAdminUserInfo()
  8362. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8363. //
  8364. // if patientPrescription.ID == 0 {
  8365. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8366. // }
  8367. //
  8368. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8369. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8370. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8371. // sickConfig, _ := service.FindSickById(sick_type)
  8372. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8373. //
  8374. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  8375. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  8376. // "&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 +
  8377. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  8378. // resp2, requestErr2 := http.Get(api2)
  8379. // if requestErr2 != nil {
  8380. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8381. // return
  8382. // }
  8383. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8384. // if ioErr2 != nil {
  8385. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8386. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8387. // return
  8388. // }
  8389. // var respJSON2 map[string]interface{}
  8390. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8391. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8392. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8393. // return
  8394. // }
  8395. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8396. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8397. //
  8398. // var res2 ResultSix
  8399. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8400. // utils.ErrorLog("解析失败:%v", err)
  8401. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8402. // return
  8403. // }
  8404. // if res2.Infcode != 0 {
  8405. // adminUser := c.GetAdminUserInfo()
  8406. // errlog := &models.HisOrderError{
  8407. // UserOrgId: adminUser.CurrentOrgId,
  8408. // Ctime: time.Now().Unix(),
  8409. // Mtime: time.Now().Unix(),
  8410. // ErrMsg: res2.ErrMsg,
  8411. // Status: 1,
  8412. // PatientId: id,
  8413. // RecordTime: recordDateTime,
  8414. // Stage: 3,
  8415. // }
  8416. // service.CreateErrMsgLog(errlog)
  8417. //
  8418. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  8419. // return
  8420. // }
  8421. //
  8422. // c.ServeSuccessJSON(map[string]interface{}{
  8423. // "msg": "上传成功",
  8424. // })
  8425. //
  8426. //}
  8427. type QueryResult struct {
  8428. ID int64
  8429. Name string
  8430. Code string
  8431. List_type_code string
  8432. }
  8433. func (c *HisApiController) GetCheckCode() {
  8434. ids_str := c.GetString("ids")
  8435. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8436. ids_arr := strings.Split(ids_str, ",")
  8437. var queryResult []QueryResult
  8438. ids := make([]int64, 0)
  8439. for _, item := range ids_arr {
  8440. id, _ := strconv.ParseInt(item, 10, 64)
  8441. ids = append(ids, id)
  8442. }
  8443. if record_type == 1 {
  8444. drugs, _ := service.GetBatchDrugList(ids)
  8445. for _, item := range drugs {
  8446. result := QueryResult{
  8447. ID: item.ID,
  8448. Name: item.DrugName,
  8449. Code: item.MedicalInsuranceNumber,
  8450. List_type_code: "101",
  8451. }
  8452. queryResult = append(queryResult, result)
  8453. }
  8454. } else if record_type == 2 {
  8455. goods, _ := service.GetBatchGoodInformationList(ids)
  8456. for _, item := range goods {
  8457. result := QueryResult{
  8458. ID: item.ID,
  8459. Name: item.GoodName,
  8460. Code: item.MedicalInsuranceNumber,
  8461. List_type_code: "301",
  8462. }
  8463. queryResult = append(queryResult, result)
  8464. }
  8465. } else if record_type == 3 {
  8466. projects, _ := service.GetBathchMyPorjecgList(ids)
  8467. for _, item := range projects {
  8468. result := QueryResult{
  8469. ID: item.ID,
  8470. Name: item.ProjectName,
  8471. Code: item.MedicalCode,
  8472. List_type_code: "201",
  8473. }
  8474. queryResult = append(queryResult, result)
  8475. }
  8476. }
  8477. admin_user_id, _ := c.GetInt64("admin_user_id")
  8478. adminUser := c.GetAdminUserInfo()
  8479. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8480. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8481. var user_name string
  8482. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8483. if role.ID == 0 {
  8484. user_name = "xxx"
  8485. } else {
  8486. user_name = role.UserName
  8487. }
  8488. baseParams := &models.BaseParams{
  8489. SecretKey: miConfig.SecretKey,
  8490. FixmedinsCode: miConfig.Code,
  8491. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8492. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8493. OrgName: miConfig.OrgName,
  8494. Doctor: user_name,
  8495. }
  8496. if config.IsOpen == 1 {
  8497. for _, item := range queryResult {
  8498. var result string
  8499. if record_type == 1 {
  8500. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8501. } else if record_type == 2 {
  8502. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8503. } else if record_type == 3 {
  8504. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8505. }
  8506. var dat map[string]interface{}
  8507. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8508. fmt.Println(dat)
  8509. } else {
  8510. fmt.Println(err)
  8511. }
  8512. userJSONBytes, _ := json.Marshal(dat)
  8513. var res ResultSix
  8514. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8515. utils.ErrorLog("解析失败:%v", err)
  8516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8517. return
  8518. }
  8519. if res.Infcode == 0 {
  8520. if record_type == 1 {
  8521. service.UpdateBaseDrugById(item.ID)
  8522. } else if record_type == 2 {
  8523. service.UpdateGoodInformaitonByDetail(item.ID)
  8524. } else if record_type == 3 {
  8525. service.UpdateProjectById(item.ID)
  8526. }
  8527. c.ServeSuccessJSON(map[string]interface{}{
  8528. "failed_code": 0,
  8529. "msg": "目录对照成功",
  8530. })
  8531. } else {
  8532. c.ServeSuccessJSON(map[string]interface{}{
  8533. "failed_code": -10,
  8534. "msg": res.ErrMsg,
  8535. })
  8536. }
  8537. }
  8538. }
  8539. }
  8540. func (c *HisApiController) UnCheckCode() {
  8541. ids_str := c.GetString("ids")
  8542. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8543. admin_user_id, _ := c.GetInt64("admin_user_id")
  8544. ids_arr := strings.Split(ids_str, ",")
  8545. var queryResult []QueryResult
  8546. ids := make([]int64, 0)
  8547. for _, item := range ids_arr {
  8548. id, _ := strconv.ParseInt(item, 10, 64)
  8549. ids = append(ids, id)
  8550. }
  8551. if record_type == 1 {
  8552. drugs, _ := service.GetBatchDrugList(ids)
  8553. for _, item := range drugs {
  8554. result := QueryResult{
  8555. ID: item.ID,
  8556. Name: item.DrugName,
  8557. Code: item.MedicalInsuranceNumber,
  8558. List_type_code: "101",
  8559. }
  8560. queryResult = append(queryResult, result)
  8561. }
  8562. } else if record_type == 2 {
  8563. goods, _ := service.GetBatchGoodInformationList(ids)
  8564. for _, item := range goods {
  8565. result := QueryResult{
  8566. ID: item.ID,
  8567. Name: item.GoodName,
  8568. Code: item.MedicalInsuranceNumber,
  8569. List_type_code: "301",
  8570. }
  8571. queryResult = append(queryResult, result)
  8572. }
  8573. } else if record_type == 3 {
  8574. projects, _ := service.GetBathchMyPorjecgList(ids)
  8575. for _, item := range projects {
  8576. result := QueryResult{
  8577. ID: item.ID,
  8578. Name: item.ProjectName,
  8579. Code: item.MedicalCode,
  8580. List_type_code: "201",
  8581. }
  8582. queryResult = append(queryResult, result)
  8583. }
  8584. }
  8585. adminUser := c.GetAdminUserInfo()
  8586. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8587. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8588. var user_name string
  8589. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8590. if role.ID == 0 {
  8591. user_name = "xxx"
  8592. } else {
  8593. user_name = role.UserName
  8594. }
  8595. baseParams := &models.BaseParams{
  8596. SecretKey: miConfig.SecretKey,
  8597. FixmedinsCode: miConfig.Code,
  8598. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8599. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8600. OrgName: miConfig.OrgName,
  8601. Doctor: user_name,
  8602. }
  8603. if config.IsOpen == 1 {
  8604. for _, item := range queryResult {
  8605. var result string
  8606. if record_type == 1 {
  8607. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8608. } else if record_type == 2 {
  8609. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8610. } else if record_type == 3 {
  8611. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8612. }
  8613. var dat2 map[string]interface{}
  8614. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  8615. fmt.Println(dat2)
  8616. } else {
  8617. fmt.Println(err)
  8618. }
  8619. userJSONBytes, _ := json.Marshal(dat2)
  8620. var res ResultSix
  8621. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8622. utils.ErrorLog("解析失败:%v", err)
  8623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8624. return
  8625. }
  8626. if res.Infcode == 0 {
  8627. if record_type == 1 {
  8628. service.UpdateDrugByIdDetail(item.ID)
  8629. } else if record_type == 2 {
  8630. service.UpdateGoodInfoById(item.ID)
  8631. } else if record_type == 3 {
  8632. service.UpdateMyProjectById(item.ID)
  8633. }
  8634. c.ServeSuccessJSON(map[string]interface{}{
  8635. "failed_code": 0,
  8636. "msg": "撤销目录对照成功",
  8637. })
  8638. } else {
  8639. c.ServeSuccessJSON(map[string]interface{}{
  8640. "failed_code": -10,
  8641. "msg": res.ErrMsg,
  8642. })
  8643. }
  8644. }
  8645. }
  8646. }
  8647. func (c *HisApiController) GetPatientInfo() {
  8648. id_card_no := c.GetString("id_card_no")
  8649. admin_user_id, _ := c.GetInt64("admin_user_id")
  8650. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8651. if patient.ID == 0 {
  8652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8653. return
  8654. }
  8655. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8656. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8657. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  8658. if config.IsOpen == 1 {
  8659. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8660. var dat map[string]interface{}
  8661. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8662. fmt.Println(dat)
  8663. } else {
  8664. fmt.Println(err)
  8665. }
  8666. userJSONBytes, _ := json.Marshal(dat)
  8667. var res ResultTwo
  8668. var res10265 ResultTwo10265
  8669. if miConfig.Code == "H15049901371" {
  8670. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8671. utils.ErrorLog("解析失败:%v", err)
  8672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8673. return
  8674. }
  8675. res.ErrMsg = res10265.ErrMsg
  8676. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8677. res.Infcode = infocode
  8678. res.Output = res10265.Output
  8679. res.InfRefmsgid = res10265.InfRefmsgid
  8680. } else {
  8681. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8682. utils.ErrorLog("解析失败:%v", err)
  8683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8684. return
  8685. }
  8686. }
  8687. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8688. // utils.ErrorLog("解析失败:%v", err)
  8689. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8690. // return
  8691. //}
  8692. if res.Infcode != 0 {
  8693. c.ServeSuccessJSON(map[string]interface{}{
  8694. "failed_code": -10,
  8695. "msg": res.ErrMsg,
  8696. })
  8697. } else {
  8698. c.ServeSuccessJSON(map[string]interface{}{
  8699. "failed_code": 0,
  8700. "info": res,
  8701. })
  8702. }
  8703. }
  8704. }
  8705. func (c *HisApiController) PsnPutOnRecord() {
  8706. record_type, _ := c.GetInt64("type")
  8707. patient_id, _ := c.GetInt64("patient_id")
  8708. admin_user_id, _ := c.GetInt64("admin_user_id")
  8709. start_time := c.GetString("start_time")
  8710. end_time := c.GetString("end_time")
  8711. adminUser := c.GetAdminUserInfo()
  8712. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8713. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8714. var patients []*models.Patients
  8715. if record_type == 1 { //全部备案
  8716. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  8717. patients = append(patients, patient...)
  8718. } else { //单个备案
  8719. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8720. patients = append(patients, patient)
  8721. }
  8722. var user_name string
  8723. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8724. if role.ID == 0 {
  8725. user_name = "xxx"
  8726. } else {
  8727. user_name = role.UserName
  8728. }
  8729. if config.IsOpen == 1 {
  8730. for _, item := range patients {
  8731. 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
  8732. resp, requestErr := http.Get(api)
  8733. if requestErr != nil {
  8734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8735. return
  8736. }
  8737. defer resp.Body.Close()
  8738. body, ioErr := ioutil.ReadAll(resp.Body)
  8739. if ioErr != nil {
  8740. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8742. return
  8743. }
  8744. var respJSON map[string]interface{}
  8745. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8746. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8748. return
  8749. }
  8750. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8751. userJSONBytes, _ := json.Marshal(userJSON)
  8752. var res ResultTwo
  8753. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8754. utils.ErrorLog("解析失败:%v", err)
  8755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8756. return
  8757. }
  8758. if res.Infcode == 0 {
  8759. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  8760. var dat map[string]interface{}
  8761. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8762. fmt.Println(dat)
  8763. } else {
  8764. fmt.Println(err)
  8765. }
  8766. userJSONBytes, _ := json.Marshal(dat)
  8767. var res2 ResultThirteen
  8768. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8769. utils.ErrorLog("解析失败:%v", err)
  8770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8771. return
  8772. }
  8773. if res2.Infcode == 0 {
  8774. psnResult := &models.GdybPsnRecord{
  8775. UserOrgId: adminUser.CurrentOrgId,
  8776. PatientId: item.ID,
  8777. PsnNo: res.Output.Baseinfo.PsnNo,
  8778. Ctime: time.Now().Unix(),
  8779. Mtime: time.Now().Unix(),
  8780. Status: 1,
  8781. IsCancel: 1,
  8782. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8783. }
  8784. service.CreatePsnRecord(psnResult)
  8785. } else {
  8786. c.ServeSuccessJSON(map[string]interface{}{
  8787. "failed_code": -10,
  8788. "msg": res2.ErrMsg,
  8789. })
  8790. return
  8791. }
  8792. }
  8793. }
  8794. }
  8795. }
  8796. func (c *HisApiController) PsnUnPutOnRecord() {
  8797. id, _ := c.GetInt64("id")
  8798. //record_type, _ := c.GetInt64("type")
  8799. admin_user_id, _ := c.GetInt64("admin_user_id")
  8800. adminUser := c.GetAdminUserInfo()
  8801. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8802. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8803. var user_name string
  8804. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8805. if role.ID == 0 {
  8806. user_name = "xxx"
  8807. } else {
  8808. user_name = role.UserName
  8809. }
  8810. psn_record, _ := service.GetPsnRecordById(id)
  8811. if psn_record.ID == 0 {
  8812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8813. return
  8814. }
  8815. if config.IsOpen == 1 {
  8816. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8817. var dat map[string]interface{}
  8818. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8819. fmt.Println(dat)
  8820. } else {
  8821. fmt.Println(err)
  8822. }
  8823. userJSONBytes, _ := json.Marshal(dat)
  8824. var res ResultFourteen
  8825. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8826. utils.ErrorLog("解析失败:%v", err)
  8827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8828. return
  8829. }
  8830. if res.Infcode == 0 {
  8831. psn_record.IsCancel = 2
  8832. service.CreatePsnRecord(&psn_record)
  8833. } else {
  8834. c.ServeSuccessJSON(map[string]interface{}{
  8835. "failed_code": -10,
  8836. "msg": res.ErrMsg,
  8837. })
  8838. return
  8839. }
  8840. }
  8841. }
  8842. func (c *HisApiController) PsnPutNCDSOnRecord() {
  8843. patient_id, _ := c.GetInt64("patient_id")
  8844. insutype_two := c.GetString("insutype")
  8845. psn_no := c.GetString("psn_no")
  8846. doctor_id, _ := c.GetInt64("doctor_id")
  8847. sick_id, _ := c.GetInt64("sick_id")
  8848. department_id, _ := c.GetInt64("department_id")
  8849. start_time := c.GetString("start_time")
  8850. end_time := c.GetString("end_time")
  8851. check_time := c.GetString("check_time")
  8852. adminUser := c.GetAdminUserInfo()
  8853. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8854. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8855. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8856. sick, _ := service.FindSickById(sick_id)
  8857. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8858. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8859. var res ResultTwo
  8860. var res10265 ResultTwo10265
  8861. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8862. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  8863. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  8864. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8865. "&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
  8866. resp, requestErr := http.Get(api)
  8867. if requestErr != nil {
  8868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8869. return
  8870. }
  8871. body, ioErr := ioutil.ReadAll(resp.Body)
  8872. if ioErr != nil {
  8873. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8875. return
  8876. }
  8877. var respJSON map[string]interface{}
  8878. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8879. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8881. return
  8882. }
  8883. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8884. result, _ := json.Marshal(respJSON)
  8885. fmt.Println("log")
  8886. fmt.Println(string(result))
  8887. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8888. utils.ErrorLog("解析失败:%v", err)
  8889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8890. return
  8891. }
  8892. res.ErrMsg = res10265.ErrMsg
  8893. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8894. res.Infcode = infocode
  8895. res.Output = res10265.Output
  8896. res.InfRefmsgid = res10265.InfRefmsgid
  8897. } else {
  8898. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8899. if miConfig.Code == "H15049901371" {
  8900. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8901. utils.ErrorLog("解析失败:%v", err)
  8902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8903. return
  8904. }
  8905. res.ErrMsg = res10265.ErrMsg
  8906. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8907. res.Infcode = infocode
  8908. res.Output = res10265.Output
  8909. res.InfRefmsgid = res10265.InfRefmsgid
  8910. } else {
  8911. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8912. utils.ErrorLog("解析失败:%v", err)
  8913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8914. return
  8915. }
  8916. }
  8917. }
  8918. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8919. infoStr := string(Iinfos)
  8920. var rf []*ResultFive
  8921. json.Unmarshal([]byte(infoStr), &rf)
  8922. var insuplc_admdvs string
  8923. var insutype string
  8924. var is390 int = 0
  8925. var is310 int = 0
  8926. var insutypes []*ResultFive
  8927. for _, item := range rf {
  8928. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8929. insutypes = append(insutypes, item)
  8930. }
  8931. }
  8932. if len(insutypes) == 1 {
  8933. insutype = insutypes[0].Insutype
  8934. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8935. } else {
  8936. for _, i := range insutypes {
  8937. if i.Insutype == "390" {
  8938. is390 = 1
  8939. }
  8940. if i.Insutype == "310" {
  8941. is310 = 1
  8942. }
  8943. }
  8944. }
  8945. if is390 == 1 {
  8946. insutype = "390"
  8947. }
  8948. if is310 == 1 {
  8949. insutype = "310"
  8950. }
  8951. if len(insutypes) == 2 {
  8952. insutype = insutype_two
  8953. }
  8954. if len(insutypes) == 0 {
  8955. insutype = "310"
  8956. }
  8957. insutype = insutype_two
  8958. fmt.Println(insutype)
  8959. for _, item := range rf {
  8960. fmt.Println(item.Insutype)
  8961. fmt.Println(insutype)
  8962. if item.Insutype == insutype {
  8963. fmt.Println(item.Insutype)
  8964. fmt.Println(insutype)
  8965. insuplc_admdvs = item.InsuplcAdmdvs
  8966. }
  8967. }
  8968. fmt.Println(insuplc_admdvs)
  8969. var res2 ResultThirteen
  8970. var res10265_2 ResultThirteen10265
  8971. if config.IsOpen == 1 {
  8972. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8973. } else {
  8974. 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)
  8975. var dat map[string]interface{}
  8976. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8977. fmt.Println(dat)
  8978. } else {
  8979. fmt.Println(err)
  8980. }
  8981. userJSONBytes, _ := json.Marshal(dat)
  8982. if miConfig.Code == "H15049901371" {
  8983. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  8984. utils.ErrorLog("解析失败:%v", err)
  8985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8986. return
  8987. }
  8988. res2.ErrMsg = res10265_2.ErrMsg
  8989. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  8990. res2.Infcode = infocode
  8991. res2.Output = res10265_2.Output
  8992. res2.InfRefmsgid = res10265_2.InfRefmsgid
  8993. } else {
  8994. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8995. utils.ErrorLog("解析失败:%v", err)
  8996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8997. return
  8998. }
  8999. }
  9000. }
  9001. if res2.Infcode == 0 {
  9002. psnResult := &models.GdybPsnNcdsRecord{
  9003. UserOrgId: adminUser.CurrentOrgId,
  9004. PatientId: patient.ID,
  9005. PsnNo: psn_no,
  9006. DoctorId: doctor.AdminUserId,
  9007. DepartmentId: department_id,
  9008. SickType: sick_id,
  9009. Insutype: insutype,
  9010. Ctime: time.Now().Unix(),
  9011. Mtime: time.Now().Unix(),
  9012. Status: 1,
  9013. IsCancel: 1,
  9014. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9015. }
  9016. service.CreatePsnNCDSRecord(psnResult)
  9017. c.ServeSuccessJSON(map[string]interface{}{
  9018. "failed_code": 0,
  9019. "msg": "备案成功",
  9020. "result": psnResult,
  9021. })
  9022. } else {
  9023. c.ServeSuccessJSON(map[string]interface{}{
  9024. "failed_code": -10,
  9025. "msg": res2.ErrMsg,
  9026. })
  9027. return
  9028. }
  9029. }
  9030. }
  9031. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  9032. id, _ := c.GetInt64("id")
  9033. admin_user_id, _ := c.GetInt64("admin_user_id")
  9034. adminUser := c.GetAdminUserInfo()
  9035. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9036. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9037. //config, _ := service.Ge(adminUser.CurrentOrgId)
  9038. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  9039. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9040. //var user_name string
  9041. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9042. //if role.ID == 0 {
  9043. // user_name = "xxx"
  9044. //} else {
  9045. // user_name = role.UserName
  9046. //}
  9047. psn_record, _ := service.GetPsnNCDSRecordById(id)
  9048. if psn_record.ID == 0 {
  9049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9050. return
  9051. }
  9052. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9053. var res ResultTwo
  9054. var res10265 ResultTwo10265
  9055. if miConfig.Code == "H15049901371" {
  9056. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9057. utils.ErrorLog("解析失败:%v", err)
  9058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9059. return
  9060. }
  9061. res.ErrMsg = res10265.ErrMsg
  9062. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9063. res.Infcode = infocode
  9064. res.Output = res10265.Output
  9065. res.InfRefmsgid = res10265.InfRefmsgid
  9066. } else {
  9067. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9068. utils.ErrorLog("解析失败:%v", err)
  9069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9070. return
  9071. }
  9072. }
  9073. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9074. infoStr := string(Iinfos)
  9075. var rf []*ResultFive
  9076. json.Unmarshal([]byte(infoStr), &rf)
  9077. var insuplc_admdvs string
  9078. var insutype string
  9079. var is390 int = 0
  9080. var is310 int = 0
  9081. var insutypes []*ResultFive
  9082. for _, item := range rf {
  9083. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9084. insutypes = append(insutypes, item)
  9085. }
  9086. }
  9087. if len(insutypes) == 1 {
  9088. insutype = insutypes[0].Insutype
  9089. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9090. } else {
  9091. for _, i := range insutypes {
  9092. if i.Insutype == "390" {
  9093. is390 = 1
  9094. }
  9095. if i.Insutype == "310" {
  9096. is310 = 1
  9097. }
  9098. }
  9099. }
  9100. if is390 == 1 {
  9101. insutype = "390"
  9102. }
  9103. if is310 == 1 {
  9104. insutype = "310"
  9105. }
  9106. if len(insutypes) == 0 {
  9107. insutype = "310"
  9108. }
  9109. insutype = psn_record.Insutype
  9110. for _, item := range rf {
  9111. if item.Insutype == insutype {
  9112. insuplc_admdvs = item.InsuplcAdmdvs
  9113. }
  9114. }
  9115. if config.IsOpen == 1 {
  9116. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9117. var dat map[string]interface{}
  9118. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9119. fmt.Println(dat)
  9120. } else {
  9121. fmt.Println(err)
  9122. }
  9123. userJSONBytes, _ := json.Marshal(dat)
  9124. var res ResultFourteen
  9125. var res10265 ResultFourteen10265
  9126. if miConfig.Code == "H15049901371" {
  9127. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9128. utils.ErrorLog("解析失败:%v", err)
  9129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9130. return
  9131. }
  9132. res.ErrMsg = res10265.ErrMsg
  9133. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9134. res.Infcode = infocode
  9135. res.Output = res10265.Output
  9136. res.InfRefmsgid = res10265.InfRefmsgid
  9137. } else {
  9138. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9139. utils.ErrorLog("解析失败:%v", err)
  9140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9141. return
  9142. }
  9143. }
  9144. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9145. // utils.ErrorLog("解析失败:%v", err)
  9146. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9147. // return
  9148. //}
  9149. if res.Infcode == 0 {
  9150. psn_record.IsCancel = 2
  9151. service.CreatePsnNCDSRecord(&psn_record)
  9152. c.ServeSuccessJSON(map[string]interface{}{
  9153. "failed_code": 0,
  9154. "msg": "撤销备案成功",
  9155. })
  9156. } else {
  9157. c.ServeSuccessJSON(map[string]interface{}{
  9158. "failed_code": -10,
  9159. "msg": res.ErrMsg,
  9160. })
  9161. return
  9162. }
  9163. }
  9164. }
  9165. func (c *HisApiController) TestTest() {
  9166. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  9167. fmt.Println(patient.Iinfo)
  9168. }
  9169. type CustomData struct {
  9170. MsgId string
  9171. PsnNo string
  9172. Info string
  9173. }
  9174. func (c *HisApiController) ReversalData() {
  9175. var customData []*CustomData
  9176. custom := &CustomData{
  9177. MsgId: "H44022900158202103301714472004",
  9178. PsnNo: "44020000001101329945",
  9179. Info: "2207",
  9180. }
  9181. customData = append(customData, custom)
  9182. custom1 := &CustomData{
  9183. MsgId: "H4402290015820210330172057803",
  9184. PsnNo: "44020000001101161813",
  9185. Info: "2207",
  9186. }
  9187. customData = append(customData, custom1)
  9188. custom2 := &CustomData{
  9189. MsgId: "H44022900158202103301705198813",
  9190. PsnNo: "44190000133097375417",
  9191. Info: "2207",
  9192. }
  9193. customData = append(customData, custom2)
  9194. custom3 := &CustomData{
  9195. MsgId: "H44022900158202103301715524756",
  9196. PsnNo: "44020000001100187221",
  9197. Info: "2207",
  9198. }
  9199. customData = append(customData, custom3)
  9200. custom4 := &CustomData{
  9201. MsgId: "H44022900158202103301730376224",
  9202. PsnNo: "44020000001101959155",
  9203. Info: "2207",
  9204. }
  9205. customData = append(customData, custom4)
  9206. custom5 := &CustomData{
  9207. MsgId: "H44022900158202103301748008725",
  9208. PsnNo: "44020000001104246641",
  9209. Info: "2207",
  9210. }
  9211. customData = append(customData, custom5)
  9212. custom6 := &CustomData{
  9213. MsgId: "H44022900158202103301718096755",
  9214. PsnNo: "44020000001102211860",
  9215. Info: "2207",
  9216. }
  9217. customData = append(customData, custom6)
  9218. custom7 := &CustomData{
  9219. MsgId: "H44022900158202103301736551640",
  9220. PsnNo: "44020000001102687718",
  9221. Info: "2207",
  9222. }
  9223. customData = append(customData, custom7)
  9224. custom8 := &CustomData{
  9225. MsgId: "H44022900158202103301743097676",
  9226. PsnNo: "44020000001102127785",
  9227. Info: "2207",
  9228. }
  9229. customData = append(customData, custom8)
  9230. custom9 := &CustomData{
  9231. MsgId: "H44022900158202103301712304203",
  9232. PsnNo: "44020000001101518097",
  9233. Info: "2207",
  9234. }
  9235. customData = append(customData, custom9)
  9236. custom10 := &CustomData{
  9237. MsgId: "H44022900158202103301738448785",
  9238. PsnNo: "44020000001100500813",
  9239. Info: "2207",
  9240. }
  9241. customData = append(customData, custom10)
  9242. custom11 := &CustomData{
  9243. MsgId: "H44022900158202103301732455843",
  9244. PsnNo: "44020000001102690557",
  9245. Info: "2207",
  9246. }
  9247. customData = append(customData, custom11)
  9248. custom12 := &CustomData{
  9249. MsgId: "H44022900158202103301745421708",
  9250. PsnNo: "44020000001102211928",
  9251. Info: "2207",
  9252. }
  9253. customData = append(customData, custom12)
  9254. custom1212 := &CustomData{
  9255. MsgId: "H440229001582021033017351627",
  9256. PsnNo: "44020000001102481733",
  9257. Info: "2207",
  9258. }
  9259. customData = append(customData, custom1212)
  9260. custom13 := &CustomData{
  9261. MsgId: "H44022900158202103301740327951",
  9262. PsnNo: "44020000001103174866",
  9263. Info: "2207",
  9264. }
  9265. customData = append(customData, custom13)
  9266. custom14 := &CustomData{
  9267. MsgId: "H4402290015820210330174922668",
  9268. PsnNo: "44020000001102927272",
  9269. Info: "2207",
  9270. }
  9271. customData = append(customData, custom14)
  9272. custom15 := &CustomData{
  9273. MsgId: "H44022900158202103301752362273",
  9274. PsnNo: "44020000001102942890",
  9275. Info: "2207",
  9276. }
  9277. customData = append(customData, custom15)
  9278. custom16 := &CustomData{
  9279. MsgId: "H44022900158202103301751082917",
  9280. PsnNo: "44020000001101662162",
  9281. Info: "2207",
  9282. }
  9283. customData = append(customData, custom16)
  9284. custom17 := &CustomData{
  9285. MsgId: "H44022900158202103301754147728",
  9286. PsnNo: "44020000000229014511",
  9287. Info: "2207",
  9288. }
  9289. customData = append(customData, custom17)
  9290. adminUser := c.GetAdminUserInfo()
  9291. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9292. for _, item := range customData {
  9293. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9294. fmt.Println(result)
  9295. }
  9296. }
  9297. func (c *HisApiController) GetAllopatry() {
  9298. year := c.GetString("year")
  9299. month := c.GetString("month")
  9300. admin_user_id, _ := c.GetInt64("admin_user_id")
  9301. adminUser := c.GetAdminUserInfo()
  9302. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9303. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9304. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9305. var dat map[string]interface{}
  9306. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9307. fmt.Println(dat)
  9308. } else {
  9309. fmt.Println(err)
  9310. }
  9311. userJSONBytes, _ := json.Marshal(dat)
  9312. var res models.Result9001
  9313. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9314. utils.ErrorLog("解析失败:%v", err)
  9315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9316. return
  9317. }
  9318. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9319. var dat2 map[string]interface{}
  9320. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9321. fmt.Println(dat)
  9322. } else {
  9323. fmt.Println(err)
  9324. }
  9325. userJSONBytes2, _ := json.Marshal(dat2)
  9326. var res2 models.Result3260
  9327. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9328. utils.ErrorLog("解析失败:%v", err)
  9329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9330. return
  9331. }
  9332. if res2.Infcode == 0 {
  9333. c.ServeSuccessJSON(map[string]interface{}{
  9334. "list": res2.Output.Data,
  9335. })
  9336. return
  9337. } else {
  9338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9339. return
  9340. }
  9341. }
  9342. func (c *HisApiController) ComfirmAllopatry() {
  9343. year := c.GetString("year")
  9344. month := c.GetString("month")
  9345. admin_user_id, _ := c.GetInt64("admin_user_id")
  9346. adminUser := c.GetAdminUserInfo()
  9347. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9348. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9349. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9350. var dat map[string]interface{}
  9351. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9352. fmt.Println(dat)
  9353. } else {
  9354. fmt.Println(err)
  9355. }
  9356. userJSONBytes, _ := json.Marshal(dat)
  9357. var res models.Result9001
  9358. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9359. utils.ErrorLog("解析失败:%v", err)
  9360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9361. return
  9362. }
  9363. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9364. var dat2 map[string]interface{}
  9365. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9366. fmt.Println(dat)
  9367. } else {
  9368. fmt.Println(err)
  9369. }
  9370. userJSONBytes2, _ := json.Marshal(dat2)
  9371. var res2 models.Result3260
  9372. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9373. utils.ErrorLog("解析失败:%v", err)
  9374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9375. return
  9376. }
  9377. if res2.Infcode == 0 {
  9378. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  9379. var dat map[string]interface{}
  9380. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9381. fmt.Println(dat)
  9382. } else {
  9383. fmt.Println(err)
  9384. }
  9385. userJSONBytes, _ := json.Marshal(dat)
  9386. var res3 models.Result3261
  9387. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  9388. utils.ErrorLog("解析失败:%v", err)
  9389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9390. return
  9391. }
  9392. if res3.Infcode == 0 {
  9393. record := &models.HisYidiClearRecord{
  9394. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9395. Ctime: time.Now().Unix(),
  9396. Mtime: time.Now().Unix(),
  9397. Status: 1,
  9398. MsgId: msgId,
  9399. }
  9400. service.SaveClearRecord(record)
  9401. c.ServeSuccessJSON(map[string]interface{}{
  9402. "msg": "提取成功",
  9403. })
  9404. }
  9405. }
  9406. }
  9407. func (c *HisApiController) RefundAllopatry() {
  9408. year := c.GetString("year")
  9409. month := c.GetString("month")
  9410. id, _ := c.GetInt64("id")
  9411. admin_user_id, _ := c.GetInt64("admin_user_id")
  9412. adminUser := c.GetAdminUserInfo()
  9413. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9414. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9415. record, _ := service.GetClearRecordById(id)
  9416. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  9417. var dat map[string]interface{}
  9418. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9419. fmt.Println(dat)
  9420. } else {
  9421. fmt.Println(err)
  9422. }
  9423. userJSONBytes, _ := json.Marshal(dat)
  9424. var empty ResultFourteen
  9425. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  9426. utils.ErrorLog("解析失败:%v", err)
  9427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9428. return
  9429. }
  9430. if empty.Infcode == 0 {
  9431. c.ServeSuccessJSON(map[string]interface{}{
  9432. "msg": "撤销成功",
  9433. })
  9434. return
  9435. }
  9436. }
  9437. func (c *HisApiController) ReversalOtherData() {
  9438. var customData []*CustomData
  9439. custom := &CustomData{
  9440. MsgId: "H44022900158202103301714472004",
  9441. PsnNo: "44020000001101329945",
  9442. Info: "2208",
  9443. }
  9444. customData = append(customData, custom)
  9445. custom1 := &CustomData{
  9446. MsgId: "H4402290015820210330172057803",
  9447. PsnNo: "44020000001101161813",
  9448. Info: "2208",
  9449. }
  9450. customData = append(customData, custom1)
  9451. custom2 := &CustomData{
  9452. MsgId: "H44022900158202103301705198813",
  9453. PsnNo: "44190000133097375417",
  9454. Info: "2208",
  9455. }
  9456. customData = append(customData, custom2)
  9457. custom3 := &CustomData{
  9458. MsgId: "H44022900158202103301715524756",
  9459. PsnNo: "44020000001100187221",
  9460. Info: "2208",
  9461. }
  9462. customData = append(customData, custom3)
  9463. custom4 := &CustomData{
  9464. MsgId: "H44022900158202103301730376224",
  9465. PsnNo: "44020000001101959155",
  9466. Info: "2208",
  9467. }
  9468. customData = append(customData, custom4)
  9469. custom5 := &CustomData{
  9470. MsgId: "H44022900158202103301748008725",
  9471. PsnNo: "44020000001104246641",
  9472. Info: "2208",
  9473. }
  9474. customData = append(customData, custom5)
  9475. custom6 := &CustomData{
  9476. MsgId: "H44022900158202103301718096755",
  9477. PsnNo: "44020000001102211860",
  9478. Info: "2208",
  9479. }
  9480. customData = append(customData, custom6)
  9481. custom7 := &CustomData{
  9482. MsgId: "H44022900158202103301736551640",
  9483. PsnNo: "44020000001102687718",
  9484. Info: "2208",
  9485. }
  9486. customData = append(customData, custom7)
  9487. custom8 := &CustomData{
  9488. MsgId: "H44022900158202103301743097676",
  9489. PsnNo: "44020000001102127785",
  9490. Info: "2208",
  9491. }
  9492. customData = append(customData, custom8)
  9493. custom9 := &CustomData{
  9494. MsgId: "H44022900158202103301712304203",
  9495. PsnNo: "44020000001101518097",
  9496. Info: "2208",
  9497. }
  9498. customData = append(customData, custom9)
  9499. custom10 := &CustomData{
  9500. MsgId: "H44022900158202103301738448785",
  9501. PsnNo: "44020000001100500813",
  9502. Info: "2208",
  9503. }
  9504. customData = append(customData, custom10)
  9505. custom11 := &CustomData{
  9506. MsgId: "H44022900158202103301732455843",
  9507. PsnNo: "44020000001102690557",
  9508. Info: "2208",
  9509. }
  9510. customData = append(customData, custom11)
  9511. custom12 := &CustomData{
  9512. MsgId: "H44022900158202103301745421708",
  9513. PsnNo: "44020000001102211928",
  9514. Info: "2208",
  9515. }
  9516. customData = append(customData, custom12)
  9517. custom1212 := &CustomData{
  9518. MsgId: "H440229001582021033017351627",
  9519. PsnNo: "44020000001102481733",
  9520. Info: "2208",
  9521. }
  9522. customData = append(customData, custom1212)
  9523. custom13 := &CustomData{
  9524. MsgId: "H44022900158202103301740327951",
  9525. PsnNo: "44020000001103174866",
  9526. Info: "2208",
  9527. }
  9528. customData = append(customData, custom13)
  9529. custom14 := &CustomData{
  9530. MsgId: "H4402290015820210330174922668",
  9531. PsnNo: "44020000001102927272",
  9532. Info: "2208",
  9533. }
  9534. customData = append(customData, custom14)
  9535. custom15 := &CustomData{
  9536. MsgId: "H44022900158202103301752362273",
  9537. PsnNo: "44020000001102942890",
  9538. Info: "2208",
  9539. }
  9540. customData = append(customData, custom15)
  9541. custom16 := &CustomData{
  9542. MsgId: "H44022900158202103301751082917",
  9543. PsnNo: "44020000001101662162",
  9544. Info: "2208",
  9545. }
  9546. customData = append(customData, custom16)
  9547. custom17 := &CustomData{
  9548. MsgId: "H44022900158202103301754147728",
  9549. PsnNo: "44020000000229014511",
  9550. Info: "2208",
  9551. }
  9552. customData = append(customData, custom17)
  9553. adminUser := c.GetAdminUserInfo()
  9554. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9555. for _, item := range customData {
  9556. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9557. fmt.Println(result)
  9558. }
  9559. }
  9560. func PathExists(path string) (bool, error) {
  9561. _, err := os.Stat(path)
  9562. if err == nil {
  9563. return true, nil
  9564. }
  9565. if os.IsNotExist(err) {
  9566. return false, nil
  9567. }
  9568. return false, err
  9569. }
  9570. //创建文件夹
  9571. func Mkdir(dir string) {
  9572. // 创建文件夹
  9573. exist, err := PathExists(dir)
  9574. if err != nil {
  9575. fmt.Println(err.Error())
  9576. } else {
  9577. if exist {
  9578. fmt.Println(dir + "文件夹已存在!")
  9579. } else {
  9580. // 文件夹名称,权限
  9581. err := os.Mkdir(dir, os.ModePerm)
  9582. if err != nil {
  9583. fmt.Println(dir+"文件夹创建失败:", err.Error())
  9584. } else {
  9585. fmt.Println(dir + "文件夹创建成功!")
  9586. }
  9587. }
  9588. }
  9589. }
  9590. //压缩文件
  9591. func Zip(srcFile string, destZip string) error {
  9592. zipfile, err := os.Create(destZip)
  9593. if err != nil {
  9594. return err
  9595. }
  9596. defer zipfile.Close()
  9597. archive := zip.NewWriter(zipfile)
  9598. defer archive.Close()
  9599. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  9600. if err != nil {
  9601. return err
  9602. }
  9603. header, err := zip.FileInfoHeader(info)
  9604. if err != nil {
  9605. return err
  9606. }
  9607. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  9608. // header.Name = path
  9609. if info.IsDir() {
  9610. header.Name += "/"
  9611. } else {
  9612. header.Method = zip.Deflate
  9613. }
  9614. writer, err := archive.CreateHeader(header)
  9615. if err != nil {
  9616. return err
  9617. }
  9618. if !info.IsDir() {
  9619. file, err := os.Open(path)
  9620. if err != nil {
  9621. return err
  9622. }
  9623. defer file.Close()
  9624. _, err = io.Copy(writer, file)
  9625. }
  9626. return err
  9627. })
  9628. return err
  9629. }
  9630. func ReadFile(filePath string) []byte {
  9631. f, err := os.Open(filePath)
  9632. if err != nil {
  9633. fmt.Println("read file fail", err)
  9634. return nil
  9635. }
  9636. defer f.Close()
  9637. fd, err := ioutil.ReadAll(f)
  9638. if err != nil {
  9639. fmt.Println("read to fd fail", err)
  9640. return nil
  9641. }
  9642. return fd
  9643. }
  9644. func saveLog(result string, request string, infno string, desc string) {
  9645. org_id, _ := beego.AppConfig.Int64("org_id")
  9646. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  9647. dir := miConfig.OrgName + "日志"
  9648. utils.Mkdir(dir)
  9649. month := time.Unix(1557042972, 0).Format("1")
  9650. year := time.Now().Format("2006")
  9651. month = time.Now().Format("01")
  9652. day := time.Now().Format("02")
  9653. hour := time.Now().Format("15")
  9654. min := time.Now().Format("04")
  9655. sec := time.Now().Format("05")
  9656. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  9657. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  9658. file_name := file + ".txt"
  9659. file_path := miConfig.OrgName + "日志" + "/" + file_name
  9660. exist, _ := utils.PathExists(file_path)
  9661. if exist { //存在
  9662. fmt.Println("存在")
  9663. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  9664. if err != nil {
  9665. fmt.Println("read fail")
  9666. }
  9667. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  9668. n, _ := f.Seek(0, 2)
  9669. _, err = f.WriteAt([]byte(content), n)
  9670. } else { //不存在
  9671. fmt.Println("文件不存在,创建文件")
  9672. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  9673. defer f.Close()
  9674. if err != nil {
  9675. } else {
  9676. _, err = f.Write([]byte("记录日志"))
  9677. }
  9678. }
  9679. }
  9680. type Charset string
  9681. const (
  9682. UTF8 = Charset("UTF-8")
  9683. GB18030 = Charset("GB18030")
  9684. )
  9685. func ConvertToString(src string, srcCode string, tagCode string) string {
  9686. srcCoder := mahonia.NewDecoder(srcCode)
  9687. srcResult := srcCoder.ConvertString(src)
  9688. tagCoder := mahonia.NewDecoder(tagCode)
  9689. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  9690. result := string(cdata)
  9691. return result
  9692. }