his_api_controller.go 397KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833
  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/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. }
  73. func (c *HisApiController) GetPsnNcdsInfo() {
  74. admin_user_id, _ := c.GetInt64("admin_user_id")
  75. patient_id, _ := c.GetInt64("patient_id")
  76. id, _ := c.GetInt64("id")
  77. adminUser := c.GetAdminUserInfo()
  78. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  79. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  80. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  81. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  82. psn_record, _ := service.GetPsnNCDSRecordById(id)
  83. //
  84. //if psn_record.ID == 0 {
  85. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  86. // return
  87. //}
  88. var res Result5301
  89. var res10265 Result5301For10265
  90. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  91. psn_info, _ := service.GetPsnByPatientId(patient_id)
  92. var api string
  93. if miConfig.MdtrtareaAdmvs == "320921" {
  94. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  95. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  96. } else {
  97. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  98. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  99. }
  100. resp, requestErr := http.Get(api)
  101. if requestErr != nil {
  102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  103. return
  104. }
  105. body, ioErr := ioutil.ReadAll(resp.Body)
  106. if ioErr != nil {
  107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  109. return
  110. }
  111. var respJSON map[string]interface{}
  112. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  115. return
  116. }
  117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  118. result, _ := json.Marshal(respJSON)
  119. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  120. utils.ErrorLog("解析失败:%v", err)
  121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  122. return
  123. }
  124. res.ErrMsg = res10265.ErrMsg
  125. res.Output = res10265.Output
  126. res.InfRefmsgid = res10265.InfRefmsgid
  127. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  128. res.Infcode = infocode
  129. } else {
  130. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  131. var dat map[string]interface{}
  132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  133. fmt.Println(dat)
  134. } else {
  135. fmt.Println(err)
  136. }
  137. userJSONBytes, _ := json.Marshal(dat)
  138. if miConfig.Code == "H15049901371" {
  139. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  140. utils.ErrorLog("解析失败:%v", err)
  141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  142. return
  143. }
  144. res.InfRefmsgid = res10265.InfRefmsgid
  145. res.Output = res10265.Output
  146. res.ErrMsg = res10265.ErrMsg
  147. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  148. res.Infcode = infocode
  149. } else {
  150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  151. utils.ErrorLog("解析失败:%v", err)
  152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  153. return
  154. }
  155. }
  156. }
  157. if res.Infcode == 0 {
  158. c.ServeSuccessJSON(map[string]interface{}{
  159. "result": res.Output.Result,
  160. })
  161. }
  162. }
  163. func (c *HisApiController) CheckInsutype() {
  164. his_patient_id, _ := c.GetInt64("his_patient_id")
  165. admin_user_id, _ := c.GetInt64("admin_user_id")
  166. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  167. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  168. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  169. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  170. var dat map[string]interface{}
  171. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  172. fmt.Println(dat)
  173. } else {
  174. fmt.Println(err)
  175. }
  176. userJSONBytes, _ := json.Marshal(dat)
  177. var res Result90100
  178. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  179. utils.ErrorLog("解析失败:%v", err)
  180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  181. return
  182. }
  183. if res.Infcode != 0 {
  184. c.ServeSuccessJSON(map[string]interface{}{
  185. "failed_code": -10,
  186. "msg": res.ErrMsg,
  187. })
  188. return
  189. } else {
  190. fmt.Println(res)
  191. }
  192. }
  193. func (c *HisApiController) CheckCardPWD() {
  194. card_pwd := c.GetString("card_pwd")
  195. his_patient_id, _ := c.GetInt64("his_patient_id")
  196. admin_user_id, _ := c.GetInt64("admin_user_id")
  197. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  198. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  199. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  200. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  201. var dat map[string]interface{}
  202. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  203. fmt.Println(dat)
  204. } else {
  205. fmt.Println(err)
  206. }
  207. userJSONBytes, _ := json.Marshal(dat)
  208. var res Result90991
  209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  210. utils.ErrorLog("解析失败:%v", err)
  211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  212. return
  213. }
  214. if res.Infcode != 0 {
  215. c.ServeSuccessJSON(map[string]interface{}{
  216. "failed_code": -10,
  217. "msg": res.ErrMsg,
  218. })
  219. return
  220. } else {
  221. if res.Output.Result.CheckStat == "0" {
  222. var msg string
  223. switch res.Output.Result.CardStat {
  224. case "00":
  225. msg = "未激活"
  226. break
  227. case "10":
  228. msg = "激活"
  229. break
  230. case "20":
  231. msg = "窗口挂失"
  232. break
  233. case "21":
  234. msg = "电话挂失"
  235. break
  236. case "22":
  237. msg = "单位网上申报挂失"
  238. break
  239. case "23":
  240. msg = "保健办挂失"
  241. break
  242. case "24":
  243. msg = "个人网上挂失"
  244. break
  245. case "25":
  246. msg = "网上服务大厅挂失"
  247. break
  248. case "30":
  249. msg = "注销"
  250. break
  251. case "40":
  252. msg = "回收"
  253. break
  254. case "99":
  255. msg = "制卡中(无效卡)"
  256. break
  257. }
  258. c.ServeSuccessJSON(map[string]interface{}{
  259. "failed_code": -10,
  260. "msg": msg,
  261. })
  262. return
  263. } else {
  264. c.ServeSuccessJSON(map[string]interface{}{
  265. "msg": "校验成功",
  266. })
  267. return
  268. }
  269. }
  270. }
  271. func (c *HisApiController) ReadCard() {
  272. id_card_type, _ := c.GetInt64("id_card_type")
  273. admin_user_id, _ := c.GetInt64("admin_user_id")
  274. certificates, _ := c.GetInt64("certificates")
  275. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  276. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  277. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  278. switch id_card_type {
  279. case 1:
  280. if miConfig.MdtrtareaAdmvs == "421300" {
  281. var res ResultTwo
  282. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  283. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  284. "&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)
  285. resp, requestErr := http.Get(api)
  286. if requestErr != nil {
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  288. return
  289. }
  290. body, ioErr := ioutil.ReadAll(resp.Body)
  291. if ioErr != nil {
  292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  294. return
  295. }
  296. var respJSON map[string]interface{}
  297. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  300. return
  301. }
  302. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  303. result, _ := json.Marshal(respJSON)
  304. fmt.Println("log")
  305. fmt.Println(string(result))
  306. if err := json.Unmarshal([]byte(result), &res); err != nil {
  307. utils.ErrorLog("解析失败:%v", err)
  308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  309. return
  310. }
  311. if res.Infcode == 0 {
  312. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  313. if err == gorm.ErrRecordNotFound {
  314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  315. return
  316. } else if err != nil {
  317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  318. return
  319. } else {
  320. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  321. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  322. infoStr := string(Iinfos)
  323. idetinfoStr := string(Idetinfos)
  324. psn := &models.HisPsn{
  325. PsnNo: res.Output.Baseinfo.PsnNo,
  326. Age: res.Output.Baseinfo.Age,
  327. PatientId: patient.ID,
  328. Certno: res.Output.Baseinfo.Certno,
  329. Brdy: res.Output.Baseinfo.Brdy,
  330. Gend: res.Output.Baseinfo.Gend,
  331. Naty: res.Output.Baseinfo.Naty,
  332. PsnCertType: res.Output.Baseinfo.PsnCertType,
  333. PsnName: res.Output.Baseinfo.PsnName,
  334. Idetinfo: idetinfoStr,
  335. Insuinfo: infoStr,
  336. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  337. }
  338. service.CreateHisPsn(psn)
  339. c.ServeSuccessJSON(map[string]interface{}{
  340. "patient": patient,
  341. "number": res.Output.Baseinfo.Certno,
  342. })
  343. }
  344. } else {
  345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  346. return
  347. }
  348. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  349. var api string
  350. if miConfig.MdtrtareaAdmvs == "320921" {
  351. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  352. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  353. fmt.Println(api)
  354. } else {
  355. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  356. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  357. }
  358. resp, requestErr := http.Get(api)
  359. if requestErr != nil {
  360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  361. return
  362. }
  363. body, ioErr := ioutil.ReadAll(resp.Body)
  364. if ioErr != nil {
  365. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  367. return
  368. }
  369. var respJSON map[string]interface{}
  370. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  373. return
  374. }
  375. var status string
  376. status = respJSON["data"].(map[string]interface{})["status"].(string)
  377. fmt.Println(respJSON["data"])
  378. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  379. //console.log()
  380. fmt.Println("type===")
  381. fmt.Println(card_type)
  382. var token string
  383. var res ResultTwo //1101结果
  384. var res10265 ResultTwo10265 //1101结果
  385. var card_info string //卡信息
  386. var busi_card_info string
  387. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  388. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  389. if status == "0" { //读卡成功
  390. if card_type == "1" {
  391. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  392. result, _ := json.Marshal(respJSON)
  393. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  394. utils.ErrorLog("解析失败:%v", err)
  395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  396. return
  397. }
  398. res.ErrMsg = res10265.ErrMsg
  399. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  400. res.Infcode = infocode
  401. res.Output = res10265.Output
  402. res.InfRefmsgid = res10265.InfRefmsgid
  403. } else {
  404. //var card_info string //卡信息
  405. //var busi_card_info string
  406. token = respJSON["data"].(map[string]interface{})["token"].(string)
  407. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  408. //fmt.Println(card_info)
  409. //fmt.Println(busi_card_info)
  410. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  411. result, _ := json.Marshal(respJSON)
  412. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  413. utils.ErrorLog("解析失败:%v", err)
  414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  415. return
  416. }
  417. res.ErrMsg = res10265.ErrMsg
  418. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  419. res.Infcode = infocode
  420. res.Output = res10265.Output
  421. res.InfRefmsgid = res10265.InfRefmsgid
  422. }
  423. if res.Infcode == 0 {
  424. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  425. if err == gorm.ErrRecordNotFound {
  426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  427. return
  428. } else if err != nil {
  429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  430. return
  431. } else {
  432. if card_type == "1" {
  433. bas := strings.Split(card_info, "|")
  434. basNumber := bas[2]
  435. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  436. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  437. infoStr := string(Iinfos)
  438. idetinfoStr := string(Idetinfos)
  439. psn := &models.HisPsn{
  440. PsnNo: res.Output.Baseinfo.PsnNo,
  441. Age: res.Output.Baseinfo.Age,
  442. PatientId: patient.ID,
  443. Certno: res.Output.Baseinfo.Certno,
  444. Brdy: res.Output.Baseinfo.Brdy,
  445. Gend: res.Output.Baseinfo.Gend,
  446. Naty: res.Output.Baseinfo.Naty,
  447. PsnCertType: res.Output.Baseinfo.PsnCertType,
  448. PsnName: res.Output.Baseinfo.PsnName,
  449. Idetinfo: idetinfoStr,
  450. Insuinfo: infoStr,
  451. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  452. CardInfo: card_info,
  453. VerifyNumber: busi_card_info,
  454. }
  455. service.CreateHisPsn(psn)
  456. c.ServeSuccessJSON(map[string]interface{}{
  457. "patient": patient,
  458. "number": basNumber,
  459. })
  460. } else {
  461. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  462. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  463. infoStr := string(Iinfos)
  464. idetinfoStr := string(Idetinfos)
  465. psn := &models.HisPsn{
  466. PsnNo: res.Output.Baseinfo.PsnNo,
  467. Age: res.Output.Baseinfo.Age,
  468. PatientId: patient.ID,
  469. Certno: res.Output.Baseinfo.Certno,
  470. Brdy: res.Output.Baseinfo.Brdy,
  471. Gend: res.Output.Baseinfo.Gend,
  472. Naty: res.Output.Baseinfo.Naty,
  473. PsnCertType: res.Output.Baseinfo.PsnCertType,
  474. PsnName: res.Output.Baseinfo.PsnName,
  475. Idetinfo: idetinfoStr,
  476. Insuinfo: infoStr,
  477. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  478. CardInfo: card_info,
  479. VerifyNumber: token,
  480. }
  481. service.CreateHisPsn(psn)
  482. c.ServeSuccessJSON(map[string]interface{}{
  483. "patient": patient,
  484. "number": token,
  485. })
  486. }
  487. }
  488. } else {
  489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  490. return
  491. }
  492. } else { //读卡失败
  493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  494. return
  495. }
  496. } else {
  497. if initFlag == 0 {
  498. c.TestGetBasBaseInit()
  499. }
  500. basStr := c.GetBasBaseInfo()
  501. if len(basStr) == 0 {
  502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  503. return
  504. }
  505. fmt.Println(basStr)
  506. bas := strings.Split(basStr, "|")
  507. basNumber := bas[1]
  508. fmt.Println(basNumber)
  509. card_sn := bas[3]
  510. fmt.Println(card_sn)
  511. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  512. var dat map[string]interface{}
  513. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  514. fmt.Println(dat)
  515. } else {
  516. fmt.Println(err)
  517. }
  518. userJSONBytes, _ := json.Marshal(dat)
  519. var res ResultTwo
  520. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  521. utils.ErrorLog("解析失败:%v", err)
  522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  523. return
  524. }
  525. if res.Infcode == 0 {
  526. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  527. if err == gorm.ErrRecordNotFound {
  528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  529. return
  530. } else if err != nil {
  531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  532. return
  533. } else {
  534. c.ServeSuccessJSON(map[string]interface{}{
  535. "patient": patient,
  536. "number": basNumber,
  537. })
  538. }
  539. } else {
  540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  541. return
  542. }
  543. break
  544. }
  545. case 2:
  546. SFZStr := c.GetSFZBaseInfo()
  547. id_card_str := strings.Split(SFZStr, "^")
  548. id_card_number := id_card_str[0]
  549. card_sn := ""
  550. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  551. var dat map[string]interface{}
  552. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  553. fmt.Println(dat)
  554. } else {
  555. fmt.Println(err)
  556. }
  557. userJSONBytes, _ := json.Marshal(dat)
  558. var res ResultTwo
  559. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  560. utils.ErrorLog("解析失败:%v", err)
  561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  562. return
  563. }
  564. if res.Infcode == 0 {
  565. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  566. if err == gorm.ErrRecordNotFound {
  567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  568. return
  569. } else if err != nil {
  570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  571. return
  572. } else {
  573. c.ServeSuccessJSON(map[string]interface{}{
  574. "patient": patient,
  575. "number": id_card_number,
  576. })
  577. }
  578. } else {
  579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  580. return
  581. }
  582. break
  583. case 3:
  584. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  585. var api string
  586. if miConfig.MdtrtareaAdmvs == "320921" {
  587. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  588. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  589. fmt.Println(api)
  590. } else {
  591. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  592. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  593. }
  594. resp, requestErr := http.Get(api)
  595. if requestErr != nil {
  596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  597. return
  598. }
  599. body, ioErr := ioutil.ReadAll(resp.Body)
  600. if ioErr != nil {
  601. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  603. return
  604. }
  605. var respJSON map[string]interface{}
  606. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  607. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  609. return
  610. }
  611. var status string
  612. status = respJSON["data"].(map[string]interface{})["status"].(string)
  613. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  614. var token string
  615. var res ResultTwo //1101结果
  616. var res10265 ResultTwo10265 //1101结果
  617. var card_info string //卡信息
  618. var busi_card_info string
  619. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  620. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  621. if status == "0" { //读卡成功
  622. if card_type == "1" {
  623. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  624. result, _ := json.Marshal(respJSON)
  625. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  626. utils.ErrorLog("解析失败:%v", err)
  627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  628. return
  629. }
  630. res.ErrMsg = res10265.ErrMsg
  631. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  632. res.Infcode = infocode
  633. res.Output = res10265.Output
  634. res.InfRefmsgid = res10265.InfRefmsgid
  635. } else {
  636. //var card_info string //卡信息
  637. //var busi_card_info string
  638. token = respJSON["data"].(map[string]interface{})["token"].(string)
  639. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  640. //fmt.Println(card_info)
  641. //fmt.Println(busi_card_info)
  642. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  643. result, _ := json.Marshal(respJSON)
  644. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  645. utils.ErrorLog("解析失败:%v", err)
  646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  647. return
  648. }
  649. res.ErrMsg = res10265.ErrMsg
  650. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  651. res.Infcode = infocode
  652. res.Output = res10265.Output
  653. res.InfRefmsgid = res10265.InfRefmsgid
  654. }
  655. if res.Infcode == 0 {
  656. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  657. if err == gorm.ErrRecordNotFound {
  658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  659. return
  660. } else if err != nil {
  661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  662. return
  663. } else {
  664. if card_type == "1" {
  665. bas := strings.Split(card_info, "|")
  666. basNumber := bas[2]
  667. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  668. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  669. infoStr := string(Iinfos)
  670. idetinfoStr := string(Idetinfos)
  671. psn := &models.HisPsn{
  672. PsnNo: res.Output.Baseinfo.PsnNo,
  673. Age: res.Output.Baseinfo.Age,
  674. PatientId: patient.ID,
  675. Certno: res.Output.Baseinfo.Certno,
  676. Brdy: res.Output.Baseinfo.Brdy,
  677. Gend: res.Output.Baseinfo.Gend,
  678. Naty: res.Output.Baseinfo.Naty,
  679. PsnCertType: res.Output.Baseinfo.PsnCertType,
  680. PsnName: res.Output.Baseinfo.PsnName,
  681. Idetinfo: idetinfoStr,
  682. Insuinfo: infoStr,
  683. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  684. CardInfo: card_info,
  685. VerifyNumber: busi_card_info,
  686. }
  687. service.CreateHisPsn(psn)
  688. c.ServeSuccessJSON(map[string]interface{}{
  689. "patient": patient,
  690. "number": basNumber,
  691. })
  692. } else {
  693. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  694. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  695. infoStr := string(Iinfos)
  696. idetinfoStr := string(Idetinfos)
  697. psn := &models.HisPsn{
  698. PsnNo: res.Output.Baseinfo.PsnNo,
  699. Age: res.Output.Baseinfo.Age,
  700. PatientId: patient.ID,
  701. Certno: res.Output.Baseinfo.Certno,
  702. Brdy: res.Output.Baseinfo.Brdy,
  703. Gend: res.Output.Baseinfo.Gend,
  704. Naty: res.Output.Baseinfo.Naty,
  705. PsnCertType: res.Output.Baseinfo.PsnCertType,
  706. PsnName: res.Output.Baseinfo.PsnName,
  707. Idetinfo: idetinfoStr,
  708. Insuinfo: infoStr,
  709. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  710. CardInfo: card_info,
  711. VerifyNumber: token,
  712. }
  713. service.CreateHisPsn(psn)
  714. c.ServeSuccessJSON(map[string]interface{}{
  715. "patient": patient,
  716. "number": token,
  717. })
  718. }
  719. }
  720. } else {
  721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  722. return
  723. }
  724. } else { //读卡失败
  725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  726. return
  727. }
  728. }
  729. break
  730. }
  731. }
  732. var initFlag int64 = 0
  733. func (c *HisApiController) TestGetBasBaseInit() {
  734. DllDef := syscall.MustLoadDLL("SSCard.dll")
  735. Iinit := DllDef.MustFindProc("Init")
  736. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  737. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  738. if ret != 0 {
  739. fmt.Println("SSCard的报错原因:", err)
  740. fmt.Println("SSCard的运算结果为:", ret)
  741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  742. return
  743. }
  744. result := int(ret)
  745. fmt.Println("SSCard的运算结果为1:", result)
  746. initFlag = 1
  747. return
  748. }
  749. func (c *HisApiController) GetSFZBaseInfo() string {
  750. DllDef := syscall.MustLoadDLL("SSCard.dll")
  751. readCard := DllDef.MustFindProc("ReadSFZ")
  752. if readCard == nil {
  753. fmt.Println("readcard is nil")
  754. readCard = DllDef.MustFindProc("ReadSFZ")
  755. }
  756. str := make([]byte, 256)
  757. str1 := make([]byte, 256)
  758. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  759. fmt.Println(r)
  760. return string(str)
  761. }
  762. func (c *HisApiController) GetBasBaseInfo() string {
  763. DllDef := syscall.MustLoadDLL("SSCard.dll")
  764. readCard := DllDef.MustFindProc("ReadCardBas")
  765. if readCard == nil {
  766. fmt.Println("readcard is nil")
  767. readCard = DllDef.MustFindProc("ReadCardBas")
  768. }
  769. str := make([]byte, 1024)
  770. str1 := make([]byte, 1024)
  771. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  772. fmt.Println(string(str1))
  773. fmt.Println(string(str))
  774. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  775. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  776. if ret2 != 0 {
  777. return ""
  778. }
  779. return string(str)
  780. }
  781. type CustomFundPay struct {
  782. FundPayType string `json:"fund_pay_type"`
  783. FundPayamt float64 `json:"fund_payamt"`
  784. }
  785. func (c *HisApiController) GetSettleList() {
  786. order_id, _ := c.GetInt64("order_id")
  787. admin_user_id, _ := c.GetInt64("admin_user_id")
  788. order, _ := service.GetHisOrderByIDTwo(order_id)
  789. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  790. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  791. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  792. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  793. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  794. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  795. if order.ID == 0 {
  796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  797. return
  798. }
  799. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  800. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  801. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  802. fmt.Println(count)
  803. var zero string
  804. number := count + 1
  805. if number >= 1000 {
  806. zero = "0000" + strconv.FormatInt(number, 10)
  807. } else if number >= 10000 {
  808. zero = "000" + strconv.FormatInt(number, 10)
  809. } else if number >= 100000 {
  810. zero = "00" + strconv.FormatInt(number, 10)
  811. } else if number >= 1000000 {
  812. zero = "0" + strconv.FormatInt(number, 10)
  813. } else {
  814. zero = strconv.FormatInt(number, 10)
  815. }
  816. fmt.Println(zero)
  817. struct4101 := service.Struct4101{
  818. PsnNo: order.PsnNo,
  819. MdtrtId: order.MdtrtId,
  820. SetlId: order.SetlId,
  821. PsnName: order.PsnName,
  822. Gend: order.Gend,
  823. Brdy: his.Brdy,
  824. Age: his.Age,
  825. Naty: order.Naty,
  826. PatnCertType: "01",
  827. Certno: order.Certno,
  828. Prfs: "90",
  829. ConerName: roles[0].UserName,
  830. PatnRlts: "99",
  831. ConerAddr: miConfig.OrgName,
  832. ConerTel: admin.Mobile,
  833. HiType: order.Insutype,
  834. Insuplc: miConfig.InsuplcAdmdvs,
  835. MaindiagFlag: "1",
  836. BillCode: last_order.FaPiaoCode,
  837. BillNo: zero,
  838. BizSn: order.Number,
  839. PsnSelfPay: order.PsnPartAmt,
  840. PsnOwnPay: order.PsnPartAmt,
  841. AcctPay: order.AcctPay,
  842. PsnCashpay: order.PsnCashPay,
  843. HiPaymtd: "1",
  844. Hsorg: miConfig.InsuplcAdmdvs,
  845. HsorgOpter: miConfig.InsuplcAdmdvs,
  846. MedinsFillPsn: curRoles.UserName,
  847. MedinsFillDept: depart.Name,
  848. IptMedType: "2",
  849. }
  850. struct4101.SetlBegnDate = order.SetlTime
  851. struct4101.SetlEndDate = order.SetlTime
  852. time_arr := strings.Split(order.SetlTime, " ")
  853. struct4101.AdmTime = time_arr[0]
  854. struct4101.AdmEndTime = time_arr[0]
  855. var rf []CustomFundPay
  856. json.Unmarshal([]byte(order.SetlDetail), &rf)
  857. var tempFunPays []service.CustomStruct
  858. for _, item := range rf {
  859. var tempFunPay service.CustomStruct
  860. tempFunPay.FundPayamt = item.FundPayamt
  861. tempFunPay.FundPayType = item.FundPayType
  862. tempFunPays = append(tempFunPays, tempFunPay)
  863. }
  864. struct4101.CustomStruct = tempFunPays
  865. var tempDiaginfos []service.DiaginfoStructTwo
  866. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  867. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  868. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  869. var config []*models.HisXtDiagnoseConfig
  870. for _, item := range diagnosis_ids {
  871. id, _ := strconv.ParseInt(item, 10, 64)
  872. diagnosisConfig, _ := service.FindDiagnoseById(id)
  873. config = append(config, &diagnosisConfig)
  874. }
  875. for index, item := range config {
  876. if index == 0 {
  877. var tempDiaginfo service.DiaginfoStructTwo
  878. tempDiaginfo.DiagCode = item.CountryCode
  879. tempDiaginfo.DiagName = item.CountryContentName
  880. tempDiaginfo.DiagType = "1"
  881. tempDiaginfo.MaindiagFlag = "1"
  882. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  883. } else {
  884. var tempDiaginfo service.DiaginfoStructTwo
  885. tempDiaginfo.DiagCode = item.CountryCode
  886. tempDiaginfo.DiagName = item.CountryContentName
  887. tempDiaginfo.DiagType = "2"
  888. tempDiaginfo.MaindiagFlag = "0"
  889. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  890. }
  891. }
  892. struct4101.Diseinfo = tempDiaginfos
  893. sickConfigTwo, _ := service.FindSickById(his.SickType)
  894. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  895. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  896. tempOpspdiseinfo2.OprnOprtCode = ""
  897. tempOpspdiseinfo2.OprnOprtName = ""
  898. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  899. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  900. var iteminfo service.IteminfoStruct
  901. var bedCostTotal float64 = 0 //床位总费
  902. var bedCostSelfTotal float64 = 0 //床位自费
  903. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  904. var operationCostTotal float64 = 0 //手术费
  905. var operationCostSelfTotal float64 = 0 //手术费
  906. var operationCostPartSelfTotal float64 = 0 //手术费
  907. var otherCostTotal float64 = 0 //其他费用
  908. var otherCostSelfTotal float64 = 0 //其他费用
  909. var otherCostPartSelfTotal float64 = 0 //其他费用
  910. var materialCostTotal float64 = 0 //材料费
  911. var materialCostSelfTotal float64 = 0 //材料费
  912. var materialCostPartSelfTotal float64 = 0 //材料费
  913. var westernMedicineCostTotal float64 = 0 //西药费
  914. var westernMedicineCostSelfTotal float64 = 0 //西药费
  915. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  916. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  917. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  918. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  919. var checkCostTotal float64 = 0 //检查费
  920. var checkCostSelfTotal float64 = 0 //检查费
  921. var checkCostPartSelfTotal float64 = 0 //检查费
  922. var laboratoryCostTotal float64 = 0 //化验费
  923. var laboratoryCostSelfTotal float64 = 0 //化验费
  924. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  925. var treatCostTotal float64 = 0 //治疗费用
  926. var treatCostSelfTotal float64 = 0 //治疗费用
  927. var treatCostPartSelfTotal float64 = 0 //治疗费用
  928. decimal.DivisionPrecision = 2
  929. var bed_fulamt_ownpay_amt float64 = 0
  930. var operation_fulamt_ownpay_amt float64 = 0
  931. var other_fulamt_ownpay_amt float64 = 0
  932. var westernMedicine_fulamt_ownpay_amt float64 = 0
  933. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  934. var check_fulamt_ownpay_amt float64 = 0
  935. var material_fulamt_ownpay_amt float64 = 0
  936. var laboratory_fulamt_ownpay_amt float64 = 0
  937. var treat_fulamt_ownpay_amt float64 = 0
  938. var bed_claa_sunmfee float64 = 0
  939. var bed_clab_amt float64 = 0
  940. var bed_other_amt float64 = 0
  941. var operation_claa_sunmfee float64 = 0
  942. var operation_clab_amt float64 = 0
  943. var operation_other_amt float64 = 0
  944. var other_claa_sunmfee float64 = 0
  945. var other_clab_amt float64 = 0
  946. var other_other_amt float64 = 0
  947. var westernMedicine_claa_sunmfee float64 = 0
  948. var westernMedicine_clab_amt float64 = 0
  949. var westernMedicine_other_amt float64 = 0
  950. var chineseTraditional_claa_sunmfee float64 = 0
  951. var chineseTraditional_clab_amt float64 = 0
  952. var chineseTraditional_other_amt float64 = 0
  953. var check_claa_sunmfee float64 = 0
  954. var check_clab_amt float64 = 0
  955. var check_other_amt float64 = 0
  956. var material_claa_sunmfee float64 = 0
  957. var material_clab_amt float64 = 0
  958. var material_other_amt float64 = 0
  959. var laboratory_claa_sunmfee float64 = 0
  960. var laboratory_clab_amt float64 = 0
  961. var laboratory_other_amt float64 = 0
  962. var treat_claa_sunmfee float64 = 0
  963. var treat_clab_amt float64 = 0
  964. var treat_other_amt float64 = 0
  965. for _, item := range order.HisOrderInfo {
  966. if item.MedChrgitmType == "01" { //床位费
  967. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  968. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  969. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  970. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  971. if item.ChrgitmLv == "1" {
  972. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  973. }
  974. if item.ChrgitmLv == "2" {
  975. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  976. }
  977. if item.ChrgitmLv == "3" {
  978. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  979. }
  980. }
  981. if item.MedChrgitmType == "03" { //检查费
  982. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  983. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  984. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  985. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  986. if item.ChrgitmLv == "1" {
  987. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  988. }
  989. if item.ChrgitmLv == "2" {
  990. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  991. }
  992. if item.ChrgitmLv == "3" {
  993. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  994. }
  995. }
  996. if item.MedChrgitmType == "04" { //化验费
  997. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  998. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  999. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1000. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1001. if item.ChrgitmLv == "1" {
  1002. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1003. }
  1004. if item.ChrgitmLv == "2" {
  1005. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1006. }
  1007. if item.ChrgitmLv == "3" {
  1008. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1009. }
  1010. }
  1011. if item.MedChrgitmType == "05" { //治疗费
  1012. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1013. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1014. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1015. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1016. if item.ChrgitmLv == "1" {
  1017. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1018. }
  1019. if item.ChrgitmLv == "2" {
  1020. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1021. }
  1022. if item.ChrgitmLv == "3" {
  1023. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1024. }
  1025. }
  1026. if item.MedChrgitmType == "06" { //手术费
  1027. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1028. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1029. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1030. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1031. if item.ChrgitmLv == "1" {
  1032. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1033. }
  1034. if item.ChrgitmLv == "2" {
  1035. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1036. }
  1037. if item.ChrgitmLv == "3" {
  1038. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1039. }
  1040. }
  1041. if item.MedChrgitmType == "08" { //材料费
  1042. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1043. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1044. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1045. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1046. if item.ChrgitmLv == "1" {
  1047. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1048. }
  1049. if item.ChrgitmLv == "2" {
  1050. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1051. }
  1052. if item.ChrgitmLv == "3" {
  1053. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1054. }
  1055. }
  1056. if item.MedChrgitmType == "09" { //西药费
  1057. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1058. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1059. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1060. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1061. if item.ChrgitmLv == "1" {
  1062. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1063. }
  1064. if item.ChrgitmLv == "2" {
  1065. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1066. }
  1067. if item.ChrgitmLv == "3" {
  1068. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1069. }
  1070. }
  1071. if item.MedChrgitmType == "11" { //中成费
  1072. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1073. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1074. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1075. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1076. if item.ChrgitmLv == "1" {
  1077. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1078. }
  1079. if item.ChrgitmLv == "2" {
  1080. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1081. }
  1082. if item.ChrgitmLv == "3" {
  1083. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1084. }
  1085. }
  1086. if item.MedChrgitmType == "14" { //其他费
  1087. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1088. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1089. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1090. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1091. if item.ChrgitmLv == "1" {
  1092. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1093. }
  1094. if item.ChrgitmLv == "2" {
  1095. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1096. }
  1097. if item.ChrgitmLv == "3" {
  1098. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1099. }
  1100. }
  1101. }
  1102. var iteminfoStructs []service.IteminfoStruct
  1103. if bedCostTotal != 0 {
  1104. iteminfo.MedChrgitm = "01"
  1105. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1106. iteminfo.Amt = bedCostTotal
  1107. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1108. iteminfo.ClabAmt = bed_clab_amt
  1109. iteminfo.OthAmt = bed_other_amt
  1110. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1111. }
  1112. if checkCostTotal != 0 {
  1113. iteminfo.MedChrgitm = "03"
  1114. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1115. iteminfo.Amt = checkCostTotal
  1116. iteminfo.ClaaSumfee = check_claa_sunmfee
  1117. iteminfo.ClabAmt = check_clab_amt
  1118. iteminfo.OthAmt = check_other_amt
  1119. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1120. }
  1121. if laboratoryCostTotal != 0 {
  1122. iteminfo.MedChrgitm = "04"
  1123. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1124. iteminfo.Amt = laboratoryCostTotal
  1125. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1126. iteminfo.ClabAmt = laboratory_clab_amt
  1127. iteminfo.OthAmt = laboratory_other_amt
  1128. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1129. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1130. }
  1131. if treatCostTotal != 0 {
  1132. iteminfo.MedChrgitm = "05"
  1133. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1134. iteminfo.Amt = treatCostTotal
  1135. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1136. iteminfo.ClabAmt = treat_clab_amt
  1137. iteminfo.OthAmt = treat_other_amt
  1138. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1139. //(struct4101.IteminfoStruct, iteminfo)
  1140. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1141. }
  1142. if operationCostTotal != 0 {
  1143. iteminfo.MedChrgitm = "06"
  1144. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1145. iteminfo.Amt = operationCostTotal
  1146. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1147. iteminfo.ClabAmt = operation_clab_amt
  1148. iteminfo.OthAmt = operation_other_amt
  1149. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1150. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1151. }
  1152. if materialCostTotal != 0 {
  1153. iteminfo.MedChrgitm = "08"
  1154. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1155. iteminfo.Amt = materialCostTotal
  1156. iteminfo.ClaaSumfee = material_claa_sunmfee
  1157. iteminfo.ClabAmt = material_clab_amt
  1158. iteminfo.OthAmt = material_other_amt
  1159. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1160. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1161. }
  1162. if westernMedicineCostTotal != 0 {
  1163. iteminfo.MedChrgitm = "09"
  1164. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1165. iteminfo.Amt = westernMedicineCostTotal
  1166. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1167. iteminfo.ClabAmt = westernMedicine_clab_amt
  1168. iteminfo.OthAmt = westernMedicine_other_amt
  1169. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1170. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1171. }
  1172. if chineseTraditionalMedicineCostTotal != 0 {
  1173. iteminfo.MedChrgitm = "11"
  1174. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1175. iteminfo.Amt = westernMedicineCostTotal
  1176. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1177. iteminfo.ClabAmt = westernMedicine_clab_amt
  1178. iteminfo.OthAmt = westernMedicine_other_amt
  1179. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1180. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1181. }
  1182. if otherCostTotal != 0 {
  1183. iteminfo.MedChrgitm = "14"
  1184. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1185. iteminfo.Amt = otherCostTotal
  1186. iteminfo.ClaaSumfee = other_claa_sunmfee
  1187. iteminfo.ClabAmt = other_clab_amt
  1188. iteminfo.OthAmt = other_other_amt
  1189. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1190. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1191. }
  1192. struct4101.IteminfoStruct = iteminfoStructs
  1193. struct4101.Ntly = "中国"
  1194. struct4101.AdmCaty = "A03.06"
  1195. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1196. fmt.Println(result)
  1197. var dat map[string]interface{}
  1198. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1199. fmt.Println(dat)
  1200. } else {
  1201. fmt.Println(err)
  1202. }
  1203. userJSONBytes, _ := json.Marshal(dat)
  1204. var res ResultSeventeen
  1205. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1206. utils.ErrorLog("解析失败:%v", err)
  1207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1208. return
  1209. }
  1210. if res.Infcode != 0 {
  1211. c.ServeSuccessJSON(map[string]interface{}{
  1212. "failed_code": -10,
  1213. "msg": res.ErrMsg,
  1214. })
  1215. return
  1216. } else {
  1217. order.FaPiaoNumber = zero
  1218. order.FaPiaoCode = last_order.FaPiaoCode
  1219. service.UpdateOrder(order)
  1220. hisFundSettleListResult := &models.HisFundSettleListResult{
  1221. Number: res.Output.SetlListId,
  1222. Status: 1,
  1223. Ctime: time.Now().Unix(),
  1224. Mtime: time.Now().Unix(),
  1225. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1226. IsUpload: 1,
  1227. OrderId: order_id,
  1228. }
  1229. service.CreateUploadRecord(hisFundSettleListResult)
  1230. c.ServeSuccessJSON(map[string]interface{}{
  1231. "msg": "上传成功",
  1232. "result": hisFundSettleListResult,
  1233. })
  1234. return
  1235. }
  1236. }
  1237. func (c *HisApiController) GetSettleListHospital() {
  1238. order_id, _ := c.GetInt64("order_id")
  1239. admin_user_id, _ := c.GetInt64("admin_user_id")
  1240. order, _ := service.GetHisOrderByIDTwo(order_id)
  1241. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1242. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1243. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1244. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1245. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1246. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1247. if order.ID == 0 {
  1248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1249. return
  1250. }
  1251. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1252. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1253. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1254. fmt.Println(count)
  1255. var zero string
  1256. number := count + 1
  1257. if number >= 1000 {
  1258. zero = "0000" + strconv.FormatInt(number, 10)
  1259. } else if number >= 10000 {
  1260. zero = "000" + strconv.FormatInt(number, 10)
  1261. } else if number >= 100000 {
  1262. zero = "00" + strconv.FormatInt(number, 10)
  1263. } else if number >= 1000000 {
  1264. zero = "0" + strconv.FormatInt(number, 10)
  1265. } else {
  1266. zero = strconv.FormatInt(number, 10)
  1267. }
  1268. fmt.Println(zero)
  1269. struct4101 := service.Struct4101{
  1270. PsnNo: order.PsnNo,
  1271. MdtrtId: order.MdtrtId,
  1272. SetlId: order.SetlId,
  1273. PsnName: order.PsnName,
  1274. Gend: order.Gend,
  1275. Brdy: his.Brdy,
  1276. Age: int64(order.Age),
  1277. Naty: order.Naty,
  1278. PatnCertType: "01",
  1279. Certno: order.Certno,
  1280. Prfs: "90",
  1281. ConerName: roles[0].UserName,
  1282. PatnRlts: "99",
  1283. ConerAddr: miConfig.OrgName,
  1284. ConerTel: admin.Mobile,
  1285. HiType: order.Insutype,
  1286. Insuplc: miConfig.InsuplcAdmdvs,
  1287. MaindiagFlag: "1",
  1288. BillCode: last_order.FaPiaoCode,
  1289. BillNo: zero,
  1290. BizSn: order.Number,
  1291. PsnSelfPay: order.PsnPartAmt,
  1292. PsnOwnPay: order.PsnPartAmt,
  1293. AcctPay: order.AcctPay,
  1294. PsnCashpay: order.PsnCashPay,
  1295. HiPaymtd: "1",
  1296. Hsorg: miConfig.InsuplcAdmdvs,
  1297. HsorgOpter: miConfig.InsuplcAdmdvs,
  1298. MedinsFillPsn: curRoles.UserName,
  1299. MedinsFillDept: depart.Name,
  1300. IptMedType: "2",
  1301. AdmTime: his.InHosptialTime,
  1302. AdmEndTime: his.OutHosptialTime,
  1303. }
  1304. struct4101.SetlBegnDate = order.SetlTime
  1305. struct4101.SetlEndDate = order.SetlTime
  1306. var rf []CustomFundPay
  1307. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1308. var tempFunPays []service.CustomStruct
  1309. for _, item := range rf {
  1310. var tempFunPay service.CustomStruct
  1311. tempFunPay.FundPayamt = item.FundPayamt
  1312. tempFunPay.FundPayType = item.FundPayType
  1313. tempFunPays = append(tempFunPays, tempFunPay)
  1314. }
  1315. struct4101.CustomStruct = tempFunPays
  1316. var tempDiaginfos []service.DiaginfoStructTwo
  1317. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1318. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1319. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1320. var config []*models.HisXtDiagnoseConfig
  1321. for _, item := range diagnosis_ids {
  1322. id, _ := strconv.ParseInt(item, 10, 64)
  1323. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1324. config = append(config, &diagnosisConfig)
  1325. }
  1326. for index, item := range config {
  1327. if index == 0 {
  1328. var tempDiaginfo service.DiaginfoStructTwo
  1329. tempDiaginfo.DiagCode = item.CountryCode
  1330. tempDiaginfo.DiagName = item.CountryContentName
  1331. tempDiaginfo.DiagType = "1"
  1332. tempDiaginfo.MaindiagFlag = "1"
  1333. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1334. } else {
  1335. var tempDiaginfo service.DiaginfoStructTwo
  1336. tempDiaginfo.DiagCode = item.CountryCode
  1337. tempDiaginfo.DiagName = item.CountryContentName
  1338. tempDiaginfo.DiagType = "2"
  1339. tempDiaginfo.MaindiagFlag = "0"
  1340. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1341. }
  1342. }
  1343. struct4101.Diseinfo = tempDiaginfos
  1344. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1345. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1346. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1347. tempOpspdiseinfo2.OprnOprtCode = ""
  1348. tempOpspdiseinfo2.OprnOprtName = ""
  1349. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1350. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1351. var iteminfo service.IteminfoStruct
  1352. var bedCostTotal float64 = 0 //床位总费
  1353. var bedCostSelfTotal float64 = 0 //床位自费
  1354. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1355. var operationCostTotal float64 = 0 //手术费
  1356. var operationCostSelfTotal float64 = 0 //手术费
  1357. var operationCostPartSelfTotal float64 = 0 //手术费
  1358. var otherCostTotal float64 = 0 //其他费用
  1359. var otherCostSelfTotal float64 = 0 //其他费用
  1360. var otherCostPartSelfTotal float64 = 0 //其他费用
  1361. var materialCostTotal float64 = 0 //材料费
  1362. var materialCostSelfTotal float64 = 0 //材料费
  1363. var materialCostPartSelfTotal float64 = 0 //材料费
  1364. var westernMedicineCostTotal float64 = 0 //西药费
  1365. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1366. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1367. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1368. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1369. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1370. var checkCostTotal float64 = 0 //检查费
  1371. var checkCostSelfTotal float64 = 0 //检查费
  1372. var checkCostPartSelfTotal float64 = 0 //检查费
  1373. var laboratoryCostTotal float64 = 0 //化验费
  1374. var laboratoryCostSelfTotal float64 = 0 //化验费
  1375. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1376. var treatCostTotal float64 = 0 //治疗费用
  1377. var treatCostSelfTotal float64 = 0 //治疗费用
  1378. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1379. decimal.DivisionPrecision = 2
  1380. var bed_fulamt_ownpay_amt float64 = 0
  1381. var operation_fulamt_ownpay_amt float64 = 0
  1382. var other_fulamt_ownpay_amt float64 = 0
  1383. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1384. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1385. var check_fulamt_ownpay_amt float64 = 0
  1386. var material_fulamt_ownpay_amt float64 = 0
  1387. var laboratory_fulamt_ownpay_amt float64 = 0
  1388. var treat_fulamt_ownpay_amt float64 = 0
  1389. var bed_claa_sunmfee float64 = 0
  1390. var bed_clab_amt float64 = 0
  1391. var bed_other_amt float64 = 0
  1392. var operation_claa_sunmfee float64 = 0
  1393. var operation_clab_amt float64 = 0
  1394. var operation_other_amt float64 = 0
  1395. var other_claa_sunmfee float64 = 0
  1396. var other_clab_amt float64 = 0
  1397. var other_other_amt float64 = 0
  1398. var westernMedicine_claa_sunmfee float64 = 0
  1399. var westernMedicine_clab_amt float64 = 0
  1400. var westernMedicine_other_amt float64 = 0
  1401. var chineseTraditional_claa_sunmfee float64 = 0
  1402. var chineseTraditional_clab_amt float64 = 0
  1403. var chineseTraditional_other_amt float64 = 0
  1404. var check_claa_sunmfee float64 = 0
  1405. var check_clab_amt float64 = 0
  1406. var check_other_amt float64 = 0
  1407. var material_claa_sunmfee float64 = 0
  1408. var material_clab_amt float64 = 0
  1409. var material_other_amt float64 = 0
  1410. var laboratory_claa_sunmfee float64 = 0
  1411. var laboratory_clab_amt float64 = 0
  1412. var laboratory_other_amt float64 = 0
  1413. var treat_claa_sunmfee float64 = 0
  1414. var treat_clab_amt float64 = 0
  1415. var treat_other_amt float64 = 0
  1416. for _, item := range order.HisOrderInfo {
  1417. if item.MedChrgitmType == "01" { //床位费
  1418. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1419. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1420. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1421. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1422. if item.ChrgitmLv == "1" {
  1423. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1424. }
  1425. if item.ChrgitmLv == "2" {
  1426. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1427. }
  1428. if item.ChrgitmLv == "3" {
  1429. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1430. }
  1431. }
  1432. if item.MedChrgitmType == "03" { //检查费
  1433. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1434. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1435. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1436. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1437. if item.ChrgitmLv == "1" {
  1438. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1439. }
  1440. if item.ChrgitmLv == "2" {
  1441. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1442. }
  1443. if item.ChrgitmLv == "3" {
  1444. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1445. }
  1446. }
  1447. if item.MedChrgitmType == "04" { //化验费
  1448. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1449. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1450. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1451. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1452. if item.ChrgitmLv == "1" {
  1453. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1454. }
  1455. if item.ChrgitmLv == "2" {
  1456. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1457. }
  1458. if item.ChrgitmLv == "3" {
  1459. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1460. }
  1461. }
  1462. if item.MedChrgitmType == "05" { //治疗费
  1463. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1464. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1465. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1466. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1467. if item.ChrgitmLv == "1" {
  1468. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1469. }
  1470. if item.ChrgitmLv == "2" {
  1471. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1472. }
  1473. if item.ChrgitmLv == "3" {
  1474. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1475. }
  1476. }
  1477. if item.MedChrgitmType == "06" { //手术费
  1478. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1479. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1480. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1481. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1482. if item.ChrgitmLv == "1" {
  1483. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1484. }
  1485. if item.ChrgitmLv == "2" {
  1486. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1487. }
  1488. if item.ChrgitmLv == "3" {
  1489. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1490. }
  1491. }
  1492. if item.MedChrgitmType == "08" { //材料费
  1493. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1494. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1495. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1496. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1497. if item.ChrgitmLv == "1" {
  1498. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1499. }
  1500. if item.ChrgitmLv == "2" {
  1501. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1502. }
  1503. if item.ChrgitmLv == "3" {
  1504. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1505. }
  1506. }
  1507. if item.MedChrgitmType == "09" { //西药费
  1508. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1509. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1510. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1511. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1512. if item.ChrgitmLv == "1" {
  1513. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1514. }
  1515. if item.ChrgitmLv == "2" {
  1516. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1517. }
  1518. if item.ChrgitmLv == "3" {
  1519. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1520. }
  1521. }
  1522. if item.MedChrgitmType == "11" { //中成费
  1523. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1524. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1525. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1526. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1527. if item.ChrgitmLv == "1" {
  1528. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1529. }
  1530. if item.ChrgitmLv == "2" {
  1531. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1532. }
  1533. if item.ChrgitmLv == "3" {
  1534. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1535. }
  1536. }
  1537. if item.MedChrgitmType == "14" { //其他费
  1538. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1539. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1540. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1541. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1542. if item.ChrgitmLv == "1" {
  1543. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1544. }
  1545. if item.ChrgitmLv == "2" {
  1546. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1547. }
  1548. if item.ChrgitmLv == "3" {
  1549. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1550. }
  1551. }
  1552. }
  1553. var iteminfoStructs []service.IteminfoStruct
  1554. if bedCostTotal != 0 {
  1555. iteminfo.MedChrgitm = "01"
  1556. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1557. iteminfo.Amt = bedCostTotal
  1558. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1559. iteminfo.ClabAmt = bed_clab_amt
  1560. iteminfo.OthAmt = bed_other_amt
  1561. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1562. }
  1563. if checkCostTotal != 0 {
  1564. iteminfo.MedChrgitm = "03"
  1565. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1566. iteminfo.Amt = checkCostTotal
  1567. iteminfo.ClaaSumfee = check_claa_sunmfee
  1568. iteminfo.ClabAmt = check_clab_amt
  1569. iteminfo.OthAmt = check_other_amt
  1570. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1571. }
  1572. if laboratoryCostTotal != 0 {
  1573. iteminfo.MedChrgitm = "04"
  1574. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1575. iteminfo.Amt = laboratoryCostTotal
  1576. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1577. iteminfo.ClabAmt = laboratory_clab_amt
  1578. iteminfo.OthAmt = laboratory_other_amt
  1579. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1580. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1581. }
  1582. if treatCostTotal != 0 {
  1583. iteminfo.MedChrgitm = "05"
  1584. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1585. iteminfo.Amt = treatCostTotal
  1586. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1587. iteminfo.ClabAmt = treat_clab_amt
  1588. iteminfo.OthAmt = treat_other_amt
  1589. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1590. //(struct4101.IteminfoStruct, iteminfo)
  1591. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1592. }
  1593. if operationCostTotal != 0 {
  1594. iteminfo.MedChrgitm = "06"
  1595. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1596. iteminfo.Amt = operationCostTotal
  1597. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1598. iteminfo.ClabAmt = operation_clab_amt
  1599. iteminfo.OthAmt = operation_other_amt
  1600. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1601. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1602. }
  1603. if materialCostTotal != 0 {
  1604. iteminfo.MedChrgitm = "08"
  1605. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1606. iteminfo.Amt = materialCostTotal
  1607. iteminfo.ClaaSumfee = material_claa_sunmfee
  1608. iteminfo.ClabAmt = material_clab_amt
  1609. iteminfo.OthAmt = material_other_amt
  1610. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1611. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1612. }
  1613. if westernMedicineCostTotal != 0 {
  1614. iteminfo.MedChrgitm = "09"
  1615. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1616. iteminfo.Amt = westernMedicineCostTotal
  1617. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1618. iteminfo.ClabAmt = westernMedicine_clab_amt
  1619. iteminfo.OthAmt = westernMedicine_other_amt
  1620. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1621. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1622. }
  1623. if chineseTraditionalMedicineCostTotal != 0 {
  1624. iteminfo.MedChrgitm = "11"
  1625. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1626. iteminfo.Amt = westernMedicineCostTotal
  1627. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1628. iteminfo.ClabAmt = westernMedicine_clab_amt
  1629. iteminfo.OthAmt = westernMedicine_other_amt
  1630. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1631. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1632. }
  1633. if otherCostTotal != 0 {
  1634. iteminfo.MedChrgitm = "14"
  1635. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1636. iteminfo.Amt = otherCostTotal
  1637. iteminfo.ClaaSumfee = other_claa_sunmfee
  1638. iteminfo.ClabAmt = other_clab_amt
  1639. iteminfo.OthAmt = other_other_amt
  1640. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1641. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1642. }
  1643. struct4101.IteminfoStruct = iteminfoStructs
  1644. struct4101.Ntly = "中国"
  1645. struct4101.AdmCaty = "A03.06"
  1646. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1647. fmt.Println(result)
  1648. var dat map[string]interface{}
  1649. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1650. fmt.Println(dat)
  1651. } else {
  1652. fmt.Println(err)
  1653. }
  1654. userJSONBytes, _ := json.Marshal(dat)
  1655. var res ResultSeventeen
  1656. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1657. utils.ErrorLog("解析失败:%v", err)
  1658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1659. return
  1660. }
  1661. if res.Infcode != 0 {
  1662. c.ServeSuccessJSON(map[string]interface{}{
  1663. "failed_code": -10,
  1664. "msg": res.ErrMsg,
  1665. })
  1666. return
  1667. } else {
  1668. order.FaPiaoNumber = zero
  1669. order.FaPiaoCode = last_order.FaPiaoCode
  1670. service.UpdateOrder(order)
  1671. hisFundSettleListResult := &models.HisFundSettleListResult{
  1672. Number: res.Output.SetlListId,
  1673. Status: 1,
  1674. Ctime: time.Now().Unix(),
  1675. Mtime: time.Now().Unix(),
  1676. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1677. IsUpload: 1,
  1678. OrderId: order_id,
  1679. }
  1680. service.CreateUploadRecord(hisFundSettleListResult)
  1681. c.ServeSuccessJSON(map[string]interface{}{
  1682. "msg": "上传成功",
  1683. "result": hisFundSettleListResult,
  1684. })
  1685. return
  1686. }
  1687. }
  1688. func (c *HisApiController) GetBatchSettleList() {
  1689. orders, _ := service.GetAllHisOrder(10106)
  1690. for _, item := range orders {
  1691. order_id := item.ID
  1692. order, _ := service.GetHisOrderByIDTwo(order_id)
  1693. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1694. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1695. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1696. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  1697. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1698. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1699. if order.ID == 0 {
  1700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1701. return
  1702. }
  1703. if his.BalanceAccountsType == 2 {
  1704. continue
  1705. }
  1706. struct4101 := service.Struct4101{
  1707. PsnNo: order.PsnNo,
  1708. MdtrtId: order.MdtrtId,
  1709. SetlId: order.SetlId,
  1710. PsnName: order.PsnName,
  1711. Gend: order.Gend,
  1712. Brdy: his.Brdy,
  1713. Age: his.Age,
  1714. Naty: order.Naty,
  1715. PatnCertType: "01",
  1716. Certno: order.Certno,
  1717. Prfs: "90",
  1718. ConerName: roles[0].UserName,
  1719. PatnRlts: "99",
  1720. ConerAddr: miConfig.OrgName,
  1721. ConerTel: admin.Mobile,
  1722. HiType: order.Insutype,
  1723. Insuplc: his.InsuplcAdmdvs,
  1724. MaindiagFlag: "1",
  1725. BillCode: order.FaPiaoCode,
  1726. BillNo: order.FaPiaoNumber,
  1727. BizSn: order.Number,
  1728. PsnSelfPay: order.PsnPartAmt,
  1729. PsnOwnPay: order.PsnPartAmt,
  1730. AcctPay: order.AcctPay,
  1731. PsnCashpay: order.PsnCashPay,
  1732. HiPaymtd: "1",
  1733. Hsorg: his.InsuplcAdmdvs,
  1734. HsorgOpter: his.InsuplcAdmdvs,
  1735. MedinsFillPsn: curRoles.UserName,
  1736. MedinsFillDept: depart.Name,
  1737. IptMedType: "2",
  1738. }
  1739. struct4101.SetlBegnDate = order.SetlTime
  1740. struct4101.SetlEndDate = order.SetlTime
  1741. //if order.SettleType == 1 {
  1742. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  1743. // dateStr := t.Format("2006-01-02")
  1744. // struct4101.SetlBegnDate = dateStr
  1745. // struct4101.SetlEndDate = dateStr
  1746. //} else {
  1747. // t := time.Unix(int64(order.SettleStartTime), 0)
  1748. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  1749. // dateStartStr := t.Format("2006-01-02")
  1750. // dateEndStr := t2.Format("2006-01-02")
  1751. // struct4101.SetlBegnDate = dateStartStr
  1752. // struct4101.SetlEndDate = dateEndStr
  1753. //}
  1754. var rf []CustomFundPay
  1755. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1756. var tempFunPays []service.CustomStruct
  1757. var tempFunPay610100 service.CustomStruct
  1758. for _, item := range rf {
  1759. if item.FundPayType == "610100" {
  1760. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  1761. tempFunPay610100.FundPayType = item.FundPayType
  1762. } else {
  1763. var tempFunPay service.CustomStruct
  1764. tempFunPay.FundPayamt = item.FundPayamt
  1765. tempFunPay.FundPayType = item.FundPayType
  1766. tempFunPays = append(tempFunPays, tempFunPay)
  1767. }
  1768. }
  1769. tempFunPays = append(tempFunPays, tempFunPay610100)
  1770. struct4101.CustomStruct = tempFunPays
  1771. var tempDiaginfos []service.DiaginfoStructTwo
  1772. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1773. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1774. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1775. var config []*models.HisXtDiagnoseConfig
  1776. for _, item := range diagnosis_ids {
  1777. id, _ := strconv.ParseInt(item, 10, 64)
  1778. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1779. config = append(config, &diagnosisConfig)
  1780. }
  1781. for index, item := range config {
  1782. if index == 0 {
  1783. var tempDiaginfo service.DiaginfoStructTwo
  1784. tempDiaginfo.DiagCode = item.CountryCode
  1785. tempDiaginfo.DiagName = item.CountryContentName
  1786. tempDiaginfo.DiagType = "1"
  1787. tempDiaginfo.MaindiagFlag = "1"
  1788. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1789. } else {
  1790. var tempDiaginfo service.DiaginfoStructTwo
  1791. tempDiaginfo.DiagCode = item.CountryCode
  1792. tempDiaginfo.DiagName = item.CountryContentName
  1793. tempDiaginfo.DiagType = "2"
  1794. tempDiaginfo.MaindiagFlag = "0"
  1795. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1796. }
  1797. }
  1798. struct4101.Diseinfo = tempDiaginfos
  1799. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1800. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1801. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1802. tempOpspdiseinfo2.OprnOprtCode = ""
  1803. tempOpspdiseinfo2.OprnOprtName = ""
  1804. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1805. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1806. var iteminfo service.IteminfoStruct
  1807. var bedCostTotal float64 = 0 //床位总费
  1808. var bedCostSelfTotal float64 = 0 //床位自费
  1809. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1810. var examineCostTotal float64 = 0 //诊查总费
  1811. var examineCostSelfTotal float64 = 0 //诊查自费
  1812. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  1813. var nursingCostTotal float64 = 0 //护理总费
  1814. var nursingCostSelfTotal float64 = 0 //护理自费
  1815. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  1816. var chineseMedicineCostTotal float64 = 0 //中成药
  1817. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  1818. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  1819. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  1820. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  1821. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  1822. var registerCostTotal float64 = 0 //一般诊疗费
  1823. var registerCostSelfTotal float64 = 0 //一般诊疗费
  1824. var registerPartSelfTotal float64 = 0 //一般诊疗费
  1825. var operationCostTotal float64 = 0 //手术费
  1826. var operationCostSelfTotal float64 = 0 //手术费
  1827. var operationCostPartSelfTotal float64 = 0 //手术费
  1828. var otherCostTotal float64 = 0 //其他费用
  1829. var otherCostSelfTotal float64 = 0 //其他费用
  1830. var otherCostPartSelfTotal float64 = 0 //其他费用
  1831. var materialCostTotal float64 = 0 //材料费
  1832. var materialCostSelfTotal float64 = 0 //材料费
  1833. var materialCostPartSelfTotal float64 = 0 //材料费
  1834. var westernMedicineCostTotal float64 = 0 //西药费
  1835. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1836. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1837. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1838. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1839. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1840. var checkCostTotal float64 = 0 //检查费
  1841. var checkCostSelfTotal float64 = 0 //检查费
  1842. var checkCostPartSelfTotal float64 = 0 //检查费
  1843. var laboratoryCostTotal float64 = 0 //化验费
  1844. var laboratoryCostSelfTotal float64 = 0 //化验费
  1845. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1846. var treatCostTotal float64 = 0 //治疗费用
  1847. var treatCostSelfTotal float64 = 0 //治疗费用
  1848. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1849. decimal.DivisionPrecision = 2
  1850. var bed_fulamt_ownpay_amt float64 = 0
  1851. var examine_fulamt_ownpay_amt float64 = 0
  1852. var nursing_fulamt_ownpay_amt float64 = 0
  1853. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1854. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1855. var register_fulamt_ownpay_amt float64 = 0
  1856. var operation_fulamt_ownpay_amt float64 = 0
  1857. var other_fulamt_ownpay_amt float64 = 0
  1858. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1859. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1860. var check_fulamt_ownpay_amt float64 = 0
  1861. var material_fulamt_ownpay_amt float64 = 0
  1862. var laboratory_fulamt_ownpay_amt float64 = 0
  1863. var treat_fulamt_ownpay_amt float64 = 0
  1864. var bed_claa_sunmfee float64 = 0
  1865. var bed_clab_amt float64 = 0
  1866. var bed_other_amt float64 = 0
  1867. var examine_claa_sunmfee float64 = 0
  1868. var examine_clab_amt float64 = 0
  1869. var examine_other_amt float64 = 0
  1870. var nursing_claa_sunmfee float64 = 0
  1871. var nursing_clab_amt float64 = 0
  1872. var nursing_other_amt float64 = 0
  1873. var chinese_medicine_claa_sunmfee float64 = 0
  1874. var chinese_medicine_clab_amt float64 = 0
  1875. var chinese_medicine_other_amt float64 = 0
  1876. var commonly_treatment_claa_sunmfee float64 = 0
  1877. var commonly_treatment_clab_amt float64 = 0
  1878. var commonly_treatment_other_amt float64 = 0
  1879. var operation_claa_sunmfee float64 = 0
  1880. var operation_clab_amt float64 = 0
  1881. var operation_other_amt float64 = 0
  1882. var other_claa_sunmfee float64 = 0
  1883. var other_clab_amt float64 = 0
  1884. var other_other_amt float64 = 0
  1885. var westernMedicine_claa_sunmfee float64 = 0
  1886. var westernMedicine_clab_amt float64 = 0
  1887. var westernMedicine_other_amt float64 = 0
  1888. var chineseTraditional_claa_sunmfee float64 = 0
  1889. var chineseTraditional_clab_amt float64 = 0
  1890. var chineseTraditional_other_amt float64 = 0
  1891. var check_claa_sunmfee float64 = 0
  1892. var check_clab_amt float64 = 0
  1893. var check_other_amt float64 = 0
  1894. var material_claa_sunmfee float64 = 0
  1895. var material_clab_amt float64 = 0
  1896. var material_other_amt float64 = 0
  1897. var laboratory_claa_sunmfee float64 = 0
  1898. var laboratory_clab_amt float64 = 0
  1899. var laboratory_other_amt float64 = 0
  1900. var treat_claa_sunmfee float64 = 0
  1901. var treat_clab_amt float64 = 0
  1902. var treat_other_amt float64 = 0
  1903. var register_claa_sunmfee float64 = 0
  1904. var register_clab_amt float64 = 0
  1905. var register_other_amt float64 = 0
  1906. for _, item := range order.HisOrderInfo {
  1907. if item.MedChrgitmType == "01" { //床位费
  1908. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1909. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1910. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1911. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1912. if item.ChrgitmLv == "1" {
  1913. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1914. }
  1915. if item.ChrgitmLv == "2" {
  1916. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1917. }
  1918. if item.ChrgitmLv == "3" {
  1919. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1920. }
  1921. }
  1922. if item.MedChrgitmType == "02" { //诊查
  1923. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1924. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1925. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1926. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1927. if item.ChrgitmLv == "1" {
  1928. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1929. }
  1930. if item.ChrgitmLv == "2" {
  1931. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1932. }
  1933. if item.ChrgitmLv == "3" {
  1934. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1935. }
  1936. }
  1937. if item.MedChrgitmType == "03" { //检查费
  1938. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1939. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1940. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1941. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1942. if item.ChrgitmLv == "1" {
  1943. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1944. }
  1945. if item.ChrgitmLv == "2" {
  1946. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1947. }
  1948. if item.ChrgitmLv == "3" {
  1949. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1950. }
  1951. }
  1952. if item.MedChrgitmType == "04" { //化验费
  1953. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1954. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1955. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1956. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1957. if item.ChrgitmLv == "1" {
  1958. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1959. }
  1960. if item.ChrgitmLv == "2" {
  1961. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1962. }
  1963. if item.ChrgitmLv == "3" {
  1964. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1965. }
  1966. }
  1967. if item.MedChrgitmType == "05" { //治疗费
  1968. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1969. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1970. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1971. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1972. if item.ChrgitmLv == "1" {
  1973. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1974. }
  1975. if item.ChrgitmLv == "2" {
  1976. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1977. }
  1978. if item.ChrgitmLv == "3" {
  1979. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1980. }
  1981. }
  1982. if item.MedChrgitmType == "06" { //手术费
  1983. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1984. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1985. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1986. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1987. if item.ChrgitmLv == "1" {
  1988. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1989. }
  1990. if item.ChrgitmLv == "2" {
  1991. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1992. }
  1993. if item.ChrgitmLv == "3" {
  1994. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1995. }
  1996. }
  1997. if item.MedChrgitmType == "07" { //手术费
  1998. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1999. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2000. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2001. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2002. if item.ChrgitmLv == "1" {
  2003. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2004. }
  2005. if item.ChrgitmLv == "2" {
  2006. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2007. }
  2008. if item.ChrgitmLv == "3" {
  2009. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2010. }
  2011. }
  2012. if item.MedChrgitmType == "08" { //材料费
  2013. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2014. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2015. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2016. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2017. if item.ChrgitmLv == "1" {
  2018. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2019. }
  2020. if item.ChrgitmLv == "2" {
  2021. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2022. }
  2023. if item.ChrgitmLv == "3" {
  2024. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2025. }
  2026. }
  2027. if item.MedChrgitmType == "09" { //西药费
  2028. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2029. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2030. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2031. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2032. if item.ChrgitmLv == "1" {
  2033. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2034. }
  2035. if item.ChrgitmLv == "2" {
  2036. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2037. }
  2038. if item.ChrgitmLv == "3" {
  2039. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2040. }
  2041. }
  2042. if item.MedChrgitmType == "10" { //中药饮片
  2043. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2044. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2045. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2046. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2047. if item.ChrgitmLv == "1" {
  2048. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2049. }
  2050. if item.ChrgitmLv == "2" {
  2051. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2052. }
  2053. if item.ChrgitmLv == "3" {
  2054. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2055. }
  2056. }
  2057. if item.MedChrgitmType == "11" { //中成费
  2058. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2059. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2060. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2061. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2062. if item.ChrgitmLv == "1" {
  2063. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2064. }
  2065. if item.ChrgitmLv == "2" {
  2066. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2067. }
  2068. if item.ChrgitmLv == "3" {
  2069. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2070. }
  2071. }
  2072. if item.MedChrgitmType == "12" { //中成费
  2073. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2074. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2075. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2076. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2077. if item.ChrgitmLv == "1" {
  2078. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2079. }
  2080. if item.ChrgitmLv == "2" {
  2081. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2082. }
  2083. if item.ChrgitmLv == "3" {
  2084. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2085. }
  2086. }
  2087. if item.MedChrgitmType == "13" { //中成费
  2088. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2089. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2090. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2091. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2092. if item.ChrgitmLv == "1" {
  2093. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2094. }
  2095. if item.ChrgitmLv == "2" {
  2096. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2097. }
  2098. if item.ChrgitmLv == "3" {
  2099. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2100. }
  2101. }
  2102. if item.MedChrgitmType == "14" { //其他费
  2103. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2104. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2105. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2106. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2107. if item.ChrgitmLv == "1" {
  2108. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2109. }
  2110. if item.ChrgitmLv == "2" {
  2111. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2112. }
  2113. if item.ChrgitmLv == "3" {
  2114. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2115. }
  2116. }
  2117. }
  2118. var iteminfoStructs []service.IteminfoStruct
  2119. if bedCostTotal != 0 {
  2120. iteminfo.MedChrgitm = "01"
  2121. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2122. iteminfo.Amt = bedCostTotal
  2123. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2124. iteminfo.ClabAmt = bed_clab_amt
  2125. iteminfo.OthAmt = bed_other_amt
  2126. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2127. }
  2128. if examineCostTotal != 0 {
  2129. iteminfo.MedChrgitm = "02"
  2130. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2131. iteminfo.Amt = examineCostTotal
  2132. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2133. iteminfo.ClabAmt = examine_clab_amt
  2134. iteminfo.OthAmt = examine_other_amt
  2135. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2136. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2137. }
  2138. if checkCostTotal != 0 {
  2139. iteminfo.MedChrgitm = "03"
  2140. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2141. iteminfo.Amt = checkCostTotal
  2142. iteminfo.ClaaSumfee = check_claa_sunmfee
  2143. iteminfo.ClabAmt = check_clab_amt
  2144. iteminfo.OthAmt = check_other_amt
  2145. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2146. }
  2147. if laboratoryCostTotal != 0 {
  2148. iteminfo.MedChrgitm = "04"
  2149. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2150. iteminfo.Amt = laboratoryCostTotal
  2151. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2152. iteminfo.ClabAmt = laboratory_clab_amt
  2153. iteminfo.OthAmt = laboratory_other_amt
  2154. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2155. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2156. }
  2157. if treatCostTotal != 0 {
  2158. iteminfo.MedChrgitm = "05"
  2159. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2160. iteminfo.Amt = treatCostTotal
  2161. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2162. iteminfo.ClabAmt = treat_clab_amt
  2163. iteminfo.OthAmt = treat_other_amt
  2164. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2165. //(struct4101.IteminfoStruct, iteminfo)
  2166. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2167. }
  2168. if operationCostTotal != 0 {
  2169. iteminfo.MedChrgitm = "06"
  2170. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2171. iteminfo.Amt = operationCostTotal
  2172. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2173. iteminfo.ClabAmt = operation_clab_amt
  2174. iteminfo.OthAmt = operation_other_amt
  2175. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2176. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2177. }
  2178. if nursingCostTotal != 0 {
  2179. iteminfo.MedChrgitm = "07"
  2180. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2181. iteminfo.Amt = nursingCostTotal
  2182. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2183. iteminfo.ClabAmt = nursing_clab_amt
  2184. iteminfo.OthAmt = nursing_other_amt
  2185. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2186. }
  2187. if materialCostTotal != 0 {
  2188. iteminfo.MedChrgitm = "08"
  2189. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2190. iteminfo.Amt = materialCostTotal
  2191. iteminfo.ClaaSumfee = material_claa_sunmfee
  2192. iteminfo.ClabAmt = material_clab_amt
  2193. iteminfo.OthAmt = material_other_amt
  2194. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2195. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2196. }
  2197. if westernMedicineCostTotal != 0 {
  2198. iteminfo.MedChrgitm = "09"
  2199. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2200. iteminfo.Amt = westernMedicineCostTotal
  2201. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2202. iteminfo.ClabAmt = westernMedicine_clab_amt
  2203. iteminfo.OthAmt = westernMedicine_other_amt
  2204. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2205. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2206. }
  2207. if chineseMedicineCostTotal != 0 {
  2208. iteminfo.MedChrgitm = "10"
  2209. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2210. iteminfo.Amt = chineseMedicineCostTotal
  2211. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2212. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2213. iteminfo.OthAmt = chinese_medicine_other_amt
  2214. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2215. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2216. }
  2217. if chineseTraditionalMedicineCostTotal != 0 {
  2218. iteminfo.MedChrgitm = "11"
  2219. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2220. iteminfo.Amt = westernMedicineCostTotal
  2221. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2222. iteminfo.ClabAmt = westernMedicine_clab_amt
  2223. iteminfo.OthAmt = westernMedicine_other_amt
  2224. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2225. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2226. }
  2227. if commonlyTreatmentCostTotal != 0 {
  2228. iteminfo.MedChrgitm = "12"
  2229. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2230. iteminfo.Amt = commonlyTreatmentCostTotal
  2231. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2232. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2233. iteminfo.OthAmt = commonly_treatment_other_amt
  2234. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2235. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2236. }
  2237. if registerCostTotal != 0 {
  2238. iteminfo.MedChrgitm = "13"
  2239. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2240. iteminfo.Amt = registerCostTotal
  2241. iteminfo.ClaaSumfee = register_claa_sunmfee
  2242. iteminfo.ClabAmt = register_clab_amt
  2243. iteminfo.OthAmt = register_other_amt
  2244. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2245. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2246. }
  2247. if otherCostTotal != 0 {
  2248. iteminfo.MedChrgitm = "14"
  2249. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2250. iteminfo.Amt = otherCostTotal
  2251. iteminfo.ClaaSumfee = other_claa_sunmfee
  2252. iteminfo.ClabAmt = other_clab_amt
  2253. iteminfo.OthAmt = other_other_amt
  2254. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2255. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2256. }
  2257. struct4101.IteminfoStruct = iteminfoStructs
  2258. struct4101.Ntly = "中国"
  2259. struct4101.AdmCaty = "A03.06"
  2260. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  2261. fmt.Println(result)
  2262. var dat map[string]interface{}
  2263. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2264. fmt.Println(dat)
  2265. } else {
  2266. fmt.Println(err)
  2267. }
  2268. userJSONBytes, _ := json.Marshal(dat)
  2269. var res ResultSeventeen
  2270. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2271. utils.ErrorLog("解析失败:%v", err)
  2272. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2273. adminUser := c.GetAdminUserInfo()
  2274. errlog := &models.HisOrderError{
  2275. UserOrgId: adminUser.CurrentOrgId,
  2276. Ctime: time.Now().Unix(),
  2277. Mtime: time.Now().Unix(),
  2278. ErrMsg: res.ErrMsg + "解析失败",
  2279. Status: 1,
  2280. PatientId: order_id,
  2281. Stage: 10106,
  2282. }
  2283. service.CreateErrMsgLog(errlog)
  2284. continue
  2285. }
  2286. if res.Infcode != 0 {
  2287. adminUser := c.GetAdminUserInfo()
  2288. errlog := &models.HisOrderError{
  2289. UserOrgId: adminUser.CurrentOrgId,
  2290. Ctime: time.Now().Unix(),
  2291. Mtime: time.Now().Unix(),
  2292. ErrMsg: res.ErrMsg,
  2293. Status: 1,
  2294. PatientId: order_id,
  2295. Stage: 10106,
  2296. }
  2297. service.CreateErrMsgLog(errlog)
  2298. continue
  2299. } else {
  2300. hisFundSettleListResult := &models.HisFundSettleListResult{
  2301. Number: res.Output.SetlListId,
  2302. Status: 1,
  2303. Ctime: time.Now().Unix(),
  2304. Mtime: time.Now().Unix(),
  2305. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2306. IsUpload: 1,
  2307. OrderId: order_id,
  2308. }
  2309. service.CreateUploadRecord(hisFundSettleListResult)
  2310. continue
  2311. }
  2312. }
  2313. }
  2314. func (c *HisApiController) GetOrgInfo() {
  2315. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2316. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2317. }
  2318. func (c *HisApiController) GetHisPatientInfo() {
  2319. medical_insurance_card := c.GetString("medical_insurance_card")
  2320. id_card_type, _ := c.GetInt64("id_card_type")
  2321. id_card := c.GetString("id_card")
  2322. adminInfo := c.GetAdminUserInfo()
  2323. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2324. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2325. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2326. IdCardNo := ""
  2327. if id_card_type == 1 {
  2328. IdCardNo = medical_insurance_card
  2329. } else if id_card_type == 2 {
  2330. IdCardNo = id_card
  2331. }
  2332. if config.IsOpen == 1 {
  2333. 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
  2334. resp, requestErr := http.Get(api)
  2335. if requestErr != nil {
  2336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2337. return
  2338. }
  2339. defer resp.Body.Close()
  2340. body, ioErr := ioutil.ReadAll(resp.Body)
  2341. if ioErr != nil {
  2342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2344. return
  2345. }
  2346. var respJSON map[string]interface{}
  2347. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2350. return
  2351. }
  2352. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2353. userJSONBytes, _ := json.Marshal(userJSON)
  2354. var res ResultTwo
  2355. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2356. utils.ErrorLog("解析失败:%v", err)
  2357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2358. return
  2359. }
  2360. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2361. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2362. infoStr := string(Iinfos)
  2363. idetinfoStr := string(Idetinfos)
  2364. if res.Infcode == 0 {
  2365. his := models.VMHisPatient{
  2366. Status: 1,
  2367. Ctime: time.Now().Unix(),
  2368. Mtime: time.Now().Unix(),
  2369. PsnNo: res.Output.Baseinfo.PsnNo,
  2370. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2371. Certno: res.Output.Baseinfo.Certno,
  2372. PsnName: res.Output.Baseinfo.PsnName,
  2373. Gend: res.Output.Baseinfo.Gend,
  2374. Naty: res.Output.Baseinfo.Naty,
  2375. Brdy: res.Output.Baseinfo.Brdy,
  2376. Age: res.Output.Baseinfo.Age,
  2377. Iinfo: infoStr,
  2378. Idetinfo: idetinfoStr,
  2379. UserOrgId: adminInfo.CurrentOrgId,
  2380. IsReturn: 1,
  2381. IdCardType: id_card_type,
  2382. }
  2383. c.ServeSuccessJSON(map[string]interface{}{
  2384. "info": his,
  2385. })
  2386. } else {
  2387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2388. return
  2389. }
  2390. }
  2391. }
  2392. //func GetBasBaseInfo() (jsonStr string, err error) {
  2393. //
  2394. // handle := syscall.NewLazyDLL("SSCard.dll")
  2395. // add := handle.NewProc("ReadCardBas")
  2396. // str := make([]byte, 1024)
  2397. // str1 := make([]byte, 1024)
  2398. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2399. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  2400. //
  2401. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  2402. //
  2403. // fmt.Println("> Add(4,5)的结果为:", ret)
  2404. // handle.Release()
  2405. //
  2406. // return "", nil
  2407. //
  2408. //}
  2409. //func GetQRBaseInfo() (jsonStr string, err error) {
  2410. // handle := syscall.LoadDLL("SSCard.dll")
  2411. // ReadCardBas := handle.FindProc("GetQRBase")
  2412. //
  2413. // str := make([]byte, 256)
  2414. // str1 := make([]byte, 256)
  2415. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2416. //
  2417. // fmt.Println(string(str))
  2418. // fmt.Println(r)
  2419. // return string(str), nil
  2420. //}
  2421. //func CardInit() int {
  2422. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  2423. // add := DllTestDef.MustFindProc("Init")
  2424. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2425. // if err != nil {
  2426. // fmt.Println("SSCard的运算结果为:", ret)
  2427. // }
  2428. // result := int(ret)
  2429. // return result
  2430. //}
  2431. //func CardInit() int {
  2432. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2433. // if err != nil {
  2434. // fmt.Println("SSCard的运算结果为:", ret)
  2435. // }
  2436. // fmt.Println(err)
  2437. // result := int(ret)
  2438. // return result
  2439. //}
  2440. func IntPtr(n int) uintptr {
  2441. return uintptr(n)
  2442. }
  2443. func StrPtr(s string) uintptr {
  2444. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  2445. }
  2446. type Result2001 struct {
  2447. Cainfo interface{} `json:"cainfo"`
  2448. ErrMsg string `json:"err_msg"`
  2449. InfRefmsgid string `json:"inf_refmsgid"`
  2450. Infcode int64 `json:"infcode"`
  2451. Output struct {
  2452. Trtinfo struct {
  2453. PsnNo string `json:"psn_no"`
  2454. TrtChkType string `json:"trt_chk_type"`
  2455. FundPayType string `json:"fund_pay_type"`
  2456. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2457. Begndate string `json:"begndate"`
  2458. Enddate string `json:"enddate"`
  2459. TrtChkRslt string `json:"trt_chk_rslt"`
  2460. } `json:"trtinfo"`
  2461. } `json:"output"`
  2462. RefmsgTime string `json:"refmsg_time"`
  2463. RespondTime string `json:"respond_time"`
  2464. Signtype interface{} `json:"signtype"`
  2465. WarnMsg interface{} `json:"warn_msg"`
  2466. }
  2467. type Result2001Org10265 struct {
  2468. Cainfo interface{} `json:"cainfo"`
  2469. ErrMsg string `json:"err_msg"`
  2470. InfRefmsgid string `json:"inf_refmsgid"`
  2471. Infcode string `json:"infcode"`
  2472. Output struct {
  2473. Trtinfo struct {
  2474. PsnNo string `json:"psn_no"`
  2475. TrtChkType string `json:"trt_chk_type"`
  2476. FundPayType string `json:"fund_pay_type"`
  2477. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2478. Begndate string `json:"begndate"`
  2479. Enddate string `json:"enddate"`
  2480. TrtChkRslt string `json:"trt_chk_rslt"`
  2481. } `json:"trtinfo"`
  2482. } `json:"output"`
  2483. RefmsgTime string `json:"refmsg_time"`
  2484. RespondTime string `json:"respond_time"`
  2485. Signtype interface{} `json:"signtype"`
  2486. WarnMsg interface{} `json:"warn_msg"`
  2487. }
  2488. type ResultTwo struct {
  2489. ErrMsg string `json:"err_msg"`
  2490. InfRefmsgid string `json:"inf_refmsgid"`
  2491. Infcode int64 `json:"infcode"`
  2492. Output struct {
  2493. Baseinfo struct {
  2494. Age float64 `json:"age"`
  2495. Brdy string `json:"brdy"`
  2496. Certno string `json:"certno"`
  2497. Gend string `json:"gend"`
  2498. Naty string `json:"naty"`
  2499. PsnCertType string `json:"psn_cert_type"`
  2500. PsnName string `json:"psn_name"`
  2501. PsnNo string `json:"psn_no"`
  2502. } `json:"baseinfo"`
  2503. Idetinfo []interface{} `json:"idetinfo"`
  2504. Iinfo []struct {
  2505. Balc float64 `json:"balc"`
  2506. CvlservFlag string `json:"cvlserv_flag"`
  2507. EmpName string `json:"emp_name"`
  2508. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2509. Insutype string `json:"insutype"`
  2510. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2511. PausInsuDate string `json:"paus_insu_date"`
  2512. PsnInsuDate string `json:"psn_insu_date"`
  2513. PsnInsuStas string `json:"psn_insu_stas"`
  2514. PsnType string `json:"psn_type"`
  2515. } `json:"insuinfo"`
  2516. } `json:"output"`
  2517. RefmsgTime string `json:"refmsg_time"`
  2518. RespondTime string `json:"respond_time"`
  2519. Signtype interface{} `json:"signtype"`
  2520. WarnInfo interface{} `json:"warn_info"`
  2521. }
  2522. type ResultTwo10265 struct {
  2523. ErrMsg string `json:"err_msg"`
  2524. InfRefmsgid string `json:"inf_refmsgid"`
  2525. Infcode string `json:"infcode"`
  2526. Output struct {
  2527. Baseinfo struct {
  2528. Age float64 `json:"age"`
  2529. Brdy string `json:"brdy"`
  2530. Certno string `json:"certno"`
  2531. Gend string `json:"gend"`
  2532. Naty string `json:"naty"`
  2533. PsnCertType string `json:"psn_cert_type"`
  2534. PsnName string `json:"psn_name"`
  2535. PsnNo string `json:"psn_no"`
  2536. } `json:"baseinfo"`
  2537. Idetinfo []interface{} `json:"idetinfo"`
  2538. Iinfo []struct {
  2539. Balc float64 `json:"balc"`
  2540. CvlservFlag string `json:"cvlserv_flag"`
  2541. EmpName string `json:"emp_name"`
  2542. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2543. Insutype string `json:"insutype"`
  2544. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2545. PausInsuDate string `json:"paus_insu_date"`
  2546. PsnInsuDate string `json:"psn_insu_date"`
  2547. PsnInsuStas string `json:"psn_insu_stas"`
  2548. PsnType string `json:"psn_type"`
  2549. } `json:"insuinfo"`
  2550. } `json:"output"`
  2551. RefmsgTime string `json:"refmsg_time"`
  2552. RespondTime string `json:"respond_time"`
  2553. Signtype interface{} `json:"signtype"`
  2554. WarnInfo interface{} `json:"warn_info"`
  2555. }
  2556. type ResultThree struct {
  2557. Cainfo interface{} `json:"cainfo"`
  2558. ErrMsg string `json:"err_msg"`
  2559. InfRefmsgid string `json:"inf_refmsgid"`
  2560. Infcode int64 `json:"infcode"`
  2561. Output struct {
  2562. Data struct {
  2563. IptOtpNo string `json:"ipt_otp_no"`
  2564. MdtrtID string `json:"mdtrt_id"`
  2565. PsnNo string `json:"psn_no"`
  2566. } `json:"data"`
  2567. } `json:"output"`
  2568. RefmsgTime string `json:"refmsg_time"`
  2569. RespondTime string `json:"respond_time"`
  2570. Signtype interface{} `json:"signtype"`
  2571. WarnMsg interface{} `json:"warn_msg"`
  2572. }
  2573. type ResultThree10265 struct {
  2574. Cainfo interface{} `json:"cainfo"`
  2575. ErrMsg string `json:"err_msg"`
  2576. InfRefmsgid string `json:"inf_refmsgid"`
  2577. Infcode string `json:"infcode"`
  2578. Output struct {
  2579. Data struct {
  2580. IptOtpNo string `json:"ipt_otp_no"`
  2581. MdtrtID string `json:"mdtrt_id"`
  2582. PsnNo string `json:"psn_no"`
  2583. } `json:"data"`
  2584. } `json:"output"`
  2585. RefmsgTime string `json:"refmsg_time"`
  2586. RespondTime string `json:"respond_time"`
  2587. Signtype interface{} `json:"signtype"`
  2588. WarnMsg interface{} `json:"warn_msg"`
  2589. }
  2590. type ResultFour struct {
  2591. Cainfo string `json:"cainfo"`
  2592. ErrMsg string `json:"err_msg"`
  2593. InfRefmsgid string `json:"inf_refmsgid"`
  2594. Infcode int64 `json:"infcode"`
  2595. Output struct {
  2596. Result []struct {
  2597. BasMednFlag string `json:"bas_medn_flag"`
  2598. ChldMedcFlag string `json:"chld_medc_flag"`
  2599. ChrgitmLv string `json:"chrgitm_lv"`
  2600. Cnt float64 `json:"cnt"`
  2601. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2602. DrtReimFlag string `json:"drt_reim_flag"`
  2603. FeedetlSn string `json:"feedetl_sn"`
  2604. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2605. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2606. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2607. ListSpItemFlag string `json:"list_sp_item_flag"`
  2608. LmtUsedFlag string `json:"lmt_used_flag"`
  2609. MedChrgitmType string `json:"med_chrgitm_type"`
  2610. Memo string `json:"memo"`
  2611. OverlmtAmt float64 `json:"overlmt_amt"`
  2612. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2613. Pric float64 `json:"pric"`
  2614. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2615. SelfpayProp float64 `json:"selfpay_prop"`
  2616. } `json:"result"`
  2617. } `json:"output"`
  2618. RefmsgTime string `json:"refmsg_time"`
  2619. RespondTime string `json:"respond_time"`
  2620. Signtype string `json:"signtype"`
  2621. WarnMsg string `json:"warn_msg"`
  2622. }
  2623. type ResultFour10265 struct {
  2624. Cainfo string `json:"cainfo"`
  2625. ErrMsg string `json:"err_msg"`
  2626. InfRefmsgid string `json:"inf_refmsgid"`
  2627. Infcode string `json:"infcode"`
  2628. Output struct {
  2629. Result []struct {
  2630. BasMednFlag string `json:"bas_medn_flag"`
  2631. ChldMedcFlag string `json:"chld_medc_flag"`
  2632. ChrgitmLv string `json:"chrgitm_lv"`
  2633. Cnt float64 `json:"cnt"`
  2634. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2635. DrtReimFlag string `json:"drt_reim_flag"`
  2636. FeedetlSn string `json:"feedetl_sn"`
  2637. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2638. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2639. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2640. ListSpItemFlag string `json:"list_sp_item_flag"`
  2641. LmtUsedFlag string `json:"lmt_used_flag"`
  2642. MedChrgitmType string `json:"med_chrgitm_type"`
  2643. Memo string `json:"memo"`
  2644. OverlmtAmt float64 `json:"overlmt_amt"`
  2645. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2646. Pric float64 `json:"pric"`
  2647. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2648. SelfpayProp float64 `json:"selfpay_prop"`
  2649. } `json:"result"`
  2650. } `json:"output"`
  2651. RefmsgTime string `json:"refmsg_time"`
  2652. RespondTime string `json:"respond_time"`
  2653. Signtype string `json:"signtype"`
  2654. WarnMsg string `json:"warn_msg"`
  2655. }
  2656. type ResultFive struct {
  2657. Balc float64 `json:"balc"`
  2658. CvlservFlag string `json:"cvlserv_flag"`
  2659. EmpName string `json:"emp_name"`
  2660. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2661. Insutype string `json:"insutype"`
  2662. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2663. PausInsuDate string `json:"paus_insu_date"`
  2664. PsnInsuDate string `json:"psn_insu_date"`
  2665. PsnInsuStas string `json:"psn_insu_stas"`
  2666. PsnType string `json:"psn_type"`
  2667. }
  2668. type ResultSix struct {
  2669. Cainfo interface{} `json:"cainfo"`
  2670. ErrMsg string `json:"err_msg"`
  2671. InfRefmsgid string `json:"inf_refmsgid"`
  2672. Infcode int64 `json:"infcode"`
  2673. Output struct {
  2674. } `json:"output"`
  2675. RefmsgTime string `json:"refmsg_time"`
  2676. RespondTime string `json:"respond_time"`
  2677. Signtype interface{} `json:"signtype"`
  2678. WarnMsg interface{} `json:"warn_msg"`
  2679. }
  2680. type ResultSix10265 struct {
  2681. Cainfo interface{} `json:"cainfo"`
  2682. ErrMsg string `json:"err_msg"`
  2683. InfRefmsgid string `json:"inf_refmsgid"`
  2684. Infcode string `json:"infcode"`
  2685. Output struct {
  2686. } `json:"output"`
  2687. RefmsgTime string `json:"refmsg_time"`
  2688. RespondTime string `json:"respond_time"`
  2689. Signtype interface{} `json:"signtype"`
  2690. WarnMsg interface{} `json:"warn_msg"`
  2691. }
  2692. type ResultSeven struct {
  2693. Cainfo string `json:"cainfo"`
  2694. ErrMsg string `json:"err_msg"`
  2695. InfRefmsgid string `json:"inf_refmsgid"`
  2696. Infcode int64 `json:"infcode"`
  2697. Output struct {
  2698. Setldetail []interface{} `json:"setldetail"`
  2699. Setlinfo struct {
  2700. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2701. AcctPay float64 `json:"acct_pay"`
  2702. ActPayDedc float64 `json:"act_pay_dedc"`
  2703. Age float64 `json:"age"`
  2704. Balc float64 `json:"balc"`
  2705. Brdy string `json:"brdy"`
  2706. Certno string `json:"certno"`
  2707. ClrOptins string `json:"clr_optins"`
  2708. ClrType string `json:"clr_type"`
  2709. ClrWay string `json:"clr_way"`
  2710. CvlservFlag string `json:"cvlserv_flag"`
  2711. CvlservPay float64 `json:"cvlserv_pay"`
  2712. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2713. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2714. Gend string `json:"gend"`
  2715. HifesPay float64 `json:"hifes_pay"`
  2716. HifmiPay float64 `json:"hifmi_pay"`
  2717. HifpPay float64 `json:"hifp_pay"`
  2718. HospPartAmt float64 `json:"hosp_part_amt"`
  2719. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2720. Insutype string `json:"insutype"`
  2721. MafPay float64 `json:"maf_pay"`
  2722. MdtrtCertType string `json:"mdtrt_cert_type"`
  2723. HifobPay float64 `json:"hifob_pay"`
  2724. MdtrtID string `json:"mdtrt_id"`
  2725. MedType string `json:"med_type"`
  2726. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2727. MedinsSetlID string `json:"medins_setl_id"`
  2728. Naty string `json:"naty"`
  2729. OthPay float64 `json:"oth_pay"`
  2730. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2731. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2732. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2733. PsnCashPay float64 `json:"psn_cash_pay"`
  2734. PsnCertType string `json:"psn_cert_type"`
  2735. PsnName string `json:"psn_name"`
  2736. PsnNo string `json:"psn_no"`
  2737. PsnPartAmt float64 `json:"psn_part_amt"`
  2738. PsnType string `json:"psn_type"`
  2739. SetlID string `json:"setl_id"`
  2740. SetlTime string `json:"setl_time"`
  2741. } `json:"setlinfo"`
  2742. } `json:"output"`
  2743. RefmsgTime string `json:"refmsg_time"`
  2744. RespondTime string `json:"respond_time"`
  2745. Signtype interface{} `json:"signtype"`
  2746. WarnMsg interface{} `json:"warn_msg"`
  2747. }
  2748. type ResultSeven10265 struct {
  2749. Cainfo string `json:"cainfo"`
  2750. ErrMsg string `json:"err_msg"`
  2751. InfRefmsgid string `json:"inf_refmsgid"`
  2752. Infcode string `json:"infcode"`
  2753. Output struct {
  2754. Setldetail []interface{} `json:"setldetail"`
  2755. Setlinfo struct {
  2756. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2757. AcctPay float64 `json:"acct_pay"`
  2758. ActPayDedc float64 `json:"act_pay_dedc"`
  2759. Age float64 `json:"age"`
  2760. Balc float64 `json:"balc"`
  2761. Brdy string `json:"brdy"`
  2762. Certno string `json:"certno"`
  2763. ClrOptins string `json:"clr_optins"`
  2764. ClrType string `json:"clr_type"`
  2765. ClrWay string `json:"clr_way"`
  2766. CvlservFlag string `json:"cvlserv_flag"`
  2767. CvlservPay float64 `json:"cvlserv_pay"`
  2768. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2769. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2770. Gend string `json:"gend"`
  2771. HifesPay float64 `json:"hifes_pay"`
  2772. HifmiPay float64 `json:"hifmi_pay"`
  2773. HifpPay float64 `json:"hifp_pay"`
  2774. HospPartAmt float64 `json:"hosp_part_amt"`
  2775. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2776. Insutype string `json:"insutype"`
  2777. MafPay float64 `json:"maf_pay"`
  2778. MdtrtCertType string `json:"mdtrt_cert_type"`
  2779. HifobPay float64 `json:"hifob_pay"`
  2780. MdtrtID string `json:"mdtrt_id"`
  2781. MedType string `json:"med_type"`
  2782. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2783. MedinsSetlID string `json:"medins_setl_id"`
  2784. Naty string `json:"naty"`
  2785. OthPay float64 `json:"oth_pay"`
  2786. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2787. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2788. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2789. PsnCashPay float64 `json:"psn_cash_pay"`
  2790. PsnCertType string `json:"psn_cert_type"`
  2791. PsnName string `json:"psn_name"`
  2792. PsnNo string `json:"psn_no"`
  2793. PsnPartAmt float64 `json:"psn_part_amt"`
  2794. PsnType string `json:"psn_type"`
  2795. SetlID string `json:"setl_id"`
  2796. SetlTime string `json:"setl_time"`
  2797. } `json:"setlinfo"`
  2798. } `json:"output"`
  2799. RefmsgTime string `json:"refmsg_time"`
  2800. RespondTime string `json:"respond_time"`
  2801. Signtype interface{} `json:"signtype"`
  2802. WarnMsg interface{} `json:"warn_msg"`
  2803. }
  2804. type ResultEight struct {
  2805. Cainfo string `json:"cainfo"`
  2806. ErrMsg string `json:"err_msg"`
  2807. InfRefmsgid string `json:"inf_refmsgid"`
  2808. Infcode int64 `json:"infcode"`
  2809. Output struct {
  2810. Stmtinfo struct {
  2811. SetlOptins string `json:"setl_optins"`
  2812. StmtRslt string `json:"stmt_rslt"`
  2813. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2814. } `json:"stmtinfo"`
  2815. } `json:"output"`
  2816. RefmsgTime string `json:"refmsg_time"`
  2817. RespondTime string `json:"respond_time"`
  2818. Signtype interface{} `json:"signtype"`
  2819. WarnMsg interface{} `json:"warn_msg"`
  2820. }
  2821. type ResultEightFor10188 struct {
  2822. Cainfo string `json:"cainfo"`
  2823. ErrMsg string `json:"err_msg"`
  2824. InfRefmsgid string `json:"inf_refmsgid"`
  2825. Infcode string `json:"infcode"`
  2826. Output struct {
  2827. Stmtinfo struct {
  2828. SetlOptins string `json:"setl_optins"`
  2829. StmtRslt string `json:"stmt_rslt"`
  2830. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2831. } `json:"stmtinfo"`
  2832. } `json:"output"`
  2833. RefmsgTime string `json:"refmsg_time"`
  2834. RespondTime string `json:"respond_time"`
  2835. Signtype interface{} `json:"signtype"`
  2836. WarnMsg interface{} `json:"warn_msg"`
  2837. }
  2838. type ResultNine struct {
  2839. Cainfo string `json:"cainfo"`
  2840. ErrMsg string `json:"err_msg"`
  2841. InfRefmsgid string `json:"inf_refmsgid"`
  2842. Infcode int64 `json:"infcode"`
  2843. Output struct {
  2844. FileQuryNo string `json:"file_qury_no"`
  2845. } `json:"output"`
  2846. RefmsgTime string `json:"refmsg_time"`
  2847. RespondTime string `json:"respond_time"`
  2848. Signtype interface{} `json:"signtype"`
  2849. WarnMsg interface{} `json:"warn_msg"`
  2850. }
  2851. type ResultTen struct {
  2852. Cainfo string `json:"cainfo"`
  2853. ErrMsg string `json:"err_msg"`
  2854. InfRefmsgid string `json:"inf_refmsgid"`
  2855. Infcode int64 `json:"infcode"`
  2856. Output struct {
  2857. DldEndtime string `json:"dld_endtime"`
  2858. FileQuryNo string `json:"file_qury_no"`
  2859. Filename string `json:"filename"`
  2860. } `json:"output"`
  2861. RefmsgTime string `json:"refmsg_time"`
  2862. RespondTime string `json:"respond_time"`
  2863. Signtype interface{} `json:"signtype"`
  2864. WarnMsg interface{} `json:"warn_msg"`
  2865. }
  2866. //type Autogenerated struct {
  2867. // Output struct {
  2868. // Setlinfo struct {
  2869. // SetlTime string `json:"setl_time"`
  2870. // CvlservPay float64 `json:"cvlserv_pay"`
  2871. // Year string `json:"year"`
  2872. // MedType string `json:"med_type"`
  2873. // PsnPay float64 `json:"psn_pay"`
  2874. // OpterID string `json:"opter_id"`
  2875. // Begndate string `json:"begndate"`
  2876. // FlxempeFlag string `json:"flxempe_flag"`
  2877. // HifmiPay float64 `json:"hifmi_pay"`
  2878. // PsnNo string `json:"psn_no"`
  2879. // ActPayDedc float64 `json:"act_pay_dedc"`
  2880. // MedinsSetlID interface{} `json:"medins_setl_id"`
  2881. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2882. // ClrWay string `json:"clr_way"`
  2883. // OthPay float64 `json:"oth_pay"`
  2884. // Gend string `json:"gend"`
  2885. // MdtrtID string `json:"mdtrt_id"`
  2886. // AcctPay float64 `json:"acct_pay"`
  2887. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  2888. // Insutype string `json:"insutype"`
  2889. // Invono interface{} `json:"invono"`
  2890. // Enddate string `json:"enddate"`
  2891. // CashPayamt float64 `json:"cash_payamt"`
  2892. // PsnType string `json:"psn_type"`
  2893. // FixmedinsName string `json:"fixmedins_name"`
  2894. // HifpPay float64 `json:"hifp_pay"`
  2895. // NewFlag interface{} `json:"new_flag"`
  2896. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2897. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  2898. // PayLoc string `json:"pay_loc"`
  2899. // ClrType string `json:"clr_type"`
  2900. // RefdSetlFlag string `json:"refd_setl_flag"`
  2901. // CvlservFlag string `json:"cvlserv_flag"`
  2902. // EmpName string `json:"emp_name"`
  2903. // Brdy string `json:"brdy"`
  2904. // Naty string `json:"naty"`
  2905. // Certno string `json:"certno"`
  2906. // DiseCode string `json:"dise_code"`
  2907. // FixmedinsCode string `json:"fixmedins_code"`
  2908. // DedcHospLv string `json:"dedc_hosp_lv"`
  2909. // OpterName string `json:"opter_name"`
  2910. // Balc float64 `json:"balc"`
  2911. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2912. // PsnCertType string `json:"psn_cert_type"`
  2913. // HifobPay float64 `json:"hifob_pay"`
  2914. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  2915. // HifesPay float64 `json:"hifes_pay"`
  2916. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2917. // OptTime string `json:"opt_time"`
  2918. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2919. // SetlID string `json:"setl_id"`
  2920. // MafPay float64 `json:"maf_pay"`
  2921. // PsnName string `json:"psn_name"`
  2922. // InsuOptins interface{} `json:"insu_optins"`
  2923. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2924. // ClrOptins string `json:"clr_optins"`
  2925. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2926. // DiseName string `json:"dise_name"`
  2927. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2928. // Age float64 `json:"age"`
  2929. // DtrtCertType string `json:"dtrt_cert_type"`
  2930. // HospLv string `json:"hosp_lv"`
  2931. // } `json:"setlinfo"`
  2932. // Setldetail []struct {
  2933. // FundPayType string `json:"fund_pay_type"`
  2934. // FundPayamt float64 `json:"fund_payamt"`
  2935. // SetlProcInfo interface{} `json:"setl_proc_info"`
  2936. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  2937. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  2938. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  2939. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2940. // } `json:"setldetail"`
  2941. // } `json:"output"`
  2942. // Infcode int `json:"infcode"`
  2943. // WarnMsg interface{} `json:"warn_msg"`
  2944. // Cainfo interface{} `json:"cainfo"`
  2945. // ErrMsg interface{} `json:"err_msg"`
  2946. // RefmsgTime string `json:"refmsg_time"`
  2947. // Signtype interface{} `json:"signtype"`
  2948. // RespondTime string `json:"respond_time"`
  2949. // InfRefmsgid string `json:"inf_refmsgid"`
  2950. //}
  2951. type ResultEleven struct {
  2952. Cainfo string `json:"cainfo"`
  2953. ErrMsg string `json:"err_msg"`
  2954. InfRefmsgid string `json:"inf_refmsgid"`
  2955. Infcode int64 `json:"infcode"`
  2956. Output struct {
  2957. Setlinfo struct {
  2958. SetlTime string `json:"setl_time"`
  2959. CvlservPay float64 `json:"cvlserv_pay"`
  2960. Year string `json:"year"`
  2961. MedType string `json:"med_type"`
  2962. PsnPay float64 `json:"psn_pay"`
  2963. OpterID string `json:"opter_id"`
  2964. Begndate string `json:"begndate"`
  2965. FlxempeFlag string `json:"flxempe_flag"`
  2966. HifmiPay float64 `json:"hifmi_pay"`
  2967. PsnNo string `json:"psn_no"`
  2968. ActPayDedc float64 `json:"act_pay_dedc"`
  2969. MedinsSetlID interface{} `json:"medins_setl_id"`
  2970. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2971. ClrWay string `json:"clr_way"`
  2972. OthPay float64 `json:"oth_pay"`
  2973. Gend string `json:"gend"`
  2974. MdtrtID string `json:"mdtrt_id"`
  2975. AcctPay float64 `json:"acct_pay"`
  2976. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2977. Insutype string `json:"insutype"`
  2978. Invono interface{} `json:"invono"`
  2979. Enddate string `json:"enddate"`
  2980. CashPayamt float64 `json:"cash_payamt"`
  2981. PsnType string `json:"psn_type"`
  2982. FixmedinsName string `json:"fixmedins_name"`
  2983. HifpPay float64 `json:"hifp_pay"`
  2984. NewFlag interface{} `json:"new_flag"`
  2985. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2986. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2987. PayLoc string `json:"pay_loc"`
  2988. ClrType string `json:"clr_type"`
  2989. RefdSetlFlag string `json:"refd_setl_flag"`
  2990. CvlservFlag string `json:"cvlserv_flag"`
  2991. EmpName string `json:"emp_name"`
  2992. Brdy string `json:"brdy"`
  2993. Naty string `json:"naty"`
  2994. Certno string `json:"certno"`
  2995. DiseCode string `json:"dise_code"`
  2996. FixmedinsCode string `json:"fixmedins_code"`
  2997. DedcHospLv string `json:"dedc_hosp_lv"`
  2998. OpterName string `json:"opter_name"`
  2999. Balc float64 `json:"balc"`
  3000. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3001. PsnCertType string `json:"psn_cert_type"`
  3002. HifobPay float64 `json:"hifob_pay"`
  3003. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3004. HifesPay float64 `json:"hifes_pay"`
  3005. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3006. OptTime string `json:"opt_time"`
  3007. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3008. SetlID string `json:"setl_id"`
  3009. MafPay float64 `json:"maf_pay"`
  3010. PsnName string `json:"psn_name"`
  3011. InsuOptins interface{} `json:"insu_optins"`
  3012. PrefFundPay interface{} `json:"pref_fund_pay"`
  3013. ClrOptins string `json:"clr_optins"`
  3014. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3015. DiseName string `json:"dise_name"`
  3016. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3017. Age float64 `json:"age"`
  3018. DtrtCertType string `json:"dtrt_cert_type"`
  3019. HospLv string `json:"hosp_lv"`
  3020. } `json:"setlinfo"`
  3021. } `json:"output"`
  3022. RefmsgTime string `json:"refmsg_time"`
  3023. RespondTime string `json:"respond_time"`
  3024. Signtype interface{} `json:"signtype"`
  3025. WarnMsg interface{} `json:"warn_msg"`
  3026. }
  3027. type ResultEleven10265 struct {
  3028. Cainfo string `json:"cainfo"`
  3029. ErrMsg string `json:"err_msg"`
  3030. InfRefmsgid string `json:"inf_refmsgid"`
  3031. Infcode string `json:"infcode"`
  3032. Output struct {
  3033. Setlinfo struct {
  3034. SetlTime string `json:"setl_time"`
  3035. CvlservPay float64 `json:"cvlserv_pay"`
  3036. Year string `json:"year"`
  3037. MedType string `json:"med_type"`
  3038. PsnPay float64 `json:"psn_pay"`
  3039. OpterID string `json:"opter_id"`
  3040. Begndate string `json:"begndate"`
  3041. FlxempeFlag string `json:"flxempe_flag"`
  3042. HifmiPay float64 `json:"hifmi_pay"`
  3043. PsnNo string `json:"psn_no"`
  3044. ActPayDedc float64 `json:"act_pay_dedc"`
  3045. MedinsSetlID interface{} `json:"medins_setl_id"`
  3046. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3047. ClrWay string `json:"clr_way"`
  3048. OthPay float64 `json:"oth_pay"`
  3049. Gend string `json:"gend"`
  3050. MdtrtID string `json:"mdtrt_id"`
  3051. AcctPay float64 `json:"acct_pay"`
  3052. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3053. Insutype string `json:"insutype"`
  3054. Invono interface{} `json:"invono"`
  3055. Enddate string `json:"enddate"`
  3056. CashPayamt float64 `json:"cash_payamt"`
  3057. PsnType string `json:"psn_type"`
  3058. FixmedinsName string `json:"fixmedins_name"`
  3059. HifpPay float64 `json:"hifp_pay"`
  3060. NewFlag interface{} `json:"new_flag"`
  3061. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3062. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3063. PayLoc string `json:"pay_loc"`
  3064. ClrType string `json:"clr_type"`
  3065. RefdSetlFlag string `json:"refd_setl_flag"`
  3066. CvlservFlag string `json:"cvlserv_flag"`
  3067. EmpName string `json:"emp_name"`
  3068. Brdy string `json:"brdy"`
  3069. Naty string `json:"naty"`
  3070. Certno string `json:"certno"`
  3071. DiseCode string `json:"dise_code"`
  3072. FixmedinsCode string `json:"fixmedins_code"`
  3073. DedcHospLv string `json:"dedc_hosp_lv"`
  3074. OpterName string `json:"opter_name"`
  3075. Balc float64 `json:"balc"`
  3076. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3077. PsnCertType string `json:"psn_cert_type"`
  3078. HifobPay float64 `json:"hifob_pay"`
  3079. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3080. HifesPay float64 `json:"hifes_pay"`
  3081. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3082. OptTime string `json:"opt_time"`
  3083. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3084. SetlID string `json:"setl_id"`
  3085. MafPay float64 `json:"maf_pay"`
  3086. PsnName string `json:"psn_name"`
  3087. InsuOptins interface{} `json:"insu_optins"`
  3088. PrefFundPay interface{} `json:"pref_fund_pay"`
  3089. ClrOptins string `json:"clr_optins"`
  3090. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3091. DiseName string `json:"dise_name"`
  3092. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3093. Age float64 `json:"age"`
  3094. DtrtCertType string `json:"dtrt_cert_type"`
  3095. HospLv string `json:"hosp_lv"`
  3096. } `json:"setlinfo"`
  3097. } `json:"output"`
  3098. RefmsgTime string `json:"refmsg_time"`
  3099. RespondTime string `json:"respond_time"`
  3100. Signtype interface{} `json:"signtype"`
  3101. WarnMsg interface{} `json:"warn_msg"`
  3102. }
  3103. type ResultTwelve struct {
  3104. Cainfo string `json:"cainfo"`
  3105. ErrMsg string `json:"err_msg"`
  3106. InfRefmsgid string `json:"inf_refmsgid"`
  3107. Infcode int64 `json:"infcode"`
  3108. Output struct {
  3109. MdtrtId string `json:"mdtrt_id"`
  3110. ChrgBchno string `json:"chrg_bchno"`
  3111. PsnNo string `json:"psn_no"`
  3112. } `json:"output"`
  3113. RefmsgTime string `json:"refmsg_time"`
  3114. RespondTime string `json:"respond_time"`
  3115. Signtype interface{} `json:"signtype"`
  3116. WarnMsg interface{} `json:"warn_msg"`
  3117. }
  3118. type ResultThirteen struct {
  3119. ErrMsg string `json:"err_msg"`
  3120. InfRefmsgid string `json:"inf_refmsgid"`
  3121. Infcode int64 `json:"infcode"`
  3122. Output struct {
  3123. Result struct {
  3124. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3125. } `json:"result"`
  3126. } `json:"output"`
  3127. RefmsgTime string `json:"refmsg_time"`
  3128. RespondTime string `json:"respond_time"`
  3129. Signtype interface{} `json:"signtype"`
  3130. WarnInfo interface{} `json:"warn_info"`
  3131. }
  3132. type ResultThirteen10265 struct {
  3133. ErrMsg string `json:"err_msg"`
  3134. InfRefmsgid string `json:"inf_refmsgid"`
  3135. Infcode string `json:"infcode"`
  3136. Output struct {
  3137. Result struct {
  3138. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3139. } `json:"result"`
  3140. } `json:"output"`
  3141. RefmsgTime string `json:"refmsg_time"`
  3142. RespondTime string `json:"respond_time"`
  3143. Signtype interface{} `json:"signtype"`
  3144. WarnInfo interface{} `json:"warn_info"`
  3145. }
  3146. type ResultFourteen struct {
  3147. ErrMsg string `json:"err_msg"`
  3148. InfRefmsgid string `json:"inf_refmsgid"`
  3149. Infcode int64 `json:"infcode"`
  3150. Output struct {
  3151. } `json:"output"`
  3152. RefmsgTime string `json:"refmsg_time"`
  3153. RespondTime string `json:"respond_time"`
  3154. Signtype interface{} `json:"signtype"`
  3155. WarnInfo interface{} `json:"warn_info"`
  3156. }
  3157. type ResultFourteen10265 struct {
  3158. ErrMsg string `json:"err_msg"`
  3159. InfRefmsgid string `json:"inf_refmsgid"`
  3160. Infcode string `json:"infcode"`
  3161. Output struct {
  3162. } `json:"output"`
  3163. RefmsgTime string `json:"refmsg_time"`
  3164. RespondTime string `json:"respond_time"`
  3165. Signtype interface{} `json:"signtype"`
  3166. WarnInfo interface{} `json:"warn_info"`
  3167. }
  3168. type ResultSixteen struct {
  3169. Cainfo string `json:"cainfo"`
  3170. ErrMsg string `json:"err_msg"`
  3171. InfRefmsgid string `json:"inf_refmsgid"`
  3172. Infcode int64 `json:"infcode"`
  3173. Output struct {
  3174. Setldetail []interface{} `json:"setldetail"`
  3175. Setlinfo struct {
  3176. MdtrtID string `json:"mdtrt_id"`
  3177. SetlID string `json:"setl_id"`
  3178. ClrOptins string `json:"clr_optins"`
  3179. SetlTime string `json:"setl_time"`
  3180. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3181. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3182. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3183. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3184. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3185. ActPayDedc float64 `json:"act_pay_dedc"`
  3186. HifpPay float64 `json:"hifp_pay"`
  3187. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3188. Lfpay float64 `json:"selfpay"`
  3189. CvlservPay float64 `json:"cvlserv_pay"`
  3190. HifesPay float64 `json:"hifes_pay"`
  3191. HifmiPay float64 `json:"hifmi_pay"`
  3192. HifobPay float64 `json:"hifob_pay"`
  3193. MafPay float64 `json:"maf_pay"`
  3194. OthPay float64 `json:"oth_pay"`
  3195. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3196. PsnPartAmt float64 `json:"psn_part_amt"`
  3197. AcctPay float64 `json:"acct_pay"`
  3198. Balc float64 `json:"balc"`
  3199. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3200. HospPartAmt float64 `json:"hosp_part_amt"`
  3201. MedinsSetlID string `json:"medins_setl_id"`
  3202. PdnCashPay string `json:"pdn_cash_pay"`
  3203. } `json:"setlinfo"`
  3204. } `json:"output"`
  3205. RefmsgTime string `json:"refmsg_time"`
  3206. RespondTime string `json:"respond_time"`
  3207. Signtype interface{} `json:"signtype"`
  3208. WarnMsg interface{} `json:"warn_msg"`
  3209. }
  3210. type ResultSixteen10265 struct {
  3211. Cainfo string `json:"cainfo"`
  3212. ErrMsg string `json:"err_msg"`
  3213. InfRefmsgid string `json:"inf_refmsgid"`
  3214. Infcode string `json:"infcode"`
  3215. Output struct {
  3216. Setldetail []interface{} `json:"setldetail"`
  3217. Setlinfo struct {
  3218. MdtrtID string `json:"mdtrt_id"`
  3219. SetlID string `json:"setl_id"`
  3220. ClrOptins string `json:"clr_optins"`
  3221. SetlTime string `json:"setl_time"`
  3222. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3223. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3224. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3225. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3226. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3227. ActPayDedc float64 `json:"act_pay_dedc"`
  3228. HifpPay float64 `json:"hifp_pay"`
  3229. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3230. Lfpay float64 `json:"selfpay"`
  3231. CvlservPay float64 `json:"cvlserv_pay"`
  3232. HifesPay float64 `json:"hifes_pay"`
  3233. HifmiPay float64 `json:"hifmi_pay"`
  3234. HifobPay float64 `json:"hifob_pay"`
  3235. MafPay float64 `json:"maf_pay"`
  3236. OthPay float64 `json:"oth_pay"`
  3237. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3238. PsnPartAmt float64 `json:"psn_part_amt"`
  3239. AcctPay float64 `json:"acct_pay"`
  3240. Balc float64 `json:"balc"`
  3241. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3242. HospPartAmt float64 `json:"hosp_part_amt"`
  3243. MedinsSetlID string `json:"medins_setl_id"`
  3244. PdnCashPay string `json:"pdn_cash_pay"`
  3245. } `json:"setlinfo"`
  3246. } `json:"output"`
  3247. RefmsgTime string `json:"refmsg_time"`
  3248. RespondTime string `json:"respond_time"`
  3249. Signtype interface{} `json:"signtype"`
  3250. WarnMsg interface{} `json:"warn_msg"`
  3251. }
  3252. type ResultSeventeen struct {
  3253. ErrMsg string `json:"err_msg"`
  3254. InfRefmsgid string `json:"inf_refmsgid"`
  3255. Infcode int64 `json:"infcode"`
  3256. Output struct {
  3257. SetlListId string `json:"setl_list_id"`
  3258. } `json:"output"`
  3259. RefmsgTime string `json:"refmsg_time"`
  3260. RespondTime string `json:"respond_time"`
  3261. Signtype string `json:"signtype"`
  3262. WarnInfo string `json:"warn_info"`
  3263. }
  3264. type Result90991 struct {
  3265. ErrMsg string `json:"err_msg"`
  3266. InfRefmsgid string `json:"inf_refmsgid"`
  3267. Infcode int64 `json:"infcode"`
  3268. Output struct {
  3269. Result struct {
  3270. PsnNo string `json:"psn_no"`
  3271. CardStat string `json:"card_stat"`
  3272. Certno string `json:"certno"`
  3273. PsnName string `json:"psn_name"`
  3274. CheckStat string `json:"check_stat"`
  3275. } `json:"result"`
  3276. } `json:"output"`
  3277. RefmsgTime string `json:"refmsg_time"`
  3278. RespondTime string `json:"respond_time"`
  3279. Signtype interface{} `json:"signtype"`
  3280. WarnInfo interface{} `json:"warn_info"`
  3281. }
  3282. type Result90100 struct {
  3283. ErrMsg string `json:"err_msg"`
  3284. InfRefmsgid string `json:"inf_refmsgid"`
  3285. Infcode int64 `json:"infcode"`
  3286. Output struct {
  3287. PoolareaNo string `json:"poolarea_no"`
  3288. PoolareaNoName string `json:"poolarea_no_name"`
  3289. Insutype string `json:"insutype"`
  3290. InsutypeName string `json:"insutype_name"`
  3291. ClctType string `json:"clct_type"`
  3292. ClctTypeName string `json:"clct_type_name"`
  3293. ClctFlag string `json:"clct_flag"`
  3294. ClctFlagName string `json:"clct_flag_name"`
  3295. AccrymBegn string `json:"accrym_begn"`
  3296. AccrymEnd string `json:"accrym_end"`
  3297. ClctTime string `json:"clct_time"`
  3298. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3299. } `json:"output"`
  3300. RefmsgTime string `json:"refmsg_time"`
  3301. RespondTime string `json:"respond_time"`
  3302. Signtype interface{} `json:"signtype"`
  3303. WarnInfo interface{} `json:"warn_info"`
  3304. }
  3305. type Custom struct {
  3306. DetItemFeeSumamt string
  3307. Cut string
  3308. FeedetlSn string
  3309. Price string
  3310. MedListCodg string
  3311. Type int64
  3312. AdviceId int64
  3313. ProjectId int64
  3314. ItemId int64
  3315. }
  3316. type Result5301 struct {
  3317. ErrMsg string `json:"err_msg"`
  3318. InfRefmsgid string `json:"inf_refmsgid"`
  3319. Infcode int64 `json:"infcode"`
  3320. Output struct {
  3321. Result []struct {
  3322. OpspDiseCode string `json:"opsp_dise_code"`
  3323. OpspDiseName string `json:"opsp_dise_name"`
  3324. Begndate string `json:"begndate"`
  3325. Enddate string `json:"enddate"`
  3326. } `json:"feedetail"`
  3327. } `json:"output"`
  3328. RefmsgTime string `json:"refmsg_time"`
  3329. RespondTime string `json:"respond_time"`
  3330. Signtype interface{} `json:"signtype"`
  3331. WarnInfo interface{} `json:"warn_info"`
  3332. }
  3333. type Result5301For10265 struct {
  3334. ErrMsg string `json:"err_msg"`
  3335. InfRefmsgid string `json:"inf_refmsgid"`
  3336. Infcode string `json:"infcode"`
  3337. Output struct {
  3338. Result []struct {
  3339. OpspDiseCode string `json:"opsp_dise_code"`
  3340. OpspDiseName string `json:"opsp_dise_name"`
  3341. Begndate string `json:"begndate"`
  3342. Enddate string `json:"enddate"`
  3343. } `json:"feedetail"`
  3344. } `json:"output"`
  3345. RefmsgTime string `json:"refmsg_time"`
  3346. RespondTime string `json:"respond_time"`
  3347. Signtype interface{} `json:"signtype"`
  3348. WarnInfo interface{} `json:"warn_info"`
  3349. }
  3350. //获取个人信息----挂号-----上传就诊信息
  3351. func (c *HisApiController) GetRegisterInfo() {
  3352. id, _ := c.GetInt64("id")
  3353. record_time := c.GetString("record_time")
  3354. settlementValue, _ := c.GetInt64("settlement_value")
  3355. medical_insurance_card := c.GetString("medical_insurance_card")
  3356. name := c.GetString("name")
  3357. id_card_type, _ := c.GetInt64("id_card_type")
  3358. certificates, _ := c.GetInt64("certificates")
  3359. medical_care, _ := c.GetInt64("medical_care")
  3360. birthday := c.GetString("birthday")
  3361. id_card := c.GetString("id_card")
  3362. register_type, _ := c.GetInt64("register")
  3363. doctor, _ := c.GetInt64("doctor")
  3364. department, _ := c.GetInt64("department")
  3365. gender, _ := c.GetInt64("sex")
  3366. registration_fee, _ := c.GetFloat("registration_fee")
  3367. medical_expenses, _ := c.GetFloat("medical_expenses")
  3368. social_type, _ := c.GetInt64("social_type")
  3369. med_type := c.GetString("social_type")
  3370. admin_user_id, _ := c.GetInt64("admin_user_id")
  3371. insuplc_admdvs := c.GetString("insuplc_admdvs")
  3372. timeLayout := "2006-01-02"
  3373. loc, _ := time.LoadLocation("Local")
  3374. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  3375. birthUnix := birthdays.Unix()
  3376. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3377. if err != nil {
  3378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3379. return
  3380. }
  3381. recordDateTime := theTime.Unix()
  3382. adminInfo := c.GetAdminUserInfo()
  3383. var patient service.Patients
  3384. if id == 0 {
  3385. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  3386. } else {
  3387. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  3388. }
  3389. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3390. if patientPrescription.ID == 0 {
  3391. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3392. }
  3393. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3394. if patient.ID == 0 {
  3395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3396. return
  3397. }
  3398. if len(patient.IdCardNo) == 0 {
  3399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3400. return
  3401. }
  3402. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3403. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  3404. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  3405. //就诊结算未完成,不能进行二次挂号
  3406. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  3407. if len(his) >= 1 {
  3408. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  3409. if len(his) >= 1 && order.ID == 0 {
  3410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  3411. return
  3412. }
  3413. }
  3414. //var register_log string
  3415. if config.IsOpen == 1 {
  3416. var res ResultTwo
  3417. var res10265 ResultTwo10265
  3418. var PsnNo string
  3419. var PsnCertType string
  3420. var Certno string
  3421. var PsnName string
  3422. var Gend string
  3423. var Naty string
  3424. var Brdy string
  3425. var Age float64
  3426. var infoStr string
  3427. var idetinfoStr string
  3428. var infocode int64
  3429. var verify_number string
  3430. fmt.Println(verify_number)
  3431. if miConfig.MdtrtareaAdmvs == "421300" {
  3432. psn_info, _ := service.GetPsnByPatientId(id)
  3433. PsnNo = psn_info.PsnNo
  3434. PsnCertType = psn_info.PsnCertType
  3435. Certno = psn_info.Certno
  3436. PsnName = psn_info.PsnName
  3437. Gend = psn_info.Gend
  3438. Naty = psn_info.Naty
  3439. Brdy = psn_info.Brdy
  3440. Age = psn_info.Age
  3441. infoStr = psn_info.Insuinfo
  3442. idetinfoStr = psn_info.Idetinfo
  3443. infocode = 0
  3444. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3445. psn_info, _ := service.GetPsnByPatientId(id)
  3446. PsnNo = psn_info.PsnNo
  3447. PsnCertType = psn_info.PsnCertType
  3448. Certno = psn_info.Certno
  3449. PsnName = psn_info.PsnName
  3450. Gend = psn_info.Gend
  3451. Naty = psn_info.Naty
  3452. Brdy = psn_info.Brdy
  3453. Age = psn_info.Age
  3454. infoStr = psn_info.Insuinfo
  3455. idetinfoStr = psn_info.Idetinfo
  3456. infocode = 0
  3457. verify_number = psn_info.VerifyNumber
  3458. } else {
  3459. var result string
  3460. var requestLog string
  3461. if miConfig.UserOrgId == 10138 {
  3462. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  3463. } else {
  3464. 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)
  3465. }
  3466. saveLog(result, requestLog, "1101", "人员基本信息获取")
  3467. if miConfig.Code == "H15049901371" {
  3468. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3469. utils.ErrorLog("解析失败:%v", err)
  3470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3471. return
  3472. }
  3473. res.ErrMsg = res10265.ErrMsg
  3474. res.Output = res10265.Output
  3475. res.InfRefmsgid = res10265.InfRefmsgid
  3476. } else {
  3477. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3478. utils.ErrorLog("解析失败:%v", err)
  3479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3480. return
  3481. }
  3482. }
  3483. PsnNo = res.Output.Baseinfo.PsnNo
  3484. PsnCertType = res.Output.Baseinfo.PsnCertType
  3485. Certno = res.Output.Baseinfo.Certno
  3486. PsnName = res.Output.Baseinfo.PsnName
  3487. Gend = res.Output.Baseinfo.Gend
  3488. Naty = res.Output.Baseinfo.Naty
  3489. Brdy = res.Output.Baseinfo.Brdy
  3490. Age = res.Output.Baseinfo.Age
  3491. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3492. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3493. infoStr = string(Iinfos)
  3494. idetinfoStr = string(Idetinfos)
  3495. if miConfig.Code == "H15049901371" {
  3496. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  3497. } else {
  3498. infocode = res.Infcode
  3499. }
  3500. }
  3501. if infocode == 0 {
  3502. his := models.VMHisPatient{
  3503. Name: name,
  3504. Gender: gender,
  3505. Birthday: birthUnix,
  3506. MedicalTreatmentType: medical_care,
  3507. IdType: certificates,
  3508. IdCardNo: id_card,
  3509. BalanceAccountsType: settlementValue,
  3510. SocialType: social_type,
  3511. MedicalInsuranceNumber: medical_insurance_card,
  3512. RegisterType: register_type,
  3513. RegisterCost: registration_fee,
  3514. TreatmentCost: medical_expenses,
  3515. Status: 1,
  3516. Ctime: time.Now().Unix(),
  3517. Mtime: time.Now().Unix(),
  3518. PsnNo: PsnNo,
  3519. PsnCertType: PsnCertType,
  3520. Certno: Certno,
  3521. PsnName: PsnName,
  3522. Gend: Gend,
  3523. Naty: Naty,
  3524. Brdy: Brdy,
  3525. Age: Age,
  3526. Iinfo: infoStr,
  3527. Idetinfo: idetinfoStr,
  3528. PatientId: patient.ID,
  3529. RecordDate: theTime.Unix(),
  3530. UserOrgId: adminInfo.CurrentOrgId,
  3531. AdminUserId: admin_user_id,
  3532. IsReturn: 1,
  3533. IdCardType: id_card_type,
  3534. Doctor: doctor,
  3535. Departments: department,
  3536. }
  3537. timestamp := time.Now().Unix()
  3538. tempTime := time.Unix(timestamp, 0)
  3539. timeFormat := tempTime.Format("20060102150405")
  3540. chrgBchno := rand.Intn(100000) + 10000
  3541. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3542. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  3543. department, _ := service.GetDepartMentDetail(department)
  3544. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3545. IdCardNo := ""
  3546. if id_card_type == 1 {
  3547. // IdCardNo = medical_insurance_card
  3548. IdCardNo = patient.IdCardNo
  3549. } else {
  3550. IdCardNo = patient.IdCardNo
  3551. }
  3552. var rf []*ResultFive
  3553. json.Unmarshal([]byte(his.Iinfo), &rf)
  3554. var insutypes []*ResultFive
  3555. var insutype string
  3556. var insuplc_admdvs_temp string
  3557. var is390 int = 0
  3558. var is310 int = 0
  3559. for _, item := range rf {
  3560. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3561. insutypes = append(insutypes, item)
  3562. }
  3563. }
  3564. if len(insutypes) == 1 {
  3565. insutype = insutypes[0].Insutype
  3566. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3567. } else {
  3568. for _, i := range insutypes {
  3569. if i.Insutype == "390" {
  3570. is390 = 1
  3571. }
  3572. if i.Insutype == "310" {
  3573. is310 = 1
  3574. }
  3575. }
  3576. }
  3577. if is390 == 1 {
  3578. insutype = "390"
  3579. }
  3580. if is310 == 1 {
  3581. insutype = "310"
  3582. }
  3583. if len(insutypes) == 0 {
  3584. insutype = "310"
  3585. }
  3586. if len(insutypes) == 2 {
  3587. insutype = med_type
  3588. }
  3589. if len(med_type) > 0 {
  3590. insutype = med_type
  3591. }
  3592. //for _, item := range rf {
  3593. // if item.Insutype == insutype {
  3594. // insuplc_admdvs = item.InsuplcAdmdvs
  3595. // }
  3596. //}
  3597. var infocode int64
  3598. var resThree ResultThree
  3599. var resThree10265 ResultThree10265
  3600. if len(insuplc_admdvs) == 0 {
  3601. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  3602. } else {
  3603. insuplc_admdvs_temp = insuplc_admdvs
  3604. }
  3605. if miConfig.MdtrtareaAdmvs == "421300" {
  3606. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  3607. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3608. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&doctor_name=" + doctor_info.UserName
  3609. resp, requestErr := http.Get(api)
  3610. if requestErr != nil {
  3611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3612. return
  3613. }
  3614. body, ioErr := ioutil.ReadAll(resp.Body)
  3615. if ioErr != nil {
  3616. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3618. return
  3619. }
  3620. var respJSON map[string]interface{}
  3621. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3622. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3624. return
  3625. }
  3626. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3627. result, _ := json.Marshal(respJSON)
  3628. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3629. utils.ErrorLog("解析失败:%v", err)
  3630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3631. return
  3632. }
  3633. infocode = resThree.Infcode
  3634. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3635. psn_info, _ := service.GetPsnByPatientId(id)
  3636. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3637. var cert_no string
  3638. if id_card_type == 3 {
  3639. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  3640. cert_no = IdCardNo
  3641. } else {
  3642. bas := strings.Split(psn_info.CardInfo, "|")
  3643. cert_no = bas[2]
  3644. }
  3645. var api string
  3646. if miConfig.MdtrtareaAdmvs == "320921" {
  3647. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  3648. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3649. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&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.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3650. } else {
  3651. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  3652. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3653. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&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.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3654. }
  3655. resp, requestErr := http.Get(api)
  3656. if requestErr != nil {
  3657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3658. return
  3659. }
  3660. body, ioErr := ioutil.ReadAll(resp.Body)
  3661. if ioErr != nil {
  3662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3664. return
  3665. }
  3666. var respJSON map[string]interface{}
  3667. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3670. return
  3671. }
  3672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3673. result, _ := json.Marshal(respJSON)
  3674. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3675. utils.ErrorLog("解析失败:%v", err)
  3676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3677. return
  3678. }
  3679. resThree.ErrMsg = resThree10265.ErrMsg
  3680. resThree.Output = resThree10265.Output
  3681. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3682. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3683. } else {
  3684. 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, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName)
  3685. saveLog(result, requestLog, "2201", "挂号")
  3686. if miConfig.Code == "H15049901371" {
  3687. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3688. utils.ErrorLog("解析失败:%v", err)
  3689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3690. return
  3691. }
  3692. resThree.ErrMsg = resThree10265.ErrMsg
  3693. resThree.Output = resThree10265.Output
  3694. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3695. } else {
  3696. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3697. utils.ErrorLog("解析失败:%v", err)
  3698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3699. return
  3700. }
  3701. }
  3702. if miConfig.Code == "H15049901371" {
  3703. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3704. } else {
  3705. infocode = resThree.Infcode
  3706. }
  3707. }
  3708. if infocode != 0 {
  3709. adminUser := c.GetAdminUserInfo()
  3710. errlog := &models.HisOrderError{
  3711. UserOrgId: adminUser.CurrentOrgId,
  3712. Ctime: time.Now().Unix(),
  3713. Mtime: time.Now().Unix(),
  3714. ErrMsg: resThree.ErrMsg,
  3715. Status: 1,
  3716. PatientId: id,
  3717. RecordTime: recordDateTime,
  3718. Stage: 2,
  3719. }
  3720. service.CreateErrMsgLog(errlog)
  3721. c.ServeSuccessJSON(map[string]interface{}{
  3722. "failed_code": -10,
  3723. "msg": resThree.ErrMsg,
  3724. })
  3725. return
  3726. }
  3727. his.Number = resThree.Output.Data.MdtrtID
  3728. his.PsnNo = resThree.Output.Data.PsnNo
  3729. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  3730. his.IdCardNo = patient.IdCardNo
  3731. his.PhoneNumber = patient.Phone
  3732. his.UserOrgId = adminInfo.CurrentOrgId
  3733. his.Insutype = insutype
  3734. his.Ctime = time.Now().Unix()
  3735. his.Mtime = time.Now().Unix()
  3736. his.InsuplcAdmdvs = insuplc_admdvs_temp
  3737. his.Status = 1
  3738. service.UpdateHisPatientStatus(&his)
  3739. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  3740. c.ServeSuccessJSON(map[string]interface{}{
  3741. "his_info": his,
  3742. })
  3743. } else {
  3744. adminUser := c.GetAdminUserInfo()
  3745. errlog := &models.HisOrderError{
  3746. UserOrgId: adminUser.CurrentOrgId,
  3747. Ctime: time.Now().Unix(),
  3748. Mtime: time.Now().Unix(),
  3749. ErrMsg: res.ErrMsg,
  3750. Status: 1,
  3751. PatientId: id,
  3752. RecordTime: recordDateTime,
  3753. Stage: 1,
  3754. }
  3755. service.CreateErrMsgLog(errlog)
  3756. c.ServeSuccessJSON(map[string]interface{}{
  3757. "failed_code": -10,
  3758. "msg": res.ErrMsg,
  3759. })
  3760. return
  3761. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3762. }
  3763. }
  3764. }
  3765. //上传明细----预结算----确认订单
  3766. func (c *HisApiController) GetUploadInfo() {
  3767. id, _ := c.GetInt64("id")
  3768. record_time := c.GetString("record_time")
  3769. his_patient_id, _ := c.GetInt64("his_patient_id")
  3770. order_id, _ := c.GetInt64("order_id")
  3771. pay_way, _ := c.GetInt64("pay_way")
  3772. pay_price, _ := c.GetFloat("pay_price")
  3773. pay_card_no := c.GetString("pay_card_no")
  3774. discount_price, _ := c.GetFloat("discount_price")
  3775. preferential_price, _ := c.GetFloat("preferential_price")
  3776. reality_price, _ := c.GetFloat("reality_price")
  3777. found_price, _ := c.GetFloat("found_price")
  3778. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3779. private_price, _ := c.GetFloat("private_price")
  3780. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3781. admin_user_id, _ := c.GetInt64("admin_user_id")
  3782. fapiao_code := c.GetString("fapiao_code")
  3783. fapiao_number := c.GetString("fapiao_number")
  3784. diagnosis_id := c.GetString("diagnosis")
  3785. sick_type, _ := c.GetInt64("sick_type")
  3786. reg_type, _ := c.GetInt64("p_type")
  3787. begin_time := c.GetString("begin_time")
  3788. id_str := c.GetString("ids")
  3789. ids_arr := strings.Split(id_str, ",")
  3790. timeLayout := "2006-01-02"
  3791. loc, _ := time.LoadLocation("Local")
  3792. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3793. if err != nil {
  3794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3795. return
  3796. }
  3797. recordDateTime := theTime.Unix()
  3798. adminUser := c.GetAdminUserInfo()
  3799. var tempOrder models.HisOrder
  3800. tempOrder, _ = service.GetHisOrderByID(order_id)
  3801. var prescriptions []*models.HisPrescription
  3802. var start_time int64
  3803. var end_time int64
  3804. //if adminUser.CurrentOrgId == 10106{
  3805. // if len(fapiao_code) == 0{
  3806. // fapiao_code = "144072080589"
  3807. // }
  3808. // if len(fapiao_number) == 0{
  3809. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3810. // if order.ID == 0{
  3811. // fapiao_number = "00001520"
  3812. // }else{
  3813. // //fapiao_code = "00001520"
  3814. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3815. // var zero string
  3816. // if fpNumber >= 1000{
  3817. // zero = "0000" + strconv.Itoa(fpNumber)
  3818. // }else if fpNumber >= 10000{
  3819. // zero = "000" + strconv.Itoa(fpNumber)
  3820. // } else if fpNumber >= 100000{
  3821. // zero = "00" + strconv.Itoa(fpNumber)
  3822. // } else if fpNumber >= 1000000{
  3823. // zero = "0" + strconv.Itoa(fpNumber)
  3824. // }else {
  3825. // zero = strconv.Itoa(fpNumber)
  3826. // }
  3827. // fapiao_number = zero
  3828. // }
  3829. // }
  3830. //}
  3831. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3832. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3833. var patientPrescription models.HisPrescriptionInfo
  3834. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3835. if patientPrescription.ID == 0 {
  3836. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3837. }
  3838. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3839. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3840. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3841. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3842. var config []*models.HisXtDiagnoseConfig
  3843. for _, item := range diagnosis_ids {
  3844. id, _ := strconv.ParseInt(item, 10, 64)
  3845. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3846. config = append(config, &diagnosisConfig)
  3847. }
  3848. sickConfig, _ := service.FindSickById(sick_type)
  3849. //if tempOrder.ID == 0 {
  3850. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3851. //}
  3852. if tempOrder.ID == 0 {
  3853. var result string
  3854. var requestLog string
  3855. var res2 ResultSix
  3856. var ressix10265 ResultSix10265
  3857. if miConfig.MdtrtareaAdmvs == "421300" {
  3858. data := make(map[string]interface{})
  3859. client := &http.Client{}
  3860. data["psn_no"] = his.PsnNo
  3861. data["mdtrt_id"] = his.Number
  3862. data["doctor"] = roles.UserName
  3863. data["department"] = department.Name
  3864. data["org_name"] = miConfig.OrgName
  3865. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3866. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3867. data["fixmedins_code"] = miConfig.Code
  3868. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3869. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3870. data["secret_key"] = miConfig.SecretKey
  3871. data["sick_code"] = sickConfig.CountryCode
  3872. data["sick_name"] = sickConfig.ClassName
  3873. data["dept"] = strconv.FormatInt(department.ID, 10)
  3874. data["config"] = config
  3875. data["begin_time"] = begin_time
  3876. bytesData, _ := json.Marshal(data)
  3877. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3878. resp, _ := client.Do(req)
  3879. defer resp.Body.Close()
  3880. body, ioErr := ioutil.ReadAll(resp.Body)
  3881. if ioErr != nil {
  3882. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3884. return
  3885. }
  3886. var respJSON map[string]interface{}
  3887. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3888. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3890. return
  3891. }
  3892. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3893. userJSONBytes, _ := json.Marshal(respJSON)
  3894. fmt.Println("log")
  3895. fmt.Println(string(userJSONBytes))
  3896. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3897. utils.ErrorLog("解析失败:%v", err)
  3898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3899. return
  3900. }
  3901. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3902. //江苏地区国家医保医疗类别
  3903. //职工透析:医疗类别选特殊情况门诊9933
  3904. //居民血透门慢: 医疗类别选门诊慢病1402
  3905. //var med_type string
  3906. //if his.Insutype == "310" {
  3907. // if reg_type == 14 {
  3908. // med_type = "9933"
  3909. // } else if reg_type == 11 {
  3910. // med_type = "11"
  3911. //
  3912. // }
  3913. //} else if his.Insutype == "390" {
  3914. // if reg_type == 14 {
  3915. // med_type = "1402"
  3916. // } else if reg_type == 11 {
  3917. // med_type = "11"
  3918. // }
  3919. //}
  3920. data := make(map[string]interface{})
  3921. client := &http.Client{}
  3922. data["psn_no"] = his.PsnNo
  3923. data["mdtrt_id"] = his.Number
  3924. data["doctor"] = roles.UserName
  3925. data["department"] = department.Name
  3926. data["org_name"] = miConfig.OrgName
  3927. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3928. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3929. data["fixmedins_code"] = miConfig.Code
  3930. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3931. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3932. data["secret_key"] = miConfig.SecretKey
  3933. data["sick_code"] = sickConfig.CountryCode
  3934. data["sick_name"] = sickConfig.ClassName
  3935. data["url"] = miConfig.Url
  3936. data["ak"] = miConfig.AccessKey
  3937. data["begin_time"] = begin_time
  3938. data["cainfo"] = miConfig.Cainfo
  3939. data["dept"] = strconv.FormatInt(department.ID, 10)
  3940. data["config"] = config
  3941. bytesData, _ := json.Marshal(data)
  3942. var req *http.Request
  3943. if miConfig.MdtrtareaAdmvs == "320921" {
  3944. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3945. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  3946. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  3947. } else {
  3948. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3949. }
  3950. resp, _ := client.Do(req)
  3951. defer resp.Body.Close()
  3952. body, ioErr := ioutil.ReadAll(resp.Body)
  3953. if ioErr != nil {
  3954. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3956. return
  3957. }
  3958. var respJSON map[string]interface{}
  3959. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3960. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3962. return
  3963. }
  3964. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3965. userJSONBytes, _ := json.Marshal(respJSON)
  3966. fmt.Println("log")
  3967. fmt.Println(string(userJSONBytes))
  3968. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  3969. utils.ErrorLog("解析失败:%v", err)
  3970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3971. return
  3972. }
  3973. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3974. res2.Output = ressix10265.Output
  3975. res2.ErrMsg = ressix10265.ErrMsg
  3976. res2.Cainfo = ressix10265.Cainfo
  3977. res2.WarnMsg = ressix10265.WarnMsg
  3978. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3979. res2.Infcode = infocode
  3980. } else {
  3981. if miConfig.MdtrtareaAdmvs == "440781" { //
  3982. 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, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  3983. } else {
  3984. if miConfig.Code == "H15049901371" {
  3985. //赤峰地区国家医保医疗类别
  3986. //职工透析:医疗类别选特殊情况门诊990502
  3987. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3988. var med_type string
  3989. if his.Insutype == "390" {
  3990. if reg_type == 14 {
  3991. med_type = "9933"
  3992. } else if reg_type == 11 {
  3993. med_type = "11"
  3994. }
  3995. } else if his.Insutype == "310" {
  3996. if reg_type == 14 {
  3997. med_type = "990502"
  3998. } else if reg_type == 11 {
  3999. med_type = "11"
  4000. }
  4001. }
  4002. 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)
  4003. } else {
  4004. 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)
  4005. }
  4006. }
  4007. saveLog(result, requestLog, "2203", "上传就诊信息")
  4008. var respJSON2 map[string]interface{}
  4009. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4010. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4012. return
  4013. }
  4014. userJSONBytes2, _ := json.Marshal(respJSON2)
  4015. if miConfig.Code == "H15049901371" {
  4016. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4017. utils.ErrorLog("解析失败:%v", err)
  4018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4019. return
  4020. }
  4021. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4022. res2.Output = ressix10265.Output
  4023. res2.ErrMsg = ressix10265.ErrMsg
  4024. res2.Cainfo = ressix10265.Cainfo
  4025. res2.WarnMsg = ressix10265.WarnMsg
  4026. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4027. res2.Infcode = infocode
  4028. } else {
  4029. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4030. utils.ErrorLog("解析失败:%v", err)
  4031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4032. return
  4033. }
  4034. }
  4035. }
  4036. if res2.Infcode != 0 {
  4037. adminUser := c.GetAdminUserInfo()
  4038. errlog := &models.HisOrderError{
  4039. UserOrgId: adminUser.CurrentOrgId,
  4040. Ctime: time.Now().Unix(),
  4041. Mtime: time.Now().Unix(),
  4042. ErrMsg: res2.ErrMsg,
  4043. Status: 1,
  4044. PatientId: id,
  4045. RecordTime: recordDateTime,
  4046. Stage: 3,
  4047. }
  4048. service.CreateErrMsgLog(errlog)
  4049. c.ServeSuccessJSON(map[string]interface{}{
  4050. "failed_code": -10,
  4051. "msg": res2.ErrMsg,
  4052. })
  4053. return
  4054. } else {
  4055. his.Diagnosis = diagnosis_id
  4056. his.SickType = sickConfig.ID
  4057. var p_type int64
  4058. if reg_type == 1111 || reg_type == 1112 {
  4059. p_type = 11
  4060. }
  4061. his.PType = fmt.Sprintf("%d", p_type)
  4062. service.UpdateHisPatientThree(&his)
  4063. data := make(map[string]interface{})
  4064. if settle_accounts_type == 1 { //日结
  4065. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4066. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4067. } else {
  4068. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4069. }
  4070. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4071. data["pre"] = prescriptions
  4072. } else { //月结
  4073. start_time_str := c.GetString("start_time")
  4074. end_time_str := c.GetString("end_time")
  4075. timeLayout := "2006-01-02"
  4076. loc, _ := time.LoadLocation("Local")
  4077. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4078. if err != nil {
  4079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4080. return
  4081. }
  4082. recordStartTime := theStartTime.Unix()
  4083. start_time = recordStartTime
  4084. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4085. if err != nil {
  4086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4087. return
  4088. }
  4089. recordEndTime := theEndTime.Unix()
  4090. end_time = recordEndTime
  4091. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4092. data["pre"] = prescriptions
  4093. }
  4094. timestamp := time.Now().Unix()
  4095. tempTime := time.Unix(timestamp, 0)
  4096. timeFormat := tempTime.Format("20060102150405")
  4097. chrgBchno := rand.Intn(100000) + 10000
  4098. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4099. strconv.FormatInt(his.PatientId, 10)
  4100. client := &http.Client{}
  4101. data["psn_no"] = his.PsnNo
  4102. data["mdtrt_id"] = his.Number
  4103. data["chrg_bchno"] = chrg_bchno
  4104. data["org_name"] = miConfig.OrgName
  4105. data["doctor"] = roles.UserName
  4106. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4107. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4108. data["fixmedins_code"] = miConfig.Code
  4109. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4110. // data["dept_code"] = "15"
  4111. //} else {
  4112. data["dept_code"] = department.Number
  4113. //}
  4114. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4115. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4116. data["secret_key"] = miConfig.SecretKey
  4117. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4118. data["url"] = miConfig.Url
  4119. data["ak"] = miConfig.AccessKey
  4120. data["new_doctor_name"] = patientPrescription.Doctor
  4121. data["diag_code"] = sickConfig.CountryCode
  4122. data["cainfo"] = miConfig.Cainfo
  4123. var ids []int64
  4124. for _, item := range prescriptions {
  4125. ids = append(ids, item.ID)
  4126. }
  4127. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4128. if config.IsOpen == 1 { //对接了医保,走医保流程
  4129. var res ResultFour
  4130. var resFour10265 ResultFour10265
  4131. if miConfig.MdtrtareaAdmvs == "421300" {
  4132. bytesData, _ := json.Marshal(data)
  4133. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4134. resp, _ := client.Do(req)
  4135. defer resp.Body.Close()
  4136. body, ioErr := ioutil.ReadAll(resp.Body)
  4137. if ioErr != nil {
  4138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4140. return
  4141. }
  4142. var respJSON map[string]interface{}
  4143. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4146. return
  4147. }
  4148. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4149. userJSONBytes, _ := json.Marshal(respJSON)
  4150. fmt.Println("log")
  4151. fmt.Println(string(userJSONBytes))
  4152. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4153. utils.ErrorLog("解析失败:%v", err)
  4154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4155. return
  4156. }
  4157. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4158. bytesData, _ := json.Marshal(data)
  4159. var req *http.Request
  4160. if miConfig.MdtrtareaAdmvs == "320921" {
  4161. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4162. } else {
  4163. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4164. }
  4165. resp, _ := client.Do(req)
  4166. defer resp.Body.Close()
  4167. body, ioErr := ioutil.ReadAll(resp.Body)
  4168. if ioErr != nil {
  4169. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4171. return
  4172. }
  4173. var respJSON map[string]interface{}
  4174. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4177. return
  4178. }
  4179. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4180. userJSONBytes, _ := json.Marshal(respJSON)
  4181. fmt.Println("log")
  4182. fmt.Println(string(userJSONBytes))
  4183. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4184. utils.ErrorLog("解析失败:%v", err)
  4185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4186. return
  4187. }
  4188. res.InfRefmsgid = resFour10265.InfRefmsgid
  4189. res.Output = resFour10265.Output
  4190. res.ErrMsg = resFour10265.ErrMsg
  4191. res.Cainfo = resFour10265.Cainfo
  4192. res.WarnMsg = resFour10265.WarnMsg
  4193. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4194. res.Infcode = infocode
  4195. } else {
  4196. if miConfig.Code == "H15049901371" {
  4197. 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)
  4198. var dat map[string]interface{}
  4199. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4200. fmt.Println(dat)
  4201. } else {
  4202. fmt.Println(err)
  4203. }
  4204. saveLog(result, request_log, "2204", "上传费用明细")
  4205. userJSONBytes, _ := json.Marshal(dat)
  4206. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4207. utils.ErrorLog("解析失败:%v", err)
  4208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4209. return
  4210. }
  4211. res.InfRefmsgid = resFour10265.InfRefmsgid
  4212. res.Output = resFour10265.Output
  4213. res.ErrMsg = resFour10265.ErrMsg
  4214. res.Cainfo = resFour10265.Cainfo
  4215. res.WarnMsg = resFour10265.WarnMsg
  4216. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4217. res.Infcode = infocode
  4218. } else {
  4219. 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)
  4220. var dat map[string]interface{}
  4221. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4222. fmt.Println(dat)
  4223. } else {
  4224. fmt.Println(err)
  4225. }
  4226. saveLog(result, request_log, "2204", "上传费用明细")
  4227. userJSONBytes, _ := json.Marshal(dat)
  4228. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4229. utils.ErrorLog("解析失败:%v", err)
  4230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4231. return
  4232. }
  4233. }
  4234. }
  4235. if res.Infcode == 0 {
  4236. order := &models.HisOrder{
  4237. UserOrgId: adminUser.CurrentOrgId,
  4238. HisPatientId: his.ID,
  4239. PatientId: his.PatientId,
  4240. SettleAccountsDate: recordDateTime,
  4241. MdtrtId: his.Number,
  4242. PsnNo: his.PsnNo,
  4243. MedType: strconv.FormatInt(reg_type, 10),
  4244. Ctime: time.Now().Unix(),
  4245. Mtime: time.Now().Unix(),
  4246. Status: 1,
  4247. Number: chrg_bchno,
  4248. Infcode: res.Infcode,
  4249. WarnMsg: res.WarnMsg,
  4250. Cainfo: res.Cainfo,
  4251. ErrMsg: res.ErrMsg,
  4252. RespondTime: res.RefmsgTime,
  4253. InfRefmsgid: res.InfRefmsgid,
  4254. OrderStatus: 1,
  4255. PayWay: pay_way,
  4256. PayPrice: pay_price,
  4257. PayCardNo: pay_card_no,
  4258. DiscountPrice: discount_price,
  4259. PreferentialPrice: preferential_price,
  4260. RealityPrice: reality_price,
  4261. FoundPrice: found_price,
  4262. MedicalInsurancePrice: medical_insurance_price,
  4263. PrivatePrice: private_price,
  4264. IsMedicineInsurance: 1,
  4265. SettleType: settle_accounts_type,
  4266. SettleStartTime: start_time,
  4267. SettleEndTime: end_time,
  4268. Creator: roles.AdminUserId,
  4269. Modify: roles.AdminUserId,
  4270. FaPiaoNumber: fapiao_number,
  4271. FaPiaoCode: fapiao_code,
  4272. PType: 2,
  4273. Diagnosis: diagnosis_id,
  4274. }
  4275. err = service.CreateOrder(order)
  4276. if err != nil {
  4277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4278. return
  4279. }
  4280. for _, item := range res.Output.Result {
  4281. temp := strings.Split(item.FeedetlSn, "-")
  4282. var advice_id int64 = 0
  4283. var project_id int64 = 0
  4284. var types int64 = 0
  4285. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4286. types, _ = strconv.ParseInt(temp[1], 10, 64)
  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. info := &models.HisOrderInfo{
  4295. OrderNumber: order.Number,
  4296. FeedetlSn: item.FeedetlSn,
  4297. UploadDate: time.Now().Unix(),
  4298. AdviceId: advice_id,
  4299. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4300. Cnt: item.Cnt,
  4301. Pric: float64(item.Pric),
  4302. PatientId: his.PatientId,
  4303. PricUplmtAmt: item.PricUplmtAmt,
  4304. SelfpayProp: item.SelfpayProp,
  4305. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4306. OverlmtAmt: item.OverlmtAmt,
  4307. PreselfpayAmt: item.PreselfpayAmt,
  4308. BasMednFlag: item.BasMednFlag,
  4309. MedChrgitmType: item.MedChrgitmType,
  4310. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4311. Status: 1,
  4312. Memo: item.Memo,
  4313. Mtime: time.Now().Unix(),
  4314. InscpScpAmt: item.InscpScpAmt,
  4315. DrtReimFlag: item.DrtReimFlag,
  4316. Ctime: time.Now().Unix(),
  4317. ListSpItemFlag: item.ListSpItemFlag,
  4318. ChldMedcFlag: item.ChldMedcFlag,
  4319. LmtUsedFlag: item.LmtUsedFlag,
  4320. ChrgitmLv: item.ChrgitmLv,
  4321. UserOrgId: adminUser.CurrentOrgId,
  4322. HisPatientId: his.ID,
  4323. OrderId: order.ID,
  4324. ProjectId: project_id,
  4325. Type: types,
  4326. }
  4327. service.CreateOrderInfo(info)
  4328. }
  4329. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4330. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4331. var total float64
  4332. for _, item := range prescriptions {
  4333. if item.Type == 1 { //药品
  4334. for _, subItem := range item.HisDoctorAdviceInfo {
  4335. total = total + (subItem.Price * subItem.PrescribingNumber)
  4336. }
  4337. }
  4338. if item.Type == 2 { //项目
  4339. for _, subItem := range item.HisPrescriptionProject {
  4340. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4341. total = total + (subItem.Price * cnt)
  4342. }
  4343. }
  4344. }
  4345. for _, item := range prescriptions {
  4346. for _, subItem := range item.HisAdditionalCharge {
  4347. total = total + (subItem.Price * float64(subItem.Count))
  4348. }
  4349. }
  4350. var allTotal string
  4351. if adminUser.CurrentOrgId == 9919 {
  4352. allTotal = fmt.Sprintf("%.4f", total)
  4353. } else {
  4354. allTotal = fmt.Sprintf("%.4f", total)
  4355. }
  4356. if res.Infcode == 0 {
  4357. var rf []*ResultFive
  4358. json.Unmarshal([]byte(his.Iinfo), &rf)
  4359. chrg_bchno := chrg_bchno
  4360. cert_no := his.Certno
  4361. var insutypes []string
  4362. var insutype string
  4363. var is390 int = 0
  4364. var is310 int = 0
  4365. for _, item := range rf {
  4366. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4367. insutypes = append(insutypes, item.Insutype)
  4368. }
  4369. }
  4370. if len(insutypes) == 1 {
  4371. insutype = insutypes[0]
  4372. } else {
  4373. for _, i := range insutypes {
  4374. if i == "390" {
  4375. is390 = 1
  4376. }
  4377. if i == "310" {
  4378. is310 = 1
  4379. }
  4380. }
  4381. }
  4382. if is390 == 1 {
  4383. insutype = "390"
  4384. }
  4385. if is310 == 1 {
  4386. insutype = "310"
  4387. }
  4388. if len(insutypes) == 0 {
  4389. insutype = "310"
  4390. }
  4391. if len(insutypes) == 2 {
  4392. insutype = strconv.FormatInt(his.SocialType, 10)
  4393. }
  4394. insutype = strconv.FormatInt(his.SocialType, 10)
  4395. //insutype = "390"
  4396. if his.IdCardType == 1 {
  4397. // cert_no = his.MedicalInsuranceNumber
  4398. cert_no = his.Certno
  4399. } else {
  4400. cert_no = his.Certno
  4401. }
  4402. var res ResultSeven
  4403. var resSeven10265 ResultSeven10265
  4404. var src_resquest string
  4405. var result2 string
  4406. var acct_used_flag string
  4407. fmt.Println("pay_way")
  4408. fmt.Println(pay_way)
  4409. fmt.Println("pay_way")
  4410. if pay_way == 4 {
  4411. acct_used_flag = "1"
  4412. } else {
  4413. acct_used_flag = "0"
  4414. }
  4415. if miConfig.MdtrtareaAdmvs == "421300" {
  4416. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4417. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4418. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4419. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4420. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4421. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4422. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4423. resp, requestErr := http.Get(api)
  4424. if requestErr != nil {
  4425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4426. return
  4427. }
  4428. body, ioErr := ioutil.ReadAll(resp.Body)
  4429. if ioErr != nil {
  4430. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4432. return
  4433. }
  4434. var respJSON map[string]interface{}
  4435. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4436. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4438. return
  4439. }
  4440. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4441. result, _ := json.Marshal(respJSON)
  4442. if miConfig.Code == "H15049901371" {
  4443. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4444. utils.ErrorLog("解析失败:%v", err)
  4445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4446. return
  4447. }
  4448. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4449. res.Output = resSeven10265.Output
  4450. res.ErrMsg = resSeven10265.ErrMsg
  4451. res.Cainfo = resSeven10265.Cainfo
  4452. res.WarnMsg = resSeven10265.WarnMsg
  4453. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4454. res.Infcode = infocode
  4455. } else {
  4456. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4457. utils.ErrorLog("解析失败:%v", err)
  4458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4459. return
  4460. }
  4461. }
  4462. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4463. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4464. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4465. //psn_info, _ := service.GetPsnByPatientId(id)
  4466. bas := strings.Split(psn_info.CardInfo, "|")
  4467. if his.IdCardType == 1 {
  4468. cert_no = bas[2]
  4469. } else if his.IdCardType == 3 {
  4470. cert_no = his.Certno
  4471. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  4472. } else {
  4473. cert_no = bas[1]
  4474. }
  4475. //江苏地区国家医保医疗类别
  4476. //职工透析:医疗类别选特殊情况门诊9933
  4477. //居民血透门慢: 医疗类别选门诊慢病1402
  4478. //var med_type string
  4479. //if his.Insutype == "310" {
  4480. // if reg_type == 14 {
  4481. // med_type = "9933"
  4482. // } else if reg_type == 11 {
  4483. // med_type = "11"
  4484. //
  4485. // }
  4486. //} else if his.Insutype == "390" {
  4487. // if reg_type == 14 {
  4488. // med_type = "1402"
  4489. // } else if reg_type == 11 {
  4490. // med_type = "11"
  4491. // }
  4492. //}
  4493. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4494. var api string
  4495. if miConfig.MdtrtareaAdmvs == "320921" {
  4496. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4497. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4498. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4499. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4500. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4501. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4502. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4503. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4504. } else {
  4505. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4506. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4507. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4508. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4509. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4510. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4511. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4512. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4513. }
  4514. resp, requestErr := http.Get(api)
  4515. if requestErr != nil {
  4516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4517. return
  4518. }
  4519. body, ioErr := ioutil.ReadAll(resp.Body)
  4520. if ioErr != nil {
  4521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4523. return
  4524. }
  4525. var respJSON map[string]interface{}
  4526. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4529. return
  4530. }
  4531. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4532. result, _ := json.Marshal(respJSON)
  4533. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4534. utils.ErrorLog("解析失败:%v", err)
  4535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4536. return
  4537. }
  4538. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4539. res.Output = resSeven10265.Output
  4540. res.ErrMsg = resSeven10265.ErrMsg
  4541. res.Cainfo = resSeven10265.Cainfo
  4542. res.WarnMsg = resSeven10265.WarnMsg
  4543. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4544. res.Infcode = infocode
  4545. } else {
  4546. if miConfig.Code == "H15049901371" {
  4547. //赤峰地区国家医保医疗类别
  4548. //职工透析:医疗类别选特殊情况门诊990502
  4549. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4550. var med_type string
  4551. if his.Insutype == "390" {
  4552. if reg_type == 14 {
  4553. med_type = "9933"
  4554. } else if reg_type == 11 {
  4555. med_type = "11"
  4556. }
  4557. } else if his.Insutype == "310" {
  4558. if reg_type == 14 {
  4559. med_type = "990502"
  4560. } else if reg_type == 11 {
  4561. med_type = "11"
  4562. }
  4563. }
  4564. 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)
  4565. } else {
  4566. 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, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  4567. }
  4568. //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)
  4569. var dat map[string]interface{}
  4570. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4571. fmt.Println(dat)
  4572. } else {
  4573. fmt.Println(err)
  4574. }
  4575. saveLog(result2, src_resquest, "2207", "结算")
  4576. userJSONBytes, _ := json.Marshal(dat)
  4577. if miConfig.Code == "H15049901371" {
  4578. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4579. utils.ErrorLog("解析失败:%v", err)
  4580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4581. return
  4582. }
  4583. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4584. res.Output = resSeven10265.Output
  4585. res.ErrMsg = resSeven10265.ErrMsg
  4586. res.Cainfo = resSeven10265.Cainfo
  4587. res.WarnMsg = resSeven10265.WarnMsg
  4588. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4589. res.Infcode = infocode
  4590. } else {
  4591. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4592. utils.ErrorLog("解析失败:%v", err)
  4593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4594. return
  4595. }
  4596. }
  4597. }
  4598. if res.Infcode != 0 {
  4599. errlog := &models.HisOrderError{
  4600. UserOrgId: adminUser.CurrentOrgId,
  4601. Ctime: time.Now().Unix(),
  4602. Mtime: time.Now().Unix(),
  4603. Number: chrg_bchno,
  4604. ErrMsg: res.ErrMsg,
  4605. Status: 1,
  4606. PatientId: id,
  4607. RecordTime: recordDateTime,
  4608. Stage: 6,
  4609. }
  4610. service.CreateErrMsgLog(errlog)
  4611. c.ServeSuccessJSON(map[string]interface{}{
  4612. "failed_code": -10,
  4613. "msg": res.ErrMsg,
  4614. })
  4615. return
  4616. } else {
  4617. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4618. order.OrderStatus = 2
  4619. order.Status = 1
  4620. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4621. order.SetlId = res.Output.Setlinfo.SetlID
  4622. order.PsnNo = res.Output.Setlinfo.PsnNo
  4623. order.PsnName = res.Output.Setlinfo.PsnName
  4624. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4625. order.Certno = res.Output.Setlinfo.Certno
  4626. order.Gend = res.Output.Setlinfo.Gend
  4627. order.Naty = res.Output.Setlinfo.Naty
  4628. order.Age = res.Output.Setlinfo.Age
  4629. order.Insutype = res.Output.Setlinfo.Insutype
  4630. order.PsnType = res.Output.Setlinfo.PsnType
  4631. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4632. order.SetlTime = res.Output.Setlinfo.SetlTime
  4633. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4634. if res.Output.Setlinfo.MedType == "140101" {
  4635. order.MedType = "14"
  4636. } else {
  4637. order.MedType = res.Output.Setlinfo.MedType
  4638. }
  4639. if reg_type == 1112 {
  4640. order.MedType = "1112"
  4641. }
  4642. if reg_type == 1111 {
  4643. order.MedType = "1111"
  4644. }
  4645. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4646. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4647. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4648. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4649. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4650. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4651. order.HifpPay = res.Output.Setlinfo.HifpPay
  4652. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4653. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4654. order.HifesPay = res.Output.Setlinfo.HifesPay
  4655. order.HifobPay = res.Output.Setlinfo.HifobPay
  4656. order.MafPay = res.Output.Setlinfo.MafPay
  4657. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4658. order.OthPay = res.Output.Setlinfo.OthPay
  4659. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4660. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4661. order.AcctPay = res.Output.Setlinfo.AcctPay
  4662. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4663. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4664. order.Balc = res.Output.Setlinfo.Balc
  4665. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4666. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4667. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4668. order.ClrType = res.Output.Setlinfo.ClrType
  4669. order.ClrWay = res.Output.Setlinfo.ClrWay
  4670. order.Creator = order.Creator
  4671. order.Modify = roles.AdminUserId
  4672. order.RequestLog = src_resquest
  4673. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4674. detailStr := string(setlDetail)
  4675. order.SetlDetail = detailStr
  4676. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4677. err = service.UpDateOrder(order)
  4678. if err == nil {
  4679. c.ServeSuccessJSON(map[string]interface{}{
  4680. "msg": "结算成功",
  4681. })
  4682. } else {
  4683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4684. return
  4685. }
  4686. }
  4687. } else {
  4688. adminUser := c.GetAdminUserInfo()
  4689. errlog := &models.HisOrderError{
  4690. UserOrgId: adminUser.CurrentOrgId,
  4691. Ctime: time.Now().Unix(),
  4692. Mtime: time.Now().Unix(),
  4693. ErrMsg: res.ErrMsg,
  4694. Status: 1,
  4695. PatientId: id,
  4696. RecordTime: recordDateTime,
  4697. Stage: 4,
  4698. }
  4699. service.CreateErrMsgLog(errlog)
  4700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4701. return
  4702. }
  4703. } else {
  4704. adminUser := c.GetAdminUserInfo()
  4705. errlog := &models.HisOrderError{
  4706. UserOrgId: adminUser.CurrentOrgId,
  4707. Ctime: time.Now().Unix(),
  4708. Mtime: time.Now().Unix(),
  4709. ErrMsg: res.ErrMsg,
  4710. Status: 1,
  4711. PatientId: id,
  4712. RecordTime: recordDateTime,
  4713. Stage: 4,
  4714. }
  4715. service.CreateErrMsgLog(errlog)
  4716. c.ServeSuccessJSON(map[string]interface{}{
  4717. "failed_code": -10,
  4718. "msg": res.ErrMsg,
  4719. })
  4720. return
  4721. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4722. //return
  4723. }
  4724. }
  4725. }
  4726. } else if tempOrder.ID > 0 {
  4727. if tempOrder.IsPre == 1 {
  4728. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  4729. var rf []*ResultFive
  4730. json.Unmarshal([]byte(his.Iinfo), &rf)
  4731. chrg_bchno := tempOrder.Number
  4732. cert_no := his.Certno
  4733. var insutypes []string
  4734. var insutype string
  4735. var is390 int = 0
  4736. var is310 int = 0
  4737. for _, item := range rf {
  4738. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4739. insutypes = append(insutypes, item.Insutype)
  4740. }
  4741. }
  4742. if len(insutypes) == 1 {
  4743. insutype = insutypes[0]
  4744. } else {
  4745. for _, i := range insutypes {
  4746. if i == "390" {
  4747. is390 = 1
  4748. }
  4749. if i == "310" {
  4750. is310 = 1
  4751. }
  4752. }
  4753. }
  4754. if is390 == 1 {
  4755. insutype = "390"
  4756. }
  4757. if is310 == 1 {
  4758. insutype = "310"
  4759. }
  4760. if len(insutypes) == 0 {
  4761. insutype = "310"
  4762. }
  4763. if len(insutypes) == 2 {
  4764. insutype = strconv.FormatInt(his.SocialType, 64)
  4765. }
  4766. //insutype = "390"
  4767. if his.IdCardType == 1 {
  4768. // cert_no = his.MedicalInsuranceNumber
  4769. cert_no = his.Certno
  4770. } else {
  4771. cert_no = his.Certno
  4772. }
  4773. var res ResultSeven
  4774. var resSeven10265 ResultSeven10265
  4775. var src_resquest string
  4776. var result2 string
  4777. var acct_used_flag string
  4778. fmt.Println("pay_way")
  4779. fmt.Println(pay_way)
  4780. fmt.Println("pay_way")
  4781. if pay_way == 4 {
  4782. acct_used_flag = "1"
  4783. } else {
  4784. acct_used_flag = "0"
  4785. }
  4786. if miConfig.MdtrtareaAdmvs == "421300" {
  4787. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4788. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4789. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4790. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4791. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4792. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4793. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4794. resp, requestErr := http.Get(api)
  4795. if requestErr != nil {
  4796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4797. return
  4798. }
  4799. body, ioErr := ioutil.ReadAll(resp.Body)
  4800. if ioErr != nil {
  4801. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4803. return
  4804. }
  4805. var respJSON map[string]interface{}
  4806. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4807. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4809. return
  4810. }
  4811. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4812. result, _ := json.Marshal(respJSON)
  4813. fmt.Println("log")
  4814. fmt.Println(string(result))
  4815. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4816. utils.ErrorLog("解析失败:%v", err)
  4817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4818. return
  4819. }
  4820. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4821. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4822. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4823. //psn_info, _ := service.GetPsnByPatientId(id)
  4824. bas := strings.Split(psn_info.CardInfo, "|")
  4825. if his.IdCardType == 1 {
  4826. cert_no = bas[2]
  4827. } else {
  4828. cert_no = bas[1]
  4829. }
  4830. //江苏地区国家医保医疗类别
  4831. //职工透析:医疗类别选特殊情况门诊9933
  4832. //居民血透门慢: 医疗类别选门诊慢病1402
  4833. //var med_type string
  4834. //if his.Insutype == "310" {
  4835. // if reg_type == 14 {
  4836. // med_type = "9933"
  4837. // } else if reg_type == 11 {
  4838. // med_type = "11"
  4839. //
  4840. // }
  4841. //} else if his.Insutype == "390" {
  4842. // if reg_type == 14 {
  4843. // med_type = "1402"
  4844. // } else if reg_type == 11 {
  4845. // med_type = "11"
  4846. // }
  4847. //}
  4848. var api string
  4849. if miConfig.MdtrtareaAdmvs == "320921" {
  4850. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4851. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4852. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4853. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4854. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4855. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4856. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4857. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4858. } else {
  4859. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4860. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4861. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4862. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4863. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4864. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4865. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4866. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4867. }
  4868. resp, requestErr := http.Get(api)
  4869. if requestErr != nil {
  4870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4871. return
  4872. }
  4873. body, ioErr := ioutil.ReadAll(resp.Body)
  4874. if ioErr != nil {
  4875. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4877. return
  4878. }
  4879. var respJSON map[string]interface{}
  4880. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4883. return
  4884. }
  4885. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4886. result, _ := json.Marshal(respJSON)
  4887. fmt.Println("log")
  4888. fmt.Println(string(result))
  4889. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4890. utils.ErrorLog("解析失败:%v", err)
  4891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4892. return
  4893. }
  4894. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4895. res.Output = resSeven10265.Output
  4896. res.ErrMsg = resSeven10265.ErrMsg
  4897. res.Cainfo = resSeven10265.Cainfo
  4898. res.WarnMsg = resSeven10265.WarnMsg
  4899. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4900. res.Infcode = infocode
  4901. } else {
  4902. var src_resquest string
  4903. if miConfig.Code == "H15049901371" {
  4904. //赤峰地区国家医保医疗类别
  4905. //职工透析:医疗类别选特殊情况门诊990502
  4906. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4907. var med_type string
  4908. if his.Insutype == "390" {
  4909. if reg_type == 14 {
  4910. med_type = "9933"
  4911. } else if reg_type == 11 {
  4912. med_type = "11"
  4913. }
  4914. } else if his.Insutype == "310" {
  4915. if reg_type == 14 {
  4916. med_type = "990502"
  4917. } else if reg_type == 11 {
  4918. med_type = "11"
  4919. }
  4920. }
  4921. 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)
  4922. } else {
  4923. 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, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  4924. }
  4925. var dat map[string]interface{}
  4926. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4927. fmt.Println(dat)
  4928. } else {
  4929. fmt.Println(err)
  4930. }
  4931. saveLog(result2, src_resquest, "2207", "结算")
  4932. userJSONBytes, _ := json.Marshal(dat)
  4933. if miConfig.Code == "H15049901371" {
  4934. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4935. utils.ErrorLog("解析失败:%v", err)
  4936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4937. return
  4938. }
  4939. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4940. res.Output = resSeven10265.Output
  4941. res.ErrMsg = resSeven10265.ErrMsg
  4942. res.Cainfo = resSeven10265.Cainfo
  4943. res.WarnMsg = resSeven10265.WarnMsg
  4944. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4945. res.Infcode = infocode
  4946. } else {
  4947. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4948. utils.ErrorLog("解析失败:%v", err)
  4949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4950. return
  4951. }
  4952. }
  4953. }
  4954. if res.Infcode != 0 {
  4955. errlog := &models.HisOrderError{
  4956. UserOrgId: adminUser.CurrentOrgId,
  4957. Ctime: time.Now().Unix(),
  4958. Mtime: time.Now().Unix(),
  4959. Number: chrg_bchno,
  4960. ErrMsg: res.ErrMsg,
  4961. Status: 1,
  4962. PatientId: id,
  4963. RecordTime: recordDateTime,
  4964. Stage: 6,
  4965. }
  4966. service.CreateErrMsgLog(errlog)
  4967. c.ServeSuccessJSON(map[string]interface{}{
  4968. "failed_code": -10,
  4969. "msg": res.ErrMsg,
  4970. })
  4971. return
  4972. } else {
  4973. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4974. order.OrderStatus = 2
  4975. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4976. order.SetlId = res.Output.Setlinfo.SetlID
  4977. order.PsnNo = res.Output.Setlinfo.PsnNo
  4978. order.PsnName = res.Output.Setlinfo.PsnName
  4979. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4980. order.Certno = res.Output.Setlinfo.Certno
  4981. order.Gend = res.Output.Setlinfo.Gend
  4982. order.Naty = res.Output.Setlinfo.Naty
  4983. order.Age = res.Output.Setlinfo.Age
  4984. order.Insutype = res.Output.Setlinfo.Insutype
  4985. order.PsnType = res.Output.Setlinfo.PsnType
  4986. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4987. order.SetlTime = res.Output.Setlinfo.SetlTime
  4988. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4989. //order.MedType = res.Output.Setlinfo.MedType
  4990. if reg_type == 1112 {
  4991. order.MedType = "1112"
  4992. }
  4993. if reg_type == 1111 {
  4994. order.MedType = "1111"
  4995. }
  4996. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4997. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4998. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4999. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5000. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5001. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5002. order.HifpPay = res.Output.Setlinfo.HifpPay
  5003. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5004. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5005. order.HifesPay = res.Output.Setlinfo.HifesPay
  5006. order.HifobPay = res.Output.Setlinfo.HifobPay
  5007. order.MafPay = res.Output.Setlinfo.MafPay
  5008. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5009. order.OthPay = res.Output.Setlinfo.OthPay
  5010. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5011. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5012. order.AcctPay = res.Output.Setlinfo.AcctPay
  5013. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5014. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5015. order.Balc = res.Output.Setlinfo.Balc
  5016. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5017. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5018. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5019. order.ClrWay = res.Output.Setlinfo.ClrWay
  5020. order.Creator = order.Creator
  5021. order.Modify = roles.AdminUserId
  5022. order.RequestLog = src_resquest
  5023. order.Diagnosis = diagnosis_id
  5024. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5025. detailStr := string(setlDetail)
  5026. order.SetlDetail = detailStr
  5027. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5028. err = service.UpDateOrder(order)
  5029. if err == nil {
  5030. c.ServeSuccessJSON(map[string]interface{}{
  5031. "msg": "结算成功",
  5032. })
  5033. } else {
  5034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5035. return
  5036. }
  5037. }
  5038. }
  5039. }
  5040. }
  5041. //func (c *HisApiController) GetPreUploadInfo() {
  5042. // id, _ := c.GetInt64("id")
  5043. // record_time := c.GetString("record_time")
  5044. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5045. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5046. //
  5047. // timeLayout := "2006-01-02"
  5048. // loc, _ := time.LoadLocation("Local")
  5049. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5050. // if err != nil {
  5051. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5052. // return
  5053. // }
  5054. // recordDateTime := theTime.Unix()
  5055. // adminUser := c.GetAdminUserInfo()
  5056. //
  5057. // var prescriptions []*models.HisPrescription
  5058. //
  5059. // var start_time int64
  5060. // var end_time int64
  5061. //
  5062. // data := make(map[string]interface{})
  5063. // if settle_accounts_type == 1 { //日结
  5064. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5065. // data["pre"] = prescriptions
  5066. //
  5067. // } else { //月结
  5068. // start_time_str := c.GetString("start_time")
  5069. // end_time_str := c.GetString("end_time")
  5070. // timeLayout := "2006-01-02"
  5071. // loc, _ := time.LoadLocation("Local")
  5072. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5073. // if err != nil {
  5074. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5075. // return
  5076. // }
  5077. // recordStartTime := theStartTime.Unix()
  5078. // start_time = recordStartTime
  5079. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5080. // if err != nil {
  5081. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5082. // return
  5083. // }
  5084. // recordEndTime := theEndTime.Unix()
  5085. // end_time = recordEndTime
  5086. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5087. // data["pre"] = prescriptions
  5088. //
  5089. // }
  5090. //
  5091. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5092. //
  5093. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5094. // timestamp := time.Now().Unix()
  5095. // tempTime := time.Unix(timestamp, 0)
  5096. // timeFormat := tempTime.Format("20060102150405")
  5097. // chrgBchno := rand.Intn(100000) + 10000
  5098. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5099. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5100. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5101. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5102. // strconv.FormatInt(his.PatientId, 10)
  5103. // client := &http.Client{}
  5104. // data["psn_no"] = his.PsnNo
  5105. // data["mdtrt_id"] = his.Number
  5106. // data["chrg_bchno"] = chrg_bchno
  5107. // data["org_name"] = miConfig.OrgName
  5108. // data["doctor"] = roles.UserName
  5109. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5110. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5111. // data["fixmedins_code"] = miConfig.Code
  5112. // data["dept_code"] = department.Number
  5113. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5114. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5115. // data["secret_key"] = miConfig.SecretKey
  5116. // var ids []int64
  5117. //
  5118. // for _, item := range prescriptions {
  5119. // ids = append(ids, item.ID)
  5120. // }
  5121. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5122. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5123. // bytesData, _ := json.Marshal(data)
  5124. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5125. // resp, _ := client.Do(req)
  5126. // defer resp.Body.Close()
  5127. // body, ioErr := ioutil.ReadAll(resp.Body)
  5128. // if ioErr != nil {
  5129. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5130. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5131. // return
  5132. // }
  5133. // var respJSON map[string]interface{}
  5134. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5135. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5136. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5137. // return
  5138. // }
  5139. //
  5140. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5141. // userJSONBytes, _ := json.Marshal(respJSON)
  5142. // var res ResultFour
  5143. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5144. // utils.ErrorLog("解析失败:%v", err)
  5145. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5146. // return
  5147. // }
  5148. //
  5149. // if res.Infcode == 0 {
  5150. // order := &models.HisOrder{
  5151. // UserOrgId: adminUser.CurrentOrgId,
  5152. // HisPatientId: his.ID,
  5153. // PatientId: his.PatientId,
  5154. // SettleAccountsDate: recordDateTime,
  5155. // Ctime: time.Now().Unix(),
  5156. // Mtime: time.Now().Unix(),
  5157. // Status: 1,
  5158. // Number: chrg_bchno,
  5159. // Infcode: res.Infcode,
  5160. // WarnMsg: res.WarnMsg,
  5161. // Cainfo: res.Cainfo,
  5162. // ErrMsg: res.ErrMsg,
  5163. // RespondTime: res.RefmsgTime,
  5164. // InfRefmsgid: res.InfRefmsgid,
  5165. // OrderStatus: 1,
  5166. // IsMedicineInsurance: 1,
  5167. // SettleType: settle_accounts_type,
  5168. // SettleStartTime: start_time,
  5169. // SettleEndTime: end_time,
  5170. // Creator: roles.ID,
  5171. // Modify: roles.ID,
  5172. // PType: 2,
  5173. // }
  5174. // err = service.CreateOrder(order)
  5175. // if err != nil {
  5176. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5177. // return
  5178. // }
  5179. //
  5180. // for _, item := range res.Output.Result {
  5181. // temp := strings.Split(item.FeedetlSn, "-")
  5182. // var advice_id int64 = 0
  5183. // var project_id int64 = 0
  5184. // var types int64 = 0
  5185. //
  5186. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  5187. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  5188. //
  5189. // if temp[1] == "1" {
  5190. // advice_id = id
  5191. // project_id = 0
  5192. // } else if temp[1] == "2" {
  5193. // advice_id = 0
  5194. // project_id = id
  5195. // }
  5196. //
  5197. // info := &models.HisOrderInfo{
  5198. // OrderNumber: order.Number,
  5199. // FeedetlSn: item.FeedetlSn,
  5200. // UploadDate: time.Now().Unix(),
  5201. // AdviceId: advice_id,
  5202. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5203. // Cnt: item.Cnt,
  5204. // Pric: float64(item.Pric),
  5205. // PatientId: his.PatientId,
  5206. // PricUplmtAmt: item.PricUplmtAmt,
  5207. // SelfpayProp: item.SelfpayProp,
  5208. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5209. // OverlmtAmt: item.OverlmtAmt,
  5210. // PreselfpayAmt: item.PreselfpayAmt,
  5211. // BasMednFlag: item.BasMednFlag,
  5212. // MedChrgitmType: item.MedChrgitmType,
  5213. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5214. // Status: 1,
  5215. // Memo: item.Memo,
  5216. // Mtime: time.Now().Unix(),
  5217. // InscpScpAmt: item.InscpScpAmt,
  5218. // DrtReimFlag: item.DrtReimFlag,
  5219. // Ctime: time.Now().Unix(),
  5220. // ListSpItemFlag: item.ListSpItemFlag,
  5221. // ChldMedcFlag: item.ChldMedcFlag,
  5222. // LmtUsedFlag: item.LmtUsedFlag,
  5223. // ChrgitmLv: item.ChrgitmLv,
  5224. // UserOrgId: adminUser.CurrentOrgId,
  5225. // HisPatientId: his.ID,
  5226. // OrderId: order.ID,
  5227. // ProjectId: project_id,
  5228. // Type: types,
  5229. // }
  5230. // service.CreateOrderInfo(info)
  5231. //
  5232. // }
  5233. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5234. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5235. //
  5236. // var total float64
  5237. // for _, item := range prescriptions {
  5238. // if item.Type == 1 { //药品
  5239. // for _, subItem := range item.HisDoctorAdviceInfo {
  5240. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5241. // }
  5242. // }
  5243. // if item.Type == 2 { //项目
  5244. // for _, subItem := range item.HisPrescriptionProject {
  5245. // total = total + (subItem.Price * float64(subItem.Count))
  5246. // }
  5247. // }
  5248. // }
  5249. //
  5250. // for _, item := range prescriptions {
  5251. // for _, subItem := range item.HisAdditionalCharge {
  5252. // total = total + (subItem.Price * float64(subItem.Count))
  5253. // }
  5254. // }
  5255. //
  5256. // allTotal := fmt.Sprintf("%.2f", total)
  5257. // if res.Infcode == 0 {
  5258. // var rf []*ResultFive
  5259. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5260. // psn_no := his.PsnNo
  5261. // mdtrt_id := his.Number
  5262. // chrg_bchno := chrg_bchno
  5263. // cert_no := his.Certno
  5264. // insutype := rf[0].Insutype
  5265. //
  5266. // if his.IdCardType == 1 {
  5267. // cert_no = his.MedicalInsuranceNumber
  5268. //
  5269. // } else {
  5270. //
  5271. // cert_no = his.Certno
  5272. //
  5273. // }
  5274. //
  5275. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5276. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5277. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5278. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5279. // resp, requestErr := http.Get(api)
  5280. // if requestErr != nil {
  5281. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5282. // return
  5283. // }
  5284. // defer resp.Body.Close()
  5285. // body, ioErr := ioutil.ReadAll(resp.Body)
  5286. // if ioErr != nil {
  5287. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5288. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5289. // return
  5290. // }
  5291. // var respJSON map[string]interface{}
  5292. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5293. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5294. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5295. // return
  5296. // }
  5297. // fmt.Println(respJSON)
  5298. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5299. // userJSONBytes, _ := json.Marshal(respJSON)
  5300. // var res ResultSeven
  5301. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5302. // utils.ErrorLog("解析失败:%v", err)
  5303. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5304. // return
  5305. // }
  5306. // if res.Infcode != 0 {
  5307. // errlog := &models.HisOrderError{
  5308. // UserOrgId: adminUser.CurrentOrgId,
  5309. // Ctime: time.Now().Unix(),
  5310. // Mtime: time.Now().Unix(),
  5311. // Number: chrg_bchno,
  5312. // ErrMsg: res.ErrMsg,
  5313. // Status: 1,
  5314. // PatientId: id,
  5315. // RecordTime: recordDateTime,
  5316. // Stage: 7,
  5317. // }
  5318. // service.CreateErrMsgLog(errlog)
  5319. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5320. // return
  5321. // } else {
  5322. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5323. // order.OrderStatus = 1
  5324. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5325. // order.SetlId = res.Output.Setlinfo.SetlID
  5326. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5327. // order.PsnName = res.Output.Setlinfo.PsnName
  5328. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5329. // order.Certno = res.Output.Setlinfo.Certno
  5330. // order.Gend = res.Output.Setlinfo.Gend
  5331. // order.Naty = res.Output.Setlinfo.Naty
  5332. // order.Age = res.Output.Setlinfo.Age
  5333. // order.Insutype = res.Output.Setlinfo.Insutype
  5334. // order.PsnType = res.Output.Setlinfo.PsnType
  5335. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5336. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5337. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5338. // order.MedType = res.Output.Setlinfo.MedType
  5339. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5340. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5341. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5342. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5343. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5344. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5345. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5346. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5347. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5348. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5349. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5350. // order.MafPay = res.Output.Setlinfo.MafPay
  5351. // order.OthPay = res.Output.Setlinfo.OthPay
  5352. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5353. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5354. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5355. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5356. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5357. // order.Balc = res.Output.Setlinfo.Balc
  5358. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5359. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5360. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5361. // order.ClrWay = res.Output.Setlinfo.ClrWay
  5362. // order.Creator = order.Creator
  5363. // order.Modify = roles.ID
  5364. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5365. // detailStr := string(setlDetail)
  5366. // order.SetlDetail = detailStr
  5367. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5368. // err = service.UpDateOrder(order)
  5369. // if err == nil {
  5370. // c.ServeSuccessJSON(map[string]interface{}{
  5371. // "msg": "预结算成功",
  5372. // })
  5373. // } else {
  5374. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5375. // return
  5376. // }
  5377. // }
  5378. // } else {
  5379. // adminUser := c.GetAdminUserInfo()
  5380. // errlog := &models.HisOrderError{
  5381. // UserOrgId: adminUser.CurrentOrgId,
  5382. // Ctime: time.Now().Unix(),
  5383. // Mtime: time.Now().Unix(),
  5384. // ErrMsg: res.ErrMsg,
  5385. // Status: 1,
  5386. // PatientId: id,
  5387. // RecordTime: recordDateTime,
  5388. // Stage: 4,
  5389. // }
  5390. // service.CreateErrMsgLog(errlog)
  5391. //
  5392. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5393. // return
  5394. // }
  5395. // } else {
  5396. // adminUser := c.GetAdminUserInfo()
  5397. // errlog := &models.HisOrderError{
  5398. // UserOrgId: adminUser.CurrentOrgId,
  5399. // Ctime: time.Now().Unix(),
  5400. // Mtime: time.Now().Unix(),
  5401. // ErrMsg: res.ErrMsg,
  5402. // Status: 1,
  5403. // PatientId: id,
  5404. // RecordTime: recordDateTime,
  5405. // Stage: 4,
  5406. // }
  5407. // service.CreateErrMsgLog(errlog)
  5408. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5409. // return
  5410. // }
  5411. //
  5412. // } else {
  5413. // var total float64
  5414. // for _, item := range prescriptions {
  5415. // if item.Type == 1 { //药品
  5416. // for _, subItem := range item.HisDoctorAdviceInfo {
  5417. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5418. // }
  5419. // }
  5420. // if item.Type == 2 { //项目
  5421. // for _, subItem := range item.HisPrescriptionProject {
  5422. // total = total + (subItem.Price * float64(subItem.Count))
  5423. // }
  5424. // }
  5425. //
  5426. // for _, subItem := range item.HisAdditionalCharge {
  5427. // total = total + (subItem.Price * float64(subItem.Count))
  5428. // }
  5429. // }
  5430. //
  5431. // allTotal := fmt.Sprintf("%.2f", total)
  5432. // totals, _ := strconv.ParseFloat(allTotal, 64)
  5433. // order := &models.HisOrder{
  5434. // UserOrgId: adminUser.CurrentOrgId,
  5435. // HisPatientId: his.ID,
  5436. // PatientId: id,
  5437. // SettleAccountsDate: recordDateTime,
  5438. // Ctime: time.Now().Unix(),
  5439. // Mtime: time.Now().Unix(),
  5440. // Status: 1,
  5441. // OrderStatus: 2,
  5442. // Number: chrg_bchno,
  5443. // MedfeeSumamt: totals,
  5444. // }
  5445. // err = service.CreateOrder(order)
  5446. // if err != nil {
  5447. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5448. // return
  5449. // }
  5450. //
  5451. // var customs []*Custom
  5452. // for _, item := range prescriptions {
  5453. //
  5454. // if item.Type == 1 { //药品
  5455. // for _, subItem := range item.HisDoctorAdviceInfo {
  5456. // cus := &Custom{
  5457. // AdviceId: subItem.ID,
  5458. // ProjectId: 0,
  5459. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  5460. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  5461. // FeedetlSn: subItem.FeedetlSn,
  5462. // Price: fmt.Sprintf("%.2f", subItem.Price),
  5463. // MedListCodg: subItem.MedListCodg,
  5464. // Type: 1,
  5465. // }
  5466. // customs = append(customs, cus)
  5467. // }
  5468. // }
  5469. //
  5470. // if item.Type == 2 { //项目
  5471. // for _, subItem := range item.HisPrescriptionProject {
  5472. //
  5473. // cus := &Custom{
  5474. // AdviceId: 0,
  5475. // ProjectId: subItem.ID,
  5476. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  5477. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  5478. // FeedetlSn: subItem.FeedetlSn,
  5479. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  5480. // MedListCodg: subItem.MedListCodg,
  5481. // Type: 2,
  5482. // }
  5483. //
  5484. // customs = append(customs, cus)
  5485. // }
  5486. // }
  5487. //
  5488. // for _, item := range item.HisAdditionalCharge {
  5489. // cus := &Custom{
  5490. // ItemId: item.ID,
  5491. // AdviceId: 0,
  5492. // ProjectId: 0,
  5493. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  5494. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  5495. // FeedetlSn: item.FeedetlSn,
  5496. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  5497. // MedListCodg: item.XtHisAddtionConfig.Code,
  5498. // Type: 3,
  5499. // }
  5500. //
  5501. // customs = append(customs, cus)
  5502. // }
  5503. //
  5504. // }
  5505. //
  5506. // for _, item := range customs {
  5507. // var advice_id int64 = 0
  5508. // var project_id int64 = 0
  5509. // var item_id int64 = 0
  5510. //
  5511. // var types int64 = 0
  5512. //
  5513. // if item.Type == 1 {
  5514. // advice_id = item.AdviceId
  5515. // project_id = 0
  5516. // item_id = 0
  5517. // } else if item.Type == 2 {
  5518. // advice_id = 0
  5519. // item_id = 0
  5520. //
  5521. // project_id = item.ProjectId
  5522. // } else if item.Type == 3 {
  5523. // advice_id = 0
  5524. // item_id = item.ItemId
  5525. // project_id = 0
  5526. // }
  5527. //
  5528. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  5529. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  5530. // pric, _ := strconv.ParseFloat(item.Price, 32)
  5531. //
  5532. // info := &models.HisOrderInfo{
  5533. // OrderNumber: order.Number,
  5534. // UploadDate: time.Now().Unix(),
  5535. // AdviceId: advice_id,
  5536. // DetItemFeeSumamt: detItemFeeSumamt,
  5537. // Cnt: cut,
  5538. // Pric: pric,
  5539. // PatientId: id,
  5540. // Status: 1,
  5541. // Mtime: time.Now().Unix(),
  5542. // Ctime: time.Now().Unix(),
  5543. // UserOrgId: adminUser.CurrentOrgId,
  5544. // HisPatientId: his.ID,
  5545. // OrderId: order.ID,
  5546. // ProjectId: project_id,
  5547. // Type: types,
  5548. // ItemId: item_id,
  5549. // }
  5550. // service.CreateOrderInfo(info)
  5551. // }
  5552. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5553. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5554. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  5555. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5556. // if err == nil {
  5557. // c.ServeSuccessJSON(map[string]interface{}{
  5558. // "msg": "结算成功",
  5559. // })
  5560. // } else {
  5561. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5562. // return
  5563. // }
  5564. // }
  5565. //}
  5566. //上传明细-预结算-
  5567. func (c *HisApiController) GetPreUploadInfo() {
  5568. id, _ := c.GetInt64("id")
  5569. record_time := c.GetString("record_time")
  5570. his_patient_id, _ := c.GetInt64("his_patient_id")
  5571. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5572. admin_user_id, _ := c.GetInt64("admin_user_id")
  5573. diagnosis_id := c.GetString("diagnosis")
  5574. sick_type, _ := c.GetInt64("sick_type")
  5575. reg_type, _ := c.GetInt64("p_type")
  5576. begin_time := c.GetString("begin_time")
  5577. id_str := c.GetString("ids")
  5578. ids_arr := strings.Split(id_str, ",")
  5579. timeLayout := "2006-01-02"
  5580. loc, _ := time.LoadLocation("Local")
  5581. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5582. if err != nil {
  5583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5584. return
  5585. }
  5586. recordDateTime := theTime.Unix()
  5587. adminUser := c.GetAdminUserInfo()
  5588. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5589. var config []*models.HisXtDiagnoseConfig
  5590. for _, item := range diagnosis_ids {
  5591. id, _ := strconv.ParseInt(item, 10, 64)
  5592. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5593. config = append(config, &diagnosisConfig)
  5594. }
  5595. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5596. sickConfig, _ := service.FindSickById(sick_type)
  5597. var prescriptions []*models.HisPrescription
  5598. var start_time int64
  5599. var end_time int64
  5600. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5601. fmt.Println(his_patient_id)
  5602. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5603. timestamp := time.Now().Unix()
  5604. tempTime := time.Unix(timestamp, 0)
  5605. timeFormat := tempTime.Format("20060102150405")
  5606. chrgBchno := rand.Intn(100000) + 10000
  5607. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5608. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5609. var patientPrescription models.HisPrescriptionInfo
  5610. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5611. if patientPrescription.ID == 0 {
  5612. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5613. }
  5614. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5615. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5616. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5617. strconv.FormatInt(his.PatientId, 10)
  5618. var res2 ResultSix
  5619. var resSix10265 ResultSix10265
  5620. var time_stamp string
  5621. if miConfig.MdtrtareaAdmvs == "421300" {
  5622. data := make(map[string]interface{})
  5623. client := &http.Client{}
  5624. data["psn_no"] = his.PsnNo
  5625. data["mdtrt_id"] = his.Number
  5626. data["doctor"] = roles.UserName
  5627. data["department"] = department.Name
  5628. data["org_name"] = miConfig.OrgName
  5629. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5630. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5631. data["fixmedins_code"] = miConfig.Code
  5632. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5633. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5634. data["secret_key"] = miConfig.SecretKey
  5635. data["sick_code"] = sickConfig.CountryCode
  5636. data["sick_name"] = sickConfig.ClassName
  5637. data["begin_time"] = begin_time
  5638. data["dept"] = strconv.FormatInt(department.ID, 10)
  5639. data["config"] = config
  5640. fmt.Println(data)
  5641. bytesData, _ := json.Marshal(data)
  5642. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5643. resp, _ := client.Do(req)
  5644. defer resp.Body.Close()
  5645. body, ioErr := ioutil.ReadAll(resp.Body)
  5646. if ioErr != nil {
  5647. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5649. return
  5650. }
  5651. var respJSON map[string]interface{}
  5652. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5653. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5655. return
  5656. }
  5657. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5658. userJSONBytes, _ := json.Marshal(respJSON)
  5659. fmt.Println("log")
  5660. fmt.Println(string(userJSONBytes))
  5661. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5662. utils.ErrorLog("解析失败:%v", err)
  5663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5664. return
  5665. }
  5666. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5667. //江苏地区国家医保医疗类别
  5668. //职工透析:医疗类别选特殊情况门诊9933
  5669. //居民血透门慢: 医疗类别选门诊慢病1402
  5670. //var med_type string
  5671. //if his.Insutype == "310" {
  5672. // if reg_type == 14 {
  5673. // med_type = "9933"
  5674. // } else if reg_type == 11 {
  5675. // med_type = "11"
  5676. //
  5677. // }
  5678. //} else if his.Insutype == "390" {
  5679. // if reg_type == 14 {
  5680. // med_type = "1402"
  5681. // } else if reg_type == 11 {
  5682. // med_type = "11"
  5683. // }
  5684. //}
  5685. data := make(map[string]interface{})
  5686. client := &http.Client{}
  5687. data["psn_no"] = his.PsnNo
  5688. data["mdtrt_id"] = his.Number
  5689. data["doctor"] = roles.UserName
  5690. data["department"] = department.Name
  5691. data["org_name"] = miConfig.OrgName
  5692. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5693. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5694. data["fixmedins_code"] = miConfig.Code
  5695. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5696. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5697. data["secret_key"] = miConfig.SecretKey
  5698. data["sick_code"] = sickConfig.CountryCode
  5699. data["sick_name"] = sickConfig.ClassName
  5700. data["begin_time"] = begin_time
  5701. data["dept"] = strconv.FormatInt(department.ID, 10)
  5702. data["config"] = config
  5703. data["url"] = miConfig.Url
  5704. data["ak"] = miConfig.AccessKey
  5705. data["cainfo"] = miConfig.Cainfo
  5706. bytesData, _ := json.Marshal(data)
  5707. var req *http.Request
  5708. if miConfig.MdtrtareaAdmvs == "320921" {
  5709. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5710. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5711. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5712. } else {
  5713. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5714. }
  5715. resp, _ := client.Do(req)
  5716. defer resp.Body.Close()
  5717. body, ioErr := ioutil.ReadAll(resp.Body)
  5718. if ioErr != nil {
  5719. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5721. return
  5722. }
  5723. var respJSON map[string]interface{}
  5724. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5725. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5727. return
  5728. }
  5729. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  5730. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  5731. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  5732. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5733. userJSONBytes, _ := json.Marshal(respJSON)
  5734. fmt.Println("log")
  5735. fmt.Println(string(userJSONBytes))
  5736. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5737. utils.ErrorLog("解析失败:%v", err)
  5738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5739. return
  5740. }
  5741. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5742. res2.Output = resSix10265.Output
  5743. res2.ErrMsg = resSix10265.ErrMsg
  5744. res2.Cainfo = resSix10265.Cainfo
  5745. res2.WarnMsg = resSix10265.WarnMsg
  5746. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5747. res2.Infcode = infocode
  5748. } else {
  5749. var result string
  5750. var requestLog string
  5751. if miConfig.MdtrtareaAdmvs == "440781" { //
  5752. 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)
  5753. } else {
  5754. if miConfig.Code == "H15049901371" {
  5755. //赤峰地区国家医保医疗类别
  5756. //职工透析:医疗类别选特殊情况门诊990502
  5757. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5758. var med_type string
  5759. if his.Insutype == "390" {
  5760. if reg_type == 14 {
  5761. med_type = "9933"
  5762. } else if reg_type == 11 {
  5763. med_type = "11"
  5764. }
  5765. } else if his.Insutype == "310" {
  5766. if reg_type == 14 {
  5767. med_type = "990502"
  5768. } else if reg_type == 11 {
  5769. med_type = "11"
  5770. }
  5771. }
  5772. 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)
  5773. } else {
  5774. 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)
  5775. }
  5776. saveLog(result, requestLog, "2203", "上传就诊信息")
  5777. var respJSON2 map[string]interface{}
  5778. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5781. return
  5782. }
  5783. userJSONBytes2, _ := json.Marshal(respJSON2)
  5784. if miConfig.Code == "H15049901371" {
  5785. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5786. utils.ErrorLog("解析失败:%v", err)
  5787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5788. return
  5789. }
  5790. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5791. res2.Output = resSix10265.Output
  5792. res2.ErrMsg = resSix10265.ErrMsg
  5793. res2.Cainfo = resSix10265.Cainfo
  5794. res2.WarnMsg = resSix10265.WarnMsg
  5795. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5796. res2.Infcode = infocode
  5797. } else {
  5798. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5799. utils.ErrorLog("解析失败:%v", err)
  5800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5801. return
  5802. }
  5803. }
  5804. }
  5805. }
  5806. if res2.Infcode != 0 {
  5807. adminUser := c.GetAdminUserInfo()
  5808. errlog := &models.HisOrderError{
  5809. UserOrgId: adminUser.CurrentOrgId,
  5810. Ctime: time.Now().Unix(),
  5811. Mtime: time.Now().Unix(),
  5812. ErrMsg: res2.ErrMsg,
  5813. Status: 1,
  5814. PatientId: id,
  5815. RecordTime: recordDateTime,
  5816. Stage: 3,
  5817. }
  5818. service.CreateErrMsgLog(errlog)
  5819. c.ServeSuccessJSON(map[string]interface{}{
  5820. "failed_code": -10,
  5821. "msg": res2.ErrMsg,
  5822. })
  5823. return
  5824. } else {
  5825. his.Diagnosis = diagnosis_id
  5826. his.SickType = sickConfig.ID
  5827. his.PType = fmt.Sprintf("%d", reg_type)
  5828. service.UpdateHisPatientThree(&his)
  5829. data := make(map[string]interface{})
  5830. if settle_accounts_type == 1 { //日结
  5831. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5832. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5833. } else {
  5834. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5835. }
  5836. data["pre"] = prescriptions
  5837. } else { //月结
  5838. start_time_str := c.GetString("start_time")
  5839. end_time_str := c.GetString("end_time")
  5840. timeLayout := "2006-01-02"
  5841. loc, _ := time.LoadLocation("Local")
  5842. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5843. if err != nil {
  5844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5845. return
  5846. }
  5847. recordStartTime := theStartTime.Unix()
  5848. start_time = recordStartTime
  5849. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5850. if err != nil {
  5851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5852. return
  5853. }
  5854. recordEndTime := theEndTime.Unix()
  5855. end_time = recordEndTime
  5856. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5857. data["pre"] = prescriptions
  5858. }
  5859. client := &http.Client{}
  5860. data["psn_no"] = his.PsnNo
  5861. data["mdtrt_id"] = his.Number
  5862. data["chrg_bchno"] = chrg_bchno
  5863. data["org_name"] = miConfig.OrgName
  5864. data["doctor"] = roles.UserName
  5865. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5866. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5867. data["fixmedins_code"] = miConfig.Code
  5868. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5869. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5870. data["dept_code"] = "15"
  5871. } else {
  5872. data["dept_code"] = department.Number
  5873. }
  5874. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5875. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5876. data["secret_key"] = miConfig.SecretKey
  5877. data["url"] = miConfig.Url
  5878. data["ak"] = miConfig.AccessKey
  5879. data["new_doctor_name"] = patientPrescription.Doctor
  5880. data["diag_code"] = sickConfig.CountryCode
  5881. data["time_stamp"] = time_stamp
  5882. data["cainfo"] = miConfig.Cainfo
  5883. var ids []int64
  5884. for _, item := range prescriptions {
  5885. ids = append(ids, item.ID)
  5886. }
  5887. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5888. if config.IsOpen == 1 { //对接了医保,走医保流程
  5889. var res ResultFour
  5890. var resFour10265 ResultFour10265
  5891. if miConfig.MdtrtareaAdmvs == "421300" {
  5892. bytesData, _ := json.Marshal(data)
  5893. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5894. resp, _ := client.Do(req)
  5895. defer resp.Body.Close()
  5896. body, ioErr := ioutil.ReadAll(resp.Body)
  5897. if ioErr != nil {
  5898. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5900. return
  5901. }
  5902. var respJSON map[string]interface{}
  5903. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5904. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5906. return
  5907. }
  5908. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5909. userJSONBytes, _ := json.Marshal(respJSON)
  5910. fmt.Println("log")
  5911. fmt.Println(string(userJSONBytes))
  5912. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5913. utils.ErrorLog("解析失败:%v", err)
  5914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5915. return
  5916. }
  5917. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5918. bytesData, _ := json.Marshal(data)
  5919. var req *http.Request
  5920. if miConfig.MdtrtareaAdmvs == "320921" {
  5921. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5922. } else {
  5923. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5924. }
  5925. resp, _ := client.Do(req)
  5926. defer resp.Body.Close()
  5927. body, ioErr := ioutil.ReadAll(resp.Body)
  5928. if ioErr != nil {
  5929. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5931. return
  5932. }
  5933. var respJSON map[string]interface{}
  5934. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5937. return
  5938. }
  5939. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5940. userJSONBytes, _ := json.Marshal(respJSON)
  5941. fmt.Println("log")
  5942. fmt.Println(string(userJSONBytes))
  5943. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5944. utils.ErrorLog("解析失败:%v", err)
  5945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5946. return
  5947. }
  5948. res.InfRefmsgid = resFour10265.InfRefmsgid
  5949. res.Output = resFour10265.Output
  5950. res.ErrMsg = resFour10265.ErrMsg
  5951. res.Cainfo = resFour10265.Cainfo
  5952. res.WarnMsg = resFour10265.WarnMsg
  5953. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5954. res.Infcode = infocode
  5955. } else {
  5956. if miConfig.Code == "H15049901371" {
  5957. 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)
  5958. var dat map[string]interface{}
  5959. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5960. fmt.Println(dat)
  5961. } else {
  5962. fmt.Println(err)
  5963. }
  5964. saveLog(result, request_log, "2204", "上传费用明细")
  5965. userJSONBytes, _ := json.Marshal(dat)
  5966. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5967. utils.ErrorLog("解析失败:%v", err)
  5968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5969. return
  5970. }
  5971. res.InfRefmsgid = resFour10265.InfRefmsgid
  5972. res.Output = resFour10265.Output
  5973. res.ErrMsg = resFour10265.ErrMsg
  5974. res.Cainfo = resFour10265.Cainfo
  5975. res.WarnMsg = resFour10265.WarnMsg
  5976. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5977. res.Infcode = infocode
  5978. } else {
  5979. 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)
  5980. var dat map[string]interface{}
  5981. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5982. fmt.Println(dat)
  5983. } else {
  5984. fmt.Println(err)
  5985. }
  5986. saveLog(result, request_log, "2204", "上传费用明细")
  5987. userJSONBytes, _ := json.Marshal(dat)
  5988. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5989. utils.ErrorLog("解析失败:%v", err)
  5990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5991. return
  5992. }
  5993. }
  5994. }
  5995. if res.Infcode == 0 {
  5996. order := &models.HisOrder{
  5997. UserOrgId: adminUser.CurrentOrgId,
  5998. HisPatientId: his.ID,
  5999. PatientId: his.PatientId,
  6000. SettleAccountsDate: recordDateTime,
  6001. Ctime: time.Now().Unix(),
  6002. Mtime: time.Now().Unix(),
  6003. MdtrtId: his.Number,
  6004. PsnNo: his.PsnNo,
  6005. MedType: strconv.FormatInt(reg_type, 10),
  6006. Status: 1,
  6007. Number: chrg_bchno,
  6008. Infcode: res.Infcode,
  6009. WarnMsg: res.WarnMsg,
  6010. Cainfo: res.Cainfo,
  6011. ErrMsg: res.ErrMsg,
  6012. RespondTime: res.RefmsgTime,
  6013. InfRefmsgid: res.InfRefmsgid,
  6014. OrderStatus: 1,
  6015. IsMedicineInsurance: 1,
  6016. SettleType: settle_accounts_type,
  6017. SettleStartTime: start_time,
  6018. SettleEndTime: end_time,
  6019. Creator: roles.AdminUserId,
  6020. Modify: roles.AdminUserId,
  6021. PType: 2,
  6022. Diagnosis: diagnosis_id,
  6023. }
  6024. err = service.CreateOrder(order)
  6025. if err != nil {
  6026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6027. return
  6028. }
  6029. for _, item := range res.Output.Result {
  6030. temp := strings.Split(item.FeedetlSn, "-")
  6031. var advice_id int64 = 0
  6032. var project_id int64 = 0
  6033. var types int64 = 0
  6034. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6035. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6036. if temp[1] == "1" {
  6037. advice_id = id
  6038. project_id = 0
  6039. } else if temp[1] == "2" {
  6040. advice_id = 0
  6041. project_id = id
  6042. }
  6043. info := &models.HisOrderInfo{
  6044. OrderNumber: order.Number,
  6045. FeedetlSn: item.FeedetlSn,
  6046. UploadDate: time.Now().Unix(),
  6047. AdviceId: advice_id,
  6048. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6049. Cnt: item.Cnt,
  6050. Pric: float64(item.Pric),
  6051. PatientId: his.PatientId,
  6052. PricUplmtAmt: item.PricUplmtAmt,
  6053. SelfpayProp: item.SelfpayProp,
  6054. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6055. OverlmtAmt: item.OverlmtAmt,
  6056. PreselfpayAmt: item.PreselfpayAmt,
  6057. BasMednFlag: item.BasMednFlag,
  6058. MedChrgitmType: item.MedChrgitmType,
  6059. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6060. Status: 1,
  6061. Memo: item.Memo,
  6062. Mtime: time.Now().Unix(),
  6063. InscpScpAmt: item.InscpScpAmt,
  6064. DrtReimFlag: item.DrtReimFlag,
  6065. Ctime: time.Now().Unix(),
  6066. ListSpItemFlag: item.ListSpItemFlag,
  6067. ChldMedcFlag: item.ChldMedcFlag,
  6068. LmtUsedFlag: item.LmtUsedFlag,
  6069. ChrgitmLv: item.ChrgitmLv,
  6070. UserOrgId: adminUser.CurrentOrgId,
  6071. HisPatientId: his.ID,
  6072. OrderId: order.ID,
  6073. ProjectId: project_id,
  6074. Type: types,
  6075. }
  6076. service.CreateOrderInfo(info)
  6077. }
  6078. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6079. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6080. var total float64
  6081. for _, item := range prescriptions {
  6082. if item.Type == 1 { //药品
  6083. for _, subItem := range item.HisDoctorAdviceInfo {
  6084. total = total + (subItem.Price * subItem.PrescribingNumber)
  6085. }
  6086. }
  6087. if item.Type == 2 { //项目
  6088. for _, subItem := range item.HisPrescriptionProject {
  6089. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6090. total = total + (subItem.Price * cnt)
  6091. }
  6092. }
  6093. }
  6094. for _, item := range prescriptions {
  6095. for _, subItem := range item.HisAdditionalCharge {
  6096. total = total + (subItem.Price * float64(subItem.Count))
  6097. }
  6098. }
  6099. allTotal := fmt.Sprintf("%.4f", total)
  6100. if res.Infcode == 0 {
  6101. var rf []*ResultFive
  6102. json.Unmarshal([]byte(his.Iinfo), &rf)
  6103. chrg_bchno := chrg_bchno
  6104. cert_no := his.Certno
  6105. var insutypes []string
  6106. var insutype string
  6107. var is390 int = 0
  6108. var is310 int = 0
  6109. for _, item := range rf {
  6110. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6111. insutypes = append(insutypes, item.Insutype)
  6112. }
  6113. }
  6114. if len(insutypes) == 1 {
  6115. insutype = insutypes[0]
  6116. } else {
  6117. for _, i := range insutypes {
  6118. if i == "390" {
  6119. is390 = 1
  6120. }
  6121. if i == "310" {
  6122. is310 = 1
  6123. }
  6124. }
  6125. }
  6126. if is390 == 1 {
  6127. insutype = "390"
  6128. }
  6129. if is310 == 1 {
  6130. insutype = "310"
  6131. }
  6132. if len(insutypes) == 0 {
  6133. insutype = "310"
  6134. }
  6135. if len(insutypes) == 2 {
  6136. insutype = strconv.FormatInt(his.SocialType, 64)
  6137. }
  6138. //insutype = "390"
  6139. if his.IdCardType == 1 {
  6140. cert_no = his.MedicalInsuranceNumber
  6141. } else {
  6142. cert_no = his.Certno
  6143. }
  6144. var res ResultSeven
  6145. var resSeven10265 ResultSeven10265
  6146. if miConfig.MdtrtareaAdmvs == "421300" {
  6147. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6148. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6149. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6150. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6151. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6152. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6153. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6154. resp, requestErr := http.Get(api)
  6155. if requestErr != nil {
  6156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6157. return
  6158. }
  6159. body, ioErr := ioutil.ReadAll(resp.Body)
  6160. if ioErr != nil {
  6161. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6163. return
  6164. }
  6165. var respJSON map[string]interface{}
  6166. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6167. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6169. return
  6170. }
  6171. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6172. result, _ := json.Marshal(respJSON)
  6173. fmt.Println("log")
  6174. fmt.Println(string(result))
  6175. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6176. utils.ErrorLog("解析失败:%v", err)
  6177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6178. return
  6179. }
  6180. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6181. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6182. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6183. bas := strings.Split(psn_info.CardInfo, "|")
  6184. if his.IdCardType == 1 {
  6185. cert_no = bas[2]
  6186. } else {
  6187. cert_no = bas[1]
  6188. }
  6189. //江苏地区国家医保医疗类别
  6190. //职工透析:医疗类别选特殊情况门诊9933
  6191. //居民血透门慢: 医疗类别选门诊慢病1402
  6192. //var med_type string
  6193. //if his.Insutype == "310" {
  6194. // if reg_type == 14 {
  6195. // med_type = "9933"
  6196. // } else if reg_type == 11 {
  6197. // med_type = "11"
  6198. //
  6199. // }
  6200. //} else if his.Insutype == "390" {
  6201. // if reg_type == 14 {
  6202. // med_type = "1402"
  6203. // } else if reg_type == 11 {
  6204. // med_type = "11"
  6205. // }
  6206. //}
  6207. var api string
  6208. if miConfig.MdtrtareaAdmvs == "320921" {
  6209. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6210. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6211. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6212. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6213. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6214. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6215. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6216. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6217. } else {
  6218. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6219. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6220. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6221. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6222. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6223. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6224. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6225. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6226. }
  6227. resp, requestErr := http.Get(api)
  6228. if requestErr != nil {
  6229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6230. return
  6231. }
  6232. body, ioErr := ioutil.ReadAll(resp.Body)
  6233. if ioErr != nil {
  6234. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6236. return
  6237. }
  6238. var respJSON map[string]interface{}
  6239. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6240. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6242. return
  6243. }
  6244. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6245. result, _ := json.Marshal(respJSON)
  6246. fmt.Println("log")
  6247. fmt.Println(string(result))
  6248. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6249. utils.ErrorLog("解析失败:%v", err)
  6250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6251. return
  6252. }
  6253. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6254. res.Output = resSeven10265.Output
  6255. res.ErrMsg = resSeven10265.ErrMsg
  6256. res.Cainfo = resSeven10265.Cainfo
  6257. res.WarnMsg = resSeven10265.WarnMsg
  6258. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6259. res.Infcode = infocode
  6260. } else {
  6261. var result string
  6262. var request_log string
  6263. if miConfig.Code == "H15049901371" {
  6264. //赤峰地区国家医保医疗类别
  6265. //职工透析:医疗类别选特殊情况门诊990502
  6266. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6267. var med_type string
  6268. if his.Insutype == "390" {
  6269. if reg_type == 14 {
  6270. med_type = "9933"
  6271. } else if reg_type == 11 {
  6272. med_type = "11"
  6273. }
  6274. } else if his.Insutype == "310" {
  6275. if reg_type == 14 {
  6276. med_type = "990502"
  6277. } else if reg_type == 11 {
  6278. med_type = "11"
  6279. }
  6280. }
  6281. 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)
  6282. } else {
  6283. 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, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  6284. }
  6285. var dat map[string]interface{}
  6286. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6287. fmt.Println(dat)
  6288. } else {
  6289. fmt.Println(err)
  6290. }
  6291. saveLog(result, request_log, "2206", "预结算")
  6292. //userJSONBytes, _ := json.Marshal(dat)
  6293. //
  6294. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6295. // utils.ErrorLog("解析失败:%v", err)
  6296. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6297. // return
  6298. //}
  6299. userJSONBytes, _ := json.Marshal(dat)
  6300. if miConfig.Code == "H15049901371" {
  6301. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6302. utils.ErrorLog("解析失败:%v", err)
  6303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6304. return
  6305. }
  6306. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6307. res.Output = resSeven10265.Output
  6308. res.ErrMsg = resSeven10265.ErrMsg
  6309. res.Cainfo = resSeven10265.Cainfo
  6310. res.WarnMsg = resSeven10265.WarnMsg
  6311. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6312. res.Infcode = infocode
  6313. } else {
  6314. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6315. utils.ErrorLog("解析失败:%v", err)
  6316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6317. return
  6318. }
  6319. }
  6320. }
  6321. if res.Infcode != 0 {
  6322. errlog := &models.HisOrderError{
  6323. UserOrgId: adminUser.CurrentOrgId,
  6324. Ctime: time.Now().Unix(),
  6325. Mtime: time.Now().Unix(),
  6326. Number: chrg_bchno,
  6327. ErrMsg: res.ErrMsg,
  6328. Status: 1,
  6329. PatientId: id,
  6330. RecordTime: recordDateTime,
  6331. Stage: 20,
  6332. }
  6333. service.CreateErrMsgLog(errlog)
  6334. c.ServeSuccessJSON(map[string]interface{}{
  6335. "failed_code": -10,
  6336. "msg": res.ErrMsg,
  6337. })
  6338. return
  6339. } else {
  6340. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6341. order.OrderStatus = 1
  6342. order.IsPre = 1
  6343. order.Status = 1
  6344. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6345. order.SetlId = res.Output.Setlinfo.SetlID
  6346. order.PsnNo = res.Output.Setlinfo.PsnNo
  6347. order.PsnName = res.Output.Setlinfo.PsnName
  6348. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6349. order.Certno = res.Output.Setlinfo.Certno
  6350. order.Gend = res.Output.Setlinfo.Gend
  6351. order.Naty = res.Output.Setlinfo.Naty
  6352. order.Age = res.Output.Setlinfo.Age
  6353. order.Insutype = res.Output.Setlinfo.Insutype
  6354. order.PsnType = res.Output.Setlinfo.PsnType
  6355. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6356. order.SetlTime = res.Output.Setlinfo.SetlTime
  6357. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6358. if res.Output.Setlinfo.MedType == "140101" {
  6359. order.MedType = "14"
  6360. } else {
  6361. order.MedType = res.Output.Setlinfo.MedType
  6362. }
  6363. if reg_type == 1112 {
  6364. order.MedType = "1112"
  6365. }
  6366. if reg_type == 1111 {
  6367. order.MedType = "1111"
  6368. }
  6369. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6370. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6371. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6372. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6373. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6374. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6375. order.HifpPay = res.Output.Setlinfo.HifpPay
  6376. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6377. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6378. order.HifesPay = res.Output.Setlinfo.HifesPay
  6379. order.HifobPay = res.Output.Setlinfo.HifobPay
  6380. order.MafPay = res.Output.Setlinfo.MafPay
  6381. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6382. order.OthPay = res.Output.Setlinfo.OthPay
  6383. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6384. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6385. order.AcctPay = res.Output.Setlinfo.AcctPay
  6386. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6387. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6388. order.Balc = res.Output.Setlinfo.Balc
  6389. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6390. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6391. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6392. order.ClrWay = res.Output.Setlinfo.ClrWay
  6393. order.Creator = order.Creator
  6394. order.Modify = roles.AdminUserId
  6395. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6396. detailStr := string(setlDetail)
  6397. order.SetlDetail = detailStr
  6398. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6399. err = service.UpDateOrder(order)
  6400. if err == nil {
  6401. c.ServeSuccessJSON(map[string]interface{}{
  6402. "msg": "预结算成功",
  6403. })
  6404. } else {
  6405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6406. return
  6407. }
  6408. }
  6409. } else {
  6410. adminUser := c.GetAdminUserInfo()
  6411. errlog := &models.HisOrderError{
  6412. UserOrgId: adminUser.CurrentOrgId,
  6413. Ctime: time.Now().Unix(),
  6414. Mtime: time.Now().Unix(),
  6415. ErrMsg: res.ErrMsg,
  6416. Status: 1,
  6417. PatientId: id,
  6418. RecordTime: recordDateTime,
  6419. Stage: 4,
  6420. }
  6421. service.CreateErrMsgLog(errlog)
  6422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6423. return
  6424. }
  6425. } else {
  6426. adminUser := c.GetAdminUserInfo()
  6427. errlog := &models.HisOrderError{
  6428. UserOrgId: adminUser.CurrentOrgId,
  6429. Ctime: time.Now().Unix(),
  6430. Mtime: time.Now().Unix(),
  6431. ErrMsg: res.ErrMsg,
  6432. Status: 1,
  6433. PatientId: id,
  6434. RecordTime: recordDateTime,
  6435. Stage: 4,
  6436. }
  6437. service.CreateErrMsgLog(errlog)
  6438. c.ServeSuccessJSON(map[string]interface{}{
  6439. "failed_code": -10,
  6440. "msg": res.ErrMsg,
  6441. })
  6442. return
  6443. }
  6444. }
  6445. }
  6446. }
  6447. //func (c *HisApiController) GetSettleInfo() {
  6448. // id, _ := c.GetInt64("id")
  6449. // order_id, _ := c.GetInt64("order_id")
  6450. //
  6451. // record_time := c.GetString("record_time")
  6452. // pay_way, _ := c.GetInt64("pay_way")
  6453. // pay_price, _ := c.GetFloat("pay_price")
  6454. // pay_card_no := c.GetString("pay_card_no")
  6455. // discount_price, _ := c.GetFloat("discount_price")
  6456. // preferential_price, _ := c.GetFloat("preferential_price")
  6457. // reality_price, _ := c.GetFloat("reality_price")
  6458. // found_price, _ := c.GetFloat("found_price")
  6459. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6460. // private_price, _ := c.GetFloat("private_price")
  6461. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6462. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6463. //
  6464. // timeLayout := "2006-01-02"
  6465. // loc, _ := time.LoadLocation("Local")
  6466. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6467. // if err != nil {
  6468. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6469. // return
  6470. // }
  6471. // recordDateTime := theTime.Unix()
  6472. // adminUser := c.GetAdminUserInfo()
  6473. //
  6474. // var prescriptions []*models.HisPrescription
  6475. //
  6476. // data := make(map[string]interface{})
  6477. // if settle_accounts_type == 1 { //日结
  6478. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6479. // data["pre"] = prescriptions
  6480. //
  6481. // } else { //月结
  6482. // start_time_str := c.GetString("start_time")
  6483. // end_time_str := c.GetString("end_time")
  6484. // timeLayout := "2006-01-02"
  6485. // loc, _ := time.LoadLocation("Local")
  6486. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6487. // if err != nil {
  6488. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6489. // return
  6490. // }
  6491. // recordStartTime := theStartTime.Unix()
  6492. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6493. // if err != nil {
  6494. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6495. // return
  6496. // }
  6497. // recordEndTime := theEndTime.Unix()
  6498. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6499. // data["pre"] = prescriptions
  6500. //
  6501. // }
  6502. //
  6503. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6504. //
  6505. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6506. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6507. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6508. // strconv.FormatInt(his.PatientId, 10)
  6509. //
  6510. // order_src, _ := service.GetHisOrderByID(order_id)
  6511. //
  6512. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6513. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6514. //
  6515. // var total float64
  6516. // for _, item := range prescriptions {
  6517. // if item.Type == 1 { //药品
  6518. // for _, subItem := range item.HisDoctorAdviceInfo {
  6519. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6520. // }
  6521. // }
  6522. // if item.Type == 2 { //项目
  6523. // for _, subItem := range item.HisPrescriptionProject {
  6524. // total = total + (subItem.Price * float64(subItem.Count))
  6525. // }
  6526. // }
  6527. // }
  6528. //
  6529. // for _, item := range prescriptions {
  6530. // for _, subItem := range item.HisAdditionalCharge {
  6531. // total = total + (subItem.Price * float64(subItem.Count))
  6532. // }
  6533. // }
  6534. //
  6535. // allTotal := fmt.Sprintf("%.2f", total)
  6536. // var rf []*ResultFive
  6537. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6538. // psn_no := order_src.PsnNo
  6539. // mdtrt_id := order_src.MdtrtId
  6540. // chrg_bchno := order_src.Number
  6541. // cert_no := order_src.Certno
  6542. // insutype := rf[0].Insutype
  6543. //
  6544. // if his.IdCardType == 1 {
  6545. // cert_no = his.MedicalInsuranceNumber
  6546. // } else {
  6547. // cert_no = his.Certno
  6548. // }
  6549. //
  6550. // 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)
  6551. // var dat map[string]interface{}
  6552. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6553. // fmt.Println(dat)
  6554. // } else {
  6555. // fmt.Println(err)
  6556. // }
  6557. //
  6558. // userJSONBytes, _ := json.Marshal(dat)
  6559. //
  6560. //
  6561. //
  6562. // var res ResultSeven
  6563. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6564. // utils.ErrorLog("解析失败:%v", err)
  6565. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6566. // return
  6567. // }
  6568. // if res.Infcode == -1 {
  6569. // errlog := &models.HisOrderError{
  6570. // UserOrgId: adminUser.CurrentOrgId,
  6571. // Ctime: time.Now().Unix(),
  6572. // Mtime: time.Now().Unix(),
  6573. // Number: chrg_bchno,
  6574. // ErrMsg: res.ErrMsg,
  6575. // Status: 1,
  6576. // PatientId: id,
  6577. // RecordTime: recordDateTime,
  6578. // Stage: 6,
  6579. // }
  6580. // service.CreateErrMsgLog(errlog)
  6581. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6582. // return
  6583. // } else {
  6584. // order_src.OrderStatus = 2
  6585. // order_src.PayWay = pay_way
  6586. // order_src.PayPrice = pay_price
  6587. // order_src.PayCardNo = pay_card_no
  6588. // order_src.DiscountPrice = discount_price
  6589. // order_src.PreferentialPrice = preferential_price
  6590. // order_src.RealityPrice = reality_price
  6591. // order_src.FoundPrice = found_price
  6592. // order_src.MedicalInsurancePrice = medical_insurance_price
  6593. // order_src.PrivatePrice = private_price
  6594. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  6595. // order_src.SetlId = res.Output.Setlinfo.SetlID
  6596. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  6597. // order_src.PsnName = res.Output.Setlinfo.PsnName
  6598. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  6599. // order_src.Certno = res.Output.Setlinfo.Certno
  6600. // order_src.Gend = res.Output.Setlinfo.Gend
  6601. // order_src.Naty = res.Output.Setlinfo.Naty
  6602. // order_src.Age = res.Output.Setlinfo.Age
  6603. // order_src.Insutype = res.Output.Setlinfo.Insutype
  6604. // order_src.PsnType = res.Output.Setlinfo.PsnType
  6605. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6606. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  6607. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6608. // order_src.MedType = res.Output.Setlinfo.MedType
  6609. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6610. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6611. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6612. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6613. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6614. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6615. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  6616. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  6617. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6618. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  6619. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  6620. // order_src.MafPay = res.Output.Setlinfo.MafPay
  6621. // order_src.OthPay = res.Output.Setlinfo.OthPay
  6622. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6623. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6624. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  6625. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6626. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6627. // order_src.Balc = res.Output.Setlinfo.Balc
  6628. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6629. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6630. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  6631. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  6632. // order_src.Creator = order_src.Creator
  6633. // order_src.Modify = roles.ID
  6634. // order_src.RequestLog = src_resquest
  6635. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6636. // detailStr := string(setlDetail)
  6637. // order_src.SetlDetail = detailStr
  6638. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6639. // err = service.UpDateOrder(order_src)
  6640. //
  6641. // if err == nil {
  6642. // c.ServeSuccessJSON(map[string]interface{}{
  6643. // "msg": "结算成功",
  6644. // })
  6645. // } else {
  6646. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6647. // return
  6648. // }
  6649. // }
  6650. // }
  6651. //}
  6652. //退款
  6653. func (c *HisApiController) Refund() {
  6654. order_id, _ := c.GetInt64("order_id")
  6655. admin_user_id, _ := c.GetInt64("admin_user_id")
  6656. adminUser := c.GetAdminUserInfo()
  6657. var order models.HisOrder
  6658. order, _ = service.GetHisOrderByID(order_id)
  6659. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6660. if order.ID == 0 {
  6661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6662. return
  6663. }
  6664. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6665. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6666. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6667. if config.IsOpen == 1 { //对接了医保,走医保流程
  6668. var res ResultSixteen
  6669. var resSixteen10265 ResultSixteen10265
  6670. var src_resquest string
  6671. var result string
  6672. if miConfig.MdtrtareaAdmvs == "421300" {
  6673. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  6674. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6675. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6676. resp3, requestErr3 := http.Get(api3)
  6677. if requestErr3 != nil {
  6678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6679. return
  6680. }
  6681. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6682. if ioErr3 != nil {
  6683. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6685. return
  6686. }
  6687. var respJSON3 map[string]interface{}
  6688. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6689. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6691. return
  6692. }
  6693. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6694. userJSONBytes3, _ := json.Marshal(respJSON3)
  6695. fmt.Println("log")
  6696. fmt.Println(string(userJSONBytes3))
  6697. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  6698. utils.ErrorLog("解析失败:%v", err)
  6699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6700. return
  6701. }
  6702. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6703. var api3 string
  6704. if miConfig.MdtrtareaAdmvs == "320921" {
  6705. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6706. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6707. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6708. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6709. } else {
  6710. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6711. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6712. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6713. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6714. }
  6715. resp3, requestErr3 := http.Get(api3)
  6716. if requestErr3 != nil {
  6717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6718. return
  6719. }
  6720. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6721. if ioErr3 != nil {
  6722. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6724. return
  6725. }
  6726. var respJSON3 map[string]interface{}
  6727. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6728. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6730. return
  6731. }
  6732. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6733. userJSONBytes3, _ := json.Marshal(respJSON3)
  6734. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  6735. utils.ErrorLog("解析失败:%v", err)
  6736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6737. return
  6738. }
  6739. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6740. res.Output = resSixteen10265.Output
  6741. res.ErrMsg = resSixteen10265.ErrMsg
  6742. res.Cainfo = resSixteen10265.Cainfo
  6743. res.WarnMsg = resSixteen10265.WarnMsg
  6744. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6745. res.Infcode = infocode
  6746. } else {
  6747. if miConfig.Code == "H15049901371" {
  6748. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6749. var dat map[string]interface{}
  6750. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6751. fmt.Println(dat)
  6752. } else {
  6753. fmt.Println(err)
  6754. }
  6755. saveLog(result, src_resquest, "2208", "退费")
  6756. userJSONBytes, _ := json.Marshal(dat)
  6757. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  6758. utils.ErrorLog("解析失败:%v", err)
  6759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6760. return
  6761. }
  6762. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6763. res.Output = resSixteen10265.Output
  6764. res.ErrMsg = resSixteen10265.ErrMsg
  6765. res.Cainfo = resSixteen10265.Cainfo
  6766. res.WarnMsg = resSixteen10265.WarnMsg
  6767. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6768. res.Infcode = infocode
  6769. } else {
  6770. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6771. var dat map[string]interface{}
  6772. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6773. fmt.Println(dat)
  6774. } else {
  6775. fmt.Println(err)
  6776. }
  6777. saveLog(result, src_resquest, "2208", "退费")
  6778. userJSONBytes, _ := json.Marshal(dat)
  6779. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6780. utils.ErrorLog("解析失败:%v", err)
  6781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6782. return
  6783. }
  6784. }
  6785. }
  6786. if res.Infcode == 0 {
  6787. var res2 ResultSix
  6788. var resSix10265 ResultSix10265
  6789. if miConfig.MdtrtareaAdmvs == "421300" {
  6790. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6791. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6792. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6793. resp3, requestErr3 := http.Get(api3)
  6794. if requestErr3 != nil {
  6795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6796. return
  6797. }
  6798. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6799. if ioErr3 != nil {
  6800. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6802. return
  6803. }
  6804. var respJSON3 map[string]interface{}
  6805. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6806. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6808. return
  6809. }
  6810. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6811. userJSONBytes3, _ := json.Marshal(respJSON3)
  6812. fmt.Println("log")
  6813. fmt.Println(string(userJSONBytes3))
  6814. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6815. utils.ErrorLog("解析失败:%v", err)
  6816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6817. return
  6818. }
  6819. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6820. var api3 string
  6821. if miConfig.MdtrtareaAdmvs == "320921" {
  6822. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6823. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6824. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6825. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6826. } else {
  6827. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6828. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6829. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6830. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6831. }
  6832. resp3, requestErr3 := http.Get(api3)
  6833. if requestErr3 != nil {
  6834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6835. return
  6836. }
  6837. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6838. if ioErr3 != nil {
  6839. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6841. return
  6842. }
  6843. var respJSON3 map[string]interface{}
  6844. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6845. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6847. return
  6848. }
  6849. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6850. userJSONBytes3, _ := json.Marshal(respJSON3)
  6851. fmt.Println("log")
  6852. fmt.Println(string(userJSONBytes3))
  6853. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6854. utils.ErrorLog("解析失败:%v", err)
  6855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6856. return
  6857. }
  6858. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6859. res2.Output = resSix10265.Output
  6860. res2.ErrMsg = resSix10265.ErrMsg
  6861. res2.Cainfo = resSix10265.Cainfo
  6862. res2.WarnMsg = resSix10265.WarnMsg
  6863. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6864. res2.Infcode = infocode
  6865. } else {
  6866. if miConfig.Code == "H15049901371" {
  6867. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6868. var dat map[string]interface{}
  6869. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6870. fmt.Println(dat)
  6871. } else {
  6872. fmt.Println(err)
  6873. }
  6874. saveLog(result2, src_request, "2205", "撤销明细")
  6875. userJSONBytes, _ := json.Marshal(dat)
  6876. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6877. utils.ErrorLog("解析失败:%v", err)
  6878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6879. return
  6880. }
  6881. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6882. res2.Output = resSix10265.Output
  6883. res2.ErrMsg = resSix10265.ErrMsg
  6884. res2.Cainfo = resSix10265.Cainfo
  6885. res2.WarnMsg = resSix10265.WarnMsg
  6886. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6887. res2.Infcode = infocode
  6888. } else {
  6889. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6890. var dat map[string]interface{}
  6891. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6892. fmt.Println(dat)
  6893. } else {
  6894. fmt.Println(err)
  6895. }
  6896. saveLog(result2, src_request, "2205", "撤销明细")
  6897. userJSONBytes, _ := json.Marshal(dat)
  6898. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6899. utils.ErrorLog("解析失败:%v", err)
  6900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6901. return
  6902. }
  6903. }
  6904. }
  6905. if res2.Infcode == 0 {
  6906. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  6907. if err == nil {
  6908. c.ServeSuccessJSON(map[string]interface{}{
  6909. "msg": "退费成功",
  6910. })
  6911. } else {
  6912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6913. return
  6914. }
  6915. } else {
  6916. c.ServeSuccessJSON(map[string]interface{}{
  6917. "code": -10,
  6918. "msg": res2.ErrMsg,
  6919. })
  6920. }
  6921. } else {
  6922. c.ServeSuccessJSON(map[string]interface{}{
  6923. "code": -10,
  6924. "msg": res.ErrMsg,
  6925. })
  6926. }
  6927. }
  6928. }
  6929. func (c *HisApiController) RefundNumber() {
  6930. record_time := c.GetString("record_time")
  6931. //patient_id, _ := c.GetInt64("patient_id")
  6932. admin_user_id, _ := c.GetInt64("admin_user_id")
  6933. his_patient_id, _ := c.GetInt64("id")
  6934. timeLayout := "2006-01-02"
  6935. loc, _ := time.LoadLocation("Local")
  6936. adminUser := c.GetAdminUserInfo()
  6937. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6938. fmt.Println(err)
  6939. if err != nil {
  6940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6941. return
  6942. }
  6943. recordDateTime := theTime.Unix()
  6944. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6945. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  6946. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6947. //order, _ := service.GetHisOrderByID(order_id)
  6948. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6949. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6950. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6951. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  6952. if count > 0 {
  6953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  6954. return
  6955. }
  6956. if config.IsOpen == 1 { //对接了医保,走医保流程
  6957. var res2 ResultSix
  6958. var resSix10265 ResultSix10265
  6959. if miConfig.MdtrtareaAdmvs == "421300" {
  6960. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  6961. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6962. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6963. resp3, requestErr3 := http.Get(api3)
  6964. if requestErr3 != nil {
  6965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6966. return
  6967. }
  6968. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6969. if ioErr3 != nil {
  6970. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6972. return
  6973. }
  6974. var respJSON3 map[string]interface{}
  6975. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6978. return
  6979. }
  6980. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6981. userJSONBytes3, _ := json.Marshal(respJSON3)
  6982. fmt.Println("log")
  6983. fmt.Println(string(userJSONBytes3))
  6984. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6985. utils.ErrorLog("解析失败:%v", err)
  6986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6987. return
  6988. }
  6989. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6990. var api3 string
  6991. if miConfig.MdtrtareaAdmvs == "320921" {
  6992. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6993. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6994. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6995. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6996. } else {
  6997. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6998. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6999. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7000. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7001. }
  7002. resp3, requestErr3 := http.Get(api3)
  7003. if requestErr3 != nil {
  7004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7005. return
  7006. }
  7007. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7008. if ioErr3 != nil {
  7009. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7011. return
  7012. }
  7013. var respJSON3 map[string]interface{}
  7014. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7017. return
  7018. }
  7019. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7020. userJSONBytes3, _ := json.Marshal(respJSON3)
  7021. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7022. utils.ErrorLog("解析失败:%v", err)
  7023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7024. return
  7025. }
  7026. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7027. res2.Output = resSix10265.Output
  7028. res2.ErrMsg = resSix10265.ErrMsg
  7029. res2.Cainfo = resSix10265.Cainfo
  7030. res2.WarnMsg = resSix10265.WarnMsg
  7031. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7032. res2.Infcode = infocode
  7033. } else {
  7034. var api3 string
  7035. if miConfig.Code == "H15049901371" {
  7036. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7037. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7038. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7039. } else {
  7040. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7041. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7042. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7043. }
  7044. resp3, requestErr3 := http.Get(api3)
  7045. if requestErr3 != nil {
  7046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7047. return
  7048. }
  7049. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7050. if ioErr3 != nil {
  7051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7053. return
  7054. }
  7055. var respJSON3 map[string]interface{}
  7056. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7059. return
  7060. }
  7061. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7062. userJSONBytes3, _ := json.Marshal(respJSON3)
  7063. if miConfig.Code == "H15049901371" {
  7064. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7065. utils.ErrorLog("解析失败:%v", err)
  7066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7067. return
  7068. }
  7069. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7070. res2.Output = resSix10265.Output
  7071. res2.ErrMsg = resSix10265.ErrMsg
  7072. res2.Cainfo = resSix10265.Cainfo
  7073. res2.WarnMsg = resSix10265.WarnMsg
  7074. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7075. res2.Infcode = infocode
  7076. } else {
  7077. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7078. utils.ErrorLog("解析失败:%v", err)
  7079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7080. return
  7081. }
  7082. }
  7083. }
  7084. if res2.Infcode == 0 {
  7085. if err == nil {
  7086. c.ServeSuccessJSON(map[string]interface{}{
  7087. "msg": "退号成功",
  7088. })
  7089. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7090. } else {
  7091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7092. return
  7093. }
  7094. } else {
  7095. c.ServeSuccessJSON(map[string]interface{}{
  7096. "code": -10,
  7097. "msg": res2.ErrMsg,
  7098. })
  7099. }
  7100. } else {
  7101. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7102. //if err == nil {
  7103. // c.ServeSuccessJSON(map[string]interface{}{
  7104. // "msg": "退费成功",
  7105. // })
  7106. //} else {
  7107. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7108. // return
  7109. //}
  7110. }
  7111. }
  7112. func (c *HisApiController) RefundDetail() {
  7113. order_id, _ := c.GetInt64("order_id")
  7114. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7115. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7116. number := c.GetString("number")
  7117. record_time := c.GetString("record_time")
  7118. patient_id, _ := c.GetInt64("patient_id")
  7119. //med_type, _ := c.GetInt64("med_type")
  7120. timeLayout := "2006-01-02"
  7121. loc, _ := time.LoadLocation("Local")
  7122. adminUser := c.GetAdminUserInfo()
  7123. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7124. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7125. fmt.Println(err)
  7126. if err != nil {
  7127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7128. return
  7129. }
  7130. recordDateTime := theTime.Unix()
  7131. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7132. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7133. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7134. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7135. var order models.HisOrder
  7136. order, _ = service.GetHisOrderByID(order_id)
  7137. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7138. if config.IsOpen == 1 { //对接了医保,走医保流程
  7139. var res2 ResultSix
  7140. if miConfig.MdtrtareaAdmvs == "421300" {
  7141. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7142. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7143. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7144. resp3, requestErr3 := http.Get(api3)
  7145. if requestErr3 != nil {
  7146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7147. return
  7148. }
  7149. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7150. if ioErr3 != nil {
  7151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7153. return
  7154. }
  7155. var respJSON3 map[string]interface{}
  7156. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7159. return
  7160. }
  7161. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7162. userJSONBytes3, _ := json.Marshal(respJSON3)
  7163. fmt.Println("log")
  7164. fmt.Println(string(userJSONBytes3))
  7165. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7166. utils.ErrorLog("解析失败:%v", err)
  7167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7168. return
  7169. }
  7170. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7171. if err == nil {
  7172. c.ServeSuccessJSON(map[string]interface{}{
  7173. "msg": "撤销明细成功",
  7174. })
  7175. return
  7176. } else {
  7177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7178. return
  7179. }
  7180. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7181. var resSix10265 ResultSix10265
  7182. var api3 string
  7183. if miConfig.MdtrtareaAdmvs == "320921" {
  7184. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7185. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7186. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7187. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7188. } else {
  7189. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7190. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7191. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7192. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7193. }
  7194. resp3, requestErr3 := http.Get(api3)
  7195. if requestErr3 != nil {
  7196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7197. return
  7198. }
  7199. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7200. if ioErr3 != nil {
  7201. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7203. return
  7204. }
  7205. var respJSON3 map[string]interface{}
  7206. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7207. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7209. return
  7210. }
  7211. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7212. userJSONBytes3, _ := json.Marshal(respJSON3)
  7213. fmt.Println("log")
  7214. fmt.Println(string(userJSONBytes3))
  7215. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7216. utils.ErrorLog("解析失败:%v", err)
  7217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7218. return
  7219. }
  7220. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7221. res2.Output = resSix10265.Output
  7222. res2.ErrMsg = resSix10265.ErrMsg
  7223. res2.Cainfo = resSix10265.Cainfo
  7224. res2.WarnMsg = resSix10265.WarnMsg
  7225. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7226. res2.Infcode = infocode
  7227. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7228. if err == nil {
  7229. c.ServeSuccessJSON(map[string]interface{}{
  7230. "msg": "撤销明细成功",
  7231. })
  7232. return
  7233. } else {
  7234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7235. return
  7236. }
  7237. } else {
  7238. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  7239. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7240. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7241. resp2, requestErr2 := http.Get(api2)
  7242. if requestErr2 != nil {
  7243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7244. return
  7245. }
  7246. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7247. if ioErr2 != nil {
  7248. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7250. return
  7251. }
  7252. var respJSON2 map[string]interface{}
  7253. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7256. return
  7257. }
  7258. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7259. if err == nil {
  7260. c.ServeSuccessJSON(map[string]interface{}{
  7261. "msg": "撤销明细成功",
  7262. })
  7263. return
  7264. } else {
  7265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7266. return
  7267. }
  7268. }
  7269. } else {
  7270. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7271. if err == nil {
  7272. c.ServeSuccessJSON(map[string]interface{}{
  7273. "msg": "退费成功",
  7274. })
  7275. } else {
  7276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7277. return
  7278. }
  7279. }
  7280. }
  7281. //对账
  7282. func (c *HisApiController) GetCheckAccount() {
  7283. start_time := c.GetString("start_time")
  7284. end_time := c.GetString("end_time")
  7285. insutype := c.GetString("insutype")
  7286. clr_type := c.GetString("clr_type")
  7287. clr_org := c.GetString("clr_optins")
  7288. admin_user_id, _ := c.GetInt64("admin_user_id")
  7289. adminUser := c.GetAdminUserInfo()
  7290. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7291. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7292. if len(clr_org) == 0 {
  7293. clr_org = miConfig.MdtrtareaAdmvs
  7294. }
  7295. timeLayout := "2006-01-02"
  7296. loc, _ := time.LoadLocation("Local")
  7297. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7298. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7299. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  7300. fixmedins_setl_cnt := int64(len(orders))
  7301. var medfee_sumamt float64
  7302. var acct_pay float64
  7303. var fund_pay_sumamt float64
  7304. for _, item := range orders {
  7305. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7306. acct_pay = acct_pay + item.AcctPay
  7307. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7308. }
  7309. var user_name string
  7310. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7311. if role.ID == 0 {
  7312. user_name = "xxx"
  7313. } else {
  7314. user_name = role.UserName
  7315. }
  7316. var res ResultEight
  7317. var res10188 ResultEightFor10188
  7318. if config.IsOpen == 1 {
  7319. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7320. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  7321. "insutype=" + insutype +
  7322. "&clr_type=" + "11" +
  7323. "&setl_optins=" + clr_org +
  7324. "&stmt_begndate=" + start_time +
  7325. "&stm_enddate=" + end_time +
  7326. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7327. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7328. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7329. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7330. "&fixmedins_code=" + miConfig.Code +
  7331. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7332. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7333. "&secret_key=" + miConfig.SecretKey +
  7334. "&org_name=" + miConfig.OrgName +
  7335. "&doctor=" + user_name +
  7336. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7337. fmt.Println(api)
  7338. resp, requestErr := http.Get(api)
  7339. if requestErr != nil {
  7340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7341. return
  7342. }
  7343. body, ioErr := ioutil.ReadAll(resp.Body)
  7344. fmt.Println(body)
  7345. if ioErr != nil {
  7346. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7348. return
  7349. }
  7350. var respJSON map[string]interface{}
  7351. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7352. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7354. return
  7355. }
  7356. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7357. userJSONBytes, _ := json.Marshal(respJSON)
  7358. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7359. utils.ErrorLog("解析失败:%v", err)
  7360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7361. return
  7362. }
  7363. res.InfRefmsgid = res10188.InfRefmsgid
  7364. res.Output = res10188.Output
  7365. res.ErrMsg = res10188.ErrMsg
  7366. res.Cainfo = res10188.Cainfo
  7367. res.WarnMsg = res10188.WarnMsg
  7368. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  7369. res.Infcode = infocode
  7370. } else {
  7371. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7372. "insutype=" + insutype +
  7373. "&clr_type=" + clr_type +
  7374. "&setl_optins=" + clr_org +
  7375. "&stmt_begndate=" + start_time +
  7376. "&stm_enddate=" + end_time +
  7377. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7378. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7379. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7380. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7381. "&fixmedins_code=" + miConfig.Code +
  7382. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7383. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7384. "&secret_key=" + miConfig.SecretKey +
  7385. "&org_name=" + miConfig.OrgName +
  7386. "&doctor=" + user_name
  7387. fmt.Println(api)
  7388. resp, requestErr := http.Get(api)
  7389. if requestErr != nil {
  7390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7391. return
  7392. }
  7393. body, ioErr := ioutil.ReadAll(resp.Body)
  7394. fmt.Println(body)
  7395. if ioErr != nil {
  7396. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7398. return
  7399. }
  7400. var respJSON map[string]interface{}
  7401. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7402. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7404. return
  7405. }
  7406. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7407. userJSONBytes, _ := json.Marshal(respJSON)
  7408. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7409. utils.ErrorLog("解析失败:%v", err)
  7410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7411. return
  7412. }
  7413. }
  7414. if res.Infcode == 0 {
  7415. if res.Output.Stmtinfo.StmtRslt == "0" {
  7416. micc := &models.MedicalInsuranceCostCompare{
  7417. StartTime: startime.Unix(),
  7418. EndTime: endtime.Unix(),
  7419. Insutype: insutype,
  7420. CheckType: 1,
  7421. Num: fixmedins_setl_cnt,
  7422. Mtime: time.Now().Unix(),
  7423. Status: 1,
  7424. UserOrgId: adminUser.CurrentOrgId,
  7425. CostTotal: medfee_sumamt,
  7426. FuncTotal: fund_pay_sumamt,
  7427. PsnPay: acct_pay,
  7428. Creator: admin_user_id,
  7429. Ctime: time.Now().Unix(),
  7430. ClrType: clr_type,
  7431. }
  7432. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  7433. if err == nil {
  7434. c.ServeSuccessJSON(map[string]interface{}{
  7435. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7436. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7437. })
  7438. } else {
  7439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7440. }
  7441. } else {
  7442. c.ServeSuccessJSON(map[string]interface{}{
  7443. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7444. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7445. })
  7446. }
  7447. } else {
  7448. c.ServeSuccessJSON(map[string]interface{}{
  7449. "code": -10,
  7450. "msg": res.ErrMsg,
  7451. })
  7452. }
  7453. }
  7454. }
  7455. func (c *HisApiController) Check310() {
  7456. adminUser := c.GetAdminUserInfo()
  7457. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7458. var user_name string
  7459. user_name = "高慧裕"
  7460. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7461. "insutype=" + "310" +
  7462. "&clr_type=" + "" +
  7463. "&setl_optins=" + "441202" +
  7464. "&stmt_begndate=" + "2022-03-01" +
  7465. "&stm_enddate=" + "2022-03-31" +
  7466. "&medfee_sumamt=" + "194930.12" +
  7467. "&fund_pay_sumamt=" + "188741.46" +
  7468. "&acct_pay=" + "0" +
  7469. "&fixmedins_setl_cnt=" + "452" +
  7470. "&fixmedins_code=" + miConfig.Code +
  7471. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7472. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7473. "&secret_key=" + miConfig.SecretKey +
  7474. "&org_name=" + miConfig.OrgName +
  7475. "&doctor=" + user_name
  7476. fmt.Println(api)
  7477. resp, requestErr := http.Get(api)
  7478. if requestErr != nil {
  7479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7480. return
  7481. }
  7482. body, ioErr := ioutil.ReadAll(resp.Body)
  7483. fmt.Println(body)
  7484. if ioErr != nil {
  7485. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7487. return
  7488. }
  7489. var respJSON map[string]interface{}
  7490. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7491. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7493. return
  7494. }
  7495. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7496. userJSONBytes, _ := json.Marshal(respJSON)
  7497. var res ResultEight
  7498. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7499. utils.ErrorLog("解析失败:%v", err)
  7500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7501. return
  7502. }
  7503. }
  7504. func (c *HisApiController) Check390() {
  7505. adminUser := c.GetAdminUserInfo()
  7506. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7507. var user_name string
  7508. user_name = "高慧裕"
  7509. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7510. "insutype=" + "390" +
  7511. "&clr_type=" + "" +
  7512. "&setl_optins=" + "441202" +
  7513. "&stmt_begndate=" + "2022-03-01" +
  7514. "&stm_enddate=" + "2022-03-31" +
  7515. "&medfee_sumamt=" + "1068448.89" +
  7516. "&fund_pay_sumamt=" + "1014677.62" +
  7517. "&acct_pay=" + "0" +
  7518. "&fixmedins_setl_cnt=" + "1950" +
  7519. "&fixmedins_code=" + miConfig.Code +
  7520. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7521. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7522. "&secret_key=" + miConfig.SecretKey +
  7523. "&org_name=" + miConfig.OrgName +
  7524. "&doctor=" + user_name
  7525. fmt.Println(api)
  7526. resp, requestErr := http.Get(api)
  7527. if requestErr != nil {
  7528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7529. return
  7530. }
  7531. body, ioErr := ioutil.ReadAll(resp.Body)
  7532. fmt.Println(body)
  7533. if ioErr != nil {
  7534. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7536. return
  7537. }
  7538. var respJSON map[string]interface{}
  7539. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7542. return
  7543. }
  7544. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7545. userJSONBytes, _ := json.Marshal(respJSON)
  7546. var res ResultEight
  7547. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7548. utils.ErrorLog("解析失败:%v", err)
  7549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7550. return
  7551. }
  7552. }
  7553. //对账明细
  7554. func (c *HisApiController) GetCheckDetailAccount() {
  7555. start_time := c.GetString("start_time")
  7556. end_time := c.GetString("end_time")
  7557. admin_user_id, _ := c.GetInt64("admin_user_id")
  7558. adminUser := c.GetAdminUserInfo()
  7559. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7560. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7561. timeLayout := "2006-01-02"
  7562. loc, _ := time.LoadLocation("Local")
  7563. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7564. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7565. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  7566. Mkdir(miConfig.OrgName)
  7567. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  7568. file_name := file + ".txt"
  7569. zip_name := file + ".zip"
  7570. zip_path := miConfig.OrgName + "/" + zip_name
  7571. file_path := miConfig.OrgName + "/" + file_name
  7572. decimal.DivisionPrecision = 2
  7573. var medfee_sumamt float64
  7574. var psn_cash_pay float64
  7575. var fund_pay_sumamt float64
  7576. fixmedins_setl_cnt := int64(len(orders))
  7577. for _, item := range orders {
  7578. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7579. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  7580. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7581. }
  7582. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  7583. defer f.Close()
  7584. if err != nil {
  7585. fmt.Println(err.Error())
  7586. } else {
  7587. for _, item := range orders {
  7588. var refd_setl_flag string
  7589. if item.OrderStatus == 2 {
  7590. refd_setl_flag = "0"
  7591. var str string
  7592. str = item.SetlId + " " +
  7593. item.MdtrtId + " " +
  7594. item.PsnNo + " " +
  7595. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7596. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7597. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  7598. _, err = f.Write([]byte(str))
  7599. }
  7600. if item.OrderStatus == 3 {
  7601. var str string
  7602. str = item.SetlId + " " +
  7603. item.MdtrtId + " " +
  7604. item.PsnNo + " " +
  7605. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7606. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7607. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  7608. _, err = f.Write([]byte(str))
  7609. var str2 string
  7610. str2 = item.SetlId + " " +
  7611. item.MdtrtId + " " +
  7612. item.PsnNo + " " +
  7613. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  7614. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  7615. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  7616. _, err = f.Write([]byte(str2))
  7617. }
  7618. }
  7619. }
  7620. Zip(file_path, zip_path)
  7621. fmt.Println(ReadFile(zip_path))
  7622. fmt.Println(string(ReadFile(zip_path)))
  7623. if config.IsOpen == 1 {
  7624. var user_name string
  7625. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7626. if role.ID == 0 {
  7627. user_name = "管理员"
  7628. } else {
  7629. user_name = role.UserName
  7630. }
  7631. baseParams := models.BaseParams{
  7632. SecretKey: miConfig.SecretKey,
  7633. FixmedinsCode: miConfig.Code,
  7634. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7635. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7636. OrgName: miConfig.OrgName,
  7637. Doctor: user_name,
  7638. }
  7639. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  7640. var dat map[string]interface{}
  7641. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7642. fmt.Println(dat)
  7643. } else {
  7644. fmt.Println(err)
  7645. }
  7646. userJSONBytes, _ := json.Marshal(dat)
  7647. var res ResultNine
  7648. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7649. utils.ErrorLog("解析失败:%v", err)
  7650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7651. return
  7652. }
  7653. if res.Infcode == 0 {
  7654. fileNo := res.Output.FileQuryNo
  7655. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  7656. "file_qury_no=" + fileNo +
  7657. "&setl_optins=" + "定点医保中心" +
  7658. "&stmt_begndate=" + start_time +
  7659. "&stm_enddate=" + end_time +
  7660. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7661. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7662. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  7663. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7664. "&fixmedins_code=" + miConfig.Code +
  7665. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7666. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7667. "&secret_key=" + miConfig.SecretKey +
  7668. "&org_name=" + miConfig.OrgName +
  7669. "&doctor=" + user_name
  7670. resp, requestErr := http.Get(api)
  7671. if requestErr != nil {
  7672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7673. return
  7674. }
  7675. body, ioErr := ioutil.ReadAll(resp.Body)
  7676. if ioErr != nil {
  7677. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7679. return
  7680. }
  7681. var respJSON map[string]interface{}
  7682. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7685. return
  7686. }
  7687. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7688. userJSONBytes, _ := json.Marshal(respJSON)
  7689. var res ResultTen
  7690. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7691. utils.ErrorLog("解析失败:%v", err)
  7692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7693. return
  7694. }
  7695. if res.Infcode == 0 {
  7696. service.Gdyb9102(baseParams, zip_name, fileNo)
  7697. micc := &models.MedicalInsuranceCostCompare{
  7698. StartTime: startime.Unix(),
  7699. EndTime: endtime.Unix(),
  7700. Insutype: "0",
  7701. CheckType: 2,
  7702. Num: fixmedins_setl_cnt,
  7703. Mtime: time.Now().Unix(),
  7704. Status: 1,
  7705. UserOrgId: adminUser.CurrentOrgId,
  7706. CostTotal: medfee_sumamt,
  7707. FuncTotal: fund_pay_sumamt,
  7708. PsnPay: psn_cash_pay,
  7709. Creator: admin_user_id,
  7710. Ctime: time.Now().Unix(),
  7711. }
  7712. service.CreateMedicalInsuranceCostCompareRecord(micc)
  7713. c.ServeSuccessJSON(map[string]interface{}{
  7714. "msg": "明细对账成功",
  7715. })
  7716. }
  7717. } else {
  7718. }
  7719. }
  7720. }
  7721. type CustomOrderInfo struct {
  7722. Name string
  7723. Spec string
  7724. Unit string
  7725. Count float64
  7726. Price float64
  7727. Total float64
  7728. }
  7729. func (c *HisApiController) GetSettleAccounts() {
  7730. //id, _ := c.GetInt64("id")
  7731. //record_time := c.GetString("record_time")
  7732. order_id, _ := c.GetInt64("order_id")
  7733. admin_user_id, _ := c.GetInt64("admin_user_id")
  7734. //timeLayout := "2006-01-02"
  7735. //loc, _ := time.LoadLocation("Local")
  7736. //
  7737. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7738. //if err != nil {
  7739. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7740. // return
  7741. //}
  7742. //recordDateTime := theTime.Unix()
  7743. adminUser := c.GetAdminUserInfo()
  7744. order, _ := service.GetHisOrderByID(order_id)
  7745. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7746. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  7747. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  7748. orderInfos = append(orderInfos, orderInfos_two...)
  7749. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7750. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  7751. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7752. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  7753. //var config []*models.HisXtDiagnoseConfig
  7754. var name string
  7755. for _, item := range diagnosis_ids {
  7756. id, _ := strconv.ParseInt(item, 10, 64)
  7757. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7758. if len(name) == 0 {
  7759. name = diagnosisConfig.ClassName
  7760. } else {
  7761. name = name + "," + diagnosisConfig.ClassName
  7762. }
  7763. }
  7764. var bedCostTotal float64 = 0 //床位总费
  7765. var bedCostSelfTotal float64 = 0 //床位自费
  7766. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7767. var operationCostTotal float64 = 0 //手术费
  7768. var operationCostSelfTotal float64 = 0 //手术费
  7769. var operationCostPartSelfTotal float64 = 0 //手术费
  7770. var otherCostTotal float64 = 0 //其他费用
  7771. var otherCostSelfTotal float64 = 0 //其他费用
  7772. var otherCostPartSelfTotal float64 = 0 //其他费用
  7773. var materialCostTotal float64 = 0 //材料费
  7774. var materialCostSelfTotal float64 = 0 //材料费
  7775. var materialCostPartSelfTotal float64 = 0 //材料费
  7776. var westernMedicineCostTotal float64 = 0 //西药费
  7777. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7778. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7779. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7780. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7781. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7782. var checkCostTotal float64 = 0 //检查费
  7783. var checkCostSelfTotal float64 = 0 //检查费
  7784. var checkCostPartSelfTotal float64 = 0 //检查费
  7785. var laboratoryCostTotal float64 = 0 //化验费
  7786. var laboratoryCostSelfTotal float64 = 0 //化验费
  7787. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7788. var treatCostTotal float64 = 0 //治疗费用
  7789. var treatCostSelfTotal float64 = 0 //治疗费用
  7790. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7791. decimal.DivisionPrecision = 2
  7792. for _, item := range orderInfos {
  7793. if item.MedChrgitmType == "01" { //床位费
  7794. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7795. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7796. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7797. }
  7798. if item.MedChrgitmType == "03" { //检查费
  7799. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7800. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7801. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7802. }
  7803. if item.MedChrgitmType == "04" { //化验费
  7804. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7805. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7806. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7807. }
  7808. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  7809. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7810. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7811. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7812. }
  7813. if item.MedChrgitmType == "06" { //手术费
  7814. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7815. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7816. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7817. }
  7818. if item.MedChrgitmType == "08" { //材料费
  7819. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7820. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7821. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7822. }
  7823. if item.MedChrgitmType == "09" { //西药费
  7824. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7825. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7826. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7827. }
  7828. if item.MedChrgitmType == "11" { //中成费
  7829. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7830. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7831. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7832. }
  7833. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  7834. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7835. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7836. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7837. }
  7838. }
  7839. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7840. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7841. var user_name string
  7842. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7843. if role.ID == 0 {
  7844. user_name = "管理员"
  7845. } else {
  7846. user_name = role.UserName
  7847. }
  7848. baseParams := models.BaseParams{
  7849. SecretKey: miConfig.SecretKey,
  7850. FixmedinsCode: miConfig.Code,
  7851. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7852. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7853. OrgName: miConfig.OrgName,
  7854. Doctor: user_name,
  7855. }
  7856. businessParams := models.BusinessParams{
  7857. PsnNo: order.PsnNo,
  7858. MdtrtId: order.MdtrtId,
  7859. SetlId: order.SetlId,
  7860. }
  7861. var res ResultEleven
  7862. var resEleven10265 ResultEleven10265
  7863. if config.IsOpen == 1 {
  7864. if miConfig.MdtrtareaAdmvs == "421300" {
  7865. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7866. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7867. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7868. resp, requestErr := http.Get(api)
  7869. if requestErr != nil {
  7870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7871. return
  7872. }
  7873. body, ioErr := ioutil.ReadAll(resp.Body)
  7874. if ioErr != nil {
  7875. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7877. return
  7878. }
  7879. var respJSON map[string]interface{}
  7880. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7883. return
  7884. }
  7885. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7886. result, _ := json.Marshal(respJSON)
  7887. fmt.Println("log")
  7888. fmt.Println(string(result))
  7889. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7890. utils.ErrorLog("解析失败:%v", err)
  7891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7892. return
  7893. }
  7894. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7895. var api string
  7896. if miConfig.MdtrtareaAdmvs == "320921" {
  7897. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7898. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7899. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7900. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7901. } else {
  7902. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7903. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7904. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7905. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7906. }
  7907. resp, requestErr := http.Get(api)
  7908. if requestErr != nil {
  7909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7910. return
  7911. }
  7912. body, ioErr := ioutil.ReadAll(resp.Body)
  7913. if ioErr != nil {
  7914. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7916. return
  7917. }
  7918. var respJSON map[string]interface{}
  7919. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7922. return
  7923. }
  7924. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7925. result, _ := json.Marshal(respJSON)
  7926. fmt.Println("log")
  7927. fmt.Println(string(result))
  7928. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  7929. utils.ErrorLog("解析失败:%v", err)
  7930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7931. return
  7932. }
  7933. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7934. res.Output = resEleven10265.Output
  7935. res.ErrMsg = resEleven10265.ErrMsg
  7936. res.Cainfo = resEleven10265.Cainfo
  7937. res.WarnMsg = resEleven10265.WarnMsg
  7938. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7939. res.Infcode = infocode
  7940. } else {
  7941. //result2 := service.Gdyb1101()
  7942. result2 := service.Gdyb5204(baseParams, businessParams)
  7943. saveLog(result2, "", "5204", "查询")
  7944. result := service.Gdyb5203(baseParams, businessParams)
  7945. var dat map[string]interface{}
  7946. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7947. fmt.Println(dat)
  7948. } else {
  7949. fmt.Println(err)
  7950. }
  7951. userJSONBytes, _ := json.Marshal(dat)
  7952. if miConfig.Code == "H15049901371" {
  7953. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  7954. utils.ErrorLog("解析失败:%v", err)
  7955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7956. return
  7957. }
  7958. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7959. res.Output = resEleven10265.Output
  7960. res.ErrMsg = resEleven10265.ErrMsg
  7961. res.Cainfo = resEleven10265.Cainfo
  7962. res.WarnMsg = resEleven10265.WarnMsg
  7963. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7964. res.Infcode = infocode
  7965. } else {
  7966. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7967. utils.ErrorLog("解析失败:%v", err)
  7968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7969. return
  7970. }
  7971. }
  7972. }
  7973. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7974. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  7975. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  7976. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7977. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7978. var doctor_name string
  7979. if roles.ID == 0 {
  7980. doctor_name = "管理员"
  7981. } else {
  7982. doctor_name = roles.UserName
  7983. }
  7984. yiliao_leibie := ""
  7985. switch order.MedType {
  7986. case "11":
  7987. yiliao_leibie = "普通门诊"
  7988. break
  7989. case "12":
  7990. yiliao_leibie = "门诊挂号"
  7991. break
  7992. case "13":
  7993. yiliao_leibie = "急诊"
  7994. break
  7995. case "14":
  7996. yiliao_leibie = "门诊特殊病"
  7997. break
  7998. case "15":
  7999. yiliao_leibie = "门诊统筹"
  8000. break
  8001. case "16":
  8002. yiliao_leibie = "门诊慢性病"
  8003. break
  8004. case "21":
  8005. yiliao_leibie = "普通住院"
  8006. break
  8007. }
  8008. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8009. if res.Infcode == 0 {
  8010. c.ServeSuccessJSON(map[string]interface{}{
  8011. "diagnosis": name,
  8012. "order_infos": orderInfos,
  8013. "number": order.MdtrtId,
  8014. "date": order.SettleAccountsDate,
  8015. "charge_admin": charge_admin,
  8016. "printor_admin": printor_admin,
  8017. "info": res.Output.Setlinfo,
  8018. "bedCostTotal": bedCostTotal,
  8019. "bedCostSelfTotal": bedCostSelfTotal,
  8020. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8021. "operationCostTotal": operationCostTotal,
  8022. "operationCostSelfTotal": operationCostSelfTotal,
  8023. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8024. "otherCostTotal": otherCostTotal,
  8025. "otherCostSelfTotal": otherCostSelfTotal,
  8026. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8027. "materialCostTotal": materialCostTotal,
  8028. "materialCostSelfTotal": materialCostSelfTotal,
  8029. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8030. "westernMedicineCostTotal": westernMedicineCostTotal,
  8031. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8032. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8033. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8034. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8035. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8036. "checkCostTotal": checkCostTotal,
  8037. "checkCostSelfTotal": checkCostSelfTotal,
  8038. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8039. "laboratoryCostTotal": laboratoryCostTotal,
  8040. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  8041. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  8042. "treatCostTotal": treatCostTotal,
  8043. "treatCostSelfTotal": treatCostSelfTotal,
  8044. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  8045. "doctor_code": adminRole_two.DoctorCode,
  8046. "doctor_name": doctor_name,
  8047. "health_card_no": order.PsnNo,
  8048. "department": departments.Name,
  8049. "yiliao_leibie": yiliao_leibie,
  8050. "after_money": order.AccountPrice,
  8051. "patient": patient,
  8052. "org_name": miConfig.OrgName,
  8053. "org_code": miConfig.Code,
  8054. "order_number": order.Number,
  8055. "his_hospital": his_hospital,
  8056. "his": his,
  8057. //"check_order_info": cus_slice,
  8058. })
  8059. }
  8060. }
  8061. }
  8062. func (c *HisApiController) CheckTreatment() {
  8063. patient_id, _ := c.GetInt64("patient_id")
  8064. id_card_no := c.GetString("id_card_no")
  8065. insutype := c.GetString("insutype")
  8066. med_type := c.GetString("med_type")
  8067. admin_user_id, _ := c.GetInt64("admin_user_id")
  8068. adminUser := c.GetAdminUserInfo()
  8069. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8070. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8071. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8072. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8073. if miConfig.MdtrtareaAdmvs == "421300" {
  8074. var res ResultTwo
  8075. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8076. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8077. "&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)
  8078. resp, requestErr := http.Get(api)
  8079. if requestErr != nil {
  8080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8081. return
  8082. }
  8083. body, ioErr := ioutil.ReadAll(resp.Body)
  8084. if ioErr != nil {
  8085. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8087. return
  8088. }
  8089. var respJSON map[string]interface{}
  8090. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8091. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8093. return
  8094. }
  8095. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8096. result, _ := json.Marshal(respJSON)
  8097. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8098. utils.ErrorLog("解析失败:%v", err)
  8099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8100. return
  8101. }
  8102. if res.Infcode == 0 {
  8103. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  8104. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8105. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  8106. resp, requestErr := http.Get(api)
  8107. if requestErr != nil {
  8108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8109. return
  8110. }
  8111. body, ioErr := ioutil.ReadAll(resp.Body)
  8112. if ioErr != nil {
  8113. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8115. return
  8116. }
  8117. var respJSON map[string]interface{}
  8118. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8119. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8121. return
  8122. }
  8123. var res Result2001
  8124. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8125. result2, _ := json.Marshal(respJSON)
  8126. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8127. utils.ErrorLog("解析失败:%v", err)
  8128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8129. return
  8130. }
  8131. if res.Infcode == 0 {
  8132. c.ServeSuccessJSON(map[string]interface{}{
  8133. "msg": res.Output.Trtinfo,
  8134. })
  8135. }
  8136. } else {
  8137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8138. return
  8139. }
  8140. } else {
  8141. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8142. var dat map[string]interface{}
  8143. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8144. fmt.Println(dat)
  8145. } else {
  8146. fmt.Println(err)
  8147. }
  8148. userJSONBytes, _ := json.Marshal(dat)
  8149. var res ResultTwo
  8150. var res10265 ResultTwo10265
  8151. if miConfig.Code == "H15049901371" {
  8152. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8153. utils.ErrorLog("解析失败:%v", err)
  8154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8155. return
  8156. }
  8157. res.ErrMsg = res10265.ErrMsg
  8158. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8159. res.Infcode = infocode
  8160. res.Output = res10265.Output
  8161. res.InfRefmsgid = res10265.InfRefmsgid
  8162. } else {
  8163. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8164. utils.ErrorLog("解析失败:%v", err)
  8165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8166. return
  8167. }
  8168. }
  8169. var user_name string
  8170. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  8171. if role.ID == 0 {
  8172. user_name = "xxx"
  8173. } else {
  8174. user_name = role.UserName
  8175. }
  8176. baseParams := models.BaseParams{
  8177. SecretKey: miConfig.SecretKey,
  8178. FixmedinsCode: miConfig.Code,
  8179. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8180. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8181. OrgName: miConfig.OrgName,
  8182. Doctor: user_name,
  8183. }
  8184. if config.IsOpen == 1 {
  8185. if miConfig.Code == "H15049901371" {
  8186. if med_type == "14" {
  8187. if insutype == "390" {
  8188. med_type = "9933"
  8189. } else if insutype == "310" {
  8190. med_type = "990502"
  8191. }
  8192. } else if med_type == "11" {
  8193. med_type = "11"
  8194. }
  8195. }
  8196. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  8197. var dat map[string]interface{}
  8198. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8199. fmt.Println(dat)
  8200. } else {
  8201. fmt.Println(err)
  8202. }
  8203. var res Result2001
  8204. var res10265 Result2001Org10265
  8205. if miConfig.Code == "H15049901371" {
  8206. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8207. utils.ErrorLog("解析失败:%v", err)
  8208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8209. return
  8210. }
  8211. res.ErrMsg = res10265.ErrMsg
  8212. res.Output = res10265.Output
  8213. res.InfRefmsgid = res10265.InfRefmsgid
  8214. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8215. res.Infcode = infocode
  8216. } else {
  8217. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8218. utils.ErrorLog("解析失败:%v", err)
  8219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8220. return
  8221. }
  8222. }
  8223. if res.Infcode == 0 {
  8224. c.ServeSuccessJSON(map[string]interface{}{
  8225. "msg": res.Output.Trtinfo,
  8226. })
  8227. }
  8228. }
  8229. }
  8230. }
  8231. //func (c *HisApiController) PutRecord() {
  8232. // id, _ := c.GetInt64("id")
  8233. // record_time := c.GetString("record_time")
  8234. // timeLayout := "2006-01-02"
  8235. // loc, _ := time.LoadLocation("Local")
  8236. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8237. // if err != nil {
  8238. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8239. // return
  8240. // }
  8241. // recordDateTime := theTime.Unix()
  8242. //
  8243. // adminInfo := c.GetAdminUserInfo()
  8244. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  8245. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8246. //
  8247. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8248. //
  8249. // fmt.Println(miConfig.SecretKey)
  8250. //
  8251. // if patient == nil {
  8252. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8253. // return
  8254. // }
  8255. // if len(patient.IdCardNo) == 0 {
  8256. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  8257. // return
  8258. // }
  8259. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8260. // if config.IsOpen == 1 {
  8261. // 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
  8262. // resp, requestErr := http.Get(api)
  8263. // if requestErr != nil {
  8264. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8265. // return
  8266. // }
  8267. // defer resp.Body.Close()
  8268. // body, ioErr := ioutil.ReadAll(resp.Body)
  8269. // if ioErr != nil {
  8270. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8271. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8272. // return
  8273. // }
  8274. // var respJSON map[string]interface{}
  8275. //
  8276. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8277. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8278. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8279. // return
  8280. // }
  8281. //
  8282. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8283. // userJSONBytes, _ := json.Marshal(userJSON)
  8284. // var res ResultTwo
  8285. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8286. // utils.ErrorLog("解析失败:%v", err)
  8287. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8288. // return
  8289. // }
  8290. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8291. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8292. // infoStr := string(Iinfos)
  8293. // idetinfoStr := string(Idetinfos)
  8294. //
  8295. // if res.Infcode == 0 {
  8296. // his := models.VMHisPatient{
  8297. // Status: 1,
  8298. // Ctime: time.Now().Unix(),
  8299. // Mtime: time.Now().Unix(),
  8300. // PsnNo: res.Output.Baseinfo.PsnNo,
  8301. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  8302. // Certno: res.Output.Baseinfo.Certno,
  8303. // PsnName: res.Output.Baseinfo.PsnName,
  8304. // Gend: res.Output.Baseinfo.Gend,
  8305. // Naty: res.Output.Baseinfo.Naty,
  8306. // Brdy: res.Output.Baseinfo.Brdy,
  8307. // Age: res.Output.Baseinfo.Age,
  8308. // Iinfo: infoStr,
  8309. // Idetinfo: idetinfoStr,
  8310. // PatientId: patient.ID,
  8311. // RecordDate: theTime.Unix(),
  8312. // UserOrgId: adminInfo.CurrentOrgId,
  8313. // AdminUserId: adminInfo.AdminUser.Id,
  8314. // IsReturn: 1,
  8315. // }
  8316. //
  8317. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  8318. // //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")
  8319. // //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")
  8320. //
  8321. // //var dat map[string]interface{}
  8322. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8323. // // fmt.Println(dat)
  8324. // //} else {
  8325. // // fmt.Println(err)
  8326. // //}
  8327. //
  8328. // var dat2 map[string]interface{}
  8329. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8330. // fmt.Println(dat2)
  8331. // } else {
  8332. // fmt.Println(err)
  8333. // }
  8334. //
  8335. // } else {
  8336. // adminUser := c.GetAdminUserInfo()
  8337. // errlog := &models.HisOrderError{
  8338. // UserOrgId: adminUser.CurrentOrgId,
  8339. // Ctime: time.Now().Unix(),
  8340. // Mtime: time.Now().Unix(),
  8341. // ErrMsg: res.ErrMsg,
  8342. // Status: 1,
  8343. // PatientId: id,
  8344. // RecordTime: recordDateTime,
  8345. // Stage: 1,
  8346. // }
  8347. // service.CreateErrMsgLog(errlog)
  8348. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8349. // return
  8350. // }
  8351. // }
  8352. //
  8353. //}
  8354. //func (c *HisApiController) GetUploadDiag() {
  8355. // id, _ := c.GetInt64("id")
  8356. // record_time := c.GetString("record_time")
  8357. //
  8358. // diagnosis_id, _ := c.GetInt64("diagnosis")
  8359. // sick_type, _ := c.GetInt64("sick_type")
  8360. // reg_type, _ := c.GetInt64("reg_type")
  8361. //
  8362. // timeLayout := "2006-01-02"
  8363. // loc, _ := time.LoadLocation("Local")
  8364. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8365. // if err != nil {
  8366. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8367. // return
  8368. // }
  8369. //
  8370. // var patientPrescription models.HisPrescriptionInfo
  8371. // recordDateTime := theTime.Unix()
  8372. // adminInfo := c.GetAdminUserInfo()
  8373. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8374. //
  8375. // if patientPrescription.ID == 0 {
  8376. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8377. // }
  8378. //
  8379. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8380. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8381. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8382. // sickConfig, _ := service.FindSickById(sick_type)
  8383. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8384. //
  8385. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  8386. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  8387. // "&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 +
  8388. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  8389. // resp2, requestErr2 := http.Get(api2)
  8390. // if requestErr2 != nil {
  8391. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8392. // return
  8393. // }
  8394. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8395. // if ioErr2 != nil {
  8396. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8397. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8398. // return
  8399. // }
  8400. // var respJSON2 map[string]interface{}
  8401. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8402. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8403. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8404. // return
  8405. // }
  8406. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8407. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8408. //
  8409. // var res2 ResultSix
  8410. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8411. // utils.ErrorLog("解析失败:%v", err)
  8412. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8413. // return
  8414. // }
  8415. // if res2.Infcode != 0 {
  8416. // adminUser := c.GetAdminUserInfo()
  8417. // errlog := &models.HisOrderError{
  8418. // UserOrgId: adminUser.CurrentOrgId,
  8419. // Ctime: time.Now().Unix(),
  8420. // Mtime: time.Now().Unix(),
  8421. // ErrMsg: res2.ErrMsg,
  8422. // Status: 1,
  8423. // PatientId: id,
  8424. // RecordTime: recordDateTime,
  8425. // Stage: 3,
  8426. // }
  8427. // service.CreateErrMsgLog(errlog)
  8428. //
  8429. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  8430. // return
  8431. // }
  8432. //
  8433. // c.ServeSuccessJSON(map[string]interface{}{
  8434. // "msg": "上传成功",
  8435. // })
  8436. //
  8437. //}
  8438. type QueryResult struct {
  8439. ID int64
  8440. Name string
  8441. Code string
  8442. List_type_code string
  8443. }
  8444. func (c *HisApiController) GetCheckCode() {
  8445. ids_str := c.GetString("ids")
  8446. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8447. ids_arr := strings.Split(ids_str, ",")
  8448. var queryResult []QueryResult
  8449. ids := make([]int64, 0)
  8450. for _, item := range ids_arr {
  8451. id, _ := strconv.ParseInt(item, 10, 64)
  8452. ids = append(ids, id)
  8453. }
  8454. if record_type == 1 {
  8455. drugs, _ := service.GetBatchDrugList(ids)
  8456. for _, item := range drugs {
  8457. result := QueryResult{
  8458. ID: item.ID,
  8459. Name: item.DrugName,
  8460. Code: item.MedicalInsuranceNumber,
  8461. List_type_code: "101",
  8462. }
  8463. queryResult = append(queryResult, result)
  8464. }
  8465. } else if record_type == 2 {
  8466. goods, _ := service.GetBatchGoodInformationList(ids)
  8467. for _, item := range goods {
  8468. result := QueryResult{
  8469. ID: item.ID,
  8470. Name: item.GoodName,
  8471. Code: item.MedicalInsuranceNumber,
  8472. List_type_code: "301",
  8473. }
  8474. queryResult = append(queryResult, result)
  8475. }
  8476. } else if record_type == 3 {
  8477. projects, _ := service.GetBathchMyPorjecgList(ids)
  8478. for _, item := range projects {
  8479. result := QueryResult{
  8480. ID: item.ID,
  8481. Name: item.ProjectName,
  8482. Code: item.MedicalCode,
  8483. List_type_code: "201",
  8484. }
  8485. queryResult = append(queryResult, result)
  8486. }
  8487. }
  8488. admin_user_id, _ := c.GetInt64("admin_user_id")
  8489. adminUser := c.GetAdminUserInfo()
  8490. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8491. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8492. var user_name string
  8493. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8494. if role.ID == 0 {
  8495. user_name = "xxx"
  8496. } else {
  8497. user_name = role.UserName
  8498. }
  8499. baseParams := &models.BaseParams{
  8500. SecretKey: miConfig.SecretKey,
  8501. FixmedinsCode: miConfig.Code,
  8502. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8503. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8504. OrgName: miConfig.OrgName,
  8505. Doctor: user_name,
  8506. }
  8507. if config.IsOpen == 1 {
  8508. for _, item := range queryResult {
  8509. var result string
  8510. if record_type == 1 {
  8511. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8512. } else if record_type == 2 {
  8513. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8514. } else if record_type == 3 {
  8515. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8516. }
  8517. var dat map[string]interface{}
  8518. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8519. fmt.Println(dat)
  8520. } else {
  8521. fmt.Println(err)
  8522. }
  8523. userJSONBytes, _ := json.Marshal(dat)
  8524. var res ResultSix
  8525. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8526. utils.ErrorLog("解析失败:%v", err)
  8527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8528. return
  8529. }
  8530. if res.Infcode == 0 {
  8531. if record_type == 1 {
  8532. service.UpdateBaseDrugById(item.ID)
  8533. } else if record_type == 2 {
  8534. service.UpdateGoodInformaitonByDetail(item.ID)
  8535. } else if record_type == 3 {
  8536. service.UpdateProjectById(item.ID)
  8537. }
  8538. c.ServeSuccessJSON(map[string]interface{}{
  8539. "failed_code": 0,
  8540. "msg": "目录对照成功",
  8541. })
  8542. } else {
  8543. c.ServeSuccessJSON(map[string]interface{}{
  8544. "failed_code": -10,
  8545. "msg": res.ErrMsg,
  8546. })
  8547. }
  8548. }
  8549. }
  8550. }
  8551. func (c *HisApiController) UnCheckCode() {
  8552. ids_str := c.GetString("ids")
  8553. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8554. admin_user_id, _ := c.GetInt64("admin_user_id")
  8555. ids_arr := strings.Split(ids_str, ",")
  8556. var queryResult []QueryResult
  8557. ids := make([]int64, 0)
  8558. for _, item := range ids_arr {
  8559. id, _ := strconv.ParseInt(item, 10, 64)
  8560. ids = append(ids, id)
  8561. }
  8562. if record_type == 1 {
  8563. drugs, _ := service.GetBatchDrugList(ids)
  8564. for _, item := range drugs {
  8565. result := QueryResult{
  8566. ID: item.ID,
  8567. Name: item.DrugName,
  8568. Code: item.MedicalInsuranceNumber,
  8569. List_type_code: "101",
  8570. }
  8571. queryResult = append(queryResult, result)
  8572. }
  8573. } else if record_type == 2 {
  8574. goods, _ := service.GetBatchGoodInformationList(ids)
  8575. for _, item := range goods {
  8576. result := QueryResult{
  8577. ID: item.ID,
  8578. Name: item.GoodName,
  8579. Code: item.MedicalInsuranceNumber,
  8580. List_type_code: "301",
  8581. }
  8582. queryResult = append(queryResult, result)
  8583. }
  8584. } else if record_type == 3 {
  8585. projects, _ := service.GetBathchMyPorjecgList(ids)
  8586. for _, item := range projects {
  8587. result := QueryResult{
  8588. ID: item.ID,
  8589. Name: item.ProjectName,
  8590. Code: item.MedicalCode,
  8591. List_type_code: "201",
  8592. }
  8593. queryResult = append(queryResult, result)
  8594. }
  8595. }
  8596. adminUser := c.GetAdminUserInfo()
  8597. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8598. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8599. var user_name string
  8600. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8601. if role.ID == 0 {
  8602. user_name = "xxx"
  8603. } else {
  8604. user_name = role.UserName
  8605. }
  8606. baseParams := &models.BaseParams{
  8607. SecretKey: miConfig.SecretKey,
  8608. FixmedinsCode: miConfig.Code,
  8609. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8610. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8611. OrgName: miConfig.OrgName,
  8612. Doctor: user_name,
  8613. }
  8614. if config.IsOpen == 1 {
  8615. for _, item := range queryResult {
  8616. var result string
  8617. if record_type == 1 {
  8618. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8619. } else if record_type == 2 {
  8620. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8621. } else if record_type == 3 {
  8622. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8623. }
  8624. var dat2 map[string]interface{}
  8625. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  8626. fmt.Println(dat2)
  8627. } else {
  8628. fmt.Println(err)
  8629. }
  8630. userJSONBytes, _ := json.Marshal(dat2)
  8631. var res ResultSix
  8632. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8633. utils.ErrorLog("解析失败:%v", err)
  8634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8635. return
  8636. }
  8637. if res.Infcode == 0 {
  8638. if record_type == 1 {
  8639. service.UpdateDrugByIdDetail(item.ID)
  8640. } else if record_type == 2 {
  8641. service.UpdateGoodInfoById(item.ID)
  8642. } else if record_type == 3 {
  8643. service.UpdateMyProjectById(item.ID)
  8644. }
  8645. c.ServeSuccessJSON(map[string]interface{}{
  8646. "failed_code": 0,
  8647. "msg": "撤销目录对照成功",
  8648. })
  8649. } else {
  8650. c.ServeSuccessJSON(map[string]interface{}{
  8651. "failed_code": -10,
  8652. "msg": res.ErrMsg,
  8653. })
  8654. }
  8655. }
  8656. }
  8657. }
  8658. func (c *HisApiController) GetPatientInfo() {
  8659. id_card_no := c.GetString("id_card_no")
  8660. admin_user_id, _ := c.GetInt64("admin_user_id")
  8661. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8662. if patient.ID == 0 {
  8663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8664. return
  8665. }
  8666. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8667. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8668. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  8669. if config.IsOpen == 1 {
  8670. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8671. var dat map[string]interface{}
  8672. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8673. fmt.Println(dat)
  8674. } else {
  8675. fmt.Println(err)
  8676. }
  8677. userJSONBytes, _ := json.Marshal(dat)
  8678. var res ResultTwo
  8679. var res10265 ResultTwo10265
  8680. if miConfig.Code == "H15049901371" {
  8681. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8682. utils.ErrorLog("解析失败:%v", err)
  8683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8684. return
  8685. }
  8686. res.ErrMsg = res10265.ErrMsg
  8687. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8688. res.Infcode = infocode
  8689. res.Output = res10265.Output
  8690. res.InfRefmsgid = res10265.InfRefmsgid
  8691. } else {
  8692. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8693. utils.ErrorLog("解析失败:%v", err)
  8694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8695. return
  8696. }
  8697. }
  8698. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8699. // utils.ErrorLog("解析失败:%v", err)
  8700. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8701. // return
  8702. //}
  8703. if res.Infcode != 0 {
  8704. c.ServeSuccessJSON(map[string]interface{}{
  8705. "failed_code": -10,
  8706. "msg": res.ErrMsg,
  8707. })
  8708. } else {
  8709. c.ServeSuccessJSON(map[string]interface{}{
  8710. "failed_code": 0,
  8711. "info": res,
  8712. })
  8713. }
  8714. }
  8715. }
  8716. func (c *HisApiController) PsnPutOnRecord() {
  8717. record_type, _ := c.GetInt64("type")
  8718. patient_id, _ := c.GetInt64("patient_id")
  8719. admin_user_id, _ := c.GetInt64("admin_user_id")
  8720. start_time := c.GetString("start_time")
  8721. end_time := c.GetString("end_time")
  8722. adminUser := c.GetAdminUserInfo()
  8723. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8724. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8725. var patients []*models.Patients
  8726. if record_type == 1 { //全部备案
  8727. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  8728. patients = append(patients, patient...)
  8729. } else { //单个备案
  8730. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8731. patients = append(patients, patient)
  8732. }
  8733. var user_name string
  8734. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8735. if role.ID == 0 {
  8736. user_name = "xxx"
  8737. } else {
  8738. user_name = role.UserName
  8739. }
  8740. if config.IsOpen == 1 {
  8741. for _, item := range patients {
  8742. 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
  8743. resp, requestErr := http.Get(api)
  8744. if requestErr != nil {
  8745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8746. return
  8747. }
  8748. defer resp.Body.Close()
  8749. body, ioErr := ioutil.ReadAll(resp.Body)
  8750. if ioErr != nil {
  8751. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8753. return
  8754. }
  8755. var respJSON map[string]interface{}
  8756. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8759. return
  8760. }
  8761. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8762. userJSONBytes, _ := json.Marshal(userJSON)
  8763. var res ResultTwo
  8764. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8765. utils.ErrorLog("解析失败:%v", err)
  8766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8767. return
  8768. }
  8769. if res.Infcode == 0 {
  8770. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  8771. var dat map[string]interface{}
  8772. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8773. fmt.Println(dat)
  8774. } else {
  8775. fmt.Println(err)
  8776. }
  8777. userJSONBytes, _ := json.Marshal(dat)
  8778. var res2 ResultThirteen
  8779. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8780. utils.ErrorLog("解析失败:%v", err)
  8781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8782. return
  8783. }
  8784. if res2.Infcode == 0 {
  8785. psnResult := &models.GdybPsnRecord{
  8786. UserOrgId: adminUser.CurrentOrgId,
  8787. PatientId: item.ID,
  8788. PsnNo: res.Output.Baseinfo.PsnNo,
  8789. Ctime: time.Now().Unix(),
  8790. Mtime: time.Now().Unix(),
  8791. Status: 1,
  8792. IsCancel: 1,
  8793. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8794. }
  8795. service.CreatePsnRecord(psnResult)
  8796. } else {
  8797. c.ServeSuccessJSON(map[string]interface{}{
  8798. "failed_code": -10,
  8799. "msg": res2.ErrMsg,
  8800. })
  8801. return
  8802. }
  8803. }
  8804. }
  8805. }
  8806. }
  8807. func (c *HisApiController) PsnUnPutOnRecord() {
  8808. id, _ := c.GetInt64("id")
  8809. //record_type, _ := c.GetInt64("type")
  8810. admin_user_id, _ := c.GetInt64("admin_user_id")
  8811. adminUser := c.GetAdminUserInfo()
  8812. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8813. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8814. var user_name string
  8815. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8816. if role.ID == 0 {
  8817. user_name = "xxx"
  8818. } else {
  8819. user_name = role.UserName
  8820. }
  8821. psn_record, _ := service.GetPsnRecordById(id)
  8822. if psn_record.ID == 0 {
  8823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8824. return
  8825. }
  8826. if config.IsOpen == 1 {
  8827. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8828. var dat map[string]interface{}
  8829. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8830. fmt.Println(dat)
  8831. } else {
  8832. fmt.Println(err)
  8833. }
  8834. userJSONBytes, _ := json.Marshal(dat)
  8835. var res ResultFourteen
  8836. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8837. utils.ErrorLog("解析失败:%v", err)
  8838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8839. return
  8840. }
  8841. if res.Infcode == 0 {
  8842. psn_record.IsCancel = 2
  8843. service.CreatePsnRecord(&psn_record)
  8844. } else {
  8845. c.ServeSuccessJSON(map[string]interface{}{
  8846. "failed_code": -10,
  8847. "msg": res.ErrMsg,
  8848. })
  8849. return
  8850. }
  8851. }
  8852. }
  8853. func (c *HisApiController) PsnPutNCDSOnRecord() {
  8854. patient_id, _ := c.GetInt64("patient_id")
  8855. insutype_two := c.GetString("insutype")
  8856. psn_no := c.GetString("psn_no")
  8857. doctor_id, _ := c.GetInt64("doctor_id")
  8858. sick_id, _ := c.GetInt64("sick_id")
  8859. department_id, _ := c.GetInt64("department_id")
  8860. start_time := c.GetString("start_time")
  8861. end_time := c.GetString("end_time")
  8862. check_time := c.GetString("check_time")
  8863. adminUser := c.GetAdminUserInfo()
  8864. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8865. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8866. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8867. sick, _ := service.FindSickById(sick_id)
  8868. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8869. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8870. var res ResultTwo
  8871. var res10265 ResultTwo10265
  8872. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8873. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  8874. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  8875. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8876. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(3, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  8877. resp, requestErr := http.Get(api)
  8878. if requestErr != nil {
  8879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8880. return
  8881. }
  8882. body, ioErr := ioutil.ReadAll(resp.Body)
  8883. if ioErr != nil {
  8884. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8886. return
  8887. }
  8888. var respJSON map[string]interface{}
  8889. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8890. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8892. return
  8893. }
  8894. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8895. result, _ := json.Marshal(respJSON)
  8896. fmt.Println("log")
  8897. fmt.Println(string(result))
  8898. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8899. utils.ErrorLog("解析失败:%v", err)
  8900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8901. return
  8902. }
  8903. res.ErrMsg = res10265.ErrMsg
  8904. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8905. res.Infcode = infocode
  8906. res.Output = res10265.Output
  8907. res.InfRefmsgid = res10265.InfRefmsgid
  8908. } else {
  8909. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8910. if miConfig.Code == "H15049901371" {
  8911. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8912. utils.ErrorLog("解析失败:%v", err)
  8913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8914. return
  8915. }
  8916. res.ErrMsg = res10265.ErrMsg
  8917. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8918. res.Infcode = infocode
  8919. res.Output = res10265.Output
  8920. res.InfRefmsgid = res10265.InfRefmsgid
  8921. } else {
  8922. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8923. utils.ErrorLog("解析失败:%v", err)
  8924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8925. return
  8926. }
  8927. }
  8928. }
  8929. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8930. infoStr := string(Iinfos)
  8931. var rf []*ResultFive
  8932. json.Unmarshal([]byte(infoStr), &rf)
  8933. var insuplc_admdvs string
  8934. var insutype string
  8935. var is390 int = 0
  8936. var is310 int = 0
  8937. var insutypes []*ResultFive
  8938. for _, item := range rf {
  8939. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8940. insutypes = append(insutypes, item)
  8941. }
  8942. }
  8943. if len(insutypes) == 1 {
  8944. insutype = insutypes[0].Insutype
  8945. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8946. } else {
  8947. for _, i := range insutypes {
  8948. if i.Insutype == "390" {
  8949. is390 = 1
  8950. }
  8951. if i.Insutype == "310" {
  8952. is310 = 1
  8953. }
  8954. }
  8955. }
  8956. if is390 == 1 {
  8957. insutype = "390"
  8958. }
  8959. if is310 == 1 {
  8960. insutype = "310"
  8961. }
  8962. if len(insutypes) == 2 {
  8963. insutype = insutype_two
  8964. }
  8965. if len(insutypes) == 0 {
  8966. insutype = "310"
  8967. }
  8968. insutype = insutype_two
  8969. fmt.Println(insutype)
  8970. for _, item := range rf {
  8971. fmt.Println(item.Insutype)
  8972. fmt.Println(insutype)
  8973. if item.Insutype == insutype {
  8974. fmt.Println(item.Insutype)
  8975. fmt.Println(insutype)
  8976. insuplc_admdvs = item.InsuplcAdmdvs
  8977. }
  8978. }
  8979. fmt.Println(insuplc_admdvs)
  8980. var res2 ResultThirteen
  8981. var res10265_2 ResultThirteen10265
  8982. if config.IsOpen == 1 {
  8983. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8984. } else {
  8985. 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)
  8986. var dat map[string]interface{}
  8987. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8988. fmt.Println(dat)
  8989. } else {
  8990. fmt.Println(err)
  8991. }
  8992. userJSONBytes, _ := json.Marshal(dat)
  8993. if miConfig.Code == "H15049901371" {
  8994. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  8995. utils.ErrorLog("解析失败:%v", err)
  8996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8997. return
  8998. }
  8999. res2.ErrMsg = res10265_2.ErrMsg
  9000. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  9001. res2.Infcode = infocode
  9002. res2.Output = res10265_2.Output
  9003. res2.InfRefmsgid = res10265_2.InfRefmsgid
  9004. } else {
  9005. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9006. utils.ErrorLog("解析失败:%v", err)
  9007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9008. return
  9009. }
  9010. }
  9011. }
  9012. if res2.Infcode == 0 {
  9013. psnResult := &models.GdybPsnNcdsRecord{
  9014. UserOrgId: adminUser.CurrentOrgId,
  9015. PatientId: patient.ID,
  9016. PsnNo: psn_no,
  9017. DoctorId: doctor.AdminUserId,
  9018. DepartmentId: department_id,
  9019. SickType: sick_id,
  9020. Insutype: insutype,
  9021. Ctime: time.Now().Unix(),
  9022. Mtime: time.Now().Unix(),
  9023. Status: 1,
  9024. IsCancel: 1,
  9025. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9026. }
  9027. service.CreatePsnNCDSRecord(psnResult)
  9028. c.ServeSuccessJSON(map[string]interface{}{
  9029. "failed_code": 0,
  9030. "msg": "备案成功",
  9031. "result": psnResult,
  9032. })
  9033. } else {
  9034. c.ServeSuccessJSON(map[string]interface{}{
  9035. "failed_code": -10,
  9036. "msg": res2.ErrMsg,
  9037. })
  9038. return
  9039. }
  9040. }
  9041. }
  9042. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  9043. id, _ := c.GetInt64("id")
  9044. admin_user_id, _ := c.GetInt64("admin_user_id")
  9045. adminUser := c.GetAdminUserInfo()
  9046. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9047. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9048. //config, _ := service.Ge(adminUser.CurrentOrgId)
  9049. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  9050. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9051. //var user_name string
  9052. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9053. //if role.ID == 0 {
  9054. // user_name = "xxx"
  9055. //} else {
  9056. // user_name = role.UserName
  9057. //}
  9058. psn_record, _ := service.GetPsnNCDSRecordById(id)
  9059. if psn_record.ID == 0 {
  9060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9061. return
  9062. }
  9063. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9064. var res ResultTwo
  9065. var res10265 ResultTwo10265
  9066. if miConfig.Code == "H15049901371" {
  9067. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9068. utils.ErrorLog("解析失败:%v", err)
  9069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9070. return
  9071. }
  9072. res.ErrMsg = res10265.ErrMsg
  9073. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9074. res.Infcode = infocode
  9075. res.Output = res10265.Output
  9076. res.InfRefmsgid = res10265.InfRefmsgid
  9077. } else {
  9078. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9079. utils.ErrorLog("解析失败:%v", err)
  9080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9081. return
  9082. }
  9083. }
  9084. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9085. infoStr := string(Iinfos)
  9086. var rf []*ResultFive
  9087. json.Unmarshal([]byte(infoStr), &rf)
  9088. var insuplc_admdvs string
  9089. var insutype string
  9090. var is390 int = 0
  9091. var is310 int = 0
  9092. var insutypes []*ResultFive
  9093. for _, item := range rf {
  9094. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9095. insutypes = append(insutypes, item)
  9096. }
  9097. }
  9098. if len(insutypes) == 1 {
  9099. insutype = insutypes[0].Insutype
  9100. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9101. } else {
  9102. for _, i := range insutypes {
  9103. if i.Insutype == "390" {
  9104. is390 = 1
  9105. }
  9106. if i.Insutype == "310" {
  9107. is310 = 1
  9108. }
  9109. }
  9110. }
  9111. if is390 == 1 {
  9112. insutype = "390"
  9113. }
  9114. if is310 == 1 {
  9115. insutype = "310"
  9116. }
  9117. if len(insutypes) == 0 {
  9118. insutype = "310"
  9119. }
  9120. insutype = psn_record.Insutype
  9121. for _, item := range rf {
  9122. if item.Insutype == insutype {
  9123. insuplc_admdvs = item.InsuplcAdmdvs
  9124. }
  9125. }
  9126. if config.IsOpen == 1 {
  9127. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9128. var dat map[string]interface{}
  9129. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9130. fmt.Println(dat)
  9131. } else {
  9132. fmt.Println(err)
  9133. }
  9134. userJSONBytes, _ := json.Marshal(dat)
  9135. var res ResultFourteen
  9136. var res10265 ResultFourteen10265
  9137. if miConfig.Code == "H15049901371" {
  9138. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9139. utils.ErrorLog("解析失败:%v", err)
  9140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9141. return
  9142. }
  9143. res.ErrMsg = res10265.ErrMsg
  9144. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9145. res.Infcode = infocode
  9146. res.Output = res10265.Output
  9147. res.InfRefmsgid = res10265.InfRefmsgid
  9148. } else {
  9149. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9150. utils.ErrorLog("解析失败:%v", err)
  9151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9152. return
  9153. }
  9154. }
  9155. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9156. // utils.ErrorLog("解析失败:%v", err)
  9157. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9158. // return
  9159. //}
  9160. if res.Infcode == 0 {
  9161. psn_record.IsCancel = 2
  9162. service.CreatePsnNCDSRecord(&psn_record)
  9163. c.ServeSuccessJSON(map[string]interface{}{
  9164. "failed_code": 0,
  9165. "msg": "撤销备案成功",
  9166. })
  9167. } else {
  9168. c.ServeSuccessJSON(map[string]interface{}{
  9169. "failed_code": -10,
  9170. "msg": res.ErrMsg,
  9171. })
  9172. return
  9173. }
  9174. }
  9175. }
  9176. func (c *HisApiController) TestTest() {
  9177. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  9178. fmt.Println(patient.Iinfo)
  9179. }
  9180. type CustomData struct {
  9181. MsgId string
  9182. PsnNo string
  9183. Info string
  9184. }
  9185. func (c *HisApiController) ReversalData() {
  9186. var customData []*CustomData
  9187. custom := &CustomData{
  9188. MsgId: "H44022900158202103301714472004",
  9189. PsnNo: "44020000001101329945",
  9190. Info: "2207",
  9191. }
  9192. customData = append(customData, custom)
  9193. custom1 := &CustomData{
  9194. MsgId: "H4402290015820210330172057803",
  9195. PsnNo: "44020000001101161813",
  9196. Info: "2207",
  9197. }
  9198. customData = append(customData, custom1)
  9199. custom2 := &CustomData{
  9200. MsgId: "H44022900158202103301705198813",
  9201. PsnNo: "44190000133097375417",
  9202. Info: "2207",
  9203. }
  9204. customData = append(customData, custom2)
  9205. custom3 := &CustomData{
  9206. MsgId: "H44022900158202103301715524756",
  9207. PsnNo: "44020000001100187221",
  9208. Info: "2207",
  9209. }
  9210. customData = append(customData, custom3)
  9211. custom4 := &CustomData{
  9212. MsgId: "H44022900158202103301730376224",
  9213. PsnNo: "44020000001101959155",
  9214. Info: "2207",
  9215. }
  9216. customData = append(customData, custom4)
  9217. custom5 := &CustomData{
  9218. MsgId: "H44022900158202103301748008725",
  9219. PsnNo: "44020000001104246641",
  9220. Info: "2207",
  9221. }
  9222. customData = append(customData, custom5)
  9223. custom6 := &CustomData{
  9224. MsgId: "H44022900158202103301718096755",
  9225. PsnNo: "44020000001102211860",
  9226. Info: "2207",
  9227. }
  9228. customData = append(customData, custom6)
  9229. custom7 := &CustomData{
  9230. MsgId: "H44022900158202103301736551640",
  9231. PsnNo: "44020000001102687718",
  9232. Info: "2207",
  9233. }
  9234. customData = append(customData, custom7)
  9235. custom8 := &CustomData{
  9236. MsgId: "H44022900158202103301743097676",
  9237. PsnNo: "44020000001102127785",
  9238. Info: "2207",
  9239. }
  9240. customData = append(customData, custom8)
  9241. custom9 := &CustomData{
  9242. MsgId: "H44022900158202103301712304203",
  9243. PsnNo: "44020000001101518097",
  9244. Info: "2207",
  9245. }
  9246. customData = append(customData, custom9)
  9247. custom10 := &CustomData{
  9248. MsgId: "H44022900158202103301738448785",
  9249. PsnNo: "44020000001100500813",
  9250. Info: "2207",
  9251. }
  9252. customData = append(customData, custom10)
  9253. custom11 := &CustomData{
  9254. MsgId: "H44022900158202103301732455843",
  9255. PsnNo: "44020000001102690557",
  9256. Info: "2207",
  9257. }
  9258. customData = append(customData, custom11)
  9259. custom12 := &CustomData{
  9260. MsgId: "H44022900158202103301745421708",
  9261. PsnNo: "44020000001102211928",
  9262. Info: "2207",
  9263. }
  9264. customData = append(customData, custom12)
  9265. custom1212 := &CustomData{
  9266. MsgId: "H440229001582021033017351627",
  9267. PsnNo: "44020000001102481733",
  9268. Info: "2207",
  9269. }
  9270. customData = append(customData, custom1212)
  9271. custom13 := &CustomData{
  9272. MsgId: "H44022900158202103301740327951",
  9273. PsnNo: "44020000001103174866",
  9274. Info: "2207",
  9275. }
  9276. customData = append(customData, custom13)
  9277. custom14 := &CustomData{
  9278. MsgId: "H4402290015820210330174922668",
  9279. PsnNo: "44020000001102927272",
  9280. Info: "2207",
  9281. }
  9282. customData = append(customData, custom14)
  9283. custom15 := &CustomData{
  9284. MsgId: "H44022900158202103301752362273",
  9285. PsnNo: "44020000001102942890",
  9286. Info: "2207",
  9287. }
  9288. customData = append(customData, custom15)
  9289. custom16 := &CustomData{
  9290. MsgId: "H44022900158202103301751082917",
  9291. PsnNo: "44020000001101662162",
  9292. Info: "2207",
  9293. }
  9294. customData = append(customData, custom16)
  9295. custom17 := &CustomData{
  9296. MsgId: "H44022900158202103301754147728",
  9297. PsnNo: "44020000000229014511",
  9298. Info: "2207",
  9299. }
  9300. customData = append(customData, custom17)
  9301. adminUser := c.GetAdminUserInfo()
  9302. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9303. for _, item := range customData {
  9304. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9305. fmt.Println(result)
  9306. }
  9307. }
  9308. func (c *HisApiController) GetAllopatry() {
  9309. year := c.GetString("year")
  9310. month := c.GetString("month")
  9311. admin_user_id, _ := c.GetInt64("admin_user_id")
  9312. adminUser := c.GetAdminUserInfo()
  9313. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9314. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9315. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9316. var dat map[string]interface{}
  9317. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9318. fmt.Println(dat)
  9319. } else {
  9320. fmt.Println(err)
  9321. }
  9322. userJSONBytes, _ := json.Marshal(dat)
  9323. var res models.Result9001
  9324. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9325. utils.ErrorLog("解析失败:%v", err)
  9326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9327. return
  9328. }
  9329. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9330. var dat2 map[string]interface{}
  9331. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9332. fmt.Println(dat)
  9333. } else {
  9334. fmt.Println(err)
  9335. }
  9336. userJSONBytes2, _ := json.Marshal(dat2)
  9337. var res2 models.Result3260
  9338. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9339. utils.ErrorLog("解析失败:%v", err)
  9340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9341. return
  9342. }
  9343. if res2.Infcode == 0 {
  9344. c.ServeSuccessJSON(map[string]interface{}{
  9345. "list": res2.Output.Data,
  9346. })
  9347. return
  9348. } else {
  9349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9350. return
  9351. }
  9352. }
  9353. func (c *HisApiController) ComfirmAllopatry() {
  9354. year := c.GetString("year")
  9355. month := c.GetString("month")
  9356. admin_user_id, _ := c.GetInt64("admin_user_id")
  9357. adminUser := c.GetAdminUserInfo()
  9358. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9359. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9360. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9361. var dat map[string]interface{}
  9362. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9363. fmt.Println(dat)
  9364. } else {
  9365. fmt.Println(err)
  9366. }
  9367. userJSONBytes, _ := json.Marshal(dat)
  9368. var res models.Result9001
  9369. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9370. utils.ErrorLog("解析失败:%v", err)
  9371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9372. return
  9373. }
  9374. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9375. var dat2 map[string]interface{}
  9376. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9377. fmt.Println(dat)
  9378. } else {
  9379. fmt.Println(err)
  9380. }
  9381. userJSONBytes2, _ := json.Marshal(dat2)
  9382. var res2 models.Result3260
  9383. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9384. utils.ErrorLog("解析失败:%v", err)
  9385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9386. return
  9387. }
  9388. if res2.Infcode == 0 {
  9389. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  9390. var dat map[string]interface{}
  9391. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9392. fmt.Println(dat)
  9393. } else {
  9394. fmt.Println(err)
  9395. }
  9396. userJSONBytes, _ := json.Marshal(dat)
  9397. var res3 models.Result3261
  9398. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  9399. utils.ErrorLog("解析失败:%v", err)
  9400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9401. return
  9402. }
  9403. if res3.Infcode == 0 {
  9404. record := &models.HisYidiClearRecord{
  9405. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9406. Ctime: time.Now().Unix(),
  9407. Mtime: time.Now().Unix(),
  9408. Status: 1,
  9409. MsgId: msgId,
  9410. }
  9411. service.SaveClearRecord(record)
  9412. c.ServeSuccessJSON(map[string]interface{}{
  9413. "msg": "提取成功",
  9414. })
  9415. }
  9416. }
  9417. }
  9418. func (c *HisApiController) RefundAllopatry() {
  9419. year := c.GetString("year")
  9420. month := c.GetString("month")
  9421. id, _ := c.GetInt64("id")
  9422. admin_user_id, _ := c.GetInt64("admin_user_id")
  9423. adminUser := c.GetAdminUserInfo()
  9424. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9425. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9426. record, _ := service.GetClearRecordById(id)
  9427. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  9428. var dat map[string]interface{}
  9429. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9430. fmt.Println(dat)
  9431. } else {
  9432. fmt.Println(err)
  9433. }
  9434. userJSONBytes, _ := json.Marshal(dat)
  9435. var empty ResultFourteen
  9436. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  9437. utils.ErrorLog("解析失败:%v", err)
  9438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9439. return
  9440. }
  9441. if empty.Infcode == 0 {
  9442. c.ServeSuccessJSON(map[string]interface{}{
  9443. "msg": "撤销成功",
  9444. })
  9445. return
  9446. }
  9447. }
  9448. func (c *HisApiController) ReversalOtherData() {
  9449. var customData []*CustomData
  9450. custom := &CustomData{
  9451. MsgId: "H44022900158202103301714472004",
  9452. PsnNo: "44020000001101329945",
  9453. Info: "2208",
  9454. }
  9455. customData = append(customData, custom)
  9456. custom1 := &CustomData{
  9457. MsgId: "H4402290015820210330172057803",
  9458. PsnNo: "44020000001101161813",
  9459. Info: "2208",
  9460. }
  9461. customData = append(customData, custom1)
  9462. custom2 := &CustomData{
  9463. MsgId: "H44022900158202103301705198813",
  9464. PsnNo: "44190000133097375417",
  9465. Info: "2208",
  9466. }
  9467. customData = append(customData, custom2)
  9468. custom3 := &CustomData{
  9469. MsgId: "H44022900158202103301715524756",
  9470. PsnNo: "44020000001100187221",
  9471. Info: "2208",
  9472. }
  9473. customData = append(customData, custom3)
  9474. custom4 := &CustomData{
  9475. MsgId: "H44022900158202103301730376224",
  9476. PsnNo: "44020000001101959155",
  9477. Info: "2208",
  9478. }
  9479. customData = append(customData, custom4)
  9480. custom5 := &CustomData{
  9481. MsgId: "H44022900158202103301748008725",
  9482. PsnNo: "44020000001104246641",
  9483. Info: "2208",
  9484. }
  9485. customData = append(customData, custom5)
  9486. custom6 := &CustomData{
  9487. MsgId: "H44022900158202103301718096755",
  9488. PsnNo: "44020000001102211860",
  9489. Info: "2208",
  9490. }
  9491. customData = append(customData, custom6)
  9492. custom7 := &CustomData{
  9493. MsgId: "H44022900158202103301736551640",
  9494. PsnNo: "44020000001102687718",
  9495. Info: "2208",
  9496. }
  9497. customData = append(customData, custom7)
  9498. custom8 := &CustomData{
  9499. MsgId: "H44022900158202103301743097676",
  9500. PsnNo: "44020000001102127785",
  9501. Info: "2208",
  9502. }
  9503. customData = append(customData, custom8)
  9504. custom9 := &CustomData{
  9505. MsgId: "H44022900158202103301712304203",
  9506. PsnNo: "44020000001101518097",
  9507. Info: "2208",
  9508. }
  9509. customData = append(customData, custom9)
  9510. custom10 := &CustomData{
  9511. MsgId: "H44022900158202103301738448785",
  9512. PsnNo: "44020000001100500813",
  9513. Info: "2208",
  9514. }
  9515. customData = append(customData, custom10)
  9516. custom11 := &CustomData{
  9517. MsgId: "H44022900158202103301732455843",
  9518. PsnNo: "44020000001102690557",
  9519. Info: "2208",
  9520. }
  9521. customData = append(customData, custom11)
  9522. custom12 := &CustomData{
  9523. MsgId: "H44022900158202103301745421708",
  9524. PsnNo: "44020000001102211928",
  9525. Info: "2208",
  9526. }
  9527. customData = append(customData, custom12)
  9528. custom1212 := &CustomData{
  9529. MsgId: "H440229001582021033017351627",
  9530. PsnNo: "44020000001102481733",
  9531. Info: "2208",
  9532. }
  9533. customData = append(customData, custom1212)
  9534. custom13 := &CustomData{
  9535. MsgId: "H44022900158202103301740327951",
  9536. PsnNo: "44020000001103174866",
  9537. Info: "2208",
  9538. }
  9539. customData = append(customData, custom13)
  9540. custom14 := &CustomData{
  9541. MsgId: "H4402290015820210330174922668",
  9542. PsnNo: "44020000001102927272",
  9543. Info: "2208",
  9544. }
  9545. customData = append(customData, custom14)
  9546. custom15 := &CustomData{
  9547. MsgId: "H44022900158202103301752362273",
  9548. PsnNo: "44020000001102942890",
  9549. Info: "2208",
  9550. }
  9551. customData = append(customData, custom15)
  9552. custom16 := &CustomData{
  9553. MsgId: "H44022900158202103301751082917",
  9554. PsnNo: "44020000001101662162",
  9555. Info: "2208",
  9556. }
  9557. customData = append(customData, custom16)
  9558. custom17 := &CustomData{
  9559. MsgId: "H44022900158202103301754147728",
  9560. PsnNo: "44020000000229014511",
  9561. Info: "2208",
  9562. }
  9563. customData = append(customData, custom17)
  9564. adminUser := c.GetAdminUserInfo()
  9565. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9566. for _, item := range customData {
  9567. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9568. fmt.Println(result)
  9569. }
  9570. }
  9571. func PathExists(path string) (bool, error) {
  9572. _, err := os.Stat(path)
  9573. if err == nil {
  9574. return true, nil
  9575. }
  9576. if os.IsNotExist(err) {
  9577. return false, nil
  9578. }
  9579. return false, err
  9580. }
  9581. //创建文件夹
  9582. func Mkdir(dir string) {
  9583. // 创建文件夹
  9584. exist, err := PathExists(dir)
  9585. if err != nil {
  9586. fmt.Println(err.Error())
  9587. } else {
  9588. if exist {
  9589. fmt.Println(dir + "文件夹已存在!")
  9590. } else {
  9591. // 文件夹名称,权限
  9592. err := os.Mkdir(dir, os.ModePerm)
  9593. if err != nil {
  9594. fmt.Println(dir+"文件夹创建失败:", err.Error())
  9595. } else {
  9596. fmt.Println(dir + "文件夹创建成功!")
  9597. }
  9598. }
  9599. }
  9600. }
  9601. //压缩文件
  9602. func Zip(srcFile string, destZip string) error {
  9603. zipfile, err := os.Create(destZip)
  9604. if err != nil {
  9605. return err
  9606. }
  9607. defer zipfile.Close()
  9608. archive := zip.NewWriter(zipfile)
  9609. defer archive.Close()
  9610. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  9611. if err != nil {
  9612. return err
  9613. }
  9614. header, err := zip.FileInfoHeader(info)
  9615. if err != nil {
  9616. return err
  9617. }
  9618. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  9619. // header.Name = path
  9620. if info.IsDir() {
  9621. header.Name += "/"
  9622. } else {
  9623. header.Method = zip.Deflate
  9624. }
  9625. writer, err := archive.CreateHeader(header)
  9626. if err != nil {
  9627. return err
  9628. }
  9629. if !info.IsDir() {
  9630. file, err := os.Open(path)
  9631. if err != nil {
  9632. return err
  9633. }
  9634. defer file.Close()
  9635. _, err = io.Copy(writer, file)
  9636. }
  9637. return err
  9638. })
  9639. return err
  9640. }
  9641. func ReadFile(filePath string) []byte {
  9642. f, err := os.Open(filePath)
  9643. if err != nil {
  9644. fmt.Println("read file fail", err)
  9645. return nil
  9646. }
  9647. defer f.Close()
  9648. fd, err := ioutil.ReadAll(f)
  9649. if err != nil {
  9650. fmt.Println("read to fd fail", err)
  9651. return nil
  9652. }
  9653. return fd
  9654. }
  9655. func saveLog(result string, request string, infno string, desc string) {
  9656. org_id, _ := beego.AppConfig.Int64("org_id")
  9657. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  9658. dir := miConfig.OrgName + "日志"
  9659. utils.Mkdir(dir)
  9660. month := time.Unix(1557042972, 0).Format("1")
  9661. year := time.Now().Format("2006")
  9662. month = time.Now().Format("01")
  9663. day := time.Now().Format("02")
  9664. hour := time.Now().Format("15")
  9665. min := time.Now().Format("04")
  9666. sec := time.Now().Format("05")
  9667. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  9668. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  9669. file_name := file + ".txt"
  9670. file_path := miConfig.OrgName + "日志" + "/" + file_name
  9671. exist, _ := utils.PathExists(file_path)
  9672. if exist { //存在
  9673. fmt.Println("存在")
  9674. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  9675. if err != nil {
  9676. fmt.Println("read fail")
  9677. }
  9678. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  9679. n, _ := f.Seek(0, 2)
  9680. _, err = f.WriteAt([]byte(content), n)
  9681. } else { //不存在
  9682. fmt.Println("文件不存在,创建文件")
  9683. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  9684. defer f.Close()
  9685. if err != nil {
  9686. } else {
  9687. _, err = f.Write([]byte("记录日志"))
  9688. }
  9689. }
  9690. }
  9691. type Charset string
  9692. const (
  9693. UTF8 = Charset("UTF-8")
  9694. GB18030 = Charset("GB18030")
  9695. )
  9696. func ConvertToString(src string, srcCode string, tagCode string) string {
  9697. srcCoder := mahonia.NewDecoder(srcCode)
  9698. srcResult := srcCoder.ConvertString(src)
  9699. tagCoder := mahonia.NewDecoder(tagCode)
  9700. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  9701. result := string(cdata)
  9702. return result
  9703. }