his_api_controller.go 339KB

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