his_api_controller.go 339KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423
  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=" + doctor_info.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 + "&doctor_name=" + doctor_info.UserName
  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. psn_info, _ := service.GetPsnByPatientId(id)
  2879. bas := strings.Split(psn_info.CardInfo, "|")
  2880. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  2881. api := "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  2882. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2883. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber + "&verify_number=" + psn_info.VerifyNumber
  2884. resp, requestErr := http.Get(api)
  2885. if requestErr != nil {
  2886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2887. return
  2888. }
  2889. body, ioErr := ioutil.ReadAll(resp.Body)
  2890. if ioErr != nil {
  2891. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2893. return
  2894. }
  2895. var respJSON map[string]interface{}
  2896. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2899. return
  2900. }
  2901. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2902. result, _ := json.Marshal(respJSON)
  2903. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  2904. utils.ErrorLog("解析失败:%v", err)
  2905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2906. return
  2907. }
  2908. resThree.ErrMsg = resThree10265.ErrMsg
  2909. resThree.Output = resThree10265.Output
  2910. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  2911. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  2912. } else {
  2913. 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)
  2914. saveLog(result, requestLog, "2201", "挂号")
  2915. if miConfig.Code == "H15049901371" {
  2916. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  2917. utils.ErrorLog("解析失败:%v", err)
  2918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2919. return
  2920. }
  2921. resThree.ErrMsg = resThree10265.ErrMsg
  2922. resThree.Output = resThree10265.Output
  2923. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  2924. } else {
  2925. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  2926. utils.ErrorLog("解析失败:%v", err)
  2927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2928. return
  2929. }
  2930. }
  2931. if miConfig.Code == "H15049901371" {
  2932. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  2933. } else {
  2934. infocode = resThree.Infcode
  2935. }
  2936. }
  2937. if infocode != 0 {
  2938. adminUser := c.GetAdminUserInfo()
  2939. errlog := &models.HisOrderError{
  2940. UserOrgId: adminUser.CurrentOrgId,
  2941. Ctime: time.Now().Unix(),
  2942. Mtime: time.Now().Unix(),
  2943. ErrMsg: resThree.ErrMsg,
  2944. Status: 1,
  2945. PatientId: id,
  2946. RecordTime: recordDateTime,
  2947. Stage: 2,
  2948. }
  2949. service.CreateErrMsgLog(errlog)
  2950. c.ServeSuccessJSON(map[string]interface{}{
  2951. "failed_code": -10,
  2952. "msg": resThree.ErrMsg,
  2953. })
  2954. return
  2955. }
  2956. his.Number = resThree.Output.Data.MdtrtID
  2957. his.PsnNo = resThree.Output.Data.PsnNo
  2958. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  2959. his.IdCardNo = patient.IdCardNo
  2960. his.PhoneNumber = patient.Phone
  2961. his.UserOrgId = adminInfo.CurrentOrgId
  2962. his.Insutype = insutype
  2963. his.Ctime = time.Now().Unix()
  2964. his.Mtime = time.Now().Unix()
  2965. his.InsuplcAdmdvs = insuplc_admdvs
  2966. his.Status = 1
  2967. service.UpdateHisPatientStatus(&his)
  2968. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  2969. c.ServeSuccessJSON(map[string]interface{}{
  2970. "his_info": his,
  2971. })
  2972. } else {
  2973. adminUser := c.GetAdminUserInfo()
  2974. errlog := &models.HisOrderError{
  2975. UserOrgId: adminUser.CurrentOrgId,
  2976. Ctime: time.Now().Unix(),
  2977. Mtime: time.Now().Unix(),
  2978. ErrMsg: res.ErrMsg,
  2979. Status: 1,
  2980. PatientId: id,
  2981. RecordTime: recordDateTime,
  2982. Stage: 1,
  2983. }
  2984. service.CreateErrMsgLog(errlog)
  2985. c.ServeSuccessJSON(map[string]interface{}{
  2986. "failed_code": -10,
  2987. "msg": res.ErrMsg,
  2988. })
  2989. return
  2990. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  2991. }
  2992. }
  2993. }
  2994. //上传明细----预结算----确认订单
  2995. func (c *HisApiController) GetUploadInfo() {
  2996. id, _ := c.GetInt64("id")
  2997. record_time := c.GetString("record_time")
  2998. his_patient_id, _ := c.GetInt64("his_patient_id")
  2999. order_id, _ := c.GetInt64("order_id")
  3000. pay_way, _ := c.GetInt64("pay_way")
  3001. pay_price, _ := c.GetFloat("pay_price")
  3002. pay_card_no := c.GetString("pay_card_no")
  3003. discount_price, _ := c.GetFloat("discount_price")
  3004. preferential_price, _ := c.GetFloat("preferential_price")
  3005. reality_price, _ := c.GetFloat("reality_price")
  3006. found_price, _ := c.GetFloat("found_price")
  3007. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3008. private_price, _ := c.GetFloat("private_price")
  3009. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3010. admin_user_id, _ := c.GetInt64("admin_user_id")
  3011. fapiao_code := c.GetString("fapiao_code")
  3012. fapiao_number := c.GetString("fapiao_number")
  3013. diagnosis_id := c.GetString("diagnosis")
  3014. sick_type, _ := c.GetInt64("sick_type")
  3015. reg_type, _ := c.GetInt64("p_type")
  3016. begin_time := c.GetString("begin_time")
  3017. id_str := c.GetString("ids")
  3018. ids_arr := strings.Split(id_str, ",")
  3019. timeLayout := "2006-01-02"
  3020. loc, _ := time.LoadLocation("Local")
  3021. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3022. if err != nil {
  3023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3024. return
  3025. }
  3026. recordDateTime := theTime.Unix()
  3027. adminUser := c.GetAdminUserInfo()
  3028. var tempOrder models.HisOrder
  3029. tempOrder, _ = service.GetHisOrderByID(order_id)
  3030. var prescriptions []*models.HisPrescription
  3031. var start_time int64
  3032. var end_time int64
  3033. //if adminUser.CurrentOrgId == 10106{
  3034. // if len(fapiao_code) == 0{
  3035. // fapiao_code = "144072080589"
  3036. // }
  3037. // if len(fapiao_number) == 0{
  3038. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3039. // if order.ID == 0{
  3040. // fapiao_number = "00001520"
  3041. // }else{
  3042. // //fapiao_code = "00001520"
  3043. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3044. // var zero string
  3045. // if fpNumber >= 1000{
  3046. // zero = "0000" + strconv.Itoa(fpNumber)
  3047. // }else if fpNumber >= 10000{
  3048. // zero = "000" + strconv.Itoa(fpNumber)
  3049. // } else if fpNumber >= 100000{
  3050. // zero = "00" + strconv.Itoa(fpNumber)
  3051. // } else if fpNumber >= 1000000{
  3052. // zero = "0" + strconv.Itoa(fpNumber)
  3053. // }else {
  3054. // zero = strconv.Itoa(fpNumber)
  3055. // }
  3056. // fapiao_number = zero
  3057. // }
  3058. // }
  3059. //}
  3060. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3061. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3062. var patientPrescription models.HisPrescriptionInfo
  3063. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3064. if patientPrescription.ID == 0 {
  3065. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3066. }
  3067. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3068. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3069. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3070. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3071. var config []*models.HisXtDiagnoseConfig
  3072. for _, item := range diagnosis_ids {
  3073. id, _ := strconv.ParseInt(item, 10, 64)
  3074. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3075. config = append(config, &diagnosisConfig)
  3076. }
  3077. sickConfig, _ := service.FindSickById(sick_type)
  3078. if tempOrder.ID == 0 {
  3079. tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3080. }
  3081. if tempOrder.ID == 0 {
  3082. var result string
  3083. var requestLog string
  3084. var res2 ResultSix
  3085. var ressix10265 ResultSix10265
  3086. if miConfig.InsuplcAdmdvs == "421300" {
  3087. data := make(map[string]interface{})
  3088. client := &http.Client{}
  3089. data["psn_no"] = his.PsnNo
  3090. data["mdtrt_id"] = his.Number
  3091. data["doctor"] = roles.UserName
  3092. data["department"] = department.Name
  3093. data["org_name"] = miConfig.OrgName
  3094. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3095. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3096. data["fixmedins_code"] = miConfig.Code
  3097. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3098. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3099. data["secret_key"] = miConfig.SecretKey
  3100. data["sick_code"] = sickConfig.CountryCode
  3101. data["sick_name"] = sickConfig.ClassName
  3102. data["dept"] = strconv.FormatInt(department.ID, 10)
  3103. data["config"] = config
  3104. data["begin_time"] = begin_time
  3105. bytesData, _ := json.Marshal(data)
  3106. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3107. resp, _ := client.Do(req)
  3108. defer resp.Body.Close()
  3109. body, ioErr := ioutil.ReadAll(resp.Body)
  3110. if ioErr != nil {
  3111. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3113. return
  3114. }
  3115. var respJSON map[string]interface{}
  3116. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3117. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3119. return
  3120. }
  3121. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3122. userJSONBytes, _ := json.Marshal(respJSON)
  3123. fmt.Println("log")
  3124. fmt.Println(string(userJSONBytes))
  3125. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3126. utils.ErrorLog("解析失败:%v", err)
  3127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3128. return
  3129. }
  3130. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3131. data := make(map[string]interface{})
  3132. client := &http.Client{}
  3133. data["psn_no"] = his.PsnNo
  3134. data["mdtrt_id"] = his.Number
  3135. data["doctor"] = roles.UserName
  3136. data["department"] = department.Name
  3137. data["org_name"] = miConfig.OrgName
  3138. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3139. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3140. data["fixmedins_code"] = miConfig.Code
  3141. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3142. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3143. data["secret_key"] = miConfig.SecretKey
  3144. data["sick_code"] = sickConfig.CountryCode
  3145. data["sick_name"] = sickConfig.ClassName
  3146. data["url"] = miConfig.Url
  3147. data["ak"] = miConfig.ChannelNumber
  3148. data["begin_time"] = begin_time
  3149. data["dept"] = strconv.FormatInt(department.ID, 10)
  3150. data["config"] = config
  3151. bytesData, _ := json.Marshal(data)
  3152. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3153. resp, _ := client.Do(req)
  3154. defer resp.Body.Close()
  3155. body, ioErr := ioutil.ReadAll(resp.Body)
  3156. if ioErr != nil {
  3157. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3159. return
  3160. }
  3161. var respJSON map[string]interface{}
  3162. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3163. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3165. return
  3166. }
  3167. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3168. userJSONBytes, _ := json.Marshal(respJSON)
  3169. fmt.Println("log")
  3170. fmt.Println(string(userJSONBytes))
  3171. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  3172. utils.ErrorLog("解析失败:%v", err)
  3173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3174. return
  3175. }
  3176. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3177. res2.Output = ressix10265.Output
  3178. res2.ErrMsg = ressix10265.ErrMsg
  3179. res2.Cainfo = ressix10265.Cainfo
  3180. res2.WarnMsg = ressix10265.WarnMsg
  3181. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3182. res2.Infcode = infocode
  3183. } else {
  3184. if miConfig.MdtrtareaAdmvs == "440781" { //
  3185. 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)
  3186. } else {
  3187. if miConfig.Code == "H15049901371" {
  3188. //赤峰地区国家医保医疗类别
  3189. //职工透析:医疗类别选特殊情况门诊990502
  3190. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3191. var med_type string
  3192. if his.Insutype == "390" {
  3193. if reg_type == 14 {
  3194. med_type = "9933"
  3195. } else if reg_type == 11 {
  3196. med_type = "11"
  3197. }
  3198. } else if his.Insutype == "310" {
  3199. if reg_type == 14 {
  3200. med_type = "990502"
  3201. } else if reg_type == 11 {
  3202. med_type = "11"
  3203. }
  3204. }
  3205. 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)
  3206. } else {
  3207. 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)
  3208. }
  3209. }
  3210. saveLog(result, requestLog, "2203", "上传就诊信息")
  3211. var respJSON2 map[string]interface{}
  3212. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3213. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3215. return
  3216. }
  3217. userJSONBytes2, _ := json.Marshal(respJSON2)
  3218. if miConfig.Code == "H15049901371" {
  3219. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  3220. utils.ErrorLog("解析失败:%v", err)
  3221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3222. return
  3223. }
  3224. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3225. res2.Output = ressix10265.Output
  3226. res2.ErrMsg = ressix10265.ErrMsg
  3227. res2.Cainfo = ressix10265.Cainfo
  3228. res2.WarnMsg = ressix10265.WarnMsg
  3229. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3230. res2.Infcode = infocode
  3231. } else {
  3232. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3233. utils.ErrorLog("解析失败:%v", err)
  3234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3235. return
  3236. }
  3237. }
  3238. }
  3239. if res2.Infcode != 0 {
  3240. adminUser := c.GetAdminUserInfo()
  3241. errlog := &models.HisOrderError{
  3242. UserOrgId: adminUser.CurrentOrgId,
  3243. Ctime: time.Now().Unix(),
  3244. Mtime: time.Now().Unix(),
  3245. ErrMsg: res2.ErrMsg,
  3246. Status: 1,
  3247. PatientId: id,
  3248. RecordTime: recordDateTime,
  3249. Stage: 3,
  3250. }
  3251. service.CreateErrMsgLog(errlog)
  3252. c.ServeSuccessJSON(map[string]interface{}{
  3253. "failed_code": -10,
  3254. "msg": res2.ErrMsg,
  3255. })
  3256. return
  3257. } else {
  3258. his.Diagnosis = diagnosis_id
  3259. his.SickType = sickConfig.ID
  3260. var p_type int64
  3261. if reg_type == 1111 || reg_type == 1112 {
  3262. p_type = 11
  3263. }
  3264. his.PType = fmt.Sprintf("%d", p_type)
  3265. service.UpdateHisPatientThree(&his)
  3266. data := make(map[string]interface{})
  3267. if settle_accounts_type == 1 { //日结
  3268. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  3269. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  3270. } else {
  3271. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  3272. }
  3273. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  3274. data["pre"] = prescriptions
  3275. } else { //月结
  3276. start_time_str := c.GetString("start_time")
  3277. end_time_str := c.GetString("end_time")
  3278. timeLayout := "2006-01-02"
  3279. loc, _ := time.LoadLocation("Local")
  3280. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3281. if err != nil {
  3282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3283. return
  3284. }
  3285. recordStartTime := theStartTime.Unix()
  3286. start_time = recordStartTime
  3287. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3288. if err != nil {
  3289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3290. return
  3291. }
  3292. recordEndTime := theEndTime.Unix()
  3293. end_time = recordEndTime
  3294. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3295. data["pre"] = prescriptions
  3296. }
  3297. timestamp := time.Now().Unix()
  3298. tempTime := time.Unix(timestamp, 0)
  3299. timeFormat := tempTime.Format("20060102150405")
  3300. chrgBchno := rand.Intn(100000) + 10000
  3301. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3302. strconv.FormatInt(his.PatientId, 10)
  3303. client := &http.Client{}
  3304. data["psn_no"] = his.PsnNo
  3305. data["mdtrt_id"] = his.Number
  3306. data["chrg_bchno"] = chrg_bchno
  3307. data["org_name"] = miConfig.OrgName
  3308. data["doctor"] = roles.UserName
  3309. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3310. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3311. data["fixmedins_code"] = miConfig.Code
  3312. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3313. data["dept_code"] = "15"
  3314. } else {
  3315. data["dept_code"] = department.Number
  3316. }
  3317. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3318. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3319. data["secret_key"] = miConfig.SecretKey
  3320. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3321. data["url"] = miConfig.Url
  3322. data["ak"] = miConfig.ChannelNumber
  3323. data["new_doctor_name"] = patientPrescription.Doctor
  3324. var ids []int64
  3325. for _, item := range prescriptions {
  3326. ids = append(ids, item.ID)
  3327. }
  3328. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3329. if config.IsOpen == 1 { //对接了医保,走医保流程
  3330. var res ResultFour
  3331. var resFour10265 ResultFour10265
  3332. if miConfig.MdtrtareaAdmvs == "421300" {
  3333. bytesData, _ := json.Marshal(data)
  3334. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3335. resp, _ := client.Do(req)
  3336. defer resp.Body.Close()
  3337. body, ioErr := ioutil.ReadAll(resp.Body)
  3338. if ioErr != nil {
  3339. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3341. return
  3342. }
  3343. var respJSON map[string]interface{}
  3344. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3345. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3347. return
  3348. }
  3349. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3350. userJSONBytes, _ := json.Marshal(respJSON)
  3351. fmt.Println("log")
  3352. fmt.Println(string(userJSONBytes))
  3353. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3354. utils.ErrorLog("解析失败:%v", err)
  3355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3356. return
  3357. }
  3358. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3359. bytesData, _ := json.Marshal(data)
  3360. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  3361. resp, _ := client.Do(req)
  3362. defer resp.Body.Close()
  3363. body, ioErr := ioutil.ReadAll(resp.Body)
  3364. if ioErr != nil {
  3365. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3367. return
  3368. }
  3369. var respJSON map[string]interface{}
  3370. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3373. return
  3374. }
  3375. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3376. userJSONBytes, _ := json.Marshal(respJSON)
  3377. fmt.Println("log")
  3378. fmt.Println(string(userJSONBytes))
  3379. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3380. utils.ErrorLog("解析失败:%v", err)
  3381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3382. return
  3383. }
  3384. res.InfRefmsgid = resFour10265.InfRefmsgid
  3385. res.Output = resFour10265.Output
  3386. res.ErrMsg = resFour10265.ErrMsg
  3387. res.Cainfo = resFour10265.Cainfo
  3388. res.WarnMsg = resFour10265.WarnMsg
  3389. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3390. res.Infcode = infocode
  3391. } else {
  3392. if miConfig.Code == "H15049901371" {
  3393. 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)
  3394. var dat map[string]interface{}
  3395. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3396. fmt.Println(dat)
  3397. } else {
  3398. fmt.Println(err)
  3399. }
  3400. saveLog(result, request_log, "2204", "上传费用明细")
  3401. userJSONBytes, _ := json.Marshal(dat)
  3402. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3403. utils.ErrorLog("解析失败:%v", err)
  3404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3405. return
  3406. }
  3407. res.InfRefmsgid = resFour10265.InfRefmsgid
  3408. res.Output = resFour10265.Output
  3409. res.ErrMsg = resFour10265.ErrMsg
  3410. res.Cainfo = resFour10265.Cainfo
  3411. res.WarnMsg = resFour10265.WarnMsg
  3412. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3413. res.Infcode = infocode
  3414. } else {
  3415. 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)
  3416. var dat map[string]interface{}
  3417. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3418. fmt.Println(dat)
  3419. } else {
  3420. fmt.Println(err)
  3421. }
  3422. saveLog(result, request_log, "2204", "上传费用明细")
  3423. userJSONBytes, _ := json.Marshal(dat)
  3424. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3425. utils.ErrorLog("解析失败:%v", err)
  3426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3427. return
  3428. }
  3429. }
  3430. }
  3431. if res.Infcode == 0 {
  3432. order := &models.HisOrder{
  3433. UserOrgId: adminUser.CurrentOrgId,
  3434. HisPatientId: his.ID,
  3435. PatientId: his.PatientId,
  3436. SettleAccountsDate: recordDateTime,
  3437. Ctime: time.Now().Unix(),
  3438. Mtime: time.Now().Unix(),
  3439. Status: 1,
  3440. Number: chrg_bchno,
  3441. Infcode: res.Infcode,
  3442. WarnMsg: res.WarnMsg,
  3443. Cainfo: res.Cainfo,
  3444. ErrMsg: res.ErrMsg,
  3445. RespondTime: res.RefmsgTime,
  3446. InfRefmsgid: res.InfRefmsgid,
  3447. OrderStatus: 1,
  3448. PayWay: pay_way,
  3449. PayPrice: pay_price,
  3450. PayCardNo: pay_card_no,
  3451. DiscountPrice: discount_price,
  3452. PreferentialPrice: preferential_price,
  3453. RealityPrice: reality_price,
  3454. FoundPrice: found_price,
  3455. MedicalInsurancePrice: medical_insurance_price,
  3456. PrivatePrice: private_price,
  3457. IsMedicineInsurance: 1,
  3458. SettleType: settle_accounts_type,
  3459. SettleStartTime: start_time,
  3460. SettleEndTime: end_time,
  3461. Creator: roles.AdminUserId,
  3462. Modify: roles.AdminUserId,
  3463. FaPiaoNumber: fapiao_number,
  3464. FaPiaoCode: fapiao_code,
  3465. PType: 2,
  3466. Diagnosis: diagnosis_id,
  3467. }
  3468. err = service.CreateOrder(order)
  3469. if err != nil {
  3470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3471. return
  3472. }
  3473. for _, item := range res.Output.Result {
  3474. temp := strings.Split(item.FeedetlSn, "-")
  3475. var advice_id int64 = 0
  3476. var project_id int64 = 0
  3477. var types int64 = 0
  3478. id, _ := strconv.ParseInt(temp[2], 10, 64)
  3479. types, _ = strconv.ParseInt(temp[1], 10, 64)
  3480. if temp[1] == "1" {
  3481. advice_id = id
  3482. project_id = 0
  3483. } else if temp[1] == "2" {
  3484. advice_id = 0
  3485. project_id = id
  3486. }
  3487. info := &models.HisOrderInfo{
  3488. OrderNumber: order.Number,
  3489. FeedetlSn: item.FeedetlSn,
  3490. UploadDate: time.Now().Unix(),
  3491. AdviceId: advice_id,
  3492. DetItemFeeSumamt: item.DetItemFeeSumamt,
  3493. Cnt: item.Cnt,
  3494. Pric: float64(item.Pric),
  3495. PatientId: his.PatientId,
  3496. PricUplmtAmt: item.PricUplmtAmt,
  3497. SelfpayProp: item.SelfpayProp,
  3498. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3499. OverlmtAmt: item.OverlmtAmt,
  3500. PreselfpayAmt: item.PreselfpayAmt,
  3501. BasMednFlag: item.BasMednFlag,
  3502. MedChrgitmType: item.MedChrgitmType,
  3503. HiNegoDrugFlag: item.HiNegoDrugFlag,
  3504. Status: 1,
  3505. Memo: item.Memo,
  3506. Mtime: time.Now().Unix(),
  3507. InscpScpAmt: item.InscpScpAmt,
  3508. DrtReimFlag: item.DrtReimFlag,
  3509. Ctime: time.Now().Unix(),
  3510. ListSpItemFlag: item.ListSpItemFlag,
  3511. ChldMedcFlag: item.ChldMedcFlag,
  3512. LmtUsedFlag: item.LmtUsedFlag,
  3513. ChrgitmLv: item.ChrgitmLv,
  3514. UserOrgId: adminUser.CurrentOrgId,
  3515. HisPatientId: his.ID,
  3516. OrderId: order.ID,
  3517. ProjectId: project_id,
  3518. Type: types,
  3519. }
  3520. service.CreateOrderInfo(info)
  3521. }
  3522. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3523. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  3524. var total float64
  3525. for _, item := range prescriptions {
  3526. if item.Type == 1 { //药品
  3527. for _, subItem := range item.HisDoctorAdviceInfo {
  3528. total = total + (subItem.Price * subItem.PrescribingNumber)
  3529. }
  3530. }
  3531. if item.Type == 2 { //项目
  3532. for _, subItem := range item.HisPrescriptionProject {
  3533. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3534. total = total + (subItem.Price * cnt)
  3535. }
  3536. }
  3537. }
  3538. for _, item := range prescriptions {
  3539. for _, subItem := range item.HisAdditionalCharge {
  3540. total = total + (subItem.Price * float64(subItem.Count))
  3541. }
  3542. }
  3543. var allTotal string
  3544. if adminUser.CurrentOrgId == 9919 {
  3545. allTotal = fmt.Sprintf("%.4f", total)
  3546. } else {
  3547. allTotal = fmt.Sprintf("%.4f", total)
  3548. }
  3549. if res.Infcode == 0 {
  3550. var rf []*ResultFive
  3551. json.Unmarshal([]byte(his.Iinfo), &rf)
  3552. chrg_bchno := chrg_bchno
  3553. cert_no := his.Certno
  3554. var insutypes []string
  3555. var insutype string
  3556. var is390 int = 0
  3557. var is310 int = 0
  3558. for _, item := range rf {
  3559. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3560. insutypes = append(insutypes, item.Insutype)
  3561. }
  3562. }
  3563. if len(insutypes) == 1 {
  3564. insutype = insutypes[0]
  3565. } else {
  3566. for _, i := range insutypes {
  3567. if i == "390" {
  3568. is390 = 1
  3569. }
  3570. if i == "310" {
  3571. is310 = 1
  3572. }
  3573. }
  3574. }
  3575. if is390 == 1 {
  3576. insutype = "390"
  3577. }
  3578. if is310 == 1 {
  3579. insutype = "310"
  3580. }
  3581. if len(insutypes) == 0 {
  3582. insutype = "310"
  3583. }
  3584. if len(insutypes) == 2 {
  3585. insutype = strconv.FormatInt(his.SocialType, 10)
  3586. }
  3587. insutype = strconv.FormatInt(his.SocialType, 10)
  3588. //insutype = "390"
  3589. if his.IdCardType == 1 {
  3590. // cert_no = his.MedicalInsuranceNumber
  3591. cert_no = his.Certno
  3592. } else {
  3593. cert_no = his.Certno
  3594. }
  3595. var res ResultSeven
  3596. var resSeven10265 ResultSeven10265
  3597. var src_resquest string
  3598. var result2 string
  3599. var acct_used_flag string
  3600. fmt.Println("pay_way")
  3601. fmt.Println(pay_way)
  3602. fmt.Println("pay_way")
  3603. if pay_way == 4 {
  3604. acct_used_flag = "1"
  3605. } else {
  3606. acct_used_flag = "0"
  3607. }
  3608. if miConfig.MdtrtareaAdmvs == "421300" {
  3609. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3610. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3611. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3612. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3613. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3614. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3615. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3616. resp, requestErr := http.Get(api)
  3617. if requestErr != nil {
  3618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3619. return
  3620. }
  3621. body, ioErr := ioutil.ReadAll(resp.Body)
  3622. if ioErr != nil {
  3623. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3625. return
  3626. }
  3627. var respJSON map[string]interface{}
  3628. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3631. return
  3632. }
  3633. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3634. result, _ := json.Marshal(respJSON)
  3635. if miConfig.Code == "H15049901371" {
  3636. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  3637. utils.ErrorLog("解析失败:%v", err)
  3638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3639. return
  3640. }
  3641. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3642. res.Output = resSeven10265.Output
  3643. res.ErrMsg = resSeven10265.ErrMsg
  3644. res.Cainfo = resSeven10265.Cainfo
  3645. res.WarnMsg = resSeven10265.WarnMsg
  3646. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3647. res.Infcode = infocode
  3648. } else {
  3649. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3650. utils.ErrorLog("解析失败:%v", err)
  3651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3652. return
  3653. }
  3654. }
  3655. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3656. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  3657. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3658. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3659. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3660. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3661. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3662. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3663. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3664. "&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
  3665. resp, requestErr := http.Get(api)
  3666. if requestErr != nil {
  3667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3668. return
  3669. }
  3670. body, ioErr := ioutil.ReadAll(resp.Body)
  3671. if ioErr != nil {
  3672. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3674. return
  3675. }
  3676. var respJSON map[string]interface{}
  3677. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3680. return
  3681. }
  3682. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3683. result, _ := json.Marshal(respJSON)
  3684. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  3685. utils.ErrorLog("解析失败:%v", err)
  3686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3687. return
  3688. }
  3689. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3690. res.Output = resSeven10265.Output
  3691. res.ErrMsg = resSeven10265.ErrMsg
  3692. res.Cainfo = resSeven10265.Cainfo
  3693. res.WarnMsg = resSeven10265.WarnMsg
  3694. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3695. res.Infcode = infocode
  3696. } else {
  3697. if miConfig.Code == "H15049901371" {
  3698. //赤峰地区国家医保医疗类别
  3699. //职工透析:医疗类别选特殊情况门诊990502
  3700. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3701. var med_type string
  3702. if his.Insutype == "390" {
  3703. if reg_type == 14 {
  3704. med_type = "9933"
  3705. } else if reg_type == 11 {
  3706. med_type = "11"
  3707. }
  3708. } else if his.Insutype == "310" {
  3709. if reg_type == 14 {
  3710. med_type = "990502"
  3711. } else if reg_type == 11 {
  3712. med_type = "11"
  3713. }
  3714. }
  3715. 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)
  3716. } else {
  3717. 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)
  3718. }
  3719. //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)
  3720. var dat map[string]interface{}
  3721. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3722. fmt.Println(dat)
  3723. } else {
  3724. fmt.Println(err)
  3725. }
  3726. saveLog(result2, src_resquest, "2207", "结算")
  3727. userJSONBytes, _ := json.Marshal(dat)
  3728. if miConfig.Code == "H15049901371" {
  3729. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  3730. utils.ErrorLog("解析失败:%v", err)
  3731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3732. return
  3733. }
  3734. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3735. res.Output = resSeven10265.Output
  3736. res.ErrMsg = resSeven10265.ErrMsg
  3737. res.Cainfo = resSeven10265.Cainfo
  3738. res.WarnMsg = resSeven10265.WarnMsg
  3739. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3740. res.Infcode = infocode
  3741. } else {
  3742. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3743. utils.ErrorLog("解析失败:%v", err)
  3744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3745. return
  3746. }
  3747. }
  3748. }
  3749. if res.Infcode != 0 {
  3750. errlog := &models.HisOrderError{
  3751. UserOrgId: adminUser.CurrentOrgId,
  3752. Ctime: time.Now().Unix(),
  3753. Mtime: time.Now().Unix(),
  3754. Number: chrg_bchno,
  3755. ErrMsg: res.ErrMsg,
  3756. Status: 1,
  3757. PatientId: id,
  3758. RecordTime: recordDateTime,
  3759. Stage: 6,
  3760. }
  3761. service.CreateErrMsgLog(errlog)
  3762. c.ServeSuccessJSON(map[string]interface{}{
  3763. "failed_code": -10,
  3764. "msg": res.ErrMsg,
  3765. })
  3766. return
  3767. } else {
  3768. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3769. order.OrderStatus = 2
  3770. order.Status = 1
  3771. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3772. order.SetlId = res.Output.Setlinfo.SetlID
  3773. order.PsnNo = res.Output.Setlinfo.PsnNo
  3774. order.PsnName = res.Output.Setlinfo.PsnName
  3775. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3776. order.Certno = res.Output.Setlinfo.Certno
  3777. order.Gend = res.Output.Setlinfo.Gend
  3778. order.Naty = res.Output.Setlinfo.Naty
  3779. order.Age = res.Output.Setlinfo.Age
  3780. order.Insutype = res.Output.Setlinfo.Insutype
  3781. order.PsnType = res.Output.Setlinfo.PsnType
  3782. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3783. order.SetlTime = res.Output.Setlinfo.SetlTime
  3784. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3785. if res.Output.Setlinfo.MedType == "140101" {
  3786. order.MedType = "14"
  3787. } else {
  3788. order.MedType = res.Output.Setlinfo.MedType
  3789. }
  3790. if reg_type == 1112 {
  3791. order.MedType = "1112"
  3792. }
  3793. if reg_type == 1111 {
  3794. order.MedType = "1111"
  3795. }
  3796. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3797. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3798. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3799. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3800. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3801. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3802. order.HifpPay = res.Output.Setlinfo.HifpPay
  3803. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3804. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3805. order.HifesPay = res.Output.Setlinfo.HifesPay
  3806. order.HifobPay = res.Output.Setlinfo.HifobPay
  3807. order.MafPay = res.Output.Setlinfo.MafPay
  3808. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3809. order.OthPay = res.Output.Setlinfo.OthPay
  3810. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3811. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3812. order.AcctPay = res.Output.Setlinfo.AcctPay
  3813. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3814. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3815. order.Balc = res.Output.Setlinfo.Balc
  3816. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3817. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3818. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3819. order.ClrWay = res.Output.Setlinfo.ClrWay
  3820. order.Creator = order.Creator
  3821. order.Modify = roles.AdminUserId
  3822. order.RequestLog = src_resquest
  3823. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3824. detailStr := string(setlDetail)
  3825. order.SetlDetail = detailStr
  3826. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3827. err = service.UpDateOrder(order)
  3828. if err == nil {
  3829. c.ServeSuccessJSON(map[string]interface{}{
  3830. "msg": "结算成功",
  3831. })
  3832. } else {
  3833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3834. return
  3835. }
  3836. }
  3837. } else {
  3838. adminUser := c.GetAdminUserInfo()
  3839. errlog := &models.HisOrderError{
  3840. UserOrgId: adminUser.CurrentOrgId,
  3841. Ctime: time.Now().Unix(),
  3842. Mtime: time.Now().Unix(),
  3843. ErrMsg: res.ErrMsg,
  3844. Status: 1,
  3845. PatientId: id,
  3846. RecordTime: recordDateTime,
  3847. Stage: 4,
  3848. }
  3849. service.CreateErrMsgLog(errlog)
  3850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3851. return
  3852. }
  3853. } else {
  3854. adminUser := c.GetAdminUserInfo()
  3855. errlog := &models.HisOrderError{
  3856. UserOrgId: adminUser.CurrentOrgId,
  3857. Ctime: time.Now().Unix(),
  3858. Mtime: time.Now().Unix(),
  3859. ErrMsg: res.ErrMsg,
  3860. Status: 1,
  3861. PatientId: id,
  3862. RecordTime: recordDateTime,
  3863. Stage: 4,
  3864. }
  3865. service.CreateErrMsgLog(errlog)
  3866. c.ServeSuccessJSON(map[string]interface{}{
  3867. "failed_code": -10,
  3868. "msg": res.ErrMsg,
  3869. })
  3870. return
  3871. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  3872. //return
  3873. }
  3874. }
  3875. }
  3876. } else if tempOrder.ID > 0 {
  3877. if tempOrder.IsPre == 1 {
  3878. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  3879. var rf []*ResultFive
  3880. json.Unmarshal([]byte(his.Iinfo), &rf)
  3881. chrg_bchno := tempOrder.Number
  3882. cert_no := his.Certno
  3883. var insutypes []string
  3884. var insutype string
  3885. var is390 int = 0
  3886. var is310 int = 0
  3887. for _, item := range rf {
  3888. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3889. insutypes = append(insutypes, item.Insutype)
  3890. }
  3891. }
  3892. if len(insutypes) == 1 {
  3893. insutype = insutypes[0]
  3894. } else {
  3895. for _, i := range insutypes {
  3896. if i == "390" {
  3897. is390 = 1
  3898. }
  3899. if i == "310" {
  3900. is310 = 1
  3901. }
  3902. }
  3903. }
  3904. if is390 == 1 {
  3905. insutype = "390"
  3906. }
  3907. if is310 == 1 {
  3908. insutype = "310"
  3909. }
  3910. if len(insutypes) == 0 {
  3911. insutype = "310"
  3912. }
  3913. if len(insutypes) == 2 {
  3914. insutype = strconv.FormatInt(his.SocialType, 64)
  3915. }
  3916. //insutype = "390"
  3917. if his.IdCardType == 1 {
  3918. // cert_no = his.MedicalInsuranceNumber
  3919. cert_no = his.Certno
  3920. } else {
  3921. cert_no = his.Certno
  3922. }
  3923. var res ResultSeven
  3924. var resSeven10265 ResultSeven10265
  3925. var src_resquest string
  3926. var result2 string
  3927. var acct_used_flag string
  3928. fmt.Println("pay_way")
  3929. fmt.Println(pay_way)
  3930. fmt.Println("pay_way")
  3931. if pay_way == 4 {
  3932. acct_used_flag = "1"
  3933. } else {
  3934. acct_used_flag = "0"
  3935. }
  3936. if miConfig.MdtrtareaAdmvs == "421300" {
  3937. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3938. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3939. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3940. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3941. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3942. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3943. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3944. resp, requestErr := http.Get(api)
  3945. if requestErr != nil {
  3946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3947. return
  3948. }
  3949. body, ioErr := ioutil.ReadAll(resp.Body)
  3950. if ioErr != nil {
  3951. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3953. return
  3954. }
  3955. var respJSON map[string]interface{}
  3956. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3957. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3959. return
  3960. }
  3961. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3962. result, _ := json.Marshal(respJSON)
  3963. fmt.Println("log")
  3964. fmt.Println(string(result))
  3965. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3966. utils.ErrorLog("解析失败:%v", err)
  3967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3968. return
  3969. }
  3970. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3971. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  3972. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3973. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3974. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3975. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3976. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3977. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3978. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3979. "&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
  3980. resp, requestErr := http.Get(api)
  3981. if requestErr != nil {
  3982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3983. return
  3984. }
  3985. body, ioErr := ioutil.ReadAll(resp.Body)
  3986. if ioErr != nil {
  3987. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3989. return
  3990. }
  3991. var respJSON map[string]interface{}
  3992. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3995. return
  3996. }
  3997. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3998. result, _ := json.Marshal(respJSON)
  3999. fmt.Println("log")
  4000. fmt.Println(string(result))
  4001. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4002. utils.ErrorLog("解析失败:%v", err)
  4003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4004. return
  4005. }
  4006. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4007. res.Output = resSeven10265.Output
  4008. res.ErrMsg = resSeven10265.ErrMsg
  4009. res.Cainfo = resSeven10265.Cainfo
  4010. res.WarnMsg = resSeven10265.WarnMsg
  4011. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4012. res.Infcode = infocode
  4013. } else {
  4014. var src_resquest string
  4015. if miConfig.Code == "H15049901371" {
  4016. //赤峰地区国家医保医疗类别
  4017. //职工透析:医疗类别选特殊情况门诊990502
  4018. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4019. var med_type string
  4020. if his.Insutype == "390" {
  4021. if reg_type == 14 {
  4022. med_type = "9933"
  4023. } else if reg_type == 11 {
  4024. med_type = "11"
  4025. }
  4026. } else if his.Insutype == "310" {
  4027. if reg_type == 14 {
  4028. med_type = "990502"
  4029. } else if reg_type == 11 {
  4030. med_type = "11"
  4031. }
  4032. }
  4033. 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)
  4034. } else {
  4035. 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)
  4036. }
  4037. var dat map[string]interface{}
  4038. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4039. fmt.Println(dat)
  4040. } else {
  4041. fmt.Println(err)
  4042. }
  4043. saveLog(result2, src_resquest, "2207", "结算")
  4044. userJSONBytes, _ := json.Marshal(dat)
  4045. if miConfig.Code == "H15049901371" {
  4046. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4047. utils.ErrorLog("解析失败:%v", err)
  4048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4049. return
  4050. }
  4051. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4052. res.Output = resSeven10265.Output
  4053. res.ErrMsg = resSeven10265.ErrMsg
  4054. res.Cainfo = resSeven10265.Cainfo
  4055. res.WarnMsg = resSeven10265.WarnMsg
  4056. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4057. res.Infcode = infocode
  4058. } else {
  4059. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4060. utils.ErrorLog("解析失败:%v", err)
  4061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4062. return
  4063. }
  4064. }
  4065. }
  4066. if res.Infcode != 0 {
  4067. errlog := &models.HisOrderError{
  4068. UserOrgId: adminUser.CurrentOrgId,
  4069. Ctime: time.Now().Unix(),
  4070. Mtime: time.Now().Unix(),
  4071. Number: chrg_bchno,
  4072. ErrMsg: res.ErrMsg,
  4073. Status: 1,
  4074. PatientId: id,
  4075. RecordTime: recordDateTime,
  4076. Stage: 6,
  4077. }
  4078. service.CreateErrMsgLog(errlog)
  4079. c.ServeSuccessJSON(map[string]interface{}{
  4080. "failed_code": -10,
  4081. "msg": res.ErrMsg,
  4082. })
  4083. return
  4084. } else {
  4085. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4086. order.OrderStatus = 2
  4087. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4088. order.SetlId = res.Output.Setlinfo.SetlID
  4089. order.PsnNo = res.Output.Setlinfo.PsnNo
  4090. order.PsnName = res.Output.Setlinfo.PsnName
  4091. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4092. order.Certno = res.Output.Setlinfo.Certno
  4093. order.Gend = res.Output.Setlinfo.Gend
  4094. order.Naty = res.Output.Setlinfo.Naty
  4095. order.Age = res.Output.Setlinfo.Age
  4096. order.Insutype = res.Output.Setlinfo.Insutype
  4097. order.PsnType = res.Output.Setlinfo.PsnType
  4098. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4099. order.SetlTime = res.Output.Setlinfo.SetlTime
  4100. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4101. //order.MedType = res.Output.Setlinfo.MedType
  4102. if reg_type == 1112 {
  4103. order.MedType = "1112"
  4104. }
  4105. if reg_type == 1111 {
  4106. order.MedType = "1111"
  4107. }
  4108. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4109. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4110. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4111. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4112. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4113. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4114. order.HifpPay = res.Output.Setlinfo.HifpPay
  4115. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4116. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4117. order.HifesPay = res.Output.Setlinfo.HifesPay
  4118. order.HifobPay = res.Output.Setlinfo.HifobPay
  4119. order.MafPay = res.Output.Setlinfo.MafPay
  4120. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4121. order.OthPay = res.Output.Setlinfo.OthPay
  4122. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4123. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4124. order.AcctPay = res.Output.Setlinfo.AcctPay
  4125. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4126. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4127. order.Balc = res.Output.Setlinfo.Balc
  4128. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4129. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4130. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4131. order.ClrWay = res.Output.Setlinfo.ClrWay
  4132. order.Creator = order.Creator
  4133. order.Modify = roles.AdminUserId
  4134. order.RequestLog = src_resquest
  4135. order.Diagnosis = diagnosis_id
  4136. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4137. detailStr := string(setlDetail)
  4138. order.SetlDetail = detailStr
  4139. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4140. err = service.UpDateOrder(order)
  4141. if err == nil {
  4142. c.ServeSuccessJSON(map[string]interface{}{
  4143. "msg": "结算成功",
  4144. })
  4145. } else {
  4146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4147. return
  4148. }
  4149. }
  4150. }
  4151. }
  4152. }
  4153. //func (c *HisApiController) GetPreUploadInfo() {
  4154. // id, _ := c.GetInt64("id")
  4155. // record_time := c.GetString("record_time")
  4156. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4157. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4158. //
  4159. // timeLayout := "2006-01-02"
  4160. // loc, _ := time.LoadLocation("Local")
  4161. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4162. // if err != nil {
  4163. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4164. // return
  4165. // }
  4166. // recordDateTime := theTime.Unix()
  4167. // adminUser := c.GetAdminUserInfo()
  4168. //
  4169. // var prescriptions []*models.HisPrescription
  4170. //
  4171. // var start_time int64
  4172. // var end_time int64
  4173. //
  4174. // data := make(map[string]interface{})
  4175. // if settle_accounts_type == 1 { //日结
  4176. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4177. // data["pre"] = prescriptions
  4178. //
  4179. // } else { //月结
  4180. // start_time_str := c.GetString("start_time")
  4181. // end_time_str := c.GetString("end_time")
  4182. // timeLayout := "2006-01-02"
  4183. // loc, _ := time.LoadLocation("Local")
  4184. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4185. // if err != nil {
  4186. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4187. // return
  4188. // }
  4189. // recordStartTime := theStartTime.Unix()
  4190. // start_time = recordStartTime
  4191. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4192. // if err != nil {
  4193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4194. // return
  4195. // }
  4196. // recordEndTime := theEndTime.Unix()
  4197. // end_time = recordEndTime
  4198. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4199. // data["pre"] = prescriptions
  4200. //
  4201. // }
  4202. //
  4203. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4204. //
  4205. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4206. // timestamp := time.Now().Unix()
  4207. // tempTime := time.Unix(timestamp, 0)
  4208. // timeFormat := tempTime.Format("20060102150405")
  4209. // chrgBchno := rand.Intn(100000) + 10000
  4210. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4211. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4212. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4213. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4214. // strconv.FormatInt(his.PatientId, 10)
  4215. // client := &http.Client{}
  4216. // data["psn_no"] = his.PsnNo
  4217. // data["mdtrt_id"] = his.Number
  4218. // data["chrg_bchno"] = chrg_bchno
  4219. // data["org_name"] = miConfig.OrgName
  4220. // data["doctor"] = roles.UserName
  4221. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4222. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4223. // data["fixmedins_code"] = miConfig.Code
  4224. // data["dept_code"] = department.Number
  4225. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4226. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4227. // data["secret_key"] = miConfig.SecretKey
  4228. // var ids []int64
  4229. //
  4230. // for _, item := range prescriptions {
  4231. // ids = append(ids, item.ID)
  4232. // }
  4233. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4234. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4235. // bytesData, _ := json.Marshal(data)
  4236. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  4237. // resp, _ := client.Do(req)
  4238. // defer resp.Body.Close()
  4239. // body, ioErr := ioutil.ReadAll(resp.Body)
  4240. // if ioErr != nil {
  4241. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4242. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4243. // return
  4244. // }
  4245. // var respJSON map[string]interface{}
  4246. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4247. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4248. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4249. // return
  4250. // }
  4251. //
  4252. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4253. // userJSONBytes, _ := json.Marshal(respJSON)
  4254. // var res ResultFour
  4255. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4256. // utils.ErrorLog("解析失败:%v", err)
  4257. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4258. // return
  4259. // }
  4260. //
  4261. // if res.Infcode == 0 {
  4262. // order := &models.HisOrder{
  4263. // UserOrgId: adminUser.CurrentOrgId,
  4264. // HisPatientId: his.ID,
  4265. // PatientId: his.PatientId,
  4266. // SettleAccountsDate: recordDateTime,
  4267. // Ctime: time.Now().Unix(),
  4268. // Mtime: time.Now().Unix(),
  4269. // Status: 1,
  4270. // Number: chrg_bchno,
  4271. // Infcode: res.Infcode,
  4272. // WarnMsg: res.WarnMsg,
  4273. // Cainfo: res.Cainfo,
  4274. // ErrMsg: res.ErrMsg,
  4275. // RespondTime: res.RefmsgTime,
  4276. // InfRefmsgid: res.InfRefmsgid,
  4277. // OrderStatus: 1,
  4278. // IsMedicineInsurance: 1,
  4279. // SettleType: settle_accounts_type,
  4280. // SettleStartTime: start_time,
  4281. // SettleEndTime: end_time,
  4282. // Creator: roles.ID,
  4283. // Modify: roles.ID,
  4284. // PType: 2,
  4285. // }
  4286. // err = service.CreateOrder(order)
  4287. // if err != nil {
  4288. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4289. // return
  4290. // }
  4291. //
  4292. // for _, item := range res.Output.Result {
  4293. // temp := strings.Split(item.FeedetlSn, "-")
  4294. // var advice_id int64 = 0
  4295. // var project_id int64 = 0
  4296. // var types int64 = 0
  4297. //
  4298. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  4299. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  4300. //
  4301. // if temp[1] == "1" {
  4302. // advice_id = id
  4303. // project_id = 0
  4304. // } else if temp[1] == "2" {
  4305. // advice_id = 0
  4306. // project_id = id
  4307. // }
  4308. //
  4309. // info := &models.HisOrderInfo{
  4310. // OrderNumber: order.Number,
  4311. // FeedetlSn: item.FeedetlSn,
  4312. // UploadDate: time.Now().Unix(),
  4313. // AdviceId: advice_id,
  4314. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  4315. // Cnt: item.Cnt,
  4316. // Pric: float64(item.Pric),
  4317. // PatientId: his.PatientId,
  4318. // PricUplmtAmt: item.PricUplmtAmt,
  4319. // SelfpayProp: item.SelfpayProp,
  4320. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4321. // OverlmtAmt: item.OverlmtAmt,
  4322. // PreselfpayAmt: item.PreselfpayAmt,
  4323. // BasMednFlag: item.BasMednFlag,
  4324. // MedChrgitmType: item.MedChrgitmType,
  4325. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  4326. // Status: 1,
  4327. // Memo: item.Memo,
  4328. // Mtime: time.Now().Unix(),
  4329. // InscpScpAmt: item.InscpScpAmt,
  4330. // DrtReimFlag: item.DrtReimFlag,
  4331. // Ctime: time.Now().Unix(),
  4332. // ListSpItemFlag: item.ListSpItemFlag,
  4333. // ChldMedcFlag: item.ChldMedcFlag,
  4334. // LmtUsedFlag: item.LmtUsedFlag,
  4335. // ChrgitmLv: item.ChrgitmLv,
  4336. // UserOrgId: adminUser.CurrentOrgId,
  4337. // HisPatientId: his.ID,
  4338. // OrderId: order.ID,
  4339. // ProjectId: project_id,
  4340. // Type: types,
  4341. // }
  4342. // service.CreateOrderInfo(info)
  4343. //
  4344. // }
  4345. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4346. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  4347. //
  4348. // var total float64
  4349. // for _, item := range prescriptions {
  4350. // if item.Type == 1 { //药品
  4351. // for _, subItem := range item.HisDoctorAdviceInfo {
  4352. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4353. // }
  4354. // }
  4355. // if item.Type == 2 { //项目
  4356. // for _, subItem := range item.HisPrescriptionProject {
  4357. // total = total + (subItem.Price * float64(subItem.Count))
  4358. // }
  4359. // }
  4360. // }
  4361. //
  4362. // for _, item := range prescriptions {
  4363. // for _, subItem := range item.HisAdditionalCharge {
  4364. // total = total + (subItem.Price * float64(subItem.Count))
  4365. // }
  4366. // }
  4367. //
  4368. // allTotal := fmt.Sprintf("%.2f", total)
  4369. // if res.Infcode == 0 {
  4370. // var rf []*ResultFive
  4371. // json.Unmarshal([]byte(his.Iinfo), &rf)
  4372. // psn_no := his.PsnNo
  4373. // mdtrt_id := his.Number
  4374. // chrg_bchno := chrg_bchno
  4375. // cert_no := his.Certno
  4376. // insutype := rf[0].Insutype
  4377. //
  4378. // if his.IdCardType == 1 {
  4379. // cert_no = his.MedicalInsuranceNumber
  4380. //
  4381. // } else {
  4382. //
  4383. // cert_no = his.Certno
  4384. //
  4385. // }
  4386. //
  4387. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  4388. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  4389. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  4390. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  4391. // resp, requestErr := http.Get(api)
  4392. // if requestErr != nil {
  4393. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4394. // return
  4395. // }
  4396. // defer resp.Body.Close()
  4397. // body, ioErr := ioutil.ReadAll(resp.Body)
  4398. // if ioErr != nil {
  4399. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4400. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4401. // return
  4402. // }
  4403. // var respJSON map[string]interface{}
  4404. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4405. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4406. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4407. // return
  4408. // }
  4409. // fmt.Println(respJSON)
  4410. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4411. // userJSONBytes, _ := json.Marshal(respJSON)
  4412. // var res ResultSeven
  4413. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4414. // utils.ErrorLog("解析失败:%v", err)
  4415. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4416. // return
  4417. // }
  4418. // if res.Infcode != 0 {
  4419. // errlog := &models.HisOrderError{
  4420. // UserOrgId: adminUser.CurrentOrgId,
  4421. // Ctime: time.Now().Unix(),
  4422. // Mtime: time.Now().Unix(),
  4423. // Number: chrg_bchno,
  4424. // ErrMsg: res.ErrMsg,
  4425. // Status: 1,
  4426. // PatientId: id,
  4427. // RecordTime: recordDateTime,
  4428. // Stage: 7,
  4429. // }
  4430. // service.CreateErrMsgLog(errlog)
  4431. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4432. // return
  4433. // } else {
  4434. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4435. // order.OrderStatus = 1
  4436. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4437. // order.SetlId = res.Output.Setlinfo.SetlID
  4438. // order.PsnNo = res.Output.Setlinfo.PsnNo
  4439. // order.PsnName = res.Output.Setlinfo.PsnName
  4440. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4441. // order.Certno = res.Output.Setlinfo.Certno
  4442. // order.Gend = res.Output.Setlinfo.Gend
  4443. // order.Naty = res.Output.Setlinfo.Naty
  4444. // order.Age = res.Output.Setlinfo.Age
  4445. // order.Insutype = res.Output.Setlinfo.Insutype
  4446. // order.PsnType = res.Output.Setlinfo.PsnType
  4447. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4448. // order.SetlTime = res.Output.Setlinfo.SetlTime
  4449. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4450. // order.MedType = res.Output.Setlinfo.MedType
  4451. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4452. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4453. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4454. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4455. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4456. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4457. // order.HifpPay = res.Output.Setlinfo.HifpPay
  4458. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4459. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4460. // order.HifesPay = res.Output.Setlinfo.HifesPay
  4461. // order.HifobPay = res.Output.Setlinfo.HifobPay
  4462. // order.MafPay = res.Output.Setlinfo.MafPay
  4463. // order.OthPay = res.Output.Setlinfo.OthPay
  4464. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4465. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4466. // order.AcctPay = res.Output.Setlinfo.AcctPay
  4467. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4468. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4469. // order.Balc = res.Output.Setlinfo.Balc
  4470. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4471. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4472. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4473. // order.ClrWay = res.Output.Setlinfo.ClrWay
  4474. // order.Creator = order.Creator
  4475. // order.Modify = roles.ID
  4476. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4477. // detailStr := string(setlDetail)
  4478. // order.SetlDetail = detailStr
  4479. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4480. // err = service.UpDateOrder(order)
  4481. // if err == nil {
  4482. // c.ServeSuccessJSON(map[string]interface{}{
  4483. // "msg": "预结算成功",
  4484. // })
  4485. // } else {
  4486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4487. // return
  4488. // }
  4489. // }
  4490. // } else {
  4491. // adminUser := c.GetAdminUserInfo()
  4492. // errlog := &models.HisOrderError{
  4493. // UserOrgId: adminUser.CurrentOrgId,
  4494. // Ctime: time.Now().Unix(),
  4495. // Mtime: time.Now().Unix(),
  4496. // ErrMsg: res.ErrMsg,
  4497. // Status: 1,
  4498. // PatientId: id,
  4499. // RecordTime: recordDateTime,
  4500. // Stage: 4,
  4501. // }
  4502. // service.CreateErrMsgLog(errlog)
  4503. //
  4504. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4505. // return
  4506. // }
  4507. // } else {
  4508. // adminUser := c.GetAdminUserInfo()
  4509. // errlog := &models.HisOrderError{
  4510. // UserOrgId: adminUser.CurrentOrgId,
  4511. // Ctime: time.Now().Unix(),
  4512. // Mtime: time.Now().Unix(),
  4513. // ErrMsg: res.ErrMsg,
  4514. // Status: 1,
  4515. // PatientId: id,
  4516. // RecordTime: recordDateTime,
  4517. // Stage: 4,
  4518. // }
  4519. // service.CreateErrMsgLog(errlog)
  4520. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4521. // return
  4522. // }
  4523. //
  4524. // } else {
  4525. // var total float64
  4526. // for _, item := range prescriptions {
  4527. // if item.Type == 1 { //药品
  4528. // for _, subItem := range item.HisDoctorAdviceInfo {
  4529. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4530. // }
  4531. // }
  4532. // if item.Type == 2 { //项目
  4533. // for _, subItem := range item.HisPrescriptionProject {
  4534. // total = total + (subItem.Price * float64(subItem.Count))
  4535. // }
  4536. // }
  4537. //
  4538. // for _, subItem := range item.HisAdditionalCharge {
  4539. // total = total + (subItem.Price * float64(subItem.Count))
  4540. // }
  4541. // }
  4542. //
  4543. // allTotal := fmt.Sprintf("%.2f", total)
  4544. // totals, _ := strconv.ParseFloat(allTotal, 64)
  4545. // order := &models.HisOrder{
  4546. // UserOrgId: adminUser.CurrentOrgId,
  4547. // HisPatientId: his.ID,
  4548. // PatientId: id,
  4549. // SettleAccountsDate: recordDateTime,
  4550. // Ctime: time.Now().Unix(),
  4551. // Mtime: time.Now().Unix(),
  4552. // Status: 1,
  4553. // OrderStatus: 2,
  4554. // Number: chrg_bchno,
  4555. // MedfeeSumamt: totals,
  4556. // }
  4557. // err = service.CreateOrder(order)
  4558. // if err != nil {
  4559. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4560. // return
  4561. // }
  4562. //
  4563. // var customs []*Custom
  4564. // for _, item := range prescriptions {
  4565. //
  4566. // if item.Type == 1 { //药品
  4567. // for _, subItem := range item.HisDoctorAdviceInfo {
  4568. // cus := &Custom{
  4569. // AdviceId: subItem.ID,
  4570. // ProjectId: 0,
  4571. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  4572. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  4573. // FeedetlSn: subItem.FeedetlSn,
  4574. // Price: fmt.Sprintf("%.2f", subItem.Price),
  4575. // MedListCodg: subItem.MedListCodg,
  4576. // Type: 1,
  4577. // }
  4578. // customs = append(customs, cus)
  4579. // }
  4580. // }
  4581. //
  4582. // if item.Type == 2 { //项目
  4583. // for _, subItem := range item.HisPrescriptionProject {
  4584. //
  4585. // cus := &Custom{
  4586. // AdviceId: 0,
  4587. // ProjectId: subItem.ID,
  4588. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  4589. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  4590. // FeedetlSn: subItem.FeedetlSn,
  4591. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  4592. // MedListCodg: subItem.MedListCodg,
  4593. // Type: 2,
  4594. // }
  4595. //
  4596. // customs = append(customs, cus)
  4597. // }
  4598. // }
  4599. //
  4600. // for _, item := range item.HisAdditionalCharge {
  4601. // cus := &Custom{
  4602. // ItemId: item.ID,
  4603. // AdviceId: 0,
  4604. // ProjectId: 0,
  4605. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  4606. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  4607. // FeedetlSn: item.FeedetlSn,
  4608. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  4609. // MedListCodg: item.XtHisAddtionConfig.Code,
  4610. // Type: 3,
  4611. // }
  4612. //
  4613. // customs = append(customs, cus)
  4614. // }
  4615. //
  4616. // }
  4617. //
  4618. // for _, item := range customs {
  4619. // var advice_id int64 = 0
  4620. // var project_id int64 = 0
  4621. // var item_id int64 = 0
  4622. //
  4623. // var types int64 = 0
  4624. //
  4625. // if item.Type == 1 {
  4626. // advice_id = item.AdviceId
  4627. // project_id = 0
  4628. // item_id = 0
  4629. // } else if item.Type == 2 {
  4630. // advice_id = 0
  4631. // item_id = 0
  4632. //
  4633. // project_id = item.ProjectId
  4634. // } else if item.Type == 3 {
  4635. // advice_id = 0
  4636. // item_id = item.ItemId
  4637. // project_id = 0
  4638. // }
  4639. //
  4640. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  4641. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  4642. // pric, _ := strconv.ParseFloat(item.Price, 32)
  4643. //
  4644. // info := &models.HisOrderInfo{
  4645. // OrderNumber: order.Number,
  4646. // UploadDate: time.Now().Unix(),
  4647. // AdviceId: advice_id,
  4648. // DetItemFeeSumamt: detItemFeeSumamt,
  4649. // Cnt: cut,
  4650. // Pric: pric,
  4651. // PatientId: id,
  4652. // Status: 1,
  4653. // Mtime: time.Now().Unix(),
  4654. // Ctime: time.Now().Unix(),
  4655. // UserOrgId: adminUser.CurrentOrgId,
  4656. // HisPatientId: his.ID,
  4657. // OrderId: order.ID,
  4658. // ProjectId: project_id,
  4659. // Type: types,
  4660. // ItemId: item_id,
  4661. // }
  4662. // service.CreateOrderInfo(info)
  4663. // }
  4664. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4665. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4666. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  4667. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4668. // if err == nil {
  4669. // c.ServeSuccessJSON(map[string]interface{}{
  4670. // "msg": "结算成功",
  4671. // })
  4672. // } else {
  4673. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4674. // return
  4675. // }
  4676. // }
  4677. //}
  4678. //上传明细-预结算-
  4679. func (c *HisApiController) GetPreUploadInfo() {
  4680. id, _ := c.GetInt64("id")
  4681. record_time := c.GetString("record_time")
  4682. his_patient_id, _ := c.GetInt64("his_patient_id")
  4683. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4684. admin_user_id, _ := c.GetInt64("admin_user_id")
  4685. diagnosis_id := c.GetString("diagnosis")
  4686. sick_type, _ := c.GetInt64("sick_type")
  4687. reg_type, _ := c.GetInt64("p_type")
  4688. begin_time := c.GetString("begin_time")
  4689. id_str := c.GetString("ids")
  4690. ids_arr := strings.Split(id_str, ",")
  4691. timeLayout := "2006-01-02"
  4692. loc, _ := time.LoadLocation("Local")
  4693. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4694. if err != nil {
  4695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4696. return
  4697. }
  4698. recordDateTime := theTime.Unix()
  4699. adminUser := c.GetAdminUserInfo()
  4700. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4701. var config []*models.HisXtDiagnoseConfig
  4702. for _, item := range diagnosis_ids {
  4703. id, _ := strconv.ParseInt(item, 10, 64)
  4704. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4705. config = append(config, &diagnosisConfig)
  4706. }
  4707. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  4708. sickConfig, _ := service.FindSickById(sick_type)
  4709. var prescriptions []*models.HisPrescription
  4710. var start_time int64
  4711. var end_time int64
  4712. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4713. fmt.Println(his_patient_id)
  4714. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4715. timestamp := time.Now().Unix()
  4716. tempTime := time.Unix(timestamp, 0)
  4717. timeFormat := tempTime.Format("20060102150405")
  4718. chrgBchno := rand.Intn(100000) + 10000
  4719. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4720. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4721. var patientPrescription models.HisPrescriptionInfo
  4722. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4723. if patientPrescription.ID == 0 {
  4724. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4725. }
  4726. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4727. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4728. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4729. strconv.FormatInt(his.PatientId, 10)
  4730. var res2 ResultSix
  4731. var resSix10265 ResultSix10265
  4732. if miConfig.InsuplcAdmdvs == "421300" {
  4733. data := make(map[string]interface{})
  4734. client := &http.Client{}
  4735. data["psn_no"] = his.PsnNo
  4736. data["mdtrt_id"] = his.Number
  4737. data["doctor"] = roles.UserName
  4738. data["department"] = department.Name
  4739. data["org_name"] = miConfig.OrgName
  4740. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4741. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4742. data["fixmedins_code"] = miConfig.Code
  4743. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4744. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4745. data["secret_key"] = miConfig.SecretKey
  4746. data["sick_code"] = sickConfig.CountryCode
  4747. data["sick_name"] = sickConfig.ClassName
  4748. data["begin_time"] = begin_time
  4749. data["dept"] = strconv.FormatInt(department.ID, 10)
  4750. data["config"] = config
  4751. fmt.Println(data)
  4752. bytesData, _ := json.Marshal(data)
  4753. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4754. resp, _ := client.Do(req)
  4755. defer resp.Body.Close()
  4756. body, ioErr := ioutil.ReadAll(resp.Body)
  4757. if ioErr != nil {
  4758. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4760. return
  4761. }
  4762. var respJSON map[string]interface{}
  4763. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4764. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4766. return
  4767. }
  4768. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4769. userJSONBytes, _ := json.Marshal(respJSON)
  4770. fmt.Println("log")
  4771. fmt.Println(string(userJSONBytes))
  4772. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4773. utils.ErrorLog("解析失败:%v", err)
  4774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4775. return
  4776. }
  4777. } else if miConfig.InsuplcAdmdvs == "320921" {
  4778. data := make(map[string]interface{})
  4779. client := &http.Client{}
  4780. data["psn_no"] = his.PsnNo
  4781. data["mdtrt_id"] = his.Number
  4782. data["doctor"] = roles.UserName
  4783. data["department"] = department.Name
  4784. data["org_name"] = miConfig.OrgName
  4785. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4786. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4787. data["fixmedins_code"] = miConfig.Code
  4788. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4789. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4790. data["secret_key"] = miConfig.SecretKey
  4791. data["sick_code"] = sickConfig.CountryCode
  4792. data["sick_name"] = sickConfig.ClassName
  4793. data["begin_time"] = begin_time
  4794. data["dept"] = strconv.FormatInt(department.ID, 10)
  4795. data["config"] = config
  4796. fmt.Println(data)
  4797. bytesData, _ := json.Marshal(data)
  4798. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4799. resp, _ := client.Do(req)
  4800. defer resp.Body.Close()
  4801. body, ioErr := ioutil.ReadAll(resp.Body)
  4802. if ioErr != nil {
  4803. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4805. return
  4806. }
  4807. var respJSON map[string]interface{}
  4808. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4811. return
  4812. }
  4813. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4814. userJSONBytes, _ := json.Marshal(respJSON)
  4815. fmt.Println("log")
  4816. fmt.Println(string(userJSONBytes))
  4817. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4818. utils.ErrorLog("解析失败:%v", err)
  4819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4820. return
  4821. }
  4822. } else {
  4823. var result string
  4824. var requestLog string
  4825. if miConfig.InsuplcAdmdvs == "440781" { //
  4826. 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)
  4827. } else {
  4828. if miConfig.Code == "H15049901371" {
  4829. //赤峰地区国家医保医疗类别
  4830. //职工透析:医疗类别选特殊情况门诊990502
  4831. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4832. var med_type string
  4833. if his.Insutype == "390" {
  4834. if reg_type == 14 {
  4835. med_type = "9933"
  4836. } else if reg_type == 11 {
  4837. med_type = "11"
  4838. }
  4839. } else if his.Insutype == "310" {
  4840. if reg_type == 14 {
  4841. med_type = "990502"
  4842. } else if reg_type == 11 {
  4843. med_type = "11"
  4844. }
  4845. }
  4846. 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)
  4847. } else {
  4848. 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)
  4849. }
  4850. saveLog(result, requestLog, "2203", "上传就诊信息")
  4851. var respJSON2 map[string]interface{}
  4852. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4855. return
  4856. }
  4857. userJSONBytes2, _ := json.Marshal(respJSON2)
  4858. if miConfig.Code == "H15049901371" {
  4859. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  4860. utils.ErrorLog("解析失败:%v", err)
  4861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4862. return
  4863. }
  4864. res2.InfRefmsgid = resSix10265.InfRefmsgid
  4865. res2.Output = resSix10265.Output
  4866. res2.ErrMsg = resSix10265.ErrMsg
  4867. res2.Cainfo = resSix10265.Cainfo
  4868. res2.WarnMsg = resSix10265.WarnMsg
  4869. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  4870. res2.Infcode = infocode
  4871. } else {
  4872. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4873. utils.ErrorLog("解析失败:%v", err)
  4874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4875. return
  4876. }
  4877. }
  4878. }
  4879. }
  4880. if res2.Infcode != 0 {
  4881. adminUser := c.GetAdminUserInfo()
  4882. errlog := &models.HisOrderError{
  4883. UserOrgId: adminUser.CurrentOrgId,
  4884. Ctime: time.Now().Unix(),
  4885. Mtime: time.Now().Unix(),
  4886. ErrMsg: res2.ErrMsg,
  4887. Status: 1,
  4888. PatientId: id,
  4889. RecordTime: recordDateTime,
  4890. Stage: 3,
  4891. }
  4892. service.CreateErrMsgLog(errlog)
  4893. c.ServeSuccessJSON(map[string]interface{}{
  4894. "failed_code": -10,
  4895. "msg": res2.ErrMsg,
  4896. })
  4897. return
  4898. } else {
  4899. his.Diagnosis = diagnosis_id
  4900. his.SickType = sickConfig.ID
  4901. his.PType = fmt.Sprintf("%d", reg_type)
  4902. service.UpdateHisPatientThree(&his)
  4903. data := make(map[string]interface{})
  4904. if settle_accounts_type == 1 { //日结
  4905. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4906. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4907. } else {
  4908. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4909. }
  4910. data["pre"] = prescriptions
  4911. } else { //月结
  4912. start_time_str := c.GetString("start_time")
  4913. end_time_str := c.GetString("end_time")
  4914. timeLayout := "2006-01-02"
  4915. loc, _ := time.LoadLocation("Local")
  4916. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4917. if err != nil {
  4918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4919. return
  4920. }
  4921. recordStartTime := theStartTime.Unix()
  4922. start_time = recordStartTime
  4923. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4924. if err != nil {
  4925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4926. return
  4927. }
  4928. recordEndTime := theEndTime.Unix()
  4929. end_time = recordEndTime
  4930. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4931. data["pre"] = prescriptions
  4932. }
  4933. client := &http.Client{}
  4934. data["psn_no"] = his.PsnNo
  4935. data["mdtrt_id"] = his.Number
  4936. data["chrg_bchno"] = chrg_bchno
  4937. data["org_name"] = miConfig.OrgName
  4938. data["doctor"] = roles.UserName
  4939. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4940. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4941. data["fixmedins_code"] = miConfig.Code
  4942. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4943. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4944. data["dept_code"] = "15"
  4945. } else {
  4946. data["dept_code"] = department.Number
  4947. }
  4948. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4949. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4950. data["secret_key"] = miConfig.SecretKey
  4951. data["url"] = miConfig.Url
  4952. data["ak"] = miConfig.ChannelNumber
  4953. data["new_doctor_name"] = patientPrescription.Doctor
  4954. var ids []int64
  4955. for _, item := range prescriptions {
  4956. ids = append(ids, item.ID)
  4957. }
  4958. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4959. if config.IsOpen == 1 { //对接了医保,走医保流程
  4960. var res ResultFour
  4961. var resFour10265 ResultFour10265
  4962. if miConfig.MdtrtareaAdmvs == "421300" {
  4963. bytesData, _ := json.Marshal(data)
  4964. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4965. resp, _ := client.Do(req)
  4966. defer resp.Body.Close()
  4967. body, ioErr := ioutil.ReadAll(resp.Body)
  4968. if ioErr != nil {
  4969. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4971. return
  4972. }
  4973. var respJSON map[string]interface{}
  4974. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4977. return
  4978. }
  4979. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4980. userJSONBytes, _ := json.Marshal(respJSON)
  4981. fmt.Println("log")
  4982. fmt.Println(string(userJSONBytes))
  4983. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4984. utils.ErrorLog("解析失败:%v", err)
  4985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4986. return
  4987. }
  4988. } else if miConfig.MdtrtareaAdmvs == "320921" {
  4989. bytesData, _ := json.Marshal(data)
  4990. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4991. resp, _ := client.Do(req)
  4992. defer resp.Body.Close()
  4993. body, ioErr := ioutil.ReadAll(resp.Body)
  4994. if ioErr != nil {
  4995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4997. return
  4998. }
  4999. var respJSON map[string]interface{}
  5000. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5003. return
  5004. }
  5005. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5006. userJSONBytes, _ := json.Marshal(respJSON)
  5007. fmt.Println("log")
  5008. fmt.Println(string(userJSONBytes))
  5009. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5010. utils.ErrorLog("解析失败:%v", err)
  5011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5012. return
  5013. }
  5014. } else {
  5015. if miConfig.Code == "H15049901371" {
  5016. 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)
  5017. var dat map[string]interface{}
  5018. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5019. fmt.Println(dat)
  5020. } else {
  5021. fmt.Println(err)
  5022. }
  5023. saveLog(result, request_log, "2204", "上传费用明细")
  5024. userJSONBytes, _ := json.Marshal(dat)
  5025. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5026. utils.ErrorLog("解析失败:%v", err)
  5027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5028. return
  5029. }
  5030. res.InfRefmsgid = resFour10265.InfRefmsgid
  5031. res.Output = resFour10265.Output
  5032. res.ErrMsg = resFour10265.ErrMsg
  5033. res.Cainfo = resFour10265.Cainfo
  5034. res.WarnMsg = resFour10265.WarnMsg
  5035. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5036. res.Infcode = infocode
  5037. } else {
  5038. 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)
  5039. var dat map[string]interface{}
  5040. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5041. fmt.Println(dat)
  5042. } else {
  5043. fmt.Println(err)
  5044. }
  5045. saveLog(result, request_log, "2204", "上传费用明细")
  5046. userJSONBytes, _ := json.Marshal(dat)
  5047. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5048. utils.ErrorLog("解析失败:%v", err)
  5049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5050. return
  5051. }
  5052. }
  5053. }
  5054. if res.Infcode == 0 {
  5055. order := &models.HisOrder{
  5056. UserOrgId: adminUser.CurrentOrgId,
  5057. HisPatientId: his.ID,
  5058. PatientId: his.PatientId,
  5059. SettleAccountsDate: recordDateTime,
  5060. Ctime: time.Now().Unix(),
  5061. Mtime: time.Now().Unix(),
  5062. Status: 1,
  5063. Number: chrg_bchno,
  5064. Infcode: res.Infcode,
  5065. WarnMsg: res.WarnMsg,
  5066. Cainfo: res.Cainfo,
  5067. ErrMsg: res.ErrMsg,
  5068. RespondTime: res.RefmsgTime,
  5069. InfRefmsgid: res.InfRefmsgid,
  5070. OrderStatus: 1,
  5071. IsMedicineInsurance: 1,
  5072. SettleType: settle_accounts_type,
  5073. SettleStartTime: start_time,
  5074. SettleEndTime: end_time,
  5075. Creator: roles.AdminUserId,
  5076. Modify: roles.AdminUserId,
  5077. PType: 2,
  5078. Diagnosis: diagnosis_id,
  5079. }
  5080. err = service.CreateOrder(order)
  5081. if err != nil {
  5082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5083. return
  5084. }
  5085. for _, item := range res.Output.Result {
  5086. temp := strings.Split(item.FeedetlSn, "-")
  5087. var advice_id int64 = 0
  5088. var project_id int64 = 0
  5089. var types int64 = 0
  5090. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5091. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5092. if temp[1] == "1" {
  5093. advice_id = id
  5094. project_id = 0
  5095. } else if temp[1] == "2" {
  5096. advice_id = 0
  5097. project_id = id
  5098. }
  5099. info := &models.HisOrderInfo{
  5100. OrderNumber: order.Number,
  5101. FeedetlSn: item.FeedetlSn,
  5102. UploadDate: time.Now().Unix(),
  5103. AdviceId: advice_id,
  5104. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5105. Cnt: item.Cnt,
  5106. Pric: float64(item.Pric),
  5107. PatientId: his.PatientId,
  5108. PricUplmtAmt: item.PricUplmtAmt,
  5109. SelfpayProp: item.SelfpayProp,
  5110. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5111. OverlmtAmt: item.OverlmtAmt,
  5112. PreselfpayAmt: item.PreselfpayAmt,
  5113. BasMednFlag: item.BasMednFlag,
  5114. MedChrgitmType: item.MedChrgitmType,
  5115. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5116. Status: 1,
  5117. Memo: item.Memo,
  5118. Mtime: time.Now().Unix(),
  5119. InscpScpAmt: item.InscpScpAmt,
  5120. DrtReimFlag: item.DrtReimFlag,
  5121. Ctime: time.Now().Unix(),
  5122. ListSpItemFlag: item.ListSpItemFlag,
  5123. ChldMedcFlag: item.ChldMedcFlag,
  5124. LmtUsedFlag: item.LmtUsedFlag,
  5125. ChrgitmLv: item.ChrgitmLv,
  5126. UserOrgId: adminUser.CurrentOrgId,
  5127. HisPatientId: his.ID,
  5128. OrderId: order.ID,
  5129. ProjectId: project_id,
  5130. Type: types,
  5131. }
  5132. service.CreateOrderInfo(info)
  5133. }
  5134. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5135. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5136. var total float64
  5137. for _, item := range prescriptions {
  5138. if item.Type == 1 { //药品
  5139. for _, subItem := range item.HisDoctorAdviceInfo {
  5140. total = total + (subItem.Price * subItem.PrescribingNumber)
  5141. }
  5142. }
  5143. if item.Type == 2 { //项目
  5144. for _, subItem := range item.HisPrescriptionProject {
  5145. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5146. total = total + (subItem.Price * cnt)
  5147. }
  5148. }
  5149. }
  5150. for _, item := range prescriptions {
  5151. for _, subItem := range item.HisAdditionalCharge {
  5152. total = total + (subItem.Price * float64(subItem.Count))
  5153. }
  5154. }
  5155. allTotal := fmt.Sprintf("%.4f", total)
  5156. if res.Infcode == 0 {
  5157. var rf []*ResultFive
  5158. json.Unmarshal([]byte(his.Iinfo), &rf)
  5159. chrg_bchno := chrg_bchno
  5160. cert_no := his.Certno
  5161. var insutypes []string
  5162. var insutype string
  5163. var is390 int = 0
  5164. var is310 int = 0
  5165. for _, item := range rf {
  5166. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5167. insutypes = append(insutypes, item.Insutype)
  5168. }
  5169. }
  5170. if len(insutypes) == 1 {
  5171. insutype = insutypes[0]
  5172. } else {
  5173. for _, i := range insutypes {
  5174. if i == "390" {
  5175. is390 = 1
  5176. }
  5177. if i == "310" {
  5178. is310 = 1
  5179. }
  5180. }
  5181. }
  5182. if is390 == 1 {
  5183. insutype = "390"
  5184. }
  5185. if is310 == 1 {
  5186. insutype = "310"
  5187. }
  5188. if len(insutypes) == 0 {
  5189. insutype = "310"
  5190. }
  5191. if len(insutypes) == 2 {
  5192. insutype = strconv.FormatInt(his.SocialType, 64)
  5193. }
  5194. //insutype = "390"
  5195. if his.IdCardType == 1 {
  5196. cert_no = his.MedicalInsuranceNumber
  5197. } else {
  5198. cert_no = his.Certno
  5199. }
  5200. var res ResultSeven
  5201. var resSeven10265 ResultSeven10265
  5202. if miConfig.MdtrtareaAdmvs == "421300" {
  5203. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5204. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5205. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5206. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5207. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5208. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5209. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  5210. resp, requestErr := http.Get(api)
  5211. if requestErr != nil {
  5212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5213. return
  5214. }
  5215. body, ioErr := ioutil.ReadAll(resp.Body)
  5216. if ioErr != nil {
  5217. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5219. return
  5220. }
  5221. var respJSON map[string]interface{}
  5222. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5223. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5225. return
  5226. }
  5227. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5228. result, _ := json.Marshal(respJSON)
  5229. fmt.Println("log")
  5230. fmt.Println(string(result))
  5231. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5232. utils.ErrorLog("解析失败:%v", err)
  5233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5234. return
  5235. }
  5236. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5237. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5238. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5239. api := "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5240. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5241. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5242. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5243. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5244. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5245. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber
  5246. resp, requestErr := http.Get(api)
  5247. if requestErr != nil {
  5248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5249. return
  5250. }
  5251. body, ioErr := ioutil.ReadAll(resp.Body)
  5252. if ioErr != nil {
  5253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5255. return
  5256. }
  5257. var respJSON map[string]interface{}
  5258. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5261. return
  5262. }
  5263. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5264. result, _ := json.Marshal(respJSON)
  5265. fmt.Println("log")
  5266. fmt.Println(string(result))
  5267. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5268. utils.ErrorLog("解析失败:%v", err)
  5269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5270. return
  5271. }
  5272. } else {
  5273. var result string
  5274. var request_log string
  5275. if miConfig.Code == "H15049901371" {
  5276. //赤峰地区国家医保医疗类别
  5277. //职工透析:医疗类别选特殊情况门诊990502
  5278. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5279. var med_type string
  5280. if his.Insutype == "390" {
  5281. if reg_type == 14 {
  5282. med_type = "9933"
  5283. } else if reg_type == 11 {
  5284. med_type = "11"
  5285. }
  5286. } else if his.Insutype == "310" {
  5287. if reg_type == 14 {
  5288. med_type = "990502"
  5289. } else if reg_type == 11 {
  5290. med_type = "11"
  5291. }
  5292. }
  5293. 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)
  5294. } else {
  5295. 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)
  5296. }
  5297. var dat map[string]interface{}
  5298. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5299. fmt.Println(dat)
  5300. } else {
  5301. fmt.Println(err)
  5302. }
  5303. saveLog(result, request_log, "2206", "预结算")
  5304. //userJSONBytes, _ := json.Marshal(dat)
  5305. //
  5306. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5307. // utils.ErrorLog("解析失败:%v", err)
  5308. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5309. // return
  5310. //}
  5311. userJSONBytes, _ := json.Marshal(dat)
  5312. if miConfig.Code == "H15049901371" {
  5313. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5314. utils.ErrorLog("解析失败:%v", err)
  5315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5316. return
  5317. }
  5318. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5319. res.Output = resSeven10265.Output
  5320. res.ErrMsg = resSeven10265.ErrMsg
  5321. res.Cainfo = resSeven10265.Cainfo
  5322. res.WarnMsg = resSeven10265.WarnMsg
  5323. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5324. res.Infcode = infocode
  5325. } else {
  5326. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5327. utils.ErrorLog("解析失败:%v", err)
  5328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5329. return
  5330. }
  5331. }
  5332. }
  5333. if res.Infcode != 0 {
  5334. errlog := &models.HisOrderError{
  5335. UserOrgId: adminUser.CurrentOrgId,
  5336. Ctime: time.Now().Unix(),
  5337. Mtime: time.Now().Unix(),
  5338. Number: chrg_bchno,
  5339. ErrMsg: res.ErrMsg,
  5340. Status: 1,
  5341. PatientId: id,
  5342. RecordTime: recordDateTime,
  5343. Stage: 20,
  5344. }
  5345. service.CreateErrMsgLog(errlog)
  5346. c.ServeSuccessJSON(map[string]interface{}{
  5347. "failed_code": -10,
  5348. "msg": res.ErrMsg,
  5349. })
  5350. return
  5351. } else {
  5352. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5353. order.OrderStatus = 1
  5354. order.IsPre = 1
  5355. order.Status = 1
  5356. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5357. order.SetlId = res.Output.Setlinfo.SetlID
  5358. order.PsnNo = res.Output.Setlinfo.PsnNo
  5359. order.PsnName = res.Output.Setlinfo.PsnName
  5360. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5361. order.Certno = res.Output.Setlinfo.Certno
  5362. order.Gend = res.Output.Setlinfo.Gend
  5363. order.Naty = res.Output.Setlinfo.Naty
  5364. order.Age = res.Output.Setlinfo.Age
  5365. order.Insutype = res.Output.Setlinfo.Insutype
  5366. order.PsnType = res.Output.Setlinfo.PsnType
  5367. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5368. order.SetlTime = res.Output.Setlinfo.SetlTime
  5369. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5370. if res.Output.Setlinfo.MedType == "140101" {
  5371. order.MedType = "14"
  5372. } else {
  5373. order.MedType = res.Output.Setlinfo.MedType
  5374. }
  5375. if reg_type == 1112 {
  5376. order.MedType = "1112"
  5377. }
  5378. if reg_type == 1111 {
  5379. order.MedType = "1111"
  5380. }
  5381. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5382. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5383. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5384. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5385. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5386. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5387. order.HifpPay = res.Output.Setlinfo.HifpPay
  5388. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5389. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5390. order.HifesPay = res.Output.Setlinfo.HifesPay
  5391. order.HifobPay = res.Output.Setlinfo.HifobPay
  5392. order.MafPay = res.Output.Setlinfo.MafPay
  5393. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5394. order.OthPay = res.Output.Setlinfo.OthPay
  5395. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5396. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5397. order.AcctPay = res.Output.Setlinfo.AcctPay
  5398. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5399. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5400. order.Balc = res.Output.Setlinfo.Balc
  5401. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5402. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5403. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5404. order.ClrWay = res.Output.Setlinfo.ClrWay
  5405. order.Creator = order.Creator
  5406. order.Modify = roles.AdminUserId
  5407. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5408. detailStr := string(setlDetail)
  5409. order.SetlDetail = detailStr
  5410. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5411. err = service.UpDateOrder(order)
  5412. if err == nil {
  5413. c.ServeSuccessJSON(map[string]interface{}{
  5414. "msg": "预结算成功",
  5415. })
  5416. } else {
  5417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5418. return
  5419. }
  5420. }
  5421. } else {
  5422. adminUser := c.GetAdminUserInfo()
  5423. errlog := &models.HisOrderError{
  5424. UserOrgId: adminUser.CurrentOrgId,
  5425. Ctime: time.Now().Unix(),
  5426. Mtime: time.Now().Unix(),
  5427. ErrMsg: res.ErrMsg,
  5428. Status: 1,
  5429. PatientId: id,
  5430. RecordTime: recordDateTime,
  5431. Stage: 4,
  5432. }
  5433. service.CreateErrMsgLog(errlog)
  5434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5435. return
  5436. }
  5437. } else {
  5438. adminUser := c.GetAdminUserInfo()
  5439. errlog := &models.HisOrderError{
  5440. UserOrgId: adminUser.CurrentOrgId,
  5441. Ctime: time.Now().Unix(),
  5442. Mtime: time.Now().Unix(),
  5443. ErrMsg: res.ErrMsg,
  5444. Status: 1,
  5445. PatientId: id,
  5446. RecordTime: recordDateTime,
  5447. Stage: 4,
  5448. }
  5449. service.CreateErrMsgLog(errlog)
  5450. c.ServeSuccessJSON(map[string]interface{}{
  5451. "failed_code": -10,
  5452. "msg": res.ErrMsg,
  5453. })
  5454. return
  5455. }
  5456. }
  5457. }
  5458. }
  5459. //func (c *HisApiController) GetSettleInfo() {
  5460. // id, _ := c.GetInt64("id")
  5461. // order_id, _ := c.GetInt64("order_id")
  5462. //
  5463. // record_time := c.GetString("record_time")
  5464. // pay_way, _ := c.GetInt64("pay_way")
  5465. // pay_price, _ := c.GetFloat("pay_price")
  5466. // pay_card_no := c.GetString("pay_card_no")
  5467. // discount_price, _ := c.GetFloat("discount_price")
  5468. // preferential_price, _ := c.GetFloat("preferential_price")
  5469. // reality_price, _ := c.GetFloat("reality_price")
  5470. // found_price, _ := c.GetFloat("found_price")
  5471. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5472. // private_price, _ := c.GetFloat("private_price")
  5473. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5474. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5475. //
  5476. // timeLayout := "2006-01-02"
  5477. // loc, _ := time.LoadLocation("Local")
  5478. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5479. // if err != nil {
  5480. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5481. // return
  5482. // }
  5483. // recordDateTime := theTime.Unix()
  5484. // adminUser := c.GetAdminUserInfo()
  5485. //
  5486. // var prescriptions []*models.HisPrescription
  5487. //
  5488. // data := make(map[string]interface{})
  5489. // if settle_accounts_type == 1 { //日结
  5490. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5491. // data["pre"] = prescriptions
  5492. //
  5493. // } else { //月结
  5494. // start_time_str := c.GetString("start_time")
  5495. // end_time_str := c.GetString("end_time")
  5496. // timeLayout := "2006-01-02"
  5497. // loc, _ := time.LoadLocation("Local")
  5498. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5499. // if err != nil {
  5500. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5501. // return
  5502. // }
  5503. // recordStartTime := theStartTime.Unix()
  5504. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5505. // if err != nil {
  5506. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5507. // return
  5508. // }
  5509. // recordEndTime := theEndTime.Unix()
  5510. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5511. // data["pre"] = prescriptions
  5512. //
  5513. // }
  5514. //
  5515. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5516. //
  5517. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5518. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5519. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5520. // strconv.FormatInt(his.PatientId, 10)
  5521. //
  5522. // order_src, _ := service.GetHisOrderByID(order_id)
  5523. //
  5524. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5525. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5526. //
  5527. // var total float64
  5528. // for _, item := range prescriptions {
  5529. // if item.Type == 1 { //药品
  5530. // for _, subItem := range item.HisDoctorAdviceInfo {
  5531. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5532. // }
  5533. // }
  5534. // if item.Type == 2 { //项目
  5535. // for _, subItem := range item.HisPrescriptionProject {
  5536. // total = total + (subItem.Price * float64(subItem.Count))
  5537. // }
  5538. // }
  5539. // }
  5540. //
  5541. // for _, item := range prescriptions {
  5542. // for _, subItem := range item.HisAdditionalCharge {
  5543. // total = total + (subItem.Price * float64(subItem.Count))
  5544. // }
  5545. // }
  5546. //
  5547. // allTotal := fmt.Sprintf("%.2f", total)
  5548. // var rf []*ResultFive
  5549. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5550. // psn_no := order_src.PsnNo
  5551. // mdtrt_id := order_src.MdtrtId
  5552. // chrg_bchno := order_src.Number
  5553. // cert_no := order_src.Certno
  5554. // insutype := rf[0].Insutype
  5555. //
  5556. // if his.IdCardType == 1 {
  5557. // cert_no = his.MedicalInsuranceNumber
  5558. // } else {
  5559. // cert_no = his.Certno
  5560. // }
  5561. //
  5562. // 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)
  5563. // var dat map[string]interface{}
  5564. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5565. // fmt.Println(dat)
  5566. // } else {
  5567. // fmt.Println(err)
  5568. // }
  5569. //
  5570. // userJSONBytes, _ := json.Marshal(dat)
  5571. //
  5572. //
  5573. //
  5574. // var res ResultSeven
  5575. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5576. // utils.ErrorLog("解析失败:%v", err)
  5577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5578. // return
  5579. // }
  5580. // if res.Infcode == -1 {
  5581. // errlog := &models.HisOrderError{
  5582. // UserOrgId: adminUser.CurrentOrgId,
  5583. // Ctime: time.Now().Unix(),
  5584. // Mtime: time.Now().Unix(),
  5585. // Number: chrg_bchno,
  5586. // ErrMsg: res.ErrMsg,
  5587. // Status: 1,
  5588. // PatientId: id,
  5589. // RecordTime: recordDateTime,
  5590. // Stage: 6,
  5591. // }
  5592. // service.CreateErrMsgLog(errlog)
  5593. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5594. // return
  5595. // } else {
  5596. // order_src.OrderStatus = 2
  5597. // order_src.PayWay = pay_way
  5598. // order_src.PayPrice = pay_price
  5599. // order_src.PayCardNo = pay_card_no
  5600. // order_src.DiscountPrice = discount_price
  5601. // order_src.PreferentialPrice = preferential_price
  5602. // order_src.RealityPrice = reality_price
  5603. // order_src.FoundPrice = found_price
  5604. // order_src.MedicalInsurancePrice = medical_insurance_price
  5605. // order_src.PrivatePrice = private_price
  5606. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  5607. // order_src.SetlId = res.Output.Setlinfo.SetlID
  5608. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  5609. // order_src.PsnName = res.Output.Setlinfo.PsnName
  5610. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  5611. // order_src.Certno = res.Output.Setlinfo.Certno
  5612. // order_src.Gend = res.Output.Setlinfo.Gend
  5613. // order_src.Naty = res.Output.Setlinfo.Naty
  5614. // order_src.Age = res.Output.Setlinfo.Age
  5615. // order_src.Insutype = res.Output.Setlinfo.Insutype
  5616. // order_src.PsnType = res.Output.Setlinfo.PsnType
  5617. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5618. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  5619. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5620. // order_src.MedType = res.Output.Setlinfo.MedType
  5621. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5622. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5623. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5624. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5625. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5626. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5627. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  5628. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  5629. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5630. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  5631. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  5632. // order_src.MafPay = res.Output.Setlinfo.MafPay
  5633. // order_src.OthPay = res.Output.Setlinfo.OthPay
  5634. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5635. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5636. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  5637. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5638. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5639. // order_src.Balc = res.Output.Setlinfo.Balc
  5640. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5641. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5642. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  5643. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  5644. // order_src.Creator = order_src.Creator
  5645. // order_src.Modify = roles.ID
  5646. // order_src.RequestLog = src_resquest
  5647. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5648. // detailStr := string(setlDetail)
  5649. // order_src.SetlDetail = detailStr
  5650. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5651. // err = service.UpDateOrder(order_src)
  5652. //
  5653. // if err == nil {
  5654. // c.ServeSuccessJSON(map[string]interface{}{
  5655. // "msg": "结算成功",
  5656. // })
  5657. // } else {
  5658. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5659. // return
  5660. // }
  5661. // }
  5662. // }
  5663. //}
  5664. //退款
  5665. func (c *HisApiController) Refund() {
  5666. order_id, _ := c.GetInt64("order_id")
  5667. admin_user_id, _ := c.GetInt64("admin_user_id")
  5668. adminUser := c.GetAdminUserInfo()
  5669. var order models.HisOrder
  5670. order, _ = service.GetHisOrderByID(order_id)
  5671. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5672. if order.ID == 0 {
  5673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5674. return
  5675. }
  5676. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5677. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5678. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5679. if config.IsOpen == 1 { //对接了医保,走医保流程
  5680. var res ResultSixteen
  5681. var resSixteen10265 ResultSixteen10265
  5682. var src_resquest string
  5683. var result string
  5684. if miConfig.MdtrtareaAdmvs == "421300" {
  5685. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  5686. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5687. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5688. resp3, requestErr3 := http.Get(api3)
  5689. if requestErr3 != nil {
  5690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5691. return
  5692. }
  5693. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5694. if ioErr3 != nil {
  5695. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5697. return
  5698. }
  5699. var respJSON3 map[string]interface{}
  5700. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5703. return
  5704. }
  5705. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5706. userJSONBytes3, _ := json.Marshal(respJSON3)
  5707. fmt.Println("log")
  5708. fmt.Println(string(userJSONBytes3))
  5709. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  5710. utils.ErrorLog("解析失败:%v", err)
  5711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5712. return
  5713. }
  5714. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5715. api3 := "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  5716. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5717. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  5718. resp3, requestErr3 := http.Get(api3)
  5719. if requestErr3 != nil {
  5720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5721. return
  5722. }
  5723. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5724. if ioErr3 != nil {
  5725. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5727. return
  5728. }
  5729. var respJSON3 map[string]interface{}
  5730. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5733. return
  5734. }
  5735. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5736. userJSONBytes3, _ := json.Marshal(respJSON3)
  5737. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  5738. utils.ErrorLog("解析失败:%v", err)
  5739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5740. return
  5741. }
  5742. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  5743. res.Output = resSixteen10265.Output
  5744. res.ErrMsg = resSixteen10265.ErrMsg
  5745. res.Cainfo = resSixteen10265.Cainfo
  5746. res.WarnMsg = resSixteen10265.WarnMsg
  5747. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  5748. res.Infcode = infocode
  5749. } else {
  5750. if miConfig.Code == "H15049901371" {
  5751. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5752. var dat map[string]interface{}
  5753. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5754. fmt.Println(dat)
  5755. } else {
  5756. fmt.Println(err)
  5757. }
  5758. saveLog(result, src_resquest, "2208", "退费")
  5759. userJSONBytes, _ := json.Marshal(dat)
  5760. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  5761. utils.ErrorLog("解析失败:%v", err)
  5762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5763. return
  5764. }
  5765. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  5766. res.Output = resSixteen10265.Output
  5767. res.ErrMsg = resSixteen10265.ErrMsg
  5768. res.Cainfo = resSixteen10265.Cainfo
  5769. res.WarnMsg = resSixteen10265.WarnMsg
  5770. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  5771. res.Infcode = infocode
  5772. } else {
  5773. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5774. var dat map[string]interface{}
  5775. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5776. fmt.Println(dat)
  5777. } else {
  5778. fmt.Println(err)
  5779. }
  5780. saveLog(result, src_resquest, "2208", "退费")
  5781. userJSONBytes, _ := json.Marshal(dat)
  5782. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5783. utils.ErrorLog("解析失败:%v", err)
  5784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5785. return
  5786. }
  5787. }
  5788. }
  5789. if res.Infcode == 0 {
  5790. var res2 ResultSix
  5791. var resSix10265 ResultSix10265
  5792. if miConfig.MdtrtareaAdmvs == "421300" {
  5793. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  5794. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5795. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5796. resp3, requestErr3 := http.Get(api3)
  5797. if requestErr3 != nil {
  5798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5799. return
  5800. }
  5801. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5802. if ioErr3 != nil {
  5803. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5805. return
  5806. }
  5807. var respJSON3 map[string]interface{}
  5808. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5811. return
  5812. }
  5813. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5814. userJSONBytes3, _ := json.Marshal(respJSON3)
  5815. fmt.Println("log")
  5816. fmt.Println(string(userJSONBytes3))
  5817. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5818. utils.ErrorLog("解析失败:%v", err)
  5819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5820. return
  5821. }
  5822. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5823. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  5824. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5825. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  5826. resp3, requestErr3 := http.Get(api3)
  5827. if requestErr3 != nil {
  5828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5829. return
  5830. }
  5831. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5832. if ioErr3 != nil {
  5833. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5835. return
  5836. }
  5837. var respJSON3 map[string]interface{}
  5838. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5839. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5841. return
  5842. }
  5843. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5844. userJSONBytes3, _ := json.Marshal(respJSON3)
  5845. fmt.Println("log")
  5846. fmt.Println(string(userJSONBytes3))
  5847. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  5848. utils.ErrorLog("解析失败:%v", err)
  5849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5850. return
  5851. }
  5852. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5853. res2.Output = resSix10265.Output
  5854. res2.ErrMsg = resSix10265.ErrMsg
  5855. res2.Cainfo = resSix10265.Cainfo
  5856. res2.WarnMsg = resSix10265.WarnMsg
  5857. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5858. res2.Infcode = infocode
  5859. } else {
  5860. if miConfig.Code == "H15049901371" {
  5861. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  5862. var dat map[string]interface{}
  5863. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5864. fmt.Println(dat)
  5865. } else {
  5866. fmt.Println(err)
  5867. }
  5868. saveLog(result2, src_request, "2205", "撤销明细")
  5869. userJSONBytes, _ := json.Marshal(dat)
  5870. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5871. utils.ErrorLog("解析失败:%v", err)
  5872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5873. return
  5874. }
  5875. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5876. res2.Output = resSix10265.Output
  5877. res2.ErrMsg = resSix10265.ErrMsg
  5878. res2.Cainfo = resSix10265.Cainfo
  5879. res2.WarnMsg = resSix10265.WarnMsg
  5880. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5881. res2.Infcode = infocode
  5882. } else {
  5883. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  5884. var dat map[string]interface{}
  5885. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5886. fmt.Println(dat)
  5887. } else {
  5888. fmt.Println(err)
  5889. }
  5890. saveLog(result2, src_request, "2205", "撤销明细")
  5891. userJSONBytes, _ := json.Marshal(dat)
  5892. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5893. utils.ErrorLog("解析失败:%v", err)
  5894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5895. return
  5896. }
  5897. }
  5898. }
  5899. if res2.Infcode == 0 {
  5900. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  5901. if err == nil {
  5902. c.ServeSuccessJSON(map[string]interface{}{
  5903. "msg": "退费成功",
  5904. })
  5905. } else {
  5906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5907. return
  5908. }
  5909. } else {
  5910. c.ServeSuccessJSON(map[string]interface{}{
  5911. "code": -10,
  5912. "msg": res2.ErrMsg,
  5913. })
  5914. }
  5915. } else {
  5916. c.ServeSuccessJSON(map[string]interface{}{
  5917. "code": -10,
  5918. "msg": res.ErrMsg,
  5919. })
  5920. }
  5921. }
  5922. }
  5923. func (c *HisApiController) RefundNumber() {
  5924. record_time := c.GetString("record_time")
  5925. //patient_id, _ := c.GetInt64("patient_id")
  5926. admin_user_id, _ := c.GetInt64("admin_user_id")
  5927. his_patient_id, _ := c.GetInt64("id")
  5928. timeLayout := "2006-01-02"
  5929. loc, _ := time.LoadLocation("Local")
  5930. adminUser := c.GetAdminUserInfo()
  5931. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5932. fmt.Println(err)
  5933. if err != nil {
  5934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5935. return
  5936. }
  5937. recordDateTime := theTime.Unix()
  5938. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5939. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  5940. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5941. //order, _ := service.GetHisOrderByID(order_id)
  5942. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5943. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5944. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5945. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  5946. if count > 0 {
  5947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  5948. return
  5949. }
  5950. if config.IsOpen == 1 { //对接了医保,走医保流程
  5951. var res2 ResultSix
  5952. var resSix10265 ResultSix10265
  5953. if miConfig.MdtrtareaAdmvs == "421300" {
  5954. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  5955. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5956. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5957. resp3, requestErr3 := http.Get(api3)
  5958. if requestErr3 != nil {
  5959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5960. return
  5961. }
  5962. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5963. if ioErr3 != nil {
  5964. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5966. return
  5967. }
  5968. var respJSON3 map[string]interface{}
  5969. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5972. return
  5973. }
  5974. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5975. userJSONBytes3, _ := json.Marshal(respJSON3)
  5976. fmt.Println("log")
  5977. fmt.Println(string(userJSONBytes3))
  5978. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5979. utils.ErrorLog("解析失败:%v", err)
  5980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5981. return
  5982. }
  5983. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5984. api3 := "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  5985. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5986. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  5987. resp3, requestErr3 := http.Get(api3)
  5988. if requestErr3 != nil {
  5989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5990. return
  5991. }
  5992. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5993. if ioErr3 != nil {
  5994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5996. return
  5997. }
  5998. var respJSON3 map[string]interface{}
  5999. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6002. return
  6003. }
  6004. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6005. userJSONBytes3, _ := json.Marshal(respJSON3)
  6006. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6007. utils.ErrorLog("解析失败:%v", err)
  6008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6009. return
  6010. }
  6011. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6012. res2.Output = resSix10265.Output
  6013. res2.ErrMsg = resSix10265.ErrMsg
  6014. res2.Cainfo = resSix10265.Cainfo
  6015. res2.WarnMsg = resSix10265.WarnMsg
  6016. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6017. res2.Infcode = infocode
  6018. } else {
  6019. var api3 string
  6020. if miConfig.Code == "H15049901371" {
  6021. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6022. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6023. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6024. } else {
  6025. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6026. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6027. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6028. }
  6029. resp3, requestErr3 := http.Get(api3)
  6030. if requestErr3 != nil {
  6031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6032. return
  6033. }
  6034. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6035. if ioErr3 != nil {
  6036. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6038. return
  6039. }
  6040. var respJSON3 map[string]interface{}
  6041. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6042. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6044. return
  6045. }
  6046. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6047. userJSONBytes3, _ := json.Marshal(respJSON3)
  6048. if miConfig.Code == "H15049901371" {
  6049. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6050. utils.ErrorLog("解析失败:%v", err)
  6051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6052. return
  6053. }
  6054. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6055. res2.Output = resSix10265.Output
  6056. res2.ErrMsg = resSix10265.ErrMsg
  6057. res2.Cainfo = resSix10265.Cainfo
  6058. res2.WarnMsg = resSix10265.WarnMsg
  6059. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6060. res2.Infcode = infocode
  6061. } else {
  6062. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6063. utils.ErrorLog("解析失败:%v", err)
  6064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6065. return
  6066. }
  6067. }
  6068. }
  6069. if res2.Infcode == 0 {
  6070. if err == nil {
  6071. c.ServeSuccessJSON(map[string]interface{}{
  6072. "msg": "退号成功",
  6073. })
  6074. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  6075. } else {
  6076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6077. return
  6078. }
  6079. } else {
  6080. c.ServeSuccessJSON(map[string]interface{}{
  6081. "code": -10,
  6082. "msg": res2.ErrMsg,
  6083. })
  6084. }
  6085. } else {
  6086. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  6087. //if err == nil {
  6088. // c.ServeSuccessJSON(map[string]interface{}{
  6089. // "msg": "退费成功",
  6090. // })
  6091. //} else {
  6092. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6093. // return
  6094. //}
  6095. }
  6096. }
  6097. func (c *HisApiController) RefundDetail() {
  6098. order_id, _ := c.GetInt64("order_id")
  6099. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6100. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6101. number := c.GetString("number")
  6102. record_time := c.GetString("record_time")
  6103. patient_id, _ := c.GetInt64("patient_id")
  6104. timeLayout := "2006-01-02"
  6105. loc, _ := time.LoadLocation("Local")
  6106. adminUser := c.GetAdminUserInfo()
  6107. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6108. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6109. fmt.Println(err)
  6110. if err != nil {
  6111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6112. return
  6113. }
  6114. recordDateTime := theTime.Unix()
  6115. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6116. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6117. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6118. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6119. var order models.HisOrder
  6120. order, _ = service.GetHisOrderByID(order_id)
  6121. if order.ID == 0 {
  6122. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  6123. }
  6124. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6125. if config.IsOpen == 1 { //对接了医保,走医保流程
  6126. var res2 ResultSix
  6127. if miConfig.MdtrtareaAdmvs == "421300" {
  6128. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6129. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6130. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6131. resp3, requestErr3 := http.Get(api3)
  6132. if requestErr3 != nil {
  6133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6134. return
  6135. }
  6136. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6137. if ioErr3 != nil {
  6138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6140. return
  6141. }
  6142. var respJSON3 map[string]interface{}
  6143. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6146. return
  6147. }
  6148. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6149. userJSONBytes3, _ := json.Marshal(respJSON3)
  6150. fmt.Println("log")
  6151. fmt.Println(string(userJSONBytes3))
  6152. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6153. utils.ErrorLog("解析失败:%v", err)
  6154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6155. return
  6156. }
  6157. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6158. if err == nil {
  6159. c.ServeSuccessJSON(map[string]interface{}{
  6160. "msg": "撤销明细成功",
  6161. })
  6162. return
  6163. } else {
  6164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6165. return
  6166. }
  6167. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6168. var resSix10265 ResultSix10265
  6169. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6170. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6171. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  6172. resp3, requestErr3 := http.Get(api3)
  6173. if requestErr3 != nil {
  6174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6175. return
  6176. }
  6177. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6178. if ioErr3 != nil {
  6179. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6181. return
  6182. }
  6183. var respJSON3 map[string]interface{}
  6184. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6185. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6187. return
  6188. }
  6189. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6190. userJSONBytes3, _ := json.Marshal(respJSON3)
  6191. fmt.Println("log")
  6192. fmt.Println(string(userJSONBytes3))
  6193. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6194. utils.ErrorLog("解析失败:%v", err)
  6195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6196. return
  6197. }
  6198. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6199. res2.Output = resSix10265.Output
  6200. res2.ErrMsg = resSix10265.ErrMsg
  6201. res2.Cainfo = resSix10265.Cainfo
  6202. res2.WarnMsg = resSix10265.WarnMsg
  6203. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6204. res2.Infcode = infocode
  6205. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6206. if err == nil {
  6207. c.ServeSuccessJSON(map[string]interface{}{
  6208. "msg": "撤销明细成功",
  6209. })
  6210. return
  6211. } else {
  6212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6213. return
  6214. }
  6215. } else {
  6216. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  6217. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6218. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6219. resp2, requestErr2 := http.Get(api2)
  6220. if requestErr2 != nil {
  6221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6222. return
  6223. }
  6224. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6225. if ioErr2 != nil {
  6226. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6228. return
  6229. }
  6230. var respJSON2 map[string]interface{}
  6231. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6232. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6234. return
  6235. }
  6236. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6237. if err == nil {
  6238. c.ServeSuccessJSON(map[string]interface{}{
  6239. "msg": "撤销明细成功",
  6240. })
  6241. return
  6242. } else {
  6243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6244. return
  6245. }
  6246. }
  6247. } else {
  6248. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6249. if err == nil {
  6250. c.ServeSuccessJSON(map[string]interface{}{
  6251. "msg": "退费成功",
  6252. })
  6253. } else {
  6254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6255. return
  6256. }
  6257. }
  6258. }
  6259. //对账
  6260. func (c *HisApiController) GetCheckAccount() {
  6261. start_time := c.GetString("start_time")
  6262. end_time := c.GetString("end_time")
  6263. insutype := c.GetString("insutype")
  6264. clr_type := c.GetString("clr_type")
  6265. clr_org := c.GetString("clr_optins")
  6266. admin_user_id, _ := c.GetInt64("admin_user_id")
  6267. adminUser := c.GetAdminUserInfo()
  6268. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6269. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6270. if len(clr_org) == 0 {
  6271. clr_org = miConfig.MdtrtareaAdmvs
  6272. }
  6273. timeLayout := "2006-01-02"
  6274. loc, _ := time.LoadLocation("Local")
  6275. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6276. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6277. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  6278. //orders_two, _ := service.GetOrderByTimeThree(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  6279. fixmedins_setl_cnt := int64(len(orders))
  6280. //
  6281. ////撤销的算2条数据为一笔
  6282. //for _, item := range orders_two {
  6283. // if item.OrderStatus == 3 {
  6284. // fixmedins_setl_cnt = fixmedins_setl_cnt + 1
  6285. // }
  6286. //}
  6287. var medfee_sumamt float64
  6288. var acct_pay float64
  6289. var fund_pay_sumamt float64
  6290. for _, item := range orders {
  6291. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6292. acct_pay = acct_pay + item.AcctPay
  6293. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6294. }
  6295. var user_name string
  6296. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6297. if role.ID == 0 {
  6298. user_name = "xxx"
  6299. } else {
  6300. user_name = role.UserName
  6301. }
  6302. if config.IsOpen == 1 {
  6303. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6304. "insutype=" + insutype +
  6305. "&clr_type=" + clr_type +
  6306. "&setl_optins=" + clr_org +
  6307. "&stmt_begndate=" + start_time +
  6308. "&stm_enddate=" + end_time +
  6309. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6310. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6311. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  6312. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6313. "&fixmedins_code=" + miConfig.Code +
  6314. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6315. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6316. "&secret_key=" + miConfig.SecretKey +
  6317. "&org_name=" + miConfig.OrgName +
  6318. "&doctor=" + user_name
  6319. fmt.Println(api)
  6320. resp, requestErr := http.Get(api)
  6321. if requestErr != nil {
  6322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6323. return
  6324. }
  6325. body, ioErr := ioutil.ReadAll(resp.Body)
  6326. fmt.Println(body)
  6327. if ioErr != nil {
  6328. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6330. return
  6331. }
  6332. var respJSON map[string]interface{}
  6333. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6336. return
  6337. }
  6338. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6339. userJSONBytes, _ := json.Marshal(respJSON)
  6340. var res ResultEight
  6341. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6342. utils.ErrorLog("解析失败:%v", err)
  6343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6344. return
  6345. }
  6346. if res.Infcode == 0 {
  6347. if res.Output.Stmtinfo.StmtRslt == "0" {
  6348. micc := &models.MedicalInsuranceCostCompare{
  6349. StartTime: startime.Unix(),
  6350. EndTime: endtime.Unix(),
  6351. Insutype: insutype,
  6352. CheckType: 1,
  6353. Num: fixmedins_setl_cnt,
  6354. Mtime: time.Now().Unix(),
  6355. Status: 1,
  6356. UserOrgId: adminUser.CurrentOrgId,
  6357. CostTotal: medfee_sumamt,
  6358. FuncTotal: fund_pay_sumamt,
  6359. PsnPay: acct_pay,
  6360. Creator: admin_user_id,
  6361. Ctime: time.Now().Unix(),
  6362. }
  6363. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  6364. if err == nil {
  6365. c.ServeSuccessJSON(map[string]interface{}{
  6366. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  6367. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  6368. })
  6369. } else {
  6370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6371. }
  6372. } else {
  6373. c.ServeSuccessJSON(map[string]interface{}{
  6374. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  6375. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  6376. })
  6377. }
  6378. } else {
  6379. c.ServeSuccessJSON(map[string]interface{}{
  6380. "code": -10,
  6381. "msg": res.ErrMsg,
  6382. })
  6383. }
  6384. }
  6385. }
  6386. func (c *HisApiController) Check310() {
  6387. adminUser := c.GetAdminUserInfo()
  6388. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6389. var user_name string
  6390. user_name = "高慧裕"
  6391. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6392. "insutype=" + "310" +
  6393. "&clr_type=" + "11" +
  6394. "&setl_optins=" + "441202" +
  6395. "&stmt_begndate=" + "2022-02-01" +
  6396. "&stm_enddate=" + "2022-02-28" +
  6397. "&medfee_sumamt=" + "155812.88" +
  6398. "&fund_pay_sumamt=" + "151026.03" +
  6399. "&acct_pay=" + "0" +
  6400. "&fixmedins_setl_cnt=" + "73" +
  6401. "&fixmedins_code=" + miConfig.Code +
  6402. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6403. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6404. "&secret_key=" + miConfig.SecretKey +
  6405. "&org_name=" + miConfig.OrgName +
  6406. "&doctor=" + user_name
  6407. fmt.Println(api)
  6408. resp, requestErr := http.Get(api)
  6409. if requestErr != nil {
  6410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6411. return
  6412. }
  6413. body, ioErr := ioutil.ReadAll(resp.Body)
  6414. fmt.Println(body)
  6415. if ioErr != nil {
  6416. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6418. return
  6419. }
  6420. var respJSON map[string]interface{}
  6421. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6422. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6424. return
  6425. }
  6426. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6427. userJSONBytes, _ := json.Marshal(respJSON)
  6428. var res ResultEight
  6429. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6430. utils.ErrorLog("解析失败:%v", err)
  6431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6432. return
  6433. }
  6434. }
  6435. func (c *HisApiController) Check390() {
  6436. adminUser := c.GetAdminUserInfo()
  6437. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6438. var user_name string
  6439. user_name = "高慧裕"
  6440. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6441. "insutype=" + "390" +
  6442. "&clr_type=" + "11" +
  6443. "&setl_optins=" + "441202" +
  6444. "&stmt_begndate=" + "2022-02-01" +
  6445. "&stm_enddate=" + "2022-02-28" +
  6446. "&medfee_sumamt=" + "933920.08" +
  6447. "&fund_pay_sumamt=" + "904130.94" +
  6448. "&acct_pay=" + "0" +
  6449. "&fixmedins_setl_cnt=" + "396" +
  6450. "&fixmedins_code=" + miConfig.Code +
  6451. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6452. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6453. "&secret_key=" + miConfig.SecretKey +
  6454. "&org_name=" + miConfig.OrgName +
  6455. "&doctor=" + user_name
  6456. fmt.Println(api)
  6457. resp, requestErr := http.Get(api)
  6458. if requestErr != nil {
  6459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6460. return
  6461. }
  6462. body, ioErr := ioutil.ReadAll(resp.Body)
  6463. fmt.Println(body)
  6464. if ioErr != nil {
  6465. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6467. return
  6468. }
  6469. var respJSON map[string]interface{}
  6470. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6473. return
  6474. }
  6475. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6476. userJSONBytes, _ := json.Marshal(respJSON)
  6477. var res ResultEight
  6478. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6479. utils.ErrorLog("解析失败:%v", err)
  6480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6481. return
  6482. }
  6483. }
  6484. //对账明细
  6485. func (c *HisApiController) GetCheckDetailAccount() {
  6486. start_time := c.GetString("start_time")
  6487. end_time := c.GetString("end_time")
  6488. admin_user_id, _ := c.GetInt64("admin_user_id")
  6489. adminUser := c.GetAdminUserInfo()
  6490. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6491. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6492. timeLayout := "2006-01-02"
  6493. loc, _ := time.LoadLocation("Local")
  6494. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6495. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6496. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  6497. Mkdir(miConfig.OrgName)
  6498. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  6499. file_name := file + ".txt"
  6500. zip_name := file + ".zip"
  6501. zip_path := miConfig.OrgName + "/" + zip_name
  6502. file_path := miConfig.OrgName + "/" + file_name
  6503. decimal.DivisionPrecision = 2
  6504. var medfee_sumamt float64
  6505. var psn_cash_pay float64
  6506. var fund_pay_sumamt float64
  6507. fixmedins_setl_cnt := int64(len(orders))
  6508. for _, item := range orders {
  6509. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6510. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  6511. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6512. }
  6513. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  6514. defer f.Close()
  6515. if err != nil {
  6516. fmt.Println(err.Error())
  6517. } else {
  6518. for _, item := range orders {
  6519. var refd_setl_flag string
  6520. if item.OrderStatus == 2 {
  6521. refd_setl_flag = "0"
  6522. var str string
  6523. str = item.SetlId + " " +
  6524. item.MdtrtId + " " +
  6525. item.PsnNo + " " +
  6526. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  6527. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  6528. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  6529. _, err = f.Write([]byte(str))
  6530. }
  6531. if item.OrderStatus == 3 {
  6532. var str string
  6533. str = item.SetlId + " " +
  6534. item.MdtrtId + " " +
  6535. item.PsnNo + " " +
  6536. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  6537. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  6538. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  6539. _, err = f.Write([]byte(str))
  6540. var str2 string
  6541. str2 = item.SetlId + " " +
  6542. item.MdtrtId + " " +
  6543. item.PsnNo + " " +
  6544. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  6545. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  6546. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  6547. _, err = f.Write([]byte(str2))
  6548. }
  6549. }
  6550. }
  6551. Zip(file_path, zip_path)
  6552. fmt.Println(ReadFile(zip_path))
  6553. fmt.Println(string(ReadFile(zip_path)))
  6554. if config.IsOpen == 1 {
  6555. var user_name string
  6556. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6557. if role.ID == 0 {
  6558. user_name = "管理员"
  6559. } else {
  6560. user_name = role.UserName
  6561. }
  6562. baseParams := models.BaseParams{
  6563. SecretKey: miConfig.SecretKey,
  6564. FixmedinsCode: miConfig.Code,
  6565. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6566. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6567. OrgName: miConfig.OrgName,
  6568. Doctor: user_name,
  6569. }
  6570. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  6571. var dat map[string]interface{}
  6572. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6573. fmt.Println(dat)
  6574. } else {
  6575. fmt.Println(err)
  6576. }
  6577. userJSONBytes, _ := json.Marshal(dat)
  6578. var res ResultNine
  6579. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6580. utils.ErrorLog("解析失败:%v", err)
  6581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6582. return
  6583. }
  6584. if res.Infcode == 0 {
  6585. fileNo := res.Output.FileQuryNo
  6586. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  6587. "file_qury_no=" + fileNo +
  6588. "&setl_optins=" + "定点医保中心" +
  6589. "&stmt_begndate=" + start_time +
  6590. "&stm_enddate=" + end_time +
  6591. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6592. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6593. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  6594. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6595. "&fixmedins_code=" + miConfig.Code +
  6596. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6597. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6598. "&secret_key=" + miConfig.SecretKey +
  6599. "&org_name=" + miConfig.OrgName +
  6600. "&doctor=" + user_name
  6601. resp, requestErr := http.Get(api)
  6602. if requestErr != nil {
  6603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6604. return
  6605. }
  6606. body, ioErr := ioutil.ReadAll(resp.Body)
  6607. if ioErr != nil {
  6608. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6610. return
  6611. }
  6612. var respJSON map[string]interface{}
  6613. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6616. return
  6617. }
  6618. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6619. userJSONBytes, _ := json.Marshal(respJSON)
  6620. var res ResultTen
  6621. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6622. utils.ErrorLog("解析失败:%v", err)
  6623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6624. return
  6625. }
  6626. if res.Infcode == 0 {
  6627. service.Gdyb9102(baseParams, zip_name, fileNo)
  6628. micc := &models.MedicalInsuranceCostCompare{
  6629. StartTime: startime.Unix(),
  6630. EndTime: endtime.Unix(),
  6631. Insutype: "0",
  6632. CheckType: 2,
  6633. Num: fixmedins_setl_cnt,
  6634. Mtime: time.Now().Unix(),
  6635. Status: 1,
  6636. UserOrgId: adminUser.CurrentOrgId,
  6637. CostTotal: medfee_sumamt,
  6638. FuncTotal: fund_pay_sumamt,
  6639. PsnPay: psn_cash_pay,
  6640. Creator: admin_user_id,
  6641. Ctime: time.Now().Unix(),
  6642. }
  6643. service.CreateMedicalInsuranceCostCompareRecord(micc)
  6644. c.ServeSuccessJSON(map[string]interface{}{
  6645. "msg": "明细对账成功",
  6646. })
  6647. }
  6648. } else {
  6649. }
  6650. }
  6651. }
  6652. type CustomOrderInfo struct {
  6653. Name string
  6654. Spec string
  6655. Unit string
  6656. Count float64
  6657. Price float64
  6658. Total float64
  6659. }
  6660. func (c *HisApiController) GetSettleAccounts() {
  6661. //id, _ := c.GetInt64("id")
  6662. //record_time := c.GetString("record_time")
  6663. order_id, _ := c.GetInt64("order_id")
  6664. admin_user_id, _ := c.GetInt64("admin_user_id")
  6665. //timeLayout := "2006-01-02"
  6666. //loc, _ := time.LoadLocation("Local")
  6667. //
  6668. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6669. //if err != nil {
  6670. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6671. // return
  6672. //}
  6673. //recordDateTime := theTime.Unix()
  6674. adminUser := c.GetAdminUserInfo()
  6675. order, _ := service.GetHisOrderByID(order_id)
  6676. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6677. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  6678. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  6679. orderInfos = append(orderInfos, orderInfos_two...)
  6680. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  6681. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6682. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  6683. //var config []*models.HisXtDiagnoseConfig
  6684. var name string
  6685. for _, item := range diagnosis_ids {
  6686. id, _ := strconv.ParseInt(item, 10, 64)
  6687. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6688. if len(name) == 0 {
  6689. name = diagnosisConfig.ClassName
  6690. } else {
  6691. name = name + "," + diagnosisConfig.ClassName
  6692. }
  6693. }
  6694. var bedCostTotal float64 = 0 //床位总费
  6695. var bedCostSelfTotal float64 = 0 //床位自费
  6696. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  6697. var operationCostTotal float64 = 0 //手术费
  6698. var operationCostSelfTotal float64 = 0 //手术费
  6699. var operationCostPartSelfTotal float64 = 0 //手术费
  6700. var otherCostTotal float64 = 0 //其他费用
  6701. var otherCostSelfTotal float64 = 0 //其他费用
  6702. var otherCostPartSelfTotal float64 = 0 //其他费用
  6703. var materialCostTotal float64 = 0 //材料费
  6704. var materialCostSelfTotal float64 = 0 //材料费
  6705. var materialCostPartSelfTotal float64 = 0 //材料费
  6706. var westernMedicineCostTotal float64 = 0 //西药费
  6707. var westernMedicineCostSelfTotal float64 = 0 //西药费
  6708. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  6709. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  6710. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  6711. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  6712. var checkCostTotal float64 = 0 //检查费
  6713. var checkCostSelfTotal float64 = 0 //检查费
  6714. var checkCostPartSelfTotal float64 = 0 //检查费
  6715. var laboratoryCostTotal float64 = 0 //化验费
  6716. var laboratoryCostSelfTotal float64 = 0 //化验费
  6717. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  6718. var treatCostTotal float64 = 0 //治疗费用
  6719. var treatCostSelfTotal float64 = 0 //治疗费用
  6720. var treatCostPartSelfTotal float64 = 0 //治疗费用
  6721. decimal.DivisionPrecision = 2
  6722. for _, item := range orderInfos {
  6723. if item.MedChrgitmType == "01" { //床位费
  6724. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6725. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6726. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6727. }
  6728. if item.MedChrgitmType == "03" { //检查费
  6729. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6730. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6731. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6732. }
  6733. if item.MedChrgitmType == "04" { //化验费
  6734. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6735. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6736. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6737. }
  6738. if item.MedChrgitmType == "05" { //治疗费
  6739. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6740. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6741. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6742. }
  6743. if item.MedChrgitmType == "06" { //手术费
  6744. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6745. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6746. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6747. }
  6748. if item.MedChrgitmType == "08" { //材料费
  6749. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6750. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6751. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6752. }
  6753. if item.MedChrgitmType == "09" { //西药费
  6754. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6755. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6756. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6757. }
  6758. if item.MedChrgitmType == "11" { //中成费
  6759. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6760. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6761. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6762. }
  6763. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  6764. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6765. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6766. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6767. }
  6768. }
  6769. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6770. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6771. var user_name string
  6772. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6773. if role.ID == 0 {
  6774. user_name = "管理员"
  6775. } else {
  6776. user_name = role.UserName
  6777. }
  6778. baseParams := models.BaseParams{
  6779. SecretKey: miConfig.SecretKey,
  6780. FixmedinsCode: miConfig.Code,
  6781. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6782. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6783. OrgName: miConfig.OrgName,
  6784. Doctor: user_name,
  6785. }
  6786. businessParams := models.BusinessParams{
  6787. PsnNo: order.PsnNo,
  6788. MdtrtId: order.MdtrtId,
  6789. SetlId: order.SetlId,
  6790. }
  6791. var res ResultEleven
  6792. var resEleven10265 ResultEleven10265
  6793. if config.IsOpen == 1 {
  6794. if miConfig.MdtrtareaAdmvs == "421300" {
  6795. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  6796. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  6797. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6798. resp, requestErr := http.Get(api)
  6799. if requestErr != nil {
  6800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6801. return
  6802. }
  6803. body, ioErr := ioutil.ReadAll(resp.Body)
  6804. if ioErr != nil {
  6805. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6807. return
  6808. }
  6809. var respJSON map[string]interface{}
  6810. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6813. return
  6814. }
  6815. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6816. result, _ := json.Marshal(respJSON)
  6817. fmt.Println("log")
  6818. fmt.Println(string(result))
  6819. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6820. utils.ErrorLog("解析失败:%v", err)
  6821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6822. return
  6823. }
  6824. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6825. api := "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  6826. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  6827. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  6828. resp, requestErr := http.Get(api)
  6829. if requestErr != nil {
  6830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6831. return
  6832. }
  6833. body, ioErr := ioutil.ReadAll(resp.Body)
  6834. if ioErr != nil {
  6835. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6837. return
  6838. }
  6839. var respJSON map[string]interface{}
  6840. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6843. return
  6844. }
  6845. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6846. result, _ := json.Marshal(respJSON)
  6847. fmt.Println("log")
  6848. fmt.Println(string(result))
  6849. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  6850. utils.ErrorLog("解析失败:%v", err)
  6851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6852. return
  6853. }
  6854. res.InfRefmsgid = resEleven10265.InfRefmsgid
  6855. res.Output = resEleven10265.Output
  6856. res.ErrMsg = resEleven10265.ErrMsg
  6857. res.Cainfo = resEleven10265.Cainfo
  6858. res.WarnMsg = resEleven10265.WarnMsg
  6859. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  6860. res.Infcode = infocode
  6861. } else {
  6862. result2 := service.Gdyb5204(baseParams, businessParams)
  6863. saveLog(result2, "", "5204", "查询")
  6864. result := service.Gdyb5203(baseParams, businessParams)
  6865. var dat map[string]interface{}
  6866. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6867. fmt.Println(dat)
  6868. } else {
  6869. fmt.Println(err)
  6870. }
  6871. userJSONBytes, _ := json.Marshal(dat)
  6872. if miConfig.Code == "H15049901371" {
  6873. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  6874. utils.ErrorLog("解析失败:%v", err)
  6875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6876. return
  6877. }
  6878. res.InfRefmsgid = resEleven10265.InfRefmsgid
  6879. res.Output = resEleven10265.Output
  6880. res.ErrMsg = resEleven10265.ErrMsg
  6881. res.Cainfo = resEleven10265.Cainfo
  6882. res.WarnMsg = resEleven10265.WarnMsg
  6883. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  6884. res.Infcode = infocode
  6885. } else {
  6886. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6887. utils.ErrorLog("解析失败:%v", err)
  6888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6889. return
  6890. }
  6891. }
  6892. }
  6893. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6894. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  6895. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  6896. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6897. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6898. var doctor_name string
  6899. if roles.ID == 0 {
  6900. doctor_name = "管理员"
  6901. } else {
  6902. doctor_name = roles.UserName
  6903. }
  6904. yiliao_leibie := ""
  6905. switch order.MedType {
  6906. case "11":
  6907. yiliao_leibie = "普通门诊"
  6908. break
  6909. case "12":
  6910. yiliao_leibie = "门诊挂号"
  6911. break
  6912. case "13":
  6913. yiliao_leibie = "急诊"
  6914. break
  6915. case "14":
  6916. yiliao_leibie = "门诊特殊病"
  6917. break
  6918. case "15":
  6919. yiliao_leibie = "门诊统筹"
  6920. break
  6921. case "16":
  6922. yiliao_leibie = "门诊慢性病"
  6923. break
  6924. case "21":
  6925. yiliao_leibie = "普通住院"
  6926. break
  6927. }
  6928. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6929. if res.Infcode == 0 {
  6930. c.ServeSuccessJSON(map[string]interface{}{
  6931. "diagnosis": name,
  6932. "order_infos": orderInfos,
  6933. "number": order.MdtrtId,
  6934. "date": order.SettleAccountsDate,
  6935. "charge_admin": charge_admin,
  6936. "printor_admin": printor_admin,
  6937. "info": res.Output.Setlinfo,
  6938. "bedCostTotal": bedCostTotal,
  6939. "bedCostSelfTotal": bedCostSelfTotal,
  6940. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  6941. "operationCostTotal": operationCostTotal,
  6942. "operationCostSelfTotal": operationCostSelfTotal,
  6943. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  6944. "otherCostTotal": otherCostTotal,
  6945. "otherCostSelfTotal": otherCostSelfTotal,
  6946. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  6947. "materialCostTotal": materialCostTotal,
  6948. "materialCostSelfTotal": materialCostSelfTotal,
  6949. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  6950. "westernMedicineCostTotal": westernMedicineCostTotal,
  6951. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  6952. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  6953. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  6954. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  6955. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  6956. "checkCostTotal": checkCostTotal,
  6957. "checkCostSelfTotal": checkCostSelfTotal,
  6958. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  6959. "laboratoryCostTotal": laboratoryCostTotal,
  6960. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  6961. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  6962. "treatCostTotal": treatCostTotal,
  6963. "treatCostSelfTotal": treatCostSelfTotal,
  6964. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  6965. "doctor_code": adminRole_two.DoctorCode,
  6966. "doctor_name": doctor_name,
  6967. "health_card_no": order.PsnNo,
  6968. "department": departments.Name,
  6969. "yiliao_leibie": yiliao_leibie,
  6970. "after_money": order.AccountPrice,
  6971. "patient": patient,
  6972. "org_name": miConfig.OrgName,
  6973. "org_code": miConfig.Code,
  6974. "order_number": order.Number,
  6975. //"check_order_info": cus_slice,
  6976. })
  6977. }
  6978. }
  6979. }
  6980. func (c *HisApiController) CheckTreatment() {
  6981. patient_id, _ := c.GetInt64("patient_id")
  6982. id_card_no := c.GetString("id_card_no")
  6983. insutype := c.GetString("insutype")
  6984. med_type := c.GetString("med_type")
  6985. admin_user_id, _ := c.GetInt64("admin_user_id")
  6986. adminUser := c.GetAdminUserInfo()
  6987. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  6988. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6989. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6990. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6991. if miConfig.MdtrtareaAdmvs == "421300" {
  6992. var res ResultTwo
  6993. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  6994. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6995. "&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)
  6996. resp, requestErr := http.Get(api)
  6997. if requestErr != nil {
  6998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6999. return
  7000. }
  7001. body, ioErr := ioutil.ReadAll(resp.Body)
  7002. if ioErr != nil {
  7003. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7005. return
  7006. }
  7007. var respJSON map[string]interface{}
  7008. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7009. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7011. return
  7012. }
  7013. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7014. result, _ := json.Marshal(respJSON)
  7015. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7016. utils.ErrorLog("解析失败:%v", err)
  7017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7018. return
  7019. }
  7020. if res.Infcode == 0 {
  7021. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  7022. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7023. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  7024. resp, requestErr := http.Get(api)
  7025. if requestErr != nil {
  7026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7027. return
  7028. }
  7029. body, ioErr := ioutil.ReadAll(resp.Body)
  7030. if ioErr != nil {
  7031. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7033. return
  7034. }
  7035. var respJSON map[string]interface{}
  7036. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7039. return
  7040. }
  7041. var res Result2001
  7042. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7043. result2, _ := json.Marshal(respJSON)
  7044. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  7045. utils.ErrorLog("解析失败:%v", err)
  7046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7047. return
  7048. }
  7049. if res.Infcode == 0 {
  7050. c.ServeSuccessJSON(map[string]interface{}{
  7051. "msg": res.Output.Trtinfo,
  7052. })
  7053. }
  7054. } else {
  7055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7056. return
  7057. }
  7058. } else {
  7059. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7060. var dat map[string]interface{}
  7061. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7062. fmt.Println(dat)
  7063. } else {
  7064. fmt.Println(err)
  7065. }
  7066. userJSONBytes, _ := json.Marshal(dat)
  7067. var res ResultTwo
  7068. var res10265 ResultTwo10265
  7069. if miConfig.Code == "H15049901371" {
  7070. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7071. utils.ErrorLog("解析失败:%v", err)
  7072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7073. return
  7074. }
  7075. res.ErrMsg = res10265.ErrMsg
  7076. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7077. res.Infcode = infocode
  7078. res.Output = res10265.Output
  7079. res.InfRefmsgid = res10265.InfRefmsgid
  7080. } else {
  7081. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7082. utils.ErrorLog("解析失败:%v", err)
  7083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7084. return
  7085. }
  7086. }
  7087. var user_name string
  7088. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  7089. if role.ID == 0 {
  7090. user_name = "xxx"
  7091. } else {
  7092. user_name = role.UserName
  7093. }
  7094. baseParams := models.BaseParams{
  7095. SecretKey: miConfig.SecretKey,
  7096. FixmedinsCode: miConfig.Code,
  7097. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7098. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7099. OrgName: miConfig.OrgName,
  7100. Doctor: user_name,
  7101. }
  7102. if config.IsOpen == 1 {
  7103. if miConfig.Code == "H15049901371" {
  7104. if med_type == "14" {
  7105. if insutype == "390" {
  7106. med_type = "9933"
  7107. } else if insutype == "310" {
  7108. med_type = "990502"
  7109. }
  7110. } else if med_type == "11" {
  7111. med_type = "11"
  7112. }
  7113. }
  7114. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  7115. var dat map[string]interface{}
  7116. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7117. fmt.Println(dat)
  7118. } else {
  7119. fmt.Println(err)
  7120. }
  7121. var res Result2001
  7122. var res10265 Result2001Org10265
  7123. if miConfig.Code == "H15049901371" {
  7124. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7125. utils.ErrorLog("解析失败:%v", err)
  7126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7127. return
  7128. }
  7129. res.ErrMsg = res10265.ErrMsg
  7130. res.Output = res10265.Output
  7131. res.InfRefmsgid = res10265.InfRefmsgid
  7132. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7133. res.Infcode = infocode
  7134. } else {
  7135. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7136. utils.ErrorLog("解析失败:%v", err)
  7137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7138. return
  7139. }
  7140. }
  7141. if res.Infcode == 0 {
  7142. c.ServeSuccessJSON(map[string]interface{}{
  7143. "msg": res.Output.Trtinfo,
  7144. })
  7145. }
  7146. }
  7147. }
  7148. }
  7149. //func (c *HisApiController) PutRecord() {
  7150. // id, _ := c.GetInt64("id")
  7151. // record_time := c.GetString("record_time")
  7152. // timeLayout := "2006-01-02"
  7153. // loc, _ := time.LoadLocation("Local")
  7154. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7155. // if err != nil {
  7156. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7157. // return
  7158. // }
  7159. // recordDateTime := theTime.Unix()
  7160. //
  7161. // adminInfo := c.GetAdminUserInfo()
  7162. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  7163. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7164. //
  7165. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7166. //
  7167. // fmt.Println(miConfig.SecretKey)
  7168. //
  7169. // if patient == nil {
  7170. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7171. // return
  7172. // }
  7173. // if len(patient.IdCardNo) == 0 {
  7174. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7175. // return
  7176. // }
  7177. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7178. // if config.IsOpen == 1 {
  7179. // 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
  7180. // resp, requestErr := http.Get(api)
  7181. // if requestErr != nil {
  7182. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7183. // return
  7184. // }
  7185. // defer resp.Body.Close()
  7186. // body, ioErr := ioutil.ReadAll(resp.Body)
  7187. // if ioErr != nil {
  7188. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7189. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7190. // return
  7191. // }
  7192. // var respJSON map[string]interface{}
  7193. //
  7194. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7195. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7196. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7197. // return
  7198. // }
  7199. //
  7200. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7201. // userJSONBytes, _ := json.Marshal(userJSON)
  7202. // var res ResultTwo
  7203. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7204. // utils.ErrorLog("解析失败:%v", err)
  7205. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7206. // return
  7207. // }
  7208. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7209. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7210. // infoStr := string(Iinfos)
  7211. // idetinfoStr := string(Idetinfos)
  7212. //
  7213. // if res.Infcode == 0 {
  7214. // his := models.VMHisPatient{
  7215. // Status: 1,
  7216. // Ctime: time.Now().Unix(),
  7217. // Mtime: time.Now().Unix(),
  7218. // PsnNo: res.Output.Baseinfo.PsnNo,
  7219. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  7220. // Certno: res.Output.Baseinfo.Certno,
  7221. // PsnName: res.Output.Baseinfo.PsnName,
  7222. // Gend: res.Output.Baseinfo.Gend,
  7223. // Naty: res.Output.Baseinfo.Naty,
  7224. // Brdy: res.Output.Baseinfo.Brdy,
  7225. // Age: res.Output.Baseinfo.Age,
  7226. // Iinfo: infoStr,
  7227. // Idetinfo: idetinfoStr,
  7228. // PatientId: patient.ID,
  7229. // RecordDate: theTime.Unix(),
  7230. // UserOrgId: adminInfo.CurrentOrgId,
  7231. // AdminUserId: adminInfo.AdminUser.Id,
  7232. // IsReturn: 1,
  7233. // }
  7234. //
  7235. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  7236. // //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")
  7237. // //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")
  7238. //
  7239. // //var dat map[string]interface{}
  7240. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7241. // // fmt.Println(dat)
  7242. // //} else {
  7243. // // fmt.Println(err)
  7244. // //}
  7245. //
  7246. // var dat2 map[string]interface{}
  7247. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  7248. // fmt.Println(dat2)
  7249. // } else {
  7250. // fmt.Println(err)
  7251. // }
  7252. //
  7253. // } else {
  7254. // adminUser := c.GetAdminUserInfo()
  7255. // errlog := &models.HisOrderError{
  7256. // UserOrgId: adminUser.CurrentOrgId,
  7257. // Ctime: time.Now().Unix(),
  7258. // Mtime: time.Now().Unix(),
  7259. // ErrMsg: res.ErrMsg,
  7260. // Status: 1,
  7261. // PatientId: id,
  7262. // RecordTime: recordDateTime,
  7263. // Stage: 1,
  7264. // }
  7265. // service.CreateErrMsgLog(errlog)
  7266. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  7267. // return
  7268. // }
  7269. // }
  7270. //
  7271. //}
  7272. //func (c *HisApiController) GetUploadDiag() {
  7273. // id, _ := c.GetInt64("id")
  7274. // record_time := c.GetString("record_time")
  7275. //
  7276. // diagnosis_id, _ := c.GetInt64("diagnosis")
  7277. // sick_type, _ := c.GetInt64("sick_type")
  7278. // reg_type, _ := c.GetInt64("reg_type")
  7279. //
  7280. // timeLayout := "2006-01-02"
  7281. // loc, _ := time.LoadLocation("Local")
  7282. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7283. // if err != nil {
  7284. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7285. // return
  7286. // }
  7287. //
  7288. // var patientPrescription models.HisPrescriptionInfo
  7289. // recordDateTime := theTime.Unix()
  7290. // adminInfo := c.GetAdminUserInfo()
  7291. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7292. //
  7293. // if patientPrescription.ID == 0 {
  7294. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7295. // }
  7296. //
  7297. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7298. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  7299. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7300. // sickConfig, _ := service.FindSickById(sick_type)
  7301. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7302. //
  7303. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  7304. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  7305. // "&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 +
  7306. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  7307. // resp2, requestErr2 := http.Get(api2)
  7308. // if requestErr2 != nil {
  7309. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7310. // return
  7311. // }
  7312. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7313. // if ioErr2 != nil {
  7314. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7315. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7316. // return
  7317. // }
  7318. // var respJSON2 map[string]interface{}
  7319. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7320. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7321. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7322. // return
  7323. // }
  7324. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7325. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7326. //
  7327. // var res2 ResultSix
  7328. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7329. // utils.ErrorLog("解析失败:%v", err)
  7330. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7331. // return
  7332. // }
  7333. // if res2.Infcode != 0 {
  7334. // adminUser := c.GetAdminUserInfo()
  7335. // errlog := &models.HisOrderError{
  7336. // UserOrgId: adminUser.CurrentOrgId,
  7337. // Ctime: time.Now().Unix(),
  7338. // Mtime: time.Now().Unix(),
  7339. // ErrMsg: res2.ErrMsg,
  7340. // Status: 1,
  7341. // PatientId: id,
  7342. // RecordTime: recordDateTime,
  7343. // Stage: 3,
  7344. // }
  7345. // service.CreateErrMsgLog(errlog)
  7346. //
  7347. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  7348. // return
  7349. // }
  7350. //
  7351. // c.ServeSuccessJSON(map[string]interface{}{
  7352. // "msg": "上传成功",
  7353. // })
  7354. //
  7355. //}
  7356. type QueryResult struct {
  7357. ID int64
  7358. Name string
  7359. Code string
  7360. List_type_code string
  7361. }
  7362. func (c *HisApiController) GetCheckCode() {
  7363. ids_str := c.GetString("ids")
  7364. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  7365. ids_arr := strings.Split(ids_str, ",")
  7366. var queryResult []QueryResult
  7367. ids := make([]int64, 0)
  7368. for _, item := range ids_arr {
  7369. id, _ := strconv.ParseInt(item, 10, 64)
  7370. ids = append(ids, id)
  7371. }
  7372. if record_type == 1 {
  7373. drugs, _ := service.GetBatchDrugList(ids)
  7374. for _, item := range drugs {
  7375. result := QueryResult{
  7376. ID: item.ID,
  7377. Name: item.DrugName,
  7378. Code: item.MedicalInsuranceNumber,
  7379. List_type_code: "101",
  7380. }
  7381. queryResult = append(queryResult, result)
  7382. }
  7383. } else if record_type == 2 {
  7384. goods, _ := service.GetBatchGoodInformationList(ids)
  7385. for _, item := range goods {
  7386. result := QueryResult{
  7387. ID: item.ID,
  7388. Name: item.GoodName,
  7389. Code: item.MedicalInsuranceNumber,
  7390. List_type_code: "301",
  7391. }
  7392. queryResult = append(queryResult, result)
  7393. }
  7394. } else if record_type == 3 {
  7395. projects, _ := service.GetBathchMyPorjecgList(ids)
  7396. for _, item := range projects {
  7397. result := QueryResult{
  7398. ID: item.ID,
  7399. Name: item.ProjectName,
  7400. Code: item.MedicalCode,
  7401. List_type_code: "201",
  7402. }
  7403. queryResult = append(queryResult, result)
  7404. }
  7405. }
  7406. admin_user_id, _ := c.GetInt64("admin_user_id")
  7407. adminUser := c.GetAdminUserInfo()
  7408. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7409. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7410. var user_name string
  7411. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7412. if role.ID == 0 {
  7413. user_name = "xxx"
  7414. } else {
  7415. user_name = role.UserName
  7416. }
  7417. baseParams := &models.BaseParams{
  7418. SecretKey: miConfig.SecretKey,
  7419. FixmedinsCode: miConfig.Code,
  7420. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7421. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7422. OrgName: miConfig.OrgName,
  7423. Doctor: user_name,
  7424. }
  7425. if config.IsOpen == 1 {
  7426. for _, item := range queryResult {
  7427. var result string
  7428. if record_type == 1 {
  7429. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7430. } else if record_type == 2 {
  7431. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7432. } else if record_type == 3 {
  7433. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7434. }
  7435. var dat map[string]interface{}
  7436. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7437. fmt.Println(dat)
  7438. } else {
  7439. fmt.Println(err)
  7440. }
  7441. userJSONBytes, _ := json.Marshal(dat)
  7442. var res ResultSix
  7443. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7444. utils.ErrorLog("解析失败:%v", err)
  7445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7446. return
  7447. }
  7448. if res.Infcode == 0 {
  7449. if record_type == 1 {
  7450. service.UpdateBaseDrugById(item.ID)
  7451. } else if record_type == 2 {
  7452. service.UpdateGoodInformaitonByDetail(item.ID)
  7453. } else if record_type == 3 {
  7454. service.UpdateProjectById(item.ID)
  7455. }
  7456. c.ServeSuccessJSON(map[string]interface{}{
  7457. "failed_code": 0,
  7458. "msg": "目录对照成功",
  7459. })
  7460. } else {
  7461. c.ServeSuccessJSON(map[string]interface{}{
  7462. "failed_code": -10,
  7463. "msg": res.ErrMsg,
  7464. })
  7465. }
  7466. }
  7467. }
  7468. }
  7469. func (c *HisApiController) UnCheckCode() {
  7470. ids_str := c.GetString("ids")
  7471. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  7472. admin_user_id, _ := c.GetInt64("admin_user_id")
  7473. ids_arr := strings.Split(ids_str, ",")
  7474. var queryResult []QueryResult
  7475. ids := make([]int64, 0)
  7476. for _, item := range ids_arr {
  7477. id, _ := strconv.ParseInt(item, 10, 64)
  7478. ids = append(ids, id)
  7479. }
  7480. if record_type == 1 {
  7481. drugs, _ := service.GetBatchDrugList(ids)
  7482. for _, item := range drugs {
  7483. result := QueryResult{
  7484. ID: item.ID,
  7485. Name: item.DrugName,
  7486. Code: item.MedicalInsuranceNumber,
  7487. List_type_code: "101",
  7488. }
  7489. queryResult = append(queryResult, result)
  7490. }
  7491. } else if record_type == 2 {
  7492. goods, _ := service.GetBatchGoodInformationList(ids)
  7493. for _, item := range goods {
  7494. result := QueryResult{
  7495. ID: item.ID,
  7496. Name: item.GoodName,
  7497. Code: item.MedicalInsuranceNumber,
  7498. List_type_code: "301",
  7499. }
  7500. queryResult = append(queryResult, result)
  7501. }
  7502. } else if record_type == 3 {
  7503. projects, _ := service.GetBathchMyPorjecgList(ids)
  7504. for _, item := range projects {
  7505. result := QueryResult{
  7506. ID: item.ID,
  7507. Name: item.ProjectName,
  7508. Code: item.MedicalCode,
  7509. List_type_code: "201",
  7510. }
  7511. queryResult = append(queryResult, result)
  7512. }
  7513. }
  7514. adminUser := c.GetAdminUserInfo()
  7515. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7516. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7517. var user_name string
  7518. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7519. if role.ID == 0 {
  7520. user_name = "xxx"
  7521. } else {
  7522. user_name = role.UserName
  7523. }
  7524. baseParams := &models.BaseParams{
  7525. SecretKey: miConfig.SecretKey,
  7526. FixmedinsCode: miConfig.Code,
  7527. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7528. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7529. OrgName: miConfig.OrgName,
  7530. Doctor: user_name,
  7531. }
  7532. if config.IsOpen == 1 {
  7533. for _, item := range queryResult {
  7534. var result string
  7535. if record_type == 1 {
  7536. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7537. } else if record_type == 2 {
  7538. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7539. } else if record_type == 3 {
  7540. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7541. }
  7542. var dat2 map[string]interface{}
  7543. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  7544. fmt.Println(dat2)
  7545. } else {
  7546. fmt.Println(err)
  7547. }
  7548. userJSONBytes, _ := json.Marshal(dat2)
  7549. var res ResultSix
  7550. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7551. utils.ErrorLog("解析失败:%v", err)
  7552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7553. return
  7554. }
  7555. if res.Infcode == 0 {
  7556. if record_type == 1 {
  7557. service.UpdateDrugByIdDetail(item.ID)
  7558. } else if record_type == 2 {
  7559. service.UpdateGoodInfoById(item.ID)
  7560. } else if record_type == 3 {
  7561. service.UpdateMyProjectById(item.ID)
  7562. }
  7563. c.ServeSuccessJSON(map[string]interface{}{
  7564. "failed_code": 0,
  7565. "msg": "撤销目录对照成功",
  7566. })
  7567. } else {
  7568. c.ServeSuccessJSON(map[string]interface{}{
  7569. "failed_code": -10,
  7570. "msg": res.ErrMsg,
  7571. })
  7572. }
  7573. }
  7574. }
  7575. }
  7576. func (c *HisApiController) GetPatientInfo() {
  7577. id_card_no := c.GetString("id_card_no")
  7578. admin_user_id, _ := c.GetInt64("admin_user_id")
  7579. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  7580. if patient.ID == 0 {
  7581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7582. return
  7583. }
  7584. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7585. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7586. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  7587. if config.IsOpen == 1 {
  7588. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7589. var dat map[string]interface{}
  7590. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7591. fmt.Println(dat)
  7592. } else {
  7593. fmt.Println(err)
  7594. }
  7595. userJSONBytes, _ := json.Marshal(dat)
  7596. var res ResultTwo
  7597. var res10265 ResultTwo10265
  7598. if miConfig.Code == "H15049901371" {
  7599. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7600. utils.ErrorLog("解析失败:%v", err)
  7601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7602. return
  7603. }
  7604. res.ErrMsg = res10265.ErrMsg
  7605. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7606. res.Infcode = infocode
  7607. res.Output = res10265.Output
  7608. res.InfRefmsgid = res10265.InfRefmsgid
  7609. } else {
  7610. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7611. utils.ErrorLog("解析失败:%v", err)
  7612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7613. return
  7614. }
  7615. }
  7616. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7617. // utils.ErrorLog("解析失败:%v", err)
  7618. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7619. // return
  7620. //}
  7621. if res.Infcode != 0 {
  7622. c.ServeSuccessJSON(map[string]interface{}{
  7623. "failed_code": -10,
  7624. "msg": res.ErrMsg,
  7625. })
  7626. } else {
  7627. c.ServeSuccessJSON(map[string]interface{}{
  7628. "failed_code": 0,
  7629. "info": res,
  7630. })
  7631. }
  7632. }
  7633. }
  7634. func (c *HisApiController) PsnPutOnRecord() {
  7635. record_type, _ := c.GetInt64("type")
  7636. patient_id, _ := c.GetInt64("patient_id")
  7637. admin_user_id, _ := c.GetInt64("admin_user_id")
  7638. start_time := c.GetString("start_time")
  7639. end_time := c.GetString("end_time")
  7640. adminUser := c.GetAdminUserInfo()
  7641. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7642. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7643. var patients []*models.Patients
  7644. if record_type == 1 { //全部备案
  7645. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  7646. patients = append(patients, patient...)
  7647. } else { //单个备案
  7648. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7649. patients = append(patients, patient)
  7650. }
  7651. var user_name string
  7652. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7653. if role.ID == 0 {
  7654. user_name = "xxx"
  7655. } else {
  7656. user_name = role.UserName
  7657. }
  7658. if config.IsOpen == 1 {
  7659. for _, item := range patients {
  7660. 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
  7661. resp, requestErr := http.Get(api)
  7662. if requestErr != nil {
  7663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7664. return
  7665. }
  7666. defer resp.Body.Close()
  7667. body, ioErr := ioutil.ReadAll(resp.Body)
  7668. if ioErr != nil {
  7669. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7671. return
  7672. }
  7673. var respJSON map[string]interface{}
  7674. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7675. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7677. return
  7678. }
  7679. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7680. userJSONBytes, _ := json.Marshal(userJSON)
  7681. var res ResultTwo
  7682. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7683. utils.ErrorLog("解析失败:%v", err)
  7684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7685. return
  7686. }
  7687. if res.Infcode == 0 {
  7688. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  7689. var dat map[string]interface{}
  7690. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7691. fmt.Println(dat)
  7692. } else {
  7693. fmt.Println(err)
  7694. }
  7695. userJSONBytes, _ := json.Marshal(dat)
  7696. var res2 ResultThirteen
  7697. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7698. utils.ErrorLog("解析失败:%v", err)
  7699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7700. return
  7701. }
  7702. if res2.Infcode == 0 {
  7703. psnResult := &models.GdybPsnRecord{
  7704. UserOrgId: adminUser.CurrentOrgId,
  7705. PatientId: item.ID,
  7706. PsnNo: res.Output.Baseinfo.PsnNo,
  7707. Ctime: time.Now().Unix(),
  7708. Mtime: time.Now().Unix(),
  7709. Status: 1,
  7710. IsCancel: 1,
  7711. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  7712. }
  7713. service.CreatePsnRecord(psnResult)
  7714. } else {
  7715. c.ServeSuccessJSON(map[string]interface{}{
  7716. "failed_code": -10,
  7717. "msg": res2.ErrMsg,
  7718. })
  7719. return
  7720. }
  7721. }
  7722. }
  7723. }
  7724. }
  7725. func (c *HisApiController) PsnUnPutOnRecord() {
  7726. id, _ := c.GetInt64("id")
  7727. //record_type, _ := c.GetInt64("type")
  7728. admin_user_id, _ := c.GetInt64("admin_user_id")
  7729. adminUser := c.GetAdminUserInfo()
  7730. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7731. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7732. var user_name string
  7733. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7734. if role.ID == 0 {
  7735. user_name = "xxx"
  7736. } else {
  7737. user_name = role.UserName
  7738. }
  7739. psn_record, _ := service.GetPsnRecordById(id)
  7740. if psn_record.ID == 0 {
  7741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7742. return
  7743. }
  7744. if config.IsOpen == 1 {
  7745. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  7746. var dat map[string]interface{}
  7747. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7748. fmt.Println(dat)
  7749. } else {
  7750. fmt.Println(err)
  7751. }
  7752. userJSONBytes, _ := json.Marshal(dat)
  7753. var res ResultFourteen
  7754. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7755. utils.ErrorLog("解析失败:%v", err)
  7756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7757. return
  7758. }
  7759. if res.Infcode == 0 {
  7760. psn_record.IsCancel = 2
  7761. service.CreatePsnRecord(&psn_record)
  7762. } else {
  7763. c.ServeSuccessJSON(map[string]interface{}{
  7764. "failed_code": -10,
  7765. "msg": res.ErrMsg,
  7766. })
  7767. return
  7768. }
  7769. }
  7770. }
  7771. func (c *HisApiController) PsnPutNCDSOnRecord() {
  7772. patient_id, _ := c.GetInt64("patient_id")
  7773. insutype_two := c.GetString("insutype")
  7774. psn_no := c.GetString("psn_no")
  7775. doctor_id, _ := c.GetInt64("doctor_id")
  7776. sick_id, _ := c.GetInt64("sick_id")
  7777. department_id, _ := c.GetInt64("department_id")
  7778. start_time := c.GetString("start_time")
  7779. end_time := c.GetString("end_time")
  7780. check_time := c.GetString("check_time")
  7781. adminUser := c.GetAdminUserInfo()
  7782. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7783. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7784. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7785. sick, _ := service.FindSickById(sick_id)
  7786. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  7787. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  7788. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  7789. var res ResultTwo
  7790. var res10265 ResultTwo10265
  7791. if miConfig.Code == "H15049901371" {
  7792. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7793. utils.ErrorLog("解析失败:%v", err)
  7794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7795. return
  7796. }
  7797. res.ErrMsg = res10265.ErrMsg
  7798. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7799. res.Infcode = infocode
  7800. res.Output = res10265.Output
  7801. res.InfRefmsgid = res10265.InfRefmsgid
  7802. } else {
  7803. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7804. utils.ErrorLog("解析失败:%v", err)
  7805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7806. return
  7807. }
  7808. }
  7809. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7810. infoStr := string(Iinfos)
  7811. var rf []*ResultFive
  7812. json.Unmarshal([]byte(infoStr), &rf)
  7813. var insuplc_admdvs string
  7814. var insutype string
  7815. var is390 int = 0
  7816. var is310 int = 0
  7817. var insutypes []*ResultFive
  7818. for _, item := range rf {
  7819. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7820. insutypes = append(insutypes, item)
  7821. }
  7822. }
  7823. if len(insutypes) == 1 {
  7824. insutype = insutypes[0].Insutype
  7825. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7826. } else {
  7827. for _, i := range insutypes {
  7828. if i.Insutype == "390" {
  7829. is390 = 1
  7830. }
  7831. if i.Insutype == "310" {
  7832. is310 = 1
  7833. }
  7834. }
  7835. }
  7836. if is390 == 1 {
  7837. insutype = "390"
  7838. }
  7839. if is310 == 1 {
  7840. insutype = "310"
  7841. }
  7842. if len(insutypes) == 2 {
  7843. insutype = insutype_two
  7844. }
  7845. if len(insutypes) == 0 {
  7846. insutype = "310"
  7847. }
  7848. insutype = insutype_two
  7849. fmt.Println(insutype)
  7850. for _, item := range rf {
  7851. fmt.Println(item.Insutype)
  7852. fmt.Println(insutype)
  7853. if item.Insutype == insutype {
  7854. fmt.Println(item.Insutype)
  7855. fmt.Println(insutype)
  7856. insuplc_admdvs = item.InsuplcAdmdvs
  7857. }
  7858. }
  7859. fmt.Println(insuplc_admdvs)
  7860. if config.IsOpen == 1 {
  7861. 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)
  7862. var dat map[string]interface{}
  7863. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7864. fmt.Println(dat)
  7865. } else {
  7866. fmt.Println(err)
  7867. }
  7868. userJSONBytes, _ := json.Marshal(dat)
  7869. var res2 ResultThirteen
  7870. var res10265 ResultThirteen10265
  7871. if miConfig.Code == "H15049901371" {
  7872. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7873. utils.ErrorLog("解析失败:%v", err)
  7874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7875. return
  7876. }
  7877. res2.ErrMsg = res10265.ErrMsg
  7878. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7879. res2.Infcode = infocode
  7880. res2.Output = res10265.Output
  7881. res2.InfRefmsgid = res10265.InfRefmsgid
  7882. } else {
  7883. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7884. utils.ErrorLog("解析失败:%v", err)
  7885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7886. return
  7887. }
  7888. }
  7889. if res2.Infcode == 0 {
  7890. psnResult := &models.GdybPsnNcdsRecord{
  7891. UserOrgId: adminUser.CurrentOrgId,
  7892. PatientId: patient.ID,
  7893. PsnNo: psn_no,
  7894. DoctorId: doctor.AdminUserId,
  7895. DepartmentId: department_id,
  7896. SickType: sick_id,
  7897. Insutype: insutype,
  7898. Ctime: time.Now().Unix(),
  7899. Mtime: time.Now().Unix(),
  7900. Status: 1,
  7901. IsCancel: 1,
  7902. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  7903. }
  7904. service.CreatePsnNCDSRecord(psnResult)
  7905. c.ServeSuccessJSON(map[string]interface{}{
  7906. "failed_code": 0,
  7907. "msg": "备案成功",
  7908. "result": psnResult,
  7909. })
  7910. } else {
  7911. c.ServeSuccessJSON(map[string]interface{}{
  7912. "failed_code": -10,
  7913. "msg": res2.ErrMsg,
  7914. })
  7915. return
  7916. }
  7917. }
  7918. }
  7919. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  7920. id, _ := c.GetInt64("id")
  7921. admin_user_id, _ := c.GetInt64("admin_user_id")
  7922. adminUser := c.GetAdminUserInfo()
  7923. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7924. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7925. //config, _ := service.Ge(adminUser.CurrentOrgId)
  7926. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  7927. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7928. //var user_name string
  7929. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7930. //if role.ID == 0 {
  7931. // user_name = "xxx"
  7932. //} else {
  7933. // user_name = role.UserName
  7934. //}
  7935. psn_record, _ := service.GetPsnNCDSRecordById(id)
  7936. if psn_record.ID == 0 {
  7937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7938. return
  7939. }
  7940. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  7941. var res ResultTwo
  7942. var res10265 ResultTwo10265
  7943. if miConfig.Code == "H15049901371" {
  7944. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7945. utils.ErrorLog("解析失败:%v", err)
  7946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7947. return
  7948. }
  7949. res.ErrMsg = res10265.ErrMsg
  7950. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7951. res.Infcode = infocode
  7952. res.Output = res10265.Output
  7953. res.InfRefmsgid = res10265.InfRefmsgid
  7954. } else {
  7955. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7956. utils.ErrorLog("解析失败:%v", err)
  7957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7958. return
  7959. }
  7960. }
  7961. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7962. infoStr := string(Iinfos)
  7963. var rf []*ResultFive
  7964. json.Unmarshal([]byte(infoStr), &rf)
  7965. var insuplc_admdvs string
  7966. var insutype string
  7967. var is390 int = 0
  7968. var is310 int = 0
  7969. var insutypes []*ResultFive
  7970. for _, item := range rf {
  7971. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7972. insutypes = append(insutypes, item)
  7973. }
  7974. }
  7975. if len(insutypes) == 1 {
  7976. insutype = insutypes[0].Insutype
  7977. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7978. } else {
  7979. for _, i := range insutypes {
  7980. if i.Insutype == "390" {
  7981. is390 = 1
  7982. }
  7983. if i.Insutype == "310" {
  7984. is310 = 1
  7985. }
  7986. }
  7987. }
  7988. if is390 == 1 {
  7989. insutype = "390"
  7990. }
  7991. if is310 == 1 {
  7992. insutype = "310"
  7993. }
  7994. if len(insutypes) == 0 {
  7995. insutype = "310"
  7996. }
  7997. insutype = psn_record.Insutype
  7998. for _, item := range rf {
  7999. if item.Insutype == insutype {
  8000. insuplc_admdvs = item.InsuplcAdmdvs
  8001. }
  8002. }
  8003. if config.IsOpen == 1 {
  8004. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8005. var dat map[string]interface{}
  8006. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8007. fmt.Println(dat)
  8008. } else {
  8009. fmt.Println(err)
  8010. }
  8011. userJSONBytes, _ := json.Marshal(dat)
  8012. var res ResultFourteen
  8013. var res10265 ResultFourteen10265
  8014. if miConfig.Code == "H15049901371" {
  8015. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8016. utils.ErrorLog("解析失败:%v", err)
  8017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8018. return
  8019. }
  8020. res.ErrMsg = res10265.ErrMsg
  8021. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8022. res.Infcode = infocode
  8023. res.Output = res10265.Output
  8024. res.InfRefmsgid = res10265.InfRefmsgid
  8025. } else {
  8026. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8027. utils.ErrorLog("解析失败:%v", err)
  8028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8029. return
  8030. }
  8031. }
  8032. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8033. // utils.ErrorLog("解析失败:%v", err)
  8034. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8035. // return
  8036. //}
  8037. if res.Infcode == 0 {
  8038. psn_record.IsCancel = 2
  8039. service.CreatePsnNCDSRecord(&psn_record)
  8040. c.ServeSuccessJSON(map[string]interface{}{
  8041. "failed_code": 0,
  8042. "msg": "撤销备案成功",
  8043. })
  8044. } else {
  8045. c.ServeSuccessJSON(map[string]interface{}{
  8046. "failed_code": -10,
  8047. "msg": res.ErrMsg,
  8048. })
  8049. return
  8050. }
  8051. }
  8052. }
  8053. func (c *HisApiController) TestTest() {
  8054. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  8055. fmt.Println(patient.Iinfo)
  8056. }
  8057. type CustomData struct {
  8058. MsgId string
  8059. PsnNo string
  8060. Info string
  8061. }
  8062. func (c *HisApiController) ReversalData() {
  8063. var customData []*CustomData
  8064. custom := &CustomData{
  8065. MsgId: "H44022900158202103301714472004",
  8066. PsnNo: "44020000001101329945",
  8067. Info: "2207",
  8068. }
  8069. customData = append(customData, custom)
  8070. custom1 := &CustomData{
  8071. MsgId: "H4402290015820210330172057803",
  8072. PsnNo: "44020000001101161813",
  8073. Info: "2207",
  8074. }
  8075. customData = append(customData, custom1)
  8076. custom2 := &CustomData{
  8077. MsgId: "H44022900158202103301705198813",
  8078. PsnNo: "44190000133097375417",
  8079. Info: "2207",
  8080. }
  8081. customData = append(customData, custom2)
  8082. custom3 := &CustomData{
  8083. MsgId: "H44022900158202103301715524756",
  8084. PsnNo: "44020000001100187221",
  8085. Info: "2207",
  8086. }
  8087. customData = append(customData, custom3)
  8088. custom4 := &CustomData{
  8089. MsgId: "H44022900158202103301730376224",
  8090. PsnNo: "44020000001101959155",
  8091. Info: "2207",
  8092. }
  8093. customData = append(customData, custom4)
  8094. custom5 := &CustomData{
  8095. MsgId: "H44022900158202103301748008725",
  8096. PsnNo: "44020000001104246641",
  8097. Info: "2207",
  8098. }
  8099. customData = append(customData, custom5)
  8100. custom6 := &CustomData{
  8101. MsgId: "H44022900158202103301718096755",
  8102. PsnNo: "44020000001102211860",
  8103. Info: "2207",
  8104. }
  8105. customData = append(customData, custom6)
  8106. custom7 := &CustomData{
  8107. MsgId: "H44022900158202103301736551640",
  8108. PsnNo: "44020000001102687718",
  8109. Info: "2207",
  8110. }
  8111. customData = append(customData, custom7)
  8112. custom8 := &CustomData{
  8113. MsgId: "H44022900158202103301743097676",
  8114. PsnNo: "44020000001102127785",
  8115. Info: "2207",
  8116. }
  8117. customData = append(customData, custom8)
  8118. custom9 := &CustomData{
  8119. MsgId: "H44022900158202103301712304203",
  8120. PsnNo: "44020000001101518097",
  8121. Info: "2207",
  8122. }
  8123. customData = append(customData, custom9)
  8124. custom10 := &CustomData{
  8125. MsgId: "H44022900158202103301738448785",
  8126. PsnNo: "44020000001100500813",
  8127. Info: "2207",
  8128. }
  8129. customData = append(customData, custom10)
  8130. custom11 := &CustomData{
  8131. MsgId: "H44022900158202103301732455843",
  8132. PsnNo: "44020000001102690557",
  8133. Info: "2207",
  8134. }
  8135. customData = append(customData, custom11)
  8136. custom12 := &CustomData{
  8137. MsgId: "H44022900158202103301745421708",
  8138. PsnNo: "44020000001102211928",
  8139. Info: "2207",
  8140. }
  8141. customData = append(customData, custom12)
  8142. custom1212 := &CustomData{
  8143. MsgId: "H440229001582021033017351627",
  8144. PsnNo: "44020000001102481733",
  8145. Info: "2207",
  8146. }
  8147. customData = append(customData, custom1212)
  8148. custom13 := &CustomData{
  8149. MsgId: "H44022900158202103301740327951",
  8150. PsnNo: "44020000001103174866",
  8151. Info: "2207",
  8152. }
  8153. customData = append(customData, custom13)
  8154. custom14 := &CustomData{
  8155. MsgId: "H4402290015820210330174922668",
  8156. PsnNo: "44020000001102927272",
  8157. Info: "2207",
  8158. }
  8159. customData = append(customData, custom14)
  8160. custom15 := &CustomData{
  8161. MsgId: "H44022900158202103301752362273",
  8162. PsnNo: "44020000001102942890",
  8163. Info: "2207",
  8164. }
  8165. customData = append(customData, custom15)
  8166. custom16 := &CustomData{
  8167. MsgId: "H44022900158202103301751082917",
  8168. PsnNo: "44020000001101662162",
  8169. Info: "2207",
  8170. }
  8171. customData = append(customData, custom16)
  8172. custom17 := &CustomData{
  8173. MsgId: "H44022900158202103301754147728",
  8174. PsnNo: "44020000000229014511",
  8175. Info: "2207",
  8176. }
  8177. customData = append(customData, custom17)
  8178. adminUser := c.GetAdminUserInfo()
  8179. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8180. for _, item := range customData {
  8181. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8182. fmt.Println(result)
  8183. }
  8184. }
  8185. func (c *HisApiController) ReversalOtherData() {
  8186. var customData []*CustomData
  8187. custom := &CustomData{
  8188. MsgId: "H44022900158202103301714472004",
  8189. PsnNo: "44020000001101329945",
  8190. Info: "2208",
  8191. }
  8192. customData = append(customData, custom)
  8193. custom1 := &CustomData{
  8194. MsgId: "H4402290015820210330172057803",
  8195. PsnNo: "44020000001101161813",
  8196. Info: "2208",
  8197. }
  8198. customData = append(customData, custom1)
  8199. custom2 := &CustomData{
  8200. MsgId: "H44022900158202103301705198813",
  8201. PsnNo: "44190000133097375417",
  8202. Info: "2208",
  8203. }
  8204. customData = append(customData, custom2)
  8205. custom3 := &CustomData{
  8206. MsgId: "H44022900158202103301715524756",
  8207. PsnNo: "44020000001100187221",
  8208. Info: "2208",
  8209. }
  8210. customData = append(customData, custom3)
  8211. custom4 := &CustomData{
  8212. MsgId: "H44022900158202103301730376224",
  8213. PsnNo: "44020000001101959155",
  8214. Info: "2208",
  8215. }
  8216. customData = append(customData, custom4)
  8217. custom5 := &CustomData{
  8218. MsgId: "H44022900158202103301748008725",
  8219. PsnNo: "44020000001104246641",
  8220. Info: "2208",
  8221. }
  8222. customData = append(customData, custom5)
  8223. custom6 := &CustomData{
  8224. MsgId: "H44022900158202103301718096755",
  8225. PsnNo: "44020000001102211860",
  8226. Info: "2208",
  8227. }
  8228. customData = append(customData, custom6)
  8229. custom7 := &CustomData{
  8230. MsgId: "H44022900158202103301736551640",
  8231. PsnNo: "44020000001102687718",
  8232. Info: "2208",
  8233. }
  8234. customData = append(customData, custom7)
  8235. custom8 := &CustomData{
  8236. MsgId: "H44022900158202103301743097676",
  8237. PsnNo: "44020000001102127785",
  8238. Info: "2208",
  8239. }
  8240. customData = append(customData, custom8)
  8241. custom9 := &CustomData{
  8242. MsgId: "H44022900158202103301712304203",
  8243. PsnNo: "44020000001101518097",
  8244. Info: "2208",
  8245. }
  8246. customData = append(customData, custom9)
  8247. custom10 := &CustomData{
  8248. MsgId: "H44022900158202103301738448785",
  8249. PsnNo: "44020000001100500813",
  8250. Info: "2208",
  8251. }
  8252. customData = append(customData, custom10)
  8253. custom11 := &CustomData{
  8254. MsgId: "H44022900158202103301732455843",
  8255. PsnNo: "44020000001102690557",
  8256. Info: "2208",
  8257. }
  8258. customData = append(customData, custom11)
  8259. custom12 := &CustomData{
  8260. MsgId: "H44022900158202103301745421708",
  8261. PsnNo: "44020000001102211928",
  8262. Info: "2208",
  8263. }
  8264. customData = append(customData, custom12)
  8265. custom1212 := &CustomData{
  8266. MsgId: "H440229001582021033017351627",
  8267. PsnNo: "44020000001102481733",
  8268. Info: "2208",
  8269. }
  8270. customData = append(customData, custom1212)
  8271. custom13 := &CustomData{
  8272. MsgId: "H44022900158202103301740327951",
  8273. PsnNo: "44020000001103174866",
  8274. Info: "2208",
  8275. }
  8276. customData = append(customData, custom13)
  8277. custom14 := &CustomData{
  8278. MsgId: "H4402290015820210330174922668",
  8279. PsnNo: "44020000001102927272",
  8280. Info: "2208",
  8281. }
  8282. customData = append(customData, custom14)
  8283. custom15 := &CustomData{
  8284. MsgId: "H44022900158202103301752362273",
  8285. PsnNo: "44020000001102942890",
  8286. Info: "2208",
  8287. }
  8288. customData = append(customData, custom15)
  8289. custom16 := &CustomData{
  8290. MsgId: "H44022900158202103301751082917",
  8291. PsnNo: "44020000001101662162",
  8292. Info: "2208",
  8293. }
  8294. customData = append(customData, custom16)
  8295. custom17 := &CustomData{
  8296. MsgId: "H44022900158202103301754147728",
  8297. PsnNo: "44020000000229014511",
  8298. Info: "2208",
  8299. }
  8300. customData = append(customData, custom17)
  8301. adminUser := c.GetAdminUserInfo()
  8302. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8303. for _, item := range customData {
  8304. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8305. fmt.Println(result)
  8306. }
  8307. }
  8308. func PathExists(path string) (bool, error) {
  8309. _, err := os.Stat(path)
  8310. if err == nil {
  8311. return true, nil
  8312. }
  8313. if os.IsNotExist(err) {
  8314. return false, nil
  8315. }
  8316. return false, err
  8317. }
  8318. //创建文件夹
  8319. func Mkdir(dir string) {
  8320. // 创建文件夹
  8321. exist, err := PathExists(dir)
  8322. if err != nil {
  8323. fmt.Println(err.Error())
  8324. } else {
  8325. if exist {
  8326. fmt.Println(dir + "文件夹已存在!")
  8327. } else {
  8328. // 文件夹名称,权限
  8329. err := os.Mkdir(dir, os.ModePerm)
  8330. if err != nil {
  8331. fmt.Println(dir+"文件夹创建失败:", err.Error())
  8332. } else {
  8333. fmt.Println(dir + "文件夹创建成功!")
  8334. }
  8335. }
  8336. }
  8337. }
  8338. //压缩文件
  8339. func Zip(srcFile string, destZip string) error {
  8340. zipfile, err := os.Create(destZip)
  8341. if err != nil {
  8342. return err
  8343. }
  8344. defer zipfile.Close()
  8345. archive := zip.NewWriter(zipfile)
  8346. defer archive.Close()
  8347. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  8348. if err != nil {
  8349. return err
  8350. }
  8351. header, err := zip.FileInfoHeader(info)
  8352. if err != nil {
  8353. return err
  8354. }
  8355. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  8356. // header.Name = path
  8357. if info.IsDir() {
  8358. header.Name += "/"
  8359. } else {
  8360. header.Method = zip.Deflate
  8361. }
  8362. writer, err := archive.CreateHeader(header)
  8363. if err != nil {
  8364. return err
  8365. }
  8366. if !info.IsDir() {
  8367. file, err := os.Open(path)
  8368. if err != nil {
  8369. return err
  8370. }
  8371. defer file.Close()
  8372. _, err = io.Copy(writer, file)
  8373. }
  8374. return err
  8375. })
  8376. return err
  8377. }
  8378. func ReadFile(filePath string) []byte {
  8379. f, err := os.Open(filePath)
  8380. if err != nil {
  8381. fmt.Println("read file fail", err)
  8382. return nil
  8383. }
  8384. defer f.Close()
  8385. fd, err := ioutil.ReadAll(f)
  8386. if err != nil {
  8387. fmt.Println("read to fd fail", err)
  8388. return nil
  8389. }
  8390. return fd
  8391. }
  8392. func RemoveRepeatedTeam(arr []*models.HisOrderInfo) (newArr []*models.HisOrderInfo) {
  8393. newArr = make([]*models.HisOrderInfo, 0)
  8394. for i := 0; i < len(arr); i++ {
  8395. repeat := false
  8396. for j := i + 1; j < len(arr); j++ {
  8397. if arr[i].HisPrescriptionProject.TeamId == arr[j].HisPrescriptionProject.TeamId {
  8398. repeat = true
  8399. break
  8400. }
  8401. }
  8402. if !repeat {
  8403. newArr = append(newArr, arr[i])
  8404. }
  8405. }
  8406. return
  8407. }
  8408. func saveRegisterLog(result string) {
  8409. org_id, _ := beego.AppConfig.Int64("org_id")
  8410. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  8411. dir := miConfig.OrgName + "日志"
  8412. utils.Mkdir(dir)
  8413. month := time.Unix(1557042972, 0).Format("1")
  8414. year := time.Now().Format("2006")
  8415. month = time.Now().Format("01")
  8416. day := time.Now().Format("02")
  8417. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  8418. file_name := file + ".txt"
  8419. file_path := miConfig.OrgName + "日志" + "/" + file_name
  8420. exist, _ := utils.PathExists(file_path)
  8421. if exist { //存在
  8422. fmt.Println("存在")
  8423. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  8424. if err != nil {
  8425. fmt.Println("read fail")
  8426. }
  8427. content := "\r\n" + result
  8428. n, _ := f.Seek(0, 2)
  8429. _, err = f.WriteAt([]byte(content), n)
  8430. } else { //不存在
  8431. fmt.Println("文件不存在,创建文件")
  8432. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  8433. defer f.Close()
  8434. if err != nil {
  8435. } else {
  8436. _, err = f.Write([]byte("记录日志"))
  8437. }
  8438. }
  8439. }
  8440. func saveLog(result string, request string, infno string, desc string) {
  8441. org_id, _ := beego.AppConfig.Int64("org_id")
  8442. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  8443. dir := miConfig.OrgName + "日志"
  8444. utils.Mkdir(dir)
  8445. month := time.Unix(1557042972, 0).Format("1")
  8446. year := time.Now().Format("2006")
  8447. month = time.Now().Format("01")
  8448. day := time.Now().Format("02")
  8449. hour := time.Now().Format("15")
  8450. min := time.Now().Format("04")
  8451. sec := time.Now().Format("05")
  8452. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  8453. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  8454. file_name := file + ".txt"
  8455. file_path := miConfig.OrgName + "日志" + "/" + file_name
  8456. exist, _ := utils.PathExists(file_path)
  8457. if exist { //存在
  8458. fmt.Println("存在")
  8459. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  8460. if err != nil {
  8461. fmt.Println("read fail")
  8462. }
  8463. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  8464. n, _ := f.Seek(0, 2)
  8465. _, err = f.WriteAt([]byte(content), n)
  8466. } else { //不存在
  8467. fmt.Println("文件不存在,创建文件")
  8468. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  8469. defer f.Close()
  8470. if err != nil {
  8471. } else {
  8472. _, err = f.Write([]byte("记录日志"))
  8473. }
  8474. }
  8475. }
  8476. type Charset string
  8477. const (
  8478. UTF8 = Charset("UTF-8")
  8479. GB18030 = Charset("GB18030")
  8480. )
  8481. func ConvertToString(src string, srcCode string, tagCode string) string {
  8482. srcCoder := mahonia.NewDecoder(srcCode)
  8483. srcResult := srcCoder.ConvertString(src)
  8484. tagCoder := mahonia.NewDecoder(tagCode)
  8485. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  8486. result := string(cdata)
  8487. return result
  8488. }