his_api_controller.go 444KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156
  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/shopspring/decimal"
  15. "io"
  16. "io/ioutil"
  17. "math/rand"
  18. "net/http"
  19. "os"
  20. "path/filepath"
  21. "strconv"
  22. "strings"
  23. "syscall"
  24. "time"
  25. "unsafe"
  26. )
  27. type HisApiController struct {
  28. controllers.BaseAuthAPIController
  29. }
  30. func HisManagerApiRegistRouters() {
  31. //挂号
  32. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  33. //上传就诊信息-上传明细-结算
  34. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  35. //查询
  36. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  37. //对总账
  38. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  39. //对明细
  40. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  41. //退费,退明细
  42. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  43. //退号
  44. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  45. //退明细
  46. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  47. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  48. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  49. //beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  52. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  53. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  54. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  55. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  56. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  57. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  58. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  59. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  60. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  61. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  62. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  63. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  64. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  65. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  66. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  67. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  68. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  69. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  70. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  71. beego.Router("/api/check", &HisApiController{}, "get:Check")
  72. beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  73. beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  74. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  75. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  76. beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  77. }
  78. func (c *HisApiController) Get9001() {
  79. adminUser := c.GetAdminUserInfo()
  80. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  81. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  82. result, inputLog := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  83. var dat map[string]interface{}
  84. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  85. fmt.Println(dat)
  86. } else {
  87. fmt.Println(err)
  88. }
  89. userJSONBytes, _ := json.Marshal(dat)
  90. var res models.Result9001
  91. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  92. utils.ErrorLog("解析失败:%v", err)
  93. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  94. return
  95. }
  96. if res.Infcode == 0 {
  97. sign := models.HisSignIn{
  98. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  99. SignNo: res.Output.Result.SignNo,
  100. SignTime: res.Output.Result.SignTime,
  101. Ctime: time.Now().Unix(),
  102. Mtime: time.Now().Unix(),
  103. Status: 1,
  104. InputLog: inputLog,
  105. OutputLog: result,
  106. }
  107. err := service.CreateSignIn(&sign)
  108. if err == nil {
  109. c.ServeSuccessJSON(map[string]interface{}{
  110. "msg": "签到成功",
  111. })
  112. }
  113. }
  114. }
  115. func (c *HisApiController) Check3101() {
  116. patient_id, _ := c.GetInt64("patient_id")
  117. his_patient_id, _ := c.GetInt64("his_patient_id")
  118. admin_user_id, _ := c.GetInt64("admin_user_id")
  119. adminUser := c.GetAdminUserInfo()
  120. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  121. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  122. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  123. record_time := c.GetString("record_time")
  124. trig_scen := c.GetString("trig_scen")
  125. timeLayout := "2006-01-02"
  126. loc, _ := time.LoadLocation("Local")
  127. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  128. if err != nil {
  129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  130. return
  131. }
  132. recordDateTime := theTime.Unix()
  133. var patientPrescription models.HisPrescriptionInfo
  134. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  135. if patientPrescription.ID == 0 {
  136. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  137. }
  138. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  139. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  140. //
  141. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  142. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  143. var pp models.PublicParams
  144. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  145. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  146. pp.FixmedinsName = miConfig.OrgName
  147. pp.FixmedinsCode = miConfig.Code
  148. pp.RequestUrl = miConfig.Url
  149. pp.Cainfo = miConfig.Cainfo
  150. pp.SecretKey = miConfig.SecretKey
  151. pp.AccessKey = miConfig.AccessKey
  152. pp.OpterName = roles.UserName
  153. var config []*models.HisXtDiagnoseConfig
  154. for _, item := range diagnosis_ids {
  155. id, _ := strconv.ParseInt(item, 10, 64)
  156. diagnosisConfig, _ := service.FindDiagnoseById(id)
  157. config = append(config, &diagnosisConfig)
  158. }
  159. var pd models.PatientDtos
  160. pd.PatnID = his.PsnNo
  161. pd.PatnName = his.Name
  162. pd.Gend = his.Gend
  163. pd.Brdy = his.Brdy
  164. pd.Poolarea = his.InsuplcAdmdvs
  165. pd.CurrMdtrtID = his.Number
  166. var fed models.FsiEncounterDtos
  167. fed.MdtrtID = his.Number
  168. fed.MedinsID = miConfig.Code
  169. fed.MedinsName = miConfig.OrgName
  170. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  171. fed.MedMdtrtType = "1"
  172. fed.MedinsType = "1"
  173. fed.MedinsLv = "11"
  174. tm := time.Unix(his.RecordDate, 0)
  175. s_tm := tm.Format("2006-01-02 15:04:05")
  176. fed.AdmDate = s_tm
  177. fed.DscgDate = s_tm
  178. fed.DscgMainDiseCodg = config[0].CountryCode
  179. fed.DscgMainDiseName = config[0].CountryContentName
  180. //诊断信息
  181. var fdds []*models.FsiDiagnoseDtos
  182. for index, item := range config {
  183. if index == 0 {
  184. var fdd models.FsiDiagnoseDtos
  185. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  186. fdd.InoutDiseType = "1"
  187. fdd.MaindiseFlag = "1"
  188. fdd.DiseDate = s_tm
  189. fdd.DiasSrtNo = "1"
  190. fdd.DiseName = item.CountryContentName
  191. fdd.DiseCodg = item.CountryCode
  192. fdds = append(fdds, &fdd)
  193. } else {
  194. var fdd models.FsiDiagnoseDtos
  195. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  196. fdd.InoutDiseType = "1"
  197. fdd.MaindiseFlag = "1"
  198. fdd.DiseDate = s_tm
  199. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  200. fdd.DiseName = item.CountryContentName
  201. fdd.DiseCodg = item.CountryCode
  202. fdds = append(fdds, &fdd)
  203. }
  204. }
  205. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  206. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  207. fed.AdmDeptName = department.Name
  208. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  209. fed.DscgDeptName = department.Name
  210. fed.MedMdtrtType = "1"
  211. fed.MedType = "11"
  212. //if his.Insutype == "390" {
  213. // fed.MedType = "1402"
  214. //} else {
  215. // fed.MedType = "9933"
  216. //}
  217. var orders []*models.FsiOrderDtos
  218. if trig_scen == "2" {
  219. //处方医嘱信息
  220. for _, item := range prescriptions {
  221. for _, subItem := range item.HisDoctorAdviceInfo {
  222. var order models.FsiOrderDtos
  223. order.RxID = strconv.FormatInt(item.ID, 10)
  224. order.Rxno = strconv.FormatInt(item.ID, 10)
  225. order.LongDrordFlag = "0"
  226. order.HilistType = "1"
  227. order.ChrgType = "1"
  228. order.DrordBhvr = "-"
  229. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  230. order.HosplistName = subItem.BaseDrugLib.DrugName
  231. order.HilistLv = "1"
  232. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  233. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  234. order.HosplistName = subItem.BaseDrugLib.DrugName
  235. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  236. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  237. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  238. order.OwnpayAmt = ""
  239. order.SelfpayAmt = ""
  240. order.Spec = ""
  241. order.SpecUnt = ""
  242. order.DrordBegnDate = s_tm
  243. order.DrordStopDate = ""
  244. order.DrordDrCodg = "1"
  245. order.DrordDeptName = department.Name
  246. order.DrordDrCodg = "1"
  247. order.DrordDrName = doctor_info.UserName
  248. order.DrordDrProfttl = ""
  249. order.CurrDrordFlag = "1"
  250. orders = append(orders, &order)
  251. }
  252. for _, subItem := range item.HisPrescriptionProject {
  253. if subItem.Type == 2 {
  254. var order models.FsiOrderDtos
  255. order.RxID = strconv.FormatInt(item.ID, 10)
  256. order.Rxno = strconv.FormatInt(item.ID, 10)
  257. order.LongDrordFlag = "0"
  258. order.HilistType = "1"
  259. order.ChrgType = "1"
  260. order.DrordBhvr = "-"
  261. order.HilistCode = subItem.HisProject.MedicalCode
  262. order.HosplistName = subItem.HisProject.ProjectName
  263. order.HilistLv = "1"
  264. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  265. order.HosplistCode = subItem.HisProject.MedicalCode
  266. order.HosplistName = subItem.HisProject.ProjectName
  267. order.Cnt = subItem.Count
  268. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  269. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  270. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  271. order.OwnpayAmt = ""
  272. order.SelfpayAmt = ""
  273. order.Spec = ""
  274. order.SpecUnt = ""
  275. order.DrordBegnDate = s_tm
  276. order.DrordStopDate = ""
  277. order.DrordDrCodg = "1"
  278. order.DrordDeptName = department.Name
  279. order.DrordDrCodg = "1"
  280. order.DrordDrName = doctor_info.UserName
  281. order.DrordDrProfttl = ""
  282. order.CurrDrordFlag = "1"
  283. orders = append(orders, &order)
  284. }
  285. if subItem.Type == 3 {
  286. var order models.FsiOrderDtos
  287. order.RxID = strconv.FormatInt(item.ID, 10)
  288. order.Rxno = strconv.FormatInt(item.ID, 10)
  289. order.LongDrordFlag = "0"
  290. order.HilistType = "1"
  291. order.ChrgType = "1"
  292. order.DrordBhvr = "-"
  293. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  294. order.HosplistName = subItem.GoodInfo.GoodName
  295. order.HilistLv = "1"
  296. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  297. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  298. order.HosplistName = subItem.GoodInfo.GoodName
  299. order.Cnt = subItem.Count
  300. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  301. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  302. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  303. order.OwnpayAmt = ""
  304. order.SelfpayAmt = ""
  305. order.Spec = ""
  306. order.SpecUnt = ""
  307. order.DrordBegnDate = s_tm
  308. order.DrordStopDate = ""
  309. order.DrordDrCodg = "1"
  310. order.DrordDeptName = department.Name
  311. order.DrordDrCodg = "1"
  312. order.DrordDrName = doctor_info.UserName
  313. order.DrordDrProfttl = ""
  314. order.CurrDrordFlag = "1"
  315. orders = append(orders, &order)
  316. }
  317. }
  318. }
  319. //处方医嘱信息
  320. }
  321. fed.MatnStas = "0"
  322. fed.MedfeeSumamt = "0"
  323. fed.OwnpayAmt = "0"
  324. fed.SelfpayAmt = "0"
  325. fed.AcctPayamt = "0"
  326. fed.MaAmt = "0"
  327. fed.HifpPayamt = "0"
  328. fed.SetlTotlnum = "1"
  329. fed.Insutype = his.Insutype
  330. fed.ReimFlag = "0"
  331. fed.OutSetlFlag = "0"
  332. var fopd []*models.FsiOperationDtosData
  333. data := make(map[string]interface{})
  334. data["fed"] = fed
  335. data["fdd"] = fdds
  336. data["fod"] = orders
  337. data["pd"] = pd
  338. data["pp"] = pp
  339. data["fopd"] = fopd
  340. data["trig_scen"] = trig_scen
  341. fmt.Println(data)
  342. fmt.Println(fed)
  343. fmt.Println(fdds)
  344. fmt.Println(orders)
  345. fmt.Println(pd)
  346. fmt.Println(pp)
  347. fmt.Println(fopd)
  348. client := &http.Client{}
  349. bytesData, _ := json.Marshal(data)
  350. var req *http.Request
  351. if miConfig.MdtrtareaAdmvs == "320921" {
  352. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  353. } else {
  354. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  355. }
  356. resp, _ := client.Do(req)
  357. defer resp.Body.Close()
  358. body, ioErr := ioutil.ReadAll(resp.Body)
  359. if ioErr != nil {
  360. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  362. return
  363. }
  364. var respJSON map[string]interface{}
  365. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  368. return
  369. }
  370. //手术操作集合
  371. //手术操作集合
  372. }
  373. func (c *HisApiController) Check3102() {
  374. patient_id, _ := c.GetInt64("patient_id")
  375. order_id, _ := c.GetInt64("order_id")
  376. his_patient_id, _ := c.GetInt64("his_patient_id")
  377. admin_user_id, _ := c.GetInt64("admin_user_id")
  378. trig_scen := c.GetString("trig_scen")
  379. adminUser := c.GetAdminUserInfo()
  380. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  381. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  382. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  383. record_time := c.GetString("record_time")
  384. order, _ := service.GetHisOrderByID(order_id)
  385. timeLayout := "2006-01-02"
  386. loc, _ := time.LoadLocation("Local")
  387. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  388. if err != nil {
  389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  390. return
  391. }
  392. recordDateTime := theTime.Unix()
  393. var patientPrescription models.HisPrescriptionInfo
  394. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  395. if patientPrescription.ID == 0 {
  396. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  397. }
  398. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  399. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  400. //
  401. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  402. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  403. var pp models.PublicParams
  404. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  405. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  406. pp.FixmedinsName = miConfig.OrgName
  407. pp.FixmedinsCode = miConfig.Code
  408. pp.RequestUrl = miConfig.Url
  409. pp.Cainfo = miConfig.Cainfo
  410. pp.SecretKey = miConfig.SecretKey
  411. pp.AccessKey = miConfig.AccessKey
  412. pp.OpterName = roles.UserName
  413. var config []*models.HisXtDiagnoseConfig
  414. for _, item := range diagnosis_ids {
  415. id, _ := strconv.ParseInt(item, 10, 64)
  416. diagnosisConfig, _ := service.FindDiagnoseById(id)
  417. config = append(config, &diagnosisConfig)
  418. }
  419. var pd models.PatientDtos
  420. pd.PatnID = his.PsnNo
  421. pd.PatnName = his.Name
  422. pd.Gend = his.Gend
  423. pd.Brdy = his.Brdy
  424. pd.Poolarea = his.InsuplcAdmdvs
  425. pd.CurrMdtrtID = his.Number
  426. var fed models.FsiEncounterDtos
  427. fed.MdtrtID = his.Number
  428. fed.MedinsID = miConfig.Code
  429. fed.MedinsName = miConfig.OrgName
  430. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  431. fed.MedMdtrtType = "1"
  432. fed.MedinsType = "1"
  433. fed.MedinsLv = "11"
  434. tm := time.Unix(his.RecordDate, 0)
  435. s_tm := tm.Format("2006-01-02 15:04:05")
  436. fed.AdmDate = s_tm
  437. fed.DscgDate = s_tm
  438. fed.DscgMainDiseCodg = config[0].CountryCode
  439. fed.DscgMainDiseName = config[0].CountryContentName
  440. //诊断信息
  441. var fdds []*models.FsiDiagnoseDtos
  442. for index, item := range config {
  443. if index == 0 {
  444. var fdd models.FsiDiagnoseDtos
  445. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  446. fdd.InoutDiseType = "1"
  447. fdd.MaindiseFlag = "1"
  448. fdd.DiseDate = s_tm
  449. fdd.DiasSrtNo = "1"
  450. fdd.DiseName = item.CountryContentName
  451. fdd.DiseCodg = item.CountryCode
  452. fdds = append(fdds, &fdd)
  453. } else {
  454. var fdd models.FsiDiagnoseDtos
  455. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  456. fdd.InoutDiseType = "1"
  457. fdd.MaindiseFlag = "1"
  458. fdd.DiseDate = s_tm
  459. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  460. fdd.DiseName = item.CountryContentName
  461. fdd.DiseCodg = item.CountryCode
  462. fdds = append(fdds, &fdd)
  463. }
  464. }
  465. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  466. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  467. fed.AdmDeptName = department.Name
  468. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  469. fed.DscgDeptName = department.Name
  470. fed.MedType = order.MedType
  471. //处方医嘱信息
  472. var orders []*models.FsiOrderDtos
  473. //for _, item := range prescriptions {
  474. // for _, subItem := range item.HisDoctorAdviceInfo {
  475. // var order models.FsiOrderDtos
  476. // order.RxID = strconv.FormatInt(item.ID, 10)
  477. // order.Rxno = strconv.FormatInt(item.ID, 10)
  478. // order.LongDrordFlag = "0"
  479. // order.HilistType = "1"
  480. // order.ChrgType = "1"
  481. // order.DrordBhvr = "-"
  482. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  483. // order.HosplistName = subItem.BaseDrugLib.DrugName
  484. // order.HilistLv = "1"
  485. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  486. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  487. // order.HosplistName = subItem.BaseDrugLib.DrugName
  488. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  489. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  490. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  491. // order.OwnpayAmt = ""
  492. // order.SelfpayAmt = ""
  493. // order.Spec = ""
  494. // order.SpecUnt = ""
  495. // order.DrordBegnDate = s_tm
  496. // order.DrordStopDate = ""
  497. // order.DrordDrCodg = "1"
  498. // order.DrordDeptName = department.Name
  499. // order.DrordDrCodg = "1"
  500. // order.DrordDrName = doctor_info.UserName
  501. // order.DrordDrProfttl = ""
  502. // order.CurrDrordFlag = "1"
  503. // orders = append(orders, &order)
  504. // }
  505. // for _, subItem := range item.HisPrescriptionProject {
  506. // if subItem.Type == 2 {
  507. // var order models.FsiOrderDtos
  508. // order.RxID = strconv.FormatInt(item.ID, 10)
  509. // order.Rxno = strconv.FormatInt(item.ID, 10)
  510. // order.LongDrordFlag = "0"
  511. // order.HilistType = "1"
  512. // order.ChrgType = "1"
  513. // order.DrordBhvr = "-"
  514. // order.HilistCode = subItem.HisProject.MedicalCode
  515. // order.HosplistName = subItem.HisProject.ProjectName
  516. // order.HilistLv = "1"
  517. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  518. // order.HosplistCode = subItem.HisProject.MedicalCode
  519. // order.HosplistName = subItem.HisProject.ProjectName
  520. // order.Cnt = subItem.Count
  521. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  522. //
  523. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  524. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  525. // order.OwnpayAmt = ""
  526. // order.SelfpayAmt = ""
  527. // order.Spec = ""
  528. // order.SpecUnt = ""
  529. // order.DrordBegnDate = s_tm
  530. // order.DrordStopDate = ""
  531. // order.DrordDrCodg = "1"
  532. // order.DrordDeptName = department.Name
  533. // order.DrordDrCodg = "1"
  534. // order.DrordDrName = doctor_info.UserName
  535. // order.DrordDrProfttl = ""
  536. // order.CurrDrordFlag = "1"
  537. // orders = append(orders, &order)
  538. //
  539. // }
  540. // if subItem.Type == 3 {
  541. //
  542. // var order models.FsiOrderDtos
  543. // order.RxID = strconv.FormatInt(item.ID, 10)
  544. // order.Rxno = strconv.FormatInt(item.ID, 10)
  545. // order.LongDrordFlag = "0"
  546. // order.HilistType = "1"
  547. // order.ChrgType = "1"
  548. // order.DrordBhvr = "-"
  549. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  550. // order.HosplistName = subItem.GoodInfo.GoodName
  551. // order.HilistLv = "1"
  552. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  553. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  554. // order.HosplistName = subItem.GoodInfo.GoodName
  555. // order.Cnt = subItem.Count
  556. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  557. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  558. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  559. // order.OwnpayAmt = ""
  560. // order.SelfpayAmt = ""
  561. // order.Spec = ""
  562. // order.SpecUnt = ""
  563. // order.DrordBegnDate = s_tm
  564. // order.DrordStopDate = ""
  565. // order.DrordDrCodg = "1"
  566. // order.DrordDeptName = department.Name
  567. // order.DrordDrCodg = "1"
  568. // order.DrordDrName = doctor_info.UserName
  569. // order.DrordDrProfttl = ""
  570. // order.CurrDrordFlag = "1"
  571. // orders = append(orders, &order)
  572. //
  573. // }
  574. // }
  575. //}
  576. for _, item := range prescriptions {
  577. for _, subItem := range item.HisDoctorAdviceInfo {
  578. var order models.FsiOrderDtos
  579. order.RxID = strconv.FormatInt(item.ID, 10)
  580. order.Rxno = strconv.FormatInt(item.ID, 10)
  581. order.LongDrordFlag = "0"
  582. order.HilistType = "1"
  583. order.ChrgType = "1"
  584. order.DrordBhvr = "-"
  585. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  586. order.HosplistName = subItem.BaseDrugLib.DrugName
  587. order.HilistLv = "1"
  588. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  589. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  590. order.HosplistName = subItem.BaseDrugLib.DrugName
  591. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  592. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  593. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  594. order.OwnpayAmt = ""
  595. order.SelfpayAmt = ""
  596. order.Spec = ""
  597. order.SpecUnt = ""
  598. order.DrordBegnDate = s_tm
  599. order.DrordStopDate = ""
  600. order.DrordDrCodg = "1"
  601. order.DrordDeptName = department.Name
  602. order.DrordDrCodg = "1"
  603. order.DrordDrName = doctor_info.UserName
  604. order.DrordDrProfttl = ""
  605. order.CurrDrordFlag = "1"
  606. orders = append(orders, &order)
  607. }
  608. for _, subItem := range item.HisPrescriptionProject {
  609. if subItem.Type == 2 {
  610. var order models.FsiOrderDtos
  611. order.RxID = strconv.FormatInt(item.ID, 10)
  612. order.Rxno = strconv.FormatInt(item.ID, 10)
  613. order.LongDrordFlag = "0"
  614. order.HilistType = "1"
  615. order.ChrgType = "1"
  616. order.DrordBhvr = "-"
  617. order.HilistCode = subItem.HisProject.MedicalCode
  618. order.HosplistName = subItem.HisProject.ProjectName
  619. order.HilistLv = "1"
  620. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  621. order.HosplistCode = subItem.HisProject.MedicalCode
  622. order.HosplistName = subItem.HisProject.ProjectName
  623. order.Cnt = subItem.Count
  624. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  625. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  626. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  627. order.OwnpayAmt = ""
  628. order.SelfpayAmt = ""
  629. order.Spec = ""
  630. order.SpecUnt = ""
  631. order.DrordBegnDate = s_tm
  632. order.DrordStopDate = ""
  633. order.DrordDrCodg = "1"
  634. order.DrordDeptName = department.Name
  635. order.DrordDrCodg = "1"
  636. order.DrordDrName = doctor_info.UserName
  637. order.DrordDrProfttl = ""
  638. order.CurrDrordFlag = "1"
  639. orders = append(orders, &order)
  640. }
  641. if subItem.Type == 3 {
  642. var order models.FsiOrderDtos
  643. order.RxID = strconv.FormatInt(item.ID, 10)
  644. order.Rxno = strconv.FormatInt(item.ID, 10)
  645. order.LongDrordFlag = "0"
  646. order.HilistType = "1"
  647. order.ChrgType = "1"
  648. order.DrordBhvr = "-"
  649. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  650. order.HosplistName = subItem.GoodInfo.GoodName
  651. order.HilistLv = "1"
  652. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  653. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  654. order.HosplistName = subItem.GoodInfo.GoodName
  655. order.Cnt = subItem.Count
  656. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  657. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  658. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  659. order.OwnpayAmt = ""
  660. order.SelfpayAmt = ""
  661. order.Spec = ""
  662. order.SpecUnt = ""
  663. order.DrordBegnDate = s_tm
  664. order.DrordStopDate = ""
  665. order.DrordDrCodg = "1"
  666. order.DrordDeptName = department.Name
  667. order.DrordDrCodg = "1"
  668. order.DrordDrName = doctor_info.UserName
  669. order.DrordDrProfttl = ""
  670. order.CurrDrordFlag = "1"
  671. orders = append(orders, &order)
  672. }
  673. }
  674. }
  675. //处方医嘱信息
  676. fed.MatnStas = "0"
  677. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  678. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  679. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  680. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  681. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  682. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  683. fed.SetlTotlnum = "1"
  684. fed.Insutype = his.Insutype
  685. fed.ReimFlag = "0"
  686. fed.OutSetlFlag = "0"
  687. var fopd []*models.FsiOperationDtosData
  688. data := make(map[string]interface{})
  689. data["fed"] = fed
  690. data["fdd"] = fdds
  691. data["fod"] = orders
  692. data["pd"] = pd
  693. data["pp"] = pp
  694. data["fopd"] = fopd
  695. data["trig_scen"] = trig_scen
  696. client := &http.Client{}
  697. bytesData, _ := json.Marshal(data)
  698. var req *http.Request
  699. if miConfig.MdtrtareaAdmvs == "320921" {
  700. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  701. } else {
  702. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  703. }
  704. resp, _ := client.Do(req)
  705. defer resp.Body.Close()
  706. body, ioErr := ioutil.ReadAll(resp.Body)
  707. if ioErr != nil {
  708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  710. return
  711. }
  712. var respJSON map[string]interface{}
  713. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  716. return
  717. }
  718. //手术操作集合
  719. //手术操作集合
  720. }
  721. func (c *HisApiController) Check() {
  722. psn_no := c.GetString("psn_no")
  723. in := c.GetString("in")
  724. mt := c.GetString("mt")
  725. baseParams := models.BaseParams{
  726. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  727. FixmedinsCode: "H15049901371",
  728. InsuplcAdmdvs: "150499",
  729. MdtrtareaAdmvs: "150499",
  730. OrgName: "赤峰费森血液透析中心",
  731. Doctor: "1111",
  732. }
  733. service.Gdyb2001(baseParams, psn_no, in, mt)
  734. }
  735. func (c *HisApiController) GetPsnNcdsInfo() {
  736. admin_user_id, _ := c.GetInt64("admin_user_id")
  737. patient_id, _ := c.GetInt64("patient_id")
  738. id, _ := c.GetInt64("id")
  739. adminUser := c.GetAdminUserInfo()
  740. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  741. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  742. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  743. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  744. psn_record, _ := service.GetPsnNCDSRecordById(id)
  745. //
  746. //if psn_record.ID == 0 {
  747. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  748. // return
  749. //}
  750. var res Result5301
  751. var res10265 Result5301For10265
  752. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  753. psn_info, _ := service.GetPsnByPatientId(patient_id)
  754. var api string
  755. if miConfig.MdtrtareaAdmvs == "320921" {
  756. 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 +
  757. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  758. } else {
  759. 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 +
  760. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  761. }
  762. resp, requestErr := http.Get(api)
  763. if requestErr != nil {
  764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  765. return
  766. }
  767. body, ioErr := ioutil.ReadAll(resp.Body)
  768. if ioErr != nil {
  769. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  771. return
  772. }
  773. var respJSON map[string]interface{}
  774. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  775. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  777. return
  778. }
  779. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  780. result, _ := json.Marshal(respJSON)
  781. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  782. utils.ErrorLog("解析失败:%v", err)
  783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  784. return
  785. }
  786. res.ErrMsg = res10265.ErrMsg
  787. res.Output = res10265.Output
  788. res.InfRefmsgid = res10265.InfRefmsgid
  789. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  790. res.Infcode = infocode
  791. } else {
  792. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  793. var dat map[string]interface{}
  794. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  795. fmt.Println(dat)
  796. } else {
  797. fmt.Println(err)
  798. }
  799. userJSONBytes, _ := json.Marshal(dat)
  800. if miConfig.Code == "H15049901371" {
  801. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  802. utils.ErrorLog("解析失败:%v", err)
  803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  804. return
  805. }
  806. res.InfRefmsgid = res10265.InfRefmsgid
  807. res.Output = res10265.Output
  808. res.ErrMsg = res10265.ErrMsg
  809. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  810. res.Infcode = infocode
  811. } else {
  812. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  813. utils.ErrorLog("解析失败:%v", err)
  814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  815. return
  816. }
  817. }
  818. }
  819. if res.Infcode == 0 {
  820. c.ServeSuccessJSON(map[string]interface{}{
  821. "result": res.Output.Result,
  822. })
  823. }
  824. }
  825. func (c *HisApiController) CheckInsutype() {
  826. his_patient_id, _ := c.GetInt64("his_patient_id")
  827. admin_user_id, _ := c.GetInt64("admin_user_id")
  828. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  829. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  830. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  831. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  832. var dat map[string]interface{}
  833. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  834. fmt.Println(dat)
  835. } else {
  836. fmt.Println(err)
  837. }
  838. userJSONBytes, _ := json.Marshal(dat)
  839. var res Result90100
  840. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  841. utils.ErrorLog("解析失败:%v", err)
  842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  843. return
  844. }
  845. if res.Infcode != 0 {
  846. c.ServeSuccessJSON(map[string]interface{}{
  847. "failed_code": -10,
  848. "msg": res.ErrMsg,
  849. })
  850. return
  851. } else {
  852. fmt.Println(res)
  853. }
  854. }
  855. func (c *HisApiController) CheckCardPWD() {
  856. card_pwd := c.GetString("card_pwd")
  857. his_patient_id, _ := c.GetInt64("his_patient_id")
  858. admin_user_id, _ := c.GetInt64("admin_user_id")
  859. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  860. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  861. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  862. psn, _ := service.GetPsnByPatientId(his.PatientId)
  863. bas := strings.Split(psn.CardInfo, "|")
  864. basNumber := bas[2]
  865. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  866. var dat map[string]interface{}
  867. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  868. fmt.Println(dat)
  869. } else {
  870. fmt.Println(err)
  871. }
  872. userJSONBytes, _ := json.Marshal(dat)
  873. var res Result90991
  874. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  875. utils.ErrorLog("解析失败:%v", err)
  876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  877. return
  878. }
  879. if res.Infcode != 0 {
  880. c.ServeSuccessJSON(map[string]interface{}{
  881. "failed_code": -10,
  882. "msg": res.ErrMsg,
  883. })
  884. return
  885. } else {
  886. if res.Output.Result.SscnoCheckStat == "0" {
  887. var msg string
  888. switch res.Output.Result.CardStat {
  889. case "00":
  890. msg = "未激活"
  891. break
  892. case "10":
  893. msg = "激活"
  894. break
  895. case "20":
  896. msg = "窗口挂失"
  897. break
  898. case "21":
  899. msg = "电话挂失"
  900. break
  901. case "22":
  902. msg = "单位网上申报挂失"
  903. break
  904. case "23":
  905. msg = "保健办挂失"
  906. break
  907. case "24":
  908. msg = "个人网上挂失"
  909. break
  910. case "25":
  911. msg = "网上服务大厅挂失"
  912. break
  913. case "30":
  914. msg = "注销"
  915. break
  916. case "40":
  917. msg = "回收"
  918. break
  919. case "99":
  920. msg = "制卡中(无效卡)"
  921. break
  922. }
  923. c.ServeSuccessJSON(map[string]interface{}{
  924. "failed_code": -10,
  925. "msg": msg,
  926. })
  927. return
  928. } else {
  929. c.ServeSuccessJSON(map[string]interface{}{
  930. "msg": "校验成功",
  931. })
  932. return
  933. }
  934. }
  935. }
  936. func (c *HisApiController) CheckCardPWDTwo() {
  937. //card_pwd := c.GetString("card_pwd")
  938. //his_patient_id, _ := c.GetInt64("his_patient_id")
  939. admin_user_id, _ := c.GetInt64("admin_user_id")
  940. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  941. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  942. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  943. var dat map[string]interface{}
  944. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  945. fmt.Println(dat)
  946. } else {
  947. fmt.Println(err)
  948. }
  949. userJSONBytes, _ := json.Marshal(dat)
  950. var res Result90991
  951. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  952. utils.ErrorLog("解析失败:%v", err)
  953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  954. return
  955. }
  956. if res.Infcode != 0 {
  957. c.ServeSuccessJSON(map[string]interface{}{
  958. "failed_code": -10,
  959. "msg": res.ErrMsg,
  960. })
  961. return
  962. } else {
  963. if res.Output.Result.SscnoCheckStat == "0" {
  964. var msg string
  965. switch res.Output.Result.CardStat {
  966. case "00":
  967. msg = "未激活"
  968. break
  969. case "10":
  970. msg = "激活"
  971. break
  972. case "20":
  973. msg = "窗口挂失"
  974. break
  975. case "21":
  976. msg = "电话挂失"
  977. break
  978. case "22":
  979. msg = "单位网上申报挂失"
  980. break
  981. case "23":
  982. msg = "保健办挂失"
  983. break
  984. case "24":
  985. msg = "个人网上挂失"
  986. break
  987. case "25":
  988. msg = "网上服务大厅挂失"
  989. break
  990. case "30":
  991. msg = "注销"
  992. break
  993. case "40":
  994. msg = "回收"
  995. break
  996. case "99":
  997. msg = "制卡中(无效卡)"
  998. break
  999. }
  1000. c.ServeSuccessJSON(map[string]interface{}{
  1001. "failed_code": -10,
  1002. "msg": msg,
  1003. })
  1004. return
  1005. } else {
  1006. c.ServeSuccessJSON(map[string]interface{}{
  1007. "msg": "校验成功",
  1008. })
  1009. return
  1010. }
  1011. }
  1012. }
  1013. //func (c *HisApiController) ReadCard() {
  1014. // id_card_type, _ := c.GetInt64("id_card_type")
  1015. // admin_user_id, _ := c.GetInt64("admin_user_id")
  1016. // certificates, _ := c.GetInt64("certificates")
  1017. // fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1018. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1019. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1020. //
  1021. // switch id_card_type {
  1022. // case 1:
  1023. // if miConfig.MdtrtareaAdmvs == "421300" {
  1024. // var res ResultTwo
  1025. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1026. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1027. // "&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)
  1028. //
  1029. // resp, requestErr := http.Get(api)
  1030. // if requestErr != nil {
  1031. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1032. // return
  1033. // }
  1034. //
  1035. // body, ioErr := ioutil.ReadAll(resp.Body)
  1036. // if ioErr != nil {
  1037. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1038. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1039. // return
  1040. // }
  1041. // var respJSON map[string]interface{}
  1042. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1043. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1044. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1045. // return
  1046. // }
  1047. //
  1048. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1049. // result, _ := json.Marshal(respJSON)
  1050. // fmt.Println("log")
  1051. // fmt.Println(string(result))
  1052. //
  1053. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  1054. // utils.ErrorLog("解析失败:%v", err)
  1055. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1056. // return
  1057. // }
  1058. //
  1059. // if res.Infcode == 0 {
  1060. // patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1061. // if err == gorm.ErrRecordNotFound {
  1062. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1063. // return
  1064. // } else if err != nil {
  1065. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1066. // return
  1067. //
  1068. // } else {
  1069. //
  1070. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1071. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1072. // infoStr := string(Iinfos)
  1073. // idetinfoStr := string(Idetinfos)
  1074. // psn := &models.HisPsn{
  1075. // PsnNo: res.Output.Baseinfo.PsnNo,
  1076. // Age: res.Output.Baseinfo.Age,
  1077. // PatientId: patient.ID,
  1078. // Certno: res.Output.Baseinfo.Certno,
  1079. // Brdy: res.Output.Baseinfo.Brdy,
  1080. // Gend: res.Output.Baseinfo.Gend,
  1081. // Naty: res.Output.Baseinfo.Naty,
  1082. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1083. // PsnName: res.Output.Baseinfo.PsnName,
  1084. // Idetinfo: idetinfoStr,
  1085. // Insuinfo: infoStr,
  1086. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1087. // }
  1088. // service.CreateHisPsn(psn)
  1089. //
  1090. // c.ServeSuccessJSON(map[string]interface{}{
  1091. // "patient": patient,
  1092. // "number": res.Output.Baseinfo.Certno,
  1093. // })
  1094. // }
  1095. // } else {
  1096. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1097. // return
  1098. // }
  1099. //
  1100. // } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1101. // var api string
  1102. // if miConfig.MdtrtareaAdmvs == "320921" {
  1103. // 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 +
  1104. // "&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
  1105. // fmt.Println(api)
  1106. // } else {
  1107. // 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 +
  1108. // "&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)
  1109. // }
  1110. //
  1111. // resp, requestErr := http.Get(api)
  1112. // if requestErr != nil {
  1113. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1114. // return
  1115. // }
  1116. //
  1117. // body, ioErr := ioutil.ReadAll(resp.Body)
  1118. // if ioErr != nil {
  1119. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1120. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1121. // return
  1122. // }
  1123. // var respJSON map[string]interface{}
  1124. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1125. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1126. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1127. // return
  1128. // }
  1129. // var status string
  1130. // status = respJSON["data"].(map[string]interface{})["status"].(string)
  1131. // card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1132. // //console.log()
  1133. // fmt.Println("type===")
  1134. //
  1135. // fmt.Println(card_type)
  1136. //
  1137. // var token string
  1138. // var res ResultTwo //1101结果
  1139. // var res10265 ResultTwo10265 //1101结果
  1140. // var card_info string //卡信息
  1141. // var busi_card_info string
  1142. //
  1143. // card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1144. // busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1145. //
  1146. // if status == "0" { //读卡成功
  1147. // if card_type == "1" {
  1148. //
  1149. // respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1150. // result, _ := json.Marshal(respJSON)
  1151. //
  1152. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1153. // utils.ErrorLog("解析失败:%v", err)
  1154. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1155. // return
  1156. // }
  1157. // res.ErrMsg = res10265.ErrMsg
  1158. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1159. // res.Infcode = infocode
  1160. // res.Output = res10265.Output
  1161. // res.InfRefmsgid = res10265.InfRefmsgid
  1162. //
  1163. // } else {
  1164. // //var card_info string //卡信息
  1165. // //var busi_card_info string
  1166. //
  1167. // token = respJSON["data"].(map[string]interface{})["token"].(string)
  1168. // //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1169. //
  1170. // //fmt.Println(card_info)
  1171. // //fmt.Println(busi_card_info)
  1172. //
  1173. // respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1174. // result, _ := json.Marshal(respJSON)
  1175. //
  1176. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1177. // utils.ErrorLog("解析失败:%v", err)
  1178. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1179. // return
  1180. // }
  1181. // res.ErrMsg = res10265.ErrMsg
  1182. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1183. // res.Infcode = infocode
  1184. // res.Output = res10265.Output
  1185. // res.InfRefmsgid = res10265.InfRefmsgid
  1186. //
  1187. // }
  1188. //
  1189. // if res.Infcode == 0 {
  1190. // patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1191. // if err == gorm.ErrRecordNotFound {
  1192. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1193. // return
  1194. // } else if err != nil {
  1195. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1196. // return
  1197. //
  1198. // } else {
  1199. //
  1200. // if card_type == "1" {
  1201. // bas := strings.Split(card_info, "|")
  1202. // basNumber := bas[2]
  1203. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1204. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1205. // infoStr := string(Iinfos)
  1206. // idetinfoStr := string(Idetinfos)
  1207. // psn := &models.HisPsn{
  1208. // PsnNo: res.Output.Baseinfo.PsnNo,
  1209. // Age: res.Output.Baseinfo.Age,
  1210. // PatientId: patient.ID,
  1211. // Certno: res.Output.Baseinfo.Certno,
  1212. // Brdy: res.Output.Baseinfo.Brdy,
  1213. // Gend: res.Output.Baseinfo.Gend,
  1214. // Naty: res.Output.Baseinfo.Naty,
  1215. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1216. // PsnName: res.Output.Baseinfo.PsnName,
  1217. // Idetinfo: idetinfoStr,
  1218. // Insuinfo: infoStr,
  1219. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1220. // CardInfo: card_info,
  1221. // VerifyNumber: busi_card_info,
  1222. // }
  1223. // service.CreateHisPsn(psn)
  1224. //
  1225. // var rf []*ResultFive
  1226. // json.Unmarshal([]byte(infoStr), &rf)
  1227. //
  1228. // var insutypes []*ResultFive
  1229. // var insutype string
  1230. // var is390 int = 0
  1231. // var is310 int = 0
  1232. //
  1233. // for _, item := range rf {
  1234. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1235. // insutypes = append(insutypes, item)
  1236. // }
  1237. // }
  1238. //
  1239. // if len(insutypes) == 1 {
  1240. // insutype = insutypes[0].Insutype
  1241. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1242. // } else {
  1243. // for _, i := range insutypes {
  1244. // if i.Insutype == "390" {
  1245. // is390 = 1
  1246. // }
  1247. //
  1248. // if i.Insutype == "310" {
  1249. // is310 = 1
  1250. // }
  1251. // }
  1252. // }
  1253. // if is390 == 1 {
  1254. // insutype = "390"
  1255. // }
  1256. //
  1257. // if is310 == 1 {
  1258. // insutype = "310"
  1259. // }
  1260. //
  1261. // if len(insutypes) == 0 {
  1262. // insutype = "310"
  1263. // }
  1264. //
  1265. // c.ServeSuccessJSON(map[string]interface{}{
  1266. // "patient": patient,
  1267. // "number": basNumber,
  1268. // "insutype": insutype,
  1269. // })
  1270. // } else {
  1271. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1272. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1273. // infoStr := string(Iinfos)
  1274. // idetinfoStr := string(Idetinfos)
  1275. // psn := &models.HisPsn{
  1276. // PsnNo: res.Output.Baseinfo.PsnNo,
  1277. // Age: res.Output.Baseinfo.Age,
  1278. // PatientId: patient.ID,
  1279. // Certno: res.Output.Baseinfo.Certno,
  1280. // Brdy: res.Output.Baseinfo.Brdy,
  1281. // Gend: res.Output.Baseinfo.Gend,
  1282. // Naty: res.Output.Baseinfo.Naty,
  1283. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1284. // PsnName: res.Output.Baseinfo.PsnName,
  1285. // Idetinfo: idetinfoStr,
  1286. // Insuinfo: infoStr,
  1287. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1288. // CardInfo: card_info,
  1289. // VerifyNumber: token,
  1290. // }
  1291. // service.CreateHisPsn(psn)
  1292. // c.ServeSuccessJSON(map[string]interface{}{
  1293. // "patient": patient,
  1294. // "number": token,
  1295. // })
  1296. // }
  1297. // }
  1298. // } else {
  1299. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1300. // return
  1301. // }
  1302. // } else { //读卡失败
  1303. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1304. // return
  1305. //
  1306. // }
  1307. //
  1308. // } else {
  1309. // if initFlag == 0 {
  1310. // c.TestGetBasBaseInit()
  1311. // }
  1312. // basStr := c.GetBasBaseInfo()
  1313. // if len(basStr) == 0 {
  1314. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1315. // return
  1316. // }
  1317. // fmt.Println(basStr)
  1318. // bas := strings.Split(basStr, "|")
  1319. // basNumber := bas[1]
  1320. // fmt.Println(basNumber)
  1321. // card_sn := bas[3]
  1322. // fmt.Println(card_sn)
  1323. // result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1324. // var dat map[string]interface{}
  1325. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1326. // fmt.Println(dat)
  1327. // } else {
  1328. // fmt.Println(err)
  1329. // }
  1330. //
  1331. // userJSONBytes, _ := json.Marshal(dat)
  1332. // var res ResultTwo
  1333. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1334. // utils.ErrorLog("解析失败:%v", err)
  1335. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1336. // return
  1337. // }
  1338. //
  1339. // if res.Infcode == 0 {
  1340. // patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1341. // if err == gorm.ErrRecordNotFound {
  1342. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1343. // return
  1344. // } else if err != nil {
  1345. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1346. // return
  1347. //
  1348. // } else {
  1349. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1350. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1351. // infoStr := string(Iinfos)
  1352. // idetinfoStr := string(Idetinfos)
  1353. // psn := &models.HisPsn{
  1354. // PsnNo: res.Output.Baseinfo.PsnNo,
  1355. // Age: res.Output.Baseinfo.Age,
  1356. // PatientId: patient.ID,
  1357. // Certno: res.Output.Baseinfo.Certno,
  1358. // Brdy: res.Output.Baseinfo.Brdy,
  1359. // Gend: res.Output.Baseinfo.Gend,
  1360. // Naty: res.Output.Baseinfo.Naty,
  1361. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1362. // PsnName: res.Output.Baseinfo.PsnName,
  1363. // Idetinfo: idetinfoStr,
  1364. // Insuinfo: infoStr,
  1365. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1366. // CardInfo: basStr,
  1367. // VerifyNumber: "",
  1368. // }
  1369. // service.CreateHisPsn(psn)
  1370. //
  1371. // c.ServeSuccessJSON(map[string]interface{}{
  1372. // "patient": patient,
  1373. // "number": basNumber,
  1374. // })
  1375. // }
  1376. // } else {
  1377. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1378. // return
  1379. // }
  1380. // break
  1381. // }
  1382. // case 2:
  1383. // SFZStr := c.GetSFZBaseInfo()
  1384. // id_card_str := strings.Split(SFZStr, "^")
  1385. // id_card_number := id_card_str[0]
  1386. // card_sn := ""
  1387. // result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1388. // var dat map[string]interface{}
  1389. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1390. // fmt.Println(dat)
  1391. // } else {
  1392. // fmt.Println(err)
  1393. // }
  1394. //
  1395. // userJSONBytes, _ := json.Marshal(dat)
  1396. // var res ResultTwo
  1397. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1398. // utils.ErrorLog("解析失败:%v", err)
  1399. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1400. // return
  1401. // }
  1402. //
  1403. // if res.Infcode == 0 {
  1404. // patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1405. // if err == gorm.ErrRecordNotFound {
  1406. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1407. // return
  1408. // } else if err != nil {
  1409. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1410. // return
  1411. //
  1412. // } else {
  1413. // c.ServeSuccessJSON(map[string]interface{}{
  1414. // "patient": patient,
  1415. // "number": id_card_number,
  1416. // })
  1417. // }
  1418. // } else {
  1419. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1420. // return
  1421. // }
  1422. //
  1423. // break
  1424. // case 3:
  1425. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1426. // var api string
  1427. // if miConfig.MdtrtareaAdmvs == "320921" {
  1428. // 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 +
  1429. // "&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
  1430. // fmt.Println(api)
  1431. //
  1432. // } else {
  1433. // 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 +
  1434. // "&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)
  1435. // }
  1436. //
  1437. // resp, requestErr := http.Get(api)
  1438. // if requestErr != nil {
  1439. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1440. // return
  1441. // }
  1442. //
  1443. // body, ioErr := ioutil.ReadAll(resp.Body)
  1444. // if ioErr != nil {
  1445. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1446. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1447. // return
  1448. // }
  1449. // var respJSON map[string]interface{}
  1450. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1451. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1452. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1453. // return
  1454. // }
  1455. // var status string
  1456. // status = respJSON["data"].(map[string]interface{})["status"].(string)
  1457. // card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1458. //
  1459. // var token string
  1460. // var res ResultTwo //1101结果
  1461. // var res10265 ResultTwo10265 //1101结果
  1462. // var card_info string //卡信息
  1463. // var busi_card_info string
  1464. //
  1465. // //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1466. // busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1467. //
  1468. // if status == "0" { //读卡成功
  1469. // if card_type == "1" {
  1470. //
  1471. // respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1472. // result, _ := json.Marshal(respJSON)
  1473. //
  1474. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1475. // utils.ErrorLog("解析失败:%v", err)
  1476. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1477. // return
  1478. // }
  1479. // res.ErrMsg = res10265.ErrMsg
  1480. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1481. // res.Infcode = infocode
  1482. // res.Output = res10265.Output
  1483. // res.InfRefmsgid = res10265.InfRefmsgid
  1484. //
  1485. // } else {
  1486. // //var card_info string //卡信息
  1487. // //var busi_card_info string
  1488. //
  1489. // token = respJSON["data"].(map[string]interface{})["token"].(string)
  1490. // //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1491. //
  1492. // //fmt.Println(card_info)
  1493. // //fmt.Println(busi_card_info)
  1494. //
  1495. // respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1496. // result, _ := json.Marshal(respJSON)
  1497. //
  1498. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1499. // utils.ErrorLog("解析失败:%v", err)
  1500. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1501. // return
  1502. // }
  1503. // res.ErrMsg = res10265.ErrMsg
  1504. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1505. // res.Infcode = infocode
  1506. // res.Output = res10265.Output
  1507. // res.InfRefmsgid = res10265.InfRefmsgid
  1508. //
  1509. // }
  1510. //
  1511. // if res.Infcode == 0 {
  1512. // patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1513. // if err == gorm.ErrRecordNotFound {
  1514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1515. // return
  1516. // } else if err != nil {
  1517. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1518. // return
  1519. //
  1520. // } else {
  1521. //
  1522. // if card_type == "1" {
  1523. // bas := strings.Split(card_info, "|")
  1524. // basNumber := bas[2]
  1525. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1526. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1527. // infoStr := string(Iinfos)
  1528. // idetinfoStr := string(Idetinfos)
  1529. // psn := &models.HisPsn{
  1530. // PsnNo: res.Output.Baseinfo.PsnNo,
  1531. // Age: res.Output.Baseinfo.Age,
  1532. // PatientId: patient.ID,
  1533. // Certno: res.Output.Baseinfo.Certno,
  1534. // Brdy: res.Output.Baseinfo.Brdy,
  1535. // Gend: res.Output.Baseinfo.Gend,
  1536. // Naty: res.Output.Baseinfo.Naty,
  1537. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1538. // PsnName: res.Output.Baseinfo.PsnName,
  1539. // Idetinfo: idetinfoStr,
  1540. // Insuinfo: infoStr,
  1541. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1542. // CardInfo: card_info,
  1543. // VerifyNumber: busi_card_info,
  1544. // }
  1545. //
  1546. // service.CreateHisPsn(psn)
  1547. // c.ServeSuccessJSON(map[string]interface{}{
  1548. // "patient": patient,
  1549. // "number": basNumber,
  1550. // })
  1551. // } else {
  1552. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1553. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1554. // infoStr := string(Iinfos)
  1555. // idetinfoStr := string(Idetinfos)
  1556. // psn := &models.HisPsn{
  1557. // PsnNo: res.Output.Baseinfo.PsnNo,
  1558. // Age: res.Output.Baseinfo.Age,
  1559. // PatientId: patient.ID,
  1560. // Certno: res.Output.Baseinfo.Certno,
  1561. // Brdy: res.Output.Baseinfo.Brdy,
  1562. // Gend: res.Output.Baseinfo.Gend,
  1563. // Naty: res.Output.Baseinfo.Naty,
  1564. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1565. // PsnName: res.Output.Baseinfo.PsnName,
  1566. // Idetinfo: idetinfoStr,
  1567. // Insuinfo: infoStr,
  1568. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1569. // CardInfo: card_info,
  1570. // VerifyNumber: token,
  1571. // }
  1572. // service.CreateHisPsn(psn)
  1573. // var rf []*ResultFive
  1574. // json.Unmarshal([]byte(infoStr), &rf)
  1575. // var insutypes []*ResultFive
  1576. // var insutype string
  1577. // var is390 int = 0
  1578. // var is310 int = 0
  1579. //
  1580. // for _, item := range rf {
  1581. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1582. // insutypes = append(insutypes, item)
  1583. // }
  1584. // }
  1585. //
  1586. // if len(insutypes) == 1 {
  1587. // insutype = insutypes[0].Insutype
  1588. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1589. // } else {
  1590. // for _, i := range insutypes {
  1591. // if i.Insutype == "390" {
  1592. // is390 = 1
  1593. // }
  1594. //
  1595. // if i.Insutype == "310" {
  1596. // is310 = 1
  1597. // }
  1598. // }
  1599. // }
  1600. //
  1601. // if is390 == 1 {
  1602. // insutype = "390"
  1603. // }
  1604. //
  1605. // if is310 == 1 {
  1606. // insutype = "310"
  1607. // }
  1608. //
  1609. // if len(insutypes) == 0 {
  1610. // insutype = "310"
  1611. // }
  1612. // c.ServeSuccessJSON(map[string]interface{}{
  1613. // "patient": patient,
  1614. // "number": token,
  1615. // "insutype": insutype,
  1616. // })
  1617. // }
  1618. // }
  1619. // } else {
  1620. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1621. // return
  1622. // }
  1623. // } else { //读卡失败
  1624. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1625. // return
  1626. //
  1627. // }
  1628. //
  1629. // }
  1630. //
  1631. // break
  1632. // case 4:
  1633. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1634. // var api string
  1635. // if miConfig.MdtrtareaAdmvs == "320921" {
  1636. // 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 +
  1637. // "&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
  1638. // fmt.Println(api)
  1639. //
  1640. // } else {
  1641. // 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 +
  1642. // "&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)
  1643. // }
  1644. //
  1645. // resp, requestErr := http.Get(api)
  1646. // if requestErr != nil {
  1647. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1648. // return
  1649. // }
  1650. //
  1651. // body, ioErr := ioutil.ReadAll(resp.Body)
  1652. // if ioErr != nil {
  1653. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1654. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1655. // return
  1656. // }
  1657. // var respJSON map[string]interface{}
  1658. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1659. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1660. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1661. // return
  1662. // }
  1663. // var status string
  1664. // status = respJSON["data"].(map[string]interface{})["status"].(string)
  1665. // //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1666. //
  1667. // var token string
  1668. // var res ResultTwo //1101结果
  1669. // var res10265 ResultTwo10265 //1101结果
  1670. //
  1671. // if status == "0" { //读卡成功
  1672. // var card_info string //卡信息
  1673. // var busi_card_info string
  1674. //
  1675. // token = respJSON["data"].(map[string]interface{})["token"].(string)
  1676. // busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1677. // card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1678. //
  1679. // fmt.Println(card_info)
  1680. // fmt.Println(busi_card_info)
  1681. //
  1682. // respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1683. // result, _ := json.Marshal(respJSON)
  1684. //
  1685. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1686. // utils.ErrorLog("解析失败:%v", err)
  1687. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1688. // return
  1689. // }
  1690. // res.ErrMsg = res10265.ErrMsg
  1691. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1692. // res.Infcode = infocode
  1693. // res.Output = res10265.Output
  1694. // res.InfRefmsgid = res10265.InfRefmsgid
  1695. //
  1696. // if res.Infcode == 0 {
  1697. // patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1698. // if err == gorm.ErrRecordNotFound {
  1699. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1700. // return
  1701. // } else if err != nil {
  1702. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1703. // return
  1704. //
  1705. // } else {
  1706. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1707. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1708. // infoStr := string(Iinfos)
  1709. // idetinfoStr := string(Idetinfos)
  1710. // psn := &models.HisPsn{
  1711. // PsnNo: res.Output.Baseinfo.PsnNo,
  1712. // Age: res.Output.Baseinfo.Age,
  1713. // PatientId: patient.ID,
  1714. // Certno: res.Output.Baseinfo.Certno,
  1715. // Brdy: res.Output.Baseinfo.Brdy,
  1716. // Gend: res.Output.Baseinfo.Gend,
  1717. // Naty: res.Output.Baseinfo.Naty,
  1718. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1719. // PsnName: res.Output.Baseinfo.PsnName,
  1720. // Idetinfo: idetinfoStr,
  1721. // Insuinfo: infoStr,
  1722. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1723. // CardInfo: card_info,
  1724. // VerifyNumber: token,
  1725. // }
  1726. // service.CreateHisPsn(psn)
  1727. // c.ServeSuccessJSON(map[string]interface{}{
  1728. // "patient": patient,
  1729. // "number": token,
  1730. // })
  1731. // }
  1732. // } else {
  1733. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1734. // return
  1735. // }
  1736. // } else { //读卡失败
  1737. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1738. // return
  1739. // }
  1740. // }
  1741. // break
  1742. // }
  1743. //}
  1744. var initFlag int64 = 0
  1745. //func (c *HisApiController) TestGetBasBaseInit() {
  1746. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  1747. // Iinit := DllDef.MustFindProc("Init")
  1748. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1749. //
  1750. // ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1751. // if ret != 0 {
  1752. // fmt.Println("SSCard的报错原因:", err)
  1753. // fmt.Println("SSCard的运算结果为:", ret)
  1754. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1755. // return
  1756. // }
  1757. //
  1758. // result := int(ret)
  1759. // fmt.Println("SSCard的运算结果为1:", result)
  1760. // initFlag = 1
  1761. // return
  1762. //}
  1763. //func (c *HisApiController) GetSFZBaseInfo() string {
  1764. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  1765. // readCard := DllDef.MustFindProc("ReadSFZ")
  1766. // if readCard == nil {
  1767. // fmt.Println("readcard is nil")
  1768. // readCard = DllDef.MustFindProc("ReadSFZ")
  1769. // }
  1770. //
  1771. // str := make([]byte, 256)
  1772. // str1 := make([]byte, 256)
  1773. // r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1774. //
  1775. // fmt.Println(r)
  1776. // return string(str)
  1777. //}
  1778. //func (c *HisApiController) GetBasBaseInfo() string {
  1779. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  1780. // readCard := DllDef.MustFindProc("ReadCardBas")
  1781. // if readCard == nil {
  1782. // fmt.Println("readcard is nil")
  1783. // readCard = DllDef.MustFindProc("ReadCardBas")
  1784. // }
  1785. // str := make([]byte, 1024)
  1786. // str1 := make([]byte, 1024)
  1787. // ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1788. // fmt.Println(string(str1))
  1789. // fmt.Println(string(str))
  1790. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1791. // fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1792. // if ret2 != 0 {
  1793. // return ""
  1794. // }
  1795. // return string(str)
  1796. //}
  1797. type CustomFundPay struct {
  1798. FundPayType string `json:"fund_pay_type"`
  1799. FundPayamt float64 `json:"fund_payamt"`
  1800. }
  1801. func (c *HisApiController) GetSettleList() {
  1802. order_id, _ := c.GetInt64("order_id")
  1803. admin_user_id, _ := c.GetInt64("admin_user_id")
  1804. order, _ := service.GetHisOrderByIDTwo(order_id)
  1805. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1806. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1807. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1808. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1809. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1810. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1811. if order.ID == 0 {
  1812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1813. return
  1814. }
  1815. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1816. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1817. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1818. fmt.Println(count)
  1819. var zero string
  1820. number := count + 1
  1821. if number >= 1000 {
  1822. zero = "0000" + strconv.FormatInt(number, 10)
  1823. } else if number >= 10000 {
  1824. zero = "000" + strconv.FormatInt(number, 10)
  1825. } else if number >= 100000 {
  1826. zero = "00" + strconv.FormatInt(number, 10)
  1827. } else if number >= 1000000 {
  1828. zero = "0" + strconv.FormatInt(number, 10)
  1829. } else {
  1830. zero = strconv.FormatInt(number, 10)
  1831. }
  1832. fmt.Println(zero)
  1833. struct4101 := service.Struct4101{
  1834. PsnNo: order.PsnNo,
  1835. MdtrtId: order.MdtrtId,
  1836. SetlId: order.SetlId,
  1837. PsnName: order.PsnName,
  1838. Gend: order.Gend,
  1839. Brdy: his.Brdy,
  1840. Age: his.Age,
  1841. Naty: order.Naty,
  1842. PatnCertType: "01",
  1843. Certno: order.Certno,
  1844. Prfs: "90",
  1845. ConerName: roles[0].UserName,
  1846. PatnRlts: "99",
  1847. ConerAddr: miConfig.OrgName,
  1848. ConerTel: admin.Mobile,
  1849. HiType: order.Insutype,
  1850. Insuplc: miConfig.InsuplcAdmdvs,
  1851. MaindiagFlag: "1",
  1852. BillCode: last_order.FaPiaoCode,
  1853. BillNo: zero,
  1854. BizSn: order.Number,
  1855. PsnSelfPay: order.PsnPartAmt,
  1856. PsnOwnPay: order.PsnPartAmt,
  1857. AcctPay: order.AcctPay,
  1858. PsnCashpay: order.PsnCashPay,
  1859. HiPaymtd: "1",
  1860. Hsorg: miConfig.InsuplcAdmdvs,
  1861. HsorgOpter: miConfig.InsuplcAdmdvs,
  1862. MedinsFillPsn: curRoles.UserName,
  1863. MedinsFillDept: depart.Name,
  1864. IptMedType: "2",
  1865. }
  1866. struct4101.SetlBegnDate = order.SetlTime
  1867. struct4101.SetlEndDate = order.SetlTime
  1868. time_arr := strings.Split(order.SetlTime, " ")
  1869. struct4101.AdmTime = time_arr[0]
  1870. struct4101.AdmEndTime = time_arr[0]
  1871. var rf []CustomFundPay
  1872. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1873. var tempFunPays []service.CustomStruct
  1874. for _, item := range rf {
  1875. var tempFunPay service.CustomStruct
  1876. tempFunPay.FundPayamt = item.FundPayamt
  1877. tempFunPay.FundPayType = item.FundPayType
  1878. tempFunPays = append(tempFunPays, tempFunPay)
  1879. }
  1880. struct4101.CustomStruct = tempFunPays
  1881. var tempDiaginfos []service.DiaginfoStructTwo
  1882. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1883. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1884. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1885. var config []*models.HisXtDiagnoseConfig
  1886. for _, item := range diagnosis_ids {
  1887. id, _ := strconv.ParseInt(item, 10, 64)
  1888. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1889. config = append(config, &diagnosisConfig)
  1890. }
  1891. for index, item := range config {
  1892. if index == 0 {
  1893. var tempDiaginfo service.DiaginfoStructTwo
  1894. tempDiaginfo.DiagCode = item.CountryCode
  1895. tempDiaginfo.DiagName = item.CountryContentName
  1896. tempDiaginfo.DiagType = "1"
  1897. tempDiaginfo.MaindiagFlag = "1"
  1898. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1899. } else {
  1900. var tempDiaginfo service.DiaginfoStructTwo
  1901. tempDiaginfo.DiagCode = item.CountryCode
  1902. tempDiaginfo.DiagName = item.CountryContentName
  1903. tempDiaginfo.DiagType = "2"
  1904. tempDiaginfo.MaindiagFlag = "0"
  1905. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1906. }
  1907. }
  1908. struct4101.Diseinfo = tempDiaginfos
  1909. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1910. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1911. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1912. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  1913. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  1914. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1915. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1916. var iteminfo service.IteminfoStruct
  1917. var bedCostTotal float64 = 0 //床位总费
  1918. var bedCostSelfTotal float64 = 0 //床位自费
  1919. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1920. var operationCostTotal float64 = 0 //手术费
  1921. var operationCostSelfTotal float64 = 0 //手术费
  1922. var operationCostPartSelfTotal float64 = 0 //手术费
  1923. var otherCostTotal float64 = 0 //其他费用
  1924. var otherCostSelfTotal float64 = 0 //其他费用
  1925. var otherCostPartSelfTotal float64 = 0 //其他费用
  1926. var materialCostTotal float64 = 0 //材料费
  1927. var materialCostSelfTotal float64 = 0 //材料费
  1928. var materialCostPartSelfTotal float64 = 0 //材料费
  1929. var westernMedicineCostTotal float64 = 0 //西药费
  1930. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1931. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1932. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1933. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1934. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1935. var checkCostTotal float64 = 0 //检查费
  1936. var checkCostSelfTotal float64 = 0 //检查费
  1937. var checkCostPartSelfTotal float64 = 0 //检查费
  1938. var laboratoryCostTotal float64 = 0 //化验费
  1939. var laboratoryCostSelfTotal float64 = 0 //化验费
  1940. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1941. var treatCostTotal float64 = 0 //治疗费用
  1942. var treatCostSelfTotal float64 = 0 //治疗费用
  1943. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1944. decimal.DivisionPrecision = 2
  1945. var bed_fulamt_ownpay_amt float64 = 0
  1946. var operation_fulamt_ownpay_amt float64 = 0
  1947. var other_fulamt_ownpay_amt float64 = 0
  1948. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1949. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1950. var check_fulamt_ownpay_amt float64 = 0
  1951. var material_fulamt_ownpay_amt float64 = 0
  1952. var laboratory_fulamt_ownpay_amt float64 = 0
  1953. var treat_fulamt_ownpay_amt float64 = 0
  1954. var bed_claa_sunmfee float64 = 0
  1955. var bed_clab_amt float64 = 0
  1956. var bed_other_amt float64 = 0
  1957. var operation_claa_sunmfee float64 = 0
  1958. var operation_clab_amt float64 = 0
  1959. var operation_other_amt float64 = 0
  1960. var other_claa_sunmfee float64 = 0
  1961. var other_clab_amt float64 = 0
  1962. var other_other_amt float64 = 0
  1963. var westernMedicine_claa_sunmfee float64 = 0
  1964. var westernMedicine_clab_amt float64 = 0
  1965. var westernMedicine_other_amt float64 = 0
  1966. var chineseTraditional_claa_sunmfee float64 = 0
  1967. var chineseTraditional_clab_amt float64 = 0
  1968. var chineseTraditional_other_amt float64 = 0
  1969. var check_claa_sunmfee float64 = 0
  1970. var check_clab_amt float64 = 0
  1971. var check_other_amt float64 = 0
  1972. var material_claa_sunmfee float64 = 0
  1973. var material_clab_amt float64 = 0
  1974. var material_other_amt float64 = 0
  1975. var laboratory_claa_sunmfee float64 = 0
  1976. var laboratory_clab_amt float64 = 0
  1977. var laboratory_other_amt float64 = 0
  1978. var treat_claa_sunmfee float64 = 0
  1979. var treat_clab_amt float64 = 0
  1980. var treat_other_amt float64 = 0
  1981. for _, item := range order.HisOrderInfo {
  1982. if item.MedChrgitmType == "01" { //床位费
  1983. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1984. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1985. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1986. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1987. if item.ChrgitmLv == "1" {
  1988. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1989. }
  1990. if item.ChrgitmLv == "2" {
  1991. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1992. }
  1993. if item.ChrgitmLv == "3" {
  1994. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1995. }
  1996. }
  1997. if item.MedChrgitmType == "03" { //检查费
  1998. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1999. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2000. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2001. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2002. if item.ChrgitmLv == "1" {
  2003. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2004. }
  2005. if item.ChrgitmLv == "2" {
  2006. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2007. }
  2008. if item.ChrgitmLv == "3" {
  2009. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2010. }
  2011. }
  2012. if item.MedChrgitmType == "04" { //化验费
  2013. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2014. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2015. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2016. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2017. if item.ChrgitmLv == "1" {
  2018. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2019. }
  2020. if item.ChrgitmLv == "2" {
  2021. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2022. }
  2023. if item.ChrgitmLv == "3" {
  2024. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2025. }
  2026. }
  2027. if item.MedChrgitmType == "05" { //治疗费
  2028. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2029. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2030. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2031. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2032. if item.ChrgitmLv == "1" {
  2033. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2034. }
  2035. if item.ChrgitmLv == "2" {
  2036. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2037. }
  2038. if item.ChrgitmLv == "3" {
  2039. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2040. }
  2041. }
  2042. if item.MedChrgitmType == "06" { //手术费
  2043. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2044. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2045. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2046. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2047. if item.ChrgitmLv == "1" {
  2048. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2049. }
  2050. if item.ChrgitmLv == "2" {
  2051. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2052. }
  2053. if item.ChrgitmLv == "3" {
  2054. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2055. }
  2056. }
  2057. if item.MedChrgitmType == "08" { //材料费
  2058. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2059. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2060. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2061. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2062. if item.ChrgitmLv == "1" {
  2063. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2064. }
  2065. if item.ChrgitmLv == "2" {
  2066. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2067. }
  2068. if item.ChrgitmLv == "3" {
  2069. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2070. }
  2071. }
  2072. if item.MedChrgitmType == "09" { //西药费
  2073. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2074. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2075. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2076. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2077. if item.ChrgitmLv == "1" {
  2078. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2079. }
  2080. if item.ChrgitmLv == "2" {
  2081. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2082. }
  2083. if item.ChrgitmLv == "3" {
  2084. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2085. }
  2086. }
  2087. if item.MedChrgitmType == "11" { //中成费
  2088. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2089. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2090. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2091. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2092. if item.ChrgitmLv == "1" {
  2093. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2094. }
  2095. if item.ChrgitmLv == "2" {
  2096. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2097. }
  2098. if item.ChrgitmLv == "3" {
  2099. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2100. }
  2101. }
  2102. if item.MedChrgitmType == "14" { //其他费
  2103. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2104. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2105. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2106. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2107. if item.ChrgitmLv == "1" {
  2108. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2109. }
  2110. if item.ChrgitmLv == "2" {
  2111. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2112. }
  2113. if item.ChrgitmLv == "3" {
  2114. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2115. }
  2116. }
  2117. }
  2118. var iteminfoStructs []service.IteminfoStruct
  2119. if bedCostTotal != 0 {
  2120. iteminfo.MedChrgitm = "01"
  2121. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2122. iteminfo.Amt = bedCostTotal
  2123. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2124. iteminfo.ClabAmt = bed_clab_amt
  2125. iteminfo.OthAmt = bed_other_amt
  2126. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2127. }
  2128. if checkCostTotal != 0 {
  2129. iteminfo.MedChrgitm = "03"
  2130. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2131. iteminfo.Amt = checkCostTotal
  2132. iteminfo.ClaaSumfee = check_claa_sunmfee
  2133. iteminfo.ClabAmt = check_clab_amt
  2134. iteminfo.OthAmt = check_other_amt
  2135. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2136. }
  2137. if laboratoryCostTotal != 0 {
  2138. iteminfo.MedChrgitm = "04"
  2139. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2140. iteminfo.Amt = laboratoryCostTotal
  2141. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2142. iteminfo.ClabAmt = laboratory_clab_amt
  2143. iteminfo.OthAmt = laboratory_other_amt
  2144. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2145. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2146. }
  2147. if treatCostTotal != 0 {
  2148. iteminfo.MedChrgitm = "05"
  2149. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2150. iteminfo.Amt = treatCostTotal
  2151. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2152. iteminfo.ClabAmt = treat_clab_amt
  2153. iteminfo.OthAmt = treat_other_amt
  2154. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2155. //(struct4101.IteminfoStruct, iteminfo)
  2156. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2157. }
  2158. if operationCostTotal != 0 {
  2159. iteminfo.MedChrgitm = "06"
  2160. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2161. iteminfo.Amt = operationCostTotal
  2162. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2163. iteminfo.ClabAmt = operation_clab_amt
  2164. iteminfo.OthAmt = operation_other_amt
  2165. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2166. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2167. }
  2168. if materialCostTotal != 0 {
  2169. iteminfo.MedChrgitm = "08"
  2170. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2171. iteminfo.Amt = materialCostTotal
  2172. iteminfo.ClaaSumfee = material_claa_sunmfee
  2173. iteminfo.ClabAmt = material_clab_amt
  2174. iteminfo.OthAmt = material_other_amt
  2175. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2176. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2177. }
  2178. if westernMedicineCostTotal != 0 {
  2179. iteminfo.MedChrgitm = "09"
  2180. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2181. iteminfo.Amt = westernMedicineCostTotal
  2182. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2183. iteminfo.ClabAmt = westernMedicine_clab_amt
  2184. iteminfo.OthAmt = westernMedicine_other_amt
  2185. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2186. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2187. }
  2188. if chineseTraditionalMedicineCostTotal != 0 {
  2189. iteminfo.MedChrgitm = "11"
  2190. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2191. iteminfo.Amt = westernMedicineCostTotal
  2192. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2193. iteminfo.ClabAmt = westernMedicine_clab_amt
  2194. iteminfo.OthAmt = westernMedicine_other_amt
  2195. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2196. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2197. }
  2198. if otherCostTotal != 0 {
  2199. iteminfo.MedChrgitm = "14"
  2200. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2201. iteminfo.Amt = otherCostTotal
  2202. iteminfo.ClaaSumfee = other_claa_sunmfee
  2203. iteminfo.ClabAmt = other_clab_amt
  2204. iteminfo.OthAmt = other_other_amt
  2205. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2206. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2207. }
  2208. struct4101.IteminfoStruct = iteminfoStructs
  2209. struct4101.Ntly = "中国"
  2210. struct4101.AdmCaty = "A03.06"
  2211. var res ResultSeventeen
  2212. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2213. var resOther ResultSeventeenOther
  2214. var pp models.PublicParams
  2215. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2216. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2217. pp.FixmedinsName = miConfig.OrgName
  2218. pp.FixmedinsCode = miConfig.Code
  2219. pp.RequestUrl = miConfig.Url
  2220. pp.Cainfo = miConfig.Cainfo
  2221. pp.SecretKey = miConfig.SecretKey
  2222. pp.AccessKey = miConfig.AccessKey
  2223. pp.OpterName = curRoles.UserName
  2224. client := &http.Client{}
  2225. var req *http.Request
  2226. data := make(map[string]interface{})
  2227. data["struct4101"] = struct4101
  2228. data["pp"] = pp
  2229. bytesData, _ := json.Marshal(data)
  2230. if miConfig.MdtrtareaAdmvs == "320921" {
  2231. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2232. } else {
  2233. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2234. }
  2235. resp, _ := client.Do(req)
  2236. defer resp.Body.Close()
  2237. body, ioErr := ioutil.ReadAll(resp.Body)
  2238. if ioErr != nil {
  2239. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2241. return
  2242. }
  2243. var respJSON map[string]interface{}
  2244. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2247. return
  2248. }
  2249. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2250. userJSONBytes, _ := json.Marshal(respJSON)
  2251. fmt.Println("log")
  2252. fmt.Println(string(userJSONBytes))
  2253. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2254. utils.ErrorLog("解析失败:%v", err)
  2255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2256. return
  2257. }
  2258. res.InfRefmsgid = resOther.InfRefmsgid
  2259. res.Output = resOther.Output
  2260. res.ErrMsg = resOther.ErrMsg
  2261. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2262. res.Infcode = infocode
  2263. } else {
  2264. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2265. var dat map[string]interface{}
  2266. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2267. fmt.Println(dat)
  2268. } else {
  2269. fmt.Println(err)
  2270. }
  2271. userJSONBytes, _ := json.Marshal(dat)
  2272. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2273. utils.ErrorLog("解析失败:%v", err)
  2274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2275. return
  2276. }
  2277. }
  2278. if res.Infcode != 0 {
  2279. c.ServeSuccessJSON(map[string]interface{}{
  2280. "failed_code": -10,
  2281. "msg": res.ErrMsg,
  2282. })
  2283. return
  2284. } else {
  2285. order.FaPiaoNumber = zero
  2286. order.FaPiaoCode = last_order.FaPiaoCode
  2287. service.UpdateOrder(order)
  2288. hisFundSettleListResult := &models.HisFundSettleListResult{
  2289. Number: res.Output.SetlListId,
  2290. Status: 1,
  2291. Ctime: time.Now().Unix(),
  2292. Mtime: time.Now().Unix(),
  2293. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2294. IsUpload: 1,
  2295. OrderId: order_id,
  2296. }
  2297. service.CreateUploadRecord(hisFundSettleListResult)
  2298. c.ServeSuccessJSON(map[string]interface{}{
  2299. "msg": "上传成功",
  2300. "result": hisFundSettleListResult,
  2301. })
  2302. return
  2303. }
  2304. }
  2305. func (c *HisApiController) GetSettleListHospital() {
  2306. order_id, _ := c.GetInt64("order_id")
  2307. admin_user_id, _ := c.GetInt64("admin_user_id")
  2308. order, _ := service.GetHisOrderByIDTwo(order_id)
  2309. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2310. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2311. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2312. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2313. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2314. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2315. if order.ID == 0 {
  2316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2317. return
  2318. }
  2319. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2320. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2321. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2322. fmt.Println(count)
  2323. var zero string
  2324. number := count + 1
  2325. if number >= 1000 {
  2326. zero = "0000" + strconv.FormatInt(number, 10)
  2327. } else if number >= 10000 {
  2328. zero = "000" + strconv.FormatInt(number, 10)
  2329. } else if number >= 100000 {
  2330. zero = "00" + strconv.FormatInt(number, 10)
  2331. } else if number >= 1000000 {
  2332. zero = "0" + strconv.FormatInt(number, 10)
  2333. } else {
  2334. zero = strconv.FormatInt(number, 10)
  2335. }
  2336. fmt.Println(zero)
  2337. struct4101 := service.Struct4101{
  2338. PsnNo: order.PsnNo,
  2339. MdtrtId: order.MdtrtId,
  2340. SetlId: order.SetlId,
  2341. PsnName: order.PsnName,
  2342. Gend: order.Gend,
  2343. Brdy: his.Brdy,
  2344. Age: int64(order.Age),
  2345. Naty: order.Naty,
  2346. PatnCertType: "01",
  2347. Certno: order.Certno,
  2348. Prfs: "90",
  2349. ConerName: roles[0].UserName,
  2350. PatnRlts: "99",
  2351. ConerAddr: miConfig.OrgName,
  2352. ConerTel: admin.Mobile,
  2353. HiType: order.Insutype,
  2354. Insuplc: miConfig.InsuplcAdmdvs,
  2355. MaindiagFlag: "1",
  2356. BillCode: last_order.FaPiaoCode,
  2357. BillNo: zero,
  2358. BizSn: order.Number,
  2359. PsnSelfPay: order.PsnPartAmt,
  2360. PsnOwnPay: order.PsnPartAmt,
  2361. AcctPay: order.AcctPay,
  2362. PsnCashpay: order.PsnCashPay,
  2363. HiPaymtd: "1",
  2364. Hsorg: miConfig.InsuplcAdmdvs,
  2365. HsorgOpter: miConfig.InsuplcAdmdvs,
  2366. MedinsFillPsn: curRoles.UserName,
  2367. MedinsFillDept: depart.Name,
  2368. IptMedType: "2",
  2369. AdmTime: his.InHosptialTime,
  2370. AdmEndTime: his.OutHosptialTime,
  2371. }
  2372. struct4101.SetlBegnDate = order.SetlTime
  2373. struct4101.SetlEndDate = order.SetlTime
  2374. var rf []CustomFundPay
  2375. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2376. var tempFunPays []service.CustomStruct
  2377. for _, item := range rf {
  2378. var tempFunPay service.CustomStruct
  2379. tempFunPay.FundPayamt = item.FundPayamt
  2380. tempFunPay.FundPayType = item.FundPayType
  2381. tempFunPays = append(tempFunPays, tempFunPay)
  2382. }
  2383. struct4101.CustomStruct = tempFunPays
  2384. var tempDiaginfos []service.DiaginfoStructTwo
  2385. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2386. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2387. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2388. var config []*models.HisXtDiagnoseConfig
  2389. for _, item := range diagnosis_ids {
  2390. id, _ := strconv.ParseInt(item, 10, 64)
  2391. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2392. config = append(config, &diagnosisConfig)
  2393. }
  2394. for index, item := range config {
  2395. if index == 0 {
  2396. var tempDiaginfo service.DiaginfoStructTwo
  2397. tempDiaginfo.DiagCode = item.CountryCode
  2398. tempDiaginfo.DiagName = item.CountryContentName
  2399. tempDiaginfo.DiagType = "1"
  2400. tempDiaginfo.MaindiagFlag = "1"
  2401. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2402. } else {
  2403. var tempDiaginfo service.DiaginfoStructTwo
  2404. tempDiaginfo.DiagCode = item.CountryCode
  2405. tempDiaginfo.DiagName = item.CountryContentName
  2406. tempDiaginfo.DiagType = "2"
  2407. tempDiaginfo.MaindiagFlag = "0"
  2408. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2409. }
  2410. }
  2411. struct4101.Diseinfo = tempDiaginfos
  2412. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2413. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2414. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2415. tempOpspdiseinfo2.OprnOprtCode = ""
  2416. tempOpspdiseinfo2.OprnOprtName = ""
  2417. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2418. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2419. var iteminfo service.IteminfoStruct
  2420. var bedCostTotal float64 = 0 //床位总费
  2421. var bedCostSelfTotal float64 = 0 //床位自费
  2422. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2423. var operationCostTotal float64 = 0 //手术费
  2424. var operationCostSelfTotal float64 = 0 //手术费
  2425. var operationCostPartSelfTotal float64 = 0 //手术费
  2426. var otherCostTotal float64 = 0 //其他费用
  2427. var otherCostSelfTotal float64 = 0 //其他费用
  2428. var otherCostPartSelfTotal float64 = 0 //其他费用
  2429. var materialCostTotal float64 = 0 //材料费
  2430. var materialCostSelfTotal float64 = 0 //材料费
  2431. var materialCostPartSelfTotal float64 = 0 //材料费
  2432. var westernMedicineCostTotal float64 = 0 //西药费
  2433. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2434. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2435. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2436. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2437. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2438. var checkCostTotal float64 = 0 //检查费
  2439. var checkCostSelfTotal float64 = 0 //检查费
  2440. var checkCostPartSelfTotal float64 = 0 //检查费
  2441. var laboratoryCostTotal float64 = 0 //化验费
  2442. var laboratoryCostSelfTotal float64 = 0 //化验费
  2443. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2444. var treatCostTotal float64 = 0 //治疗费用
  2445. var treatCostSelfTotal float64 = 0 //治疗费用
  2446. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2447. decimal.DivisionPrecision = 2
  2448. var bed_fulamt_ownpay_amt float64 = 0
  2449. var operation_fulamt_ownpay_amt float64 = 0
  2450. var other_fulamt_ownpay_amt float64 = 0
  2451. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2452. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2453. var check_fulamt_ownpay_amt float64 = 0
  2454. var material_fulamt_ownpay_amt float64 = 0
  2455. var laboratory_fulamt_ownpay_amt float64 = 0
  2456. var treat_fulamt_ownpay_amt float64 = 0
  2457. var bed_claa_sunmfee float64 = 0
  2458. var bed_clab_amt float64 = 0
  2459. var bed_other_amt float64 = 0
  2460. var operation_claa_sunmfee float64 = 0
  2461. var operation_clab_amt float64 = 0
  2462. var operation_other_amt float64 = 0
  2463. var other_claa_sunmfee float64 = 0
  2464. var other_clab_amt float64 = 0
  2465. var other_other_amt float64 = 0
  2466. var westernMedicine_claa_sunmfee float64 = 0
  2467. var westernMedicine_clab_amt float64 = 0
  2468. var westernMedicine_other_amt float64 = 0
  2469. var chineseTraditional_claa_sunmfee float64 = 0
  2470. var chineseTraditional_clab_amt float64 = 0
  2471. var chineseTraditional_other_amt float64 = 0
  2472. var check_claa_sunmfee float64 = 0
  2473. var check_clab_amt float64 = 0
  2474. var check_other_amt float64 = 0
  2475. var material_claa_sunmfee float64 = 0
  2476. var material_clab_amt float64 = 0
  2477. var material_other_amt float64 = 0
  2478. var laboratory_claa_sunmfee float64 = 0
  2479. var laboratory_clab_amt float64 = 0
  2480. var laboratory_other_amt float64 = 0
  2481. var treat_claa_sunmfee float64 = 0
  2482. var treat_clab_amt float64 = 0
  2483. var treat_other_amt float64 = 0
  2484. for _, item := range order.HisOrderInfo {
  2485. if item.MedChrgitmType == "01" { //床位费
  2486. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2487. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2488. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2489. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2490. if item.ChrgitmLv == "1" {
  2491. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2492. }
  2493. if item.ChrgitmLv == "2" {
  2494. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2495. }
  2496. if item.ChrgitmLv == "3" {
  2497. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2498. }
  2499. }
  2500. if item.MedChrgitmType == "03" { //检查费
  2501. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2502. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2503. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2504. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2505. if item.ChrgitmLv == "1" {
  2506. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2507. }
  2508. if item.ChrgitmLv == "2" {
  2509. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2510. }
  2511. if item.ChrgitmLv == "3" {
  2512. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2513. }
  2514. }
  2515. if item.MedChrgitmType == "04" { //化验费
  2516. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2517. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2518. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2519. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2520. if item.ChrgitmLv == "1" {
  2521. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2522. }
  2523. if item.ChrgitmLv == "2" {
  2524. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2525. }
  2526. if item.ChrgitmLv == "3" {
  2527. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2528. }
  2529. }
  2530. if item.MedChrgitmType == "05" { //治疗费
  2531. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2532. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2533. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2534. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2535. if item.ChrgitmLv == "1" {
  2536. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2537. }
  2538. if item.ChrgitmLv == "2" {
  2539. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2540. }
  2541. if item.ChrgitmLv == "3" {
  2542. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2543. }
  2544. }
  2545. if item.MedChrgitmType == "06" { //手术费
  2546. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2547. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2548. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2549. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2550. if item.ChrgitmLv == "1" {
  2551. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2552. }
  2553. if item.ChrgitmLv == "2" {
  2554. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2555. }
  2556. if item.ChrgitmLv == "3" {
  2557. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2558. }
  2559. }
  2560. if item.MedChrgitmType == "08" { //材料费
  2561. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2562. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2563. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2564. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2565. if item.ChrgitmLv == "1" {
  2566. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2567. }
  2568. if item.ChrgitmLv == "2" {
  2569. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2570. }
  2571. if item.ChrgitmLv == "3" {
  2572. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2573. }
  2574. }
  2575. if item.MedChrgitmType == "09" { //西药费
  2576. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2577. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2578. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2579. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2580. if item.ChrgitmLv == "1" {
  2581. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2582. }
  2583. if item.ChrgitmLv == "2" {
  2584. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2585. }
  2586. if item.ChrgitmLv == "3" {
  2587. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2588. }
  2589. }
  2590. if item.MedChrgitmType == "11" { //中成费
  2591. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2592. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2593. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2594. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2595. if item.ChrgitmLv == "1" {
  2596. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2597. }
  2598. if item.ChrgitmLv == "2" {
  2599. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2600. }
  2601. if item.ChrgitmLv == "3" {
  2602. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2603. }
  2604. }
  2605. if item.MedChrgitmType == "14" { //其他费
  2606. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2607. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2608. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2609. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2610. if item.ChrgitmLv == "1" {
  2611. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2612. }
  2613. if item.ChrgitmLv == "2" {
  2614. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2615. }
  2616. if item.ChrgitmLv == "3" {
  2617. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2618. }
  2619. }
  2620. }
  2621. var iteminfoStructs []service.IteminfoStruct
  2622. if bedCostTotal != 0 {
  2623. iteminfo.MedChrgitm = "01"
  2624. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2625. iteminfo.Amt = bedCostTotal
  2626. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2627. iteminfo.ClabAmt = bed_clab_amt
  2628. iteminfo.OthAmt = bed_other_amt
  2629. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2630. }
  2631. if checkCostTotal != 0 {
  2632. iteminfo.MedChrgitm = "03"
  2633. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2634. iteminfo.Amt = checkCostTotal
  2635. iteminfo.ClaaSumfee = check_claa_sunmfee
  2636. iteminfo.ClabAmt = check_clab_amt
  2637. iteminfo.OthAmt = check_other_amt
  2638. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2639. }
  2640. if laboratoryCostTotal != 0 {
  2641. iteminfo.MedChrgitm = "04"
  2642. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2643. iteminfo.Amt = laboratoryCostTotal
  2644. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2645. iteminfo.ClabAmt = laboratory_clab_amt
  2646. iteminfo.OthAmt = laboratory_other_amt
  2647. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2648. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2649. }
  2650. if treatCostTotal != 0 {
  2651. iteminfo.MedChrgitm = "05"
  2652. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2653. iteminfo.Amt = treatCostTotal
  2654. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2655. iteminfo.ClabAmt = treat_clab_amt
  2656. iteminfo.OthAmt = treat_other_amt
  2657. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2658. //(struct4101.IteminfoStruct, iteminfo)
  2659. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2660. }
  2661. if operationCostTotal != 0 {
  2662. iteminfo.MedChrgitm = "06"
  2663. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2664. iteminfo.Amt = operationCostTotal
  2665. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2666. iteminfo.ClabAmt = operation_clab_amt
  2667. iteminfo.OthAmt = operation_other_amt
  2668. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2669. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2670. }
  2671. if materialCostTotal != 0 {
  2672. iteminfo.MedChrgitm = "08"
  2673. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2674. iteminfo.Amt = materialCostTotal
  2675. iteminfo.ClaaSumfee = material_claa_sunmfee
  2676. iteminfo.ClabAmt = material_clab_amt
  2677. iteminfo.OthAmt = material_other_amt
  2678. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2679. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2680. }
  2681. if westernMedicineCostTotal != 0 {
  2682. iteminfo.MedChrgitm = "09"
  2683. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2684. iteminfo.Amt = westernMedicineCostTotal
  2685. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2686. iteminfo.ClabAmt = westernMedicine_clab_amt
  2687. iteminfo.OthAmt = westernMedicine_other_amt
  2688. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2689. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2690. }
  2691. if chineseTraditionalMedicineCostTotal != 0 {
  2692. iteminfo.MedChrgitm = "11"
  2693. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2694. iteminfo.Amt = westernMedicineCostTotal
  2695. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2696. iteminfo.ClabAmt = westernMedicine_clab_amt
  2697. iteminfo.OthAmt = westernMedicine_other_amt
  2698. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2699. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2700. }
  2701. if otherCostTotal != 0 {
  2702. iteminfo.MedChrgitm = "14"
  2703. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2704. iteminfo.Amt = otherCostTotal
  2705. iteminfo.ClaaSumfee = other_claa_sunmfee
  2706. iteminfo.ClabAmt = other_clab_amt
  2707. iteminfo.OthAmt = other_other_amt
  2708. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2709. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2710. }
  2711. struct4101.IteminfoStruct = iteminfoStructs
  2712. struct4101.Ntly = "中国"
  2713. struct4101.AdmCaty = "A03.06"
  2714. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2715. fmt.Println(result)
  2716. var dat map[string]interface{}
  2717. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2718. fmt.Println(dat)
  2719. } else {
  2720. fmt.Println(err)
  2721. }
  2722. userJSONBytes, _ := json.Marshal(dat)
  2723. var res ResultSeventeen
  2724. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2725. utils.ErrorLog("解析失败:%v", err)
  2726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2727. return
  2728. }
  2729. if res.Infcode != 0 {
  2730. c.ServeSuccessJSON(map[string]interface{}{
  2731. "failed_code": -10,
  2732. "msg": res.ErrMsg,
  2733. })
  2734. return
  2735. } else {
  2736. order.FaPiaoNumber = zero
  2737. order.FaPiaoCode = last_order.FaPiaoCode
  2738. service.UpdateOrder(order)
  2739. hisFundSettleListResult := &models.HisFundSettleListResult{
  2740. Number: res.Output.SetlListId,
  2741. Status: 1,
  2742. Ctime: time.Now().Unix(),
  2743. Mtime: time.Now().Unix(),
  2744. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2745. IsUpload: 1,
  2746. OrderId: order_id,
  2747. }
  2748. service.CreateUploadRecord(hisFundSettleListResult)
  2749. c.ServeSuccessJSON(map[string]interface{}{
  2750. "msg": "上传成功",
  2751. "result": hisFundSettleListResult,
  2752. })
  2753. return
  2754. }
  2755. }
  2756. func (c *HisApiController) GetBatchSettleList() {
  2757. orders, _ := service.GetAllHisOrder(10106)
  2758. for _, item := range orders {
  2759. order_id := item.ID
  2760. order, _ := service.GetHisOrderByIDTwo(order_id)
  2761. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2762. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2763. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2764. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2765. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2766. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2767. if order.ID == 0 {
  2768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2769. return
  2770. }
  2771. if his.BalanceAccountsType == 2 {
  2772. continue
  2773. }
  2774. struct4101 := service.Struct4101{
  2775. PsnNo: order.PsnNo,
  2776. MdtrtId: order.MdtrtId,
  2777. SetlId: order.SetlId,
  2778. PsnName: order.PsnName,
  2779. Gend: order.Gend,
  2780. Brdy: his.Brdy,
  2781. Age: his.Age,
  2782. Naty: order.Naty,
  2783. PatnCertType: "01",
  2784. Certno: order.Certno,
  2785. Prfs: "90",
  2786. ConerName: roles[0].UserName,
  2787. PatnRlts: "99",
  2788. ConerAddr: miConfig.OrgName,
  2789. ConerTel: admin.Mobile,
  2790. HiType: order.Insutype,
  2791. Insuplc: his.InsuplcAdmdvs,
  2792. MaindiagFlag: "1",
  2793. BillCode: order.FaPiaoCode,
  2794. BillNo: order.FaPiaoNumber,
  2795. BizSn: order.Number,
  2796. PsnSelfPay: order.PsnPartAmt,
  2797. PsnOwnPay: order.PsnPartAmt,
  2798. AcctPay: order.AcctPay,
  2799. PsnCashpay: order.PsnCashPay,
  2800. HiPaymtd: "1",
  2801. Hsorg: his.InsuplcAdmdvs,
  2802. HsorgOpter: his.InsuplcAdmdvs,
  2803. MedinsFillPsn: curRoles.UserName,
  2804. MedinsFillDept: depart.Name,
  2805. IptMedType: "2",
  2806. }
  2807. struct4101.SetlBegnDate = order.SetlTime
  2808. struct4101.SetlEndDate = order.SetlTime
  2809. //if order.SettleType == 1 {
  2810. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2811. // dateStr := t.Format("2006-01-02")
  2812. // struct4101.SetlBegnDate = dateStr
  2813. // struct4101.SetlEndDate = dateStr
  2814. //} else {
  2815. // t := time.Unix(int64(order.SettleStartTime), 0)
  2816. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2817. // dateStartStr := t.Format("2006-01-02")
  2818. // dateEndStr := t2.Format("2006-01-02")
  2819. // struct4101.SetlBegnDate = dateStartStr
  2820. // struct4101.SetlEndDate = dateEndStr
  2821. //}
  2822. var rf []CustomFundPay
  2823. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2824. var tempFunPays []service.CustomStruct
  2825. var tempFunPay610100 service.CustomStruct
  2826. for _, item := range rf {
  2827. if item.FundPayType == "610100" {
  2828. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2829. tempFunPay610100.FundPayType = item.FundPayType
  2830. } else {
  2831. var tempFunPay service.CustomStruct
  2832. tempFunPay.FundPayamt = item.FundPayamt
  2833. tempFunPay.FundPayType = item.FundPayType
  2834. tempFunPays = append(tempFunPays, tempFunPay)
  2835. }
  2836. }
  2837. tempFunPays = append(tempFunPays, tempFunPay610100)
  2838. struct4101.CustomStruct = tempFunPays
  2839. var tempDiaginfos []service.DiaginfoStructTwo
  2840. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2841. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2842. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2843. var config []*models.HisXtDiagnoseConfig
  2844. for _, item := range diagnosis_ids {
  2845. id, _ := strconv.ParseInt(item, 10, 64)
  2846. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2847. config = append(config, &diagnosisConfig)
  2848. }
  2849. for index, item := range config {
  2850. if index == 0 {
  2851. var tempDiaginfo service.DiaginfoStructTwo
  2852. tempDiaginfo.DiagCode = item.CountryCode
  2853. tempDiaginfo.DiagName = item.CountryContentName
  2854. tempDiaginfo.DiagType = "1"
  2855. tempDiaginfo.MaindiagFlag = "1"
  2856. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2857. } else {
  2858. var tempDiaginfo service.DiaginfoStructTwo
  2859. tempDiaginfo.DiagCode = item.CountryCode
  2860. tempDiaginfo.DiagName = item.CountryContentName
  2861. tempDiaginfo.DiagType = "2"
  2862. tempDiaginfo.MaindiagFlag = "0"
  2863. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2864. }
  2865. }
  2866. struct4101.Diseinfo = tempDiaginfos
  2867. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2868. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2869. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2870. tempOpspdiseinfo2.OprnOprtCode = ""
  2871. tempOpspdiseinfo2.OprnOprtName = ""
  2872. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2873. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2874. var iteminfo service.IteminfoStruct
  2875. var bedCostTotal float64 = 0 //床位总费
  2876. var bedCostSelfTotal float64 = 0 //床位自费
  2877. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2878. var examineCostTotal float64 = 0 //诊查总费
  2879. var examineCostSelfTotal float64 = 0 //诊查自费
  2880. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2881. var nursingCostTotal float64 = 0 //护理总费
  2882. var nursingCostSelfTotal float64 = 0 //护理自费
  2883. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2884. var chineseMedicineCostTotal float64 = 0 //中成药
  2885. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2886. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2887. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2888. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2889. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2890. var registerCostTotal float64 = 0 //一般诊疗费
  2891. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2892. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2893. var operationCostTotal float64 = 0 //手术费
  2894. var operationCostSelfTotal float64 = 0 //手术费
  2895. var operationCostPartSelfTotal float64 = 0 //手术费
  2896. var otherCostTotal float64 = 0 //其他费用
  2897. var otherCostSelfTotal float64 = 0 //其他费用
  2898. var otherCostPartSelfTotal float64 = 0 //其他费用
  2899. var materialCostTotal float64 = 0 //材料费
  2900. var materialCostSelfTotal float64 = 0 //材料费
  2901. var materialCostPartSelfTotal float64 = 0 //材料费
  2902. var westernMedicineCostTotal float64 = 0 //西药费
  2903. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2904. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2905. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2906. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2907. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2908. var checkCostTotal float64 = 0 //检查费
  2909. var checkCostSelfTotal float64 = 0 //检查费
  2910. var checkCostPartSelfTotal float64 = 0 //检查费
  2911. var laboratoryCostTotal float64 = 0 //化验费
  2912. var laboratoryCostSelfTotal float64 = 0 //化验费
  2913. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2914. var treatCostTotal float64 = 0 //治疗费用
  2915. var treatCostSelfTotal float64 = 0 //治疗费用
  2916. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2917. decimal.DivisionPrecision = 2
  2918. var bed_fulamt_ownpay_amt float64 = 0
  2919. var examine_fulamt_ownpay_amt float64 = 0
  2920. var nursing_fulamt_ownpay_amt float64 = 0
  2921. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2922. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2923. var register_fulamt_ownpay_amt float64 = 0
  2924. var operation_fulamt_ownpay_amt float64 = 0
  2925. var other_fulamt_ownpay_amt float64 = 0
  2926. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2927. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2928. var check_fulamt_ownpay_amt float64 = 0
  2929. var material_fulamt_ownpay_amt float64 = 0
  2930. var laboratory_fulamt_ownpay_amt float64 = 0
  2931. var treat_fulamt_ownpay_amt float64 = 0
  2932. var bed_claa_sunmfee float64 = 0
  2933. var bed_clab_amt float64 = 0
  2934. var bed_other_amt float64 = 0
  2935. var examine_claa_sunmfee float64 = 0
  2936. var examine_clab_amt float64 = 0
  2937. var examine_other_amt float64 = 0
  2938. var nursing_claa_sunmfee float64 = 0
  2939. var nursing_clab_amt float64 = 0
  2940. var nursing_other_amt float64 = 0
  2941. var chinese_medicine_claa_sunmfee float64 = 0
  2942. var chinese_medicine_clab_amt float64 = 0
  2943. var chinese_medicine_other_amt float64 = 0
  2944. var commonly_treatment_claa_sunmfee float64 = 0
  2945. var commonly_treatment_clab_amt float64 = 0
  2946. var commonly_treatment_other_amt float64 = 0
  2947. var operation_claa_sunmfee float64 = 0
  2948. var operation_clab_amt float64 = 0
  2949. var operation_other_amt float64 = 0
  2950. var other_claa_sunmfee float64 = 0
  2951. var other_clab_amt float64 = 0
  2952. var other_other_amt float64 = 0
  2953. var westernMedicine_claa_sunmfee float64 = 0
  2954. var westernMedicine_clab_amt float64 = 0
  2955. var westernMedicine_other_amt float64 = 0
  2956. var chineseTraditional_claa_sunmfee float64 = 0
  2957. var chineseTraditional_clab_amt float64 = 0
  2958. var chineseTraditional_other_amt float64 = 0
  2959. var check_claa_sunmfee float64 = 0
  2960. var check_clab_amt float64 = 0
  2961. var check_other_amt float64 = 0
  2962. var material_claa_sunmfee float64 = 0
  2963. var material_clab_amt float64 = 0
  2964. var material_other_amt float64 = 0
  2965. var laboratory_claa_sunmfee float64 = 0
  2966. var laboratory_clab_amt float64 = 0
  2967. var laboratory_other_amt float64 = 0
  2968. var treat_claa_sunmfee float64 = 0
  2969. var treat_clab_amt float64 = 0
  2970. var treat_other_amt float64 = 0
  2971. var register_claa_sunmfee float64 = 0
  2972. var register_clab_amt float64 = 0
  2973. var register_other_amt float64 = 0
  2974. for _, item := range order.HisOrderInfo {
  2975. if item.MedChrgitmType == "01" { //床位费
  2976. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2977. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2978. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2979. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2980. if item.ChrgitmLv == "1" {
  2981. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2982. }
  2983. if item.ChrgitmLv == "2" {
  2984. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2985. }
  2986. if item.ChrgitmLv == "3" {
  2987. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2988. }
  2989. }
  2990. if item.MedChrgitmType == "02" { //诊查
  2991. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2992. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2993. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2994. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2995. if item.ChrgitmLv == "1" {
  2996. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2997. }
  2998. if item.ChrgitmLv == "2" {
  2999. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3000. }
  3001. if item.ChrgitmLv == "3" {
  3002. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3003. }
  3004. }
  3005. if item.MedChrgitmType == "03" { //检查费
  3006. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3007. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3008. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3009. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3010. if item.ChrgitmLv == "1" {
  3011. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3012. }
  3013. if item.ChrgitmLv == "2" {
  3014. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3015. }
  3016. if item.ChrgitmLv == "3" {
  3017. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3018. }
  3019. }
  3020. if item.MedChrgitmType == "04" { //化验费
  3021. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3022. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3023. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3024. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3025. if item.ChrgitmLv == "1" {
  3026. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3027. }
  3028. if item.ChrgitmLv == "2" {
  3029. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3030. }
  3031. if item.ChrgitmLv == "3" {
  3032. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3033. }
  3034. }
  3035. if item.MedChrgitmType == "05" { //治疗费
  3036. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3037. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3038. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3039. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3040. if item.ChrgitmLv == "1" {
  3041. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3042. }
  3043. if item.ChrgitmLv == "2" {
  3044. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3045. }
  3046. if item.ChrgitmLv == "3" {
  3047. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3048. }
  3049. }
  3050. if item.MedChrgitmType == "06" { //手术费
  3051. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3052. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3053. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3054. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3055. if item.ChrgitmLv == "1" {
  3056. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3057. }
  3058. if item.ChrgitmLv == "2" {
  3059. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3060. }
  3061. if item.ChrgitmLv == "3" {
  3062. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3063. }
  3064. }
  3065. if item.MedChrgitmType == "07" { //手术费
  3066. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3067. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3068. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3069. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3070. if item.ChrgitmLv == "1" {
  3071. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3072. }
  3073. if item.ChrgitmLv == "2" {
  3074. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3075. }
  3076. if item.ChrgitmLv == "3" {
  3077. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3078. }
  3079. }
  3080. if item.MedChrgitmType == "08" { //材料费
  3081. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3082. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3083. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3084. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3085. if item.ChrgitmLv == "1" {
  3086. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3087. }
  3088. if item.ChrgitmLv == "2" {
  3089. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3090. }
  3091. if item.ChrgitmLv == "3" {
  3092. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3093. }
  3094. }
  3095. if item.MedChrgitmType == "09" { //西药费
  3096. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3097. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3098. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3099. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3100. if item.ChrgitmLv == "1" {
  3101. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3102. }
  3103. if item.ChrgitmLv == "2" {
  3104. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3105. }
  3106. if item.ChrgitmLv == "3" {
  3107. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3108. }
  3109. }
  3110. if item.MedChrgitmType == "10" { //中药饮片
  3111. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3112. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3113. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3114. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3115. if item.ChrgitmLv == "1" {
  3116. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3117. }
  3118. if item.ChrgitmLv == "2" {
  3119. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3120. }
  3121. if item.ChrgitmLv == "3" {
  3122. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3123. }
  3124. }
  3125. if item.MedChrgitmType == "11" { //中成费
  3126. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3127. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3128. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3129. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3130. if item.ChrgitmLv == "1" {
  3131. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3132. }
  3133. if item.ChrgitmLv == "2" {
  3134. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3135. }
  3136. if item.ChrgitmLv == "3" {
  3137. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3138. }
  3139. }
  3140. if item.MedChrgitmType == "12" { //中成费
  3141. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3142. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3143. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3144. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3145. if item.ChrgitmLv == "1" {
  3146. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3147. }
  3148. if item.ChrgitmLv == "2" {
  3149. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3150. }
  3151. if item.ChrgitmLv == "3" {
  3152. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3153. }
  3154. }
  3155. if item.MedChrgitmType == "13" { //中成费
  3156. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3157. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3158. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3159. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3160. if item.ChrgitmLv == "1" {
  3161. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3162. }
  3163. if item.ChrgitmLv == "2" {
  3164. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3165. }
  3166. if item.ChrgitmLv == "3" {
  3167. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3168. }
  3169. }
  3170. if item.MedChrgitmType == "14" { //其他费
  3171. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3172. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3173. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3174. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3175. if item.ChrgitmLv == "1" {
  3176. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3177. }
  3178. if item.ChrgitmLv == "2" {
  3179. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3180. }
  3181. if item.ChrgitmLv == "3" {
  3182. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3183. }
  3184. }
  3185. }
  3186. var iteminfoStructs []service.IteminfoStruct
  3187. if bedCostTotal != 0 {
  3188. iteminfo.MedChrgitm = "01"
  3189. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3190. iteminfo.Amt = bedCostTotal
  3191. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3192. iteminfo.ClabAmt = bed_clab_amt
  3193. iteminfo.OthAmt = bed_other_amt
  3194. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3195. }
  3196. if examineCostTotal != 0 {
  3197. iteminfo.MedChrgitm = "02"
  3198. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3199. iteminfo.Amt = examineCostTotal
  3200. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3201. iteminfo.ClabAmt = examine_clab_amt
  3202. iteminfo.OthAmt = examine_other_amt
  3203. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3204. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3205. }
  3206. if checkCostTotal != 0 {
  3207. iteminfo.MedChrgitm = "03"
  3208. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3209. iteminfo.Amt = checkCostTotal
  3210. iteminfo.ClaaSumfee = check_claa_sunmfee
  3211. iteminfo.ClabAmt = check_clab_amt
  3212. iteminfo.OthAmt = check_other_amt
  3213. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3214. }
  3215. if laboratoryCostTotal != 0 {
  3216. iteminfo.MedChrgitm = "04"
  3217. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3218. iteminfo.Amt = laboratoryCostTotal
  3219. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3220. iteminfo.ClabAmt = laboratory_clab_amt
  3221. iteminfo.OthAmt = laboratory_other_amt
  3222. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3223. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3224. }
  3225. if treatCostTotal != 0 {
  3226. iteminfo.MedChrgitm = "05"
  3227. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3228. iteminfo.Amt = treatCostTotal
  3229. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3230. iteminfo.ClabAmt = treat_clab_amt
  3231. iteminfo.OthAmt = treat_other_amt
  3232. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3233. //(struct4101.IteminfoStruct, iteminfo)
  3234. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3235. }
  3236. if operationCostTotal != 0 {
  3237. iteminfo.MedChrgitm = "06"
  3238. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3239. iteminfo.Amt = operationCostTotal
  3240. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3241. iteminfo.ClabAmt = operation_clab_amt
  3242. iteminfo.OthAmt = operation_other_amt
  3243. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3244. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3245. }
  3246. if nursingCostTotal != 0 {
  3247. iteminfo.MedChrgitm = "07"
  3248. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3249. iteminfo.Amt = nursingCostTotal
  3250. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3251. iteminfo.ClabAmt = nursing_clab_amt
  3252. iteminfo.OthAmt = nursing_other_amt
  3253. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3254. }
  3255. if materialCostTotal != 0 {
  3256. iteminfo.MedChrgitm = "08"
  3257. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3258. iteminfo.Amt = materialCostTotal
  3259. iteminfo.ClaaSumfee = material_claa_sunmfee
  3260. iteminfo.ClabAmt = material_clab_amt
  3261. iteminfo.OthAmt = material_other_amt
  3262. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3263. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3264. }
  3265. if westernMedicineCostTotal != 0 {
  3266. iteminfo.MedChrgitm = "09"
  3267. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3268. iteminfo.Amt = westernMedicineCostTotal
  3269. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3270. iteminfo.ClabAmt = westernMedicine_clab_amt
  3271. iteminfo.OthAmt = westernMedicine_other_amt
  3272. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3273. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3274. }
  3275. if chineseMedicineCostTotal != 0 {
  3276. iteminfo.MedChrgitm = "10"
  3277. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3278. iteminfo.Amt = chineseMedicineCostTotal
  3279. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3280. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3281. iteminfo.OthAmt = chinese_medicine_other_amt
  3282. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3283. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3284. }
  3285. if chineseTraditionalMedicineCostTotal != 0 {
  3286. iteminfo.MedChrgitm = "11"
  3287. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3288. iteminfo.Amt = westernMedicineCostTotal
  3289. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3290. iteminfo.ClabAmt = westernMedicine_clab_amt
  3291. iteminfo.OthAmt = westernMedicine_other_amt
  3292. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3293. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3294. }
  3295. if commonlyTreatmentCostTotal != 0 {
  3296. iteminfo.MedChrgitm = "12"
  3297. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3298. iteminfo.Amt = commonlyTreatmentCostTotal
  3299. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3300. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3301. iteminfo.OthAmt = commonly_treatment_other_amt
  3302. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3303. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3304. }
  3305. if registerCostTotal != 0 {
  3306. iteminfo.MedChrgitm = "13"
  3307. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3308. iteminfo.Amt = registerCostTotal
  3309. iteminfo.ClaaSumfee = register_claa_sunmfee
  3310. iteminfo.ClabAmt = register_clab_amt
  3311. iteminfo.OthAmt = register_other_amt
  3312. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3313. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3314. }
  3315. if otherCostTotal != 0 {
  3316. iteminfo.MedChrgitm = "14"
  3317. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3318. iteminfo.Amt = otherCostTotal
  3319. iteminfo.ClaaSumfee = other_claa_sunmfee
  3320. iteminfo.ClabAmt = other_clab_amt
  3321. iteminfo.OthAmt = other_other_amt
  3322. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3323. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3324. }
  3325. struct4101.IteminfoStruct = iteminfoStructs
  3326. struct4101.Ntly = "中国"
  3327. struct4101.AdmCaty = "A03.06"
  3328. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3329. fmt.Println(result)
  3330. var dat map[string]interface{}
  3331. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3332. fmt.Println(dat)
  3333. } else {
  3334. fmt.Println(err)
  3335. }
  3336. userJSONBytes, _ := json.Marshal(dat)
  3337. var res ResultSeventeen
  3338. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3339. utils.ErrorLog("解析失败:%v", err)
  3340. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3341. adminUser := c.GetAdminUserInfo()
  3342. errlog := &models.HisOrderError{
  3343. UserOrgId: adminUser.CurrentOrgId,
  3344. Ctime: time.Now().Unix(),
  3345. Mtime: time.Now().Unix(),
  3346. ErrMsg: res.ErrMsg + "解析失败",
  3347. Status: 1,
  3348. PatientId: order_id,
  3349. Stage: 10106,
  3350. }
  3351. service.CreateErrMsgLog(errlog)
  3352. continue
  3353. }
  3354. if res.Infcode != 0 {
  3355. adminUser := c.GetAdminUserInfo()
  3356. errlog := &models.HisOrderError{
  3357. UserOrgId: adminUser.CurrentOrgId,
  3358. Ctime: time.Now().Unix(),
  3359. Mtime: time.Now().Unix(),
  3360. ErrMsg: res.ErrMsg,
  3361. Status: 1,
  3362. PatientId: order_id,
  3363. Stage: 10106,
  3364. }
  3365. service.CreateErrMsgLog(errlog)
  3366. continue
  3367. } else {
  3368. hisFundSettleListResult := &models.HisFundSettleListResult{
  3369. Number: res.Output.SetlListId,
  3370. Status: 1,
  3371. Ctime: time.Now().Unix(),
  3372. Mtime: time.Now().Unix(),
  3373. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3374. IsUpload: 1,
  3375. OrderId: order_id,
  3376. }
  3377. service.CreateUploadRecord(hisFundSettleListResult)
  3378. continue
  3379. }
  3380. }
  3381. }
  3382. func (c *HisApiController) GetOrgInfo() {
  3383. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3384. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3385. }
  3386. func (c *HisApiController) GetHisPatientInfo() {
  3387. medical_insurance_card := c.GetString("medical_insurance_card")
  3388. id_card_type, _ := c.GetInt64("id_card_type")
  3389. id_card := c.GetString("id_card")
  3390. adminInfo := c.GetAdminUserInfo()
  3391. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3392. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3393. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3394. IdCardNo := ""
  3395. if id_card_type == 1 {
  3396. IdCardNo = medical_insurance_card
  3397. } else if id_card_type == 2 {
  3398. IdCardNo = id_card
  3399. }
  3400. if config.IsOpen == 1 {
  3401. 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
  3402. resp, requestErr := http.Get(api)
  3403. if requestErr != nil {
  3404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3405. return
  3406. }
  3407. defer resp.Body.Close()
  3408. body, ioErr := ioutil.ReadAll(resp.Body)
  3409. if ioErr != nil {
  3410. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3412. return
  3413. }
  3414. var respJSON map[string]interface{}
  3415. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3418. return
  3419. }
  3420. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3421. userJSONBytes, _ := json.Marshal(userJSON)
  3422. var res ResultTwo
  3423. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3424. utils.ErrorLog("解析失败:%v", err)
  3425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3426. return
  3427. }
  3428. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3429. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3430. infoStr := string(Iinfos)
  3431. idetinfoStr := string(Idetinfos)
  3432. if res.Infcode == 0 {
  3433. his := models.VMHisPatient{
  3434. Status: 1,
  3435. Ctime: time.Now().Unix(),
  3436. Mtime: time.Now().Unix(),
  3437. PsnNo: res.Output.Baseinfo.PsnNo,
  3438. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3439. Certno: res.Output.Baseinfo.Certno,
  3440. PsnName: res.Output.Baseinfo.PsnName,
  3441. Gend: res.Output.Baseinfo.Gend,
  3442. Naty: res.Output.Baseinfo.Naty,
  3443. Brdy: res.Output.Baseinfo.Brdy,
  3444. Age: res.Output.Baseinfo.Age,
  3445. Iinfo: infoStr,
  3446. Idetinfo: idetinfoStr,
  3447. UserOrgId: adminInfo.CurrentOrgId,
  3448. IsReturn: 1,
  3449. IdCardType: id_card_type,
  3450. }
  3451. c.ServeSuccessJSON(map[string]interface{}{
  3452. "info": his,
  3453. })
  3454. } else {
  3455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3456. return
  3457. }
  3458. }
  3459. }
  3460. //func GetBasBaseInfo() (jsonStr string, err error) {
  3461. //
  3462. // handle := syscall.NewLazyDLL("SSCard.dll")
  3463. // add := handle.NewProc("ReadCardBas")
  3464. // str := make([]byte, 1024)
  3465. // str1 := make([]byte, 1024)
  3466. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3467. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3468. //
  3469. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3470. //
  3471. // fmt.Println("> Add(4,5)的结果为:", ret)
  3472. // handle.Release()
  3473. //
  3474. // return "", nil
  3475. //
  3476. //}
  3477. //func GetQRBaseInfo() (jsonStr string, err error) {
  3478. // handle := syscall.LoadDLL("SSCard.dll")
  3479. // ReadCardBas := handle.FindProc("GetQRBase")
  3480. //
  3481. // str := make([]byte, 256)
  3482. // str1 := make([]byte, 256)
  3483. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3484. //
  3485. // fmt.Println(string(str))
  3486. // fmt.Println(r)
  3487. // return string(str), nil
  3488. //}
  3489. //func CardInit() int {
  3490. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3491. // add := DllTestDef.MustFindProc("Init")
  3492. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3493. // if err != nil {
  3494. // fmt.Println("SSCard的运算结果为:", ret)
  3495. // }
  3496. // result := int(ret)
  3497. // return result
  3498. //}
  3499. //func CardInit() int {
  3500. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3501. // if err != nil {
  3502. // fmt.Println("SSCard的运算结果为:", ret)
  3503. // }
  3504. // fmt.Println(err)
  3505. // result := int(ret)
  3506. // return result
  3507. //}
  3508. func IntPtr(n int) uintptr {
  3509. return uintptr(n)
  3510. }
  3511. func StrPtr(s string) uintptr {
  3512. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3513. }
  3514. type Result2001 struct {
  3515. Cainfo interface{} `json:"cainfo"`
  3516. ErrMsg string `json:"err_msg"`
  3517. InfRefmsgid string `json:"inf_refmsgid"`
  3518. Infcode int64 `json:"infcode"`
  3519. Output struct {
  3520. Trtinfo struct {
  3521. PsnNo string `json:"psn_no"`
  3522. TrtChkType string `json:"trt_chk_type"`
  3523. FundPayType string `json:"fund_pay_type"`
  3524. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3525. Begndate string `json:"begndate"`
  3526. Enddate string `json:"enddate"`
  3527. TrtChkRslt string `json:"trt_chk_rslt"`
  3528. } `json:"trtinfo"`
  3529. } `json:"output"`
  3530. RefmsgTime string `json:"refmsg_time"`
  3531. RespondTime string `json:"respond_time"`
  3532. Signtype interface{} `json:"signtype"`
  3533. WarnMsg interface{} `json:"warn_msg"`
  3534. }
  3535. type Result2001Org10265 struct {
  3536. Cainfo interface{} `json:"cainfo"`
  3537. ErrMsg string `json:"err_msg"`
  3538. InfRefmsgid string `json:"inf_refmsgid"`
  3539. Infcode string `json:"infcode"`
  3540. Output struct {
  3541. Trtinfo struct {
  3542. PsnNo string `json:"psn_no"`
  3543. TrtChkType string `json:"trt_chk_type"`
  3544. FundPayType string `json:"fund_pay_type"`
  3545. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3546. Begndate string `json:"begndate"`
  3547. Enddate string `json:"enddate"`
  3548. TrtChkRslt string `json:"trt_chk_rslt"`
  3549. } `json:"trtinfo"`
  3550. } `json:"output"`
  3551. RefmsgTime string `json:"refmsg_time"`
  3552. RespondTime string `json:"respond_time"`
  3553. Signtype interface{} `json:"signtype"`
  3554. WarnMsg interface{} `json:"warn_msg"`
  3555. }
  3556. type ResultTwo struct {
  3557. ErrMsg string `json:"err_msg"`
  3558. InfRefmsgid string `json:"inf_refmsgid"`
  3559. Infcode int64 `json:"infcode"`
  3560. Output struct {
  3561. Baseinfo struct {
  3562. Age float64 `json:"age"`
  3563. Brdy string `json:"brdy"`
  3564. Certno string `json:"certno"`
  3565. Gend string `json:"gend"`
  3566. Naty string `json:"naty"`
  3567. PsnCertType string `json:"psn_cert_type"`
  3568. PsnName string `json:"psn_name"`
  3569. PsnNo string `json:"psn_no"`
  3570. } `json:"baseinfo"`
  3571. Idetinfo []interface{} `json:"idetinfo"`
  3572. Iinfo []struct {
  3573. Balc float64 `json:"balc"`
  3574. CvlservFlag string `json:"cvlserv_flag"`
  3575. EmpName string `json:"emp_name"`
  3576. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3577. Insutype string `json:"insutype"`
  3578. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3579. PausInsuDate string `json:"paus_insu_date"`
  3580. PsnInsuDate string `json:"psn_insu_date"`
  3581. PsnInsuStas string `json:"psn_insu_stas"`
  3582. PsnType string `json:"psn_type"`
  3583. } `json:"insuinfo"`
  3584. } `json:"output"`
  3585. RefmsgTime string `json:"refmsg_time"`
  3586. RespondTime string `json:"respond_time"`
  3587. Signtype interface{} `json:"signtype"`
  3588. WarnInfo interface{} `json:"warn_info"`
  3589. }
  3590. type ResultTwo10265 struct {
  3591. ErrMsg string `json:"err_msg"`
  3592. InfRefmsgid string `json:"inf_refmsgid"`
  3593. Infcode string `json:"infcode"`
  3594. Output struct {
  3595. Baseinfo struct {
  3596. Age float64 `json:"age"`
  3597. Brdy string `json:"brdy"`
  3598. Certno string `json:"certno"`
  3599. Gend string `json:"gend"`
  3600. Naty string `json:"naty"`
  3601. PsnCertType string `json:"psn_cert_type"`
  3602. PsnName string `json:"psn_name"`
  3603. PsnNo string `json:"psn_no"`
  3604. } `json:"baseinfo"`
  3605. Idetinfo []interface{} `json:"idetinfo"`
  3606. Iinfo []struct {
  3607. Balc float64 `json:"balc"`
  3608. CvlservFlag string `json:"cvlserv_flag"`
  3609. EmpName string `json:"emp_name"`
  3610. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3611. Insutype string `json:"insutype"`
  3612. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3613. PausInsuDate string `json:"paus_insu_date"`
  3614. PsnInsuDate string `json:"psn_insu_date"`
  3615. PsnInsuStas string `json:"psn_insu_stas"`
  3616. PsnType string `json:"psn_type"`
  3617. } `json:"insuinfo"`
  3618. } `json:"output"`
  3619. RefmsgTime string `json:"refmsg_time"`
  3620. RespondTime string `json:"respond_time"`
  3621. Signtype interface{} `json:"signtype"`
  3622. WarnInfo interface{} `json:"warn_info"`
  3623. }
  3624. type ResultThree struct {
  3625. Cainfo interface{} `json:"cainfo"`
  3626. ErrMsg string `json:"err_msg"`
  3627. InfRefmsgid string `json:"inf_refmsgid"`
  3628. Infcode int64 `json:"infcode"`
  3629. Output struct {
  3630. Data struct {
  3631. IptOtpNo string `json:"ipt_otp_no"`
  3632. MdtrtID string `json:"mdtrt_id"`
  3633. PsnNo string `json:"psn_no"`
  3634. } `json:"data"`
  3635. } `json:"output"`
  3636. RefmsgTime string `json:"refmsg_time"`
  3637. RespondTime string `json:"respond_time"`
  3638. Signtype interface{} `json:"signtype"`
  3639. WarnMsg interface{} `json:"warn_msg"`
  3640. }
  3641. type ResultThree10265 struct {
  3642. Cainfo interface{} `json:"cainfo"`
  3643. ErrMsg string `json:"err_msg"`
  3644. InfRefmsgid string `json:"inf_refmsgid"`
  3645. Infcode string `json:"infcode"`
  3646. Output struct {
  3647. Data struct {
  3648. IptOtpNo string `json:"ipt_otp_no"`
  3649. MdtrtID string `json:"mdtrt_id"`
  3650. PsnNo string `json:"psn_no"`
  3651. } `json:"data"`
  3652. } `json:"output"`
  3653. RefmsgTime string `json:"refmsg_time"`
  3654. RespondTime string `json:"respond_time"`
  3655. Signtype interface{} `json:"signtype"`
  3656. WarnMsg interface{} `json:"warn_msg"`
  3657. }
  3658. type ResultFour struct {
  3659. Cainfo string `json:"cainfo"`
  3660. ErrMsg string `json:"err_msg"`
  3661. InfRefmsgid string `json:"inf_refmsgid"`
  3662. Infcode int64 `json:"infcode"`
  3663. Output struct {
  3664. Result []struct {
  3665. BasMednFlag string `json:"bas_medn_flag"`
  3666. ChldMedcFlag string `json:"chld_medc_flag"`
  3667. ChrgitmLv string `json:"chrgitm_lv"`
  3668. Cnt float64 `json:"cnt"`
  3669. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3670. DrtReimFlag string `json:"drt_reim_flag"`
  3671. FeedetlSn string `json:"feedetl_sn"`
  3672. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3673. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3674. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3675. ListSpItemFlag string `json:"list_sp_item_flag"`
  3676. LmtUsedFlag string `json:"lmt_used_flag"`
  3677. MedChrgitmType string `json:"med_chrgitm_type"`
  3678. Memo string `json:"memo"`
  3679. OverlmtAmt float64 `json:"overlmt_amt"`
  3680. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3681. Pric float64 `json:"pric"`
  3682. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3683. SelfpayProp float64 `json:"selfpay_prop"`
  3684. } `json:"result"`
  3685. } `json:"output"`
  3686. RefmsgTime string `json:"refmsg_time"`
  3687. RespondTime string `json:"respond_time"`
  3688. Signtype string `json:"signtype"`
  3689. WarnMsg string `json:"warn_msg"`
  3690. }
  3691. type ResultFour10265 struct {
  3692. Cainfo string `json:"cainfo"`
  3693. ErrMsg string `json:"err_msg"`
  3694. InfRefmsgid string `json:"inf_refmsgid"`
  3695. Infcode string `json:"infcode"`
  3696. Output struct {
  3697. Result []struct {
  3698. BasMednFlag string `json:"bas_medn_flag"`
  3699. ChldMedcFlag string `json:"chld_medc_flag"`
  3700. ChrgitmLv string `json:"chrgitm_lv"`
  3701. Cnt float64 `json:"cnt"`
  3702. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3703. DrtReimFlag string `json:"drt_reim_flag"`
  3704. FeedetlSn string `json:"feedetl_sn"`
  3705. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3706. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3707. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3708. ListSpItemFlag string `json:"list_sp_item_flag"`
  3709. LmtUsedFlag string `json:"lmt_used_flag"`
  3710. MedChrgitmType string `json:"med_chrgitm_type"`
  3711. Memo string `json:"memo"`
  3712. OverlmtAmt float64 `json:"overlmt_amt"`
  3713. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3714. Pric float64 `json:"pric"`
  3715. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3716. SelfpayProp float64 `json:"selfpay_prop"`
  3717. } `json:"result"`
  3718. } `json:"output"`
  3719. RefmsgTime string `json:"refmsg_time"`
  3720. RespondTime string `json:"respond_time"`
  3721. Signtype string `json:"signtype"`
  3722. WarnMsg string `json:"warn_msg"`
  3723. }
  3724. type ResultFive struct {
  3725. Balc float64 `json:"balc"`
  3726. CvlservFlag string `json:"cvlserv_flag"`
  3727. EmpName string `json:"emp_name"`
  3728. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3729. Insutype string `json:"insutype"`
  3730. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3731. PausInsuDate string `json:"paus_insu_date"`
  3732. PsnInsuDate string `json:"psn_insu_date"`
  3733. PsnInsuStas string `json:"psn_insu_stas"`
  3734. PsnType string `json:"psn_type"`
  3735. }
  3736. type ResultSix struct {
  3737. Cainfo interface{} `json:"cainfo"`
  3738. ErrMsg string `json:"err_msg"`
  3739. InfRefmsgid string `json:"inf_refmsgid"`
  3740. Infcode int64 `json:"infcode"`
  3741. Output struct {
  3742. } `json:"output"`
  3743. RefmsgTime string `json:"refmsg_time"`
  3744. RespondTime string `json:"respond_time"`
  3745. Signtype interface{} `json:"signtype"`
  3746. WarnMsg interface{} `json:"warn_msg"`
  3747. }
  3748. type ResultSix10265 struct {
  3749. Cainfo interface{} `json:"cainfo"`
  3750. ErrMsg string `json:"err_msg"`
  3751. InfRefmsgid string `json:"inf_refmsgid"`
  3752. Infcode string `json:"infcode"`
  3753. Output struct {
  3754. } `json:"output"`
  3755. RefmsgTime string `json:"refmsg_time"`
  3756. RespondTime string `json:"respond_time"`
  3757. Signtype interface{} `json:"signtype"`
  3758. WarnMsg interface{} `json:"warn_msg"`
  3759. }
  3760. type ResultSeven struct {
  3761. Cainfo string `json:"cainfo"`
  3762. ErrMsg string `json:"err_msg"`
  3763. InfRefmsgid string `json:"inf_refmsgid"`
  3764. Infcode int64 `json:"infcode"`
  3765. Output struct {
  3766. Setldetail []interface{} `json:"setldetail"`
  3767. Setlinfo struct {
  3768. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3769. AcctPay float64 `json:"acct_pay"`
  3770. ActPayDedc float64 `json:"act_pay_dedc"`
  3771. Age float64 `json:"age"`
  3772. Balc float64 `json:"balc"`
  3773. Brdy string `json:"brdy"`
  3774. Certno string `json:"certno"`
  3775. ClrOptins string `json:"clr_optins"`
  3776. ClrType string `json:"clr_type"`
  3777. ClrWay string `json:"clr_way"`
  3778. CvlservFlag string `json:"cvlserv_flag"`
  3779. CvlservPay float64 `json:"cvlserv_pay"`
  3780. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3781. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3782. Gend string `json:"gend"`
  3783. HifesPay float64 `json:"hifes_pay"`
  3784. HifmiPay float64 `json:"hifmi_pay"`
  3785. HifpPay float64 `json:"hifp_pay"`
  3786. HospPartAmt float64 `json:"hosp_part_amt"`
  3787. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3788. Insutype string `json:"insutype"`
  3789. MafPay float64 `json:"maf_pay"`
  3790. MdtrtCertType string `json:"mdtrt_cert_type"`
  3791. HifobPay float64 `json:"hifob_pay"`
  3792. MdtrtID string `json:"mdtrt_id"`
  3793. MedType string `json:"med_type"`
  3794. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3795. MedinsSetlID string `json:"medins_setl_id"`
  3796. Naty string `json:"naty"`
  3797. OthPay float64 `json:"oth_pay"`
  3798. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3799. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3800. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3801. PsnCashPay float64 `json:"psn_cash_pay"`
  3802. PsnCertType string `json:"psn_cert_type"`
  3803. PsnName string `json:"psn_name"`
  3804. PsnNo string `json:"psn_no"`
  3805. PsnPartAmt float64 `json:"psn_part_amt"`
  3806. PsnType string `json:"psn_type"`
  3807. SetlID string `json:"setl_id"`
  3808. SetlTime string `json:"setl_time"`
  3809. } `json:"setlinfo"`
  3810. } `json:"output"`
  3811. RefmsgTime string `json:"refmsg_time"`
  3812. RespondTime string `json:"respond_time"`
  3813. Signtype interface{} `json:"signtype"`
  3814. WarnMsg interface{} `json:"warn_msg"`
  3815. }
  3816. type ResultSeven10265 struct {
  3817. Cainfo string `json:"cainfo"`
  3818. ErrMsg string `json:"err_msg"`
  3819. InfRefmsgid string `json:"inf_refmsgid"`
  3820. Infcode string `json:"infcode"`
  3821. Output struct {
  3822. Setldetail []interface{} `json:"setldetail"`
  3823. Setlinfo struct {
  3824. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3825. AcctPay float64 `json:"acct_pay"`
  3826. ActPayDedc float64 `json:"act_pay_dedc"`
  3827. Age float64 `json:"age"`
  3828. Balc float64 `json:"balc"`
  3829. Brdy string `json:"brdy"`
  3830. Certno string `json:"certno"`
  3831. ClrOptins string `json:"clr_optins"`
  3832. ClrType string `json:"clr_type"`
  3833. ClrWay string `json:"clr_way"`
  3834. CvlservFlag string `json:"cvlserv_flag"`
  3835. CvlservPay float64 `json:"cvlserv_pay"`
  3836. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3837. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3838. Gend string `json:"gend"`
  3839. HifesPay float64 `json:"hifes_pay"`
  3840. HifmiPay float64 `json:"hifmi_pay"`
  3841. HifpPay float64 `json:"hifp_pay"`
  3842. HospPartAmt float64 `json:"hosp_part_amt"`
  3843. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3844. Insutype string `json:"insutype"`
  3845. MafPay float64 `json:"maf_pay"`
  3846. MdtrtCertType string `json:"mdtrt_cert_type"`
  3847. HifobPay float64 `json:"hifob_pay"`
  3848. MdtrtID string `json:"mdtrt_id"`
  3849. MedType string `json:"med_type"`
  3850. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3851. MedinsSetlID string `json:"medins_setl_id"`
  3852. Naty string `json:"naty"`
  3853. OthPay float64 `json:"oth_pay"`
  3854. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3855. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3856. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3857. PsnCashPay float64 `json:"psn_cash_pay"`
  3858. PsnCertType string `json:"psn_cert_type"`
  3859. PsnName string `json:"psn_name"`
  3860. PsnNo string `json:"psn_no"`
  3861. PsnPartAmt float64 `json:"psn_part_amt"`
  3862. PsnType string `json:"psn_type"`
  3863. SetlID string `json:"setl_id"`
  3864. SetlTime string `json:"setl_time"`
  3865. } `json:"setlinfo"`
  3866. } `json:"output"`
  3867. RefmsgTime string `json:"refmsg_time"`
  3868. RespondTime string `json:"respond_time"`
  3869. Signtype interface{} `json:"signtype"`
  3870. WarnMsg interface{} `json:"warn_msg"`
  3871. }
  3872. type ResultEight struct {
  3873. Cainfo string `json:"cainfo"`
  3874. ErrMsg string `json:"err_msg"`
  3875. InfRefmsgid string `json:"inf_refmsgid"`
  3876. Infcode int64 `json:"infcode"`
  3877. Output struct {
  3878. Stmtinfo struct {
  3879. SetlOptins string `json:"setl_optins"`
  3880. StmtRslt string `json:"stmt_rslt"`
  3881. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3882. } `json:"stmtinfo"`
  3883. } `json:"output"`
  3884. RefmsgTime string `json:"refmsg_time"`
  3885. RespondTime string `json:"respond_time"`
  3886. Signtype interface{} `json:"signtype"`
  3887. WarnMsg interface{} `json:"warn_msg"`
  3888. }
  3889. type ResultEightFor10188 struct {
  3890. Cainfo string `json:"cainfo"`
  3891. ErrMsg string `json:"err_msg"`
  3892. InfRefmsgid string `json:"inf_refmsgid"`
  3893. Infcode string `json:"infcode"`
  3894. Output struct {
  3895. Stmtinfo struct {
  3896. SetlOptins string `json:"setl_optins"`
  3897. StmtRslt string `json:"stmt_rslt"`
  3898. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3899. } `json:"stmtinfo"`
  3900. } `json:"output"`
  3901. RefmsgTime string `json:"refmsg_time"`
  3902. RespondTime string `json:"respond_time"`
  3903. Signtype interface{} `json:"signtype"`
  3904. WarnMsg interface{} `json:"warn_msg"`
  3905. }
  3906. type ResultNine struct {
  3907. Cainfo string `json:"cainfo"`
  3908. ErrMsg string `json:"err_msg"`
  3909. InfRefmsgid string `json:"inf_refmsgid"`
  3910. Infcode int64 `json:"infcode"`
  3911. Output struct {
  3912. FileQuryNo string `json:"file_qury_no"`
  3913. } `json:"output"`
  3914. RefmsgTime string `json:"refmsg_time"`
  3915. RespondTime string `json:"respond_time"`
  3916. Signtype interface{} `json:"signtype"`
  3917. WarnMsg interface{} `json:"warn_msg"`
  3918. }
  3919. type ResultTen struct {
  3920. Cainfo string `json:"cainfo"`
  3921. ErrMsg string `json:"err_msg"`
  3922. InfRefmsgid string `json:"inf_refmsgid"`
  3923. Infcode int64 `json:"infcode"`
  3924. Output struct {
  3925. DldEndtime string `json:"dld_endtime"`
  3926. FileQuryNo string `json:"file_qury_no"`
  3927. Filename string `json:"filename"`
  3928. } `json:"output"`
  3929. RefmsgTime string `json:"refmsg_time"`
  3930. RespondTime string `json:"respond_time"`
  3931. Signtype interface{} `json:"signtype"`
  3932. WarnMsg interface{} `json:"warn_msg"`
  3933. }
  3934. //type Autogenerated struct {
  3935. // Output struct {
  3936. // Setlinfo struct {
  3937. // SetlTime string `json:"setl_time"`
  3938. // CvlservPay float64 `json:"cvlserv_pay"`
  3939. // Year string `json:"year"`
  3940. // MedType string `json:"med_type"`
  3941. // PsnPay float64 `json:"psn_pay"`
  3942. // OpterID string `json:"opter_id"`
  3943. // Begndate string `json:"begndate"`
  3944. // FlxempeFlag string `json:"flxempe_flag"`
  3945. // HifmiPay float64 `json:"hifmi_pay"`
  3946. // PsnNo string `json:"psn_no"`
  3947. // ActPayDedc float64 `json:"act_pay_dedc"`
  3948. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3949. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3950. // ClrWay string `json:"clr_way"`
  3951. // OthPay float64 `json:"oth_pay"`
  3952. // Gend string `json:"gend"`
  3953. // MdtrtID string `json:"mdtrt_id"`
  3954. // AcctPay float64 `json:"acct_pay"`
  3955. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3956. // Insutype string `json:"insutype"`
  3957. // Invono interface{} `json:"invono"`
  3958. // Enddate string `json:"enddate"`
  3959. // CashPayamt float64 `json:"cash_payamt"`
  3960. // PsnType string `json:"psn_type"`
  3961. // FixmedinsName string `json:"fixmedins_name"`
  3962. // HifpPay float64 `json:"hifp_pay"`
  3963. // NewFlag interface{} `json:"new_flag"`
  3964. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3965. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3966. // PayLoc string `json:"pay_loc"`
  3967. // ClrType string `json:"clr_type"`
  3968. // RefdSetlFlag string `json:"refd_setl_flag"`
  3969. // CvlservFlag string `json:"cvlserv_flag"`
  3970. // EmpName string `json:"emp_name"`
  3971. // Brdy string `json:"brdy"`
  3972. // Naty string `json:"naty"`
  3973. // Certno string `json:"certno"`
  3974. // DiseCode string `json:"dise_code"`
  3975. // FixmedinsCode string `json:"fixmedins_code"`
  3976. // DedcHospLv string `json:"dedc_hosp_lv"`
  3977. // OpterName string `json:"opter_name"`
  3978. // Balc float64 `json:"balc"`
  3979. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3980. // PsnCertType string `json:"psn_cert_type"`
  3981. // HifobPay float64 `json:"hifob_pay"`
  3982. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3983. // HifesPay float64 `json:"hifes_pay"`
  3984. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3985. // OptTime string `json:"opt_time"`
  3986. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3987. // SetlID string `json:"setl_id"`
  3988. // MafPay float64 `json:"maf_pay"`
  3989. // PsnName string `json:"psn_name"`
  3990. // InsuOptins interface{} `json:"insu_optins"`
  3991. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3992. // ClrOptins string `json:"clr_optins"`
  3993. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3994. // DiseName string `json:"dise_name"`
  3995. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3996. // Age float64 `json:"age"`
  3997. // DtrtCertType string `json:"dtrt_cert_type"`
  3998. // HospLv string `json:"hosp_lv"`
  3999. // } `json:"setlinfo"`
  4000. // Setldetail []struct {
  4001. // FundPayType string `json:"fund_pay_type"`
  4002. // FundPayamt float64 `json:"fund_payamt"`
  4003. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4004. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4005. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4006. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4007. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4008. // } `json:"setldetail"`
  4009. // } `json:"output"`
  4010. // Infcode int `json:"infcode"`
  4011. // WarnMsg interface{} `json:"warn_msg"`
  4012. // Cainfo interface{} `json:"cainfo"`
  4013. // ErrMsg interface{} `json:"err_msg"`
  4014. // RefmsgTime string `json:"refmsg_time"`
  4015. // Signtype interface{} `json:"signtype"`
  4016. // RespondTime string `json:"respond_time"`
  4017. // InfRefmsgid string `json:"inf_refmsgid"`
  4018. //}
  4019. type ResultEleven struct {
  4020. Cainfo string `json:"cainfo"`
  4021. ErrMsg string `json:"err_msg"`
  4022. InfRefmsgid string `json:"inf_refmsgid"`
  4023. Infcode int64 `json:"infcode"`
  4024. Output struct {
  4025. Setlinfo struct {
  4026. SetlTime string `json:"setl_time"`
  4027. CvlservPay float64 `json:"cvlserv_pay"`
  4028. Year string `json:"year"`
  4029. MedType string `json:"med_type"`
  4030. PsnPay float64 `json:"psn_pay"`
  4031. OpterID string `json:"opter_id"`
  4032. Begndate string `json:"begndate"`
  4033. FlxempeFlag string `json:"flxempe_flag"`
  4034. HifmiPay float64 `json:"hifmi_pay"`
  4035. PsnNo string `json:"psn_no"`
  4036. ActPayDedc float64 `json:"act_pay_dedc"`
  4037. MedinsSetlID interface{} `json:"medins_setl_id"`
  4038. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4039. ClrWay string `json:"clr_way"`
  4040. OthPay float64 `json:"oth_pay"`
  4041. Gend string `json:"gend"`
  4042. MdtrtID string `json:"mdtrt_id"`
  4043. AcctPay float64 `json:"acct_pay"`
  4044. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4045. Insutype string `json:"insutype"`
  4046. Invono interface{} `json:"invono"`
  4047. Enddate string `json:"enddate"`
  4048. CashPayamt float64 `json:"cash_payamt"`
  4049. PsnType string `json:"psn_type"`
  4050. FixmedinsName string `json:"fixmedins_name"`
  4051. HifpPay float64 `json:"hifp_pay"`
  4052. NewFlag interface{} `json:"new_flag"`
  4053. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4054. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4055. PayLoc string `json:"pay_loc"`
  4056. ClrType string `json:"clr_type"`
  4057. RefdSetlFlag string `json:"refd_setl_flag"`
  4058. CvlservFlag string `json:"cvlserv_flag"`
  4059. EmpName string `json:"emp_name"`
  4060. Brdy string `json:"brdy"`
  4061. Naty string `json:"naty"`
  4062. Certno string `json:"certno"`
  4063. DiseCode string `json:"dise_code"`
  4064. FixmedinsCode string `json:"fixmedins_code"`
  4065. DedcHospLv string `json:"dedc_hosp_lv"`
  4066. OpterName string `json:"opter_name"`
  4067. Balc float64 `json:"balc"`
  4068. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4069. PsnCertType string `json:"psn_cert_type"`
  4070. HifobPay float64 `json:"hifob_pay"`
  4071. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4072. HifesPay float64 `json:"hifes_pay"`
  4073. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4074. OptTime string `json:"opt_time"`
  4075. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4076. SetlID string `json:"setl_id"`
  4077. MafPay float64 `json:"maf_pay"`
  4078. PsnName string `json:"psn_name"`
  4079. InsuOptins interface{} `json:"insu_optins"`
  4080. PrefFundPay interface{} `json:"pref_fund_pay"`
  4081. ClrOptins string `json:"clr_optins"`
  4082. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4083. DiseName string `json:"dise_name"`
  4084. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4085. Age float64 `json:"age"`
  4086. DtrtCertType string `json:"dtrt_cert_type"`
  4087. HospLv string `json:"hosp_lv"`
  4088. } `json:"setlinfo"`
  4089. } `json:"output"`
  4090. RefmsgTime string `json:"refmsg_time"`
  4091. RespondTime string `json:"respond_time"`
  4092. Signtype interface{} `json:"signtype"`
  4093. WarnMsg interface{} `json:"warn_msg"`
  4094. }
  4095. type ResultEleven10265 struct {
  4096. Cainfo string `json:"cainfo"`
  4097. ErrMsg string `json:"err_msg"`
  4098. InfRefmsgid string `json:"inf_refmsgid"`
  4099. Infcode string `json:"infcode"`
  4100. Output struct {
  4101. Setlinfo struct {
  4102. SetlTime string `json:"setl_time"`
  4103. CvlservPay float64 `json:"cvlserv_pay"`
  4104. Year string `json:"year"`
  4105. MedType string `json:"med_type"`
  4106. PsnPay float64 `json:"psn_pay"`
  4107. OpterID string `json:"opter_id"`
  4108. Begndate string `json:"begndate"`
  4109. FlxempeFlag string `json:"flxempe_flag"`
  4110. HifmiPay float64 `json:"hifmi_pay"`
  4111. PsnNo string `json:"psn_no"`
  4112. ActPayDedc float64 `json:"act_pay_dedc"`
  4113. MedinsSetlID interface{} `json:"medins_setl_id"`
  4114. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4115. ClrWay string `json:"clr_way"`
  4116. OthPay float64 `json:"oth_pay"`
  4117. Gend string `json:"gend"`
  4118. MdtrtID string `json:"mdtrt_id"`
  4119. AcctPay float64 `json:"acct_pay"`
  4120. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4121. Insutype string `json:"insutype"`
  4122. Invono interface{} `json:"invono"`
  4123. Enddate string `json:"enddate"`
  4124. CashPayamt float64 `json:"cash_payamt"`
  4125. PsnType string `json:"psn_type"`
  4126. FixmedinsName string `json:"fixmedins_name"`
  4127. HifpPay float64 `json:"hifp_pay"`
  4128. NewFlag interface{} `json:"new_flag"`
  4129. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4130. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4131. PayLoc string `json:"pay_loc"`
  4132. ClrType string `json:"clr_type"`
  4133. RefdSetlFlag string `json:"refd_setl_flag"`
  4134. CvlservFlag string `json:"cvlserv_flag"`
  4135. EmpName string `json:"emp_name"`
  4136. Brdy string `json:"brdy"`
  4137. Naty string `json:"naty"`
  4138. Certno string `json:"certno"`
  4139. DiseCode string `json:"dise_code"`
  4140. FixmedinsCode string `json:"fixmedins_code"`
  4141. DedcHospLv string `json:"dedc_hosp_lv"`
  4142. OpterName string `json:"opter_name"`
  4143. Balc float64 `json:"balc"`
  4144. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4145. PsnCertType string `json:"psn_cert_type"`
  4146. HifobPay float64 `json:"hifob_pay"`
  4147. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4148. HifesPay float64 `json:"hifes_pay"`
  4149. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4150. OptTime string `json:"opt_time"`
  4151. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4152. SetlID string `json:"setl_id"`
  4153. MafPay float64 `json:"maf_pay"`
  4154. PsnName string `json:"psn_name"`
  4155. InsuOptins interface{} `json:"insu_optins"`
  4156. PrefFundPay interface{} `json:"pref_fund_pay"`
  4157. ClrOptins string `json:"clr_optins"`
  4158. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4159. DiseName string `json:"dise_name"`
  4160. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4161. Age float64 `json:"age"`
  4162. DtrtCertType string `json:"dtrt_cert_type"`
  4163. HospLv string `json:"hosp_lv"`
  4164. } `json:"setlinfo"`
  4165. } `json:"output"`
  4166. RefmsgTime string `json:"refmsg_time"`
  4167. RespondTime string `json:"respond_time"`
  4168. Signtype interface{} `json:"signtype"`
  4169. WarnMsg interface{} `json:"warn_msg"`
  4170. }
  4171. type ResultTwelve struct {
  4172. Cainfo string `json:"cainfo"`
  4173. ErrMsg string `json:"err_msg"`
  4174. InfRefmsgid string `json:"inf_refmsgid"`
  4175. Infcode int64 `json:"infcode"`
  4176. Output struct {
  4177. MdtrtId string `json:"mdtrt_id"`
  4178. ChrgBchno string `json:"chrg_bchno"`
  4179. PsnNo string `json:"psn_no"`
  4180. } `json:"output"`
  4181. RefmsgTime string `json:"refmsg_time"`
  4182. RespondTime string `json:"respond_time"`
  4183. Signtype interface{} `json:"signtype"`
  4184. WarnMsg interface{} `json:"warn_msg"`
  4185. }
  4186. type ResultThirteen struct {
  4187. ErrMsg string `json:"err_msg"`
  4188. InfRefmsgid string `json:"inf_refmsgid"`
  4189. Infcode int64 `json:"infcode"`
  4190. Output struct {
  4191. Result struct {
  4192. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4193. } `json:"result"`
  4194. } `json:"output"`
  4195. RefmsgTime string `json:"refmsg_time"`
  4196. RespondTime string `json:"respond_time"`
  4197. Signtype interface{} `json:"signtype"`
  4198. WarnInfo interface{} `json:"warn_info"`
  4199. }
  4200. type ResultThirteen10265 struct {
  4201. ErrMsg string `json:"err_msg"`
  4202. InfRefmsgid string `json:"inf_refmsgid"`
  4203. Infcode string `json:"infcode"`
  4204. Output struct {
  4205. Result struct {
  4206. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4207. } `json:"result"`
  4208. } `json:"output"`
  4209. RefmsgTime string `json:"refmsg_time"`
  4210. RespondTime string `json:"respond_time"`
  4211. Signtype interface{} `json:"signtype"`
  4212. WarnInfo interface{} `json:"warn_info"`
  4213. }
  4214. type ResultFourteen struct {
  4215. ErrMsg string `json:"err_msg"`
  4216. InfRefmsgid string `json:"inf_refmsgid"`
  4217. Infcode int64 `json:"infcode"`
  4218. Output struct {
  4219. } `json:"output"`
  4220. RefmsgTime string `json:"refmsg_time"`
  4221. RespondTime string `json:"respond_time"`
  4222. Signtype interface{} `json:"signtype"`
  4223. WarnInfo interface{} `json:"warn_info"`
  4224. }
  4225. type ResultFourteen10265 struct {
  4226. ErrMsg string `json:"err_msg"`
  4227. InfRefmsgid string `json:"inf_refmsgid"`
  4228. Infcode string `json:"infcode"`
  4229. Output struct {
  4230. } `json:"output"`
  4231. RefmsgTime string `json:"refmsg_time"`
  4232. RespondTime string `json:"respond_time"`
  4233. Signtype interface{} `json:"signtype"`
  4234. WarnInfo interface{} `json:"warn_info"`
  4235. }
  4236. type ResultSixteen struct {
  4237. Cainfo string `json:"cainfo"`
  4238. ErrMsg string `json:"err_msg"`
  4239. InfRefmsgid string `json:"inf_refmsgid"`
  4240. Infcode int64 `json:"infcode"`
  4241. Output struct {
  4242. Setldetail []interface{} `json:"setldetail"`
  4243. Setlinfo struct {
  4244. MdtrtID string `json:"mdtrt_id"`
  4245. SetlID string `json:"setl_id"`
  4246. ClrOptins string `json:"clr_optins"`
  4247. SetlTime string `json:"setl_time"`
  4248. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4249. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4250. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4251. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4252. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4253. ActPayDedc float64 `json:"act_pay_dedc"`
  4254. HifpPay float64 `json:"hifp_pay"`
  4255. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4256. Lfpay float64 `json:"selfpay"`
  4257. CvlservPay float64 `json:"cvlserv_pay"`
  4258. HifesPay float64 `json:"hifes_pay"`
  4259. HifmiPay float64 `json:"hifmi_pay"`
  4260. HifobPay float64 `json:"hifob_pay"`
  4261. MafPay float64 `json:"maf_pay"`
  4262. OthPay float64 `json:"oth_pay"`
  4263. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4264. PsnPartAmt float64 `json:"psn_part_amt"`
  4265. AcctPay float64 `json:"acct_pay"`
  4266. Balc float64 `json:"balc"`
  4267. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4268. HospPartAmt float64 `json:"hosp_part_amt"`
  4269. MedinsSetlID string `json:"medins_setl_id"`
  4270. PdnCashPay string `json:"pdn_cash_pay"`
  4271. } `json:"setlinfo"`
  4272. } `json:"output"`
  4273. RefmsgTime string `json:"refmsg_time"`
  4274. RespondTime string `json:"respond_time"`
  4275. Signtype interface{} `json:"signtype"`
  4276. WarnMsg interface{} `json:"warn_msg"`
  4277. }
  4278. type ResultSixteen10265 struct {
  4279. Cainfo string `json:"cainfo"`
  4280. ErrMsg string `json:"err_msg"`
  4281. InfRefmsgid string `json:"inf_refmsgid"`
  4282. Infcode string `json:"infcode"`
  4283. Output struct {
  4284. Setldetail []interface{} `json:"setldetail"`
  4285. Setlinfo struct {
  4286. MdtrtID string `json:"mdtrt_id"`
  4287. SetlID string `json:"setl_id"`
  4288. ClrOptins string `json:"clr_optins"`
  4289. SetlTime string `json:"setl_time"`
  4290. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4291. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4292. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4293. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4294. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4295. ActPayDedc float64 `json:"act_pay_dedc"`
  4296. HifpPay float64 `json:"hifp_pay"`
  4297. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4298. Lfpay float64 `json:"selfpay"`
  4299. CvlservPay float64 `json:"cvlserv_pay"`
  4300. HifesPay float64 `json:"hifes_pay"`
  4301. HifmiPay float64 `json:"hifmi_pay"`
  4302. HifobPay float64 `json:"hifob_pay"`
  4303. MafPay float64 `json:"maf_pay"`
  4304. OthPay float64 `json:"oth_pay"`
  4305. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4306. PsnPartAmt float64 `json:"psn_part_amt"`
  4307. AcctPay float64 `json:"acct_pay"`
  4308. Balc float64 `json:"balc"`
  4309. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4310. HospPartAmt float64 `json:"hosp_part_amt"`
  4311. MedinsSetlID string `json:"medins_setl_id"`
  4312. PdnCashPay string `json:"pdn_cash_pay"`
  4313. } `json:"setlinfo"`
  4314. } `json:"output"`
  4315. RefmsgTime string `json:"refmsg_time"`
  4316. RespondTime string `json:"respond_time"`
  4317. Signtype interface{} `json:"signtype"`
  4318. WarnMsg interface{} `json:"warn_msg"`
  4319. }
  4320. type ResultSeventeen struct {
  4321. ErrMsg string `json:"err_msg"`
  4322. InfRefmsgid string `json:"inf_refmsgid"`
  4323. Infcode int64 `json:"infcode"`
  4324. Output struct {
  4325. SetlListId string `json:"setl_list_id"`
  4326. } `json:"output"`
  4327. RefmsgTime string `json:"refmsg_time"`
  4328. RespondTime string `json:"respond_time"`
  4329. Signtype string `json:"signtype"`
  4330. WarnInfo string `json:"warn_info"`
  4331. }
  4332. type ResultSeventeenOther struct {
  4333. ErrMsg string `json:"err_msg"`
  4334. InfRefmsgid string `json:"inf_refmsgid"`
  4335. Infcode string `json:"infcode"`
  4336. Output struct {
  4337. SetlListId string `json:"setl_list_id"`
  4338. } `json:"output"`
  4339. RefmsgTime string `json:"refmsg_time"`
  4340. RespondTime string `json:"respond_time"`
  4341. Signtype string `json:"signtype"`
  4342. WarnInfo string `json:"warn_info"`
  4343. }
  4344. type Result90991 struct {
  4345. ErrMsg string `json:"err_msg"`
  4346. InfRefmsgid string `json:"inf_refmsgid"`
  4347. Infcode int64 `json:"infcode"`
  4348. Output struct {
  4349. Result struct {
  4350. PsnNo string `json:"psn_no"`
  4351. CardStat string `json:"card_stat"`
  4352. Certno string `json:"certno"`
  4353. PsnName string `json:"psn_name"`
  4354. CheckStat string `json:"check_stat"`
  4355. SscnoCheckStat string `json:"sscno_check_stat"`
  4356. } `json:"result"`
  4357. } `json:"output"`
  4358. RefmsgTime string `json:"refmsg_time"`
  4359. RespondTime string `json:"respond_time"`
  4360. Signtype interface{} `json:"signtype"`
  4361. WarnInfo interface{} `json:"warn_info"`
  4362. }
  4363. type Result90100 struct {
  4364. ErrMsg string `json:"err_msg"`
  4365. InfRefmsgid string `json:"inf_refmsgid"`
  4366. Infcode int64 `json:"infcode"`
  4367. Output struct {
  4368. PoolareaNo string `json:"poolarea_no"`
  4369. PoolareaNoName string `json:"poolarea_no_name"`
  4370. Insutype string `json:"insutype"`
  4371. InsutypeName string `json:"insutype_name"`
  4372. ClctType string `json:"clct_type"`
  4373. ClctTypeName string `json:"clct_type_name"`
  4374. ClctFlag string `json:"clct_flag"`
  4375. ClctFlagName string `json:"clct_flag_name"`
  4376. AccrymBegn string `json:"accrym_begn"`
  4377. AccrymEnd string `json:"accrym_end"`
  4378. ClctTime string `json:"clct_time"`
  4379. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4380. } `json:"output"`
  4381. RefmsgTime string `json:"refmsg_time"`
  4382. RespondTime string `json:"respond_time"`
  4383. Signtype interface{} `json:"signtype"`
  4384. WarnInfo interface{} `json:"warn_info"`
  4385. }
  4386. type Custom struct {
  4387. DetItemFeeSumamt string
  4388. Cut string
  4389. FeedetlSn string
  4390. Price string
  4391. MedListCodg string
  4392. Type int64
  4393. AdviceId int64
  4394. ProjectId int64
  4395. ItemId int64
  4396. }
  4397. type Result5301 struct {
  4398. ErrMsg string `json:"err_msg"`
  4399. InfRefmsgid string `json:"inf_refmsgid"`
  4400. Infcode int64 `json:"infcode"`
  4401. Output struct {
  4402. Result []struct {
  4403. OpspDiseCode string `json:"opsp_dise_code"`
  4404. OpspDiseName string `json:"opsp_dise_name"`
  4405. Begndate string `json:"begndate"`
  4406. Enddate string `json:"enddate"`
  4407. } `json:"feedetail"`
  4408. } `json:"output"`
  4409. RefmsgTime string `json:"refmsg_time"`
  4410. RespondTime string `json:"respond_time"`
  4411. Signtype interface{} `json:"signtype"`
  4412. WarnInfo interface{} `json:"warn_info"`
  4413. }
  4414. type Result5301For10265 struct {
  4415. ErrMsg string `json:"err_msg"`
  4416. InfRefmsgid string `json:"inf_refmsgid"`
  4417. Infcode string `json:"infcode"`
  4418. Output struct {
  4419. Result []struct {
  4420. OpspDiseCode string `json:"opsp_dise_code"`
  4421. OpspDiseName string `json:"opsp_dise_name"`
  4422. Begndate string `json:"begndate"`
  4423. Enddate string `json:"enddate"`
  4424. } `json:"feedetail"`
  4425. } `json:"output"`
  4426. RefmsgTime string `json:"refmsg_time"`
  4427. RespondTime string `json:"respond_time"`
  4428. Signtype interface{} `json:"signtype"`
  4429. WarnInfo interface{} `json:"warn_info"`
  4430. }
  4431. //获取个人信息----挂号-----上传就诊信息
  4432. func (c *HisApiController) GetRegisterInfo() {
  4433. id, _ := c.GetInt64("id")
  4434. record_time := c.GetString("record_time")
  4435. settlementValue, _ := c.GetInt64("settlement_value")
  4436. medical_insurance_card := c.GetString("medical_insurance_card")
  4437. name := c.GetString("name")
  4438. id_card_type, _ := c.GetInt64("id_card_type")
  4439. certificates, _ := c.GetInt64("certificates")
  4440. medical_care, _ := c.GetInt64("medical_care")
  4441. birthday := c.GetString("birthday")
  4442. id_card := c.GetString("id_card")
  4443. register_type, _ := c.GetInt64("register")
  4444. doctor, _ := c.GetInt64("doctor")
  4445. department, _ := c.GetInt64("department")
  4446. gender, _ := c.GetInt64("sex")
  4447. registration_fee, _ := c.GetFloat("registration_fee")
  4448. medical_expenses, _ := c.GetFloat("medical_expenses")
  4449. social_type, _ := c.GetInt64("social_type")
  4450. med_type := c.GetString("social_type")
  4451. admin_user_id, _ := c.GetInt64("admin_user_id")
  4452. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4453. timeLayout := "2006-01-02"
  4454. loc, _ := time.LoadLocation("Local")
  4455. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4456. birthUnix := birthdays.Unix()
  4457. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4458. if err != nil {
  4459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4460. return
  4461. }
  4462. recordDateTime := theTime.Unix()
  4463. adminInfo := c.GetAdminUserInfo()
  4464. var patient service.Patients
  4465. if id == 0 {
  4466. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4467. } else {
  4468. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4469. }
  4470. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4471. if patientPrescription.ID == 0 {
  4472. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4473. }
  4474. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4475. if patient.ID == 0 {
  4476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4477. return
  4478. }
  4479. if len(patient.IdCardNo) == 0 {
  4480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4481. return
  4482. }
  4483. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4484. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4485. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4486. //就诊结算未完成,不能进行二次挂号
  4487. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4488. if len(his) >= 1 {
  4489. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4490. if len(his) >= 1 && order.ID == 0 {
  4491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4492. return
  4493. }
  4494. }
  4495. //var register_log string
  4496. if config.IsOpen == 1 {
  4497. var res ResultTwo
  4498. var res10265 ResultTwo10265
  4499. var PsnNo string
  4500. var PsnCertType string
  4501. var Certno string
  4502. var PsnName string
  4503. var Gend string
  4504. var Naty string
  4505. var Brdy string
  4506. var Age float64
  4507. var infoStr string
  4508. var idetinfoStr string
  4509. var infocode int64
  4510. var verify_number string
  4511. fmt.Println(verify_number)
  4512. if miConfig.MdtrtareaAdmvs == "421300" {
  4513. psn_info, _ := service.GetPsnByPatientId(id)
  4514. PsnNo = psn_info.PsnNo
  4515. PsnCertType = psn_info.PsnCertType
  4516. Certno = psn_info.Certno
  4517. PsnName = psn_info.PsnName
  4518. Gend = psn_info.Gend
  4519. Naty = psn_info.Naty
  4520. Brdy = psn_info.Brdy
  4521. Age = psn_info.Age
  4522. infoStr = psn_info.Insuinfo
  4523. idetinfoStr = psn_info.Idetinfo
  4524. infocode = 0
  4525. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4526. psn_info, _ := service.GetPsnByPatientId(id)
  4527. PsnNo = psn_info.PsnNo
  4528. PsnCertType = psn_info.PsnCertType
  4529. Certno = psn_info.Certno
  4530. PsnName = psn_info.PsnName
  4531. Gend = psn_info.Gend
  4532. Naty = psn_info.Naty
  4533. Brdy = psn_info.Brdy
  4534. Age = psn_info.Age
  4535. infoStr = psn_info.Insuinfo
  4536. idetinfoStr = psn_info.Idetinfo
  4537. infocode = 0
  4538. verify_number = psn_info.VerifyNumber
  4539. } else {
  4540. var result string
  4541. var requestLog string
  4542. if miConfig.UserOrgId == 10138 {
  4543. 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, record_time)
  4544. } else {
  4545. 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)
  4546. }
  4547. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4548. if miConfig.Code == "H15049901371" {
  4549. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4550. utils.ErrorLog("解析失败:%v", err)
  4551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4552. return
  4553. }
  4554. res.ErrMsg = res10265.ErrMsg
  4555. res.Output = res10265.Output
  4556. res.InfRefmsgid = res10265.InfRefmsgid
  4557. } else {
  4558. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4559. utils.ErrorLog("解析失败:%v", err)
  4560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4561. return
  4562. }
  4563. }
  4564. PsnNo = res.Output.Baseinfo.PsnNo
  4565. PsnCertType = res.Output.Baseinfo.PsnCertType
  4566. Certno = res.Output.Baseinfo.Certno
  4567. PsnName = res.Output.Baseinfo.PsnName
  4568. Gend = res.Output.Baseinfo.Gend
  4569. Naty = res.Output.Baseinfo.Naty
  4570. Brdy = res.Output.Baseinfo.Brdy
  4571. Age = res.Output.Baseinfo.Age
  4572. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4573. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4574. infoStr = string(Iinfos)
  4575. idetinfoStr = string(Idetinfos)
  4576. if miConfig.Code == "H15049901371" {
  4577. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4578. } else {
  4579. infocode = res.Infcode
  4580. }
  4581. }
  4582. if infocode == 0 {
  4583. his := models.VMHisPatient{
  4584. Name: name,
  4585. Gender: gender,
  4586. Birthday: birthUnix,
  4587. MedicalTreatmentType: medical_care,
  4588. IdType: certificates,
  4589. IdCardNo: id_card,
  4590. BalanceAccountsType: settlementValue,
  4591. SocialType: social_type,
  4592. MedicalInsuranceNumber: medical_insurance_card,
  4593. RegisterType: register_type,
  4594. RegisterCost: registration_fee,
  4595. TreatmentCost: medical_expenses,
  4596. Status: 1,
  4597. Ctime: time.Now().Unix(),
  4598. Mtime: time.Now().Unix(),
  4599. PsnNo: PsnNo,
  4600. PsnCertType: PsnCertType,
  4601. Certno: Certno,
  4602. PsnName: PsnName,
  4603. Gend: Gend,
  4604. Naty: Naty,
  4605. Brdy: Brdy,
  4606. Age: Age,
  4607. Iinfo: infoStr,
  4608. Idetinfo: idetinfoStr,
  4609. PatientId: patient.ID,
  4610. RecordDate: theTime.Unix(),
  4611. UserOrgId: adminInfo.CurrentOrgId,
  4612. AdminUserId: admin_user_id,
  4613. IsReturn: 1,
  4614. IdCardType: id_card_type,
  4615. Doctor: doctor,
  4616. Departments: department,
  4617. }
  4618. timestamp := time.Now().Unix()
  4619. tempTime := time.Unix(timestamp, 0)
  4620. timeFormat := tempTime.Format("20060102150405")
  4621. chrgBchno := rand.Intn(100000) + 10000
  4622. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4623. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4624. department, _ := service.GetDepartMentDetail(department)
  4625. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4626. IdCardNo := ""
  4627. if id_card_type == 1 {
  4628. // IdCardNo = medical_insurance_card
  4629. IdCardNo = patient.IdCardNo
  4630. } else {
  4631. IdCardNo = patient.IdCardNo
  4632. }
  4633. var rf []*ResultFive
  4634. json.Unmarshal([]byte(his.Iinfo), &rf)
  4635. var insutypes []*ResultFive
  4636. var insutype string
  4637. var insuplc_admdvs_temp string
  4638. var is390 int = 0
  4639. var is310 int = 0
  4640. for _, item := range rf {
  4641. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4642. insutypes = append(insutypes, item)
  4643. }
  4644. }
  4645. if len(insutypes) == 1 {
  4646. insutype = insutypes[0].Insutype
  4647. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4648. } else {
  4649. for _, i := range insutypes {
  4650. if i.Insutype == "390" {
  4651. is390 = 1
  4652. }
  4653. if i.Insutype == "310" {
  4654. is310 = 1
  4655. }
  4656. }
  4657. }
  4658. if is390 == 1 {
  4659. insutype = "390"
  4660. }
  4661. if is310 == 1 {
  4662. insutype = "310"
  4663. }
  4664. if len(insutypes) == 0 {
  4665. insutype = "310"
  4666. }
  4667. if len(insutypes) == 2 {
  4668. insutype = med_type
  4669. }
  4670. if len(med_type) > 0 {
  4671. insutype = med_type
  4672. }
  4673. //for _, item := range rf {
  4674. // if item.Insutype == insutype {
  4675. // insuplc_admdvs = item.InsuplcAdmdvs
  4676. // }
  4677. //}
  4678. var infocode int64
  4679. var resThree ResultThree
  4680. var resThree10265 ResultThree10265
  4681. if len(insuplc_admdvs) == 0 {
  4682. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4683. } else {
  4684. insuplc_admdvs_temp = insuplc_admdvs
  4685. }
  4686. if miConfig.MdtrtareaAdmvs == "421300" {
  4687. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4688. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4689. "&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
  4690. resp, requestErr := http.Get(api)
  4691. if requestErr != nil {
  4692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4693. return
  4694. }
  4695. body, ioErr := ioutil.ReadAll(resp.Body)
  4696. if ioErr != nil {
  4697. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4699. return
  4700. }
  4701. var respJSON map[string]interface{}
  4702. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4705. return
  4706. }
  4707. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4708. result, _ := json.Marshal(respJSON)
  4709. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4710. utils.ErrorLog("解析失败:%v", err)
  4711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4712. return
  4713. }
  4714. infocode = resThree.Infcode
  4715. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4716. psn_info, _ := service.GetPsnByPatientId(id)
  4717. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4718. var cert_no string
  4719. if id_card_type == 3 {
  4720. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4721. cert_no = IdCardNo
  4722. } else if id_card_type == 4 {
  4723. cert_no = IdCardNo
  4724. psn_info.VerifyNumber = psn_info.VerifyNumber
  4725. } else {
  4726. bas := strings.Split(psn_info.CardInfo, "|")
  4727. cert_no = bas[2]
  4728. }
  4729. var api string
  4730. if miConfig.MdtrtareaAdmvs == "320921" {
  4731. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4732. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4733. "&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
  4734. } else {
  4735. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4736. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4737. "&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
  4738. }
  4739. resp, requestErr := http.Get(api)
  4740. if requestErr != nil {
  4741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4742. return
  4743. }
  4744. body, ioErr := ioutil.ReadAll(resp.Body)
  4745. if ioErr != nil {
  4746. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4748. return
  4749. }
  4750. var respJSON map[string]interface{}
  4751. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4752. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4754. return
  4755. }
  4756. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4757. result, _ := json.Marshal(respJSON)
  4758. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4759. utils.ErrorLog("解析失败:%v", err)
  4760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4761. return
  4762. }
  4763. resThree.ErrMsg = resThree10265.ErrMsg
  4764. resThree.Output = resThree10265.Output
  4765. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4766. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4767. } else {
  4768. result, requestLog := service.Gdyb2201A(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, record_time)
  4769. saveLog(result, requestLog, "2201A", "挂号")
  4770. if miConfig.Code == "H15049901371" {
  4771. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4772. utils.ErrorLog("解析失败:%v", err)
  4773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4774. return
  4775. }
  4776. resThree.ErrMsg = resThree10265.ErrMsg
  4777. resThree.Output = resThree10265.Output
  4778. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4779. } else {
  4780. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4781. utils.ErrorLog("解析失败:%v", err)
  4782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4783. return
  4784. }
  4785. }
  4786. if miConfig.Code == "H15049901371" {
  4787. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4788. } else {
  4789. infocode = resThree.Infcode
  4790. }
  4791. }
  4792. if infocode != 0 {
  4793. adminUser := c.GetAdminUserInfo()
  4794. errlog := &models.HisOrderError{
  4795. UserOrgId: adminUser.CurrentOrgId,
  4796. Ctime: time.Now().Unix(),
  4797. Mtime: time.Now().Unix(),
  4798. ErrMsg: resThree.ErrMsg,
  4799. Status: 1,
  4800. PatientId: id,
  4801. RecordTime: recordDateTime,
  4802. Stage: 2,
  4803. }
  4804. service.CreateErrMsgLog(errlog)
  4805. c.ServeSuccessJSON(map[string]interface{}{
  4806. "failed_code": -10,
  4807. "msg": resThree.ErrMsg,
  4808. })
  4809. return
  4810. }
  4811. his.Number = resThree.Output.Data.MdtrtID
  4812. his.PsnNo = resThree.Output.Data.PsnNo
  4813. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4814. his.IdCardNo = patient.IdCardNo
  4815. his.PhoneNumber = patient.Phone
  4816. his.UserOrgId = adminInfo.CurrentOrgId
  4817. his.Insutype = insutype
  4818. his.Ctime = time.Now().Unix()
  4819. his.Mtime = time.Now().Unix()
  4820. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4821. his.Status = 1
  4822. service.UpdateHisPatientStatus(&his)
  4823. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4824. c.ServeSuccessJSON(map[string]interface{}{
  4825. "his_info": his,
  4826. })
  4827. } else {
  4828. adminUser := c.GetAdminUserInfo()
  4829. errlog := &models.HisOrderError{
  4830. UserOrgId: adminUser.CurrentOrgId,
  4831. Ctime: time.Now().Unix(),
  4832. Mtime: time.Now().Unix(),
  4833. ErrMsg: res.ErrMsg,
  4834. Status: 1,
  4835. PatientId: id,
  4836. RecordTime: recordDateTime,
  4837. Stage: 1,
  4838. }
  4839. service.CreateErrMsgLog(errlog)
  4840. c.ServeSuccessJSON(map[string]interface{}{
  4841. "failed_code": -10,
  4842. "msg": res.ErrMsg,
  4843. })
  4844. return
  4845. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4846. }
  4847. }
  4848. }
  4849. //上传明细----预结算----确认订单
  4850. func (c *HisApiController) GetUploadInfo() {
  4851. id, _ := c.GetInt64("id")
  4852. record_time := c.GetString("record_time")
  4853. his_patient_id, _ := c.GetInt64("his_patient_id")
  4854. order_id, _ := c.GetInt64("order_id")
  4855. pay_way, _ := c.GetInt64("pay_way")
  4856. pay_price, _ := c.GetFloat("pay_price")
  4857. pay_card_no := c.GetString("pay_card_no")
  4858. token := c.GetString("token")
  4859. discount_price, _ := c.GetFloat("discount_price")
  4860. preferential_price, _ := c.GetFloat("preferential_price")
  4861. reality_price, _ := c.GetFloat("reality_price")
  4862. found_price, _ := c.GetFloat("found_price")
  4863. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4864. private_price, _ := c.GetFloat("private_price")
  4865. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4866. admin_user_id, _ := c.GetInt64("admin_user_id")
  4867. fapiao_code := c.GetString("fapiao_code")
  4868. fapiao_number := c.GetString("fapiao_number")
  4869. diagnosis_id := c.GetString("diagnosis")
  4870. sick_type, _ := c.GetInt64("sick_type")
  4871. reg_type, _ := c.GetInt64("p_type")
  4872. begin_time := c.GetString("begin_time")
  4873. id_str := c.GetString("ids")
  4874. ids_arr := strings.Split(id_str, ",")
  4875. timeLayout := "2006-01-02"
  4876. loc, _ := time.LoadLocation("Local")
  4877. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4878. if err != nil {
  4879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4880. return
  4881. }
  4882. recordDateTime := theTime.Unix()
  4883. adminUser := c.GetAdminUserInfo()
  4884. var tempOrder models.HisOrder
  4885. tempOrder, _ = service.GetHisOrderByID(order_id)
  4886. var prescriptions []*models.HisPrescription
  4887. var start_time int64
  4888. var end_time int64
  4889. //押金模块
  4890. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  4891. tmp_decimal := c.GetString("tmp_decimal")
  4892. var decimal float64 //本次使用的押金
  4893. var errmsg error
  4894. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  4895. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  4896. return
  4897. }
  4898. if len(tmp_decimal) > 0 {
  4899. if tmp_decimal[0] == 45 {
  4900. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  4901. return
  4902. }
  4903. }
  4904. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  4905. fmt.Println(errs)
  4906. decimal = tt
  4907. //if adminUser.CurrentOrgId == 10106{
  4908. // if len(fapiao_code) == 0{
  4909. // fapiao_code = "144072080589"
  4910. // }
  4911. // if len(fapiao_number) == 0{
  4912. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4913. // if order.ID == 0{
  4914. // fapiao_number = "00001520"
  4915. // }else{
  4916. // //fapiao_code = "00001520"
  4917. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4918. // var zero string
  4919. // if fpNumber >= 1000{
  4920. // zero = "0000" + strconv.Itoa(fpNumber)
  4921. // }else if fpNumber >= 10000{
  4922. // zero = "000" + strconv.Itoa(fpNumber)
  4923. // } else if fpNumber >= 100000{
  4924. // zero = "00" + strconv.Itoa(fpNumber)
  4925. // } else if fpNumber >= 1000000{
  4926. // zero = "0" + strconv.Itoa(fpNumber)
  4927. // }else {
  4928. // zero = strconv.Itoa(fpNumber)
  4929. // }
  4930. // fapiao_number = zero
  4931. // }
  4932. // }
  4933. //}
  4934. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4935. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4936. var patientPrescription models.HisPrescriptionInfo
  4937. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4938. if patientPrescription.ID == 0 {
  4939. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4940. }
  4941. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4942. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4943. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4944. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4945. var config []*models.HisXtDiagnoseConfig
  4946. for _, item := range diagnosis_ids {
  4947. id, _ := strconv.ParseInt(item, 10, 64)
  4948. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4949. config = append(config, &diagnosisConfig)
  4950. }
  4951. sickConfig, _ := service.FindSickById(sick_type)
  4952. //if tempOrder.ID == 0 {
  4953. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4954. //}
  4955. if tempOrder.ID == 0 {
  4956. var result string
  4957. var requestLog string
  4958. var res2 ResultSix
  4959. var ressix10265 ResultSix10265
  4960. if miConfig.MdtrtareaAdmvs == "421300" {
  4961. data := make(map[string]interface{})
  4962. client := &http.Client{}
  4963. data["psn_no"] = his.PsnNo
  4964. data["mdtrt_id"] = his.Number
  4965. data["doctor"] = roles.UserName
  4966. data["department"] = department.Name
  4967. data["org_name"] = miConfig.OrgName
  4968. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4969. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4970. data["fixmedins_code"] = miConfig.Code
  4971. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4972. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4973. data["secret_key"] = miConfig.SecretKey
  4974. data["sick_code"] = sickConfig.CountryCode
  4975. data["sick_name"] = sickConfig.ClassName
  4976. data["dept"] = strconv.FormatInt(department.ID, 10)
  4977. data["config"] = config
  4978. data["begin_time"] = begin_time
  4979. bytesData, _ := json.Marshal(data)
  4980. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4981. resp, _ := client.Do(req)
  4982. defer resp.Body.Close()
  4983. body, ioErr := ioutil.ReadAll(resp.Body)
  4984. if ioErr != nil {
  4985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4987. return
  4988. }
  4989. var respJSON map[string]interface{}
  4990. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4993. return
  4994. }
  4995. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4996. userJSONBytes, _ := json.Marshal(respJSON)
  4997. fmt.Println("log")
  4998. fmt.Println(string(userJSONBytes))
  4999. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5000. utils.ErrorLog("解析失败:%v", err)
  5001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5002. return
  5003. }
  5004. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5005. //江苏地区国家医保医疗类别
  5006. //职工透析:医疗类别选特殊情况门诊9933
  5007. //居民血透门慢: 医疗类别选门诊慢病1402
  5008. //var med_type string
  5009. //if his.Insutype == "310" {
  5010. // if reg_type == 14 {
  5011. // med_type = "9933"
  5012. // } else if reg_type == 11 {
  5013. // med_type = "11"
  5014. //
  5015. // }
  5016. //} else if his.Insutype == "390" {
  5017. // if reg_type == 14 {
  5018. // med_type = "1402"
  5019. // } else if reg_type == 11 {
  5020. // med_type = "11"
  5021. // }
  5022. //}
  5023. data := make(map[string]interface{})
  5024. client := &http.Client{}
  5025. data["psn_no"] = his.PsnNo
  5026. data["mdtrt_id"] = his.Number
  5027. data["doctor"] = roles.UserName
  5028. data["department"] = department.Name
  5029. data["org_name"] = miConfig.OrgName
  5030. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5031. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5032. data["fixmedins_code"] = miConfig.Code
  5033. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5034. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5035. data["secret_key"] = miConfig.SecretKey
  5036. data["sick_code"] = sickConfig.CountryCode
  5037. data["sick_name"] = sickConfig.ClassName
  5038. data["url"] = miConfig.Url
  5039. data["ak"] = miConfig.AccessKey
  5040. data["begin_time"] = begin_time
  5041. data["cainfo"] = miConfig.Cainfo
  5042. data["dept"] = strconv.FormatInt(department.ID, 10)
  5043. data["config"] = config
  5044. bytesData, _ := json.Marshal(data)
  5045. var req *http.Request
  5046. if miConfig.MdtrtareaAdmvs == "320921" {
  5047. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5048. //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 +
  5049. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5050. } else {
  5051. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5052. }
  5053. resp, _ := client.Do(req)
  5054. defer resp.Body.Close()
  5055. body, ioErr := ioutil.ReadAll(resp.Body)
  5056. if ioErr != nil {
  5057. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5059. return
  5060. }
  5061. var respJSON map[string]interface{}
  5062. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5065. return
  5066. }
  5067. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5068. userJSONBytes, _ := json.Marshal(respJSON)
  5069. fmt.Println("log")
  5070. fmt.Println(string(userJSONBytes))
  5071. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5072. utils.ErrorLog("解析失败:%v", err)
  5073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5074. return
  5075. }
  5076. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5077. res2.Output = ressix10265.Output
  5078. res2.ErrMsg = ressix10265.ErrMsg
  5079. res2.Cainfo = ressix10265.Cainfo
  5080. res2.WarnMsg = ressix10265.WarnMsg
  5081. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5082. res2.Infcode = infocode
  5083. } else {
  5084. if miConfig.MdtrtareaAdmvs == "440781" { //
  5085. 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)
  5086. } else {
  5087. if miConfig.Code == "H15049901371" {
  5088. //赤峰地区国家医保医疗类别
  5089. //职工透析:医疗类别选特殊情况门诊990502
  5090. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5091. var med_type string
  5092. if his.Insutype == "390" {
  5093. if reg_type == 14 {
  5094. med_type = "9933"
  5095. } else if reg_type == 11 {
  5096. med_type = "11"
  5097. }
  5098. } else if his.Insutype == "310" {
  5099. if reg_type == 14 {
  5100. med_type = "990502"
  5101. } else if reg_type == 11 {
  5102. med_type = "11"
  5103. }
  5104. }
  5105. 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)
  5106. } else {
  5107. 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)
  5108. }
  5109. }
  5110. saveLog(result, requestLog, "2203", "上传就诊信息")
  5111. var respJSON2 map[string]interface{}
  5112. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5115. return
  5116. }
  5117. userJSONBytes2, _ := json.Marshal(respJSON2)
  5118. if miConfig.Code == "H15049901371" {
  5119. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5120. utils.ErrorLog("解析失败:%v", err)
  5121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5122. return
  5123. }
  5124. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5125. res2.Output = ressix10265.Output
  5126. res2.ErrMsg = ressix10265.ErrMsg
  5127. res2.Cainfo = ressix10265.Cainfo
  5128. res2.WarnMsg = ressix10265.WarnMsg
  5129. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5130. res2.Infcode = infocode
  5131. } else {
  5132. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5133. utils.ErrorLog("解析失败:%v", err)
  5134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5135. return
  5136. }
  5137. }
  5138. }
  5139. if res2.Infcode != 0 {
  5140. adminUser := c.GetAdminUserInfo()
  5141. errlog := &models.HisOrderError{
  5142. UserOrgId: adminUser.CurrentOrgId,
  5143. Ctime: time.Now().Unix(),
  5144. Mtime: time.Now().Unix(),
  5145. ErrMsg: res2.ErrMsg,
  5146. Status: 1,
  5147. PatientId: id,
  5148. RecordTime: recordDateTime,
  5149. Stage: 3,
  5150. }
  5151. service.CreateErrMsgLog(errlog)
  5152. c.ServeSuccessJSON(map[string]interface{}{
  5153. "failed_code": -10,
  5154. "msg": res2.ErrMsg,
  5155. })
  5156. return
  5157. } else {
  5158. his.Diagnosis = diagnosis_id
  5159. his.SickType = sickConfig.ID
  5160. //var p_type int64
  5161. //if reg_type == 1111 || reg_type == 1112 {
  5162. // p_type = 11
  5163. //
  5164. //}
  5165. his.PType = fmt.Sprintf("%d", reg_type)
  5166. service.UpdateHisPatientThree(&his)
  5167. data := make(map[string]interface{})
  5168. if settle_accounts_type == 1 { //日结
  5169. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5170. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5171. } else {
  5172. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5173. }
  5174. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5175. data["pre"] = prescriptions
  5176. } else { //月结
  5177. start_time_str := c.GetString("start_time")
  5178. end_time_str := c.GetString("end_time")
  5179. timeLayout := "2006-01-02"
  5180. loc, _ := time.LoadLocation("Local")
  5181. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5182. if err != nil {
  5183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5184. return
  5185. }
  5186. recordStartTime := theStartTime.Unix()
  5187. start_time = recordStartTime
  5188. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5189. if err != nil {
  5190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5191. return
  5192. }
  5193. recordEndTime := theEndTime.Unix()
  5194. end_time = recordEndTime
  5195. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5196. data["pre"] = prescriptions
  5197. }
  5198. timestamp := time.Now().Unix()
  5199. tempTime := time.Unix(timestamp, 0)
  5200. timeFormat := tempTime.Format("20060102150405")
  5201. chrgBchno := rand.Intn(100000) + 10000
  5202. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5203. strconv.FormatInt(his.PatientId, 10)
  5204. client := &http.Client{}
  5205. data["psn_no"] = his.PsnNo
  5206. data["mdtrt_id"] = his.Number
  5207. data["chrg_bchno"] = chrg_bchno
  5208. data["org_name"] = miConfig.OrgName
  5209. data["doctor"] = roles.UserName
  5210. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5211. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5212. data["fixmedins_code"] = miConfig.Code
  5213. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5214. // data["dept_code"] = "15"
  5215. //} else {
  5216. data["dept_code"] = department.Number
  5217. //}
  5218. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5219. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5220. data["secret_key"] = miConfig.SecretKey
  5221. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5222. data["url"] = miConfig.Url
  5223. data["ak"] = miConfig.AccessKey
  5224. data["new_doctor_name"] = patientPrescription.Doctor
  5225. data["diag_code"] = sickConfig.CountryCode
  5226. data["cainfo"] = miConfig.Cainfo
  5227. var ids []int64
  5228. for _, item := range prescriptions {
  5229. ids = append(ids, item.ID)
  5230. }
  5231. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5232. if config.IsOpen == 1 { //对接了医保,走医保流程
  5233. var res ResultFour
  5234. var resFour10265 ResultFour10265
  5235. if miConfig.MdtrtareaAdmvs == "421300" {
  5236. bytesData, _ := json.Marshal(data)
  5237. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5238. resp, _ := client.Do(req)
  5239. defer resp.Body.Close()
  5240. body, ioErr := ioutil.ReadAll(resp.Body)
  5241. if ioErr != nil {
  5242. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5244. return
  5245. }
  5246. var respJSON map[string]interface{}
  5247. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5248. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5250. return
  5251. }
  5252. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5253. userJSONBytes, _ := json.Marshal(respJSON)
  5254. fmt.Println("log")
  5255. fmt.Println(string(userJSONBytes))
  5256. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5257. utils.ErrorLog("解析失败:%v", err)
  5258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5259. return
  5260. }
  5261. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5262. bytesData, _ := json.Marshal(data)
  5263. var req *http.Request
  5264. if miConfig.MdtrtareaAdmvs == "320921" {
  5265. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5266. } else {
  5267. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5268. }
  5269. resp, _ := client.Do(req)
  5270. defer resp.Body.Close()
  5271. body, ioErr := ioutil.ReadAll(resp.Body)
  5272. if ioErr != nil {
  5273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5275. return
  5276. }
  5277. var respJSON map[string]interface{}
  5278. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5281. return
  5282. }
  5283. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5284. userJSONBytes, _ := json.Marshal(respJSON)
  5285. fmt.Println("log")
  5286. fmt.Println(string(userJSONBytes))
  5287. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5288. utils.ErrorLog("解析失败:%v", err)
  5289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5290. return
  5291. }
  5292. res.InfRefmsgid = resFour10265.InfRefmsgid
  5293. res.Output = resFour10265.Output
  5294. res.ErrMsg = resFour10265.ErrMsg
  5295. res.Cainfo = resFour10265.Cainfo
  5296. res.WarnMsg = resFour10265.WarnMsg
  5297. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5298. res.Infcode = infocode
  5299. } else {
  5300. if miConfig.Code == "H15049901371" {
  5301. 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)
  5302. var dat map[string]interface{}
  5303. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5304. fmt.Println(dat)
  5305. } else {
  5306. fmt.Println(err)
  5307. }
  5308. saveLog(result, request_log, "2204", "上传费用明细")
  5309. userJSONBytes, _ := json.Marshal(dat)
  5310. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5311. utils.ErrorLog("解析失败:%v", err)
  5312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5313. return
  5314. }
  5315. res.InfRefmsgid = resFour10265.InfRefmsgid
  5316. res.Output = resFour10265.Output
  5317. res.ErrMsg = resFour10265.ErrMsg
  5318. res.Cainfo = resFour10265.Cainfo
  5319. res.WarnMsg = resFour10265.WarnMsg
  5320. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5321. res.Infcode = infocode
  5322. } else {
  5323. 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)
  5324. var dat map[string]interface{}
  5325. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5326. fmt.Println(dat)
  5327. } else {
  5328. fmt.Println(err)
  5329. }
  5330. saveLog(result, request_log, "2204", "上传费用明细")
  5331. userJSONBytes, _ := json.Marshal(dat)
  5332. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5333. utils.ErrorLog("解析失败:%v", err)
  5334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5335. return
  5336. }
  5337. }
  5338. }
  5339. if res.Infcode == 0 {
  5340. order := &models.HisOrder{
  5341. UserOrgId: adminUser.CurrentOrgId,
  5342. HisPatientId: his.ID,
  5343. PatientId: his.PatientId,
  5344. SettleAccountsDate: recordDateTime,
  5345. MdtrtId: his.Number,
  5346. PsnNo: his.PsnNo,
  5347. MedType: strconv.FormatInt(reg_type, 10),
  5348. Ctime: time.Now().Unix(),
  5349. Mtime: time.Now().Unix(),
  5350. Status: 1,
  5351. Number: chrg_bchno,
  5352. Infcode: res.Infcode,
  5353. WarnMsg: res.WarnMsg,
  5354. Cainfo: res.Cainfo,
  5355. ErrMsg: res.ErrMsg,
  5356. RespondTime: res.RefmsgTime,
  5357. InfRefmsgid: res.InfRefmsgid,
  5358. OrderStatus: 1,
  5359. PayWay: pay_way,
  5360. PayPrice: pay_price,
  5361. PayCardNo: pay_card_no,
  5362. DiscountPrice: discount_price,
  5363. PreferentialPrice: preferential_price,
  5364. RealityPrice: reality_price,
  5365. FoundPrice: found_price,
  5366. MedicalInsurancePrice: medical_insurance_price,
  5367. PrivatePrice: private_price,
  5368. IsMedicineInsurance: 1,
  5369. SettleType: settle_accounts_type,
  5370. SettleStartTime: start_time,
  5371. SettleEndTime: end_time,
  5372. Creator: roles.AdminUserId,
  5373. Modify: roles.AdminUserId,
  5374. FaPiaoNumber: fapiao_number,
  5375. FaPiaoCode: fapiao_code,
  5376. PType: 2,
  5377. Diagnosis: diagnosis_id,
  5378. }
  5379. err = service.CreateOrder(order)
  5380. if err != nil {
  5381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5382. return
  5383. }
  5384. for _, item := range res.Output.Result {
  5385. temp := strings.Split(item.FeedetlSn, "-")
  5386. var advice_id int64 = 0
  5387. var project_id int64 = 0
  5388. var types int64 = 0
  5389. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5390. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5391. if temp[1] == "1" {
  5392. advice_id = id
  5393. project_id = 0
  5394. } else if temp[1] == "2" {
  5395. advice_id = 0
  5396. project_id = id
  5397. }
  5398. info := &models.HisOrderInfo{
  5399. OrderNumber: order.Number,
  5400. FeedetlSn: item.FeedetlSn,
  5401. UploadDate: time.Now().Unix(),
  5402. AdviceId: advice_id,
  5403. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5404. Cnt: item.Cnt,
  5405. Pric: float64(item.Pric),
  5406. PatientId: his.PatientId,
  5407. PricUplmtAmt: item.PricUplmtAmt,
  5408. SelfpayProp: item.SelfpayProp,
  5409. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5410. OverlmtAmt: item.OverlmtAmt,
  5411. PreselfpayAmt: item.PreselfpayAmt,
  5412. BasMednFlag: item.BasMednFlag,
  5413. MedChrgitmType: item.MedChrgitmType,
  5414. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5415. Status: 1,
  5416. Memo: item.Memo,
  5417. Mtime: time.Now().Unix(),
  5418. InscpScpAmt: item.InscpScpAmt,
  5419. DrtReimFlag: item.DrtReimFlag,
  5420. Ctime: time.Now().Unix(),
  5421. ListSpItemFlag: item.ListSpItemFlag,
  5422. ChldMedcFlag: item.ChldMedcFlag,
  5423. LmtUsedFlag: item.LmtUsedFlag,
  5424. ChrgitmLv: item.ChrgitmLv,
  5425. UserOrgId: adminUser.CurrentOrgId,
  5426. HisPatientId: his.ID,
  5427. OrderId: order.ID,
  5428. ProjectId: project_id,
  5429. Type: types,
  5430. }
  5431. service.CreateOrderInfo(info)
  5432. }
  5433. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5434. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5435. var total float64
  5436. for _, item := range prescriptions {
  5437. if item.Type == 1 { //药品
  5438. for _, subItem := range item.HisDoctorAdviceInfo {
  5439. total = total + (subItem.Price * subItem.PrescribingNumber)
  5440. }
  5441. }
  5442. if item.Type == 2 { //项目
  5443. for _, subItem := range item.HisPrescriptionProject {
  5444. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5445. total = total + (subItem.Price * cnt)
  5446. }
  5447. }
  5448. }
  5449. for _, item := range prescriptions {
  5450. for _, subItem := range item.HisAdditionalCharge {
  5451. total = total + (subItem.Price * float64(subItem.Count))
  5452. }
  5453. }
  5454. var allTotal string
  5455. if adminUser.CurrentOrgId == 9919 {
  5456. allTotal = fmt.Sprintf("%.4f", total)
  5457. } else {
  5458. allTotal = fmt.Sprintf("%.4f", total)
  5459. }
  5460. if res.Infcode == 0 {
  5461. var rf []*ResultFive
  5462. json.Unmarshal([]byte(his.Iinfo), &rf)
  5463. chrg_bchno := chrg_bchno
  5464. cert_no := his.Certno
  5465. var insutypes []string
  5466. var insutype string
  5467. var is390 int = 0
  5468. var is310 int = 0
  5469. for _, item := range rf {
  5470. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5471. insutypes = append(insutypes, item.Insutype)
  5472. }
  5473. }
  5474. if len(insutypes) == 1 {
  5475. insutype = insutypes[0]
  5476. } else {
  5477. for _, i := range insutypes {
  5478. if i == "390" {
  5479. is390 = 1
  5480. }
  5481. if i == "310" {
  5482. is310 = 1
  5483. }
  5484. }
  5485. }
  5486. if is390 == 1 {
  5487. insutype = "390"
  5488. }
  5489. if is310 == 1 {
  5490. insutype = "310"
  5491. }
  5492. if len(insutypes) == 0 {
  5493. insutype = "310"
  5494. }
  5495. if len(insutypes) == 2 {
  5496. insutype = strconv.FormatInt(his.SocialType, 10)
  5497. }
  5498. insutype = strconv.FormatInt(his.SocialType, 10)
  5499. //insutype = "390"
  5500. if his.IdCardType == 1 {
  5501. // cert_no = his.MedicalInsuranceNumber
  5502. cert_no = his.Certno
  5503. } else {
  5504. cert_no = his.Certno
  5505. }
  5506. var res ResultSeven
  5507. var resSeven10265 ResultSeven10265
  5508. var src_resquest string
  5509. var result2 string
  5510. var acct_used_flag string
  5511. fmt.Println("pay_way")
  5512. fmt.Println(pay_way)
  5513. fmt.Println("pay_way")
  5514. if pay_way == 5 {
  5515. acct_used_flag = "1"
  5516. } else {
  5517. acct_used_flag = "0"
  5518. }
  5519. if miConfig.MdtrtareaAdmvs == "421300" {
  5520. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5521. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5522. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5523. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5524. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5525. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5526. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5527. resp, requestErr := http.Get(api)
  5528. if requestErr != nil {
  5529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5530. return
  5531. }
  5532. body, ioErr := ioutil.ReadAll(resp.Body)
  5533. if ioErr != nil {
  5534. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5536. return
  5537. }
  5538. var respJSON map[string]interface{}
  5539. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5542. return
  5543. }
  5544. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5545. result, _ := json.Marshal(respJSON)
  5546. if miConfig.Code == "H15049901371" {
  5547. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5548. utils.ErrorLog("解析失败:%v", err)
  5549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5550. return
  5551. }
  5552. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5553. res.Output = resSeven10265.Output
  5554. res.ErrMsg = resSeven10265.ErrMsg
  5555. res.Cainfo = resSeven10265.Cainfo
  5556. res.WarnMsg = resSeven10265.WarnMsg
  5557. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5558. res.Infcode = infocode
  5559. } else {
  5560. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5561. utils.ErrorLog("解析失败:%v", err)
  5562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5563. return
  5564. }
  5565. }
  5566. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5567. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5568. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5569. bas := strings.Split(psn_info.CardInfo, "|")
  5570. if his.IdCardType == 1 {
  5571. cert_no = bas[2]
  5572. } else if his.IdCardType == 3 {
  5573. cert_no = his.Certno
  5574. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5575. } else if his.IdCardType == 4 {
  5576. cert_no = his.Certno
  5577. psn_info.VerifyNumber = token
  5578. }
  5579. var api string
  5580. if miConfig.MdtrtareaAdmvs == "320921" {
  5581. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5582. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5583. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5584. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5585. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5586. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5587. "&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
  5588. } else {
  5589. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5590. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5591. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5592. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5593. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5594. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5595. "&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
  5596. }
  5597. resp, requestErr := http.Get(api)
  5598. if requestErr != nil {
  5599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5600. return
  5601. }
  5602. body, ioErr := ioutil.ReadAll(resp.Body)
  5603. if ioErr != nil {
  5604. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5606. return
  5607. }
  5608. var respJSON map[string]interface{}
  5609. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5610. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5612. return
  5613. }
  5614. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5615. result, _ := json.Marshal(respJSON)
  5616. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5617. utils.ErrorLog("解析失败:%v", err)
  5618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5619. return
  5620. }
  5621. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5622. res.Output = resSeven10265.Output
  5623. res.ErrMsg = resSeven10265.ErrMsg
  5624. res.Cainfo = resSeven10265.Cainfo
  5625. res.WarnMsg = resSeven10265.WarnMsg
  5626. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5627. res.Infcode = infocode
  5628. } else {
  5629. if miConfig.Code == "H15049901371" {
  5630. //赤峰地区国家医保医疗类别
  5631. //职工透析:医疗类别选特殊情况门诊990502
  5632. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5633. var med_type string
  5634. if his.Insutype == "390" {
  5635. if reg_type == 14 {
  5636. med_type = "9933"
  5637. } else if reg_type == 11 {
  5638. med_type = "11"
  5639. }
  5640. } else if his.Insutype == "310" {
  5641. if reg_type == 14 {
  5642. med_type = "990502"
  5643. } else if reg_type == 11 {
  5644. med_type = "11"
  5645. }
  5646. }
  5647. 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)
  5648. } else {
  5649. 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)
  5650. }
  5651. //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)
  5652. var dat map[string]interface{}
  5653. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5654. fmt.Println(dat)
  5655. } else {
  5656. fmt.Println(err)
  5657. }
  5658. saveLog(result2, src_resquest, "2207", "结算")
  5659. userJSONBytes, _ := json.Marshal(dat)
  5660. if miConfig.Code == "H15049901371" {
  5661. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5662. utils.ErrorLog("解析失败:%v", err)
  5663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5664. return
  5665. }
  5666. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5667. res.Output = resSeven10265.Output
  5668. res.ErrMsg = resSeven10265.ErrMsg
  5669. res.Cainfo = resSeven10265.Cainfo
  5670. res.WarnMsg = resSeven10265.WarnMsg
  5671. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5672. res.Infcode = infocode
  5673. } else {
  5674. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5675. utils.ErrorLog("解析失败:%v", err)
  5676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5677. return
  5678. }
  5679. }
  5680. }
  5681. if res.Infcode != 0 {
  5682. errlog := &models.HisOrderError{
  5683. UserOrgId: adminUser.CurrentOrgId,
  5684. Ctime: time.Now().Unix(),
  5685. Mtime: time.Now().Unix(),
  5686. Number: chrg_bchno,
  5687. ErrMsg: res.ErrMsg,
  5688. Status: 1,
  5689. PatientId: id,
  5690. RecordTime: recordDateTime,
  5691. Stage: 6,
  5692. }
  5693. service.CreateErrMsgLog(errlog)
  5694. c.ServeSuccessJSON(map[string]interface{}{
  5695. "failed_code": -10,
  5696. "msg": res.ErrMsg,
  5697. })
  5698. return
  5699. } else {
  5700. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5701. order.OrderStatus = 2
  5702. order.Status = 1
  5703. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5704. order.SetlId = res.Output.Setlinfo.SetlID
  5705. order.PsnNo = res.Output.Setlinfo.PsnNo
  5706. order.PsnName = res.Output.Setlinfo.PsnName
  5707. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5708. order.Certno = res.Output.Setlinfo.Certno
  5709. order.Gend = res.Output.Setlinfo.Gend
  5710. order.Naty = res.Output.Setlinfo.Naty
  5711. order.Age = res.Output.Setlinfo.Age
  5712. order.Insutype = res.Output.Setlinfo.Insutype
  5713. order.PsnType = res.Output.Setlinfo.PsnType
  5714. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5715. order.SetlTime = res.Output.Setlinfo.SetlTime
  5716. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5717. if res.Output.Setlinfo.MedType == "140101" {
  5718. order.MedType = "14"
  5719. } else {
  5720. order.MedType = res.Output.Setlinfo.MedType
  5721. }
  5722. if reg_type == 1112 {
  5723. order.MedType = "1112"
  5724. }
  5725. if reg_type == 1111 {
  5726. order.MedType = "1111"
  5727. }
  5728. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5729. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5730. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5731. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5732. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5733. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5734. order.HifpPay = res.Output.Setlinfo.HifpPay
  5735. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5736. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5737. order.HifesPay = res.Output.Setlinfo.HifesPay
  5738. order.HifobPay = res.Output.Setlinfo.HifobPay
  5739. order.MafPay = res.Output.Setlinfo.MafPay
  5740. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5741. order.OthPay = res.Output.Setlinfo.OthPay
  5742. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5743. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5744. order.AcctPay = res.Output.Setlinfo.AcctPay
  5745. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5746. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5747. order.Balc = res.Output.Setlinfo.Balc
  5748. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5749. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5750. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5751. order.ClrType = res.Output.Setlinfo.ClrType
  5752. order.ClrWay = res.Output.Setlinfo.ClrWay
  5753. order.Creator = order.Creator
  5754. order.Modify = roles.AdminUserId
  5755. order.RequestLog = src_resquest
  5756. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5757. detailStr := string(setlDetail)
  5758. order.SetlDetail = detailStr
  5759. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5760. err = service.UpDateOrder(order)
  5761. if err == nil {
  5762. //判断是否使用了押金
  5763. if dec_way == "true" {
  5764. tmpstring := strconv.FormatInt(order.ID, 10)
  5765. order.Decimal = decimal
  5766. service.UpDateOrder(order)
  5767. //扣押金
  5768. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  5769. if errmsg != nil {
  5770. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  5771. return
  5772. }
  5773. }
  5774. c.ServeSuccessJSON(map[string]interface{}{
  5775. "msg": "结算成功",
  5776. })
  5777. } else {
  5778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5779. return
  5780. }
  5781. }
  5782. } else {
  5783. adminUser := c.GetAdminUserInfo()
  5784. errlog := &models.HisOrderError{
  5785. UserOrgId: adminUser.CurrentOrgId,
  5786. Ctime: time.Now().Unix(),
  5787. Mtime: time.Now().Unix(),
  5788. ErrMsg: res.ErrMsg,
  5789. Status: 1,
  5790. PatientId: id,
  5791. RecordTime: recordDateTime,
  5792. Stage: 4,
  5793. }
  5794. service.CreateErrMsgLog(errlog)
  5795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5796. return
  5797. }
  5798. } else {
  5799. adminUser := c.GetAdminUserInfo()
  5800. errlog := &models.HisOrderError{
  5801. UserOrgId: adminUser.CurrentOrgId,
  5802. Ctime: time.Now().Unix(),
  5803. Mtime: time.Now().Unix(),
  5804. ErrMsg: res.ErrMsg,
  5805. Status: 1,
  5806. PatientId: id,
  5807. RecordTime: recordDateTime,
  5808. Stage: 4,
  5809. }
  5810. service.CreateErrMsgLog(errlog)
  5811. c.ServeSuccessJSON(map[string]interface{}{
  5812. "failed_code": -10,
  5813. "msg": res.ErrMsg,
  5814. })
  5815. return
  5816. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5817. //return
  5818. }
  5819. }
  5820. }
  5821. } else if tempOrder.ID > 0 {
  5822. if tempOrder.IsPre == 1 {
  5823. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5824. var rf []*ResultFive
  5825. json.Unmarshal([]byte(his.Iinfo), &rf)
  5826. chrg_bchno := tempOrder.Number
  5827. cert_no := his.Certno
  5828. var insutypes []string
  5829. var insutype string
  5830. var is390 int = 0
  5831. var is310 int = 0
  5832. for _, item := range rf {
  5833. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5834. insutypes = append(insutypes, item.Insutype)
  5835. }
  5836. }
  5837. if len(insutypes) == 1 {
  5838. insutype = insutypes[0]
  5839. } else {
  5840. for _, i := range insutypes {
  5841. if i == "390" {
  5842. is390 = 1
  5843. }
  5844. if i == "310" {
  5845. is310 = 1
  5846. }
  5847. }
  5848. }
  5849. if is390 == 1 {
  5850. insutype = "390"
  5851. }
  5852. if is310 == 1 {
  5853. insutype = "310"
  5854. }
  5855. if len(insutypes) == 0 {
  5856. insutype = "310"
  5857. }
  5858. if len(insutypes) == 2 {
  5859. insutype = strconv.FormatInt(his.SocialType, 64)
  5860. }
  5861. //insutype = "390"
  5862. if his.IdCardType == 1 {
  5863. // cert_no = his.MedicalInsuranceNumber
  5864. cert_no = his.Certno
  5865. } else {
  5866. cert_no = his.Certno
  5867. }
  5868. var res ResultSeven
  5869. var resSeven10265 ResultSeven10265
  5870. var src_resquest string
  5871. var result2 string
  5872. var acct_used_flag string
  5873. fmt.Println("pay_way")
  5874. fmt.Println(pay_way)
  5875. fmt.Println("pay_way")
  5876. if pay_way == 5 {
  5877. acct_used_flag = "1"
  5878. } else {
  5879. acct_used_flag = "0"
  5880. }
  5881. if miConfig.MdtrtareaAdmvs == "421300" {
  5882. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5883. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5884. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5885. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5886. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5887. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5888. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5889. resp, requestErr := http.Get(api)
  5890. if requestErr != nil {
  5891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5892. return
  5893. }
  5894. body, ioErr := ioutil.ReadAll(resp.Body)
  5895. if ioErr != nil {
  5896. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5898. return
  5899. }
  5900. var respJSON map[string]interface{}
  5901. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5902. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5904. return
  5905. }
  5906. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5907. result, _ := json.Marshal(respJSON)
  5908. fmt.Println("log")
  5909. fmt.Println(string(result))
  5910. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5911. utils.ErrorLog("解析失败:%v", err)
  5912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5913. return
  5914. }
  5915. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5916. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5917. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5918. //psn_info, _ := service.GetPsnByPatientId(id)
  5919. bas := strings.Split(psn_info.CardInfo, "|")
  5920. if his.IdCardType == 1 {
  5921. cert_no = bas[2]
  5922. } else {
  5923. cert_no = bas[1]
  5924. }
  5925. //江苏地区国家医保医疗类别
  5926. //职工透析:医疗类别选特殊情况门诊9933
  5927. //居民血透门慢: 医疗类别选门诊慢病1402
  5928. //var med_type string
  5929. //if his.Insutype == "310" {
  5930. // if reg_type == 14 {
  5931. // med_type = "9933"
  5932. // } else if reg_type == 11 {
  5933. // med_type = "11"
  5934. //
  5935. // }
  5936. //} else if his.Insutype == "390" {
  5937. // if reg_type == 14 {
  5938. // med_type = "1402"
  5939. // } else if reg_type == 11 {
  5940. // med_type = "11"
  5941. // }
  5942. //}
  5943. var api string
  5944. if miConfig.MdtrtareaAdmvs == "320921" {
  5945. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5946. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5947. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5948. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5949. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5950. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5951. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5952. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5953. } else {
  5954. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5955. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5956. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5957. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5958. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5959. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5960. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5961. "&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
  5962. }
  5963. resp, requestErr := http.Get(api)
  5964. if requestErr != nil {
  5965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5966. return
  5967. }
  5968. body, ioErr := ioutil.ReadAll(resp.Body)
  5969. if ioErr != nil {
  5970. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5972. return
  5973. }
  5974. var respJSON map[string]interface{}
  5975. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5978. return
  5979. }
  5980. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5981. result, _ := json.Marshal(respJSON)
  5982. fmt.Println("log")
  5983. fmt.Println(string(result))
  5984. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5985. utils.ErrorLog("解析失败:%v", err)
  5986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5987. return
  5988. }
  5989. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5990. res.Output = resSeven10265.Output
  5991. res.ErrMsg = resSeven10265.ErrMsg
  5992. res.Cainfo = resSeven10265.Cainfo
  5993. res.WarnMsg = resSeven10265.WarnMsg
  5994. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5995. res.Infcode = infocode
  5996. } else {
  5997. var src_resquest string
  5998. if miConfig.Code == "H15049901371" {
  5999. //赤峰地区国家医保医疗类别
  6000. //职工透析:医疗类别选特殊情况门诊990502
  6001. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6002. var med_type string
  6003. if his.Insutype == "390" {
  6004. if reg_type == 14 {
  6005. med_type = "9933"
  6006. } else if reg_type == 11 {
  6007. med_type = "11"
  6008. }
  6009. } else if his.Insutype == "310" {
  6010. if reg_type == 14 {
  6011. med_type = "990502"
  6012. } else if reg_type == 11 {
  6013. med_type = "11"
  6014. }
  6015. }
  6016. 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)
  6017. } else {
  6018. 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)
  6019. }
  6020. var dat map[string]interface{}
  6021. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6022. fmt.Println(dat)
  6023. } else {
  6024. fmt.Println(err)
  6025. }
  6026. saveLog(result2, src_resquest, "2207", "结算")
  6027. userJSONBytes, _ := json.Marshal(dat)
  6028. if miConfig.Code == "H15049901371" {
  6029. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6030. utils.ErrorLog("解析失败:%v", err)
  6031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6032. return
  6033. }
  6034. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6035. res.Output = resSeven10265.Output
  6036. res.ErrMsg = resSeven10265.ErrMsg
  6037. res.Cainfo = resSeven10265.Cainfo
  6038. res.WarnMsg = resSeven10265.WarnMsg
  6039. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6040. res.Infcode = infocode
  6041. } else {
  6042. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6043. utils.ErrorLog("解析失败:%v", err)
  6044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6045. return
  6046. }
  6047. }
  6048. }
  6049. if res.Infcode != 0 {
  6050. errlog := &models.HisOrderError{
  6051. UserOrgId: adminUser.CurrentOrgId,
  6052. Ctime: time.Now().Unix(),
  6053. Mtime: time.Now().Unix(),
  6054. Number: chrg_bchno,
  6055. ErrMsg: res.ErrMsg,
  6056. Status: 1,
  6057. PatientId: id,
  6058. RecordTime: recordDateTime,
  6059. Stage: 6,
  6060. }
  6061. service.CreateErrMsgLog(errlog)
  6062. c.ServeSuccessJSON(map[string]interface{}{
  6063. "failed_code": -10,
  6064. "msg": res.ErrMsg,
  6065. })
  6066. return
  6067. } else {
  6068. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6069. order.OrderStatus = 2
  6070. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6071. order.SetlId = res.Output.Setlinfo.SetlID
  6072. order.PsnNo = res.Output.Setlinfo.PsnNo
  6073. order.PsnName = res.Output.Setlinfo.PsnName
  6074. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6075. order.Certno = res.Output.Setlinfo.Certno
  6076. order.Gend = res.Output.Setlinfo.Gend
  6077. order.Naty = res.Output.Setlinfo.Naty
  6078. order.Age = res.Output.Setlinfo.Age
  6079. order.Insutype = res.Output.Setlinfo.Insutype
  6080. order.PsnType = res.Output.Setlinfo.PsnType
  6081. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6082. order.SetlTime = res.Output.Setlinfo.SetlTime
  6083. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6084. //order.MedType = res.Output.Setlinfo.MedType
  6085. if reg_type == 1112 {
  6086. order.MedType = "1112"
  6087. }
  6088. if reg_type == 1111 {
  6089. order.MedType = "1111"
  6090. }
  6091. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6092. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6093. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6094. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6095. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6096. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6097. order.HifpPay = res.Output.Setlinfo.HifpPay
  6098. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6099. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6100. order.HifesPay = res.Output.Setlinfo.HifesPay
  6101. order.HifobPay = res.Output.Setlinfo.HifobPay
  6102. order.MafPay = res.Output.Setlinfo.MafPay
  6103. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6104. order.OthPay = res.Output.Setlinfo.OthPay
  6105. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6106. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6107. order.AcctPay = res.Output.Setlinfo.AcctPay
  6108. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6109. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6110. order.Balc = res.Output.Setlinfo.Balc
  6111. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6112. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6113. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6114. order.ClrWay = res.Output.Setlinfo.ClrWay
  6115. order.Creator = order.Creator
  6116. order.Modify = roles.AdminUserId
  6117. order.RequestLog = src_resquest
  6118. order.Diagnosis = diagnosis_id
  6119. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6120. detailStr := string(setlDetail)
  6121. order.SetlDetail = detailStr
  6122. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6123. err = service.UpDateOrder(order)
  6124. if err == nil {
  6125. //判断是否使用了押金
  6126. if dec_way == "true" {
  6127. tmpstring := strconv.FormatInt(order.ID, 10)
  6128. //扣押金
  6129. order.Decimal = decimal
  6130. service.UpDateOrder(order)
  6131. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6132. if errmsg != nil {
  6133. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6134. return
  6135. }
  6136. }
  6137. c.ServeSuccessJSON(map[string]interface{}{
  6138. "msg": "结算成功",
  6139. })
  6140. } else {
  6141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6142. return
  6143. }
  6144. }
  6145. }
  6146. }
  6147. }
  6148. //func (c *HisApiController) GetPreUploadInfo() {
  6149. // id, _ := c.GetInt64("id")
  6150. // record_time := c.GetString("record_time")
  6151. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6152. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6153. //
  6154. // timeLayout := "2006-01-02"
  6155. // loc, _ := time.LoadLocation("Local")
  6156. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6157. // if err != nil {
  6158. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6159. // return
  6160. // }
  6161. // recordDateTime := theTime.Unix()
  6162. // adminUser := c.GetAdminUserInfo()
  6163. //
  6164. // var prescriptions []*models.HisPrescription
  6165. //
  6166. // var start_time int64
  6167. // var end_time int64
  6168. //
  6169. // data := make(map[string]interface{})
  6170. // if settle_accounts_type == 1 { //日结
  6171. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6172. // data["pre"] = prescriptions
  6173. //
  6174. // } else { //月结
  6175. // start_time_str := c.GetString("start_time")
  6176. // end_time_str := c.GetString("end_time")
  6177. // timeLayout := "2006-01-02"
  6178. // loc, _ := time.LoadLocation("Local")
  6179. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6180. // if err != nil {
  6181. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6182. // return
  6183. // }
  6184. // recordStartTime := theStartTime.Unix()
  6185. // start_time = recordStartTime
  6186. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6187. // if err != nil {
  6188. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6189. // return
  6190. // }
  6191. // recordEndTime := theEndTime.Unix()
  6192. // end_time = recordEndTime
  6193. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6194. // data["pre"] = prescriptions
  6195. //
  6196. // }
  6197. //
  6198. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6199. //
  6200. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6201. // timestamp := time.Now().Unix()
  6202. // tempTime := time.Unix(timestamp, 0)
  6203. // timeFormat := tempTime.Format("20060102150405")
  6204. // chrgBchno := rand.Intn(100000) + 10000
  6205. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6206. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6207. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6208. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6209. // strconv.FormatInt(his.PatientId, 10)
  6210. // client := &http.Client{}
  6211. // data["psn_no"] = his.PsnNo
  6212. // data["mdtrt_id"] = his.Number
  6213. // data["chrg_bchno"] = chrg_bchno
  6214. // data["org_name"] = miConfig.OrgName
  6215. // data["doctor"] = roles.UserName
  6216. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6217. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6218. // data["fixmedins_code"] = miConfig.Code
  6219. // data["dept_code"] = department.Number
  6220. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6221. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6222. // data["secret_key"] = miConfig.SecretKey
  6223. // var ids []int64
  6224. //
  6225. // for _, item := range prescriptions {
  6226. // ids = append(ids, item.ID)
  6227. // }
  6228. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6229. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6230. // bytesData, _ := json.Marshal(data)
  6231. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6232. // resp, _ := client.Do(req)
  6233. // defer resp.Body.Close()
  6234. // body, ioErr := ioutil.ReadAll(resp.Body)
  6235. // if ioErr != nil {
  6236. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6237. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6238. // return
  6239. // }
  6240. // var respJSON map[string]interface{}
  6241. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6242. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6243. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6244. // return
  6245. // }
  6246. //
  6247. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6248. // userJSONBytes, _ := json.Marshal(respJSON)
  6249. // var res ResultFour
  6250. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6251. // utils.ErrorLog("解析失败:%v", err)
  6252. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6253. // return
  6254. // }
  6255. //
  6256. // if res.Infcode == 0 {
  6257. // order := &models.HisOrder{
  6258. // UserOrgId: adminUser.CurrentOrgId,
  6259. // HisPatientId: his.ID,
  6260. // PatientId: his.PatientId,
  6261. // SettleAccountsDate: recordDateTime,
  6262. // Ctime: time.Now().Unix(),
  6263. // Mtime: time.Now().Unix(),
  6264. // Status: 1,
  6265. // Number: chrg_bchno,
  6266. // Infcode: res.Infcode,
  6267. // WarnMsg: res.WarnMsg,
  6268. // Cainfo: res.Cainfo,
  6269. // ErrMsg: res.ErrMsg,
  6270. // RespondTime: res.RefmsgTime,
  6271. // InfRefmsgid: res.InfRefmsgid,
  6272. // OrderStatus: 1,
  6273. // IsMedicineInsurance: 1,
  6274. // SettleType: settle_accounts_type,
  6275. // SettleStartTime: start_time,
  6276. // SettleEndTime: end_time,
  6277. // Creator: roles.ID,
  6278. // Modify: roles.ID,
  6279. // PType: 2,
  6280. // }
  6281. // err = service.CreateOrder(order)
  6282. // if err != nil {
  6283. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6284. // return
  6285. // }
  6286. //
  6287. // for _, item := range res.Output.Result {
  6288. // temp := strings.Split(item.FeedetlSn, "-")
  6289. // var advice_id int64 = 0
  6290. // var project_id int64 = 0
  6291. // var types int64 = 0
  6292. //
  6293. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6294. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6295. //
  6296. // if temp[1] == "1" {
  6297. // advice_id = id
  6298. // project_id = 0
  6299. // } else if temp[1] == "2" {
  6300. // advice_id = 0
  6301. // project_id = id
  6302. // }
  6303. //
  6304. // info := &models.HisOrderInfo{
  6305. // OrderNumber: order.Number,
  6306. // FeedetlSn: item.FeedetlSn,
  6307. // UploadDate: time.Now().Unix(),
  6308. // AdviceId: advice_id,
  6309. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6310. // Cnt: item.Cnt,
  6311. // Pric: float64(item.Pric),
  6312. // PatientId: his.PatientId,
  6313. // PricUplmtAmt: item.PricUplmtAmt,
  6314. // SelfpayProp: item.SelfpayProp,
  6315. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6316. // OverlmtAmt: item.OverlmtAmt,
  6317. // PreselfpayAmt: item.PreselfpayAmt,
  6318. // BasMednFlag: item.BasMednFlag,
  6319. // MedChrgitmType: item.MedChrgitmType,
  6320. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6321. // Status: 1,
  6322. // Memo: item.Memo,
  6323. // Mtime: time.Now().Unix(),
  6324. // InscpScpAmt: item.InscpScpAmt,
  6325. // DrtReimFlag: item.DrtReimFlag,
  6326. // Ctime: time.Now().Unix(),
  6327. // ListSpItemFlag: item.ListSpItemFlag,
  6328. // ChldMedcFlag: item.ChldMedcFlag,
  6329. // LmtUsedFlag: item.LmtUsedFlag,
  6330. // ChrgitmLv: item.ChrgitmLv,
  6331. // UserOrgId: adminUser.CurrentOrgId,
  6332. // HisPatientId: his.ID,
  6333. // OrderId: order.ID,
  6334. // ProjectId: project_id,
  6335. // Type: types,
  6336. // }
  6337. // service.CreateOrderInfo(info)
  6338. //
  6339. // }
  6340. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6341. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6342. //
  6343. // var total float64
  6344. // for _, item := range prescriptions {
  6345. // if item.Type == 1 { //药品
  6346. // for _, subItem := range item.HisDoctorAdviceInfo {
  6347. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6348. // }
  6349. // }
  6350. // if item.Type == 2 { //项目
  6351. // for _, subItem := range item.HisPrescriptionProject {
  6352. // total = total + (subItem.Price * float64(subItem.Count))
  6353. // }
  6354. // }
  6355. // }
  6356. //
  6357. // for _, item := range prescriptions {
  6358. // for _, subItem := range item.HisAdditionalCharge {
  6359. // total = total + (subItem.Price * float64(subItem.Count))
  6360. // }
  6361. // }
  6362. //
  6363. // allTotal := fmt.Sprintf("%.2f", total)
  6364. // if res.Infcode == 0 {
  6365. // var rf []*ResultFive
  6366. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6367. // psn_no := his.PsnNo
  6368. // mdtrt_id := his.Number
  6369. // chrg_bchno := chrg_bchno
  6370. // cert_no := his.Certno
  6371. // insutype := rf[0].Insutype
  6372. //
  6373. // if his.IdCardType == 1 {
  6374. // cert_no = his.MedicalInsuranceNumber
  6375. //
  6376. // } else {
  6377. //
  6378. // cert_no = his.Certno
  6379. //
  6380. // }
  6381. //
  6382. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6383. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6384. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6385. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6386. // resp, requestErr := http.Get(api)
  6387. // if requestErr != nil {
  6388. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6389. // return
  6390. // }
  6391. // defer resp.Body.Close()
  6392. // body, ioErr := ioutil.ReadAll(resp.Body)
  6393. // if ioErr != nil {
  6394. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6395. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6396. // return
  6397. // }
  6398. // var respJSON map[string]interface{}
  6399. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6400. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6401. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6402. // return
  6403. // }
  6404. // fmt.Println(respJSON)
  6405. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6406. // userJSONBytes, _ := json.Marshal(respJSON)
  6407. // var res ResultSeven
  6408. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6409. // utils.ErrorLog("解析失败:%v", err)
  6410. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6411. // return
  6412. // }
  6413. // if res.Infcode != 0 {
  6414. // errlog := &models.HisOrderError{
  6415. // UserOrgId: adminUser.CurrentOrgId,
  6416. // Ctime: time.Now().Unix(),
  6417. // Mtime: time.Now().Unix(),
  6418. // Number: chrg_bchno,
  6419. // ErrMsg: res.ErrMsg,
  6420. // Status: 1,
  6421. // PatientId: id,
  6422. // RecordTime: recordDateTime,
  6423. // Stage: 7,
  6424. // }
  6425. // service.CreateErrMsgLog(errlog)
  6426. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6427. // return
  6428. // } else {
  6429. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6430. // order.OrderStatus = 1
  6431. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6432. // order.SetlId = res.Output.Setlinfo.SetlID
  6433. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6434. // order.PsnName = res.Output.Setlinfo.PsnName
  6435. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6436. // order.Certno = res.Output.Setlinfo.Certno
  6437. // order.Gend = res.Output.Setlinfo.Gend
  6438. // order.Naty = res.Output.Setlinfo.Naty
  6439. // order.Age = res.Output.Setlinfo.Age
  6440. // order.Insutype = res.Output.Setlinfo.Insutype
  6441. // order.PsnType = res.Output.Setlinfo.PsnType
  6442. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6443. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6444. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6445. // order.MedType = res.Output.Setlinfo.MedType
  6446. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6447. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6448. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6449. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6450. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6451. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6452. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6453. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6454. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6455. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6456. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6457. // order.MafPay = res.Output.Setlinfo.MafPay
  6458. // order.OthPay = res.Output.Setlinfo.OthPay
  6459. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6460. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6461. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6462. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6463. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6464. // order.Balc = res.Output.Setlinfo.Balc
  6465. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6466. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6467. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6468. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6469. // order.Creator = order.Creator
  6470. // order.Modify = roles.ID
  6471. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6472. // detailStr := string(setlDetail)
  6473. // order.SetlDetail = detailStr
  6474. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6475. // err = service.UpDateOrder(order)
  6476. // if err == nil {
  6477. // c.ServeSuccessJSON(map[string]interface{}{
  6478. // "msg": "预结算成功",
  6479. // })
  6480. // } else {
  6481. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6482. // return
  6483. // }
  6484. // }
  6485. // } else {
  6486. // adminUser := c.GetAdminUserInfo()
  6487. // errlog := &models.HisOrderError{
  6488. // UserOrgId: adminUser.CurrentOrgId,
  6489. // Ctime: time.Now().Unix(),
  6490. // Mtime: time.Now().Unix(),
  6491. // ErrMsg: res.ErrMsg,
  6492. // Status: 1,
  6493. // PatientId: id,
  6494. // RecordTime: recordDateTime,
  6495. // Stage: 4,
  6496. // }
  6497. // service.CreateErrMsgLog(errlog)
  6498. //
  6499. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6500. // return
  6501. // }
  6502. // } else {
  6503. // adminUser := c.GetAdminUserInfo()
  6504. // errlog := &models.HisOrderError{
  6505. // UserOrgId: adminUser.CurrentOrgId,
  6506. // Ctime: time.Now().Unix(),
  6507. // Mtime: time.Now().Unix(),
  6508. // ErrMsg: res.ErrMsg,
  6509. // Status: 1,
  6510. // PatientId: id,
  6511. // RecordTime: recordDateTime,
  6512. // Stage: 4,
  6513. // }
  6514. // service.CreateErrMsgLog(errlog)
  6515. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6516. // return
  6517. // }
  6518. //
  6519. // } else {
  6520. // var total float64
  6521. // for _, item := range prescriptions {
  6522. // if item.Type == 1 { //药品
  6523. // for _, subItem := range item.HisDoctorAdviceInfo {
  6524. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6525. // }
  6526. // }
  6527. // if item.Type == 2 { //项目
  6528. // for _, subItem := range item.HisPrescriptionProject {
  6529. // total = total + (subItem.Price * float64(subItem.Count))
  6530. // }
  6531. // }
  6532. //
  6533. // for _, subItem := range item.HisAdditionalCharge {
  6534. // total = total + (subItem.Price * float64(subItem.Count))
  6535. // }
  6536. // }
  6537. //
  6538. // allTotal := fmt.Sprintf("%.2f", total)
  6539. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6540. // order := &models.HisOrder{
  6541. // UserOrgId: adminUser.CurrentOrgId,
  6542. // HisPatientId: his.ID,
  6543. // PatientId: id,
  6544. // SettleAccountsDate: recordDateTime,
  6545. // Ctime: time.Now().Unix(),
  6546. // Mtime: time.Now().Unix(),
  6547. // Status: 1,
  6548. // OrderStatus: 2,
  6549. // Number: chrg_bchno,
  6550. // MedfeeSumamt: totals,
  6551. // }
  6552. // err = service.CreateOrder(order)
  6553. // if err != nil {
  6554. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6555. // return
  6556. // }
  6557. //
  6558. // var customs []*Custom
  6559. // for _, item := range prescriptions {
  6560. //
  6561. // if item.Type == 1 { //药品
  6562. // for _, subItem := range item.HisDoctorAdviceInfo {
  6563. // cus := &Custom{
  6564. // AdviceId: subItem.ID,
  6565. // ProjectId: 0,
  6566. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6567. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6568. // FeedetlSn: subItem.FeedetlSn,
  6569. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6570. // MedListCodg: subItem.MedListCodg,
  6571. // Type: 1,
  6572. // }
  6573. // customs = append(customs, cus)
  6574. // }
  6575. // }
  6576. //
  6577. // if item.Type == 2 { //项目
  6578. // for _, subItem := range item.HisPrescriptionProject {
  6579. //
  6580. // cus := &Custom{
  6581. // AdviceId: 0,
  6582. // ProjectId: subItem.ID,
  6583. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6584. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6585. // FeedetlSn: subItem.FeedetlSn,
  6586. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6587. // MedListCodg: subItem.MedListCodg,
  6588. // Type: 2,
  6589. // }
  6590. //
  6591. // customs = append(customs, cus)
  6592. // }
  6593. // }
  6594. //
  6595. // for _, item := range item.HisAdditionalCharge {
  6596. // cus := &Custom{
  6597. // ItemId: item.ID,
  6598. // AdviceId: 0,
  6599. // ProjectId: 0,
  6600. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6601. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6602. // FeedetlSn: item.FeedetlSn,
  6603. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6604. // MedListCodg: item.XtHisAddtionConfig.Code,
  6605. // Type: 3,
  6606. // }
  6607. //
  6608. // customs = append(customs, cus)
  6609. // }
  6610. //
  6611. // }
  6612. //
  6613. // for _, item := range customs {
  6614. // var advice_id int64 = 0
  6615. // var project_id int64 = 0
  6616. // var item_id int64 = 0
  6617. //
  6618. // var types int64 = 0
  6619. //
  6620. // if item.Type == 1 {
  6621. // advice_id = item.AdviceId
  6622. // project_id = 0
  6623. // item_id = 0
  6624. // } else if item.Type == 2 {
  6625. // advice_id = 0
  6626. // item_id = 0
  6627. //
  6628. // project_id = item.ProjectId
  6629. // } else if item.Type == 3 {
  6630. // advice_id = 0
  6631. // item_id = item.ItemId
  6632. // project_id = 0
  6633. // }
  6634. //
  6635. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6636. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6637. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6638. //
  6639. // info := &models.HisOrderInfo{
  6640. // OrderNumber: order.Number,
  6641. // UploadDate: time.Now().Unix(),
  6642. // AdviceId: advice_id,
  6643. // DetItemFeeSumamt: detItemFeeSumamt,
  6644. // Cnt: cut,
  6645. // Pric: pric,
  6646. // PatientId: id,
  6647. // Status: 1,
  6648. // Mtime: time.Now().Unix(),
  6649. // Ctime: time.Now().Unix(),
  6650. // UserOrgId: adminUser.CurrentOrgId,
  6651. // HisPatientId: his.ID,
  6652. // OrderId: order.ID,
  6653. // ProjectId: project_id,
  6654. // Type: types,
  6655. // ItemId: item_id,
  6656. // }
  6657. // service.CreateOrderInfo(info)
  6658. // }
  6659. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6660. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6661. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6662. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6663. // if err == nil {
  6664. // c.ServeSuccessJSON(map[string]interface{}{
  6665. // "msg": "结算成功",
  6666. // })
  6667. // } else {
  6668. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6669. // return
  6670. // }
  6671. // }
  6672. //}
  6673. //上传明细-预结算-
  6674. func (c *HisApiController) GetPreUploadInfo() {
  6675. id, _ := c.GetInt64("id")
  6676. record_time := c.GetString("record_time")
  6677. his_patient_id, _ := c.GetInt64("his_patient_id")
  6678. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6679. admin_user_id, _ := c.GetInt64("admin_user_id")
  6680. diagnosis_id := c.GetString("diagnosis")
  6681. sick_type, _ := c.GetInt64("sick_type")
  6682. reg_type, _ := c.GetInt64("p_type")
  6683. begin_time := c.GetString("begin_time")
  6684. id_str := c.GetString("ids")
  6685. ids_arr := strings.Split(id_str, ",")
  6686. timeLayout := "2006-01-02"
  6687. loc, _ := time.LoadLocation("Local")
  6688. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6689. if err != nil {
  6690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6691. return
  6692. }
  6693. recordDateTime := theTime.Unix()
  6694. adminUser := c.GetAdminUserInfo()
  6695. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6696. var config []*models.HisXtDiagnoseConfig
  6697. for _, item := range diagnosis_ids {
  6698. id, _ := strconv.ParseInt(item, 10, 64)
  6699. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6700. config = append(config, &diagnosisConfig)
  6701. }
  6702. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6703. sickConfig, _ := service.FindSickById(sick_type)
  6704. var prescriptions []*models.HisPrescription
  6705. var start_time int64
  6706. var end_time int64
  6707. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6708. fmt.Println(his_patient_id)
  6709. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6710. timestamp := time.Now().Unix()
  6711. tempTime := time.Unix(timestamp, 0)
  6712. timeFormat := tempTime.Format("20060102150405")
  6713. chrgBchno := rand.Intn(100000) + 10000
  6714. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6715. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6716. var patientPrescription models.HisPrescriptionInfo
  6717. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6718. if patientPrescription.ID == 0 {
  6719. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6720. }
  6721. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6722. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6723. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6724. strconv.FormatInt(his.PatientId, 10)
  6725. var res2 ResultSix
  6726. var resSix10265 ResultSix10265
  6727. var time_stamp string
  6728. if miConfig.MdtrtareaAdmvs == "421300" {
  6729. data := make(map[string]interface{})
  6730. client := &http.Client{}
  6731. data["psn_no"] = his.PsnNo
  6732. data["mdtrt_id"] = his.Number
  6733. data["doctor"] = roles.UserName
  6734. data["department"] = department.Name
  6735. data["org_name"] = miConfig.OrgName
  6736. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6737. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6738. data["fixmedins_code"] = miConfig.Code
  6739. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6740. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6741. data["secret_key"] = miConfig.SecretKey
  6742. data["sick_code"] = sickConfig.CountryCode
  6743. data["sick_name"] = sickConfig.ClassName
  6744. data["begin_time"] = begin_time
  6745. data["dept"] = strconv.FormatInt(department.ID, 10)
  6746. data["config"] = config
  6747. fmt.Println(data)
  6748. bytesData, _ := json.Marshal(data)
  6749. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6750. resp, _ := client.Do(req)
  6751. defer resp.Body.Close()
  6752. body, ioErr := ioutil.ReadAll(resp.Body)
  6753. if ioErr != nil {
  6754. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6756. return
  6757. }
  6758. var respJSON map[string]interface{}
  6759. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6760. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6762. return
  6763. }
  6764. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6765. userJSONBytes, _ := json.Marshal(respJSON)
  6766. fmt.Println("log")
  6767. fmt.Println(string(userJSONBytes))
  6768. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6769. utils.ErrorLog("解析失败:%v", err)
  6770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6771. return
  6772. }
  6773. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6774. //江苏地区国家医保医疗类别
  6775. //职工透析:医疗类别选特殊情况门诊9933
  6776. //居民血透门慢: 医疗类别选门诊慢病1402
  6777. //var med_type string
  6778. //if his.Insutype == "310" {
  6779. // if reg_type == 14 {
  6780. // med_type = "9933"
  6781. // } else if reg_type == 11 {
  6782. // med_type = "11"
  6783. //
  6784. // }
  6785. //} else if his.Insutype == "390" {
  6786. // if reg_type == 14 {
  6787. // med_type = "1402"
  6788. // } else if reg_type == 11 {
  6789. // med_type = "11"
  6790. // }
  6791. //}
  6792. data := make(map[string]interface{})
  6793. client := &http.Client{}
  6794. data["psn_no"] = his.PsnNo
  6795. data["mdtrt_id"] = his.Number
  6796. data["doctor"] = roles.UserName
  6797. data["department"] = department.Name
  6798. data["org_name"] = miConfig.OrgName
  6799. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6800. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6801. data["fixmedins_code"] = miConfig.Code
  6802. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6803. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6804. data["secret_key"] = miConfig.SecretKey
  6805. data["sick_code"] = sickConfig.CountryCode
  6806. data["sick_name"] = sickConfig.ClassName
  6807. data["begin_time"] = begin_time
  6808. data["dept"] = strconv.FormatInt(department.ID, 10)
  6809. data["config"] = config
  6810. data["url"] = miConfig.Url
  6811. data["ak"] = miConfig.AccessKey
  6812. data["cainfo"] = miConfig.Cainfo
  6813. bytesData, _ := json.Marshal(data)
  6814. var req *http.Request
  6815. if miConfig.MdtrtareaAdmvs == "320921" {
  6816. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6817. //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 +
  6818. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6819. } else {
  6820. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6821. }
  6822. resp, _ := client.Do(req)
  6823. defer resp.Body.Close()
  6824. body, ioErr := ioutil.ReadAll(resp.Body)
  6825. if ioErr != nil {
  6826. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6828. return
  6829. }
  6830. var respJSON map[string]interface{}
  6831. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6834. return
  6835. }
  6836. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6837. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6838. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6839. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6840. userJSONBytes, _ := json.Marshal(respJSON)
  6841. fmt.Println("log")
  6842. fmt.Println(string(userJSONBytes))
  6843. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6844. utils.ErrorLog("解析失败:%v", err)
  6845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6846. return
  6847. }
  6848. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6849. res2.Output = resSix10265.Output
  6850. res2.ErrMsg = resSix10265.ErrMsg
  6851. res2.Cainfo = resSix10265.Cainfo
  6852. res2.WarnMsg = resSix10265.WarnMsg
  6853. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6854. res2.Infcode = infocode
  6855. } else {
  6856. var result string
  6857. var requestLog string
  6858. if miConfig.MdtrtareaAdmvs == "440781" { //
  6859. 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)
  6860. } else {
  6861. if miConfig.Code == "H15049901371" {
  6862. //赤峰地区国家医保医疗类别
  6863. //职工透析:医疗类别选特殊情况门诊990502
  6864. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6865. var med_type string
  6866. if his.Insutype == "390" {
  6867. if reg_type == 14 {
  6868. med_type = "9933"
  6869. } else if reg_type == 11 {
  6870. med_type = "11"
  6871. }
  6872. } else if his.Insutype == "310" {
  6873. if reg_type == 14 {
  6874. med_type = "990502"
  6875. } else if reg_type == 11 {
  6876. med_type = "11"
  6877. }
  6878. }
  6879. 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)
  6880. } else {
  6881. 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)
  6882. }
  6883. saveLog(result, requestLog, "2203", "上传就诊信息")
  6884. var respJSON2 map[string]interface{}
  6885. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6888. return
  6889. }
  6890. userJSONBytes2, _ := json.Marshal(respJSON2)
  6891. if miConfig.Code == "H15049901371" {
  6892. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  6893. utils.ErrorLog("解析失败:%v", err)
  6894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6895. return
  6896. }
  6897. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6898. res2.Output = resSix10265.Output
  6899. res2.ErrMsg = resSix10265.ErrMsg
  6900. res2.Cainfo = resSix10265.Cainfo
  6901. res2.WarnMsg = resSix10265.WarnMsg
  6902. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6903. res2.Infcode = infocode
  6904. } else {
  6905. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6906. utils.ErrorLog("解析失败:%v", err)
  6907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6908. return
  6909. }
  6910. }
  6911. }
  6912. }
  6913. if res2.Infcode != 0 {
  6914. adminUser := c.GetAdminUserInfo()
  6915. errlog := &models.HisOrderError{
  6916. UserOrgId: adminUser.CurrentOrgId,
  6917. Ctime: time.Now().Unix(),
  6918. Mtime: time.Now().Unix(),
  6919. ErrMsg: res2.ErrMsg,
  6920. Status: 1,
  6921. PatientId: id,
  6922. RecordTime: recordDateTime,
  6923. Stage: 3,
  6924. }
  6925. service.CreateErrMsgLog(errlog)
  6926. c.ServeSuccessJSON(map[string]interface{}{
  6927. "failed_code": -10,
  6928. "msg": res2.ErrMsg,
  6929. })
  6930. return
  6931. } else {
  6932. his.Diagnosis = diagnosis_id
  6933. his.SickType = sickConfig.ID
  6934. his.PType = fmt.Sprintf("%d", reg_type)
  6935. service.UpdateHisPatientThree(&his)
  6936. data := make(map[string]interface{})
  6937. if settle_accounts_type == 1 { //日结
  6938. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6939. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6940. } else {
  6941. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6942. }
  6943. data["pre"] = prescriptions
  6944. } else { //月结
  6945. start_time_str := c.GetString("start_time")
  6946. end_time_str := c.GetString("end_time")
  6947. timeLayout := "2006-01-02"
  6948. loc, _ := time.LoadLocation("Local")
  6949. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6950. if err != nil {
  6951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6952. return
  6953. }
  6954. recordStartTime := theStartTime.Unix()
  6955. start_time = recordStartTime
  6956. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6957. if err != nil {
  6958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6959. return
  6960. }
  6961. recordEndTime := theEndTime.Unix()
  6962. end_time = recordEndTime
  6963. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6964. data["pre"] = prescriptions
  6965. }
  6966. client := &http.Client{}
  6967. data["psn_no"] = his.PsnNo
  6968. data["mdtrt_id"] = his.Number
  6969. data["chrg_bchno"] = chrg_bchno
  6970. data["org_name"] = miConfig.OrgName
  6971. data["doctor"] = roles.UserName
  6972. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6973. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6974. data["fixmedins_code"] = miConfig.Code
  6975. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  6976. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  6977. data["dept_code"] = "15"
  6978. } else {
  6979. data["dept_code"] = department.Number
  6980. }
  6981. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6982. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6983. data["secret_key"] = miConfig.SecretKey
  6984. data["url"] = miConfig.Url
  6985. data["ak"] = miConfig.AccessKey
  6986. data["new_doctor_name"] = patientPrescription.Doctor
  6987. data["diag_code"] = sickConfig.CountryCode
  6988. data["time_stamp"] = time_stamp
  6989. data["cainfo"] = miConfig.Cainfo
  6990. var ids []int64
  6991. for _, item := range prescriptions {
  6992. ids = append(ids, item.ID)
  6993. }
  6994. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6995. if config.IsOpen == 1 { //对接了医保,走医保流程
  6996. var res ResultFour
  6997. var resFour10265 ResultFour10265
  6998. if miConfig.MdtrtareaAdmvs == "421300" {
  6999. bytesData, _ := json.Marshal(data)
  7000. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7001. resp, _ := client.Do(req)
  7002. defer resp.Body.Close()
  7003. body, ioErr := ioutil.ReadAll(resp.Body)
  7004. if ioErr != nil {
  7005. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7007. return
  7008. }
  7009. var respJSON map[string]interface{}
  7010. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7011. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7013. return
  7014. }
  7015. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7016. userJSONBytes, _ := json.Marshal(respJSON)
  7017. fmt.Println("log")
  7018. fmt.Println(string(userJSONBytes))
  7019. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7020. utils.ErrorLog("解析失败:%v", err)
  7021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7022. return
  7023. }
  7024. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7025. bytesData, _ := json.Marshal(data)
  7026. var req *http.Request
  7027. if miConfig.MdtrtareaAdmvs == "320921" {
  7028. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7029. } else {
  7030. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7031. }
  7032. resp, _ := client.Do(req)
  7033. defer resp.Body.Close()
  7034. body, ioErr := ioutil.ReadAll(resp.Body)
  7035. if ioErr != nil {
  7036. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7038. return
  7039. }
  7040. var respJSON map[string]interface{}
  7041. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7042. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7044. return
  7045. }
  7046. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7047. userJSONBytes, _ := json.Marshal(respJSON)
  7048. fmt.Println("log")
  7049. fmt.Println(string(userJSONBytes))
  7050. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7051. utils.ErrorLog("解析失败:%v", err)
  7052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7053. return
  7054. }
  7055. res.InfRefmsgid = resFour10265.InfRefmsgid
  7056. res.Output = resFour10265.Output
  7057. res.ErrMsg = resFour10265.ErrMsg
  7058. res.Cainfo = resFour10265.Cainfo
  7059. res.WarnMsg = resFour10265.WarnMsg
  7060. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7061. res.Infcode = infocode
  7062. } else {
  7063. if miConfig.Code == "H15049901371" {
  7064. 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)
  7065. var dat map[string]interface{}
  7066. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7067. fmt.Println(dat)
  7068. } else {
  7069. fmt.Println(err)
  7070. }
  7071. saveLog(result, request_log, "2204", "上传费用明细")
  7072. userJSONBytes, _ := json.Marshal(dat)
  7073. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7074. utils.ErrorLog("解析失败:%v", err)
  7075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7076. return
  7077. }
  7078. res.InfRefmsgid = resFour10265.InfRefmsgid
  7079. res.Output = resFour10265.Output
  7080. res.ErrMsg = resFour10265.ErrMsg
  7081. res.Cainfo = resFour10265.Cainfo
  7082. res.WarnMsg = resFour10265.WarnMsg
  7083. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7084. res.Infcode = infocode
  7085. } else {
  7086. 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)
  7087. var dat map[string]interface{}
  7088. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7089. fmt.Println(dat)
  7090. } else {
  7091. fmt.Println(err)
  7092. }
  7093. saveLog(result, request_log, "2204", "上传费用明细")
  7094. userJSONBytes, _ := json.Marshal(dat)
  7095. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7096. utils.ErrorLog("解析失败:%v", err)
  7097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7098. return
  7099. }
  7100. }
  7101. }
  7102. if res.Infcode == 0 {
  7103. order := &models.HisOrder{
  7104. UserOrgId: adminUser.CurrentOrgId,
  7105. HisPatientId: his.ID,
  7106. PatientId: his.PatientId,
  7107. SettleAccountsDate: recordDateTime,
  7108. Ctime: time.Now().Unix(),
  7109. Mtime: time.Now().Unix(),
  7110. MdtrtId: his.Number,
  7111. PsnNo: his.PsnNo,
  7112. MedType: strconv.FormatInt(reg_type, 10),
  7113. Status: 1,
  7114. Number: chrg_bchno,
  7115. Infcode: res.Infcode,
  7116. WarnMsg: res.WarnMsg,
  7117. Cainfo: res.Cainfo,
  7118. ErrMsg: res.ErrMsg,
  7119. RespondTime: res.RefmsgTime,
  7120. InfRefmsgid: res.InfRefmsgid,
  7121. OrderStatus: 1,
  7122. IsMedicineInsurance: 1,
  7123. SettleType: settle_accounts_type,
  7124. SettleStartTime: start_time,
  7125. SettleEndTime: end_time,
  7126. Creator: roles.AdminUserId,
  7127. Modify: roles.AdminUserId,
  7128. PType: 2,
  7129. Diagnosis: diagnosis_id,
  7130. }
  7131. err = service.CreateOrder(order)
  7132. if err != nil {
  7133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7134. return
  7135. }
  7136. for _, item := range res.Output.Result {
  7137. temp := strings.Split(item.FeedetlSn, "-")
  7138. var advice_id int64 = 0
  7139. var project_id int64 = 0
  7140. var types int64 = 0
  7141. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7142. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7143. if temp[1] == "1" {
  7144. advice_id = id
  7145. project_id = 0
  7146. } else if temp[1] == "2" {
  7147. advice_id = 0
  7148. project_id = id
  7149. }
  7150. info := &models.HisOrderInfo{
  7151. OrderNumber: order.Number,
  7152. FeedetlSn: item.FeedetlSn,
  7153. UploadDate: time.Now().Unix(),
  7154. AdviceId: advice_id,
  7155. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7156. Cnt: item.Cnt,
  7157. Pric: float64(item.Pric),
  7158. PatientId: his.PatientId,
  7159. PricUplmtAmt: item.PricUplmtAmt,
  7160. SelfpayProp: item.SelfpayProp,
  7161. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7162. OverlmtAmt: item.OverlmtAmt,
  7163. PreselfpayAmt: item.PreselfpayAmt,
  7164. BasMednFlag: item.BasMednFlag,
  7165. MedChrgitmType: item.MedChrgitmType,
  7166. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7167. Status: 1,
  7168. Memo: item.Memo,
  7169. Mtime: time.Now().Unix(),
  7170. InscpScpAmt: item.InscpScpAmt,
  7171. DrtReimFlag: item.DrtReimFlag,
  7172. Ctime: time.Now().Unix(),
  7173. ListSpItemFlag: item.ListSpItemFlag,
  7174. ChldMedcFlag: item.ChldMedcFlag,
  7175. LmtUsedFlag: item.LmtUsedFlag,
  7176. ChrgitmLv: item.ChrgitmLv,
  7177. UserOrgId: adminUser.CurrentOrgId,
  7178. HisPatientId: his.ID,
  7179. OrderId: order.ID,
  7180. ProjectId: project_id,
  7181. Type: types,
  7182. }
  7183. service.CreateOrderInfo(info)
  7184. }
  7185. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7186. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7187. var total float64
  7188. for _, item := range prescriptions {
  7189. if item.Type == 1 { //药品
  7190. for _, subItem := range item.HisDoctorAdviceInfo {
  7191. total = total + (subItem.Price * subItem.PrescribingNumber)
  7192. }
  7193. }
  7194. if item.Type == 2 { //项目
  7195. for _, subItem := range item.HisPrescriptionProject {
  7196. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7197. total = total + (subItem.Price * cnt)
  7198. }
  7199. }
  7200. }
  7201. for _, item := range prescriptions {
  7202. for _, subItem := range item.HisAdditionalCharge {
  7203. total = total + (subItem.Price * float64(subItem.Count))
  7204. }
  7205. }
  7206. allTotal := fmt.Sprintf("%.4f", total)
  7207. if res.Infcode == 0 {
  7208. var rf []*ResultFive
  7209. json.Unmarshal([]byte(his.Iinfo), &rf)
  7210. chrg_bchno := chrg_bchno
  7211. cert_no := his.Certno
  7212. var insutypes []string
  7213. var insutype string
  7214. var is390 int = 0
  7215. var is310 int = 0
  7216. for _, item := range rf {
  7217. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7218. insutypes = append(insutypes, item.Insutype)
  7219. }
  7220. }
  7221. if len(insutypes) == 1 {
  7222. insutype = insutypes[0]
  7223. } else {
  7224. for _, i := range insutypes {
  7225. if i == "390" {
  7226. is390 = 1
  7227. }
  7228. if i == "310" {
  7229. is310 = 1
  7230. }
  7231. }
  7232. }
  7233. if is390 == 1 {
  7234. insutype = "390"
  7235. }
  7236. if is310 == 1 {
  7237. insutype = "310"
  7238. }
  7239. if len(insutypes) == 0 {
  7240. insutype = "310"
  7241. }
  7242. if len(insutypes) == 2 {
  7243. insutype = strconv.FormatInt(his.SocialType, 64)
  7244. }
  7245. //insutype = "390"
  7246. if his.IdCardType == 1 {
  7247. cert_no = his.MedicalInsuranceNumber
  7248. } else {
  7249. cert_no = his.Certno
  7250. }
  7251. var res ResultSeven
  7252. var resSeven10265 ResultSeven10265
  7253. if miConfig.MdtrtareaAdmvs == "421300" {
  7254. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7255. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7256. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7257. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7258. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7259. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7260. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7261. resp, requestErr := http.Get(api)
  7262. if requestErr != nil {
  7263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7264. return
  7265. }
  7266. body, ioErr := ioutil.ReadAll(resp.Body)
  7267. if ioErr != nil {
  7268. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7270. return
  7271. }
  7272. var respJSON map[string]interface{}
  7273. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7274. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7276. return
  7277. }
  7278. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7279. result, _ := json.Marshal(respJSON)
  7280. fmt.Println("log")
  7281. fmt.Println(string(result))
  7282. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7283. utils.ErrorLog("解析失败:%v", err)
  7284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7285. return
  7286. }
  7287. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7288. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7289. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7290. bas := strings.Split(psn_info.CardInfo, "|")
  7291. if his.IdCardType == 1 {
  7292. cert_no = bas[2]
  7293. } else {
  7294. cert_no = bas[1]
  7295. }
  7296. //江苏地区国家医保医疗类别
  7297. //职工透析:医疗类别选特殊情况门诊9933
  7298. //居民血透门慢: 医疗类别选门诊慢病1402
  7299. //var med_type string
  7300. //if his.Insutype == "310" {
  7301. // if reg_type == 14 {
  7302. // med_type = "9933"
  7303. // } else if reg_type == 11 {
  7304. // med_type = "11"
  7305. //
  7306. // }
  7307. //} else if his.Insutype == "390" {
  7308. // if reg_type == 14 {
  7309. // med_type = "1402"
  7310. // } else if reg_type == 11 {
  7311. // med_type = "11"
  7312. // }
  7313. //}
  7314. var api string
  7315. if miConfig.MdtrtareaAdmvs == "320921" {
  7316. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7317. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7318. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7319. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7320. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7321. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7322. "&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
  7323. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7324. } else {
  7325. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7326. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7327. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7328. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7329. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7330. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7331. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7332. "&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
  7333. }
  7334. resp, requestErr := http.Get(api)
  7335. if requestErr != nil {
  7336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7337. return
  7338. }
  7339. body, ioErr := ioutil.ReadAll(resp.Body)
  7340. if ioErr != nil {
  7341. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7343. return
  7344. }
  7345. var respJSON map[string]interface{}
  7346. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7347. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7349. return
  7350. }
  7351. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7352. result, _ := json.Marshal(respJSON)
  7353. fmt.Println("log")
  7354. fmt.Println(string(result))
  7355. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7356. utils.ErrorLog("解析失败:%v", err)
  7357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7358. return
  7359. }
  7360. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7361. res.Output = resSeven10265.Output
  7362. res.ErrMsg = resSeven10265.ErrMsg
  7363. res.Cainfo = resSeven10265.Cainfo
  7364. res.WarnMsg = resSeven10265.WarnMsg
  7365. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7366. res.Infcode = infocode
  7367. } else {
  7368. var result string
  7369. var request_log string
  7370. if miConfig.Code == "H15049901371" {
  7371. //赤峰地区国家医保医疗类别
  7372. //职工透析:医疗类别选特殊情况门诊990502
  7373. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7374. var med_type string
  7375. if his.Insutype == "390" {
  7376. if reg_type == 14 {
  7377. med_type = "9933"
  7378. } else if reg_type == 11 {
  7379. med_type = "11"
  7380. }
  7381. } else if his.Insutype == "310" {
  7382. if reg_type == 14 {
  7383. med_type = "990502"
  7384. } else if reg_type == 11 {
  7385. med_type = "11"
  7386. }
  7387. }
  7388. 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)
  7389. } else {
  7390. 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)
  7391. }
  7392. var dat map[string]interface{}
  7393. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7394. fmt.Println(dat)
  7395. } else {
  7396. fmt.Println(err)
  7397. }
  7398. saveLog(result, request_log, "2206", "预结算")
  7399. //userJSONBytes, _ := json.Marshal(dat)
  7400. //
  7401. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7402. // utils.ErrorLog("解析失败:%v", err)
  7403. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7404. // return
  7405. //}
  7406. userJSONBytes, _ := json.Marshal(dat)
  7407. if miConfig.Code == "H15049901371" {
  7408. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7409. utils.ErrorLog("解析失败:%v", err)
  7410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7411. return
  7412. }
  7413. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7414. res.Output = resSeven10265.Output
  7415. res.ErrMsg = resSeven10265.ErrMsg
  7416. res.Cainfo = resSeven10265.Cainfo
  7417. res.WarnMsg = resSeven10265.WarnMsg
  7418. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7419. res.Infcode = infocode
  7420. } else {
  7421. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7422. utils.ErrorLog("解析失败:%v", err)
  7423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7424. return
  7425. }
  7426. }
  7427. }
  7428. if res.Infcode != 0 {
  7429. errlog := &models.HisOrderError{
  7430. UserOrgId: adminUser.CurrentOrgId,
  7431. Ctime: time.Now().Unix(),
  7432. Mtime: time.Now().Unix(),
  7433. Number: chrg_bchno,
  7434. ErrMsg: res.ErrMsg,
  7435. Status: 1,
  7436. PatientId: id,
  7437. RecordTime: recordDateTime,
  7438. Stage: 20,
  7439. }
  7440. service.CreateErrMsgLog(errlog)
  7441. c.ServeSuccessJSON(map[string]interface{}{
  7442. "failed_code": -10,
  7443. "msg": res.ErrMsg,
  7444. })
  7445. return
  7446. } else {
  7447. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7448. order.OrderStatus = 1
  7449. order.IsPre = 1
  7450. order.Status = 1
  7451. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7452. order.SetlId = res.Output.Setlinfo.SetlID
  7453. order.PsnNo = res.Output.Setlinfo.PsnNo
  7454. order.PsnName = res.Output.Setlinfo.PsnName
  7455. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7456. order.Certno = res.Output.Setlinfo.Certno
  7457. order.Gend = res.Output.Setlinfo.Gend
  7458. order.Naty = res.Output.Setlinfo.Naty
  7459. order.Age = res.Output.Setlinfo.Age
  7460. order.Insutype = res.Output.Setlinfo.Insutype
  7461. order.PsnType = res.Output.Setlinfo.PsnType
  7462. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7463. order.SetlTime = res.Output.Setlinfo.SetlTime
  7464. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7465. if res.Output.Setlinfo.MedType == "140101" {
  7466. order.MedType = "14"
  7467. } else {
  7468. order.MedType = res.Output.Setlinfo.MedType
  7469. }
  7470. if reg_type == 1112 {
  7471. order.MedType = "1112"
  7472. }
  7473. if reg_type == 1111 {
  7474. order.MedType = "1111"
  7475. }
  7476. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7477. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7478. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7479. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7480. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7481. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7482. order.HifpPay = res.Output.Setlinfo.HifpPay
  7483. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7484. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7485. order.HifesPay = res.Output.Setlinfo.HifesPay
  7486. order.HifobPay = res.Output.Setlinfo.HifobPay
  7487. order.MafPay = res.Output.Setlinfo.MafPay
  7488. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7489. order.OthPay = res.Output.Setlinfo.OthPay
  7490. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7491. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7492. order.AcctPay = res.Output.Setlinfo.AcctPay
  7493. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7494. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7495. order.Balc = res.Output.Setlinfo.Balc
  7496. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7497. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7498. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7499. order.ClrWay = res.Output.Setlinfo.ClrWay
  7500. order.Creator = order.Creator
  7501. order.Modify = roles.AdminUserId
  7502. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7503. detailStr := string(setlDetail)
  7504. order.SetlDetail = detailStr
  7505. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7506. err = service.UpDateOrder(order)
  7507. if err == nil {
  7508. c.ServeSuccessJSON(map[string]interface{}{
  7509. "msg": "预结算成功",
  7510. })
  7511. } else {
  7512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7513. return
  7514. }
  7515. }
  7516. } else {
  7517. adminUser := c.GetAdminUserInfo()
  7518. errlog := &models.HisOrderError{
  7519. UserOrgId: adminUser.CurrentOrgId,
  7520. Ctime: time.Now().Unix(),
  7521. Mtime: time.Now().Unix(),
  7522. ErrMsg: res.ErrMsg,
  7523. Status: 1,
  7524. PatientId: id,
  7525. RecordTime: recordDateTime,
  7526. Stage: 4,
  7527. }
  7528. service.CreateErrMsgLog(errlog)
  7529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7530. return
  7531. }
  7532. } else {
  7533. adminUser := c.GetAdminUserInfo()
  7534. errlog := &models.HisOrderError{
  7535. UserOrgId: adminUser.CurrentOrgId,
  7536. Ctime: time.Now().Unix(),
  7537. Mtime: time.Now().Unix(),
  7538. ErrMsg: res.ErrMsg,
  7539. Status: 1,
  7540. PatientId: id,
  7541. RecordTime: recordDateTime,
  7542. Stage: 4,
  7543. }
  7544. service.CreateErrMsgLog(errlog)
  7545. c.ServeSuccessJSON(map[string]interface{}{
  7546. "failed_code": -10,
  7547. "msg": res.ErrMsg,
  7548. })
  7549. return
  7550. }
  7551. }
  7552. }
  7553. }
  7554. //func (c *HisApiController) GetSettleInfo() {
  7555. // id, _ := c.GetInt64("id")
  7556. // order_id, _ := c.GetInt64("order_id")
  7557. //
  7558. // record_time := c.GetString("record_time")
  7559. // pay_way, _ := c.GetInt64("pay_way")
  7560. // pay_price, _ := c.GetFloat("pay_price")
  7561. // pay_card_no := c.GetString("pay_card_no")
  7562. // discount_price, _ := c.GetFloat("discount_price")
  7563. // preferential_price, _ := c.GetFloat("preferential_price")
  7564. // reality_price, _ := c.GetFloat("reality_price")
  7565. // found_price, _ := c.GetFloat("found_price")
  7566. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7567. // private_price, _ := c.GetFloat("private_price")
  7568. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7569. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7570. //
  7571. // timeLayout := "2006-01-02"
  7572. // loc, _ := time.LoadLocation("Local")
  7573. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7574. // if err != nil {
  7575. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7576. // return
  7577. // }
  7578. // recordDateTime := theTime.Unix()
  7579. // adminUser := c.GetAdminUserInfo()
  7580. //
  7581. // var prescriptions []*models.HisPrescription
  7582. //
  7583. // data := make(map[string]interface{})
  7584. // if settle_accounts_type == 1 { //日结
  7585. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7586. // data["pre"] = prescriptions
  7587. //
  7588. // } else { //月结
  7589. // start_time_str := c.GetString("start_time")
  7590. // end_time_str := c.GetString("end_time")
  7591. // timeLayout := "2006-01-02"
  7592. // loc, _ := time.LoadLocation("Local")
  7593. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7594. // if err != nil {
  7595. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7596. // return
  7597. // }
  7598. // recordStartTime := theStartTime.Unix()
  7599. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7600. // if err != nil {
  7601. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7602. // return
  7603. // }
  7604. // recordEndTime := theEndTime.Unix()
  7605. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7606. // data["pre"] = prescriptions
  7607. //
  7608. // }
  7609. //
  7610. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7611. //
  7612. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7613. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7614. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7615. // strconv.FormatInt(his.PatientId, 10)
  7616. //
  7617. // order_src, _ := service.GetHisOrderByID(order_id)
  7618. //
  7619. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7620. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7621. //
  7622. // var total float64
  7623. // for _, item := range prescriptions {
  7624. // if item.Type == 1 { //药品
  7625. // for _, subItem := range item.HisDoctorAdviceInfo {
  7626. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7627. // }
  7628. // }
  7629. // if item.Type == 2 { //项目
  7630. // for _, subItem := range item.HisPrescriptionProject {
  7631. // total = total + (subItem.Price * float64(subItem.Count))
  7632. // }
  7633. // }
  7634. // }
  7635. //
  7636. // for _, item := range prescriptions {
  7637. // for _, subItem := range item.HisAdditionalCharge {
  7638. // total = total + (subItem.Price * float64(subItem.Count))
  7639. // }
  7640. // }
  7641. //
  7642. // allTotal := fmt.Sprintf("%.2f", total)
  7643. // var rf []*ResultFive
  7644. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7645. // psn_no := order_src.PsnNo
  7646. // mdtrt_id := order_src.MdtrtId
  7647. // chrg_bchno := order_src.Number
  7648. // cert_no := order_src.Certno
  7649. // insutype := rf[0].Insutype
  7650. //
  7651. // if his.IdCardType == 1 {
  7652. // cert_no = his.MedicalInsuranceNumber
  7653. // } else {
  7654. // cert_no = his.Certno
  7655. // }
  7656. //
  7657. // 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)
  7658. // var dat map[string]interface{}
  7659. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7660. // fmt.Println(dat)
  7661. // } else {
  7662. // fmt.Println(err)
  7663. // }
  7664. //
  7665. // userJSONBytes, _ := json.Marshal(dat)
  7666. //
  7667. //
  7668. //
  7669. // var res ResultSeven
  7670. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7671. // utils.ErrorLog("解析失败:%v", err)
  7672. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7673. // return
  7674. // }
  7675. // if res.Infcode == -1 {
  7676. // errlog := &models.HisOrderError{
  7677. // UserOrgId: adminUser.CurrentOrgId,
  7678. // Ctime: time.Now().Unix(),
  7679. // Mtime: time.Now().Unix(),
  7680. // Number: chrg_bchno,
  7681. // ErrMsg: res.ErrMsg,
  7682. // Status: 1,
  7683. // PatientId: id,
  7684. // RecordTime: recordDateTime,
  7685. // Stage: 6,
  7686. // }
  7687. // service.CreateErrMsgLog(errlog)
  7688. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7689. // return
  7690. // } else {
  7691. // order_src.OrderStatus = 2
  7692. // order_src.PayWay = pay_way
  7693. // order_src.PayPrice = pay_price
  7694. // order_src.PayCardNo = pay_card_no
  7695. // order_src.DiscountPrice = discount_price
  7696. // order_src.PreferentialPrice = preferential_price
  7697. // order_src.RealityPrice = reality_price
  7698. // order_src.FoundPrice = found_price
  7699. // order_src.MedicalInsurancePrice = medical_insurance_price
  7700. // order_src.PrivatePrice = private_price
  7701. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7702. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7703. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7704. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7705. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7706. // order_src.Certno = res.Output.Setlinfo.Certno
  7707. // order_src.Gend = res.Output.Setlinfo.Gend
  7708. // order_src.Naty = res.Output.Setlinfo.Naty
  7709. // order_src.Age = res.Output.Setlinfo.Age
  7710. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7711. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7712. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7713. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7714. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7715. // order_src.MedType = res.Output.Setlinfo.MedType
  7716. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7717. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7718. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7719. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7720. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7721. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7722. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7723. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7724. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7725. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7726. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7727. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7728. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7729. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7730. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7731. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7732. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7733. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7734. // order_src.Balc = res.Output.Setlinfo.Balc
  7735. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7736. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7737. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7738. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7739. // order_src.Creator = order_src.Creator
  7740. // order_src.Modify = roles.ID
  7741. // order_src.RequestLog = src_resquest
  7742. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7743. // detailStr := string(setlDetail)
  7744. // order_src.SetlDetail = detailStr
  7745. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7746. // err = service.UpDateOrder(order_src)
  7747. //
  7748. // if err == nil {
  7749. // c.ServeSuccessJSON(map[string]interface{}{
  7750. // "msg": "结算成功",
  7751. // })
  7752. // } else {
  7753. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7754. // return
  7755. // }
  7756. // }
  7757. // }
  7758. //}
  7759. //退款
  7760. func (c *HisApiController) Refund() {
  7761. order_id, _ := c.GetInt64("order_id")
  7762. admin_user_id, _ := c.GetInt64("admin_user_id")
  7763. adminUser := c.GetAdminUserInfo()
  7764. var order models.HisOrder
  7765. order, _ = service.GetHisOrderByID(order_id)
  7766. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7767. if order.ID == 0 {
  7768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7769. return
  7770. }
  7771. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7772. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7773. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7774. if config.IsOpen == 1 { //对接了医保,走医保流程
  7775. var res ResultSixteen
  7776. var resSixteen10265 ResultSixteen10265
  7777. var src_resquest string
  7778. var result string
  7779. if miConfig.MdtrtareaAdmvs == "421300" {
  7780. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7781. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7782. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7783. resp3, requestErr3 := http.Get(api3)
  7784. if requestErr3 != nil {
  7785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7786. return
  7787. }
  7788. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7789. if ioErr3 != nil {
  7790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7792. return
  7793. }
  7794. var respJSON3 map[string]interface{}
  7795. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7798. return
  7799. }
  7800. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7801. userJSONBytes3, _ := json.Marshal(respJSON3)
  7802. fmt.Println("log")
  7803. fmt.Println(string(userJSONBytes3))
  7804. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7805. utils.ErrorLog("解析失败:%v", err)
  7806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7807. return
  7808. }
  7809. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7810. var api3 string
  7811. if miConfig.MdtrtareaAdmvs == "320921" {
  7812. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7813. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7814. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7815. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7816. } else {
  7817. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7818. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7819. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7820. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7821. }
  7822. resp3, requestErr3 := http.Get(api3)
  7823. if requestErr3 != nil {
  7824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7825. return
  7826. }
  7827. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7828. if ioErr3 != nil {
  7829. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7831. return
  7832. }
  7833. var respJSON3 map[string]interface{}
  7834. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7837. return
  7838. }
  7839. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7840. userJSONBytes3, _ := json.Marshal(respJSON3)
  7841. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7842. utils.ErrorLog("解析失败:%v", err)
  7843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7844. return
  7845. }
  7846. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7847. res.Output = resSixteen10265.Output
  7848. res.ErrMsg = resSixteen10265.ErrMsg
  7849. res.Cainfo = resSixteen10265.Cainfo
  7850. res.WarnMsg = resSixteen10265.WarnMsg
  7851. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7852. res.Infcode = infocode
  7853. } else {
  7854. if miConfig.Code == "H15049901371" {
  7855. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7856. var dat map[string]interface{}
  7857. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7858. fmt.Println(dat)
  7859. } else {
  7860. fmt.Println(err)
  7861. }
  7862. saveLog(result, src_resquest, "2208", "退费")
  7863. userJSONBytes, _ := json.Marshal(dat)
  7864. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7865. utils.ErrorLog("解析失败:%v", err)
  7866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7867. return
  7868. }
  7869. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7870. res.Output = resSixteen10265.Output
  7871. res.ErrMsg = resSixteen10265.ErrMsg
  7872. res.Cainfo = resSixteen10265.Cainfo
  7873. res.WarnMsg = resSixteen10265.WarnMsg
  7874. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7875. res.Infcode = infocode
  7876. } else {
  7877. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7878. var dat map[string]interface{}
  7879. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7880. fmt.Println(dat)
  7881. } else {
  7882. fmt.Println(err)
  7883. }
  7884. saveLog(result, src_resquest, "2208", "退费")
  7885. userJSONBytes, _ := json.Marshal(dat)
  7886. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7887. utils.ErrorLog("解析失败:%v", err)
  7888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7889. return
  7890. }
  7891. }
  7892. }
  7893. if res.Infcode == 0 {
  7894. var res2 ResultSix
  7895. var resSix10265 ResultSix10265
  7896. if miConfig.MdtrtareaAdmvs == "421300" {
  7897. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7898. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7899. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7900. resp3, requestErr3 := http.Get(api3)
  7901. if requestErr3 != nil {
  7902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7903. return
  7904. }
  7905. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7906. if ioErr3 != nil {
  7907. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7909. return
  7910. }
  7911. var respJSON3 map[string]interface{}
  7912. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7915. return
  7916. }
  7917. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7918. userJSONBytes3, _ := json.Marshal(respJSON3)
  7919. fmt.Println("log")
  7920. fmt.Println(string(userJSONBytes3))
  7921. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7922. utils.ErrorLog("解析失败:%v", err)
  7923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7924. return
  7925. }
  7926. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7927. var api3 string
  7928. if miConfig.MdtrtareaAdmvs == "320921" {
  7929. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7930. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7931. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7932. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7933. } else {
  7934. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7935. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7936. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7937. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7938. }
  7939. resp3, requestErr3 := http.Get(api3)
  7940. if requestErr3 != nil {
  7941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7942. return
  7943. }
  7944. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7945. if ioErr3 != nil {
  7946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7948. return
  7949. }
  7950. var respJSON3 map[string]interface{}
  7951. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7954. return
  7955. }
  7956. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7957. userJSONBytes3, _ := json.Marshal(respJSON3)
  7958. fmt.Println("log")
  7959. fmt.Println(string(userJSONBytes3))
  7960. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7961. utils.ErrorLog("解析失败:%v", err)
  7962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7963. return
  7964. }
  7965. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7966. res2.Output = resSix10265.Output
  7967. res2.ErrMsg = resSix10265.ErrMsg
  7968. res2.Cainfo = resSix10265.Cainfo
  7969. res2.WarnMsg = resSix10265.WarnMsg
  7970. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7971. res2.Infcode = infocode
  7972. } else {
  7973. if miConfig.Code == "H15049901371" {
  7974. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7975. var dat map[string]interface{}
  7976. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7977. fmt.Println(dat)
  7978. } else {
  7979. fmt.Println(err)
  7980. }
  7981. saveLog(result2, src_request, "2205", "撤销明细")
  7982. userJSONBytes, _ := json.Marshal(dat)
  7983. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7984. utils.ErrorLog("解析失败:%v", err)
  7985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7986. return
  7987. }
  7988. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7989. res2.Output = resSix10265.Output
  7990. res2.ErrMsg = resSix10265.ErrMsg
  7991. res2.Cainfo = resSix10265.Cainfo
  7992. res2.WarnMsg = resSix10265.WarnMsg
  7993. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7994. res2.Infcode = infocode
  7995. } else {
  7996. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7997. var dat map[string]interface{}
  7998. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7999. fmt.Println(dat)
  8000. } else {
  8001. fmt.Println(err)
  8002. }
  8003. saveLog(result2, src_request, "2205", "撤销明细")
  8004. userJSONBytes, _ := json.Marshal(dat)
  8005. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8006. utils.ErrorLog("解析失败:%v", err)
  8007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8008. return
  8009. }
  8010. }
  8011. }
  8012. if res2.Infcode == 0 {
  8013. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8014. if err == nil {
  8015. //当押金不为零时产生退费记录
  8016. if order.Decimal != 0 {
  8017. tmp := strconv.FormatInt(order.ID, 10)
  8018. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8019. if err != nil {
  8020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8021. return
  8022. }
  8023. }
  8024. c.ServeSuccessJSON(map[string]interface{}{
  8025. "msg": "退费成功",
  8026. })
  8027. } else {
  8028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8029. return
  8030. }
  8031. } else {
  8032. c.ServeSuccessJSON(map[string]interface{}{
  8033. "code": -10,
  8034. "msg": res2.ErrMsg,
  8035. })
  8036. }
  8037. } else {
  8038. c.ServeSuccessJSON(map[string]interface{}{
  8039. "code": -10,
  8040. "msg": res.ErrMsg,
  8041. })
  8042. }
  8043. }
  8044. }
  8045. func (c *HisApiController) RefundNumber() {
  8046. record_time := c.GetString("record_time")
  8047. //patient_id, _ := c.GetInt64("patient_id")
  8048. admin_user_id, _ := c.GetInt64("admin_user_id")
  8049. his_patient_id, _ := c.GetInt64("id")
  8050. timeLayout := "2006-01-02"
  8051. loc, _ := time.LoadLocation("Local")
  8052. adminUser := c.GetAdminUserInfo()
  8053. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8054. fmt.Println(err)
  8055. if err != nil {
  8056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8057. return
  8058. }
  8059. recordDateTime := theTime.Unix()
  8060. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8061. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8062. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8063. //order, _ := service.GetHisOrderByID(order_id)
  8064. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8065. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8066. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8067. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8068. if count > 0 {
  8069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8070. return
  8071. }
  8072. if config.IsOpen == 1 { //对接了医保,走医保流程
  8073. var res2 ResultSix
  8074. var resSix10265 ResultSix10265
  8075. if miConfig.MdtrtareaAdmvs == "421300" {
  8076. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8077. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8078. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8079. resp3, requestErr3 := http.Get(api3)
  8080. if requestErr3 != nil {
  8081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8082. return
  8083. }
  8084. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8085. if ioErr3 != nil {
  8086. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8088. return
  8089. }
  8090. var respJSON3 map[string]interface{}
  8091. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8092. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8094. return
  8095. }
  8096. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8097. userJSONBytes3, _ := json.Marshal(respJSON3)
  8098. fmt.Println("log")
  8099. fmt.Println(string(userJSONBytes3))
  8100. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8101. utils.ErrorLog("解析失败:%v", err)
  8102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8103. return
  8104. }
  8105. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8106. var api3 string
  8107. if miConfig.MdtrtareaAdmvs == "320921" {
  8108. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8109. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8110. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8111. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8112. } else {
  8113. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8114. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8115. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8116. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8117. }
  8118. resp3, requestErr3 := http.Get(api3)
  8119. if requestErr3 != nil {
  8120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8121. return
  8122. }
  8123. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8124. if ioErr3 != nil {
  8125. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8127. return
  8128. }
  8129. var respJSON3 map[string]interface{}
  8130. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8133. return
  8134. }
  8135. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8136. userJSONBytes3, _ := json.Marshal(respJSON3)
  8137. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8138. utils.ErrorLog("解析失败:%v", err)
  8139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8140. return
  8141. }
  8142. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8143. res2.Output = resSix10265.Output
  8144. res2.ErrMsg = resSix10265.ErrMsg
  8145. res2.Cainfo = resSix10265.Cainfo
  8146. res2.WarnMsg = resSix10265.WarnMsg
  8147. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8148. res2.Infcode = infocode
  8149. } else {
  8150. var api3 string
  8151. if miConfig.Code == "H15049901371" {
  8152. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8153. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8154. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8155. } else {
  8156. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8157. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8158. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8159. }
  8160. resp3, requestErr3 := http.Get(api3)
  8161. if requestErr3 != nil {
  8162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8163. return
  8164. }
  8165. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8166. if ioErr3 != nil {
  8167. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8169. return
  8170. }
  8171. var respJSON3 map[string]interface{}
  8172. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8173. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8175. return
  8176. }
  8177. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8178. userJSONBytes3, _ := json.Marshal(respJSON3)
  8179. if miConfig.Code == "H15049901371" {
  8180. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8181. utils.ErrorLog("解析失败:%v", err)
  8182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8183. return
  8184. }
  8185. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8186. res2.Output = resSix10265.Output
  8187. res2.ErrMsg = resSix10265.ErrMsg
  8188. res2.Cainfo = resSix10265.Cainfo
  8189. res2.WarnMsg = resSix10265.WarnMsg
  8190. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8191. res2.Infcode = infocode
  8192. } else {
  8193. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8194. utils.ErrorLog("解析失败:%v", err)
  8195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8196. return
  8197. }
  8198. }
  8199. }
  8200. if res2.Infcode == 0 {
  8201. if err == nil {
  8202. c.ServeSuccessJSON(map[string]interface{}{
  8203. "msg": "退号成功",
  8204. })
  8205. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8206. } else {
  8207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8208. return
  8209. }
  8210. } else {
  8211. c.ServeSuccessJSON(map[string]interface{}{
  8212. "code": -10,
  8213. "msg": res2.ErrMsg,
  8214. })
  8215. }
  8216. } else {
  8217. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8218. //if err == nil {
  8219. // c.ServeSuccessJSON(map[string]interface{}{
  8220. // "msg": "退费成功",
  8221. // })
  8222. //} else {
  8223. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8224. // return
  8225. //}
  8226. }
  8227. }
  8228. func (c *HisApiController) RefundDetail() {
  8229. order_id, _ := c.GetInt64("order_id")
  8230. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8231. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8232. number := c.GetString("number")
  8233. record_time := c.GetString("record_time")
  8234. patient_id, _ := c.GetInt64("patient_id")
  8235. //med_type, _ := c.GetInt64("med_type")
  8236. timeLayout := "2006-01-02"
  8237. loc, _ := time.LoadLocation("Local")
  8238. adminUser := c.GetAdminUserInfo()
  8239. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8240. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8241. fmt.Println(err)
  8242. if err != nil {
  8243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8244. return
  8245. }
  8246. recordDateTime := theTime.Unix()
  8247. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8248. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8249. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8250. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8251. var order models.HisOrder
  8252. order, _ = service.GetHisOrderByID(order_id)
  8253. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8254. if config.IsOpen == 1 { //对接了医保,走医保流程
  8255. var res2 ResultSix
  8256. if miConfig.MdtrtareaAdmvs == "421300" {
  8257. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8258. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8259. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8260. resp3, requestErr3 := http.Get(api3)
  8261. if requestErr3 != nil {
  8262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8263. return
  8264. }
  8265. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8266. if ioErr3 != nil {
  8267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8269. return
  8270. }
  8271. var respJSON3 map[string]interface{}
  8272. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8275. return
  8276. }
  8277. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8278. userJSONBytes3, _ := json.Marshal(respJSON3)
  8279. fmt.Println("log")
  8280. fmt.Println(string(userJSONBytes3))
  8281. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8282. utils.ErrorLog("解析失败:%v", err)
  8283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8284. return
  8285. }
  8286. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8287. if err == nil {
  8288. c.ServeSuccessJSON(map[string]interface{}{
  8289. "msg": "撤销明细成功",
  8290. })
  8291. return
  8292. } else {
  8293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8294. return
  8295. }
  8296. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8297. var resSix10265 ResultSix10265
  8298. var api3 string
  8299. if miConfig.MdtrtareaAdmvs == "320921" {
  8300. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8301. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8302. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8303. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8304. } else {
  8305. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8306. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8307. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8308. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8309. }
  8310. resp3, requestErr3 := http.Get(api3)
  8311. if requestErr3 != nil {
  8312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8313. return
  8314. }
  8315. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8316. if ioErr3 != nil {
  8317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8319. return
  8320. }
  8321. var respJSON3 map[string]interface{}
  8322. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8325. return
  8326. }
  8327. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8328. userJSONBytes3, _ := json.Marshal(respJSON3)
  8329. fmt.Println("log")
  8330. fmt.Println(string(userJSONBytes3))
  8331. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8332. utils.ErrorLog("解析失败:%v", err)
  8333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8334. return
  8335. }
  8336. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8337. res2.Output = resSix10265.Output
  8338. res2.ErrMsg = resSix10265.ErrMsg
  8339. res2.Cainfo = resSix10265.Cainfo
  8340. res2.WarnMsg = resSix10265.WarnMsg
  8341. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8342. res2.Infcode = infocode
  8343. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8344. if err == nil {
  8345. c.ServeSuccessJSON(map[string]interface{}{
  8346. "msg": "撤销明细成功",
  8347. })
  8348. return
  8349. } else {
  8350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8351. return
  8352. }
  8353. } else {
  8354. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8355. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8356. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8357. resp2, requestErr2 := http.Get(api2)
  8358. if requestErr2 != nil {
  8359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8360. return
  8361. }
  8362. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8363. if ioErr2 != nil {
  8364. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8366. return
  8367. }
  8368. var respJSON2 map[string]interface{}
  8369. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8370. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8372. return
  8373. }
  8374. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8375. if err == nil {
  8376. c.ServeSuccessJSON(map[string]interface{}{
  8377. "msg": "撤销明细成功",
  8378. })
  8379. return
  8380. } else {
  8381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8382. return
  8383. }
  8384. }
  8385. } else {
  8386. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8387. if err == nil {
  8388. c.ServeSuccessJSON(map[string]interface{}{
  8389. "msg": "退费成功",
  8390. })
  8391. } else {
  8392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8393. return
  8394. }
  8395. }
  8396. }
  8397. //对账
  8398. func (c *HisApiController) GetCheckAccount() {
  8399. start_time := c.GetString("start_time")
  8400. end_time := c.GetString("end_time")
  8401. insutype := c.GetString("insutype")
  8402. clr_type := c.GetString("clr_type")
  8403. clr_org := c.GetString("clr_optins")
  8404. admin_user_id, _ := c.GetInt64("admin_user_id")
  8405. adminUser := c.GetAdminUserInfo()
  8406. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8407. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8408. if len(clr_org) == 0 {
  8409. clr_org = miConfig.MdtrtareaAdmvs
  8410. }
  8411. timeLayout := "2006-01-02"
  8412. loc, _ := time.LoadLocation("Local")
  8413. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8414. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8415. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8416. fixmedins_setl_cnt := int64(len(orders))
  8417. var medfee_sumamt float64
  8418. var acct_pay float64
  8419. var fund_pay_sumamt float64
  8420. for _, item := range orders {
  8421. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8422. acct_pay = acct_pay + item.AcctPay
  8423. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8424. }
  8425. var user_name string
  8426. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8427. if role.ID == 0 {
  8428. user_name = "xxx"
  8429. } else {
  8430. user_name = role.UserName
  8431. }
  8432. var res ResultEight
  8433. var res10188 ResultEightFor10188
  8434. if config.IsOpen == 1 {
  8435. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8436. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  8437. "insutype=" + insutype +
  8438. "&clr_type=" + "11" +
  8439. "&setl_optins=" + clr_org +
  8440. "&stmt_begndate=" + start_time +
  8441. "&stm_enddate=" + end_time +
  8442. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8443. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8444. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8445. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8446. "&fixmedins_code=" + miConfig.Code +
  8447. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8448. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8449. "&secret_key=" + miConfig.SecretKey +
  8450. "&org_name=" + miConfig.OrgName +
  8451. "&doctor=" + user_name +
  8452. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8453. fmt.Println(api)
  8454. resp, requestErr := http.Get(api)
  8455. if requestErr != nil {
  8456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8457. return
  8458. }
  8459. body, ioErr := ioutil.ReadAll(resp.Body)
  8460. fmt.Println(body)
  8461. if ioErr != nil {
  8462. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8464. return
  8465. }
  8466. var respJSON map[string]interface{}
  8467. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8470. return
  8471. }
  8472. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8473. userJSONBytes, _ := json.Marshal(respJSON)
  8474. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8475. utils.ErrorLog("解析失败:%v", err)
  8476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8477. return
  8478. }
  8479. res.InfRefmsgid = res10188.InfRefmsgid
  8480. res.Output = res10188.Output
  8481. res.ErrMsg = res10188.ErrMsg
  8482. res.Cainfo = res10188.Cainfo
  8483. res.WarnMsg = res10188.WarnMsg
  8484. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8485. res.Infcode = infocode
  8486. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8487. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8488. "insutype=" + insutype +
  8489. "&clr_type=" + "21" +
  8490. "&setl_optins=" + clr_org +
  8491. "&stmt_begndate=" + start_time +
  8492. "&stm_enddate=" + end_time +
  8493. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8494. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8495. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8496. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8497. "&fixmedins_code=" + miConfig.Code +
  8498. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8499. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8500. "&secret_key=" + miConfig.SecretKey +
  8501. "&org_name=" + miConfig.OrgName +
  8502. "&doctor=" + user_name
  8503. resp, requestErr := http.Get(api)
  8504. if requestErr != nil {
  8505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8506. return
  8507. }
  8508. body, ioErr := ioutil.ReadAll(resp.Body)
  8509. if ioErr != nil {
  8510. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8512. return
  8513. }
  8514. var respJSON map[string]interface{}
  8515. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8516. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8518. return
  8519. }
  8520. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8521. result, _ := json.Marshal(respJSON)
  8522. fmt.Println("log")
  8523. fmt.Println(string(result))
  8524. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8525. utils.ErrorLog("解析失败:%v", err)
  8526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8527. return
  8528. }
  8529. res.InfRefmsgid = res10188.InfRefmsgid
  8530. res.Output = res10188.Output
  8531. res.ErrMsg = res10188.ErrMsg
  8532. res.Cainfo = res10188.Cainfo
  8533. res.WarnMsg = res10188.WarnMsg
  8534. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8535. res.Infcode = infocode
  8536. } else {
  8537. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8538. "insutype=" + insutype +
  8539. "&clr_type=" + clr_type +
  8540. "&setl_optins=" + clr_org +
  8541. "&stmt_begndate=" + start_time +
  8542. "&stm_enddate=" + end_time +
  8543. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8544. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8545. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8546. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8547. "&fixmedins_code=" + miConfig.Code +
  8548. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8549. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8550. "&secret_key=" + miConfig.SecretKey +
  8551. "&org_name=" + miConfig.OrgName +
  8552. "&doctor=" + user_name
  8553. fmt.Println(api)
  8554. resp, requestErr := http.Get(api)
  8555. if requestErr != nil {
  8556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8557. return
  8558. }
  8559. body, ioErr := ioutil.ReadAll(resp.Body)
  8560. fmt.Println(body)
  8561. if ioErr != nil {
  8562. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8564. return
  8565. }
  8566. var respJSON map[string]interface{}
  8567. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8568. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8570. return
  8571. }
  8572. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8573. userJSONBytes, _ := json.Marshal(respJSON)
  8574. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8575. utils.ErrorLog("解析失败:%v", err)
  8576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8577. return
  8578. }
  8579. }
  8580. if res.Infcode == 0 {
  8581. if res.Output.Stmtinfo.StmtRslt == "0" {
  8582. micc := &models.MedicalInsuranceCostCompare{
  8583. StartTime: startime.Unix(),
  8584. EndTime: endtime.Unix(),
  8585. Insutype: insutype,
  8586. CheckType: 1,
  8587. Num: fixmedins_setl_cnt,
  8588. Mtime: time.Now().Unix(),
  8589. Status: 1,
  8590. UserOrgId: adminUser.CurrentOrgId,
  8591. CostTotal: medfee_sumamt,
  8592. FuncTotal: fund_pay_sumamt,
  8593. PsnPay: acct_pay,
  8594. Creator: admin_user_id,
  8595. Ctime: time.Now().Unix(),
  8596. ClrType: clr_type,
  8597. }
  8598. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8599. if err == nil {
  8600. c.ServeSuccessJSON(map[string]interface{}{
  8601. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8602. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8603. })
  8604. } else {
  8605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8606. }
  8607. } else {
  8608. c.ServeSuccessJSON(map[string]interface{}{
  8609. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8610. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8611. })
  8612. }
  8613. } else {
  8614. c.ServeSuccessJSON(map[string]interface{}{
  8615. "code": -10,
  8616. "msg": res.ErrMsg,
  8617. })
  8618. }
  8619. }
  8620. }
  8621. func (c *HisApiController) Check310() {
  8622. adminUser := c.GetAdminUserInfo()
  8623. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8624. var user_name string
  8625. user_name = "高慧裕"
  8626. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8627. "insutype=" + "310" +
  8628. "&clr_type=" + "" +
  8629. "&setl_optins=" + "441202" +
  8630. "&stmt_begndate=" + "2022-03-01" +
  8631. "&stm_enddate=" + "2022-03-31" +
  8632. "&medfee_sumamt=" + "194930.12" +
  8633. "&fund_pay_sumamt=" + "188741.46" +
  8634. "&acct_pay=" + "0" +
  8635. "&fixmedins_setl_cnt=" + "452" +
  8636. "&fixmedins_code=" + miConfig.Code +
  8637. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8638. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8639. "&secret_key=" + miConfig.SecretKey +
  8640. "&org_name=" + miConfig.OrgName +
  8641. "&doctor=" + user_name
  8642. fmt.Println(api)
  8643. resp, requestErr := http.Get(api)
  8644. if requestErr != nil {
  8645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8646. return
  8647. }
  8648. body, ioErr := ioutil.ReadAll(resp.Body)
  8649. fmt.Println(body)
  8650. if ioErr != nil {
  8651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8653. return
  8654. }
  8655. var respJSON map[string]interface{}
  8656. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8659. return
  8660. }
  8661. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8662. userJSONBytes, _ := json.Marshal(respJSON)
  8663. var res ResultEight
  8664. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8665. utils.ErrorLog("解析失败:%v", err)
  8666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8667. return
  8668. }
  8669. }
  8670. func (c *HisApiController) Check390() {
  8671. adminUser := c.GetAdminUserInfo()
  8672. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8673. var user_name string
  8674. user_name = "高慧裕"
  8675. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8676. "insutype=" + "390" +
  8677. "&clr_type=" + "" +
  8678. "&setl_optins=" + "441202" +
  8679. "&stmt_begndate=" + "2022-03-01" +
  8680. "&stm_enddate=" + "2022-03-31" +
  8681. "&medfee_sumamt=" + "1068448.89" +
  8682. "&fund_pay_sumamt=" + "1014677.62" +
  8683. "&acct_pay=" + "0" +
  8684. "&fixmedins_setl_cnt=" + "1950" +
  8685. "&fixmedins_code=" + miConfig.Code +
  8686. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8687. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8688. "&secret_key=" + miConfig.SecretKey +
  8689. "&org_name=" + miConfig.OrgName +
  8690. "&doctor=" + user_name
  8691. fmt.Println(api)
  8692. resp, requestErr := http.Get(api)
  8693. if requestErr != nil {
  8694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8695. return
  8696. }
  8697. body, ioErr := ioutil.ReadAll(resp.Body)
  8698. fmt.Println(body)
  8699. if ioErr != nil {
  8700. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8702. return
  8703. }
  8704. var respJSON map[string]interface{}
  8705. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8706. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8708. return
  8709. }
  8710. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8711. userJSONBytes, _ := json.Marshal(respJSON)
  8712. var res ResultEight
  8713. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8714. utils.ErrorLog("解析失败:%v", err)
  8715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8716. return
  8717. }
  8718. }
  8719. //对账明细
  8720. func (c *HisApiController) GetCheckDetailAccount() {
  8721. start_time := c.GetString("start_time")
  8722. end_time := c.GetString("end_time")
  8723. admin_user_id, _ := c.GetInt64("admin_user_id")
  8724. adminUser := c.GetAdminUserInfo()
  8725. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8726. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8727. timeLayout := "2006-01-02"
  8728. loc, _ := time.LoadLocation("Local")
  8729. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8730. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8731. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8732. rand.Seed(time.Now().UnixNano())
  8733. num := rand.Intn(30000)
  8734. Mkdir(miConfig.OrgName)
  8735. file := strconv.FormatInt(int64(num), 10)
  8736. file_name := file + ".txt"
  8737. zip_name := file + ".zip"
  8738. zip_path := miConfig.OrgName + "/" + zip_name
  8739. file_path := miConfig.OrgName + "/" + file_name
  8740. decimal.DivisionPrecision = 2
  8741. var medfee_sumamt float64
  8742. var psn_cash_pay float64
  8743. var fund_pay_sumamt float64
  8744. fixmedins_setl_cnt := int64(len(orders))
  8745. for _, item := range orders {
  8746. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8747. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8748. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8749. }
  8750. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8751. defer f.Close()
  8752. if err != nil {
  8753. fmt.Println(err.Error())
  8754. } else {
  8755. for _, item := range orders {
  8756. var refd_setl_flag string
  8757. if item.OrderStatus == 2 {
  8758. refd_setl_flag = "0"
  8759. var str string
  8760. str = item.SetlId + " " +
  8761. item.MdtrtId + " " +
  8762. item.PsnNo + " " +
  8763. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8764. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8765. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8766. _, err = f.Write([]byte(str))
  8767. }
  8768. if item.OrderStatus == 3 {
  8769. var str string
  8770. str = item.SetlId + " " +
  8771. item.MdtrtId + " " +
  8772. item.PsnNo + " " +
  8773. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8774. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8775. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8776. _, err = f.Write([]byte(str))
  8777. var str2 string
  8778. str2 = item.SetlId + " " +
  8779. item.MdtrtId + " " +
  8780. item.PsnNo + " " +
  8781. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8782. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8783. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8784. _, err = f.Write([]byte(str2))
  8785. }
  8786. }
  8787. }
  8788. Zip(file_path, zip_path)
  8789. fmt.Println(ReadFile(zip_path))
  8790. fmt.Println(string(ReadFile(zip_path)))
  8791. if config.IsOpen == 1 {
  8792. var user_name string
  8793. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8794. if role.ID == 0 {
  8795. user_name = "管理员"
  8796. } else {
  8797. user_name = role.UserName
  8798. }
  8799. baseParams := models.BaseParams{
  8800. SecretKey: miConfig.SecretKey,
  8801. FixmedinsCode: miConfig.Code,
  8802. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8803. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8804. OrgName: miConfig.OrgName,
  8805. Doctor: user_name,
  8806. }
  8807. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  8808. var dat map[string]interface{}
  8809. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8810. fmt.Println(dat)
  8811. } else {
  8812. fmt.Println(err)
  8813. }
  8814. userJSONBytes, _ := json.Marshal(dat)
  8815. var res ResultNine
  8816. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8817. utils.ErrorLog("解析失败:%v", err)
  8818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8819. return
  8820. }
  8821. if res.Infcode == 0 {
  8822. fileNo := res.Output.FileQuryNo
  8823. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8824. "file_qury_no=" + fileNo +
  8825. "&setl_optins=" + "定点医保中心" +
  8826. "&stmt_begndate=" + start_time +
  8827. "&stm_enddate=" + end_time +
  8828. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8829. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8830. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8831. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8832. "&fixmedins_code=" + miConfig.Code +
  8833. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8834. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8835. "&secret_key=" + miConfig.SecretKey +
  8836. "&org_name=" + miConfig.OrgName +
  8837. "&doctor=" + user_name
  8838. resp, requestErr := http.Get(api)
  8839. if requestErr != nil {
  8840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8841. return
  8842. }
  8843. body, ioErr := ioutil.ReadAll(resp.Body)
  8844. if ioErr != nil {
  8845. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8847. return
  8848. }
  8849. var respJSON map[string]interface{}
  8850. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8851. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8853. return
  8854. }
  8855. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8856. userJSONBytes, _ := json.Marshal(respJSON)
  8857. var res ResultTen
  8858. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8859. utils.ErrorLog("解析失败:%v", err)
  8860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8861. return
  8862. }
  8863. if res.Infcode == 0 {
  8864. service.Gdyb9102(baseParams, zip_name, fileNo)
  8865. micc := &models.MedicalInsuranceCostCompare{
  8866. StartTime: startime.Unix(),
  8867. EndTime: endtime.Unix(),
  8868. Insutype: "0",
  8869. CheckType: 2,
  8870. Num: fixmedins_setl_cnt,
  8871. Mtime: time.Now().Unix(),
  8872. Status: 1,
  8873. UserOrgId: adminUser.CurrentOrgId,
  8874. CostTotal: medfee_sumamt,
  8875. FuncTotal: fund_pay_sumamt,
  8876. PsnPay: psn_cash_pay,
  8877. Creator: admin_user_id,
  8878. Ctime: time.Now().Unix(),
  8879. }
  8880. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8881. c.ServeSuccessJSON(map[string]interface{}{
  8882. "msg": "明细对账成功",
  8883. })
  8884. }
  8885. } else {
  8886. }
  8887. }
  8888. }
  8889. type CustomOrderInfo struct {
  8890. Name string
  8891. Spec string
  8892. Unit string
  8893. Count float64
  8894. Price float64
  8895. Total float64
  8896. }
  8897. func (c *HisApiController) GetSettleAccounts() {
  8898. //id, _ := c.GetInt64("id")
  8899. //record_time := c.GetString("record_time")
  8900. order_id, _ := c.GetInt64("order_id")
  8901. admin_user_id, _ := c.GetInt64("admin_user_id")
  8902. //timeLayout := "2006-01-02"
  8903. //loc, _ := time.LoadLocation("Local")
  8904. //
  8905. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8906. //if err != nil {
  8907. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8908. // return
  8909. //}
  8910. //recordDateTime := theTime.Unix()
  8911. adminUser := c.GetAdminUserInfo()
  8912. order, _ := service.GetHisOrderByID(order_id)
  8913. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8914. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8915. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8916. orderInfos = append(orderInfos, orderInfos_two...)
  8917. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8918. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8919. var diagnosis_ids []string
  8920. if his.ID > 0 {
  8921. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8922. } else {
  8923. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8924. }
  8925. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8926. var dia_config []*models.HisXtDiagnoseConfig
  8927. var name string
  8928. for _, item := range diagnosis_ids {
  8929. id, _ := strconv.ParseInt(item, 10, 64)
  8930. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8931. dia_config = append(dia_config, &diagnosisConfig)
  8932. if len(name) == 0 {
  8933. name = diagnosisConfig.ClassName
  8934. } else {
  8935. name = name + "," + diagnosisConfig.ClassName
  8936. }
  8937. }
  8938. var bedCostTotal float64 = 0 //床位总费
  8939. var bedCostSelfTotal float64 = 0 //床位自费
  8940. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8941. var operationCostTotal float64 = 0 //手术费
  8942. var operationCostSelfTotal float64 = 0 //手术费
  8943. var operationCostPartSelfTotal float64 = 0 //手术费
  8944. var otherCostTotal float64 = 0 //其他费用
  8945. var otherCostSelfTotal float64 = 0 //其他费用
  8946. var otherCostPartSelfTotal float64 = 0 //其他费用
  8947. var materialCostTotal float64 = 0 //材料费
  8948. var materialCostSelfTotal float64 = 0 //材料费
  8949. var materialCostPartSelfTotal float64 = 0 //材料费
  8950. var westernMedicineCostTotal float64 = 0 //西药费
  8951. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8952. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8953. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8954. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8955. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8956. var checkCostTotal float64 = 0 //检查费
  8957. var checkCostSelfTotal float64 = 0 //检查费
  8958. var checkCostPartSelfTotal float64 = 0 //检查费
  8959. var laboratoryCostTotal float64 = 0 //化验费
  8960. var laboratoryCostSelfTotal float64 = 0 //化验费
  8961. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8962. var treatCostTotal float64 = 0 //治疗费用
  8963. var treatCostSelfTotal float64 = 0 //治疗费用
  8964. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8965. decimal.DivisionPrecision = 2
  8966. for _, item := range orderInfos {
  8967. if item.MedChrgitmType == "01" { //床位费
  8968. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8969. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8970. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8971. }
  8972. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8973. if item.MedChrgitmType == "03" { //检查费
  8974. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8975. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8976. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8977. }
  8978. } else {
  8979. if item.MedChrgitmType == "03" { //检查费
  8980. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8981. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8982. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8983. }
  8984. }
  8985. if item.MedChrgitmType == "04" { //化验费
  8986. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8987. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8988. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8989. }
  8990. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  8991. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8992. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8993. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8994. }
  8995. if item.MedChrgitmType == "06" { //手术费
  8996. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8997. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8998. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8999. }
  9000. if item.MedChrgitmType == "08" { //材料费
  9001. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9002. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9003. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9004. }
  9005. if item.MedChrgitmType == "09" { //西药费
  9006. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9007. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9008. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9009. }
  9010. if item.MedChrgitmType == "11" { //中成费
  9011. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9012. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9013. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9014. }
  9015. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9016. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9017. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9018. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9019. }
  9020. }
  9021. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9022. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9023. var user_name string
  9024. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9025. if role.ID == 0 {
  9026. user_name = "管理员"
  9027. } else {
  9028. user_name = role.UserName
  9029. }
  9030. baseParams := models.BaseParams{
  9031. SecretKey: miConfig.SecretKey,
  9032. FixmedinsCode: miConfig.Code,
  9033. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9034. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9035. OrgName: miConfig.OrgName,
  9036. Doctor: user_name,
  9037. }
  9038. businessParams := models.BusinessParams{
  9039. PsnNo: order.PsnNo,
  9040. MdtrtId: order.MdtrtId,
  9041. SetlId: order.SetlId,
  9042. }
  9043. var res ResultEleven
  9044. var resEleven10265 ResultEleven10265
  9045. if config.IsOpen == 1 {
  9046. if miConfig.MdtrtareaAdmvs == "421300" {
  9047. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9048. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9049. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9050. resp, requestErr := http.Get(api)
  9051. if requestErr != nil {
  9052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9053. return
  9054. }
  9055. body, ioErr := ioutil.ReadAll(resp.Body)
  9056. if ioErr != nil {
  9057. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9059. return
  9060. }
  9061. var respJSON map[string]interface{}
  9062. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9065. return
  9066. }
  9067. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9068. result, _ := json.Marshal(respJSON)
  9069. fmt.Println("log")
  9070. fmt.Println(string(result))
  9071. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9072. utils.ErrorLog("解析失败:%v", err)
  9073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9074. return
  9075. }
  9076. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9077. var api string
  9078. if miConfig.MdtrtareaAdmvs == "320921" {
  9079. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9080. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9081. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9082. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9083. } else {
  9084. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9085. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9086. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9087. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9088. }
  9089. resp, requestErr := http.Get(api)
  9090. if requestErr != nil {
  9091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9092. return
  9093. }
  9094. body, ioErr := ioutil.ReadAll(resp.Body)
  9095. if ioErr != nil {
  9096. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9098. return
  9099. }
  9100. var respJSON map[string]interface{}
  9101. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9102. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9104. return
  9105. }
  9106. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9107. result, _ := json.Marshal(respJSON)
  9108. fmt.Println("log")
  9109. fmt.Println(string(result))
  9110. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9111. utils.ErrorLog("解析失败:%v", err)
  9112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9113. return
  9114. }
  9115. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9116. res.Output = resEleven10265.Output
  9117. res.ErrMsg = resEleven10265.ErrMsg
  9118. res.Cainfo = resEleven10265.Cainfo
  9119. res.WarnMsg = resEleven10265.WarnMsg
  9120. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9121. res.Infcode = infocode
  9122. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9123. fmt.Println("~~~~~~~")
  9124. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9125. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9126. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9127. resp, requestErr := http.Get(api)
  9128. if requestErr != nil {
  9129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9130. return
  9131. }
  9132. body, ioErr := ioutil.ReadAll(resp.Body)
  9133. if ioErr != nil {
  9134. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9136. return
  9137. }
  9138. var respJSON map[string]interface{}
  9139. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9140. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9142. return
  9143. }
  9144. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9145. result, _ := json.Marshal(respJSON)
  9146. fmt.Println("log")
  9147. fmt.Println(string(result))
  9148. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9149. utils.ErrorLog("解析失败:%v", err)
  9150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9151. return
  9152. }
  9153. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9154. res.Output = resEleven10265.Output
  9155. res.ErrMsg = resEleven10265.ErrMsg
  9156. res.Cainfo = resEleven10265.Cainfo
  9157. res.WarnMsg = resEleven10265.WarnMsg
  9158. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9159. res.Infcode = infocode
  9160. } else {
  9161. result := service.Gdyb5203(baseParams, businessParams)
  9162. //service.Gdyb5204(baseParams, businessParams)
  9163. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9164. var dat map[string]interface{}
  9165. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9166. fmt.Println(dat)
  9167. } else {
  9168. fmt.Println(err)
  9169. }
  9170. userJSONBytes, _ := json.Marshal(dat)
  9171. if miConfig.Code == "H15049901371" {
  9172. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9173. utils.ErrorLog("解析失败:%v", err)
  9174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9175. return
  9176. }
  9177. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9178. res.Output = resEleven10265.Output
  9179. res.ErrMsg = resEleven10265.ErrMsg
  9180. res.Cainfo = resEleven10265.Cainfo
  9181. res.WarnMsg = resEleven10265.WarnMsg
  9182. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9183. res.Infcode = infocode
  9184. } else {
  9185. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9186. utils.ErrorLog("解析失败:%v", err)
  9187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9188. return
  9189. }
  9190. }
  9191. }
  9192. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9193. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9194. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9195. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9196. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9197. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9198. var doctor_name string
  9199. if roles.ID == 0 {
  9200. doctor_name = "管理员"
  9201. } else {
  9202. doctor_name = roles.UserName
  9203. }
  9204. yiliao_leibie := ""
  9205. switch order.MedType {
  9206. case "11":
  9207. yiliao_leibie = "普通门诊"
  9208. break
  9209. case "12":
  9210. yiliao_leibie = "门诊挂号"
  9211. break
  9212. case "13":
  9213. yiliao_leibie = "急诊"
  9214. break
  9215. case "14":
  9216. yiliao_leibie = "门诊特殊病"
  9217. break
  9218. case "15":
  9219. yiliao_leibie = "门诊统筹"
  9220. break
  9221. case "16":
  9222. yiliao_leibie = "门诊慢性病"
  9223. break
  9224. case "21":
  9225. yiliao_leibie = "普通住院"
  9226. break
  9227. }
  9228. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9229. if res.Infcode == 0 {
  9230. c.ServeSuccessJSON(map[string]interface{}{
  9231. "diagnosis": name,
  9232. "order_infos": orderInfos,
  9233. "number": order.MdtrtId,
  9234. "date": order.SettleAccountsDate,
  9235. "charge_admin": charge_admin,
  9236. "printor_admin": printor_admin,
  9237. "info": res.Output.Setlinfo,
  9238. "order": order,
  9239. "bedCostTotal": bedCostTotal,
  9240. "bedCostSelfTotal": bedCostSelfTotal,
  9241. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9242. "operationCostTotal": operationCostTotal,
  9243. "operationCostSelfTotal": operationCostSelfTotal,
  9244. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9245. "otherCostTotal": otherCostTotal,
  9246. "otherCostSelfTotal": otherCostSelfTotal,
  9247. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9248. "materialCostTotal": materialCostTotal,
  9249. "materialCostSelfTotal": materialCostSelfTotal,
  9250. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9251. "westernMedicineCostTotal": westernMedicineCostTotal,
  9252. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9253. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9254. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9255. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9256. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9257. "checkCostTotal": checkCostTotal,
  9258. "checkCostSelfTotal": checkCostSelfTotal,
  9259. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9260. "laboratoryCostTotal": laboratoryCostTotal,
  9261. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9262. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9263. "treatCostTotal": treatCostTotal,
  9264. "treatCostSelfTotal": treatCostSelfTotal,
  9265. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9266. "doctor_info": doctor_info,
  9267. "doctor_code": adminRole_two.DoctorCode,
  9268. "doctor_name": doctor_name,
  9269. "health_card_no": order.PsnNo,
  9270. "department": departments.Name,
  9271. "yiliao_leibie": yiliao_leibie,
  9272. "after_money": order.AccountPrice,
  9273. "patient": patient,
  9274. "org_name": miConfig.OrgName,
  9275. "org_code": miConfig.Code,
  9276. "order_number": order.Number,
  9277. "his_hospital": his_hospital,
  9278. "his": his,
  9279. "dia_config": dia_config,
  9280. //"check_order_info": cus_slice,
  9281. })
  9282. }
  9283. }
  9284. }
  9285. func (c *HisApiController) CheckTreatment() {
  9286. patient_id, _ := c.GetInt64("patient_id")
  9287. id_card_no := c.GetString("id_card_no")
  9288. insutype := c.GetString("insutype")
  9289. med_type := c.GetString("med_type")
  9290. admin_user_id, _ := c.GetInt64("admin_user_id")
  9291. adminUser := c.GetAdminUserInfo()
  9292. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9293. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9294. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9295. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9296. if miConfig.MdtrtareaAdmvs == "421300" {
  9297. var res ResultTwo
  9298. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9299. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9300. "&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)
  9301. resp, requestErr := http.Get(api)
  9302. if requestErr != nil {
  9303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9304. return
  9305. }
  9306. body, ioErr := ioutil.ReadAll(resp.Body)
  9307. if ioErr != nil {
  9308. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9310. return
  9311. }
  9312. var respJSON map[string]interface{}
  9313. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9314. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9316. return
  9317. }
  9318. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9319. result, _ := json.Marshal(respJSON)
  9320. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9321. utils.ErrorLog("解析失败:%v", err)
  9322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9323. return
  9324. }
  9325. if res.Infcode == 0 {
  9326. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9327. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9328. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9329. resp, requestErr := http.Get(api)
  9330. if requestErr != nil {
  9331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9332. return
  9333. }
  9334. body, ioErr := ioutil.ReadAll(resp.Body)
  9335. if ioErr != nil {
  9336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9338. return
  9339. }
  9340. var respJSON map[string]interface{}
  9341. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9344. return
  9345. }
  9346. var res Result2001
  9347. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9348. result2, _ := json.Marshal(respJSON)
  9349. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9350. utils.ErrorLog("解析失败:%v", err)
  9351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9352. return
  9353. }
  9354. if res.Infcode == 0 {
  9355. c.ServeSuccessJSON(map[string]interface{}{
  9356. "msg": res.Output.Trtinfo,
  9357. })
  9358. }
  9359. } else {
  9360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9361. return
  9362. }
  9363. } else {
  9364. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9365. var dat map[string]interface{}
  9366. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9367. fmt.Println(dat)
  9368. } else {
  9369. fmt.Println(err)
  9370. }
  9371. userJSONBytes, _ := json.Marshal(dat)
  9372. var res ResultTwo
  9373. var res10265 ResultTwo10265
  9374. if miConfig.Code == "H15049901371" {
  9375. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9376. utils.ErrorLog("解析失败:%v", err)
  9377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9378. return
  9379. }
  9380. res.ErrMsg = res10265.ErrMsg
  9381. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9382. res.Infcode = infocode
  9383. res.Output = res10265.Output
  9384. res.InfRefmsgid = res10265.InfRefmsgid
  9385. } else {
  9386. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9387. utils.ErrorLog("解析失败:%v", err)
  9388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9389. return
  9390. }
  9391. }
  9392. var user_name string
  9393. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9394. if role.ID == 0 {
  9395. user_name = "xxx"
  9396. } else {
  9397. user_name = role.UserName
  9398. }
  9399. baseParams := models.BaseParams{
  9400. SecretKey: miConfig.SecretKey,
  9401. FixmedinsCode: miConfig.Code,
  9402. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9403. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9404. OrgName: miConfig.OrgName,
  9405. Doctor: user_name,
  9406. }
  9407. if config.IsOpen == 1 {
  9408. if miConfig.Code == "H15049901371" {
  9409. if med_type == "14" {
  9410. if insutype == "390" {
  9411. med_type = "9933"
  9412. } else if insutype == "310" {
  9413. med_type = "990502"
  9414. }
  9415. } else if med_type == "11" {
  9416. med_type = "11"
  9417. }
  9418. }
  9419. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9420. var dat map[string]interface{}
  9421. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9422. fmt.Println(dat)
  9423. } else {
  9424. fmt.Println(err)
  9425. }
  9426. var res Result2001
  9427. var res10265 Result2001Org10265
  9428. if miConfig.Code == "H15049901371" {
  9429. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9430. utils.ErrorLog("解析失败:%v", err)
  9431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9432. return
  9433. }
  9434. res.ErrMsg = res10265.ErrMsg
  9435. res.Output = res10265.Output
  9436. res.InfRefmsgid = res10265.InfRefmsgid
  9437. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9438. res.Infcode = infocode
  9439. } else {
  9440. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9441. utils.ErrorLog("解析失败:%v", err)
  9442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9443. return
  9444. }
  9445. }
  9446. if res.Infcode == 0 {
  9447. c.ServeSuccessJSON(map[string]interface{}{
  9448. "msg": res.Output.Trtinfo,
  9449. })
  9450. }
  9451. }
  9452. }
  9453. }
  9454. //func (c *HisApiController) PutRecord() {
  9455. // id, _ := c.GetInt64("id")
  9456. // record_time := c.GetString("record_time")
  9457. // timeLayout := "2006-01-02"
  9458. // loc, _ := time.LoadLocation("Local")
  9459. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9460. // if err != nil {
  9461. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9462. // return
  9463. // }
  9464. // recordDateTime := theTime.Unix()
  9465. //
  9466. // adminInfo := c.GetAdminUserInfo()
  9467. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9468. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9469. //
  9470. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9471. //
  9472. // fmt.Println(miConfig.SecretKey)
  9473. //
  9474. // if patient == nil {
  9475. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9476. // return
  9477. // }
  9478. // if len(patient.IdCardNo) == 0 {
  9479. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9480. // return
  9481. // }
  9482. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9483. // if config.IsOpen == 1 {
  9484. // 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
  9485. // resp, requestErr := http.Get(api)
  9486. // if requestErr != nil {
  9487. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9488. // return
  9489. // }
  9490. // defer resp.Body.Close()
  9491. // body, ioErr := ioutil.ReadAll(resp.Body)
  9492. // if ioErr != nil {
  9493. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9494. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9495. // return
  9496. // }
  9497. // var respJSON map[string]interface{}
  9498. //
  9499. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9500. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9501. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9502. // return
  9503. // }
  9504. //
  9505. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9506. // userJSONBytes, _ := json.Marshal(userJSON)
  9507. // var res ResultTwo
  9508. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9509. // utils.ErrorLog("解析失败:%v", err)
  9510. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9511. // return
  9512. // }
  9513. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9514. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9515. // infoStr := string(Iinfos)
  9516. // idetinfoStr := string(Idetinfos)
  9517. //
  9518. // if res.Infcode == 0 {
  9519. // his := models.VMHisPatient{
  9520. // Status: 1,
  9521. // Ctime: time.Now().Unix(),
  9522. // Mtime: time.Now().Unix(),
  9523. // PsnNo: res.Output.Baseinfo.PsnNo,
  9524. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9525. // Certno: res.Output.Baseinfo.Certno,
  9526. // PsnName: res.Output.Baseinfo.PsnName,
  9527. // Gend: res.Output.Baseinfo.Gend,
  9528. // Naty: res.Output.Baseinfo.Naty,
  9529. // Brdy: res.Output.Baseinfo.Brdy,
  9530. // Age: res.Output.Baseinfo.Age,
  9531. // Iinfo: infoStr,
  9532. // Idetinfo: idetinfoStr,
  9533. // PatientId: patient.ID,
  9534. // RecordDate: theTime.Unix(),
  9535. // UserOrgId: adminInfo.CurrentOrgId,
  9536. // AdminUserId: adminInfo.AdminUser.Id,
  9537. // IsReturn: 1,
  9538. // }
  9539. //
  9540. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9541. // //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")
  9542. // //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")
  9543. //
  9544. // //var dat map[string]interface{}
  9545. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9546. // // fmt.Println(dat)
  9547. // //} else {
  9548. // // fmt.Println(err)
  9549. // //}
  9550. //
  9551. // var dat2 map[string]interface{}
  9552. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9553. // fmt.Println(dat2)
  9554. // } else {
  9555. // fmt.Println(err)
  9556. // }
  9557. //
  9558. // } else {
  9559. // adminUser := c.GetAdminUserInfo()
  9560. // errlog := &models.HisOrderError{
  9561. // UserOrgId: adminUser.CurrentOrgId,
  9562. // Ctime: time.Now().Unix(),
  9563. // Mtime: time.Now().Unix(),
  9564. // ErrMsg: res.ErrMsg,
  9565. // Status: 1,
  9566. // PatientId: id,
  9567. // RecordTime: recordDateTime,
  9568. // Stage: 1,
  9569. // }
  9570. // service.CreateErrMsgLog(errlog)
  9571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9572. // return
  9573. // }
  9574. // }
  9575. //
  9576. //}
  9577. //func (c *HisApiController) GetUploadDiag() {
  9578. // id, _ := c.GetInt64("id")
  9579. // record_time := c.GetString("record_time")
  9580. //
  9581. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9582. // sick_type, _ := c.GetInt64("sick_type")
  9583. // reg_type, _ := c.GetInt64("reg_type")
  9584. //
  9585. // timeLayout := "2006-01-02"
  9586. // loc, _ := time.LoadLocation("Local")
  9587. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9588. // if err != nil {
  9589. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9590. // return
  9591. // }
  9592. //
  9593. // var patientPrescription models.HisPrescriptionInfo
  9594. // recordDateTime := theTime.Unix()
  9595. // adminInfo := c.GetAdminUserInfo()
  9596. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9597. //
  9598. // if patientPrescription.ID == 0 {
  9599. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9600. // }
  9601. //
  9602. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9603. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9604. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9605. // sickConfig, _ := service.FindSickById(sick_type)
  9606. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9607. //
  9608. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9609. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9610. // "&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 +
  9611. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9612. // resp2, requestErr2 := http.Get(api2)
  9613. // if requestErr2 != nil {
  9614. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9615. // return
  9616. // }
  9617. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9618. // if ioErr2 != nil {
  9619. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9620. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9621. // return
  9622. // }
  9623. // var respJSON2 map[string]interface{}
  9624. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9625. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9626. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9627. // return
  9628. // }
  9629. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9630. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9631. //
  9632. // var res2 ResultSix
  9633. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9634. // utils.ErrorLog("解析失败:%v", err)
  9635. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9636. // return
  9637. // }
  9638. // if res2.Infcode != 0 {
  9639. // adminUser := c.GetAdminUserInfo()
  9640. // errlog := &models.HisOrderError{
  9641. // UserOrgId: adminUser.CurrentOrgId,
  9642. // Ctime: time.Now().Unix(),
  9643. // Mtime: time.Now().Unix(),
  9644. // ErrMsg: res2.ErrMsg,
  9645. // Status: 1,
  9646. // PatientId: id,
  9647. // RecordTime: recordDateTime,
  9648. // Stage: 3,
  9649. // }
  9650. // service.CreateErrMsgLog(errlog)
  9651. //
  9652. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9653. // return
  9654. // }
  9655. //
  9656. // c.ServeSuccessJSON(map[string]interface{}{
  9657. // "msg": "上传成功",
  9658. // })
  9659. //
  9660. //}
  9661. type QueryResult struct {
  9662. ID int64
  9663. Name string
  9664. Code string
  9665. List_type_code string
  9666. }
  9667. func (c *HisApiController) GetCheckCode() {
  9668. ids_str := c.GetString("ids")
  9669. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9670. ids_arr := strings.Split(ids_str, ",")
  9671. var queryResult []QueryResult
  9672. ids := make([]int64, 0)
  9673. for _, item := range ids_arr {
  9674. id, _ := strconv.ParseInt(item, 10, 64)
  9675. ids = append(ids, id)
  9676. }
  9677. if record_type == 1 {
  9678. drugs, _ := service.GetBatchDrugList(ids)
  9679. for _, item := range drugs {
  9680. result := QueryResult{
  9681. ID: item.ID,
  9682. Name: item.DrugName,
  9683. Code: item.MedicalInsuranceNumber,
  9684. List_type_code: "101",
  9685. }
  9686. queryResult = append(queryResult, result)
  9687. }
  9688. } else if record_type == 2 {
  9689. goods, _ := service.GetBatchGoodInformationList(ids)
  9690. for _, item := range goods {
  9691. result := QueryResult{
  9692. ID: item.ID,
  9693. Name: item.GoodName,
  9694. Code: item.MedicalInsuranceNumber,
  9695. List_type_code: "301",
  9696. }
  9697. queryResult = append(queryResult, result)
  9698. }
  9699. } else if record_type == 3 {
  9700. projects, _ := service.GetBathchMyPorjecgList(ids)
  9701. for _, item := range projects {
  9702. result := QueryResult{
  9703. ID: item.ID,
  9704. Name: item.ProjectName,
  9705. Code: item.MedicalCode,
  9706. List_type_code: "201",
  9707. }
  9708. queryResult = append(queryResult, result)
  9709. }
  9710. }
  9711. admin_user_id, _ := c.GetInt64("admin_user_id")
  9712. adminUser := c.GetAdminUserInfo()
  9713. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9714. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9715. var user_name string
  9716. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9717. if role.ID == 0 {
  9718. user_name = "xxx"
  9719. } else {
  9720. user_name = role.UserName
  9721. }
  9722. baseParams := &models.BaseParams{
  9723. SecretKey: miConfig.SecretKey,
  9724. FixmedinsCode: miConfig.Code,
  9725. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9726. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9727. OrgName: miConfig.OrgName,
  9728. Doctor: user_name,
  9729. }
  9730. if config.IsOpen == 1 {
  9731. for _, item := range queryResult {
  9732. var result string
  9733. if record_type == 1 {
  9734. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9735. } else if record_type == 2 {
  9736. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9737. } else if record_type == 3 {
  9738. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9739. }
  9740. var dat map[string]interface{}
  9741. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9742. fmt.Println(dat)
  9743. } else {
  9744. fmt.Println(err)
  9745. }
  9746. userJSONBytes, _ := json.Marshal(dat)
  9747. var res ResultSix
  9748. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9749. utils.ErrorLog("解析失败:%v", err)
  9750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9751. return
  9752. }
  9753. if res.Infcode == 0 {
  9754. if record_type == 1 {
  9755. service.UpdateBaseDrugById(item.ID)
  9756. } else if record_type == 2 {
  9757. service.UpdateGoodInformaitonByDetail(item.ID)
  9758. } else if record_type == 3 {
  9759. service.UpdateProjectById(item.ID)
  9760. }
  9761. c.ServeSuccessJSON(map[string]interface{}{
  9762. "failed_code": 0,
  9763. "msg": "目录对照成功",
  9764. })
  9765. } else {
  9766. c.ServeSuccessJSON(map[string]interface{}{
  9767. "failed_code": -10,
  9768. "msg": res.ErrMsg,
  9769. })
  9770. }
  9771. }
  9772. }
  9773. }
  9774. func (c *HisApiController) UnCheckCode() {
  9775. ids_str := c.GetString("ids")
  9776. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9777. admin_user_id, _ := c.GetInt64("admin_user_id")
  9778. ids_arr := strings.Split(ids_str, ",")
  9779. var queryResult []QueryResult
  9780. ids := make([]int64, 0)
  9781. for _, item := range ids_arr {
  9782. id, _ := strconv.ParseInt(item, 10, 64)
  9783. ids = append(ids, id)
  9784. }
  9785. if record_type == 1 {
  9786. drugs, _ := service.GetBatchDrugList(ids)
  9787. for _, item := range drugs {
  9788. result := QueryResult{
  9789. ID: item.ID,
  9790. Name: item.DrugName,
  9791. Code: item.MedicalInsuranceNumber,
  9792. List_type_code: "101",
  9793. }
  9794. queryResult = append(queryResult, result)
  9795. }
  9796. } else if record_type == 2 {
  9797. goods, _ := service.GetBatchGoodInformationList(ids)
  9798. for _, item := range goods {
  9799. result := QueryResult{
  9800. ID: item.ID,
  9801. Name: item.GoodName,
  9802. Code: item.MedicalInsuranceNumber,
  9803. List_type_code: "301",
  9804. }
  9805. queryResult = append(queryResult, result)
  9806. }
  9807. } else if record_type == 3 {
  9808. projects, _ := service.GetBathchMyPorjecgList(ids)
  9809. for _, item := range projects {
  9810. result := QueryResult{
  9811. ID: item.ID,
  9812. Name: item.ProjectName,
  9813. Code: item.MedicalCode,
  9814. List_type_code: "201",
  9815. }
  9816. queryResult = append(queryResult, result)
  9817. }
  9818. }
  9819. adminUser := c.GetAdminUserInfo()
  9820. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9821. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9822. var user_name string
  9823. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9824. if role.ID == 0 {
  9825. user_name = "xxx"
  9826. } else {
  9827. user_name = role.UserName
  9828. }
  9829. baseParams := &models.BaseParams{
  9830. SecretKey: miConfig.SecretKey,
  9831. FixmedinsCode: miConfig.Code,
  9832. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9833. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9834. OrgName: miConfig.OrgName,
  9835. Doctor: user_name,
  9836. }
  9837. if config.IsOpen == 1 {
  9838. for _, item := range queryResult {
  9839. var result string
  9840. if record_type == 1 {
  9841. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9842. } else if record_type == 2 {
  9843. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9844. } else if record_type == 3 {
  9845. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9846. }
  9847. var dat2 map[string]interface{}
  9848. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9849. fmt.Println(dat2)
  9850. } else {
  9851. fmt.Println(err)
  9852. }
  9853. userJSONBytes, _ := json.Marshal(dat2)
  9854. var res ResultSix
  9855. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9856. utils.ErrorLog("解析失败:%v", err)
  9857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9858. return
  9859. }
  9860. if res.Infcode == 0 {
  9861. if record_type == 1 {
  9862. service.UpdateDrugByIdDetail(item.ID)
  9863. } else if record_type == 2 {
  9864. service.UpdateGoodInfoById(item.ID)
  9865. } else if record_type == 3 {
  9866. service.UpdateMyProjectById(item.ID)
  9867. }
  9868. c.ServeSuccessJSON(map[string]interface{}{
  9869. "failed_code": 0,
  9870. "msg": "撤销目录对照成功",
  9871. })
  9872. } else {
  9873. c.ServeSuccessJSON(map[string]interface{}{
  9874. "failed_code": -10,
  9875. "msg": res.ErrMsg,
  9876. })
  9877. }
  9878. }
  9879. }
  9880. }
  9881. func (c *HisApiController) GetPatientInfo() {
  9882. id_card_no := c.GetString("id_card_no")
  9883. admin_user_id, _ := c.GetInt64("admin_user_id")
  9884. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9885. if patient.ID == 0 {
  9886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9887. return
  9888. }
  9889. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9890. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9891. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9892. if config.IsOpen == 1 {
  9893. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9894. var dat map[string]interface{}
  9895. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9896. fmt.Println(dat)
  9897. } else {
  9898. fmt.Println(err)
  9899. }
  9900. userJSONBytes, _ := json.Marshal(dat)
  9901. var res ResultTwo
  9902. var res10265 ResultTwo10265
  9903. if miConfig.Code == "H15049901371" {
  9904. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9905. utils.ErrorLog("解析失败:%v", err)
  9906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9907. return
  9908. }
  9909. res.ErrMsg = res10265.ErrMsg
  9910. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9911. res.Infcode = infocode
  9912. res.Output = res10265.Output
  9913. res.InfRefmsgid = res10265.InfRefmsgid
  9914. } else {
  9915. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9916. utils.ErrorLog("解析失败:%v", err)
  9917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9918. return
  9919. }
  9920. }
  9921. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9922. // utils.ErrorLog("解析失败:%v", err)
  9923. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9924. // return
  9925. //}
  9926. if res.Infcode != 0 {
  9927. c.ServeSuccessJSON(map[string]interface{}{
  9928. "failed_code": -10,
  9929. "msg": res.ErrMsg,
  9930. })
  9931. } else {
  9932. c.ServeSuccessJSON(map[string]interface{}{
  9933. "failed_code": 0,
  9934. "info": res,
  9935. })
  9936. }
  9937. }
  9938. }
  9939. func (c *HisApiController) PsnPutOnRecord() {
  9940. record_type, _ := c.GetInt64("type")
  9941. patient_id, _ := c.GetInt64("patient_id")
  9942. admin_user_id, _ := c.GetInt64("admin_user_id")
  9943. start_time := c.GetString("start_time")
  9944. end_time := c.GetString("end_time")
  9945. adminUser := c.GetAdminUserInfo()
  9946. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9947. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9948. var patients []*models.Patients
  9949. if record_type == 1 { //全部备案
  9950. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9951. patients = append(patients, patient...)
  9952. } else { //单个备案
  9953. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9954. patients = append(patients, patient)
  9955. }
  9956. var user_name string
  9957. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9958. if role.ID == 0 {
  9959. user_name = "xxx"
  9960. } else {
  9961. user_name = role.UserName
  9962. }
  9963. if config.IsOpen == 1 {
  9964. for _, item := range patients {
  9965. 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
  9966. resp, requestErr := http.Get(api)
  9967. if requestErr != nil {
  9968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9969. return
  9970. }
  9971. defer resp.Body.Close()
  9972. body, ioErr := ioutil.ReadAll(resp.Body)
  9973. if ioErr != nil {
  9974. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9976. return
  9977. }
  9978. var respJSON map[string]interface{}
  9979. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9982. return
  9983. }
  9984. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9985. userJSONBytes, _ := json.Marshal(userJSON)
  9986. var res ResultTwo
  9987. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9988. utils.ErrorLog("解析失败:%v", err)
  9989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9990. return
  9991. }
  9992. if res.Infcode == 0 {
  9993. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  9994. var dat map[string]interface{}
  9995. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9996. fmt.Println(dat)
  9997. } else {
  9998. fmt.Println(err)
  9999. }
  10000. userJSONBytes, _ := json.Marshal(dat)
  10001. var res2 ResultThirteen
  10002. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10003. utils.ErrorLog("解析失败:%v", err)
  10004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10005. return
  10006. }
  10007. if res2.Infcode == 0 {
  10008. psnResult := &models.GdybPsnRecord{
  10009. UserOrgId: adminUser.CurrentOrgId,
  10010. PatientId: item.ID,
  10011. PsnNo: res.Output.Baseinfo.PsnNo,
  10012. Ctime: time.Now().Unix(),
  10013. Mtime: time.Now().Unix(),
  10014. Status: 1,
  10015. IsCancel: 1,
  10016. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10017. }
  10018. service.CreatePsnRecord(psnResult)
  10019. } else {
  10020. c.ServeSuccessJSON(map[string]interface{}{
  10021. "failed_code": -10,
  10022. "msg": res2.ErrMsg,
  10023. })
  10024. return
  10025. }
  10026. }
  10027. }
  10028. }
  10029. }
  10030. func (c *HisApiController) PsnUnPutOnRecord() {
  10031. id, _ := c.GetInt64("id")
  10032. //record_type, _ := c.GetInt64("type")
  10033. admin_user_id, _ := c.GetInt64("admin_user_id")
  10034. adminUser := c.GetAdminUserInfo()
  10035. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10036. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10037. var user_name string
  10038. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10039. if role.ID == 0 {
  10040. user_name = "xxx"
  10041. } else {
  10042. user_name = role.UserName
  10043. }
  10044. psn_record, _ := service.GetPsnRecordById(id)
  10045. if psn_record.ID == 0 {
  10046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10047. return
  10048. }
  10049. if config.IsOpen == 1 {
  10050. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10051. var dat map[string]interface{}
  10052. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10053. fmt.Println(dat)
  10054. } else {
  10055. fmt.Println(err)
  10056. }
  10057. userJSONBytes, _ := json.Marshal(dat)
  10058. var res ResultFourteen
  10059. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10060. utils.ErrorLog("解析失败:%v", err)
  10061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10062. return
  10063. }
  10064. if res.Infcode == 0 {
  10065. psn_record.IsCancel = 2
  10066. service.CreatePsnRecord(&psn_record)
  10067. } else {
  10068. c.ServeSuccessJSON(map[string]interface{}{
  10069. "failed_code": -10,
  10070. "msg": res.ErrMsg,
  10071. })
  10072. return
  10073. }
  10074. }
  10075. }
  10076. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10077. patient_id, _ := c.GetInt64("patient_id")
  10078. insutype_two := c.GetString("insutype")
  10079. psn_no := c.GetString("psn_no")
  10080. doctor_id, _ := c.GetInt64("doctor_id")
  10081. sick_id, _ := c.GetInt64("sick_id")
  10082. department_id, _ := c.GetInt64("department_id")
  10083. start_time := c.GetString("start_time")
  10084. end_time := c.GetString("end_time")
  10085. check_time := c.GetString("check_time")
  10086. adminUser := c.GetAdminUserInfo()
  10087. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10088. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10089. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10090. sick, _ := service.FindSickById(sick_id)
  10091. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10092. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10093. var res ResultTwo
  10094. var res10265 ResultTwo10265
  10095. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10096. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10097. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  10098. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10099. "&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
  10100. resp, requestErr := http.Get(api)
  10101. if requestErr != nil {
  10102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10103. return
  10104. }
  10105. body, ioErr := ioutil.ReadAll(resp.Body)
  10106. if ioErr != nil {
  10107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10109. return
  10110. }
  10111. var respJSON map[string]interface{}
  10112. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10115. return
  10116. }
  10117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10118. result, _ := json.Marshal(respJSON)
  10119. fmt.Println("log")
  10120. fmt.Println(string(result))
  10121. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10122. utils.ErrorLog("解析失败:%v", err)
  10123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10124. return
  10125. }
  10126. res.ErrMsg = res10265.ErrMsg
  10127. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10128. res.Infcode = infocode
  10129. res.Output = res10265.Output
  10130. res.InfRefmsgid = res10265.InfRefmsgid
  10131. } else {
  10132. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10133. if miConfig.Code == "H15049901371" {
  10134. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10135. utils.ErrorLog("解析失败:%v", err)
  10136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10137. return
  10138. }
  10139. res.ErrMsg = res10265.ErrMsg
  10140. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10141. res.Infcode = infocode
  10142. res.Output = res10265.Output
  10143. res.InfRefmsgid = res10265.InfRefmsgid
  10144. } else {
  10145. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10146. utils.ErrorLog("解析失败:%v", err)
  10147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10148. return
  10149. }
  10150. }
  10151. }
  10152. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10153. infoStr := string(Iinfos)
  10154. var rf []*ResultFive
  10155. json.Unmarshal([]byte(infoStr), &rf)
  10156. var insuplc_admdvs string
  10157. var insutype string
  10158. var is390 int = 0
  10159. var is310 int = 0
  10160. var insutypes []*ResultFive
  10161. for _, item := range rf {
  10162. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10163. insutypes = append(insutypes, item)
  10164. }
  10165. }
  10166. if len(insutypes) == 1 {
  10167. insutype = insutypes[0].Insutype
  10168. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10169. } else {
  10170. for _, i := range insutypes {
  10171. if i.Insutype == "390" {
  10172. is390 = 1
  10173. }
  10174. if i.Insutype == "310" {
  10175. is310 = 1
  10176. }
  10177. }
  10178. }
  10179. if is390 == 1 {
  10180. insutype = "390"
  10181. }
  10182. if is310 == 1 {
  10183. insutype = "310"
  10184. }
  10185. if len(insutypes) == 2 {
  10186. insutype = insutype_two
  10187. }
  10188. if len(insutypes) == 0 {
  10189. insutype = "310"
  10190. }
  10191. insutype = insutype_two
  10192. fmt.Println(insutype)
  10193. for _, item := range rf {
  10194. fmt.Println(item.Insutype)
  10195. fmt.Println(insutype)
  10196. if item.Insutype == insutype {
  10197. fmt.Println(item.Insutype)
  10198. fmt.Println(insutype)
  10199. insuplc_admdvs = item.InsuplcAdmdvs
  10200. }
  10201. }
  10202. fmt.Println(insuplc_admdvs)
  10203. var res2 ResultThirteen
  10204. var res10265_2 ResultThirteen10265
  10205. if config.IsOpen == 1 {
  10206. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10207. } else {
  10208. 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)
  10209. var dat map[string]interface{}
  10210. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10211. fmt.Println(dat)
  10212. } else {
  10213. fmt.Println(err)
  10214. }
  10215. userJSONBytes, _ := json.Marshal(dat)
  10216. if miConfig.Code == "H15049901371" {
  10217. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10218. utils.ErrorLog("解析失败:%v", err)
  10219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10220. return
  10221. }
  10222. res2.ErrMsg = res10265_2.ErrMsg
  10223. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10224. res2.Infcode = infocode
  10225. res2.Output = res10265_2.Output
  10226. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10227. } else {
  10228. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10229. utils.ErrorLog("解析失败:%v", err)
  10230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10231. return
  10232. }
  10233. }
  10234. }
  10235. if res2.Infcode == 0 {
  10236. psnResult := &models.GdybPsnNcdsRecord{
  10237. UserOrgId: adminUser.CurrentOrgId,
  10238. PatientId: patient.ID,
  10239. PsnNo: psn_no,
  10240. DoctorId: doctor.AdminUserId,
  10241. DepartmentId: department_id,
  10242. SickType: sick_id,
  10243. Insutype: insutype,
  10244. Ctime: time.Now().Unix(),
  10245. Mtime: time.Now().Unix(),
  10246. Status: 1,
  10247. IsCancel: 1,
  10248. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10249. }
  10250. service.CreatePsnNCDSRecord(psnResult)
  10251. c.ServeSuccessJSON(map[string]interface{}{
  10252. "failed_code": 0,
  10253. "msg": "备案成功",
  10254. "result": psnResult,
  10255. })
  10256. } else {
  10257. c.ServeSuccessJSON(map[string]interface{}{
  10258. "failed_code": -10,
  10259. "msg": res2.ErrMsg,
  10260. })
  10261. return
  10262. }
  10263. }
  10264. }
  10265. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10266. id, _ := c.GetInt64("id")
  10267. admin_user_id, _ := c.GetInt64("admin_user_id")
  10268. adminUser := c.GetAdminUserInfo()
  10269. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10270. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10271. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10272. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10273. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10274. //var user_name string
  10275. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10276. //if role.ID == 0 {
  10277. // user_name = "xxx"
  10278. //} else {
  10279. // user_name = role.UserName
  10280. //}
  10281. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10282. if psn_record.ID == 0 {
  10283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10284. return
  10285. }
  10286. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10287. var res ResultTwo
  10288. var res10265 ResultTwo10265
  10289. if miConfig.Code == "H15049901371" {
  10290. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10291. utils.ErrorLog("解析失败:%v", err)
  10292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10293. return
  10294. }
  10295. res.ErrMsg = res10265.ErrMsg
  10296. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10297. res.Infcode = infocode
  10298. res.Output = res10265.Output
  10299. res.InfRefmsgid = res10265.InfRefmsgid
  10300. } else {
  10301. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10302. utils.ErrorLog("解析失败:%v", err)
  10303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10304. return
  10305. }
  10306. }
  10307. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10308. infoStr := string(Iinfos)
  10309. var rf []*ResultFive
  10310. json.Unmarshal([]byte(infoStr), &rf)
  10311. var insuplc_admdvs string
  10312. var insutype string
  10313. var is390 int = 0
  10314. var is310 int = 0
  10315. var insutypes []*ResultFive
  10316. for _, item := range rf {
  10317. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10318. insutypes = append(insutypes, item)
  10319. }
  10320. }
  10321. if len(insutypes) == 1 {
  10322. insutype = insutypes[0].Insutype
  10323. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10324. } else {
  10325. for _, i := range insutypes {
  10326. if i.Insutype == "390" {
  10327. is390 = 1
  10328. }
  10329. if i.Insutype == "310" {
  10330. is310 = 1
  10331. }
  10332. }
  10333. }
  10334. if is390 == 1 {
  10335. insutype = "390"
  10336. }
  10337. if is310 == 1 {
  10338. insutype = "310"
  10339. }
  10340. if len(insutypes) == 0 {
  10341. insutype = "310"
  10342. }
  10343. insutype = psn_record.Insutype
  10344. for _, item := range rf {
  10345. if item.Insutype == insutype {
  10346. insuplc_admdvs = item.InsuplcAdmdvs
  10347. }
  10348. }
  10349. if config.IsOpen == 1 {
  10350. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10351. var dat map[string]interface{}
  10352. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10353. fmt.Println(dat)
  10354. } else {
  10355. fmt.Println(err)
  10356. }
  10357. userJSONBytes, _ := json.Marshal(dat)
  10358. var res ResultFourteen
  10359. var res10265 ResultFourteen10265
  10360. if miConfig.Code == "H15049901371" {
  10361. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10362. utils.ErrorLog("解析失败:%v", err)
  10363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10364. return
  10365. }
  10366. res.ErrMsg = res10265.ErrMsg
  10367. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10368. res.Infcode = infocode
  10369. res.Output = res10265.Output
  10370. res.InfRefmsgid = res10265.InfRefmsgid
  10371. } else {
  10372. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10373. utils.ErrorLog("解析失败:%v", err)
  10374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10375. return
  10376. }
  10377. }
  10378. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10379. // utils.ErrorLog("解析失败:%v", err)
  10380. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10381. // return
  10382. //}
  10383. if res.Infcode == 0 {
  10384. psn_record.IsCancel = 2
  10385. service.CreatePsnNCDSRecord(&psn_record)
  10386. c.ServeSuccessJSON(map[string]interface{}{
  10387. "failed_code": 0,
  10388. "msg": "撤销备案成功",
  10389. })
  10390. } else {
  10391. c.ServeSuccessJSON(map[string]interface{}{
  10392. "failed_code": -10,
  10393. "msg": res.ErrMsg,
  10394. })
  10395. return
  10396. }
  10397. }
  10398. }
  10399. func (c *HisApiController) TestTest() {
  10400. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10401. fmt.Println(patient.Iinfo)
  10402. }
  10403. type CustomData struct {
  10404. MsgId string
  10405. PsnNo string
  10406. Info string
  10407. }
  10408. func (c *HisApiController) ReversalData() {
  10409. var customData []*CustomData
  10410. custom := &CustomData{
  10411. MsgId: "H44022900158202103301714472004",
  10412. PsnNo: "44020000001101329945",
  10413. Info: "2207",
  10414. }
  10415. customData = append(customData, custom)
  10416. custom1 := &CustomData{
  10417. MsgId: "H4402290015820210330172057803",
  10418. PsnNo: "44020000001101161813",
  10419. Info: "2207",
  10420. }
  10421. customData = append(customData, custom1)
  10422. custom2 := &CustomData{
  10423. MsgId: "H44022900158202103301705198813",
  10424. PsnNo: "44190000133097375417",
  10425. Info: "2207",
  10426. }
  10427. customData = append(customData, custom2)
  10428. custom3 := &CustomData{
  10429. MsgId: "H44022900158202103301715524756",
  10430. PsnNo: "44020000001100187221",
  10431. Info: "2207",
  10432. }
  10433. customData = append(customData, custom3)
  10434. custom4 := &CustomData{
  10435. MsgId: "H44022900158202103301730376224",
  10436. PsnNo: "44020000001101959155",
  10437. Info: "2207",
  10438. }
  10439. customData = append(customData, custom4)
  10440. custom5 := &CustomData{
  10441. MsgId: "H44022900158202103301748008725",
  10442. PsnNo: "44020000001104246641",
  10443. Info: "2207",
  10444. }
  10445. customData = append(customData, custom5)
  10446. custom6 := &CustomData{
  10447. MsgId: "H44022900158202103301718096755",
  10448. PsnNo: "44020000001102211860",
  10449. Info: "2207",
  10450. }
  10451. customData = append(customData, custom6)
  10452. custom7 := &CustomData{
  10453. MsgId: "H44022900158202103301736551640",
  10454. PsnNo: "44020000001102687718",
  10455. Info: "2207",
  10456. }
  10457. customData = append(customData, custom7)
  10458. custom8 := &CustomData{
  10459. MsgId: "H44022900158202103301743097676",
  10460. PsnNo: "44020000001102127785",
  10461. Info: "2207",
  10462. }
  10463. customData = append(customData, custom8)
  10464. custom9 := &CustomData{
  10465. MsgId: "H44022900158202103301712304203",
  10466. PsnNo: "44020000001101518097",
  10467. Info: "2207",
  10468. }
  10469. customData = append(customData, custom9)
  10470. custom10 := &CustomData{
  10471. MsgId: "H44022900158202103301738448785",
  10472. PsnNo: "44020000001100500813",
  10473. Info: "2207",
  10474. }
  10475. customData = append(customData, custom10)
  10476. custom11 := &CustomData{
  10477. MsgId: "H44022900158202103301732455843",
  10478. PsnNo: "44020000001102690557",
  10479. Info: "2207",
  10480. }
  10481. customData = append(customData, custom11)
  10482. custom12 := &CustomData{
  10483. MsgId: "H44022900158202103301745421708",
  10484. PsnNo: "44020000001102211928",
  10485. Info: "2207",
  10486. }
  10487. customData = append(customData, custom12)
  10488. custom1212 := &CustomData{
  10489. MsgId: "H440229001582021033017351627",
  10490. PsnNo: "44020000001102481733",
  10491. Info: "2207",
  10492. }
  10493. customData = append(customData, custom1212)
  10494. custom13 := &CustomData{
  10495. MsgId: "H44022900158202103301740327951",
  10496. PsnNo: "44020000001103174866",
  10497. Info: "2207",
  10498. }
  10499. customData = append(customData, custom13)
  10500. custom14 := &CustomData{
  10501. MsgId: "H4402290015820210330174922668",
  10502. PsnNo: "44020000001102927272",
  10503. Info: "2207",
  10504. }
  10505. customData = append(customData, custom14)
  10506. custom15 := &CustomData{
  10507. MsgId: "H44022900158202103301752362273",
  10508. PsnNo: "44020000001102942890",
  10509. Info: "2207",
  10510. }
  10511. customData = append(customData, custom15)
  10512. custom16 := &CustomData{
  10513. MsgId: "H44022900158202103301751082917",
  10514. PsnNo: "44020000001101662162",
  10515. Info: "2207",
  10516. }
  10517. customData = append(customData, custom16)
  10518. custom17 := &CustomData{
  10519. MsgId: "H44022900158202103301754147728",
  10520. PsnNo: "44020000000229014511",
  10521. Info: "2207",
  10522. }
  10523. customData = append(customData, custom17)
  10524. adminUser := c.GetAdminUserInfo()
  10525. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10526. for _, item := range customData {
  10527. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10528. fmt.Println(result)
  10529. }
  10530. }
  10531. func (c *HisApiController) GetAllopatry() {
  10532. year := c.GetString("year")
  10533. month := c.GetString("month")
  10534. admin_user_id, _ := c.GetInt64("admin_user_id")
  10535. adminUser := c.GetAdminUserInfo()
  10536. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10537. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10538. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10539. var dat map[string]interface{}
  10540. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10541. fmt.Println(dat)
  10542. } else {
  10543. fmt.Println(err)
  10544. }
  10545. userJSONBytes, _ := json.Marshal(dat)
  10546. var res models.Result9001
  10547. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10548. utils.ErrorLog("解析失败:%v", err)
  10549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10550. return
  10551. }
  10552. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "")
  10553. var dat2 map[string]interface{}
  10554. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10555. fmt.Println(dat)
  10556. } else {
  10557. fmt.Println(err)
  10558. }
  10559. userJSONBytes2, _ := json.Marshal(dat2)
  10560. var res2 models.Result3260
  10561. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10562. utils.ErrorLog("解析失败:%v", err)
  10563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10564. return
  10565. }
  10566. if res2.Infcode == 0 {
  10567. c.ServeSuccessJSON(map[string]interface{}{
  10568. "list": res2.Output.Data,
  10569. })
  10570. return
  10571. } else {
  10572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10573. return
  10574. }
  10575. }
  10576. func (c *HisApiController) ComfirmAllopatry() {
  10577. year := c.GetString("year")
  10578. month := c.GetString("month")
  10579. admin_user_id, _ := c.GetInt64("admin_user_id")
  10580. adminUser := c.GetAdminUserInfo()
  10581. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10582. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10583. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10584. var dat map[string]interface{}
  10585. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10586. fmt.Println(dat)
  10587. } else {
  10588. fmt.Println(err)
  10589. }
  10590. userJSONBytes, _ := json.Marshal(dat)
  10591. var res models.Result9001
  10592. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10593. utils.ErrorLog("解析失败:%v", err)
  10594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10595. return
  10596. }
  10597. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "")
  10598. var dat2 map[string]interface{}
  10599. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10600. fmt.Println(dat)
  10601. } else {
  10602. fmt.Println(err)
  10603. }
  10604. userJSONBytes2, _ := json.Marshal(dat2)
  10605. var res2 models.Result3260
  10606. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10607. utils.ErrorLog("解析失败:%v", err)
  10608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10609. return
  10610. }
  10611. if res2.Infcode == 0 {
  10612. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10613. var dat map[string]interface{}
  10614. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10615. fmt.Println(dat)
  10616. } else {
  10617. fmt.Println(err)
  10618. }
  10619. userJSONBytes, _ := json.Marshal(dat)
  10620. var res3 models.Result3261
  10621. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10622. utils.ErrorLog("解析失败:%v", err)
  10623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10624. return
  10625. }
  10626. if res3.Infcode == 0 {
  10627. record := &models.HisYidiClearRecord{
  10628. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10629. Ctime: time.Now().Unix(),
  10630. Mtime: time.Now().Unix(),
  10631. Status: 1,
  10632. MsgId: msgId,
  10633. }
  10634. service.SaveClearRecord(record)
  10635. c.ServeSuccessJSON(map[string]interface{}{
  10636. "msg": "提取成功",
  10637. })
  10638. }
  10639. }
  10640. }
  10641. func (c *HisApiController) RefundAllopatry() {
  10642. year := c.GetString("year")
  10643. month := c.GetString("month")
  10644. id, _ := c.GetInt64("id")
  10645. admin_user_id, _ := c.GetInt64("admin_user_id")
  10646. adminUser := c.GetAdminUserInfo()
  10647. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10648. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10649. record, _ := service.GetClearRecordById(id)
  10650. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10651. var dat map[string]interface{}
  10652. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10653. fmt.Println(dat)
  10654. } else {
  10655. fmt.Println(err)
  10656. }
  10657. userJSONBytes, _ := json.Marshal(dat)
  10658. var empty ResultFourteen
  10659. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10660. utils.ErrorLog("解析失败:%v", err)
  10661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10662. return
  10663. }
  10664. if empty.Infcode == 0 {
  10665. c.ServeSuccessJSON(map[string]interface{}{
  10666. "msg": "撤销成功",
  10667. })
  10668. return
  10669. }
  10670. }
  10671. func (c *HisApiController) ReversalOtherData() {
  10672. var customData []*CustomData
  10673. custom := &CustomData{
  10674. MsgId: "H44022900158202103301714472004",
  10675. PsnNo: "44020000001101329945",
  10676. Info: "2208",
  10677. }
  10678. customData = append(customData, custom)
  10679. custom1 := &CustomData{
  10680. MsgId: "H4402290015820210330172057803",
  10681. PsnNo: "44020000001101161813",
  10682. Info: "2208",
  10683. }
  10684. customData = append(customData, custom1)
  10685. custom2 := &CustomData{
  10686. MsgId: "H44022900158202103301705198813",
  10687. PsnNo: "44190000133097375417",
  10688. Info: "2208",
  10689. }
  10690. customData = append(customData, custom2)
  10691. custom3 := &CustomData{
  10692. MsgId: "H44022900158202103301715524756",
  10693. PsnNo: "44020000001100187221",
  10694. Info: "2208",
  10695. }
  10696. customData = append(customData, custom3)
  10697. custom4 := &CustomData{
  10698. MsgId: "H44022900158202103301730376224",
  10699. PsnNo: "44020000001101959155",
  10700. Info: "2208",
  10701. }
  10702. customData = append(customData, custom4)
  10703. custom5 := &CustomData{
  10704. MsgId: "H44022900158202103301748008725",
  10705. PsnNo: "44020000001104246641",
  10706. Info: "2208",
  10707. }
  10708. customData = append(customData, custom5)
  10709. custom6 := &CustomData{
  10710. MsgId: "H44022900158202103301718096755",
  10711. PsnNo: "44020000001102211860",
  10712. Info: "2208",
  10713. }
  10714. customData = append(customData, custom6)
  10715. custom7 := &CustomData{
  10716. MsgId: "H44022900158202103301736551640",
  10717. PsnNo: "44020000001102687718",
  10718. Info: "2208",
  10719. }
  10720. customData = append(customData, custom7)
  10721. custom8 := &CustomData{
  10722. MsgId: "H44022900158202103301743097676",
  10723. PsnNo: "44020000001102127785",
  10724. Info: "2208",
  10725. }
  10726. customData = append(customData, custom8)
  10727. custom9 := &CustomData{
  10728. MsgId: "H44022900158202103301712304203",
  10729. PsnNo: "44020000001101518097",
  10730. Info: "2208",
  10731. }
  10732. customData = append(customData, custom9)
  10733. custom10 := &CustomData{
  10734. MsgId: "H44022900158202103301738448785",
  10735. PsnNo: "44020000001100500813",
  10736. Info: "2208",
  10737. }
  10738. customData = append(customData, custom10)
  10739. custom11 := &CustomData{
  10740. MsgId: "H44022900158202103301732455843",
  10741. PsnNo: "44020000001102690557",
  10742. Info: "2208",
  10743. }
  10744. customData = append(customData, custom11)
  10745. custom12 := &CustomData{
  10746. MsgId: "H44022900158202103301745421708",
  10747. PsnNo: "44020000001102211928",
  10748. Info: "2208",
  10749. }
  10750. customData = append(customData, custom12)
  10751. custom1212 := &CustomData{
  10752. MsgId: "H440229001582021033017351627",
  10753. PsnNo: "44020000001102481733",
  10754. Info: "2208",
  10755. }
  10756. customData = append(customData, custom1212)
  10757. custom13 := &CustomData{
  10758. MsgId: "H44022900158202103301740327951",
  10759. PsnNo: "44020000001103174866",
  10760. Info: "2208",
  10761. }
  10762. customData = append(customData, custom13)
  10763. custom14 := &CustomData{
  10764. MsgId: "H4402290015820210330174922668",
  10765. PsnNo: "44020000001102927272",
  10766. Info: "2208",
  10767. }
  10768. customData = append(customData, custom14)
  10769. custom15 := &CustomData{
  10770. MsgId: "H44022900158202103301752362273",
  10771. PsnNo: "44020000001102942890",
  10772. Info: "2208",
  10773. }
  10774. customData = append(customData, custom15)
  10775. custom16 := &CustomData{
  10776. MsgId: "H44022900158202103301751082917",
  10777. PsnNo: "44020000001101662162",
  10778. Info: "2208",
  10779. }
  10780. customData = append(customData, custom16)
  10781. custom17 := &CustomData{
  10782. MsgId: "H44022900158202103301754147728",
  10783. PsnNo: "44020000000229014511",
  10784. Info: "2208",
  10785. }
  10786. customData = append(customData, custom17)
  10787. adminUser := c.GetAdminUserInfo()
  10788. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10789. for _, item := range customData {
  10790. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10791. fmt.Println(result)
  10792. }
  10793. }
  10794. func PathExists(path string) (bool, error) {
  10795. _, err := os.Stat(path)
  10796. if err == nil {
  10797. return true, nil
  10798. }
  10799. if os.IsNotExist(err) {
  10800. return false, nil
  10801. }
  10802. return false, err
  10803. }
  10804. //创建文件夹
  10805. func Mkdir(dir string) {
  10806. // 创建文件夹
  10807. exist, err := PathExists(dir)
  10808. if err != nil {
  10809. fmt.Println(err.Error())
  10810. } else {
  10811. if exist {
  10812. fmt.Println(dir + "文件夹已存在!")
  10813. } else {
  10814. // 文件夹名称,权限
  10815. err := os.Mkdir(dir, os.ModePerm)
  10816. if err != nil {
  10817. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10818. } else {
  10819. fmt.Println(dir + "文件夹创建成功!")
  10820. }
  10821. }
  10822. }
  10823. }
  10824. //压缩文件
  10825. func Zip(srcFile string, destZip string) error {
  10826. zipfile, err := os.Create(destZip)
  10827. if err != nil {
  10828. return err
  10829. }
  10830. defer zipfile.Close()
  10831. archive := zip.NewWriter(zipfile)
  10832. defer archive.Close()
  10833. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10834. if err != nil {
  10835. return err
  10836. }
  10837. header, err := zip.FileInfoHeader(info)
  10838. if err != nil {
  10839. return err
  10840. }
  10841. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10842. // header.Name = path
  10843. if info.IsDir() {
  10844. header.Name += "/"
  10845. } else {
  10846. header.Method = zip.Deflate
  10847. }
  10848. writer, err := archive.CreateHeader(header)
  10849. if err != nil {
  10850. return err
  10851. }
  10852. if !info.IsDir() {
  10853. file, err := os.Open(path)
  10854. if err != nil {
  10855. return err
  10856. }
  10857. defer file.Close()
  10858. _, err = io.Copy(writer, file)
  10859. }
  10860. return err
  10861. })
  10862. return err
  10863. }
  10864. func ReadFile(filePath string) []byte {
  10865. f, err := os.Open(filePath)
  10866. if err != nil {
  10867. fmt.Println("read file fail", err)
  10868. return nil
  10869. }
  10870. defer f.Close()
  10871. fd, err := ioutil.ReadAll(f)
  10872. if err != nil {
  10873. fmt.Println("read to fd fail", err)
  10874. return nil
  10875. }
  10876. return fd
  10877. }
  10878. func saveLog(result string, request string, infno string, desc string) {
  10879. org_id, _ := beego.AppConfig.Int64("org_id")
  10880. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10881. dir := miConfig.OrgName + "日志"
  10882. utils.Mkdir(dir)
  10883. month := time.Unix(1557042972, 0).Format("1")
  10884. year := time.Now().Format("2006")
  10885. month = time.Now().Format("01")
  10886. day := time.Now().Format("02")
  10887. hour := time.Now().Format("15")
  10888. min := time.Now().Format("04")
  10889. sec := time.Now().Format("05")
  10890. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10891. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10892. file_name := file + ".txt"
  10893. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10894. exist, _ := utils.PathExists(file_path)
  10895. if exist { //存在
  10896. fmt.Println("存在")
  10897. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10898. if err != nil {
  10899. fmt.Println("read fail")
  10900. }
  10901. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10902. n, _ := f.Seek(0, 2)
  10903. _, err = f.WriteAt([]byte(content), n)
  10904. } else { //不存在
  10905. fmt.Println("文件不存在,创建文件")
  10906. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10907. defer f.Close()
  10908. if err != nil {
  10909. } else {
  10910. _, err = f.Write([]byte("记录日志"))
  10911. }
  10912. }
  10913. }
  10914. type Charset string
  10915. const (
  10916. UTF8 = Charset("UTF-8")
  10917. GB18030 = Charset("GB18030")
  10918. )
  10919. func ConvertToString(src string, srcCode string, tagCode string) string {
  10920. srcCoder := mahonia.NewDecoder(srcCode)
  10921. srcResult := srcCoder.ConvertString(src)
  10922. tagCoder := mahonia.NewDecoder(tagCode)
  10923. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10924. result := string(cdata)
  10925. return result
  10926. }
  10927. func (c *HisApiController) ReadEleCard() {
  10928. id_card_type, _ := c.GetInt64("id_card_type")
  10929. admin_user_id, _ := c.GetInt64("admin_user_id")
  10930. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  10931. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10932. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10933. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10934. var api string
  10935. if miConfig.MdtrtareaAdmvs == "320921" {
  10936. 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 +
  10937. "&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
  10938. fmt.Println(api)
  10939. } else {
  10940. 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 +
  10941. "&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)
  10942. }
  10943. resp, requestErr := http.Get(api)
  10944. if requestErr != nil {
  10945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10946. return
  10947. }
  10948. body, ioErr := ioutil.ReadAll(resp.Body)
  10949. if ioErr != nil {
  10950. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10952. return
  10953. }
  10954. var respJSON map[string]interface{}
  10955. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10958. return
  10959. }
  10960. var status string
  10961. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10962. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10963. var token string
  10964. var res ResultTwo //1101结果
  10965. var res10265 ResultTwo10265 //1101结果
  10966. if status == "0" { //读卡成功
  10967. var card_info string //卡信息
  10968. var busi_card_info string
  10969. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10970. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10971. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10972. fmt.Println(card_info)
  10973. fmt.Println(busi_card_info)
  10974. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10975. result, _ := json.Marshal(respJSON)
  10976. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10977. utils.ErrorLog("解析失败:%v", err)
  10978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10979. return
  10980. }
  10981. res.ErrMsg = res10265.ErrMsg
  10982. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10983. res.Infcode = infocode
  10984. res.Output = res10265.Output
  10985. res.InfRefmsgid = res10265.InfRefmsgid
  10986. if res.Infcode == 0 {
  10987. c.ServeSuccessJSON(map[string]interface{}{
  10988. "number": token,
  10989. })
  10990. }
  10991. } else {
  10992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10993. return
  10994. }
  10995. } else { //读卡失败
  10996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10997. return
  10998. }
  10999. }