his_api_controller.go 336KB

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