his_api_controller.go 335KB

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