his_api_controller.go 515KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187
  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. "regexp"
  23. "strconv"
  24. "strings"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. type HisApiController struct {
  30. controllers.BaseAuthAPIController
  31. }
  32. func HisManagerApiRegistRouters() {
  33. //挂号
  34. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  35. //上传就诊信息-上传明细-结算
  36. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  37. //查询
  38. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  39. //对总账
  40. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  41. //对明细
  42. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  43. //退费,退明细
  44. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  45. //退号
  46. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  47. //退明细
  48. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  49. //上传就诊信息-上传明细-预结算
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  52. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  53. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  54. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  55. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  56. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  57. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  58. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  59. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  60. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  61. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  62. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  63. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  64. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  67. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  68. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  69. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  70. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  78. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  79. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  80. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  81. }
  82. type Result3101 struct {
  83. Infcode string `json:"infcode"`
  84. InfRefmsgid string `json:"inf_refmsgid"`
  85. RefmsgTime string `json:"refmsg_time"`
  86. RespondTime string `json:"respond_time"`
  87. Enctype string `json:"enctype"`
  88. Signtype string `json:"signtype"`
  89. ErrMsg string `json:"err_msg"`
  90. Output struct {
  91. Result []struct {
  92. JudgeResultDetailDtos []struct {
  93. VolaItemType string `json:"vola_item_type"`
  94. MdtrtID string `json:"mdtrt_id"`
  95. JrdID string `json:"jrd_id"`
  96. PatnID string `json:"patn_id"`
  97. RxID string `json:"rx_id"`
  98. VolaAmt interface{} `json:"vola_amt"`
  99. } `json:"judge_result_detail_dtos"`
  100. RuleID string `json:"rule_id"`
  101. VolaEvid string `json:"vola_evid"`
  102. MdtrtID string `json:"mdtrt_id"`
  103. RuleName string `json:"rule_name"`
  104. VolaAmtStas string `json:"vola_amt_stas"`
  105. JrID string `json:"jr_id"`
  106. PatnID string `json:"patn_id"`
  107. SevDeg string `json:"sev_deg"`
  108. VolaAmt float64 `json:"vola_amt"`
  109. VolaBhvrType string `json:"vola_bhvr_type"`
  110. VolaCont string `json:"vola_cont"`
  111. } `json:"result"`
  112. } `json:"output"`
  113. }
  114. func (c *HisApiController) ReadEleToken() {
  115. admin_user_id, _ := c.GetInt64("admin_user_id")
  116. his_patient_id, _ := c.GetInt64("his_patient_id")
  117. adminUser := c.GetAdminUserInfo()
  118. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  119. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  120. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  121. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  122. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  123. if len(tokens) > 0 {
  124. c.ServeSuccessJSON(map[string]interface{}{
  125. "msg": "读取成功",
  126. })
  127. } else {
  128. c.ServeSuccessJSON(map[string]interface{}{
  129. "failed_code": -10,
  130. "msg": "读取失败",
  131. })
  132. }
  133. } else if miConfig.MdtrtareaAdmvs == "440305" {
  134. if initFlag == 0 {
  135. c.TestGetBasBaseInit()
  136. }
  137. token := c.GetEleBaseInfo()
  138. token = Remove0000(token)
  139. if len(token) > 0 {
  140. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token)
  141. saveLog(result2, requestLog2, "1101", "获取人员信息")
  142. var res ResultTwo
  143. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  144. utils.ErrorLog("解析失败:%v", err)
  145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  146. return
  147. }
  148. if res.Infcode == 0 {
  149. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  150. if err == gorm.ErrRecordNotFound {
  151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  152. return
  153. } else if err != nil {
  154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  155. return
  156. } else {
  157. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  158. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  159. infoStr := string(Iinfos)
  160. idetinfoStr := string(Idetinfos)
  161. psn := &models.HisPsn{
  162. PsnNo: res.Output.Baseinfo.PsnNo,
  163. Age: res.Output.Baseinfo.Age,
  164. PatientId: patient.ID,
  165. Certno: res.Output.Baseinfo.Certno,
  166. Brdy: res.Output.Baseinfo.Brdy,
  167. Gend: res.Output.Baseinfo.Gend,
  168. Naty: res.Output.Baseinfo.Naty,
  169. PsnCertType: res.Output.Baseinfo.PsnCertType,
  170. PsnName: res.Output.Baseinfo.PsnName,
  171. Idetinfo: idetinfoStr,
  172. Insuinfo: infoStr,
  173. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  174. CardInfo: "",
  175. VerifyNumber: token,
  176. }
  177. service.CreateHisPsn(psn)
  178. c.ServeSuccessJSON(map[string]interface{}{
  179. "msg": "读取成功",
  180. })
  181. }
  182. } else {
  183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  184. return
  185. }
  186. } else {
  187. c.ServeSuccessJSON(map[string]interface{}{
  188. "failed_code": -10,
  189. "msg": "读取失败",
  190. })
  191. }
  192. } else if miConfig.MdtrtareaAdmvs == "350500" {
  193. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  194. if len(errMsg) == 0 {
  195. type ELeData struct {
  196. Data struct {
  197. IdNo string `json:"idNo"`
  198. IdType string `json:"idType"`
  199. UserName string `json:"userName"`
  200. EcToken string `json:"ecToken"`
  201. InsuOrg string `json:"insuOrg"`
  202. Gender string `json:"gender"`
  203. Birthday string `json:"birthday"`
  204. Nationality string `json:"nationality"`
  205. Email string `json:"email"`
  206. Extra string `json:"extra"`
  207. } `json:"data"`
  208. Code int `json:"code"`
  209. Message string `json:"message"`
  210. }
  211. var ele ELeData
  212. err := json.Unmarshal([]byte(outPutInfo), &ele)
  213. if err != nil {
  214. utils.ErrorLog("解析失败:%v", err)
  215. }
  216. token := ele.Data.EcToken
  217. if len(token) > 0 {
  218. psn := &models.HisPsn{
  219. PsnNo: his.PsnNo,
  220. Age: 0,
  221. PatientId: his.PatientId,
  222. Certno: his.Certno,
  223. Brdy: his.Brdy,
  224. Gend: his.Gend,
  225. Naty: his.Naty,
  226. PsnCertType: his.PsnCertType,
  227. PsnName: his.PsnName,
  228. Idetinfo: his.Idetinfo,
  229. Insuinfo: his.Iinfo,
  230. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  231. CardInfo: outPutInfo,
  232. VerifyNumber: token,
  233. }
  234. service.CreateHisPsn(psn)
  235. }
  236. if len(token) > 0 {
  237. c.ServeSuccessJSON(map[string]interface{}{
  238. "msg": "读取成功",
  239. })
  240. } else {
  241. c.ServeSuccessJSON(map[string]interface{}{
  242. "failed_code": -10,
  243. "msg": "读取失败",
  244. })
  245. }
  246. }
  247. }
  248. }
  249. func (c *HisApiController) Get9001() {
  250. adminUser := c.GetAdminUserInfo()
  251. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  252. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  253. if miConfig.MdtrtareaAdmvs == "350500" {
  254. service.GetFjAuthorizationInfo(miConfig.Code)
  255. } else {
  256. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  257. var dat map[string]interface{}
  258. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  259. fmt.Println(dat)
  260. } else {
  261. fmt.Println(err)
  262. }
  263. userJSONBytes, _ := json.Marshal(dat)
  264. var res models.Result9001
  265. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  266. utils.ErrorLog("解析失败:%v", err)
  267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  268. return
  269. }
  270. }
  271. }
  272. func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res2 Result3101) {
  273. var res Result3101
  274. adminUser := c.GetAdminUserInfo()
  275. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  276. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  277. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  278. //record_time := c.GetString("record_time")
  279. //trig_scen := c.GetString("trig_scen")
  280. timeLayout := "2006-01-02"
  281. loc, _ := time.LoadLocation("Local")
  282. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  283. if err != nil {
  284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  285. return res
  286. }
  287. recordDateTime := theTime.Unix()
  288. var patientPrescription models.HisPrescriptionInfo
  289. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  290. //if patientPrescription.ID == 0 {
  291. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  292. //}
  293. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  294. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  295. //
  296. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  297. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  298. var pp models.PublicParams
  299. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  300. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  301. pp.FixmedinsName = miConfig.OrgName
  302. pp.FixmedinsCode = miConfig.Code
  303. pp.RequestUrl = miConfig.Url
  304. pp.Cainfo = miConfig.Cainfo
  305. pp.SecretKey = miConfig.SecretKey
  306. pp.AccessKey = miConfig.AccessKey
  307. pp.OpterName = roles.UserName
  308. var config []*models.HisXtDiagnoseConfig
  309. for _, item := range diagnosis_ids {
  310. id, _ := strconv.ParseInt(item, 10, 64)
  311. diagnosisConfig, _ := service.FindDiagnoseById(id)
  312. config = append(config, &diagnosisConfig)
  313. }
  314. var pd models.PatientDtos
  315. pd.PatnID = his.PsnNo
  316. pd.PatnName = his.Name
  317. pd.Gend = his.Gend
  318. pd.Brdy = his.Brdy
  319. pd.Poolarea = miConfig.MdtrtareaAdmvs
  320. pd.CurrMdtrtID = his.Number
  321. var fed models.FsiEncounterDtos
  322. fed.MdtrtID = his.Number
  323. fed.MedinsID = miConfig.Code
  324. fed.MedinsName = miConfig.OrgName
  325. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  326. fed.MedMdtrtType = "1"
  327. fed.MedinsType = "1"
  328. fed.MedinsLv = "11"
  329. tm := time.Unix(his.RecordDate, 0)
  330. s_tm := tm.Format("2006-01-02 15:04:05")
  331. fed.AdmDate = s_tm
  332. fed.DscgDate = s_tm
  333. fed.DscgMainDiseCodg = config[0].CountryCode
  334. fed.DscgMainDiseName = config[0].CountryContentName
  335. //诊断信息
  336. var fdds []*models.FsiDiagnoseDtos
  337. for index, item := range config {
  338. if index == 0 {
  339. var fdd models.FsiDiagnoseDtos
  340. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  341. fdd.InoutDiseType = "1"
  342. fdd.MaindiseFlag = "1"
  343. fdd.DiseDate = s_tm
  344. fdd.DiasSrtNo = "1"
  345. fdd.DiseName = item.CountryContentName
  346. fdd.DiseCodg = item.CountryCode
  347. fdds = append(fdds, &fdd)
  348. } else {
  349. var fdd models.FsiDiagnoseDtos
  350. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  351. fdd.InoutDiseType = "1"
  352. fdd.MaindiseFlag = "1"
  353. fdd.DiseDate = s_tm
  354. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  355. fdd.DiseName = item.CountryContentName
  356. fdd.DiseCodg = item.CountryCode
  357. fdds = append(fdds, &fdd)
  358. }
  359. }
  360. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  361. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  362. fed.AdmDeptName = department.Name
  363. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  364. fed.DscgDeptName = department.Name
  365. fed.MedMdtrtType = "1"
  366. fed.MedType = "11"
  367. //if his.Insutype == "390" {
  368. // fed.MedType = "1402"
  369. //} else {
  370. // fed.MedType = "9933"
  371. //}
  372. var orders []*models.FsiOrderDtos
  373. if trig_scen == "2" {
  374. //处方医嘱信息
  375. for _, item := range prescriptions {
  376. for _, subItem := range item.HisDoctorAdviceInfo {
  377. var order models.FsiOrderDtos
  378. order.RxID = strconv.FormatInt(item.ID, 10)
  379. order.Rxno = strconv.FormatInt(item.ID, 10)
  380. order.LongDrordFlag = "0"
  381. order.HilistType = "1"
  382. order.ChrgType = "1"
  383. order.DrordBhvr = "-"
  384. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  385. order.HosplistName = subItem.BaseDrugLib.DrugName
  386. order.HilistLv = "1"
  387. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  388. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  389. order.HosplistName = subItem.BaseDrugLib.DrugName
  390. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  391. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  392. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  393. order.OwnpayAmt = ""
  394. order.SelfpayAmt = ""
  395. order.Spec = ""
  396. order.SpecUnt = ""
  397. order.DrordBegnDate = s_tm
  398. order.DrordStopDate = ""
  399. order.DrordDrCodg = "1"
  400. order.DrordDeptName = department.Name
  401. order.DrordDrCodg = "1"
  402. order.DrordDrName = doctor_info.UserName
  403. order.DrordDrProfttl = ""
  404. order.CurrDrordFlag = "1"
  405. orders = append(orders, &order)
  406. }
  407. for _, subItem := range item.HisPrescriptionProject {
  408. if subItem.Type == 2 {
  409. var order models.FsiOrderDtos
  410. order.RxID = strconv.FormatInt(item.ID, 10)
  411. order.Rxno = strconv.FormatInt(item.ID, 10)
  412. order.LongDrordFlag = "0"
  413. order.HilistType = "1"
  414. order.ChrgType = "1"
  415. order.DrordBhvr = "-"
  416. order.HilistCode = subItem.HisProject.MedicalCode
  417. order.HosplistName = subItem.HisProject.ProjectName
  418. order.HilistLv = "1"
  419. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  420. order.HosplistCode = subItem.HisProject.MedicalCode
  421. order.HosplistName = subItem.HisProject.ProjectName
  422. order.Cnt = subItem.Count
  423. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  424. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  425. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  426. order.OwnpayAmt = ""
  427. order.SelfpayAmt = ""
  428. order.Spec = ""
  429. order.SpecUnt = ""
  430. order.DrordBegnDate = s_tm
  431. order.DrordStopDate = ""
  432. order.DrordDrCodg = "1"
  433. order.DrordDeptName = department.Name
  434. order.DrordDrCodg = "1"
  435. order.DrordDrName = doctor_info.UserName
  436. order.DrordDrProfttl = ""
  437. order.CurrDrordFlag = "1"
  438. orders = append(orders, &order)
  439. }
  440. if subItem.Type == 3 {
  441. var order models.FsiOrderDtos
  442. order.RxID = strconv.FormatInt(item.ID, 10)
  443. order.Rxno = strconv.FormatInt(item.ID, 10)
  444. order.LongDrordFlag = "0"
  445. order.HilistType = "1"
  446. order.ChrgType = "1"
  447. order.DrordBhvr = "-"
  448. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  449. order.HosplistName = subItem.GoodInfo.GoodName
  450. order.HilistLv = "1"
  451. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  452. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  453. order.HosplistName = subItem.GoodInfo.GoodName
  454. order.Cnt = subItem.Count
  455. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  456. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  457. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  458. order.OwnpayAmt = ""
  459. order.SelfpayAmt = ""
  460. order.Spec = ""
  461. order.SpecUnt = ""
  462. order.DrordBegnDate = s_tm
  463. order.DrordStopDate = ""
  464. order.DrordDrCodg = "1"
  465. order.DrordDeptName = department.Name
  466. order.DrordDrCodg = "1"
  467. order.DrordDrName = doctor_info.UserName
  468. order.DrordDrProfttl = ""
  469. order.CurrDrordFlag = "1"
  470. orders = append(orders, &order)
  471. }
  472. }
  473. }
  474. //处方医嘱信息
  475. }
  476. fed.MatnStas = "0"
  477. fed.MedfeeSumamt = "0"
  478. fed.OwnpayAmt = "0"
  479. fed.SelfpayAmt = "0"
  480. fed.AcctPayamt = "0"
  481. fed.MaAmt = "0"
  482. fed.HifpPayamt = "0"
  483. fed.SetlTotlnum = "1"
  484. fed.Insutype = his.Insutype
  485. fed.ReimFlag = "0"
  486. fed.OutSetlFlag = "0"
  487. var fopd []*models.FsiOperationDtosData
  488. data := make(map[string]interface{})
  489. data["fed"] = fed
  490. data["fdd"] = fdds
  491. data["fod"] = orders
  492. data["pd"] = pd
  493. data["pp"] = pp
  494. data["fopd"] = fopd
  495. data["trig_scen"] = trig_scen
  496. fmt.Println(data)
  497. fmt.Println(fed)
  498. fmt.Println(fdds)
  499. fmt.Println(orders)
  500. fmt.Println(pd)
  501. fmt.Println(pp)
  502. fmt.Println(fopd)
  503. client := &http.Client{}
  504. bytesData, _ := json.Marshal(data)
  505. var req *http.Request
  506. if miConfig.MdtrtareaAdmvs == "320921" {
  507. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  508. } else {
  509. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  510. }
  511. resp, _ := client.Do(req)
  512. defer resp.Body.Close()
  513. body, ioErr := ioutil.ReadAll(resp.Body)
  514. if ioErr != nil {
  515. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  517. return res
  518. }
  519. var respJSON map[string]interface{}
  520. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  521. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  523. return res
  524. }
  525. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  526. fmt.Println(respJSON)
  527. result, _ := json.Marshal(respJSON)
  528. fmt.Println(result)
  529. if err := json.Unmarshal([]byte(result), &res); err != nil {
  530. utils.ErrorLog("解析失败:%v", err)
  531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  532. return res
  533. }
  534. return res
  535. }
  536. func Check3101(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
  537. adminUser := c.GetAdminUserInfo()
  538. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  539. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  540. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  541. //record_time := c.GetString("record_time")
  542. //trig_scen := c.GetString("trig_scen")
  543. timeLayout := "2006-01-02"
  544. loc, _ := time.LoadLocation("Local")
  545. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  546. if err != nil {
  547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  548. return res
  549. }
  550. recordDateTime := theTime.Unix()
  551. var patientPrescription models.HisPrescriptionInfo
  552. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  553. if patientPrescription.ID == 0 {
  554. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  555. }
  556. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  557. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  558. //
  559. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  560. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  561. var pp models.PublicParams
  562. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  563. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  564. pp.FixmedinsName = miConfig.OrgName
  565. pp.FixmedinsCode = miConfig.Code
  566. pp.RequestUrl = miConfig.Url
  567. pp.Cainfo = miConfig.Cainfo
  568. pp.SecretKey = miConfig.SecretKey
  569. pp.AccessKey = miConfig.AccessKey
  570. pp.OpterName = roles.UserName
  571. var config []*models.HisXtDiagnoseConfig
  572. for _, item := range diagnosis_ids {
  573. id, _ := strconv.ParseInt(item, 10, 64)
  574. diagnosisConfig, _ := service.FindDiagnoseById(id)
  575. config = append(config, &diagnosisConfig)
  576. }
  577. var pd models.PatientDtos
  578. pd.PatnID = his.PsnNo
  579. pd.PatnName = his.Name
  580. pd.Gend = his.Gend
  581. pd.Brdy = his.Brdy
  582. pd.Poolarea = his.InsuplcAdmdvs
  583. pd.CurrMdtrtID = his.Number
  584. var fed models.FsiEncounterDtos
  585. fed.MdtrtID = his.Number
  586. fed.MedinsID = miConfig.Code
  587. fed.MedinsName = miConfig.OrgName
  588. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  589. fed.MedMdtrtType = "1"
  590. fed.MedinsType = "1"
  591. fed.MedinsLv = "11"
  592. tm := time.Unix(his.RecordDate, 0)
  593. s_tm := tm.Format("2006-01-02 15:04:05")
  594. fed.AdmDate = s_tm
  595. fed.DscgDate = s_tm
  596. fed.DscgMainDiseCodg = config[0].CountryCode
  597. fed.DscgMainDiseName = config[0].CountryContentName
  598. //诊断信息
  599. var fdds []*models.FsiDiagnoseDtos
  600. for index, item := range config {
  601. if index == 0 {
  602. var fdd models.FsiDiagnoseDtos
  603. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  604. fdd.InoutDiseType = "1"
  605. fdd.MaindiseFlag = "1"
  606. fdd.DiseDate = s_tm
  607. fdd.DiasSrtNo = "1"
  608. fdd.DiseName = item.CountryContentName
  609. fdd.DiseCodg = item.CountryCode
  610. fdds = append(fdds, &fdd)
  611. } else {
  612. var fdd models.FsiDiagnoseDtos
  613. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  614. fdd.InoutDiseType = "1"
  615. fdd.MaindiseFlag = "1"
  616. fdd.DiseDate = s_tm
  617. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  618. fdd.DiseName = item.CountryContentName
  619. fdd.DiseCodg = item.CountryCode
  620. fdds = append(fdds, &fdd)
  621. }
  622. }
  623. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  624. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  625. fed.AdmDeptName = department.Name
  626. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  627. fed.DscgDeptName = department.Name
  628. fed.MedMdtrtType = "1"
  629. fed.MedType = "11"
  630. //if his.Insutype == "390" {
  631. // fed.MedType = "1402"
  632. //} else {
  633. // fed.MedType = "9933"
  634. //}
  635. var orders []*models.FsiOrderDtos
  636. if trig_scen == "2" {
  637. //处方医嘱信息
  638. for _, item := range prescriptions {
  639. for _, subItem := range item.HisDoctorAdviceInfo {
  640. var order models.FsiOrderDtos
  641. order.RxID = strconv.FormatInt(item.ID, 10)
  642. order.Rxno = strconv.FormatInt(item.ID, 10)
  643. order.LongDrordFlag = "0"
  644. order.HilistType = "1"
  645. order.ChrgType = "1"
  646. order.DrordBhvr = "-"
  647. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  648. order.HosplistName = subItem.BaseDrugLib.DrugName
  649. order.HilistLv = "1"
  650. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  651. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  652. order.HosplistName = subItem.BaseDrugLib.DrugName
  653. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  654. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  655. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  656. order.OwnpayAmt = ""
  657. order.SelfpayAmt = ""
  658. order.Spec = ""
  659. order.SpecUnt = ""
  660. order.DrordBegnDate = s_tm
  661. order.DrordStopDate = ""
  662. order.DrordDrCodg = "1"
  663. order.DrordDeptName = department.Name
  664. order.DrordDrCodg = "1"
  665. order.DrordDrName = doctor_info.UserName
  666. order.DrordDrProfttl = ""
  667. order.CurrDrordFlag = "1"
  668. orders = append(orders, &order)
  669. }
  670. for _, subItem := range item.HisPrescriptionProject {
  671. if subItem.Type == 2 {
  672. var order models.FsiOrderDtos
  673. order.RxID = strconv.FormatInt(item.ID, 10)
  674. order.Rxno = strconv.FormatInt(item.ID, 10)
  675. order.LongDrordFlag = "0"
  676. order.HilistType = "1"
  677. order.ChrgType = "1"
  678. order.DrordBhvr = "-"
  679. order.HilistCode = subItem.HisProject.MedicalCode
  680. order.HosplistName = subItem.HisProject.ProjectName
  681. order.HilistLv = "1"
  682. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  683. order.HosplistCode = subItem.HisProject.MedicalCode
  684. order.HosplistName = subItem.HisProject.ProjectName
  685. order.Cnt = subItem.Count
  686. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  687. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  688. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  689. order.OwnpayAmt = ""
  690. order.SelfpayAmt = ""
  691. order.Spec = ""
  692. order.SpecUnt = ""
  693. order.DrordBegnDate = s_tm
  694. order.DrordStopDate = ""
  695. order.DrordDrCodg = "1"
  696. order.DrordDeptName = department.Name
  697. order.DrordDrCodg = "1"
  698. order.DrordDrName = doctor_info.UserName
  699. order.DrordDrProfttl = ""
  700. order.CurrDrordFlag = "1"
  701. orders = append(orders, &order)
  702. }
  703. if subItem.Type == 3 {
  704. var order models.FsiOrderDtos
  705. order.RxID = strconv.FormatInt(item.ID, 10)
  706. order.Rxno = strconv.FormatInt(item.ID, 10)
  707. order.LongDrordFlag = "0"
  708. order.HilistType = "1"
  709. order.ChrgType = "1"
  710. order.DrordBhvr = "-"
  711. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  712. order.HosplistName = subItem.GoodInfo.GoodName
  713. order.HilistLv = "1"
  714. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  715. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  716. order.HosplistName = subItem.GoodInfo.GoodName
  717. order.Cnt = subItem.Count
  718. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  719. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  720. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  721. order.OwnpayAmt = ""
  722. order.SelfpayAmt = ""
  723. order.Spec = ""
  724. order.SpecUnt = ""
  725. order.DrordBegnDate = s_tm
  726. order.DrordStopDate = ""
  727. order.DrordDrCodg = "1"
  728. order.DrordDeptName = department.Name
  729. order.DrordDrCodg = "1"
  730. order.DrordDrName = doctor_info.UserName
  731. order.DrordDrProfttl = ""
  732. order.CurrDrordFlag = "1"
  733. orders = append(orders, &order)
  734. }
  735. }
  736. }
  737. //处方医嘱信息
  738. }
  739. fed.MatnStas = "0"
  740. fed.MedfeeSumamt = "0"
  741. fed.OwnpayAmt = "0"
  742. fed.SelfpayAmt = "0"
  743. fed.AcctPayamt = "0"
  744. fed.MaAmt = "0"
  745. fed.HifpPayamt = "0"
  746. fed.SetlTotlnum = "1"
  747. fed.Insutype = his.Insutype
  748. fed.ReimFlag = "0"
  749. fed.OutSetlFlag = "0"
  750. var fopd []*models.FsiOperationDtosData
  751. data := make(map[string]interface{})
  752. data["fed"] = fed
  753. data["fdd"] = fdds
  754. data["fod"] = orders
  755. data["pd"] = pd
  756. data["pp"] = pp
  757. data["fopd"] = fopd
  758. data["trig_scen"] = trig_scen
  759. fmt.Println(data)
  760. fmt.Println(fed)
  761. fmt.Println(fdds)
  762. fmt.Println(orders)
  763. fmt.Println(pd)
  764. fmt.Println(pp)
  765. fmt.Println(fopd)
  766. client := &http.Client{}
  767. bytesData, _ := json.Marshal(data)
  768. var req *http.Request
  769. if miConfig.MdtrtareaAdmvs == "320921" {
  770. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  771. } else {
  772. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  773. }
  774. resp, _ := client.Do(req)
  775. defer resp.Body.Close()
  776. body, ioErr := ioutil.ReadAll(resp.Body)
  777. if ioErr != nil {
  778. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  780. return res
  781. }
  782. var respJSON map[string]interface{}
  783. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  786. return res
  787. }
  788. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  789. result, _ := json.Marshal(respJSON)
  790. if err := json.Unmarshal([]byte(result), &res); err != nil {
  791. utils.ErrorLog("解析失败:%v", err)
  792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  793. return res
  794. }
  795. return res
  796. }
  797. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  798. ////patient_id, _ := c.GetInt64("patient_id")
  799. //order_id, _ := c.GetInt64("order_id")
  800. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  801. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  802. //trig_scen := c.GetString("trig_scen")
  803. adminUser := c.GetAdminUserInfo()
  804. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  805. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  806. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  807. record_time := c.GetString("record_time")
  808. order, _ := service.GetHisOrderByID(order_id)
  809. timeLayout := "2006-01-02"
  810. loc, _ := time.LoadLocation("Local")
  811. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  812. if err != nil {
  813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  814. return
  815. }
  816. recordDateTime := theTime.Unix()
  817. var patientPrescription models.HisPrescriptionInfo
  818. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  819. if patientPrescription.ID == 0 {
  820. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  821. }
  822. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  823. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  824. //
  825. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  826. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  827. var pp models.PublicParams
  828. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  829. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  830. pp.FixmedinsName = miConfig.OrgName
  831. pp.FixmedinsCode = miConfig.Code
  832. pp.RequestUrl = miConfig.Url
  833. pp.Cainfo = miConfig.Cainfo
  834. pp.SecretKey = miConfig.SecretKey
  835. pp.AccessKey = miConfig.AccessKey
  836. pp.OpterName = roles.UserName
  837. var config []*models.HisXtDiagnoseConfig
  838. for _, item := range diagnosis_ids {
  839. id, _ := strconv.ParseInt(item, 10, 64)
  840. diagnosisConfig, _ := service.FindDiagnoseById(id)
  841. config = append(config, &diagnosisConfig)
  842. }
  843. var pd models.PatientDtos
  844. pd.PatnID = his.PsnNo
  845. pd.PatnName = his.Name
  846. pd.Gend = his.Gend
  847. pd.Brdy = his.Brdy
  848. pd.Poolarea = his.InsuplcAdmdvs
  849. pd.CurrMdtrtID = his.Number
  850. var fed models.FsiEncounterDtos
  851. fed.MdtrtID = his.Number
  852. fed.MedinsID = miConfig.Code
  853. fed.MedinsName = miConfig.OrgName
  854. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  855. fed.MedMdtrtType = "1"
  856. fed.MedinsType = "1"
  857. fed.MedinsLv = "11"
  858. tm := time.Unix(his.RecordDate, 0)
  859. s_tm := tm.Format("2006-01-02 15:04:05")
  860. fed.AdmDate = s_tm
  861. fed.DscgDate = s_tm
  862. fed.DscgMainDiseCodg = config[0].CountryCode
  863. fed.DscgMainDiseName = config[0].CountryContentName
  864. //诊断信息
  865. var fdds []*models.FsiDiagnoseDtos
  866. for index, item := range config {
  867. if index == 0 {
  868. var fdd models.FsiDiagnoseDtos
  869. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  870. fdd.InoutDiseType = "1"
  871. fdd.MaindiseFlag = "1"
  872. fdd.DiseDate = s_tm
  873. fdd.DiasSrtNo = "1"
  874. fdd.DiseName = item.CountryContentName
  875. fdd.DiseCodg = item.CountryCode
  876. fdds = append(fdds, &fdd)
  877. } else {
  878. var fdd models.FsiDiagnoseDtos
  879. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  880. fdd.InoutDiseType = "1"
  881. fdd.MaindiseFlag = "1"
  882. fdd.DiseDate = s_tm
  883. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  884. fdd.DiseName = item.CountryContentName
  885. fdd.DiseCodg = item.CountryCode
  886. fdds = append(fdds, &fdd)
  887. }
  888. }
  889. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  890. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  891. fed.AdmDeptName = department.Name
  892. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  893. fed.DscgDeptName = department.Name
  894. fed.MedType = order.MedType
  895. //处方医嘱信息
  896. var orders []*models.FsiOrderDtos
  897. //for _, item := range prescriptions {
  898. // for _, subItem := range item.HisDoctorAdviceInfo {
  899. // var order models.FsiOrderDtos
  900. // order.RxID = strconv.FormatInt(item.ID, 10)
  901. // order.Rxno = strconv.FormatInt(item.ID, 10)
  902. // order.LongDrordFlag = "0"
  903. // order.HilistType = "1"
  904. // order.ChrgType = "1"
  905. // order.DrordBhvr = "-"
  906. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  907. // order.HosplistName = subItem.BaseDrugLib.DrugName
  908. // order.HilistLv = "1"
  909. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  910. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  911. // order.HosplistName = subItem.BaseDrugLib.DrugName
  912. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  913. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  914. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  915. // order.OwnpayAmt = ""
  916. // order.SelfpayAmt = ""
  917. // order.Spec = ""
  918. // order.SpecUnt = ""
  919. // order.DrordBegnDate = s_tm
  920. // order.DrordStopDate = ""
  921. // order.DrordDrCodg = "1"
  922. // order.DrordDeptName = department.Name
  923. // order.DrordDrCodg = "1"
  924. // order.DrordDrName = doctor_info.UserName
  925. // order.DrordDrProfttl = ""
  926. // order.CurrDrordFlag = "1"
  927. // orders = append(orders, &order)
  928. // }
  929. // for _, subItem := range item.HisPrescriptionProject {
  930. // if subItem.Type == 2 {
  931. // var order models.FsiOrderDtos
  932. // order.RxID = strconv.FormatInt(item.ID, 10)
  933. // order.Rxno = strconv.FormatInt(item.ID, 10)
  934. // order.LongDrordFlag = "0"
  935. // order.HilistType = "1"
  936. // order.ChrgType = "1"
  937. // order.DrordBhvr = "-"
  938. // order.HilistCode = subItem.HisProject.MedicalCode
  939. // order.HosplistName = subItem.HisProject.ProjectName
  940. // order.HilistLv = "1"
  941. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  942. // order.HosplistCode = subItem.HisProject.MedicalCode
  943. // order.HosplistName = subItem.HisProject.ProjectName
  944. // order.Cnt = subItem.Count
  945. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  946. //
  947. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  948. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  949. // order.OwnpayAmt = ""
  950. // order.SelfpayAmt = ""
  951. // order.Spec = ""
  952. // order.SpecUnt = ""
  953. // order.DrordBegnDate = s_tm
  954. // order.DrordStopDate = ""
  955. // order.DrordDrCodg = "1"
  956. // order.DrordDeptName = department.Name
  957. // order.DrordDrCodg = "1"
  958. // order.DrordDrName = doctor_info.UserName
  959. // order.DrordDrProfttl = ""
  960. // order.CurrDrordFlag = "1"
  961. // orders = append(orders, &order)
  962. //
  963. // }
  964. // if subItem.Type == 3 {
  965. //
  966. // var order models.FsiOrderDtos
  967. // order.RxID = strconv.FormatInt(item.ID, 10)
  968. // order.Rxno = strconv.FormatInt(item.ID, 10)
  969. // order.LongDrordFlag = "0"
  970. // order.HilistType = "1"
  971. // order.ChrgType = "1"
  972. // order.DrordBhvr = "-"
  973. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  974. // order.HosplistName = subItem.GoodInfo.GoodName
  975. // order.HilistLv = "1"
  976. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  977. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  978. // order.HosplistName = subItem.GoodInfo.GoodName
  979. // order.Cnt = subItem.Count
  980. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  981. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  982. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  983. // order.OwnpayAmt = ""
  984. // order.SelfpayAmt = ""
  985. // order.Spec = ""
  986. // order.SpecUnt = ""
  987. // order.DrordBegnDate = s_tm
  988. // order.DrordStopDate = ""
  989. // order.DrordDrCodg = "1"
  990. // order.DrordDeptName = department.Name
  991. // order.DrordDrCodg = "1"
  992. // order.DrordDrName = doctor_info.UserName
  993. // order.DrordDrProfttl = ""
  994. // order.CurrDrordFlag = "1"
  995. // orders = append(orders, &order)
  996. //
  997. // }
  998. // }
  999. //}
  1000. for _, item := range prescriptions {
  1001. for _, subItem := range item.HisDoctorAdviceInfo {
  1002. var order models.FsiOrderDtos
  1003. order.RxID = strconv.FormatInt(item.ID, 10)
  1004. order.Rxno = strconv.FormatInt(item.ID, 10)
  1005. order.LongDrordFlag = "0"
  1006. order.HilistType = "1"
  1007. order.ChrgType = "1"
  1008. order.DrordBhvr = "-"
  1009. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1010. order.HosplistName = subItem.BaseDrugLib.DrugName
  1011. order.HilistLv = "1"
  1012. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1013. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1014. order.HosplistName = subItem.BaseDrugLib.DrugName
  1015. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1016. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1017. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1018. order.OwnpayAmt = ""
  1019. order.SelfpayAmt = ""
  1020. order.Spec = ""
  1021. order.SpecUnt = ""
  1022. order.DrordBegnDate = s_tm
  1023. order.DrordStopDate = ""
  1024. order.DrordDrCodg = "1"
  1025. order.DrordDeptName = department.Name
  1026. order.DrordDrCodg = "1"
  1027. order.DrordDrName = doctor_info.UserName
  1028. order.DrordDrProfttl = ""
  1029. order.CurrDrordFlag = "1"
  1030. orders = append(orders, &order)
  1031. }
  1032. for _, subItem := range item.HisPrescriptionProject {
  1033. if subItem.Type == 2 {
  1034. var order models.FsiOrderDtos
  1035. order.RxID = strconv.FormatInt(item.ID, 10)
  1036. order.Rxno = strconv.FormatInt(item.ID, 10)
  1037. order.LongDrordFlag = "0"
  1038. order.HilistType = "1"
  1039. order.ChrgType = "1"
  1040. order.DrordBhvr = "-"
  1041. order.HilistCode = subItem.HisProject.MedicalCode
  1042. order.HosplistName = subItem.HisProject.ProjectName
  1043. order.HilistLv = "1"
  1044. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1045. order.HosplistCode = subItem.HisProject.MedicalCode
  1046. order.HosplistName = subItem.HisProject.ProjectName
  1047. order.Cnt = subItem.Count
  1048. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1049. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1050. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1051. order.OwnpayAmt = ""
  1052. order.SelfpayAmt = ""
  1053. order.Spec = ""
  1054. order.SpecUnt = ""
  1055. order.DrordBegnDate = s_tm
  1056. order.DrordStopDate = ""
  1057. order.DrordDrCodg = "1"
  1058. order.DrordDeptName = department.Name
  1059. order.DrordDrCodg = "1"
  1060. order.DrordDrName = doctor_info.UserName
  1061. order.DrordDrProfttl = ""
  1062. order.CurrDrordFlag = "1"
  1063. orders = append(orders, &order)
  1064. }
  1065. if subItem.Type == 3 {
  1066. var order models.FsiOrderDtos
  1067. order.RxID = strconv.FormatInt(item.ID, 10)
  1068. order.Rxno = strconv.FormatInt(item.ID, 10)
  1069. order.LongDrordFlag = "0"
  1070. order.HilistType = "1"
  1071. order.ChrgType = "1"
  1072. order.DrordBhvr = "-"
  1073. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1074. order.HosplistName = subItem.GoodInfo.GoodName
  1075. order.HilistLv = "1"
  1076. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1077. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1078. order.HosplistName = subItem.GoodInfo.GoodName
  1079. order.Cnt = subItem.Count
  1080. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1081. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1082. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1083. order.OwnpayAmt = ""
  1084. order.SelfpayAmt = ""
  1085. order.Spec = ""
  1086. order.SpecUnt = ""
  1087. order.DrordBegnDate = s_tm
  1088. order.DrordStopDate = ""
  1089. order.DrordDrCodg = "1"
  1090. order.DrordDeptName = department.Name
  1091. order.DrordDrCodg = "1"
  1092. order.DrordDrName = doctor_info.UserName
  1093. order.DrordDrProfttl = ""
  1094. order.CurrDrordFlag = "1"
  1095. orders = append(orders, &order)
  1096. }
  1097. }
  1098. }
  1099. //处方医嘱信息
  1100. fed.MatnStas = "0"
  1101. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  1102. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  1103. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  1104. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  1105. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  1106. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  1107. fed.SetlTotlnum = "1"
  1108. fed.Insutype = his.Insutype
  1109. fed.ReimFlag = "0"
  1110. fed.OutSetlFlag = "0"
  1111. var fopd []*models.FsiOperationDtosData
  1112. data := make(map[string]interface{})
  1113. data["fed"] = fed
  1114. data["fdd"] = fdds
  1115. data["fod"] = orders
  1116. data["pd"] = pd
  1117. data["pp"] = pp
  1118. data["fopd"] = fopd
  1119. data["trig_scen"] = trig_scen
  1120. client := &http.Client{}
  1121. bytesData, _ := json.Marshal(data)
  1122. var req *http.Request
  1123. if miConfig.MdtrtareaAdmvs == "320921" {
  1124. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  1125. } else {
  1126. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  1127. }
  1128. resp, _ := client.Do(req)
  1129. defer resp.Body.Close()
  1130. body, ioErr := ioutil.ReadAll(resp.Body)
  1131. if ioErr != nil {
  1132. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1134. return res
  1135. }
  1136. var respJSON map[string]interface{}
  1137. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1140. return res
  1141. }
  1142. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1143. result, _ := json.Marshal(respJSON)
  1144. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1145. utils.ErrorLog("解析失败:%v", err)
  1146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1147. return res
  1148. }
  1149. return res
  1150. //手术操作集合
  1151. //手术操作集合
  1152. }
  1153. func (c *HisApiController) Check() {
  1154. psn_no := c.GetString("psn_no")
  1155. in := c.GetString("in")
  1156. mt := c.GetString("mt")
  1157. baseParams := models.BaseParams{
  1158. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  1159. FixmedinsCode: "H15049901371",
  1160. InsuplcAdmdvs: "150499",
  1161. MdtrtareaAdmvs: "150499",
  1162. OrgName: "赤峰费森血液透析中心",
  1163. Doctor: "1111",
  1164. }
  1165. service.Gdyb2001(baseParams, psn_no, in, mt)
  1166. }
  1167. func (c *HisApiController) GetPsnNcdsInfo() {
  1168. admin_user_id, _ := c.GetInt64("admin_user_id")
  1169. patient_id, _ := c.GetInt64("patient_id")
  1170. id, _ := c.GetInt64("id")
  1171. adminUser := c.GetAdminUserInfo()
  1172. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1173. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1174. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  1175. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1176. psn_record, _ := service.GetPsnNCDSRecordById(id)
  1177. //
  1178. //if psn_record.ID == 0 {
  1179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  1180. // return
  1181. //}
  1182. var res Result5301
  1183. var res10265 Result5301For10265
  1184. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1185. psn_info, _ := service.GetPsnByPatientId(patient_id)
  1186. var api string
  1187. if miConfig.MdtrtareaAdmvs == "320921" {
  1188. api = "http://192.168.2.110:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  1189. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1190. } else {
  1191. 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 +
  1192. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1193. }
  1194. resp, requestErr := http.Get(api)
  1195. if requestErr != nil {
  1196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1197. return
  1198. }
  1199. body, ioErr := ioutil.ReadAll(resp.Body)
  1200. if ioErr != nil {
  1201. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1203. return
  1204. }
  1205. var respJSON map[string]interface{}
  1206. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1207. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1209. return
  1210. }
  1211. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1212. result, _ := json.Marshal(respJSON)
  1213. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1214. utils.ErrorLog("解析失败:%v", err)
  1215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1216. return
  1217. }
  1218. res.ErrMsg = res10265.ErrMsg
  1219. res.Output = res10265.Output
  1220. res.InfRefmsgid = res10265.InfRefmsgid
  1221. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1222. res.Infcode = infocode
  1223. } else {
  1224. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1225. var dat map[string]interface{}
  1226. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1227. fmt.Println(dat)
  1228. } else {
  1229. fmt.Println(err)
  1230. }
  1231. userJSONBytes, _ := json.Marshal(dat)
  1232. if miConfig.Code == "H15049901371" {
  1233. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  1234. utils.ErrorLog("解析失败:%v", err)
  1235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1236. return
  1237. }
  1238. res.InfRefmsgid = res10265.InfRefmsgid
  1239. res.Output = res10265.Output
  1240. res.ErrMsg = res10265.ErrMsg
  1241. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1242. res.Infcode = infocode
  1243. } else {
  1244. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1245. utils.ErrorLog("解析失败:%v", err)
  1246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1247. return
  1248. }
  1249. }
  1250. }
  1251. if res.Infcode == 0 {
  1252. c.ServeSuccessJSON(map[string]interface{}{
  1253. "result": res.Output.Result,
  1254. })
  1255. }
  1256. }
  1257. func (c *HisApiController) CheckInsutype() {
  1258. his_patient_id, _ := c.GetInt64("his_patient_id")
  1259. admin_user_id, _ := c.GetInt64("admin_user_id")
  1260. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1261. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1262. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1263. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1264. var dat map[string]interface{}
  1265. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1266. fmt.Println(dat)
  1267. } else {
  1268. fmt.Println(err)
  1269. }
  1270. userJSONBytes, _ := json.Marshal(dat)
  1271. var res Result90100
  1272. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1273. utils.ErrorLog("解析失败:%v", err)
  1274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1275. return
  1276. }
  1277. if res.Infcode != 0 {
  1278. c.ServeSuccessJSON(map[string]interface{}{
  1279. "failed_code": -10,
  1280. "msg": res.ErrMsg,
  1281. })
  1282. return
  1283. } else {
  1284. fmt.Println(res)
  1285. }
  1286. }
  1287. func (c *HisApiController) CheckCardPWD() {
  1288. card_pwd := c.GetString("card_pwd")
  1289. his_patient_id, _ := c.GetInt64("his_patient_id")
  1290. admin_user_id, _ := c.GetInt64("admin_user_id")
  1291. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1292. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1293. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1294. psn, _ := service.GetPsnByPatientId(his.PatientId)
  1295. bas := strings.Split(psn.CardInfo, "|")
  1296. basNumber := bas[2]
  1297. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  1298. var dat map[string]interface{}
  1299. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1300. fmt.Println(dat)
  1301. } else {
  1302. fmt.Println(err)
  1303. }
  1304. userJSONBytes, _ := json.Marshal(dat)
  1305. var res Result90991
  1306. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1307. utils.ErrorLog("解析失败:%v", err)
  1308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1309. return
  1310. }
  1311. if res.Infcode != 0 {
  1312. c.ServeSuccessJSON(map[string]interface{}{
  1313. "failed_code": -10,
  1314. "msg": res.ErrMsg,
  1315. })
  1316. return
  1317. } else {
  1318. if res.Output.Result.SscnoCheckStat == "0" {
  1319. var msg string
  1320. switch res.Output.Result.CardStat {
  1321. case "00":
  1322. msg = "未激活"
  1323. break
  1324. case "10":
  1325. msg = "激活"
  1326. break
  1327. case "20":
  1328. msg = "窗口挂失"
  1329. break
  1330. case "21":
  1331. msg = "电话挂失"
  1332. break
  1333. case "22":
  1334. msg = "单位网上申报挂失"
  1335. break
  1336. case "23":
  1337. msg = "保健办挂失"
  1338. break
  1339. case "24":
  1340. msg = "个人网上挂失"
  1341. break
  1342. case "25":
  1343. msg = "网上服务大厅挂失"
  1344. break
  1345. case "30":
  1346. msg = "注销"
  1347. break
  1348. case "40":
  1349. msg = "回收"
  1350. break
  1351. case "99":
  1352. msg = "制卡中(无效卡)"
  1353. break
  1354. }
  1355. c.ServeSuccessJSON(map[string]interface{}{
  1356. "failed_code": -10,
  1357. "msg": msg,
  1358. })
  1359. return
  1360. } else {
  1361. c.ServeSuccessJSON(map[string]interface{}{
  1362. "msg": "校验成功",
  1363. })
  1364. return
  1365. }
  1366. }
  1367. }
  1368. func (c *HisApiController) CheckCardPWDTwo() {
  1369. //card_pwd := c.GetString("card_pwd")
  1370. //his_patient_id, _ := c.GetInt64("his_patient_id")
  1371. admin_user_id, _ := c.GetInt64("admin_user_id")
  1372. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1373. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1374. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  1375. var dat map[string]interface{}
  1376. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1377. fmt.Println(dat)
  1378. } else {
  1379. fmt.Println(err)
  1380. }
  1381. userJSONBytes, _ := json.Marshal(dat)
  1382. var res Result90991
  1383. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1384. utils.ErrorLog("解析失败:%v", err)
  1385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1386. return
  1387. }
  1388. if res.Infcode != 0 {
  1389. c.ServeSuccessJSON(map[string]interface{}{
  1390. "failed_code": -10,
  1391. "msg": res.ErrMsg,
  1392. })
  1393. return
  1394. } else {
  1395. if res.Output.Result.SscnoCheckStat == "0" {
  1396. var msg string
  1397. switch res.Output.Result.CardStat {
  1398. case "00":
  1399. msg = "未激活"
  1400. break
  1401. case "10":
  1402. msg = "激活"
  1403. break
  1404. case "20":
  1405. msg = "窗口挂失"
  1406. break
  1407. case "21":
  1408. msg = "电话挂失"
  1409. break
  1410. case "22":
  1411. msg = "单位网上申报挂失"
  1412. break
  1413. case "23":
  1414. msg = "保健办挂失"
  1415. break
  1416. case "24":
  1417. msg = "个人网上挂失"
  1418. break
  1419. case "25":
  1420. msg = "网上服务大厅挂失"
  1421. break
  1422. case "30":
  1423. msg = "注销"
  1424. break
  1425. case "40":
  1426. msg = "回收"
  1427. break
  1428. case "99":
  1429. msg = "制卡中(无效卡)"
  1430. break
  1431. }
  1432. c.ServeSuccessJSON(map[string]interface{}{
  1433. "failed_code": -10,
  1434. "msg": msg,
  1435. })
  1436. return
  1437. } else {
  1438. c.ServeSuccessJSON(map[string]interface{}{
  1439. "msg": "校验成功",
  1440. })
  1441. return
  1442. }
  1443. }
  1444. }
  1445. type ELeCertData struct {
  1446. Data struct {
  1447. Extra string `json:"extra"`
  1448. IDNo string `json:"idNo"`
  1449. IDType string `json:"idType"`
  1450. EcToken string `json:"ecToken"`
  1451. InsuOrg string `json:"insuOrg"`
  1452. UserName string `json:"userName"`
  1453. EcIndexNo string `json:"ecIndexNo"`
  1454. Gender string `json:"gender"`
  1455. Birthday string `json:"birthday"`
  1456. Nationality string `json:"nationality"`
  1457. Email string `json:"email"`
  1458. } `json:"OutData"`
  1459. }
  1460. func (c *HisApiController) ReadCard() {
  1461. id_card_type, _ := c.GetInt64("id_card_type")
  1462. admin_user_id, _ := c.GetInt64("admin_user_id")
  1463. certificates, _ := c.GetInt64("certificates")
  1464. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1465. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1466. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1467. switch id_card_type {
  1468. case 1:
  1469. if miConfig.MdtrtareaAdmvs == "421300" {
  1470. var res ResultTwo
  1471. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1472. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1473. "&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)
  1474. resp, requestErr := http.Get(api)
  1475. if requestErr != nil {
  1476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1477. return
  1478. }
  1479. body, ioErr := ioutil.ReadAll(resp.Body)
  1480. if ioErr != nil {
  1481. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1483. return
  1484. }
  1485. var respJSON map[string]interface{}
  1486. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1489. return
  1490. }
  1491. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1492. result, _ := json.Marshal(respJSON)
  1493. fmt.Println("log")
  1494. fmt.Println(string(result))
  1495. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1496. utils.ErrorLog("解析失败:%v", err)
  1497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1498. return
  1499. }
  1500. if res.Infcode == 0 {
  1501. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1502. if err == gorm.ErrRecordNotFound {
  1503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1504. return
  1505. } else if err != nil {
  1506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1507. return
  1508. } else {
  1509. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1510. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1511. infoStr := string(Iinfos)
  1512. idetinfoStr := string(Idetinfos)
  1513. psn := &models.HisPsn{
  1514. PsnNo: res.Output.Baseinfo.PsnNo,
  1515. Age: res.Output.Baseinfo.Age,
  1516. PatientId: patient.ID,
  1517. Certno: res.Output.Baseinfo.Certno,
  1518. Brdy: res.Output.Baseinfo.Brdy,
  1519. Gend: res.Output.Baseinfo.Gend,
  1520. Naty: res.Output.Baseinfo.Naty,
  1521. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1522. PsnName: res.Output.Baseinfo.PsnName,
  1523. Idetinfo: idetinfoStr,
  1524. Insuinfo: infoStr,
  1525. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1526. }
  1527. service.CreateHisPsn(psn)
  1528. c.ServeSuccessJSON(map[string]interface{}{
  1529. "patient": patient,
  1530. "number": res.Output.Baseinfo.Certno,
  1531. })
  1532. }
  1533. } else {
  1534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1535. return
  1536. }
  1537. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1538. var api string
  1539. if miConfig.MdtrtareaAdmvs == "320921" {
  1540. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1541. "&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
  1542. fmt.Println(api)
  1543. } else {
  1544. 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 +
  1545. "&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)
  1546. }
  1547. resp, requestErr := http.Get(api)
  1548. if requestErr != nil {
  1549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1550. return
  1551. }
  1552. body, ioErr := ioutil.ReadAll(resp.Body)
  1553. if ioErr != nil {
  1554. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1556. return
  1557. }
  1558. var respJSON map[string]interface{}
  1559. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1562. return
  1563. }
  1564. var status string
  1565. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1566. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1567. //console.log()
  1568. fmt.Println("type===")
  1569. fmt.Println(card_type)
  1570. var token string
  1571. var res ResultTwo //1101结果
  1572. var res10265 ResultTwo10265 //1101结果
  1573. var card_info string //卡信息
  1574. var busi_card_info string
  1575. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1576. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1577. if status == "0" { //读卡成功
  1578. if card_type == "1" {
  1579. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1580. result, _ := json.Marshal(respJSON)
  1581. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1582. utils.ErrorLog("解析失败:%v", err)
  1583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1584. return
  1585. }
  1586. res.ErrMsg = res10265.ErrMsg
  1587. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1588. res.Infcode = infocode
  1589. res.Output = res10265.Output
  1590. res.InfRefmsgid = res10265.InfRefmsgid
  1591. } else {
  1592. //var card_info string //卡信息
  1593. //var busi_card_info string
  1594. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1595. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1596. //fmt.Println(card_info)
  1597. //fmt.Println(busi_card_info)
  1598. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1599. result, _ := json.Marshal(respJSON)
  1600. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1601. utils.ErrorLog("解析失败:%v", err)
  1602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1603. return
  1604. }
  1605. res.ErrMsg = res10265.ErrMsg
  1606. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1607. res.Infcode = infocode
  1608. res.Output = res10265.Output
  1609. res.InfRefmsgid = res10265.InfRefmsgid
  1610. }
  1611. if res.Infcode == 0 {
  1612. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1613. if err == gorm.ErrRecordNotFound {
  1614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1615. return
  1616. } else if err != nil {
  1617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1618. return
  1619. } else {
  1620. if card_type == "1" {
  1621. bas := strings.Split(card_info, "|")
  1622. basNumber := bas[2]
  1623. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1624. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1625. infoStr := string(Iinfos)
  1626. idetinfoStr := string(Idetinfos)
  1627. psn := &models.HisPsn{
  1628. PsnNo: res.Output.Baseinfo.PsnNo,
  1629. Age: res.Output.Baseinfo.Age,
  1630. PatientId: patient.ID,
  1631. Certno: res.Output.Baseinfo.Certno,
  1632. Brdy: res.Output.Baseinfo.Brdy,
  1633. Gend: res.Output.Baseinfo.Gend,
  1634. Naty: res.Output.Baseinfo.Naty,
  1635. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1636. PsnName: res.Output.Baseinfo.PsnName,
  1637. Idetinfo: idetinfoStr,
  1638. Insuinfo: infoStr,
  1639. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1640. CardInfo: card_info,
  1641. VerifyNumber: busi_card_info,
  1642. }
  1643. service.CreateHisPsn(psn)
  1644. var rf []*ResultFive
  1645. json.Unmarshal([]byte(infoStr), &rf)
  1646. var insutypes []*ResultFive
  1647. var insutype string
  1648. var is390 int = 0
  1649. var is310 int = 0
  1650. for _, item := range rf {
  1651. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1652. insutypes = append(insutypes, item)
  1653. }
  1654. }
  1655. if len(insutypes) == 1 {
  1656. insutype = insutypes[0].Insutype
  1657. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1658. } else {
  1659. for _, i := range insutypes {
  1660. if i.Insutype == "390" {
  1661. is390 = 1
  1662. }
  1663. if i.Insutype == "310" {
  1664. is310 = 1
  1665. }
  1666. }
  1667. }
  1668. if is390 == 1 {
  1669. insutype = "390"
  1670. }
  1671. if is310 == 1 {
  1672. insutype = "310"
  1673. }
  1674. if len(insutypes) == 0 {
  1675. insutype = "310"
  1676. }
  1677. c.ServeSuccessJSON(map[string]interface{}{
  1678. "patient": patient,
  1679. "number": basNumber,
  1680. "insutype": insutype,
  1681. })
  1682. } else {
  1683. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1684. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1685. infoStr := string(Iinfos)
  1686. idetinfoStr := string(Idetinfos)
  1687. psn := &models.HisPsn{
  1688. PsnNo: res.Output.Baseinfo.PsnNo,
  1689. Age: res.Output.Baseinfo.Age,
  1690. PatientId: patient.ID,
  1691. Certno: res.Output.Baseinfo.Certno,
  1692. Brdy: res.Output.Baseinfo.Brdy,
  1693. Gend: res.Output.Baseinfo.Gend,
  1694. Naty: res.Output.Baseinfo.Naty,
  1695. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1696. PsnName: res.Output.Baseinfo.PsnName,
  1697. Idetinfo: idetinfoStr,
  1698. Insuinfo: infoStr,
  1699. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1700. CardInfo: card_info,
  1701. VerifyNumber: token,
  1702. }
  1703. service.CreateHisPsn(psn)
  1704. c.ServeSuccessJSON(map[string]interface{}{
  1705. "patient": patient,
  1706. "number": token,
  1707. })
  1708. }
  1709. }
  1710. } else {
  1711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1712. return
  1713. }
  1714. } else { //读卡失败
  1715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1716. return
  1717. }
  1718. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1719. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1720. cardnum = DeleteExtraSpaceTwo(cardnum)
  1721. cardCode = DeleteExtraSpaceTwo(cardCode)
  1722. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1723. name = DeleteExtraSpaceTwo(name)
  1724. errmsg = DeleteExtraSpaceTwo(errmsg)
  1725. cardnum = Remove0000(cardnum)
  1726. cardCode = Remove0000(cardCode)
  1727. id_card_no = Remove0000(id_card_no)
  1728. name = Remove0000(name)
  1729. errmsg = Remove0000(errmsg)
  1730. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1731. result, requestLog, errMsgLog := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  1732. saveLog(result, requestLog, "1101", "获取人员信息")
  1733. fmt.Println(errMsgLog)
  1734. if len(errMsgLog) > 0 {
  1735. } else {
  1736. var dat map[string]interface{}
  1737. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1738. fmt.Println(dat)
  1739. } else {
  1740. fmt.Println(err)
  1741. }
  1742. userJSONBytes, _ := json.Marshal(dat)
  1743. var res ResultTwo
  1744. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1745. utils.ErrorLog("解析失败:%v", err)
  1746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1747. return
  1748. }
  1749. res.ErrMsg = errMsgLog
  1750. if res.Infcode == 0 {
  1751. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1752. if err == gorm.ErrRecordNotFound {
  1753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1754. return
  1755. } else if err != nil {
  1756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1757. return
  1758. } else {
  1759. fmt.Println(res)
  1760. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1761. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1762. infoStr := string(Iinfos)
  1763. idetinfoStr := string(Idetinfos)
  1764. psn := &models.HisPsn{
  1765. PsnNo: res.Output.Baseinfo.PsnNo,
  1766. Age: res.Output.Baseinfo.Age,
  1767. PatientId: patient.ID,
  1768. Certno: res.Output.Baseinfo.Certno,
  1769. Brdy: res.Output.Baseinfo.Brdy,
  1770. Gend: res.Output.Baseinfo.Gend,
  1771. Naty: res.Output.Baseinfo.Naty,
  1772. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1773. PsnName: res.Output.Baseinfo.PsnName,
  1774. Idetinfo: idetinfoStr,
  1775. Insuinfo: infoStr,
  1776. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1777. CardInfo: basStr,
  1778. VerifyNumber: "",
  1779. }
  1780. service.CreateHisPsn(psn)
  1781. var rf []*ResultFive
  1782. json.Unmarshal([]byte(infoStr), &rf)
  1783. var insutypes []*ResultFive
  1784. var insutype string
  1785. var is390 int = 0
  1786. var is310 int = 0
  1787. for _, item := range rf {
  1788. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1789. insutypes = append(insutypes, item)
  1790. }
  1791. }
  1792. if len(insutypes) == 1 {
  1793. insutype = insutypes[0].Insutype
  1794. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1795. } else {
  1796. for _, i := range insutypes {
  1797. if i.Insutype == "390" {
  1798. is390 = 1
  1799. }
  1800. if i.Insutype == "310" {
  1801. is310 = 1
  1802. }
  1803. }
  1804. }
  1805. if is390 == 1 {
  1806. insutype = "390"
  1807. }
  1808. if is310 == 1 {
  1809. insutype = "310"
  1810. }
  1811. if len(insutypes) == 0 {
  1812. insutype = "310"
  1813. }
  1814. c.ServeSuccessJSON(map[string]interface{}{
  1815. "patient": patient,
  1816. "number": cardnum,
  1817. "insutype": insutype,
  1818. })
  1819. }
  1820. } else {
  1821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1822. return
  1823. }
  1824. }
  1825. } else {
  1826. if initFlag == 0 {
  1827. c.TestGetBasBaseInit()
  1828. }
  1829. basStr := c.GetBasBaseInfo()
  1830. if len(basStr) == 0 {
  1831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1832. return
  1833. }
  1834. fmt.Println(basStr)
  1835. bas := strings.Split(basStr, "|")
  1836. basNumber := bas[1]
  1837. fmt.Println(basNumber)
  1838. card_sn := bas[3]
  1839. fmt.Println(card_sn)
  1840. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1841. var dat map[string]interface{}
  1842. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1843. fmt.Println(dat)
  1844. } else {
  1845. fmt.Println(err)
  1846. }
  1847. userJSONBytes, _ := json.Marshal(dat)
  1848. var res ResultTwo
  1849. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1850. utils.ErrorLog("解析失败:%v", err)
  1851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1852. return
  1853. }
  1854. if res.Infcode == 0 {
  1855. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1856. if err == gorm.ErrRecordNotFound {
  1857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1858. return
  1859. } else if err != nil {
  1860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1861. return
  1862. } else {
  1863. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1864. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1865. infoStr := string(Iinfos)
  1866. idetinfoStr := string(Idetinfos)
  1867. psn := &models.HisPsn{
  1868. PsnNo: res.Output.Baseinfo.PsnNo,
  1869. Age: res.Output.Baseinfo.Age,
  1870. PatientId: patient.ID,
  1871. Certno: res.Output.Baseinfo.Certno,
  1872. Brdy: res.Output.Baseinfo.Brdy,
  1873. Gend: res.Output.Baseinfo.Gend,
  1874. Naty: res.Output.Baseinfo.Naty,
  1875. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1876. PsnName: res.Output.Baseinfo.PsnName,
  1877. Idetinfo: idetinfoStr,
  1878. Insuinfo: infoStr,
  1879. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1880. CardInfo: basStr,
  1881. VerifyNumber: "",
  1882. }
  1883. service.CreateHisPsn(psn)
  1884. c.ServeSuccessJSON(map[string]interface{}{
  1885. "patient": patient,
  1886. "number": basNumber,
  1887. })
  1888. }
  1889. } else {
  1890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1891. return
  1892. }
  1893. break
  1894. }
  1895. case 2:
  1896. SFZStr := c.GetSFZBaseInfo()
  1897. id_card_str := strings.Split(SFZStr, "^")
  1898. id_card_number := id_card_str[0]
  1899. card_sn := ""
  1900. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1901. var dat map[string]interface{}
  1902. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1903. fmt.Println(dat)
  1904. } else {
  1905. fmt.Println(err)
  1906. }
  1907. userJSONBytes, _ := json.Marshal(dat)
  1908. var res ResultTwo
  1909. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1910. utils.ErrorLog("解析失败:%v", err)
  1911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1912. return
  1913. }
  1914. if res.Infcode == 0 {
  1915. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1916. if err == gorm.ErrRecordNotFound {
  1917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1918. return
  1919. } else if err != nil {
  1920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1921. return
  1922. } else {
  1923. c.ServeSuccessJSON(map[string]interface{}{
  1924. "patient": patient,
  1925. "number": id_card_number,
  1926. })
  1927. }
  1928. } else {
  1929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1930. return
  1931. }
  1932. break
  1933. case 3:
  1934. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1935. var api string
  1936. if miConfig.MdtrtareaAdmvs == "320921" {
  1937. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1938. "&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
  1939. fmt.Println(api)
  1940. } else {
  1941. 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 +
  1942. "&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)
  1943. }
  1944. resp, requestErr := http.Get(api)
  1945. if requestErr != nil {
  1946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1947. return
  1948. }
  1949. body, ioErr := ioutil.ReadAll(resp.Body)
  1950. if ioErr != nil {
  1951. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1953. return
  1954. }
  1955. var respJSON map[string]interface{}
  1956. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1957. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1959. return
  1960. }
  1961. var status string
  1962. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1963. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1964. var token string
  1965. var res ResultTwo //1101结果
  1966. var res10265 ResultTwo10265 //1101结果
  1967. var card_info string //卡信息
  1968. var busi_card_info string
  1969. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1970. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1971. if status == "0" { //读卡成功
  1972. if card_type == "1" {
  1973. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1974. result, _ := json.Marshal(respJSON)
  1975. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1976. utils.ErrorLog("解析失败:%v", err)
  1977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1978. return
  1979. }
  1980. res.ErrMsg = res10265.ErrMsg
  1981. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1982. res.Infcode = infocode
  1983. res.Output = res10265.Output
  1984. res.InfRefmsgid = res10265.InfRefmsgid
  1985. } else {
  1986. //var card_info string //卡信息
  1987. //var busi_card_info string
  1988. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1989. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1990. //fmt.Println(card_info)
  1991. //fmt.Println(busi_card_info)
  1992. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1993. result, _ := json.Marshal(respJSON)
  1994. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1995. utils.ErrorLog("解析失败:%v", err)
  1996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1997. return
  1998. }
  1999. res.ErrMsg = res10265.ErrMsg
  2000. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2001. res.Infcode = infocode
  2002. res.Output = res10265.Output
  2003. res.InfRefmsgid = res10265.InfRefmsgid
  2004. }
  2005. if res.Infcode == 0 {
  2006. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2007. if err == gorm.ErrRecordNotFound {
  2008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2009. return
  2010. } else if err != nil {
  2011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2012. return
  2013. } else {
  2014. if card_type == "1" {
  2015. bas := strings.Split(card_info, "|")
  2016. basNumber := bas[2]
  2017. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2018. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2019. infoStr := string(Iinfos)
  2020. idetinfoStr := string(Idetinfos)
  2021. psn := &models.HisPsn{
  2022. PsnNo: res.Output.Baseinfo.PsnNo,
  2023. Age: res.Output.Baseinfo.Age,
  2024. PatientId: patient.ID,
  2025. Certno: res.Output.Baseinfo.Certno,
  2026. Brdy: res.Output.Baseinfo.Brdy,
  2027. Gend: res.Output.Baseinfo.Gend,
  2028. Naty: res.Output.Baseinfo.Naty,
  2029. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2030. PsnName: res.Output.Baseinfo.PsnName,
  2031. Idetinfo: idetinfoStr,
  2032. Insuinfo: infoStr,
  2033. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2034. CardInfo: card_info,
  2035. VerifyNumber: busi_card_info,
  2036. }
  2037. service.CreateHisPsn(psn)
  2038. c.ServeSuccessJSON(map[string]interface{}{
  2039. "patient": patient,
  2040. "number": basNumber,
  2041. })
  2042. } else {
  2043. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2044. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2045. infoStr := string(Iinfos)
  2046. idetinfoStr := string(Idetinfos)
  2047. psn := &models.HisPsn{
  2048. PsnNo: res.Output.Baseinfo.PsnNo,
  2049. Age: res.Output.Baseinfo.Age,
  2050. PatientId: patient.ID,
  2051. Certno: res.Output.Baseinfo.Certno,
  2052. Brdy: res.Output.Baseinfo.Brdy,
  2053. Gend: res.Output.Baseinfo.Gend,
  2054. Naty: res.Output.Baseinfo.Naty,
  2055. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2056. PsnName: res.Output.Baseinfo.PsnName,
  2057. Idetinfo: idetinfoStr,
  2058. Insuinfo: infoStr,
  2059. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2060. CardInfo: card_info,
  2061. VerifyNumber: token,
  2062. }
  2063. service.CreateHisPsn(psn)
  2064. var rf []*ResultFive
  2065. json.Unmarshal([]byte(infoStr), &rf)
  2066. var insutypes []*ResultFive
  2067. var insutype string
  2068. var is390 int = 0
  2069. var is310 int = 0
  2070. for _, item := range rf {
  2071. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2072. insutypes = append(insutypes, item)
  2073. }
  2074. }
  2075. if len(insutypes) == 1 {
  2076. insutype = insutypes[0].Insutype
  2077. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2078. } else {
  2079. for _, i := range insutypes {
  2080. if i.Insutype == "390" {
  2081. is390 = 1
  2082. }
  2083. if i.Insutype == "310" {
  2084. is310 = 1
  2085. }
  2086. }
  2087. }
  2088. if is390 == 1 {
  2089. insutype = "390"
  2090. }
  2091. if is310 == 1 {
  2092. insutype = "310"
  2093. }
  2094. if len(insutypes) == 0 {
  2095. insutype = "310"
  2096. }
  2097. c.ServeSuccessJSON(map[string]interface{}{
  2098. "patient": patient,
  2099. "number": token,
  2100. "insutype": insutype,
  2101. })
  2102. }
  2103. }
  2104. } else {
  2105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2106. return
  2107. }
  2108. } else { //读卡失败
  2109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2110. return
  2111. }
  2112. }
  2113. break
  2114. case 4:
  2115. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2116. var api string
  2117. if miConfig.MdtrtareaAdmvs == "320921" {
  2118. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  2119. "&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
  2120. fmt.Println(api)
  2121. } else {
  2122. 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 +
  2123. "&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)
  2124. }
  2125. resp, requestErr := http.Get(api)
  2126. if requestErr != nil {
  2127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2128. return
  2129. }
  2130. body, ioErr := ioutil.ReadAll(resp.Body)
  2131. if ioErr != nil {
  2132. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2134. return
  2135. }
  2136. var respJSON map[string]interface{}
  2137. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2140. return
  2141. }
  2142. var status string
  2143. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2144. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2145. var token string
  2146. var res ResultTwo //1101结果
  2147. var res10265 ResultTwo10265 //1101结果
  2148. if status == "0" { //读卡成功
  2149. var card_info string //卡信息
  2150. var busi_card_info string
  2151. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2152. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2153. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2154. fmt.Println(card_info)
  2155. fmt.Println(busi_card_info)
  2156. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2157. result, _ := json.Marshal(respJSON)
  2158. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2159. utils.ErrorLog("解析失败:%v", err)
  2160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2161. return
  2162. }
  2163. res.ErrMsg = res10265.ErrMsg
  2164. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2165. res.Infcode = infocode
  2166. res.Output = res10265.Output
  2167. res.InfRefmsgid = res10265.InfRefmsgid
  2168. if res.Infcode == 0 {
  2169. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2170. if err == gorm.ErrRecordNotFound {
  2171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2172. return
  2173. } else if err != nil {
  2174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2175. return
  2176. } else {
  2177. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2178. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2179. infoStr := string(Iinfos)
  2180. idetinfoStr := string(Idetinfos)
  2181. psn := &models.HisPsn{
  2182. PsnNo: res.Output.Baseinfo.PsnNo,
  2183. Age: res.Output.Baseinfo.Age,
  2184. PatientId: patient.ID,
  2185. Certno: res.Output.Baseinfo.Certno,
  2186. Brdy: res.Output.Baseinfo.Brdy,
  2187. Gend: res.Output.Baseinfo.Gend,
  2188. Naty: res.Output.Baseinfo.Naty,
  2189. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2190. PsnName: res.Output.Baseinfo.PsnName,
  2191. Idetinfo: idetinfoStr,
  2192. Insuinfo: infoStr,
  2193. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2194. CardInfo: card_info,
  2195. VerifyNumber: token,
  2196. }
  2197. service.CreateHisPsn(psn)
  2198. c.ServeSuccessJSON(map[string]interface{}{
  2199. "patient": patient,
  2200. "number": token,
  2201. })
  2202. }
  2203. } else {
  2204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2205. return
  2206. }
  2207. } else { //读卡失败
  2208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2209. return
  2210. }
  2211. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  2212. if initFlag == 0 {
  2213. c.TestGetBasBaseInit()
  2214. }
  2215. token := c.GetEleBaseInfo()
  2216. token = Remove0000(token)
  2217. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token)
  2218. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2219. //
  2220. var res ResultTwo
  2221. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2222. utils.ErrorLog("解析失败:%v", err)
  2223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2224. return
  2225. }
  2226. if res.Infcode == 0 {
  2227. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2228. if err == gorm.ErrRecordNotFound {
  2229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2230. return
  2231. } else if err != nil {
  2232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2233. return
  2234. } else {
  2235. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2236. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2237. infoStr := string(Iinfos)
  2238. idetinfoStr := string(Idetinfos)
  2239. psn := &models.HisPsn{
  2240. PsnNo: res.Output.Baseinfo.PsnNo,
  2241. Age: res.Output.Baseinfo.Age,
  2242. PatientId: patient.ID,
  2243. Certno: res.Output.Baseinfo.Certno,
  2244. Brdy: res.Output.Baseinfo.Brdy,
  2245. Gend: res.Output.Baseinfo.Gend,
  2246. Naty: res.Output.Baseinfo.Naty,
  2247. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2248. PsnName: res.Output.Baseinfo.PsnName,
  2249. Idetinfo: idetinfoStr,
  2250. Insuinfo: infoStr,
  2251. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2252. CardInfo: "",
  2253. VerifyNumber: token,
  2254. }
  2255. service.CreateHisPsn(psn)
  2256. c.ServeSuccessJSON(map[string]interface{}{
  2257. "patient": patient,
  2258. "number": token,
  2259. })
  2260. }
  2261. } else {
  2262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2263. return
  2264. }
  2265. } else if miConfig.MdtrtareaAdmvs == "350500" {
  2266. type ELeData struct {
  2267. Code string `json:"code"`
  2268. Data struct {
  2269. Aac002 string `json:"aac002"`
  2270. Aaz500 string `json:"aaz500"`
  2271. ActCardNo string `json:"actCardNo"`
  2272. Bab520 string `json:"bab520"`
  2273. Bkz543 string `json:"bkz543"`
  2274. BusinessType string `json:"businessType"`
  2275. CertfCodg string `json:"certfCodg"`
  2276. EcIndexNo string `json:"ecIndexNo"`
  2277. EcToken string `json:"ecToken"`
  2278. ID0000 string `json:"id0000"`
  2279. IDNo string `json:"idNo"`
  2280. IDType string `json:"idType"`
  2281. Idcode string `json:"idcode"`
  2282. IdentityToken string `json:"identity_token"`
  2283. InsuOrg string `json:"insuOrg"`
  2284. OfficeID string `json:"officeId"`
  2285. OfficeName string `json:"officeName"`
  2286. OperatorID string `json:"operatorId"`
  2287. OperatorName string `json:"operatorName"`
  2288. OrgID string `json:"orgId"`
  2289. UserName string `json:"userName"`
  2290. } `json:"data"`
  2291. Infno interface{} `json:"infno"`
  2292. Message string `json:"message"`
  2293. OrgID string `json:"orgId"`
  2294. TransType string `json:"transType"`
  2295. }
  2296. inputInfo, outPutInfo, errMsg := service.ReadEleCard(miConfig.Code)
  2297. fmt.Println(errMsg)
  2298. if len(outPutInfo) > 0 {
  2299. var ele ELeData
  2300. err := json.Unmarshal([]byte(outPutInfo), &ele)
  2301. if err != nil {
  2302. utils.ErrorLog("解析失败:%v", err)
  2303. }
  2304. token := ele.Data.EcToken
  2305. fmt.Println(inputInfo)
  2306. fmt.Println(outPutInfo)
  2307. result, requestLog, errMsgLog := service.FJyb1101ForEleToken(ele.Data.IDNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, "", certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, token)
  2308. saveLog(result, requestLog, "1101", "获取人员信息")
  2309. var dat map[string]interface{}
  2310. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2311. fmt.Println(dat)
  2312. } else {
  2313. fmt.Println(err)
  2314. }
  2315. userJSONBytes, _ := json.Marshal(dat)
  2316. var res ResultTwo
  2317. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2318. utils.ErrorLog("解析失败:%v", err)
  2319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2320. return
  2321. }
  2322. res.ErrMsg = errMsgLog
  2323. if res.Infcode == 0 {
  2324. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  2325. if err == gorm.ErrRecordNotFound {
  2326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2327. return
  2328. } else if err != nil {
  2329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2330. return
  2331. } else {
  2332. fmt.Println(res)
  2333. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2334. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2335. infoStr := string(Iinfos)
  2336. idetinfoStr := string(Idetinfos)
  2337. psn := &models.HisPsn{
  2338. PsnNo: res.Output.Baseinfo.PsnNo,
  2339. Age: res.Output.Baseinfo.Age,
  2340. PatientId: patient.ID,
  2341. Certno: res.Output.Baseinfo.Certno,
  2342. Brdy: res.Output.Baseinfo.Brdy,
  2343. Gend: res.Output.Baseinfo.Gend,
  2344. Naty: res.Output.Baseinfo.Naty,
  2345. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2346. PsnName: res.Output.Baseinfo.PsnName,
  2347. Idetinfo: idetinfoStr,
  2348. Insuinfo: infoStr,
  2349. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2350. CardInfo: outPutInfo,
  2351. VerifyNumber: token,
  2352. }
  2353. service.CreateHisPsn(psn)
  2354. var rf []*ResultFive
  2355. json.Unmarshal([]byte(infoStr), &rf)
  2356. var insutypes []*ResultFive
  2357. var insutype string
  2358. var is390 int = 0
  2359. var is310 int = 0
  2360. for _, item := range rf {
  2361. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2362. insutypes = append(insutypes, item)
  2363. }
  2364. }
  2365. if len(insutypes) == 1 {
  2366. insutype = insutypes[0].Insutype
  2367. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2368. } else {
  2369. for _, i := range insutypes {
  2370. if i.Insutype == "390" {
  2371. is390 = 1
  2372. }
  2373. if i.Insutype == "310" {
  2374. is310 = 1
  2375. }
  2376. }
  2377. }
  2378. if is390 == 1 {
  2379. insutype = "390"
  2380. }
  2381. if is310 == 1 {
  2382. insutype = "310"
  2383. }
  2384. if len(insutypes) == 0 {
  2385. insutype = "310"
  2386. }
  2387. c.ServeSuccessJSON(map[string]interface{}{
  2388. "patient": patient,
  2389. "number": token,
  2390. "insutype": insutype,
  2391. })
  2392. }
  2393. } else {
  2394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2395. return
  2396. }
  2397. }
  2398. }
  2399. break
  2400. }
  2401. }
  2402. var initFlag int64 = 0
  2403. func (c *HisApiController) TestGetBasBaseInit() {
  2404. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2405. Iinit := DllDef.MustFindProc("Init")
  2406. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2407. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  2408. if ret != 0 {
  2409. fmt.Println("SSCard的报错原因:", err)
  2410. fmt.Println("SSCard的运算结果为:", ret)
  2411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2412. return
  2413. }
  2414. result := int(ret)
  2415. fmt.Println("SSCard的运算结果为1:", result)
  2416. initFlag = 1
  2417. return
  2418. }
  2419. func (c *HisApiController) GetSFZBaseInfo() string {
  2420. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2421. readCard := DllDef.MustFindProc("ReadSFZ")
  2422. if readCard == nil {
  2423. fmt.Println("readcard is nil")
  2424. readCard = DllDef.MustFindProc("ReadSFZ")
  2425. }
  2426. str := make([]byte, 256)
  2427. str1 := make([]byte, 256)
  2428. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2429. fmt.Println(r)
  2430. return string(str)
  2431. }
  2432. func (c *HisApiController) GetEleBaseInfo() string {
  2433. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2434. readCard := DllDef.MustFindProc("GetQRBase")
  2435. fmt.Println(readCard)
  2436. if readCard == nil {
  2437. fmt.Println("readcard is nil")
  2438. readCard = DllDef.MustFindProc("GetQRBase")
  2439. }
  2440. str := make([]byte, 1024)
  2441. str1 := make([]byte, 1024)
  2442. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  2443. fmt.Println(ret2)
  2444. fmt.Println(string(str1))
  2445. fmt.Println(string(str))
  2446. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  2447. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  2448. if ret2 != 0 {
  2449. return ""
  2450. }
  2451. return string(str)
  2452. }
  2453. func (c *HisApiController) GetBasBaseInfo() string {
  2454. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2455. readCard := DllDef.MustFindProc("ReadCardBas")
  2456. if readCard == nil {
  2457. fmt.Println("readcard is nil")
  2458. readCard = DllDef.MustFindProc("ReadCardBas")
  2459. }
  2460. str := make([]byte, 1024)
  2461. str1 := make([]byte, 1024)
  2462. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  2463. fmt.Println(string(str1))
  2464. fmt.Println(string(str))
  2465. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  2466. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  2467. if ret2 != 0 {
  2468. return ""
  2469. }
  2470. return string(str)
  2471. }
  2472. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  2473. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  2474. readCard := DllDef.MustFindProc("read_cardinfo")
  2475. if readCard == nil {
  2476. fmt.Println("readcard is nil")
  2477. readCard = DllDef.MustFindProc("read_cardinfo")
  2478. }
  2479. str := make([]byte, 1024) //卡号
  2480. str1 := make([]byte, 1024) //卡识别码
  2481. str2 := make([]byte, 1024) //身份证号
  2482. str3 := make([]byte, 1024) //姓名
  2483. str4 := make([]byte, 1024) //错误信息
  2484. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])), (uintptr)(unsafe.Pointer(&str2[0])), (uintptr)(unsafe.Pointer(&str3[0])), (uintptr)(unsafe.Pointer(&str4[0])))
  2485. fmt.Println(string(str1))
  2486. fmt.Println(string(str))
  2487. fmt.Println(string(str2))
  2488. fmt.Println(string(str3))
  2489. fmt.Println(string(str4))
  2490. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  2491. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  2492. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  2493. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  2494. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  2495. if ret2 != 0 {
  2496. return "", "", "", "", ""
  2497. }
  2498. return string(str), string(str1), string(str2), string(str3), string(str4)
  2499. }
  2500. type CustomFundPay struct {
  2501. FundPayType string `json:"fund_pay_type"`
  2502. FundPayamt float64 `json:"fund_payamt"`
  2503. }
  2504. func (c *HisApiController) GetSettleList() {
  2505. order_id, _ := c.GetInt64("order_id")
  2506. admin_user_id, _ := c.GetInt64("admin_user_id")
  2507. order, _ := service.GetHisOrderByIDTwo(order_id)
  2508. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2509. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2510. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2511. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2512. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2513. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2514. if order.ID == 0 {
  2515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2516. return
  2517. }
  2518. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2519. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2520. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2521. fmt.Println(count)
  2522. var zero string
  2523. number := count + 1
  2524. if number >= 1000 {
  2525. zero = "0000" + strconv.FormatInt(number, 10)
  2526. } else if number >= 10000 {
  2527. zero = "000" + strconv.FormatInt(number, 10)
  2528. } else if number >= 100000 {
  2529. zero = "00" + strconv.FormatInt(number, 10)
  2530. } else if number >= 1000000 {
  2531. zero = "0" + strconv.FormatInt(number, 10)
  2532. } else {
  2533. zero = strconv.FormatInt(number, 10)
  2534. }
  2535. fmt.Println(zero)
  2536. struct4101 := service.Struct4101{
  2537. PsnNo: order.PsnNo,
  2538. MdtrtId: order.MdtrtId,
  2539. SetlId: order.SetlId,
  2540. PsnName: order.PsnName,
  2541. Gend: order.Gend,
  2542. Brdy: his.Brdy,
  2543. Age: his.Age,
  2544. Naty: order.Naty,
  2545. PatnCertType: "01",
  2546. Certno: order.Certno,
  2547. Prfs: "90",
  2548. ConerName: roles[0].UserName,
  2549. PatnRlts: "99",
  2550. ConerAddr: miConfig.OrgName,
  2551. ConerTel: admin.Mobile,
  2552. HiType: order.Insutype,
  2553. Insuplc: miConfig.InsuplcAdmdvs,
  2554. MaindiagFlag: "1",
  2555. BillCode: last_order.FaPiaoCode,
  2556. BillNo: zero,
  2557. BizSn: order.Number,
  2558. PsnSelfPay: order.PsnPartAmt,
  2559. PsnOwnPay: order.PsnPartAmt,
  2560. AcctPay: order.AcctPay,
  2561. PsnCashpay: order.PsnCashPay,
  2562. HiPaymtd: "1",
  2563. Hsorg: miConfig.InsuplcAdmdvs,
  2564. HsorgOpter: miConfig.InsuplcAdmdvs,
  2565. MedinsFillPsn: curRoles.UserName,
  2566. MedinsFillDept: depart.Name,
  2567. IptMedType: "2",
  2568. }
  2569. struct4101.SetlBegnDate = order.SetlTime
  2570. struct4101.SetlEndDate = order.SetlTime
  2571. time_arr := strings.Split(order.SetlTime, " ")
  2572. struct4101.AdmTime = time_arr[0]
  2573. struct4101.AdmEndTime = time_arr[0]
  2574. var rf []CustomFundPay
  2575. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2576. var tempFunPays []service.CustomStruct
  2577. for _, item := range rf {
  2578. var tempFunPay service.CustomStruct
  2579. tempFunPay.FundPayamt = item.FundPayamt
  2580. tempFunPay.FundPayType = item.FundPayType
  2581. tempFunPays = append(tempFunPays, tempFunPay)
  2582. }
  2583. struct4101.CustomStruct = tempFunPays
  2584. var tempDiaginfos []service.DiaginfoStructTwo
  2585. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2586. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2587. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  2588. var config []*models.HisXtDiagnoseConfig
  2589. for _, item := range diagnosis_ids {
  2590. id, _ := strconv.ParseInt(item, 10, 64)
  2591. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2592. config = append(config, &diagnosisConfig)
  2593. }
  2594. for index, item := range config {
  2595. if index == 0 {
  2596. var tempDiaginfo service.DiaginfoStructTwo
  2597. tempDiaginfo.DiagCode = item.CountryCode
  2598. tempDiaginfo.DiagName = item.CountryContentName
  2599. tempDiaginfo.DiagType = "1"
  2600. tempDiaginfo.MaindiagFlag = "1"
  2601. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2602. } else {
  2603. var tempDiaginfo service.DiaginfoStructTwo
  2604. tempDiaginfo.DiagCode = item.CountryCode
  2605. tempDiaginfo.DiagName = item.CountryContentName
  2606. tempDiaginfo.DiagType = "2"
  2607. tempDiaginfo.MaindiagFlag = "0"
  2608. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2609. }
  2610. }
  2611. struct4101.Diseinfo = tempDiaginfos
  2612. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2613. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2614. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2615. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  2616. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  2617. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2618. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2619. var iteminfo service.IteminfoStruct
  2620. var bedCostTotal float64 = 0 //床位总费
  2621. var bedCostSelfTotal float64 = 0 //床位自费
  2622. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2623. var operationCostTotal float64 = 0 //手术费
  2624. var operationCostSelfTotal float64 = 0 //手术费
  2625. var operationCostPartSelfTotal float64 = 0 //手术费
  2626. var otherCostTotal float64 = 0 //其他费用
  2627. var otherCostSelfTotal float64 = 0 //其他费用
  2628. var otherCostPartSelfTotal float64 = 0 //其他费用
  2629. var materialCostTotal float64 = 0 //材料费
  2630. var materialCostSelfTotal float64 = 0 //材料费
  2631. var materialCostPartSelfTotal float64 = 0 //材料费
  2632. var westernMedicineCostTotal float64 = 0 //西药费
  2633. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2634. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2635. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2636. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2637. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2638. var checkCostTotal float64 = 0 //检查费
  2639. var checkCostSelfTotal float64 = 0 //检查费
  2640. var checkCostPartSelfTotal float64 = 0 //检查费
  2641. var laboratoryCostTotal float64 = 0 //化验费
  2642. var laboratoryCostSelfTotal float64 = 0 //化验费
  2643. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2644. var treatCostTotal float64 = 0 //治疗费用
  2645. var treatCostSelfTotal float64 = 0 //治疗费用
  2646. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2647. decimal.DivisionPrecision = 2
  2648. var bed_fulamt_ownpay_amt float64 = 0
  2649. var operation_fulamt_ownpay_amt float64 = 0
  2650. var other_fulamt_ownpay_amt float64 = 0
  2651. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2652. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2653. var check_fulamt_ownpay_amt float64 = 0
  2654. var material_fulamt_ownpay_amt float64 = 0
  2655. var laboratory_fulamt_ownpay_amt float64 = 0
  2656. var treat_fulamt_ownpay_amt float64 = 0
  2657. var bed_claa_sunmfee float64 = 0
  2658. var bed_clab_amt float64 = 0
  2659. var bed_other_amt float64 = 0
  2660. var operation_claa_sunmfee float64 = 0
  2661. var operation_clab_amt float64 = 0
  2662. var operation_other_amt float64 = 0
  2663. var other_claa_sunmfee float64 = 0
  2664. var other_clab_amt float64 = 0
  2665. var other_other_amt float64 = 0
  2666. var westernMedicine_claa_sunmfee float64 = 0
  2667. var westernMedicine_clab_amt float64 = 0
  2668. var westernMedicine_other_amt float64 = 0
  2669. var chineseTraditional_claa_sunmfee float64 = 0
  2670. var chineseTraditional_clab_amt float64 = 0
  2671. var chineseTraditional_other_amt float64 = 0
  2672. var check_claa_sunmfee float64 = 0
  2673. var check_clab_amt float64 = 0
  2674. var check_other_amt float64 = 0
  2675. var material_claa_sunmfee float64 = 0
  2676. var material_clab_amt float64 = 0
  2677. var material_other_amt float64 = 0
  2678. var laboratory_claa_sunmfee float64 = 0
  2679. var laboratory_clab_amt float64 = 0
  2680. var laboratory_other_amt float64 = 0
  2681. var treat_claa_sunmfee float64 = 0
  2682. var treat_clab_amt float64 = 0
  2683. var treat_other_amt float64 = 0
  2684. for _, item := range order.HisOrderInfo {
  2685. if item.MedChrgitmType == "01" { //床位费
  2686. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2687. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2688. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2689. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2690. if item.ChrgitmLv == "1" {
  2691. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2692. }
  2693. if item.ChrgitmLv == "2" {
  2694. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2695. }
  2696. if item.ChrgitmLv == "3" {
  2697. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2698. }
  2699. }
  2700. if item.MedChrgitmType == "03" { //检查费
  2701. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2702. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2703. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2704. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2705. if item.ChrgitmLv == "1" {
  2706. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2707. }
  2708. if item.ChrgitmLv == "2" {
  2709. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2710. }
  2711. if item.ChrgitmLv == "3" {
  2712. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2713. }
  2714. }
  2715. if item.MedChrgitmType == "04" { //化验费
  2716. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2717. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2718. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2719. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2720. if item.ChrgitmLv == "1" {
  2721. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2722. }
  2723. if item.ChrgitmLv == "2" {
  2724. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2725. }
  2726. if item.ChrgitmLv == "3" {
  2727. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2728. }
  2729. }
  2730. if item.MedChrgitmType == "05" { //治疗费
  2731. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2732. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2733. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2734. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2735. if item.ChrgitmLv == "1" {
  2736. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2737. }
  2738. if item.ChrgitmLv == "2" {
  2739. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2740. }
  2741. if item.ChrgitmLv == "3" {
  2742. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2743. }
  2744. }
  2745. if item.MedChrgitmType == "06" { //手术费
  2746. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2747. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2748. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2749. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2750. if item.ChrgitmLv == "1" {
  2751. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2752. }
  2753. if item.ChrgitmLv == "2" {
  2754. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2755. }
  2756. if item.ChrgitmLv == "3" {
  2757. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2758. }
  2759. }
  2760. if item.MedChrgitmType == "08" { //材料费
  2761. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2762. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2763. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2764. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2765. if item.ChrgitmLv == "1" {
  2766. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2767. }
  2768. if item.ChrgitmLv == "2" {
  2769. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2770. }
  2771. if item.ChrgitmLv == "3" {
  2772. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2773. }
  2774. }
  2775. if item.MedChrgitmType == "09" { //西药费
  2776. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2777. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2778. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2779. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2780. if item.ChrgitmLv == "1" {
  2781. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2782. }
  2783. if item.ChrgitmLv == "2" {
  2784. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2785. }
  2786. if item.ChrgitmLv == "3" {
  2787. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2788. }
  2789. }
  2790. if item.MedChrgitmType == "11" { //中成费
  2791. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2792. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2793. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2794. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2795. if item.ChrgitmLv == "1" {
  2796. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2797. }
  2798. if item.ChrgitmLv == "2" {
  2799. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2800. }
  2801. if item.ChrgitmLv == "3" {
  2802. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2803. }
  2804. }
  2805. if item.MedChrgitmType == "14" { //其他费
  2806. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2807. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2808. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2809. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2810. if item.ChrgitmLv == "1" {
  2811. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2812. }
  2813. if item.ChrgitmLv == "2" {
  2814. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2815. }
  2816. if item.ChrgitmLv == "3" {
  2817. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2818. }
  2819. }
  2820. }
  2821. var iteminfoStructs []service.IteminfoStruct
  2822. if bedCostTotal != 0 {
  2823. iteminfo.MedChrgitm = "01"
  2824. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2825. iteminfo.Amt = bedCostTotal
  2826. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2827. iteminfo.ClabAmt = bed_clab_amt
  2828. iteminfo.OthAmt = bed_other_amt
  2829. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2830. }
  2831. if checkCostTotal != 0 {
  2832. iteminfo.MedChrgitm = "03"
  2833. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2834. iteminfo.Amt = checkCostTotal
  2835. iteminfo.ClaaSumfee = check_claa_sunmfee
  2836. iteminfo.ClabAmt = check_clab_amt
  2837. iteminfo.OthAmt = check_other_amt
  2838. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2839. }
  2840. if laboratoryCostTotal != 0 {
  2841. iteminfo.MedChrgitm = "04"
  2842. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2843. iteminfo.Amt = laboratoryCostTotal
  2844. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2845. iteminfo.ClabAmt = laboratory_clab_amt
  2846. iteminfo.OthAmt = laboratory_other_amt
  2847. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2848. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2849. }
  2850. if treatCostTotal != 0 {
  2851. iteminfo.MedChrgitm = "05"
  2852. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2853. iteminfo.Amt = treatCostTotal
  2854. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2855. iteminfo.ClabAmt = treat_clab_amt
  2856. iteminfo.OthAmt = treat_other_amt
  2857. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2858. //(struct4101.IteminfoStruct, iteminfo)
  2859. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2860. }
  2861. if operationCostTotal != 0 {
  2862. iteminfo.MedChrgitm = "06"
  2863. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2864. iteminfo.Amt = operationCostTotal
  2865. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2866. iteminfo.ClabAmt = operation_clab_amt
  2867. iteminfo.OthAmt = operation_other_amt
  2868. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2869. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2870. }
  2871. if materialCostTotal != 0 {
  2872. iteminfo.MedChrgitm = "08"
  2873. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2874. iteminfo.Amt = materialCostTotal
  2875. iteminfo.ClaaSumfee = material_claa_sunmfee
  2876. iteminfo.ClabAmt = material_clab_amt
  2877. iteminfo.OthAmt = material_other_amt
  2878. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2879. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2880. }
  2881. if westernMedicineCostTotal != 0 {
  2882. iteminfo.MedChrgitm = "09"
  2883. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2884. iteminfo.Amt = westernMedicineCostTotal
  2885. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2886. iteminfo.ClabAmt = westernMedicine_clab_amt
  2887. iteminfo.OthAmt = westernMedicine_other_amt
  2888. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2889. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2890. }
  2891. if chineseTraditionalMedicineCostTotal != 0 {
  2892. iteminfo.MedChrgitm = "11"
  2893. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2894. iteminfo.Amt = westernMedicineCostTotal
  2895. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2896. iteminfo.ClabAmt = westernMedicine_clab_amt
  2897. iteminfo.OthAmt = westernMedicine_other_amt
  2898. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2899. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2900. }
  2901. if otherCostTotal != 0 {
  2902. iteminfo.MedChrgitm = "14"
  2903. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2904. iteminfo.Amt = otherCostTotal
  2905. iteminfo.ClaaSumfee = other_claa_sunmfee
  2906. iteminfo.ClabAmt = other_clab_amt
  2907. iteminfo.OthAmt = other_other_amt
  2908. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2909. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2910. }
  2911. struct4101.IteminfoStruct = iteminfoStructs
  2912. struct4101.Ntly = "中国"
  2913. struct4101.AdmCaty = "A03.06"
  2914. var res ResultSeventeen
  2915. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2916. struct4101.BillCode = order.Number
  2917. struct4101.BillNo = order.SetlId
  2918. var resOther ResultSeventeenOther
  2919. var pp models.PublicParams
  2920. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2921. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2922. pp.FixmedinsName = miConfig.OrgName
  2923. pp.FixmedinsCode = miConfig.Code
  2924. pp.RequestUrl = miConfig.Url
  2925. pp.Cainfo = miConfig.Cainfo
  2926. pp.SecretKey = miConfig.SecretKey
  2927. pp.AccessKey = miConfig.AccessKey
  2928. pp.OpterName = curRoles.UserName
  2929. client := &http.Client{}
  2930. var req *http.Request
  2931. data := make(map[string]interface{})
  2932. data["struct4101"] = struct4101
  2933. data["pp"] = pp
  2934. bytesData, _ := json.Marshal(data)
  2935. if miConfig.MdtrtareaAdmvs == "320921" {
  2936. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2937. } else {
  2938. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2939. }
  2940. resp, _ := client.Do(req)
  2941. defer resp.Body.Close()
  2942. body, ioErr := ioutil.ReadAll(resp.Body)
  2943. if ioErr != nil {
  2944. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2946. return
  2947. }
  2948. var respJSON map[string]interface{}
  2949. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2950. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2952. return
  2953. }
  2954. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2955. userJSONBytes, _ := json.Marshal(respJSON)
  2956. fmt.Println("log")
  2957. fmt.Println(string(userJSONBytes))
  2958. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2959. utils.ErrorLog("解析失败:%v", err)
  2960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2961. return
  2962. }
  2963. res.InfRefmsgid = resOther.InfRefmsgid
  2964. res.Output = resOther.Output
  2965. res.ErrMsg = resOther.ErrMsg
  2966. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2967. res.Infcode = infocode
  2968. } else {
  2969. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2970. var dat map[string]interface{}
  2971. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2972. fmt.Println(dat)
  2973. } else {
  2974. fmt.Println(err)
  2975. }
  2976. userJSONBytes, _ := json.Marshal(dat)
  2977. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2978. utils.ErrorLog("解析失败:%v", err)
  2979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2980. return
  2981. }
  2982. }
  2983. if res.Infcode != 0 {
  2984. c.ServeSuccessJSON(map[string]interface{}{
  2985. "failed_code": -10,
  2986. "msg": res.ErrMsg,
  2987. })
  2988. return
  2989. } else {
  2990. order.FaPiaoNumber = zero
  2991. order.FaPiaoCode = last_order.FaPiaoCode
  2992. service.UpdateOrder(order)
  2993. hisFundSettleListResult := &models.HisFundSettleListResult{
  2994. Number: res.Output.SetlListId,
  2995. Status: 1,
  2996. Ctime: time.Now().Unix(),
  2997. Mtime: time.Now().Unix(),
  2998. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2999. IsUpload: 1,
  3000. OrderId: order_id,
  3001. }
  3002. service.CreateUploadRecord(hisFundSettleListResult)
  3003. c.ServeSuccessJSON(map[string]interface{}{
  3004. "msg": "上传成功",
  3005. "result": hisFundSettleListResult,
  3006. })
  3007. return
  3008. }
  3009. }
  3010. func (c *HisApiController) GetSettleListHospital() {
  3011. order_id, _ := c.GetInt64("order_id")
  3012. admin_user_id, _ := c.GetInt64("admin_user_id")
  3013. order, _ := service.GetHisOrderByIDTwo(order_id)
  3014. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  3015. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3016. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  3017. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3018. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  3019. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3020. if order.ID == 0 {
  3021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3022. return
  3023. }
  3024. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  3025. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  3026. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  3027. fmt.Println(count)
  3028. var zero string
  3029. number := count + 1
  3030. if number >= 1000 {
  3031. zero = "0000" + strconv.FormatInt(number, 10)
  3032. } else if number >= 10000 {
  3033. zero = "000" + strconv.FormatInt(number, 10)
  3034. } else if number >= 100000 {
  3035. zero = "00" + strconv.FormatInt(number, 10)
  3036. } else if number >= 1000000 {
  3037. zero = "0" + strconv.FormatInt(number, 10)
  3038. } else {
  3039. zero = strconv.FormatInt(number, 10)
  3040. }
  3041. fmt.Println(zero)
  3042. struct4101 := service.Struct4101{
  3043. PsnNo: order.PsnNo,
  3044. MdtrtId: order.MdtrtId,
  3045. SetlId: order.SetlId,
  3046. PsnName: order.PsnName,
  3047. Gend: order.Gend,
  3048. Brdy: his.Brdy,
  3049. Age: int64(order.Age),
  3050. Naty: order.Naty,
  3051. PatnCertType: "01",
  3052. Certno: order.Certno,
  3053. Prfs: "90",
  3054. ConerName: roles[0].UserName,
  3055. PatnRlts: "99",
  3056. ConerAddr: miConfig.OrgName,
  3057. ConerTel: admin.Mobile,
  3058. HiType: order.Insutype,
  3059. Insuplc: miConfig.InsuplcAdmdvs,
  3060. MaindiagFlag: "1",
  3061. BillCode: order.FaPiaoNumber,
  3062. BillNo: order.FaPiaoNumber,
  3063. BizSn: order.Number,
  3064. PsnSelfPay: order.PsnPartAmt,
  3065. PsnOwnPay: order.PsnPartAmt,
  3066. AcctPay: order.AcctPay,
  3067. PsnCashpay: order.PsnCashPay,
  3068. HiPaymtd: "1",
  3069. Hsorg: miConfig.InsuplcAdmdvs,
  3070. HsorgOpter: miConfig.InsuplcAdmdvs,
  3071. MedinsFillPsn: curRoles.UserName,
  3072. MedinsFillDept: depart.Name,
  3073. IptMedType: "2",
  3074. AdmTime: his.InHosptialTime,
  3075. AdmEndTime: his.OutHosptialTime,
  3076. }
  3077. struct4101.SetlBegnDate = order.SetlTime
  3078. struct4101.SetlEndDate = order.SetlTime
  3079. var rf []CustomFundPay
  3080. json.Unmarshal([]byte(order.SetlDetail), &rf)
  3081. var tempFunPays []service.CustomStruct
  3082. for _, item := range rf {
  3083. var tempFunPay service.CustomStruct
  3084. tempFunPay.FundPayamt = item.FundPayamt
  3085. tempFunPay.FundPayType = item.FundPayType
  3086. tempFunPays = append(tempFunPays, tempFunPay)
  3087. }
  3088. struct4101.CustomStruct = tempFunPays
  3089. var tempDiaginfos []service.DiaginfoStructTwo
  3090. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3091. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3092. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3093. var config []*models.HisXtDiagnoseConfig
  3094. for _, item := range diagnosis_ids {
  3095. id, _ := strconv.ParseInt(item, 10, 64)
  3096. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3097. config = append(config, &diagnosisConfig)
  3098. }
  3099. for index, item := range config {
  3100. if index == 0 {
  3101. var tempDiaginfo service.DiaginfoStructTwo
  3102. tempDiaginfo.DiagCode = item.CountryCode
  3103. tempDiaginfo.DiagName = item.CountryContentName
  3104. tempDiaginfo.DiagType = "1"
  3105. tempDiaginfo.MaindiagFlag = "1"
  3106. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3107. } else {
  3108. var tempDiaginfo service.DiaginfoStructTwo
  3109. tempDiaginfo.DiagCode = item.CountryCode
  3110. tempDiaginfo.DiagName = item.CountryContentName
  3111. tempDiaginfo.DiagType = "2"
  3112. tempDiaginfo.MaindiagFlag = "0"
  3113. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3114. }
  3115. }
  3116. struct4101.Diseinfo = tempDiaginfos
  3117. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3118. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3119. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3120. tempOpspdiseinfo2.OprnOprtCode = ""
  3121. tempOpspdiseinfo2.OprnOprtName = ""
  3122. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3123. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3124. var iteminfo service.IteminfoStruct
  3125. var bedCostTotal float64 = 0 //床位总费
  3126. var bedCostSelfTotal float64 = 0 //床位自费
  3127. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3128. var operationCostTotal float64 = 0 //手术费
  3129. var operationCostSelfTotal float64 = 0 //手术费
  3130. var operationCostPartSelfTotal float64 = 0 //手术费
  3131. var otherCostTotal float64 = 0 //其他费用
  3132. var otherCostSelfTotal float64 = 0 //其他费用
  3133. var otherCostPartSelfTotal float64 = 0 //其他费用
  3134. var materialCostTotal float64 = 0 //材料费
  3135. var materialCostSelfTotal float64 = 0 //材料费
  3136. var materialCostPartSelfTotal float64 = 0 //材料费
  3137. var westernMedicineCostTotal float64 = 0 //西药费
  3138. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3139. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3140. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3141. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3142. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3143. var checkCostTotal float64 = 0 //检查费
  3144. var checkCostSelfTotal float64 = 0 //检查费
  3145. var checkCostPartSelfTotal float64 = 0 //检查费
  3146. var laboratoryCostTotal float64 = 0 //化验费
  3147. var laboratoryCostSelfTotal float64 = 0 //化验费
  3148. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3149. var treatCostTotal float64 = 0 //治疗费用
  3150. var treatCostSelfTotal float64 = 0 //治疗费用
  3151. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3152. decimal.DivisionPrecision = 2
  3153. var bed_fulamt_ownpay_amt float64 = 0
  3154. var operation_fulamt_ownpay_amt float64 = 0
  3155. var other_fulamt_ownpay_amt float64 = 0
  3156. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3157. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3158. var check_fulamt_ownpay_amt float64 = 0
  3159. var material_fulamt_ownpay_amt float64 = 0
  3160. var laboratory_fulamt_ownpay_amt float64 = 0
  3161. var treat_fulamt_ownpay_amt float64 = 0
  3162. var bed_claa_sunmfee float64 = 0
  3163. var bed_clab_amt float64 = 0
  3164. var bed_other_amt float64 = 0
  3165. var operation_claa_sunmfee float64 = 0
  3166. var operation_clab_amt float64 = 0
  3167. var operation_other_amt float64 = 0
  3168. var other_claa_sunmfee float64 = 0
  3169. var other_clab_amt float64 = 0
  3170. var other_other_amt float64 = 0
  3171. var westernMedicine_claa_sunmfee float64 = 0
  3172. var westernMedicine_clab_amt float64 = 0
  3173. var westernMedicine_other_amt float64 = 0
  3174. var chineseTraditional_claa_sunmfee float64 = 0
  3175. var chineseTraditional_clab_amt float64 = 0
  3176. var chineseTraditional_other_amt float64 = 0
  3177. var check_claa_sunmfee float64 = 0
  3178. var check_clab_amt float64 = 0
  3179. var check_other_amt float64 = 0
  3180. var material_claa_sunmfee float64 = 0
  3181. var material_clab_amt float64 = 0
  3182. var material_other_amt float64 = 0
  3183. var laboratory_claa_sunmfee float64 = 0
  3184. var laboratory_clab_amt float64 = 0
  3185. var laboratory_other_amt float64 = 0
  3186. var treat_claa_sunmfee float64 = 0
  3187. var treat_clab_amt float64 = 0
  3188. var treat_other_amt float64 = 0
  3189. for _, item := range order.HisOrderInfo {
  3190. if item.MedChrgitmType == "01" { //床位费
  3191. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3192. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3193. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3194. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3195. if item.ChrgitmLv == "1" {
  3196. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3197. }
  3198. if item.ChrgitmLv == "2" {
  3199. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3200. }
  3201. if item.ChrgitmLv == "3" {
  3202. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3203. }
  3204. }
  3205. if item.MedChrgitmType == "03" { //检查费
  3206. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3207. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3208. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3209. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3210. if item.ChrgitmLv == "1" {
  3211. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3212. }
  3213. if item.ChrgitmLv == "2" {
  3214. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3215. }
  3216. if item.ChrgitmLv == "3" {
  3217. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3218. }
  3219. }
  3220. if item.MedChrgitmType == "04" { //化验费
  3221. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3222. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3223. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3224. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3225. if item.ChrgitmLv == "1" {
  3226. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3227. }
  3228. if item.ChrgitmLv == "2" {
  3229. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3230. }
  3231. if item.ChrgitmLv == "3" {
  3232. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3233. }
  3234. }
  3235. if item.MedChrgitmType == "05" { //治疗费
  3236. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3237. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3238. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3239. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3240. if item.ChrgitmLv == "1" {
  3241. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3242. }
  3243. if item.ChrgitmLv == "2" {
  3244. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3245. }
  3246. if item.ChrgitmLv == "3" {
  3247. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3248. }
  3249. }
  3250. if item.MedChrgitmType == "06" { //手术费
  3251. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3252. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3253. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3254. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3255. if item.ChrgitmLv == "1" {
  3256. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3257. }
  3258. if item.ChrgitmLv == "2" {
  3259. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3260. }
  3261. if item.ChrgitmLv == "3" {
  3262. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3263. }
  3264. }
  3265. if item.MedChrgitmType == "08" { //材料费
  3266. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3267. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3268. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3269. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3270. if item.ChrgitmLv == "1" {
  3271. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3272. }
  3273. if item.ChrgitmLv == "2" {
  3274. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3275. }
  3276. if item.ChrgitmLv == "3" {
  3277. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3278. }
  3279. }
  3280. if item.MedChrgitmType == "09" { //西药费
  3281. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3282. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3283. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3284. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3285. if item.ChrgitmLv == "1" {
  3286. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3287. }
  3288. if item.ChrgitmLv == "2" {
  3289. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3290. }
  3291. if item.ChrgitmLv == "3" {
  3292. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3293. }
  3294. }
  3295. if item.MedChrgitmType == "11" { //中成费
  3296. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3297. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3298. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3299. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3300. if item.ChrgitmLv == "1" {
  3301. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3302. }
  3303. if item.ChrgitmLv == "2" {
  3304. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3305. }
  3306. if item.ChrgitmLv == "3" {
  3307. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3308. }
  3309. }
  3310. if item.MedChrgitmType == "14" { //其他费
  3311. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3312. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3313. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3314. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3315. if item.ChrgitmLv == "1" {
  3316. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3317. }
  3318. if item.ChrgitmLv == "2" {
  3319. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3320. }
  3321. if item.ChrgitmLv == "3" {
  3322. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3323. }
  3324. }
  3325. }
  3326. var iteminfoStructs []service.IteminfoStruct
  3327. if bedCostTotal != 0 {
  3328. iteminfo.MedChrgitm = "01"
  3329. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3330. iteminfo.Amt = bedCostTotal
  3331. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3332. iteminfo.ClabAmt = bed_clab_amt
  3333. iteminfo.OthAmt = bed_other_amt
  3334. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3335. }
  3336. if checkCostTotal != 0 {
  3337. iteminfo.MedChrgitm = "03"
  3338. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3339. iteminfo.Amt = checkCostTotal
  3340. iteminfo.ClaaSumfee = check_claa_sunmfee
  3341. iteminfo.ClabAmt = check_clab_amt
  3342. iteminfo.OthAmt = check_other_amt
  3343. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3344. }
  3345. if laboratoryCostTotal != 0 {
  3346. iteminfo.MedChrgitm = "04"
  3347. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3348. iteminfo.Amt = laboratoryCostTotal
  3349. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3350. iteminfo.ClabAmt = laboratory_clab_amt
  3351. iteminfo.OthAmt = laboratory_other_amt
  3352. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3353. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3354. }
  3355. if treatCostTotal != 0 {
  3356. iteminfo.MedChrgitm = "05"
  3357. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3358. iteminfo.Amt = treatCostTotal
  3359. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3360. iteminfo.ClabAmt = treat_clab_amt
  3361. iteminfo.OthAmt = treat_other_amt
  3362. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3363. //(struct4101.IteminfoStruct, iteminfo)
  3364. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3365. }
  3366. if operationCostTotal != 0 {
  3367. iteminfo.MedChrgitm = "06"
  3368. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3369. iteminfo.Amt = operationCostTotal
  3370. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3371. iteminfo.ClabAmt = operation_clab_amt
  3372. iteminfo.OthAmt = operation_other_amt
  3373. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3374. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3375. }
  3376. if materialCostTotal != 0 {
  3377. iteminfo.MedChrgitm = "08"
  3378. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3379. iteminfo.Amt = materialCostTotal
  3380. iteminfo.ClaaSumfee = material_claa_sunmfee
  3381. iteminfo.ClabAmt = material_clab_amt
  3382. iteminfo.OthAmt = material_other_amt
  3383. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3384. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3385. }
  3386. if westernMedicineCostTotal != 0 {
  3387. iteminfo.MedChrgitm = "09"
  3388. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3389. iteminfo.Amt = westernMedicineCostTotal
  3390. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3391. iteminfo.ClabAmt = westernMedicine_clab_amt
  3392. iteminfo.OthAmt = westernMedicine_other_amt
  3393. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3394. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3395. }
  3396. if chineseTraditionalMedicineCostTotal != 0 {
  3397. iteminfo.MedChrgitm = "11"
  3398. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3399. iteminfo.Amt = westernMedicineCostTotal
  3400. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3401. iteminfo.ClabAmt = westernMedicine_clab_amt
  3402. iteminfo.OthAmt = westernMedicine_other_amt
  3403. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3404. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3405. }
  3406. if otherCostTotal != 0 {
  3407. iteminfo.MedChrgitm = "14"
  3408. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3409. iteminfo.Amt = otherCostTotal
  3410. iteminfo.ClaaSumfee = other_claa_sunmfee
  3411. iteminfo.ClabAmt = other_clab_amt
  3412. iteminfo.OthAmt = other_other_amt
  3413. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3414. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3415. }
  3416. struct4101.IteminfoStruct = iteminfoStructs
  3417. struct4101.Ntly = "中国"
  3418. struct4101.AdmCaty = "A03.06"
  3419. var resOther ResultSeventeenOther
  3420. var res ResultSeventeen
  3421. if miConfig.MdtrtareaAdmvs == "150499" {
  3422. var pp models.PublicParams
  3423. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3424. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3425. pp.FixmedinsName = miConfig.OrgName
  3426. pp.FixmedinsCode = miConfig.Code
  3427. pp.RequestUrl = miConfig.Url
  3428. pp.Cainfo = miConfig.Cainfo
  3429. pp.SecretKey = miConfig.SecretKey
  3430. pp.AccessKey = miConfig.AccessKey
  3431. pp.OpterName = curRoles.UserName
  3432. client := &http.Client{}
  3433. var req *http.Request
  3434. data := make(map[string]interface{})
  3435. data["struct4101"] = struct4101
  3436. data["pp"] = pp
  3437. bytesData, _ := json.Marshal(data)
  3438. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  3439. resp, _ := client.Do(req)
  3440. defer resp.Body.Close()
  3441. body, ioErr := ioutil.ReadAll(resp.Body)
  3442. if ioErr != nil {
  3443. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3445. return
  3446. }
  3447. var respJSON map[string]interface{}
  3448. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3449. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3451. return
  3452. }
  3453. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3454. userJSONBytes, _ := json.Marshal(respJSON)
  3455. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  3456. utils.ErrorLog("解析失败:%v", err)
  3457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3458. return
  3459. }
  3460. res.InfRefmsgid = resOther.InfRefmsgid
  3461. res.Output = resOther.Output
  3462. res.ErrMsg = resOther.ErrMsg
  3463. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  3464. res.Infcode = infocode
  3465. } else {
  3466. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  3467. var dat map[string]interface{}
  3468. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3469. fmt.Println(dat)
  3470. } else {
  3471. fmt.Println(err)
  3472. }
  3473. userJSONBytes, _ := json.Marshal(dat)
  3474. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3475. utils.ErrorLog("解析失败:%v", err)
  3476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3477. return
  3478. }
  3479. }
  3480. if res.Infcode != 0 {
  3481. c.ServeSuccessJSON(map[string]interface{}{
  3482. "failed_code": -10,
  3483. "msg": res.ErrMsg,
  3484. })
  3485. return
  3486. } else {
  3487. if miConfig.MdtrtareaAdmvs != "150499" {
  3488. order.FaPiaoNumber = zero
  3489. order.FaPiaoCode = last_order.FaPiaoCode
  3490. service.UpdateOrder(order)
  3491. }
  3492. hisFundSettleListResult := &models.HisFundSettleListResult{
  3493. Number: res.Output.SetlListId,
  3494. Status: 1,
  3495. Ctime: time.Now().Unix(),
  3496. Mtime: time.Now().Unix(),
  3497. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3498. IsUpload: 1,
  3499. OrderId: order_id,
  3500. }
  3501. service.CreateUploadRecord(hisFundSettleListResult)
  3502. c.ServeSuccessJSON(map[string]interface{}{
  3503. "msg": "上传成功",
  3504. "result": hisFundSettleListResult,
  3505. })
  3506. return
  3507. }
  3508. }
  3509. func (c *HisApiController) GetBatchSettleList() {
  3510. orders, _ := service.GetAllHisOrderErr(10106, 101060)
  3511. for _, item := range orders {
  3512. order_id := item.PatientId
  3513. order, _ := service.GetHisOrderByIDTwo(order_id)
  3514. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  3515. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3516. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  3517. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  3518. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  3519. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3520. if order.ID == 0 {
  3521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3522. return
  3523. }
  3524. if his.BalanceAccountsType == 2 {
  3525. continue
  3526. }
  3527. struct4101 := service.Struct4101{
  3528. PsnNo: order.PsnNo,
  3529. MdtrtId: order.MdtrtId,
  3530. SetlId: order.SetlId,
  3531. PsnName: order.PsnName,
  3532. Gend: order.Gend,
  3533. Brdy: his.Brdy,
  3534. Age: his.Age,
  3535. Naty: order.Naty,
  3536. PatnCertType: "01",
  3537. Certno: order.Certno,
  3538. Prfs: "90",
  3539. ConerName: roles[0].UserName,
  3540. PatnRlts: "99",
  3541. ConerAddr: miConfig.OrgName,
  3542. ConerTel: admin.Mobile,
  3543. HiType: order.Insutype,
  3544. Insuplc: his.InsuplcAdmdvs,
  3545. MaindiagFlag: "1",
  3546. BillCode: order.SetlId,
  3547. BillNo: order.SetlId,
  3548. BizSn: order.Number,
  3549. PsnSelfPay: order.PsnPartAmt,
  3550. PsnOwnPay: order.PsnPartAmt,
  3551. AcctPay: order.AcctPay,
  3552. PsnCashpay: order.PsnCashPay,
  3553. HiPaymtd: "1",
  3554. Hsorg: his.InsuplcAdmdvs,
  3555. HsorgOpter: his.InsuplcAdmdvs,
  3556. MedinsFillPsn: curRoles.UserName,
  3557. MedinsFillDept: depart.Name,
  3558. IptMedType: "2",
  3559. }
  3560. struct4101.SetlBegnDate = order.SetlTime
  3561. struct4101.SetlEndDate = order.SetlTime
  3562. //if order.SettleType == 1 {
  3563. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  3564. // dateStr := t.Format("2006-01-02")
  3565. // struct4101.SetlBegnDate = dateStr
  3566. // struct4101.SetlEndDate = dateStr
  3567. //} else {
  3568. // t := time.Unix(int64(order.SettleStartTime), 0)
  3569. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  3570. // dateStartStr := t.Format("2006-01-02")
  3571. // dateEndStr := t2.Format("2006-01-02")
  3572. // struct4101.SetlBegnDate = dateStartStr
  3573. // struct4101.SetlEndDate = dateEndStr
  3574. //}
  3575. var rf []CustomFundPay
  3576. json.Unmarshal([]byte(order.SetlDetail), &rf)
  3577. var tempFunPays []service.CustomStruct
  3578. var tempFunPay610100 service.CustomStruct
  3579. for _, item := range rf {
  3580. if item.FundPayType == "610100" {
  3581. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  3582. tempFunPay610100.FundPayType = item.FundPayType
  3583. } else {
  3584. var tempFunPay service.CustomStruct
  3585. tempFunPay.FundPayamt = item.FundPayamt
  3586. tempFunPay.FundPayType = item.FundPayType
  3587. tempFunPays = append(tempFunPays, tempFunPay)
  3588. }
  3589. }
  3590. tempFunPays = append(tempFunPays, tempFunPay610100)
  3591. struct4101.CustomStruct = tempFunPays
  3592. var tempDiaginfos []service.DiaginfoStructTwo
  3593. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3594. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3595. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3596. var config []*models.HisXtDiagnoseConfig
  3597. for _, item := range diagnosis_ids {
  3598. id, _ := strconv.ParseInt(item, 10, 64)
  3599. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3600. config = append(config, &diagnosisConfig)
  3601. }
  3602. for index, item := range config {
  3603. if index == 0 {
  3604. var tempDiaginfo service.DiaginfoStructTwo
  3605. tempDiaginfo.DiagCode = item.CountryCode
  3606. tempDiaginfo.DiagName = item.CountryContentName
  3607. tempDiaginfo.DiagType = "1"
  3608. tempDiaginfo.MaindiagFlag = "1"
  3609. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3610. } else {
  3611. var tempDiaginfo service.DiaginfoStructTwo
  3612. tempDiaginfo.DiagCode = item.CountryCode
  3613. tempDiaginfo.DiagName = item.CountryContentName
  3614. tempDiaginfo.DiagType = "2"
  3615. tempDiaginfo.MaindiagFlag = "0"
  3616. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3617. }
  3618. }
  3619. struct4101.Diseinfo = tempDiaginfos
  3620. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3621. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3622. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3623. tempOpspdiseinfo2.OprnOprtCode = ""
  3624. tempOpspdiseinfo2.OprnOprtName = ""
  3625. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3626. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3627. var iteminfo service.IteminfoStruct
  3628. var bedCostTotal float64 = 0 //床位总费
  3629. var bedCostSelfTotal float64 = 0 //床位自费
  3630. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3631. var examineCostTotal float64 = 0 //诊查总费
  3632. var examineCostSelfTotal float64 = 0 //诊查自费
  3633. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  3634. var nursingCostTotal float64 = 0 //护理总费
  3635. var nursingCostSelfTotal float64 = 0 //护理自费
  3636. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  3637. var chineseMedicineCostTotal float64 = 0 //中成药
  3638. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  3639. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  3640. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  3641. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  3642. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  3643. var registerCostTotal float64 = 0 //一般诊疗费
  3644. var registerCostSelfTotal float64 = 0 //一般诊疗费
  3645. var registerPartSelfTotal float64 = 0 //一般诊疗费
  3646. var operationCostTotal float64 = 0 //手术费
  3647. var operationCostSelfTotal float64 = 0 //手术费
  3648. var operationCostPartSelfTotal float64 = 0 //手术费
  3649. var otherCostTotal float64 = 0 //其他费用
  3650. var otherCostSelfTotal float64 = 0 //其他费用
  3651. var otherCostPartSelfTotal float64 = 0 //其他费用
  3652. var materialCostTotal float64 = 0 //材料费
  3653. var materialCostSelfTotal float64 = 0 //材料费
  3654. var materialCostPartSelfTotal float64 = 0 //材料费
  3655. var westernMedicineCostTotal float64 = 0 //西药费
  3656. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3657. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3658. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3659. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3660. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3661. var checkCostTotal float64 = 0 //检查费
  3662. var checkCostSelfTotal float64 = 0 //检查费
  3663. var checkCostPartSelfTotal float64 = 0 //检查费
  3664. var laboratoryCostTotal float64 = 0 //化验费
  3665. var laboratoryCostSelfTotal float64 = 0 //化验费
  3666. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3667. var treatCostTotal float64 = 0 //治疗费用
  3668. var treatCostSelfTotal float64 = 0 //治疗费用
  3669. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3670. decimal.DivisionPrecision = 2
  3671. var bed_fulamt_ownpay_amt float64 = 0
  3672. var examine_fulamt_ownpay_amt float64 = 0
  3673. var nursing_fulamt_ownpay_amt float64 = 0
  3674. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  3675. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  3676. var register_fulamt_ownpay_amt float64 = 0
  3677. var operation_fulamt_ownpay_amt float64 = 0
  3678. var other_fulamt_ownpay_amt float64 = 0
  3679. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3680. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3681. var check_fulamt_ownpay_amt float64 = 0
  3682. var material_fulamt_ownpay_amt float64 = 0
  3683. var laboratory_fulamt_ownpay_amt float64 = 0
  3684. var treat_fulamt_ownpay_amt float64 = 0
  3685. var bed_claa_sunmfee float64 = 0
  3686. var bed_clab_amt float64 = 0
  3687. var bed_other_amt float64 = 0
  3688. var examine_claa_sunmfee float64 = 0
  3689. var examine_clab_amt float64 = 0
  3690. var examine_other_amt float64 = 0
  3691. var nursing_claa_sunmfee float64 = 0
  3692. var nursing_clab_amt float64 = 0
  3693. var nursing_other_amt float64 = 0
  3694. var chinese_medicine_claa_sunmfee float64 = 0
  3695. var chinese_medicine_clab_amt float64 = 0
  3696. var chinese_medicine_other_amt float64 = 0
  3697. var commonly_treatment_claa_sunmfee float64 = 0
  3698. var commonly_treatment_clab_amt float64 = 0
  3699. var commonly_treatment_other_amt float64 = 0
  3700. var operation_claa_sunmfee float64 = 0
  3701. var operation_clab_amt float64 = 0
  3702. var operation_other_amt float64 = 0
  3703. var other_claa_sunmfee float64 = 0
  3704. var other_clab_amt float64 = 0
  3705. var other_other_amt float64 = 0
  3706. var westernMedicine_claa_sunmfee float64 = 0
  3707. var westernMedicine_clab_amt float64 = 0
  3708. var westernMedicine_other_amt float64 = 0
  3709. var chineseTraditional_claa_sunmfee float64 = 0
  3710. var chineseTraditional_clab_amt float64 = 0
  3711. var chineseTraditional_other_amt float64 = 0
  3712. var check_claa_sunmfee float64 = 0
  3713. var check_clab_amt float64 = 0
  3714. var check_other_amt float64 = 0
  3715. var material_claa_sunmfee float64 = 0
  3716. var material_clab_amt float64 = 0
  3717. var material_other_amt float64 = 0
  3718. var laboratory_claa_sunmfee float64 = 0
  3719. var laboratory_clab_amt float64 = 0
  3720. var laboratory_other_amt float64 = 0
  3721. var treat_claa_sunmfee float64 = 0
  3722. var treat_clab_amt float64 = 0
  3723. var treat_other_amt float64 = 0
  3724. var register_claa_sunmfee float64 = 0
  3725. var register_clab_amt float64 = 0
  3726. var register_other_amt float64 = 0
  3727. for _, item := range order.HisOrderInfo {
  3728. if item.MedChrgitmType == "01" { //床位费
  3729. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3730. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3731. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3732. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3733. if item.ChrgitmLv == "1" {
  3734. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3735. }
  3736. if item.ChrgitmLv == "2" {
  3737. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3738. }
  3739. if item.ChrgitmLv == "3" {
  3740. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3741. }
  3742. }
  3743. if item.MedChrgitmType == "02" { //诊查
  3744. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3745. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3746. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3747. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3748. if item.ChrgitmLv == "1" {
  3749. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3750. }
  3751. if item.ChrgitmLv == "2" {
  3752. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3753. }
  3754. if item.ChrgitmLv == "3" {
  3755. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3756. }
  3757. }
  3758. if item.MedChrgitmType == "03" { //检查费
  3759. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3760. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3761. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3762. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3763. if item.ChrgitmLv == "1" {
  3764. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3765. }
  3766. if item.ChrgitmLv == "2" {
  3767. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3768. }
  3769. if item.ChrgitmLv == "3" {
  3770. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3771. }
  3772. }
  3773. if item.MedChrgitmType == "04" { //化验费
  3774. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3775. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3776. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3777. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3778. if item.ChrgitmLv == "1" {
  3779. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3780. }
  3781. if item.ChrgitmLv == "2" {
  3782. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3783. }
  3784. if item.ChrgitmLv == "3" {
  3785. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3786. }
  3787. }
  3788. if item.MedChrgitmType == "05" { //治疗费
  3789. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3790. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3791. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3792. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3793. if item.ChrgitmLv == "1" {
  3794. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3795. }
  3796. if item.ChrgitmLv == "2" {
  3797. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3798. }
  3799. if item.ChrgitmLv == "3" {
  3800. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3801. }
  3802. }
  3803. if item.MedChrgitmType == "06" { //手术费
  3804. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3805. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3806. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3807. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3808. if item.ChrgitmLv == "1" {
  3809. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3810. }
  3811. if item.ChrgitmLv == "2" {
  3812. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3813. }
  3814. if item.ChrgitmLv == "3" {
  3815. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3816. }
  3817. }
  3818. if item.MedChrgitmType == "07" { //手术费
  3819. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3820. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3821. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3822. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3823. if item.ChrgitmLv == "1" {
  3824. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3825. }
  3826. if item.ChrgitmLv == "2" {
  3827. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3828. }
  3829. if item.ChrgitmLv == "3" {
  3830. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3831. }
  3832. }
  3833. if item.MedChrgitmType == "08" { //材料费
  3834. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3835. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3836. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3837. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3838. if item.ChrgitmLv == "1" {
  3839. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3840. }
  3841. if item.ChrgitmLv == "2" {
  3842. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3843. }
  3844. if item.ChrgitmLv == "3" {
  3845. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3846. }
  3847. }
  3848. if item.MedChrgitmType == "09" { //西药费
  3849. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3850. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3851. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3852. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3853. if item.ChrgitmLv == "1" {
  3854. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3855. }
  3856. if item.ChrgitmLv == "2" {
  3857. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3858. }
  3859. if item.ChrgitmLv == "3" {
  3860. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3861. }
  3862. }
  3863. if item.MedChrgitmType == "10" { //中药饮片
  3864. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3865. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3866. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3867. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3868. if item.ChrgitmLv == "1" {
  3869. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3870. }
  3871. if item.ChrgitmLv == "2" {
  3872. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3873. }
  3874. if item.ChrgitmLv == "3" {
  3875. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3876. }
  3877. }
  3878. if item.MedChrgitmType == "11" { //中成费
  3879. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3880. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3881. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3882. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3883. if item.ChrgitmLv == "1" {
  3884. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3885. }
  3886. if item.ChrgitmLv == "2" {
  3887. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3888. }
  3889. if item.ChrgitmLv == "3" {
  3890. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3891. }
  3892. }
  3893. if item.MedChrgitmType == "12" { //中成费
  3894. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3895. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3896. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3897. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3898. if item.ChrgitmLv == "1" {
  3899. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3900. }
  3901. if item.ChrgitmLv == "2" {
  3902. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3903. }
  3904. if item.ChrgitmLv == "3" {
  3905. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3906. }
  3907. }
  3908. if item.MedChrgitmType == "13" { //中成费
  3909. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3910. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3911. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3912. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3913. if item.ChrgitmLv == "1" {
  3914. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3915. }
  3916. if item.ChrgitmLv == "2" {
  3917. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3918. }
  3919. if item.ChrgitmLv == "3" {
  3920. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3921. }
  3922. }
  3923. if item.MedChrgitmType == "14" { //其他费
  3924. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3925. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3926. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3927. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3928. if item.ChrgitmLv == "1" {
  3929. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3930. }
  3931. if item.ChrgitmLv == "2" {
  3932. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3933. }
  3934. if item.ChrgitmLv == "3" {
  3935. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3936. }
  3937. }
  3938. }
  3939. var iteminfoStructs []service.IteminfoStruct
  3940. if bedCostTotal != 0 {
  3941. iteminfo.MedChrgitm = "01"
  3942. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3943. iteminfo.Amt = bedCostTotal
  3944. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3945. iteminfo.ClabAmt = bed_clab_amt
  3946. iteminfo.OthAmt = bed_other_amt
  3947. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3948. }
  3949. if examineCostTotal != 0 {
  3950. iteminfo.MedChrgitm = "02"
  3951. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3952. iteminfo.Amt = examineCostTotal
  3953. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3954. iteminfo.ClabAmt = examine_clab_amt
  3955. iteminfo.OthAmt = examine_other_amt
  3956. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3957. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3958. }
  3959. if checkCostTotal != 0 {
  3960. iteminfo.MedChrgitm = "03"
  3961. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3962. iteminfo.Amt = checkCostTotal
  3963. iteminfo.ClaaSumfee = check_claa_sunmfee
  3964. iteminfo.ClabAmt = check_clab_amt
  3965. iteminfo.OthAmt = check_other_amt
  3966. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3967. }
  3968. if laboratoryCostTotal != 0 {
  3969. iteminfo.MedChrgitm = "04"
  3970. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3971. iteminfo.Amt = laboratoryCostTotal
  3972. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3973. iteminfo.ClabAmt = laboratory_clab_amt
  3974. iteminfo.OthAmt = laboratory_other_amt
  3975. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3976. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3977. }
  3978. if treatCostTotal != 0 {
  3979. iteminfo.MedChrgitm = "05"
  3980. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3981. iteminfo.Amt = treatCostTotal
  3982. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3983. iteminfo.ClabAmt = treat_clab_amt
  3984. iteminfo.OthAmt = treat_other_amt
  3985. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3986. //(struct4101.IteminfoStruct, iteminfo)
  3987. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3988. }
  3989. if operationCostTotal != 0 {
  3990. iteminfo.MedChrgitm = "06"
  3991. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3992. iteminfo.Amt = operationCostTotal
  3993. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3994. iteminfo.ClabAmt = operation_clab_amt
  3995. iteminfo.OthAmt = operation_other_amt
  3996. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3997. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3998. }
  3999. if nursingCostTotal != 0 {
  4000. iteminfo.MedChrgitm = "07"
  4001. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  4002. iteminfo.Amt = nursingCostTotal
  4003. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  4004. iteminfo.ClabAmt = nursing_clab_amt
  4005. iteminfo.OthAmt = nursing_other_amt
  4006. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4007. }
  4008. if materialCostTotal != 0 {
  4009. iteminfo.MedChrgitm = "08"
  4010. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  4011. iteminfo.Amt = materialCostTotal
  4012. iteminfo.ClaaSumfee = material_claa_sunmfee
  4013. iteminfo.ClabAmt = material_clab_amt
  4014. iteminfo.OthAmt = material_other_amt
  4015. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4016. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4017. }
  4018. if westernMedicineCostTotal != 0 {
  4019. iteminfo.MedChrgitm = "09"
  4020. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4021. iteminfo.Amt = westernMedicineCostTotal
  4022. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4023. iteminfo.ClabAmt = westernMedicine_clab_amt
  4024. iteminfo.OthAmt = westernMedicine_other_amt
  4025. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4026. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4027. }
  4028. if chineseMedicineCostTotal != 0 {
  4029. iteminfo.MedChrgitm = "10"
  4030. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  4031. iteminfo.Amt = chineseMedicineCostTotal
  4032. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  4033. iteminfo.ClabAmt = chinese_medicine_clab_amt
  4034. iteminfo.OthAmt = chinese_medicine_other_amt
  4035. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4036. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4037. }
  4038. if chineseTraditionalMedicineCostTotal != 0 {
  4039. iteminfo.MedChrgitm = "11"
  4040. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4041. iteminfo.Amt = westernMedicineCostTotal
  4042. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4043. iteminfo.ClabAmt = westernMedicine_clab_amt
  4044. iteminfo.OthAmt = westernMedicine_other_amt
  4045. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4046. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4047. }
  4048. if commonlyTreatmentCostTotal != 0 {
  4049. iteminfo.MedChrgitm = "12"
  4050. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  4051. iteminfo.Amt = commonlyTreatmentCostTotal
  4052. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  4053. iteminfo.ClabAmt = commonly_treatment_clab_amt
  4054. iteminfo.OthAmt = commonly_treatment_other_amt
  4055. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4056. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4057. }
  4058. if registerCostTotal != 0 {
  4059. iteminfo.MedChrgitm = "13"
  4060. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  4061. iteminfo.Amt = registerCostTotal
  4062. iteminfo.ClaaSumfee = register_claa_sunmfee
  4063. iteminfo.ClabAmt = register_clab_amt
  4064. iteminfo.OthAmt = register_other_amt
  4065. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4066. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4067. }
  4068. if otherCostTotal != 0 {
  4069. iteminfo.MedChrgitm = "14"
  4070. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  4071. iteminfo.Amt = otherCostTotal
  4072. iteminfo.ClaaSumfee = other_claa_sunmfee
  4073. iteminfo.ClabAmt = other_clab_amt
  4074. iteminfo.OthAmt = other_other_amt
  4075. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4076. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4077. }
  4078. struct4101.IteminfoStruct = iteminfoStructs
  4079. struct4101.Ntly = "中国"
  4080. struct4101.AdmCaty = "A03.06"
  4081. var res ResultSeventeen
  4082. if miConfig.MdtrtareaAdmvs == "421300" {
  4083. data := make(map[string]interface{})
  4084. data["struct4101"] = struct4101
  4085. data["secret_key"] = miConfig.SecretKey
  4086. data["org_name"] = miConfig.OrgName
  4087. data["opera"] = curRoles.UserName
  4088. data["code"] = miConfig.Code
  4089. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4090. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4091. client := &http.Client{}
  4092. bytesData, _ := json.Marshal(data)
  4093. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  4094. resp, _ := client.Do(req)
  4095. defer resp.Body.Close()
  4096. body, ioErr := ioutil.ReadAll(resp.Body)
  4097. if ioErr != nil {
  4098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4100. return
  4101. }
  4102. var respJSON map[string]interface{}
  4103. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4104. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4106. return
  4107. }
  4108. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4109. userJSONBytes, _ := json.Marshal(respJSON)
  4110. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4111. utils.ErrorLog("解析失败:%v", err)
  4112. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4113. adminUser := c.GetAdminUserInfo()
  4114. errlog := &models.HisOrderError{
  4115. UserOrgId: adminUser.CurrentOrgId,
  4116. Ctime: time.Now().Unix(),
  4117. Mtime: time.Now().Unix(),
  4118. ErrMsg: res.ErrMsg + "解析失败",
  4119. Status: 1,
  4120. PatientId: order_id,
  4121. Stage: 10088,
  4122. }
  4123. service.CreateErrMsgLog(errlog)
  4124. continue
  4125. }
  4126. } else {
  4127. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  4128. fmt.Println(result)
  4129. var dat map[string]interface{}
  4130. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4131. fmt.Println(dat)
  4132. } else {
  4133. fmt.Println(err)
  4134. }
  4135. userJSONBytes, _ := json.Marshal(dat)
  4136. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4137. utils.ErrorLog("解析失败:%v", err)
  4138. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4139. adminUser := c.GetAdminUserInfo()
  4140. errlog := &models.HisOrderError{
  4141. UserOrgId: adminUser.CurrentOrgId,
  4142. Ctime: time.Now().Unix(),
  4143. Mtime: time.Now().Unix(),
  4144. ErrMsg: res.ErrMsg + "解析失败",
  4145. Status: 1,
  4146. PatientId: order_id,
  4147. Stage: 10106,
  4148. }
  4149. service.CreateErrMsgLog(errlog)
  4150. continue
  4151. }
  4152. }
  4153. if res.Infcode != 0 {
  4154. adminUser := c.GetAdminUserInfo()
  4155. errlog := &models.HisOrderError{
  4156. UserOrgId: adminUser.CurrentOrgId,
  4157. Ctime: time.Now().Unix(),
  4158. Mtime: time.Now().Unix(),
  4159. ErrMsg: res.ErrMsg,
  4160. Status: 1,
  4161. PatientId: order_id,
  4162. Stage: 10106,
  4163. }
  4164. service.CreateErrMsgLog(errlog)
  4165. continue
  4166. } else {
  4167. hisFundSettleListResult := &models.HisFundSettleListResult{
  4168. Number: res.Output.SetlListId,
  4169. Status: 1,
  4170. Ctime: time.Now().Unix(),
  4171. Mtime: time.Now().Unix(),
  4172. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4173. IsUpload: 1,
  4174. OrderId: order_id,
  4175. }
  4176. service.CreateUploadRecord(hisFundSettleListResult)
  4177. continue
  4178. }
  4179. }
  4180. }
  4181. func (c *HisApiController) GetOrgInfo() {
  4182. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  4183. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  4184. }
  4185. func (c *HisApiController) GetHisPatientInfo() {
  4186. medical_insurance_card := c.GetString("medical_insurance_card")
  4187. id_card_type, _ := c.GetInt64("id_card_type")
  4188. id_card := c.GetString("id_card")
  4189. adminInfo := c.GetAdminUserInfo()
  4190. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4191. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4192. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  4193. IdCardNo := ""
  4194. if id_card_type == 1 {
  4195. IdCardNo = medical_insurance_card
  4196. } else if id_card_type == 2 {
  4197. IdCardNo = id_card
  4198. }
  4199. if config.IsOpen == 1 {
  4200. 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
  4201. resp, requestErr := http.Get(api)
  4202. if requestErr != nil {
  4203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4204. return
  4205. }
  4206. defer resp.Body.Close()
  4207. body, ioErr := ioutil.ReadAll(resp.Body)
  4208. if ioErr != nil {
  4209. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4211. return
  4212. }
  4213. var respJSON map[string]interface{}
  4214. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4217. return
  4218. }
  4219. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4220. userJSONBytes, _ := json.Marshal(userJSON)
  4221. var res ResultTwo
  4222. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4223. utils.ErrorLog("解析失败:%v", err)
  4224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4225. return
  4226. }
  4227. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4228. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4229. infoStr := string(Iinfos)
  4230. idetinfoStr := string(Idetinfos)
  4231. if res.Infcode == 0 {
  4232. his := models.VMHisPatient{
  4233. Status: 1,
  4234. Ctime: time.Now().Unix(),
  4235. Mtime: time.Now().Unix(),
  4236. PsnNo: res.Output.Baseinfo.PsnNo,
  4237. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4238. Certno: res.Output.Baseinfo.Certno,
  4239. PsnName: res.Output.Baseinfo.PsnName,
  4240. Gend: res.Output.Baseinfo.Gend,
  4241. Naty: res.Output.Baseinfo.Naty,
  4242. Brdy: res.Output.Baseinfo.Brdy,
  4243. Age: res.Output.Baseinfo.Age,
  4244. Iinfo: infoStr,
  4245. Idetinfo: idetinfoStr,
  4246. UserOrgId: adminInfo.CurrentOrgId,
  4247. IsReturn: 1,
  4248. IdCardType: id_card_type,
  4249. }
  4250. c.ServeSuccessJSON(map[string]interface{}{
  4251. "info": his,
  4252. })
  4253. } else {
  4254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4255. return
  4256. }
  4257. }
  4258. }
  4259. //func GetBasBaseInfo() (jsonStr string, err error) {
  4260. //
  4261. // handle := syscall.NewLazyDLL("SSCard.dll")
  4262. // add := handle.NewProc("ReadCardBas")
  4263. // str := make([]byte, 1024)
  4264. // str1 := make([]byte, 1024)
  4265. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  4266. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  4267. //
  4268. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  4269. //
  4270. // fmt.Println("> Add(4,5)的结果为:", ret)
  4271. // handle.Release()
  4272. //
  4273. // return "", nil
  4274. //
  4275. //}
  4276. //func GetQRBaseInfo() (jsonStr string, err error) {
  4277. // handle := syscall.LoadDLL("SSCard.dll")
  4278. // ReadCardBas := handle.FindProc("GetQRBase")
  4279. //
  4280. // str := make([]byte, 256)
  4281. // str1 := make([]byte, 256)
  4282. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  4283. //
  4284. // fmt.Println(string(str))
  4285. // fmt.Println(r)
  4286. // return string(str), nil
  4287. //}
  4288. //func CardInit() int {
  4289. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  4290. // add := DllTestDef.MustFindProc("Init")
  4291. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  4292. // if err != nil {
  4293. // fmt.Println("SSCard的运算结果为:", ret)
  4294. // }
  4295. // result := int(ret)
  4296. // return result
  4297. //}
  4298. //func CardInit() int {
  4299. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  4300. // if err != nil {
  4301. // fmt.Println("SSCard的运算结果为:", ret)
  4302. // }
  4303. // fmt.Println(err)
  4304. // result := int(ret)
  4305. // return result
  4306. //}
  4307. func IntPtr(n int) uintptr {
  4308. return uintptr(n)
  4309. }
  4310. func StrPtr(s string) uintptr {
  4311. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  4312. }
  4313. type Result2001 struct {
  4314. Cainfo interface{} `json:"cainfo"`
  4315. ErrMsg string `json:"err_msg"`
  4316. InfRefmsgid string `json:"inf_refmsgid"`
  4317. Infcode int64 `json:"infcode"`
  4318. Output struct {
  4319. Trtinfo struct {
  4320. PsnNo string `json:"psn_no"`
  4321. TrtChkType string `json:"trt_chk_type"`
  4322. FundPayType string `json:"fund_pay_type"`
  4323. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  4324. Begndate string `json:"begndate"`
  4325. Enddate string `json:"enddate"`
  4326. TrtChkRslt string `json:"trt_chk_rslt"`
  4327. } `json:"trtinfo"`
  4328. } `json:"output"`
  4329. RefmsgTime string `json:"refmsg_time"`
  4330. RespondTime string `json:"respond_time"`
  4331. Signtype interface{} `json:"signtype"`
  4332. WarnMsg interface{} `json:"warn_msg"`
  4333. }
  4334. type Result2001Org10265 struct {
  4335. Cainfo interface{} `json:"cainfo"`
  4336. ErrMsg string `json:"err_msg"`
  4337. InfRefmsgid string `json:"inf_refmsgid"`
  4338. Infcode string `json:"infcode"`
  4339. Output struct {
  4340. Trtinfo struct {
  4341. PsnNo string `json:"psn_no"`
  4342. TrtChkType string `json:"trt_chk_type"`
  4343. FundPayType string `json:"fund_pay_type"`
  4344. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  4345. Begndate string `json:"begndate"`
  4346. Enddate string `json:"enddate"`
  4347. TrtChkRslt string `json:"trt_chk_rslt"`
  4348. } `json:"trtinfo"`
  4349. } `json:"output"`
  4350. RefmsgTime string `json:"refmsg_time"`
  4351. RespondTime string `json:"respond_time"`
  4352. Signtype interface{} `json:"signtype"`
  4353. WarnMsg interface{} `json:"warn_msg"`
  4354. }
  4355. type ResultTwo struct {
  4356. ErrMsg string `json:"err_msg"`
  4357. InfRefmsgid string `json:"inf_refmsgid"`
  4358. Infcode int64 `json:"infcode"`
  4359. Output struct {
  4360. Baseinfo struct {
  4361. Age float64 `json:"age"`
  4362. Brdy string `json:"brdy"`
  4363. Certno string `json:"certno"`
  4364. Gend string `json:"gend"`
  4365. Naty string `json:"naty"`
  4366. PsnCertType string `json:"psn_cert_type"`
  4367. PsnName string `json:"psn_name"`
  4368. PsnNo string `json:"psn_no"`
  4369. } `json:"baseinfo"`
  4370. Idetinfo []interface{} `json:"idetinfo"`
  4371. Iinfo []struct {
  4372. Balc float64 `json:"balc"`
  4373. CvlservFlag string `json:"cvlserv_flag"`
  4374. EmpName string `json:"emp_name"`
  4375. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4376. Insutype string `json:"insutype"`
  4377. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4378. PausInsuDate string `json:"paus_insu_date"`
  4379. PsnInsuDate string `json:"psn_insu_date"`
  4380. PsnInsuStas string `json:"psn_insu_stas"`
  4381. PsnType string `json:"psn_type"`
  4382. } `json:"insuinfo"`
  4383. } `json:"output"`
  4384. RefmsgTime string `json:"refmsg_time"`
  4385. RespondTime string `json:"respond_time"`
  4386. Signtype interface{} `json:"signtype"`
  4387. WarnInfo interface{} `json:"warn_info"`
  4388. }
  4389. type ResultTwo10265 struct {
  4390. ErrMsg string `json:"err_msg"`
  4391. InfRefmsgid string `json:"inf_refmsgid"`
  4392. Infcode string `json:"infcode"`
  4393. Output struct {
  4394. Baseinfo struct {
  4395. Age float64 `json:"age"`
  4396. Brdy string `json:"brdy"`
  4397. Certno string `json:"certno"`
  4398. Gend string `json:"gend"`
  4399. Naty string `json:"naty"`
  4400. PsnCertType string `json:"psn_cert_type"`
  4401. PsnName string `json:"psn_name"`
  4402. PsnNo string `json:"psn_no"`
  4403. } `json:"baseinfo"`
  4404. Idetinfo []interface{} `json:"idetinfo"`
  4405. Iinfo []struct {
  4406. Balc float64 `json:"balc"`
  4407. CvlservFlag string `json:"cvlserv_flag"`
  4408. EmpName string `json:"emp_name"`
  4409. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4410. Insutype string `json:"insutype"`
  4411. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4412. PausInsuDate string `json:"paus_insu_date"`
  4413. PsnInsuDate string `json:"psn_insu_date"`
  4414. PsnInsuStas string `json:"psn_insu_stas"`
  4415. PsnType string `json:"psn_type"`
  4416. } `json:"insuinfo"`
  4417. } `json:"output"`
  4418. RefmsgTime string `json:"refmsg_time"`
  4419. RespondTime string `json:"respond_time"`
  4420. Signtype interface{} `json:"signtype"`
  4421. WarnInfo interface{} `json:"warn_info"`
  4422. }
  4423. type ResultThree struct {
  4424. Cainfo interface{} `json:"cainfo"`
  4425. ErrMsg string `json:"err_msg"`
  4426. InfRefmsgid string `json:"inf_refmsgid"`
  4427. Infcode int64 `json:"infcode"`
  4428. Output struct {
  4429. Data struct {
  4430. IptOtpNo string `json:"ipt_otp_no"`
  4431. MdtrtID string `json:"mdtrt_id"`
  4432. PsnNo string `json:"psn_no"`
  4433. } `json:"data"`
  4434. } `json:"output"`
  4435. RefmsgTime string `json:"refmsg_time"`
  4436. RespondTime string `json:"respond_time"`
  4437. Signtype interface{} `json:"signtype"`
  4438. WarnMsg interface{} `json:"warn_msg"`
  4439. }
  4440. type ResultThree10265 struct {
  4441. Cainfo interface{} `json:"cainfo"`
  4442. ErrMsg string `json:"err_msg"`
  4443. InfRefmsgid string `json:"inf_refmsgid"`
  4444. Infcode string `json:"infcode"`
  4445. Output struct {
  4446. Data struct {
  4447. IptOtpNo string `json:"ipt_otp_no"`
  4448. MdtrtID string `json:"mdtrt_id"`
  4449. PsnNo string `json:"psn_no"`
  4450. } `json:"data"`
  4451. } `json:"output"`
  4452. RefmsgTime string `json:"refmsg_time"`
  4453. RespondTime string `json:"respond_time"`
  4454. Signtype interface{} `json:"signtype"`
  4455. WarnMsg interface{} `json:"warn_msg"`
  4456. }
  4457. type ResultFour struct {
  4458. Cainfo string `json:"cainfo"`
  4459. ErrMsg string `json:"err_msg"`
  4460. InfRefmsgid string `json:"inf_refmsgid"`
  4461. Infcode int64 `json:"infcode"`
  4462. Output struct {
  4463. Result []struct {
  4464. BasMednFlag string `json:"bas_medn_flag"`
  4465. ChldMedcFlag string `json:"chld_medc_flag"`
  4466. ChrgitmLv string `json:"chrgitm_lv"`
  4467. Cnt float64 `json:"cnt"`
  4468. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  4469. DrtReimFlag string `json:"drt_reim_flag"`
  4470. FeedetlSn string `json:"feedetl_sn"`
  4471. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4472. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  4473. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4474. ListSpItemFlag string `json:"list_sp_item_flag"`
  4475. LmtUsedFlag string `json:"lmt_used_flag"`
  4476. MedChrgitmType string `json:"med_chrgitm_type"`
  4477. Memo string `json:"memo"`
  4478. OverlmtAmt float64 `json:"overlmt_amt"`
  4479. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4480. Pric float64 `json:"pric"`
  4481. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  4482. SelfpayProp float64 `json:"selfpay_prop"`
  4483. } `json:"result"`
  4484. } `json:"output"`
  4485. RefmsgTime string `json:"refmsg_time"`
  4486. RespondTime string `json:"respond_time"`
  4487. Signtype string `json:"signtype"`
  4488. WarnMsg string `json:"warn_msg"`
  4489. }
  4490. type ResultFour10265 struct {
  4491. Cainfo string `json:"cainfo"`
  4492. ErrMsg string `json:"err_msg"`
  4493. InfRefmsgid string `json:"inf_refmsgid"`
  4494. Infcode string `json:"infcode"`
  4495. Output struct {
  4496. Result []struct {
  4497. BasMednFlag string `json:"bas_medn_flag"`
  4498. ChldMedcFlag string `json:"chld_medc_flag"`
  4499. ChrgitmLv string `json:"chrgitm_lv"`
  4500. Cnt float64 `json:"cnt"`
  4501. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  4502. DrtReimFlag string `json:"drt_reim_flag"`
  4503. FeedetlSn string `json:"feedetl_sn"`
  4504. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4505. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  4506. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4507. ListSpItemFlag string `json:"list_sp_item_flag"`
  4508. LmtUsedFlag string `json:"lmt_used_flag"`
  4509. MedChrgitmType string `json:"med_chrgitm_type"`
  4510. Memo string `json:"memo"`
  4511. OverlmtAmt float64 `json:"overlmt_amt"`
  4512. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4513. Pric float64 `json:"pric"`
  4514. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  4515. SelfpayProp float64 `json:"selfpay_prop"`
  4516. } `json:"result"`
  4517. } `json:"output"`
  4518. RefmsgTime string `json:"refmsg_time"`
  4519. RespondTime string `json:"respond_time"`
  4520. Signtype string `json:"signtype"`
  4521. WarnMsg string `json:"warn_msg"`
  4522. }
  4523. type ResultFive struct {
  4524. Balc float64 `json:"balc"`
  4525. CvlservFlag string `json:"cvlserv_flag"`
  4526. EmpName string `json:"emp_name"`
  4527. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4528. Insutype string `json:"insutype"`
  4529. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4530. PausInsuDate string `json:"paus_insu_date"`
  4531. PsnInsuDate string `json:"psn_insu_date"`
  4532. PsnInsuStas string `json:"psn_insu_stas"`
  4533. PsnType string `json:"psn_type"`
  4534. }
  4535. type ResultSix struct {
  4536. Cainfo interface{} `json:"cainfo"`
  4537. ErrMsg string `json:"err_msg"`
  4538. InfRefmsgid string `json:"inf_refmsgid"`
  4539. Infcode int64 `json:"infcode"`
  4540. Output struct {
  4541. } `json:"output"`
  4542. RefmsgTime string `json:"refmsg_time"`
  4543. RespondTime string `json:"respond_time"`
  4544. Signtype interface{} `json:"signtype"`
  4545. WarnMsg interface{} `json:"warn_msg"`
  4546. }
  4547. type ResultSix10265 struct {
  4548. Cainfo interface{} `json:"cainfo"`
  4549. ErrMsg string `json:"err_msg"`
  4550. InfRefmsgid string `json:"inf_refmsgid"`
  4551. Infcode string `json:"infcode"`
  4552. Output struct {
  4553. } `json:"output"`
  4554. RefmsgTime string `json:"refmsg_time"`
  4555. RespondTime string `json:"respond_time"`
  4556. Signtype interface{} `json:"signtype"`
  4557. WarnMsg interface{} `json:"warn_msg"`
  4558. }
  4559. type ResultSeven struct {
  4560. Cainfo string `json:"cainfo"`
  4561. ErrMsg string `json:"err_msg"`
  4562. InfRefmsgid string `json:"inf_refmsgid"`
  4563. Infcode int64 `json:"infcode"`
  4564. Output struct {
  4565. Setldetail []interface{} `json:"setldetail"`
  4566. Setlinfo struct {
  4567. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4568. AcctPay float64 `json:"acct_pay"`
  4569. ActPayDedc float64 `json:"act_pay_dedc"`
  4570. Age float64 `json:"age"`
  4571. Balc float64 `json:"balc"`
  4572. Brdy string `json:"brdy"`
  4573. Certno string `json:"certno"`
  4574. ClrOptins string `json:"clr_optins"`
  4575. ClrType string `json:"clr_type"`
  4576. ClrWay string `json:"clr_way"`
  4577. CvlservFlag string `json:"cvlserv_flag"`
  4578. CvlservPay float64 `json:"cvlserv_pay"`
  4579. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4580. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4581. Gend string `json:"gend"`
  4582. HifesPay float64 `json:"hifes_pay"`
  4583. HifmiPay float64 `json:"hifmi_pay"`
  4584. HifpPay float64 `json:"hifp_pay"`
  4585. HospPartAmt float64 `json:"hosp_part_amt"`
  4586. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4587. Insutype string `json:"insutype"`
  4588. MafPay float64 `json:"maf_pay"`
  4589. MdtrtCertType string `json:"mdtrt_cert_type"`
  4590. HifobPay float64 `json:"hifob_pay"`
  4591. MdtrtID string `json:"mdtrt_id"`
  4592. MedType string `json:"med_type"`
  4593. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4594. MedinsSetlID string `json:"medins_setl_id"`
  4595. Naty string `json:"naty"`
  4596. OthPay float64 `json:"oth_pay"`
  4597. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4598. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4599. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4600. PsnCashPay float64 `json:"psn_cash_pay"`
  4601. PsnCertType string `json:"psn_cert_type"`
  4602. PsnName string `json:"psn_name"`
  4603. PsnNo string `json:"psn_no"`
  4604. PsnPartAmt float64 `json:"psn_part_amt"`
  4605. PsnType string `json:"psn_type"`
  4606. SetlID string `json:"setl_id"`
  4607. SetlTime string `json:"setl_time"`
  4608. } `json:"setlinfo"`
  4609. } `json:"output"`
  4610. RefmsgTime string `json:"refmsg_time"`
  4611. RespondTime string `json:"respond_time"`
  4612. Signtype interface{} `json:"signtype"`
  4613. WarnMsg interface{} `json:"warn_msg"`
  4614. }
  4615. type ResultSeven10265 struct {
  4616. Cainfo string `json:"cainfo"`
  4617. ErrMsg string `json:"err_msg"`
  4618. InfRefmsgid string `json:"inf_refmsgid"`
  4619. Infcode string `json:"infcode"`
  4620. Output struct {
  4621. Setldetail []interface{} `json:"setldetail"`
  4622. Setlinfo struct {
  4623. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4624. AcctPay float64 `json:"acct_pay"`
  4625. ActPayDedc float64 `json:"act_pay_dedc"`
  4626. Age float64 `json:"age"`
  4627. Balc float64 `json:"balc"`
  4628. Brdy string `json:"brdy"`
  4629. Certno string `json:"certno"`
  4630. ClrOptins string `json:"clr_optins"`
  4631. ClrType string `json:"clr_type"`
  4632. ClrWay string `json:"clr_way"`
  4633. CvlservFlag string `json:"cvlserv_flag"`
  4634. CvlservPay float64 `json:"cvlserv_pay"`
  4635. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4636. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4637. Gend string `json:"gend"`
  4638. HifesPay float64 `json:"hifes_pay"`
  4639. HifmiPay float64 `json:"hifmi_pay"`
  4640. HifpPay float64 `json:"hifp_pay"`
  4641. HospPartAmt float64 `json:"hosp_part_amt"`
  4642. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4643. Insutype string `json:"insutype"`
  4644. MafPay float64 `json:"maf_pay"`
  4645. MdtrtCertType string `json:"mdtrt_cert_type"`
  4646. HifobPay float64 `json:"hifob_pay"`
  4647. MdtrtID string `json:"mdtrt_id"`
  4648. MedType string `json:"med_type"`
  4649. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4650. MedinsSetlID string `json:"medins_setl_id"`
  4651. Naty string `json:"naty"`
  4652. OthPay float64 `json:"oth_pay"`
  4653. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4654. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4655. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4656. PsnCashPay float64 `json:"psn_cash_pay"`
  4657. PsnCertType string `json:"psn_cert_type"`
  4658. PsnName string `json:"psn_name"`
  4659. PsnNo string `json:"psn_no"`
  4660. PsnPartAmt float64 `json:"psn_part_amt"`
  4661. PsnType string `json:"psn_type"`
  4662. SetlID string `json:"setl_id"`
  4663. SetlTime string `json:"setl_time"`
  4664. } `json:"setlinfo"`
  4665. } `json:"output"`
  4666. RefmsgTime string `json:"refmsg_time"`
  4667. RespondTime string `json:"respond_time"`
  4668. Signtype interface{} `json:"signtype"`
  4669. WarnMsg interface{} `json:"warn_msg"`
  4670. }
  4671. type ResultEight struct {
  4672. Cainfo string `json:"cainfo"`
  4673. ErrMsg string `json:"err_msg"`
  4674. InfRefmsgid string `json:"inf_refmsgid"`
  4675. Infcode int64 `json:"infcode"`
  4676. Output struct {
  4677. Stmtinfo struct {
  4678. SetlOptins string `json:"setl_optins"`
  4679. StmtRslt string `json:"stmt_rslt"`
  4680. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4681. } `json:"stmtinfo"`
  4682. } `json:"output"`
  4683. RefmsgTime string `json:"refmsg_time"`
  4684. RespondTime string `json:"respond_time"`
  4685. Signtype interface{} `json:"signtype"`
  4686. WarnMsg interface{} `json:"warn_msg"`
  4687. }
  4688. type ResultEightFor10188 struct {
  4689. Cainfo string `json:"cainfo"`
  4690. ErrMsg string `json:"err_msg"`
  4691. InfRefmsgid string `json:"inf_refmsgid"`
  4692. Infcode string `json:"infcode"`
  4693. Output struct {
  4694. Stmtinfo struct {
  4695. SetlOptins string `json:"setl_optins"`
  4696. StmtRslt string `json:"stmt_rslt"`
  4697. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4698. } `json:"stmtinfo"`
  4699. } `json:"output"`
  4700. RefmsgTime string `json:"refmsg_time"`
  4701. RespondTime string `json:"respond_time"`
  4702. Signtype interface{} `json:"signtype"`
  4703. WarnMsg interface{} `json:"warn_msg"`
  4704. }
  4705. type ResultNine struct {
  4706. Cainfo string `json:"cainfo"`
  4707. ErrMsg string `json:"err_msg"`
  4708. InfRefmsgid string `json:"inf_refmsgid"`
  4709. Infcode int64 `json:"infcode"`
  4710. Output struct {
  4711. FileQuryNo string `json:"file_qury_no"`
  4712. } `json:"output"`
  4713. RefmsgTime string `json:"refmsg_time"`
  4714. RespondTime string `json:"respond_time"`
  4715. Signtype interface{} `json:"signtype"`
  4716. WarnMsg interface{} `json:"warn_msg"`
  4717. }
  4718. type ResultTen struct {
  4719. Cainfo string `json:"cainfo"`
  4720. ErrMsg string `json:"err_msg"`
  4721. InfRefmsgid string `json:"inf_refmsgid"`
  4722. Infcode int64 `json:"infcode"`
  4723. Output struct {
  4724. DldEndtime string `json:"dld_endtime"`
  4725. FileQuryNo string `json:"file_qury_no"`
  4726. Filename string `json:"filename"`
  4727. } `json:"output"`
  4728. RefmsgTime string `json:"refmsg_time"`
  4729. RespondTime string `json:"respond_time"`
  4730. Signtype interface{} `json:"signtype"`
  4731. WarnMsg interface{} `json:"warn_msg"`
  4732. }
  4733. //type Autogenerated struct {
  4734. // Output struct {
  4735. // Setlinfo struct {
  4736. // SetlTime string `json:"setl_time"`
  4737. // CvlservPay float64 `json:"cvlserv_pay"`
  4738. // Year string `json:"year"`
  4739. // MedType string `json:"med_type"`
  4740. // PsnPay float64 `json:"psn_pay"`
  4741. // OpterID string `json:"opter_id"`
  4742. // Begndate string `json:"begndate"`
  4743. // FlxempeFlag string `json:"flxempe_flag"`
  4744. // HifmiPay float64 `json:"hifmi_pay"`
  4745. // PsnNo string `json:"psn_no"`
  4746. // ActPayDedc float64 `json:"act_pay_dedc"`
  4747. // MedinsSetlID interface{} `json:"medins_setl_id"`
  4748. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4749. // ClrWay string `json:"clr_way"`
  4750. // OthPay float64 `json:"oth_pay"`
  4751. // Gend string `json:"gend"`
  4752. // MdtrtID string `json:"mdtrt_id"`
  4753. // AcctPay float64 `json:"acct_pay"`
  4754. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  4755. // Insutype string `json:"insutype"`
  4756. // Invono interface{} `json:"invono"`
  4757. // Enddate string `json:"enddate"`
  4758. // CashPayamt float64 `json:"cash_payamt"`
  4759. // PsnType string `json:"psn_type"`
  4760. // FixmedinsName string `json:"fixmedins_name"`
  4761. // HifpPay float64 `json:"hifp_pay"`
  4762. // NewFlag interface{} `json:"new_flag"`
  4763. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4764. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  4765. // PayLoc string `json:"pay_loc"`
  4766. // ClrType string `json:"clr_type"`
  4767. // RefdSetlFlag string `json:"refd_setl_flag"`
  4768. // CvlservFlag string `json:"cvlserv_flag"`
  4769. // EmpName string `json:"emp_name"`
  4770. // Brdy string `json:"brdy"`
  4771. // Naty string `json:"naty"`
  4772. // Certno string `json:"certno"`
  4773. // DiseCode string `json:"dise_code"`
  4774. // FixmedinsCode string `json:"fixmedins_code"`
  4775. // DedcHospLv string `json:"dedc_hosp_lv"`
  4776. // OpterName string `json:"opter_name"`
  4777. // Balc float64 `json:"balc"`
  4778. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4779. // PsnCertType string `json:"psn_cert_type"`
  4780. // HifobPay float64 `json:"hifob_pay"`
  4781. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  4782. // HifesPay float64 `json:"hifes_pay"`
  4783. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4784. // OptTime string `json:"opt_time"`
  4785. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4786. // SetlID string `json:"setl_id"`
  4787. // MafPay float64 `json:"maf_pay"`
  4788. // PsnName string `json:"psn_name"`
  4789. // InsuOptins interface{} `json:"insu_optins"`
  4790. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4791. // ClrOptins string `json:"clr_optins"`
  4792. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4793. // DiseName string `json:"dise_name"`
  4794. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4795. // Age float64 `json:"age"`
  4796. // DtrtCertType string `json:"dtrt_cert_type"`
  4797. // HospLv string `json:"hosp_lv"`
  4798. // } `json:"setlinfo"`
  4799. // Setldetail []struct {
  4800. // FundPayType string `json:"fund_pay_type"`
  4801. // FundPayamt float64 `json:"fund_payamt"`
  4802. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4803. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4804. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4805. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4806. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4807. // } `json:"setldetail"`
  4808. // } `json:"output"`
  4809. // Infcode int `json:"infcode"`
  4810. // WarnMsg interface{} `json:"warn_msg"`
  4811. // Cainfo interface{} `json:"cainfo"`
  4812. // ErrMsg interface{} `json:"err_msg"`
  4813. // RefmsgTime string `json:"refmsg_time"`
  4814. // Signtype interface{} `json:"signtype"`
  4815. // RespondTime string `json:"respond_time"`
  4816. // InfRefmsgid string `json:"inf_refmsgid"`
  4817. //}
  4818. type ResultEleven struct {
  4819. Cainfo string `json:"cainfo"`
  4820. ErrMsg string `json:"err_msg"`
  4821. InfRefmsgid string `json:"inf_refmsgid"`
  4822. Infcode int64 `json:"infcode"`
  4823. Output struct {
  4824. Setlinfo struct {
  4825. SetlTime string `json:"setl_time"`
  4826. CvlservPay float64 `json:"cvlserv_pay"`
  4827. Year string `json:"year"`
  4828. MedType string `json:"med_type"`
  4829. PsnPay float64 `json:"psn_pay"`
  4830. OpterID string `json:"opter_id"`
  4831. Begndate string `json:"begndate"`
  4832. FlxempeFlag string `json:"flxempe_flag"`
  4833. HifmiPay float64 `json:"hifmi_pay"`
  4834. PsnNo string `json:"psn_no"`
  4835. ActPayDedc float64 `json:"act_pay_dedc"`
  4836. MedinsSetlID interface{} `json:"medins_setl_id"`
  4837. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4838. ClrWay string `json:"clr_way"`
  4839. OthPay float64 `json:"oth_pay"`
  4840. Gend string `json:"gend"`
  4841. MdtrtID string `json:"mdtrt_id"`
  4842. AcctPay float64 `json:"acct_pay"`
  4843. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4844. Insutype string `json:"insutype"`
  4845. Invono interface{} `json:"invono"`
  4846. Enddate string `json:"enddate"`
  4847. CashPayamt float64 `json:"cash_payamt"`
  4848. PsnType string `json:"psn_type"`
  4849. FixmedinsName string `json:"fixmedins_name"`
  4850. HifpPay float64 `json:"hifp_pay"`
  4851. NewFlag interface{} `json:"new_flag"`
  4852. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4853. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4854. PayLoc string `json:"pay_loc"`
  4855. ClrType string `json:"clr_type"`
  4856. RefdSetlFlag string `json:"refd_setl_flag"`
  4857. CvlservFlag string `json:"cvlserv_flag"`
  4858. EmpName string `json:"emp_name"`
  4859. Brdy string `json:"brdy"`
  4860. Naty string `json:"naty"`
  4861. Certno string `json:"certno"`
  4862. DiseCode string `json:"dise_code"`
  4863. FixmedinsCode string `json:"fixmedins_code"`
  4864. DedcHospLv string `json:"dedc_hosp_lv"`
  4865. OpterName string `json:"opter_name"`
  4866. Balc float64 `json:"balc"`
  4867. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4868. PsnCertType string `json:"psn_cert_type"`
  4869. HifobPay float64 `json:"hifob_pay"`
  4870. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4871. HifesPay float64 `json:"hifes_pay"`
  4872. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4873. OptTime string `json:"opt_time"`
  4874. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4875. SetlID string `json:"setl_id"`
  4876. MafPay float64 `json:"maf_pay"`
  4877. PsnName string `json:"psn_name"`
  4878. InsuOptins interface{} `json:"insu_optins"`
  4879. PrefFundPay interface{} `json:"pref_fund_pay"`
  4880. ClrOptins string `json:"clr_optins"`
  4881. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4882. DiseName string `json:"dise_name"`
  4883. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4884. Age float64 `json:"age"`
  4885. DtrtCertType string `json:"dtrt_cert_type"`
  4886. HospLv string `json:"hosp_lv"`
  4887. } `json:"setlinfo"`
  4888. } `json:"output"`
  4889. RefmsgTime string `json:"refmsg_time"`
  4890. RespondTime string `json:"respond_time"`
  4891. Signtype interface{} `json:"signtype"`
  4892. WarnMsg interface{} `json:"warn_msg"`
  4893. }
  4894. type ResultEleven10265 struct {
  4895. Cainfo string `json:"cainfo"`
  4896. ErrMsg string `json:"err_msg"`
  4897. InfRefmsgid string `json:"inf_refmsgid"`
  4898. Infcode string `json:"infcode"`
  4899. Output struct {
  4900. Setlinfo struct {
  4901. SetlTime string `json:"setl_time"`
  4902. CvlservPay float64 `json:"cvlserv_pay"`
  4903. Year string `json:"year"`
  4904. MedType string `json:"med_type"`
  4905. PsnPay float64 `json:"psn_pay"`
  4906. OpterID string `json:"opter_id"`
  4907. Begndate string `json:"begndate"`
  4908. FlxempeFlag string `json:"flxempe_flag"`
  4909. HifmiPay float64 `json:"hifmi_pay"`
  4910. PsnNo string `json:"psn_no"`
  4911. ActPayDedc float64 `json:"act_pay_dedc"`
  4912. MedinsSetlID interface{} `json:"medins_setl_id"`
  4913. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4914. ClrWay string `json:"clr_way"`
  4915. OthPay float64 `json:"oth_pay"`
  4916. Gend string `json:"gend"`
  4917. MdtrtID string `json:"mdtrt_id"`
  4918. AcctPay float64 `json:"acct_pay"`
  4919. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4920. Insutype string `json:"insutype"`
  4921. Invono interface{} `json:"invono"`
  4922. Enddate string `json:"enddate"`
  4923. CashPayamt float64 `json:"cash_payamt"`
  4924. PsnType string `json:"psn_type"`
  4925. FixmedinsName string `json:"fixmedins_name"`
  4926. HifpPay float64 `json:"hifp_pay"`
  4927. NewFlag interface{} `json:"new_flag"`
  4928. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4929. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4930. PayLoc string `json:"pay_loc"`
  4931. ClrType string `json:"clr_type"`
  4932. RefdSetlFlag string `json:"refd_setl_flag"`
  4933. CvlservFlag string `json:"cvlserv_flag"`
  4934. EmpName string `json:"emp_name"`
  4935. Brdy string `json:"brdy"`
  4936. Naty string `json:"naty"`
  4937. Certno string `json:"certno"`
  4938. DiseCode string `json:"dise_code"`
  4939. FixmedinsCode string `json:"fixmedins_code"`
  4940. DedcHospLv string `json:"dedc_hosp_lv"`
  4941. OpterName string `json:"opter_name"`
  4942. Balc float64 `json:"balc"`
  4943. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4944. PsnCertType string `json:"psn_cert_type"`
  4945. HifobPay float64 `json:"hifob_pay"`
  4946. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4947. HifesPay float64 `json:"hifes_pay"`
  4948. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4949. OptTime string `json:"opt_time"`
  4950. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4951. SetlID string `json:"setl_id"`
  4952. MafPay float64 `json:"maf_pay"`
  4953. PsnName string `json:"psn_name"`
  4954. InsuOptins interface{} `json:"insu_optins"`
  4955. PrefFundPay interface{} `json:"pref_fund_pay"`
  4956. ClrOptins string `json:"clr_optins"`
  4957. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4958. DiseName string `json:"dise_name"`
  4959. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4960. Age float64 `json:"age"`
  4961. DtrtCertType string `json:"dtrt_cert_type"`
  4962. HospLv string `json:"hosp_lv"`
  4963. } `json:"setlinfo"`
  4964. } `json:"output"`
  4965. RefmsgTime string `json:"refmsg_time"`
  4966. RespondTime string `json:"respond_time"`
  4967. Signtype interface{} `json:"signtype"`
  4968. WarnMsg interface{} `json:"warn_msg"`
  4969. }
  4970. type ResultTwelve struct {
  4971. Cainfo string `json:"cainfo"`
  4972. ErrMsg string `json:"err_msg"`
  4973. InfRefmsgid string `json:"inf_refmsgid"`
  4974. Infcode int64 `json:"infcode"`
  4975. Output struct {
  4976. MdtrtId string `json:"mdtrt_id"`
  4977. ChrgBchno string `json:"chrg_bchno"`
  4978. PsnNo string `json:"psn_no"`
  4979. } `json:"output"`
  4980. RefmsgTime string `json:"refmsg_time"`
  4981. RespondTime string `json:"respond_time"`
  4982. Signtype interface{} `json:"signtype"`
  4983. WarnMsg interface{} `json:"warn_msg"`
  4984. }
  4985. type ResultThirteen struct {
  4986. ErrMsg string `json:"err_msg"`
  4987. InfRefmsgid string `json:"inf_refmsgid"`
  4988. Infcode int64 `json:"infcode"`
  4989. Output struct {
  4990. Result struct {
  4991. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4992. } `json:"result"`
  4993. } `json:"output"`
  4994. RefmsgTime string `json:"refmsg_time"`
  4995. RespondTime string `json:"respond_time"`
  4996. Signtype interface{} `json:"signtype"`
  4997. WarnInfo interface{} `json:"warn_info"`
  4998. }
  4999. type ResultThirteen10265 struct {
  5000. ErrMsg string `json:"err_msg"`
  5001. InfRefmsgid string `json:"inf_refmsgid"`
  5002. Infcode string `json:"infcode"`
  5003. Output struct {
  5004. Result struct {
  5005. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  5006. } `json:"result"`
  5007. } `json:"output"`
  5008. RefmsgTime string `json:"refmsg_time"`
  5009. RespondTime string `json:"respond_time"`
  5010. Signtype interface{} `json:"signtype"`
  5011. WarnInfo interface{} `json:"warn_info"`
  5012. }
  5013. type ResultFourteen struct {
  5014. ErrMsg string `json:"err_msg"`
  5015. InfRefmsgid string `json:"inf_refmsgid"`
  5016. Infcode int64 `json:"infcode"`
  5017. Output struct {
  5018. } `json:"output"`
  5019. RefmsgTime string `json:"refmsg_time"`
  5020. RespondTime string `json:"respond_time"`
  5021. Signtype interface{} `json:"signtype"`
  5022. WarnInfo interface{} `json:"warn_info"`
  5023. }
  5024. type ResultFourteen10265 struct {
  5025. ErrMsg string `json:"err_msg"`
  5026. InfRefmsgid string `json:"inf_refmsgid"`
  5027. Infcode string `json:"infcode"`
  5028. Output struct {
  5029. } `json:"output"`
  5030. RefmsgTime string `json:"refmsg_time"`
  5031. RespondTime string `json:"respond_time"`
  5032. Signtype interface{} `json:"signtype"`
  5033. WarnInfo interface{} `json:"warn_info"`
  5034. }
  5035. type ResultSixteen struct {
  5036. Cainfo string `json:"cainfo"`
  5037. ErrMsg string `json:"err_msg"`
  5038. InfRefmsgid string `json:"inf_refmsgid"`
  5039. Infcode int64 `json:"infcode"`
  5040. Output struct {
  5041. Setldetail []interface{} `json:"setldetail"`
  5042. Setlinfo struct {
  5043. MdtrtID string `json:"mdtrt_id"`
  5044. SetlID string `json:"setl_id"`
  5045. ClrOptins string `json:"clr_optins"`
  5046. SetlTime string `json:"setl_time"`
  5047. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5048. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5049. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5050. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5051. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5052. ActPayDedc float64 `json:"act_pay_dedc"`
  5053. HifpPay float64 `json:"hifp_pay"`
  5054. PoolPropSe float64 `json:"pool_prop_selfpay"`
  5055. Lfpay float64 `json:"selfpay"`
  5056. CvlservPay float64 `json:"cvlserv_pay"`
  5057. HifesPay float64 `json:"hifes_pay"`
  5058. HifmiPay float64 `json:"hifmi_pay"`
  5059. HifobPay float64 `json:"hifob_pay"`
  5060. MafPay float64 `json:"maf_pay"`
  5061. OthPay float64 `json:"oth_pay"`
  5062. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5063. PsnPartAmt float64 `json:"psn_part_amt"`
  5064. AcctPay float64 `json:"acct_pay"`
  5065. Balc float64 `json:"balc"`
  5066. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5067. HospPartAmt float64 `json:"hosp_part_amt"`
  5068. MedinsSetlID string `json:"medins_setl_id"`
  5069. PdnCashPay string `json:"pdn_cash_pay"`
  5070. } `json:"setlinfo"`
  5071. } `json:"output"`
  5072. RefmsgTime string `json:"refmsg_time"`
  5073. RespondTime string `json:"respond_time"`
  5074. Signtype interface{} `json:"signtype"`
  5075. WarnMsg interface{} `json:"warn_msg"`
  5076. }
  5077. type ResultSixteen10265 struct {
  5078. Cainfo string `json:"cainfo"`
  5079. ErrMsg string `json:"err_msg"`
  5080. InfRefmsgid string `json:"inf_refmsgid"`
  5081. Infcode string `json:"infcode"`
  5082. Output struct {
  5083. Setldetail []interface{} `json:"setldetail"`
  5084. Setlinfo struct {
  5085. MdtrtID string `json:"mdtrt_id"`
  5086. SetlID string `json:"setl_id"`
  5087. ClrOptins string `json:"clr_optins"`
  5088. SetlTime string `json:"setl_time"`
  5089. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5090. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5091. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5092. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5093. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5094. ActPayDedc float64 `json:"act_pay_dedc"`
  5095. HifpPay float64 `json:"hifp_pay"`
  5096. PoolPropSe float64 `json:"pool_prop_selfpay"`
  5097. Lfpay float64 `json:"selfpay"`
  5098. CvlservPay float64 `json:"cvlserv_pay"`
  5099. HifesPay float64 `json:"hifes_pay"`
  5100. HifmiPay float64 `json:"hifmi_pay"`
  5101. HifobPay float64 `json:"hifob_pay"`
  5102. MafPay float64 `json:"maf_pay"`
  5103. OthPay float64 `json:"oth_pay"`
  5104. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5105. PsnPartAmt float64 `json:"psn_part_amt"`
  5106. AcctPay float64 `json:"acct_pay"`
  5107. Balc float64 `json:"balc"`
  5108. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5109. HospPartAmt float64 `json:"hosp_part_amt"`
  5110. MedinsSetlID string `json:"medins_setl_id"`
  5111. PdnCashPay string `json:"pdn_cash_pay"`
  5112. } `json:"setlinfo"`
  5113. } `json:"output"`
  5114. RefmsgTime string `json:"refmsg_time"`
  5115. RespondTime string `json:"respond_time"`
  5116. Signtype interface{} `json:"signtype"`
  5117. WarnMsg interface{} `json:"warn_msg"`
  5118. }
  5119. type ResultSeventeen struct {
  5120. ErrMsg string `json:"err_msg"`
  5121. InfRefmsgid string `json:"inf_refmsgid"`
  5122. Infcode int64 `json:"infcode"`
  5123. Output struct {
  5124. SetlListId string `json:"setl_list_id"`
  5125. } `json:"output"`
  5126. RefmsgTime string `json:"refmsg_time"`
  5127. RespondTime string `json:"respond_time"`
  5128. Signtype string `json:"signtype"`
  5129. WarnInfo string `json:"warn_info"`
  5130. }
  5131. type ResultSeventeenOther struct {
  5132. ErrMsg string `json:"err_msg"`
  5133. InfRefmsgid string `json:"inf_refmsgid"`
  5134. Infcode string `json:"infcode"`
  5135. Output struct {
  5136. SetlListId string `json:"setl_list_id"`
  5137. } `json:"output"`
  5138. RefmsgTime string `json:"refmsg_time"`
  5139. RespondTime string `json:"respond_time"`
  5140. Signtype string `json:"signtype"`
  5141. WarnInfo string `json:"warn_info"`
  5142. }
  5143. type Result90991 struct {
  5144. ErrMsg string `json:"err_msg"`
  5145. InfRefmsgid string `json:"inf_refmsgid"`
  5146. Infcode int64 `json:"infcode"`
  5147. Output struct {
  5148. Result struct {
  5149. PsnNo string `json:"psn_no"`
  5150. CardStat string `json:"card_stat"`
  5151. Certno string `json:"certno"`
  5152. PsnName string `json:"psn_name"`
  5153. CheckStat string `json:"check_stat"`
  5154. SscnoCheckStat string `json:"sscno_check_stat"`
  5155. } `json:"result"`
  5156. } `json:"output"`
  5157. RefmsgTime string `json:"refmsg_time"`
  5158. RespondTime string `json:"respond_time"`
  5159. Signtype interface{} `json:"signtype"`
  5160. WarnInfo interface{} `json:"warn_info"`
  5161. }
  5162. type Result90100 struct {
  5163. ErrMsg string `json:"err_msg"`
  5164. InfRefmsgid string `json:"inf_refmsgid"`
  5165. Infcode int64 `json:"infcode"`
  5166. Output struct {
  5167. PoolareaNo string `json:"poolarea_no"`
  5168. PoolareaNoName string `json:"poolarea_no_name"`
  5169. Insutype string `json:"insutype"`
  5170. InsutypeName string `json:"insutype_name"`
  5171. ClctType string `json:"clct_type"`
  5172. ClctTypeName string `json:"clct_type_name"`
  5173. ClctFlag string `json:"clct_flag"`
  5174. ClctFlagName string `json:"clct_flag_name"`
  5175. AccrymBegn string `json:"accrym_begn"`
  5176. AccrymEnd string `json:"accrym_end"`
  5177. ClctTime string `json:"clct_time"`
  5178. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  5179. } `json:"output"`
  5180. RefmsgTime string `json:"refmsg_time"`
  5181. RespondTime string `json:"respond_time"`
  5182. Signtype interface{} `json:"signtype"`
  5183. WarnInfo interface{} `json:"warn_info"`
  5184. }
  5185. type Custom struct {
  5186. DetItemFeeSumamt string
  5187. Cut string
  5188. FeedetlSn string
  5189. Price string
  5190. MedListCodg string
  5191. Type int64
  5192. AdviceId int64
  5193. ProjectId int64
  5194. ItemId int64
  5195. }
  5196. type Result5301 struct {
  5197. ErrMsg string `json:"err_msg"`
  5198. InfRefmsgid string `json:"inf_refmsgid"`
  5199. Infcode int64 `json:"infcode"`
  5200. Output struct {
  5201. Result []struct {
  5202. OpspDiseCode string `json:"opsp_dise_code"`
  5203. OpspDiseName string `json:"opsp_dise_name"`
  5204. Begndate string `json:"begndate"`
  5205. Enddate string `json:"enddate"`
  5206. } `json:"feedetail"`
  5207. } `json:"output"`
  5208. RefmsgTime string `json:"refmsg_time"`
  5209. RespondTime string `json:"respond_time"`
  5210. Signtype interface{} `json:"signtype"`
  5211. WarnInfo interface{} `json:"warn_info"`
  5212. }
  5213. type Result5301For10265 struct {
  5214. ErrMsg string `json:"err_msg"`
  5215. InfRefmsgid string `json:"inf_refmsgid"`
  5216. Infcode string `json:"infcode"`
  5217. Output struct {
  5218. Result []struct {
  5219. OpspDiseCode string `json:"opsp_dise_code"`
  5220. OpspDiseName string `json:"opsp_dise_name"`
  5221. Begndate string `json:"begndate"`
  5222. Enddate string `json:"enddate"`
  5223. } `json:"feedetail"`
  5224. } `json:"output"`
  5225. RefmsgTime string `json:"refmsg_time"`
  5226. RespondTime string `json:"respond_time"`
  5227. Signtype interface{} `json:"signtype"`
  5228. WarnInfo interface{} `json:"warn_info"`
  5229. }
  5230. //获取个人信息----挂号-----上传就诊信息
  5231. func (c *HisApiController) GetRegisterInfo() {
  5232. id, _ := c.GetInt64("id")
  5233. record_time := c.GetString("record_time")
  5234. settlementValue, _ := c.GetInt64("settlement_value")
  5235. medical_insurance_card := c.GetString("medical_insurance_card")
  5236. name := c.GetString("name")
  5237. id_card_type, _ := c.GetInt64("id_card_type")
  5238. certificates, _ := c.GetInt64("certificates")
  5239. medical_care, _ := c.GetInt64("medical_care")
  5240. birthday := c.GetString("birthday")
  5241. id_card := c.GetString("id_card")
  5242. register_type, _ := c.GetInt64("register")
  5243. doctor, _ := c.GetInt64("doctor")
  5244. department, _ := c.GetInt64("department")
  5245. gender, _ := c.GetInt64("sex")
  5246. registration_fee, _ := c.GetFloat("registration_fee")
  5247. medical_expenses, _ := c.GetFloat("medical_expenses")
  5248. social_type, _ := c.GetInt64("social_type")
  5249. med_type := c.GetString("social_type")
  5250. admin_user_id, _ := c.GetInt64("admin_user_id")
  5251. insuplc_admdvs := c.GetString("insuplc_admdvs")
  5252. timeLayout := "2006-01-02"
  5253. loc, _ := time.LoadLocation("Local")
  5254. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  5255. birthUnix := birthdays.Unix()
  5256. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5257. if err != nil {
  5258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5259. return
  5260. }
  5261. recordDateTime := theTime.Unix()
  5262. adminInfo := c.GetAdminUserInfo()
  5263. var patient service.Patients
  5264. if id == 0 {
  5265. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  5266. } else {
  5267. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  5268. }
  5269. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  5270. if patientPrescription.ID == 0 {
  5271. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  5272. }
  5273. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  5274. if patient.ID == 0 {
  5275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  5276. return
  5277. }
  5278. if len(patient.IdCardNo) == 0 {
  5279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  5280. return
  5281. }
  5282. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  5283. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  5284. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  5285. //就诊结算未完成,不能进行二次挂号
  5286. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  5287. if len(his) >= 1 {
  5288. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  5289. if len(his) >= 1 && order.ID == 0 {
  5290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  5291. return
  5292. }
  5293. }
  5294. //var register_log string
  5295. if config.IsOpen == 1 {
  5296. var res ResultTwo
  5297. var res10265 ResultTwo10265
  5298. var PsnNo string
  5299. var PsnCertType string
  5300. var Certno string
  5301. var PsnName string
  5302. var Gend string
  5303. var Naty string
  5304. var Brdy string
  5305. var Age float64
  5306. var infoStr string
  5307. var idetinfoStr string
  5308. var infocode int64
  5309. var verify_number string
  5310. fmt.Println(verify_number)
  5311. if miConfig.MdtrtareaAdmvs == "421300" {
  5312. psn_info, _ := service.GetPsnByPatientId(id)
  5313. PsnNo = psn_info.PsnNo
  5314. PsnCertType = psn_info.PsnCertType
  5315. Certno = psn_info.Certno
  5316. PsnName = psn_info.PsnName
  5317. Gend = psn_info.Gend
  5318. Naty = psn_info.Naty
  5319. Brdy = psn_info.Brdy
  5320. Age = psn_info.Age
  5321. infoStr = psn_info.Insuinfo
  5322. idetinfoStr = psn_info.Idetinfo
  5323. infocode = 0
  5324. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5325. psn_info, _ := service.GetPsnByPatientId(id)
  5326. PsnNo = psn_info.PsnNo
  5327. PsnCertType = psn_info.PsnCertType
  5328. Certno = psn_info.Certno
  5329. PsnName = psn_info.PsnName
  5330. Gend = psn_info.Gend
  5331. Naty = psn_info.Naty
  5332. Brdy = psn_info.Brdy
  5333. Age = psn_info.Age
  5334. infoStr = psn_info.Insuinfo
  5335. idetinfoStr = psn_info.Idetinfo
  5336. infocode = 0
  5337. verify_number = psn_info.VerifyNumber
  5338. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5339. if id_card_type == 1 {
  5340. psn_info, _ := service.GetPsnByPatientId(id)
  5341. PsnNo = psn_info.PsnNo
  5342. PsnCertType = psn_info.PsnCertType
  5343. Certno = psn_info.Certno
  5344. PsnName = psn_info.PsnName
  5345. Gend = psn_info.Gend
  5346. Naty = psn_info.Naty
  5347. Brdy = psn_info.Brdy
  5348. Age = psn_info.Age
  5349. infoStr = psn_info.Insuinfo
  5350. idetinfoStr = psn_info.Idetinfo
  5351. infocode = 0
  5352. verify_number = psn_info.VerifyNumber
  5353. } else if id_card_type == 2 {
  5354. result, requestLog, errMsgLog := service.FJyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, patient.IdCardNo, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5355. fmt.Println(errMsgLog)
  5356. saveLog(result, requestLog, "1101", "人员基本信息获取")
  5357. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5358. utils.ErrorLog("解析失败:%v", err)
  5359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5360. return
  5361. }
  5362. PsnNo = res.Output.Baseinfo.PsnNo
  5363. PsnCertType = res.Output.Baseinfo.PsnCertType
  5364. Certno = res.Output.Baseinfo.Certno
  5365. PsnName = res.Output.Baseinfo.PsnName
  5366. Gend = res.Output.Baseinfo.Gend
  5367. Naty = res.Output.Baseinfo.Naty
  5368. Brdy = res.Output.Baseinfo.Brdy
  5369. Age = res.Output.Baseinfo.Age
  5370. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5371. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5372. infoStr = string(Iinfos)
  5373. idetinfoStr = string(Idetinfos)
  5374. infocode = res.Infcode
  5375. }
  5376. } else {
  5377. var result string
  5378. var requestLog string
  5379. if miConfig.UserOrgId == 10138 {
  5380. if id_card_type != 4 {
  5381. //psn_info, _ := service.GetPsnByPatientId(id)
  5382. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  5383. 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, record_time)
  5384. }
  5385. } else {
  5386. 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)
  5387. }
  5388. if id_card_type == 4 {
  5389. psn_info, _ := service.GetPsnByPatientId(id)
  5390. PsnNo = psn_info.PsnNo
  5391. PsnCertType = psn_info.PsnCertType
  5392. Certno = psn_info.Certno
  5393. PsnName = psn_info.PsnName
  5394. Gend = psn_info.Gend
  5395. Naty = psn_info.Naty
  5396. Brdy = psn_info.Brdy
  5397. Age = psn_info.Age
  5398. infoStr = psn_info.Insuinfo
  5399. idetinfoStr = psn_info.Idetinfo
  5400. infocode = 0
  5401. verify_number = psn_info.VerifyNumber
  5402. } else {
  5403. saveLog(result, requestLog, "1101", "人员基本信息获取")
  5404. if miConfig.Code == "H15049901371" {
  5405. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5406. utils.ErrorLog("解析失败:%v", err)
  5407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5408. return
  5409. }
  5410. res.ErrMsg = res10265.ErrMsg
  5411. res.Output = res10265.Output
  5412. res.InfRefmsgid = res10265.InfRefmsgid
  5413. } else {
  5414. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5415. utils.ErrorLog("解析失败:%v", err)
  5416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5417. return
  5418. }
  5419. }
  5420. PsnNo = res.Output.Baseinfo.PsnNo
  5421. PsnCertType = res.Output.Baseinfo.PsnCertType
  5422. Certno = res.Output.Baseinfo.Certno
  5423. PsnName = res.Output.Baseinfo.PsnName
  5424. Gend = res.Output.Baseinfo.Gend
  5425. Naty = res.Output.Baseinfo.Naty
  5426. Brdy = res.Output.Baseinfo.Brdy
  5427. Age = res.Output.Baseinfo.Age
  5428. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5429. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5430. infoStr = string(Iinfos)
  5431. idetinfoStr = string(Idetinfos)
  5432. if miConfig.Code == "H15049901371" {
  5433. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  5434. } else {
  5435. infocode = res.Infcode
  5436. }
  5437. }
  5438. }
  5439. if infocode == 0 {
  5440. his := models.VMHisPatient{
  5441. Name: name,
  5442. Gender: gender,
  5443. Birthday: birthUnix,
  5444. MedicalTreatmentType: medical_care,
  5445. IdType: certificates,
  5446. IdCardNo: id_card,
  5447. BalanceAccountsType: settlementValue,
  5448. SocialType: social_type,
  5449. MedicalInsuranceNumber: medical_insurance_card,
  5450. RegisterType: register_type,
  5451. RegisterCost: registration_fee,
  5452. TreatmentCost: medical_expenses,
  5453. Status: 1,
  5454. Ctime: time.Now().Unix(),
  5455. Mtime: time.Now().Unix(),
  5456. PsnNo: PsnNo,
  5457. PsnCertType: PsnCertType,
  5458. Certno: Certno,
  5459. PsnName: PsnName,
  5460. Gend: Gend,
  5461. Naty: Naty,
  5462. Brdy: Brdy,
  5463. Age: Age,
  5464. Iinfo: infoStr,
  5465. Idetinfo: idetinfoStr,
  5466. PatientId: patient.ID,
  5467. RecordDate: theTime.Unix(),
  5468. UserOrgId: adminInfo.CurrentOrgId,
  5469. AdminUserId: admin_user_id,
  5470. IsReturn: 1,
  5471. IdCardType: id_card_type,
  5472. Doctor: doctor,
  5473. Departments: department,
  5474. }
  5475. timestamp := time.Now().Unix()
  5476. tempTime := time.Unix(timestamp, 0)
  5477. timeFormat := tempTime.Format("20060102150405")
  5478. chrgBchno := rand.Intn(100000) + 10000
  5479. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5480. his.Number = ipt_otp_no
  5481. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  5482. department, _ := service.GetDepartMentDetail(department)
  5483. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  5484. IdCardNo := ""
  5485. if id_card_type == 1 {
  5486. // IdCardNo = medical_insurance_card
  5487. IdCardNo = patient.IdCardNo
  5488. } else {
  5489. IdCardNo = patient.IdCardNo
  5490. }
  5491. var rf []*ResultFive
  5492. json.Unmarshal([]byte(his.Iinfo), &rf)
  5493. var insutypes []*ResultFive
  5494. var insutype string
  5495. var insuplc_admdvs_temp string
  5496. var is390 int = 0
  5497. var is310 int = 0
  5498. for _, item := range rf {
  5499. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5500. insutypes = append(insutypes, item)
  5501. }
  5502. }
  5503. if len(insutypes) == 1 {
  5504. insutype = insutypes[0].Insutype
  5505. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5506. } else {
  5507. for _, i := range insutypes {
  5508. if i.Insutype == "390" {
  5509. is390 = 1
  5510. }
  5511. if i.Insutype == "310" {
  5512. is310 = 1
  5513. }
  5514. }
  5515. }
  5516. if is390 == 1 {
  5517. insutype = "390"
  5518. }
  5519. if is310 == 1 {
  5520. insutype = "310"
  5521. }
  5522. if len(insutypes) == 0 {
  5523. insutype = "310"
  5524. }
  5525. if len(insutypes) == 2 {
  5526. insutype = med_type
  5527. }
  5528. if len(med_type) > 0 {
  5529. insutype = med_type
  5530. }
  5531. var infocode int64
  5532. var resThree ResultThree
  5533. var resThree10265 ResultThree10265
  5534. if len(insuplc_admdvs) == 0 {
  5535. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  5536. } else {
  5537. insuplc_admdvs_temp = insuplc_admdvs
  5538. }
  5539. if miConfig.MdtrtareaAdmvs == "421300" {
  5540. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  5541. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  5542. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5543. "&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=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName
  5544. resp, requestErr := http.Get(api)
  5545. if requestErr != nil {
  5546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5547. return
  5548. }
  5549. body, ioErr := ioutil.ReadAll(resp.Body)
  5550. if ioErr != nil {
  5551. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5553. return
  5554. }
  5555. var respJSON map[string]interface{}
  5556. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5557. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5559. return
  5560. }
  5561. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5562. result, _ := json.Marshal(respJSON)
  5563. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5564. utils.ErrorLog("解析失败:%v", err)
  5565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5566. return
  5567. }
  5568. infocode = resThree.Infcode
  5569. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5570. psn_info, _ := service.GetPsnByPatientId(id)
  5571. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5572. var cert_no string
  5573. if id_card_type == 3 {
  5574. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  5575. cert_no = IdCardNo
  5576. } else if id_card_type == 4 {
  5577. cert_no = IdCardNo
  5578. psn_info.VerifyNumber = psn_info.VerifyNumber
  5579. } else {
  5580. bas := strings.Split(psn_info.CardInfo, "|")
  5581. cert_no = bas[2]
  5582. }
  5583. var hisPrescription []*models.HisPrescription
  5584. for _, item := range rf {
  5585. if item.Insutype == insutype {
  5586. //insuplc_admdvs = item.InsuplcAdmdvs
  5587. his.InsuplcAdmdvs = insuplc_admdvs
  5588. }
  5589. }
  5590. his.Insutype = insutype
  5591. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  5592. fmt.Println(res3101)
  5593. fmt.Println(res3101.Infcode)
  5594. if res3101.Infcode == "0" {
  5595. fmt.Println("33333333")
  5596. if len(res3101.Output.Result) > 0 {
  5597. fmt.Println("222222")
  5598. for _, item := range res3101.Output.Result {
  5599. if len(res3101.ErrMsg) == 0 {
  5600. res3101.ErrMsg = item.VolaCont
  5601. } else {
  5602. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  5603. }
  5604. }
  5605. c.ServeSuccessJSON(map[string]interface{}{
  5606. "failed_code": -10,
  5607. "msg": res3101.ErrMsg,
  5608. })
  5609. return
  5610. } else {
  5611. fmt.Println("11111")
  5612. var api string
  5613. if miConfig.MdtrtareaAdmvs == "320921" {
  5614. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  5615. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5616. "&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_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5617. } else {
  5618. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  5619. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5620. "&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_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5621. }
  5622. resp, requestErr := http.Get(api)
  5623. if requestErr != nil {
  5624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5625. return
  5626. }
  5627. body, ioErr := ioutil.ReadAll(resp.Body)
  5628. if ioErr != nil {
  5629. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5631. return
  5632. }
  5633. var respJSON map[string]interface{}
  5634. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5635. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5637. return
  5638. }
  5639. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5640. result, _ := json.Marshal(respJSON)
  5641. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5642. utils.ErrorLog("解析失败:%v", err)
  5643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5644. return
  5645. }
  5646. resThree.ErrMsg = resThree10265.ErrMsg
  5647. resThree.Output = resThree10265.Output
  5648. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5649. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5650. }
  5651. } else if res3101.Infcode != "0" {
  5652. c.ServeSuccessJSON(map[string]interface{}{
  5653. "failed_code": -10,
  5654. "msg": res3101.ErrMsg,
  5655. })
  5656. return
  5657. }
  5658. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5659. psn_info, _ := service.GetPsnByPatientId(id)
  5660. var cert_no string
  5661. if id_card_type == 1 {
  5662. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  5663. } else if id_card_type == 4 {
  5664. cert_no = psn_info.VerifyNumber
  5665. } else {
  5666. cert_no = psn_info.VerifyNumber
  5667. }
  5668. result, requestLog, _ := service.FJyb2201(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, roles.UserName, doctor_info.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, cert_no)
  5669. saveLog(result, requestLog, "2201", "挂号")
  5670. if miConfig.Code == "H15049901371" {
  5671. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5672. utils.ErrorLog("解析失败:%v", err)
  5673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5674. return
  5675. }
  5676. resThree.ErrMsg = resThree10265.ErrMsg
  5677. resThree.Output = resThree10265.Output
  5678. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5679. } else {
  5680. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5681. utils.ErrorLog("解析失败:%v", err)
  5682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5683. return
  5684. }
  5685. }
  5686. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5687. } else {
  5688. psn_info, _ := service.GetPsnByPatientId(id)
  5689. result, requestLog := service.Gdyb2201A(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time, psn_info.VerifyNumber)
  5690. saveLog(result, requestLog, "2201A", "挂号")
  5691. if miConfig.Code == "H15049901371" {
  5692. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5693. utils.ErrorLog("解析失败:%v", err)
  5694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5695. return
  5696. }
  5697. resThree.ErrMsg = resThree10265.ErrMsg
  5698. resThree.Output = resThree10265.Output
  5699. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5700. } else {
  5701. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5702. utils.ErrorLog("解析失败:%v", err)
  5703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5704. return
  5705. }
  5706. }
  5707. if miConfig.Code == "H15049901371" {
  5708. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5709. } else {
  5710. infocode = resThree.Infcode
  5711. }
  5712. }
  5713. if infocode != 0 {
  5714. adminUser := c.GetAdminUserInfo()
  5715. errlog := &models.HisOrderError{
  5716. UserOrgId: adminUser.CurrentOrgId,
  5717. Ctime: time.Now().Unix(),
  5718. Mtime: time.Now().Unix(),
  5719. ErrMsg: resThree.ErrMsg,
  5720. Status: 1,
  5721. PatientId: id,
  5722. RecordTime: recordDateTime,
  5723. Stage: 2,
  5724. }
  5725. service.CreateErrMsgLog(errlog)
  5726. c.ServeSuccessJSON(map[string]interface{}{
  5727. "failed_code": -10,
  5728. "msg": resThree.ErrMsg,
  5729. })
  5730. return
  5731. }
  5732. his.Number = resThree.Output.Data.MdtrtID
  5733. his.PsnNo = resThree.Output.Data.PsnNo
  5734. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  5735. his.IdCardNo = patient.IdCardNo
  5736. his.PhoneNumber = patient.Phone
  5737. his.UserOrgId = adminInfo.CurrentOrgId
  5738. his.Insutype = insutype
  5739. his.Ctime = time.Now().Unix()
  5740. his.Mtime = time.Now().Unix()
  5741. his.InsuplcAdmdvs = insuplc_admdvs_temp
  5742. his.Status = 1
  5743. service.UpdateHisPatientStatus(&his)
  5744. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  5745. c.ServeSuccessJSON(map[string]interface{}{
  5746. "his_info": his,
  5747. })
  5748. } else {
  5749. adminUser := c.GetAdminUserInfo()
  5750. errlog := &models.HisOrderError{
  5751. UserOrgId: adminUser.CurrentOrgId,
  5752. Ctime: time.Now().Unix(),
  5753. Mtime: time.Now().Unix(),
  5754. ErrMsg: res.ErrMsg,
  5755. Status: 1,
  5756. PatientId: id,
  5757. RecordTime: recordDateTime,
  5758. Stage: 1,
  5759. }
  5760. service.CreateErrMsgLog(errlog)
  5761. c.ServeSuccessJSON(map[string]interface{}{
  5762. "failed_code": -10,
  5763. "msg": res.ErrMsg,
  5764. })
  5765. return
  5766. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  5767. }
  5768. }
  5769. }
  5770. //上传明细----预结算----确认订单
  5771. func (c *HisApiController) GetUploadInfo() {
  5772. id, _ := c.GetInt64("id")
  5773. record_time := c.GetString("record_time")
  5774. his_patient_id, _ := c.GetInt64("his_patient_id")
  5775. order_id, _ := c.GetInt64("order_id")
  5776. pay_way, _ := c.GetInt64("pay_way")
  5777. pay_price, _ := c.GetFloat("pay_price")
  5778. pay_card_no := c.GetString("pay_card_no")
  5779. discount_price, _ := c.GetFloat("discount_price")
  5780. preferential_price, _ := c.GetFloat("preferential_price")
  5781. reality_price, _ := c.GetFloat("reality_price")
  5782. found_price, _ := c.GetFloat("found_price")
  5783. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5784. private_price, _ := c.GetFloat("private_price")
  5785. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5786. admin_user_id, _ := c.GetInt64("admin_user_id")
  5787. fapiao_code := c.GetString("fapiao_code")
  5788. fapiao_number := c.GetString("fapiao_number")
  5789. diagnosis_id := c.GetString("diagnosis")
  5790. sick_type, _ := c.GetInt64("sick_type")
  5791. reg_type, _ := c.GetInt64("p_type")
  5792. begin_time := c.GetString("begin_time")
  5793. id_str := c.GetString("ids")
  5794. ids_arr := strings.Split(id_str, ",")
  5795. timeLayout := "2006-01-02"
  5796. loc, _ := time.LoadLocation("Local")
  5797. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5798. if err != nil {
  5799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5800. return
  5801. }
  5802. recordDateTime := theTime.Unix()
  5803. adminUser := c.GetAdminUserInfo()
  5804. var tempOrder models.HisOrder
  5805. tempOrder, _ = service.GetHisOrderByID(order_id)
  5806. var prescriptions []*models.HisPrescription
  5807. var start_time int64
  5808. var end_time int64
  5809. //押金模块
  5810. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  5811. tmp_decimal := c.GetString("tmp_decimal")
  5812. var decimal float64 //本次使用的押金
  5813. var errmsg error
  5814. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  5815. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  5816. return
  5817. }
  5818. if len(tmp_decimal) > 0 {
  5819. if tmp_decimal[0] == 45 {
  5820. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  5821. return
  5822. }
  5823. }
  5824. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  5825. fmt.Println(errs)
  5826. decimal = tt
  5827. //if adminUser.CurrentOrgId == 10106{
  5828. // if len(fapiao_code) == 0{
  5829. // fapiao_code = "144072080589"
  5830. // }
  5831. // if len(fapiao_number) == 0{
  5832. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  5833. // if order.ID == 0{
  5834. // fapiao_number = "00001520"
  5835. // }else{
  5836. // //fapiao_code = "00001520"
  5837. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  5838. // var zero string
  5839. // if fpNumber >= 1000{
  5840. // zero = "0000" + strconv.Itoa(fpNumber)
  5841. // }else if fpNumber >= 10000{
  5842. // zero = "000" + strconv.Itoa(fpNumber)
  5843. // } else if fpNumber >= 100000{
  5844. // zero = "00" + strconv.Itoa(fpNumber)
  5845. // } else if fpNumber >= 1000000{
  5846. // zero = "0" + strconv.Itoa(fpNumber)
  5847. // }else {
  5848. // zero = strconv.Itoa(fpNumber)
  5849. // }
  5850. // fapiao_number = zero
  5851. // }
  5852. // }
  5853. //}
  5854. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5855. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5856. var patientPrescription models.HisPrescriptionInfo
  5857. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5858. if patientPrescription.ID == 0 {
  5859. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5860. }
  5861. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5862. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5863. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5864. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5865. var config []*models.HisXtDiagnoseConfig
  5866. for _, item := range diagnosis_ids {
  5867. id, _ := strconv.ParseInt(item, 10, 64)
  5868. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5869. config = append(config, &diagnosisConfig)
  5870. }
  5871. sickConfig, _ := service.FindSickById(sick_type)
  5872. //if tempOrder.ID == 0 {
  5873. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  5874. //}
  5875. if tempOrder.ID == 0 {
  5876. var result string
  5877. var requestLog string
  5878. var res2 ResultSix
  5879. var ressix10265 ResultSix10265
  5880. if miConfig.MdtrtareaAdmvs == "421300" {
  5881. data := make(map[string]interface{})
  5882. client := &http.Client{}
  5883. data["psn_no"] = his.PsnNo
  5884. data["mdtrt_id"] = his.Number
  5885. data["opter"] = roles.UserName
  5886. data["org_name"] = miConfig.OrgName
  5887. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5888. data["doctor_id"] = doctor_info.DoctorNumber
  5889. data["doctor_name"] = doctor_info.UserName
  5890. data["department"] = department.Name
  5891. data["fixmedins_code"] = miConfig.Code
  5892. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5893. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5894. data["secret_key"] = miConfig.SecretKey
  5895. data["sick_code"] = sickConfig.CountryCode
  5896. data["sick_name"] = sickConfig.ClassName
  5897. data["dept"] = strconv.FormatInt(department.ID, 10)
  5898. data["config"] = config
  5899. data["begin_time"] = begin_time
  5900. bytesData, _ := json.Marshal(data)
  5901. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5902. resp, _ := client.Do(req)
  5903. defer resp.Body.Close()
  5904. body, ioErr := ioutil.ReadAll(resp.Body)
  5905. if ioErr != nil {
  5906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5908. return
  5909. }
  5910. var respJSON map[string]interface{}
  5911. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5914. return
  5915. }
  5916. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5917. userJSONBytes, _ := json.Marshal(respJSON)
  5918. fmt.Println("log")
  5919. fmt.Println(string(userJSONBytes))
  5920. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5921. utils.ErrorLog("解析失败:%v", err)
  5922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5923. return
  5924. }
  5925. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5926. data := make(map[string]interface{})
  5927. client := &http.Client{}
  5928. data["psn_no"] = his.PsnNo
  5929. data["mdtrt_id"] = his.Number
  5930. data["doctor"] = roles.UserName
  5931. data["department"] = department.Name
  5932. data["org_name"] = miConfig.OrgName
  5933. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5934. data["doctor_id"] = doctor_info.DoctorNumber
  5935. data["new_doctor_name"] = doctor_info.UserName
  5936. data["fixmedins_code"] = miConfig.Code
  5937. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5938. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5939. data["secret_key"] = miConfig.SecretKey
  5940. data["sick_code"] = sickConfig.CountryCode
  5941. data["sick_name"] = sickConfig.ClassName
  5942. data["url"] = miConfig.Url
  5943. data["ak"] = miConfig.AccessKey
  5944. data["begin_time"] = begin_time
  5945. data["cainfo"] = miConfig.Cainfo
  5946. data["dept"] = strconv.FormatInt(department.ID, 10)
  5947. data["config"] = config
  5948. bytesData, _ := json.Marshal(data)
  5949. var req *http.Request
  5950. if miConfig.MdtrtareaAdmvs == "320921" {
  5951. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5952. //api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5953. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5954. } else {
  5955. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5956. }
  5957. resp, _ := client.Do(req)
  5958. defer resp.Body.Close()
  5959. body, ioErr := ioutil.ReadAll(resp.Body)
  5960. if ioErr != nil {
  5961. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5963. return
  5964. }
  5965. var respJSON map[string]interface{}
  5966. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5969. return
  5970. }
  5971. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5972. userJSONBytes, _ := json.Marshal(respJSON)
  5973. fmt.Println("log")
  5974. fmt.Println(string(userJSONBytes))
  5975. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5976. utils.ErrorLog("解析失败:%v", err)
  5977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5978. return
  5979. }
  5980. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5981. res2.Output = ressix10265.Output
  5982. res2.ErrMsg = ressix10265.ErrMsg
  5983. res2.Cainfo = ressix10265.Cainfo
  5984. res2.WarnMsg = ressix10265.WarnMsg
  5985. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5986. res2.Infcode = infocode
  5987. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5988. result, requestLog, _ = service.FJyb2203(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, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5989. saveLog(result, requestLog, "2203", "上传就诊信息")
  5990. var respJSON2 map[string]interface{}
  5991. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5994. return
  5995. }
  5996. userJSONBytes2, _ := json.Marshal(respJSON2)
  5997. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5998. utils.ErrorLog("解析失败:%v", err)
  5999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6000. return
  6001. }
  6002. } else {
  6003. if miConfig.MdtrtareaAdmvs == "440781" { //
  6004. 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)
  6005. } else {
  6006. if miConfig.Code == "H15049901371" {
  6007. //赤峰地区国家医保医疗类别
  6008. //职工透析:医疗类别选特殊情况门诊990502
  6009. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6010. var med_type string
  6011. if his.Insutype == "390" {
  6012. if reg_type == 14 {
  6013. med_type = "9933"
  6014. } else if reg_type == 11 {
  6015. med_type = "11"
  6016. }
  6017. } else if his.Insutype == "310" {
  6018. if reg_type == 14 {
  6019. med_type = "990502"
  6020. } else if reg_type == 11 {
  6021. med_type = "11"
  6022. }
  6023. }
  6024. 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)
  6025. } else {
  6026. 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)
  6027. }
  6028. }
  6029. saveLog(result, requestLog, "2203", "上传就诊信息")
  6030. var respJSON2 map[string]interface{}
  6031. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6032. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6034. return
  6035. }
  6036. userJSONBytes2, _ := json.Marshal(respJSON2)
  6037. if miConfig.Code == "H15049901371" {
  6038. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  6039. utils.ErrorLog("解析失败:%v", err)
  6040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6041. return
  6042. }
  6043. res2.InfRefmsgid = ressix10265.InfRefmsgid
  6044. res2.Output = ressix10265.Output
  6045. res2.ErrMsg = ressix10265.ErrMsg
  6046. res2.Cainfo = ressix10265.Cainfo
  6047. res2.WarnMsg = ressix10265.WarnMsg
  6048. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  6049. res2.Infcode = infocode
  6050. } else {
  6051. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6052. utils.ErrorLog("解析失败:%v", err)
  6053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6054. return
  6055. }
  6056. }
  6057. }
  6058. if res2.Infcode != 0 {
  6059. adminUser := c.GetAdminUserInfo()
  6060. errlog := &models.HisOrderError{
  6061. UserOrgId: adminUser.CurrentOrgId,
  6062. Ctime: time.Now().Unix(),
  6063. Mtime: time.Now().Unix(),
  6064. ErrMsg: res2.ErrMsg,
  6065. Status: 1,
  6066. PatientId: id,
  6067. RecordTime: recordDateTime,
  6068. Stage: 3,
  6069. }
  6070. service.CreateErrMsgLog(errlog)
  6071. c.ServeSuccessJSON(map[string]interface{}{
  6072. "failed_code": -10,
  6073. "msg": res2.ErrMsg,
  6074. })
  6075. return
  6076. } else {
  6077. his.Diagnosis = diagnosis_id
  6078. his.SickType = sickConfig.ID
  6079. //var p_type int64
  6080. //if reg_type == 1111 || reg_type == 1112 {
  6081. // p_type = 11
  6082. //
  6083. //}
  6084. his.PType = fmt.Sprintf("%d", reg_type)
  6085. service.UpdateHisPatientThree(&his)
  6086. data := make(map[string]interface{})
  6087. if settle_accounts_type == 1 { //日结
  6088. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6089. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6090. } else {
  6091. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6092. }
  6093. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  6094. data["pre"] = prescriptions
  6095. } else { //月结
  6096. start_time_str := c.GetString("start_time")
  6097. end_time_str := c.GetString("end_time")
  6098. timeLayout := "2006-01-02"
  6099. loc, _ := time.LoadLocation("Local")
  6100. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6101. if err != nil {
  6102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6103. return
  6104. }
  6105. recordStartTime := theStartTime.Unix()
  6106. start_time = recordStartTime
  6107. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6108. if err != nil {
  6109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6110. return
  6111. }
  6112. recordEndTime := theEndTime.Unix()
  6113. end_time = recordEndTime
  6114. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6115. data["pre"] = prescriptions
  6116. }
  6117. timestamp := time.Now().Unix()
  6118. tempTime := time.Unix(timestamp, 0)
  6119. timeFormat := tempTime.Format("20060102150405")
  6120. chrgBchno := rand.Intn(100000) + 10000
  6121. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6122. strconv.FormatInt(his.PatientId, 10)
  6123. client := &http.Client{}
  6124. data["psn_no"] = his.PsnNo
  6125. data["mdtrt_id"] = his.Number
  6126. data["chrg_bchno"] = chrg_bchno
  6127. data["org_name"] = miConfig.OrgName
  6128. data["doctor"] = doctor_info.UserName
  6129. data["doctor_id"] = doctor_info.DoctorNumber
  6130. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6131. data["fixmedins_code"] = miConfig.Code
  6132. data["opter"] = roles.UserName
  6133. data["dept_code"] = department.Number
  6134. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6135. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6136. data["secret_key"] = miConfig.SecretKey
  6137. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  6138. data["url"] = miConfig.Url
  6139. data["ak"] = miConfig.AccessKey
  6140. data["new_doctor_name"] = patientPrescription.Doctor
  6141. data["diag_code"] = sickConfig.CountryCode
  6142. data["cainfo"] = miConfig.Cainfo
  6143. var ids []int64
  6144. for _, item := range prescriptions {
  6145. ids = append(ids, item.ID)
  6146. }
  6147. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6148. if config.IsOpen == 1 { //对接了医保,走医保流程
  6149. var res ResultFour
  6150. var resFour10265 ResultFour10265
  6151. if miConfig.MdtrtareaAdmvs == "421300" {
  6152. bytesData, _ := json.Marshal(data)
  6153. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  6154. resp, _ := client.Do(req)
  6155. defer resp.Body.Close()
  6156. body, ioErr := ioutil.ReadAll(resp.Body)
  6157. if ioErr != nil {
  6158. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6160. return
  6161. }
  6162. var respJSON map[string]interface{}
  6163. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6166. return
  6167. }
  6168. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6169. userJSONBytes, _ := json.Marshal(respJSON)
  6170. fmt.Println("log")
  6171. fmt.Println(string(userJSONBytes))
  6172. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6173. utils.ErrorLog("解析失败:%v", err)
  6174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6175. return
  6176. }
  6177. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6178. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  6179. if result3101.Infcode == "0" {
  6180. if len(result3101.Output.Result) > 0 {
  6181. var errMsgs []string
  6182. for _, item := range result3101.Output.Result {
  6183. errMsgs = append(errMsgs, item.VolaCont)
  6184. }
  6185. c.ServeSuccessJSON(map[string]interface{}{
  6186. "failed_code": -10,
  6187. "msg": errMsgs,
  6188. })
  6189. return
  6190. }
  6191. }
  6192. bytesData, _ := json.Marshal(data)
  6193. var req *http.Request
  6194. if miConfig.MdtrtareaAdmvs == "320921" {
  6195. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6196. } else {
  6197. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6198. }
  6199. resp, _ := client.Do(req)
  6200. defer resp.Body.Close()
  6201. body, ioErr := ioutil.ReadAll(resp.Body)
  6202. if ioErr != nil {
  6203. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6205. return
  6206. }
  6207. var respJSON map[string]interface{}
  6208. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6209. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6211. return
  6212. }
  6213. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6214. userJSONBytes, _ := json.Marshal(respJSON)
  6215. fmt.Println("log")
  6216. fmt.Println(string(userJSONBytes))
  6217. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6218. utils.ErrorLog("解析失败:%v", err)
  6219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6220. return
  6221. }
  6222. res.InfRefmsgid = resFour10265.InfRefmsgid
  6223. res.Output = resFour10265.Output
  6224. res.ErrMsg = resFour10265.ErrMsg
  6225. res.Cainfo = resFour10265.Cainfo
  6226. res.WarnMsg = resFour10265.WarnMsg
  6227. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6228. res.Infcode = infocode
  6229. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6230. result, request_log, _ := service.FJyb2204(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), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode)
  6231. var dat map[string]interface{}
  6232. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6233. fmt.Println(dat)
  6234. } else {
  6235. fmt.Println(err)
  6236. }
  6237. saveLog(result, request_log, "2204", "上传费用明细")
  6238. userJSONBytes, _ := json.Marshal(dat)
  6239. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6240. utils.ErrorLog("解析失败:%v", err)
  6241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6242. return
  6243. }
  6244. res.InfRefmsgid = resFour10265.InfRefmsgid
  6245. res.Output = resFour10265.Output
  6246. res.ErrMsg = resFour10265.ErrMsg
  6247. res.Cainfo = resFour10265.Cainfo
  6248. res.WarnMsg = resFour10265.WarnMsg
  6249. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6250. res.Infcode = infocode
  6251. } else {
  6252. if miConfig.Code == "H15049901371" {
  6253. 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)
  6254. var dat map[string]interface{}
  6255. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6256. fmt.Println(dat)
  6257. } else {
  6258. fmt.Println(err)
  6259. }
  6260. saveLog(result, request_log, "2204", "上传费用明细")
  6261. userJSONBytes, _ := json.Marshal(dat)
  6262. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6263. utils.ErrorLog("解析失败:%v", err)
  6264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6265. return
  6266. }
  6267. res.InfRefmsgid = resFour10265.InfRefmsgid
  6268. res.Output = resFour10265.Output
  6269. res.ErrMsg = resFour10265.ErrMsg
  6270. res.Cainfo = resFour10265.Cainfo
  6271. res.WarnMsg = resFour10265.WarnMsg
  6272. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6273. res.Infcode = infocode
  6274. } else {
  6275. 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)
  6276. var dat map[string]interface{}
  6277. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6278. fmt.Println(dat)
  6279. } else {
  6280. fmt.Println(err)
  6281. }
  6282. saveLog(result, request_log, "2204", "上传费用明细")
  6283. userJSONBytes, _ := json.Marshal(dat)
  6284. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6285. utils.ErrorLog("解析失败:%v", err)
  6286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6287. return
  6288. }
  6289. }
  6290. }
  6291. if res.Infcode == 0 {
  6292. order := &models.HisOrder{
  6293. UserOrgId: adminUser.CurrentOrgId,
  6294. HisPatientId: his.ID,
  6295. PatientId: his.PatientId,
  6296. SettleAccountsDate: recordDateTime,
  6297. MdtrtId: his.Number,
  6298. PsnNo: his.PsnNo,
  6299. MedType: strconv.FormatInt(reg_type, 10),
  6300. Ctime: time.Now().Unix(),
  6301. Mtime: time.Now().Unix(),
  6302. Status: 1,
  6303. Number: chrg_bchno,
  6304. Infcode: res.Infcode,
  6305. WarnMsg: res.WarnMsg,
  6306. Cainfo: res.Cainfo,
  6307. ErrMsg: res.ErrMsg,
  6308. RespondTime: res.RefmsgTime,
  6309. InfRefmsgid: res.InfRefmsgid,
  6310. OrderStatus: 1,
  6311. PayWay: pay_way,
  6312. PayPrice: pay_price,
  6313. PayCardNo: pay_card_no,
  6314. DiscountPrice: discount_price,
  6315. PreferentialPrice: preferential_price,
  6316. RealityPrice: reality_price,
  6317. FoundPrice: found_price,
  6318. MedicalInsurancePrice: medical_insurance_price,
  6319. PrivatePrice: private_price,
  6320. IsMedicineInsurance: 1,
  6321. SettleType: settle_accounts_type,
  6322. SettleStartTime: start_time,
  6323. SettleEndTime: end_time,
  6324. Creator: roles.AdminUserId,
  6325. Modify: roles.AdminUserId,
  6326. FaPiaoNumber: fapiao_number,
  6327. FaPiaoCode: fapiao_code,
  6328. PType: 2,
  6329. Diagnosis: diagnosis_id,
  6330. }
  6331. err = service.CreateOrder(order)
  6332. if err != nil {
  6333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6334. return
  6335. }
  6336. for _, item := range res.Output.Result {
  6337. temp := strings.Split(item.FeedetlSn, "-")
  6338. var advice_id int64 = 0
  6339. var project_id int64 = 0
  6340. var types int64 = 0
  6341. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6342. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6343. if temp[1] == "1" {
  6344. advice_id = id
  6345. project_id = 0
  6346. } else if temp[1] == "2" {
  6347. advice_id = 0
  6348. project_id = id
  6349. }
  6350. info := &models.HisOrderInfo{
  6351. OrderNumber: order.Number,
  6352. FeedetlSn: item.FeedetlSn,
  6353. UploadDate: time.Now().Unix(),
  6354. AdviceId: advice_id,
  6355. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6356. Cnt: item.Cnt,
  6357. Pric: float64(item.Pric),
  6358. PatientId: his.PatientId,
  6359. PricUplmtAmt: item.PricUplmtAmt,
  6360. SelfpayProp: item.SelfpayProp,
  6361. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6362. OverlmtAmt: item.OverlmtAmt,
  6363. PreselfpayAmt: item.PreselfpayAmt,
  6364. BasMednFlag: item.BasMednFlag,
  6365. MedChrgitmType: item.MedChrgitmType,
  6366. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6367. Status: 1,
  6368. Memo: item.Memo,
  6369. Mtime: time.Now().Unix(),
  6370. InscpScpAmt: item.InscpScpAmt,
  6371. DrtReimFlag: item.DrtReimFlag,
  6372. Ctime: time.Now().Unix(),
  6373. ListSpItemFlag: item.ListSpItemFlag,
  6374. ChldMedcFlag: item.ChldMedcFlag,
  6375. LmtUsedFlag: item.LmtUsedFlag,
  6376. ChrgitmLv: item.ChrgitmLv,
  6377. UserOrgId: adminUser.CurrentOrgId,
  6378. HisPatientId: his.ID,
  6379. OrderId: order.ID,
  6380. ProjectId: project_id,
  6381. Type: types,
  6382. }
  6383. service.CreateOrderInfo(info)
  6384. }
  6385. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6386. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6387. var total float64
  6388. for _, item := range prescriptions {
  6389. if item.Type == 1 { //药品
  6390. for _, subItem := range item.HisDoctorAdviceInfo {
  6391. total = total + (subItem.Price * subItem.PrescribingNumber)
  6392. }
  6393. }
  6394. if item.Type == 2 { //项目
  6395. for _, subItem := range item.HisPrescriptionProject {
  6396. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6397. total = total + (subItem.Price * cnt)
  6398. }
  6399. }
  6400. }
  6401. for _, item := range prescriptions {
  6402. for _, subItem := range item.HisAdditionalCharge {
  6403. total = total + (subItem.Price * float64(subItem.Count))
  6404. }
  6405. }
  6406. var allTotal string
  6407. if adminUser.CurrentOrgId == 9919 {
  6408. allTotal = fmt.Sprintf("%.4f", total)
  6409. } else {
  6410. allTotal = fmt.Sprintf("%.4f", total)
  6411. }
  6412. if res.Infcode == 0 {
  6413. var rf []*ResultFive
  6414. json.Unmarshal([]byte(his.Iinfo), &rf)
  6415. chrg_bchno := chrg_bchno
  6416. cert_no := his.Certno
  6417. var insutypes []string
  6418. var insutype string
  6419. var is390 int = 0
  6420. var is310 int = 0
  6421. for _, item := range rf {
  6422. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6423. insutypes = append(insutypes, item.Insutype)
  6424. }
  6425. }
  6426. if len(insutypes) == 1 {
  6427. insutype = insutypes[0]
  6428. } else {
  6429. for _, i := range insutypes {
  6430. if i == "390" {
  6431. is390 = 1
  6432. }
  6433. if i == "310" {
  6434. is310 = 1
  6435. }
  6436. }
  6437. }
  6438. if is390 == 1 {
  6439. insutype = "390"
  6440. }
  6441. if is310 == 1 {
  6442. insutype = "310"
  6443. }
  6444. if len(insutypes) == 0 {
  6445. insutype = "310"
  6446. }
  6447. if len(insutypes) == 2 {
  6448. insutype = strconv.FormatInt(his.SocialType, 10)
  6449. }
  6450. insutype = strconv.FormatInt(his.SocialType, 10)
  6451. //insutype = "390"
  6452. if his.IdCardType == 1 {
  6453. // cert_no = his.MedicalInsuranceNumber
  6454. cert_no = his.Certno
  6455. } else {
  6456. cert_no = his.Certno
  6457. }
  6458. var res ResultSeven
  6459. var resSeven10265 ResultSeven10265
  6460. var src_resquest string
  6461. var result2 string
  6462. var acct_used_flag string
  6463. fmt.Println("pay_way")
  6464. fmt.Println(pay_way)
  6465. fmt.Println("pay_way")
  6466. if pay_way == 4 {
  6467. acct_used_flag = "1"
  6468. } else {
  6469. acct_used_flag = "0"
  6470. }
  6471. if miConfig.MdtrtareaAdmvs == "421300" {
  6472. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6473. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6474. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6475. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6476. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6477. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6478. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6479. resp, requestErr := http.Get(api)
  6480. if requestErr != nil {
  6481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6482. return
  6483. }
  6484. body, ioErr := ioutil.ReadAll(resp.Body)
  6485. if ioErr != nil {
  6486. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6488. return
  6489. }
  6490. var respJSON map[string]interface{}
  6491. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6492. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6494. return
  6495. }
  6496. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6497. result, _ := json.Marshal(respJSON)
  6498. if miConfig.Code == "H15049901371" {
  6499. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6500. utils.ErrorLog("解析失败:%v", err)
  6501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6502. return
  6503. }
  6504. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6505. res.Output = resSeven10265.Output
  6506. res.ErrMsg = resSeven10265.ErrMsg
  6507. res.Cainfo = resSeven10265.Cainfo
  6508. res.WarnMsg = resSeven10265.WarnMsg
  6509. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6510. res.Infcode = infocode
  6511. } else {
  6512. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6513. utils.ErrorLog("解析失败:%v", err)
  6514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6515. return
  6516. }
  6517. }
  6518. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6519. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  6520. if result3101.Infcode == "0" {
  6521. if len(result3101.Output.Result) > 0 {
  6522. var errMsgs []string
  6523. for _, item := range result3101.Output.Result {
  6524. errMsgs = append(errMsgs, item.VolaCont)
  6525. }
  6526. c.ServeSuccessJSON(map[string]interface{}{
  6527. "failed_code": -10,
  6528. "msg": errMsgs,
  6529. })
  6530. return
  6531. } else {
  6532. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6533. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6534. bas := strings.Split(psn_info.CardInfo, "|")
  6535. if his.IdCardType == 1 {
  6536. cert_no = bas[2]
  6537. } else if his.IdCardType == 3 {
  6538. cert_no = his.Certno
  6539. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  6540. } else if his.IdCardType == 4 {
  6541. cert_no = his.Certno
  6542. psn_info.VerifyNumber = psn_info.VerifyNumber
  6543. }
  6544. var api string
  6545. if miConfig.MdtrtareaAdmvs == "320921" {
  6546. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6547. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6548. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6549. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6550. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6551. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6552. "&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
  6553. } else {
  6554. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6555. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6556. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6557. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6558. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6559. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6560. "&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
  6561. }
  6562. resp, requestErr := http.Get(api)
  6563. if requestErr != nil {
  6564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6565. return
  6566. }
  6567. body, ioErr := ioutil.ReadAll(resp.Body)
  6568. if ioErr != nil {
  6569. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6571. return
  6572. }
  6573. var respJSON map[string]interface{}
  6574. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6577. return
  6578. }
  6579. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6580. result, _ := json.Marshal(respJSON)
  6581. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6582. utils.ErrorLog("解析失败:%v", err)
  6583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6584. return
  6585. }
  6586. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6587. res.Output = resSeven10265.Output
  6588. res.ErrMsg = resSeven10265.ErrMsg
  6589. res.Cainfo = resSeven10265.Cainfo
  6590. res.WarnMsg = resSeven10265.WarnMsg
  6591. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6592. res.Infcode = infocode
  6593. }
  6594. }
  6595. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6596. var cert_no string
  6597. if his.IdCardType == 4 {
  6598. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6599. cert_no = psn_info.VerifyNumber
  6600. result2, src_resquest, _ = service.FJyb2207ForToken(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, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  6601. } else if his.IdCardType == 1 {
  6602. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6603. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6604. result2, src_resquest, _ = service.FJyb2207(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, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  6605. }
  6606. //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)
  6607. var dat map[string]interface{}
  6608. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6609. fmt.Println(dat)
  6610. } else {
  6611. fmt.Println(err)
  6612. }
  6613. saveLog(result2, src_resquest, "2207", "结算")
  6614. userJSONBytes, _ := json.Marshal(dat)
  6615. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6616. utils.ErrorLog("解析失败:%v", err)
  6617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6618. return
  6619. }
  6620. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6621. res.Output = resSeven10265.Output
  6622. res.ErrMsg = resSeven10265.ErrMsg
  6623. res.Cainfo = resSeven10265.Cainfo
  6624. res.WarnMsg = resSeven10265.WarnMsg
  6625. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6626. res.Infcode = infocode
  6627. } else {
  6628. if miConfig.Code == "H15049901371" {
  6629. //赤峰地区国家医保医疗类别
  6630. //职工透析:医疗类别选特殊情况门诊990502
  6631. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6632. var med_type string
  6633. if his.Insutype == "390" {
  6634. if reg_type == 14 {
  6635. med_type = "9933"
  6636. } else if reg_type == 11 {
  6637. med_type = "11"
  6638. }
  6639. } else if his.Insutype == "310" {
  6640. if reg_type == 14 {
  6641. med_type = "990502"
  6642. } else if reg_type == 11 {
  6643. med_type = "11"
  6644. }
  6645. }
  6646. 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, "")
  6647. } else {
  6648. if his.IdCardType == 4 {
  6649. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6650. var token string
  6651. token = psn_info.VerifyNumber
  6652. 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, token)
  6653. } else {
  6654. 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, "")
  6655. }
  6656. }
  6657. //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)
  6658. var dat map[string]interface{}
  6659. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6660. fmt.Println(dat)
  6661. } else {
  6662. fmt.Println(err)
  6663. }
  6664. saveLog(result2, src_resquest, "2207", "结算")
  6665. userJSONBytes, _ := json.Marshal(dat)
  6666. if miConfig.Code == "H15049901371" {
  6667. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6668. utils.ErrorLog("解析失败:%v", err)
  6669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6670. return
  6671. }
  6672. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6673. res.Output = resSeven10265.Output
  6674. res.ErrMsg = resSeven10265.ErrMsg
  6675. res.Cainfo = resSeven10265.Cainfo
  6676. res.WarnMsg = resSeven10265.WarnMsg
  6677. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6678. res.Infcode = infocode
  6679. } else {
  6680. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6681. utils.ErrorLog("解析失败:%v", err)
  6682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6683. return
  6684. }
  6685. }
  6686. }
  6687. if res.Infcode != 0 {
  6688. errlog := &models.HisOrderError{
  6689. UserOrgId: adminUser.CurrentOrgId,
  6690. Ctime: time.Now().Unix(),
  6691. Mtime: time.Now().Unix(),
  6692. Number: chrg_bchno,
  6693. ErrMsg: res.ErrMsg,
  6694. Status: 1,
  6695. PatientId: id,
  6696. RecordTime: recordDateTime,
  6697. Stage: 6,
  6698. }
  6699. service.CreateErrMsgLog(errlog)
  6700. c.ServeSuccessJSON(map[string]interface{}{
  6701. "failed_code": -10,
  6702. "msg": res.ErrMsg,
  6703. })
  6704. return
  6705. } else {
  6706. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6707. order.OrderStatus = 2
  6708. order.Status = 1
  6709. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6710. order.SetlId = res.Output.Setlinfo.SetlID
  6711. order.PsnNo = res.Output.Setlinfo.PsnNo
  6712. order.PsnName = res.Output.Setlinfo.PsnName
  6713. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6714. order.Certno = res.Output.Setlinfo.Certno
  6715. order.Gend = res.Output.Setlinfo.Gend
  6716. order.Naty = res.Output.Setlinfo.Naty
  6717. order.Age = res.Output.Setlinfo.Age
  6718. order.Insutype = res.Output.Setlinfo.Insutype
  6719. order.PsnType = res.Output.Setlinfo.PsnType
  6720. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6721. order.SetlTime = res.Output.Setlinfo.SetlTime
  6722. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6723. if res.Output.Setlinfo.MedType == "140101" {
  6724. order.MedType = "14"
  6725. } else {
  6726. order.MedType = res.Output.Setlinfo.MedType
  6727. }
  6728. if reg_type == 1112 {
  6729. order.MedType = "1112"
  6730. }
  6731. if reg_type == 1111 {
  6732. order.MedType = "1111"
  6733. }
  6734. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6735. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6736. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6737. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6738. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6739. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6740. order.HifpPay = res.Output.Setlinfo.HifpPay
  6741. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6742. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6743. order.HifesPay = res.Output.Setlinfo.HifesPay
  6744. order.HifobPay = res.Output.Setlinfo.HifobPay
  6745. order.MafPay = res.Output.Setlinfo.MafPay
  6746. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6747. order.OthPay = res.Output.Setlinfo.OthPay
  6748. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6749. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6750. order.AcctPay = res.Output.Setlinfo.AcctPay
  6751. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6752. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6753. order.Balc = res.Output.Setlinfo.Balc
  6754. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6755. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6756. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6757. order.ClrType = res.Output.Setlinfo.ClrType
  6758. order.ClrWay = res.Output.Setlinfo.ClrWay
  6759. order.Creator = order.Creator
  6760. order.Modify = roles.AdminUserId
  6761. order.RequestLog = src_resquest
  6762. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6763. detailStr := string(setlDetail)
  6764. order.SetlDetail = detailStr
  6765. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6766. err = service.UpDateOrder(order)
  6767. if err == nil {
  6768. //判断是否使用了押金
  6769. if dec_way == "true" {
  6770. tmpstring := strconv.FormatInt(order.ID, 10)
  6771. order.Decimal = decimal
  6772. service.UpDateOrder(order)
  6773. //扣押金
  6774. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6775. if errmsg != nil {
  6776. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6777. return
  6778. }
  6779. }
  6780. c.ServeSuccessJSON(map[string]interface{}{
  6781. "msg": "结算成功",
  6782. })
  6783. } else {
  6784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6785. return
  6786. }
  6787. }
  6788. } else {
  6789. adminUser := c.GetAdminUserInfo()
  6790. errlog := &models.HisOrderError{
  6791. UserOrgId: adminUser.CurrentOrgId,
  6792. Ctime: time.Now().Unix(),
  6793. Mtime: time.Now().Unix(),
  6794. ErrMsg: res.ErrMsg,
  6795. Status: 1,
  6796. PatientId: id,
  6797. RecordTime: recordDateTime,
  6798. Stage: 4,
  6799. }
  6800. service.CreateErrMsgLog(errlog)
  6801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6802. return
  6803. }
  6804. } else {
  6805. adminUser := c.GetAdminUserInfo()
  6806. errlog := &models.HisOrderError{
  6807. UserOrgId: adminUser.CurrentOrgId,
  6808. Ctime: time.Now().Unix(),
  6809. Mtime: time.Now().Unix(),
  6810. ErrMsg: res.ErrMsg,
  6811. Status: 1,
  6812. PatientId: id,
  6813. RecordTime: recordDateTime,
  6814. Stage: 4,
  6815. }
  6816. service.CreateErrMsgLog(errlog)
  6817. c.ServeSuccessJSON(map[string]interface{}{
  6818. "failed_code": -10,
  6819. "msg": res.ErrMsg,
  6820. })
  6821. return
  6822. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6823. //return
  6824. }
  6825. }
  6826. }
  6827. } else if tempOrder.ID > 0 {
  6828. if tempOrder.IsPre == 1 {
  6829. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  6830. var rf []*ResultFive
  6831. json.Unmarshal([]byte(his.Iinfo), &rf)
  6832. chrg_bchno := tempOrder.Number
  6833. cert_no := his.Certno
  6834. var insutypes []string
  6835. var insutype string
  6836. var is390 int = 0
  6837. var is310 int = 0
  6838. for _, item := range rf {
  6839. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6840. insutypes = append(insutypes, item.Insutype)
  6841. }
  6842. }
  6843. if len(insutypes) == 1 {
  6844. insutype = insutypes[0]
  6845. } else {
  6846. for _, i := range insutypes {
  6847. if i == "390" {
  6848. is390 = 1
  6849. }
  6850. if i == "310" {
  6851. is310 = 1
  6852. }
  6853. }
  6854. }
  6855. if is390 == 1 {
  6856. insutype = "390"
  6857. }
  6858. if is310 == 1 {
  6859. insutype = "310"
  6860. }
  6861. if len(insutypes) == 0 {
  6862. insutype = "310"
  6863. }
  6864. if len(insutypes) == 2 {
  6865. insutype = strconv.FormatInt(his.SocialType, 64)
  6866. }
  6867. //insutype = "390"
  6868. if his.IdCardType == 1 {
  6869. // cert_no = his.MedicalInsuranceNumber
  6870. cert_no = his.Certno
  6871. } else {
  6872. cert_no = his.Certno
  6873. }
  6874. var res ResultSeven
  6875. var resSeven10265 ResultSeven10265
  6876. var src_resquest string
  6877. var result2 string
  6878. var acct_used_flag string
  6879. fmt.Println("pay_way")
  6880. fmt.Println(pay_way)
  6881. fmt.Println("pay_way")
  6882. if pay_way == 4 {
  6883. acct_used_flag = "1"
  6884. } else {
  6885. acct_used_flag = "0"
  6886. }
  6887. if miConfig.MdtrtareaAdmvs == "421300" {
  6888. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6889. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6890. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6891. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6892. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6893. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6894. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6895. resp, requestErr := http.Get(api)
  6896. if requestErr != nil {
  6897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6898. return
  6899. }
  6900. body, ioErr := ioutil.ReadAll(resp.Body)
  6901. if ioErr != nil {
  6902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6904. return
  6905. }
  6906. var respJSON map[string]interface{}
  6907. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6910. return
  6911. }
  6912. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6913. result, _ := json.Marshal(respJSON)
  6914. fmt.Println("log")
  6915. fmt.Println(string(result))
  6916. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6917. utils.ErrorLog("解析失败:%v", err)
  6918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6919. return
  6920. }
  6921. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6922. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  6923. if result3101.Infcode == "0" {
  6924. if len(result3101.Output.Result) > 0 {
  6925. var errMsgs []string
  6926. for _, item := range result3101.Output.Result {
  6927. errMsgs = append(errMsgs, item.VolaCont)
  6928. }
  6929. c.ServeSuccessJSON(map[string]interface{}{
  6930. "failed_code": -10,
  6931. "msg": errMsgs,
  6932. })
  6933. return
  6934. } else {
  6935. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6936. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6937. bas := strings.Split(psn_info.CardInfo, "|")
  6938. if his.IdCardType == 1 {
  6939. cert_no = bas[2]
  6940. } else if his.IdCardType == 3 {
  6941. cert_no = his.Certno
  6942. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  6943. } else if his.IdCardType == 4 {
  6944. cert_no = his.Certno
  6945. psn_info.VerifyNumber = psn_info.VerifyNumber
  6946. }
  6947. //江苏地区国家医保医疗类别
  6948. //职工透析:医疗类别选特殊情况门诊9933
  6949. //居民血透门慢: 医疗类别选门诊慢病1402
  6950. //var med_type string
  6951. //if his.Insutype == "310" {
  6952. // if reg_type == 14 {
  6953. // med_type = "9933"
  6954. // } else if reg_type == 11 {
  6955. // med_type = "11"
  6956. //
  6957. // }
  6958. //} else if his.Insutype == "390" {
  6959. // if reg_type == 14 {
  6960. // med_type = "1402"
  6961. // } else if reg_type == 11 {
  6962. // med_type = "11"
  6963. // }
  6964. //}
  6965. var api string
  6966. if miConfig.MdtrtareaAdmvs == "320921" {
  6967. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6968. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6969. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6970. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6971. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6972. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6973. "&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
  6974. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6975. } else {
  6976. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6977. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6978. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6979. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6980. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6981. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6982. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6983. "&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
  6984. }
  6985. resp, requestErr := http.Get(api)
  6986. if requestErr != nil {
  6987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6988. return
  6989. }
  6990. body, ioErr := ioutil.ReadAll(resp.Body)
  6991. if ioErr != nil {
  6992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6994. return
  6995. }
  6996. var respJSON map[string]interface{}
  6997. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7000. return
  7001. }
  7002. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7003. result, _ := json.Marshal(respJSON)
  7004. fmt.Println("log")
  7005. fmt.Println(string(result))
  7006. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7007. utils.ErrorLog("解析失败:%v", err)
  7008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7009. return
  7010. }
  7011. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7012. res.Output = resSeven10265.Output
  7013. res.ErrMsg = resSeven10265.ErrMsg
  7014. res.Cainfo = resSeven10265.Cainfo
  7015. res.WarnMsg = resSeven10265.WarnMsg
  7016. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7017. res.Infcode = infocode
  7018. }
  7019. }
  7020. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7021. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7022. var cert_no string
  7023. if his.IdCardType == 1 {
  7024. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  7025. } else {
  7026. cert_no = psn_info.VerifyNumber
  7027. }
  7028. result2, src_resquest, _ = service.FJyb2207(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, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7029. var dat map[string]interface{}
  7030. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7031. fmt.Println(dat)
  7032. } else {
  7033. fmt.Println(err)
  7034. }
  7035. saveLog(result2, src_resquest, "2207", "结算")
  7036. userJSONBytes, _ := json.Marshal(dat)
  7037. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7038. utils.ErrorLog("解析失败:%v", err)
  7039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7040. return
  7041. }
  7042. } else {
  7043. var src_resquest string
  7044. if miConfig.Code == "H15049901371" {
  7045. //赤峰地区国家医保医疗类别
  7046. //职工透析:医疗类别选特殊情况门诊990502
  7047. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7048. var med_type string
  7049. if his.Insutype == "390" {
  7050. if reg_type == 14 {
  7051. med_type = "9933"
  7052. } else if reg_type == 11 {
  7053. med_type = "11"
  7054. }
  7055. } else if his.Insutype == "310" {
  7056. if reg_type == 14 {
  7057. med_type = "990502"
  7058. } else if reg_type == 11 {
  7059. med_type = "11"
  7060. }
  7061. }
  7062. 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, "")
  7063. } else {
  7064. if his.IdCardType == 4 {
  7065. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7066. token := psn_info.VerifyNumber
  7067. 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, token)
  7068. } else {
  7069. 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, "")
  7070. }
  7071. }
  7072. var dat map[string]interface{}
  7073. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7074. fmt.Println(dat)
  7075. } else {
  7076. fmt.Println(err)
  7077. }
  7078. saveLog(result2, src_resquest, "2207", "结算")
  7079. userJSONBytes, _ := json.Marshal(dat)
  7080. if miConfig.Code == "H15049901371" {
  7081. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7082. utils.ErrorLog("解析失败:%v", err)
  7083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7084. return
  7085. }
  7086. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7087. res.Output = resSeven10265.Output
  7088. res.ErrMsg = resSeven10265.ErrMsg
  7089. res.Cainfo = resSeven10265.Cainfo
  7090. res.WarnMsg = resSeven10265.WarnMsg
  7091. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7092. res.Infcode = infocode
  7093. } else {
  7094. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7095. utils.ErrorLog("解析失败:%v", err)
  7096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7097. return
  7098. }
  7099. }
  7100. }
  7101. if res.Infcode != 0 {
  7102. errlog := &models.HisOrderError{
  7103. UserOrgId: adminUser.CurrentOrgId,
  7104. Ctime: time.Now().Unix(),
  7105. Mtime: time.Now().Unix(),
  7106. Number: chrg_bchno,
  7107. ErrMsg: res.ErrMsg,
  7108. Status: 1,
  7109. PatientId: id,
  7110. RecordTime: recordDateTime,
  7111. Stage: 6,
  7112. }
  7113. service.CreateErrMsgLog(errlog)
  7114. c.ServeSuccessJSON(map[string]interface{}{
  7115. "failed_code": -10,
  7116. "msg": res.ErrMsg,
  7117. })
  7118. return
  7119. } else {
  7120. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7121. order.OrderStatus = 2
  7122. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7123. order.SetlId = res.Output.Setlinfo.SetlID
  7124. order.PsnNo = res.Output.Setlinfo.PsnNo
  7125. order.PsnName = res.Output.Setlinfo.PsnName
  7126. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7127. order.Certno = res.Output.Setlinfo.Certno
  7128. order.Gend = res.Output.Setlinfo.Gend
  7129. order.Naty = res.Output.Setlinfo.Naty
  7130. order.Age = res.Output.Setlinfo.Age
  7131. order.Insutype = res.Output.Setlinfo.Insutype
  7132. order.PsnType = res.Output.Setlinfo.PsnType
  7133. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7134. order.SetlTime = res.Output.Setlinfo.SetlTime
  7135. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7136. //order.MedType = res.Output.Setlinfo.MedType
  7137. if reg_type == 1112 {
  7138. order.MedType = "1112"
  7139. }
  7140. if reg_type == 1111 {
  7141. order.MedType = "1111"
  7142. }
  7143. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7144. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7145. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7146. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7147. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7148. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7149. order.HifpPay = res.Output.Setlinfo.HifpPay
  7150. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7151. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7152. order.HifesPay = res.Output.Setlinfo.HifesPay
  7153. order.HifobPay = res.Output.Setlinfo.HifobPay
  7154. order.MafPay = res.Output.Setlinfo.MafPay
  7155. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7156. order.OthPay = res.Output.Setlinfo.OthPay
  7157. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7158. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7159. order.AcctPay = res.Output.Setlinfo.AcctPay
  7160. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7161. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7162. order.Balc = res.Output.Setlinfo.Balc
  7163. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7164. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7165. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7166. order.ClrWay = res.Output.Setlinfo.ClrWay
  7167. order.Creator = order.Creator
  7168. order.Modify = roles.AdminUserId
  7169. order.RequestLog = src_resquest
  7170. order.Diagnosis = diagnosis_id
  7171. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7172. detailStr := string(setlDetail)
  7173. order.SetlDetail = detailStr
  7174. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7175. err = service.UpDateOrder(order)
  7176. if err == nil {
  7177. //判断是否使用了押金
  7178. if dec_way == "true" {
  7179. tmpstring := strconv.FormatInt(order.ID, 10)
  7180. //扣押金
  7181. order.Decimal = decimal
  7182. service.UpDateOrder(order)
  7183. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  7184. if errmsg != nil {
  7185. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  7186. return
  7187. }
  7188. }
  7189. c.ServeSuccessJSON(map[string]interface{}{
  7190. "msg": "结算成功",
  7191. })
  7192. } else {
  7193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7194. return
  7195. }
  7196. }
  7197. }
  7198. }
  7199. }
  7200. //func (c *HisApiController) GetPreUploadInfo() {
  7201. // id, _ := c.GetInt64("id")
  7202. // record_time := c.GetString("record_time")
  7203. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7204. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7205. //
  7206. // timeLayout := "2006-01-02"
  7207. // loc, _ := time.LoadLocation("Local")
  7208. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7209. // if err != nil {
  7210. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7211. // return
  7212. // }
  7213. // recordDateTime := theTime.Unix()
  7214. // adminUser := c.GetAdminUserInfo()
  7215. //
  7216. // var prescriptions []*models.HisPrescription
  7217. //
  7218. // var start_time int64
  7219. // var end_time int64
  7220. //
  7221. // data := make(map[string]interface{})
  7222. // if settle_accounts_type == 1 { //日结
  7223. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7224. // data["pre"] = prescriptions
  7225. //
  7226. // } else { //月结
  7227. // start_time_str := c.GetString("start_time")
  7228. // end_time_str := c.GetString("end_time")
  7229. // timeLayout := "2006-01-02"
  7230. // loc, _ := time.LoadLocation("Local")
  7231. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7232. // if err != nil {
  7233. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7234. // return
  7235. // }
  7236. // recordStartTime := theStartTime.Unix()
  7237. // start_time = recordStartTime
  7238. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7239. // if err != nil {
  7240. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7241. // return
  7242. // }
  7243. // recordEndTime := theEndTime.Unix()
  7244. // end_time = recordEndTime
  7245. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7246. // data["pre"] = prescriptions
  7247. //
  7248. // }
  7249. //
  7250. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7251. //
  7252. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7253. // timestamp := time.Now().Unix()
  7254. // tempTime := time.Unix(timestamp, 0)
  7255. // timeFormat := tempTime.Format("20060102150405")
  7256. // chrgBchno := rand.Intn(100000) + 10000
  7257. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7258. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7259. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7260. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7261. // strconv.FormatInt(his.PatientId, 10)
  7262. // client := &http.Client{}
  7263. // data["psn_no"] = his.PsnNo
  7264. // data["mdtrt_id"] = his.Number
  7265. // data["chrg_bchno"] = chrg_bchno
  7266. // data["org_name"] = miConfig.OrgName
  7267. // data["doctor"] = roles.UserName
  7268. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7269. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7270. // data["fixmedins_code"] = miConfig.Code
  7271. // data["dept_code"] = department.Number
  7272. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7273. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7274. // data["secret_key"] = miConfig.SecretKey
  7275. // var ids []int64
  7276. //
  7277. // for _, item := range prescriptions {
  7278. // ids = append(ids, item.ID)
  7279. // }
  7280. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7281. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7282. // bytesData, _ := json.Marshal(data)
  7283. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  7284. // resp, _ := client.Do(req)
  7285. // defer resp.Body.Close()
  7286. // body, ioErr := ioutil.ReadAll(resp.Body)
  7287. // if ioErr != nil {
  7288. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7289. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7290. // return
  7291. // }
  7292. // var respJSON map[string]interface{}
  7293. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7294. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7295. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7296. // return
  7297. // }
  7298. //
  7299. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7300. // userJSONBytes, _ := json.Marshal(respJSON)
  7301. // var res ResultFour
  7302. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7303. // utils.ErrorLog("解析失败:%v", err)
  7304. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7305. // return
  7306. // }
  7307. //
  7308. // if res.Infcode == 0 {
  7309. // order := &models.HisOrder{
  7310. // UserOrgId: adminUser.CurrentOrgId,
  7311. // HisPatientId: his.ID,
  7312. // PatientId: his.PatientId,
  7313. // SettleAccountsDate: recordDateTime,
  7314. // Ctime: time.Now().Unix(),
  7315. // Mtime: time.Now().Unix(),
  7316. // Status: 1,
  7317. // Number: chrg_bchno,
  7318. // Infcode: res.Infcode,
  7319. // WarnMsg: res.WarnMsg,
  7320. // Cainfo: res.Cainfo,
  7321. // ErrMsg: res.ErrMsg,
  7322. // RespondTime: res.RefmsgTime,
  7323. // InfRefmsgid: res.InfRefmsgid,
  7324. // OrderStatus: 1,
  7325. // IsMedicineInsurance: 1,
  7326. // SettleType: settle_accounts_type,
  7327. // SettleStartTime: start_time,
  7328. // SettleEndTime: end_time,
  7329. // Creator: roles.ID,
  7330. // Modify: roles.ID,
  7331. // PType: 2,
  7332. // }
  7333. // err = service.CreateOrder(order)
  7334. // if err != nil {
  7335. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7336. // return
  7337. // }
  7338. //
  7339. // for _, item := range res.Output.Result {
  7340. // temp := strings.Split(item.FeedetlSn, "-")
  7341. // var advice_id int64 = 0
  7342. // var project_id int64 = 0
  7343. // var types int64 = 0
  7344. //
  7345. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  7346. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  7347. //
  7348. // if temp[1] == "1" {
  7349. // advice_id = id
  7350. // project_id = 0
  7351. // } else if temp[1] == "2" {
  7352. // advice_id = 0
  7353. // project_id = id
  7354. // }
  7355. //
  7356. // info := &models.HisOrderInfo{
  7357. // OrderNumber: order.Number,
  7358. // FeedetlSn: item.FeedetlSn,
  7359. // UploadDate: time.Now().Unix(),
  7360. // AdviceId: advice_id,
  7361. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  7362. // Cnt: item.Cnt,
  7363. // Pric: float64(item.Pric),
  7364. // PatientId: his.PatientId,
  7365. // PricUplmtAmt: item.PricUplmtAmt,
  7366. // SelfpayProp: item.SelfpayProp,
  7367. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7368. // OverlmtAmt: item.OverlmtAmt,
  7369. // PreselfpayAmt: item.PreselfpayAmt,
  7370. // BasMednFlag: item.BasMednFlag,
  7371. // MedChrgitmType: item.MedChrgitmType,
  7372. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  7373. // Status: 1,
  7374. // Memo: item.Memo,
  7375. // Mtime: time.Now().Unix(),
  7376. // InscpScpAmt: item.InscpScpAmt,
  7377. // DrtReimFlag: item.DrtReimFlag,
  7378. // Ctime: time.Now().Unix(),
  7379. // ListSpItemFlag: item.ListSpItemFlag,
  7380. // ChldMedcFlag: item.ChldMedcFlag,
  7381. // LmtUsedFlag: item.LmtUsedFlag,
  7382. // ChrgitmLv: item.ChrgitmLv,
  7383. // UserOrgId: adminUser.CurrentOrgId,
  7384. // HisPatientId: his.ID,
  7385. // OrderId: order.ID,
  7386. // ProjectId: project_id,
  7387. // Type: types,
  7388. // }
  7389. // service.CreateOrderInfo(info)
  7390. //
  7391. // }
  7392. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7393. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  7394. //
  7395. // var total float64
  7396. // for _, item := range prescriptions {
  7397. // if item.Type == 1 { //药品
  7398. // for _, subItem := range item.HisDoctorAdviceInfo {
  7399. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7400. // }
  7401. // }
  7402. // if item.Type == 2 { //项目
  7403. // for _, subItem := range item.HisPrescriptionProject {
  7404. // total = total + (subItem.Price * float64(subItem.Count))
  7405. // }
  7406. // }
  7407. // }
  7408. //
  7409. // for _, item := range prescriptions {
  7410. // for _, subItem := range item.HisAdditionalCharge {
  7411. // total = total + (subItem.Price * float64(subItem.Count))
  7412. // }
  7413. // }
  7414. //
  7415. // allTotal := fmt.Sprintf("%.2f", total)
  7416. // if res.Infcode == 0 {
  7417. // var rf []*ResultFive
  7418. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7419. // psn_no := his.PsnNo
  7420. // mdtrt_id := his.Number
  7421. // chrg_bchno := chrg_bchno
  7422. // cert_no := his.Certno
  7423. // insutype := rf[0].Insutype
  7424. //
  7425. // if his.IdCardType == 1 {
  7426. // cert_no = his.MedicalInsuranceNumber
  7427. //
  7428. // } else {
  7429. //
  7430. // cert_no = his.Certno
  7431. //
  7432. // }
  7433. //
  7434. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  7435. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  7436. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  7437. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  7438. // resp, requestErr := http.Get(api)
  7439. // if requestErr != nil {
  7440. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7441. // return
  7442. // }
  7443. // defer resp.Body.Close()
  7444. // body, ioErr := ioutil.ReadAll(resp.Body)
  7445. // if ioErr != nil {
  7446. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7447. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7448. // return
  7449. // }
  7450. // var respJSON map[string]interface{}
  7451. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7452. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7453. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7454. // return
  7455. // }
  7456. // fmt.Println(respJSON)
  7457. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7458. // userJSONBytes, _ := json.Marshal(respJSON)
  7459. // var res ResultSeven
  7460. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7461. // utils.ErrorLog("解析失败:%v", err)
  7462. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7463. // return
  7464. // }
  7465. // if res.Infcode != 0 {
  7466. // errlog := &models.HisOrderError{
  7467. // UserOrgId: adminUser.CurrentOrgId,
  7468. // Ctime: time.Now().Unix(),
  7469. // Mtime: time.Now().Unix(),
  7470. // Number: chrg_bchno,
  7471. // ErrMsg: res.ErrMsg,
  7472. // Status: 1,
  7473. // PatientId: id,
  7474. // RecordTime: recordDateTime,
  7475. // Stage: 7,
  7476. // }
  7477. // service.CreateErrMsgLog(errlog)
  7478. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7479. // return
  7480. // } else {
  7481. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7482. // order.OrderStatus = 1
  7483. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7484. // order.SetlId = res.Output.Setlinfo.SetlID
  7485. // order.PsnNo = res.Output.Setlinfo.PsnNo
  7486. // order.PsnName = res.Output.Setlinfo.PsnName
  7487. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7488. // order.Certno = res.Output.Setlinfo.Certno
  7489. // order.Gend = res.Output.Setlinfo.Gend
  7490. // order.Naty = res.Output.Setlinfo.Naty
  7491. // order.Age = res.Output.Setlinfo.Age
  7492. // order.Insutype = res.Output.Setlinfo.Insutype
  7493. // order.PsnType = res.Output.Setlinfo.PsnType
  7494. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7495. // order.SetlTime = res.Output.Setlinfo.SetlTime
  7496. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7497. // order.MedType = res.Output.Setlinfo.MedType
  7498. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7499. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7500. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7501. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7502. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7503. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7504. // order.HifpPay = res.Output.Setlinfo.HifpPay
  7505. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7506. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7507. // order.HifesPay = res.Output.Setlinfo.HifesPay
  7508. // order.HifobPay = res.Output.Setlinfo.HifobPay
  7509. // order.MafPay = res.Output.Setlinfo.MafPay
  7510. // order.OthPay = res.Output.Setlinfo.OthPay
  7511. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7512. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7513. // order.AcctPay = res.Output.Setlinfo.AcctPay
  7514. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7515. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7516. // order.Balc = res.Output.Setlinfo.Balc
  7517. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7518. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7519. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7520. // order.ClrWay = res.Output.Setlinfo.ClrWay
  7521. // order.Creator = order.Creator
  7522. // order.Modify = roles.ID
  7523. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7524. // detailStr := string(setlDetail)
  7525. // order.SetlDetail = detailStr
  7526. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7527. // err = service.UpDateOrder(order)
  7528. // if err == nil {
  7529. // c.ServeSuccessJSON(map[string]interface{}{
  7530. // "msg": "预结算成功",
  7531. // })
  7532. // } else {
  7533. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7534. // return
  7535. // }
  7536. // }
  7537. // } else {
  7538. // adminUser := c.GetAdminUserInfo()
  7539. // errlog := &models.HisOrderError{
  7540. // UserOrgId: adminUser.CurrentOrgId,
  7541. // Ctime: time.Now().Unix(),
  7542. // Mtime: time.Now().Unix(),
  7543. // ErrMsg: res.ErrMsg,
  7544. // Status: 1,
  7545. // PatientId: id,
  7546. // RecordTime: recordDateTime,
  7547. // Stage: 4,
  7548. // }
  7549. // service.CreateErrMsgLog(errlog)
  7550. //
  7551. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7552. // return
  7553. // }
  7554. // } else {
  7555. // adminUser := c.GetAdminUserInfo()
  7556. // errlog := &models.HisOrderError{
  7557. // UserOrgId: adminUser.CurrentOrgId,
  7558. // Ctime: time.Now().Unix(),
  7559. // Mtime: time.Now().Unix(),
  7560. // ErrMsg: res.ErrMsg,
  7561. // Status: 1,
  7562. // PatientId: id,
  7563. // RecordTime: recordDateTime,
  7564. // Stage: 4,
  7565. // }
  7566. // service.CreateErrMsgLog(errlog)
  7567. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  7568. // return
  7569. // }
  7570. //
  7571. // } else {
  7572. // var total float64
  7573. // for _, item := range prescriptions {
  7574. // if item.Type == 1 { //药品
  7575. // for _, subItem := range item.HisDoctorAdviceInfo {
  7576. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7577. // }
  7578. // }
  7579. // if item.Type == 2 { //项目
  7580. // for _, subItem := range item.HisPrescriptionProject {
  7581. // total = total + (subItem.Price * float64(subItem.Count))
  7582. // }
  7583. // }
  7584. //
  7585. // for _, subItem := range item.HisAdditionalCharge {
  7586. // total = total + (subItem.Price * float64(subItem.Count))
  7587. // }
  7588. // }
  7589. //
  7590. // allTotal := fmt.Sprintf("%.2f", total)
  7591. // totals, _ := strconv.ParseFloat(allTotal, 64)
  7592. // order := &models.HisOrder{
  7593. // UserOrgId: adminUser.CurrentOrgId,
  7594. // HisPatientId: his.ID,
  7595. // PatientId: id,
  7596. // SettleAccountsDate: recordDateTime,
  7597. // Ctime: time.Now().Unix(),
  7598. // Mtime: time.Now().Unix(),
  7599. // Status: 1,
  7600. // OrderStatus: 2,
  7601. // Number: chrg_bchno,
  7602. // MedfeeSumamt: totals,
  7603. // }
  7604. // err = service.CreateOrder(order)
  7605. // if err != nil {
  7606. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7607. // return
  7608. // }
  7609. //
  7610. // var customs []*Custom
  7611. // for _, item := range prescriptions {
  7612. //
  7613. // if item.Type == 1 { //药品
  7614. // for _, subItem := range item.HisDoctorAdviceInfo {
  7615. // cus := &Custom{
  7616. // AdviceId: subItem.ID,
  7617. // ProjectId: 0,
  7618. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  7619. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  7620. // FeedetlSn: subItem.FeedetlSn,
  7621. // Price: fmt.Sprintf("%.2f", subItem.Price),
  7622. // MedListCodg: subItem.MedListCodg,
  7623. // Type: 1,
  7624. // }
  7625. // customs = append(customs, cus)
  7626. // }
  7627. // }
  7628. //
  7629. // if item.Type == 2 { //项目
  7630. // for _, subItem := range item.HisPrescriptionProject {
  7631. //
  7632. // cus := &Custom{
  7633. // AdviceId: 0,
  7634. // ProjectId: subItem.ID,
  7635. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  7636. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  7637. // FeedetlSn: subItem.FeedetlSn,
  7638. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  7639. // MedListCodg: subItem.MedListCodg,
  7640. // Type: 2,
  7641. // }
  7642. //
  7643. // customs = append(customs, cus)
  7644. // }
  7645. // }
  7646. //
  7647. // for _, item := range item.HisAdditionalCharge {
  7648. // cus := &Custom{
  7649. // ItemId: item.ID,
  7650. // AdviceId: 0,
  7651. // ProjectId: 0,
  7652. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  7653. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  7654. // FeedetlSn: item.FeedetlSn,
  7655. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  7656. // MedListCodg: item.XtHisAddtionConfig.Code,
  7657. // Type: 3,
  7658. // }
  7659. //
  7660. // customs = append(customs, cus)
  7661. // }
  7662. //
  7663. // }
  7664. //
  7665. // for _, item := range customs {
  7666. // var advice_id int64 = 0
  7667. // var project_id int64 = 0
  7668. // var item_id int64 = 0
  7669. //
  7670. // var types int64 = 0
  7671. //
  7672. // if item.Type == 1 {
  7673. // advice_id = item.AdviceId
  7674. // project_id = 0
  7675. // item_id = 0
  7676. // } else if item.Type == 2 {
  7677. // advice_id = 0
  7678. // item_id = 0
  7679. //
  7680. // project_id = item.ProjectId
  7681. // } else if item.Type == 3 {
  7682. // advice_id = 0
  7683. // item_id = item.ItemId
  7684. // project_id = 0
  7685. // }
  7686. //
  7687. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  7688. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  7689. // pric, _ := strconv.ParseFloat(item.Price, 32)
  7690. //
  7691. // info := &models.HisOrderInfo{
  7692. // OrderNumber: order.Number,
  7693. // UploadDate: time.Now().Unix(),
  7694. // AdviceId: advice_id,
  7695. // DetItemFeeSumamt: detItemFeeSumamt,
  7696. // Cnt: cut,
  7697. // Pric: pric,
  7698. // PatientId: id,
  7699. // Status: 1,
  7700. // Mtime: time.Now().Unix(),
  7701. // Ctime: time.Now().Unix(),
  7702. // UserOrgId: adminUser.CurrentOrgId,
  7703. // HisPatientId: his.ID,
  7704. // OrderId: order.ID,
  7705. // ProjectId: project_id,
  7706. // Type: types,
  7707. // ItemId: item_id,
  7708. // }
  7709. // service.CreateOrderInfo(info)
  7710. // }
  7711. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7712. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7713. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  7714. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7715. // if err == nil {
  7716. // c.ServeSuccessJSON(map[string]interface{}{
  7717. // "msg": "结算成功",
  7718. // })
  7719. // } else {
  7720. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7721. // return
  7722. // }
  7723. // }
  7724. //}
  7725. //上传明细-预结算-
  7726. func (c *HisApiController) GetPreUploadInfo() {
  7727. id, _ := c.GetInt64("id")
  7728. record_time := c.GetString("record_time")
  7729. his_patient_id, _ := c.GetInt64("his_patient_id")
  7730. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7731. admin_user_id, _ := c.GetInt64("admin_user_id")
  7732. diagnosis_id := c.GetString("diagnosis")
  7733. sick_type, _ := c.GetInt64("sick_type")
  7734. reg_type, _ := c.GetInt64("p_type")
  7735. begin_time := c.GetString("begin_time")
  7736. id_str := c.GetString("ids")
  7737. ids_arr := strings.Split(id_str, ",")
  7738. timeLayout := "2006-01-02"
  7739. loc, _ := time.LoadLocation("Local")
  7740. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7741. if err != nil {
  7742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7743. return
  7744. }
  7745. recordDateTime := theTime.Unix()
  7746. adminUser := c.GetAdminUserInfo()
  7747. diagnosis_ids := strings.Split(diagnosis_id, ",")
  7748. var config []*models.HisXtDiagnoseConfig
  7749. for _, item := range diagnosis_ids {
  7750. id, _ := strconv.ParseInt(item, 10, 64)
  7751. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7752. config = append(config, &diagnosisConfig)
  7753. }
  7754. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  7755. sickConfig, _ := service.FindSickById(sick_type)
  7756. var prescriptions []*models.HisPrescription
  7757. var start_time int64
  7758. var end_time int64
  7759. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7760. fmt.Println(his_patient_id)
  7761. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7762. timestamp := time.Now().Unix()
  7763. tempTime := time.Unix(timestamp, 0)
  7764. timeFormat := tempTime.Format("20060102150405")
  7765. chrgBchno := rand.Intn(100000) + 10000
  7766. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7767. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7768. var patientPrescription models.HisPrescriptionInfo
  7769. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7770. if patientPrescription.ID == 0 {
  7771. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7772. }
  7773. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7774. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7775. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7776. strconv.FormatInt(his.PatientId, 10)
  7777. var res2 ResultSix
  7778. var resSix10265 ResultSix10265
  7779. var time_stamp string
  7780. if miConfig.MdtrtareaAdmvs == "421300" {
  7781. data := make(map[string]interface{})
  7782. client := &http.Client{}
  7783. data["psn_no"] = his.PsnNo
  7784. data["mdtrt_id"] = his.Number
  7785. data["department"] = department.Name
  7786. data["org_name"] = miConfig.OrgName
  7787. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7788. data["doctor_id"] = doctor_info.DoctorNumber
  7789. data["doctor_name"] = roles.UserName
  7790. data["fixmedins_code"] = miConfig.Code
  7791. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7792. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7793. data["secret_key"] = miConfig.SecretKey
  7794. data["sick_code"] = sickConfig.CountryCode
  7795. data["sick_name"] = sickConfig.ClassName
  7796. data["begin_time"] = begin_time
  7797. data["dept"] = strconv.FormatInt(department.ID, 10)
  7798. data["config"] = config
  7799. data["opter"] = roles.UserName
  7800. fmt.Println(data)
  7801. bytesData, _ := json.Marshal(data)
  7802. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7803. resp, _ := client.Do(req)
  7804. defer resp.Body.Close()
  7805. body, ioErr := ioutil.ReadAll(resp.Body)
  7806. if ioErr != nil {
  7807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7809. return
  7810. }
  7811. var respJSON map[string]interface{}
  7812. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7815. return
  7816. }
  7817. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7818. userJSONBytes, _ := json.Marshal(respJSON)
  7819. fmt.Println("log")
  7820. fmt.Println(string(userJSONBytes))
  7821. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7822. utils.ErrorLog("解析失败:%v", err)
  7823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7824. return
  7825. }
  7826. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7827. data := make(map[string]interface{})
  7828. client := &http.Client{}
  7829. data["psn_no"] = his.PsnNo
  7830. data["mdtrt_id"] = his.Number
  7831. data["doctor"] = roles.UserName
  7832. data["department"] = department.Name
  7833. data["org_name"] = miConfig.OrgName
  7834. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7835. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  7836. data["fixmedins_code"] = miConfig.Code
  7837. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7838. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7839. data["secret_key"] = miConfig.SecretKey
  7840. data["sick_code"] = sickConfig.CountryCode
  7841. data["sick_name"] = sickConfig.ClassName
  7842. data["begin_time"] = begin_time
  7843. data["dept"] = strconv.FormatInt(department.ID, 10)
  7844. data["config"] = config
  7845. data["url"] = miConfig.Url
  7846. data["ak"] = miConfig.AccessKey
  7847. data["cainfo"] = miConfig.Cainfo
  7848. bytesData, _ := json.Marshal(data)
  7849. var req *http.Request
  7850. if miConfig.MdtrtareaAdmvs == "320921" {
  7851. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7852. } else {
  7853. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7854. }
  7855. resp, _ := client.Do(req)
  7856. defer resp.Body.Close()
  7857. body, ioErr := ioutil.ReadAll(resp.Body)
  7858. if ioErr != nil {
  7859. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7861. return
  7862. }
  7863. var respJSON map[string]interface{}
  7864. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7867. return
  7868. }
  7869. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  7870. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  7871. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  7872. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7873. userJSONBytes, _ := json.Marshal(respJSON)
  7874. fmt.Println("log")
  7875. fmt.Println(string(userJSONBytes))
  7876. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7877. utils.ErrorLog("解析失败:%v", err)
  7878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7879. return
  7880. }
  7881. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7882. res2.Output = resSix10265.Output
  7883. res2.ErrMsg = resSix10265.ErrMsg
  7884. res2.Cainfo = resSix10265.Cainfo
  7885. res2.WarnMsg = resSix10265.WarnMsg
  7886. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7887. res2.Infcode = infocode
  7888. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7889. result, requestLog, _ := service.FJyb2203(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, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7890. saveLog(result, requestLog, "2203", "上传就诊信息")
  7891. var respJSON2 map[string]interface{}
  7892. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7895. return
  7896. }
  7897. userJSONBytes2, _ := json.Marshal(respJSON2)
  7898. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7899. utils.ErrorLog("解析失败:%v", err)
  7900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7901. return
  7902. }
  7903. } else {
  7904. var result string
  7905. var requestLog string
  7906. if miConfig.MdtrtareaAdmvs == "440781" { //
  7907. 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)
  7908. } else {
  7909. if miConfig.Code == "H15049901371" {
  7910. //赤峰地区国家医保医疗类别
  7911. //职工透析:医疗类别选特殊情况门诊990502
  7912. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7913. var med_type string
  7914. if his.Insutype == "390" {
  7915. if reg_type == 14 {
  7916. med_type = "9933"
  7917. } else if reg_type == 11 {
  7918. med_type = "11"
  7919. }
  7920. } else if his.Insutype == "310" {
  7921. if reg_type == 14 {
  7922. med_type = "990502"
  7923. } else if reg_type == 11 {
  7924. med_type = "11"
  7925. }
  7926. }
  7927. 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)
  7928. } else {
  7929. 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)
  7930. }
  7931. saveLog(result, requestLog, "2203", "上传就诊信息")
  7932. var respJSON2 map[string]interface{}
  7933. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7936. return
  7937. }
  7938. userJSONBytes2, _ := json.Marshal(respJSON2)
  7939. if miConfig.Code == "H15049901371" {
  7940. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7941. utils.ErrorLog("解析失败:%v", err)
  7942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7943. return
  7944. }
  7945. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7946. res2.Output = resSix10265.Output
  7947. res2.ErrMsg = resSix10265.ErrMsg
  7948. res2.Cainfo = resSix10265.Cainfo
  7949. res2.WarnMsg = resSix10265.WarnMsg
  7950. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7951. res2.Infcode = infocode
  7952. } else {
  7953. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7954. utils.ErrorLog("解析失败:%v", err)
  7955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7956. return
  7957. }
  7958. }
  7959. }
  7960. }
  7961. if res2.Infcode != 0 {
  7962. adminUser := c.GetAdminUserInfo()
  7963. errlog := &models.HisOrderError{
  7964. UserOrgId: adminUser.CurrentOrgId,
  7965. Ctime: time.Now().Unix(),
  7966. Mtime: time.Now().Unix(),
  7967. ErrMsg: res2.ErrMsg,
  7968. Status: 1,
  7969. PatientId: id,
  7970. RecordTime: recordDateTime,
  7971. Stage: 3,
  7972. }
  7973. service.CreateErrMsgLog(errlog)
  7974. c.ServeSuccessJSON(map[string]interface{}{
  7975. "failed_code": -10,
  7976. "msg": res2.ErrMsg,
  7977. })
  7978. return
  7979. } else {
  7980. his.Diagnosis = diagnosis_id
  7981. his.SickType = sickConfig.ID
  7982. his.PType = fmt.Sprintf("%d", reg_type)
  7983. service.UpdateHisPatientThree(&his)
  7984. data := make(map[string]interface{})
  7985. if settle_accounts_type == 1 { //日结
  7986. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7987. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7988. } else {
  7989. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7990. }
  7991. data["pre"] = prescriptions
  7992. } else { //月结
  7993. start_time_str := c.GetString("start_time")
  7994. end_time_str := c.GetString("end_time")
  7995. timeLayout := "2006-01-02"
  7996. loc, _ := time.LoadLocation("Local")
  7997. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7998. if err != nil {
  7999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8000. return
  8001. }
  8002. recordStartTime := theStartTime.Unix()
  8003. start_time = recordStartTime
  8004. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  8005. if err != nil {
  8006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8007. return
  8008. }
  8009. recordEndTime := theEndTime.Unix()
  8010. end_time = recordEndTime
  8011. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  8012. data["pre"] = prescriptions
  8013. }
  8014. client := &http.Client{}
  8015. data["psn_no"] = his.PsnNo
  8016. data["mdtrt_id"] = his.Number
  8017. data["chrg_bchno"] = chrg_bchno
  8018. data["org_name"] = miConfig.OrgName
  8019. data["doctor"] = roles.UserName
  8020. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  8021. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  8022. data["fixmedins_code"] = miConfig.Code
  8023. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  8024. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  8025. data["dept_code"] = "15"
  8026. } else {
  8027. data["dept_code"] = department.Number
  8028. }
  8029. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  8030. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8031. data["secret_key"] = miConfig.SecretKey
  8032. data["url"] = miConfig.Url
  8033. data["ak"] = miConfig.AccessKey
  8034. data["new_doctor_name"] = patientPrescription.Doctor
  8035. data["diag_code"] = sickConfig.CountryCode
  8036. data["time_stamp"] = time_stamp
  8037. data["cainfo"] = miConfig.Cainfo
  8038. var ids []int64
  8039. for _, item := range prescriptions {
  8040. ids = append(ids, item.ID)
  8041. }
  8042. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8043. if config.IsOpen == 1 { //对接了医保,走医保流程
  8044. var res ResultFour
  8045. var resFour10265 ResultFour10265
  8046. if miConfig.MdtrtareaAdmvs == "421300" {
  8047. bytesData, _ := json.Marshal(data)
  8048. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  8049. resp, _ := client.Do(req)
  8050. defer resp.Body.Close()
  8051. body, ioErr := ioutil.ReadAll(resp.Body)
  8052. if ioErr != nil {
  8053. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8055. return
  8056. }
  8057. var respJSON map[string]interface{}
  8058. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8059. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8061. return
  8062. }
  8063. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8064. userJSONBytes, _ := json.Marshal(respJSON)
  8065. fmt.Println("log")
  8066. fmt.Println(string(userJSONBytes))
  8067. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8068. utils.ErrorLog("解析失败:%v", err)
  8069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8070. return
  8071. }
  8072. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8073. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  8074. if result3101.Infcode == "0" {
  8075. if len(result3101.Output.Result) > 0 {
  8076. var errMsgs []string
  8077. for _, item := range result3101.Output.Result {
  8078. errMsgs = append(errMsgs, item.VolaCont)
  8079. }
  8080. c.ServeSuccessJSON(map[string]interface{}{
  8081. "failed_code": -10,
  8082. "msg": errMsgs,
  8083. })
  8084. return
  8085. } else {
  8086. bytesData, _ := json.Marshal(data)
  8087. var req *http.Request
  8088. if miConfig.MdtrtareaAdmvs == "320921" {
  8089. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8090. } else {
  8091. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8092. }
  8093. resp, _ := client.Do(req)
  8094. defer resp.Body.Close()
  8095. body, ioErr := ioutil.ReadAll(resp.Body)
  8096. if ioErr != nil {
  8097. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8099. return
  8100. }
  8101. var respJSON map[string]interface{}
  8102. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8103. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8105. return
  8106. }
  8107. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8108. userJSONBytes, _ := json.Marshal(respJSON)
  8109. fmt.Println("log")
  8110. fmt.Println(string(userJSONBytes))
  8111. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  8112. utils.ErrorLog("解析失败:%v", err)
  8113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8114. return
  8115. }
  8116. res.InfRefmsgid = resFour10265.InfRefmsgid
  8117. res.Output = resFour10265.Output
  8118. res.ErrMsg = resFour10265.ErrMsg
  8119. res.Cainfo = resFour10265.Cainfo
  8120. res.WarnMsg = resFour10265.WarnMsg
  8121. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  8122. res.Infcode = infocode
  8123. }
  8124. }
  8125. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8126. result, request_log, _ := service.FJyb2204(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), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode)
  8127. var dat map[string]interface{}
  8128. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8129. fmt.Println(dat)
  8130. } else {
  8131. fmt.Println(err)
  8132. }
  8133. saveLog(result, request_log, "2204", "上传费用明细")
  8134. userJSONBytes, _ := json.Marshal(dat)
  8135. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8136. utils.ErrorLog("解析失败:%v", err)
  8137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8138. return
  8139. }
  8140. } else {
  8141. if miConfig.Code == "H15049901371" {
  8142. 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)
  8143. var dat map[string]interface{}
  8144. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8145. fmt.Println(dat)
  8146. } else {
  8147. fmt.Println(err)
  8148. }
  8149. saveLog(result, request_log, "2204", "上传费用明细")
  8150. userJSONBytes, _ := json.Marshal(dat)
  8151. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  8152. utils.ErrorLog("解析失败:%v", err)
  8153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8154. return
  8155. }
  8156. res.InfRefmsgid = resFour10265.InfRefmsgid
  8157. res.Output = resFour10265.Output
  8158. res.ErrMsg = resFour10265.ErrMsg
  8159. res.Cainfo = resFour10265.Cainfo
  8160. res.WarnMsg = resFour10265.WarnMsg
  8161. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  8162. res.Infcode = infocode
  8163. } else {
  8164. 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)
  8165. var dat map[string]interface{}
  8166. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8167. fmt.Println(dat)
  8168. } else {
  8169. fmt.Println(err)
  8170. }
  8171. saveLog(result, request_log, "2204", "上传费用明细")
  8172. userJSONBytes, _ := json.Marshal(dat)
  8173. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8174. utils.ErrorLog("解析失败:%v", err)
  8175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8176. return
  8177. }
  8178. }
  8179. }
  8180. if res.Infcode == 0 {
  8181. order := &models.HisOrder{
  8182. UserOrgId: adminUser.CurrentOrgId,
  8183. HisPatientId: his.ID,
  8184. PatientId: his.PatientId,
  8185. SettleAccountsDate: recordDateTime,
  8186. Ctime: time.Now().Unix(),
  8187. Mtime: time.Now().Unix(),
  8188. MdtrtId: his.Number,
  8189. PsnNo: his.PsnNo,
  8190. MedType: strconv.FormatInt(reg_type, 10),
  8191. Status: 1,
  8192. Number: chrg_bchno,
  8193. Infcode: res.Infcode,
  8194. WarnMsg: res.WarnMsg,
  8195. Cainfo: res.Cainfo,
  8196. ErrMsg: res.ErrMsg,
  8197. RespondTime: res.RefmsgTime,
  8198. InfRefmsgid: res.InfRefmsgid,
  8199. OrderStatus: 1,
  8200. IsMedicineInsurance: 1,
  8201. SettleType: settle_accounts_type,
  8202. SettleStartTime: start_time,
  8203. SettleEndTime: end_time,
  8204. Creator: roles.AdminUserId,
  8205. Modify: roles.AdminUserId,
  8206. PType: 2,
  8207. Diagnosis: diagnosis_id,
  8208. }
  8209. err = service.CreateOrder(order)
  8210. if err != nil {
  8211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  8212. return
  8213. }
  8214. for _, item := range res.Output.Result {
  8215. temp := strings.Split(item.FeedetlSn, "-")
  8216. var advice_id int64 = 0
  8217. var project_id int64 = 0
  8218. var types int64 = 0
  8219. id, _ := strconv.ParseInt(temp[2], 10, 64)
  8220. types, _ = strconv.ParseInt(temp[1], 10, 64)
  8221. if temp[1] == "1" {
  8222. advice_id = id
  8223. project_id = 0
  8224. } else if temp[1] == "2" {
  8225. advice_id = 0
  8226. project_id = id
  8227. }
  8228. info := &models.HisOrderInfo{
  8229. OrderNumber: order.Number,
  8230. FeedetlSn: item.FeedetlSn,
  8231. UploadDate: time.Now().Unix(),
  8232. AdviceId: advice_id,
  8233. DetItemFeeSumamt: item.DetItemFeeSumamt,
  8234. Cnt: item.Cnt,
  8235. Pric: float64(item.Pric),
  8236. PatientId: his.PatientId,
  8237. PricUplmtAmt: item.PricUplmtAmt,
  8238. SelfpayProp: item.SelfpayProp,
  8239. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  8240. OverlmtAmt: item.OverlmtAmt,
  8241. PreselfpayAmt: item.PreselfpayAmt,
  8242. BasMednFlag: item.BasMednFlag,
  8243. MedChrgitmType: item.MedChrgitmType,
  8244. HiNegoDrugFlag: item.HiNegoDrugFlag,
  8245. Status: 1,
  8246. Memo: item.Memo,
  8247. Mtime: time.Now().Unix(),
  8248. InscpScpAmt: item.InscpScpAmt,
  8249. DrtReimFlag: item.DrtReimFlag,
  8250. Ctime: time.Now().Unix(),
  8251. ListSpItemFlag: item.ListSpItemFlag,
  8252. ChldMedcFlag: item.ChldMedcFlag,
  8253. LmtUsedFlag: item.LmtUsedFlag,
  8254. ChrgitmLv: item.ChrgitmLv,
  8255. UserOrgId: adminUser.CurrentOrgId,
  8256. HisPatientId: his.ID,
  8257. OrderId: order.ID,
  8258. ProjectId: project_id,
  8259. Type: types,
  8260. }
  8261. service.CreateOrderInfo(info)
  8262. }
  8263. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8264. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  8265. var total float64
  8266. for _, item := range prescriptions {
  8267. if item.Type == 1 { //药品
  8268. for _, subItem := range item.HisDoctorAdviceInfo {
  8269. total = total + (subItem.Price * subItem.PrescribingNumber)
  8270. }
  8271. }
  8272. if item.Type == 2 { //项目
  8273. for _, subItem := range item.HisPrescriptionProject {
  8274. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  8275. total = total + (subItem.Price * cnt)
  8276. }
  8277. }
  8278. }
  8279. for _, item := range prescriptions {
  8280. for _, subItem := range item.HisAdditionalCharge {
  8281. total = total + (subItem.Price * float64(subItem.Count))
  8282. }
  8283. }
  8284. allTotal := fmt.Sprintf("%.4f", total)
  8285. if res.Infcode == 0 {
  8286. var rf []*ResultFive
  8287. json.Unmarshal([]byte(his.Iinfo), &rf)
  8288. chrg_bchno := chrg_bchno
  8289. cert_no := his.Certno
  8290. var insutypes []string
  8291. var insutype string
  8292. var is390 int = 0
  8293. var is310 int = 0
  8294. for _, item := range rf {
  8295. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8296. insutypes = append(insutypes, item.Insutype)
  8297. }
  8298. }
  8299. if len(insutypes) == 1 {
  8300. insutype = insutypes[0]
  8301. } else {
  8302. for _, i := range insutypes {
  8303. if i == "390" {
  8304. is390 = 1
  8305. }
  8306. if i == "310" {
  8307. is310 = 1
  8308. }
  8309. }
  8310. }
  8311. if is390 == 1 {
  8312. insutype = "390"
  8313. }
  8314. if is310 == 1 {
  8315. insutype = "310"
  8316. }
  8317. if len(insutypes) == 0 {
  8318. insutype = "310"
  8319. }
  8320. if len(insutypes) == 2 {
  8321. insutype = strconv.FormatInt(his.SocialType, 64)
  8322. }
  8323. //insutype = "390"
  8324. if his.IdCardType == 1 {
  8325. cert_no = his.MedicalInsuranceNumber
  8326. } else {
  8327. cert_no = his.Certno
  8328. }
  8329. var res ResultSeven
  8330. var resSeven10265 ResultSeven10265
  8331. if miConfig.MdtrtareaAdmvs == "421300" {
  8332. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8333. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8334. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8335. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8336. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8337. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8338. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  8339. resp, requestErr := http.Get(api)
  8340. if requestErr != nil {
  8341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8342. return
  8343. }
  8344. body, ioErr := ioutil.ReadAll(resp.Body)
  8345. if ioErr != nil {
  8346. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8348. return
  8349. }
  8350. var respJSON map[string]interface{}
  8351. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8352. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8354. return
  8355. }
  8356. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8357. result, _ := json.Marshal(respJSON)
  8358. fmt.Println("log")
  8359. fmt.Println(string(result))
  8360. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8361. utils.ErrorLog("解析失败:%v", err)
  8362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8363. return
  8364. }
  8365. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8366. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  8367. if result3101.Infcode == "0" {
  8368. if len(result3101.Output.Result) > 0 {
  8369. var errMsgs []string
  8370. for _, item := range result3101.Output.Result {
  8371. errMsgs = append(errMsgs, item.VolaCont)
  8372. }
  8373. c.ServeSuccessJSON(map[string]interface{}{
  8374. "failed_code": -10,
  8375. "msg": errMsgs,
  8376. })
  8377. return
  8378. } else {
  8379. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8380. if his.IdCardType != 4 {
  8381. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8382. bas := strings.Split(psn_info.CardInfo, "|")
  8383. if his.IdCardType == 1 {
  8384. cert_no = bas[2]
  8385. } else {
  8386. cert_no = bas[1]
  8387. }
  8388. } else {
  8389. cert_no = his.Certno
  8390. }
  8391. //江苏地区国家医保医疗类别
  8392. //职工透析:医疗类别选特殊情况门诊9933
  8393. //居民血透门慢: 医疗类别选门诊慢病1402
  8394. //var med_type string
  8395. //if his.Insutype == "310" {
  8396. // if reg_type == 14 {
  8397. // med_type = "9933"
  8398. // } else if reg_type == 11 {
  8399. // med_type = "11"
  8400. //
  8401. // }
  8402. //} else if his.Insutype == "390" {
  8403. // if reg_type == 14 {
  8404. // med_type = "1402"
  8405. // } else if reg_type == 11 {
  8406. // med_type = "11"
  8407. // }
  8408. //}
  8409. var api string
  8410. if miConfig.MdtrtareaAdmvs == "320921" {
  8411. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8412. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8413. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8414. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8415. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8416. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8417. "&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
  8418. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8419. } else {
  8420. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8421. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8422. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8423. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8424. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8425. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8426. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8427. "&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
  8428. }
  8429. resp, requestErr := http.Get(api)
  8430. if requestErr != nil {
  8431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8432. return
  8433. }
  8434. body, ioErr := ioutil.ReadAll(resp.Body)
  8435. if ioErr != nil {
  8436. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8438. return
  8439. }
  8440. var respJSON map[string]interface{}
  8441. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8442. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8444. return
  8445. }
  8446. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8447. result, _ := json.Marshal(respJSON)
  8448. fmt.Println("log")
  8449. fmt.Println(string(result))
  8450. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8451. utils.ErrorLog("解析失败:%v", err)
  8452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8453. return
  8454. }
  8455. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8456. res.Output = resSeven10265.Output
  8457. res.ErrMsg = resSeven10265.ErrMsg
  8458. res.Cainfo = resSeven10265.Cainfo
  8459. res.WarnMsg = resSeven10265.WarnMsg
  8460. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8461. res.Infcode = infocode
  8462. }
  8463. }
  8464. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8465. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId, recordDateTime)
  8466. var result string
  8467. var request_log string
  8468. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  8469. result, request_log, _ = service.FJyb2206ForToken(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, 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, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8470. } else {
  8471. result, request_log, _ = service.FJyb2206(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, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8472. }
  8473. var dat map[string]interface{}
  8474. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8475. fmt.Println(dat)
  8476. } else {
  8477. fmt.Println(err)
  8478. }
  8479. saveLog(result, request_log, "2206", "预结算")
  8480. userJSONBytes, _ := json.Marshal(dat)
  8481. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8482. utils.ErrorLog("解析失败:%v", err)
  8483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8484. return
  8485. }
  8486. } else {
  8487. var result string
  8488. var request_log string
  8489. if miConfig.Code == "H15049901371" {
  8490. //赤峰地区国家医保医疗类别
  8491. //职工透析:医疗类别选特殊情况门诊990502
  8492. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8493. var med_type string
  8494. if his.Insutype == "390" {
  8495. if reg_type == 14 {
  8496. med_type = "9933"
  8497. } else if reg_type == 11 {
  8498. med_type = "11"
  8499. }
  8500. } else if his.Insutype == "310" {
  8501. if reg_type == 14 {
  8502. med_type = "990502"
  8503. } else if reg_type == 11 {
  8504. med_type = "11"
  8505. }
  8506. }
  8507. 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)
  8508. } else {
  8509. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8510. if his.IdCardType == 4 {
  8511. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, 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)
  8512. } else {
  8513. 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)
  8514. }
  8515. }
  8516. var dat map[string]interface{}
  8517. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8518. fmt.Println(dat)
  8519. } else {
  8520. fmt.Println(err)
  8521. }
  8522. saveLog(result, request_log, "2206", "预结算")
  8523. //userJSONBytes, _ := json.Marshal(dat)
  8524. //
  8525. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8526. // utils.ErrorLog("解析失败:%v", err)
  8527. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8528. // return
  8529. //}
  8530. userJSONBytes, _ := json.Marshal(dat)
  8531. if miConfig.Code == "H15049901371" {
  8532. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8533. utils.ErrorLog("解析失败:%v", err)
  8534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8535. return
  8536. }
  8537. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8538. res.Output = resSeven10265.Output
  8539. res.ErrMsg = resSeven10265.ErrMsg
  8540. res.Cainfo = resSeven10265.Cainfo
  8541. res.WarnMsg = resSeven10265.WarnMsg
  8542. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8543. res.Infcode = infocode
  8544. } else {
  8545. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8546. utils.ErrorLog("解析失败:%v", err)
  8547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8548. return
  8549. }
  8550. }
  8551. }
  8552. if res.Infcode != 0 {
  8553. errlog := &models.HisOrderError{
  8554. UserOrgId: adminUser.CurrentOrgId,
  8555. Ctime: time.Now().Unix(),
  8556. Mtime: time.Now().Unix(),
  8557. Number: chrg_bchno,
  8558. ErrMsg: res.ErrMsg,
  8559. Status: 1,
  8560. PatientId: id,
  8561. RecordTime: recordDateTime,
  8562. Stage: 20,
  8563. }
  8564. service.CreateErrMsgLog(errlog)
  8565. c.ServeSuccessJSON(map[string]interface{}{
  8566. "failed_code": -10,
  8567. "msg": res.ErrMsg,
  8568. })
  8569. return
  8570. } else {
  8571. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8572. order.OrderStatus = 1
  8573. order.IsPre = 1
  8574. order.Status = 1
  8575. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8576. order.SetlId = res.Output.Setlinfo.SetlID
  8577. order.PsnNo = res.Output.Setlinfo.PsnNo
  8578. order.PsnName = res.Output.Setlinfo.PsnName
  8579. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8580. order.Certno = res.Output.Setlinfo.Certno
  8581. order.Gend = res.Output.Setlinfo.Gend
  8582. order.Naty = res.Output.Setlinfo.Naty
  8583. order.Age = res.Output.Setlinfo.Age
  8584. order.Insutype = res.Output.Setlinfo.Insutype
  8585. order.PsnType = res.Output.Setlinfo.PsnType
  8586. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8587. order.SetlTime = res.Output.Setlinfo.SetlTime
  8588. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8589. if res.Output.Setlinfo.MedType == "140101" {
  8590. order.MedType = "14"
  8591. } else {
  8592. order.MedType = res.Output.Setlinfo.MedType
  8593. }
  8594. if reg_type == 1112 {
  8595. order.MedType = "1112"
  8596. }
  8597. if reg_type == 1111 {
  8598. order.MedType = "1111"
  8599. }
  8600. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8601. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8602. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8603. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8604. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8605. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8606. order.HifpPay = res.Output.Setlinfo.HifpPay
  8607. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8608. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8609. order.HifesPay = res.Output.Setlinfo.HifesPay
  8610. order.HifobPay = res.Output.Setlinfo.HifobPay
  8611. order.MafPay = res.Output.Setlinfo.MafPay
  8612. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8613. order.OthPay = res.Output.Setlinfo.OthPay
  8614. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8615. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8616. order.AcctPay = res.Output.Setlinfo.AcctPay
  8617. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8618. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8619. order.Balc = res.Output.Setlinfo.Balc
  8620. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8621. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8622. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8623. order.ClrWay = res.Output.Setlinfo.ClrWay
  8624. order.Creator = order.Creator
  8625. order.Modify = roles.AdminUserId
  8626. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8627. detailStr := string(setlDetail)
  8628. order.SetlDetail = detailStr
  8629. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8630. err = service.UpDateOrder(order)
  8631. if err == nil {
  8632. c.ServeSuccessJSON(map[string]interface{}{
  8633. "msg": "预结算成功",
  8634. })
  8635. } else {
  8636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8637. return
  8638. }
  8639. }
  8640. } else {
  8641. adminUser := c.GetAdminUserInfo()
  8642. errlog := &models.HisOrderError{
  8643. UserOrgId: adminUser.CurrentOrgId,
  8644. Ctime: time.Now().Unix(),
  8645. Mtime: time.Now().Unix(),
  8646. ErrMsg: res.ErrMsg,
  8647. Status: 1,
  8648. PatientId: id,
  8649. RecordTime: recordDateTime,
  8650. Stage: 4,
  8651. }
  8652. service.CreateErrMsgLog(errlog)
  8653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8654. return
  8655. }
  8656. } else {
  8657. adminUser := c.GetAdminUserInfo()
  8658. errlog := &models.HisOrderError{
  8659. UserOrgId: adminUser.CurrentOrgId,
  8660. Ctime: time.Now().Unix(),
  8661. Mtime: time.Now().Unix(),
  8662. ErrMsg: res.ErrMsg,
  8663. Status: 1,
  8664. PatientId: id,
  8665. RecordTime: recordDateTime,
  8666. Stage: 4,
  8667. }
  8668. service.CreateErrMsgLog(errlog)
  8669. c.ServeSuccessJSON(map[string]interface{}{
  8670. "failed_code": -10,
  8671. "msg": res.ErrMsg,
  8672. })
  8673. return
  8674. }
  8675. }
  8676. }
  8677. }
  8678. //退款
  8679. func (c *HisApiController) Refund() {
  8680. order_id, _ := c.GetInt64("order_id")
  8681. admin_user_id, _ := c.GetInt64("admin_user_id")
  8682. adminUser := c.GetAdminUserInfo()
  8683. var order models.HisOrder
  8684. order, _ = service.GetHisOrderByID(order_id)
  8685. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8686. if order.ID == 0 {
  8687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8688. return
  8689. }
  8690. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8691. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8692. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8693. if config.IsOpen == 1 { //对接了医保,走医保流程
  8694. var res ResultSixteen
  8695. var resSixteen10265 ResultSixteen10265
  8696. var src_resquest string
  8697. var result string
  8698. if miConfig.MdtrtareaAdmvs == "421300" {
  8699. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  8700. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8701. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8702. resp3, requestErr3 := http.Get(api3)
  8703. if requestErr3 != nil {
  8704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8705. return
  8706. }
  8707. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8708. if ioErr3 != nil {
  8709. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8711. return
  8712. }
  8713. var respJSON3 map[string]interface{}
  8714. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8715. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8717. return
  8718. }
  8719. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8720. userJSONBytes3, _ := json.Marshal(respJSON3)
  8721. fmt.Println("log")
  8722. fmt.Println(string(userJSONBytes3))
  8723. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  8724. utils.ErrorLog("解析失败:%v", err)
  8725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8726. return
  8727. }
  8728. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8729. var api3 string
  8730. if miConfig.MdtrtareaAdmvs == "320921" {
  8731. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8732. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8733. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8734. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8735. } else {
  8736. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8737. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8738. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8739. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8740. }
  8741. resp3, requestErr3 := http.Get(api3)
  8742. if requestErr3 != nil {
  8743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8744. return
  8745. }
  8746. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8747. if ioErr3 != nil {
  8748. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8750. return
  8751. }
  8752. var respJSON3 map[string]interface{}
  8753. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8756. return
  8757. }
  8758. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8759. userJSONBytes3, _ := json.Marshal(respJSON3)
  8760. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  8761. utils.ErrorLog("解析失败:%v", err)
  8762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8763. return
  8764. }
  8765. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8766. res.Output = resSixteen10265.Output
  8767. res.ErrMsg = resSixteen10265.ErrMsg
  8768. res.Cainfo = resSixteen10265.Cainfo
  8769. res.WarnMsg = resSixteen10265.WarnMsg
  8770. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8771. res.Infcode = infocode
  8772. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8773. result, src_resquest, _ = service.FJyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8774. var dat map[string]interface{}
  8775. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8776. fmt.Println(dat)
  8777. } else {
  8778. fmt.Println(err)
  8779. }
  8780. saveLog(result, src_resquest, "2208", "退费")
  8781. userJSONBytes, _ := json.Marshal(dat)
  8782. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8783. utils.ErrorLog("解析失败:%v", err)
  8784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8785. return
  8786. }
  8787. } else {
  8788. if miConfig.Code == "H15049901371" {
  8789. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8790. var dat map[string]interface{}
  8791. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8792. fmt.Println(dat)
  8793. } else {
  8794. fmt.Println(err)
  8795. }
  8796. saveLog(result, src_resquest, "2208", "退费")
  8797. userJSONBytes, _ := json.Marshal(dat)
  8798. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  8799. utils.ErrorLog("解析失败:%v", err)
  8800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8801. return
  8802. }
  8803. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8804. res.Output = resSixteen10265.Output
  8805. res.ErrMsg = resSixteen10265.ErrMsg
  8806. res.Cainfo = resSixteen10265.Cainfo
  8807. res.WarnMsg = resSixteen10265.WarnMsg
  8808. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8809. res.Infcode = infocode
  8810. } else {
  8811. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8812. var dat map[string]interface{}
  8813. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8814. fmt.Println(dat)
  8815. } else {
  8816. fmt.Println(err)
  8817. }
  8818. saveLog(result, src_resquest, "2208", "退费")
  8819. userJSONBytes, _ := json.Marshal(dat)
  8820. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8821. utils.ErrorLog("解析失败:%v", err)
  8822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8823. return
  8824. }
  8825. }
  8826. }
  8827. if res.Infcode == 0 {
  8828. var res2 ResultSix
  8829. var resSix10265 ResultSix10265
  8830. if miConfig.MdtrtareaAdmvs == "421300" {
  8831. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8832. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8833. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8834. resp3, requestErr3 := http.Get(api3)
  8835. if requestErr3 != nil {
  8836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8837. return
  8838. }
  8839. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8840. if ioErr3 != nil {
  8841. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8843. return
  8844. }
  8845. var respJSON3 map[string]interface{}
  8846. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8847. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8849. return
  8850. }
  8851. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8852. userJSONBytes3, _ := json.Marshal(respJSON3)
  8853. fmt.Println("log")
  8854. fmt.Println(string(userJSONBytes3))
  8855. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8856. utils.ErrorLog("解析失败:%v", err)
  8857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8858. return
  8859. }
  8860. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8861. var api3 string
  8862. if miConfig.MdtrtareaAdmvs == "320921" {
  8863. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8864. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8865. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8866. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8867. } else {
  8868. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8869. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8870. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8871. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8872. }
  8873. resp3, requestErr3 := http.Get(api3)
  8874. if requestErr3 != nil {
  8875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8876. return
  8877. }
  8878. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8879. if ioErr3 != nil {
  8880. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8882. return
  8883. }
  8884. var respJSON3 map[string]interface{}
  8885. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8888. return
  8889. }
  8890. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8891. userJSONBytes3, _ := json.Marshal(respJSON3)
  8892. fmt.Println("log")
  8893. fmt.Println(string(userJSONBytes3))
  8894. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8895. utils.ErrorLog("解析失败:%v", err)
  8896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8897. return
  8898. }
  8899. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8900. res2.Output = resSix10265.Output
  8901. res2.ErrMsg = resSix10265.ErrMsg
  8902. res2.Cainfo = resSix10265.Cainfo
  8903. res2.WarnMsg = resSix10265.WarnMsg
  8904. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8905. res2.Infcode = infocode
  8906. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8907. result2, src_request, _ := service.FJyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8908. var dat map[string]interface{}
  8909. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8910. fmt.Println(dat)
  8911. } else {
  8912. fmt.Println(err)
  8913. }
  8914. saveLog(result2, src_request, "2205", "撤销明细")
  8915. userJSONBytes, _ := json.Marshal(dat)
  8916. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8917. utils.ErrorLog("解析失败:%v", err)
  8918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8919. return
  8920. }
  8921. } else {
  8922. if miConfig.Code == "H15049901371" {
  8923. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8924. var dat map[string]interface{}
  8925. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8926. fmt.Println(dat)
  8927. } else {
  8928. fmt.Println(err)
  8929. }
  8930. saveLog(result2, src_request, "2205", "撤销明细")
  8931. userJSONBytes, _ := json.Marshal(dat)
  8932. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8933. utils.ErrorLog("解析失败:%v", err)
  8934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8935. return
  8936. }
  8937. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8938. res2.Output = resSix10265.Output
  8939. res2.ErrMsg = resSix10265.ErrMsg
  8940. res2.Cainfo = resSix10265.Cainfo
  8941. res2.WarnMsg = resSix10265.WarnMsg
  8942. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8943. res2.Infcode = infocode
  8944. } else {
  8945. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8946. var dat map[string]interface{}
  8947. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8948. fmt.Println(dat)
  8949. } else {
  8950. fmt.Println(err)
  8951. }
  8952. saveLog(result2, src_request, "2205", "撤销明细")
  8953. userJSONBytes, _ := json.Marshal(dat)
  8954. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8955. utils.ErrorLog("解析失败:%v", err)
  8956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8957. return
  8958. }
  8959. }
  8960. }
  8961. if res2.Infcode == 0 {
  8962. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8963. if err == nil {
  8964. //当押金不为零时产生退费记录
  8965. if order.Decimal != 0 {
  8966. tmp := strconv.FormatInt(order.ID, 10)
  8967. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8968. if err != nil {
  8969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8970. return
  8971. }
  8972. }
  8973. c.ServeSuccessJSON(map[string]interface{}{
  8974. "msg": "退费成功",
  8975. })
  8976. } else {
  8977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8978. return
  8979. }
  8980. } else {
  8981. c.ServeSuccessJSON(map[string]interface{}{
  8982. "code": -10,
  8983. "msg": res2.ErrMsg,
  8984. })
  8985. }
  8986. } else {
  8987. c.ServeSuccessJSON(map[string]interface{}{
  8988. "code": -10,
  8989. "msg": res.ErrMsg,
  8990. })
  8991. }
  8992. }
  8993. }
  8994. func (c *HisApiController) RefundNumber() {
  8995. record_time := c.GetString("record_time")
  8996. //patient_id, _ := c.GetInt64("patient_id")
  8997. admin_user_id, _ := c.GetInt64("admin_user_id")
  8998. his_patient_id, _ := c.GetInt64("id")
  8999. timeLayout := "2006-01-02"
  9000. loc, _ := time.LoadLocation("Local")
  9001. adminUser := c.GetAdminUserInfo()
  9002. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9003. fmt.Println(err)
  9004. if err != nil {
  9005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9006. return
  9007. }
  9008. recordDateTime := theTime.Unix()
  9009. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  9010. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  9011. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  9012. //order, _ := service.GetHisOrderByID(order_id)
  9013. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9014. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9015. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9016. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  9017. if count > 0 {
  9018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  9019. return
  9020. }
  9021. if config.IsOpen == 1 { //对接了医保,走医保流程
  9022. var res2 ResultSix
  9023. var resSix10265 ResultSix10265
  9024. if miConfig.MdtrtareaAdmvs == "421300" {
  9025. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  9026. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  9027. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9028. resp3, requestErr3 := http.Get(api3)
  9029. if requestErr3 != nil {
  9030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9031. return
  9032. }
  9033. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  9034. if ioErr3 != nil {
  9035. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  9036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9037. return
  9038. }
  9039. var respJSON3 map[string]interface{}
  9040. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  9041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9043. return
  9044. }
  9045. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9046. userJSONBytes3, _ := json.Marshal(respJSON3)
  9047. fmt.Println("log")
  9048. fmt.Println(string(userJSONBytes3))
  9049. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  9050. utils.ErrorLog("解析失败:%v", err)
  9051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9052. return
  9053. }
  9054. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9055. var api3 string
  9056. if miConfig.MdtrtareaAdmvs == "320921" {
  9057. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  9058. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  9059. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9060. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9061. } else {
  9062. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9063. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  9064. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  9065. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9066. }
  9067. resp3, requestErr3 := http.Get(api3)
  9068. if requestErr3 != nil {
  9069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9070. return
  9071. }
  9072. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  9073. if ioErr3 != nil {
  9074. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  9075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9076. return
  9077. }
  9078. var respJSON3 map[string]interface{}
  9079. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  9080. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9082. return
  9083. }
  9084. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9085. userJSONBytes3, _ := json.Marshal(respJSON3)
  9086. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  9087. utils.ErrorLog("解析失败:%v", err)
  9088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9089. return
  9090. }
  9091. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9092. res2.Output = resSix10265.Output
  9093. res2.ErrMsg = resSix10265.ErrMsg
  9094. res2.Cainfo = resSix10265.Cainfo
  9095. res2.WarnMsg = resSix10265.WarnMsg
  9096. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9097. res2.Infcode = infocode
  9098. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9099. result, request, _ := service.FJyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9100. var dat map[string]interface{}
  9101. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9102. fmt.Println(dat)
  9103. } else {
  9104. fmt.Println(err)
  9105. }
  9106. saveLog(result, request, "2202", "退号")
  9107. userJSONBytes, _ := json.Marshal(dat)
  9108. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9109. utils.ErrorLog("解析失败:%v", err)
  9110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9111. return
  9112. }
  9113. } else {
  9114. var api3 string
  9115. if miConfig.Code == "H15049901371" {
  9116. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  9117. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  9118. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9119. } else {
  9120. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  9121. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  9122. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9123. }
  9124. resp3, requestErr3 := http.Get(api3)
  9125. if requestErr3 != nil {
  9126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9127. return
  9128. }
  9129. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  9130. if ioErr3 != nil {
  9131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  9132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9133. return
  9134. }
  9135. var respJSON3 map[string]interface{}
  9136. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  9137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9139. return
  9140. }
  9141. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9142. userJSONBytes3, _ := json.Marshal(respJSON3)
  9143. if miConfig.Code == "H15049901371" {
  9144. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  9145. utils.ErrorLog("解析失败:%v", err)
  9146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9147. return
  9148. }
  9149. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9150. res2.Output = resSix10265.Output
  9151. res2.ErrMsg = resSix10265.ErrMsg
  9152. res2.Cainfo = resSix10265.Cainfo
  9153. res2.WarnMsg = resSix10265.WarnMsg
  9154. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9155. res2.Infcode = infocode
  9156. } else {
  9157. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  9158. utils.ErrorLog("解析失败:%v", err)
  9159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9160. return
  9161. }
  9162. }
  9163. }
  9164. if res2.Infcode == 0 {
  9165. if err == nil {
  9166. c.ServeSuccessJSON(map[string]interface{}{
  9167. "msg": "退号成功",
  9168. })
  9169. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  9170. } else {
  9171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9172. return
  9173. }
  9174. } else {
  9175. c.ServeSuccessJSON(map[string]interface{}{
  9176. "code": -10,
  9177. "msg": res2.ErrMsg,
  9178. })
  9179. }
  9180. } else {
  9181. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  9182. //if err == nil {
  9183. // c.ServeSuccessJSON(map[string]interface{}{
  9184. // "msg": "退费成功",
  9185. // })
  9186. //} else {
  9187. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9188. // return
  9189. //}
  9190. }
  9191. }
  9192. func (c *HisApiController) RefundDetail() {
  9193. order_id, _ := c.GetInt64("order_id")
  9194. admin_user_id, _ := c.GetInt64("admin_user_id")
  9195. //his_patient_id, _ := c.GetInt64("his_patient_id")
  9196. number := c.GetString("number")
  9197. record_time := c.GetString("record_time")
  9198. patient_id, _ := c.GetInt64("patient_id")
  9199. //med_type, _ := c.GetInt64("med_type")
  9200. timeLayout := "2006-01-02"
  9201. loc, _ := time.LoadLocation("Local")
  9202. adminUser := c.GetAdminUserInfo()
  9203. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9204. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9205. fmt.Println(err)
  9206. if err != nil {
  9207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9208. return
  9209. }
  9210. recordDateTime := theTime.Unix()
  9211. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9212. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  9213. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9214. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9215. var order models.HisOrder
  9216. order, _ = service.GetHisOrderByID(order_id)
  9217. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9218. if config.IsOpen == 1 { //对接了医保,走医保流程
  9219. var res2 ResultSix
  9220. if miConfig.MdtrtareaAdmvs == "421300" {
  9221. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  9222. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  9223. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9224. resp3, requestErr3 := http.Get(api3)
  9225. if requestErr3 != nil {
  9226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9227. return
  9228. }
  9229. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  9230. if ioErr3 != nil {
  9231. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  9232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9233. return
  9234. }
  9235. var respJSON3 map[string]interface{}
  9236. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  9237. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9239. return
  9240. }
  9241. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9242. userJSONBytes3, _ := json.Marshal(respJSON3)
  9243. fmt.Println("log")
  9244. fmt.Println(string(userJSONBytes3))
  9245. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  9246. utils.ErrorLog("解析失败:%v", err)
  9247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9248. return
  9249. }
  9250. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9251. if err == nil {
  9252. c.ServeSuccessJSON(map[string]interface{}{
  9253. "msg": "撤销明细成功",
  9254. })
  9255. return
  9256. } else {
  9257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9258. return
  9259. }
  9260. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9261. var resSix10265 ResultSix10265
  9262. var api3 string
  9263. if miConfig.MdtrtareaAdmvs == "320921" {
  9264. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  9265. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  9266. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9267. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9268. } else {
  9269. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9270. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  9271. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  9272. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9273. }
  9274. resp3, requestErr3 := http.Get(api3)
  9275. if requestErr3 != nil {
  9276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9277. return
  9278. }
  9279. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  9280. if ioErr3 != nil {
  9281. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  9282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9283. return
  9284. }
  9285. var respJSON3 map[string]interface{}
  9286. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  9287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9289. return
  9290. }
  9291. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9292. userJSONBytes3, _ := json.Marshal(respJSON3)
  9293. fmt.Println("log")
  9294. fmt.Println(string(userJSONBytes3))
  9295. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  9296. utils.ErrorLog("解析失败:%v", err)
  9297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9298. return
  9299. }
  9300. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9301. res2.Output = resSix10265.Output
  9302. res2.ErrMsg = resSix10265.ErrMsg
  9303. res2.Cainfo = resSix10265.Cainfo
  9304. res2.WarnMsg = resSix10265.WarnMsg
  9305. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9306. res2.Infcode = infocode
  9307. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9308. if err == nil {
  9309. c.ServeSuccessJSON(map[string]interface{}{
  9310. "msg": "撤销明细成功",
  9311. })
  9312. return
  9313. } else {
  9314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9315. return
  9316. }
  9317. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9318. result2, src_request, _ := service.FJyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9319. var dat map[string]interface{}
  9320. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9321. fmt.Println(dat)
  9322. } else {
  9323. fmt.Println(err)
  9324. }
  9325. saveLog(result2, src_request, "2205", "撤销明细")
  9326. userJSONBytes, _ := json.Marshal(dat)
  9327. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9328. utils.ErrorLog("解析失败:%v", err)
  9329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9330. return
  9331. }
  9332. if res2.Infcode == 0 {
  9333. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9334. if err == nil {
  9335. c.ServeSuccessJSON(map[string]interface{}{
  9336. "msg": "撤销明细成功",
  9337. })
  9338. return
  9339. } else {
  9340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9341. return
  9342. }
  9343. } else {
  9344. c.ServeSuccessJSON(map[string]interface{}{
  9345. "code": -10,
  9346. "msg": res2.ErrMsg,
  9347. })
  9348. }
  9349. } else {
  9350. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  9351. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  9352. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9353. resp2, requestErr2 := http.Get(api2)
  9354. if requestErr2 != nil {
  9355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9356. return
  9357. }
  9358. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9359. if ioErr2 != nil {
  9360. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9362. return
  9363. }
  9364. var respJSON2 map[string]interface{}
  9365. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9368. return
  9369. }
  9370. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9371. if err == nil {
  9372. c.ServeSuccessJSON(map[string]interface{}{
  9373. "msg": "撤销明细成功",
  9374. })
  9375. return
  9376. } else {
  9377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9378. return
  9379. }
  9380. }
  9381. } else {
  9382. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9383. if err == nil {
  9384. c.ServeSuccessJSON(map[string]interface{}{
  9385. "msg": "退费成功",
  9386. })
  9387. } else {
  9388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9389. return
  9390. }
  9391. }
  9392. }
  9393. //对账
  9394. func (c *HisApiController) GetCheckAccount() {
  9395. start_time := c.GetString("start_time")
  9396. end_time := c.GetString("end_time")
  9397. insutype := c.GetString("insutype")
  9398. clr_type := c.GetString("clr_type")
  9399. clr_org := c.GetString("clr_optins")
  9400. admin_user_id, _ := c.GetInt64("admin_user_id")
  9401. adminUser := c.GetAdminUserInfo()
  9402. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9403. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9404. if len(clr_org) == 0 {
  9405. clr_org = miConfig.MdtrtareaAdmvs
  9406. }
  9407. timeLayout := "2006-01-02"
  9408. loc, _ := time.LoadLocation("Local")
  9409. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  9410. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  9411. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  9412. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  9413. fixmedins_setl_cnt := int64(len(orders))
  9414. var medfee_sumamt float64
  9415. var acct_pay float64
  9416. var fund_pay_sumamt float64
  9417. for _, item := range orders {
  9418. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  9419. acct_pay = acct_pay + item.AcctPay
  9420. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  9421. }
  9422. var user_name string
  9423. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9424. if role.ID == 0 {
  9425. user_name = "xxx"
  9426. } else {
  9427. user_name = role.UserName
  9428. }
  9429. var res ResultEight
  9430. var res10188 ResultEightFor10188
  9431. if config.IsOpen == 1 {
  9432. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9433. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  9434. "insutype=" + insutype +
  9435. "&clr_type=" + clr_type +
  9436. "&setl_optins=" + clr_org +
  9437. "&stmt_begndate=" + start_time +
  9438. "&stm_enddate=" + end_time +
  9439. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9440. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9441. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9442. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  9443. "&fixmedins_code=" + miConfig.Code +
  9444. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9445. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9446. "&secret_key=" + miConfig.SecretKey +
  9447. "&org_name=" + miConfig.OrgName +
  9448. "&doctor=" + user_name +
  9449. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9450. fmt.Println(api)
  9451. resp, requestErr := http.Get(api)
  9452. if requestErr != nil {
  9453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9454. return
  9455. }
  9456. body, ioErr := ioutil.ReadAll(resp.Body)
  9457. fmt.Println(body)
  9458. if ioErr != nil {
  9459. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9461. return
  9462. }
  9463. var respJSON map[string]interface{}
  9464. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9465. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9467. return
  9468. }
  9469. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9470. userJSONBytes, _ := json.Marshal(respJSON)
  9471. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9472. utils.ErrorLog("解析失败:%v", err)
  9473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9474. return
  9475. }
  9476. res.InfRefmsgid = res10188.InfRefmsgid
  9477. res.Output = res10188.Output
  9478. res.ErrMsg = res10188.ErrMsg
  9479. res.Cainfo = res10188.Cainfo
  9480. res.WarnMsg = res10188.WarnMsg
  9481. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  9482. res.Infcode = infocode
  9483. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9484. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  9485. "insutype=" + insutype +
  9486. "&clr_type=" + "21" +
  9487. "&setl_optins=" + clr_org +
  9488. "&stmt_begndate=" + start_time +
  9489. "&stm_enddate=" + end_time +
  9490. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9491. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9492. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9493. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  9494. "&fixmedins_code=" + miConfig.Code +
  9495. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9496. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9497. "&secret_key=" + miConfig.SecretKey +
  9498. "&org_name=" + miConfig.OrgName +
  9499. "&doctor=" + user_name
  9500. resp, requestErr := http.Get(api)
  9501. if requestErr != nil {
  9502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9503. return
  9504. }
  9505. body, ioErr := ioutil.ReadAll(resp.Body)
  9506. if ioErr != nil {
  9507. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9509. return
  9510. }
  9511. var respJSON map[string]interface{}
  9512. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9513. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9515. return
  9516. }
  9517. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9518. result, _ := json.Marshal(respJSON)
  9519. fmt.Println("log")
  9520. fmt.Println(string(result))
  9521. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  9522. utils.ErrorLog("解析失败:%v", err)
  9523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9524. return
  9525. }
  9526. res.InfRefmsgid = res10188.InfRefmsgid
  9527. res.Output = res10188.Output
  9528. res.ErrMsg = res10188.ErrMsg
  9529. res.Cainfo = res10188.Cainfo
  9530. res.WarnMsg = res10188.WarnMsg
  9531. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  9532. res.Infcode = infocode
  9533. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9534. var baseParams models.BaseParams
  9535. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9536. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9537. baseParams.SecretKey = miConfig.SecretKey
  9538. baseParams.OrgName = miConfig.OrgName
  9539. baseParams.FixmedinsCode = miConfig.Code
  9540. baseParams.EncKey = miConfig.EncKey
  9541. baseParams.AppSecret = miConfig.AppSecret
  9542. baseParams.SignKey = miConfig.SignKey
  9543. baseParams.AppID = miConfig.Code
  9544. baseParams.Doctor = role.UserName
  9545. baseParams.RequestUrl = miConfig.Url
  9546. businessParams := models.BusinessParams{
  9547. Insutype: insutype,
  9548. ClrType: clr_type,
  9549. SetlOptins: clr_org,
  9550. StmtBegndate: start_time,
  9551. StmtEnddate: end_time,
  9552. MedfeeSumamt: medfee_sumamt,
  9553. FundPaySumamt: fund_pay_sumamt,
  9554. AcctPay: acct_pay,
  9555. FixmedinsSetlCnt: fixmedins_setl_cnt + int64(len(orders_two)*2),
  9556. }
  9557. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams)
  9558. fmt.Println(requestLog)
  9559. fmt.Println(result)
  9560. fmt.Println(err_msg)
  9561. } else {
  9562. if len(clr_type) == 0 {
  9563. clr_type = "11"
  9564. }
  9565. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9566. "insutype=" + insutype +
  9567. "&clr_type=" + clr_type +
  9568. "&setl_optins=" + clr_org +
  9569. "&stmt_begndate=" + start_time +
  9570. "&stm_enddate=" + end_time +
  9571. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9572. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9573. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9574. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9575. "&fixmedins_code=" + miConfig.Code +
  9576. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9577. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9578. "&secret_key=" + miConfig.SecretKey +
  9579. "&org_name=" + miConfig.OrgName +
  9580. "&doctor=" + user_name
  9581. fmt.Println(api)
  9582. resp, requestErr := http.Get(api)
  9583. if requestErr != nil {
  9584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9585. return
  9586. }
  9587. body, ioErr := ioutil.ReadAll(resp.Body)
  9588. fmt.Println(body)
  9589. if ioErr != nil {
  9590. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9592. return
  9593. }
  9594. var respJSON map[string]interface{}
  9595. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9596. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9598. return
  9599. }
  9600. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9601. userJSONBytes, _ := json.Marshal(respJSON)
  9602. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9603. utils.ErrorLog("解析失败:%v", err)
  9604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9605. return
  9606. }
  9607. }
  9608. if res.Infcode == 0 {
  9609. if res.Output.Stmtinfo.StmtRslt == "0" {
  9610. micc := &models.MedicalInsuranceCostCompare{
  9611. StartTime: startime.Unix(),
  9612. EndTime: endtime.Unix(),
  9613. Insutype: insutype,
  9614. CheckType: 1,
  9615. Num: fixmedins_setl_cnt,
  9616. Mtime: time.Now().Unix(),
  9617. Status: 1,
  9618. UserOrgId: adminUser.CurrentOrgId,
  9619. CostTotal: medfee_sumamt,
  9620. FuncTotal: fund_pay_sumamt,
  9621. PsnPay: acct_pay,
  9622. Creator: admin_user_id,
  9623. Ctime: time.Now().Unix(),
  9624. ClrType: clr_type,
  9625. }
  9626. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  9627. if err == nil {
  9628. c.ServeSuccessJSON(map[string]interface{}{
  9629. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  9630. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  9631. })
  9632. } else {
  9633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9634. }
  9635. } else {
  9636. c.ServeSuccessJSON(map[string]interface{}{
  9637. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  9638. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  9639. })
  9640. }
  9641. } else {
  9642. c.ServeSuccessJSON(map[string]interface{}{
  9643. "code": -10,
  9644. "msg": res.ErrMsg,
  9645. })
  9646. }
  9647. }
  9648. }
  9649. func (c *HisApiController) Check310() {
  9650. adminUser := c.GetAdminUserInfo()
  9651. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9652. var user_name string
  9653. user_name = "高慧裕"
  9654. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9655. "insutype=" + "310" +
  9656. "&clr_type=" + "" +
  9657. "&setl_optins=" + "441202" +
  9658. "&stmt_begndate=" + "2022-03-01" +
  9659. "&stm_enddate=" + "2022-03-31" +
  9660. "&medfee_sumamt=" + "194930.12" +
  9661. "&fund_pay_sumamt=" + "188741.46" +
  9662. "&acct_pay=" + "0" +
  9663. "&fixmedins_setl_cnt=" + "452" +
  9664. "&fixmedins_code=" + miConfig.Code +
  9665. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9666. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9667. "&secret_key=" + miConfig.SecretKey +
  9668. "&org_name=" + miConfig.OrgName +
  9669. "&doctor=" + user_name
  9670. fmt.Println(api)
  9671. resp, requestErr := http.Get(api)
  9672. if requestErr != nil {
  9673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9674. return
  9675. }
  9676. body, ioErr := ioutil.ReadAll(resp.Body)
  9677. fmt.Println(body)
  9678. if ioErr != nil {
  9679. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9681. return
  9682. }
  9683. var respJSON map[string]interface{}
  9684. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9685. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9687. return
  9688. }
  9689. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9690. userJSONBytes, _ := json.Marshal(respJSON)
  9691. var res ResultEight
  9692. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9693. utils.ErrorLog("解析失败:%v", err)
  9694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9695. return
  9696. }
  9697. }
  9698. func (c *HisApiController) Check390() {
  9699. adminUser := c.GetAdminUserInfo()
  9700. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9701. var user_name string
  9702. user_name = "高慧裕"
  9703. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9704. "insutype=" + "390" +
  9705. "&clr_type=" + "" +
  9706. "&setl_optins=" + "441202" +
  9707. "&stmt_begndate=" + "2022-03-01" +
  9708. "&stm_enddate=" + "2022-03-31" +
  9709. "&medfee_sumamt=" + "1068448.89" +
  9710. "&fund_pay_sumamt=" + "1014677.62" +
  9711. "&acct_pay=" + "0" +
  9712. "&fixmedins_setl_cnt=" + "1950" +
  9713. "&fixmedins_code=" + miConfig.Code +
  9714. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9715. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9716. "&secret_key=" + miConfig.SecretKey +
  9717. "&org_name=" + miConfig.OrgName +
  9718. "&doctor=" + user_name
  9719. fmt.Println(api)
  9720. resp, requestErr := http.Get(api)
  9721. if requestErr != nil {
  9722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9723. return
  9724. }
  9725. body, ioErr := ioutil.ReadAll(resp.Body)
  9726. fmt.Println(body)
  9727. if ioErr != nil {
  9728. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9730. return
  9731. }
  9732. var respJSON map[string]interface{}
  9733. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9734. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9736. return
  9737. }
  9738. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9739. userJSONBytes, _ := json.Marshal(respJSON)
  9740. var res ResultEight
  9741. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9742. utils.ErrorLog("解析失败:%v", err)
  9743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9744. return
  9745. }
  9746. }
  9747. //对账明细
  9748. func (c *HisApiController) GetCheckDetailAccount() {
  9749. start_time := c.GetString("start_time")
  9750. end_time := c.GetString("end_time")
  9751. admin_user_id, _ := c.GetInt64("admin_user_id")
  9752. adminUser := c.GetAdminUserInfo()
  9753. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9754. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9755. timeLayout := "2006-01-02"
  9756. loc, _ := time.LoadLocation("Local")
  9757. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  9758. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  9759. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  9760. rand.Seed(time.Now().UnixNano())
  9761. num := rand.Intn(30000)
  9762. Mkdir(miConfig.OrgName)
  9763. file := strconv.FormatInt(int64(num), 10)
  9764. file_name := file + ".txt"
  9765. zip_name := file + ".zip"
  9766. zip_path := miConfig.OrgName + "/" + zip_name
  9767. file_path := miConfig.OrgName + "/" + file_name
  9768. decimal.DivisionPrecision = 2
  9769. var medfee_sumamt float64
  9770. var psn_cash_pay float64
  9771. var fund_pay_sumamt float64
  9772. fixmedins_setl_cnt := int64(len(orders))
  9773. for _, item := range orders {
  9774. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  9775. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  9776. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  9777. }
  9778. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  9779. defer f.Close()
  9780. if err != nil {
  9781. fmt.Println(err.Error())
  9782. } else {
  9783. for _, item := range orders {
  9784. var refd_setl_flag string
  9785. if item.OrderStatus == 2 {
  9786. refd_setl_flag = "0"
  9787. var str string
  9788. str = item.SetlId + " " +
  9789. item.MdtrtId + " " +
  9790. item.PsnNo + " " +
  9791. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9792. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9793. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  9794. _, err = f.Write([]byte(str))
  9795. }
  9796. if item.OrderStatus == 3 {
  9797. var str string
  9798. str = item.SetlId + " " +
  9799. item.MdtrtId + " " +
  9800. item.PsnNo + " " +
  9801. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9802. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9803. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  9804. _, err = f.Write([]byte(str))
  9805. var str2 string
  9806. str2 = item.SetlId + " " +
  9807. item.MdtrtId + " " +
  9808. item.PsnNo + " " +
  9809. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  9810. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  9811. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  9812. _, err = f.Write([]byte(str2))
  9813. }
  9814. }
  9815. }
  9816. Zip(file_path, zip_path)
  9817. fmt.Println(ReadFile(zip_path))
  9818. fmt.Println(string(ReadFile(zip_path)))
  9819. if config.IsOpen == 1 {
  9820. var user_name string
  9821. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9822. if role.ID == 0 {
  9823. user_name = "管理员"
  9824. } else {
  9825. user_name = role.UserName
  9826. }
  9827. baseParams := models.BaseParams{
  9828. SecretKey: miConfig.SecretKey,
  9829. FixmedinsCode: miConfig.Code,
  9830. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9831. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9832. OrgName: miConfig.OrgName,
  9833. Doctor: user_name,
  9834. }
  9835. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  9836. var dat map[string]interface{}
  9837. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9838. fmt.Println(dat)
  9839. } else {
  9840. fmt.Println(err)
  9841. }
  9842. userJSONBytes, _ := json.Marshal(dat)
  9843. var res ResultNine
  9844. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9845. utils.ErrorLog("解析失败:%v", err)
  9846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9847. return
  9848. }
  9849. if res.Infcode == 0 {
  9850. fileNo := res.Output.FileQuryNo
  9851. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  9852. "file_qury_no=" + fileNo +
  9853. "&setl_optins=" + "定点医保中心" +
  9854. "&stmt_begndate=" + start_time +
  9855. "&stm_enddate=" + end_time +
  9856. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9857. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9858. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  9859. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9860. "&fixmedins_code=" + miConfig.Code +
  9861. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9862. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9863. "&secret_key=" + miConfig.SecretKey +
  9864. "&org_name=" + miConfig.OrgName +
  9865. "&doctor=" + user_name
  9866. resp, requestErr := http.Get(api)
  9867. if requestErr != nil {
  9868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9869. return
  9870. }
  9871. body, ioErr := ioutil.ReadAll(resp.Body)
  9872. if ioErr != nil {
  9873. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9875. return
  9876. }
  9877. var respJSON map[string]interface{}
  9878. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9879. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9881. return
  9882. }
  9883. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9884. userJSONBytes, _ := json.Marshal(respJSON)
  9885. var res ResultTen
  9886. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9887. utils.ErrorLog("解析失败:%v", err)
  9888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9889. return
  9890. }
  9891. if res.Infcode == 0 {
  9892. service.Gdyb9102(baseParams, zip_name, fileNo)
  9893. micc := &models.MedicalInsuranceCostCompare{
  9894. StartTime: startime.Unix(),
  9895. EndTime: endtime.Unix(),
  9896. Insutype: "0",
  9897. CheckType: 2,
  9898. Num: fixmedins_setl_cnt,
  9899. Mtime: time.Now().Unix(),
  9900. Status: 1,
  9901. UserOrgId: adminUser.CurrentOrgId,
  9902. CostTotal: medfee_sumamt,
  9903. FuncTotal: fund_pay_sumamt,
  9904. PsnPay: psn_cash_pay,
  9905. Creator: admin_user_id,
  9906. Ctime: time.Now().Unix(),
  9907. }
  9908. service.CreateMedicalInsuranceCostCompareRecord(micc)
  9909. c.ServeSuccessJSON(map[string]interface{}{
  9910. "msg": "明细对账成功",
  9911. })
  9912. }
  9913. } else {
  9914. }
  9915. }
  9916. }
  9917. type CustomOrderInfo struct {
  9918. Name string
  9919. Spec string
  9920. Unit string
  9921. Count float64
  9922. Price float64
  9923. Total float64
  9924. }
  9925. func (c *HisApiController) GetSettleAccounts() {
  9926. //id, _ := c.GetInt64("id")
  9927. //record_time := c.GetString("record_time")
  9928. order_id, _ := c.GetInt64("order_id")
  9929. admin_user_id, _ := c.GetInt64("admin_user_id")
  9930. //timeLayout := "2006-01-02"
  9931. //loc, _ := time.LoadLocation("Local")
  9932. //
  9933. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9934. //if err != nil {
  9935. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9936. // return
  9937. //}
  9938. //recordDateTime := theTime.Unix()
  9939. adminUser := c.GetAdminUserInfo()
  9940. order, _ := service.GetHisOrderByID(order_id)
  9941. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9942. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  9943. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9944. orderInfos = append(orderInfos, orderInfos_two...)
  9945. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9946. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  9947. var diagnosis_ids []string
  9948. if his.ID > 0 {
  9949. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  9950. } else {
  9951. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  9952. }
  9953. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  9954. var dia_config []*models.HisXtDiagnoseConfig
  9955. var name string
  9956. for _, item := range diagnosis_ids {
  9957. id, _ := strconv.ParseInt(item, 10, 64)
  9958. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9959. dia_config = append(dia_config, &diagnosisConfig)
  9960. if len(name) == 0 {
  9961. name = diagnosisConfig.ClassName
  9962. } else {
  9963. name = name + "," + diagnosisConfig.ClassName
  9964. }
  9965. }
  9966. var bedCostTotal float64 = 0 //床位总费
  9967. var bedCostSelfTotal float64 = 0 //床位自费
  9968. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  9969. var operationCostTotal float64 = 0 //手术费
  9970. var operationCostSelfTotal float64 = 0 //手术费
  9971. var operationCostPartSelfTotal float64 = 0 //手术费
  9972. var otherCostTotal float64 = 0 //其他费用
  9973. var otherCostSelfTotal float64 = 0 //其他费用
  9974. var otherCostPartSelfTotal float64 = 0 //其他费用
  9975. var materialCostTotal float64 = 0 //材料费
  9976. var materialCostSelfTotal float64 = 0 //材料费
  9977. var materialCostPartSelfTotal float64 = 0 //材料费
  9978. var westernMedicineCostTotal float64 = 0 //西药费
  9979. var westernMedicineCostSelfTotal float64 = 0 //西药费
  9980. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  9981. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  9982. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  9983. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  9984. var checkCostTotal float64 = 0 //检查费
  9985. var checkCostSelfTotal float64 = 0 //检查费
  9986. var checkCostPartSelfTotal float64 = 0 //检查费
  9987. var laboratoryCostTotal float64 = 0 //化验费
  9988. var laboratoryCostSelfTotal float64 = 0 //化验费
  9989. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  9990. var treatCostTotal float64 = 0 //治疗费用
  9991. var treatCostSelfTotal float64 = 0 //治疗费用
  9992. var treatCostPartSelfTotal float64 = 0 //治疗费用
  9993. decimal.DivisionPrecision = 2
  9994. for _, item := range orderInfos {
  9995. if item.MedChrgitmType == "01" { //床位费
  9996. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9997. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9998. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9999. }
  10000. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  10001. if item.MedChrgitmType == "03" { //检查费
  10002. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10003. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10004. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10005. }
  10006. } else {
  10007. if item.MedChrgitmType == "03" { //检查费
  10008. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10009. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10010. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10011. }
  10012. }
  10013. if item.MedChrgitmType == "04" { //化验费
  10014. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10015. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10016. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10017. }
  10018. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  10019. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10020. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10021. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10022. }
  10023. if item.MedChrgitmType == "06" { //手术费
  10024. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10025. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10026. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10027. }
  10028. if item.MedChrgitmType == "08" { //材料费
  10029. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10030. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10031. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10032. }
  10033. if item.MedChrgitmType == "09" { //西药费
  10034. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10035. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10036. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10037. }
  10038. if item.MedChrgitmType == "11" { //中成费
  10039. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10040. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10041. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10042. }
  10043. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  10044. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10045. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10046. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10047. }
  10048. }
  10049. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10050. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10051. var user_name string
  10052. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10053. if role.ID == 0 {
  10054. user_name = "管理员"
  10055. } else {
  10056. user_name = role.UserName
  10057. }
  10058. baseParams := models.BaseParams{
  10059. SecretKey: miConfig.SecretKey,
  10060. FixmedinsCode: miConfig.Code,
  10061. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10062. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10063. OrgName: miConfig.OrgName,
  10064. Doctor: user_name,
  10065. }
  10066. businessParams := models.BusinessParams{
  10067. PsnNo: order.PsnNo,
  10068. MdtrtId: order.MdtrtId,
  10069. SetlId: order.SetlId,
  10070. }
  10071. var res ResultEleven
  10072. var resEleven10265 ResultEleven10265
  10073. if config.IsOpen == 1 {
  10074. if miConfig.MdtrtareaAdmvs == "421300" {
  10075. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  10076. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  10077. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10078. resp, requestErr := http.Get(api)
  10079. if requestErr != nil {
  10080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10081. return
  10082. }
  10083. body, ioErr := ioutil.ReadAll(resp.Body)
  10084. if ioErr != nil {
  10085. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10087. return
  10088. }
  10089. var respJSON map[string]interface{}
  10090. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10091. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10093. return
  10094. }
  10095. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10096. result, _ := json.Marshal(respJSON)
  10097. fmt.Println("log")
  10098. fmt.Println(string(result))
  10099. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10100. utils.ErrorLog("解析失败:%v", err)
  10101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10102. return
  10103. }
  10104. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10105. var api string
  10106. if miConfig.MdtrtareaAdmvs == "320921" {
  10107. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  10108. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  10109. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10110. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10111. } else {
  10112. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10113. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  10114. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  10115. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10116. }
  10117. resp, requestErr := http.Get(api)
  10118. if requestErr != nil {
  10119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10120. return
  10121. }
  10122. body, ioErr := ioutil.ReadAll(resp.Body)
  10123. if ioErr != nil {
  10124. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10126. return
  10127. }
  10128. var respJSON map[string]interface{}
  10129. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10132. return
  10133. }
  10134. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10135. result, _ := json.Marshal(respJSON)
  10136. fmt.Println("log")
  10137. fmt.Println(string(result))
  10138. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  10139. utils.ErrorLog("解析失败:%v", err)
  10140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10141. return
  10142. }
  10143. res.InfRefmsgid = resEleven10265.InfRefmsgid
  10144. res.Output = resEleven10265.Output
  10145. res.ErrMsg = resEleven10265.ErrMsg
  10146. res.Cainfo = resEleven10265.Cainfo
  10147. res.WarnMsg = resEleven10265.WarnMsg
  10148. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  10149. res.Infcode = infocode
  10150. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10151. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  10152. saveLog(result, requestLog, "5203", "结算单")
  10153. var dat map[string]interface{}
  10154. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10155. fmt.Println(dat)
  10156. } else {
  10157. fmt.Println(err)
  10158. }
  10159. userJSONBytes, _ := json.Marshal(dat)
  10160. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10161. utils.ErrorLog("解析失败:%v", err)
  10162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10163. return
  10164. }
  10165. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10166. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  10167. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  10168. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10169. resp, requestErr := http.Get(api)
  10170. if requestErr != nil {
  10171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10172. return
  10173. }
  10174. body, ioErr := ioutil.ReadAll(resp.Body)
  10175. if ioErr != nil {
  10176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10178. return
  10179. }
  10180. var respJSON map[string]interface{}
  10181. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10184. return
  10185. }
  10186. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10187. result, _ := json.Marshal(respJSON)
  10188. fmt.Println("log")
  10189. fmt.Println(string(result))
  10190. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  10191. utils.ErrorLog("解析失败:%v", err)
  10192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10193. return
  10194. }
  10195. res.InfRefmsgid = resEleven10265.InfRefmsgid
  10196. res.Output = resEleven10265.Output
  10197. res.ErrMsg = resEleven10265.ErrMsg
  10198. res.Cainfo = resEleven10265.Cainfo
  10199. res.WarnMsg = resEleven10265.WarnMsg
  10200. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  10201. res.Infcode = infocode
  10202. } else {
  10203. result := service.Gdyb5203(baseParams, businessParams)
  10204. //service.Gdyb5204(baseParams, businessParams)
  10205. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  10206. var dat map[string]interface{}
  10207. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10208. fmt.Println(dat)
  10209. } else {
  10210. fmt.Println(err)
  10211. }
  10212. userJSONBytes, _ := json.Marshal(dat)
  10213. if miConfig.Code == "H15049901371" {
  10214. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  10215. utils.ErrorLog("解析失败:%v", err)
  10216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10217. return
  10218. }
  10219. res.InfRefmsgid = resEleven10265.InfRefmsgid
  10220. res.Output = resEleven10265.Output
  10221. res.ErrMsg = resEleven10265.ErrMsg
  10222. res.Cainfo = resEleven10265.Cainfo
  10223. res.WarnMsg = resEleven10265.WarnMsg
  10224. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  10225. res.Infcode = infocode
  10226. } else {
  10227. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10228. utils.ErrorLog("解析失败:%v", err)
  10229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10230. return
  10231. }
  10232. }
  10233. }
  10234. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10235. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  10236. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  10237. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10238. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  10239. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10240. var doctor_name string
  10241. if roles.ID == 0 {
  10242. doctor_name = "管理员"
  10243. } else {
  10244. doctor_name = roles.UserName
  10245. }
  10246. yiliao_leibie := ""
  10247. switch order.MedType {
  10248. case "11":
  10249. yiliao_leibie = "普通门诊"
  10250. break
  10251. case "12":
  10252. yiliao_leibie = "门诊挂号"
  10253. break
  10254. case "13":
  10255. yiliao_leibie = "急诊"
  10256. break
  10257. case "14":
  10258. yiliao_leibie = "门诊特殊病"
  10259. break
  10260. case "15":
  10261. yiliao_leibie = "门诊统筹"
  10262. break
  10263. case "16":
  10264. yiliao_leibie = "门诊慢性病"
  10265. break
  10266. case "21":
  10267. yiliao_leibie = "普通住院"
  10268. break
  10269. }
  10270. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10271. if res.Infcode == 0 {
  10272. c.ServeSuccessJSON(map[string]interface{}{
  10273. "diagnosis": name,
  10274. "order_infos": orderInfos,
  10275. "number": order.MdtrtId,
  10276. "date": order.SettleAccountsDate,
  10277. "charge_admin": charge_admin,
  10278. "printor_admin": printor_admin,
  10279. "info": res.Output.Setlinfo,
  10280. "order": order,
  10281. "bedCostTotal": bedCostTotal,
  10282. "bedCostSelfTotal": bedCostSelfTotal,
  10283. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  10284. "operationCostTotal": operationCostTotal,
  10285. "operationCostSelfTotal": operationCostSelfTotal,
  10286. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  10287. "otherCostTotal": otherCostTotal,
  10288. "otherCostSelfTotal": otherCostSelfTotal,
  10289. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  10290. "materialCostTotal": materialCostTotal,
  10291. "materialCostSelfTotal": materialCostSelfTotal,
  10292. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  10293. "westernMedicineCostTotal": westernMedicineCostTotal,
  10294. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  10295. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  10296. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  10297. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  10298. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  10299. "checkCostTotal": checkCostTotal,
  10300. "checkCostSelfTotal": checkCostSelfTotal,
  10301. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  10302. "laboratoryCostTotal": laboratoryCostTotal,
  10303. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  10304. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  10305. "treatCostTotal": treatCostTotal,
  10306. "treatCostSelfTotal": treatCostSelfTotal,
  10307. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  10308. "doctor_info": doctor_info,
  10309. "doctor_code": adminRole_two.DoctorCode,
  10310. "doctor_name": doctor_name,
  10311. "health_card_no": order.PsnNo,
  10312. "department": departments.Name,
  10313. "yiliao_leibie": yiliao_leibie,
  10314. "after_money": order.AccountPrice,
  10315. "patient": patient,
  10316. "org_name": miConfig.OrgName,
  10317. "org_code": miConfig.Code,
  10318. "order_number": order.Number,
  10319. "his_hospital": his_hospital,
  10320. "his": his,
  10321. "dia_config": dia_config,
  10322. //"check_order_info": cus_slice,
  10323. })
  10324. }
  10325. }
  10326. }
  10327. func (c *HisApiController) CheckTreatment() {
  10328. patient_id, _ := c.GetInt64("patient_id")
  10329. id_card_no := c.GetString("id_card_no")
  10330. insutype := c.GetString("insutype")
  10331. med_type := c.GetString("med_type")
  10332. admin_user_id, _ := c.GetInt64("admin_user_id")
  10333. adminUser := c.GetAdminUserInfo()
  10334. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10335. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10336. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10337. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10338. if miConfig.MdtrtareaAdmvs == "421300" {
  10339. var res ResultTwo
  10340. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  10341. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10342. "&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)
  10343. resp, requestErr := http.Get(api)
  10344. if requestErr != nil {
  10345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10346. return
  10347. }
  10348. body, ioErr := ioutil.ReadAll(resp.Body)
  10349. if ioErr != nil {
  10350. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10352. return
  10353. }
  10354. var respJSON map[string]interface{}
  10355. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10356. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10358. return
  10359. }
  10360. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10361. result, _ := json.Marshal(respJSON)
  10362. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10363. utils.ErrorLog("解析失败:%v", err)
  10364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10365. return
  10366. }
  10367. if res.Infcode == 0 {
  10368. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  10369. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10370. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  10371. resp, requestErr := http.Get(api)
  10372. if requestErr != nil {
  10373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10374. return
  10375. }
  10376. body, ioErr := ioutil.ReadAll(resp.Body)
  10377. if ioErr != nil {
  10378. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10380. return
  10381. }
  10382. var respJSON map[string]interface{}
  10383. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10384. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10386. return
  10387. }
  10388. var res Result2001
  10389. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10390. result2, _ := json.Marshal(respJSON)
  10391. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10392. utils.ErrorLog("解析失败:%v", err)
  10393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10394. return
  10395. }
  10396. if res.Infcode == 0 {
  10397. c.ServeSuccessJSON(map[string]interface{}{
  10398. "msg": res.Output.Trtinfo,
  10399. })
  10400. }
  10401. } else {
  10402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10403. return
  10404. }
  10405. } else {
  10406. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10407. var dat map[string]interface{}
  10408. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10409. fmt.Println(dat)
  10410. } else {
  10411. fmt.Println(err)
  10412. }
  10413. userJSONBytes, _ := json.Marshal(dat)
  10414. var res ResultTwo
  10415. var res10265 ResultTwo10265
  10416. if miConfig.Code == "H15049901371" {
  10417. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10418. utils.ErrorLog("解析失败:%v", err)
  10419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10420. return
  10421. }
  10422. res.ErrMsg = res10265.ErrMsg
  10423. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10424. res.Infcode = infocode
  10425. res.Output = res10265.Output
  10426. res.InfRefmsgid = res10265.InfRefmsgid
  10427. } else {
  10428. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10429. utils.ErrorLog("解析失败:%v", err)
  10430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10431. return
  10432. }
  10433. }
  10434. var user_name string
  10435. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  10436. if role.ID == 0 {
  10437. user_name = "xxx"
  10438. } else {
  10439. user_name = role.UserName
  10440. }
  10441. baseParams := models.BaseParams{
  10442. SecretKey: miConfig.SecretKey,
  10443. FixmedinsCode: miConfig.Code,
  10444. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10445. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10446. OrgName: miConfig.OrgName,
  10447. Doctor: user_name,
  10448. }
  10449. if config.IsOpen == 1 {
  10450. if miConfig.Code == "H15049901371" {
  10451. if med_type == "14" {
  10452. if insutype == "390" {
  10453. med_type = "9933"
  10454. } else if insutype == "310" {
  10455. med_type = "990502"
  10456. }
  10457. } else if med_type == "11" {
  10458. med_type = "11"
  10459. }
  10460. }
  10461. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  10462. var dat map[string]interface{}
  10463. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10464. fmt.Println(dat)
  10465. } else {
  10466. fmt.Println(err)
  10467. }
  10468. var res Result2001
  10469. var res10265 Result2001Org10265
  10470. if miConfig.Code == "H15049901371" {
  10471. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10472. utils.ErrorLog("解析失败:%v", err)
  10473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10474. return
  10475. }
  10476. res.ErrMsg = res10265.ErrMsg
  10477. res.Output = res10265.Output
  10478. res.InfRefmsgid = res10265.InfRefmsgid
  10479. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10480. res.Infcode = infocode
  10481. } else {
  10482. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10483. utils.ErrorLog("解析失败:%v", err)
  10484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10485. return
  10486. }
  10487. }
  10488. if res.Infcode == 0 {
  10489. c.ServeSuccessJSON(map[string]interface{}{
  10490. "msg": res.Output.Trtinfo,
  10491. })
  10492. }
  10493. }
  10494. }
  10495. }
  10496. //func (c *HisApiController) PutRecord() {
  10497. // id, _ := c.GetInt64("id")
  10498. // record_time := c.GetString("record_time")
  10499. // timeLayout := "2006-01-02"
  10500. // loc, _ := time.LoadLocation("Local")
  10501. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10502. // if err != nil {
  10503. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10504. // return
  10505. // }
  10506. // recordDateTime := theTime.Unix()
  10507. //
  10508. // adminInfo := c.GetAdminUserInfo()
  10509. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  10510. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10511. //
  10512. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  10513. //
  10514. // fmt.Println(miConfig.SecretKey)
  10515. //
  10516. // if patient == nil {
  10517. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10518. // return
  10519. // }
  10520. // if len(patient.IdCardNo) == 0 {
  10521. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  10522. // return
  10523. // }
  10524. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  10525. // if config.IsOpen == 1 {
  10526. // 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
  10527. // resp, requestErr := http.Get(api)
  10528. // if requestErr != nil {
  10529. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10530. // return
  10531. // }
  10532. // defer resp.Body.Close()
  10533. // body, ioErr := ioutil.ReadAll(resp.Body)
  10534. // if ioErr != nil {
  10535. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10536. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10537. // return
  10538. // }
  10539. // var respJSON map[string]interface{}
  10540. //
  10541. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10542. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10543. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10544. // return
  10545. // }
  10546. //
  10547. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10548. // userJSONBytes, _ := json.Marshal(userJSON)
  10549. // var res ResultTwo
  10550. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10551. // utils.ErrorLog("解析失败:%v", err)
  10552. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10553. // return
  10554. // }
  10555. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10556. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10557. // infoStr := string(Iinfos)
  10558. // idetinfoStr := string(Idetinfos)
  10559. //
  10560. // if res.Infcode == 0 {
  10561. // his := models.VMHisPatient{
  10562. // Status: 1,
  10563. // Ctime: time.Now().Unix(),
  10564. // Mtime: time.Now().Unix(),
  10565. // PsnNo: res.Output.Baseinfo.PsnNo,
  10566. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  10567. // Certno: res.Output.Baseinfo.Certno,
  10568. // PsnName: res.Output.Baseinfo.PsnName,
  10569. // Gend: res.Output.Baseinfo.Gend,
  10570. // Naty: res.Output.Baseinfo.Naty,
  10571. // Brdy: res.Output.Baseinfo.Brdy,
  10572. // Age: res.Output.Baseinfo.Age,
  10573. // Iinfo: infoStr,
  10574. // Idetinfo: idetinfoStr,
  10575. // PatientId: patient.ID,
  10576. // RecordDate: theTime.Unix(),
  10577. // UserOrgId: adminInfo.CurrentOrgId,
  10578. // AdminUserId: adminInfo.AdminUser.Id,
  10579. // IsReturn: 1,
  10580. // }
  10581. //
  10582. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  10583. // //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")
  10584. // //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")
  10585. //
  10586. // //var dat map[string]interface{}
  10587. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10588. // // fmt.Println(dat)
  10589. // //} else {
  10590. // // fmt.Println(err)
  10591. // //}
  10592. //
  10593. // var dat2 map[string]interface{}
  10594. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10595. // fmt.Println(dat2)
  10596. // } else {
  10597. // fmt.Println(err)
  10598. // }
  10599. //
  10600. // } else {
  10601. // adminUser := c.GetAdminUserInfo()
  10602. // errlog := &models.HisOrderError{
  10603. // UserOrgId: adminUser.CurrentOrgId,
  10604. // Ctime: time.Now().Unix(),
  10605. // Mtime: time.Now().Unix(),
  10606. // ErrMsg: res.ErrMsg,
  10607. // Status: 1,
  10608. // PatientId: id,
  10609. // RecordTime: recordDateTime,
  10610. // Stage: 1,
  10611. // }
  10612. // service.CreateErrMsgLog(errlog)
  10613. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  10614. // return
  10615. // }
  10616. // }
  10617. //
  10618. //}
  10619. //func (c *HisApiController) GetUploadDiag() {
  10620. // id, _ := c.GetInt64("id")
  10621. // record_time := c.GetString("record_time")
  10622. //
  10623. // diagnosis_id, _ := c.GetInt64("diagnosis")
  10624. // sick_type, _ := c.GetInt64("sick_type")
  10625. // reg_type, _ := c.GetInt64("reg_type")
  10626. //
  10627. // timeLayout := "2006-01-02"
  10628. // loc, _ := time.LoadLocation("Local")
  10629. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10630. // if err != nil {
  10631. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10632. // return
  10633. // }
  10634. //
  10635. // var patientPrescription models.HisPrescriptionInfo
  10636. // recordDateTime := theTime.Unix()
  10637. // adminInfo := c.GetAdminUserInfo()
  10638. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10639. //
  10640. // if patientPrescription.ID == 0 {
  10641. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10642. // }
  10643. //
  10644. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  10645. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  10646. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10647. // sickConfig, _ := service.FindSickById(sick_type)
  10648. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10649. //
  10650. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  10651. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  10652. // "&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 +
  10653. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  10654. // resp2, requestErr2 := http.Get(api2)
  10655. // if requestErr2 != nil {
  10656. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10657. // return
  10658. // }
  10659. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  10660. // if ioErr2 != nil {
  10661. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  10662. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10663. // return
  10664. // }
  10665. // var respJSON2 map[string]interface{}
  10666. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  10667. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10668. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10669. // return
  10670. // }
  10671. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10672. // userJSONBytes2, _ := json.Marshal(respJSON2)
  10673. //
  10674. // var res2 ResultSix
  10675. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10676. // utils.ErrorLog("解析失败:%v", err)
  10677. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10678. // return
  10679. // }
  10680. // if res2.Infcode != 0 {
  10681. // adminUser := c.GetAdminUserInfo()
  10682. // errlog := &models.HisOrderError{
  10683. // UserOrgId: adminUser.CurrentOrgId,
  10684. // Ctime: time.Now().Unix(),
  10685. // Mtime: time.Now().Unix(),
  10686. // ErrMsg: res2.ErrMsg,
  10687. // Status: 1,
  10688. // PatientId: id,
  10689. // RecordTime: recordDateTime,
  10690. // Stage: 3,
  10691. // }
  10692. // service.CreateErrMsgLog(errlog)
  10693. //
  10694. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  10695. // return
  10696. // }
  10697. //
  10698. // c.ServeSuccessJSON(map[string]interface{}{
  10699. // "msg": "上传成功",
  10700. // })
  10701. //
  10702. //}
  10703. type QueryResult struct {
  10704. ID int64
  10705. Name string
  10706. Code string
  10707. List_type_code string
  10708. }
  10709. func (c *HisApiController) GetCheckCode() {
  10710. ids_str := c.GetString("ids")
  10711. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  10712. ids_arr := strings.Split(ids_str, ",")
  10713. var queryResult []QueryResult
  10714. ids := make([]int64, 0)
  10715. for _, item := range ids_arr {
  10716. id, _ := strconv.ParseInt(item, 10, 64)
  10717. ids = append(ids, id)
  10718. }
  10719. if record_type == 1 {
  10720. drugs, _ := service.GetBatchDrugList(ids)
  10721. for _, item := range drugs {
  10722. result := QueryResult{
  10723. ID: item.ID,
  10724. Name: item.DrugName,
  10725. Code: item.MedicalInsuranceNumber,
  10726. List_type_code: "101",
  10727. }
  10728. queryResult = append(queryResult, result)
  10729. }
  10730. } else if record_type == 2 {
  10731. goods, _ := service.GetBatchGoodInformationList(ids)
  10732. for _, item := range goods {
  10733. result := QueryResult{
  10734. ID: item.ID,
  10735. Name: item.GoodName,
  10736. Code: item.MedicalInsuranceNumber,
  10737. List_type_code: "301",
  10738. }
  10739. queryResult = append(queryResult, result)
  10740. }
  10741. } else if record_type == 3 {
  10742. projects, _ := service.GetBathchMyPorjecgList(ids)
  10743. for _, item := range projects {
  10744. result := QueryResult{
  10745. ID: item.ID,
  10746. Name: item.ProjectName,
  10747. Code: item.MedicalCode,
  10748. List_type_code: "201",
  10749. }
  10750. queryResult = append(queryResult, result)
  10751. }
  10752. }
  10753. admin_user_id, _ := c.GetInt64("admin_user_id")
  10754. adminUser := c.GetAdminUserInfo()
  10755. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10756. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10757. var user_name string
  10758. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10759. if role.ID == 0 {
  10760. user_name = "xxx"
  10761. } else {
  10762. user_name = role.UserName
  10763. }
  10764. baseParams := &models.BaseParams{
  10765. SecretKey: miConfig.SecretKey,
  10766. FixmedinsCode: miConfig.Code,
  10767. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10768. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10769. OrgName: miConfig.OrgName,
  10770. Doctor: user_name,
  10771. }
  10772. if config.IsOpen == 1 {
  10773. for _, item := range queryResult {
  10774. var result string
  10775. if record_type == 1 {
  10776. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10777. } else if record_type == 2 {
  10778. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10779. } else if record_type == 3 {
  10780. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10781. }
  10782. var dat map[string]interface{}
  10783. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10784. fmt.Println(dat)
  10785. } else {
  10786. fmt.Println(err)
  10787. }
  10788. userJSONBytes, _ := json.Marshal(dat)
  10789. var res ResultSix
  10790. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10791. utils.ErrorLog("解析失败:%v", err)
  10792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10793. return
  10794. }
  10795. if res.Infcode == 0 {
  10796. if record_type == 1 {
  10797. service.UpdateBaseDrugById(item.ID)
  10798. } else if record_type == 2 {
  10799. service.UpdateGoodInformaitonByDetail(item.ID)
  10800. } else if record_type == 3 {
  10801. service.UpdateProjectById(item.ID)
  10802. }
  10803. c.ServeSuccessJSON(map[string]interface{}{
  10804. "failed_code": 0,
  10805. "msg": "目录对照成功",
  10806. })
  10807. } else {
  10808. c.ServeSuccessJSON(map[string]interface{}{
  10809. "failed_code": -10,
  10810. "msg": res.ErrMsg,
  10811. })
  10812. }
  10813. }
  10814. }
  10815. }
  10816. func (c *HisApiController) UnCheckCode() {
  10817. ids_str := c.GetString("ids")
  10818. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  10819. admin_user_id, _ := c.GetInt64("admin_user_id")
  10820. ids_arr := strings.Split(ids_str, ",")
  10821. var queryResult []QueryResult
  10822. ids := make([]int64, 0)
  10823. for _, item := range ids_arr {
  10824. id, _ := strconv.ParseInt(item, 10, 64)
  10825. ids = append(ids, id)
  10826. }
  10827. if record_type == 1 {
  10828. drugs, _ := service.GetBatchDrugList(ids)
  10829. for _, item := range drugs {
  10830. result := QueryResult{
  10831. ID: item.ID,
  10832. Name: item.DrugName,
  10833. Code: item.MedicalInsuranceNumber,
  10834. List_type_code: "101",
  10835. }
  10836. queryResult = append(queryResult, result)
  10837. }
  10838. } else if record_type == 2 {
  10839. goods, _ := service.GetBatchGoodInformationList(ids)
  10840. for _, item := range goods {
  10841. result := QueryResult{
  10842. ID: item.ID,
  10843. Name: item.GoodName,
  10844. Code: item.MedicalInsuranceNumber,
  10845. List_type_code: "301",
  10846. }
  10847. queryResult = append(queryResult, result)
  10848. }
  10849. } else if record_type == 3 {
  10850. projects, _ := service.GetBathchMyPorjecgList(ids)
  10851. for _, item := range projects {
  10852. result := QueryResult{
  10853. ID: item.ID,
  10854. Name: item.ProjectName,
  10855. Code: item.MedicalCode,
  10856. List_type_code: "201",
  10857. }
  10858. queryResult = append(queryResult, result)
  10859. }
  10860. }
  10861. adminUser := c.GetAdminUserInfo()
  10862. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10863. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10864. var user_name string
  10865. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10866. if role.ID == 0 {
  10867. user_name = "xxx"
  10868. } else {
  10869. user_name = role.UserName
  10870. }
  10871. baseParams := &models.BaseParams{
  10872. SecretKey: miConfig.SecretKey,
  10873. FixmedinsCode: miConfig.Code,
  10874. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10875. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10876. OrgName: miConfig.OrgName,
  10877. Doctor: user_name,
  10878. }
  10879. if config.IsOpen == 1 {
  10880. for _, item := range queryResult {
  10881. var result string
  10882. if record_type == 1 {
  10883. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10884. } else if record_type == 2 {
  10885. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10886. } else if record_type == 3 {
  10887. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10888. }
  10889. var dat2 map[string]interface{}
  10890. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  10891. fmt.Println(dat2)
  10892. } else {
  10893. fmt.Println(err)
  10894. }
  10895. userJSONBytes, _ := json.Marshal(dat2)
  10896. var res ResultSix
  10897. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10898. utils.ErrorLog("解析失败:%v", err)
  10899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10900. return
  10901. }
  10902. if res.Infcode == 0 {
  10903. if record_type == 1 {
  10904. service.UpdateDrugByIdDetail(item.ID)
  10905. } else if record_type == 2 {
  10906. service.UpdateGoodInfoById(item.ID)
  10907. } else if record_type == 3 {
  10908. service.UpdateMyProjectById(item.ID)
  10909. }
  10910. c.ServeSuccessJSON(map[string]interface{}{
  10911. "failed_code": 0,
  10912. "msg": "撤销目录对照成功",
  10913. })
  10914. } else {
  10915. c.ServeSuccessJSON(map[string]interface{}{
  10916. "failed_code": -10,
  10917. "msg": res.ErrMsg,
  10918. })
  10919. }
  10920. }
  10921. }
  10922. }
  10923. func (c *HisApiController) GetPatientInfo() {
  10924. id_card_no := c.GetString("id_card_no")
  10925. admin_user_id, _ := c.GetInt64("admin_user_id")
  10926. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  10927. if patient.ID == 0 {
  10928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10929. return
  10930. }
  10931. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10932. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10933. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  10934. if config.IsOpen == 1 {
  10935. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10936. var dat map[string]interface{}
  10937. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10938. fmt.Println(dat)
  10939. } else {
  10940. fmt.Println(err)
  10941. }
  10942. userJSONBytes, _ := json.Marshal(dat)
  10943. var res ResultTwo
  10944. var res10265 ResultTwo10265
  10945. if miConfig.Code == "H15049901371" {
  10946. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10947. utils.ErrorLog("解析失败:%v", err)
  10948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10949. return
  10950. }
  10951. res.ErrMsg = res10265.ErrMsg
  10952. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10953. res.Infcode = infocode
  10954. res.Output = res10265.Output
  10955. res.InfRefmsgid = res10265.InfRefmsgid
  10956. } else {
  10957. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10958. utils.ErrorLog("解析失败:%v", err)
  10959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10960. return
  10961. }
  10962. }
  10963. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10964. // utils.ErrorLog("解析失败:%v", err)
  10965. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10966. // return
  10967. //}
  10968. if res.Infcode != 0 {
  10969. c.ServeSuccessJSON(map[string]interface{}{
  10970. "failed_code": -10,
  10971. "msg": res.ErrMsg,
  10972. })
  10973. } else {
  10974. c.ServeSuccessJSON(map[string]interface{}{
  10975. "failed_code": 0,
  10976. "info": res,
  10977. })
  10978. }
  10979. }
  10980. }
  10981. func (c *HisApiController) PsnPutOnRecord() {
  10982. record_type, _ := c.GetInt64("type")
  10983. patient_id, _ := c.GetInt64("patient_id")
  10984. admin_user_id, _ := c.GetInt64("admin_user_id")
  10985. start_time := c.GetString("start_time")
  10986. end_time := c.GetString("end_time")
  10987. adminUser := c.GetAdminUserInfo()
  10988. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10989. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10990. var patients []*models.Patients
  10991. if record_type == 1 { //全部备案
  10992. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  10993. patients = append(patients, patient...)
  10994. } else { //单个备案
  10995. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10996. patients = append(patients, patient)
  10997. }
  10998. var user_name string
  10999. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11000. if role.ID == 0 {
  11001. user_name = "xxx"
  11002. } else {
  11003. user_name = role.UserName
  11004. }
  11005. if config.IsOpen == 1 {
  11006. for _, item := range patients {
  11007. 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
  11008. resp, requestErr := http.Get(api)
  11009. if requestErr != nil {
  11010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11011. return
  11012. }
  11013. defer resp.Body.Close()
  11014. body, ioErr := ioutil.ReadAll(resp.Body)
  11015. if ioErr != nil {
  11016. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11018. return
  11019. }
  11020. var respJSON map[string]interface{}
  11021. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11024. return
  11025. }
  11026. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11027. userJSONBytes, _ := json.Marshal(userJSON)
  11028. var res ResultTwo
  11029. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11030. utils.ErrorLog("解析失败:%v", err)
  11031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11032. return
  11033. }
  11034. if res.Infcode == 0 {
  11035. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  11036. var dat map[string]interface{}
  11037. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11038. fmt.Println(dat)
  11039. } else {
  11040. fmt.Println(err)
  11041. }
  11042. userJSONBytes, _ := json.Marshal(dat)
  11043. var res2 ResultThirteen
  11044. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11045. utils.ErrorLog("解析失败:%v", err)
  11046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11047. return
  11048. }
  11049. if res2.Infcode == 0 {
  11050. psnResult := &models.GdybPsnRecord{
  11051. UserOrgId: adminUser.CurrentOrgId,
  11052. PatientId: item.ID,
  11053. PsnNo: res.Output.Baseinfo.PsnNo,
  11054. Ctime: time.Now().Unix(),
  11055. Mtime: time.Now().Unix(),
  11056. Status: 1,
  11057. IsCancel: 1,
  11058. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  11059. }
  11060. service.CreatePsnRecord(psnResult)
  11061. } else {
  11062. c.ServeSuccessJSON(map[string]interface{}{
  11063. "failed_code": -10,
  11064. "msg": res2.ErrMsg,
  11065. })
  11066. return
  11067. }
  11068. }
  11069. }
  11070. }
  11071. }
  11072. func (c *HisApiController) PsnUnPutOnRecord() {
  11073. id, _ := c.GetInt64("id")
  11074. //record_type, _ := c.GetInt64("type")
  11075. admin_user_id, _ := c.GetInt64("admin_user_id")
  11076. adminUser := c.GetAdminUserInfo()
  11077. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11078. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11079. var user_name string
  11080. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11081. if role.ID == 0 {
  11082. user_name = "xxx"
  11083. } else {
  11084. user_name = role.UserName
  11085. }
  11086. psn_record, _ := service.GetPsnRecordById(id)
  11087. if psn_record.ID == 0 {
  11088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  11089. return
  11090. }
  11091. if config.IsOpen == 1 {
  11092. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  11093. var dat map[string]interface{}
  11094. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11095. fmt.Println(dat)
  11096. } else {
  11097. fmt.Println(err)
  11098. }
  11099. userJSONBytes, _ := json.Marshal(dat)
  11100. var res ResultFourteen
  11101. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11102. utils.ErrorLog("解析失败:%v", err)
  11103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11104. return
  11105. }
  11106. if res.Infcode == 0 {
  11107. psn_record.IsCancel = 2
  11108. service.CreatePsnRecord(&psn_record)
  11109. } else {
  11110. c.ServeSuccessJSON(map[string]interface{}{
  11111. "failed_code": -10,
  11112. "msg": res.ErrMsg,
  11113. })
  11114. return
  11115. }
  11116. }
  11117. }
  11118. func (c *HisApiController) PsnPutNCDSOnRecord() {
  11119. patient_id, _ := c.GetInt64("patient_id")
  11120. insutype_two := c.GetString("insutype")
  11121. psn_no := c.GetString("psn_no")
  11122. doctor_id, _ := c.GetInt64("doctor_id")
  11123. sick_id, _ := c.GetInt64("sick_id")
  11124. department_id, _ := c.GetInt64("department_id")
  11125. start_time := c.GetString("start_time")
  11126. end_time := c.GetString("end_time")
  11127. check_time := c.GetString("check_time")
  11128. adminUser := c.GetAdminUserInfo()
  11129. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  11130. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11131. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11132. sick, _ := service.FindSickById(sick_id)
  11133. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  11134. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  11135. var res ResultTwo
  11136. var res10265 ResultTwo10265
  11137. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11138. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  11139. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  11140. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11141. "&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
  11142. resp, requestErr := http.Get(api)
  11143. if requestErr != nil {
  11144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11145. return
  11146. }
  11147. body, ioErr := ioutil.ReadAll(resp.Body)
  11148. if ioErr != nil {
  11149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11151. return
  11152. }
  11153. var respJSON map[string]interface{}
  11154. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11155. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11157. return
  11158. }
  11159. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11160. result, _ := json.Marshal(respJSON)
  11161. fmt.Println("log")
  11162. fmt.Println(string(result))
  11163. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11164. utils.ErrorLog("解析失败:%v", err)
  11165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11166. return
  11167. }
  11168. res.ErrMsg = res10265.ErrMsg
  11169. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11170. res.Infcode = infocode
  11171. res.Output = res10265.Output
  11172. res.InfRefmsgid = res10265.InfRefmsgid
  11173. } else {
  11174. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  11175. if miConfig.Code == "H15049901371" {
  11176. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11177. utils.ErrorLog("解析失败:%v", err)
  11178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11179. return
  11180. }
  11181. res.ErrMsg = res10265.ErrMsg
  11182. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11183. res.Infcode = infocode
  11184. res.Output = res10265.Output
  11185. res.InfRefmsgid = res10265.InfRefmsgid
  11186. } else {
  11187. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11188. utils.ErrorLog("解析失败:%v", err)
  11189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11190. return
  11191. }
  11192. }
  11193. }
  11194. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11195. infoStr := string(Iinfos)
  11196. var rf []*ResultFive
  11197. json.Unmarshal([]byte(infoStr), &rf)
  11198. var insuplc_admdvs string
  11199. var insutype string
  11200. var is390 int = 0
  11201. var is310 int = 0
  11202. var insutypes []*ResultFive
  11203. for _, item := range rf {
  11204. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11205. insutypes = append(insutypes, item)
  11206. }
  11207. }
  11208. if len(insutypes) == 1 {
  11209. insutype = insutypes[0].Insutype
  11210. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11211. } else {
  11212. for _, i := range insutypes {
  11213. if i.Insutype == "390" {
  11214. is390 = 1
  11215. }
  11216. if i.Insutype == "310" {
  11217. is310 = 1
  11218. }
  11219. }
  11220. }
  11221. if is390 == 1 {
  11222. insutype = "390"
  11223. }
  11224. if is310 == 1 {
  11225. insutype = "310"
  11226. }
  11227. if len(insutypes) == 2 {
  11228. insutype = insutype_two
  11229. }
  11230. if len(insutypes) == 0 {
  11231. insutype = "310"
  11232. }
  11233. insutype = insutype_two
  11234. fmt.Println(insutype)
  11235. for _, item := range rf {
  11236. fmt.Println(item.Insutype)
  11237. fmt.Println(insutype)
  11238. if item.Insutype == insutype {
  11239. fmt.Println(item.Insutype)
  11240. fmt.Println(insutype)
  11241. insuplc_admdvs = item.InsuplcAdmdvs
  11242. }
  11243. }
  11244. fmt.Println(insuplc_admdvs)
  11245. var res2 ResultThirteen
  11246. var res10265_2 ResultThirteen10265
  11247. if config.IsOpen == 1 {
  11248. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11249. } else {
  11250. 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)
  11251. var dat map[string]interface{}
  11252. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11253. fmt.Println(dat)
  11254. } else {
  11255. fmt.Println(err)
  11256. }
  11257. userJSONBytes, _ := json.Marshal(dat)
  11258. if miConfig.Code == "H15049901371" {
  11259. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  11260. utils.ErrorLog("解析失败:%v", err)
  11261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11262. return
  11263. }
  11264. res2.ErrMsg = res10265_2.ErrMsg
  11265. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  11266. res2.Infcode = infocode
  11267. res2.Output = res10265_2.Output
  11268. res2.InfRefmsgid = res10265_2.InfRefmsgid
  11269. } else {
  11270. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11271. utils.ErrorLog("解析失败:%v", err)
  11272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11273. return
  11274. }
  11275. }
  11276. }
  11277. if res2.Infcode == 0 {
  11278. psnResult := &models.GdybPsnNcdsRecord{
  11279. UserOrgId: adminUser.CurrentOrgId,
  11280. PatientId: patient.ID,
  11281. PsnNo: psn_no,
  11282. DoctorId: doctor.AdminUserId,
  11283. DepartmentId: department_id,
  11284. SickType: sick_id,
  11285. Insutype: insutype,
  11286. Ctime: time.Now().Unix(),
  11287. Mtime: time.Now().Unix(),
  11288. Status: 1,
  11289. IsCancel: 1,
  11290. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  11291. }
  11292. service.CreatePsnNCDSRecord(psnResult)
  11293. c.ServeSuccessJSON(map[string]interface{}{
  11294. "failed_code": 0,
  11295. "msg": "备案成功",
  11296. "result": psnResult,
  11297. })
  11298. } else {
  11299. c.ServeSuccessJSON(map[string]interface{}{
  11300. "failed_code": -10,
  11301. "msg": res2.ErrMsg,
  11302. })
  11303. return
  11304. }
  11305. }
  11306. }
  11307. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  11308. id, _ := c.GetInt64("id")
  11309. admin_user_id, _ := c.GetInt64("admin_user_id")
  11310. adminUser := c.GetAdminUserInfo()
  11311. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11312. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11313. //config, _ := service.Ge(adminUser.CurrentOrgId)
  11314. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  11315. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11316. //var user_name string
  11317. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11318. //if role.ID == 0 {
  11319. // user_name = "xxx"
  11320. //} else {
  11321. // user_name = role.UserName
  11322. //}
  11323. psn_record, _ := service.GetPsnNCDSRecordById(id)
  11324. if psn_record.ID == 0 {
  11325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  11326. return
  11327. }
  11328. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  11329. var res ResultTwo
  11330. var res10265 ResultTwo10265
  11331. if miConfig.Code == "H15049901371" {
  11332. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11333. utils.ErrorLog("解析失败:%v", err)
  11334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11335. return
  11336. }
  11337. res.ErrMsg = res10265.ErrMsg
  11338. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11339. res.Infcode = infocode
  11340. res.Output = res10265.Output
  11341. res.InfRefmsgid = res10265.InfRefmsgid
  11342. } else {
  11343. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11344. utils.ErrorLog("解析失败:%v", err)
  11345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11346. return
  11347. }
  11348. }
  11349. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11350. infoStr := string(Iinfos)
  11351. var rf []*ResultFive
  11352. json.Unmarshal([]byte(infoStr), &rf)
  11353. var insuplc_admdvs string
  11354. var insutype string
  11355. var is390 int = 0
  11356. var is310 int = 0
  11357. var insutypes []*ResultFive
  11358. for _, item := range rf {
  11359. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11360. insutypes = append(insutypes, item)
  11361. }
  11362. }
  11363. if len(insutypes) == 1 {
  11364. insutype = insutypes[0].Insutype
  11365. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11366. } else {
  11367. for _, i := range insutypes {
  11368. if i.Insutype == "390" {
  11369. is390 = 1
  11370. }
  11371. if i.Insutype == "310" {
  11372. is310 = 1
  11373. }
  11374. }
  11375. }
  11376. if is390 == 1 {
  11377. insutype = "390"
  11378. }
  11379. if is310 == 1 {
  11380. insutype = "310"
  11381. }
  11382. if len(insutypes) == 0 {
  11383. insutype = "310"
  11384. }
  11385. insutype = psn_record.Insutype
  11386. for _, item := range rf {
  11387. if item.Insutype == insutype {
  11388. insuplc_admdvs = item.InsuplcAdmdvs
  11389. }
  11390. }
  11391. if config.IsOpen == 1 {
  11392. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  11393. var dat map[string]interface{}
  11394. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11395. fmt.Println(dat)
  11396. } else {
  11397. fmt.Println(err)
  11398. }
  11399. userJSONBytes, _ := json.Marshal(dat)
  11400. var res ResultFourteen
  11401. var res10265 ResultFourteen10265
  11402. if miConfig.Code == "H15049901371" {
  11403. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  11404. utils.ErrorLog("解析失败:%v", err)
  11405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11406. return
  11407. }
  11408. res.ErrMsg = res10265.ErrMsg
  11409. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11410. res.Infcode = infocode
  11411. res.Output = res10265.Output
  11412. res.InfRefmsgid = res10265.InfRefmsgid
  11413. } else {
  11414. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11415. utils.ErrorLog("解析失败:%v", err)
  11416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11417. return
  11418. }
  11419. }
  11420. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11421. // utils.ErrorLog("解析失败:%v", err)
  11422. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11423. // return
  11424. //}
  11425. if res.Infcode == 0 {
  11426. psn_record.IsCancel = 2
  11427. service.CreatePsnNCDSRecord(&psn_record)
  11428. c.ServeSuccessJSON(map[string]interface{}{
  11429. "failed_code": 0,
  11430. "msg": "撤销备案成功",
  11431. })
  11432. } else {
  11433. c.ServeSuccessJSON(map[string]interface{}{
  11434. "failed_code": -10,
  11435. "msg": res.ErrMsg,
  11436. })
  11437. return
  11438. }
  11439. }
  11440. }
  11441. func (c *HisApiController) TestTest() {
  11442. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  11443. fmt.Println(patient.Iinfo)
  11444. }
  11445. type CustomData struct {
  11446. MsgId string
  11447. PsnNo string
  11448. Info string
  11449. }
  11450. func (c *HisApiController) ReversalData() {
  11451. var customData []*CustomData
  11452. custom := &CustomData{
  11453. MsgId: "H44022900158202103301714472004",
  11454. PsnNo: "44020000001101329945",
  11455. Info: "2207",
  11456. }
  11457. customData = append(customData, custom)
  11458. custom1 := &CustomData{
  11459. MsgId: "H4402290015820210330172057803",
  11460. PsnNo: "44020000001101161813",
  11461. Info: "2207",
  11462. }
  11463. customData = append(customData, custom1)
  11464. custom2 := &CustomData{
  11465. MsgId: "H44022900158202103301705198813",
  11466. PsnNo: "44190000133097375417",
  11467. Info: "2207",
  11468. }
  11469. customData = append(customData, custom2)
  11470. custom3 := &CustomData{
  11471. MsgId: "H44022900158202103301715524756",
  11472. PsnNo: "44020000001100187221",
  11473. Info: "2207",
  11474. }
  11475. customData = append(customData, custom3)
  11476. custom4 := &CustomData{
  11477. MsgId: "H44022900158202103301730376224",
  11478. PsnNo: "44020000001101959155",
  11479. Info: "2207",
  11480. }
  11481. customData = append(customData, custom4)
  11482. custom5 := &CustomData{
  11483. MsgId: "H44022900158202103301748008725",
  11484. PsnNo: "44020000001104246641",
  11485. Info: "2207",
  11486. }
  11487. customData = append(customData, custom5)
  11488. custom6 := &CustomData{
  11489. MsgId: "H44022900158202103301718096755",
  11490. PsnNo: "44020000001102211860",
  11491. Info: "2207",
  11492. }
  11493. customData = append(customData, custom6)
  11494. custom7 := &CustomData{
  11495. MsgId: "H44022900158202103301736551640",
  11496. PsnNo: "44020000001102687718",
  11497. Info: "2207",
  11498. }
  11499. customData = append(customData, custom7)
  11500. custom8 := &CustomData{
  11501. MsgId: "H44022900158202103301743097676",
  11502. PsnNo: "44020000001102127785",
  11503. Info: "2207",
  11504. }
  11505. customData = append(customData, custom8)
  11506. custom9 := &CustomData{
  11507. MsgId: "H44022900158202103301712304203",
  11508. PsnNo: "44020000001101518097",
  11509. Info: "2207",
  11510. }
  11511. customData = append(customData, custom9)
  11512. custom10 := &CustomData{
  11513. MsgId: "H44022900158202103301738448785",
  11514. PsnNo: "44020000001100500813",
  11515. Info: "2207",
  11516. }
  11517. customData = append(customData, custom10)
  11518. custom11 := &CustomData{
  11519. MsgId: "H44022900158202103301732455843",
  11520. PsnNo: "44020000001102690557",
  11521. Info: "2207",
  11522. }
  11523. customData = append(customData, custom11)
  11524. custom12 := &CustomData{
  11525. MsgId: "H44022900158202103301745421708",
  11526. PsnNo: "44020000001102211928",
  11527. Info: "2207",
  11528. }
  11529. customData = append(customData, custom12)
  11530. custom1212 := &CustomData{
  11531. MsgId: "H440229001582021033017351627",
  11532. PsnNo: "44020000001102481733",
  11533. Info: "2207",
  11534. }
  11535. customData = append(customData, custom1212)
  11536. custom13 := &CustomData{
  11537. MsgId: "H44022900158202103301740327951",
  11538. PsnNo: "44020000001103174866",
  11539. Info: "2207",
  11540. }
  11541. customData = append(customData, custom13)
  11542. custom14 := &CustomData{
  11543. MsgId: "H4402290015820210330174922668",
  11544. PsnNo: "44020000001102927272",
  11545. Info: "2207",
  11546. }
  11547. customData = append(customData, custom14)
  11548. custom15 := &CustomData{
  11549. MsgId: "H44022900158202103301752362273",
  11550. PsnNo: "44020000001102942890",
  11551. Info: "2207",
  11552. }
  11553. customData = append(customData, custom15)
  11554. custom16 := &CustomData{
  11555. MsgId: "H44022900158202103301751082917",
  11556. PsnNo: "44020000001101662162",
  11557. Info: "2207",
  11558. }
  11559. customData = append(customData, custom16)
  11560. custom17 := &CustomData{
  11561. MsgId: "H44022900158202103301754147728",
  11562. PsnNo: "44020000000229014511",
  11563. Info: "2207",
  11564. }
  11565. customData = append(customData, custom17)
  11566. adminUser := c.GetAdminUserInfo()
  11567. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11568. for _, item := range customData {
  11569. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11570. fmt.Println(result)
  11571. }
  11572. }
  11573. //func (c *HisApiController) GetAllopatry() {
  11574. // year := c.GetString("year")
  11575. // month := c.GetString("month")
  11576. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11577. // adminUser := c.GetAdminUserInfo()
  11578. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11579. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11580. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  11581. //
  11582. // var dat map[string]interface{}
  11583. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11584. // fmt.Println(dat)
  11585. // } else {
  11586. // fmt.Println(err)
  11587. // }
  11588. // userJSONBytes, _ := json.Marshal(dat)
  11589. // var res models.Result9001
  11590. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11591. // utils.ErrorLog("解析失败:%v", err)
  11592. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11593. // return
  11594. // }
  11595. //
  11596. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  11597. // var dat2 map[string]interface{}
  11598. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  11599. // fmt.Println(dat)
  11600. // } else {
  11601. // fmt.Println(err)
  11602. // }
  11603. // userJSONBytes2, _ := json.Marshal(dat2)
  11604. // var res2 models.Result3260
  11605. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11606. // utils.ErrorLog("解析失败:%v", err)
  11607. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11608. // return
  11609. // }
  11610. // if res2.Infcode == 0 {
  11611. // c.ServeSuccessJSON(map[string]interface{}{
  11612. // "list": res2.Output.Data,
  11613. // })
  11614. // return
  11615. // } else {
  11616. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11617. // return
  11618. // }
  11619. //
  11620. //}
  11621. //func (c *HisApiController) ComfirmAllopatry() {
  11622. // year := c.GetString("year")
  11623. // month := c.GetString("month")
  11624. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11625. // adminUser := c.GetAdminUserInfo()
  11626. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11627. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11628. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  11629. // var dat map[string]interface{}
  11630. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11631. // fmt.Println(dat)
  11632. // } else {
  11633. // fmt.Println(err)
  11634. // }
  11635. // userJSONBytes, _ := json.Marshal(dat)
  11636. // var res models.Result9001
  11637. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11638. // utils.ErrorLog("解析失败:%v", err)
  11639. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11640. // return
  11641. // }
  11642. //
  11643. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  11644. // var dat2 map[string]interface{}
  11645. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  11646. // fmt.Println(dat)
  11647. // } else {
  11648. // fmt.Println(err)
  11649. // }
  11650. // userJSONBytes2, _ := json.Marshal(dat2)
  11651. // var res2 models.Result3260
  11652. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11653. // utils.ErrorLog("解析失败:%v", err)
  11654. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11655. // return
  11656. // }
  11657. //
  11658. // if res2.Infcode == 0 {
  11659. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  11660. // var dat map[string]interface{}
  11661. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11662. // fmt.Println(dat)
  11663. // } else {
  11664. // fmt.Println(err)
  11665. // }
  11666. // userJSONBytes, _ := json.Marshal(dat)
  11667. // var res3 models.Result3261
  11668. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  11669. // utils.ErrorLog("解析失败:%v", err)
  11670. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11671. // return
  11672. // }
  11673. //
  11674. // if res3.Infcode == 0 {
  11675. // record := &models.HisYidiClearRecord{
  11676. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11677. // Ctime: time.Now().Unix(),
  11678. // Mtime: time.Now().Unix(),
  11679. // Status: 1,
  11680. // MsgId: msgId,
  11681. // }
  11682. // service.SaveClearRecord(record)
  11683. // c.ServeSuccessJSON(map[string]interface{}{
  11684. // "msg": "提取成功",
  11685. // })
  11686. // }
  11687. // }
  11688. //}
  11689. func (c *HisApiController) RefundAllopatry() {
  11690. year := c.GetString("year")
  11691. month := c.GetString("month")
  11692. id, _ := c.GetInt64("id")
  11693. admin_user_id, _ := c.GetInt64("admin_user_id")
  11694. adminUser := c.GetAdminUserInfo()
  11695. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11696. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11697. record, _ := service.GetClearRecordById(id)
  11698. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  11699. var dat map[string]interface{}
  11700. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11701. fmt.Println(dat)
  11702. } else {
  11703. fmt.Println(err)
  11704. }
  11705. userJSONBytes, _ := json.Marshal(dat)
  11706. var empty ResultFourteen
  11707. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  11708. utils.ErrorLog("解析失败:%v", err)
  11709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11710. return
  11711. }
  11712. if empty.Infcode == 0 {
  11713. c.ServeSuccessJSON(map[string]interface{}{
  11714. "msg": "撤销成功",
  11715. })
  11716. return
  11717. }
  11718. }
  11719. func (c *HisApiController) ReversalOtherData() {
  11720. var customData []*CustomData
  11721. custom := &CustomData{
  11722. MsgId: "H44022900158202103301714472004",
  11723. PsnNo: "44020000001101329945",
  11724. Info: "2208",
  11725. }
  11726. customData = append(customData, custom)
  11727. custom1 := &CustomData{
  11728. MsgId: "H4402290015820210330172057803",
  11729. PsnNo: "44020000001101161813",
  11730. Info: "2208",
  11731. }
  11732. customData = append(customData, custom1)
  11733. custom2 := &CustomData{
  11734. MsgId: "H44022900158202103301705198813",
  11735. PsnNo: "44190000133097375417",
  11736. Info: "2208",
  11737. }
  11738. customData = append(customData, custom2)
  11739. custom3 := &CustomData{
  11740. MsgId: "H44022900158202103301715524756",
  11741. PsnNo: "44020000001100187221",
  11742. Info: "2208",
  11743. }
  11744. customData = append(customData, custom3)
  11745. custom4 := &CustomData{
  11746. MsgId: "H44022900158202103301730376224",
  11747. PsnNo: "44020000001101959155",
  11748. Info: "2208",
  11749. }
  11750. customData = append(customData, custom4)
  11751. custom5 := &CustomData{
  11752. MsgId: "H44022900158202103301748008725",
  11753. PsnNo: "44020000001104246641",
  11754. Info: "2208",
  11755. }
  11756. customData = append(customData, custom5)
  11757. custom6 := &CustomData{
  11758. MsgId: "H44022900158202103301718096755",
  11759. PsnNo: "44020000001102211860",
  11760. Info: "2208",
  11761. }
  11762. customData = append(customData, custom6)
  11763. custom7 := &CustomData{
  11764. MsgId: "H44022900158202103301736551640",
  11765. PsnNo: "44020000001102687718",
  11766. Info: "2208",
  11767. }
  11768. customData = append(customData, custom7)
  11769. custom8 := &CustomData{
  11770. MsgId: "H44022900158202103301743097676",
  11771. PsnNo: "44020000001102127785",
  11772. Info: "2208",
  11773. }
  11774. customData = append(customData, custom8)
  11775. custom9 := &CustomData{
  11776. MsgId: "H44022900158202103301712304203",
  11777. PsnNo: "44020000001101518097",
  11778. Info: "2208",
  11779. }
  11780. customData = append(customData, custom9)
  11781. custom10 := &CustomData{
  11782. MsgId: "H44022900158202103301738448785",
  11783. PsnNo: "44020000001100500813",
  11784. Info: "2208",
  11785. }
  11786. customData = append(customData, custom10)
  11787. custom11 := &CustomData{
  11788. MsgId: "H44022900158202103301732455843",
  11789. PsnNo: "44020000001102690557",
  11790. Info: "2208",
  11791. }
  11792. customData = append(customData, custom11)
  11793. custom12 := &CustomData{
  11794. MsgId: "H44022900158202103301745421708",
  11795. PsnNo: "44020000001102211928",
  11796. Info: "2208",
  11797. }
  11798. customData = append(customData, custom12)
  11799. custom1212 := &CustomData{
  11800. MsgId: "H440229001582021033017351627",
  11801. PsnNo: "44020000001102481733",
  11802. Info: "2208",
  11803. }
  11804. customData = append(customData, custom1212)
  11805. custom13 := &CustomData{
  11806. MsgId: "H44022900158202103301740327951",
  11807. PsnNo: "44020000001103174866",
  11808. Info: "2208",
  11809. }
  11810. customData = append(customData, custom13)
  11811. custom14 := &CustomData{
  11812. MsgId: "H4402290015820210330174922668",
  11813. PsnNo: "44020000001102927272",
  11814. Info: "2208",
  11815. }
  11816. customData = append(customData, custom14)
  11817. custom15 := &CustomData{
  11818. MsgId: "H44022900158202103301752362273",
  11819. PsnNo: "44020000001102942890",
  11820. Info: "2208",
  11821. }
  11822. customData = append(customData, custom15)
  11823. custom16 := &CustomData{
  11824. MsgId: "H44022900158202103301751082917",
  11825. PsnNo: "44020000001101662162",
  11826. Info: "2208",
  11827. }
  11828. customData = append(customData, custom16)
  11829. custom17 := &CustomData{
  11830. MsgId: "H44022900158202103301754147728",
  11831. PsnNo: "44020000000229014511",
  11832. Info: "2208",
  11833. }
  11834. customData = append(customData, custom17)
  11835. adminUser := c.GetAdminUserInfo()
  11836. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11837. for _, item := range customData {
  11838. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11839. fmt.Println(result)
  11840. }
  11841. }
  11842. func PathExists(path string) (bool, error) {
  11843. _, err := os.Stat(path)
  11844. if err == nil {
  11845. return true, nil
  11846. }
  11847. if os.IsNotExist(err) {
  11848. return false, nil
  11849. }
  11850. return false, err
  11851. }
  11852. //创建文件夹
  11853. func Mkdir(dir string) {
  11854. // 创建文件夹
  11855. exist, err := PathExists(dir)
  11856. if err != nil {
  11857. fmt.Println(err.Error())
  11858. } else {
  11859. if exist {
  11860. fmt.Println(dir + "文件夹已存在!")
  11861. } else {
  11862. // 文件夹名称,权限
  11863. err := os.Mkdir(dir, os.ModePerm)
  11864. if err != nil {
  11865. fmt.Println(dir+"文件夹创建失败:", err.Error())
  11866. } else {
  11867. fmt.Println(dir + "文件夹创建成功!")
  11868. }
  11869. }
  11870. }
  11871. }
  11872. //压缩文件
  11873. func Zip(srcFile string, destZip string) error {
  11874. zipfile, err := os.Create(destZip)
  11875. if err != nil {
  11876. return err
  11877. }
  11878. defer zipfile.Close()
  11879. archive := zip.NewWriter(zipfile)
  11880. defer archive.Close()
  11881. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  11882. if err != nil {
  11883. return err
  11884. }
  11885. header, err := zip.FileInfoHeader(info)
  11886. if err != nil {
  11887. return err
  11888. }
  11889. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  11890. // header.Name = path
  11891. if info.IsDir() {
  11892. header.Name += "/"
  11893. } else {
  11894. header.Method = zip.Deflate
  11895. }
  11896. writer, err := archive.CreateHeader(header)
  11897. if err != nil {
  11898. return err
  11899. }
  11900. if !info.IsDir() {
  11901. file, err := os.Open(path)
  11902. if err != nil {
  11903. return err
  11904. }
  11905. defer file.Close()
  11906. _, err = io.Copy(writer, file)
  11907. }
  11908. return err
  11909. })
  11910. return err
  11911. }
  11912. func ReadFile(filePath string) []byte {
  11913. f, err := os.Open(filePath)
  11914. if err != nil {
  11915. fmt.Println("read file fail", err)
  11916. return nil
  11917. }
  11918. defer f.Close()
  11919. fd, err := ioutil.ReadAll(f)
  11920. if err != nil {
  11921. fmt.Println("read to fd fail", err)
  11922. return nil
  11923. }
  11924. return fd
  11925. }
  11926. func saveLog(result string, request string, infno string, desc string) {
  11927. org_id, _ := beego.AppConfig.Int64("org_id")
  11928. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11929. dir := miConfig.OrgName + "日志"
  11930. utils.Mkdir(dir)
  11931. month := time.Unix(1557042972, 0).Format("1")
  11932. year := time.Now().Format("2006")
  11933. month = time.Now().Format("01")
  11934. day := time.Now().Format("02")
  11935. hour := time.Now().Format("15")
  11936. min := time.Now().Format("04")
  11937. sec := time.Now().Format("05")
  11938. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  11939. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  11940. file_name := file + ".txt"
  11941. file_path := miConfig.OrgName + "日志" + "/" + file_name
  11942. exist, _ := utils.PathExists(file_path)
  11943. if exist { //存在
  11944. fmt.Println("存在")
  11945. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  11946. if err != nil {
  11947. fmt.Println("read fail")
  11948. }
  11949. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  11950. n, _ := f.Seek(0, 2)
  11951. _, err = f.WriteAt([]byte(content), n)
  11952. } else { //不存在
  11953. fmt.Println("文件不存在,创建文件")
  11954. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  11955. defer f.Close()
  11956. if err != nil {
  11957. } else {
  11958. _, err = f.Write([]byte("记录日志"))
  11959. }
  11960. }
  11961. }
  11962. type Charset string
  11963. const (
  11964. UTF8 = Charset("UTF-8")
  11965. GB18030 = Charset("GB18030")
  11966. )
  11967. func ConvertToString(src string, srcCode string, tagCode string) string {
  11968. srcCoder := mahonia.NewDecoder(srcCode)
  11969. srcResult := srcCoder.ConvertString(src)
  11970. tagCoder := mahonia.NewDecoder(tagCode)
  11971. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  11972. result := string(cdata)
  11973. return result
  11974. }
  11975. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  11976. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  11977. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11978. var token string
  11979. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11980. var api string
  11981. if miConfig.MdtrtareaAdmvs == "320921" {
  11982. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  11983. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  11984. fmt.Println(api)
  11985. } else {
  11986. 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 +
  11987. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  11988. }
  11989. resp, requestErr := http.Get(api)
  11990. if requestErr != nil {
  11991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11992. return ""
  11993. }
  11994. body, ioErr := ioutil.ReadAll(resp.Body)
  11995. if ioErr != nil {
  11996. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11998. return ""
  11999. }
  12000. var respJSON map[string]interface{}
  12001. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12002. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12004. return ""
  12005. }
  12006. var status string
  12007. status = respJSON["data"].(map[string]interface{})["status"].(string)
  12008. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  12009. var res ResultTwo //1101结果
  12010. var res10265 ResultTwo10265 //1101结果
  12011. if status == "0" { //读卡成功
  12012. var card_info string //卡信息
  12013. var busi_card_info string
  12014. token = respJSON["data"].(map[string]interface{})["token"].(string)
  12015. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12016. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  12017. fmt.Println(card_info)
  12018. fmt.Println(busi_card_info)
  12019. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12020. result, _ := json.Marshal(respJSON)
  12021. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12022. utils.ErrorLog("解析失败:%v", err)
  12023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12024. return ""
  12025. }
  12026. res.ErrMsg = res10265.ErrMsg
  12027. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12028. res.Infcode = infocode
  12029. res.Output = res10265.Output
  12030. res.InfRefmsgid = res10265.InfRefmsgid
  12031. if res.Infcode == 0 {
  12032. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12033. if err == gorm.ErrRecordNotFound {
  12034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12035. return ""
  12036. } else if err != nil {
  12037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12038. return ""
  12039. } else {
  12040. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12041. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12042. infoStr := string(Iinfos)
  12043. idetinfoStr := string(Idetinfos)
  12044. psn := &models.HisPsn{
  12045. PsnNo: res.Output.Baseinfo.PsnNo,
  12046. Age: res.Output.Baseinfo.Age,
  12047. PatientId: patient.ID,
  12048. Certno: res.Output.Baseinfo.Certno,
  12049. Brdy: res.Output.Baseinfo.Brdy,
  12050. Gend: res.Output.Baseinfo.Gend,
  12051. Naty: res.Output.Baseinfo.Naty,
  12052. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12053. PsnName: res.Output.Baseinfo.PsnName,
  12054. Idetinfo: idetinfoStr,
  12055. Insuinfo: infoStr,
  12056. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12057. CardInfo: card_info,
  12058. VerifyNumber: token,
  12059. }
  12060. service.CreateHisPsn(psn)
  12061. return token
  12062. }
  12063. }
  12064. } else {
  12065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12066. return ""
  12067. }
  12068. } else { //读卡失败
  12069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12070. return ""
  12071. }
  12072. return token
  12073. }
  12074. func DeleteExtraSpaceTwo(s string) string {
  12075. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  12076. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  12077. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  12078. reg, _ := regexp.Compile(regstr) //编译正则表达式
  12079. s2 := make([]byte, len(s1)) //定义字符数组切片
  12080. copy(s2, s1) //将字符串复制到切片
  12081. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  12082. for len(spc_index) > 0 { //找到适配项
  12083. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  12084. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  12085. }
  12086. return string(s2)
  12087. }
  12088. func Remove0000(s string) string {
  12089. str := make([]rune, 0, len(s))
  12090. for _, v := range []rune(s) {
  12091. if v == 0 {
  12092. continue
  12093. }
  12094. str = append(str, v)
  12095. }
  12096. return string(str)
  12097. }
  12098. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  12099. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  12100. readCard := DllDef.MustFindProc("EcQuery")
  12101. pCardInfo := make([]byte, 8192)
  12102. pBusiCardInfo := make([]byte, 8192)
  12103. data := make(map[string]interface{})
  12104. //pData := make(map[string]interface{})
  12105. inputData := make(map[string]interface{})
  12106. inputData["orgId"] = code
  12107. inputData["businessType"] = "01101"
  12108. inputData["operatorId"] = operator_id
  12109. inputData["operatorName"] = operator_name
  12110. inputData["officeId"] = "001"
  12111. inputData["officeName"] = "血透室"
  12112. //
  12113. data["data"] = inputData
  12114. data["transType"] = "ec.query"
  12115. data["orgId"] = code
  12116. bytesData, _ := json.Marshal(data)
  12117. pCardInfo = bytesData
  12118. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  12119. fmt.Println(ret2)
  12120. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  12121. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  12122. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  12123. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  12124. if ret2 != 0 {
  12125. return "", ""
  12126. }
  12127. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  12128. }
  12129. func DeleteExtraSpace(s string) string {
  12130. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  12131. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  12132. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  12133. reg, _ := regexp.Compile(regstr) //编译正则表达式
  12134. s2 := make([]byte, len(s1)) //定义字符数组切片
  12135. copy(s2, s1) //将字符串复制到切片
  12136. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  12137. for len(spc_index) > 0 { //找到适配项
  12138. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  12139. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  12140. }
  12141. return string(s2)
  12142. }
  12143. //对账
  12144. func (c *HisApiController) Post3202() {
  12145. start_time := c.GetString("start_time")
  12146. end_time := c.GetString("end_time")
  12147. //insutype := c.GetString("insutype")
  12148. clr_type := c.GetString("clr_type")
  12149. clr_org := c.GetString("clr_optins")
  12150. admin_user_id, _ := c.GetInt64("admin_user_id")
  12151. adminUser := c.GetAdminUserInfo()
  12152. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12153. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12154. if len(clr_org) == 0 {
  12155. clr_org = miConfig.MdtrtareaAdmvs
  12156. }
  12157. timeLayout := "2006-01-02"
  12158. loc, _ := time.LoadLocation("Local")
  12159. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  12160. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  12161. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  12162. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  12163. //fixmedins_setl_cnt := int64(len(orders))
  12164. var medfee_sumamt float64
  12165. var acct_pay float64
  12166. var fund_pay_sumamt float64
  12167. for _, item := range orders {
  12168. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  12169. acct_pay = acct_pay + item.AcctPay
  12170. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  12171. }
  12172. //var medfee_sumamt_two float64
  12173. //var acct_pay_two float64
  12174. //var fund_pay_sumamt_two float64
  12175. //for _, item := range orders_two {
  12176. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  12177. // acct_pay_two = acct_pay_two + item.AcctPay
  12178. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  12179. //}
  12180. //var user_name string
  12181. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12182. //if role.ID == 0 {
  12183. // user_name = "xxx"
  12184. //} else {
  12185. // user_name = role.UserName
  12186. //}
  12187. var res ResultSix
  12188. if config.IsOpen == 1 {
  12189. var bps []*models.BusinessParamsTwo
  12190. var bp models.BusinessParamsTwo
  12191. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  12192. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  12193. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  12194. bp.MedfeeSumamt = medfee_sumamt_str
  12195. bp.AcctPay = acct_pay_str
  12196. bp.FundPaySumamt = fund_pay_sumamt_str
  12197. bp.Insutype = "390"
  12198. bp.StmtBegndate = start_time
  12199. bp.ClrType = clr_type
  12200. bp.SetlOptins = clr_org
  12201. bp.StmtEnddate = end_time
  12202. bps = append(bps, &bp)
  12203. data := make(map[string]interface{})
  12204. data["bps"] = bps
  12205. data["org_name"] = miConfig.OrgName
  12206. data["doctor"] = role.UserName
  12207. data["fixmedins_code"] = miConfig.Code
  12208. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  12209. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  12210. if miConfig.MdtrtareaAdmvs == "421300" {
  12211. client := &http.Client{}
  12212. bytesData, _ := json.Marshal(data)
  12213. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  12214. resp, _ := client.Do(req)
  12215. defer resp.Body.Close()
  12216. body, ioErr := ioutil.ReadAll(resp.Body)
  12217. if ioErr != nil {
  12218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12220. return
  12221. }
  12222. var respJSON map[string]interface{}
  12223. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12226. return
  12227. }
  12228. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12229. userJSONBytes, _ := json.Marshal(respJSON)
  12230. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12231. utils.ErrorLog("解析失败:%v", err)
  12232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12233. return
  12234. }
  12235. }
  12236. if res.Infcode == 0 {
  12237. c.ServeSuccessJSON(map[string]interface{}{
  12238. "msg": "发起成功",
  12239. })
  12240. } else {
  12241. c.ServeSuccessJSON(map[string]interface{}{
  12242. "code": -10,
  12243. "msg": res.ErrMsg,
  12244. })
  12245. }
  12246. }
  12247. }
  12248. func (c *HisApiController) Post3501() {
  12249. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12250. data := make(map[string]interface{})
  12251. var struct3501s []models.Struct3501
  12252. var struct3501 models.Struct3501
  12253. struct3501.OrgName = miConfig.OrgName
  12254. struct3501.AccessKey = miConfig.AccessKey
  12255. struct3501.RequestUrl = miConfig.Url
  12256. struct3501.SecretKey = miConfig.SecretKey
  12257. struct3501.ManuDate = "2022-08-17"
  12258. struct3501.FixmedinsBchno = ""
  12259. struct3501.ManuLotnum = ""
  12260. struct3501.RxFlag = "0"
  12261. struct3501.ExpyEnd = "2022-08-17"
  12262. struct3501.Invdate = "2022-08-17"
  12263. struct3501.InvCnt = "20.25"
  12264. struct3501.Memo = ""
  12265. struct3501.MedListCodg = "XB01ABD056B002020200517"
  12266. struct3501.FixmedinsHilistId = miConfig.Code
  12267. struct3501.FixmedinsHilistName = miConfig.OrgName
  12268. struct3501s = append(struct3501s, struct3501)
  12269. data["struct_3501s"] = struct3501s
  12270. client := &http.Client{}
  12271. bytesData, _ := json.Marshal(data)
  12272. var req *http.Request
  12273. if miConfig.MdtrtareaAdmvs == "320921" {
  12274. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12275. } else {
  12276. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12277. }
  12278. resp, _ := client.Do(req)
  12279. defer resp.Body.Close()
  12280. body, ioErr := ioutil.ReadAll(resp.Body)
  12281. if ioErr != nil {
  12282. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12284. return
  12285. }
  12286. var respJSON map[string]interface{}
  12287. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12290. return
  12291. }
  12292. var res ResultSix
  12293. var resSix10265 ResultSix10265 //1101结果
  12294. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12295. result, _ := json.Marshal(respJSON)
  12296. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12297. utils.ErrorLog("解析失败:%v", err)
  12298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12299. return
  12300. }
  12301. res.InfRefmsgid = resSix10265.InfRefmsgid
  12302. res.Output = resSix10265.Output
  12303. res.ErrMsg = resSix10265.ErrMsg
  12304. res.Cainfo = resSix10265.Cainfo
  12305. res.WarnMsg = resSix10265.WarnMsg
  12306. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12307. res.Infcode = infocode
  12308. if infocode == 0 {
  12309. c.ServeSuccessJSON(map[string]interface{}{
  12310. "msg": "上传成功",
  12311. })
  12312. return
  12313. } else {
  12314. c.ServeSuccessJSON(map[string]interface{}{
  12315. "failed_code": -10,
  12316. "msg": res.ErrMsg,
  12317. })
  12318. return
  12319. }
  12320. }
  12321. func (c *HisApiController) Post3502() {
  12322. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12323. data := make(map[string]interface{})
  12324. var struct3502s []models.Struct3502
  12325. var struct3502 models.Struct3502
  12326. struct3502.OrgName = miConfig.OrgName
  12327. struct3502.AccessKey = miConfig.AccessKey
  12328. struct3502.RequestUrl = miConfig.Url
  12329. struct3502.SecretKey = miConfig.SecretKey
  12330. struct3502.ManuDate = "2022-08-15"
  12331. struct3502.FixmedinsBchno = ""
  12332. struct3502.ManuLotnum = ""
  12333. struct3502.RxFlag = "0"
  12334. struct3502.ExpyEnd = "2022-08-15"
  12335. struct3502.Invdate = "2022-08-15"
  12336. struct3502.InvCnt = "20.25"
  12337. struct3502.Memo = ""
  12338. struct3502.MedListCodg = "XB01ABD056B002020200517"
  12339. struct3502.FixmedinsHilistId = miConfig.Code
  12340. struct3502.FixmedinsHilistName = miConfig.OrgName
  12341. struct3502s = append(struct3502s, struct3502)
  12342. data["struct_3502s"] = struct3502s
  12343. client := &http.Client{}
  12344. bytesData, _ := json.Marshal(data)
  12345. var req *http.Request
  12346. if miConfig.MdtrtareaAdmvs == "320921" {
  12347. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12348. } else {
  12349. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12350. }
  12351. resp, _ := client.Do(req)
  12352. defer resp.Body.Close()
  12353. body, ioErr := ioutil.ReadAll(resp.Body)
  12354. if ioErr != nil {
  12355. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12357. return
  12358. }
  12359. var respJSON map[string]interface{}
  12360. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12361. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12363. return
  12364. }
  12365. var res ResultSix
  12366. var resSix10265 ResultSix10265 //1101结果
  12367. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12368. result, _ := json.Marshal(respJSON)
  12369. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12370. utils.ErrorLog("解析失败:%v", err)
  12371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12372. return
  12373. }
  12374. res.InfRefmsgid = resSix10265.InfRefmsgid
  12375. res.Output = resSix10265.Output
  12376. res.ErrMsg = resSix10265.ErrMsg
  12377. res.Cainfo = resSix10265.Cainfo
  12378. res.WarnMsg = resSix10265.WarnMsg
  12379. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12380. res.Infcode = infocode
  12381. if infocode == 0 {
  12382. c.ServeSuccessJSON(map[string]interface{}{
  12383. "msg": "上传成功",
  12384. })
  12385. return
  12386. } else {
  12387. c.ServeSuccessJSON(map[string]interface{}{
  12388. "failed_code": -10,
  12389. "msg": res.ErrMsg,
  12390. })
  12391. return
  12392. }
  12393. }
  12394. func (c *HisApiController) Post3503() {
  12395. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12396. data := make(map[string]interface{})
  12397. var struct3501s []models.Struct3501
  12398. var struct3501 models.Struct3501
  12399. struct3501.OrgName = miConfig.OrgName
  12400. struct3501.AccessKey = miConfig.AccessKey
  12401. struct3501.RequestUrl = miConfig.Url
  12402. struct3501.SecretKey = miConfig.SecretKey
  12403. struct3501.ManuDate = "2022-08-15"
  12404. struct3501.FixmedinsBchno = ""
  12405. struct3501.ManuLotnum = ""
  12406. struct3501.RxFlag = "0"
  12407. struct3501.ExpyEnd = "2022-08-15"
  12408. struct3501.Invdate = "2022-08-15"
  12409. struct3501.InvCnt = "20.25"
  12410. struct3501.Memo = ""
  12411. struct3501.MedListCodg = "XB01ABD056B002020200517"
  12412. struct3501.FixmedinsHilistId = miConfig.Code
  12413. struct3501.FixmedinsHilistName = miConfig.OrgName
  12414. struct3501s = append(struct3501s, struct3501)
  12415. data["struct_3501s"] = struct3501s
  12416. client := &http.Client{}
  12417. bytesData, _ := json.Marshal(data)
  12418. var req *http.Request
  12419. if miConfig.MdtrtareaAdmvs == "320921" {
  12420. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12421. } else {
  12422. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12423. }
  12424. resp, _ := client.Do(req)
  12425. defer resp.Body.Close()
  12426. body, ioErr := ioutil.ReadAll(resp.Body)
  12427. if ioErr != nil {
  12428. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12430. return
  12431. }
  12432. var respJSON map[string]interface{}
  12433. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12434. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12436. return
  12437. }
  12438. var res ResultSix
  12439. var resSix10265 ResultSix10265 //1101结果
  12440. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12441. result, _ := json.Marshal(respJSON)
  12442. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12443. utils.ErrorLog("解析失败:%v", err)
  12444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12445. return
  12446. }
  12447. res.InfRefmsgid = resSix10265.InfRefmsgid
  12448. res.Output = resSix10265.Output
  12449. res.ErrMsg = resSix10265.ErrMsg
  12450. res.Cainfo = resSix10265.Cainfo
  12451. res.WarnMsg = resSix10265.WarnMsg
  12452. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12453. res.Infcode = infocode
  12454. if infocode == 0 {
  12455. c.ServeSuccessJSON(map[string]interface{}{
  12456. "msg": "上传成功",
  12457. })
  12458. return
  12459. } else {
  12460. c.ServeSuccessJSON(map[string]interface{}{
  12461. "failed_code": -10,
  12462. "msg": res.ErrMsg,
  12463. })
  12464. return
  12465. }
  12466. }
  12467. func (c *HisApiController) Post3504() {
  12468. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12469. data := make(map[string]interface{})
  12470. var struct3501s []models.Struct3501
  12471. var struct3501 models.Struct3501
  12472. struct3501.OrgName = miConfig.OrgName
  12473. struct3501.AccessKey = miConfig.AccessKey
  12474. struct3501.RequestUrl = miConfig.Url
  12475. struct3501.SecretKey = miConfig.SecretKey
  12476. struct3501.ManuDate = "2022-08-15"
  12477. struct3501.FixmedinsBchno = ""
  12478. struct3501.ManuLotnum = ""
  12479. struct3501.RxFlag = "0"
  12480. struct3501.ExpyEnd = "2022-08-15"
  12481. struct3501.Invdate = "2022-08-15"
  12482. struct3501.InvCnt = "20.25"
  12483. struct3501.Memo = ""
  12484. struct3501.MedListCodg = "XB01ABD056B002020200517"
  12485. struct3501.FixmedinsHilistId = miConfig.Code
  12486. struct3501.FixmedinsHilistName = miConfig.OrgName
  12487. struct3501s = append(struct3501s, struct3501)
  12488. data["struct_3501s"] = struct3501s
  12489. client := &http.Client{}
  12490. bytesData, _ := json.Marshal(data)
  12491. var req *http.Request
  12492. if miConfig.MdtrtareaAdmvs == "320921" {
  12493. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12494. } else {
  12495. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12496. }
  12497. resp, _ := client.Do(req)
  12498. defer resp.Body.Close()
  12499. body, ioErr := ioutil.ReadAll(resp.Body)
  12500. if ioErr != nil {
  12501. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12503. return
  12504. }
  12505. var respJSON map[string]interface{}
  12506. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12509. return
  12510. }
  12511. var res ResultSix
  12512. var resSix10265 ResultSix10265 //1101结果
  12513. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12514. result, _ := json.Marshal(respJSON)
  12515. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12516. utils.ErrorLog("解析失败:%v", err)
  12517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12518. return
  12519. }
  12520. res.InfRefmsgid = resSix10265.InfRefmsgid
  12521. res.Output = resSix10265.Output
  12522. res.ErrMsg = resSix10265.ErrMsg
  12523. res.Cainfo = resSix10265.Cainfo
  12524. res.WarnMsg = resSix10265.WarnMsg
  12525. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12526. res.Infcode = infocode
  12527. if infocode == 0 {
  12528. c.ServeSuccessJSON(map[string]interface{}{
  12529. "msg": "上传成功",
  12530. })
  12531. return
  12532. } else {
  12533. c.ServeSuccessJSON(map[string]interface{}{
  12534. "failed_code": -10,
  12535. "msg": res.ErrMsg,
  12536. })
  12537. return
  12538. }
  12539. }
  12540. func (c *HisApiController) Post3505() {
  12541. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12542. data := make(map[string]interface{})
  12543. var struct3501s []models.Struct3501
  12544. var struct3501 models.Struct3501
  12545. struct3501.OrgName = miConfig.OrgName
  12546. struct3501.AccessKey = miConfig.AccessKey
  12547. struct3501.RequestUrl = miConfig.Url
  12548. struct3501.SecretKey = miConfig.SecretKey
  12549. struct3501.ManuDate = "2022-08-15"
  12550. struct3501.FixmedinsBchno = ""
  12551. struct3501.ManuLotnum = ""
  12552. struct3501.RxFlag = "0"
  12553. struct3501.ExpyEnd = "2022-08-15"
  12554. struct3501.Invdate = "2022-08-15"
  12555. struct3501.InvCnt = "20.25"
  12556. struct3501.Memo = ""
  12557. struct3501.MedListCodg = "XB01ABD056B002020200517"
  12558. struct3501.FixmedinsHilistId = miConfig.Code
  12559. struct3501.FixmedinsHilistName = miConfig.OrgName
  12560. struct3501s = append(struct3501s, struct3501)
  12561. data["struct_3501s"] = struct3501s
  12562. client := &http.Client{}
  12563. bytesData, _ := json.Marshal(data)
  12564. var req *http.Request
  12565. if miConfig.MdtrtareaAdmvs == "320921" {
  12566. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12567. } else {
  12568. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12569. }
  12570. resp, _ := client.Do(req)
  12571. defer resp.Body.Close()
  12572. body, ioErr := ioutil.ReadAll(resp.Body)
  12573. if ioErr != nil {
  12574. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12576. return
  12577. }
  12578. var respJSON map[string]interface{}
  12579. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12580. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12582. return
  12583. }
  12584. var res ResultSix
  12585. var resSix10265 ResultSix10265 //1101结果
  12586. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12587. result, _ := json.Marshal(respJSON)
  12588. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12589. utils.ErrorLog("解析失败:%v", err)
  12590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12591. return
  12592. }
  12593. res.InfRefmsgid = resSix10265.InfRefmsgid
  12594. res.Output = resSix10265.Output
  12595. res.ErrMsg = resSix10265.ErrMsg
  12596. res.Cainfo = resSix10265.Cainfo
  12597. res.WarnMsg = resSix10265.WarnMsg
  12598. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12599. res.Infcode = infocode
  12600. if infocode == 0 {
  12601. c.ServeSuccessJSON(map[string]interface{}{
  12602. "msg": "上传成功",
  12603. })
  12604. return
  12605. } else {
  12606. c.ServeSuccessJSON(map[string]interface{}{
  12607. "failed_code": -10,
  12608. "msg": res.ErrMsg,
  12609. })
  12610. return
  12611. }
  12612. }
  12613. func (c *HisApiController) Post3506() {
  12614. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12615. data := make(map[string]interface{})
  12616. var struct3501s []models.Struct3501
  12617. var struct3501 models.Struct3501
  12618. struct3501.OrgName = miConfig.OrgName
  12619. struct3501.AccessKey = miConfig.AccessKey
  12620. struct3501.RequestUrl = miConfig.Url
  12621. struct3501.SecretKey = miConfig.SecretKey
  12622. struct3501.ManuDate = "2022-08-15"
  12623. struct3501.FixmedinsBchno = ""
  12624. struct3501.ManuLotnum = ""
  12625. struct3501.RxFlag = "0"
  12626. struct3501.ExpyEnd = "2022-08-15"
  12627. struct3501.Invdate = "2022-08-15"
  12628. struct3501.InvCnt = "20.25"
  12629. struct3501.Memo = ""
  12630. struct3501.MedListCodg = "XB01ABD056B002020200517"
  12631. struct3501.FixmedinsHilistId = miConfig.Code
  12632. struct3501.FixmedinsHilistName = miConfig.OrgName
  12633. struct3501s = append(struct3501s, struct3501)
  12634. data["struct_3501s"] = struct3501s
  12635. client := &http.Client{}
  12636. bytesData, _ := json.Marshal(data)
  12637. var req *http.Request
  12638. if miConfig.MdtrtareaAdmvs == "320921" {
  12639. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12640. } else {
  12641. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12642. }
  12643. resp, _ := client.Do(req)
  12644. defer resp.Body.Close()
  12645. body, ioErr := ioutil.ReadAll(resp.Body)
  12646. if ioErr != nil {
  12647. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12649. return
  12650. }
  12651. var respJSON map[string]interface{}
  12652. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12653. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12655. return
  12656. }
  12657. var res ResultSix
  12658. var resSix10265 ResultSix10265 //1101结果
  12659. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12660. result, _ := json.Marshal(respJSON)
  12661. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12662. utils.ErrorLog("解析失败:%v", err)
  12663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12664. return
  12665. }
  12666. res.InfRefmsgid = resSix10265.InfRefmsgid
  12667. res.Output = resSix10265.Output
  12668. res.ErrMsg = resSix10265.ErrMsg
  12669. res.Cainfo = resSix10265.Cainfo
  12670. res.WarnMsg = resSix10265.WarnMsg
  12671. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12672. res.Infcode = infocode
  12673. if infocode == 0 {
  12674. c.ServeSuccessJSON(map[string]interface{}{
  12675. "msg": "上传成功",
  12676. })
  12677. return
  12678. } else {
  12679. c.ServeSuccessJSON(map[string]interface{}{
  12680. "failed_code": -10,
  12681. "msg": res.ErrMsg,
  12682. })
  12683. return
  12684. }
  12685. }
  12686. func (c *HisApiController) Post3507() {
  12687. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12688. data := make(map[string]interface{})
  12689. var struct3501s []models.Struct3501
  12690. var struct3501 models.Struct3501
  12691. struct3501.OrgName = miConfig.OrgName
  12692. struct3501.AccessKey = miConfig.AccessKey
  12693. struct3501.RequestUrl = miConfig.Url
  12694. struct3501.SecretKey = miConfig.SecretKey
  12695. struct3501.ManuDate = "2022-08-15"
  12696. struct3501.FixmedinsBchno = ""
  12697. struct3501.ManuLotnum = ""
  12698. struct3501.RxFlag = "0"
  12699. struct3501.ExpyEnd = "2022-08-15"
  12700. struct3501.Invdate = "2022-08-15"
  12701. struct3501.InvCnt = "20.25"
  12702. struct3501.Memo = ""
  12703. struct3501.MedListCodg = "XB01ABD056B002020200517"
  12704. struct3501.FixmedinsHilistId = miConfig.Code
  12705. struct3501.FixmedinsHilistName = miConfig.OrgName
  12706. struct3501s = append(struct3501s, struct3501)
  12707. data["struct_3501s"] = struct3501s
  12708. client := &http.Client{}
  12709. bytesData, _ := json.Marshal(data)
  12710. var req *http.Request
  12711. if miConfig.MdtrtareaAdmvs == "320921" {
  12712. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12713. } else {
  12714. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12715. }
  12716. resp, _ := client.Do(req)
  12717. defer resp.Body.Close()
  12718. body, ioErr := ioutil.ReadAll(resp.Body)
  12719. if ioErr != nil {
  12720. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12722. return
  12723. }
  12724. var respJSON map[string]interface{}
  12725. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12726. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12728. return
  12729. }
  12730. var res ResultSix
  12731. var resSix10265 ResultSix10265 //1101结果
  12732. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12733. result, _ := json.Marshal(respJSON)
  12734. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12735. utils.ErrorLog("解析失败:%v", err)
  12736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12737. return
  12738. }
  12739. res.InfRefmsgid = resSix10265.InfRefmsgid
  12740. res.Output = resSix10265.Output
  12741. res.ErrMsg = resSix10265.ErrMsg
  12742. res.Cainfo = resSix10265.Cainfo
  12743. res.WarnMsg = resSix10265.WarnMsg
  12744. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12745. res.Infcode = infocode
  12746. if infocode == 0 {
  12747. c.ServeSuccessJSON(map[string]interface{}{
  12748. "msg": "上传成功",
  12749. })
  12750. return
  12751. } else {
  12752. c.ServeSuccessJSON(map[string]interface{}{
  12753. "failed_code": -10,
  12754. "msg": res.ErrMsg,
  12755. })
  12756. return
  12757. }
  12758. }