his_api_controller.go 389KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. }
  73. func (c *HisApiController) GetPsnNcdsInfo() {
  74. admin_user_id, _ := c.GetInt64("admin_user_id")
  75. patient_id, _ := c.GetInt64("patient_id")
  76. id, _ := c.GetInt64("id")
  77. adminUser := c.GetAdminUserInfo()
  78. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  79. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  80. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  81. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  82. psn_record, _ := service.GetPsnNCDSRecordById(id)
  83. //
  84. //if psn_record.ID == 0 {
  85. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  86. // return
  87. //}
  88. var res Result5301
  89. var res10265 Result5301For10265
  90. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  91. psn_info, _ := service.GetPsnByPatientId(patient_id)
  92. var api string
  93. if miConfig.MdtrtareaAdmvs == "320921" {
  94. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  95. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  96. } else {
  97. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  98. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  99. }
  100. resp, requestErr := http.Get(api)
  101. if requestErr != nil {
  102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  103. return
  104. }
  105. body, ioErr := ioutil.ReadAll(resp.Body)
  106. if ioErr != nil {
  107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  109. return
  110. }
  111. var respJSON map[string]interface{}
  112. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  115. return
  116. }
  117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  118. result, _ := json.Marshal(respJSON)
  119. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  120. utils.ErrorLog("解析失败:%v", err)
  121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  122. return
  123. }
  124. res.ErrMsg = res10265.ErrMsg
  125. res.Output = res10265.Output
  126. res.InfRefmsgid = res10265.InfRefmsgid
  127. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  128. res.Infcode = infocode
  129. } else {
  130. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  131. var dat map[string]interface{}
  132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  133. fmt.Println(dat)
  134. } else {
  135. fmt.Println(err)
  136. }
  137. userJSONBytes, _ := json.Marshal(dat)
  138. if miConfig.Code == "H15049901371" {
  139. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  140. utils.ErrorLog("解析失败:%v", err)
  141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  142. return
  143. }
  144. res.InfRefmsgid = res10265.InfRefmsgid
  145. res.Output = res10265.Output
  146. res.ErrMsg = res10265.ErrMsg
  147. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  148. res.Infcode = infocode
  149. } else {
  150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  151. utils.ErrorLog("解析失败:%v", err)
  152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  153. return
  154. }
  155. }
  156. }
  157. if res.Infcode == 0 {
  158. c.ServeSuccessJSON(map[string]interface{}{
  159. "result": res.Output.Result,
  160. })
  161. }
  162. }
  163. func (c *HisApiController) CheckInsutype() {
  164. his_patient_id, _ := c.GetInt64("his_patient_id")
  165. admin_user_id, _ := c.GetInt64("admin_user_id")
  166. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  167. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  168. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  169. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  170. var dat map[string]interface{}
  171. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  172. fmt.Println(dat)
  173. } else {
  174. fmt.Println(err)
  175. }
  176. userJSONBytes, _ := json.Marshal(dat)
  177. var res Result90100
  178. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  179. utils.ErrorLog("解析失败:%v", err)
  180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  181. return
  182. }
  183. if res.Infcode != 0 {
  184. c.ServeSuccessJSON(map[string]interface{}{
  185. "failed_code": -10,
  186. "msg": res.ErrMsg,
  187. })
  188. return
  189. } else {
  190. fmt.Println(res)
  191. }
  192. }
  193. func (c *HisApiController) CheckCardPWD() {
  194. card_pwd := c.GetString("card_pwd")
  195. his_patient_id, _ := c.GetInt64("his_patient_id")
  196. admin_user_id, _ := c.GetInt64("admin_user_id")
  197. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  198. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  199. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  200. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  201. var dat map[string]interface{}
  202. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  203. fmt.Println(dat)
  204. } else {
  205. fmt.Println(err)
  206. }
  207. userJSONBytes, _ := json.Marshal(dat)
  208. var res Result90991
  209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  210. utils.ErrorLog("解析失败:%v", err)
  211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  212. return
  213. }
  214. if res.Infcode != 0 {
  215. c.ServeSuccessJSON(map[string]interface{}{
  216. "failed_code": -10,
  217. "msg": res.ErrMsg,
  218. })
  219. return
  220. } else {
  221. if res.Output.Result.CheckStat == "0" {
  222. var msg string
  223. switch res.Output.Result.CardStat {
  224. case "00":
  225. msg = "未激活"
  226. break
  227. case "10":
  228. msg = "激活"
  229. break
  230. case "20":
  231. msg = "窗口挂失"
  232. break
  233. case "21":
  234. msg = "电话挂失"
  235. break
  236. case "22":
  237. msg = "单位网上申报挂失"
  238. break
  239. case "23":
  240. msg = "保健办挂失"
  241. break
  242. case "24":
  243. msg = "个人网上挂失"
  244. break
  245. case "25":
  246. msg = "网上服务大厅挂失"
  247. break
  248. case "30":
  249. msg = "注销"
  250. break
  251. case "40":
  252. msg = "回收"
  253. break
  254. case "99":
  255. msg = "制卡中(无效卡)"
  256. break
  257. }
  258. c.ServeSuccessJSON(map[string]interface{}{
  259. "failed_code": -10,
  260. "msg": msg,
  261. })
  262. return
  263. } else {
  264. c.ServeSuccessJSON(map[string]interface{}{
  265. "msg": "校验成功",
  266. })
  267. return
  268. }
  269. }
  270. }
  271. func (c *HisApiController) ReadCard() {
  272. id_card_type, _ := c.GetInt64("id_card_type")
  273. admin_user_id, _ := c.GetInt64("admin_user_id")
  274. certificates, _ := c.GetInt64("certificates")
  275. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  276. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  277. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  278. switch id_card_type {
  279. case 1:
  280. if miConfig.MdtrtareaAdmvs == "421300" {
  281. var res ResultTwo
  282. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  283. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  284. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10)
  285. resp, requestErr := http.Get(api)
  286. if requestErr != nil {
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  288. return
  289. }
  290. body, ioErr := ioutil.ReadAll(resp.Body)
  291. if ioErr != nil {
  292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  294. return
  295. }
  296. var respJSON map[string]interface{}
  297. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  300. return
  301. }
  302. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  303. result, _ := json.Marshal(respJSON)
  304. fmt.Println("log")
  305. fmt.Println(string(result))
  306. if err := json.Unmarshal([]byte(result), &res); err != nil {
  307. utils.ErrorLog("解析失败:%v", err)
  308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  309. return
  310. }
  311. if res.Infcode == 0 {
  312. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  313. if err == gorm.ErrRecordNotFound {
  314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  315. return
  316. } else if err != nil {
  317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  318. return
  319. } else {
  320. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  321. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  322. infoStr := string(Iinfos)
  323. idetinfoStr := string(Idetinfos)
  324. psn := &models.HisPsn{
  325. PsnNo: res.Output.Baseinfo.PsnNo,
  326. Age: res.Output.Baseinfo.Age,
  327. PatientId: patient.ID,
  328. Certno: res.Output.Baseinfo.Certno,
  329. Brdy: res.Output.Baseinfo.Brdy,
  330. Gend: res.Output.Baseinfo.Gend,
  331. Naty: res.Output.Baseinfo.Naty,
  332. PsnCertType: res.Output.Baseinfo.PsnCertType,
  333. PsnName: res.Output.Baseinfo.PsnName,
  334. Idetinfo: idetinfoStr,
  335. Insuinfo: infoStr,
  336. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  337. }
  338. service.CreateHisPsn(psn)
  339. c.ServeSuccessJSON(map[string]interface{}{
  340. "patient": patient,
  341. "number": res.Output.Baseinfo.Certno,
  342. })
  343. }
  344. } else {
  345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  346. return
  347. }
  348. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  349. var api string
  350. if miConfig.MdtrtareaAdmvs == "320921" {
  351. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  352. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "operator_id=" + strconv.FormatInt(admin_user_id, 10) + "operator=" + roles.UserName
  353. } else {
  354. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  355. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  356. }
  357. resp, requestErr := http.Get(api)
  358. if requestErr != nil {
  359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  360. return
  361. }
  362. body, ioErr := ioutil.ReadAll(resp.Body)
  363. if ioErr != nil {
  364. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  366. return
  367. }
  368. var respJSON map[string]interface{}
  369. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  370. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  372. return
  373. }
  374. var status string
  375. status = respJSON["data"].(map[string]interface{})["status"].(string)
  376. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  377. var token string
  378. var res ResultTwo //1101结果
  379. var res10265 ResultTwo10265 //1101结果
  380. var card_info string //卡信息
  381. var busi_card_info string
  382. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  383. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  384. if status == "0" { //读卡成功
  385. if card_type == "1" {
  386. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  387. result, _ := json.Marshal(respJSON)
  388. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  389. utils.ErrorLog("解析失败:%v", err)
  390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  391. return
  392. }
  393. res.ErrMsg = res10265.ErrMsg
  394. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  395. res.Infcode = infocode
  396. res.Output = res10265.Output
  397. res.InfRefmsgid = res10265.InfRefmsgid
  398. } else {
  399. //var card_info string //卡信息
  400. //var busi_card_info string
  401. token = respJSON["data"].(map[string]interface{})["token"].(string)
  402. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  403. //fmt.Println(card_info)
  404. //fmt.Println(busi_card_info)
  405. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  406. result, _ := json.Marshal(respJSON)
  407. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  408. utils.ErrorLog("解析失败:%v", err)
  409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  410. return
  411. }
  412. res.ErrMsg = res10265.ErrMsg
  413. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  414. res.Infcode = infocode
  415. res.Output = res10265.Output
  416. res.InfRefmsgid = res10265.InfRefmsgid
  417. }
  418. if res.Infcode == 0 {
  419. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  420. if err == gorm.ErrRecordNotFound {
  421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  422. return
  423. } else if err != nil {
  424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  425. return
  426. } else {
  427. if card_type == "1" {
  428. bas := strings.Split(card_info, "|")
  429. basNumber := bas[2]
  430. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  431. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  432. infoStr := string(Iinfos)
  433. idetinfoStr := string(Idetinfos)
  434. psn := &models.HisPsn{
  435. PsnNo: res.Output.Baseinfo.PsnNo,
  436. Age: res.Output.Baseinfo.Age,
  437. PatientId: patient.ID,
  438. Certno: res.Output.Baseinfo.Certno,
  439. Brdy: res.Output.Baseinfo.Brdy,
  440. Gend: res.Output.Baseinfo.Gend,
  441. Naty: res.Output.Baseinfo.Naty,
  442. PsnCertType: res.Output.Baseinfo.PsnCertType,
  443. PsnName: res.Output.Baseinfo.PsnName,
  444. Idetinfo: idetinfoStr,
  445. Insuinfo: infoStr,
  446. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  447. CardInfo: card_info,
  448. VerifyNumber: busi_card_info,
  449. }
  450. service.CreateHisPsn(psn)
  451. c.ServeSuccessJSON(map[string]interface{}{
  452. "patient": patient,
  453. "number": basNumber,
  454. })
  455. } else {
  456. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  457. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  458. infoStr := string(Iinfos)
  459. idetinfoStr := string(Idetinfos)
  460. psn := &models.HisPsn{
  461. PsnNo: res.Output.Baseinfo.PsnNo,
  462. Age: res.Output.Baseinfo.Age,
  463. PatientId: patient.ID,
  464. Certno: res.Output.Baseinfo.Certno,
  465. Brdy: res.Output.Baseinfo.Brdy,
  466. Gend: res.Output.Baseinfo.Gend,
  467. Naty: res.Output.Baseinfo.Naty,
  468. PsnCertType: res.Output.Baseinfo.PsnCertType,
  469. PsnName: res.Output.Baseinfo.PsnName,
  470. Idetinfo: idetinfoStr,
  471. Insuinfo: infoStr,
  472. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  473. CardInfo: card_info,
  474. VerifyNumber: token,
  475. }
  476. service.CreateHisPsn(psn)
  477. c.ServeSuccessJSON(map[string]interface{}{
  478. "patient": patient,
  479. "number": token,
  480. })
  481. }
  482. }
  483. } else {
  484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  485. return
  486. }
  487. } else { //读卡失败
  488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  489. return
  490. }
  491. } else {
  492. if initFlag == 0 {
  493. c.TestGetBasBaseInit()
  494. }
  495. basStr := c.GetBasBaseInfo()
  496. if len(basStr) == 0 {
  497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  498. return
  499. }
  500. fmt.Println(basStr)
  501. bas := strings.Split(basStr, "|")
  502. basNumber := bas[1]
  503. fmt.Println(basNumber)
  504. card_sn := bas[3]
  505. fmt.Println(card_sn)
  506. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  507. var dat map[string]interface{}
  508. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  509. fmt.Println(dat)
  510. } else {
  511. fmt.Println(err)
  512. }
  513. userJSONBytes, _ := json.Marshal(dat)
  514. var res ResultTwo
  515. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  516. utils.ErrorLog("解析失败:%v", err)
  517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  518. return
  519. }
  520. if res.Infcode == 0 {
  521. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  522. if err == gorm.ErrRecordNotFound {
  523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  524. return
  525. } else if err != nil {
  526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  527. return
  528. } else {
  529. c.ServeSuccessJSON(map[string]interface{}{
  530. "patient": patient,
  531. "number": basNumber,
  532. })
  533. }
  534. } else {
  535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  536. return
  537. }
  538. break
  539. }
  540. case 2:
  541. SFZStr := c.GetSFZBaseInfo()
  542. id_card_str := strings.Split(SFZStr, "^")
  543. id_card_number := id_card_str[0]
  544. card_sn := ""
  545. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  546. var dat map[string]interface{}
  547. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  548. fmt.Println(dat)
  549. } else {
  550. fmt.Println(err)
  551. }
  552. userJSONBytes, _ := json.Marshal(dat)
  553. var res ResultTwo
  554. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  555. utils.ErrorLog("解析失败:%v", err)
  556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  557. return
  558. }
  559. if res.Infcode == 0 {
  560. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  561. if err == gorm.ErrRecordNotFound {
  562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  563. return
  564. } else if err != nil {
  565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  566. return
  567. } else {
  568. c.ServeSuccessJSON(map[string]interface{}{
  569. "patient": patient,
  570. "number": id_card_number,
  571. })
  572. }
  573. } else {
  574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  575. return
  576. }
  577. break
  578. case 3:
  579. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  580. var api string
  581. if miConfig.MdtrtareaAdmvs == "320921" {
  582. 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 +
  583. "&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
  584. } else {
  585. 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 +
  586. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  587. }
  588. resp, requestErr := http.Get(api)
  589. if requestErr != nil {
  590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  591. return
  592. }
  593. body, ioErr := ioutil.ReadAll(resp.Body)
  594. if ioErr != nil {
  595. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  597. return
  598. }
  599. var respJSON map[string]interface{}
  600. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  601. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  603. return
  604. }
  605. var status string
  606. status = respJSON["data"].(map[string]interface{})["status"].(string)
  607. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  608. var token string
  609. var res ResultTwo //1101结果
  610. var res10265 ResultTwo10265 //1101结果
  611. var card_info string //卡信息
  612. var busi_card_info string
  613. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  614. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  615. if status == "0" { //读卡成功
  616. if card_type == "1" {
  617. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  618. result, _ := json.Marshal(respJSON)
  619. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  620. utils.ErrorLog("解析失败:%v", err)
  621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  622. return
  623. }
  624. res.ErrMsg = res10265.ErrMsg
  625. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  626. res.Infcode = infocode
  627. res.Output = res10265.Output
  628. res.InfRefmsgid = res10265.InfRefmsgid
  629. } else {
  630. //var card_info string //卡信息
  631. //var busi_card_info string
  632. token = respJSON["data"].(map[string]interface{})["token"].(string)
  633. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  634. //fmt.Println(card_info)
  635. //fmt.Println(busi_card_info)
  636. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  637. result, _ := json.Marshal(respJSON)
  638. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  639. utils.ErrorLog("解析失败:%v", err)
  640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  641. return
  642. }
  643. res.ErrMsg = res10265.ErrMsg
  644. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  645. res.Infcode = infocode
  646. res.Output = res10265.Output
  647. res.InfRefmsgid = res10265.InfRefmsgid
  648. }
  649. if res.Infcode == 0 {
  650. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  651. if err == gorm.ErrRecordNotFound {
  652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  653. return
  654. } else if err != nil {
  655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  656. return
  657. } else {
  658. if card_type == "1" {
  659. bas := strings.Split(card_info, "|")
  660. basNumber := bas[2]
  661. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  662. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  663. infoStr := string(Iinfos)
  664. idetinfoStr := string(Idetinfos)
  665. psn := &models.HisPsn{
  666. PsnNo: res.Output.Baseinfo.PsnNo,
  667. Age: res.Output.Baseinfo.Age,
  668. PatientId: patient.ID,
  669. Certno: res.Output.Baseinfo.Certno,
  670. Brdy: res.Output.Baseinfo.Brdy,
  671. Gend: res.Output.Baseinfo.Gend,
  672. Naty: res.Output.Baseinfo.Naty,
  673. PsnCertType: res.Output.Baseinfo.PsnCertType,
  674. PsnName: res.Output.Baseinfo.PsnName,
  675. Idetinfo: idetinfoStr,
  676. Insuinfo: infoStr,
  677. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  678. CardInfo: card_info,
  679. VerifyNumber: busi_card_info,
  680. }
  681. service.CreateHisPsn(psn)
  682. c.ServeSuccessJSON(map[string]interface{}{
  683. "patient": patient,
  684. "number": basNumber,
  685. })
  686. } else {
  687. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  688. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  689. infoStr := string(Iinfos)
  690. idetinfoStr := string(Idetinfos)
  691. psn := &models.HisPsn{
  692. PsnNo: res.Output.Baseinfo.PsnNo,
  693. Age: res.Output.Baseinfo.Age,
  694. PatientId: patient.ID,
  695. Certno: res.Output.Baseinfo.Certno,
  696. Brdy: res.Output.Baseinfo.Brdy,
  697. Gend: res.Output.Baseinfo.Gend,
  698. Naty: res.Output.Baseinfo.Naty,
  699. PsnCertType: res.Output.Baseinfo.PsnCertType,
  700. PsnName: res.Output.Baseinfo.PsnName,
  701. Idetinfo: idetinfoStr,
  702. Insuinfo: infoStr,
  703. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  704. CardInfo: card_info,
  705. VerifyNumber: token,
  706. }
  707. service.CreateHisPsn(psn)
  708. c.ServeSuccessJSON(map[string]interface{}{
  709. "patient": patient,
  710. "number": token,
  711. })
  712. }
  713. }
  714. } else {
  715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  716. return
  717. }
  718. } else { //读卡失败
  719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  720. return
  721. }
  722. }
  723. break
  724. }
  725. }
  726. var initFlag int64 = 0
  727. func (c *HisApiController) TestGetBasBaseInit() {
  728. DllDef := syscall.MustLoadDLL("SSCard.dll")
  729. Iinit := DllDef.MustFindProc("Init")
  730. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  731. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  732. if ret != 0 {
  733. fmt.Println("SSCard的报错原因:", err)
  734. fmt.Println("SSCard的运算结果为:", ret)
  735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  736. return
  737. }
  738. result := int(ret)
  739. fmt.Println("SSCard的运算结果为1:", result)
  740. initFlag = 1
  741. return
  742. }
  743. func (c *HisApiController) GetSFZBaseInfo() string {
  744. DllDef := syscall.MustLoadDLL("SSCard.dll")
  745. readCard := DllDef.MustFindProc("ReadSFZ")
  746. if readCard == nil {
  747. fmt.Println("readcard is nil")
  748. readCard = DllDef.MustFindProc("ReadSFZ")
  749. }
  750. str := make([]byte, 256)
  751. str1 := make([]byte, 256)
  752. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  753. fmt.Println(r)
  754. return string(str)
  755. }
  756. func (c *HisApiController) GetBasBaseInfo() string {
  757. DllDef := syscall.MustLoadDLL("SSCard.dll")
  758. readCard := DllDef.MustFindProc("ReadCardBas")
  759. if readCard == nil {
  760. fmt.Println("readcard is nil")
  761. readCard = DllDef.MustFindProc("ReadCardBas")
  762. }
  763. str := make([]byte, 1024)
  764. str1 := make([]byte, 1024)
  765. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  766. fmt.Println(string(str1))
  767. fmt.Println(string(str))
  768. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  769. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  770. if ret2 != 0 {
  771. return ""
  772. }
  773. return string(str)
  774. }
  775. type CustomFundPay struct {
  776. FundPayType string `json:"fund_pay_type"`
  777. FundPayamt float64 `json:"fund_payamt"`
  778. }
  779. func (c *HisApiController) GetSettleList() {
  780. order_id, _ := c.GetInt64("order_id")
  781. admin_user_id, _ := c.GetInt64("admin_user_id")
  782. order, _ := service.GetHisOrderByIDTwo(order_id)
  783. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  784. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  785. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  786. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  787. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  788. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  789. if order.ID == 0 {
  790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  791. return
  792. }
  793. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  794. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  795. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  796. fmt.Println(count)
  797. var zero string
  798. number := count + 1
  799. if number >= 1000 {
  800. zero = "0000" + strconv.FormatInt(number, 10)
  801. } else if number >= 10000 {
  802. zero = "000" + strconv.FormatInt(number, 10)
  803. } else if number >= 100000 {
  804. zero = "00" + strconv.FormatInt(number, 10)
  805. } else if number >= 1000000 {
  806. zero = "0" + strconv.FormatInt(number, 10)
  807. } else {
  808. zero = strconv.FormatInt(number, 10)
  809. }
  810. fmt.Println(zero)
  811. struct4101 := service.Struct4101{
  812. PsnNo: order.PsnNo,
  813. MdtrtId: order.MdtrtId,
  814. SetlId: order.SetlId,
  815. PsnName: order.PsnName,
  816. Gend: order.Gend,
  817. Brdy: his.Brdy,
  818. Age: his.Age,
  819. Naty: order.Naty,
  820. PatnCertType: "01",
  821. Certno: order.Certno,
  822. Prfs: "90",
  823. ConerName: roles[0].UserName,
  824. PatnRlts: "99",
  825. ConerAddr: miConfig.OrgName,
  826. ConerTel: admin.Mobile,
  827. HiType: order.Insutype,
  828. Insuplc: miConfig.InsuplcAdmdvs,
  829. MaindiagFlag: "1",
  830. BillCode: last_order.FaPiaoCode,
  831. BillNo: zero,
  832. BizSn: order.Number,
  833. PsnSelfPay: order.PsnPartAmt,
  834. PsnOwnPay: order.PsnPartAmt,
  835. AcctPay: order.AcctPay,
  836. PsnCashpay: order.PsnCashPay,
  837. HiPaymtd: "1",
  838. Hsorg: miConfig.InsuplcAdmdvs,
  839. HsorgOpter: miConfig.InsuplcAdmdvs,
  840. MedinsFillPsn: curRoles.UserName,
  841. MedinsFillDept: depart.Name,
  842. IptMedType: "2",
  843. }
  844. struct4101.SetlBegnDate = order.SetlTime
  845. struct4101.SetlEndDate = order.SetlTime
  846. time_arr := strings.Split(order.SetlTime, " ")
  847. struct4101.AdmTime = time_arr[0]
  848. struct4101.AdmEndTime = time_arr[0]
  849. var rf []CustomFundPay
  850. json.Unmarshal([]byte(order.SetlDetail), &rf)
  851. var tempFunPays []service.CustomStruct
  852. for _, item := range rf {
  853. var tempFunPay service.CustomStruct
  854. tempFunPay.FundPayamt = item.FundPayamt
  855. tempFunPay.FundPayType = item.FundPayType
  856. tempFunPays = append(tempFunPays, tempFunPay)
  857. }
  858. struct4101.CustomStruct = tempFunPays
  859. var tempDiaginfos []service.DiaginfoStructTwo
  860. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  861. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  862. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  863. var config []*models.HisXtDiagnoseConfig
  864. for _, item := range diagnosis_ids {
  865. id, _ := strconv.ParseInt(item, 10, 64)
  866. diagnosisConfig, _ := service.FindDiagnoseById(id)
  867. config = append(config, &diagnosisConfig)
  868. }
  869. for index, item := range config {
  870. if index == 0 {
  871. var tempDiaginfo service.DiaginfoStructTwo
  872. tempDiaginfo.DiagCode = item.CountryCode
  873. tempDiaginfo.DiagName = item.CountryContentName
  874. tempDiaginfo.DiagType = "1"
  875. tempDiaginfo.MaindiagFlag = "1"
  876. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  877. } else {
  878. var tempDiaginfo service.DiaginfoStructTwo
  879. tempDiaginfo.DiagCode = item.CountryCode
  880. tempDiaginfo.DiagName = item.CountryContentName
  881. tempDiaginfo.DiagType = "2"
  882. tempDiaginfo.MaindiagFlag = "0"
  883. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  884. }
  885. }
  886. struct4101.Diseinfo = tempDiaginfos
  887. sickConfigTwo, _ := service.FindSickById(his.SickType)
  888. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  889. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  890. tempOpspdiseinfo2.OprnOprtCode = ""
  891. tempOpspdiseinfo2.OprnOprtName = ""
  892. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  893. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  894. var iteminfo service.IteminfoStruct
  895. var bedCostTotal float64 = 0 //床位总费
  896. var bedCostSelfTotal float64 = 0 //床位自费
  897. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  898. var operationCostTotal float64 = 0 //手术费
  899. var operationCostSelfTotal float64 = 0 //手术费
  900. var operationCostPartSelfTotal float64 = 0 //手术费
  901. var otherCostTotal float64 = 0 //其他费用
  902. var otherCostSelfTotal float64 = 0 //其他费用
  903. var otherCostPartSelfTotal float64 = 0 //其他费用
  904. var materialCostTotal float64 = 0 //材料费
  905. var materialCostSelfTotal float64 = 0 //材料费
  906. var materialCostPartSelfTotal float64 = 0 //材料费
  907. var westernMedicineCostTotal float64 = 0 //西药费
  908. var westernMedicineCostSelfTotal float64 = 0 //西药费
  909. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  910. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  911. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  912. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  913. var checkCostTotal float64 = 0 //检查费
  914. var checkCostSelfTotal float64 = 0 //检查费
  915. var checkCostPartSelfTotal float64 = 0 //检查费
  916. var laboratoryCostTotal float64 = 0 //化验费
  917. var laboratoryCostSelfTotal float64 = 0 //化验费
  918. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  919. var treatCostTotal float64 = 0 //治疗费用
  920. var treatCostSelfTotal float64 = 0 //治疗费用
  921. var treatCostPartSelfTotal float64 = 0 //治疗费用
  922. decimal.DivisionPrecision = 2
  923. var bed_fulamt_ownpay_amt float64 = 0
  924. var operation_fulamt_ownpay_amt float64 = 0
  925. var other_fulamt_ownpay_amt float64 = 0
  926. var westernMedicine_fulamt_ownpay_amt float64 = 0
  927. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  928. var check_fulamt_ownpay_amt float64 = 0
  929. var material_fulamt_ownpay_amt float64 = 0
  930. var laboratory_fulamt_ownpay_amt float64 = 0
  931. var treat_fulamt_ownpay_amt float64 = 0
  932. var bed_claa_sunmfee float64 = 0
  933. var bed_clab_amt float64 = 0
  934. var bed_other_amt float64 = 0
  935. var operation_claa_sunmfee float64 = 0
  936. var operation_clab_amt float64 = 0
  937. var operation_other_amt float64 = 0
  938. var other_claa_sunmfee float64 = 0
  939. var other_clab_amt float64 = 0
  940. var other_other_amt float64 = 0
  941. var westernMedicine_claa_sunmfee float64 = 0
  942. var westernMedicine_clab_amt float64 = 0
  943. var westernMedicine_other_amt float64 = 0
  944. var chineseTraditional_claa_sunmfee float64 = 0
  945. var chineseTraditional_clab_amt float64 = 0
  946. var chineseTraditional_other_amt float64 = 0
  947. var check_claa_sunmfee float64 = 0
  948. var check_clab_amt float64 = 0
  949. var check_other_amt float64 = 0
  950. var material_claa_sunmfee float64 = 0
  951. var material_clab_amt float64 = 0
  952. var material_other_amt float64 = 0
  953. var laboratory_claa_sunmfee float64 = 0
  954. var laboratory_clab_amt float64 = 0
  955. var laboratory_other_amt float64 = 0
  956. var treat_claa_sunmfee float64 = 0
  957. var treat_clab_amt float64 = 0
  958. var treat_other_amt float64 = 0
  959. for _, item := range order.HisOrderInfo {
  960. if item.MedChrgitmType == "01" { //床位费
  961. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  962. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  963. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  964. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  965. if item.ChrgitmLv == "1" {
  966. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  967. }
  968. if item.ChrgitmLv == "2" {
  969. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  970. }
  971. if item.ChrgitmLv == "3" {
  972. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  973. }
  974. }
  975. if item.MedChrgitmType == "03" { //检查费
  976. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  977. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  978. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  979. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  980. if item.ChrgitmLv == "1" {
  981. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  982. }
  983. if item.ChrgitmLv == "2" {
  984. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  985. }
  986. if item.ChrgitmLv == "3" {
  987. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  988. }
  989. }
  990. if item.MedChrgitmType == "04" { //化验费
  991. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  992. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  993. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  994. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  995. if item.ChrgitmLv == "1" {
  996. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  997. }
  998. if item.ChrgitmLv == "2" {
  999. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1000. }
  1001. if item.ChrgitmLv == "3" {
  1002. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1003. }
  1004. }
  1005. if item.MedChrgitmType == "05" { //治疗费
  1006. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1007. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1008. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1009. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1010. if item.ChrgitmLv == "1" {
  1011. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1012. }
  1013. if item.ChrgitmLv == "2" {
  1014. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1015. }
  1016. if item.ChrgitmLv == "3" {
  1017. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1018. }
  1019. }
  1020. if item.MedChrgitmType == "06" { //手术费
  1021. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1022. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1023. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1024. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1025. if item.ChrgitmLv == "1" {
  1026. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1027. }
  1028. if item.ChrgitmLv == "2" {
  1029. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1030. }
  1031. if item.ChrgitmLv == "3" {
  1032. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1033. }
  1034. }
  1035. if item.MedChrgitmType == "08" { //材料费
  1036. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1037. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1038. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1039. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1040. if item.ChrgitmLv == "1" {
  1041. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1042. }
  1043. if item.ChrgitmLv == "2" {
  1044. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1045. }
  1046. if item.ChrgitmLv == "3" {
  1047. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1048. }
  1049. }
  1050. if item.MedChrgitmType == "09" { //西药费
  1051. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1052. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1053. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1054. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1055. if item.ChrgitmLv == "1" {
  1056. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1057. }
  1058. if item.ChrgitmLv == "2" {
  1059. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1060. }
  1061. if item.ChrgitmLv == "3" {
  1062. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1063. }
  1064. }
  1065. if item.MedChrgitmType == "11" { //中成费
  1066. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1067. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1068. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1069. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1070. if item.ChrgitmLv == "1" {
  1071. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1072. }
  1073. if item.ChrgitmLv == "2" {
  1074. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1075. }
  1076. if item.ChrgitmLv == "3" {
  1077. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1078. }
  1079. }
  1080. if item.MedChrgitmType == "14" { //其他费
  1081. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1082. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1083. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1084. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1085. if item.ChrgitmLv == "1" {
  1086. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1087. }
  1088. if item.ChrgitmLv == "2" {
  1089. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1090. }
  1091. if item.ChrgitmLv == "3" {
  1092. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1093. }
  1094. }
  1095. }
  1096. var iteminfoStructs []service.IteminfoStruct
  1097. if bedCostTotal != 0 {
  1098. iteminfo.MedChrgitm = "01"
  1099. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1100. iteminfo.Amt = bedCostTotal
  1101. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1102. iteminfo.ClabAmt = bed_clab_amt
  1103. iteminfo.OthAmt = bed_other_amt
  1104. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1105. }
  1106. if checkCostTotal != 0 {
  1107. iteminfo.MedChrgitm = "03"
  1108. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1109. iteminfo.Amt = checkCostTotal
  1110. iteminfo.ClaaSumfee = check_claa_sunmfee
  1111. iteminfo.ClabAmt = check_clab_amt
  1112. iteminfo.OthAmt = check_other_amt
  1113. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1114. }
  1115. if laboratoryCostTotal != 0 {
  1116. iteminfo.MedChrgitm = "04"
  1117. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1118. iteminfo.Amt = laboratoryCostTotal
  1119. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1120. iteminfo.ClabAmt = laboratory_clab_amt
  1121. iteminfo.OthAmt = laboratory_other_amt
  1122. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1123. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1124. }
  1125. if treatCostTotal != 0 {
  1126. iteminfo.MedChrgitm = "05"
  1127. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1128. iteminfo.Amt = treatCostTotal
  1129. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1130. iteminfo.ClabAmt = treat_clab_amt
  1131. iteminfo.OthAmt = treat_other_amt
  1132. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1133. //(struct4101.IteminfoStruct, iteminfo)
  1134. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1135. }
  1136. if operationCostTotal != 0 {
  1137. iteminfo.MedChrgitm = "06"
  1138. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1139. iteminfo.Amt = operationCostTotal
  1140. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1141. iteminfo.ClabAmt = operation_clab_amt
  1142. iteminfo.OthAmt = operation_other_amt
  1143. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1144. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1145. }
  1146. if materialCostTotal != 0 {
  1147. iteminfo.MedChrgitm = "08"
  1148. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1149. iteminfo.Amt = materialCostTotal
  1150. iteminfo.ClaaSumfee = material_claa_sunmfee
  1151. iteminfo.ClabAmt = material_clab_amt
  1152. iteminfo.OthAmt = material_other_amt
  1153. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1154. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1155. }
  1156. if westernMedicineCostTotal != 0 {
  1157. iteminfo.MedChrgitm = "09"
  1158. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1159. iteminfo.Amt = westernMedicineCostTotal
  1160. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1161. iteminfo.ClabAmt = westernMedicine_clab_amt
  1162. iteminfo.OthAmt = westernMedicine_other_amt
  1163. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1164. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1165. }
  1166. if chineseTraditionalMedicineCostTotal != 0 {
  1167. iteminfo.MedChrgitm = "11"
  1168. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1169. iteminfo.Amt = westernMedicineCostTotal
  1170. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1171. iteminfo.ClabAmt = westernMedicine_clab_amt
  1172. iteminfo.OthAmt = westernMedicine_other_amt
  1173. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1174. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1175. }
  1176. if otherCostTotal != 0 {
  1177. iteminfo.MedChrgitm = "14"
  1178. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1179. iteminfo.Amt = otherCostTotal
  1180. iteminfo.ClaaSumfee = other_claa_sunmfee
  1181. iteminfo.ClabAmt = other_clab_amt
  1182. iteminfo.OthAmt = other_other_amt
  1183. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1184. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1185. }
  1186. struct4101.IteminfoStruct = iteminfoStructs
  1187. struct4101.Ntly = "中国"
  1188. struct4101.AdmCaty = "A03.06"
  1189. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1190. fmt.Println(result)
  1191. var dat map[string]interface{}
  1192. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1193. fmt.Println(dat)
  1194. } else {
  1195. fmt.Println(err)
  1196. }
  1197. userJSONBytes, _ := json.Marshal(dat)
  1198. var res ResultSeventeen
  1199. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1200. utils.ErrorLog("解析失败:%v", err)
  1201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1202. return
  1203. }
  1204. if res.Infcode != 0 {
  1205. c.ServeSuccessJSON(map[string]interface{}{
  1206. "failed_code": -10,
  1207. "msg": res.ErrMsg,
  1208. })
  1209. return
  1210. } else {
  1211. order.FaPiaoNumber = zero
  1212. order.FaPiaoCode = last_order.FaPiaoCode
  1213. service.UpdateOrder(order)
  1214. hisFundSettleListResult := &models.HisFundSettleListResult{
  1215. Number: res.Output.SetlListId,
  1216. Status: 1,
  1217. Ctime: time.Now().Unix(),
  1218. Mtime: time.Now().Unix(),
  1219. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1220. IsUpload: 1,
  1221. OrderId: order_id,
  1222. }
  1223. service.CreateUploadRecord(hisFundSettleListResult)
  1224. c.ServeSuccessJSON(map[string]interface{}{
  1225. "msg": "上传成功",
  1226. "result": hisFundSettleListResult,
  1227. })
  1228. return
  1229. }
  1230. }
  1231. func (c *HisApiController) GetSettleListHospital() {
  1232. order_id, _ := c.GetInt64("order_id")
  1233. admin_user_id, _ := c.GetInt64("admin_user_id")
  1234. order, _ := service.GetHisOrderByIDTwo(order_id)
  1235. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1236. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1237. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1238. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1239. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1240. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1241. if order.ID == 0 {
  1242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1243. return
  1244. }
  1245. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1246. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1247. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1248. fmt.Println(count)
  1249. var zero string
  1250. number := count + 1
  1251. if number >= 1000 {
  1252. zero = "0000" + strconv.FormatInt(number, 10)
  1253. } else if number >= 10000 {
  1254. zero = "000" + strconv.FormatInt(number, 10)
  1255. } else if number >= 100000 {
  1256. zero = "00" + strconv.FormatInt(number, 10)
  1257. } else if number >= 1000000 {
  1258. zero = "0" + strconv.FormatInt(number, 10)
  1259. } else {
  1260. zero = strconv.FormatInt(number, 10)
  1261. }
  1262. fmt.Println(zero)
  1263. struct4101 := service.Struct4101{
  1264. PsnNo: order.PsnNo,
  1265. MdtrtId: order.MdtrtId,
  1266. SetlId: order.SetlId,
  1267. PsnName: order.PsnName,
  1268. Gend: order.Gend,
  1269. Brdy: his.Brdy,
  1270. Age: int64(order.Age),
  1271. Naty: order.Naty,
  1272. PatnCertType: "01",
  1273. Certno: order.Certno,
  1274. Prfs: "90",
  1275. ConerName: roles[0].UserName,
  1276. PatnRlts: "99",
  1277. ConerAddr: miConfig.OrgName,
  1278. ConerTel: admin.Mobile,
  1279. HiType: order.Insutype,
  1280. Insuplc: miConfig.InsuplcAdmdvs,
  1281. MaindiagFlag: "1",
  1282. BillCode: last_order.FaPiaoCode,
  1283. BillNo: zero,
  1284. BizSn: order.Number,
  1285. PsnSelfPay: order.PsnPartAmt,
  1286. PsnOwnPay: order.PsnPartAmt,
  1287. AcctPay: order.AcctPay,
  1288. PsnCashpay: order.PsnCashPay,
  1289. HiPaymtd: "1",
  1290. Hsorg: miConfig.InsuplcAdmdvs,
  1291. HsorgOpter: miConfig.InsuplcAdmdvs,
  1292. MedinsFillPsn: curRoles.UserName,
  1293. MedinsFillDept: depart.Name,
  1294. IptMedType: "2",
  1295. AdmTime: his.InHosptialTime,
  1296. AdmEndTime: his.OutHosptialTime,
  1297. }
  1298. struct4101.SetlBegnDate = order.SetlTime
  1299. struct4101.SetlEndDate = order.SetlTime
  1300. var rf []CustomFundPay
  1301. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1302. var tempFunPays []service.CustomStruct
  1303. for _, item := range rf {
  1304. var tempFunPay service.CustomStruct
  1305. tempFunPay.FundPayamt = item.FundPayamt
  1306. tempFunPay.FundPayType = item.FundPayType
  1307. tempFunPays = append(tempFunPays, tempFunPay)
  1308. }
  1309. struct4101.CustomStruct = tempFunPays
  1310. var tempDiaginfos []service.DiaginfoStructTwo
  1311. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1312. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1313. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1314. var config []*models.HisXtDiagnoseConfig
  1315. for _, item := range diagnosis_ids {
  1316. id, _ := strconv.ParseInt(item, 10, 64)
  1317. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1318. config = append(config, &diagnosisConfig)
  1319. }
  1320. for index, item := range config {
  1321. if index == 0 {
  1322. var tempDiaginfo service.DiaginfoStructTwo
  1323. tempDiaginfo.DiagCode = item.CountryCode
  1324. tempDiaginfo.DiagName = item.CountryContentName
  1325. tempDiaginfo.DiagType = "1"
  1326. tempDiaginfo.MaindiagFlag = "1"
  1327. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1328. } else {
  1329. var tempDiaginfo service.DiaginfoStructTwo
  1330. tempDiaginfo.DiagCode = item.CountryCode
  1331. tempDiaginfo.DiagName = item.CountryContentName
  1332. tempDiaginfo.DiagType = "2"
  1333. tempDiaginfo.MaindiagFlag = "0"
  1334. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1335. }
  1336. }
  1337. struct4101.Diseinfo = tempDiaginfos
  1338. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1339. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1340. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1341. tempOpspdiseinfo2.OprnOprtCode = ""
  1342. tempOpspdiseinfo2.OprnOprtName = ""
  1343. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1344. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1345. var iteminfo service.IteminfoStruct
  1346. var bedCostTotal float64 = 0 //床位总费
  1347. var bedCostSelfTotal float64 = 0 //床位自费
  1348. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1349. var operationCostTotal float64 = 0 //手术费
  1350. var operationCostSelfTotal float64 = 0 //手术费
  1351. var operationCostPartSelfTotal float64 = 0 //手术费
  1352. var otherCostTotal float64 = 0 //其他费用
  1353. var otherCostSelfTotal float64 = 0 //其他费用
  1354. var otherCostPartSelfTotal float64 = 0 //其他费用
  1355. var materialCostTotal float64 = 0 //材料费
  1356. var materialCostSelfTotal float64 = 0 //材料费
  1357. var materialCostPartSelfTotal float64 = 0 //材料费
  1358. var westernMedicineCostTotal float64 = 0 //西药费
  1359. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1360. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1361. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1362. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1363. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1364. var checkCostTotal float64 = 0 //检查费
  1365. var checkCostSelfTotal float64 = 0 //检查费
  1366. var checkCostPartSelfTotal float64 = 0 //检查费
  1367. var laboratoryCostTotal float64 = 0 //化验费
  1368. var laboratoryCostSelfTotal float64 = 0 //化验费
  1369. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1370. var treatCostTotal float64 = 0 //治疗费用
  1371. var treatCostSelfTotal float64 = 0 //治疗费用
  1372. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1373. decimal.DivisionPrecision = 2
  1374. var bed_fulamt_ownpay_amt float64 = 0
  1375. var operation_fulamt_ownpay_amt float64 = 0
  1376. var other_fulamt_ownpay_amt float64 = 0
  1377. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1378. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1379. var check_fulamt_ownpay_amt float64 = 0
  1380. var material_fulamt_ownpay_amt float64 = 0
  1381. var laboratory_fulamt_ownpay_amt float64 = 0
  1382. var treat_fulamt_ownpay_amt float64 = 0
  1383. var bed_claa_sunmfee float64 = 0
  1384. var bed_clab_amt float64 = 0
  1385. var bed_other_amt float64 = 0
  1386. var operation_claa_sunmfee float64 = 0
  1387. var operation_clab_amt float64 = 0
  1388. var operation_other_amt float64 = 0
  1389. var other_claa_sunmfee float64 = 0
  1390. var other_clab_amt float64 = 0
  1391. var other_other_amt float64 = 0
  1392. var westernMedicine_claa_sunmfee float64 = 0
  1393. var westernMedicine_clab_amt float64 = 0
  1394. var westernMedicine_other_amt float64 = 0
  1395. var chineseTraditional_claa_sunmfee float64 = 0
  1396. var chineseTraditional_clab_amt float64 = 0
  1397. var chineseTraditional_other_amt float64 = 0
  1398. var check_claa_sunmfee float64 = 0
  1399. var check_clab_amt float64 = 0
  1400. var check_other_amt float64 = 0
  1401. var material_claa_sunmfee float64 = 0
  1402. var material_clab_amt float64 = 0
  1403. var material_other_amt float64 = 0
  1404. var laboratory_claa_sunmfee float64 = 0
  1405. var laboratory_clab_amt float64 = 0
  1406. var laboratory_other_amt float64 = 0
  1407. var treat_claa_sunmfee float64 = 0
  1408. var treat_clab_amt float64 = 0
  1409. var treat_other_amt float64 = 0
  1410. for _, item := range order.HisOrderInfo {
  1411. if item.MedChrgitmType == "01" { //床位费
  1412. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1413. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1414. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1415. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1416. if item.ChrgitmLv == "1" {
  1417. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1418. }
  1419. if item.ChrgitmLv == "2" {
  1420. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1421. }
  1422. if item.ChrgitmLv == "3" {
  1423. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1424. }
  1425. }
  1426. if item.MedChrgitmType == "03" { //检查费
  1427. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1428. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1429. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1430. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1431. if item.ChrgitmLv == "1" {
  1432. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1433. }
  1434. if item.ChrgitmLv == "2" {
  1435. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1436. }
  1437. if item.ChrgitmLv == "3" {
  1438. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1439. }
  1440. }
  1441. if item.MedChrgitmType == "04" { //化验费
  1442. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1443. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1444. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1445. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1446. if item.ChrgitmLv == "1" {
  1447. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1448. }
  1449. if item.ChrgitmLv == "2" {
  1450. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1451. }
  1452. if item.ChrgitmLv == "3" {
  1453. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1454. }
  1455. }
  1456. if item.MedChrgitmType == "05" { //治疗费
  1457. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1458. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1459. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1460. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1461. if item.ChrgitmLv == "1" {
  1462. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1463. }
  1464. if item.ChrgitmLv == "2" {
  1465. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1466. }
  1467. if item.ChrgitmLv == "3" {
  1468. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1469. }
  1470. }
  1471. if item.MedChrgitmType == "06" { //手术费
  1472. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1473. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1474. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1475. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1476. if item.ChrgitmLv == "1" {
  1477. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1478. }
  1479. if item.ChrgitmLv == "2" {
  1480. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1481. }
  1482. if item.ChrgitmLv == "3" {
  1483. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1484. }
  1485. }
  1486. if item.MedChrgitmType == "08" { //材料费
  1487. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1488. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1489. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1490. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1491. if item.ChrgitmLv == "1" {
  1492. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1493. }
  1494. if item.ChrgitmLv == "2" {
  1495. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1496. }
  1497. if item.ChrgitmLv == "3" {
  1498. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1499. }
  1500. }
  1501. if item.MedChrgitmType == "09" { //西药费
  1502. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1503. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1504. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1505. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1506. if item.ChrgitmLv == "1" {
  1507. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1508. }
  1509. if item.ChrgitmLv == "2" {
  1510. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1511. }
  1512. if item.ChrgitmLv == "3" {
  1513. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1514. }
  1515. }
  1516. if item.MedChrgitmType == "11" { //中成费
  1517. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1518. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1519. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1520. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1521. if item.ChrgitmLv == "1" {
  1522. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1523. }
  1524. if item.ChrgitmLv == "2" {
  1525. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1526. }
  1527. if item.ChrgitmLv == "3" {
  1528. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1529. }
  1530. }
  1531. if item.MedChrgitmType == "14" { //其他费
  1532. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1533. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1534. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1535. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1536. if item.ChrgitmLv == "1" {
  1537. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1538. }
  1539. if item.ChrgitmLv == "2" {
  1540. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1541. }
  1542. if item.ChrgitmLv == "3" {
  1543. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1544. }
  1545. }
  1546. }
  1547. var iteminfoStructs []service.IteminfoStruct
  1548. if bedCostTotal != 0 {
  1549. iteminfo.MedChrgitm = "01"
  1550. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1551. iteminfo.Amt = bedCostTotal
  1552. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1553. iteminfo.ClabAmt = bed_clab_amt
  1554. iteminfo.OthAmt = bed_other_amt
  1555. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1556. }
  1557. if checkCostTotal != 0 {
  1558. iteminfo.MedChrgitm = "03"
  1559. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1560. iteminfo.Amt = checkCostTotal
  1561. iteminfo.ClaaSumfee = check_claa_sunmfee
  1562. iteminfo.ClabAmt = check_clab_amt
  1563. iteminfo.OthAmt = check_other_amt
  1564. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1565. }
  1566. if laboratoryCostTotal != 0 {
  1567. iteminfo.MedChrgitm = "04"
  1568. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1569. iteminfo.Amt = laboratoryCostTotal
  1570. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1571. iteminfo.ClabAmt = laboratory_clab_amt
  1572. iteminfo.OthAmt = laboratory_other_amt
  1573. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1574. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1575. }
  1576. if treatCostTotal != 0 {
  1577. iteminfo.MedChrgitm = "05"
  1578. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1579. iteminfo.Amt = treatCostTotal
  1580. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1581. iteminfo.ClabAmt = treat_clab_amt
  1582. iteminfo.OthAmt = treat_other_amt
  1583. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1584. //(struct4101.IteminfoStruct, iteminfo)
  1585. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1586. }
  1587. if operationCostTotal != 0 {
  1588. iteminfo.MedChrgitm = "06"
  1589. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1590. iteminfo.Amt = operationCostTotal
  1591. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1592. iteminfo.ClabAmt = operation_clab_amt
  1593. iteminfo.OthAmt = operation_other_amt
  1594. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1595. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1596. }
  1597. if materialCostTotal != 0 {
  1598. iteminfo.MedChrgitm = "08"
  1599. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1600. iteminfo.Amt = materialCostTotal
  1601. iteminfo.ClaaSumfee = material_claa_sunmfee
  1602. iteminfo.ClabAmt = material_clab_amt
  1603. iteminfo.OthAmt = material_other_amt
  1604. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1605. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1606. }
  1607. if westernMedicineCostTotal != 0 {
  1608. iteminfo.MedChrgitm = "09"
  1609. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1610. iteminfo.Amt = westernMedicineCostTotal
  1611. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1612. iteminfo.ClabAmt = westernMedicine_clab_amt
  1613. iteminfo.OthAmt = westernMedicine_other_amt
  1614. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1615. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1616. }
  1617. if chineseTraditionalMedicineCostTotal != 0 {
  1618. iteminfo.MedChrgitm = "11"
  1619. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1620. iteminfo.Amt = westernMedicineCostTotal
  1621. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1622. iteminfo.ClabAmt = westernMedicine_clab_amt
  1623. iteminfo.OthAmt = westernMedicine_other_amt
  1624. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1625. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1626. }
  1627. if otherCostTotal != 0 {
  1628. iteminfo.MedChrgitm = "14"
  1629. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1630. iteminfo.Amt = otherCostTotal
  1631. iteminfo.ClaaSumfee = other_claa_sunmfee
  1632. iteminfo.ClabAmt = other_clab_amt
  1633. iteminfo.OthAmt = other_other_amt
  1634. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1635. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1636. }
  1637. struct4101.IteminfoStruct = iteminfoStructs
  1638. struct4101.Ntly = "中国"
  1639. struct4101.AdmCaty = "A03.06"
  1640. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1641. fmt.Println(result)
  1642. var dat map[string]interface{}
  1643. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1644. fmt.Println(dat)
  1645. } else {
  1646. fmt.Println(err)
  1647. }
  1648. userJSONBytes, _ := json.Marshal(dat)
  1649. var res ResultSeventeen
  1650. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1651. utils.ErrorLog("解析失败:%v", err)
  1652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1653. return
  1654. }
  1655. if res.Infcode != 0 {
  1656. c.ServeSuccessJSON(map[string]interface{}{
  1657. "failed_code": -10,
  1658. "msg": res.ErrMsg,
  1659. })
  1660. return
  1661. } else {
  1662. order.FaPiaoNumber = zero
  1663. order.FaPiaoCode = last_order.FaPiaoCode
  1664. service.UpdateOrder(order)
  1665. hisFundSettleListResult := &models.HisFundSettleListResult{
  1666. Number: res.Output.SetlListId,
  1667. Status: 1,
  1668. Ctime: time.Now().Unix(),
  1669. Mtime: time.Now().Unix(),
  1670. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1671. IsUpload: 1,
  1672. OrderId: order_id,
  1673. }
  1674. service.CreateUploadRecord(hisFundSettleListResult)
  1675. c.ServeSuccessJSON(map[string]interface{}{
  1676. "msg": "上传成功",
  1677. "result": hisFundSettleListResult,
  1678. })
  1679. return
  1680. }
  1681. }
  1682. func (c *HisApiController) GetBatchSettleList() {
  1683. orders, _ := service.GetAllHisOrder(10106)
  1684. for _, item := range orders {
  1685. order_id := item.ID
  1686. order, _ := service.GetHisOrderByIDTwo(order_id)
  1687. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1688. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1689. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1690. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  1691. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1692. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1693. if order.ID == 0 {
  1694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1695. return
  1696. }
  1697. if his.BalanceAccountsType == 2 {
  1698. continue
  1699. }
  1700. struct4101 := service.Struct4101{
  1701. PsnNo: order.PsnNo,
  1702. MdtrtId: order.MdtrtId,
  1703. SetlId: order.SetlId,
  1704. PsnName: order.PsnName,
  1705. Gend: order.Gend,
  1706. Brdy: his.Brdy,
  1707. Age: his.Age,
  1708. Naty: order.Naty,
  1709. PatnCertType: "01",
  1710. Certno: order.Certno,
  1711. Prfs: "90",
  1712. ConerName: roles[0].UserName,
  1713. PatnRlts: "99",
  1714. ConerAddr: miConfig.OrgName,
  1715. ConerTel: admin.Mobile,
  1716. HiType: order.Insutype,
  1717. Insuplc: his.InsuplcAdmdvs,
  1718. MaindiagFlag: "1",
  1719. BillCode: order.FaPiaoCode,
  1720. BillNo: order.FaPiaoNumber,
  1721. BizSn: order.Number,
  1722. PsnSelfPay: order.PsnPartAmt,
  1723. PsnOwnPay: order.PsnPartAmt,
  1724. AcctPay: order.AcctPay,
  1725. PsnCashpay: order.PsnCashPay,
  1726. HiPaymtd: "1",
  1727. Hsorg: his.InsuplcAdmdvs,
  1728. HsorgOpter: his.InsuplcAdmdvs,
  1729. MedinsFillPsn: curRoles.UserName,
  1730. MedinsFillDept: depart.Name,
  1731. IptMedType: "2",
  1732. }
  1733. struct4101.SetlBegnDate = order.SetlTime
  1734. struct4101.SetlEndDate = order.SetlTime
  1735. //if order.SettleType == 1 {
  1736. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  1737. // dateStr := t.Format("2006-01-02")
  1738. // struct4101.SetlBegnDate = dateStr
  1739. // struct4101.SetlEndDate = dateStr
  1740. //} else {
  1741. // t := time.Unix(int64(order.SettleStartTime), 0)
  1742. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  1743. // dateStartStr := t.Format("2006-01-02")
  1744. // dateEndStr := t2.Format("2006-01-02")
  1745. // struct4101.SetlBegnDate = dateStartStr
  1746. // struct4101.SetlEndDate = dateEndStr
  1747. //}
  1748. var rf []CustomFundPay
  1749. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1750. var tempFunPays []service.CustomStruct
  1751. var tempFunPay610100 service.CustomStruct
  1752. for _, item := range rf {
  1753. if item.FundPayType == "610100" {
  1754. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  1755. tempFunPay610100.FundPayType = item.FundPayType
  1756. } else {
  1757. var tempFunPay service.CustomStruct
  1758. tempFunPay.FundPayamt = item.FundPayamt
  1759. tempFunPay.FundPayType = item.FundPayType
  1760. tempFunPays = append(tempFunPays, tempFunPay)
  1761. }
  1762. }
  1763. tempFunPays = append(tempFunPays, tempFunPay610100)
  1764. struct4101.CustomStruct = tempFunPays
  1765. var tempDiaginfos []service.DiaginfoStructTwo
  1766. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1767. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1768. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1769. var config []*models.HisXtDiagnoseConfig
  1770. for _, item := range diagnosis_ids {
  1771. id, _ := strconv.ParseInt(item, 10, 64)
  1772. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1773. config = append(config, &diagnosisConfig)
  1774. }
  1775. for index, item := range config {
  1776. if index == 0 {
  1777. var tempDiaginfo service.DiaginfoStructTwo
  1778. tempDiaginfo.DiagCode = item.CountryCode
  1779. tempDiaginfo.DiagName = item.CountryContentName
  1780. tempDiaginfo.DiagType = "1"
  1781. tempDiaginfo.MaindiagFlag = "1"
  1782. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1783. } else {
  1784. var tempDiaginfo service.DiaginfoStructTwo
  1785. tempDiaginfo.DiagCode = item.CountryCode
  1786. tempDiaginfo.DiagName = item.CountryContentName
  1787. tempDiaginfo.DiagType = "2"
  1788. tempDiaginfo.MaindiagFlag = "0"
  1789. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1790. }
  1791. }
  1792. struct4101.Diseinfo = tempDiaginfos
  1793. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1794. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1795. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1796. tempOpspdiseinfo2.OprnOprtCode = ""
  1797. tempOpspdiseinfo2.OprnOprtName = ""
  1798. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1799. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1800. var iteminfo service.IteminfoStruct
  1801. var bedCostTotal float64 = 0 //床位总费
  1802. var bedCostSelfTotal float64 = 0 //床位自费
  1803. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1804. var examineCostTotal float64 = 0 //诊查总费
  1805. var examineCostSelfTotal float64 = 0 //诊查自费
  1806. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  1807. var nursingCostTotal float64 = 0 //护理总费
  1808. var nursingCostSelfTotal float64 = 0 //护理自费
  1809. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  1810. var chineseMedicineCostTotal float64 = 0 //中成药
  1811. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  1812. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  1813. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  1814. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  1815. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  1816. var registerCostTotal float64 = 0 //一般诊疗费
  1817. var registerCostSelfTotal float64 = 0 //一般诊疗费
  1818. var registerPartSelfTotal float64 = 0 //一般诊疗费
  1819. var operationCostTotal float64 = 0 //手术费
  1820. var operationCostSelfTotal float64 = 0 //手术费
  1821. var operationCostPartSelfTotal float64 = 0 //手术费
  1822. var otherCostTotal float64 = 0 //其他费用
  1823. var otherCostSelfTotal float64 = 0 //其他费用
  1824. var otherCostPartSelfTotal float64 = 0 //其他费用
  1825. var materialCostTotal float64 = 0 //材料费
  1826. var materialCostSelfTotal float64 = 0 //材料费
  1827. var materialCostPartSelfTotal float64 = 0 //材料费
  1828. var westernMedicineCostTotal float64 = 0 //西药费
  1829. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1830. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1831. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1832. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1833. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1834. var checkCostTotal float64 = 0 //检查费
  1835. var checkCostSelfTotal float64 = 0 //检查费
  1836. var checkCostPartSelfTotal float64 = 0 //检查费
  1837. var laboratoryCostTotal float64 = 0 //化验费
  1838. var laboratoryCostSelfTotal float64 = 0 //化验费
  1839. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1840. var treatCostTotal float64 = 0 //治疗费用
  1841. var treatCostSelfTotal float64 = 0 //治疗费用
  1842. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1843. decimal.DivisionPrecision = 2
  1844. var bed_fulamt_ownpay_amt float64 = 0
  1845. var examine_fulamt_ownpay_amt float64 = 0
  1846. var nursing_fulamt_ownpay_amt float64 = 0
  1847. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1848. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1849. var register_fulamt_ownpay_amt float64 = 0
  1850. var operation_fulamt_ownpay_amt float64 = 0
  1851. var other_fulamt_ownpay_amt float64 = 0
  1852. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1853. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1854. var check_fulamt_ownpay_amt float64 = 0
  1855. var material_fulamt_ownpay_amt float64 = 0
  1856. var laboratory_fulamt_ownpay_amt float64 = 0
  1857. var treat_fulamt_ownpay_amt float64 = 0
  1858. var bed_claa_sunmfee float64 = 0
  1859. var bed_clab_amt float64 = 0
  1860. var bed_other_amt float64 = 0
  1861. var examine_claa_sunmfee float64 = 0
  1862. var examine_clab_amt float64 = 0
  1863. var examine_other_amt float64 = 0
  1864. var nursing_claa_sunmfee float64 = 0
  1865. var nursing_clab_amt float64 = 0
  1866. var nursing_other_amt float64 = 0
  1867. var chinese_medicine_claa_sunmfee float64 = 0
  1868. var chinese_medicine_clab_amt float64 = 0
  1869. var chinese_medicine_other_amt float64 = 0
  1870. var commonly_treatment_claa_sunmfee float64 = 0
  1871. var commonly_treatment_clab_amt float64 = 0
  1872. var commonly_treatment_other_amt float64 = 0
  1873. var operation_claa_sunmfee float64 = 0
  1874. var operation_clab_amt float64 = 0
  1875. var operation_other_amt float64 = 0
  1876. var other_claa_sunmfee float64 = 0
  1877. var other_clab_amt float64 = 0
  1878. var other_other_amt float64 = 0
  1879. var westernMedicine_claa_sunmfee float64 = 0
  1880. var westernMedicine_clab_amt float64 = 0
  1881. var westernMedicine_other_amt float64 = 0
  1882. var chineseTraditional_claa_sunmfee float64 = 0
  1883. var chineseTraditional_clab_amt float64 = 0
  1884. var chineseTraditional_other_amt float64 = 0
  1885. var check_claa_sunmfee float64 = 0
  1886. var check_clab_amt float64 = 0
  1887. var check_other_amt float64 = 0
  1888. var material_claa_sunmfee float64 = 0
  1889. var material_clab_amt float64 = 0
  1890. var material_other_amt float64 = 0
  1891. var laboratory_claa_sunmfee float64 = 0
  1892. var laboratory_clab_amt float64 = 0
  1893. var laboratory_other_amt float64 = 0
  1894. var treat_claa_sunmfee float64 = 0
  1895. var treat_clab_amt float64 = 0
  1896. var treat_other_amt float64 = 0
  1897. var register_claa_sunmfee float64 = 0
  1898. var register_clab_amt float64 = 0
  1899. var register_other_amt float64 = 0
  1900. for _, item := range order.HisOrderInfo {
  1901. if item.MedChrgitmType == "01" { //床位费
  1902. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1903. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1904. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1905. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1906. if item.ChrgitmLv == "1" {
  1907. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1908. }
  1909. if item.ChrgitmLv == "2" {
  1910. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1911. }
  1912. if item.ChrgitmLv == "3" {
  1913. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1914. }
  1915. }
  1916. if item.MedChrgitmType == "02" { //诊查
  1917. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1918. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1919. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1920. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1921. if item.ChrgitmLv == "1" {
  1922. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1923. }
  1924. if item.ChrgitmLv == "2" {
  1925. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1926. }
  1927. if item.ChrgitmLv == "3" {
  1928. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1929. }
  1930. }
  1931. if item.MedChrgitmType == "03" { //检查费
  1932. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1933. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1934. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1935. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1936. if item.ChrgitmLv == "1" {
  1937. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1938. }
  1939. if item.ChrgitmLv == "2" {
  1940. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1941. }
  1942. if item.ChrgitmLv == "3" {
  1943. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1944. }
  1945. }
  1946. if item.MedChrgitmType == "04" { //化验费
  1947. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1948. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1949. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1950. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1951. if item.ChrgitmLv == "1" {
  1952. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1953. }
  1954. if item.ChrgitmLv == "2" {
  1955. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1956. }
  1957. if item.ChrgitmLv == "3" {
  1958. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1959. }
  1960. }
  1961. if item.MedChrgitmType == "05" { //治疗费
  1962. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1963. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1964. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1965. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1966. if item.ChrgitmLv == "1" {
  1967. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1968. }
  1969. if item.ChrgitmLv == "2" {
  1970. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1971. }
  1972. if item.ChrgitmLv == "3" {
  1973. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1974. }
  1975. }
  1976. if item.MedChrgitmType == "06" { //手术费
  1977. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1978. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1979. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1980. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1981. if item.ChrgitmLv == "1" {
  1982. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1983. }
  1984. if item.ChrgitmLv == "2" {
  1985. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1986. }
  1987. if item.ChrgitmLv == "3" {
  1988. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1989. }
  1990. }
  1991. if item.MedChrgitmType == "07" { //手术费
  1992. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1993. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1994. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1995. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1996. if item.ChrgitmLv == "1" {
  1997. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1998. }
  1999. if item.ChrgitmLv == "2" {
  2000. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2001. }
  2002. if item.ChrgitmLv == "3" {
  2003. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2004. }
  2005. }
  2006. if item.MedChrgitmType == "08" { //材料费
  2007. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2008. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2009. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2010. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2011. if item.ChrgitmLv == "1" {
  2012. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2013. }
  2014. if item.ChrgitmLv == "2" {
  2015. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2016. }
  2017. if item.ChrgitmLv == "3" {
  2018. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2019. }
  2020. }
  2021. if item.MedChrgitmType == "09" { //西药费
  2022. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2023. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2024. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2025. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2026. if item.ChrgitmLv == "1" {
  2027. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2028. }
  2029. if item.ChrgitmLv == "2" {
  2030. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2031. }
  2032. if item.ChrgitmLv == "3" {
  2033. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2034. }
  2035. }
  2036. if item.MedChrgitmType == "10" { //中药饮片
  2037. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2038. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2039. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2040. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2041. if item.ChrgitmLv == "1" {
  2042. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2043. }
  2044. if item.ChrgitmLv == "2" {
  2045. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2046. }
  2047. if item.ChrgitmLv == "3" {
  2048. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2049. }
  2050. }
  2051. if item.MedChrgitmType == "11" { //中成费
  2052. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2053. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2054. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2055. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2056. if item.ChrgitmLv == "1" {
  2057. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2058. }
  2059. if item.ChrgitmLv == "2" {
  2060. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2061. }
  2062. if item.ChrgitmLv == "3" {
  2063. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2064. }
  2065. }
  2066. if item.MedChrgitmType == "12" { //中成费
  2067. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2068. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2069. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2070. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2071. if item.ChrgitmLv == "1" {
  2072. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2073. }
  2074. if item.ChrgitmLv == "2" {
  2075. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2076. }
  2077. if item.ChrgitmLv == "3" {
  2078. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2079. }
  2080. }
  2081. if item.MedChrgitmType == "13" { //中成费
  2082. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2083. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2084. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2085. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2086. if item.ChrgitmLv == "1" {
  2087. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2088. }
  2089. if item.ChrgitmLv == "2" {
  2090. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2091. }
  2092. if item.ChrgitmLv == "3" {
  2093. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2094. }
  2095. }
  2096. if item.MedChrgitmType == "14" { //其他费
  2097. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2098. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2099. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2100. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2101. if item.ChrgitmLv == "1" {
  2102. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2103. }
  2104. if item.ChrgitmLv == "2" {
  2105. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2106. }
  2107. if item.ChrgitmLv == "3" {
  2108. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2109. }
  2110. }
  2111. }
  2112. var iteminfoStructs []service.IteminfoStruct
  2113. if bedCostTotal != 0 {
  2114. iteminfo.MedChrgitm = "01"
  2115. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2116. iteminfo.Amt = bedCostTotal
  2117. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2118. iteminfo.ClabAmt = bed_clab_amt
  2119. iteminfo.OthAmt = bed_other_amt
  2120. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2121. }
  2122. if examineCostTotal != 0 {
  2123. iteminfo.MedChrgitm = "02"
  2124. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2125. iteminfo.Amt = examineCostTotal
  2126. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2127. iteminfo.ClabAmt = examine_clab_amt
  2128. iteminfo.OthAmt = examine_other_amt
  2129. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2130. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2131. }
  2132. if checkCostTotal != 0 {
  2133. iteminfo.MedChrgitm = "03"
  2134. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2135. iteminfo.Amt = checkCostTotal
  2136. iteminfo.ClaaSumfee = check_claa_sunmfee
  2137. iteminfo.ClabAmt = check_clab_amt
  2138. iteminfo.OthAmt = check_other_amt
  2139. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2140. }
  2141. if laboratoryCostTotal != 0 {
  2142. iteminfo.MedChrgitm = "04"
  2143. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2144. iteminfo.Amt = laboratoryCostTotal
  2145. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2146. iteminfo.ClabAmt = laboratory_clab_amt
  2147. iteminfo.OthAmt = laboratory_other_amt
  2148. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2149. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2150. }
  2151. if treatCostTotal != 0 {
  2152. iteminfo.MedChrgitm = "05"
  2153. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2154. iteminfo.Amt = treatCostTotal
  2155. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2156. iteminfo.ClabAmt = treat_clab_amt
  2157. iteminfo.OthAmt = treat_other_amt
  2158. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2159. //(struct4101.IteminfoStruct, iteminfo)
  2160. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2161. }
  2162. if operationCostTotal != 0 {
  2163. iteminfo.MedChrgitm = "06"
  2164. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2165. iteminfo.Amt = operationCostTotal
  2166. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2167. iteminfo.ClabAmt = operation_clab_amt
  2168. iteminfo.OthAmt = operation_other_amt
  2169. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2170. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2171. }
  2172. if nursingCostTotal != 0 {
  2173. iteminfo.MedChrgitm = "07"
  2174. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2175. iteminfo.Amt = nursingCostTotal
  2176. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2177. iteminfo.ClabAmt = nursing_clab_amt
  2178. iteminfo.OthAmt = nursing_other_amt
  2179. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2180. }
  2181. if materialCostTotal != 0 {
  2182. iteminfo.MedChrgitm = "08"
  2183. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2184. iteminfo.Amt = materialCostTotal
  2185. iteminfo.ClaaSumfee = material_claa_sunmfee
  2186. iteminfo.ClabAmt = material_clab_amt
  2187. iteminfo.OthAmt = material_other_amt
  2188. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2189. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2190. }
  2191. if westernMedicineCostTotal != 0 {
  2192. iteminfo.MedChrgitm = "09"
  2193. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2194. iteminfo.Amt = westernMedicineCostTotal
  2195. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2196. iteminfo.ClabAmt = westernMedicine_clab_amt
  2197. iteminfo.OthAmt = westernMedicine_other_amt
  2198. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2199. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2200. }
  2201. if chineseMedicineCostTotal != 0 {
  2202. iteminfo.MedChrgitm = "10"
  2203. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2204. iteminfo.Amt = chineseMedicineCostTotal
  2205. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2206. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2207. iteminfo.OthAmt = chinese_medicine_other_amt
  2208. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2209. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2210. }
  2211. if chineseTraditionalMedicineCostTotal != 0 {
  2212. iteminfo.MedChrgitm = "11"
  2213. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2214. iteminfo.Amt = westernMedicineCostTotal
  2215. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2216. iteminfo.ClabAmt = westernMedicine_clab_amt
  2217. iteminfo.OthAmt = westernMedicine_other_amt
  2218. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2219. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2220. }
  2221. if commonlyTreatmentCostTotal != 0 {
  2222. iteminfo.MedChrgitm = "12"
  2223. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2224. iteminfo.Amt = commonlyTreatmentCostTotal
  2225. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2226. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2227. iteminfo.OthAmt = commonly_treatment_other_amt
  2228. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2229. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2230. }
  2231. if registerCostTotal != 0 {
  2232. iteminfo.MedChrgitm = "13"
  2233. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2234. iteminfo.Amt = registerCostTotal
  2235. iteminfo.ClaaSumfee = register_claa_sunmfee
  2236. iteminfo.ClabAmt = register_clab_amt
  2237. iteminfo.OthAmt = register_other_amt
  2238. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2239. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2240. }
  2241. if otherCostTotal != 0 {
  2242. iteminfo.MedChrgitm = "14"
  2243. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2244. iteminfo.Amt = otherCostTotal
  2245. iteminfo.ClaaSumfee = other_claa_sunmfee
  2246. iteminfo.ClabAmt = other_clab_amt
  2247. iteminfo.OthAmt = other_other_amt
  2248. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2249. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2250. }
  2251. struct4101.IteminfoStruct = iteminfoStructs
  2252. struct4101.Ntly = "中国"
  2253. struct4101.AdmCaty = "A03.06"
  2254. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  2255. fmt.Println(result)
  2256. var dat map[string]interface{}
  2257. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2258. fmt.Println(dat)
  2259. } else {
  2260. fmt.Println(err)
  2261. }
  2262. userJSONBytes, _ := json.Marshal(dat)
  2263. var res ResultSeventeen
  2264. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2265. utils.ErrorLog("解析失败:%v", err)
  2266. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2267. adminUser := c.GetAdminUserInfo()
  2268. errlog := &models.HisOrderError{
  2269. UserOrgId: adminUser.CurrentOrgId,
  2270. Ctime: time.Now().Unix(),
  2271. Mtime: time.Now().Unix(),
  2272. ErrMsg: res.ErrMsg + "解析失败",
  2273. Status: 1,
  2274. PatientId: order_id,
  2275. Stage: 10106,
  2276. }
  2277. service.CreateErrMsgLog(errlog)
  2278. continue
  2279. }
  2280. if res.Infcode != 0 {
  2281. adminUser := c.GetAdminUserInfo()
  2282. errlog := &models.HisOrderError{
  2283. UserOrgId: adminUser.CurrentOrgId,
  2284. Ctime: time.Now().Unix(),
  2285. Mtime: time.Now().Unix(),
  2286. ErrMsg: res.ErrMsg,
  2287. Status: 1,
  2288. PatientId: order_id,
  2289. Stage: 10106,
  2290. }
  2291. service.CreateErrMsgLog(errlog)
  2292. continue
  2293. } else {
  2294. hisFundSettleListResult := &models.HisFundSettleListResult{
  2295. Number: res.Output.SetlListId,
  2296. Status: 1,
  2297. Ctime: time.Now().Unix(),
  2298. Mtime: time.Now().Unix(),
  2299. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2300. IsUpload: 1,
  2301. OrderId: order_id,
  2302. }
  2303. service.CreateUploadRecord(hisFundSettleListResult)
  2304. continue
  2305. }
  2306. }
  2307. }
  2308. func (c *HisApiController) GetOrgInfo() {
  2309. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2310. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2311. }
  2312. func (c *HisApiController) GetHisPatientInfo() {
  2313. medical_insurance_card := c.GetString("medical_insurance_card")
  2314. id_card_type, _ := c.GetInt64("id_card_type")
  2315. id_card := c.GetString("id_card")
  2316. adminInfo := c.GetAdminUserInfo()
  2317. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2318. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2319. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2320. IdCardNo := ""
  2321. if id_card_type == 1 {
  2322. IdCardNo = medical_insurance_card
  2323. } else if id_card_type == 2 {
  2324. IdCardNo = id_card
  2325. }
  2326. if config.IsOpen == 1 {
  2327. 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
  2328. resp, requestErr := http.Get(api)
  2329. if requestErr != nil {
  2330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2331. return
  2332. }
  2333. defer resp.Body.Close()
  2334. body, ioErr := ioutil.ReadAll(resp.Body)
  2335. if ioErr != nil {
  2336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2338. return
  2339. }
  2340. var respJSON map[string]interface{}
  2341. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2344. return
  2345. }
  2346. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2347. userJSONBytes, _ := json.Marshal(userJSON)
  2348. var res ResultTwo
  2349. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2350. utils.ErrorLog("解析失败:%v", err)
  2351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2352. return
  2353. }
  2354. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2355. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2356. infoStr := string(Iinfos)
  2357. idetinfoStr := string(Idetinfos)
  2358. if res.Infcode == 0 {
  2359. his := models.VMHisPatient{
  2360. Status: 1,
  2361. Ctime: time.Now().Unix(),
  2362. Mtime: time.Now().Unix(),
  2363. PsnNo: res.Output.Baseinfo.PsnNo,
  2364. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2365. Certno: res.Output.Baseinfo.Certno,
  2366. PsnName: res.Output.Baseinfo.PsnName,
  2367. Gend: res.Output.Baseinfo.Gend,
  2368. Naty: res.Output.Baseinfo.Naty,
  2369. Brdy: res.Output.Baseinfo.Brdy,
  2370. Age: res.Output.Baseinfo.Age,
  2371. Iinfo: infoStr,
  2372. Idetinfo: idetinfoStr,
  2373. UserOrgId: adminInfo.CurrentOrgId,
  2374. IsReturn: 1,
  2375. IdCardType: id_card_type,
  2376. }
  2377. c.ServeSuccessJSON(map[string]interface{}{
  2378. "info": his,
  2379. })
  2380. } else {
  2381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2382. return
  2383. }
  2384. }
  2385. }
  2386. //func GetBasBaseInfo() (jsonStr string, err error) {
  2387. //
  2388. // handle := syscall.NewLazyDLL("SSCard.dll")
  2389. // add := handle.NewProc("ReadCardBas")
  2390. // str := make([]byte, 1024)
  2391. // str1 := make([]byte, 1024)
  2392. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2393. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  2394. //
  2395. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  2396. //
  2397. // fmt.Println("> Add(4,5)的结果为:", ret)
  2398. // handle.Release()
  2399. //
  2400. // return "", nil
  2401. //
  2402. //}
  2403. //func GetQRBaseInfo() (jsonStr string, err error) {
  2404. // handle := syscall.LoadDLL("SSCard.dll")
  2405. // ReadCardBas := handle.FindProc("GetQRBase")
  2406. //
  2407. // str := make([]byte, 256)
  2408. // str1 := make([]byte, 256)
  2409. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2410. //
  2411. // fmt.Println(string(str))
  2412. // fmt.Println(r)
  2413. // return string(str), nil
  2414. //}
  2415. //func CardInit() int {
  2416. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  2417. // add := DllTestDef.MustFindProc("Init")
  2418. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2419. // if err != nil {
  2420. // fmt.Println("SSCard的运算结果为:", ret)
  2421. // }
  2422. // result := int(ret)
  2423. // return result
  2424. //}
  2425. //func CardInit() int {
  2426. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2427. // if err != nil {
  2428. // fmt.Println("SSCard的运算结果为:", ret)
  2429. // }
  2430. // fmt.Println(err)
  2431. // result := int(ret)
  2432. // return result
  2433. //}
  2434. func IntPtr(n int) uintptr {
  2435. return uintptr(n)
  2436. }
  2437. func StrPtr(s string) uintptr {
  2438. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  2439. }
  2440. type Result2001 struct {
  2441. Cainfo interface{} `json:"cainfo"`
  2442. ErrMsg string `json:"err_msg"`
  2443. InfRefmsgid string `json:"inf_refmsgid"`
  2444. Infcode int64 `json:"infcode"`
  2445. Output struct {
  2446. Trtinfo struct {
  2447. PsnNo string `json:"psn_no"`
  2448. TrtChkType string `json:"trt_chk_type"`
  2449. FundPayType string `json:"fund_pay_type"`
  2450. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2451. Begndate string `json:"begndate"`
  2452. Enddate string `json:"enddate"`
  2453. TrtChkRslt string `json:"trt_chk_rslt"`
  2454. } `json:"trtinfo"`
  2455. } `json:"output"`
  2456. RefmsgTime string `json:"refmsg_time"`
  2457. RespondTime string `json:"respond_time"`
  2458. Signtype interface{} `json:"signtype"`
  2459. WarnMsg interface{} `json:"warn_msg"`
  2460. }
  2461. type Result2001Org10265 struct {
  2462. Cainfo interface{} `json:"cainfo"`
  2463. ErrMsg string `json:"err_msg"`
  2464. InfRefmsgid string `json:"inf_refmsgid"`
  2465. Infcode string `json:"infcode"`
  2466. Output struct {
  2467. Trtinfo struct {
  2468. PsnNo string `json:"psn_no"`
  2469. TrtChkType string `json:"trt_chk_type"`
  2470. FundPayType string `json:"fund_pay_type"`
  2471. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2472. Begndate string `json:"begndate"`
  2473. Enddate string `json:"enddate"`
  2474. TrtChkRslt string `json:"trt_chk_rslt"`
  2475. } `json:"trtinfo"`
  2476. } `json:"output"`
  2477. RefmsgTime string `json:"refmsg_time"`
  2478. RespondTime string `json:"respond_time"`
  2479. Signtype interface{} `json:"signtype"`
  2480. WarnMsg interface{} `json:"warn_msg"`
  2481. }
  2482. type ResultTwo struct {
  2483. ErrMsg string `json:"err_msg"`
  2484. InfRefmsgid string `json:"inf_refmsgid"`
  2485. Infcode int64 `json:"infcode"`
  2486. Output struct {
  2487. Baseinfo struct {
  2488. Age float64 `json:"age"`
  2489. Brdy string `json:"brdy"`
  2490. Certno string `json:"certno"`
  2491. Gend string `json:"gend"`
  2492. Naty string `json:"naty"`
  2493. PsnCertType string `json:"psn_cert_type"`
  2494. PsnName string `json:"psn_name"`
  2495. PsnNo string `json:"psn_no"`
  2496. } `json:"baseinfo"`
  2497. Idetinfo []interface{} `json:"idetinfo"`
  2498. Iinfo []struct {
  2499. Balc float64 `json:"balc"`
  2500. CvlservFlag string `json:"cvlserv_flag"`
  2501. EmpName string `json:"emp_name"`
  2502. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2503. Insutype string `json:"insutype"`
  2504. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2505. PausInsuDate string `json:"paus_insu_date"`
  2506. PsnInsuDate string `json:"psn_insu_date"`
  2507. PsnInsuStas string `json:"psn_insu_stas"`
  2508. PsnType string `json:"psn_type"`
  2509. } `json:"insuinfo"`
  2510. } `json:"output"`
  2511. RefmsgTime string `json:"refmsg_time"`
  2512. RespondTime string `json:"respond_time"`
  2513. Signtype interface{} `json:"signtype"`
  2514. WarnInfo interface{} `json:"warn_info"`
  2515. }
  2516. type ResultTwo10265 struct {
  2517. ErrMsg string `json:"err_msg"`
  2518. InfRefmsgid string `json:"inf_refmsgid"`
  2519. Infcode string `json:"infcode"`
  2520. Output struct {
  2521. Baseinfo struct {
  2522. Age float64 `json:"age"`
  2523. Brdy string `json:"brdy"`
  2524. Certno string `json:"certno"`
  2525. Gend string `json:"gend"`
  2526. Naty string `json:"naty"`
  2527. PsnCertType string `json:"psn_cert_type"`
  2528. PsnName string `json:"psn_name"`
  2529. PsnNo string `json:"psn_no"`
  2530. } `json:"baseinfo"`
  2531. Idetinfo []interface{} `json:"idetinfo"`
  2532. Iinfo []struct {
  2533. Balc float64 `json:"balc"`
  2534. CvlservFlag string `json:"cvlserv_flag"`
  2535. EmpName string `json:"emp_name"`
  2536. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2537. Insutype string `json:"insutype"`
  2538. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2539. PausInsuDate string `json:"paus_insu_date"`
  2540. PsnInsuDate string `json:"psn_insu_date"`
  2541. PsnInsuStas string `json:"psn_insu_stas"`
  2542. PsnType string `json:"psn_type"`
  2543. } `json:"insuinfo"`
  2544. } `json:"output"`
  2545. RefmsgTime string `json:"refmsg_time"`
  2546. RespondTime string `json:"respond_time"`
  2547. Signtype interface{} `json:"signtype"`
  2548. WarnInfo interface{} `json:"warn_info"`
  2549. }
  2550. type ResultThree struct {
  2551. Cainfo interface{} `json:"cainfo"`
  2552. ErrMsg string `json:"err_msg"`
  2553. InfRefmsgid string `json:"inf_refmsgid"`
  2554. Infcode int64 `json:"infcode"`
  2555. Output struct {
  2556. Data struct {
  2557. IptOtpNo string `json:"ipt_otp_no"`
  2558. MdtrtID string `json:"mdtrt_id"`
  2559. PsnNo string `json:"psn_no"`
  2560. } `json:"data"`
  2561. } `json:"output"`
  2562. RefmsgTime string `json:"refmsg_time"`
  2563. RespondTime string `json:"respond_time"`
  2564. Signtype interface{} `json:"signtype"`
  2565. WarnMsg interface{} `json:"warn_msg"`
  2566. }
  2567. type ResultThree10265 struct {
  2568. Cainfo interface{} `json:"cainfo"`
  2569. ErrMsg string `json:"err_msg"`
  2570. InfRefmsgid string `json:"inf_refmsgid"`
  2571. Infcode string `json:"infcode"`
  2572. Output struct {
  2573. Data struct {
  2574. IptOtpNo string `json:"ipt_otp_no"`
  2575. MdtrtID string `json:"mdtrt_id"`
  2576. PsnNo string `json:"psn_no"`
  2577. } `json:"data"`
  2578. } `json:"output"`
  2579. RefmsgTime string `json:"refmsg_time"`
  2580. RespondTime string `json:"respond_time"`
  2581. Signtype interface{} `json:"signtype"`
  2582. WarnMsg interface{} `json:"warn_msg"`
  2583. }
  2584. type ResultFour struct {
  2585. Cainfo string `json:"cainfo"`
  2586. ErrMsg string `json:"err_msg"`
  2587. InfRefmsgid string `json:"inf_refmsgid"`
  2588. Infcode int64 `json:"infcode"`
  2589. Output struct {
  2590. Result []struct {
  2591. BasMednFlag string `json:"bas_medn_flag"`
  2592. ChldMedcFlag string `json:"chld_medc_flag"`
  2593. ChrgitmLv string `json:"chrgitm_lv"`
  2594. Cnt float64 `json:"cnt"`
  2595. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2596. DrtReimFlag string `json:"drt_reim_flag"`
  2597. FeedetlSn string `json:"feedetl_sn"`
  2598. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2599. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2600. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2601. ListSpItemFlag string `json:"list_sp_item_flag"`
  2602. LmtUsedFlag string `json:"lmt_used_flag"`
  2603. MedChrgitmType string `json:"med_chrgitm_type"`
  2604. Memo string `json:"memo"`
  2605. OverlmtAmt float64 `json:"overlmt_amt"`
  2606. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2607. Pric float64 `json:"pric"`
  2608. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2609. SelfpayProp float64 `json:"selfpay_prop"`
  2610. } `json:"result"`
  2611. } `json:"output"`
  2612. RefmsgTime string `json:"refmsg_time"`
  2613. RespondTime string `json:"respond_time"`
  2614. Signtype string `json:"signtype"`
  2615. WarnMsg string `json:"warn_msg"`
  2616. }
  2617. type ResultFour10265 struct {
  2618. Cainfo string `json:"cainfo"`
  2619. ErrMsg string `json:"err_msg"`
  2620. InfRefmsgid string `json:"inf_refmsgid"`
  2621. Infcode string `json:"infcode"`
  2622. Output struct {
  2623. Result []struct {
  2624. BasMednFlag string `json:"bas_medn_flag"`
  2625. ChldMedcFlag string `json:"chld_medc_flag"`
  2626. ChrgitmLv string `json:"chrgitm_lv"`
  2627. Cnt float64 `json:"cnt"`
  2628. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2629. DrtReimFlag string `json:"drt_reim_flag"`
  2630. FeedetlSn string `json:"feedetl_sn"`
  2631. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2632. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2633. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2634. ListSpItemFlag string `json:"list_sp_item_flag"`
  2635. LmtUsedFlag string `json:"lmt_used_flag"`
  2636. MedChrgitmType string `json:"med_chrgitm_type"`
  2637. Memo string `json:"memo"`
  2638. OverlmtAmt float64 `json:"overlmt_amt"`
  2639. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2640. Pric float64 `json:"pric"`
  2641. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2642. SelfpayProp float64 `json:"selfpay_prop"`
  2643. } `json:"result"`
  2644. } `json:"output"`
  2645. RefmsgTime string `json:"refmsg_time"`
  2646. RespondTime string `json:"respond_time"`
  2647. Signtype string `json:"signtype"`
  2648. WarnMsg string `json:"warn_msg"`
  2649. }
  2650. type ResultFive struct {
  2651. Balc float64 `json:"balc"`
  2652. CvlservFlag string `json:"cvlserv_flag"`
  2653. EmpName string `json:"emp_name"`
  2654. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2655. Insutype string `json:"insutype"`
  2656. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2657. PausInsuDate string `json:"paus_insu_date"`
  2658. PsnInsuDate string `json:"psn_insu_date"`
  2659. PsnInsuStas string `json:"psn_insu_stas"`
  2660. PsnType string `json:"psn_type"`
  2661. }
  2662. type ResultSix struct {
  2663. Cainfo interface{} `json:"cainfo"`
  2664. ErrMsg string `json:"err_msg"`
  2665. InfRefmsgid string `json:"inf_refmsgid"`
  2666. Infcode int64 `json:"infcode"`
  2667. Output struct {
  2668. } `json:"output"`
  2669. RefmsgTime string `json:"refmsg_time"`
  2670. RespondTime string `json:"respond_time"`
  2671. Signtype interface{} `json:"signtype"`
  2672. WarnMsg interface{} `json:"warn_msg"`
  2673. }
  2674. type ResultSix10265 struct {
  2675. Cainfo interface{} `json:"cainfo"`
  2676. ErrMsg string `json:"err_msg"`
  2677. InfRefmsgid string `json:"inf_refmsgid"`
  2678. Infcode string `json:"infcode"`
  2679. Output struct {
  2680. } `json:"output"`
  2681. RefmsgTime string `json:"refmsg_time"`
  2682. RespondTime string `json:"respond_time"`
  2683. Signtype interface{} `json:"signtype"`
  2684. WarnMsg interface{} `json:"warn_msg"`
  2685. }
  2686. type ResultSeven struct {
  2687. Cainfo string `json:"cainfo"`
  2688. ErrMsg string `json:"err_msg"`
  2689. InfRefmsgid string `json:"inf_refmsgid"`
  2690. Infcode int64 `json:"infcode"`
  2691. Output struct {
  2692. Setldetail []interface{} `json:"setldetail"`
  2693. Setlinfo struct {
  2694. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2695. AcctPay float64 `json:"acct_pay"`
  2696. ActPayDedc float64 `json:"act_pay_dedc"`
  2697. Age float64 `json:"age"`
  2698. Balc float64 `json:"balc"`
  2699. Brdy string `json:"brdy"`
  2700. Certno string `json:"certno"`
  2701. ClrOptins string `json:"clr_optins"`
  2702. ClrType string `json:"clr_type"`
  2703. ClrWay string `json:"clr_way"`
  2704. CvlservFlag string `json:"cvlserv_flag"`
  2705. CvlservPay float64 `json:"cvlserv_pay"`
  2706. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2707. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2708. Gend string `json:"gend"`
  2709. HifesPay float64 `json:"hifes_pay"`
  2710. HifmiPay float64 `json:"hifmi_pay"`
  2711. HifpPay float64 `json:"hifp_pay"`
  2712. HospPartAmt float64 `json:"hosp_part_amt"`
  2713. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2714. Insutype string `json:"insutype"`
  2715. MafPay float64 `json:"maf_pay"`
  2716. MdtrtCertType string `json:"mdtrt_cert_type"`
  2717. HifobPay float64 `json:"hifob_pay"`
  2718. MdtrtID string `json:"mdtrt_id"`
  2719. MedType string `json:"med_type"`
  2720. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2721. MedinsSetlID string `json:"medins_setl_id"`
  2722. Naty string `json:"naty"`
  2723. OthPay float64 `json:"oth_pay"`
  2724. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2725. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2726. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2727. PsnCashPay float64 `json:"psn_cash_pay"`
  2728. PsnCertType string `json:"psn_cert_type"`
  2729. PsnName string `json:"psn_name"`
  2730. PsnNo string `json:"psn_no"`
  2731. PsnPartAmt float64 `json:"psn_part_amt"`
  2732. PsnType string `json:"psn_type"`
  2733. SetlID string `json:"setl_id"`
  2734. SetlTime string `json:"setl_time"`
  2735. } `json:"setlinfo"`
  2736. } `json:"output"`
  2737. RefmsgTime string `json:"refmsg_time"`
  2738. RespondTime string `json:"respond_time"`
  2739. Signtype interface{} `json:"signtype"`
  2740. WarnMsg interface{} `json:"warn_msg"`
  2741. }
  2742. type ResultSeven10265 struct {
  2743. Cainfo string `json:"cainfo"`
  2744. ErrMsg string `json:"err_msg"`
  2745. InfRefmsgid string `json:"inf_refmsgid"`
  2746. Infcode string `json:"infcode"`
  2747. Output struct {
  2748. Setldetail []interface{} `json:"setldetail"`
  2749. Setlinfo struct {
  2750. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2751. AcctPay float64 `json:"acct_pay"`
  2752. ActPayDedc float64 `json:"act_pay_dedc"`
  2753. Age float64 `json:"age"`
  2754. Balc float64 `json:"balc"`
  2755. Brdy string `json:"brdy"`
  2756. Certno string `json:"certno"`
  2757. ClrOptins string `json:"clr_optins"`
  2758. ClrType string `json:"clr_type"`
  2759. ClrWay string `json:"clr_way"`
  2760. CvlservFlag string `json:"cvlserv_flag"`
  2761. CvlservPay float64 `json:"cvlserv_pay"`
  2762. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2763. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2764. Gend string `json:"gend"`
  2765. HifesPay float64 `json:"hifes_pay"`
  2766. HifmiPay float64 `json:"hifmi_pay"`
  2767. HifpPay float64 `json:"hifp_pay"`
  2768. HospPartAmt float64 `json:"hosp_part_amt"`
  2769. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2770. Insutype string `json:"insutype"`
  2771. MafPay float64 `json:"maf_pay"`
  2772. MdtrtCertType string `json:"mdtrt_cert_type"`
  2773. HifobPay float64 `json:"hifob_pay"`
  2774. MdtrtID string `json:"mdtrt_id"`
  2775. MedType string `json:"med_type"`
  2776. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2777. MedinsSetlID string `json:"medins_setl_id"`
  2778. Naty string `json:"naty"`
  2779. OthPay float64 `json:"oth_pay"`
  2780. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2781. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2782. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2783. PsnCashPay float64 `json:"psn_cash_pay"`
  2784. PsnCertType string `json:"psn_cert_type"`
  2785. PsnName string `json:"psn_name"`
  2786. PsnNo string `json:"psn_no"`
  2787. PsnPartAmt float64 `json:"psn_part_amt"`
  2788. PsnType string `json:"psn_type"`
  2789. SetlID string `json:"setl_id"`
  2790. SetlTime string `json:"setl_time"`
  2791. } `json:"setlinfo"`
  2792. } `json:"output"`
  2793. RefmsgTime string `json:"refmsg_time"`
  2794. RespondTime string `json:"respond_time"`
  2795. Signtype interface{} `json:"signtype"`
  2796. WarnMsg interface{} `json:"warn_msg"`
  2797. }
  2798. type ResultEight struct {
  2799. Cainfo string `json:"cainfo"`
  2800. ErrMsg string `json:"err_msg"`
  2801. InfRefmsgid string `json:"inf_refmsgid"`
  2802. Infcode int64 `json:"infcode"`
  2803. Output struct {
  2804. Stmtinfo struct {
  2805. SetlOptins string `json:"setl_optins"`
  2806. StmtRslt string `json:"stmt_rslt"`
  2807. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2808. } `json:"stmtinfo"`
  2809. } `json:"output"`
  2810. RefmsgTime string `json:"refmsg_time"`
  2811. RespondTime string `json:"respond_time"`
  2812. Signtype interface{} `json:"signtype"`
  2813. WarnMsg interface{} `json:"warn_msg"`
  2814. }
  2815. type ResultEightFor10188 struct {
  2816. Cainfo string `json:"cainfo"`
  2817. ErrMsg string `json:"err_msg"`
  2818. InfRefmsgid string `json:"inf_refmsgid"`
  2819. Infcode string `json:"infcode"`
  2820. Output struct {
  2821. Stmtinfo struct {
  2822. SetlOptins string `json:"setl_optins"`
  2823. StmtRslt string `json:"stmt_rslt"`
  2824. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2825. } `json:"stmtinfo"`
  2826. } `json:"output"`
  2827. RefmsgTime string `json:"refmsg_time"`
  2828. RespondTime string `json:"respond_time"`
  2829. Signtype interface{} `json:"signtype"`
  2830. WarnMsg interface{} `json:"warn_msg"`
  2831. }
  2832. type ResultNine struct {
  2833. Cainfo string `json:"cainfo"`
  2834. ErrMsg string `json:"err_msg"`
  2835. InfRefmsgid string `json:"inf_refmsgid"`
  2836. Infcode int64 `json:"infcode"`
  2837. Output struct {
  2838. FileQuryNo string `json:"file_qury_no"`
  2839. } `json:"output"`
  2840. RefmsgTime string `json:"refmsg_time"`
  2841. RespondTime string `json:"respond_time"`
  2842. Signtype interface{} `json:"signtype"`
  2843. WarnMsg interface{} `json:"warn_msg"`
  2844. }
  2845. type ResultTen struct {
  2846. Cainfo string `json:"cainfo"`
  2847. ErrMsg string `json:"err_msg"`
  2848. InfRefmsgid string `json:"inf_refmsgid"`
  2849. Infcode int64 `json:"infcode"`
  2850. Output struct {
  2851. DldEndtime string `json:"dld_endtime"`
  2852. FileQuryNo string `json:"file_qury_no"`
  2853. Filename string `json:"filename"`
  2854. } `json:"output"`
  2855. RefmsgTime string `json:"refmsg_time"`
  2856. RespondTime string `json:"respond_time"`
  2857. Signtype interface{} `json:"signtype"`
  2858. WarnMsg interface{} `json:"warn_msg"`
  2859. }
  2860. //type Autogenerated struct {
  2861. // Output struct {
  2862. // Setlinfo struct {
  2863. // SetlTime string `json:"setl_time"`
  2864. // CvlservPay float64 `json:"cvlserv_pay"`
  2865. // Year string `json:"year"`
  2866. // MedType string `json:"med_type"`
  2867. // PsnPay float64 `json:"psn_pay"`
  2868. // OpterID string `json:"opter_id"`
  2869. // Begndate string `json:"begndate"`
  2870. // FlxempeFlag string `json:"flxempe_flag"`
  2871. // HifmiPay float64 `json:"hifmi_pay"`
  2872. // PsnNo string `json:"psn_no"`
  2873. // ActPayDedc float64 `json:"act_pay_dedc"`
  2874. // MedinsSetlID interface{} `json:"medins_setl_id"`
  2875. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2876. // ClrWay string `json:"clr_way"`
  2877. // OthPay float64 `json:"oth_pay"`
  2878. // Gend string `json:"gend"`
  2879. // MdtrtID string `json:"mdtrt_id"`
  2880. // AcctPay float64 `json:"acct_pay"`
  2881. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  2882. // Insutype string `json:"insutype"`
  2883. // Invono interface{} `json:"invono"`
  2884. // Enddate string `json:"enddate"`
  2885. // CashPayamt float64 `json:"cash_payamt"`
  2886. // PsnType string `json:"psn_type"`
  2887. // FixmedinsName string `json:"fixmedins_name"`
  2888. // HifpPay float64 `json:"hifp_pay"`
  2889. // NewFlag interface{} `json:"new_flag"`
  2890. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2891. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  2892. // PayLoc string `json:"pay_loc"`
  2893. // ClrType string `json:"clr_type"`
  2894. // RefdSetlFlag string `json:"refd_setl_flag"`
  2895. // CvlservFlag string `json:"cvlserv_flag"`
  2896. // EmpName string `json:"emp_name"`
  2897. // Brdy string `json:"brdy"`
  2898. // Naty string `json:"naty"`
  2899. // Certno string `json:"certno"`
  2900. // DiseCode string `json:"dise_code"`
  2901. // FixmedinsCode string `json:"fixmedins_code"`
  2902. // DedcHospLv string `json:"dedc_hosp_lv"`
  2903. // OpterName string `json:"opter_name"`
  2904. // Balc float64 `json:"balc"`
  2905. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2906. // PsnCertType string `json:"psn_cert_type"`
  2907. // HifobPay float64 `json:"hifob_pay"`
  2908. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  2909. // HifesPay float64 `json:"hifes_pay"`
  2910. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2911. // OptTime string `json:"opt_time"`
  2912. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2913. // SetlID string `json:"setl_id"`
  2914. // MafPay float64 `json:"maf_pay"`
  2915. // PsnName string `json:"psn_name"`
  2916. // InsuOptins interface{} `json:"insu_optins"`
  2917. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2918. // ClrOptins string `json:"clr_optins"`
  2919. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2920. // DiseName string `json:"dise_name"`
  2921. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2922. // Age float64 `json:"age"`
  2923. // DtrtCertType string `json:"dtrt_cert_type"`
  2924. // HospLv string `json:"hosp_lv"`
  2925. // } `json:"setlinfo"`
  2926. // Setldetail []struct {
  2927. // FundPayType string `json:"fund_pay_type"`
  2928. // FundPayamt float64 `json:"fund_payamt"`
  2929. // SetlProcInfo interface{} `json:"setl_proc_info"`
  2930. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  2931. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  2932. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  2933. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2934. // } `json:"setldetail"`
  2935. // } `json:"output"`
  2936. // Infcode int `json:"infcode"`
  2937. // WarnMsg interface{} `json:"warn_msg"`
  2938. // Cainfo interface{} `json:"cainfo"`
  2939. // ErrMsg interface{} `json:"err_msg"`
  2940. // RefmsgTime string `json:"refmsg_time"`
  2941. // Signtype interface{} `json:"signtype"`
  2942. // RespondTime string `json:"respond_time"`
  2943. // InfRefmsgid string `json:"inf_refmsgid"`
  2944. //}
  2945. type ResultEleven struct {
  2946. Cainfo string `json:"cainfo"`
  2947. ErrMsg string `json:"err_msg"`
  2948. InfRefmsgid string `json:"inf_refmsgid"`
  2949. Infcode int64 `json:"infcode"`
  2950. Output struct {
  2951. Setlinfo struct {
  2952. SetlTime string `json:"setl_time"`
  2953. CvlservPay float64 `json:"cvlserv_pay"`
  2954. Year string `json:"year"`
  2955. MedType string `json:"med_type"`
  2956. PsnPay float64 `json:"psn_pay"`
  2957. OpterID string `json:"opter_id"`
  2958. Begndate string `json:"begndate"`
  2959. FlxempeFlag string `json:"flxempe_flag"`
  2960. HifmiPay float64 `json:"hifmi_pay"`
  2961. PsnNo string `json:"psn_no"`
  2962. ActPayDedc float64 `json:"act_pay_dedc"`
  2963. MedinsSetlID interface{} `json:"medins_setl_id"`
  2964. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2965. ClrWay string `json:"clr_way"`
  2966. OthPay float64 `json:"oth_pay"`
  2967. Gend string `json:"gend"`
  2968. MdtrtID string `json:"mdtrt_id"`
  2969. AcctPay float64 `json:"acct_pay"`
  2970. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2971. Insutype string `json:"insutype"`
  2972. Invono interface{} `json:"invono"`
  2973. Enddate string `json:"enddate"`
  2974. CashPayamt float64 `json:"cash_payamt"`
  2975. PsnType string `json:"psn_type"`
  2976. FixmedinsName string `json:"fixmedins_name"`
  2977. HifpPay float64 `json:"hifp_pay"`
  2978. NewFlag interface{} `json:"new_flag"`
  2979. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2980. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2981. PayLoc string `json:"pay_loc"`
  2982. ClrType string `json:"clr_type"`
  2983. RefdSetlFlag string `json:"refd_setl_flag"`
  2984. CvlservFlag string `json:"cvlserv_flag"`
  2985. EmpName string `json:"emp_name"`
  2986. Brdy string `json:"brdy"`
  2987. Naty string `json:"naty"`
  2988. Certno string `json:"certno"`
  2989. DiseCode string `json:"dise_code"`
  2990. FixmedinsCode string `json:"fixmedins_code"`
  2991. DedcHospLv string `json:"dedc_hosp_lv"`
  2992. OpterName string `json:"opter_name"`
  2993. Balc float64 `json:"balc"`
  2994. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2995. PsnCertType string `json:"psn_cert_type"`
  2996. HifobPay float64 `json:"hifob_pay"`
  2997. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2998. HifesPay float64 `json:"hifes_pay"`
  2999. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3000. OptTime string `json:"opt_time"`
  3001. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3002. SetlID string `json:"setl_id"`
  3003. MafPay float64 `json:"maf_pay"`
  3004. PsnName string `json:"psn_name"`
  3005. InsuOptins interface{} `json:"insu_optins"`
  3006. PrefFundPay interface{} `json:"pref_fund_pay"`
  3007. ClrOptins string `json:"clr_optins"`
  3008. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3009. DiseName string `json:"dise_name"`
  3010. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3011. Age float64 `json:"age"`
  3012. DtrtCertType string `json:"dtrt_cert_type"`
  3013. HospLv string `json:"hosp_lv"`
  3014. } `json:"setlinfo"`
  3015. } `json:"output"`
  3016. RefmsgTime string `json:"refmsg_time"`
  3017. RespondTime string `json:"respond_time"`
  3018. Signtype interface{} `json:"signtype"`
  3019. WarnMsg interface{} `json:"warn_msg"`
  3020. }
  3021. type ResultEleven10265 struct {
  3022. Cainfo string `json:"cainfo"`
  3023. ErrMsg string `json:"err_msg"`
  3024. InfRefmsgid string `json:"inf_refmsgid"`
  3025. Infcode string `json:"infcode"`
  3026. Output struct {
  3027. Setlinfo struct {
  3028. SetlTime string `json:"setl_time"`
  3029. CvlservPay float64 `json:"cvlserv_pay"`
  3030. Year string `json:"year"`
  3031. MedType string `json:"med_type"`
  3032. PsnPay float64 `json:"psn_pay"`
  3033. OpterID string `json:"opter_id"`
  3034. Begndate string `json:"begndate"`
  3035. FlxempeFlag string `json:"flxempe_flag"`
  3036. HifmiPay float64 `json:"hifmi_pay"`
  3037. PsnNo string `json:"psn_no"`
  3038. ActPayDedc float64 `json:"act_pay_dedc"`
  3039. MedinsSetlID interface{} `json:"medins_setl_id"`
  3040. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3041. ClrWay string `json:"clr_way"`
  3042. OthPay float64 `json:"oth_pay"`
  3043. Gend string `json:"gend"`
  3044. MdtrtID string `json:"mdtrt_id"`
  3045. AcctPay float64 `json:"acct_pay"`
  3046. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3047. Insutype string `json:"insutype"`
  3048. Invono interface{} `json:"invono"`
  3049. Enddate string `json:"enddate"`
  3050. CashPayamt float64 `json:"cash_payamt"`
  3051. PsnType string `json:"psn_type"`
  3052. FixmedinsName string `json:"fixmedins_name"`
  3053. HifpPay float64 `json:"hifp_pay"`
  3054. NewFlag interface{} `json:"new_flag"`
  3055. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3056. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3057. PayLoc string `json:"pay_loc"`
  3058. ClrType string `json:"clr_type"`
  3059. RefdSetlFlag string `json:"refd_setl_flag"`
  3060. CvlservFlag string `json:"cvlserv_flag"`
  3061. EmpName string `json:"emp_name"`
  3062. Brdy string `json:"brdy"`
  3063. Naty string `json:"naty"`
  3064. Certno string `json:"certno"`
  3065. DiseCode string `json:"dise_code"`
  3066. FixmedinsCode string `json:"fixmedins_code"`
  3067. DedcHospLv string `json:"dedc_hosp_lv"`
  3068. OpterName string `json:"opter_name"`
  3069. Balc float64 `json:"balc"`
  3070. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3071. PsnCertType string `json:"psn_cert_type"`
  3072. HifobPay float64 `json:"hifob_pay"`
  3073. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3074. HifesPay float64 `json:"hifes_pay"`
  3075. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3076. OptTime string `json:"opt_time"`
  3077. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3078. SetlID string `json:"setl_id"`
  3079. MafPay float64 `json:"maf_pay"`
  3080. PsnName string `json:"psn_name"`
  3081. InsuOptins interface{} `json:"insu_optins"`
  3082. PrefFundPay interface{} `json:"pref_fund_pay"`
  3083. ClrOptins string `json:"clr_optins"`
  3084. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3085. DiseName string `json:"dise_name"`
  3086. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3087. Age float64 `json:"age"`
  3088. DtrtCertType string `json:"dtrt_cert_type"`
  3089. HospLv string `json:"hosp_lv"`
  3090. } `json:"setlinfo"`
  3091. } `json:"output"`
  3092. RefmsgTime string `json:"refmsg_time"`
  3093. RespondTime string `json:"respond_time"`
  3094. Signtype interface{} `json:"signtype"`
  3095. WarnMsg interface{} `json:"warn_msg"`
  3096. }
  3097. type ResultTwelve struct {
  3098. Cainfo string `json:"cainfo"`
  3099. ErrMsg string `json:"err_msg"`
  3100. InfRefmsgid string `json:"inf_refmsgid"`
  3101. Infcode int64 `json:"infcode"`
  3102. Output struct {
  3103. MdtrtId string `json:"mdtrt_id"`
  3104. ChrgBchno string `json:"chrg_bchno"`
  3105. PsnNo string `json:"psn_no"`
  3106. } `json:"output"`
  3107. RefmsgTime string `json:"refmsg_time"`
  3108. RespondTime string `json:"respond_time"`
  3109. Signtype interface{} `json:"signtype"`
  3110. WarnMsg interface{} `json:"warn_msg"`
  3111. }
  3112. type ResultThirteen struct {
  3113. ErrMsg string `json:"err_msg"`
  3114. InfRefmsgid string `json:"inf_refmsgid"`
  3115. Infcode int64 `json:"infcode"`
  3116. Output struct {
  3117. Result struct {
  3118. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3119. } `json:"result"`
  3120. } `json:"output"`
  3121. RefmsgTime string `json:"refmsg_time"`
  3122. RespondTime string `json:"respond_time"`
  3123. Signtype interface{} `json:"signtype"`
  3124. WarnInfo interface{} `json:"warn_info"`
  3125. }
  3126. type ResultThirteen10265 struct {
  3127. ErrMsg string `json:"err_msg"`
  3128. InfRefmsgid string `json:"inf_refmsgid"`
  3129. Infcode string `json:"infcode"`
  3130. Output struct {
  3131. Result struct {
  3132. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3133. } `json:"result"`
  3134. } `json:"output"`
  3135. RefmsgTime string `json:"refmsg_time"`
  3136. RespondTime string `json:"respond_time"`
  3137. Signtype interface{} `json:"signtype"`
  3138. WarnInfo interface{} `json:"warn_info"`
  3139. }
  3140. type ResultFourteen struct {
  3141. ErrMsg string `json:"err_msg"`
  3142. InfRefmsgid string `json:"inf_refmsgid"`
  3143. Infcode int64 `json:"infcode"`
  3144. Output struct {
  3145. } `json:"output"`
  3146. RefmsgTime string `json:"refmsg_time"`
  3147. RespondTime string `json:"respond_time"`
  3148. Signtype interface{} `json:"signtype"`
  3149. WarnInfo interface{} `json:"warn_info"`
  3150. }
  3151. type ResultFourteen10265 struct {
  3152. ErrMsg string `json:"err_msg"`
  3153. InfRefmsgid string `json:"inf_refmsgid"`
  3154. Infcode string `json:"infcode"`
  3155. Output struct {
  3156. } `json:"output"`
  3157. RefmsgTime string `json:"refmsg_time"`
  3158. RespondTime string `json:"respond_time"`
  3159. Signtype interface{} `json:"signtype"`
  3160. WarnInfo interface{} `json:"warn_info"`
  3161. }
  3162. type ResultSixteen struct {
  3163. Cainfo string `json:"cainfo"`
  3164. ErrMsg string `json:"err_msg"`
  3165. InfRefmsgid string `json:"inf_refmsgid"`
  3166. Infcode int64 `json:"infcode"`
  3167. Output struct {
  3168. Setldetail []interface{} `json:"setldetail"`
  3169. Setlinfo struct {
  3170. MdtrtID string `json:"mdtrt_id"`
  3171. SetlID string `json:"setl_id"`
  3172. ClrOptins string `json:"clr_optins"`
  3173. SetlTime string `json:"setl_time"`
  3174. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3175. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3176. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3177. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3178. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3179. ActPayDedc float64 `json:"act_pay_dedc"`
  3180. HifpPay float64 `json:"hifp_pay"`
  3181. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3182. Lfpay float64 `json:"selfpay"`
  3183. CvlservPay float64 `json:"cvlserv_pay"`
  3184. HifesPay float64 `json:"hifes_pay"`
  3185. HifmiPay float64 `json:"hifmi_pay"`
  3186. HifobPay float64 `json:"hifob_pay"`
  3187. MafPay float64 `json:"maf_pay"`
  3188. OthPay float64 `json:"oth_pay"`
  3189. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3190. PsnPartAmt float64 `json:"psn_part_amt"`
  3191. AcctPay float64 `json:"acct_pay"`
  3192. Balc float64 `json:"balc"`
  3193. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3194. HospPartAmt float64 `json:"hosp_part_amt"`
  3195. MedinsSetlID string `json:"medins_setl_id"`
  3196. PdnCashPay string `json:"pdn_cash_pay"`
  3197. } `json:"setlinfo"`
  3198. } `json:"output"`
  3199. RefmsgTime string `json:"refmsg_time"`
  3200. RespondTime string `json:"respond_time"`
  3201. Signtype interface{} `json:"signtype"`
  3202. WarnMsg interface{} `json:"warn_msg"`
  3203. }
  3204. type ResultSixteen10265 struct {
  3205. Cainfo string `json:"cainfo"`
  3206. ErrMsg string `json:"err_msg"`
  3207. InfRefmsgid string `json:"inf_refmsgid"`
  3208. Infcode string `json:"infcode"`
  3209. Output struct {
  3210. Setldetail []interface{} `json:"setldetail"`
  3211. Setlinfo struct {
  3212. MdtrtID string `json:"mdtrt_id"`
  3213. SetlID string `json:"setl_id"`
  3214. ClrOptins string `json:"clr_optins"`
  3215. SetlTime string `json:"setl_time"`
  3216. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3217. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3218. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3219. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3220. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3221. ActPayDedc float64 `json:"act_pay_dedc"`
  3222. HifpPay float64 `json:"hifp_pay"`
  3223. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3224. Lfpay float64 `json:"selfpay"`
  3225. CvlservPay float64 `json:"cvlserv_pay"`
  3226. HifesPay float64 `json:"hifes_pay"`
  3227. HifmiPay float64 `json:"hifmi_pay"`
  3228. HifobPay float64 `json:"hifob_pay"`
  3229. MafPay float64 `json:"maf_pay"`
  3230. OthPay float64 `json:"oth_pay"`
  3231. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3232. PsnPartAmt float64 `json:"psn_part_amt"`
  3233. AcctPay float64 `json:"acct_pay"`
  3234. Balc float64 `json:"balc"`
  3235. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3236. HospPartAmt float64 `json:"hosp_part_amt"`
  3237. MedinsSetlID string `json:"medins_setl_id"`
  3238. PdnCashPay string `json:"pdn_cash_pay"`
  3239. } `json:"setlinfo"`
  3240. } `json:"output"`
  3241. RefmsgTime string `json:"refmsg_time"`
  3242. RespondTime string `json:"respond_time"`
  3243. Signtype interface{} `json:"signtype"`
  3244. WarnMsg interface{} `json:"warn_msg"`
  3245. }
  3246. type ResultSeventeen struct {
  3247. ErrMsg string `json:"err_msg"`
  3248. InfRefmsgid string `json:"inf_refmsgid"`
  3249. Infcode int64 `json:"infcode"`
  3250. Output struct {
  3251. SetlListId string `json:"setl_list_id"`
  3252. } `json:"output"`
  3253. RefmsgTime string `json:"refmsg_time"`
  3254. RespondTime string `json:"respond_time"`
  3255. Signtype string `json:"signtype"`
  3256. WarnInfo string `json:"warn_info"`
  3257. }
  3258. type Result90991 struct {
  3259. ErrMsg string `json:"err_msg"`
  3260. InfRefmsgid string `json:"inf_refmsgid"`
  3261. Infcode int64 `json:"infcode"`
  3262. Output struct {
  3263. Result struct {
  3264. PsnNo string `json:"psn_no"`
  3265. CardStat string `json:"card_stat"`
  3266. Certno string `json:"certno"`
  3267. PsnName string `json:"psn_name"`
  3268. CheckStat string `json:"check_stat"`
  3269. } `json:"result"`
  3270. } `json:"output"`
  3271. RefmsgTime string `json:"refmsg_time"`
  3272. RespondTime string `json:"respond_time"`
  3273. Signtype interface{} `json:"signtype"`
  3274. WarnInfo interface{} `json:"warn_info"`
  3275. }
  3276. type Result90100 struct {
  3277. ErrMsg string `json:"err_msg"`
  3278. InfRefmsgid string `json:"inf_refmsgid"`
  3279. Infcode int64 `json:"infcode"`
  3280. Output struct {
  3281. PoolareaNo string `json:"poolarea_no"`
  3282. PoolareaNoName string `json:"poolarea_no_name"`
  3283. Insutype string `json:"insutype"`
  3284. InsutypeName string `json:"insutype_name"`
  3285. ClctType string `json:"clct_type"`
  3286. ClctTypeName string `json:"clct_type_name"`
  3287. ClctFlag string `json:"clct_flag"`
  3288. ClctFlagName string `json:"clct_flag_name"`
  3289. AccrymBegn string `json:"accrym_begn"`
  3290. AccrymEnd string `json:"accrym_end"`
  3291. ClctTime string `json:"clct_time"`
  3292. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3293. } `json:"output"`
  3294. RefmsgTime string `json:"refmsg_time"`
  3295. RespondTime string `json:"respond_time"`
  3296. Signtype interface{} `json:"signtype"`
  3297. WarnInfo interface{} `json:"warn_info"`
  3298. }
  3299. type Custom struct {
  3300. DetItemFeeSumamt string
  3301. Cut string
  3302. FeedetlSn string
  3303. Price string
  3304. MedListCodg string
  3305. Type int64
  3306. AdviceId int64
  3307. ProjectId int64
  3308. ItemId int64
  3309. }
  3310. type Result5301 struct {
  3311. ErrMsg string `json:"err_msg"`
  3312. InfRefmsgid string `json:"inf_refmsgid"`
  3313. Infcode int64 `json:"infcode"`
  3314. Output struct {
  3315. Result []struct {
  3316. OpspDiseCode string `json:"opsp_dise_code"`
  3317. OpspDiseName string `json:"opsp_dise_name"`
  3318. Begndate string `json:"begndate"`
  3319. Enddate string `json:"enddate"`
  3320. } `json:"feedetail"`
  3321. } `json:"output"`
  3322. RefmsgTime string `json:"refmsg_time"`
  3323. RespondTime string `json:"respond_time"`
  3324. Signtype interface{} `json:"signtype"`
  3325. WarnInfo interface{} `json:"warn_info"`
  3326. }
  3327. type Result5301For10265 struct {
  3328. ErrMsg string `json:"err_msg"`
  3329. InfRefmsgid string `json:"inf_refmsgid"`
  3330. Infcode string `json:"infcode"`
  3331. Output struct {
  3332. Result []struct {
  3333. OpspDiseCode string `json:"opsp_dise_code"`
  3334. OpspDiseName string `json:"opsp_dise_name"`
  3335. Begndate string `json:"begndate"`
  3336. Enddate string `json:"enddate"`
  3337. } `json:"feedetail"`
  3338. } `json:"output"`
  3339. RefmsgTime string `json:"refmsg_time"`
  3340. RespondTime string `json:"respond_time"`
  3341. Signtype interface{} `json:"signtype"`
  3342. WarnInfo interface{} `json:"warn_info"`
  3343. }
  3344. //获取个人信息----挂号-----上传就诊信息
  3345. func (c *HisApiController) GetRegisterInfo() {
  3346. id, _ := c.GetInt64("id")
  3347. record_time := c.GetString("record_time")
  3348. settlementValue, _ := c.GetInt64("settlement_value")
  3349. medical_insurance_card := c.GetString("medical_insurance_card")
  3350. name := c.GetString("name")
  3351. id_card_type, _ := c.GetInt64("id_card_type")
  3352. certificates, _ := c.GetInt64("certificates")
  3353. medical_care, _ := c.GetInt64("medical_care")
  3354. birthday := c.GetString("birthday")
  3355. id_card := c.GetString("id_card")
  3356. register_type, _ := c.GetInt64("register")
  3357. doctor, _ := c.GetInt64("doctor")
  3358. department, _ := c.GetInt64("department")
  3359. gender, _ := c.GetInt64("sex")
  3360. registration_fee, _ := c.GetFloat("registration_fee")
  3361. medical_expenses, _ := c.GetFloat("medical_expenses")
  3362. social_type, _ := c.GetInt64("social_type")
  3363. med_type := c.GetString("social_type")
  3364. admin_user_id, _ := c.GetInt64("admin_user_id")
  3365. insuplc_admdvs := c.GetString("insuplc_admdvs")
  3366. timeLayout := "2006-01-02"
  3367. loc, _ := time.LoadLocation("Local")
  3368. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  3369. birthUnix := birthdays.Unix()
  3370. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3371. if err != nil {
  3372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3373. return
  3374. }
  3375. recordDateTime := theTime.Unix()
  3376. adminInfo := c.GetAdminUserInfo()
  3377. var patient service.Patients
  3378. if id == 0 {
  3379. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  3380. } else {
  3381. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  3382. }
  3383. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3384. if patientPrescription.ID == 0 {
  3385. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3386. }
  3387. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3388. if patient.ID == 0 {
  3389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3390. return
  3391. }
  3392. if len(patient.IdCardNo) == 0 {
  3393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3394. return
  3395. }
  3396. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3397. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  3398. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  3399. //就诊结算未完成,不能进行二次挂号
  3400. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  3401. if len(his) >= 1 {
  3402. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  3403. if len(his) >= 1 && order.ID == 0 {
  3404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  3405. return
  3406. }
  3407. }
  3408. //var register_log string
  3409. if config.IsOpen == 1 {
  3410. var res ResultTwo
  3411. var res10265 ResultTwo10265
  3412. var PsnNo string
  3413. var PsnCertType string
  3414. var Certno string
  3415. var PsnName string
  3416. var Gend string
  3417. var Naty string
  3418. var Brdy string
  3419. var Age float64
  3420. var infoStr string
  3421. var idetinfoStr string
  3422. var infocode int64
  3423. var verify_number string
  3424. fmt.Println(verify_number)
  3425. if miConfig.MdtrtareaAdmvs == "421300" {
  3426. psn_info, _ := service.GetPsnByPatientId(id)
  3427. PsnNo = psn_info.PsnNo
  3428. PsnCertType = psn_info.PsnCertType
  3429. Certno = psn_info.Certno
  3430. PsnName = psn_info.PsnName
  3431. Gend = psn_info.Gend
  3432. Naty = psn_info.Naty
  3433. Brdy = psn_info.Brdy
  3434. Age = psn_info.Age
  3435. infoStr = psn_info.Insuinfo
  3436. idetinfoStr = psn_info.Idetinfo
  3437. infocode = 0
  3438. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3439. psn_info, _ := service.GetPsnByPatientId(id)
  3440. PsnNo = psn_info.PsnNo
  3441. PsnCertType = psn_info.PsnCertType
  3442. Certno = psn_info.Certno
  3443. PsnName = psn_info.PsnName
  3444. Gend = psn_info.Gend
  3445. Naty = psn_info.Naty
  3446. Brdy = psn_info.Brdy
  3447. Age = psn_info.Age
  3448. infoStr = psn_info.Insuinfo
  3449. idetinfoStr = psn_info.Idetinfo
  3450. infocode = 0
  3451. verify_number = psn_info.VerifyNumber
  3452. } else {
  3453. var result string
  3454. var requestLog string
  3455. if miConfig.UserOrgId == 10138 {
  3456. 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)
  3457. } else {
  3458. 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)
  3459. }
  3460. saveLog(result, requestLog, "1101", "人员基本信息获取")
  3461. if miConfig.Code == "H15049901371" {
  3462. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3463. utils.ErrorLog("解析失败:%v", err)
  3464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3465. return
  3466. }
  3467. res.ErrMsg = res10265.ErrMsg
  3468. res.Output = res10265.Output
  3469. res.InfRefmsgid = res10265.InfRefmsgid
  3470. } else {
  3471. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3472. utils.ErrorLog("解析失败:%v", err)
  3473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3474. return
  3475. }
  3476. }
  3477. PsnNo = res.Output.Baseinfo.PsnNo
  3478. PsnCertType = res.Output.Baseinfo.PsnCertType
  3479. Certno = res.Output.Baseinfo.Certno
  3480. PsnName = res.Output.Baseinfo.PsnName
  3481. Gend = res.Output.Baseinfo.Gend
  3482. Naty = res.Output.Baseinfo.Naty
  3483. Brdy = res.Output.Baseinfo.Brdy
  3484. Age = res.Output.Baseinfo.Age
  3485. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3486. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3487. infoStr = string(Iinfos)
  3488. idetinfoStr = string(Idetinfos)
  3489. if miConfig.Code == "H15049901371" {
  3490. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  3491. } else {
  3492. infocode = res.Infcode
  3493. }
  3494. }
  3495. if infocode == 0 {
  3496. his := models.VMHisPatient{
  3497. Name: name,
  3498. Gender: gender,
  3499. Birthday: birthUnix,
  3500. MedicalTreatmentType: medical_care,
  3501. IdType: certificates,
  3502. IdCardNo: id_card,
  3503. BalanceAccountsType: settlementValue,
  3504. SocialType: social_type,
  3505. MedicalInsuranceNumber: medical_insurance_card,
  3506. RegisterType: register_type,
  3507. RegisterCost: registration_fee,
  3508. TreatmentCost: medical_expenses,
  3509. Status: 1,
  3510. Ctime: time.Now().Unix(),
  3511. Mtime: time.Now().Unix(),
  3512. PsnNo: PsnNo,
  3513. PsnCertType: PsnCertType,
  3514. Certno: Certno,
  3515. PsnName: PsnName,
  3516. Gend: Gend,
  3517. Naty: Naty,
  3518. Brdy: Brdy,
  3519. Age: Age,
  3520. Iinfo: infoStr,
  3521. Idetinfo: idetinfoStr,
  3522. PatientId: patient.ID,
  3523. RecordDate: theTime.Unix(),
  3524. UserOrgId: adminInfo.CurrentOrgId,
  3525. AdminUserId: admin_user_id,
  3526. IsReturn: 1,
  3527. IdCardType: id_card_type,
  3528. Doctor: doctor,
  3529. Departments: department,
  3530. }
  3531. timestamp := time.Now().Unix()
  3532. tempTime := time.Unix(timestamp, 0)
  3533. timeFormat := tempTime.Format("20060102150405")
  3534. chrgBchno := rand.Intn(100000) + 10000
  3535. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3536. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  3537. department, _ := service.GetDepartMentDetail(department)
  3538. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3539. IdCardNo := ""
  3540. if id_card_type == 1 {
  3541. // IdCardNo = medical_insurance_card
  3542. IdCardNo = patient.IdCardNo
  3543. } else {
  3544. IdCardNo = patient.IdCardNo
  3545. }
  3546. var rf []*ResultFive
  3547. json.Unmarshal([]byte(his.Iinfo), &rf)
  3548. var insutypes []*ResultFive
  3549. var insutype string
  3550. var insuplc_admdvs_temp string
  3551. var is390 int = 0
  3552. var is310 int = 0
  3553. for _, item := range rf {
  3554. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3555. insutypes = append(insutypes, item)
  3556. }
  3557. }
  3558. if len(insutypes) == 1 {
  3559. insutype = insutypes[0].Insutype
  3560. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3561. } else {
  3562. for _, i := range insutypes {
  3563. if i.Insutype == "390" {
  3564. is390 = 1
  3565. }
  3566. if i.Insutype == "310" {
  3567. is310 = 1
  3568. }
  3569. }
  3570. }
  3571. if is390 == 1 {
  3572. insutype = "390"
  3573. }
  3574. if is310 == 1 {
  3575. insutype = "310"
  3576. }
  3577. if len(insutypes) == 0 {
  3578. insutype = "310"
  3579. }
  3580. if len(insutypes) == 2 {
  3581. insutype = med_type
  3582. }
  3583. if len(med_type) > 0 {
  3584. insutype = med_type
  3585. }
  3586. //for _, item := range rf {
  3587. // if item.Insutype == insutype {
  3588. // insuplc_admdvs = item.InsuplcAdmdvs
  3589. // }
  3590. //}
  3591. var infocode int64
  3592. var resThree ResultThree
  3593. var resThree10265 ResultThree10265
  3594. if len(insuplc_admdvs) == 0 {
  3595. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  3596. } else {
  3597. insuplc_admdvs_temp = insuplc_admdvs
  3598. }
  3599. if miConfig.MdtrtareaAdmvs == "421300" {
  3600. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  3601. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3602. "&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
  3603. resp, requestErr := http.Get(api)
  3604. if requestErr != nil {
  3605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3606. return
  3607. }
  3608. body, ioErr := ioutil.ReadAll(resp.Body)
  3609. if ioErr != nil {
  3610. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3612. return
  3613. }
  3614. var respJSON map[string]interface{}
  3615. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3618. return
  3619. }
  3620. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3621. result, _ := json.Marshal(respJSON)
  3622. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3623. utils.ErrorLog("解析失败:%v", err)
  3624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3625. return
  3626. }
  3627. infocode = resThree.Infcode
  3628. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3629. psn_info, _ := service.GetPsnByPatientId(id)
  3630. bas := strings.Split(psn_info.CardInfo, "|")
  3631. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3632. var api string
  3633. if miConfig.MdtrtareaAdmvs == "320921" {
  3634. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3635. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3636. "&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
  3637. } else {
  3638. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3639. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3640. "&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
  3641. }
  3642. resp, requestErr := http.Get(api)
  3643. if requestErr != nil {
  3644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3645. return
  3646. }
  3647. body, ioErr := ioutil.ReadAll(resp.Body)
  3648. if ioErr != nil {
  3649. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3651. return
  3652. }
  3653. var respJSON map[string]interface{}
  3654. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3655. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3657. return
  3658. }
  3659. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3660. result, _ := json.Marshal(respJSON)
  3661. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3662. utils.ErrorLog("解析失败:%v", err)
  3663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3664. return
  3665. }
  3666. resThree.ErrMsg = resThree10265.ErrMsg
  3667. resThree.Output = resThree10265.Output
  3668. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3669. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3670. } else {
  3671. result, requestLog := service.Gdyb2201(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName)
  3672. saveLog(result, requestLog, "2201", "挂号")
  3673. if miConfig.Code == "H15049901371" {
  3674. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3675. utils.ErrorLog("解析失败:%v", err)
  3676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3677. return
  3678. }
  3679. resThree.ErrMsg = resThree10265.ErrMsg
  3680. resThree.Output = resThree10265.Output
  3681. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3682. } else {
  3683. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3684. utils.ErrorLog("解析失败:%v", err)
  3685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3686. return
  3687. }
  3688. }
  3689. if miConfig.Code == "H15049901371" {
  3690. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3691. } else {
  3692. infocode = resThree.Infcode
  3693. }
  3694. }
  3695. if infocode != 0 {
  3696. adminUser := c.GetAdminUserInfo()
  3697. errlog := &models.HisOrderError{
  3698. UserOrgId: adminUser.CurrentOrgId,
  3699. Ctime: time.Now().Unix(),
  3700. Mtime: time.Now().Unix(),
  3701. ErrMsg: resThree.ErrMsg,
  3702. Status: 1,
  3703. PatientId: id,
  3704. RecordTime: recordDateTime,
  3705. Stage: 2,
  3706. }
  3707. service.CreateErrMsgLog(errlog)
  3708. c.ServeSuccessJSON(map[string]interface{}{
  3709. "failed_code": -10,
  3710. "msg": resThree.ErrMsg,
  3711. })
  3712. return
  3713. }
  3714. his.Number = resThree.Output.Data.MdtrtID
  3715. his.PsnNo = resThree.Output.Data.PsnNo
  3716. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  3717. his.IdCardNo = patient.IdCardNo
  3718. his.PhoneNumber = patient.Phone
  3719. his.UserOrgId = adminInfo.CurrentOrgId
  3720. his.Insutype = insutype
  3721. his.Ctime = time.Now().Unix()
  3722. his.Mtime = time.Now().Unix()
  3723. his.InsuplcAdmdvs = insuplc_admdvs_temp
  3724. his.Status = 1
  3725. service.UpdateHisPatientStatus(&his)
  3726. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  3727. c.ServeSuccessJSON(map[string]interface{}{
  3728. "his_info": his,
  3729. })
  3730. } else {
  3731. adminUser := c.GetAdminUserInfo()
  3732. errlog := &models.HisOrderError{
  3733. UserOrgId: adminUser.CurrentOrgId,
  3734. Ctime: time.Now().Unix(),
  3735. Mtime: time.Now().Unix(),
  3736. ErrMsg: res.ErrMsg,
  3737. Status: 1,
  3738. PatientId: id,
  3739. RecordTime: recordDateTime,
  3740. Stage: 1,
  3741. }
  3742. service.CreateErrMsgLog(errlog)
  3743. c.ServeSuccessJSON(map[string]interface{}{
  3744. "failed_code": -10,
  3745. "msg": res.ErrMsg,
  3746. })
  3747. return
  3748. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3749. }
  3750. }
  3751. }
  3752. //上传明细----预结算----确认订单
  3753. func (c *HisApiController) GetUploadInfo() {
  3754. id, _ := c.GetInt64("id")
  3755. record_time := c.GetString("record_time")
  3756. his_patient_id, _ := c.GetInt64("his_patient_id")
  3757. order_id, _ := c.GetInt64("order_id")
  3758. pay_way, _ := c.GetInt64("pay_way")
  3759. pay_price, _ := c.GetFloat("pay_price")
  3760. pay_card_no := c.GetString("pay_card_no")
  3761. discount_price, _ := c.GetFloat("discount_price")
  3762. preferential_price, _ := c.GetFloat("preferential_price")
  3763. reality_price, _ := c.GetFloat("reality_price")
  3764. found_price, _ := c.GetFloat("found_price")
  3765. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3766. private_price, _ := c.GetFloat("private_price")
  3767. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3768. admin_user_id, _ := c.GetInt64("admin_user_id")
  3769. fapiao_code := c.GetString("fapiao_code")
  3770. fapiao_number := c.GetString("fapiao_number")
  3771. diagnosis_id := c.GetString("diagnosis")
  3772. sick_type, _ := c.GetInt64("sick_type")
  3773. reg_type, _ := c.GetInt64("p_type")
  3774. begin_time := c.GetString("begin_time")
  3775. id_str := c.GetString("ids")
  3776. ids_arr := strings.Split(id_str, ",")
  3777. timeLayout := "2006-01-02"
  3778. loc, _ := time.LoadLocation("Local")
  3779. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3780. if err != nil {
  3781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3782. return
  3783. }
  3784. recordDateTime := theTime.Unix()
  3785. adminUser := c.GetAdminUserInfo()
  3786. var tempOrder models.HisOrder
  3787. tempOrder, _ = service.GetHisOrderByID(order_id)
  3788. var prescriptions []*models.HisPrescription
  3789. var start_time int64
  3790. var end_time int64
  3791. //if adminUser.CurrentOrgId == 10106{
  3792. // if len(fapiao_code) == 0{
  3793. // fapiao_code = "144072080589"
  3794. // }
  3795. // if len(fapiao_number) == 0{
  3796. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3797. // if order.ID == 0{
  3798. // fapiao_number = "00001520"
  3799. // }else{
  3800. // //fapiao_code = "00001520"
  3801. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3802. // var zero string
  3803. // if fpNumber >= 1000{
  3804. // zero = "0000" + strconv.Itoa(fpNumber)
  3805. // }else if fpNumber >= 10000{
  3806. // zero = "000" + strconv.Itoa(fpNumber)
  3807. // } else if fpNumber >= 100000{
  3808. // zero = "00" + strconv.Itoa(fpNumber)
  3809. // } else if fpNumber >= 1000000{
  3810. // zero = "0" + strconv.Itoa(fpNumber)
  3811. // }else {
  3812. // zero = strconv.Itoa(fpNumber)
  3813. // }
  3814. // fapiao_number = zero
  3815. // }
  3816. // }
  3817. //}
  3818. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3819. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3820. var patientPrescription models.HisPrescriptionInfo
  3821. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3822. if patientPrescription.ID == 0 {
  3823. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3824. }
  3825. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3826. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3827. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3828. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3829. var config []*models.HisXtDiagnoseConfig
  3830. for _, item := range diagnosis_ids {
  3831. id, _ := strconv.ParseInt(item, 10, 64)
  3832. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3833. config = append(config, &diagnosisConfig)
  3834. }
  3835. sickConfig, _ := service.FindSickById(sick_type)
  3836. //if tempOrder.ID == 0 {
  3837. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3838. //}
  3839. if tempOrder.ID == 0 {
  3840. var result string
  3841. var requestLog string
  3842. var res2 ResultSix
  3843. var ressix10265 ResultSix10265
  3844. if miConfig.MdtrtareaAdmvs == "421300" {
  3845. data := make(map[string]interface{})
  3846. client := &http.Client{}
  3847. data["psn_no"] = his.PsnNo
  3848. data["mdtrt_id"] = his.Number
  3849. data["doctor"] = roles.UserName
  3850. data["department"] = department.Name
  3851. data["org_name"] = miConfig.OrgName
  3852. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3853. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3854. data["fixmedins_code"] = miConfig.Code
  3855. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3856. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3857. data["secret_key"] = miConfig.SecretKey
  3858. data["sick_code"] = sickConfig.CountryCode
  3859. data["sick_name"] = sickConfig.ClassName
  3860. data["dept"] = strconv.FormatInt(department.ID, 10)
  3861. data["config"] = config
  3862. data["begin_time"] = begin_time
  3863. bytesData, _ := json.Marshal(data)
  3864. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3865. resp, _ := client.Do(req)
  3866. defer resp.Body.Close()
  3867. body, ioErr := ioutil.ReadAll(resp.Body)
  3868. if ioErr != nil {
  3869. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3871. return
  3872. }
  3873. var respJSON map[string]interface{}
  3874. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3877. return
  3878. }
  3879. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3880. userJSONBytes, _ := json.Marshal(respJSON)
  3881. fmt.Println("log")
  3882. fmt.Println(string(userJSONBytes))
  3883. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3884. utils.ErrorLog("解析失败:%v", err)
  3885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3886. return
  3887. }
  3888. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3889. //江苏地区国家医保医疗类别
  3890. //职工透析:医疗类别选特殊情况门诊9933
  3891. //居民血透门慢: 医疗类别选门诊慢病1402
  3892. //var med_type string
  3893. //if his.Insutype == "310" {
  3894. // if reg_type == 14 {
  3895. // med_type = "9933"
  3896. // } else if reg_type == 11 {
  3897. // med_type = "11"
  3898. //
  3899. // }
  3900. //} else if his.Insutype == "390" {
  3901. // if reg_type == 14 {
  3902. // med_type = "1402"
  3903. // } else if reg_type == 11 {
  3904. // med_type = "11"
  3905. // }
  3906. //}
  3907. data := make(map[string]interface{})
  3908. client := &http.Client{}
  3909. data["psn_no"] = his.PsnNo
  3910. data["mdtrt_id"] = his.Number
  3911. data["doctor"] = roles.UserName
  3912. data["department"] = department.Name
  3913. data["org_name"] = miConfig.OrgName
  3914. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3915. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3916. data["fixmedins_code"] = miConfig.Code
  3917. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3918. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3919. data["secret_key"] = miConfig.SecretKey
  3920. data["sick_code"] = sickConfig.CountryCode
  3921. data["sick_name"] = sickConfig.ClassName
  3922. data["url"] = miConfig.Url
  3923. data["ak"] = miConfig.AccessKey
  3924. data["begin_time"] = begin_time
  3925. data["cainfo"] = miConfig.Cainfo
  3926. data["dept"] = strconv.FormatInt(department.ID, 10)
  3927. data["config"] = config
  3928. bytesData, _ := json.Marshal(data)
  3929. var req *http.Request
  3930. if miConfig.MdtrtareaAdmvs == "320921" {
  3931. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3932. //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 +
  3933. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  3934. } else {
  3935. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3936. }
  3937. resp, _ := client.Do(req)
  3938. defer resp.Body.Close()
  3939. body, ioErr := ioutil.ReadAll(resp.Body)
  3940. if ioErr != nil {
  3941. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3943. return
  3944. }
  3945. var respJSON map[string]interface{}
  3946. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3949. return
  3950. }
  3951. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3952. userJSONBytes, _ := json.Marshal(respJSON)
  3953. fmt.Println("log")
  3954. fmt.Println(string(userJSONBytes))
  3955. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  3956. utils.ErrorLog("解析失败:%v", err)
  3957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3958. return
  3959. }
  3960. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3961. res2.Output = ressix10265.Output
  3962. res2.ErrMsg = ressix10265.ErrMsg
  3963. res2.Cainfo = ressix10265.Cainfo
  3964. res2.WarnMsg = ressix10265.WarnMsg
  3965. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3966. res2.Infcode = infocode
  3967. } else {
  3968. if miConfig.MdtrtareaAdmvs == "440781" { //
  3969. 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)
  3970. } else {
  3971. if miConfig.Code == "H15049901371" {
  3972. //赤峰地区国家医保医疗类别
  3973. //职工透析:医疗类别选特殊情况门诊990502
  3974. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3975. var med_type string
  3976. if his.Insutype == "390" {
  3977. if reg_type == 14 {
  3978. med_type = "9933"
  3979. } else if reg_type == 11 {
  3980. med_type = "11"
  3981. }
  3982. } else if his.Insutype == "310" {
  3983. if reg_type == 14 {
  3984. med_type = "990502"
  3985. } else if reg_type == 11 {
  3986. med_type = "11"
  3987. }
  3988. }
  3989. 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)
  3990. } else {
  3991. 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)
  3992. }
  3993. }
  3994. saveLog(result, requestLog, "2203", "上传就诊信息")
  3995. var respJSON2 map[string]interface{}
  3996. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3999. return
  4000. }
  4001. userJSONBytes2, _ := json.Marshal(respJSON2)
  4002. if miConfig.Code == "H15049901371" {
  4003. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4004. utils.ErrorLog("解析失败:%v", err)
  4005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4006. return
  4007. }
  4008. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4009. res2.Output = ressix10265.Output
  4010. res2.ErrMsg = ressix10265.ErrMsg
  4011. res2.Cainfo = ressix10265.Cainfo
  4012. res2.WarnMsg = ressix10265.WarnMsg
  4013. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4014. res2.Infcode = infocode
  4015. } else {
  4016. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4017. utils.ErrorLog("解析失败:%v", err)
  4018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4019. return
  4020. }
  4021. }
  4022. }
  4023. if res2.Infcode != 0 {
  4024. adminUser := c.GetAdminUserInfo()
  4025. errlog := &models.HisOrderError{
  4026. UserOrgId: adminUser.CurrentOrgId,
  4027. Ctime: time.Now().Unix(),
  4028. Mtime: time.Now().Unix(),
  4029. ErrMsg: res2.ErrMsg,
  4030. Status: 1,
  4031. PatientId: id,
  4032. RecordTime: recordDateTime,
  4033. Stage: 3,
  4034. }
  4035. service.CreateErrMsgLog(errlog)
  4036. c.ServeSuccessJSON(map[string]interface{}{
  4037. "failed_code": -10,
  4038. "msg": res2.ErrMsg,
  4039. })
  4040. return
  4041. } else {
  4042. his.Diagnosis = diagnosis_id
  4043. his.SickType = sickConfig.ID
  4044. var p_type int64
  4045. if reg_type == 1111 || reg_type == 1112 {
  4046. p_type = 11
  4047. }
  4048. his.PType = fmt.Sprintf("%d", p_type)
  4049. service.UpdateHisPatientThree(&his)
  4050. data := make(map[string]interface{})
  4051. if settle_accounts_type == 1 { //日结
  4052. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4053. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4054. } else {
  4055. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4056. }
  4057. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4058. data["pre"] = prescriptions
  4059. } else { //月结
  4060. start_time_str := c.GetString("start_time")
  4061. end_time_str := c.GetString("end_time")
  4062. timeLayout := "2006-01-02"
  4063. loc, _ := time.LoadLocation("Local")
  4064. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4065. if err != nil {
  4066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4067. return
  4068. }
  4069. recordStartTime := theStartTime.Unix()
  4070. start_time = recordStartTime
  4071. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4072. if err != nil {
  4073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4074. return
  4075. }
  4076. recordEndTime := theEndTime.Unix()
  4077. end_time = recordEndTime
  4078. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4079. data["pre"] = prescriptions
  4080. }
  4081. timestamp := time.Now().Unix()
  4082. tempTime := time.Unix(timestamp, 0)
  4083. timeFormat := tempTime.Format("20060102150405")
  4084. chrgBchno := rand.Intn(100000) + 10000
  4085. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4086. strconv.FormatInt(his.PatientId, 10)
  4087. client := &http.Client{}
  4088. data["psn_no"] = his.PsnNo
  4089. data["mdtrt_id"] = his.Number
  4090. data["chrg_bchno"] = chrg_bchno
  4091. data["org_name"] = miConfig.OrgName
  4092. data["doctor"] = roles.UserName
  4093. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4094. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4095. data["fixmedins_code"] = miConfig.Code
  4096. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4097. // data["dept_code"] = "15"
  4098. //} else {
  4099. data["dept_code"] = department.Number
  4100. //}
  4101. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4102. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4103. data["secret_key"] = miConfig.SecretKey
  4104. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4105. data["url"] = miConfig.Url
  4106. data["ak"] = miConfig.AccessKey
  4107. data["new_doctor_name"] = patientPrescription.Doctor
  4108. data["diag_code"] = sickConfig.CountryCode
  4109. data["cainfo"] = miConfig.Cainfo
  4110. var ids []int64
  4111. for _, item := range prescriptions {
  4112. ids = append(ids, item.ID)
  4113. }
  4114. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4115. if config.IsOpen == 1 { //对接了医保,走医保流程
  4116. var res ResultFour
  4117. var resFour10265 ResultFour10265
  4118. if miConfig.MdtrtareaAdmvs == "421300" {
  4119. bytesData, _ := json.Marshal(data)
  4120. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4121. resp, _ := client.Do(req)
  4122. defer resp.Body.Close()
  4123. body, ioErr := ioutil.ReadAll(resp.Body)
  4124. if ioErr != nil {
  4125. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4127. return
  4128. }
  4129. var respJSON map[string]interface{}
  4130. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4133. return
  4134. }
  4135. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4136. userJSONBytes, _ := json.Marshal(respJSON)
  4137. fmt.Println("log")
  4138. fmt.Println(string(userJSONBytes))
  4139. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4140. utils.ErrorLog("解析失败:%v", err)
  4141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4142. return
  4143. }
  4144. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4145. bytesData, _ := json.Marshal(data)
  4146. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4147. resp, _ := client.Do(req)
  4148. defer resp.Body.Close()
  4149. body, ioErr := ioutil.ReadAll(resp.Body)
  4150. if ioErr != nil {
  4151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4153. return
  4154. }
  4155. var respJSON map[string]interface{}
  4156. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4159. return
  4160. }
  4161. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4162. userJSONBytes, _ := json.Marshal(respJSON)
  4163. fmt.Println("log")
  4164. fmt.Println(string(userJSONBytes))
  4165. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4166. utils.ErrorLog("解析失败:%v", err)
  4167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4168. return
  4169. }
  4170. res.InfRefmsgid = resFour10265.InfRefmsgid
  4171. res.Output = resFour10265.Output
  4172. res.ErrMsg = resFour10265.ErrMsg
  4173. res.Cainfo = resFour10265.Cainfo
  4174. res.WarnMsg = resFour10265.WarnMsg
  4175. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4176. res.Infcode = infocode
  4177. } else {
  4178. if miConfig.Code == "H15049901371" {
  4179. 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)
  4180. var dat map[string]interface{}
  4181. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4182. fmt.Println(dat)
  4183. } else {
  4184. fmt.Println(err)
  4185. }
  4186. saveLog(result, request_log, "2204", "上传费用明细")
  4187. userJSONBytes, _ := json.Marshal(dat)
  4188. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4189. utils.ErrorLog("解析失败:%v", err)
  4190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4191. return
  4192. }
  4193. res.InfRefmsgid = resFour10265.InfRefmsgid
  4194. res.Output = resFour10265.Output
  4195. res.ErrMsg = resFour10265.ErrMsg
  4196. res.Cainfo = resFour10265.Cainfo
  4197. res.WarnMsg = resFour10265.WarnMsg
  4198. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4199. res.Infcode = infocode
  4200. } else {
  4201. 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)
  4202. var dat map[string]interface{}
  4203. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4204. fmt.Println(dat)
  4205. } else {
  4206. fmt.Println(err)
  4207. }
  4208. saveLog(result, request_log, "2204", "上传费用明细")
  4209. userJSONBytes, _ := json.Marshal(dat)
  4210. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4211. utils.ErrorLog("解析失败:%v", err)
  4212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4213. return
  4214. }
  4215. }
  4216. }
  4217. if res.Infcode == 0 {
  4218. order := &models.HisOrder{
  4219. UserOrgId: adminUser.CurrentOrgId,
  4220. HisPatientId: his.ID,
  4221. PatientId: his.PatientId,
  4222. SettleAccountsDate: recordDateTime,
  4223. MdtrtId: his.Number,
  4224. PsnNo: his.PsnNo,
  4225. MedType: strconv.FormatInt(reg_type, 10),
  4226. Ctime: time.Now().Unix(),
  4227. Mtime: time.Now().Unix(),
  4228. Status: 1,
  4229. Number: chrg_bchno,
  4230. Infcode: res.Infcode,
  4231. WarnMsg: res.WarnMsg,
  4232. Cainfo: res.Cainfo,
  4233. ErrMsg: res.ErrMsg,
  4234. RespondTime: res.RefmsgTime,
  4235. InfRefmsgid: res.InfRefmsgid,
  4236. OrderStatus: 1,
  4237. PayWay: pay_way,
  4238. PayPrice: pay_price,
  4239. PayCardNo: pay_card_no,
  4240. DiscountPrice: discount_price,
  4241. PreferentialPrice: preferential_price,
  4242. RealityPrice: reality_price,
  4243. FoundPrice: found_price,
  4244. MedicalInsurancePrice: medical_insurance_price,
  4245. PrivatePrice: private_price,
  4246. IsMedicineInsurance: 1,
  4247. SettleType: settle_accounts_type,
  4248. SettleStartTime: start_time,
  4249. SettleEndTime: end_time,
  4250. Creator: roles.AdminUserId,
  4251. Modify: roles.AdminUserId,
  4252. FaPiaoNumber: fapiao_number,
  4253. FaPiaoCode: fapiao_code,
  4254. PType: 2,
  4255. Diagnosis: diagnosis_id,
  4256. }
  4257. err = service.CreateOrder(order)
  4258. if err != nil {
  4259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4260. return
  4261. }
  4262. for _, item := range res.Output.Result {
  4263. temp := strings.Split(item.FeedetlSn, "-")
  4264. var advice_id int64 = 0
  4265. var project_id int64 = 0
  4266. var types int64 = 0
  4267. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4268. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4269. if temp[1] == "1" {
  4270. advice_id = id
  4271. project_id = 0
  4272. } else if temp[1] == "2" {
  4273. advice_id = 0
  4274. project_id = id
  4275. }
  4276. info := &models.HisOrderInfo{
  4277. OrderNumber: order.Number,
  4278. FeedetlSn: item.FeedetlSn,
  4279. UploadDate: time.Now().Unix(),
  4280. AdviceId: advice_id,
  4281. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4282. Cnt: item.Cnt,
  4283. Pric: float64(item.Pric),
  4284. PatientId: his.PatientId,
  4285. PricUplmtAmt: item.PricUplmtAmt,
  4286. SelfpayProp: item.SelfpayProp,
  4287. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4288. OverlmtAmt: item.OverlmtAmt,
  4289. PreselfpayAmt: item.PreselfpayAmt,
  4290. BasMednFlag: item.BasMednFlag,
  4291. MedChrgitmType: item.MedChrgitmType,
  4292. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4293. Status: 1,
  4294. Memo: item.Memo,
  4295. Mtime: time.Now().Unix(),
  4296. InscpScpAmt: item.InscpScpAmt,
  4297. DrtReimFlag: item.DrtReimFlag,
  4298. Ctime: time.Now().Unix(),
  4299. ListSpItemFlag: item.ListSpItemFlag,
  4300. ChldMedcFlag: item.ChldMedcFlag,
  4301. LmtUsedFlag: item.LmtUsedFlag,
  4302. ChrgitmLv: item.ChrgitmLv,
  4303. UserOrgId: adminUser.CurrentOrgId,
  4304. HisPatientId: his.ID,
  4305. OrderId: order.ID,
  4306. ProjectId: project_id,
  4307. Type: types,
  4308. }
  4309. service.CreateOrderInfo(info)
  4310. }
  4311. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4312. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4313. var total float64
  4314. for _, item := range prescriptions {
  4315. if item.Type == 1 { //药品
  4316. for _, subItem := range item.HisDoctorAdviceInfo {
  4317. total = total + (subItem.Price * subItem.PrescribingNumber)
  4318. }
  4319. }
  4320. if item.Type == 2 { //项目
  4321. for _, subItem := range item.HisPrescriptionProject {
  4322. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4323. total = total + (subItem.Price * cnt)
  4324. }
  4325. }
  4326. }
  4327. for _, item := range prescriptions {
  4328. for _, subItem := range item.HisAdditionalCharge {
  4329. total = total + (subItem.Price * float64(subItem.Count))
  4330. }
  4331. }
  4332. var allTotal string
  4333. if adminUser.CurrentOrgId == 9919 {
  4334. allTotal = fmt.Sprintf("%.4f", total)
  4335. } else {
  4336. allTotal = fmt.Sprintf("%.4f", total)
  4337. }
  4338. if res.Infcode == 0 {
  4339. var rf []*ResultFive
  4340. json.Unmarshal([]byte(his.Iinfo), &rf)
  4341. chrg_bchno := chrg_bchno
  4342. cert_no := his.Certno
  4343. var insutypes []string
  4344. var insutype string
  4345. var is390 int = 0
  4346. var is310 int = 0
  4347. for _, item := range rf {
  4348. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4349. insutypes = append(insutypes, item.Insutype)
  4350. }
  4351. }
  4352. if len(insutypes) == 1 {
  4353. insutype = insutypes[0]
  4354. } else {
  4355. for _, i := range insutypes {
  4356. if i == "390" {
  4357. is390 = 1
  4358. }
  4359. if i == "310" {
  4360. is310 = 1
  4361. }
  4362. }
  4363. }
  4364. if is390 == 1 {
  4365. insutype = "390"
  4366. }
  4367. if is310 == 1 {
  4368. insutype = "310"
  4369. }
  4370. if len(insutypes) == 0 {
  4371. insutype = "310"
  4372. }
  4373. if len(insutypes) == 2 {
  4374. insutype = strconv.FormatInt(his.SocialType, 10)
  4375. }
  4376. insutype = strconv.FormatInt(his.SocialType, 10)
  4377. //insutype = "390"
  4378. if his.IdCardType == 1 {
  4379. // cert_no = his.MedicalInsuranceNumber
  4380. cert_no = his.Certno
  4381. } else {
  4382. cert_no = his.Certno
  4383. }
  4384. var res ResultSeven
  4385. var resSeven10265 ResultSeven10265
  4386. var src_resquest string
  4387. var result2 string
  4388. var acct_used_flag string
  4389. fmt.Println("pay_way")
  4390. fmt.Println(pay_way)
  4391. fmt.Println("pay_way")
  4392. if pay_way == 4 {
  4393. acct_used_flag = "1"
  4394. } else {
  4395. acct_used_flag = "0"
  4396. }
  4397. if miConfig.MdtrtareaAdmvs == "421300" {
  4398. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4399. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4400. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4401. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4402. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4403. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4404. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4405. resp, requestErr := http.Get(api)
  4406. if requestErr != nil {
  4407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4408. return
  4409. }
  4410. body, ioErr := ioutil.ReadAll(resp.Body)
  4411. if ioErr != nil {
  4412. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4414. return
  4415. }
  4416. var respJSON map[string]interface{}
  4417. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4420. return
  4421. }
  4422. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4423. result, _ := json.Marshal(respJSON)
  4424. if miConfig.Code == "H15049901371" {
  4425. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4426. utils.ErrorLog("解析失败:%v", err)
  4427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4428. return
  4429. }
  4430. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4431. res.Output = resSeven10265.Output
  4432. res.ErrMsg = resSeven10265.ErrMsg
  4433. res.Cainfo = resSeven10265.Cainfo
  4434. res.WarnMsg = resSeven10265.WarnMsg
  4435. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4436. res.Infcode = infocode
  4437. } else {
  4438. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4439. utils.ErrorLog("解析失败:%v", err)
  4440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4441. return
  4442. }
  4443. }
  4444. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4445. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4446. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4447. //psn_info, _ := service.GetPsnByPatientId(id)
  4448. bas := strings.Split(psn_info.CardInfo, "|")
  4449. if his.IdCardType == 1 {
  4450. cert_no = bas[2]
  4451. } else {
  4452. cert_no = bas[1]
  4453. }
  4454. //江苏地区国家医保医疗类别
  4455. //职工透析:医疗类别选特殊情况门诊9933
  4456. //居民血透门慢: 医疗类别选门诊慢病1402
  4457. //var med_type string
  4458. //if his.Insutype == "310" {
  4459. // if reg_type == 14 {
  4460. // med_type = "9933"
  4461. // } else if reg_type == 11 {
  4462. // med_type = "11"
  4463. //
  4464. // }
  4465. //} else if his.Insutype == "390" {
  4466. // if reg_type == 14 {
  4467. // med_type = "1402"
  4468. // } else if reg_type == 11 {
  4469. // med_type = "11"
  4470. // }
  4471. //}
  4472. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4473. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4474. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4475. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4476. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4477. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4478. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4479. "&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
  4480. resp, requestErr := http.Get(api)
  4481. if requestErr != nil {
  4482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4483. return
  4484. }
  4485. body, ioErr := ioutil.ReadAll(resp.Body)
  4486. if ioErr != nil {
  4487. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4489. return
  4490. }
  4491. var respJSON map[string]interface{}
  4492. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4493. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4495. return
  4496. }
  4497. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4498. result, _ := json.Marshal(respJSON)
  4499. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4500. utils.ErrorLog("解析失败:%v", err)
  4501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4502. return
  4503. }
  4504. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4505. res.Output = resSeven10265.Output
  4506. res.ErrMsg = resSeven10265.ErrMsg
  4507. res.Cainfo = resSeven10265.Cainfo
  4508. res.WarnMsg = resSeven10265.WarnMsg
  4509. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4510. res.Infcode = infocode
  4511. } else {
  4512. if miConfig.Code == "H15049901371" {
  4513. //赤峰地区国家医保医疗类别
  4514. //职工透析:医疗类别选特殊情况门诊990502
  4515. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4516. var med_type string
  4517. if his.Insutype == "390" {
  4518. if reg_type == 14 {
  4519. med_type = "9933"
  4520. } else if reg_type == 11 {
  4521. med_type = "11"
  4522. }
  4523. } else if his.Insutype == "310" {
  4524. if reg_type == 14 {
  4525. med_type = "990502"
  4526. } else if reg_type == 11 {
  4527. med_type = "11"
  4528. }
  4529. }
  4530. 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)
  4531. } else {
  4532. 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)
  4533. }
  4534. //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)
  4535. var dat map[string]interface{}
  4536. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4537. fmt.Println(dat)
  4538. } else {
  4539. fmt.Println(err)
  4540. }
  4541. saveLog(result2, src_resquest, "2207", "结算")
  4542. userJSONBytes, _ := json.Marshal(dat)
  4543. if miConfig.Code == "H15049901371" {
  4544. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4545. utils.ErrorLog("解析失败:%v", err)
  4546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4547. return
  4548. }
  4549. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4550. res.Output = resSeven10265.Output
  4551. res.ErrMsg = resSeven10265.ErrMsg
  4552. res.Cainfo = resSeven10265.Cainfo
  4553. res.WarnMsg = resSeven10265.WarnMsg
  4554. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4555. res.Infcode = infocode
  4556. } else {
  4557. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4558. utils.ErrorLog("解析失败:%v", err)
  4559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4560. return
  4561. }
  4562. }
  4563. }
  4564. if res.Infcode != 0 {
  4565. errlog := &models.HisOrderError{
  4566. UserOrgId: adminUser.CurrentOrgId,
  4567. Ctime: time.Now().Unix(),
  4568. Mtime: time.Now().Unix(),
  4569. Number: chrg_bchno,
  4570. ErrMsg: res.ErrMsg,
  4571. Status: 1,
  4572. PatientId: id,
  4573. RecordTime: recordDateTime,
  4574. Stage: 6,
  4575. }
  4576. service.CreateErrMsgLog(errlog)
  4577. c.ServeSuccessJSON(map[string]interface{}{
  4578. "failed_code": -10,
  4579. "msg": res.ErrMsg,
  4580. })
  4581. return
  4582. } else {
  4583. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4584. order.OrderStatus = 2
  4585. order.Status = 1
  4586. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4587. order.SetlId = res.Output.Setlinfo.SetlID
  4588. order.PsnNo = res.Output.Setlinfo.PsnNo
  4589. order.PsnName = res.Output.Setlinfo.PsnName
  4590. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4591. order.Certno = res.Output.Setlinfo.Certno
  4592. order.Gend = res.Output.Setlinfo.Gend
  4593. order.Naty = res.Output.Setlinfo.Naty
  4594. order.Age = res.Output.Setlinfo.Age
  4595. order.Insutype = res.Output.Setlinfo.Insutype
  4596. order.PsnType = res.Output.Setlinfo.PsnType
  4597. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4598. order.SetlTime = res.Output.Setlinfo.SetlTime
  4599. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4600. if res.Output.Setlinfo.MedType == "140101" {
  4601. order.MedType = "14"
  4602. } else {
  4603. order.MedType = res.Output.Setlinfo.MedType
  4604. }
  4605. if reg_type == 1112 {
  4606. order.MedType = "1112"
  4607. }
  4608. if reg_type == 1111 {
  4609. order.MedType = "1111"
  4610. }
  4611. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4612. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4613. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4614. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4615. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4616. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4617. order.HifpPay = res.Output.Setlinfo.HifpPay
  4618. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4619. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4620. order.HifesPay = res.Output.Setlinfo.HifesPay
  4621. order.HifobPay = res.Output.Setlinfo.HifobPay
  4622. order.MafPay = res.Output.Setlinfo.MafPay
  4623. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4624. order.OthPay = res.Output.Setlinfo.OthPay
  4625. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4626. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4627. order.AcctPay = res.Output.Setlinfo.AcctPay
  4628. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4629. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4630. order.Balc = res.Output.Setlinfo.Balc
  4631. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4632. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4633. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4634. order.ClrType = res.Output.Setlinfo.ClrType
  4635. order.ClrWay = res.Output.Setlinfo.ClrWay
  4636. order.Creator = order.Creator
  4637. order.Modify = roles.AdminUserId
  4638. order.RequestLog = src_resquest
  4639. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4640. detailStr := string(setlDetail)
  4641. order.SetlDetail = detailStr
  4642. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4643. err = service.UpDateOrder(order)
  4644. if err == nil {
  4645. c.ServeSuccessJSON(map[string]interface{}{
  4646. "msg": "结算成功",
  4647. })
  4648. } else {
  4649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4650. return
  4651. }
  4652. }
  4653. } else {
  4654. adminUser := c.GetAdminUserInfo()
  4655. errlog := &models.HisOrderError{
  4656. UserOrgId: adminUser.CurrentOrgId,
  4657. Ctime: time.Now().Unix(),
  4658. Mtime: time.Now().Unix(),
  4659. ErrMsg: res.ErrMsg,
  4660. Status: 1,
  4661. PatientId: id,
  4662. RecordTime: recordDateTime,
  4663. Stage: 4,
  4664. }
  4665. service.CreateErrMsgLog(errlog)
  4666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4667. return
  4668. }
  4669. } else {
  4670. adminUser := c.GetAdminUserInfo()
  4671. errlog := &models.HisOrderError{
  4672. UserOrgId: adminUser.CurrentOrgId,
  4673. Ctime: time.Now().Unix(),
  4674. Mtime: time.Now().Unix(),
  4675. ErrMsg: res.ErrMsg,
  4676. Status: 1,
  4677. PatientId: id,
  4678. RecordTime: recordDateTime,
  4679. Stage: 4,
  4680. }
  4681. service.CreateErrMsgLog(errlog)
  4682. c.ServeSuccessJSON(map[string]interface{}{
  4683. "failed_code": -10,
  4684. "msg": res.ErrMsg,
  4685. })
  4686. return
  4687. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4688. //return
  4689. }
  4690. }
  4691. }
  4692. } else if tempOrder.ID > 0 {
  4693. if tempOrder.IsPre == 1 {
  4694. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  4695. var rf []*ResultFive
  4696. json.Unmarshal([]byte(his.Iinfo), &rf)
  4697. chrg_bchno := tempOrder.Number
  4698. cert_no := his.Certno
  4699. var insutypes []string
  4700. var insutype string
  4701. var is390 int = 0
  4702. var is310 int = 0
  4703. for _, item := range rf {
  4704. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4705. insutypes = append(insutypes, item.Insutype)
  4706. }
  4707. }
  4708. if len(insutypes) == 1 {
  4709. insutype = insutypes[0]
  4710. } else {
  4711. for _, i := range insutypes {
  4712. if i == "390" {
  4713. is390 = 1
  4714. }
  4715. if i == "310" {
  4716. is310 = 1
  4717. }
  4718. }
  4719. }
  4720. if is390 == 1 {
  4721. insutype = "390"
  4722. }
  4723. if is310 == 1 {
  4724. insutype = "310"
  4725. }
  4726. if len(insutypes) == 0 {
  4727. insutype = "310"
  4728. }
  4729. if len(insutypes) == 2 {
  4730. insutype = strconv.FormatInt(his.SocialType, 64)
  4731. }
  4732. //insutype = "390"
  4733. if his.IdCardType == 1 {
  4734. // cert_no = his.MedicalInsuranceNumber
  4735. cert_no = his.Certno
  4736. } else {
  4737. cert_no = his.Certno
  4738. }
  4739. var res ResultSeven
  4740. var resSeven10265 ResultSeven10265
  4741. var src_resquest string
  4742. var result2 string
  4743. var acct_used_flag string
  4744. fmt.Println("pay_way")
  4745. fmt.Println(pay_way)
  4746. fmt.Println("pay_way")
  4747. if pay_way == 4 {
  4748. acct_used_flag = "1"
  4749. } else {
  4750. acct_used_flag = "0"
  4751. }
  4752. if miConfig.MdtrtareaAdmvs == "421300" {
  4753. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4754. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4755. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4756. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4757. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4758. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4759. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4760. resp, requestErr := http.Get(api)
  4761. if requestErr != nil {
  4762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4763. return
  4764. }
  4765. body, ioErr := ioutil.ReadAll(resp.Body)
  4766. if ioErr != nil {
  4767. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4769. return
  4770. }
  4771. var respJSON map[string]interface{}
  4772. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4773. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4775. return
  4776. }
  4777. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4778. result, _ := json.Marshal(respJSON)
  4779. fmt.Println("log")
  4780. fmt.Println(string(result))
  4781. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4782. utils.ErrorLog("解析失败:%v", err)
  4783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4784. return
  4785. }
  4786. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4787. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4788. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4789. //psn_info, _ := service.GetPsnByPatientId(id)
  4790. bas := strings.Split(psn_info.CardInfo, "|")
  4791. if his.IdCardType == 1 {
  4792. cert_no = bas[2]
  4793. } else {
  4794. cert_no = bas[1]
  4795. }
  4796. //江苏地区国家医保医疗类别
  4797. //职工透析:医疗类别选特殊情况门诊9933
  4798. //居民血透门慢: 医疗类别选门诊慢病1402
  4799. //var med_type string
  4800. //if his.Insutype == "310" {
  4801. // if reg_type == 14 {
  4802. // med_type = "9933"
  4803. // } else if reg_type == 11 {
  4804. // med_type = "11"
  4805. //
  4806. // }
  4807. //} else if his.Insutype == "390" {
  4808. // if reg_type == 14 {
  4809. // med_type = "1402"
  4810. // } else if reg_type == 11 {
  4811. // med_type = "11"
  4812. // }
  4813. //}
  4814. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4815. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4816. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4817. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4818. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4819. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4820. "&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
  4821. resp, requestErr := http.Get(api)
  4822. if requestErr != nil {
  4823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4824. return
  4825. }
  4826. body, ioErr := ioutil.ReadAll(resp.Body)
  4827. if ioErr != nil {
  4828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4830. return
  4831. }
  4832. var respJSON map[string]interface{}
  4833. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4834. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4836. return
  4837. }
  4838. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4839. result, _ := json.Marshal(respJSON)
  4840. fmt.Println("log")
  4841. fmt.Println(string(result))
  4842. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4843. utils.ErrorLog("解析失败:%v", err)
  4844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4845. return
  4846. }
  4847. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4848. res.Output = resSeven10265.Output
  4849. res.ErrMsg = resSeven10265.ErrMsg
  4850. res.Cainfo = resSeven10265.Cainfo
  4851. res.WarnMsg = resSeven10265.WarnMsg
  4852. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4853. res.Infcode = infocode
  4854. } else {
  4855. var src_resquest string
  4856. if miConfig.Code == "H15049901371" {
  4857. //赤峰地区国家医保医疗类别
  4858. //职工透析:医疗类别选特殊情况门诊990502
  4859. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4860. var med_type string
  4861. if his.Insutype == "390" {
  4862. if reg_type == 14 {
  4863. med_type = "9933"
  4864. } else if reg_type == 11 {
  4865. med_type = "11"
  4866. }
  4867. } else if his.Insutype == "310" {
  4868. if reg_type == 14 {
  4869. med_type = "990502"
  4870. } else if reg_type == 11 {
  4871. med_type = "11"
  4872. }
  4873. }
  4874. 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)
  4875. } else {
  4876. 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)
  4877. }
  4878. var dat map[string]interface{}
  4879. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4880. fmt.Println(dat)
  4881. } else {
  4882. fmt.Println(err)
  4883. }
  4884. saveLog(result2, src_resquest, "2207", "结算")
  4885. userJSONBytes, _ := json.Marshal(dat)
  4886. if miConfig.Code == "H15049901371" {
  4887. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4888. utils.ErrorLog("解析失败:%v", err)
  4889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4890. return
  4891. }
  4892. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4893. res.Output = resSeven10265.Output
  4894. res.ErrMsg = resSeven10265.ErrMsg
  4895. res.Cainfo = resSeven10265.Cainfo
  4896. res.WarnMsg = resSeven10265.WarnMsg
  4897. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4898. res.Infcode = infocode
  4899. } else {
  4900. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4901. utils.ErrorLog("解析失败:%v", err)
  4902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4903. return
  4904. }
  4905. }
  4906. }
  4907. if res.Infcode != 0 {
  4908. errlog := &models.HisOrderError{
  4909. UserOrgId: adminUser.CurrentOrgId,
  4910. Ctime: time.Now().Unix(),
  4911. Mtime: time.Now().Unix(),
  4912. Number: chrg_bchno,
  4913. ErrMsg: res.ErrMsg,
  4914. Status: 1,
  4915. PatientId: id,
  4916. RecordTime: recordDateTime,
  4917. Stage: 6,
  4918. }
  4919. service.CreateErrMsgLog(errlog)
  4920. c.ServeSuccessJSON(map[string]interface{}{
  4921. "failed_code": -10,
  4922. "msg": res.ErrMsg,
  4923. })
  4924. return
  4925. } else {
  4926. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4927. order.OrderStatus = 2
  4928. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4929. order.SetlId = res.Output.Setlinfo.SetlID
  4930. order.PsnNo = res.Output.Setlinfo.PsnNo
  4931. order.PsnName = res.Output.Setlinfo.PsnName
  4932. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4933. order.Certno = res.Output.Setlinfo.Certno
  4934. order.Gend = res.Output.Setlinfo.Gend
  4935. order.Naty = res.Output.Setlinfo.Naty
  4936. order.Age = res.Output.Setlinfo.Age
  4937. order.Insutype = res.Output.Setlinfo.Insutype
  4938. order.PsnType = res.Output.Setlinfo.PsnType
  4939. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4940. order.SetlTime = res.Output.Setlinfo.SetlTime
  4941. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4942. //order.MedType = res.Output.Setlinfo.MedType
  4943. if reg_type == 1112 {
  4944. order.MedType = "1112"
  4945. }
  4946. if reg_type == 1111 {
  4947. order.MedType = "1111"
  4948. }
  4949. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4950. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4951. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4952. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4953. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4954. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4955. order.HifpPay = res.Output.Setlinfo.HifpPay
  4956. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4957. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4958. order.HifesPay = res.Output.Setlinfo.HifesPay
  4959. order.HifobPay = res.Output.Setlinfo.HifobPay
  4960. order.MafPay = res.Output.Setlinfo.MafPay
  4961. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4962. order.OthPay = res.Output.Setlinfo.OthPay
  4963. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4964. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4965. order.AcctPay = res.Output.Setlinfo.AcctPay
  4966. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4967. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4968. order.Balc = res.Output.Setlinfo.Balc
  4969. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4970. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4971. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4972. order.ClrWay = res.Output.Setlinfo.ClrWay
  4973. order.Creator = order.Creator
  4974. order.Modify = roles.AdminUserId
  4975. order.RequestLog = src_resquest
  4976. order.Diagnosis = diagnosis_id
  4977. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4978. detailStr := string(setlDetail)
  4979. order.SetlDetail = detailStr
  4980. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4981. err = service.UpDateOrder(order)
  4982. if err == nil {
  4983. c.ServeSuccessJSON(map[string]interface{}{
  4984. "msg": "结算成功",
  4985. })
  4986. } else {
  4987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4988. return
  4989. }
  4990. }
  4991. }
  4992. }
  4993. }
  4994. //func (c *HisApiController) GetPreUploadInfo() {
  4995. // id, _ := c.GetInt64("id")
  4996. // record_time := c.GetString("record_time")
  4997. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4998. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4999. //
  5000. // timeLayout := "2006-01-02"
  5001. // loc, _ := time.LoadLocation("Local")
  5002. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5003. // if err != nil {
  5004. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5005. // return
  5006. // }
  5007. // recordDateTime := theTime.Unix()
  5008. // adminUser := c.GetAdminUserInfo()
  5009. //
  5010. // var prescriptions []*models.HisPrescription
  5011. //
  5012. // var start_time int64
  5013. // var end_time int64
  5014. //
  5015. // data := make(map[string]interface{})
  5016. // if settle_accounts_type == 1 { //日结
  5017. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5018. // data["pre"] = prescriptions
  5019. //
  5020. // } else { //月结
  5021. // start_time_str := c.GetString("start_time")
  5022. // end_time_str := c.GetString("end_time")
  5023. // timeLayout := "2006-01-02"
  5024. // loc, _ := time.LoadLocation("Local")
  5025. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5026. // if err != nil {
  5027. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5028. // return
  5029. // }
  5030. // recordStartTime := theStartTime.Unix()
  5031. // start_time = recordStartTime
  5032. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5033. // if err != nil {
  5034. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5035. // return
  5036. // }
  5037. // recordEndTime := theEndTime.Unix()
  5038. // end_time = recordEndTime
  5039. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5040. // data["pre"] = prescriptions
  5041. //
  5042. // }
  5043. //
  5044. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5045. //
  5046. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5047. // timestamp := time.Now().Unix()
  5048. // tempTime := time.Unix(timestamp, 0)
  5049. // timeFormat := tempTime.Format("20060102150405")
  5050. // chrgBchno := rand.Intn(100000) + 10000
  5051. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5052. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5053. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5054. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5055. // strconv.FormatInt(his.PatientId, 10)
  5056. // client := &http.Client{}
  5057. // data["psn_no"] = his.PsnNo
  5058. // data["mdtrt_id"] = his.Number
  5059. // data["chrg_bchno"] = chrg_bchno
  5060. // data["org_name"] = miConfig.OrgName
  5061. // data["doctor"] = roles.UserName
  5062. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5063. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5064. // data["fixmedins_code"] = miConfig.Code
  5065. // data["dept_code"] = department.Number
  5066. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5067. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5068. // data["secret_key"] = miConfig.SecretKey
  5069. // var ids []int64
  5070. //
  5071. // for _, item := range prescriptions {
  5072. // ids = append(ids, item.ID)
  5073. // }
  5074. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5075. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5076. // bytesData, _ := json.Marshal(data)
  5077. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5078. // resp, _ := client.Do(req)
  5079. // defer resp.Body.Close()
  5080. // body, ioErr := ioutil.ReadAll(resp.Body)
  5081. // if ioErr != nil {
  5082. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5083. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5084. // return
  5085. // }
  5086. // var respJSON map[string]interface{}
  5087. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5088. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5089. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5090. // return
  5091. // }
  5092. //
  5093. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5094. // userJSONBytes, _ := json.Marshal(respJSON)
  5095. // var res ResultFour
  5096. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5097. // utils.ErrorLog("解析失败:%v", err)
  5098. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5099. // return
  5100. // }
  5101. //
  5102. // if res.Infcode == 0 {
  5103. // order := &models.HisOrder{
  5104. // UserOrgId: adminUser.CurrentOrgId,
  5105. // HisPatientId: his.ID,
  5106. // PatientId: his.PatientId,
  5107. // SettleAccountsDate: recordDateTime,
  5108. // Ctime: time.Now().Unix(),
  5109. // Mtime: time.Now().Unix(),
  5110. // Status: 1,
  5111. // Number: chrg_bchno,
  5112. // Infcode: res.Infcode,
  5113. // WarnMsg: res.WarnMsg,
  5114. // Cainfo: res.Cainfo,
  5115. // ErrMsg: res.ErrMsg,
  5116. // RespondTime: res.RefmsgTime,
  5117. // InfRefmsgid: res.InfRefmsgid,
  5118. // OrderStatus: 1,
  5119. // IsMedicineInsurance: 1,
  5120. // SettleType: settle_accounts_type,
  5121. // SettleStartTime: start_time,
  5122. // SettleEndTime: end_time,
  5123. // Creator: roles.ID,
  5124. // Modify: roles.ID,
  5125. // PType: 2,
  5126. // }
  5127. // err = service.CreateOrder(order)
  5128. // if err != nil {
  5129. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5130. // return
  5131. // }
  5132. //
  5133. // for _, item := range res.Output.Result {
  5134. // temp := strings.Split(item.FeedetlSn, "-")
  5135. // var advice_id int64 = 0
  5136. // var project_id int64 = 0
  5137. // var types int64 = 0
  5138. //
  5139. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  5140. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  5141. //
  5142. // if temp[1] == "1" {
  5143. // advice_id = id
  5144. // project_id = 0
  5145. // } else if temp[1] == "2" {
  5146. // advice_id = 0
  5147. // project_id = id
  5148. // }
  5149. //
  5150. // info := &models.HisOrderInfo{
  5151. // OrderNumber: order.Number,
  5152. // FeedetlSn: item.FeedetlSn,
  5153. // UploadDate: time.Now().Unix(),
  5154. // AdviceId: advice_id,
  5155. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5156. // Cnt: item.Cnt,
  5157. // Pric: float64(item.Pric),
  5158. // PatientId: his.PatientId,
  5159. // PricUplmtAmt: item.PricUplmtAmt,
  5160. // SelfpayProp: item.SelfpayProp,
  5161. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5162. // OverlmtAmt: item.OverlmtAmt,
  5163. // PreselfpayAmt: item.PreselfpayAmt,
  5164. // BasMednFlag: item.BasMednFlag,
  5165. // MedChrgitmType: item.MedChrgitmType,
  5166. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5167. // Status: 1,
  5168. // Memo: item.Memo,
  5169. // Mtime: time.Now().Unix(),
  5170. // InscpScpAmt: item.InscpScpAmt,
  5171. // DrtReimFlag: item.DrtReimFlag,
  5172. // Ctime: time.Now().Unix(),
  5173. // ListSpItemFlag: item.ListSpItemFlag,
  5174. // ChldMedcFlag: item.ChldMedcFlag,
  5175. // LmtUsedFlag: item.LmtUsedFlag,
  5176. // ChrgitmLv: item.ChrgitmLv,
  5177. // UserOrgId: adminUser.CurrentOrgId,
  5178. // HisPatientId: his.ID,
  5179. // OrderId: order.ID,
  5180. // ProjectId: project_id,
  5181. // Type: types,
  5182. // }
  5183. // service.CreateOrderInfo(info)
  5184. //
  5185. // }
  5186. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5187. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5188. //
  5189. // var total float64
  5190. // for _, item := range prescriptions {
  5191. // if item.Type == 1 { //药品
  5192. // for _, subItem := range item.HisDoctorAdviceInfo {
  5193. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5194. // }
  5195. // }
  5196. // if item.Type == 2 { //项目
  5197. // for _, subItem := range item.HisPrescriptionProject {
  5198. // total = total + (subItem.Price * float64(subItem.Count))
  5199. // }
  5200. // }
  5201. // }
  5202. //
  5203. // for _, item := range prescriptions {
  5204. // for _, subItem := range item.HisAdditionalCharge {
  5205. // total = total + (subItem.Price * float64(subItem.Count))
  5206. // }
  5207. // }
  5208. //
  5209. // allTotal := fmt.Sprintf("%.2f", total)
  5210. // if res.Infcode == 0 {
  5211. // var rf []*ResultFive
  5212. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5213. // psn_no := his.PsnNo
  5214. // mdtrt_id := his.Number
  5215. // chrg_bchno := chrg_bchno
  5216. // cert_no := his.Certno
  5217. // insutype := rf[0].Insutype
  5218. //
  5219. // if his.IdCardType == 1 {
  5220. // cert_no = his.MedicalInsuranceNumber
  5221. //
  5222. // } else {
  5223. //
  5224. // cert_no = his.Certno
  5225. //
  5226. // }
  5227. //
  5228. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5229. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5230. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5231. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5232. // resp, requestErr := http.Get(api)
  5233. // if requestErr != nil {
  5234. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5235. // return
  5236. // }
  5237. // defer resp.Body.Close()
  5238. // body, ioErr := ioutil.ReadAll(resp.Body)
  5239. // if ioErr != nil {
  5240. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5241. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5242. // return
  5243. // }
  5244. // var respJSON map[string]interface{}
  5245. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5246. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5247. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5248. // return
  5249. // }
  5250. // fmt.Println(respJSON)
  5251. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5252. // userJSONBytes, _ := json.Marshal(respJSON)
  5253. // var res ResultSeven
  5254. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5255. // utils.ErrorLog("解析失败:%v", err)
  5256. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5257. // return
  5258. // }
  5259. // if res.Infcode != 0 {
  5260. // errlog := &models.HisOrderError{
  5261. // UserOrgId: adminUser.CurrentOrgId,
  5262. // Ctime: time.Now().Unix(),
  5263. // Mtime: time.Now().Unix(),
  5264. // Number: chrg_bchno,
  5265. // ErrMsg: res.ErrMsg,
  5266. // Status: 1,
  5267. // PatientId: id,
  5268. // RecordTime: recordDateTime,
  5269. // Stage: 7,
  5270. // }
  5271. // service.CreateErrMsgLog(errlog)
  5272. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5273. // return
  5274. // } else {
  5275. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5276. // order.OrderStatus = 1
  5277. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5278. // order.SetlId = res.Output.Setlinfo.SetlID
  5279. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5280. // order.PsnName = res.Output.Setlinfo.PsnName
  5281. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5282. // order.Certno = res.Output.Setlinfo.Certno
  5283. // order.Gend = res.Output.Setlinfo.Gend
  5284. // order.Naty = res.Output.Setlinfo.Naty
  5285. // order.Age = res.Output.Setlinfo.Age
  5286. // order.Insutype = res.Output.Setlinfo.Insutype
  5287. // order.PsnType = res.Output.Setlinfo.PsnType
  5288. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5289. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5290. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5291. // order.MedType = res.Output.Setlinfo.MedType
  5292. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5293. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5294. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5295. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5296. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5297. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5298. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5299. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5300. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5301. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5302. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5303. // order.MafPay = res.Output.Setlinfo.MafPay
  5304. // order.OthPay = res.Output.Setlinfo.OthPay
  5305. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5306. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5307. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5308. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5309. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5310. // order.Balc = res.Output.Setlinfo.Balc
  5311. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5312. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5313. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5314. // order.ClrWay = res.Output.Setlinfo.ClrWay
  5315. // order.Creator = order.Creator
  5316. // order.Modify = roles.ID
  5317. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5318. // detailStr := string(setlDetail)
  5319. // order.SetlDetail = detailStr
  5320. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5321. // err = service.UpDateOrder(order)
  5322. // if err == nil {
  5323. // c.ServeSuccessJSON(map[string]interface{}{
  5324. // "msg": "预结算成功",
  5325. // })
  5326. // } else {
  5327. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5328. // return
  5329. // }
  5330. // }
  5331. // } else {
  5332. // adminUser := c.GetAdminUserInfo()
  5333. // errlog := &models.HisOrderError{
  5334. // UserOrgId: adminUser.CurrentOrgId,
  5335. // Ctime: time.Now().Unix(),
  5336. // Mtime: time.Now().Unix(),
  5337. // ErrMsg: res.ErrMsg,
  5338. // Status: 1,
  5339. // PatientId: id,
  5340. // RecordTime: recordDateTime,
  5341. // Stage: 4,
  5342. // }
  5343. // service.CreateErrMsgLog(errlog)
  5344. //
  5345. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5346. // return
  5347. // }
  5348. // } else {
  5349. // adminUser := c.GetAdminUserInfo()
  5350. // errlog := &models.HisOrderError{
  5351. // UserOrgId: adminUser.CurrentOrgId,
  5352. // Ctime: time.Now().Unix(),
  5353. // Mtime: time.Now().Unix(),
  5354. // ErrMsg: res.ErrMsg,
  5355. // Status: 1,
  5356. // PatientId: id,
  5357. // RecordTime: recordDateTime,
  5358. // Stage: 4,
  5359. // }
  5360. // service.CreateErrMsgLog(errlog)
  5361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5362. // return
  5363. // }
  5364. //
  5365. // } else {
  5366. // var total float64
  5367. // for _, item := range prescriptions {
  5368. // if item.Type == 1 { //药品
  5369. // for _, subItem := range item.HisDoctorAdviceInfo {
  5370. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5371. // }
  5372. // }
  5373. // if item.Type == 2 { //项目
  5374. // for _, subItem := range item.HisPrescriptionProject {
  5375. // total = total + (subItem.Price * float64(subItem.Count))
  5376. // }
  5377. // }
  5378. //
  5379. // for _, subItem := range item.HisAdditionalCharge {
  5380. // total = total + (subItem.Price * float64(subItem.Count))
  5381. // }
  5382. // }
  5383. //
  5384. // allTotal := fmt.Sprintf("%.2f", total)
  5385. // totals, _ := strconv.ParseFloat(allTotal, 64)
  5386. // order := &models.HisOrder{
  5387. // UserOrgId: adminUser.CurrentOrgId,
  5388. // HisPatientId: his.ID,
  5389. // PatientId: id,
  5390. // SettleAccountsDate: recordDateTime,
  5391. // Ctime: time.Now().Unix(),
  5392. // Mtime: time.Now().Unix(),
  5393. // Status: 1,
  5394. // OrderStatus: 2,
  5395. // Number: chrg_bchno,
  5396. // MedfeeSumamt: totals,
  5397. // }
  5398. // err = service.CreateOrder(order)
  5399. // if err != nil {
  5400. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5401. // return
  5402. // }
  5403. //
  5404. // var customs []*Custom
  5405. // for _, item := range prescriptions {
  5406. //
  5407. // if item.Type == 1 { //药品
  5408. // for _, subItem := range item.HisDoctorAdviceInfo {
  5409. // cus := &Custom{
  5410. // AdviceId: subItem.ID,
  5411. // ProjectId: 0,
  5412. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  5413. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  5414. // FeedetlSn: subItem.FeedetlSn,
  5415. // Price: fmt.Sprintf("%.2f", subItem.Price),
  5416. // MedListCodg: subItem.MedListCodg,
  5417. // Type: 1,
  5418. // }
  5419. // customs = append(customs, cus)
  5420. // }
  5421. // }
  5422. //
  5423. // if item.Type == 2 { //项目
  5424. // for _, subItem := range item.HisPrescriptionProject {
  5425. //
  5426. // cus := &Custom{
  5427. // AdviceId: 0,
  5428. // ProjectId: subItem.ID,
  5429. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  5430. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  5431. // FeedetlSn: subItem.FeedetlSn,
  5432. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  5433. // MedListCodg: subItem.MedListCodg,
  5434. // Type: 2,
  5435. // }
  5436. //
  5437. // customs = append(customs, cus)
  5438. // }
  5439. // }
  5440. //
  5441. // for _, item := range item.HisAdditionalCharge {
  5442. // cus := &Custom{
  5443. // ItemId: item.ID,
  5444. // AdviceId: 0,
  5445. // ProjectId: 0,
  5446. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  5447. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  5448. // FeedetlSn: item.FeedetlSn,
  5449. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  5450. // MedListCodg: item.XtHisAddtionConfig.Code,
  5451. // Type: 3,
  5452. // }
  5453. //
  5454. // customs = append(customs, cus)
  5455. // }
  5456. //
  5457. // }
  5458. //
  5459. // for _, item := range customs {
  5460. // var advice_id int64 = 0
  5461. // var project_id int64 = 0
  5462. // var item_id int64 = 0
  5463. //
  5464. // var types int64 = 0
  5465. //
  5466. // if item.Type == 1 {
  5467. // advice_id = item.AdviceId
  5468. // project_id = 0
  5469. // item_id = 0
  5470. // } else if item.Type == 2 {
  5471. // advice_id = 0
  5472. // item_id = 0
  5473. //
  5474. // project_id = item.ProjectId
  5475. // } else if item.Type == 3 {
  5476. // advice_id = 0
  5477. // item_id = item.ItemId
  5478. // project_id = 0
  5479. // }
  5480. //
  5481. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  5482. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  5483. // pric, _ := strconv.ParseFloat(item.Price, 32)
  5484. //
  5485. // info := &models.HisOrderInfo{
  5486. // OrderNumber: order.Number,
  5487. // UploadDate: time.Now().Unix(),
  5488. // AdviceId: advice_id,
  5489. // DetItemFeeSumamt: detItemFeeSumamt,
  5490. // Cnt: cut,
  5491. // Pric: pric,
  5492. // PatientId: id,
  5493. // Status: 1,
  5494. // Mtime: time.Now().Unix(),
  5495. // Ctime: time.Now().Unix(),
  5496. // UserOrgId: adminUser.CurrentOrgId,
  5497. // HisPatientId: his.ID,
  5498. // OrderId: order.ID,
  5499. // ProjectId: project_id,
  5500. // Type: types,
  5501. // ItemId: item_id,
  5502. // }
  5503. // service.CreateOrderInfo(info)
  5504. // }
  5505. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5506. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5507. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  5508. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5509. // if err == nil {
  5510. // c.ServeSuccessJSON(map[string]interface{}{
  5511. // "msg": "结算成功",
  5512. // })
  5513. // } else {
  5514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5515. // return
  5516. // }
  5517. // }
  5518. //}
  5519. //上传明细-预结算-
  5520. func (c *HisApiController) GetPreUploadInfo() {
  5521. id, _ := c.GetInt64("id")
  5522. record_time := c.GetString("record_time")
  5523. his_patient_id, _ := c.GetInt64("his_patient_id")
  5524. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5525. admin_user_id, _ := c.GetInt64("admin_user_id")
  5526. diagnosis_id := c.GetString("diagnosis")
  5527. sick_type, _ := c.GetInt64("sick_type")
  5528. reg_type, _ := c.GetInt64("p_type")
  5529. begin_time := c.GetString("begin_time")
  5530. id_str := c.GetString("ids")
  5531. ids_arr := strings.Split(id_str, ",")
  5532. timeLayout := "2006-01-02"
  5533. loc, _ := time.LoadLocation("Local")
  5534. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5535. if err != nil {
  5536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5537. return
  5538. }
  5539. recordDateTime := theTime.Unix()
  5540. adminUser := c.GetAdminUserInfo()
  5541. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5542. var config []*models.HisXtDiagnoseConfig
  5543. for _, item := range diagnosis_ids {
  5544. id, _ := strconv.ParseInt(item, 10, 64)
  5545. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5546. config = append(config, &diagnosisConfig)
  5547. }
  5548. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5549. sickConfig, _ := service.FindSickById(sick_type)
  5550. var prescriptions []*models.HisPrescription
  5551. var start_time int64
  5552. var end_time int64
  5553. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5554. fmt.Println(his_patient_id)
  5555. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5556. timestamp := time.Now().Unix()
  5557. tempTime := time.Unix(timestamp, 0)
  5558. timeFormat := tempTime.Format("20060102150405")
  5559. chrgBchno := rand.Intn(100000) + 10000
  5560. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5561. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5562. var patientPrescription models.HisPrescriptionInfo
  5563. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5564. if patientPrescription.ID == 0 {
  5565. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5566. }
  5567. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5568. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5569. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5570. strconv.FormatInt(his.PatientId, 10)
  5571. var res2 ResultSix
  5572. var resSix10265 ResultSix10265
  5573. var time_stamp string
  5574. if miConfig.MdtrtareaAdmvs == "421300" {
  5575. data := make(map[string]interface{})
  5576. client := &http.Client{}
  5577. data["psn_no"] = his.PsnNo
  5578. data["mdtrt_id"] = his.Number
  5579. data["doctor"] = roles.UserName
  5580. data["department"] = department.Name
  5581. data["org_name"] = miConfig.OrgName
  5582. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5583. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5584. data["fixmedins_code"] = miConfig.Code
  5585. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5586. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5587. data["secret_key"] = miConfig.SecretKey
  5588. data["sick_code"] = sickConfig.CountryCode
  5589. data["sick_name"] = sickConfig.ClassName
  5590. data["begin_time"] = begin_time
  5591. data["dept"] = strconv.FormatInt(department.ID, 10)
  5592. data["config"] = config
  5593. fmt.Println(data)
  5594. bytesData, _ := json.Marshal(data)
  5595. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5596. resp, _ := client.Do(req)
  5597. defer resp.Body.Close()
  5598. body, ioErr := ioutil.ReadAll(resp.Body)
  5599. if ioErr != nil {
  5600. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5602. return
  5603. }
  5604. var respJSON map[string]interface{}
  5605. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5606. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5608. return
  5609. }
  5610. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5611. userJSONBytes, _ := json.Marshal(respJSON)
  5612. fmt.Println("log")
  5613. fmt.Println(string(userJSONBytes))
  5614. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5615. utils.ErrorLog("解析失败:%v", err)
  5616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5617. return
  5618. }
  5619. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5620. //江苏地区国家医保医疗类别
  5621. //职工透析:医疗类别选特殊情况门诊9933
  5622. //居民血透门慢: 医疗类别选门诊慢病1402
  5623. //var med_type string
  5624. //if his.Insutype == "310" {
  5625. // if reg_type == 14 {
  5626. // med_type = "9933"
  5627. // } else if reg_type == 11 {
  5628. // med_type = "11"
  5629. //
  5630. // }
  5631. //} else if his.Insutype == "390" {
  5632. // if reg_type == 14 {
  5633. // med_type = "1402"
  5634. // } else if reg_type == 11 {
  5635. // med_type = "11"
  5636. // }
  5637. //}
  5638. data := make(map[string]interface{})
  5639. client := &http.Client{}
  5640. data["psn_no"] = his.PsnNo
  5641. data["mdtrt_id"] = his.Number
  5642. data["doctor"] = roles.UserName
  5643. data["department"] = department.Name
  5644. data["org_name"] = miConfig.OrgName
  5645. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5646. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5647. data["fixmedins_code"] = miConfig.Code
  5648. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5649. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5650. data["secret_key"] = miConfig.SecretKey
  5651. data["sick_code"] = sickConfig.CountryCode
  5652. data["sick_name"] = sickConfig.ClassName
  5653. data["begin_time"] = begin_time
  5654. data["dept"] = strconv.FormatInt(department.ID, 10)
  5655. data["config"] = config
  5656. data["url"] = miConfig.Url
  5657. data["ak"] = miConfig.AccessKey
  5658. data["cainfo"] = miConfig.Cainfo
  5659. bytesData, _ := json.Marshal(data)
  5660. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5661. resp, _ := client.Do(req)
  5662. defer resp.Body.Close()
  5663. body, ioErr := ioutil.ReadAll(resp.Body)
  5664. if ioErr != nil {
  5665. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5667. return
  5668. }
  5669. var respJSON map[string]interface{}
  5670. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5673. return
  5674. }
  5675. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  5676. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  5677. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  5678. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5679. userJSONBytes, _ := json.Marshal(respJSON)
  5680. fmt.Println("log")
  5681. fmt.Println(string(userJSONBytes))
  5682. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5683. utils.ErrorLog("解析失败:%v", err)
  5684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5685. return
  5686. }
  5687. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5688. res2.Output = resSix10265.Output
  5689. res2.ErrMsg = resSix10265.ErrMsg
  5690. res2.Cainfo = resSix10265.Cainfo
  5691. res2.WarnMsg = resSix10265.WarnMsg
  5692. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5693. res2.Infcode = infocode
  5694. } else {
  5695. var result string
  5696. var requestLog string
  5697. if miConfig.MdtrtareaAdmvs == "440781" { //
  5698. 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)
  5699. } else {
  5700. if miConfig.Code == "H15049901371" {
  5701. //赤峰地区国家医保医疗类别
  5702. //职工透析:医疗类别选特殊情况门诊990502
  5703. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5704. var med_type string
  5705. if his.Insutype == "390" {
  5706. if reg_type == 14 {
  5707. med_type = "9933"
  5708. } else if reg_type == 11 {
  5709. med_type = "11"
  5710. }
  5711. } else if his.Insutype == "310" {
  5712. if reg_type == 14 {
  5713. med_type = "990502"
  5714. } else if reg_type == 11 {
  5715. med_type = "11"
  5716. }
  5717. }
  5718. 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)
  5719. } else {
  5720. 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)
  5721. }
  5722. saveLog(result, requestLog, "2203", "上传就诊信息")
  5723. var respJSON2 map[string]interface{}
  5724. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5725. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5727. return
  5728. }
  5729. userJSONBytes2, _ := json.Marshal(respJSON2)
  5730. if miConfig.Code == "H15049901371" {
  5731. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5732. utils.ErrorLog("解析失败:%v", err)
  5733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5734. return
  5735. }
  5736. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5737. res2.Output = resSix10265.Output
  5738. res2.ErrMsg = resSix10265.ErrMsg
  5739. res2.Cainfo = resSix10265.Cainfo
  5740. res2.WarnMsg = resSix10265.WarnMsg
  5741. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5742. res2.Infcode = infocode
  5743. } else {
  5744. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5745. utils.ErrorLog("解析失败:%v", err)
  5746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5747. return
  5748. }
  5749. }
  5750. }
  5751. }
  5752. if res2.Infcode != 0 {
  5753. adminUser := c.GetAdminUserInfo()
  5754. errlog := &models.HisOrderError{
  5755. UserOrgId: adminUser.CurrentOrgId,
  5756. Ctime: time.Now().Unix(),
  5757. Mtime: time.Now().Unix(),
  5758. ErrMsg: res2.ErrMsg,
  5759. Status: 1,
  5760. PatientId: id,
  5761. RecordTime: recordDateTime,
  5762. Stage: 3,
  5763. }
  5764. service.CreateErrMsgLog(errlog)
  5765. c.ServeSuccessJSON(map[string]interface{}{
  5766. "failed_code": -10,
  5767. "msg": res2.ErrMsg,
  5768. })
  5769. return
  5770. } else {
  5771. his.Diagnosis = diagnosis_id
  5772. his.SickType = sickConfig.ID
  5773. his.PType = fmt.Sprintf("%d", reg_type)
  5774. service.UpdateHisPatientThree(&his)
  5775. data := make(map[string]interface{})
  5776. if settle_accounts_type == 1 { //日结
  5777. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5778. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5779. } else {
  5780. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5781. }
  5782. data["pre"] = prescriptions
  5783. } else { //月结
  5784. start_time_str := c.GetString("start_time")
  5785. end_time_str := c.GetString("end_time")
  5786. timeLayout := "2006-01-02"
  5787. loc, _ := time.LoadLocation("Local")
  5788. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5789. if err != nil {
  5790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5791. return
  5792. }
  5793. recordStartTime := theStartTime.Unix()
  5794. start_time = recordStartTime
  5795. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5796. if err != nil {
  5797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5798. return
  5799. }
  5800. recordEndTime := theEndTime.Unix()
  5801. end_time = recordEndTime
  5802. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5803. data["pre"] = prescriptions
  5804. }
  5805. client := &http.Client{}
  5806. data["psn_no"] = his.PsnNo
  5807. data["mdtrt_id"] = his.Number
  5808. data["chrg_bchno"] = chrg_bchno
  5809. data["org_name"] = miConfig.OrgName
  5810. data["doctor"] = roles.UserName
  5811. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5812. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5813. data["fixmedins_code"] = miConfig.Code
  5814. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5815. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5816. data["dept_code"] = "15"
  5817. } else {
  5818. data["dept_code"] = department.Number
  5819. }
  5820. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5821. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5822. data["secret_key"] = miConfig.SecretKey
  5823. data["url"] = miConfig.Url
  5824. data["ak"] = miConfig.AccessKey
  5825. data["new_doctor_name"] = patientPrescription.Doctor
  5826. data["diag_code"] = sickConfig.CountryCode
  5827. data["time_stamp"] = time_stamp
  5828. data["cainfo"] = miConfig.Cainfo
  5829. var ids []int64
  5830. for _, item := range prescriptions {
  5831. ids = append(ids, item.ID)
  5832. }
  5833. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5834. if config.IsOpen == 1 { //对接了医保,走医保流程
  5835. var res ResultFour
  5836. var resFour10265 ResultFour10265
  5837. if miConfig.MdtrtareaAdmvs == "421300" {
  5838. bytesData, _ := json.Marshal(data)
  5839. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5840. resp, _ := client.Do(req)
  5841. defer resp.Body.Close()
  5842. body, ioErr := ioutil.ReadAll(resp.Body)
  5843. if ioErr != nil {
  5844. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5846. return
  5847. }
  5848. var respJSON map[string]interface{}
  5849. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5852. return
  5853. }
  5854. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5855. userJSONBytes, _ := json.Marshal(respJSON)
  5856. fmt.Println("log")
  5857. fmt.Println(string(userJSONBytes))
  5858. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5859. utils.ErrorLog("解析失败:%v", err)
  5860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5861. return
  5862. }
  5863. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5864. bytesData, _ := json.Marshal(data)
  5865. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5866. resp, _ := client.Do(req)
  5867. defer resp.Body.Close()
  5868. body, ioErr := ioutil.ReadAll(resp.Body)
  5869. if ioErr != nil {
  5870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5872. return
  5873. }
  5874. var respJSON map[string]interface{}
  5875. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5876. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5878. return
  5879. }
  5880. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5881. userJSONBytes, _ := json.Marshal(respJSON)
  5882. fmt.Println("log")
  5883. fmt.Println(string(userJSONBytes))
  5884. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5885. utils.ErrorLog("解析失败:%v", err)
  5886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5887. return
  5888. }
  5889. res.InfRefmsgid = resFour10265.InfRefmsgid
  5890. res.Output = resFour10265.Output
  5891. res.ErrMsg = resFour10265.ErrMsg
  5892. res.Cainfo = resFour10265.Cainfo
  5893. res.WarnMsg = resFour10265.WarnMsg
  5894. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5895. res.Infcode = infocode
  5896. } else {
  5897. if miConfig.Code == "H15049901371" {
  5898. 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)
  5899. var dat map[string]interface{}
  5900. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5901. fmt.Println(dat)
  5902. } else {
  5903. fmt.Println(err)
  5904. }
  5905. saveLog(result, request_log, "2204", "上传费用明细")
  5906. userJSONBytes, _ := json.Marshal(dat)
  5907. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5908. utils.ErrorLog("解析失败:%v", err)
  5909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5910. return
  5911. }
  5912. res.InfRefmsgid = resFour10265.InfRefmsgid
  5913. res.Output = resFour10265.Output
  5914. res.ErrMsg = resFour10265.ErrMsg
  5915. res.Cainfo = resFour10265.Cainfo
  5916. res.WarnMsg = resFour10265.WarnMsg
  5917. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5918. res.Infcode = infocode
  5919. } else {
  5920. 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)
  5921. var dat map[string]interface{}
  5922. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5923. fmt.Println(dat)
  5924. } else {
  5925. fmt.Println(err)
  5926. }
  5927. saveLog(result, request_log, "2204", "上传费用明细")
  5928. userJSONBytes, _ := json.Marshal(dat)
  5929. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5930. utils.ErrorLog("解析失败:%v", err)
  5931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5932. return
  5933. }
  5934. }
  5935. }
  5936. if res.Infcode == 0 {
  5937. order := &models.HisOrder{
  5938. UserOrgId: adminUser.CurrentOrgId,
  5939. HisPatientId: his.ID,
  5940. PatientId: his.PatientId,
  5941. SettleAccountsDate: recordDateTime,
  5942. Ctime: time.Now().Unix(),
  5943. Mtime: time.Now().Unix(),
  5944. MdtrtId: his.Number,
  5945. PsnNo: his.PsnNo,
  5946. MedType: strconv.FormatInt(reg_type, 10),
  5947. Status: 1,
  5948. Number: chrg_bchno,
  5949. Infcode: res.Infcode,
  5950. WarnMsg: res.WarnMsg,
  5951. Cainfo: res.Cainfo,
  5952. ErrMsg: res.ErrMsg,
  5953. RespondTime: res.RefmsgTime,
  5954. InfRefmsgid: res.InfRefmsgid,
  5955. OrderStatus: 1,
  5956. IsMedicineInsurance: 1,
  5957. SettleType: settle_accounts_type,
  5958. SettleStartTime: start_time,
  5959. SettleEndTime: end_time,
  5960. Creator: roles.AdminUserId,
  5961. Modify: roles.AdminUserId,
  5962. PType: 2,
  5963. Diagnosis: diagnosis_id,
  5964. }
  5965. err = service.CreateOrder(order)
  5966. if err != nil {
  5967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5968. return
  5969. }
  5970. for _, item := range res.Output.Result {
  5971. temp := strings.Split(item.FeedetlSn, "-")
  5972. var advice_id int64 = 0
  5973. var project_id int64 = 0
  5974. var types int64 = 0
  5975. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5976. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5977. if temp[1] == "1" {
  5978. advice_id = id
  5979. project_id = 0
  5980. } else if temp[1] == "2" {
  5981. advice_id = 0
  5982. project_id = id
  5983. }
  5984. info := &models.HisOrderInfo{
  5985. OrderNumber: order.Number,
  5986. FeedetlSn: item.FeedetlSn,
  5987. UploadDate: time.Now().Unix(),
  5988. AdviceId: advice_id,
  5989. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5990. Cnt: item.Cnt,
  5991. Pric: float64(item.Pric),
  5992. PatientId: his.PatientId,
  5993. PricUplmtAmt: item.PricUplmtAmt,
  5994. SelfpayProp: item.SelfpayProp,
  5995. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5996. OverlmtAmt: item.OverlmtAmt,
  5997. PreselfpayAmt: item.PreselfpayAmt,
  5998. BasMednFlag: item.BasMednFlag,
  5999. MedChrgitmType: item.MedChrgitmType,
  6000. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6001. Status: 1,
  6002. Memo: item.Memo,
  6003. Mtime: time.Now().Unix(),
  6004. InscpScpAmt: item.InscpScpAmt,
  6005. DrtReimFlag: item.DrtReimFlag,
  6006. Ctime: time.Now().Unix(),
  6007. ListSpItemFlag: item.ListSpItemFlag,
  6008. ChldMedcFlag: item.ChldMedcFlag,
  6009. LmtUsedFlag: item.LmtUsedFlag,
  6010. ChrgitmLv: item.ChrgitmLv,
  6011. UserOrgId: adminUser.CurrentOrgId,
  6012. HisPatientId: his.ID,
  6013. OrderId: order.ID,
  6014. ProjectId: project_id,
  6015. Type: types,
  6016. }
  6017. service.CreateOrderInfo(info)
  6018. }
  6019. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6020. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6021. var total float64
  6022. for _, item := range prescriptions {
  6023. if item.Type == 1 { //药品
  6024. for _, subItem := range item.HisDoctorAdviceInfo {
  6025. total = total + (subItem.Price * subItem.PrescribingNumber)
  6026. }
  6027. }
  6028. if item.Type == 2 { //项目
  6029. for _, subItem := range item.HisPrescriptionProject {
  6030. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6031. total = total + (subItem.Price * cnt)
  6032. }
  6033. }
  6034. }
  6035. for _, item := range prescriptions {
  6036. for _, subItem := range item.HisAdditionalCharge {
  6037. total = total + (subItem.Price * float64(subItem.Count))
  6038. }
  6039. }
  6040. allTotal := fmt.Sprintf("%.4f", total)
  6041. if res.Infcode == 0 {
  6042. var rf []*ResultFive
  6043. json.Unmarshal([]byte(his.Iinfo), &rf)
  6044. chrg_bchno := chrg_bchno
  6045. cert_no := his.Certno
  6046. var insutypes []string
  6047. var insutype string
  6048. var is390 int = 0
  6049. var is310 int = 0
  6050. for _, item := range rf {
  6051. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6052. insutypes = append(insutypes, item.Insutype)
  6053. }
  6054. }
  6055. if len(insutypes) == 1 {
  6056. insutype = insutypes[0]
  6057. } else {
  6058. for _, i := range insutypes {
  6059. if i == "390" {
  6060. is390 = 1
  6061. }
  6062. if i == "310" {
  6063. is310 = 1
  6064. }
  6065. }
  6066. }
  6067. if is390 == 1 {
  6068. insutype = "390"
  6069. }
  6070. if is310 == 1 {
  6071. insutype = "310"
  6072. }
  6073. if len(insutypes) == 0 {
  6074. insutype = "310"
  6075. }
  6076. if len(insutypes) == 2 {
  6077. insutype = strconv.FormatInt(his.SocialType, 64)
  6078. }
  6079. //insutype = "390"
  6080. if his.IdCardType == 1 {
  6081. cert_no = his.MedicalInsuranceNumber
  6082. } else {
  6083. cert_no = his.Certno
  6084. }
  6085. var res ResultSeven
  6086. var resSeven10265 ResultSeven10265
  6087. if miConfig.MdtrtareaAdmvs == "421300" {
  6088. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6089. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6090. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6091. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6092. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6093. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6094. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6095. resp, requestErr := http.Get(api)
  6096. if requestErr != nil {
  6097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6098. return
  6099. }
  6100. body, ioErr := ioutil.ReadAll(resp.Body)
  6101. if ioErr != nil {
  6102. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6104. return
  6105. }
  6106. var respJSON map[string]interface{}
  6107. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6108. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6110. return
  6111. }
  6112. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6113. result, _ := json.Marshal(respJSON)
  6114. fmt.Println("log")
  6115. fmt.Println(string(result))
  6116. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6117. utils.ErrorLog("解析失败:%v", err)
  6118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6119. return
  6120. }
  6121. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6122. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6123. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6124. bas := strings.Split(psn_info.CardInfo, "|")
  6125. if his.IdCardType == 1 {
  6126. cert_no = bas[2]
  6127. } else {
  6128. cert_no = bas[1]
  6129. }
  6130. //江苏地区国家医保医疗类别
  6131. //职工透析:医疗类别选特殊情况门诊9933
  6132. //居民血透门慢: 医疗类别选门诊慢病1402
  6133. //var med_type string
  6134. //if his.Insutype == "310" {
  6135. // if reg_type == 14 {
  6136. // med_type = "9933"
  6137. // } else if reg_type == 11 {
  6138. // med_type = "11"
  6139. //
  6140. // }
  6141. //} else if his.Insutype == "390" {
  6142. // if reg_type == 14 {
  6143. // med_type = "1402"
  6144. // } else if reg_type == 11 {
  6145. // med_type = "11"
  6146. // }
  6147. //}
  6148. api := "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6149. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6150. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6151. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6152. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6153. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6154. "&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
  6155. resp, requestErr := http.Get(api)
  6156. if requestErr != nil {
  6157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6158. return
  6159. }
  6160. body, ioErr := ioutil.ReadAll(resp.Body)
  6161. if ioErr != nil {
  6162. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6164. return
  6165. }
  6166. var respJSON map[string]interface{}
  6167. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6168. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6170. return
  6171. }
  6172. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6173. result, _ := json.Marshal(respJSON)
  6174. fmt.Println("log")
  6175. fmt.Println(string(result))
  6176. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6177. utils.ErrorLog("解析失败:%v", err)
  6178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6179. return
  6180. }
  6181. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6182. res.Output = resSeven10265.Output
  6183. res.ErrMsg = resSeven10265.ErrMsg
  6184. res.Cainfo = resSeven10265.Cainfo
  6185. res.WarnMsg = resSeven10265.WarnMsg
  6186. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6187. res.Infcode = infocode
  6188. } else {
  6189. var result string
  6190. var request_log string
  6191. if miConfig.Code == "H15049901371" {
  6192. //赤峰地区国家医保医疗类别
  6193. //职工透析:医疗类别选特殊情况门诊990502
  6194. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6195. var med_type string
  6196. if his.Insutype == "390" {
  6197. if reg_type == 14 {
  6198. med_type = "9933"
  6199. } else if reg_type == 11 {
  6200. med_type = "11"
  6201. }
  6202. } else if his.Insutype == "310" {
  6203. if reg_type == 14 {
  6204. med_type = "990502"
  6205. } else if reg_type == 11 {
  6206. med_type = "11"
  6207. }
  6208. }
  6209. 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)
  6210. } else {
  6211. 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)
  6212. }
  6213. var dat map[string]interface{}
  6214. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6215. fmt.Println(dat)
  6216. } else {
  6217. fmt.Println(err)
  6218. }
  6219. saveLog(result, request_log, "2206", "预结算")
  6220. //userJSONBytes, _ := json.Marshal(dat)
  6221. //
  6222. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6223. // utils.ErrorLog("解析失败:%v", err)
  6224. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6225. // return
  6226. //}
  6227. userJSONBytes, _ := json.Marshal(dat)
  6228. if miConfig.Code == "H15049901371" {
  6229. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6230. utils.ErrorLog("解析失败:%v", err)
  6231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6232. return
  6233. }
  6234. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6235. res.Output = resSeven10265.Output
  6236. res.ErrMsg = resSeven10265.ErrMsg
  6237. res.Cainfo = resSeven10265.Cainfo
  6238. res.WarnMsg = resSeven10265.WarnMsg
  6239. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6240. res.Infcode = infocode
  6241. } else {
  6242. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6243. utils.ErrorLog("解析失败:%v", err)
  6244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6245. return
  6246. }
  6247. }
  6248. }
  6249. if res.Infcode != 0 {
  6250. errlog := &models.HisOrderError{
  6251. UserOrgId: adminUser.CurrentOrgId,
  6252. Ctime: time.Now().Unix(),
  6253. Mtime: time.Now().Unix(),
  6254. Number: chrg_bchno,
  6255. ErrMsg: res.ErrMsg,
  6256. Status: 1,
  6257. PatientId: id,
  6258. RecordTime: recordDateTime,
  6259. Stage: 20,
  6260. }
  6261. service.CreateErrMsgLog(errlog)
  6262. c.ServeSuccessJSON(map[string]interface{}{
  6263. "failed_code": -10,
  6264. "msg": res.ErrMsg,
  6265. })
  6266. return
  6267. } else {
  6268. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6269. order.OrderStatus = 1
  6270. order.IsPre = 1
  6271. order.Status = 1
  6272. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6273. order.SetlId = res.Output.Setlinfo.SetlID
  6274. order.PsnNo = res.Output.Setlinfo.PsnNo
  6275. order.PsnName = res.Output.Setlinfo.PsnName
  6276. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6277. order.Certno = res.Output.Setlinfo.Certno
  6278. order.Gend = res.Output.Setlinfo.Gend
  6279. order.Naty = res.Output.Setlinfo.Naty
  6280. order.Age = res.Output.Setlinfo.Age
  6281. order.Insutype = res.Output.Setlinfo.Insutype
  6282. order.PsnType = res.Output.Setlinfo.PsnType
  6283. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6284. order.SetlTime = res.Output.Setlinfo.SetlTime
  6285. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6286. if res.Output.Setlinfo.MedType == "140101" {
  6287. order.MedType = "14"
  6288. } else {
  6289. order.MedType = res.Output.Setlinfo.MedType
  6290. }
  6291. if reg_type == 1112 {
  6292. order.MedType = "1112"
  6293. }
  6294. if reg_type == 1111 {
  6295. order.MedType = "1111"
  6296. }
  6297. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6298. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6299. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6300. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6301. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6302. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6303. order.HifpPay = res.Output.Setlinfo.HifpPay
  6304. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6305. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6306. order.HifesPay = res.Output.Setlinfo.HifesPay
  6307. order.HifobPay = res.Output.Setlinfo.HifobPay
  6308. order.MafPay = res.Output.Setlinfo.MafPay
  6309. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6310. order.OthPay = res.Output.Setlinfo.OthPay
  6311. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6312. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6313. order.AcctPay = res.Output.Setlinfo.AcctPay
  6314. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6315. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6316. order.Balc = res.Output.Setlinfo.Balc
  6317. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6318. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6319. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6320. order.ClrWay = res.Output.Setlinfo.ClrWay
  6321. order.Creator = order.Creator
  6322. order.Modify = roles.AdminUserId
  6323. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6324. detailStr := string(setlDetail)
  6325. order.SetlDetail = detailStr
  6326. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6327. err = service.UpDateOrder(order)
  6328. if err == nil {
  6329. c.ServeSuccessJSON(map[string]interface{}{
  6330. "msg": "预结算成功",
  6331. })
  6332. } else {
  6333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6334. return
  6335. }
  6336. }
  6337. } else {
  6338. adminUser := c.GetAdminUserInfo()
  6339. errlog := &models.HisOrderError{
  6340. UserOrgId: adminUser.CurrentOrgId,
  6341. Ctime: time.Now().Unix(),
  6342. Mtime: time.Now().Unix(),
  6343. ErrMsg: res.ErrMsg,
  6344. Status: 1,
  6345. PatientId: id,
  6346. RecordTime: recordDateTime,
  6347. Stage: 4,
  6348. }
  6349. service.CreateErrMsgLog(errlog)
  6350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6351. return
  6352. }
  6353. } else {
  6354. adminUser := c.GetAdminUserInfo()
  6355. errlog := &models.HisOrderError{
  6356. UserOrgId: adminUser.CurrentOrgId,
  6357. Ctime: time.Now().Unix(),
  6358. Mtime: time.Now().Unix(),
  6359. ErrMsg: res.ErrMsg,
  6360. Status: 1,
  6361. PatientId: id,
  6362. RecordTime: recordDateTime,
  6363. Stage: 4,
  6364. }
  6365. service.CreateErrMsgLog(errlog)
  6366. c.ServeSuccessJSON(map[string]interface{}{
  6367. "failed_code": -10,
  6368. "msg": res.ErrMsg,
  6369. })
  6370. return
  6371. }
  6372. }
  6373. }
  6374. }
  6375. //func (c *HisApiController) GetSettleInfo() {
  6376. // id, _ := c.GetInt64("id")
  6377. // order_id, _ := c.GetInt64("order_id")
  6378. //
  6379. // record_time := c.GetString("record_time")
  6380. // pay_way, _ := c.GetInt64("pay_way")
  6381. // pay_price, _ := c.GetFloat("pay_price")
  6382. // pay_card_no := c.GetString("pay_card_no")
  6383. // discount_price, _ := c.GetFloat("discount_price")
  6384. // preferential_price, _ := c.GetFloat("preferential_price")
  6385. // reality_price, _ := c.GetFloat("reality_price")
  6386. // found_price, _ := c.GetFloat("found_price")
  6387. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6388. // private_price, _ := c.GetFloat("private_price")
  6389. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6390. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6391. //
  6392. // timeLayout := "2006-01-02"
  6393. // loc, _ := time.LoadLocation("Local")
  6394. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6395. // if err != nil {
  6396. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6397. // return
  6398. // }
  6399. // recordDateTime := theTime.Unix()
  6400. // adminUser := c.GetAdminUserInfo()
  6401. //
  6402. // var prescriptions []*models.HisPrescription
  6403. //
  6404. // data := make(map[string]interface{})
  6405. // if settle_accounts_type == 1 { //日结
  6406. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6407. // data["pre"] = prescriptions
  6408. //
  6409. // } else { //月结
  6410. // start_time_str := c.GetString("start_time")
  6411. // end_time_str := c.GetString("end_time")
  6412. // timeLayout := "2006-01-02"
  6413. // loc, _ := time.LoadLocation("Local")
  6414. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6415. // if err != nil {
  6416. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6417. // return
  6418. // }
  6419. // recordStartTime := theStartTime.Unix()
  6420. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6421. // if err != nil {
  6422. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6423. // return
  6424. // }
  6425. // recordEndTime := theEndTime.Unix()
  6426. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6427. // data["pre"] = prescriptions
  6428. //
  6429. // }
  6430. //
  6431. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6432. //
  6433. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6434. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6435. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6436. // strconv.FormatInt(his.PatientId, 10)
  6437. //
  6438. // order_src, _ := service.GetHisOrderByID(order_id)
  6439. //
  6440. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6441. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6442. //
  6443. // var total float64
  6444. // for _, item := range prescriptions {
  6445. // if item.Type == 1 { //药品
  6446. // for _, subItem := range item.HisDoctorAdviceInfo {
  6447. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6448. // }
  6449. // }
  6450. // if item.Type == 2 { //项目
  6451. // for _, subItem := range item.HisPrescriptionProject {
  6452. // total = total + (subItem.Price * float64(subItem.Count))
  6453. // }
  6454. // }
  6455. // }
  6456. //
  6457. // for _, item := range prescriptions {
  6458. // for _, subItem := range item.HisAdditionalCharge {
  6459. // total = total + (subItem.Price * float64(subItem.Count))
  6460. // }
  6461. // }
  6462. //
  6463. // allTotal := fmt.Sprintf("%.2f", total)
  6464. // var rf []*ResultFive
  6465. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6466. // psn_no := order_src.PsnNo
  6467. // mdtrt_id := order_src.MdtrtId
  6468. // chrg_bchno := order_src.Number
  6469. // cert_no := order_src.Certno
  6470. // insutype := rf[0].Insutype
  6471. //
  6472. // if his.IdCardType == 1 {
  6473. // cert_no = his.MedicalInsuranceNumber
  6474. // } else {
  6475. // cert_no = his.Certno
  6476. // }
  6477. //
  6478. // 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)
  6479. // var dat map[string]interface{}
  6480. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6481. // fmt.Println(dat)
  6482. // } else {
  6483. // fmt.Println(err)
  6484. // }
  6485. //
  6486. // userJSONBytes, _ := json.Marshal(dat)
  6487. //
  6488. //
  6489. //
  6490. // var res ResultSeven
  6491. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6492. // utils.ErrorLog("解析失败:%v", err)
  6493. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6494. // return
  6495. // }
  6496. // if res.Infcode == -1 {
  6497. // errlog := &models.HisOrderError{
  6498. // UserOrgId: adminUser.CurrentOrgId,
  6499. // Ctime: time.Now().Unix(),
  6500. // Mtime: time.Now().Unix(),
  6501. // Number: chrg_bchno,
  6502. // ErrMsg: res.ErrMsg,
  6503. // Status: 1,
  6504. // PatientId: id,
  6505. // RecordTime: recordDateTime,
  6506. // Stage: 6,
  6507. // }
  6508. // service.CreateErrMsgLog(errlog)
  6509. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6510. // return
  6511. // } else {
  6512. // order_src.OrderStatus = 2
  6513. // order_src.PayWay = pay_way
  6514. // order_src.PayPrice = pay_price
  6515. // order_src.PayCardNo = pay_card_no
  6516. // order_src.DiscountPrice = discount_price
  6517. // order_src.PreferentialPrice = preferential_price
  6518. // order_src.RealityPrice = reality_price
  6519. // order_src.FoundPrice = found_price
  6520. // order_src.MedicalInsurancePrice = medical_insurance_price
  6521. // order_src.PrivatePrice = private_price
  6522. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  6523. // order_src.SetlId = res.Output.Setlinfo.SetlID
  6524. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  6525. // order_src.PsnName = res.Output.Setlinfo.PsnName
  6526. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  6527. // order_src.Certno = res.Output.Setlinfo.Certno
  6528. // order_src.Gend = res.Output.Setlinfo.Gend
  6529. // order_src.Naty = res.Output.Setlinfo.Naty
  6530. // order_src.Age = res.Output.Setlinfo.Age
  6531. // order_src.Insutype = res.Output.Setlinfo.Insutype
  6532. // order_src.PsnType = res.Output.Setlinfo.PsnType
  6533. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6534. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  6535. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6536. // order_src.MedType = res.Output.Setlinfo.MedType
  6537. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6538. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6539. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6540. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6541. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6542. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6543. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  6544. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  6545. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6546. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  6547. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  6548. // order_src.MafPay = res.Output.Setlinfo.MafPay
  6549. // order_src.OthPay = res.Output.Setlinfo.OthPay
  6550. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6551. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6552. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  6553. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6554. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6555. // order_src.Balc = res.Output.Setlinfo.Balc
  6556. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6557. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6558. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  6559. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  6560. // order_src.Creator = order_src.Creator
  6561. // order_src.Modify = roles.ID
  6562. // order_src.RequestLog = src_resquest
  6563. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6564. // detailStr := string(setlDetail)
  6565. // order_src.SetlDetail = detailStr
  6566. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6567. // err = service.UpDateOrder(order_src)
  6568. //
  6569. // if err == nil {
  6570. // c.ServeSuccessJSON(map[string]interface{}{
  6571. // "msg": "结算成功",
  6572. // })
  6573. // } else {
  6574. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6575. // return
  6576. // }
  6577. // }
  6578. // }
  6579. //}
  6580. //退款
  6581. func (c *HisApiController) Refund() {
  6582. order_id, _ := c.GetInt64("order_id")
  6583. admin_user_id, _ := c.GetInt64("admin_user_id")
  6584. adminUser := c.GetAdminUserInfo()
  6585. var order models.HisOrder
  6586. order, _ = service.GetHisOrderByID(order_id)
  6587. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6588. if order.ID == 0 {
  6589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6590. return
  6591. }
  6592. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6593. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6594. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6595. if config.IsOpen == 1 { //对接了医保,走医保流程
  6596. var res ResultSixteen
  6597. var resSixteen10265 ResultSixteen10265
  6598. var src_resquest string
  6599. var result string
  6600. if miConfig.MdtrtareaAdmvs == "421300" {
  6601. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  6602. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6603. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6604. resp3, requestErr3 := http.Get(api3)
  6605. if requestErr3 != nil {
  6606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6607. return
  6608. }
  6609. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6610. if ioErr3 != nil {
  6611. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6613. return
  6614. }
  6615. var respJSON3 map[string]interface{}
  6616. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6617. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6619. return
  6620. }
  6621. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6622. userJSONBytes3, _ := json.Marshal(respJSON3)
  6623. fmt.Println("log")
  6624. fmt.Println(string(userJSONBytes3))
  6625. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  6626. utils.ErrorLog("解析失败:%v", err)
  6627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6628. return
  6629. }
  6630. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6631. api3 := "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6632. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6633. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6634. resp3, requestErr3 := http.Get(api3)
  6635. if requestErr3 != nil {
  6636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6637. return
  6638. }
  6639. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6640. if ioErr3 != nil {
  6641. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6643. return
  6644. }
  6645. var respJSON3 map[string]interface{}
  6646. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6647. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6649. return
  6650. }
  6651. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6652. userJSONBytes3, _ := json.Marshal(respJSON3)
  6653. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  6654. utils.ErrorLog("解析失败:%v", err)
  6655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6656. return
  6657. }
  6658. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6659. res.Output = resSixteen10265.Output
  6660. res.ErrMsg = resSixteen10265.ErrMsg
  6661. res.Cainfo = resSixteen10265.Cainfo
  6662. res.WarnMsg = resSixteen10265.WarnMsg
  6663. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6664. res.Infcode = infocode
  6665. } else {
  6666. if miConfig.Code == "H15049901371" {
  6667. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6668. var dat map[string]interface{}
  6669. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6670. fmt.Println(dat)
  6671. } else {
  6672. fmt.Println(err)
  6673. }
  6674. saveLog(result, src_resquest, "2208", "退费")
  6675. userJSONBytes, _ := json.Marshal(dat)
  6676. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  6677. utils.ErrorLog("解析失败:%v", err)
  6678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6679. return
  6680. }
  6681. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6682. res.Output = resSixteen10265.Output
  6683. res.ErrMsg = resSixteen10265.ErrMsg
  6684. res.Cainfo = resSixteen10265.Cainfo
  6685. res.WarnMsg = resSixteen10265.WarnMsg
  6686. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6687. res.Infcode = infocode
  6688. } else {
  6689. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6690. var dat map[string]interface{}
  6691. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6692. fmt.Println(dat)
  6693. } else {
  6694. fmt.Println(err)
  6695. }
  6696. saveLog(result, src_resquest, "2208", "退费")
  6697. userJSONBytes, _ := json.Marshal(dat)
  6698. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6699. utils.ErrorLog("解析失败:%v", err)
  6700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6701. return
  6702. }
  6703. }
  6704. }
  6705. if res.Infcode == 0 {
  6706. var res2 ResultSix
  6707. var resSix10265 ResultSix10265
  6708. if miConfig.MdtrtareaAdmvs == "421300" {
  6709. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6710. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6711. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6712. resp3, requestErr3 := http.Get(api3)
  6713. if requestErr3 != nil {
  6714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6715. return
  6716. }
  6717. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6718. if ioErr3 != nil {
  6719. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6721. return
  6722. }
  6723. var respJSON3 map[string]interface{}
  6724. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6725. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6727. return
  6728. }
  6729. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6730. userJSONBytes3, _ := json.Marshal(respJSON3)
  6731. fmt.Println("log")
  6732. fmt.Println(string(userJSONBytes3))
  6733. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6734. utils.ErrorLog("解析失败:%v", err)
  6735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6736. return
  6737. }
  6738. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6739. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6740. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6741. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6742. resp3, requestErr3 := http.Get(api3)
  6743. if requestErr3 != nil {
  6744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6745. return
  6746. }
  6747. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6748. if ioErr3 != nil {
  6749. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6751. return
  6752. }
  6753. var respJSON3 map[string]interface{}
  6754. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6757. return
  6758. }
  6759. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6760. userJSONBytes3, _ := json.Marshal(respJSON3)
  6761. fmt.Println("log")
  6762. fmt.Println(string(userJSONBytes3))
  6763. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6764. utils.ErrorLog("解析失败:%v", err)
  6765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6766. return
  6767. }
  6768. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6769. res2.Output = resSix10265.Output
  6770. res2.ErrMsg = resSix10265.ErrMsg
  6771. res2.Cainfo = resSix10265.Cainfo
  6772. res2.WarnMsg = resSix10265.WarnMsg
  6773. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6774. res2.Infcode = infocode
  6775. } else {
  6776. if miConfig.Code == "H15049901371" {
  6777. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6778. var dat map[string]interface{}
  6779. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6780. fmt.Println(dat)
  6781. } else {
  6782. fmt.Println(err)
  6783. }
  6784. saveLog(result2, src_request, "2205", "撤销明细")
  6785. userJSONBytes, _ := json.Marshal(dat)
  6786. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6787. utils.ErrorLog("解析失败:%v", err)
  6788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6789. return
  6790. }
  6791. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6792. res2.Output = resSix10265.Output
  6793. res2.ErrMsg = resSix10265.ErrMsg
  6794. res2.Cainfo = resSix10265.Cainfo
  6795. res2.WarnMsg = resSix10265.WarnMsg
  6796. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6797. res2.Infcode = infocode
  6798. } else {
  6799. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6800. var dat map[string]interface{}
  6801. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6802. fmt.Println(dat)
  6803. } else {
  6804. fmt.Println(err)
  6805. }
  6806. saveLog(result2, src_request, "2205", "撤销明细")
  6807. userJSONBytes, _ := json.Marshal(dat)
  6808. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6809. utils.ErrorLog("解析失败:%v", err)
  6810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6811. return
  6812. }
  6813. }
  6814. }
  6815. if res2.Infcode == 0 {
  6816. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  6817. if err == nil {
  6818. c.ServeSuccessJSON(map[string]interface{}{
  6819. "msg": "退费成功",
  6820. })
  6821. } else {
  6822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6823. return
  6824. }
  6825. } else {
  6826. c.ServeSuccessJSON(map[string]interface{}{
  6827. "code": -10,
  6828. "msg": res2.ErrMsg,
  6829. })
  6830. }
  6831. } else {
  6832. c.ServeSuccessJSON(map[string]interface{}{
  6833. "code": -10,
  6834. "msg": res.ErrMsg,
  6835. })
  6836. }
  6837. }
  6838. }
  6839. func (c *HisApiController) RefundNumber() {
  6840. record_time := c.GetString("record_time")
  6841. //patient_id, _ := c.GetInt64("patient_id")
  6842. admin_user_id, _ := c.GetInt64("admin_user_id")
  6843. his_patient_id, _ := c.GetInt64("id")
  6844. timeLayout := "2006-01-02"
  6845. loc, _ := time.LoadLocation("Local")
  6846. adminUser := c.GetAdminUserInfo()
  6847. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6848. fmt.Println(err)
  6849. if err != nil {
  6850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6851. return
  6852. }
  6853. recordDateTime := theTime.Unix()
  6854. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6855. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  6856. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6857. //order, _ := service.GetHisOrderByID(order_id)
  6858. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6859. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6860. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6861. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  6862. if count > 0 {
  6863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  6864. return
  6865. }
  6866. if config.IsOpen == 1 { //对接了医保,走医保流程
  6867. var res2 ResultSix
  6868. var resSix10265 ResultSix10265
  6869. if miConfig.MdtrtareaAdmvs == "421300" {
  6870. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  6871. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6872. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6873. resp3, requestErr3 := http.Get(api3)
  6874. if requestErr3 != nil {
  6875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6876. return
  6877. }
  6878. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6879. if ioErr3 != nil {
  6880. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6882. return
  6883. }
  6884. var respJSON3 map[string]interface{}
  6885. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6888. return
  6889. }
  6890. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6891. userJSONBytes3, _ := json.Marshal(respJSON3)
  6892. fmt.Println("log")
  6893. fmt.Println(string(userJSONBytes3))
  6894. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6895. utils.ErrorLog("解析失败:%v", err)
  6896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6897. return
  6898. }
  6899. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6900. api3 := "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6901. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6902. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6903. resp3, requestErr3 := http.Get(api3)
  6904. if requestErr3 != nil {
  6905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6906. return
  6907. }
  6908. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6909. if ioErr3 != nil {
  6910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6912. return
  6913. }
  6914. var respJSON3 map[string]interface{}
  6915. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6918. return
  6919. }
  6920. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6921. userJSONBytes3, _ := json.Marshal(respJSON3)
  6922. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6923. utils.ErrorLog("解析失败:%v", err)
  6924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6925. return
  6926. }
  6927. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6928. res2.Output = resSix10265.Output
  6929. res2.ErrMsg = resSix10265.ErrMsg
  6930. res2.Cainfo = resSix10265.Cainfo
  6931. res2.WarnMsg = resSix10265.WarnMsg
  6932. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6933. res2.Infcode = infocode
  6934. } else {
  6935. var api3 string
  6936. if miConfig.Code == "H15049901371" {
  6937. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6938. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6939. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6940. } else {
  6941. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6942. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6943. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6944. }
  6945. resp3, requestErr3 := http.Get(api3)
  6946. if requestErr3 != nil {
  6947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6948. return
  6949. }
  6950. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6951. if ioErr3 != nil {
  6952. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6954. return
  6955. }
  6956. var respJSON3 map[string]interface{}
  6957. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6958. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6960. return
  6961. }
  6962. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6963. userJSONBytes3, _ := json.Marshal(respJSON3)
  6964. if miConfig.Code == "H15049901371" {
  6965. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6966. utils.ErrorLog("解析失败:%v", err)
  6967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6968. return
  6969. }
  6970. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6971. res2.Output = resSix10265.Output
  6972. res2.ErrMsg = resSix10265.ErrMsg
  6973. res2.Cainfo = resSix10265.Cainfo
  6974. res2.WarnMsg = resSix10265.WarnMsg
  6975. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6976. res2.Infcode = infocode
  6977. } else {
  6978. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6979. utils.ErrorLog("解析失败:%v", err)
  6980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6981. return
  6982. }
  6983. }
  6984. }
  6985. if res2.Infcode == 0 {
  6986. if err == nil {
  6987. c.ServeSuccessJSON(map[string]interface{}{
  6988. "msg": "退号成功",
  6989. })
  6990. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  6991. } else {
  6992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6993. return
  6994. }
  6995. } else {
  6996. c.ServeSuccessJSON(map[string]interface{}{
  6997. "code": -10,
  6998. "msg": res2.ErrMsg,
  6999. })
  7000. }
  7001. } else {
  7002. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7003. //if err == nil {
  7004. // c.ServeSuccessJSON(map[string]interface{}{
  7005. // "msg": "退费成功",
  7006. // })
  7007. //} else {
  7008. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7009. // return
  7010. //}
  7011. }
  7012. }
  7013. func (c *HisApiController) RefundDetail() {
  7014. order_id, _ := c.GetInt64("order_id")
  7015. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7016. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7017. number := c.GetString("number")
  7018. record_time := c.GetString("record_time")
  7019. patient_id, _ := c.GetInt64("patient_id")
  7020. timeLayout := "2006-01-02"
  7021. loc, _ := time.LoadLocation("Local")
  7022. adminUser := c.GetAdminUserInfo()
  7023. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7024. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7025. fmt.Println(err)
  7026. if err != nil {
  7027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7028. return
  7029. }
  7030. recordDateTime := theTime.Unix()
  7031. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7032. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7033. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7034. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7035. var order models.HisOrder
  7036. order, _ = service.GetHisOrderByID(order_id)
  7037. if order.ID == 0 {
  7038. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  7039. }
  7040. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7041. if config.IsOpen == 1 { //对接了医保,走医保流程
  7042. var res2 ResultSix
  7043. if miConfig.MdtrtareaAdmvs == "421300" {
  7044. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7045. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7046. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7047. resp3, requestErr3 := http.Get(api3)
  7048. if requestErr3 != nil {
  7049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7050. return
  7051. }
  7052. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7053. if ioErr3 != nil {
  7054. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7056. return
  7057. }
  7058. var respJSON3 map[string]interface{}
  7059. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7060. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7062. return
  7063. }
  7064. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7065. userJSONBytes3, _ := json.Marshal(respJSON3)
  7066. fmt.Println("log")
  7067. fmt.Println(string(userJSONBytes3))
  7068. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7069. utils.ErrorLog("解析失败:%v", err)
  7070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7071. return
  7072. }
  7073. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7074. if err == nil {
  7075. c.ServeSuccessJSON(map[string]interface{}{
  7076. "msg": "撤销明细成功",
  7077. })
  7078. return
  7079. } else {
  7080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7081. return
  7082. }
  7083. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7084. var resSix10265 ResultSix10265
  7085. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7086. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7087. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7088. resp3, requestErr3 := http.Get(api3)
  7089. if requestErr3 != nil {
  7090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7091. return
  7092. }
  7093. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7094. if ioErr3 != nil {
  7095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7097. return
  7098. }
  7099. var respJSON3 map[string]interface{}
  7100. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7103. return
  7104. }
  7105. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7106. userJSONBytes3, _ := json.Marshal(respJSON3)
  7107. fmt.Println("log")
  7108. fmt.Println(string(userJSONBytes3))
  7109. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7110. utils.ErrorLog("解析失败:%v", err)
  7111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7112. return
  7113. }
  7114. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7115. res2.Output = resSix10265.Output
  7116. res2.ErrMsg = resSix10265.ErrMsg
  7117. res2.Cainfo = resSix10265.Cainfo
  7118. res2.WarnMsg = resSix10265.WarnMsg
  7119. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7120. res2.Infcode = infocode
  7121. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7122. if err == nil {
  7123. c.ServeSuccessJSON(map[string]interface{}{
  7124. "msg": "撤销明细成功",
  7125. })
  7126. return
  7127. } else {
  7128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7129. return
  7130. }
  7131. } else {
  7132. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  7133. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7134. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7135. resp2, requestErr2 := http.Get(api2)
  7136. if requestErr2 != nil {
  7137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7138. return
  7139. }
  7140. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7141. if ioErr2 != nil {
  7142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7144. return
  7145. }
  7146. var respJSON2 map[string]interface{}
  7147. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7150. return
  7151. }
  7152. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7153. if err == nil {
  7154. c.ServeSuccessJSON(map[string]interface{}{
  7155. "msg": "撤销明细成功",
  7156. })
  7157. return
  7158. } else {
  7159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7160. return
  7161. }
  7162. }
  7163. } else {
  7164. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7165. if err == nil {
  7166. c.ServeSuccessJSON(map[string]interface{}{
  7167. "msg": "退费成功",
  7168. })
  7169. } else {
  7170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7171. return
  7172. }
  7173. }
  7174. }
  7175. //对账
  7176. func (c *HisApiController) GetCheckAccount() {
  7177. start_time := c.GetString("start_time")
  7178. end_time := c.GetString("end_time")
  7179. insutype := c.GetString("insutype")
  7180. clr_type := c.GetString("clr_type")
  7181. clr_org := c.GetString("clr_optins")
  7182. admin_user_id, _ := c.GetInt64("admin_user_id")
  7183. adminUser := c.GetAdminUserInfo()
  7184. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7185. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7186. if len(clr_org) == 0 {
  7187. clr_org = miConfig.MdtrtareaAdmvs
  7188. }
  7189. timeLayout := "2006-01-02"
  7190. loc, _ := time.LoadLocation("Local")
  7191. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7192. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7193. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  7194. fixmedins_setl_cnt := int64(len(orders))
  7195. var medfee_sumamt float64
  7196. var acct_pay float64
  7197. var fund_pay_sumamt float64
  7198. for _, item := range orders {
  7199. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7200. acct_pay = acct_pay + item.AcctPay
  7201. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7202. }
  7203. var user_name string
  7204. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7205. if role.ID == 0 {
  7206. user_name = "xxx"
  7207. } else {
  7208. user_name = role.UserName
  7209. }
  7210. var res ResultEight
  7211. var res10188 ResultEightFor10188
  7212. if config.IsOpen == 1 {
  7213. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7214. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  7215. "insutype=" + insutype +
  7216. "&clr_type=" + "11" +
  7217. "&setl_optins=" + clr_org +
  7218. "&stmt_begndate=" + start_time +
  7219. "&stm_enddate=" + end_time +
  7220. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7221. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7222. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7223. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7224. "&fixmedins_code=" + miConfig.Code +
  7225. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7226. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7227. "&secret_key=" + miConfig.SecretKey +
  7228. "&org_name=" + miConfig.OrgName +
  7229. "&doctor=" + user_name +
  7230. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7231. fmt.Println(api)
  7232. resp, requestErr := http.Get(api)
  7233. if requestErr != nil {
  7234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7235. return
  7236. }
  7237. body, ioErr := ioutil.ReadAll(resp.Body)
  7238. fmt.Println(body)
  7239. if ioErr != nil {
  7240. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7242. return
  7243. }
  7244. var respJSON map[string]interface{}
  7245. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7246. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7248. return
  7249. }
  7250. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7251. userJSONBytes, _ := json.Marshal(respJSON)
  7252. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7253. utils.ErrorLog("解析失败:%v", err)
  7254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7255. return
  7256. }
  7257. res.InfRefmsgid = res10188.InfRefmsgid
  7258. res.Output = res10188.Output
  7259. res.ErrMsg = res10188.ErrMsg
  7260. res.Cainfo = res10188.Cainfo
  7261. res.WarnMsg = res10188.WarnMsg
  7262. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  7263. res.Infcode = infocode
  7264. } else {
  7265. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7266. "insutype=" + insutype +
  7267. "&clr_type=" + clr_type +
  7268. "&setl_optins=" + clr_org +
  7269. "&stmt_begndate=" + start_time +
  7270. "&stm_enddate=" + end_time +
  7271. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7272. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7273. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7274. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7275. "&fixmedins_code=" + miConfig.Code +
  7276. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7277. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7278. "&secret_key=" + miConfig.SecretKey +
  7279. "&org_name=" + miConfig.OrgName +
  7280. "&doctor=" + user_name
  7281. fmt.Println(api)
  7282. resp, requestErr := http.Get(api)
  7283. if requestErr != nil {
  7284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7285. return
  7286. }
  7287. body, ioErr := ioutil.ReadAll(resp.Body)
  7288. fmt.Println(body)
  7289. if ioErr != nil {
  7290. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7292. return
  7293. }
  7294. var respJSON map[string]interface{}
  7295. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7298. return
  7299. }
  7300. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7301. userJSONBytes, _ := json.Marshal(respJSON)
  7302. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7303. utils.ErrorLog("解析失败:%v", err)
  7304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7305. return
  7306. }
  7307. }
  7308. if res.Infcode == 0 {
  7309. if res.Output.Stmtinfo.StmtRslt == "0" {
  7310. micc := &models.MedicalInsuranceCostCompare{
  7311. StartTime: startime.Unix(),
  7312. EndTime: endtime.Unix(),
  7313. Insutype: insutype,
  7314. CheckType: 1,
  7315. Num: fixmedins_setl_cnt,
  7316. Mtime: time.Now().Unix(),
  7317. Status: 1,
  7318. UserOrgId: adminUser.CurrentOrgId,
  7319. CostTotal: medfee_sumamt,
  7320. FuncTotal: fund_pay_sumamt,
  7321. PsnPay: acct_pay,
  7322. Creator: admin_user_id,
  7323. Ctime: time.Now().Unix(),
  7324. ClrType: clr_type,
  7325. }
  7326. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  7327. if err == nil {
  7328. c.ServeSuccessJSON(map[string]interface{}{
  7329. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7330. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7331. })
  7332. } else {
  7333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7334. }
  7335. } else {
  7336. c.ServeSuccessJSON(map[string]interface{}{
  7337. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7338. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7339. })
  7340. }
  7341. } else {
  7342. c.ServeSuccessJSON(map[string]interface{}{
  7343. "code": -10,
  7344. "msg": res.ErrMsg,
  7345. })
  7346. }
  7347. }
  7348. }
  7349. func (c *HisApiController) Check310() {
  7350. adminUser := c.GetAdminUserInfo()
  7351. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7352. var user_name string
  7353. user_name = "高慧裕"
  7354. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7355. "insutype=" + "310" +
  7356. "&clr_type=" + "" +
  7357. "&setl_optins=" + "441202" +
  7358. "&stmt_begndate=" + "2022-03-01" +
  7359. "&stm_enddate=" + "2022-03-31" +
  7360. "&medfee_sumamt=" + "194930.12" +
  7361. "&fund_pay_sumamt=" + "188741.46" +
  7362. "&acct_pay=" + "0" +
  7363. "&fixmedins_setl_cnt=" + "452" +
  7364. "&fixmedins_code=" + miConfig.Code +
  7365. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7366. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7367. "&secret_key=" + miConfig.SecretKey +
  7368. "&org_name=" + miConfig.OrgName +
  7369. "&doctor=" + user_name
  7370. fmt.Println(api)
  7371. resp, requestErr := http.Get(api)
  7372. if requestErr != nil {
  7373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7374. return
  7375. }
  7376. body, ioErr := ioutil.ReadAll(resp.Body)
  7377. fmt.Println(body)
  7378. if ioErr != nil {
  7379. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7381. return
  7382. }
  7383. var respJSON map[string]interface{}
  7384. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7387. return
  7388. }
  7389. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7390. userJSONBytes, _ := json.Marshal(respJSON)
  7391. var res ResultEight
  7392. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7393. utils.ErrorLog("解析失败:%v", err)
  7394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7395. return
  7396. }
  7397. }
  7398. func (c *HisApiController) Check390() {
  7399. adminUser := c.GetAdminUserInfo()
  7400. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7401. var user_name string
  7402. user_name = "高慧裕"
  7403. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7404. "insutype=" + "390" +
  7405. "&clr_type=" + "" +
  7406. "&setl_optins=" + "441202" +
  7407. "&stmt_begndate=" + "2022-03-01" +
  7408. "&stm_enddate=" + "2022-03-31" +
  7409. "&medfee_sumamt=" + "1068448.89" +
  7410. "&fund_pay_sumamt=" + "1014677.62" +
  7411. "&acct_pay=" + "0" +
  7412. "&fixmedins_setl_cnt=" + "1950" +
  7413. "&fixmedins_code=" + miConfig.Code +
  7414. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7415. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7416. "&secret_key=" + miConfig.SecretKey +
  7417. "&org_name=" + miConfig.OrgName +
  7418. "&doctor=" + user_name
  7419. fmt.Println(api)
  7420. resp, requestErr := http.Get(api)
  7421. if requestErr != nil {
  7422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7423. return
  7424. }
  7425. body, ioErr := ioutil.ReadAll(resp.Body)
  7426. fmt.Println(body)
  7427. if ioErr != nil {
  7428. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7430. return
  7431. }
  7432. var respJSON map[string]interface{}
  7433. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7434. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7436. return
  7437. }
  7438. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7439. userJSONBytes, _ := json.Marshal(respJSON)
  7440. var res ResultEight
  7441. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7442. utils.ErrorLog("解析失败:%v", err)
  7443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7444. return
  7445. }
  7446. }
  7447. //对账明细
  7448. func (c *HisApiController) GetCheckDetailAccount() {
  7449. start_time := c.GetString("start_time")
  7450. end_time := c.GetString("end_time")
  7451. admin_user_id, _ := c.GetInt64("admin_user_id")
  7452. adminUser := c.GetAdminUserInfo()
  7453. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7454. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7455. timeLayout := "2006-01-02"
  7456. loc, _ := time.LoadLocation("Local")
  7457. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7458. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7459. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  7460. Mkdir(miConfig.OrgName)
  7461. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  7462. file_name := file + ".txt"
  7463. zip_name := file + ".zip"
  7464. zip_path := miConfig.OrgName + "/" + zip_name
  7465. file_path := miConfig.OrgName + "/" + file_name
  7466. decimal.DivisionPrecision = 2
  7467. var medfee_sumamt float64
  7468. var psn_cash_pay float64
  7469. var fund_pay_sumamt float64
  7470. fixmedins_setl_cnt := int64(len(orders))
  7471. for _, item := range orders {
  7472. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7473. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  7474. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7475. }
  7476. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  7477. defer f.Close()
  7478. if err != nil {
  7479. fmt.Println(err.Error())
  7480. } else {
  7481. for _, item := range orders {
  7482. var refd_setl_flag string
  7483. if item.OrderStatus == 2 {
  7484. refd_setl_flag = "0"
  7485. var str string
  7486. str = item.SetlId + " " +
  7487. item.MdtrtId + " " +
  7488. item.PsnNo + " " +
  7489. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7490. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7491. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  7492. _, err = f.Write([]byte(str))
  7493. }
  7494. if item.OrderStatus == 3 {
  7495. var str string
  7496. str = item.SetlId + " " +
  7497. item.MdtrtId + " " +
  7498. item.PsnNo + " " +
  7499. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7500. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7501. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  7502. _, err = f.Write([]byte(str))
  7503. var str2 string
  7504. str2 = item.SetlId + " " +
  7505. item.MdtrtId + " " +
  7506. item.PsnNo + " " +
  7507. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  7508. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  7509. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  7510. _, err = f.Write([]byte(str2))
  7511. }
  7512. }
  7513. }
  7514. Zip(file_path, zip_path)
  7515. fmt.Println(ReadFile(zip_path))
  7516. fmt.Println(string(ReadFile(zip_path)))
  7517. if config.IsOpen == 1 {
  7518. var user_name string
  7519. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7520. if role.ID == 0 {
  7521. user_name = "管理员"
  7522. } else {
  7523. user_name = role.UserName
  7524. }
  7525. baseParams := models.BaseParams{
  7526. SecretKey: miConfig.SecretKey,
  7527. FixmedinsCode: miConfig.Code,
  7528. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7529. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7530. OrgName: miConfig.OrgName,
  7531. Doctor: user_name,
  7532. }
  7533. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  7534. var dat map[string]interface{}
  7535. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7536. fmt.Println(dat)
  7537. } else {
  7538. fmt.Println(err)
  7539. }
  7540. userJSONBytes, _ := json.Marshal(dat)
  7541. var res ResultNine
  7542. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7543. utils.ErrorLog("解析失败:%v", err)
  7544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7545. return
  7546. }
  7547. if res.Infcode == 0 {
  7548. fileNo := res.Output.FileQuryNo
  7549. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  7550. "file_qury_no=" + fileNo +
  7551. "&setl_optins=" + "定点医保中心" +
  7552. "&stmt_begndate=" + start_time +
  7553. "&stm_enddate=" + end_time +
  7554. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7555. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7556. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  7557. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7558. "&fixmedins_code=" + miConfig.Code +
  7559. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7560. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7561. "&secret_key=" + miConfig.SecretKey +
  7562. "&org_name=" + miConfig.OrgName +
  7563. "&doctor=" + user_name
  7564. resp, requestErr := http.Get(api)
  7565. if requestErr != nil {
  7566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7567. return
  7568. }
  7569. body, ioErr := ioutil.ReadAll(resp.Body)
  7570. if ioErr != nil {
  7571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7573. return
  7574. }
  7575. var respJSON map[string]interface{}
  7576. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7577. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7579. return
  7580. }
  7581. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7582. userJSONBytes, _ := json.Marshal(respJSON)
  7583. var res ResultTen
  7584. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7585. utils.ErrorLog("解析失败:%v", err)
  7586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7587. return
  7588. }
  7589. if res.Infcode == 0 {
  7590. service.Gdyb9102(baseParams, zip_name, fileNo)
  7591. micc := &models.MedicalInsuranceCostCompare{
  7592. StartTime: startime.Unix(),
  7593. EndTime: endtime.Unix(),
  7594. Insutype: "0",
  7595. CheckType: 2,
  7596. Num: fixmedins_setl_cnt,
  7597. Mtime: time.Now().Unix(),
  7598. Status: 1,
  7599. UserOrgId: adminUser.CurrentOrgId,
  7600. CostTotal: medfee_sumamt,
  7601. FuncTotal: fund_pay_sumamt,
  7602. PsnPay: psn_cash_pay,
  7603. Creator: admin_user_id,
  7604. Ctime: time.Now().Unix(),
  7605. }
  7606. service.CreateMedicalInsuranceCostCompareRecord(micc)
  7607. c.ServeSuccessJSON(map[string]interface{}{
  7608. "msg": "明细对账成功",
  7609. })
  7610. }
  7611. } else {
  7612. }
  7613. }
  7614. }
  7615. type CustomOrderInfo struct {
  7616. Name string
  7617. Spec string
  7618. Unit string
  7619. Count float64
  7620. Price float64
  7621. Total float64
  7622. }
  7623. func (c *HisApiController) GetSettleAccounts() {
  7624. //id, _ := c.GetInt64("id")
  7625. //record_time := c.GetString("record_time")
  7626. order_id, _ := c.GetInt64("order_id")
  7627. admin_user_id, _ := c.GetInt64("admin_user_id")
  7628. //timeLayout := "2006-01-02"
  7629. //loc, _ := time.LoadLocation("Local")
  7630. //
  7631. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7632. //if err != nil {
  7633. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7634. // return
  7635. //}
  7636. //recordDateTime := theTime.Unix()
  7637. adminUser := c.GetAdminUserInfo()
  7638. order, _ := service.GetHisOrderByID(order_id)
  7639. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7640. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  7641. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  7642. orderInfos = append(orderInfos, orderInfos_two...)
  7643. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7644. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  7645. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7646. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  7647. //var config []*models.HisXtDiagnoseConfig
  7648. var name string
  7649. for _, item := range diagnosis_ids {
  7650. id, _ := strconv.ParseInt(item, 10, 64)
  7651. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7652. if len(name) == 0 {
  7653. name = diagnosisConfig.ClassName
  7654. } else {
  7655. name = name + "," + diagnosisConfig.ClassName
  7656. }
  7657. }
  7658. var bedCostTotal float64 = 0 //床位总费
  7659. var bedCostSelfTotal float64 = 0 //床位自费
  7660. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7661. var operationCostTotal float64 = 0 //手术费
  7662. var operationCostSelfTotal float64 = 0 //手术费
  7663. var operationCostPartSelfTotal float64 = 0 //手术费
  7664. var otherCostTotal float64 = 0 //其他费用
  7665. var otherCostSelfTotal float64 = 0 //其他费用
  7666. var otherCostPartSelfTotal float64 = 0 //其他费用
  7667. var materialCostTotal float64 = 0 //材料费
  7668. var materialCostSelfTotal float64 = 0 //材料费
  7669. var materialCostPartSelfTotal float64 = 0 //材料费
  7670. var westernMedicineCostTotal float64 = 0 //西药费
  7671. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7672. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7673. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7674. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7675. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7676. var checkCostTotal float64 = 0 //检查费
  7677. var checkCostSelfTotal float64 = 0 //检查费
  7678. var checkCostPartSelfTotal float64 = 0 //检查费
  7679. var laboratoryCostTotal float64 = 0 //化验费
  7680. var laboratoryCostSelfTotal float64 = 0 //化验费
  7681. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7682. var treatCostTotal float64 = 0 //治疗费用
  7683. var treatCostSelfTotal float64 = 0 //治疗费用
  7684. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7685. decimal.DivisionPrecision = 2
  7686. for _, item := range orderInfos {
  7687. if item.MedChrgitmType == "01" { //床位费
  7688. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7689. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7690. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7691. }
  7692. if item.MedChrgitmType == "03" { //检查费
  7693. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7694. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7695. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7696. }
  7697. if item.MedChrgitmType == "04" { //化验费
  7698. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7699. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7700. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7701. }
  7702. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  7703. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7704. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7705. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7706. }
  7707. if item.MedChrgitmType == "06" { //手术费
  7708. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7709. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7710. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7711. }
  7712. if item.MedChrgitmType == "08" { //材料费
  7713. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7714. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7715. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7716. }
  7717. if item.MedChrgitmType == "09" { //西药费
  7718. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7719. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7720. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7721. }
  7722. if item.MedChrgitmType == "11" { //中成费
  7723. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7724. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7725. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7726. }
  7727. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  7728. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7729. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7730. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7731. }
  7732. }
  7733. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7734. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7735. var user_name string
  7736. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7737. if role.ID == 0 {
  7738. user_name = "管理员"
  7739. } else {
  7740. user_name = role.UserName
  7741. }
  7742. baseParams := models.BaseParams{
  7743. SecretKey: miConfig.SecretKey,
  7744. FixmedinsCode: miConfig.Code,
  7745. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7746. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7747. OrgName: miConfig.OrgName,
  7748. Doctor: user_name,
  7749. }
  7750. businessParams := models.BusinessParams{
  7751. PsnNo: order.PsnNo,
  7752. MdtrtId: order.MdtrtId,
  7753. SetlId: order.SetlId,
  7754. }
  7755. var res ResultEleven
  7756. var resEleven10265 ResultEleven10265
  7757. if config.IsOpen == 1 {
  7758. if miConfig.MdtrtareaAdmvs == "421300" {
  7759. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7760. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7761. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7762. resp, requestErr := http.Get(api)
  7763. if requestErr != nil {
  7764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7765. return
  7766. }
  7767. body, ioErr := ioutil.ReadAll(resp.Body)
  7768. if ioErr != nil {
  7769. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7771. return
  7772. }
  7773. var respJSON map[string]interface{}
  7774. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7775. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7777. return
  7778. }
  7779. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7780. result, _ := json.Marshal(respJSON)
  7781. fmt.Println("log")
  7782. fmt.Println(string(result))
  7783. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7784. utils.ErrorLog("解析失败:%v", err)
  7785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7786. return
  7787. }
  7788. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7789. api := "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7790. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7791. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7792. resp, requestErr := http.Get(api)
  7793. if requestErr != nil {
  7794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7795. return
  7796. }
  7797. body, ioErr := ioutil.ReadAll(resp.Body)
  7798. if ioErr != nil {
  7799. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7801. return
  7802. }
  7803. var respJSON map[string]interface{}
  7804. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7807. return
  7808. }
  7809. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7810. result, _ := json.Marshal(respJSON)
  7811. fmt.Println("log")
  7812. fmt.Println(string(result))
  7813. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  7814. utils.ErrorLog("解析失败:%v", err)
  7815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7816. return
  7817. }
  7818. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7819. res.Output = resEleven10265.Output
  7820. res.ErrMsg = resEleven10265.ErrMsg
  7821. res.Cainfo = resEleven10265.Cainfo
  7822. res.WarnMsg = resEleven10265.WarnMsg
  7823. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7824. res.Infcode = infocode
  7825. } else {
  7826. //result2 := service.Gdyb1101()
  7827. result2 := service.Gdyb5204(baseParams, businessParams)
  7828. saveLog(result2, "", "5204", "查询")
  7829. result := service.Gdyb5203(baseParams, businessParams)
  7830. var dat map[string]interface{}
  7831. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7832. fmt.Println(dat)
  7833. } else {
  7834. fmt.Println(err)
  7835. }
  7836. userJSONBytes, _ := json.Marshal(dat)
  7837. if miConfig.Code == "H15049901371" {
  7838. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  7839. utils.ErrorLog("解析失败:%v", err)
  7840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7841. return
  7842. }
  7843. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7844. res.Output = resEleven10265.Output
  7845. res.ErrMsg = resEleven10265.ErrMsg
  7846. res.Cainfo = resEleven10265.Cainfo
  7847. res.WarnMsg = resEleven10265.WarnMsg
  7848. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7849. res.Infcode = infocode
  7850. } else {
  7851. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7852. utils.ErrorLog("解析失败:%v", err)
  7853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7854. return
  7855. }
  7856. }
  7857. }
  7858. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7859. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  7860. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  7861. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7862. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7863. var doctor_name string
  7864. if roles.ID == 0 {
  7865. doctor_name = "管理员"
  7866. } else {
  7867. doctor_name = roles.UserName
  7868. }
  7869. yiliao_leibie := ""
  7870. switch order.MedType {
  7871. case "11":
  7872. yiliao_leibie = "普通门诊"
  7873. break
  7874. case "12":
  7875. yiliao_leibie = "门诊挂号"
  7876. break
  7877. case "13":
  7878. yiliao_leibie = "急诊"
  7879. break
  7880. case "14":
  7881. yiliao_leibie = "门诊特殊病"
  7882. break
  7883. case "15":
  7884. yiliao_leibie = "门诊统筹"
  7885. break
  7886. case "16":
  7887. yiliao_leibie = "门诊慢性病"
  7888. break
  7889. case "21":
  7890. yiliao_leibie = "普通住院"
  7891. break
  7892. }
  7893. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7894. if res.Infcode == 0 {
  7895. c.ServeSuccessJSON(map[string]interface{}{
  7896. "diagnosis": name,
  7897. "order_infos": orderInfos,
  7898. "number": order.MdtrtId,
  7899. "date": order.SettleAccountsDate,
  7900. "charge_admin": charge_admin,
  7901. "printor_admin": printor_admin,
  7902. "info": res.Output.Setlinfo,
  7903. "bedCostTotal": bedCostTotal,
  7904. "bedCostSelfTotal": bedCostSelfTotal,
  7905. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  7906. "operationCostTotal": operationCostTotal,
  7907. "operationCostSelfTotal": operationCostSelfTotal,
  7908. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  7909. "otherCostTotal": otherCostTotal,
  7910. "otherCostSelfTotal": otherCostSelfTotal,
  7911. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  7912. "materialCostTotal": materialCostTotal,
  7913. "materialCostSelfTotal": materialCostSelfTotal,
  7914. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  7915. "westernMedicineCostTotal": westernMedicineCostTotal,
  7916. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  7917. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  7918. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  7919. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  7920. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  7921. "checkCostTotal": checkCostTotal,
  7922. "checkCostSelfTotal": checkCostSelfTotal,
  7923. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  7924. "laboratoryCostTotal": laboratoryCostTotal,
  7925. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  7926. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  7927. "treatCostTotal": treatCostTotal,
  7928. "treatCostSelfTotal": treatCostSelfTotal,
  7929. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  7930. "doctor_code": adminRole_two.DoctorCode,
  7931. "doctor_name": doctor_name,
  7932. "health_card_no": order.PsnNo,
  7933. "department": departments.Name,
  7934. "yiliao_leibie": yiliao_leibie,
  7935. "after_money": order.AccountPrice,
  7936. "patient": patient,
  7937. "org_name": miConfig.OrgName,
  7938. "org_code": miConfig.Code,
  7939. "order_number": order.Number,
  7940. "his_hospital": his_hospital,
  7941. "his": his,
  7942. //"check_order_info": cus_slice,
  7943. })
  7944. }
  7945. }
  7946. }
  7947. func (c *HisApiController) CheckTreatment() {
  7948. patient_id, _ := c.GetInt64("patient_id")
  7949. id_card_no := c.GetString("id_card_no")
  7950. insutype := c.GetString("insutype")
  7951. med_type := c.GetString("med_type")
  7952. admin_user_id, _ := c.GetInt64("admin_user_id")
  7953. adminUser := c.GetAdminUserInfo()
  7954. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7955. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7956. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7957. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7958. if miConfig.MdtrtareaAdmvs == "421300" {
  7959. var res ResultTwo
  7960. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7961. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7962. "&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)
  7963. resp, requestErr := http.Get(api)
  7964. if requestErr != nil {
  7965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7966. return
  7967. }
  7968. body, ioErr := ioutil.ReadAll(resp.Body)
  7969. if ioErr != nil {
  7970. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7972. return
  7973. }
  7974. var respJSON map[string]interface{}
  7975. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7978. return
  7979. }
  7980. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7981. result, _ := json.Marshal(respJSON)
  7982. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7983. utils.ErrorLog("解析失败:%v", err)
  7984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7985. return
  7986. }
  7987. if res.Infcode == 0 {
  7988. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  7989. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7990. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  7991. resp, requestErr := http.Get(api)
  7992. if requestErr != nil {
  7993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7994. return
  7995. }
  7996. body, ioErr := ioutil.ReadAll(resp.Body)
  7997. if ioErr != nil {
  7998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8000. return
  8001. }
  8002. var respJSON map[string]interface{}
  8003. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8006. return
  8007. }
  8008. var res Result2001
  8009. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8010. result2, _ := json.Marshal(respJSON)
  8011. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8012. utils.ErrorLog("解析失败:%v", err)
  8013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8014. return
  8015. }
  8016. if res.Infcode == 0 {
  8017. c.ServeSuccessJSON(map[string]interface{}{
  8018. "msg": res.Output.Trtinfo,
  8019. })
  8020. }
  8021. } else {
  8022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8023. return
  8024. }
  8025. } else {
  8026. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8027. var dat map[string]interface{}
  8028. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8029. fmt.Println(dat)
  8030. } else {
  8031. fmt.Println(err)
  8032. }
  8033. userJSONBytes, _ := json.Marshal(dat)
  8034. var res ResultTwo
  8035. var res10265 ResultTwo10265
  8036. if miConfig.Code == "H15049901371" {
  8037. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8038. utils.ErrorLog("解析失败:%v", err)
  8039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8040. return
  8041. }
  8042. res.ErrMsg = res10265.ErrMsg
  8043. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8044. res.Infcode = infocode
  8045. res.Output = res10265.Output
  8046. res.InfRefmsgid = res10265.InfRefmsgid
  8047. } else {
  8048. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8049. utils.ErrorLog("解析失败:%v", err)
  8050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8051. return
  8052. }
  8053. }
  8054. var user_name string
  8055. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  8056. if role.ID == 0 {
  8057. user_name = "xxx"
  8058. } else {
  8059. user_name = role.UserName
  8060. }
  8061. baseParams := models.BaseParams{
  8062. SecretKey: miConfig.SecretKey,
  8063. FixmedinsCode: miConfig.Code,
  8064. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8065. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8066. OrgName: miConfig.OrgName,
  8067. Doctor: user_name,
  8068. }
  8069. if config.IsOpen == 1 {
  8070. if miConfig.Code == "H15049901371" {
  8071. if med_type == "14" {
  8072. if insutype == "390" {
  8073. med_type = "9933"
  8074. } else if insutype == "310" {
  8075. med_type = "990502"
  8076. }
  8077. } else if med_type == "11" {
  8078. med_type = "11"
  8079. }
  8080. }
  8081. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  8082. var dat map[string]interface{}
  8083. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8084. fmt.Println(dat)
  8085. } else {
  8086. fmt.Println(err)
  8087. }
  8088. var res Result2001
  8089. var res10265 Result2001Org10265
  8090. if miConfig.Code == "H15049901371" {
  8091. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8092. utils.ErrorLog("解析失败:%v", err)
  8093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8094. return
  8095. }
  8096. res.ErrMsg = res10265.ErrMsg
  8097. res.Output = res10265.Output
  8098. res.InfRefmsgid = res10265.InfRefmsgid
  8099. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8100. res.Infcode = infocode
  8101. } else {
  8102. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8103. utils.ErrorLog("解析失败:%v", err)
  8104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8105. return
  8106. }
  8107. }
  8108. if res.Infcode == 0 {
  8109. c.ServeSuccessJSON(map[string]interface{}{
  8110. "msg": res.Output.Trtinfo,
  8111. })
  8112. }
  8113. }
  8114. }
  8115. }
  8116. //func (c *HisApiController) PutRecord() {
  8117. // id, _ := c.GetInt64("id")
  8118. // record_time := c.GetString("record_time")
  8119. // timeLayout := "2006-01-02"
  8120. // loc, _ := time.LoadLocation("Local")
  8121. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8122. // if err != nil {
  8123. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8124. // return
  8125. // }
  8126. // recordDateTime := theTime.Unix()
  8127. //
  8128. // adminInfo := c.GetAdminUserInfo()
  8129. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  8130. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8131. //
  8132. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8133. //
  8134. // fmt.Println(miConfig.SecretKey)
  8135. //
  8136. // if patient == nil {
  8137. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8138. // return
  8139. // }
  8140. // if len(patient.IdCardNo) == 0 {
  8141. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  8142. // return
  8143. // }
  8144. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8145. // if config.IsOpen == 1 {
  8146. // 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
  8147. // resp, requestErr := http.Get(api)
  8148. // if requestErr != nil {
  8149. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8150. // return
  8151. // }
  8152. // defer resp.Body.Close()
  8153. // body, ioErr := ioutil.ReadAll(resp.Body)
  8154. // if ioErr != nil {
  8155. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8156. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8157. // return
  8158. // }
  8159. // var respJSON map[string]interface{}
  8160. //
  8161. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8162. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8163. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8164. // return
  8165. // }
  8166. //
  8167. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8168. // userJSONBytes, _ := json.Marshal(userJSON)
  8169. // var res ResultTwo
  8170. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8171. // utils.ErrorLog("解析失败:%v", err)
  8172. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8173. // return
  8174. // }
  8175. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8176. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8177. // infoStr := string(Iinfos)
  8178. // idetinfoStr := string(Idetinfos)
  8179. //
  8180. // if res.Infcode == 0 {
  8181. // his := models.VMHisPatient{
  8182. // Status: 1,
  8183. // Ctime: time.Now().Unix(),
  8184. // Mtime: time.Now().Unix(),
  8185. // PsnNo: res.Output.Baseinfo.PsnNo,
  8186. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  8187. // Certno: res.Output.Baseinfo.Certno,
  8188. // PsnName: res.Output.Baseinfo.PsnName,
  8189. // Gend: res.Output.Baseinfo.Gend,
  8190. // Naty: res.Output.Baseinfo.Naty,
  8191. // Brdy: res.Output.Baseinfo.Brdy,
  8192. // Age: res.Output.Baseinfo.Age,
  8193. // Iinfo: infoStr,
  8194. // Idetinfo: idetinfoStr,
  8195. // PatientId: patient.ID,
  8196. // RecordDate: theTime.Unix(),
  8197. // UserOrgId: adminInfo.CurrentOrgId,
  8198. // AdminUserId: adminInfo.AdminUser.Id,
  8199. // IsReturn: 1,
  8200. // }
  8201. //
  8202. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  8203. // //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")
  8204. // //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")
  8205. //
  8206. // //var dat map[string]interface{}
  8207. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8208. // // fmt.Println(dat)
  8209. // //} else {
  8210. // // fmt.Println(err)
  8211. // //}
  8212. //
  8213. // var dat2 map[string]interface{}
  8214. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8215. // fmt.Println(dat2)
  8216. // } else {
  8217. // fmt.Println(err)
  8218. // }
  8219. //
  8220. // } else {
  8221. // adminUser := c.GetAdminUserInfo()
  8222. // errlog := &models.HisOrderError{
  8223. // UserOrgId: adminUser.CurrentOrgId,
  8224. // Ctime: time.Now().Unix(),
  8225. // Mtime: time.Now().Unix(),
  8226. // ErrMsg: res.ErrMsg,
  8227. // Status: 1,
  8228. // PatientId: id,
  8229. // RecordTime: recordDateTime,
  8230. // Stage: 1,
  8231. // }
  8232. // service.CreateErrMsgLog(errlog)
  8233. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8234. // return
  8235. // }
  8236. // }
  8237. //
  8238. //}
  8239. //func (c *HisApiController) GetUploadDiag() {
  8240. // id, _ := c.GetInt64("id")
  8241. // record_time := c.GetString("record_time")
  8242. //
  8243. // diagnosis_id, _ := c.GetInt64("diagnosis")
  8244. // sick_type, _ := c.GetInt64("sick_type")
  8245. // reg_type, _ := c.GetInt64("reg_type")
  8246. //
  8247. // timeLayout := "2006-01-02"
  8248. // loc, _ := time.LoadLocation("Local")
  8249. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8250. // if err != nil {
  8251. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8252. // return
  8253. // }
  8254. //
  8255. // var patientPrescription models.HisPrescriptionInfo
  8256. // recordDateTime := theTime.Unix()
  8257. // adminInfo := c.GetAdminUserInfo()
  8258. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8259. //
  8260. // if patientPrescription.ID == 0 {
  8261. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8262. // }
  8263. //
  8264. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8265. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8266. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8267. // sickConfig, _ := service.FindSickById(sick_type)
  8268. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8269. //
  8270. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  8271. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  8272. // "&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 +
  8273. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  8274. // resp2, requestErr2 := http.Get(api2)
  8275. // if requestErr2 != nil {
  8276. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8277. // return
  8278. // }
  8279. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8280. // if ioErr2 != nil {
  8281. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8282. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8283. // return
  8284. // }
  8285. // var respJSON2 map[string]interface{}
  8286. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8287. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8288. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8289. // return
  8290. // }
  8291. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8292. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8293. //
  8294. // var res2 ResultSix
  8295. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8296. // utils.ErrorLog("解析失败:%v", err)
  8297. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8298. // return
  8299. // }
  8300. // if res2.Infcode != 0 {
  8301. // adminUser := c.GetAdminUserInfo()
  8302. // errlog := &models.HisOrderError{
  8303. // UserOrgId: adminUser.CurrentOrgId,
  8304. // Ctime: time.Now().Unix(),
  8305. // Mtime: time.Now().Unix(),
  8306. // ErrMsg: res2.ErrMsg,
  8307. // Status: 1,
  8308. // PatientId: id,
  8309. // RecordTime: recordDateTime,
  8310. // Stage: 3,
  8311. // }
  8312. // service.CreateErrMsgLog(errlog)
  8313. //
  8314. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  8315. // return
  8316. // }
  8317. //
  8318. // c.ServeSuccessJSON(map[string]interface{}{
  8319. // "msg": "上传成功",
  8320. // })
  8321. //
  8322. //}
  8323. type QueryResult struct {
  8324. ID int64
  8325. Name string
  8326. Code string
  8327. List_type_code string
  8328. }
  8329. func (c *HisApiController) GetCheckCode() {
  8330. ids_str := c.GetString("ids")
  8331. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8332. ids_arr := strings.Split(ids_str, ",")
  8333. var queryResult []QueryResult
  8334. ids := make([]int64, 0)
  8335. for _, item := range ids_arr {
  8336. id, _ := strconv.ParseInt(item, 10, 64)
  8337. ids = append(ids, id)
  8338. }
  8339. if record_type == 1 {
  8340. drugs, _ := service.GetBatchDrugList(ids)
  8341. for _, item := range drugs {
  8342. result := QueryResult{
  8343. ID: item.ID,
  8344. Name: item.DrugName,
  8345. Code: item.MedicalInsuranceNumber,
  8346. List_type_code: "101",
  8347. }
  8348. queryResult = append(queryResult, result)
  8349. }
  8350. } else if record_type == 2 {
  8351. goods, _ := service.GetBatchGoodInformationList(ids)
  8352. for _, item := range goods {
  8353. result := QueryResult{
  8354. ID: item.ID,
  8355. Name: item.GoodName,
  8356. Code: item.MedicalInsuranceNumber,
  8357. List_type_code: "301",
  8358. }
  8359. queryResult = append(queryResult, result)
  8360. }
  8361. } else if record_type == 3 {
  8362. projects, _ := service.GetBathchMyPorjecgList(ids)
  8363. for _, item := range projects {
  8364. result := QueryResult{
  8365. ID: item.ID,
  8366. Name: item.ProjectName,
  8367. Code: item.MedicalCode,
  8368. List_type_code: "201",
  8369. }
  8370. queryResult = append(queryResult, result)
  8371. }
  8372. }
  8373. admin_user_id, _ := c.GetInt64("admin_user_id")
  8374. adminUser := c.GetAdminUserInfo()
  8375. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8376. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8377. var user_name string
  8378. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8379. if role.ID == 0 {
  8380. user_name = "xxx"
  8381. } else {
  8382. user_name = role.UserName
  8383. }
  8384. baseParams := &models.BaseParams{
  8385. SecretKey: miConfig.SecretKey,
  8386. FixmedinsCode: miConfig.Code,
  8387. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8388. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8389. OrgName: miConfig.OrgName,
  8390. Doctor: user_name,
  8391. }
  8392. if config.IsOpen == 1 {
  8393. for _, item := range queryResult {
  8394. var result string
  8395. if record_type == 1 {
  8396. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8397. } else if record_type == 2 {
  8398. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8399. } else if record_type == 3 {
  8400. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8401. }
  8402. var dat map[string]interface{}
  8403. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8404. fmt.Println(dat)
  8405. } else {
  8406. fmt.Println(err)
  8407. }
  8408. userJSONBytes, _ := json.Marshal(dat)
  8409. var res ResultSix
  8410. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8411. utils.ErrorLog("解析失败:%v", err)
  8412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8413. return
  8414. }
  8415. if res.Infcode == 0 {
  8416. if record_type == 1 {
  8417. service.UpdateBaseDrugById(item.ID)
  8418. } else if record_type == 2 {
  8419. service.UpdateGoodInformaitonByDetail(item.ID)
  8420. } else if record_type == 3 {
  8421. service.UpdateProjectById(item.ID)
  8422. }
  8423. c.ServeSuccessJSON(map[string]interface{}{
  8424. "failed_code": 0,
  8425. "msg": "目录对照成功",
  8426. })
  8427. } else {
  8428. c.ServeSuccessJSON(map[string]interface{}{
  8429. "failed_code": -10,
  8430. "msg": res.ErrMsg,
  8431. })
  8432. }
  8433. }
  8434. }
  8435. }
  8436. func (c *HisApiController) UnCheckCode() {
  8437. ids_str := c.GetString("ids")
  8438. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8439. admin_user_id, _ := c.GetInt64("admin_user_id")
  8440. ids_arr := strings.Split(ids_str, ",")
  8441. var queryResult []QueryResult
  8442. ids := make([]int64, 0)
  8443. for _, item := range ids_arr {
  8444. id, _ := strconv.ParseInt(item, 10, 64)
  8445. ids = append(ids, id)
  8446. }
  8447. if record_type == 1 {
  8448. drugs, _ := service.GetBatchDrugList(ids)
  8449. for _, item := range drugs {
  8450. result := QueryResult{
  8451. ID: item.ID,
  8452. Name: item.DrugName,
  8453. Code: item.MedicalInsuranceNumber,
  8454. List_type_code: "101",
  8455. }
  8456. queryResult = append(queryResult, result)
  8457. }
  8458. } else if record_type == 2 {
  8459. goods, _ := service.GetBatchGoodInformationList(ids)
  8460. for _, item := range goods {
  8461. result := QueryResult{
  8462. ID: item.ID,
  8463. Name: item.GoodName,
  8464. Code: item.MedicalInsuranceNumber,
  8465. List_type_code: "301",
  8466. }
  8467. queryResult = append(queryResult, result)
  8468. }
  8469. } else if record_type == 3 {
  8470. projects, _ := service.GetBathchMyPorjecgList(ids)
  8471. for _, item := range projects {
  8472. result := QueryResult{
  8473. ID: item.ID,
  8474. Name: item.ProjectName,
  8475. Code: item.MedicalCode,
  8476. List_type_code: "201",
  8477. }
  8478. queryResult = append(queryResult, result)
  8479. }
  8480. }
  8481. adminUser := c.GetAdminUserInfo()
  8482. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8483. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8484. var user_name string
  8485. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8486. if role.ID == 0 {
  8487. user_name = "xxx"
  8488. } else {
  8489. user_name = role.UserName
  8490. }
  8491. baseParams := &models.BaseParams{
  8492. SecretKey: miConfig.SecretKey,
  8493. FixmedinsCode: miConfig.Code,
  8494. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8495. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8496. OrgName: miConfig.OrgName,
  8497. Doctor: user_name,
  8498. }
  8499. if config.IsOpen == 1 {
  8500. for _, item := range queryResult {
  8501. var result string
  8502. if record_type == 1 {
  8503. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8504. } else if record_type == 2 {
  8505. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8506. } else if record_type == 3 {
  8507. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8508. }
  8509. var dat2 map[string]interface{}
  8510. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  8511. fmt.Println(dat2)
  8512. } else {
  8513. fmt.Println(err)
  8514. }
  8515. userJSONBytes, _ := json.Marshal(dat2)
  8516. var res ResultSix
  8517. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8518. utils.ErrorLog("解析失败:%v", err)
  8519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8520. return
  8521. }
  8522. if res.Infcode == 0 {
  8523. if record_type == 1 {
  8524. service.UpdateDrugByIdDetail(item.ID)
  8525. } else if record_type == 2 {
  8526. service.UpdateGoodInfoById(item.ID)
  8527. } else if record_type == 3 {
  8528. service.UpdateMyProjectById(item.ID)
  8529. }
  8530. c.ServeSuccessJSON(map[string]interface{}{
  8531. "failed_code": 0,
  8532. "msg": "撤销目录对照成功",
  8533. })
  8534. } else {
  8535. c.ServeSuccessJSON(map[string]interface{}{
  8536. "failed_code": -10,
  8537. "msg": res.ErrMsg,
  8538. })
  8539. }
  8540. }
  8541. }
  8542. }
  8543. func (c *HisApiController) GetPatientInfo() {
  8544. id_card_no := c.GetString("id_card_no")
  8545. admin_user_id, _ := c.GetInt64("admin_user_id")
  8546. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8547. if patient.ID == 0 {
  8548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8549. return
  8550. }
  8551. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8552. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8553. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  8554. if config.IsOpen == 1 {
  8555. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8556. var dat map[string]interface{}
  8557. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8558. fmt.Println(dat)
  8559. } else {
  8560. fmt.Println(err)
  8561. }
  8562. userJSONBytes, _ := json.Marshal(dat)
  8563. var res ResultTwo
  8564. var res10265 ResultTwo10265
  8565. if miConfig.Code == "H15049901371" {
  8566. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8567. utils.ErrorLog("解析失败:%v", err)
  8568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8569. return
  8570. }
  8571. res.ErrMsg = res10265.ErrMsg
  8572. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8573. res.Infcode = infocode
  8574. res.Output = res10265.Output
  8575. res.InfRefmsgid = res10265.InfRefmsgid
  8576. } else {
  8577. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8578. utils.ErrorLog("解析失败:%v", err)
  8579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8580. return
  8581. }
  8582. }
  8583. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8584. // utils.ErrorLog("解析失败:%v", err)
  8585. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8586. // return
  8587. //}
  8588. if res.Infcode != 0 {
  8589. c.ServeSuccessJSON(map[string]interface{}{
  8590. "failed_code": -10,
  8591. "msg": res.ErrMsg,
  8592. })
  8593. } else {
  8594. c.ServeSuccessJSON(map[string]interface{}{
  8595. "failed_code": 0,
  8596. "info": res,
  8597. })
  8598. }
  8599. }
  8600. }
  8601. func (c *HisApiController) PsnPutOnRecord() {
  8602. record_type, _ := c.GetInt64("type")
  8603. patient_id, _ := c.GetInt64("patient_id")
  8604. admin_user_id, _ := c.GetInt64("admin_user_id")
  8605. start_time := c.GetString("start_time")
  8606. end_time := c.GetString("end_time")
  8607. adminUser := c.GetAdminUserInfo()
  8608. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8609. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8610. var patients []*models.Patients
  8611. if record_type == 1 { //全部备案
  8612. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  8613. patients = append(patients, patient...)
  8614. } else { //单个备案
  8615. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8616. patients = append(patients, patient)
  8617. }
  8618. var user_name string
  8619. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8620. if role.ID == 0 {
  8621. user_name = "xxx"
  8622. } else {
  8623. user_name = role.UserName
  8624. }
  8625. if config.IsOpen == 1 {
  8626. for _, item := range patients {
  8627. 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
  8628. resp, requestErr := http.Get(api)
  8629. if requestErr != nil {
  8630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8631. return
  8632. }
  8633. defer resp.Body.Close()
  8634. body, ioErr := ioutil.ReadAll(resp.Body)
  8635. if ioErr != nil {
  8636. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8638. return
  8639. }
  8640. var respJSON map[string]interface{}
  8641. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8642. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8644. return
  8645. }
  8646. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8647. userJSONBytes, _ := json.Marshal(userJSON)
  8648. var res ResultTwo
  8649. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8650. utils.ErrorLog("解析失败:%v", err)
  8651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8652. return
  8653. }
  8654. if res.Infcode == 0 {
  8655. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  8656. var dat map[string]interface{}
  8657. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8658. fmt.Println(dat)
  8659. } else {
  8660. fmt.Println(err)
  8661. }
  8662. userJSONBytes, _ := json.Marshal(dat)
  8663. var res2 ResultThirteen
  8664. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8665. utils.ErrorLog("解析失败:%v", err)
  8666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8667. return
  8668. }
  8669. if res2.Infcode == 0 {
  8670. psnResult := &models.GdybPsnRecord{
  8671. UserOrgId: adminUser.CurrentOrgId,
  8672. PatientId: item.ID,
  8673. PsnNo: res.Output.Baseinfo.PsnNo,
  8674. Ctime: time.Now().Unix(),
  8675. Mtime: time.Now().Unix(),
  8676. Status: 1,
  8677. IsCancel: 1,
  8678. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8679. }
  8680. service.CreatePsnRecord(psnResult)
  8681. } else {
  8682. c.ServeSuccessJSON(map[string]interface{}{
  8683. "failed_code": -10,
  8684. "msg": res2.ErrMsg,
  8685. })
  8686. return
  8687. }
  8688. }
  8689. }
  8690. }
  8691. }
  8692. func (c *HisApiController) PsnUnPutOnRecord() {
  8693. id, _ := c.GetInt64("id")
  8694. //record_type, _ := c.GetInt64("type")
  8695. admin_user_id, _ := c.GetInt64("admin_user_id")
  8696. adminUser := c.GetAdminUserInfo()
  8697. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8698. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8699. var user_name string
  8700. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8701. if role.ID == 0 {
  8702. user_name = "xxx"
  8703. } else {
  8704. user_name = role.UserName
  8705. }
  8706. psn_record, _ := service.GetPsnRecordById(id)
  8707. if psn_record.ID == 0 {
  8708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8709. return
  8710. }
  8711. if config.IsOpen == 1 {
  8712. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8713. var dat map[string]interface{}
  8714. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8715. fmt.Println(dat)
  8716. } else {
  8717. fmt.Println(err)
  8718. }
  8719. userJSONBytes, _ := json.Marshal(dat)
  8720. var res ResultFourteen
  8721. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8722. utils.ErrorLog("解析失败:%v", err)
  8723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8724. return
  8725. }
  8726. if res.Infcode == 0 {
  8727. psn_record.IsCancel = 2
  8728. service.CreatePsnRecord(&psn_record)
  8729. } else {
  8730. c.ServeSuccessJSON(map[string]interface{}{
  8731. "failed_code": -10,
  8732. "msg": res.ErrMsg,
  8733. })
  8734. return
  8735. }
  8736. }
  8737. }
  8738. func (c *HisApiController) PsnPutNCDSOnRecord() {
  8739. patient_id, _ := c.GetInt64("patient_id")
  8740. insutype_two := c.GetString("insutype")
  8741. psn_no := c.GetString("psn_no")
  8742. doctor_id, _ := c.GetInt64("doctor_id")
  8743. sick_id, _ := c.GetInt64("sick_id")
  8744. department_id, _ := c.GetInt64("department_id")
  8745. start_time := c.GetString("start_time")
  8746. end_time := c.GetString("end_time")
  8747. check_time := c.GetString("check_time")
  8748. adminUser := c.GetAdminUserInfo()
  8749. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8750. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8751. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8752. sick, _ := service.FindSickById(sick_id)
  8753. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8754. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8755. var res ResultTwo
  8756. var res10265 ResultTwo10265
  8757. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8758. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  8759. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  8760. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8761. "&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
  8762. resp, requestErr := http.Get(api)
  8763. if requestErr != nil {
  8764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8765. return
  8766. }
  8767. body, ioErr := ioutil.ReadAll(resp.Body)
  8768. if ioErr != nil {
  8769. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8771. return
  8772. }
  8773. var respJSON map[string]interface{}
  8774. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8775. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8777. return
  8778. }
  8779. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8780. result, _ := json.Marshal(respJSON)
  8781. fmt.Println("log")
  8782. fmt.Println(string(result))
  8783. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8784. utils.ErrorLog("解析失败:%v", err)
  8785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8786. return
  8787. }
  8788. res.ErrMsg = res10265.ErrMsg
  8789. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8790. res.Infcode = infocode
  8791. res.Output = res10265.Output
  8792. res.InfRefmsgid = res10265.InfRefmsgid
  8793. } else {
  8794. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8795. if miConfig.Code == "H15049901371" {
  8796. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8797. utils.ErrorLog("解析失败:%v", err)
  8798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8799. return
  8800. }
  8801. res.ErrMsg = res10265.ErrMsg
  8802. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8803. res.Infcode = infocode
  8804. res.Output = res10265.Output
  8805. res.InfRefmsgid = res10265.InfRefmsgid
  8806. } else {
  8807. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8808. utils.ErrorLog("解析失败:%v", err)
  8809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8810. return
  8811. }
  8812. }
  8813. }
  8814. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8815. infoStr := string(Iinfos)
  8816. var rf []*ResultFive
  8817. json.Unmarshal([]byte(infoStr), &rf)
  8818. var insuplc_admdvs string
  8819. var insutype string
  8820. var is390 int = 0
  8821. var is310 int = 0
  8822. var insutypes []*ResultFive
  8823. for _, item := range rf {
  8824. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8825. insutypes = append(insutypes, item)
  8826. }
  8827. }
  8828. if len(insutypes) == 1 {
  8829. insutype = insutypes[0].Insutype
  8830. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8831. } else {
  8832. for _, i := range insutypes {
  8833. if i.Insutype == "390" {
  8834. is390 = 1
  8835. }
  8836. if i.Insutype == "310" {
  8837. is310 = 1
  8838. }
  8839. }
  8840. }
  8841. if is390 == 1 {
  8842. insutype = "390"
  8843. }
  8844. if is310 == 1 {
  8845. insutype = "310"
  8846. }
  8847. if len(insutypes) == 2 {
  8848. insutype = insutype_two
  8849. }
  8850. if len(insutypes) == 0 {
  8851. insutype = "310"
  8852. }
  8853. insutype = insutype_two
  8854. fmt.Println(insutype)
  8855. for _, item := range rf {
  8856. fmt.Println(item.Insutype)
  8857. fmt.Println(insutype)
  8858. if item.Insutype == insutype {
  8859. fmt.Println(item.Insutype)
  8860. fmt.Println(insutype)
  8861. insuplc_admdvs = item.InsuplcAdmdvs
  8862. }
  8863. }
  8864. fmt.Println(insuplc_admdvs)
  8865. var res2 ResultThirteen
  8866. var res10265_2 ResultThirteen10265
  8867. if config.IsOpen == 1 {
  8868. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8869. } else {
  8870. 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)
  8871. var dat map[string]interface{}
  8872. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8873. fmt.Println(dat)
  8874. } else {
  8875. fmt.Println(err)
  8876. }
  8877. userJSONBytes, _ := json.Marshal(dat)
  8878. if miConfig.Code == "H15049901371" {
  8879. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  8880. utils.ErrorLog("解析失败:%v", err)
  8881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8882. return
  8883. }
  8884. res2.ErrMsg = res10265_2.ErrMsg
  8885. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  8886. res2.Infcode = infocode
  8887. res2.Output = res10265_2.Output
  8888. res2.InfRefmsgid = res10265_2.InfRefmsgid
  8889. } else {
  8890. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8891. utils.ErrorLog("解析失败:%v", err)
  8892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8893. return
  8894. }
  8895. }
  8896. }
  8897. if res2.Infcode == 0 {
  8898. psnResult := &models.GdybPsnNcdsRecord{
  8899. UserOrgId: adminUser.CurrentOrgId,
  8900. PatientId: patient.ID,
  8901. PsnNo: psn_no,
  8902. DoctorId: doctor.AdminUserId,
  8903. DepartmentId: department_id,
  8904. SickType: sick_id,
  8905. Insutype: insutype,
  8906. Ctime: time.Now().Unix(),
  8907. Mtime: time.Now().Unix(),
  8908. Status: 1,
  8909. IsCancel: 1,
  8910. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8911. }
  8912. service.CreatePsnNCDSRecord(psnResult)
  8913. c.ServeSuccessJSON(map[string]interface{}{
  8914. "failed_code": 0,
  8915. "msg": "备案成功",
  8916. "result": psnResult,
  8917. })
  8918. } else {
  8919. c.ServeSuccessJSON(map[string]interface{}{
  8920. "failed_code": -10,
  8921. "msg": res2.ErrMsg,
  8922. })
  8923. return
  8924. }
  8925. }
  8926. }
  8927. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  8928. id, _ := c.GetInt64("id")
  8929. admin_user_id, _ := c.GetInt64("admin_user_id")
  8930. adminUser := c.GetAdminUserInfo()
  8931. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8932. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8933. //config, _ := service.Ge(adminUser.CurrentOrgId)
  8934. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  8935. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8936. //var user_name string
  8937. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8938. //if role.ID == 0 {
  8939. // user_name = "xxx"
  8940. //} else {
  8941. // user_name = role.UserName
  8942. //}
  8943. psn_record, _ := service.GetPsnNCDSRecordById(id)
  8944. if psn_record.ID == 0 {
  8945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8946. return
  8947. }
  8948. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8949. var res ResultTwo
  8950. var res10265 ResultTwo10265
  8951. if miConfig.Code == "H15049901371" {
  8952. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8953. utils.ErrorLog("解析失败:%v", err)
  8954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8955. return
  8956. }
  8957. res.ErrMsg = res10265.ErrMsg
  8958. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8959. res.Infcode = infocode
  8960. res.Output = res10265.Output
  8961. res.InfRefmsgid = res10265.InfRefmsgid
  8962. } else {
  8963. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8964. utils.ErrorLog("解析失败:%v", err)
  8965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8966. return
  8967. }
  8968. }
  8969. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8970. infoStr := string(Iinfos)
  8971. var rf []*ResultFive
  8972. json.Unmarshal([]byte(infoStr), &rf)
  8973. var insuplc_admdvs string
  8974. var insutype string
  8975. var is390 int = 0
  8976. var is310 int = 0
  8977. var insutypes []*ResultFive
  8978. for _, item := range rf {
  8979. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8980. insutypes = append(insutypes, item)
  8981. }
  8982. }
  8983. if len(insutypes) == 1 {
  8984. insutype = insutypes[0].Insutype
  8985. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8986. } else {
  8987. for _, i := range insutypes {
  8988. if i.Insutype == "390" {
  8989. is390 = 1
  8990. }
  8991. if i.Insutype == "310" {
  8992. is310 = 1
  8993. }
  8994. }
  8995. }
  8996. if is390 == 1 {
  8997. insutype = "390"
  8998. }
  8999. if is310 == 1 {
  9000. insutype = "310"
  9001. }
  9002. if len(insutypes) == 0 {
  9003. insutype = "310"
  9004. }
  9005. insutype = psn_record.Insutype
  9006. for _, item := range rf {
  9007. if item.Insutype == insutype {
  9008. insuplc_admdvs = item.InsuplcAdmdvs
  9009. }
  9010. }
  9011. if config.IsOpen == 1 {
  9012. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9013. var dat map[string]interface{}
  9014. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9015. fmt.Println(dat)
  9016. } else {
  9017. fmt.Println(err)
  9018. }
  9019. userJSONBytes, _ := json.Marshal(dat)
  9020. var res ResultFourteen
  9021. var res10265 ResultFourteen10265
  9022. if miConfig.Code == "H15049901371" {
  9023. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9024. utils.ErrorLog("解析失败:%v", err)
  9025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9026. return
  9027. }
  9028. res.ErrMsg = res10265.ErrMsg
  9029. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9030. res.Infcode = infocode
  9031. res.Output = res10265.Output
  9032. res.InfRefmsgid = res10265.InfRefmsgid
  9033. } else {
  9034. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9035. utils.ErrorLog("解析失败:%v", err)
  9036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9037. return
  9038. }
  9039. }
  9040. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9041. // utils.ErrorLog("解析失败:%v", err)
  9042. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9043. // return
  9044. //}
  9045. if res.Infcode == 0 {
  9046. psn_record.IsCancel = 2
  9047. service.CreatePsnNCDSRecord(&psn_record)
  9048. c.ServeSuccessJSON(map[string]interface{}{
  9049. "failed_code": 0,
  9050. "msg": "撤销备案成功",
  9051. })
  9052. } else {
  9053. c.ServeSuccessJSON(map[string]interface{}{
  9054. "failed_code": -10,
  9055. "msg": res.ErrMsg,
  9056. })
  9057. return
  9058. }
  9059. }
  9060. }
  9061. func (c *HisApiController) TestTest() {
  9062. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  9063. fmt.Println(patient.Iinfo)
  9064. }
  9065. type CustomData struct {
  9066. MsgId string
  9067. PsnNo string
  9068. Info string
  9069. }
  9070. func (c *HisApiController) ReversalData() {
  9071. var customData []*CustomData
  9072. custom := &CustomData{
  9073. MsgId: "H44022900158202103301714472004",
  9074. PsnNo: "44020000001101329945",
  9075. Info: "2207",
  9076. }
  9077. customData = append(customData, custom)
  9078. custom1 := &CustomData{
  9079. MsgId: "H4402290015820210330172057803",
  9080. PsnNo: "44020000001101161813",
  9081. Info: "2207",
  9082. }
  9083. customData = append(customData, custom1)
  9084. custom2 := &CustomData{
  9085. MsgId: "H44022900158202103301705198813",
  9086. PsnNo: "44190000133097375417",
  9087. Info: "2207",
  9088. }
  9089. customData = append(customData, custom2)
  9090. custom3 := &CustomData{
  9091. MsgId: "H44022900158202103301715524756",
  9092. PsnNo: "44020000001100187221",
  9093. Info: "2207",
  9094. }
  9095. customData = append(customData, custom3)
  9096. custom4 := &CustomData{
  9097. MsgId: "H44022900158202103301730376224",
  9098. PsnNo: "44020000001101959155",
  9099. Info: "2207",
  9100. }
  9101. customData = append(customData, custom4)
  9102. custom5 := &CustomData{
  9103. MsgId: "H44022900158202103301748008725",
  9104. PsnNo: "44020000001104246641",
  9105. Info: "2207",
  9106. }
  9107. customData = append(customData, custom5)
  9108. custom6 := &CustomData{
  9109. MsgId: "H44022900158202103301718096755",
  9110. PsnNo: "44020000001102211860",
  9111. Info: "2207",
  9112. }
  9113. customData = append(customData, custom6)
  9114. custom7 := &CustomData{
  9115. MsgId: "H44022900158202103301736551640",
  9116. PsnNo: "44020000001102687718",
  9117. Info: "2207",
  9118. }
  9119. customData = append(customData, custom7)
  9120. custom8 := &CustomData{
  9121. MsgId: "H44022900158202103301743097676",
  9122. PsnNo: "44020000001102127785",
  9123. Info: "2207",
  9124. }
  9125. customData = append(customData, custom8)
  9126. custom9 := &CustomData{
  9127. MsgId: "H44022900158202103301712304203",
  9128. PsnNo: "44020000001101518097",
  9129. Info: "2207",
  9130. }
  9131. customData = append(customData, custom9)
  9132. custom10 := &CustomData{
  9133. MsgId: "H44022900158202103301738448785",
  9134. PsnNo: "44020000001100500813",
  9135. Info: "2207",
  9136. }
  9137. customData = append(customData, custom10)
  9138. custom11 := &CustomData{
  9139. MsgId: "H44022900158202103301732455843",
  9140. PsnNo: "44020000001102690557",
  9141. Info: "2207",
  9142. }
  9143. customData = append(customData, custom11)
  9144. custom12 := &CustomData{
  9145. MsgId: "H44022900158202103301745421708",
  9146. PsnNo: "44020000001102211928",
  9147. Info: "2207",
  9148. }
  9149. customData = append(customData, custom12)
  9150. custom1212 := &CustomData{
  9151. MsgId: "H440229001582021033017351627",
  9152. PsnNo: "44020000001102481733",
  9153. Info: "2207",
  9154. }
  9155. customData = append(customData, custom1212)
  9156. custom13 := &CustomData{
  9157. MsgId: "H44022900158202103301740327951",
  9158. PsnNo: "44020000001103174866",
  9159. Info: "2207",
  9160. }
  9161. customData = append(customData, custom13)
  9162. custom14 := &CustomData{
  9163. MsgId: "H4402290015820210330174922668",
  9164. PsnNo: "44020000001102927272",
  9165. Info: "2207",
  9166. }
  9167. customData = append(customData, custom14)
  9168. custom15 := &CustomData{
  9169. MsgId: "H44022900158202103301752362273",
  9170. PsnNo: "44020000001102942890",
  9171. Info: "2207",
  9172. }
  9173. customData = append(customData, custom15)
  9174. custom16 := &CustomData{
  9175. MsgId: "H44022900158202103301751082917",
  9176. PsnNo: "44020000001101662162",
  9177. Info: "2207",
  9178. }
  9179. customData = append(customData, custom16)
  9180. custom17 := &CustomData{
  9181. MsgId: "H44022900158202103301754147728",
  9182. PsnNo: "44020000000229014511",
  9183. Info: "2207",
  9184. }
  9185. customData = append(customData, custom17)
  9186. adminUser := c.GetAdminUserInfo()
  9187. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9188. for _, item := range customData {
  9189. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9190. fmt.Println(result)
  9191. }
  9192. }
  9193. func (c *HisApiController) GetAllopatry() {
  9194. year := c.GetString("year")
  9195. month := c.GetString("month")
  9196. admin_user_id, _ := c.GetInt64("admin_user_id")
  9197. adminUser := c.GetAdminUserInfo()
  9198. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9199. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9200. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9201. var dat map[string]interface{}
  9202. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9203. fmt.Println(dat)
  9204. } else {
  9205. fmt.Println(err)
  9206. }
  9207. userJSONBytes, _ := json.Marshal(dat)
  9208. var res models.Result9001
  9209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9210. utils.ErrorLog("解析失败:%v", err)
  9211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9212. return
  9213. }
  9214. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9215. var dat2 map[string]interface{}
  9216. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9217. fmt.Println(dat)
  9218. } else {
  9219. fmt.Println(err)
  9220. }
  9221. userJSONBytes2, _ := json.Marshal(dat2)
  9222. var res2 models.Result3260
  9223. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9224. utils.ErrorLog("解析失败:%v", err)
  9225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9226. return
  9227. }
  9228. if res2.Infcode == 0 {
  9229. c.ServeSuccessJSON(map[string]interface{}{
  9230. "list": res2.Output.Data,
  9231. })
  9232. return
  9233. } else {
  9234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9235. return
  9236. }
  9237. }
  9238. func (c *HisApiController) ComfirmAllopatry() {
  9239. year := c.GetString("year")
  9240. month := c.GetString("month")
  9241. admin_user_id, _ := c.GetInt64("admin_user_id")
  9242. adminUser := c.GetAdminUserInfo()
  9243. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9244. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9245. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9246. var dat map[string]interface{}
  9247. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9248. fmt.Println(dat)
  9249. } else {
  9250. fmt.Println(err)
  9251. }
  9252. userJSONBytes, _ := json.Marshal(dat)
  9253. var res models.Result9001
  9254. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9255. utils.ErrorLog("解析失败:%v", err)
  9256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9257. return
  9258. }
  9259. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9260. var dat2 map[string]interface{}
  9261. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9262. fmt.Println(dat)
  9263. } else {
  9264. fmt.Println(err)
  9265. }
  9266. userJSONBytes2, _ := json.Marshal(dat2)
  9267. var res2 models.Result3260
  9268. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9269. utils.ErrorLog("解析失败:%v", err)
  9270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9271. return
  9272. }
  9273. if res2.Infcode == 0 {
  9274. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  9275. var dat map[string]interface{}
  9276. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9277. fmt.Println(dat)
  9278. } else {
  9279. fmt.Println(err)
  9280. }
  9281. userJSONBytes, _ := json.Marshal(dat)
  9282. var res3 models.Result3261
  9283. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  9284. utils.ErrorLog("解析失败:%v", err)
  9285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9286. return
  9287. }
  9288. if res3.Infcode == 0 {
  9289. record := &models.HisYidiClearRecord{
  9290. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9291. Ctime: time.Now().Unix(),
  9292. Mtime: time.Now().Unix(),
  9293. Status: 1,
  9294. MsgId: msgId,
  9295. }
  9296. service.SaveClearRecord(record)
  9297. c.ServeSuccessJSON(map[string]interface{}{
  9298. "msg": "提取成功",
  9299. })
  9300. }
  9301. }
  9302. }
  9303. func (c *HisApiController) RefundAllopatry() {
  9304. year := c.GetString("year")
  9305. month := c.GetString("month")
  9306. id, _ := c.GetInt64("id")
  9307. admin_user_id, _ := c.GetInt64("admin_user_id")
  9308. adminUser := c.GetAdminUserInfo()
  9309. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9310. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9311. record, _ := service.GetClearRecordById(id)
  9312. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  9313. var dat map[string]interface{}
  9314. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9315. fmt.Println(dat)
  9316. } else {
  9317. fmt.Println(err)
  9318. }
  9319. userJSONBytes, _ := json.Marshal(dat)
  9320. var empty ResultFourteen
  9321. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  9322. utils.ErrorLog("解析失败:%v", err)
  9323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9324. return
  9325. }
  9326. if empty.Infcode == 0 {
  9327. c.ServeSuccessJSON(map[string]interface{}{
  9328. "msg": "撤销成功",
  9329. })
  9330. return
  9331. }
  9332. }
  9333. func (c *HisApiController) ReversalOtherData() {
  9334. var customData []*CustomData
  9335. custom := &CustomData{
  9336. MsgId: "H44022900158202103301714472004",
  9337. PsnNo: "44020000001101329945",
  9338. Info: "2208",
  9339. }
  9340. customData = append(customData, custom)
  9341. custom1 := &CustomData{
  9342. MsgId: "H4402290015820210330172057803",
  9343. PsnNo: "44020000001101161813",
  9344. Info: "2208",
  9345. }
  9346. customData = append(customData, custom1)
  9347. custom2 := &CustomData{
  9348. MsgId: "H44022900158202103301705198813",
  9349. PsnNo: "44190000133097375417",
  9350. Info: "2208",
  9351. }
  9352. customData = append(customData, custom2)
  9353. custom3 := &CustomData{
  9354. MsgId: "H44022900158202103301715524756",
  9355. PsnNo: "44020000001100187221",
  9356. Info: "2208",
  9357. }
  9358. customData = append(customData, custom3)
  9359. custom4 := &CustomData{
  9360. MsgId: "H44022900158202103301730376224",
  9361. PsnNo: "44020000001101959155",
  9362. Info: "2208",
  9363. }
  9364. customData = append(customData, custom4)
  9365. custom5 := &CustomData{
  9366. MsgId: "H44022900158202103301748008725",
  9367. PsnNo: "44020000001104246641",
  9368. Info: "2208",
  9369. }
  9370. customData = append(customData, custom5)
  9371. custom6 := &CustomData{
  9372. MsgId: "H44022900158202103301718096755",
  9373. PsnNo: "44020000001102211860",
  9374. Info: "2208",
  9375. }
  9376. customData = append(customData, custom6)
  9377. custom7 := &CustomData{
  9378. MsgId: "H44022900158202103301736551640",
  9379. PsnNo: "44020000001102687718",
  9380. Info: "2208",
  9381. }
  9382. customData = append(customData, custom7)
  9383. custom8 := &CustomData{
  9384. MsgId: "H44022900158202103301743097676",
  9385. PsnNo: "44020000001102127785",
  9386. Info: "2208",
  9387. }
  9388. customData = append(customData, custom8)
  9389. custom9 := &CustomData{
  9390. MsgId: "H44022900158202103301712304203",
  9391. PsnNo: "44020000001101518097",
  9392. Info: "2208",
  9393. }
  9394. customData = append(customData, custom9)
  9395. custom10 := &CustomData{
  9396. MsgId: "H44022900158202103301738448785",
  9397. PsnNo: "44020000001100500813",
  9398. Info: "2208",
  9399. }
  9400. customData = append(customData, custom10)
  9401. custom11 := &CustomData{
  9402. MsgId: "H44022900158202103301732455843",
  9403. PsnNo: "44020000001102690557",
  9404. Info: "2208",
  9405. }
  9406. customData = append(customData, custom11)
  9407. custom12 := &CustomData{
  9408. MsgId: "H44022900158202103301745421708",
  9409. PsnNo: "44020000001102211928",
  9410. Info: "2208",
  9411. }
  9412. customData = append(customData, custom12)
  9413. custom1212 := &CustomData{
  9414. MsgId: "H440229001582021033017351627",
  9415. PsnNo: "44020000001102481733",
  9416. Info: "2208",
  9417. }
  9418. customData = append(customData, custom1212)
  9419. custom13 := &CustomData{
  9420. MsgId: "H44022900158202103301740327951",
  9421. PsnNo: "44020000001103174866",
  9422. Info: "2208",
  9423. }
  9424. customData = append(customData, custom13)
  9425. custom14 := &CustomData{
  9426. MsgId: "H4402290015820210330174922668",
  9427. PsnNo: "44020000001102927272",
  9428. Info: "2208",
  9429. }
  9430. customData = append(customData, custom14)
  9431. custom15 := &CustomData{
  9432. MsgId: "H44022900158202103301752362273",
  9433. PsnNo: "44020000001102942890",
  9434. Info: "2208",
  9435. }
  9436. customData = append(customData, custom15)
  9437. custom16 := &CustomData{
  9438. MsgId: "H44022900158202103301751082917",
  9439. PsnNo: "44020000001101662162",
  9440. Info: "2208",
  9441. }
  9442. customData = append(customData, custom16)
  9443. custom17 := &CustomData{
  9444. MsgId: "H44022900158202103301754147728",
  9445. PsnNo: "44020000000229014511",
  9446. Info: "2208",
  9447. }
  9448. customData = append(customData, custom17)
  9449. adminUser := c.GetAdminUserInfo()
  9450. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9451. for _, item := range customData {
  9452. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9453. fmt.Println(result)
  9454. }
  9455. }
  9456. func PathExists(path string) (bool, error) {
  9457. _, err := os.Stat(path)
  9458. if err == nil {
  9459. return true, nil
  9460. }
  9461. if os.IsNotExist(err) {
  9462. return false, nil
  9463. }
  9464. return false, err
  9465. }
  9466. //创建文件夹
  9467. func Mkdir(dir string) {
  9468. // 创建文件夹
  9469. exist, err := PathExists(dir)
  9470. if err != nil {
  9471. fmt.Println(err.Error())
  9472. } else {
  9473. if exist {
  9474. fmt.Println(dir + "文件夹已存在!")
  9475. } else {
  9476. // 文件夹名称,权限
  9477. err := os.Mkdir(dir, os.ModePerm)
  9478. if err != nil {
  9479. fmt.Println(dir+"文件夹创建失败:", err.Error())
  9480. } else {
  9481. fmt.Println(dir + "文件夹创建成功!")
  9482. }
  9483. }
  9484. }
  9485. }
  9486. //压缩文件
  9487. func Zip(srcFile string, destZip string) error {
  9488. zipfile, err := os.Create(destZip)
  9489. if err != nil {
  9490. return err
  9491. }
  9492. defer zipfile.Close()
  9493. archive := zip.NewWriter(zipfile)
  9494. defer archive.Close()
  9495. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  9496. if err != nil {
  9497. return err
  9498. }
  9499. header, err := zip.FileInfoHeader(info)
  9500. if err != nil {
  9501. return err
  9502. }
  9503. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  9504. // header.Name = path
  9505. if info.IsDir() {
  9506. header.Name += "/"
  9507. } else {
  9508. header.Method = zip.Deflate
  9509. }
  9510. writer, err := archive.CreateHeader(header)
  9511. if err != nil {
  9512. return err
  9513. }
  9514. if !info.IsDir() {
  9515. file, err := os.Open(path)
  9516. if err != nil {
  9517. return err
  9518. }
  9519. defer file.Close()
  9520. _, err = io.Copy(writer, file)
  9521. }
  9522. return err
  9523. })
  9524. return err
  9525. }
  9526. func ReadFile(filePath string) []byte {
  9527. f, err := os.Open(filePath)
  9528. if err != nil {
  9529. fmt.Println("read file fail", err)
  9530. return nil
  9531. }
  9532. defer f.Close()
  9533. fd, err := ioutil.ReadAll(f)
  9534. if err != nil {
  9535. fmt.Println("read to fd fail", err)
  9536. return nil
  9537. }
  9538. return fd
  9539. }
  9540. func saveLog(result string, request string, infno string, desc string) {
  9541. org_id, _ := beego.AppConfig.Int64("org_id")
  9542. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  9543. dir := miConfig.OrgName + "日志"
  9544. utils.Mkdir(dir)
  9545. month := time.Unix(1557042972, 0).Format("1")
  9546. year := time.Now().Format("2006")
  9547. month = time.Now().Format("01")
  9548. day := time.Now().Format("02")
  9549. hour := time.Now().Format("15")
  9550. min := time.Now().Format("04")
  9551. sec := time.Now().Format("05")
  9552. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  9553. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  9554. file_name := file + ".txt"
  9555. file_path := miConfig.OrgName + "日志" + "/" + file_name
  9556. exist, _ := utils.PathExists(file_path)
  9557. if exist { //存在
  9558. fmt.Println("存在")
  9559. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  9560. if err != nil {
  9561. fmt.Println("read fail")
  9562. }
  9563. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  9564. n, _ := f.Seek(0, 2)
  9565. _, err = f.WriteAt([]byte(content), n)
  9566. } else { //不存在
  9567. fmt.Println("文件不存在,创建文件")
  9568. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  9569. defer f.Close()
  9570. if err != nil {
  9571. } else {
  9572. _, err = f.Write([]byte("记录日志"))
  9573. }
  9574. }
  9575. }
  9576. type Charset string
  9577. const (
  9578. UTF8 = Charset("UTF-8")
  9579. GB18030 = Charset("GB18030")
  9580. )
  9581. func ConvertToString(src string, srcCode string, tagCode string) string {
  9582. srcCoder := mahonia.NewDecoder(srcCode)
  9583. srcResult := srcCoder.ConvertString(src)
  9584. tagCoder := mahonia.NewDecoder(tagCode)
  9585. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  9586. result := string(cdata)
  9587. return result
  9588. }