his_api_controller.go 313KB

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