his_api_controller.go 340KB

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