his_api_controller.go 332KB

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