his_api_controller.go 466KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696
  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. }
  79. type Result3101 struct {
  80. Infcode string `json:"infcode"`
  81. InfRefmsgid string `json:"inf_refmsgid"`
  82. RefmsgTime string `json:"refmsg_time"`
  83. RespondTime string `json:"respond_time"`
  84. Enctype string `json:"enctype"`
  85. Signtype string `json:"signtype"`
  86. ErrMsg interface{} `json:"err_msg"`
  87. Output struct {
  88. Result []struct {
  89. JudgeResultDetailDtos []struct {
  90. VolaItemType string `json:"vola_item_type"`
  91. MdtrtID string `json:"mdtrt_id"`
  92. JrdID string `json:"jrd_id"`
  93. PatnID string `json:"patn_id"`
  94. RxID string `json:"rx_id"`
  95. VolaAmt interface{} `json:"vola_amt"`
  96. } `json:"judge_result_detail_dtos"`
  97. RuleID string `json:"rule_id"`
  98. VolaEvid string `json:"vola_evid"`
  99. MdtrtID string `json:"mdtrt_id"`
  100. RuleName string `json:"rule_name"`
  101. VolaAmtStas string `json:"vola_amt_stas"`
  102. JrID string `json:"jr_id"`
  103. PatnID string `json:"patn_id"`
  104. SevDeg string `json:"sev_deg"`
  105. VolaAmt float64 `json:"vola_amt"`
  106. VolaBhvrType string `json:"vola_bhvr_type"`
  107. VolaCont string `json:"vola_cont"`
  108. } `json:"result"`
  109. } `json:"output"`
  110. }
  111. func (c *HisApiController) Get9001() {
  112. adminUser := c.GetAdminUserInfo()
  113. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  114. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  115. if miConfig.MdtrtareaAdmvs == "350500" {
  116. service.GetFjAuthorizationInfo(miConfig.Code)
  117. } else {
  118. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  119. var dat map[string]interface{}
  120. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  121. fmt.Println(dat)
  122. } else {
  123. fmt.Println(err)
  124. }
  125. userJSONBytes, _ := json.Marshal(dat)
  126. var res models.Result9001
  127. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  128. utils.ErrorLog("解析失败:%v", err)
  129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  130. return
  131. }
  132. }
  133. }
  134. 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) {
  135. adminUser := c.GetAdminUserInfo()
  136. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  137. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  138. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  139. //record_time := c.GetString("record_time")
  140. //trig_scen := c.GetString("trig_scen")
  141. timeLayout := "2006-01-02"
  142. loc, _ := time.LoadLocation("Local")
  143. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  144. if err != nil {
  145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  146. return res
  147. }
  148. recordDateTime := theTime.Unix()
  149. var patientPrescription models.HisPrescriptionInfo
  150. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  151. if patientPrescription.ID == 0 {
  152. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  153. }
  154. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  155. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  156. //
  157. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  158. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  159. var pp models.PublicParams
  160. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  161. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  162. pp.FixmedinsName = miConfig.OrgName
  163. pp.FixmedinsCode = miConfig.Code
  164. pp.RequestUrl = miConfig.Url
  165. pp.Cainfo = miConfig.Cainfo
  166. pp.SecretKey = miConfig.SecretKey
  167. pp.AccessKey = miConfig.AccessKey
  168. pp.OpterName = roles.UserName
  169. var config []*models.HisXtDiagnoseConfig
  170. for _, item := range diagnosis_ids {
  171. id, _ := strconv.ParseInt(item, 10, 64)
  172. diagnosisConfig, _ := service.FindDiagnoseById(id)
  173. config = append(config, &diagnosisConfig)
  174. }
  175. var pd models.PatientDtos
  176. pd.PatnID = his.PsnNo
  177. pd.PatnName = his.Name
  178. pd.Gend = his.Gend
  179. pd.Brdy = his.Brdy
  180. pd.Poolarea = his.InsuplcAdmdvs
  181. pd.CurrMdtrtID = his.Number
  182. var fed models.FsiEncounterDtos
  183. fed.MdtrtID = his.Number
  184. fed.MedinsID = miConfig.Code
  185. fed.MedinsName = miConfig.OrgName
  186. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  187. fed.MedMdtrtType = "1"
  188. fed.MedinsType = "1"
  189. fed.MedinsLv = "11"
  190. tm := time.Unix(his.RecordDate, 0)
  191. s_tm := tm.Format("2006-01-02 15:04:05")
  192. fed.AdmDate = s_tm
  193. fed.DscgDate = s_tm
  194. fed.DscgMainDiseCodg = config[0].CountryCode
  195. fed.DscgMainDiseName = config[0].CountryContentName
  196. //诊断信息
  197. var fdds []*models.FsiDiagnoseDtos
  198. for index, item := range config {
  199. if index == 0 {
  200. var fdd models.FsiDiagnoseDtos
  201. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  202. fdd.InoutDiseType = "1"
  203. fdd.MaindiseFlag = "1"
  204. fdd.DiseDate = s_tm
  205. fdd.DiasSrtNo = "1"
  206. fdd.DiseName = item.CountryContentName
  207. fdd.DiseCodg = item.CountryCode
  208. fdds = append(fdds, &fdd)
  209. } else {
  210. var fdd models.FsiDiagnoseDtos
  211. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  212. fdd.InoutDiseType = "1"
  213. fdd.MaindiseFlag = "1"
  214. fdd.DiseDate = s_tm
  215. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  216. fdd.DiseName = item.CountryContentName
  217. fdd.DiseCodg = item.CountryCode
  218. fdds = append(fdds, &fdd)
  219. }
  220. }
  221. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  222. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  223. fed.AdmDeptName = department.Name
  224. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  225. fed.DscgDeptName = department.Name
  226. fed.MedMdtrtType = "1"
  227. fed.MedType = "11"
  228. //if his.Insutype == "390" {
  229. // fed.MedType = "1402"
  230. //} else {
  231. // fed.MedType = "9933"
  232. //}
  233. var orders []*models.FsiOrderDtos
  234. if trig_scen == "2" {
  235. //处方医嘱信息
  236. for _, item := range prescriptions {
  237. for _, subItem := range item.HisDoctorAdviceInfo {
  238. var order models.FsiOrderDtos
  239. order.RxID = strconv.FormatInt(item.ID, 10)
  240. order.Rxno = strconv.FormatInt(item.ID, 10)
  241. order.LongDrordFlag = "0"
  242. order.HilistType = "1"
  243. order.ChrgType = "1"
  244. order.DrordBhvr = "-"
  245. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  246. order.HosplistName = subItem.BaseDrugLib.DrugName
  247. order.HilistLv = "1"
  248. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  249. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  250. order.HosplistName = subItem.BaseDrugLib.DrugName
  251. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  252. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  253. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  254. order.OwnpayAmt = ""
  255. order.SelfpayAmt = ""
  256. order.Spec = ""
  257. order.SpecUnt = ""
  258. order.DrordBegnDate = s_tm
  259. order.DrordStopDate = ""
  260. order.DrordDrCodg = "1"
  261. order.DrordDeptName = department.Name
  262. order.DrordDrCodg = "1"
  263. order.DrordDrName = doctor_info.UserName
  264. order.DrordDrProfttl = ""
  265. order.CurrDrordFlag = "1"
  266. orders = append(orders, &order)
  267. }
  268. for _, subItem := range item.HisPrescriptionProject {
  269. if subItem.Type == 2 {
  270. var order models.FsiOrderDtos
  271. order.RxID = strconv.FormatInt(item.ID, 10)
  272. order.Rxno = strconv.FormatInt(item.ID, 10)
  273. order.LongDrordFlag = "0"
  274. order.HilistType = "1"
  275. order.ChrgType = "1"
  276. order.DrordBhvr = "-"
  277. order.HilistCode = subItem.HisProject.MedicalCode
  278. order.HosplistName = subItem.HisProject.ProjectName
  279. order.HilistLv = "1"
  280. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  281. order.HosplistCode = subItem.HisProject.MedicalCode
  282. order.HosplistName = subItem.HisProject.ProjectName
  283. order.Cnt = subItem.Count
  284. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  285. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  286. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  287. order.OwnpayAmt = ""
  288. order.SelfpayAmt = ""
  289. order.Spec = ""
  290. order.SpecUnt = ""
  291. order.DrordBegnDate = s_tm
  292. order.DrordStopDate = ""
  293. order.DrordDrCodg = "1"
  294. order.DrordDeptName = department.Name
  295. order.DrordDrCodg = "1"
  296. order.DrordDrName = doctor_info.UserName
  297. order.DrordDrProfttl = ""
  298. order.CurrDrordFlag = "1"
  299. orders = append(orders, &order)
  300. }
  301. if subItem.Type == 3 {
  302. var order models.FsiOrderDtos
  303. order.RxID = strconv.FormatInt(item.ID, 10)
  304. order.Rxno = strconv.FormatInt(item.ID, 10)
  305. order.LongDrordFlag = "0"
  306. order.HilistType = "1"
  307. order.ChrgType = "1"
  308. order.DrordBhvr = "-"
  309. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  310. order.HosplistName = subItem.GoodInfo.GoodName
  311. order.HilistLv = "1"
  312. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  313. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  314. order.HosplistName = subItem.GoodInfo.GoodName
  315. order.Cnt = subItem.Count
  316. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  317. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  318. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  319. order.OwnpayAmt = ""
  320. order.SelfpayAmt = ""
  321. order.Spec = ""
  322. order.SpecUnt = ""
  323. order.DrordBegnDate = s_tm
  324. order.DrordStopDate = ""
  325. order.DrordDrCodg = "1"
  326. order.DrordDeptName = department.Name
  327. order.DrordDrCodg = "1"
  328. order.DrordDrName = doctor_info.UserName
  329. order.DrordDrProfttl = ""
  330. order.CurrDrordFlag = "1"
  331. orders = append(orders, &order)
  332. }
  333. }
  334. }
  335. //处方医嘱信息
  336. }
  337. fed.MatnStas = "0"
  338. fed.MedfeeSumamt = "0"
  339. fed.OwnpayAmt = "0"
  340. fed.SelfpayAmt = "0"
  341. fed.AcctPayamt = "0"
  342. fed.MaAmt = "0"
  343. fed.HifpPayamt = "0"
  344. fed.SetlTotlnum = "1"
  345. fed.Insutype = his.Insutype
  346. fed.ReimFlag = "0"
  347. fed.OutSetlFlag = "0"
  348. var fopd []*models.FsiOperationDtosData
  349. data := make(map[string]interface{})
  350. data["fed"] = fed
  351. data["fdd"] = fdds
  352. data["fod"] = orders
  353. data["pd"] = pd
  354. data["pp"] = pp
  355. data["fopd"] = fopd
  356. data["trig_scen"] = trig_scen
  357. fmt.Println(data)
  358. fmt.Println(fed)
  359. fmt.Println(fdds)
  360. fmt.Println(orders)
  361. fmt.Println(pd)
  362. fmt.Println(pp)
  363. fmt.Println(fopd)
  364. client := &http.Client{}
  365. bytesData, _ := json.Marshal(data)
  366. var req *http.Request
  367. if miConfig.MdtrtareaAdmvs == "320921" {
  368. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  369. } else {
  370. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  371. }
  372. resp, _ := client.Do(req)
  373. defer resp.Body.Close()
  374. body, ioErr := ioutil.ReadAll(resp.Body)
  375. if ioErr != nil {
  376. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  378. return res
  379. }
  380. var respJSON map[string]interface{}
  381. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  384. return res
  385. }
  386. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  387. result, _ := json.Marshal(respJSON)
  388. if err := json.Unmarshal([]byte(result), &res); err != nil {
  389. utils.ErrorLog("解析失败:%v", err)
  390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  391. return res
  392. }
  393. return res
  394. }
  395. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  396. ////patient_id, _ := c.GetInt64("patient_id")
  397. //order_id, _ := c.GetInt64("order_id")
  398. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  399. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  400. //trig_scen := c.GetString("trig_scen")
  401. adminUser := c.GetAdminUserInfo()
  402. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  403. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  404. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  405. record_time := c.GetString("record_time")
  406. order, _ := service.GetHisOrderByID(order_id)
  407. timeLayout := "2006-01-02"
  408. loc, _ := time.LoadLocation("Local")
  409. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  410. if err != nil {
  411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  412. return
  413. }
  414. recordDateTime := theTime.Unix()
  415. var patientPrescription models.HisPrescriptionInfo
  416. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  417. if patientPrescription.ID == 0 {
  418. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  419. }
  420. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  421. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  422. //
  423. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  424. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  425. var pp models.PublicParams
  426. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  427. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  428. pp.FixmedinsName = miConfig.OrgName
  429. pp.FixmedinsCode = miConfig.Code
  430. pp.RequestUrl = miConfig.Url
  431. pp.Cainfo = miConfig.Cainfo
  432. pp.SecretKey = miConfig.SecretKey
  433. pp.AccessKey = miConfig.AccessKey
  434. pp.OpterName = roles.UserName
  435. var config []*models.HisXtDiagnoseConfig
  436. for _, item := range diagnosis_ids {
  437. id, _ := strconv.ParseInt(item, 10, 64)
  438. diagnosisConfig, _ := service.FindDiagnoseById(id)
  439. config = append(config, &diagnosisConfig)
  440. }
  441. var pd models.PatientDtos
  442. pd.PatnID = his.PsnNo
  443. pd.PatnName = his.Name
  444. pd.Gend = his.Gend
  445. pd.Brdy = his.Brdy
  446. pd.Poolarea = his.InsuplcAdmdvs
  447. pd.CurrMdtrtID = his.Number
  448. var fed models.FsiEncounterDtos
  449. fed.MdtrtID = his.Number
  450. fed.MedinsID = miConfig.Code
  451. fed.MedinsName = miConfig.OrgName
  452. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  453. fed.MedMdtrtType = "1"
  454. fed.MedinsType = "1"
  455. fed.MedinsLv = "11"
  456. tm := time.Unix(his.RecordDate, 0)
  457. s_tm := tm.Format("2006-01-02 15:04:05")
  458. fed.AdmDate = s_tm
  459. fed.DscgDate = s_tm
  460. fed.DscgMainDiseCodg = config[0].CountryCode
  461. fed.DscgMainDiseName = config[0].CountryContentName
  462. //诊断信息
  463. var fdds []*models.FsiDiagnoseDtos
  464. for index, item := range config {
  465. if index == 0 {
  466. var fdd models.FsiDiagnoseDtos
  467. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  468. fdd.InoutDiseType = "1"
  469. fdd.MaindiseFlag = "1"
  470. fdd.DiseDate = s_tm
  471. fdd.DiasSrtNo = "1"
  472. fdd.DiseName = item.CountryContentName
  473. fdd.DiseCodg = item.CountryCode
  474. fdds = append(fdds, &fdd)
  475. } else {
  476. var fdd models.FsiDiagnoseDtos
  477. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  478. fdd.InoutDiseType = "1"
  479. fdd.MaindiseFlag = "1"
  480. fdd.DiseDate = s_tm
  481. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  482. fdd.DiseName = item.CountryContentName
  483. fdd.DiseCodg = item.CountryCode
  484. fdds = append(fdds, &fdd)
  485. }
  486. }
  487. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  488. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  489. fed.AdmDeptName = department.Name
  490. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  491. fed.DscgDeptName = department.Name
  492. fed.MedType = order.MedType
  493. //处方医嘱信息
  494. var orders []*models.FsiOrderDtos
  495. //for _, item := range prescriptions {
  496. // for _, subItem := range item.HisDoctorAdviceInfo {
  497. // var order models.FsiOrderDtos
  498. // order.RxID = strconv.FormatInt(item.ID, 10)
  499. // order.Rxno = strconv.FormatInt(item.ID, 10)
  500. // order.LongDrordFlag = "0"
  501. // order.HilistType = "1"
  502. // order.ChrgType = "1"
  503. // order.DrordBhvr = "-"
  504. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  505. // order.HosplistName = subItem.BaseDrugLib.DrugName
  506. // order.HilistLv = "1"
  507. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  508. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  509. // order.HosplistName = subItem.BaseDrugLib.DrugName
  510. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  511. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  512. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  513. // order.OwnpayAmt = ""
  514. // order.SelfpayAmt = ""
  515. // order.Spec = ""
  516. // order.SpecUnt = ""
  517. // order.DrordBegnDate = s_tm
  518. // order.DrordStopDate = ""
  519. // order.DrordDrCodg = "1"
  520. // order.DrordDeptName = department.Name
  521. // order.DrordDrCodg = "1"
  522. // order.DrordDrName = doctor_info.UserName
  523. // order.DrordDrProfttl = ""
  524. // order.CurrDrordFlag = "1"
  525. // orders = append(orders, &order)
  526. // }
  527. // for _, subItem := range item.HisPrescriptionProject {
  528. // if subItem.Type == 2 {
  529. // var order models.FsiOrderDtos
  530. // order.RxID = strconv.FormatInt(item.ID, 10)
  531. // order.Rxno = strconv.FormatInt(item.ID, 10)
  532. // order.LongDrordFlag = "0"
  533. // order.HilistType = "1"
  534. // order.ChrgType = "1"
  535. // order.DrordBhvr = "-"
  536. // order.HilistCode = subItem.HisProject.MedicalCode
  537. // order.HosplistName = subItem.HisProject.ProjectName
  538. // order.HilistLv = "1"
  539. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  540. // order.HosplistCode = subItem.HisProject.MedicalCode
  541. // order.HosplistName = subItem.HisProject.ProjectName
  542. // order.Cnt = subItem.Count
  543. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  544. //
  545. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  546. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  547. // order.OwnpayAmt = ""
  548. // order.SelfpayAmt = ""
  549. // order.Spec = ""
  550. // order.SpecUnt = ""
  551. // order.DrordBegnDate = s_tm
  552. // order.DrordStopDate = ""
  553. // order.DrordDrCodg = "1"
  554. // order.DrordDeptName = department.Name
  555. // order.DrordDrCodg = "1"
  556. // order.DrordDrName = doctor_info.UserName
  557. // order.DrordDrProfttl = ""
  558. // order.CurrDrordFlag = "1"
  559. // orders = append(orders, &order)
  560. //
  561. // }
  562. // if subItem.Type == 3 {
  563. //
  564. // var order models.FsiOrderDtos
  565. // order.RxID = strconv.FormatInt(item.ID, 10)
  566. // order.Rxno = strconv.FormatInt(item.ID, 10)
  567. // order.LongDrordFlag = "0"
  568. // order.HilistType = "1"
  569. // order.ChrgType = "1"
  570. // order.DrordBhvr = "-"
  571. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  572. // order.HosplistName = subItem.GoodInfo.GoodName
  573. // order.HilistLv = "1"
  574. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  575. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  576. // order.HosplistName = subItem.GoodInfo.GoodName
  577. // order.Cnt = subItem.Count
  578. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  579. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  580. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  581. // order.OwnpayAmt = ""
  582. // order.SelfpayAmt = ""
  583. // order.Spec = ""
  584. // order.SpecUnt = ""
  585. // order.DrordBegnDate = s_tm
  586. // order.DrordStopDate = ""
  587. // order.DrordDrCodg = "1"
  588. // order.DrordDeptName = department.Name
  589. // order.DrordDrCodg = "1"
  590. // order.DrordDrName = doctor_info.UserName
  591. // order.DrordDrProfttl = ""
  592. // order.CurrDrordFlag = "1"
  593. // orders = append(orders, &order)
  594. //
  595. // }
  596. // }
  597. //}
  598. for _, item := range prescriptions {
  599. for _, subItem := range item.HisDoctorAdviceInfo {
  600. var order models.FsiOrderDtos
  601. order.RxID = strconv.FormatInt(item.ID, 10)
  602. order.Rxno = strconv.FormatInt(item.ID, 10)
  603. order.LongDrordFlag = "0"
  604. order.HilistType = "1"
  605. order.ChrgType = "1"
  606. order.DrordBhvr = "-"
  607. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  608. order.HosplistName = subItem.BaseDrugLib.DrugName
  609. order.HilistLv = "1"
  610. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  611. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  612. order.HosplistName = subItem.BaseDrugLib.DrugName
  613. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  614. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  615. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  616. order.OwnpayAmt = ""
  617. order.SelfpayAmt = ""
  618. order.Spec = ""
  619. order.SpecUnt = ""
  620. order.DrordBegnDate = s_tm
  621. order.DrordStopDate = ""
  622. order.DrordDrCodg = "1"
  623. order.DrordDeptName = department.Name
  624. order.DrordDrCodg = "1"
  625. order.DrordDrName = doctor_info.UserName
  626. order.DrordDrProfttl = ""
  627. order.CurrDrordFlag = "1"
  628. orders = append(orders, &order)
  629. }
  630. for _, subItem := range item.HisPrescriptionProject {
  631. if subItem.Type == 2 {
  632. var order models.FsiOrderDtos
  633. order.RxID = strconv.FormatInt(item.ID, 10)
  634. order.Rxno = strconv.FormatInt(item.ID, 10)
  635. order.LongDrordFlag = "0"
  636. order.HilistType = "1"
  637. order.ChrgType = "1"
  638. order.DrordBhvr = "-"
  639. order.HilistCode = subItem.HisProject.MedicalCode
  640. order.HosplistName = subItem.HisProject.ProjectName
  641. order.HilistLv = "1"
  642. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  643. order.HosplistCode = subItem.HisProject.MedicalCode
  644. order.HosplistName = subItem.HisProject.ProjectName
  645. order.Cnt = subItem.Count
  646. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  647. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  648. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  649. order.OwnpayAmt = ""
  650. order.SelfpayAmt = ""
  651. order.Spec = ""
  652. order.SpecUnt = ""
  653. order.DrordBegnDate = s_tm
  654. order.DrordStopDate = ""
  655. order.DrordDrCodg = "1"
  656. order.DrordDeptName = department.Name
  657. order.DrordDrCodg = "1"
  658. order.DrordDrName = doctor_info.UserName
  659. order.DrordDrProfttl = ""
  660. order.CurrDrordFlag = "1"
  661. orders = append(orders, &order)
  662. }
  663. if subItem.Type == 3 {
  664. var order models.FsiOrderDtos
  665. order.RxID = strconv.FormatInt(item.ID, 10)
  666. order.Rxno = strconv.FormatInt(item.ID, 10)
  667. order.LongDrordFlag = "0"
  668. order.HilistType = "1"
  669. order.ChrgType = "1"
  670. order.DrordBhvr = "-"
  671. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  672. order.HosplistName = subItem.GoodInfo.GoodName
  673. order.HilistLv = "1"
  674. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  675. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  676. order.HosplistName = subItem.GoodInfo.GoodName
  677. order.Cnt = subItem.Count
  678. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  679. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  680. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  681. order.OwnpayAmt = ""
  682. order.SelfpayAmt = ""
  683. order.Spec = ""
  684. order.SpecUnt = ""
  685. order.DrordBegnDate = s_tm
  686. order.DrordStopDate = ""
  687. order.DrordDrCodg = "1"
  688. order.DrordDeptName = department.Name
  689. order.DrordDrCodg = "1"
  690. order.DrordDrName = doctor_info.UserName
  691. order.DrordDrProfttl = ""
  692. order.CurrDrordFlag = "1"
  693. orders = append(orders, &order)
  694. }
  695. }
  696. }
  697. //处方医嘱信息
  698. fed.MatnStas = "0"
  699. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  700. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  701. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  702. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  703. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  704. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  705. fed.SetlTotlnum = "1"
  706. fed.Insutype = his.Insutype
  707. fed.ReimFlag = "0"
  708. fed.OutSetlFlag = "0"
  709. var fopd []*models.FsiOperationDtosData
  710. data := make(map[string]interface{})
  711. data["fed"] = fed
  712. data["fdd"] = fdds
  713. data["fod"] = orders
  714. data["pd"] = pd
  715. data["pp"] = pp
  716. data["fopd"] = fopd
  717. data["trig_scen"] = trig_scen
  718. client := &http.Client{}
  719. bytesData, _ := json.Marshal(data)
  720. var req *http.Request
  721. if miConfig.MdtrtareaAdmvs == "320921" {
  722. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  723. } else {
  724. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  725. }
  726. resp, _ := client.Do(req)
  727. defer resp.Body.Close()
  728. body, ioErr := ioutil.ReadAll(resp.Body)
  729. if ioErr != nil {
  730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  732. return res
  733. }
  734. var respJSON map[string]interface{}
  735. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  738. return res
  739. }
  740. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  741. result, _ := json.Marshal(respJSON)
  742. if err := json.Unmarshal([]byte(result), &res); err != nil {
  743. utils.ErrorLog("解析失败:%v", err)
  744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  745. return res
  746. }
  747. return res
  748. //手术操作集合
  749. //手术操作集合
  750. }
  751. func (c *HisApiController) Check() {
  752. psn_no := c.GetString("psn_no")
  753. in := c.GetString("in")
  754. mt := c.GetString("mt")
  755. baseParams := models.BaseParams{
  756. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  757. FixmedinsCode: "H15049901371",
  758. InsuplcAdmdvs: "150499",
  759. MdtrtareaAdmvs: "150499",
  760. OrgName: "赤峰费森血液透析中心",
  761. Doctor: "1111",
  762. }
  763. service.Gdyb2001(baseParams, psn_no, in, mt)
  764. }
  765. func (c *HisApiController) GetPsnNcdsInfo() {
  766. admin_user_id, _ := c.GetInt64("admin_user_id")
  767. patient_id, _ := c.GetInt64("patient_id")
  768. id, _ := c.GetInt64("id")
  769. adminUser := c.GetAdminUserInfo()
  770. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  771. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  772. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  773. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  774. psn_record, _ := service.GetPsnNCDSRecordById(id)
  775. //
  776. //if psn_record.ID == 0 {
  777. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  778. // return
  779. //}
  780. var res Result5301
  781. var res10265 Result5301For10265
  782. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  783. psn_info, _ := service.GetPsnByPatientId(patient_id)
  784. var api string
  785. if miConfig.MdtrtareaAdmvs == "320921" {
  786. 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 +
  787. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  788. } else {
  789. 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 +
  790. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  791. }
  792. resp, requestErr := http.Get(api)
  793. if requestErr != nil {
  794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  795. return
  796. }
  797. body, ioErr := ioutil.ReadAll(resp.Body)
  798. if ioErr != nil {
  799. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  801. return
  802. }
  803. var respJSON map[string]interface{}
  804. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  807. return
  808. }
  809. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  810. result, _ := json.Marshal(respJSON)
  811. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  812. utils.ErrorLog("解析失败:%v", err)
  813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  814. return
  815. }
  816. res.ErrMsg = res10265.ErrMsg
  817. res.Output = res10265.Output
  818. res.InfRefmsgid = res10265.InfRefmsgid
  819. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  820. res.Infcode = infocode
  821. } else {
  822. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  823. var dat map[string]interface{}
  824. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  825. fmt.Println(dat)
  826. } else {
  827. fmt.Println(err)
  828. }
  829. userJSONBytes, _ := json.Marshal(dat)
  830. if miConfig.Code == "H15049901371" {
  831. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  832. utils.ErrorLog("解析失败:%v", err)
  833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  834. return
  835. }
  836. res.InfRefmsgid = res10265.InfRefmsgid
  837. res.Output = res10265.Output
  838. res.ErrMsg = res10265.ErrMsg
  839. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  840. res.Infcode = infocode
  841. } else {
  842. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  843. utils.ErrorLog("解析失败:%v", err)
  844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  845. return
  846. }
  847. }
  848. }
  849. if res.Infcode == 0 {
  850. c.ServeSuccessJSON(map[string]interface{}{
  851. "result": res.Output.Result,
  852. })
  853. }
  854. }
  855. func (c *HisApiController) CheckInsutype() {
  856. his_patient_id, _ := c.GetInt64("his_patient_id")
  857. admin_user_id, _ := c.GetInt64("admin_user_id")
  858. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  859. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  860. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  861. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  862. var dat map[string]interface{}
  863. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  864. fmt.Println(dat)
  865. } else {
  866. fmt.Println(err)
  867. }
  868. userJSONBytes, _ := json.Marshal(dat)
  869. var res Result90100
  870. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  871. utils.ErrorLog("解析失败:%v", err)
  872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  873. return
  874. }
  875. if res.Infcode != 0 {
  876. c.ServeSuccessJSON(map[string]interface{}{
  877. "failed_code": -10,
  878. "msg": res.ErrMsg,
  879. })
  880. return
  881. } else {
  882. fmt.Println(res)
  883. }
  884. }
  885. func (c *HisApiController) CheckCardPWD() {
  886. card_pwd := c.GetString("card_pwd")
  887. his_patient_id, _ := c.GetInt64("his_patient_id")
  888. admin_user_id, _ := c.GetInt64("admin_user_id")
  889. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  890. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  891. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  892. psn, _ := service.GetPsnByPatientId(his.PatientId)
  893. bas := strings.Split(psn.CardInfo, "|")
  894. basNumber := bas[2]
  895. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  896. var dat map[string]interface{}
  897. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  898. fmt.Println(dat)
  899. } else {
  900. fmt.Println(err)
  901. }
  902. userJSONBytes, _ := json.Marshal(dat)
  903. var res Result90991
  904. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  905. utils.ErrorLog("解析失败:%v", err)
  906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  907. return
  908. }
  909. if res.Infcode != 0 {
  910. c.ServeSuccessJSON(map[string]interface{}{
  911. "failed_code": -10,
  912. "msg": res.ErrMsg,
  913. })
  914. return
  915. } else {
  916. if res.Output.Result.SscnoCheckStat == "0" {
  917. var msg string
  918. switch res.Output.Result.CardStat {
  919. case "00":
  920. msg = "未激活"
  921. break
  922. case "10":
  923. msg = "激活"
  924. break
  925. case "20":
  926. msg = "窗口挂失"
  927. break
  928. case "21":
  929. msg = "电话挂失"
  930. break
  931. case "22":
  932. msg = "单位网上申报挂失"
  933. break
  934. case "23":
  935. msg = "保健办挂失"
  936. break
  937. case "24":
  938. msg = "个人网上挂失"
  939. break
  940. case "25":
  941. msg = "网上服务大厅挂失"
  942. break
  943. case "30":
  944. msg = "注销"
  945. break
  946. case "40":
  947. msg = "回收"
  948. break
  949. case "99":
  950. msg = "制卡中(无效卡)"
  951. break
  952. }
  953. c.ServeSuccessJSON(map[string]interface{}{
  954. "failed_code": -10,
  955. "msg": msg,
  956. })
  957. return
  958. } else {
  959. c.ServeSuccessJSON(map[string]interface{}{
  960. "msg": "校验成功",
  961. })
  962. return
  963. }
  964. }
  965. }
  966. func (c *HisApiController) CheckCardPWDTwo() {
  967. //card_pwd := c.GetString("card_pwd")
  968. //his_patient_id, _ := c.GetInt64("his_patient_id")
  969. admin_user_id, _ := c.GetInt64("admin_user_id")
  970. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  971. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  972. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  973. var dat map[string]interface{}
  974. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  975. fmt.Println(dat)
  976. } else {
  977. fmt.Println(err)
  978. }
  979. userJSONBytes, _ := json.Marshal(dat)
  980. var res Result90991
  981. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  982. utils.ErrorLog("解析失败:%v", err)
  983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  984. return
  985. }
  986. if res.Infcode != 0 {
  987. c.ServeSuccessJSON(map[string]interface{}{
  988. "failed_code": -10,
  989. "msg": res.ErrMsg,
  990. })
  991. return
  992. } else {
  993. if res.Output.Result.SscnoCheckStat == "0" {
  994. var msg string
  995. switch res.Output.Result.CardStat {
  996. case "00":
  997. msg = "未激活"
  998. break
  999. case "10":
  1000. msg = "激活"
  1001. break
  1002. case "20":
  1003. msg = "窗口挂失"
  1004. break
  1005. case "21":
  1006. msg = "电话挂失"
  1007. break
  1008. case "22":
  1009. msg = "单位网上申报挂失"
  1010. break
  1011. case "23":
  1012. msg = "保健办挂失"
  1013. break
  1014. case "24":
  1015. msg = "个人网上挂失"
  1016. break
  1017. case "25":
  1018. msg = "网上服务大厅挂失"
  1019. break
  1020. case "30":
  1021. msg = "注销"
  1022. break
  1023. case "40":
  1024. msg = "回收"
  1025. break
  1026. case "99":
  1027. msg = "制卡中(无效卡)"
  1028. break
  1029. }
  1030. c.ServeSuccessJSON(map[string]interface{}{
  1031. "failed_code": -10,
  1032. "msg": msg,
  1033. })
  1034. return
  1035. } else {
  1036. c.ServeSuccessJSON(map[string]interface{}{
  1037. "msg": "校验成功",
  1038. })
  1039. return
  1040. }
  1041. }
  1042. }
  1043. type ELeCertData struct {
  1044. Data struct {
  1045. Extra string `json:"extra"`
  1046. IDNo string `json:"idNo"`
  1047. IDType string `json:"idType"`
  1048. EcToken string `json:"ecToken"`
  1049. InsuOrg string `json:"insuOrg"`
  1050. UserName string `json:"userName"`
  1051. EcIndexNo string `json:"ecIndexNo"`
  1052. Gender string `json:"gender"`
  1053. Birthday string `json:"birthday"`
  1054. Nationality string `json:"nationality"`
  1055. Email string `json:"email"`
  1056. } `json:"OutData"`
  1057. }
  1058. func (c *HisApiController) ReadCard() {
  1059. id_card_type, _ := c.GetInt64("id_card_type")
  1060. admin_user_id, _ := c.GetInt64("admin_user_id")
  1061. certificates, _ := c.GetInt64("certificates")
  1062. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1063. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1064. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1065. switch id_card_type {
  1066. case 1:
  1067. if miConfig.MdtrtareaAdmvs == "421300" {
  1068. var res ResultTwo
  1069. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1070. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1071. "&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)
  1072. resp, requestErr := http.Get(api)
  1073. if requestErr != nil {
  1074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1075. return
  1076. }
  1077. body, ioErr := ioutil.ReadAll(resp.Body)
  1078. if ioErr != nil {
  1079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1081. return
  1082. }
  1083. var respJSON map[string]interface{}
  1084. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1087. return
  1088. }
  1089. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1090. result, _ := json.Marshal(respJSON)
  1091. fmt.Println("log")
  1092. fmt.Println(string(result))
  1093. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1094. utils.ErrorLog("解析失败:%v", err)
  1095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1096. return
  1097. }
  1098. if res.Infcode == 0 {
  1099. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1100. if err == gorm.ErrRecordNotFound {
  1101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1102. return
  1103. } else if err != nil {
  1104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1105. return
  1106. } else {
  1107. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1108. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1109. infoStr := string(Iinfos)
  1110. idetinfoStr := string(Idetinfos)
  1111. psn := &models.HisPsn{
  1112. PsnNo: res.Output.Baseinfo.PsnNo,
  1113. Age: res.Output.Baseinfo.Age,
  1114. PatientId: patient.ID,
  1115. Certno: res.Output.Baseinfo.Certno,
  1116. Brdy: res.Output.Baseinfo.Brdy,
  1117. Gend: res.Output.Baseinfo.Gend,
  1118. Naty: res.Output.Baseinfo.Naty,
  1119. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1120. PsnName: res.Output.Baseinfo.PsnName,
  1121. Idetinfo: idetinfoStr,
  1122. Insuinfo: infoStr,
  1123. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1124. }
  1125. service.CreateHisPsn(psn)
  1126. c.ServeSuccessJSON(map[string]interface{}{
  1127. "patient": patient,
  1128. "number": res.Output.Baseinfo.Certno,
  1129. })
  1130. }
  1131. } else {
  1132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1133. return
  1134. }
  1135. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1136. var api string
  1137. if miConfig.MdtrtareaAdmvs == "320921" {
  1138. 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 +
  1139. "&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
  1140. fmt.Println(api)
  1141. } else {
  1142. 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 +
  1143. "&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)
  1144. }
  1145. resp, requestErr := http.Get(api)
  1146. if requestErr != nil {
  1147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1148. return
  1149. }
  1150. body, ioErr := ioutil.ReadAll(resp.Body)
  1151. if ioErr != nil {
  1152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1154. return
  1155. }
  1156. var respJSON map[string]interface{}
  1157. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1160. return
  1161. }
  1162. var status string
  1163. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1164. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1165. //console.log()
  1166. fmt.Println("type===")
  1167. fmt.Println(card_type)
  1168. var token string
  1169. var res ResultTwo //1101结果
  1170. var res10265 ResultTwo10265 //1101结果
  1171. var card_info string //卡信息
  1172. var busi_card_info string
  1173. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1174. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1175. if status == "0" { //读卡成功
  1176. if card_type == "1" {
  1177. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1178. result, _ := json.Marshal(respJSON)
  1179. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1180. utils.ErrorLog("解析失败:%v", err)
  1181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1182. return
  1183. }
  1184. res.ErrMsg = res10265.ErrMsg
  1185. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1186. res.Infcode = infocode
  1187. res.Output = res10265.Output
  1188. res.InfRefmsgid = res10265.InfRefmsgid
  1189. } else {
  1190. //var card_info string //卡信息
  1191. //var busi_card_info string
  1192. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1193. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1194. //fmt.Println(card_info)
  1195. //fmt.Println(busi_card_info)
  1196. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1197. result, _ := json.Marshal(respJSON)
  1198. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1199. utils.ErrorLog("解析失败:%v", err)
  1200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1201. return
  1202. }
  1203. res.ErrMsg = res10265.ErrMsg
  1204. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1205. res.Infcode = infocode
  1206. res.Output = res10265.Output
  1207. res.InfRefmsgid = res10265.InfRefmsgid
  1208. }
  1209. if res.Infcode == 0 {
  1210. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1211. if err == gorm.ErrRecordNotFound {
  1212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1213. return
  1214. } else if err != nil {
  1215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1216. return
  1217. } else {
  1218. if card_type == "1" {
  1219. bas := strings.Split(card_info, "|")
  1220. basNumber := bas[2]
  1221. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1222. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1223. infoStr := string(Iinfos)
  1224. idetinfoStr := string(Idetinfos)
  1225. psn := &models.HisPsn{
  1226. PsnNo: res.Output.Baseinfo.PsnNo,
  1227. Age: res.Output.Baseinfo.Age,
  1228. PatientId: patient.ID,
  1229. Certno: res.Output.Baseinfo.Certno,
  1230. Brdy: res.Output.Baseinfo.Brdy,
  1231. Gend: res.Output.Baseinfo.Gend,
  1232. Naty: res.Output.Baseinfo.Naty,
  1233. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1234. PsnName: res.Output.Baseinfo.PsnName,
  1235. Idetinfo: idetinfoStr,
  1236. Insuinfo: infoStr,
  1237. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1238. CardInfo: card_info,
  1239. VerifyNumber: busi_card_info,
  1240. }
  1241. service.CreateHisPsn(psn)
  1242. var rf []*ResultFive
  1243. json.Unmarshal([]byte(infoStr), &rf)
  1244. var insutypes []*ResultFive
  1245. var insutype string
  1246. var is390 int = 0
  1247. var is310 int = 0
  1248. for _, item := range rf {
  1249. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1250. insutypes = append(insutypes, item)
  1251. }
  1252. }
  1253. if len(insutypes) == 1 {
  1254. insutype = insutypes[0].Insutype
  1255. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1256. } else {
  1257. for _, i := range insutypes {
  1258. if i.Insutype == "390" {
  1259. is390 = 1
  1260. }
  1261. if i.Insutype == "310" {
  1262. is310 = 1
  1263. }
  1264. }
  1265. }
  1266. if is390 == 1 {
  1267. insutype = "390"
  1268. }
  1269. if is310 == 1 {
  1270. insutype = "310"
  1271. }
  1272. if len(insutypes) == 0 {
  1273. insutype = "310"
  1274. }
  1275. c.ServeSuccessJSON(map[string]interface{}{
  1276. "patient": patient,
  1277. "number": basNumber,
  1278. "insutype": insutype,
  1279. })
  1280. } else {
  1281. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1282. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1283. infoStr := string(Iinfos)
  1284. idetinfoStr := string(Idetinfos)
  1285. psn := &models.HisPsn{
  1286. PsnNo: res.Output.Baseinfo.PsnNo,
  1287. Age: res.Output.Baseinfo.Age,
  1288. PatientId: patient.ID,
  1289. Certno: res.Output.Baseinfo.Certno,
  1290. Brdy: res.Output.Baseinfo.Brdy,
  1291. Gend: res.Output.Baseinfo.Gend,
  1292. Naty: res.Output.Baseinfo.Naty,
  1293. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1294. PsnName: res.Output.Baseinfo.PsnName,
  1295. Idetinfo: idetinfoStr,
  1296. Insuinfo: infoStr,
  1297. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1298. CardInfo: card_info,
  1299. VerifyNumber: token,
  1300. }
  1301. service.CreateHisPsn(psn)
  1302. c.ServeSuccessJSON(map[string]interface{}{
  1303. "patient": patient,
  1304. "number": token,
  1305. })
  1306. }
  1307. }
  1308. } else {
  1309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1310. return
  1311. }
  1312. } else { //读卡失败
  1313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1314. return
  1315. }
  1316. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1317. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1318. cardnum = DeleteExtraSpaceTwo(cardnum)
  1319. cardCode = DeleteExtraSpaceTwo(cardCode)
  1320. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1321. name = DeleteExtraSpaceTwo(name)
  1322. errmsg = DeleteExtraSpaceTwo(errmsg)
  1323. cardnum = Remove0000(cardnum)
  1324. cardCode = Remove0000(cardCode)
  1325. id_card_no = Remove0000(id_card_no)
  1326. name = Remove0000(name)
  1327. errmsg = Remove0000(errmsg)
  1328. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1329. 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)
  1330. saveLog(result, requestLog, "1101", "获取人员信息")
  1331. fmt.Println(errMsgLog)
  1332. if len(errMsgLog) > 0 {
  1333. } else {
  1334. var dat map[string]interface{}
  1335. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1336. fmt.Println(dat)
  1337. } else {
  1338. fmt.Println(err)
  1339. }
  1340. userJSONBytes, _ := json.Marshal(dat)
  1341. var res ResultTwo
  1342. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1343. utils.ErrorLog("解析失败:%v", err)
  1344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1345. return
  1346. }
  1347. res.ErrMsg = errMsgLog
  1348. if res.Infcode == 0 {
  1349. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1350. if err == gorm.ErrRecordNotFound {
  1351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1352. return
  1353. } else if err != nil {
  1354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1355. return
  1356. } else {
  1357. fmt.Println(res)
  1358. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1359. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1360. infoStr := string(Iinfos)
  1361. idetinfoStr := string(Idetinfos)
  1362. psn := &models.HisPsn{
  1363. PsnNo: res.Output.Baseinfo.PsnNo,
  1364. Age: res.Output.Baseinfo.Age,
  1365. PatientId: patient.ID,
  1366. Certno: res.Output.Baseinfo.Certno,
  1367. Brdy: res.Output.Baseinfo.Brdy,
  1368. Gend: res.Output.Baseinfo.Gend,
  1369. Naty: res.Output.Baseinfo.Naty,
  1370. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1371. PsnName: res.Output.Baseinfo.PsnName,
  1372. Idetinfo: idetinfoStr,
  1373. Insuinfo: infoStr,
  1374. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1375. CardInfo: basStr,
  1376. VerifyNumber: "",
  1377. }
  1378. service.CreateHisPsn(psn)
  1379. var rf []*ResultFive
  1380. json.Unmarshal([]byte(infoStr), &rf)
  1381. var insutypes []*ResultFive
  1382. var insutype string
  1383. var is390 int = 0
  1384. var is310 int = 0
  1385. for _, item := range rf {
  1386. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1387. insutypes = append(insutypes, item)
  1388. }
  1389. }
  1390. if len(insutypes) == 1 {
  1391. insutype = insutypes[0].Insutype
  1392. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1393. } else {
  1394. for _, i := range insutypes {
  1395. if i.Insutype == "390" {
  1396. is390 = 1
  1397. }
  1398. if i.Insutype == "310" {
  1399. is310 = 1
  1400. }
  1401. }
  1402. }
  1403. if is390 == 1 {
  1404. insutype = "390"
  1405. }
  1406. if is310 == 1 {
  1407. insutype = "310"
  1408. }
  1409. if len(insutypes) == 0 {
  1410. insutype = "310"
  1411. }
  1412. c.ServeSuccessJSON(map[string]interface{}{
  1413. "patient": patient,
  1414. "number": cardnum,
  1415. "insutype": insutype,
  1416. })
  1417. }
  1418. } else {
  1419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1420. return
  1421. }
  1422. }
  1423. } else {
  1424. if initFlag == 0 {
  1425. c.TestGetBasBaseInit()
  1426. }
  1427. basStr := c.GetBasBaseInfo()
  1428. if len(basStr) == 0 {
  1429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1430. return
  1431. }
  1432. fmt.Println(basStr)
  1433. bas := strings.Split(basStr, "|")
  1434. basNumber := bas[1]
  1435. fmt.Println(basNumber)
  1436. card_sn := bas[3]
  1437. fmt.Println(card_sn)
  1438. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1439. var dat map[string]interface{}
  1440. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1441. fmt.Println(dat)
  1442. } else {
  1443. fmt.Println(err)
  1444. }
  1445. userJSONBytes, _ := json.Marshal(dat)
  1446. var res ResultTwo
  1447. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1448. utils.ErrorLog("解析失败:%v", err)
  1449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1450. return
  1451. }
  1452. if res.Infcode == 0 {
  1453. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1454. if err == gorm.ErrRecordNotFound {
  1455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1456. return
  1457. } else if err != nil {
  1458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1459. return
  1460. } else {
  1461. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1462. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1463. infoStr := string(Iinfos)
  1464. idetinfoStr := string(Idetinfos)
  1465. psn := &models.HisPsn{
  1466. PsnNo: res.Output.Baseinfo.PsnNo,
  1467. Age: res.Output.Baseinfo.Age,
  1468. PatientId: patient.ID,
  1469. Certno: res.Output.Baseinfo.Certno,
  1470. Brdy: res.Output.Baseinfo.Brdy,
  1471. Gend: res.Output.Baseinfo.Gend,
  1472. Naty: res.Output.Baseinfo.Naty,
  1473. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1474. PsnName: res.Output.Baseinfo.PsnName,
  1475. Idetinfo: idetinfoStr,
  1476. Insuinfo: infoStr,
  1477. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1478. CardInfo: basStr,
  1479. VerifyNumber: "",
  1480. }
  1481. service.CreateHisPsn(psn)
  1482. c.ServeSuccessJSON(map[string]interface{}{
  1483. "patient": patient,
  1484. "number": basNumber,
  1485. })
  1486. }
  1487. } else {
  1488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1489. return
  1490. }
  1491. break
  1492. }
  1493. case 2:
  1494. SFZStr := c.GetSFZBaseInfo()
  1495. id_card_str := strings.Split(SFZStr, "^")
  1496. id_card_number := id_card_str[0]
  1497. card_sn := ""
  1498. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1499. var dat map[string]interface{}
  1500. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1501. fmt.Println(dat)
  1502. } else {
  1503. fmt.Println(err)
  1504. }
  1505. userJSONBytes, _ := json.Marshal(dat)
  1506. var res ResultTwo
  1507. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1508. utils.ErrorLog("解析失败:%v", err)
  1509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1510. return
  1511. }
  1512. if res.Infcode == 0 {
  1513. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1514. if err == gorm.ErrRecordNotFound {
  1515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1516. return
  1517. } else if err != nil {
  1518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1519. return
  1520. } else {
  1521. c.ServeSuccessJSON(map[string]interface{}{
  1522. "patient": patient,
  1523. "number": id_card_number,
  1524. })
  1525. }
  1526. } else {
  1527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1528. return
  1529. }
  1530. break
  1531. case 3:
  1532. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1533. var api string
  1534. if miConfig.MdtrtareaAdmvs == "320921" {
  1535. 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 +
  1536. "&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
  1537. fmt.Println(api)
  1538. } else {
  1539. 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 +
  1540. "&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)
  1541. }
  1542. resp, requestErr := http.Get(api)
  1543. if requestErr != nil {
  1544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1545. return
  1546. }
  1547. body, ioErr := ioutil.ReadAll(resp.Body)
  1548. if ioErr != nil {
  1549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1551. return
  1552. }
  1553. var respJSON map[string]interface{}
  1554. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1557. return
  1558. }
  1559. var status string
  1560. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1561. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1562. var token string
  1563. var res ResultTwo //1101结果
  1564. var res10265 ResultTwo10265 //1101结果
  1565. var card_info string //卡信息
  1566. var busi_card_info string
  1567. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1568. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1569. if status == "0" { //读卡成功
  1570. if card_type == "1" {
  1571. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1572. result, _ := json.Marshal(respJSON)
  1573. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1574. utils.ErrorLog("解析失败:%v", err)
  1575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1576. return
  1577. }
  1578. res.ErrMsg = res10265.ErrMsg
  1579. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1580. res.Infcode = infocode
  1581. res.Output = res10265.Output
  1582. res.InfRefmsgid = res10265.InfRefmsgid
  1583. } else {
  1584. //var card_info string //卡信息
  1585. //var busi_card_info string
  1586. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1587. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1588. //fmt.Println(card_info)
  1589. //fmt.Println(busi_card_info)
  1590. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1591. result, _ := json.Marshal(respJSON)
  1592. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1593. utils.ErrorLog("解析失败:%v", err)
  1594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1595. return
  1596. }
  1597. res.ErrMsg = res10265.ErrMsg
  1598. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1599. res.Infcode = infocode
  1600. res.Output = res10265.Output
  1601. res.InfRefmsgid = res10265.InfRefmsgid
  1602. }
  1603. if res.Infcode == 0 {
  1604. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1605. if err == gorm.ErrRecordNotFound {
  1606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1607. return
  1608. } else if err != nil {
  1609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1610. return
  1611. } else {
  1612. if card_type == "1" {
  1613. bas := strings.Split(card_info, "|")
  1614. basNumber := bas[2]
  1615. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1616. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1617. infoStr := string(Iinfos)
  1618. idetinfoStr := string(Idetinfos)
  1619. psn := &models.HisPsn{
  1620. PsnNo: res.Output.Baseinfo.PsnNo,
  1621. Age: res.Output.Baseinfo.Age,
  1622. PatientId: patient.ID,
  1623. Certno: res.Output.Baseinfo.Certno,
  1624. Brdy: res.Output.Baseinfo.Brdy,
  1625. Gend: res.Output.Baseinfo.Gend,
  1626. Naty: res.Output.Baseinfo.Naty,
  1627. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1628. PsnName: res.Output.Baseinfo.PsnName,
  1629. Idetinfo: idetinfoStr,
  1630. Insuinfo: infoStr,
  1631. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1632. CardInfo: card_info,
  1633. VerifyNumber: busi_card_info,
  1634. }
  1635. service.CreateHisPsn(psn)
  1636. c.ServeSuccessJSON(map[string]interface{}{
  1637. "patient": patient,
  1638. "number": basNumber,
  1639. })
  1640. } else {
  1641. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1642. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1643. infoStr := string(Iinfos)
  1644. idetinfoStr := string(Idetinfos)
  1645. psn := &models.HisPsn{
  1646. PsnNo: res.Output.Baseinfo.PsnNo,
  1647. Age: res.Output.Baseinfo.Age,
  1648. PatientId: patient.ID,
  1649. Certno: res.Output.Baseinfo.Certno,
  1650. Brdy: res.Output.Baseinfo.Brdy,
  1651. Gend: res.Output.Baseinfo.Gend,
  1652. Naty: res.Output.Baseinfo.Naty,
  1653. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1654. PsnName: res.Output.Baseinfo.PsnName,
  1655. Idetinfo: idetinfoStr,
  1656. Insuinfo: infoStr,
  1657. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1658. CardInfo: card_info,
  1659. VerifyNumber: token,
  1660. }
  1661. service.CreateHisPsn(psn)
  1662. var rf []*ResultFive
  1663. json.Unmarshal([]byte(infoStr), &rf)
  1664. var insutypes []*ResultFive
  1665. var insutype string
  1666. var is390 int = 0
  1667. var is310 int = 0
  1668. for _, item := range rf {
  1669. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1670. insutypes = append(insutypes, item)
  1671. }
  1672. }
  1673. if len(insutypes) == 1 {
  1674. insutype = insutypes[0].Insutype
  1675. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1676. } else {
  1677. for _, i := range insutypes {
  1678. if i.Insutype == "390" {
  1679. is390 = 1
  1680. }
  1681. if i.Insutype == "310" {
  1682. is310 = 1
  1683. }
  1684. }
  1685. }
  1686. if is390 == 1 {
  1687. insutype = "390"
  1688. }
  1689. if is310 == 1 {
  1690. insutype = "310"
  1691. }
  1692. if len(insutypes) == 0 {
  1693. insutype = "310"
  1694. }
  1695. c.ServeSuccessJSON(map[string]interface{}{
  1696. "patient": patient,
  1697. "number": token,
  1698. "insutype": insutype,
  1699. })
  1700. }
  1701. }
  1702. } else {
  1703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1704. return
  1705. }
  1706. } else { //读卡失败
  1707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1708. return
  1709. }
  1710. }
  1711. break
  1712. case 4:
  1713. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1714. var api string
  1715. if miConfig.MdtrtareaAdmvs == "320921" {
  1716. 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 +
  1717. "&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
  1718. fmt.Println(api)
  1719. } else {
  1720. 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 +
  1721. "&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)
  1722. }
  1723. resp, requestErr := http.Get(api)
  1724. if requestErr != nil {
  1725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1726. return
  1727. }
  1728. body, ioErr := ioutil.ReadAll(resp.Body)
  1729. if ioErr != nil {
  1730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1732. return
  1733. }
  1734. var respJSON map[string]interface{}
  1735. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1738. return
  1739. }
  1740. var status string
  1741. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1742. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1743. var token string
  1744. var res ResultTwo //1101结果
  1745. var res10265 ResultTwo10265 //1101结果
  1746. if status == "0" { //读卡成功
  1747. var card_info string //卡信息
  1748. var busi_card_info string
  1749. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1750. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1751. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1752. fmt.Println(card_info)
  1753. fmt.Println(busi_card_info)
  1754. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1755. result, _ := json.Marshal(respJSON)
  1756. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1757. utils.ErrorLog("解析失败:%v", err)
  1758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1759. return
  1760. }
  1761. res.ErrMsg = res10265.ErrMsg
  1762. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1763. res.Infcode = infocode
  1764. res.Output = res10265.Output
  1765. res.InfRefmsgid = res10265.InfRefmsgid
  1766. if res.Infcode == 0 {
  1767. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1768. if err == gorm.ErrRecordNotFound {
  1769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1770. return
  1771. } else if err != nil {
  1772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1773. return
  1774. } else {
  1775. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1776. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1777. infoStr := string(Iinfos)
  1778. idetinfoStr := string(Idetinfos)
  1779. psn := &models.HisPsn{
  1780. PsnNo: res.Output.Baseinfo.PsnNo,
  1781. Age: res.Output.Baseinfo.Age,
  1782. PatientId: patient.ID,
  1783. Certno: res.Output.Baseinfo.Certno,
  1784. Brdy: res.Output.Baseinfo.Brdy,
  1785. Gend: res.Output.Baseinfo.Gend,
  1786. Naty: res.Output.Baseinfo.Naty,
  1787. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1788. PsnName: res.Output.Baseinfo.PsnName,
  1789. Idetinfo: idetinfoStr,
  1790. Insuinfo: infoStr,
  1791. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1792. CardInfo: card_info,
  1793. VerifyNumber: token,
  1794. }
  1795. service.CreateHisPsn(psn)
  1796. c.ServeSuccessJSON(map[string]interface{}{
  1797. "patient": patient,
  1798. "number": token,
  1799. })
  1800. }
  1801. } else {
  1802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1803. return
  1804. }
  1805. } else { //读卡失败
  1806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1807. return
  1808. }
  1809. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  1810. result, requestLog := service.Gdyb6101(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1811. saveLog(result, requestLog, "6101", "电子凭证")
  1812. var ele ELeCertData
  1813. err := json.Unmarshal([]byte(result), &ele)
  1814. if err != nil {
  1815. utils.ErrorLog("解析失败:%v", err)
  1816. }
  1817. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, ele.Data.EcToken)
  1818. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1819. var res ResultTwo
  1820. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1821. utils.ErrorLog("解析失败:%v", err)
  1822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1823. return
  1824. }
  1825. if res.Infcode == 0 {
  1826. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  1827. if err == gorm.ErrRecordNotFound {
  1828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1829. return
  1830. } else if err != nil {
  1831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1832. return
  1833. } else {
  1834. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1835. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1836. infoStr := string(Iinfos)
  1837. idetinfoStr := string(Idetinfos)
  1838. psn := &models.HisPsn{
  1839. PsnNo: res.Output.Baseinfo.PsnNo,
  1840. Age: res.Output.Baseinfo.Age,
  1841. PatientId: patient.ID,
  1842. Certno: res.Output.Baseinfo.Certno,
  1843. Brdy: res.Output.Baseinfo.Brdy,
  1844. Gend: res.Output.Baseinfo.Gend,
  1845. Naty: res.Output.Baseinfo.Naty,
  1846. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1847. PsnName: res.Output.Baseinfo.PsnName,
  1848. Idetinfo: idetinfoStr,
  1849. Insuinfo: infoStr,
  1850. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1851. CardInfo: "",
  1852. VerifyNumber: ele.Data.EcToken,
  1853. }
  1854. service.CreateHisPsn(psn)
  1855. c.ServeSuccessJSON(map[string]interface{}{
  1856. "patient": patient,
  1857. "number": ele.Data.EcToken,
  1858. })
  1859. }
  1860. } else {
  1861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1862. return
  1863. }
  1864. }
  1865. break
  1866. }
  1867. }
  1868. var initFlag int64 = 0
  1869. func (c *HisApiController) TestGetBasBaseInit() {
  1870. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1871. Iinit := DllDef.MustFindProc("Init")
  1872. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1873. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1874. if ret != 0 {
  1875. fmt.Println("SSCard的报错原因:", err)
  1876. fmt.Println("SSCard的运算结果为:", ret)
  1877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1878. return
  1879. }
  1880. result := int(ret)
  1881. fmt.Println("SSCard的运算结果为1:", result)
  1882. initFlag = 1
  1883. return
  1884. }
  1885. func (c *HisApiController) GetSFZBaseInfo() string {
  1886. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1887. readCard := DllDef.MustFindProc("ReadSFZ")
  1888. if readCard == nil {
  1889. fmt.Println("readcard is nil")
  1890. readCard = DllDef.MustFindProc("ReadSFZ")
  1891. }
  1892. str := make([]byte, 256)
  1893. str1 := make([]byte, 256)
  1894. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1895. fmt.Println(r)
  1896. return string(str)
  1897. }
  1898. func (c *HisApiController) GetBasBaseInfo() string {
  1899. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1900. readCard := DllDef.MustFindProc("ReadCardBas")
  1901. if readCard == nil {
  1902. fmt.Println("readcard is nil")
  1903. readCard = DllDef.MustFindProc("ReadCardBas")
  1904. }
  1905. str := make([]byte, 1024)
  1906. str1 := make([]byte, 1024)
  1907. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1908. fmt.Println(string(str1))
  1909. fmt.Println(string(str))
  1910. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1911. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1912. if ret2 != 0 {
  1913. return ""
  1914. }
  1915. return string(str)
  1916. }
  1917. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  1918. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  1919. readCard := DllDef.MustFindProc("read_cardinfo")
  1920. if readCard == nil {
  1921. fmt.Println("readcard is nil")
  1922. readCard = DllDef.MustFindProc("read_cardinfo")
  1923. }
  1924. str := make([]byte, 1024) //卡号
  1925. str1 := make([]byte, 1024) //卡识别码
  1926. str2 := make([]byte, 1024) //身份证号
  1927. str3 := make([]byte, 1024) //姓名
  1928. str4 := make([]byte, 1024) //错误信息
  1929. 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])))
  1930. fmt.Println(string(str1))
  1931. fmt.Println(string(str))
  1932. fmt.Println(string(str2))
  1933. fmt.Println(string(str3))
  1934. fmt.Println(string(str4))
  1935. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1936. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1937. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  1938. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  1939. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  1940. if ret2 != 0 {
  1941. return "", "", "", "", ""
  1942. }
  1943. return string(str), string(str1), string(str2), string(str3), string(str4)
  1944. }
  1945. type CustomFundPay struct {
  1946. FundPayType string `json:"fund_pay_type"`
  1947. FundPayamt float64 `json:"fund_payamt"`
  1948. }
  1949. func (c *HisApiController) GetSettleList() {
  1950. order_id, _ := c.GetInt64("order_id")
  1951. admin_user_id, _ := c.GetInt64("admin_user_id")
  1952. order, _ := service.GetHisOrderByIDTwo(order_id)
  1953. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1954. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1955. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1956. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1957. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1958. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1959. if order.ID == 0 {
  1960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1961. return
  1962. }
  1963. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1964. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1965. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1966. fmt.Println(count)
  1967. var zero string
  1968. number := count + 1
  1969. if number >= 1000 {
  1970. zero = "0000" + strconv.FormatInt(number, 10)
  1971. } else if number >= 10000 {
  1972. zero = "000" + strconv.FormatInt(number, 10)
  1973. } else if number >= 100000 {
  1974. zero = "00" + strconv.FormatInt(number, 10)
  1975. } else if number >= 1000000 {
  1976. zero = "0" + strconv.FormatInt(number, 10)
  1977. } else {
  1978. zero = strconv.FormatInt(number, 10)
  1979. }
  1980. fmt.Println(zero)
  1981. struct4101 := service.Struct4101{
  1982. PsnNo: order.PsnNo,
  1983. MdtrtId: order.MdtrtId,
  1984. SetlId: order.SetlId,
  1985. PsnName: order.PsnName,
  1986. Gend: order.Gend,
  1987. Brdy: his.Brdy,
  1988. Age: his.Age,
  1989. Naty: order.Naty,
  1990. PatnCertType: "01",
  1991. Certno: order.Certno,
  1992. Prfs: "90",
  1993. ConerName: roles[0].UserName,
  1994. PatnRlts: "99",
  1995. ConerAddr: miConfig.OrgName,
  1996. ConerTel: admin.Mobile,
  1997. HiType: order.Insutype,
  1998. Insuplc: miConfig.InsuplcAdmdvs,
  1999. MaindiagFlag: "1",
  2000. BillCode: last_order.FaPiaoCode,
  2001. BillNo: zero,
  2002. BizSn: order.Number,
  2003. PsnSelfPay: order.PsnPartAmt,
  2004. PsnOwnPay: order.PsnPartAmt,
  2005. AcctPay: order.AcctPay,
  2006. PsnCashpay: order.PsnCashPay,
  2007. HiPaymtd: "1",
  2008. Hsorg: miConfig.InsuplcAdmdvs,
  2009. HsorgOpter: miConfig.InsuplcAdmdvs,
  2010. MedinsFillPsn: curRoles.UserName,
  2011. MedinsFillDept: depart.Name,
  2012. IptMedType: "2",
  2013. }
  2014. struct4101.SetlBegnDate = order.SetlTime
  2015. struct4101.SetlEndDate = order.SetlTime
  2016. time_arr := strings.Split(order.SetlTime, " ")
  2017. struct4101.AdmTime = time_arr[0]
  2018. struct4101.AdmEndTime = time_arr[0]
  2019. var rf []CustomFundPay
  2020. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2021. var tempFunPays []service.CustomStruct
  2022. for _, item := range rf {
  2023. var tempFunPay service.CustomStruct
  2024. tempFunPay.FundPayamt = item.FundPayamt
  2025. tempFunPay.FundPayType = item.FundPayType
  2026. tempFunPays = append(tempFunPays, tempFunPay)
  2027. }
  2028. struct4101.CustomStruct = tempFunPays
  2029. var tempDiaginfos []service.DiaginfoStructTwo
  2030. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2031. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2032. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  2033. var config []*models.HisXtDiagnoseConfig
  2034. for _, item := range diagnosis_ids {
  2035. id, _ := strconv.ParseInt(item, 10, 64)
  2036. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2037. config = append(config, &diagnosisConfig)
  2038. }
  2039. for index, item := range config {
  2040. if index == 0 {
  2041. var tempDiaginfo service.DiaginfoStructTwo
  2042. tempDiaginfo.DiagCode = item.CountryCode
  2043. tempDiaginfo.DiagName = item.CountryContentName
  2044. tempDiaginfo.DiagType = "1"
  2045. tempDiaginfo.MaindiagFlag = "1"
  2046. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2047. } else {
  2048. var tempDiaginfo service.DiaginfoStructTwo
  2049. tempDiaginfo.DiagCode = item.CountryCode
  2050. tempDiaginfo.DiagName = item.CountryContentName
  2051. tempDiaginfo.DiagType = "2"
  2052. tempDiaginfo.MaindiagFlag = "0"
  2053. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2054. }
  2055. }
  2056. struct4101.Diseinfo = tempDiaginfos
  2057. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2058. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2059. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2060. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  2061. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  2062. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2063. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2064. var iteminfo service.IteminfoStruct
  2065. var bedCostTotal float64 = 0 //床位总费
  2066. var bedCostSelfTotal float64 = 0 //床位自费
  2067. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2068. var operationCostTotal float64 = 0 //手术费
  2069. var operationCostSelfTotal float64 = 0 //手术费
  2070. var operationCostPartSelfTotal float64 = 0 //手术费
  2071. var otherCostTotal float64 = 0 //其他费用
  2072. var otherCostSelfTotal float64 = 0 //其他费用
  2073. var otherCostPartSelfTotal float64 = 0 //其他费用
  2074. var materialCostTotal float64 = 0 //材料费
  2075. var materialCostSelfTotal float64 = 0 //材料费
  2076. var materialCostPartSelfTotal float64 = 0 //材料费
  2077. var westernMedicineCostTotal float64 = 0 //西药费
  2078. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2079. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2080. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2081. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2082. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2083. var checkCostTotal float64 = 0 //检查费
  2084. var checkCostSelfTotal float64 = 0 //检查费
  2085. var checkCostPartSelfTotal float64 = 0 //检查费
  2086. var laboratoryCostTotal float64 = 0 //化验费
  2087. var laboratoryCostSelfTotal float64 = 0 //化验费
  2088. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2089. var treatCostTotal float64 = 0 //治疗费用
  2090. var treatCostSelfTotal float64 = 0 //治疗费用
  2091. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2092. decimal.DivisionPrecision = 2
  2093. var bed_fulamt_ownpay_amt float64 = 0
  2094. var operation_fulamt_ownpay_amt float64 = 0
  2095. var other_fulamt_ownpay_amt float64 = 0
  2096. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2097. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2098. var check_fulamt_ownpay_amt float64 = 0
  2099. var material_fulamt_ownpay_amt float64 = 0
  2100. var laboratory_fulamt_ownpay_amt float64 = 0
  2101. var treat_fulamt_ownpay_amt float64 = 0
  2102. var bed_claa_sunmfee float64 = 0
  2103. var bed_clab_amt float64 = 0
  2104. var bed_other_amt float64 = 0
  2105. var operation_claa_sunmfee float64 = 0
  2106. var operation_clab_amt float64 = 0
  2107. var operation_other_amt float64 = 0
  2108. var other_claa_sunmfee float64 = 0
  2109. var other_clab_amt float64 = 0
  2110. var other_other_amt float64 = 0
  2111. var westernMedicine_claa_sunmfee float64 = 0
  2112. var westernMedicine_clab_amt float64 = 0
  2113. var westernMedicine_other_amt float64 = 0
  2114. var chineseTraditional_claa_sunmfee float64 = 0
  2115. var chineseTraditional_clab_amt float64 = 0
  2116. var chineseTraditional_other_amt float64 = 0
  2117. var check_claa_sunmfee float64 = 0
  2118. var check_clab_amt float64 = 0
  2119. var check_other_amt float64 = 0
  2120. var material_claa_sunmfee float64 = 0
  2121. var material_clab_amt float64 = 0
  2122. var material_other_amt float64 = 0
  2123. var laboratory_claa_sunmfee float64 = 0
  2124. var laboratory_clab_amt float64 = 0
  2125. var laboratory_other_amt float64 = 0
  2126. var treat_claa_sunmfee float64 = 0
  2127. var treat_clab_amt float64 = 0
  2128. var treat_other_amt float64 = 0
  2129. for _, item := range order.HisOrderInfo {
  2130. if item.MedChrgitmType == "01" { //床位费
  2131. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2132. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2133. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2134. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2135. if item.ChrgitmLv == "1" {
  2136. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2137. }
  2138. if item.ChrgitmLv == "2" {
  2139. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2140. }
  2141. if item.ChrgitmLv == "3" {
  2142. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2143. }
  2144. }
  2145. if item.MedChrgitmType == "03" { //检查费
  2146. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2147. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2148. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2149. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2150. if item.ChrgitmLv == "1" {
  2151. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2152. }
  2153. if item.ChrgitmLv == "2" {
  2154. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2155. }
  2156. if item.ChrgitmLv == "3" {
  2157. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2158. }
  2159. }
  2160. if item.MedChrgitmType == "04" { //化验费
  2161. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2162. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2163. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2164. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2165. if item.ChrgitmLv == "1" {
  2166. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2167. }
  2168. if item.ChrgitmLv == "2" {
  2169. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2170. }
  2171. if item.ChrgitmLv == "3" {
  2172. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2173. }
  2174. }
  2175. if item.MedChrgitmType == "05" { //治疗费
  2176. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2177. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2178. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2179. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2180. if item.ChrgitmLv == "1" {
  2181. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2182. }
  2183. if item.ChrgitmLv == "2" {
  2184. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2185. }
  2186. if item.ChrgitmLv == "3" {
  2187. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2188. }
  2189. }
  2190. if item.MedChrgitmType == "06" { //手术费
  2191. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2192. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2193. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2194. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2195. if item.ChrgitmLv == "1" {
  2196. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2197. }
  2198. if item.ChrgitmLv == "2" {
  2199. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2200. }
  2201. if item.ChrgitmLv == "3" {
  2202. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2203. }
  2204. }
  2205. if item.MedChrgitmType == "08" { //材料费
  2206. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2207. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2208. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2209. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2210. if item.ChrgitmLv == "1" {
  2211. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2212. }
  2213. if item.ChrgitmLv == "2" {
  2214. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2215. }
  2216. if item.ChrgitmLv == "3" {
  2217. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2218. }
  2219. }
  2220. if item.MedChrgitmType == "09" { //西药费
  2221. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2222. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2223. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2224. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2225. if item.ChrgitmLv == "1" {
  2226. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2227. }
  2228. if item.ChrgitmLv == "2" {
  2229. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2230. }
  2231. if item.ChrgitmLv == "3" {
  2232. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2233. }
  2234. }
  2235. if item.MedChrgitmType == "11" { //中成费
  2236. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2237. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2238. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2239. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2240. if item.ChrgitmLv == "1" {
  2241. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2242. }
  2243. if item.ChrgitmLv == "2" {
  2244. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2245. }
  2246. if item.ChrgitmLv == "3" {
  2247. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2248. }
  2249. }
  2250. if item.MedChrgitmType == "14" { //其他费
  2251. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2252. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2253. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2254. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2255. if item.ChrgitmLv == "1" {
  2256. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2257. }
  2258. if item.ChrgitmLv == "2" {
  2259. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2260. }
  2261. if item.ChrgitmLv == "3" {
  2262. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2263. }
  2264. }
  2265. }
  2266. var iteminfoStructs []service.IteminfoStruct
  2267. if bedCostTotal != 0 {
  2268. iteminfo.MedChrgitm = "01"
  2269. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2270. iteminfo.Amt = bedCostTotal
  2271. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2272. iteminfo.ClabAmt = bed_clab_amt
  2273. iteminfo.OthAmt = bed_other_amt
  2274. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2275. }
  2276. if checkCostTotal != 0 {
  2277. iteminfo.MedChrgitm = "03"
  2278. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2279. iteminfo.Amt = checkCostTotal
  2280. iteminfo.ClaaSumfee = check_claa_sunmfee
  2281. iteminfo.ClabAmt = check_clab_amt
  2282. iteminfo.OthAmt = check_other_amt
  2283. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2284. }
  2285. if laboratoryCostTotal != 0 {
  2286. iteminfo.MedChrgitm = "04"
  2287. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2288. iteminfo.Amt = laboratoryCostTotal
  2289. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2290. iteminfo.ClabAmt = laboratory_clab_amt
  2291. iteminfo.OthAmt = laboratory_other_amt
  2292. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2293. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2294. }
  2295. if treatCostTotal != 0 {
  2296. iteminfo.MedChrgitm = "05"
  2297. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2298. iteminfo.Amt = treatCostTotal
  2299. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2300. iteminfo.ClabAmt = treat_clab_amt
  2301. iteminfo.OthAmt = treat_other_amt
  2302. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2303. //(struct4101.IteminfoStruct, iteminfo)
  2304. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2305. }
  2306. if operationCostTotal != 0 {
  2307. iteminfo.MedChrgitm = "06"
  2308. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2309. iteminfo.Amt = operationCostTotal
  2310. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2311. iteminfo.ClabAmt = operation_clab_amt
  2312. iteminfo.OthAmt = operation_other_amt
  2313. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2314. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2315. }
  2316. if materialCostTotal != 0 {
  2317. iteminfo.MedChrgitm = "08"
  2318. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2319. iteminfo.Amt = materialCostTotal
  2320. iteminfo.ClaaSumfee = material_claa_sunmfee
  2321. iteminfo.ClabAmt = material_clab_amt
  2322. iteminfo.OthAmt = material_other_amt
  2323. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2324. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2325. }
  2326. if westernMedicineCostTotal != 0 {
  2327. iteminfo.MedChrgitm = "09"
  2328. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2329. iteminfo.Amt = westernMedicineCostTotal
  2330. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2331. iteminfo.ClabAmt = westernMedicine_clab_amt
  2332. iteminfo.OthAmt = westernMedicine_other_amt
  2333. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2334. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2335. }
  2336. if chineseTraditionalMedicineCostTotal != 0 {
  2337. iteminfo.MedChrgitm = "11"
  2338. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2339. iteminfo.Amt = westernMedicineCostTotal
  2340. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2341. iteminfo.ClabAmt = westernMedicine_clab_amt
  2342. iteminfo.OthAmt = westernMedicine_other_amt
  2343. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2344. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2345. }
  2346. if otherCostTotal != 0 {
  2347. iteminfo.MedChrgitm = "14"
  2348. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2349. iteminfo.Amt = otherCostTotal
  2350. iteminfo.ClaaSumfee = other_claa_sunmfee
  2351. iteminfo.ClabAmt = other_clab_amt
  2352. iteminfo.OthAmt = other_other_amt
  2353. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2354. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2355. }
  2356. struct4101.IteminfoStruct = iteminfoStructs
  2357. struct4101.Ntly = "中国"
  2358. struct4101.AdmCaty = "A03.06"
  2359. var res ResultSeventeen
  2360. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2361. var resOther ResultSeventeenOther
  2362. var pp models.PublicParams
  2363. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2364. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2365. pp.FixmedinsName = miConfig.OrgName
  2366. pp.FixmedinsCode = miConfig.Code
  2367. pp.RequestUrl = miConfig.Url
  2368. pp.Cainfo = miConfig.Cainfo
  2369. pp.SecretKey = miConfig.SecretKey
  2370. pp.AccessKey = miConfig.AccessKey
  2371. pp.OpterName = curRoles.UserName
  2372. client := &http.Client{}
  2373. var req *http.Request
  2374. data := make(map[string]interface{})
  2375. data["struct4101"] = struct4101
  2376. data["pp"] = pp
  2377. bytesData, _ := json.Marshal(data)
  2378. if miConfig.MdtrtareaAdmvs == "320921" {
  2379. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2380. } else {
  2381. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2382. }
  2383. resp, _ := client.Do(req)
  2384. defer resp.Body.Close()
  2385. body, ioErr := ioutil.ReadAll(resp.Body)
  2386. if ioErr != nil {
  2387. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2389. return
  2390. }
  2391. var respJSON map[string]interface{}
  2392. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2393. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2395. return
  2396. }
  2397. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2398. userJSONBytes, _ := json.Marshal(respJSON)
  2399. fmt.Println("log")
  2400. fmt.Println(string(userJSONBytes))
  2401. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2402. utils.ErrorLog("解析失败:%v", err)
  2403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2404. return
  2405. }
  2406. res.InfRefmsgid = resOther.InfRefmsgid
  2407. res.Output = resOther.Output
  2408. res.ErrMsg = resOther.ErrMsg
  2409. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2410. res.Infcode = infocode
  2411. } else {
  2412. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2413. var dat map[string]interface{}
  2414. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2415. fmt.Println(dat)
  2416. } else {
  2417. fmt.Println(err)
  2418. }
  2419. userJSONBytes, _ := json.Marshal(dat)
  2420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2421. utils.ErrorLog("解析失败:%v", err)
  2422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2423. return
  2424. }
  2425. }
  2426. if res.Infcode != 0 {
  2427. c.ServeSuccessJSON(map[string]interface{}{
  2428. "failed_code": -10,
  2429. "msg": res.ErrMsg,
  2430. })
  2431. return
  2432. } else {
  2433. order.FaPiaoNumber = zero
  2434. order.FaPiaoCode = last_order.FaPiaoCode
  2435. service.UpdateOrder(order)
  2436. hisFundSettleListResult := &models.HisFundSettleListResult{
  2437. Number: res.Output.SetlListId,
  2438. Status: 1,
  2439. Ctime: time.Now().Unix(),
  2440. Mtime: time.Now().Unix(),
  2441. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2442. IsUpload: 1,
  2443. OrderId: order_id,
  2444. }
  2445. service.CreateUploadRecord(hisFundSettleListResult)
  2446. c.ServeSuccessJSON(map[string]interface{}{
  2447. "msg": "上传成功",
  2448. "result": hisFundSettleListResult,
  2449. })
  2450. return
  2451. }
  2452. }
  2453. func (c *HisApiController) GetSettleListHospital() {
  2454. order_id, _ := c.GetInt64("order_id")
  2455. admin_user_id, _ := c.GetInt64("admin_user_id")
  2456. order, _ := service.GetHisOrderByIDTwo(order_id)
  2457. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2458. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2459. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2460. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2461. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2462. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2463. if order.ID == 0 {
  2464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2465. return
  2466. }
  2467. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2468. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2469. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2470. fmt.Println(count)
  2471. var zero string
  2472. number := count + 1
  2473. if number >= 1000 {
  2474. zero = "0000" + strconv.FormatInt(number, 10)
  2475. } else if number >= 10000 {
  2476. zero = "000" + strconv.FormatInt(number, 10)
  2477. } else if number >= 100000 {
  2478. zero = "00" + strconv.FormatInt(number, 10)
  2479. } else if number >= 1000000 {
  2480. zero = "0" + strconv.FormatInt(number, 10)
  2481. } else {
  2482. zero = strconv.FormatInt(number, 10)
  2483. }
  2484. fmt.Println(zero)
  2485. struct4101 := service.Struct4101{
  2486. PsnNo: order.PsnNo,
  2487. MdtrtId: order.MdtrtId,
  2488. SetlId: order.SetlId,
  2489. PsnName: order.PsnName,
  2490. Gend: order.Gend,
  2491. Brdy: his.Brdy,
  2492. Age: int64(order.Age),
  2493. Naty: order.Naty,
  2494. PatnCertType: "01",
  2495. Certno: order.Certno,
  2496. Prfs: "90",
  2497. ConerName: roles[0].UserName,
  2498. PatnRlts: "99",
  2499. ConerAddr: miConfig.OrgName,
  2500. ConerTel: admin.Mobile,
  2501. HiType: order.Insutype,
  2502. Insuplc: miConfig.InsuplcAdmdvs,
  2503. MaindiagFlag: "1",
  2504. BillCode: last_order.FaPiaoCode,
  2505. BillNo: zero,
  2506. BizSn: order.Number,
  2507. PsnSelfPay: order.PsnPartAmt,
  2508. PsnOwnPay: order.PsnPartAmt,
  2509. AcctPay: order.AcctPay,
  2510. PsnCashpay: order.PsnCashPay,
  2511. HiPaymtd: "1",
  2512. Hsorg: miConfig.InsuplcAdmdvs,
  2513. HsorgOpter: miConfig.InsuplcAdmdvs,
  2514. MedinsFillPsn: curRoles.UserName,
  2515. MedinsFillDept: depart.Name,
  2516. IptMedType: "2",
  2517. AdmTime: his.InHosptialTime,
  2518. AdmEndTime: his.OutHosptialTime,
  2519. }
  2520. struct4101.SetlBegnDate = order.SetlTime
  2521. struct4101.SetlEndDate = order.SetlTime
  2522. var rf []CustomFundPay
  2523. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2524. var tempFunPays []service.CustomStruct
  2525. for _, item := range rf {
  2526. var tempFunPay service.CustomStruct
  2527. tempFunPay.FundPayamt = item.FundPayamt
  2528. tempFunPay.FundPayType = item.FundPayType
  2529. tempFunPays = append(tempFunPays, tempFunPay)
  2530. }
  2531. struct4101.CustomStruct = tempFunPays
  2532. var tempDiaginfos []service.DiaginfoStructTwo
  2533. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2534. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2535. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2536. var config []*models.HisXtDiagnoseConfig
  2537. for _, item := range diagnosis_ids {
  2538. id, _ := strconv.ParseInt(item, 10, 64)
  2539. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2540. config = append(config, &diagnosisConfig)
  2541. }
  2542. for index, item := range config {
  2543. if index == 0 {
  2544. var tempDiaginfo service.DiaginfoStructTwo
  2545. tempDiaginfo.DiagCode = item.CountryCode
  2546. tempDiaginfo.DiagName = item.CountryContentName
  2547. tempDiaginfo.DiagType = "1"
  2548. tempDiaginfo.MaindiagFlag = "1"
  2549. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2550. } else {
  2551. var tempDiaginfo service.DiaginfoStructTwo
  2552. tempDiaginfo.DiagCode = item.CountryCode
  2553. tempDiaginfo.DiagName = item.CountryContentName
  2554. tempDiaginfo.DiagType = "2"
  2555. tempDiaginfo.MaindiagFlag = "0"
  2556. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2557. }
  2558. }
  2559. struct4101.Diseinfo = tempDiaginfos
  2560. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2561. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2562. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2563. tempOpspdiseinfo2.OprnOprtCode = ""
  2564. tempOpspdiseinfo2.OprnOprtName = ""
  2565. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2566. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2567. var iteminfo service.IteminfoStruct
  2568. var bedCostTotal float64 = 0 //床位总费
  2569. var bedCostSelfTotal float64 = 0 //床位自费
  2570. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2571. var operationCostTotal float64 = 0 //手术费
  2572. var operationCostSelfTotal float64 = 0 //手术费
  2573. var operationCostPartSelfTotal float64 = 0 //手术费
  2574. var otherCostTotal float64 = 0 //其他费用
  2575. var otherCostSelfTotal float64 = 0 //其他费用
  2576. var otherCostPartSelfTotal float64 = 0 //其他费用
  2577. var materialCostTotal float64 = 0 //材料费
  2578. var materialCostSelfTotal float64 = 0 //材料费
  2579. var materialCostPartSelfTotal float64 = 0 //材料费
  2580. var westernMedicineCostTotal float64 = 0 //西药费
  2581. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2582. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2583. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2584. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2585. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2586. var checkCostTotal float64 = 0 //检查费
  2587. var checkCostSelfTotal float64 = 0 //检查费
  2588. var checkCostPartSelfTotal float64 = 0 //检查费
  2589. var laboratoryCostTotal float64 = 0 //化验费
  2590. var laboratoryCostSelfTotal float64 = 0 //化验费
  2591. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2592. var treatCostTotal float64 = 0 //治疗费用
  2593. var treatCostSelfTotal float64 = 0 //治疗费用
  2594. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2595. decimal.DivisionPrecision = 2
  2596. var bed_fulamt_ownpay_amt float64 = 0
  2597. var operation_fulamt_ownpay_amt float64 = 0
  2598. var other_fulamt_ownpay_amt float64 = 0
  2599. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2600. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2601. var check_fulamt_ownpay_amt float64 = 0
  2602. var material_fulamt_ownpay_amt float64 = 0
  2603. var laboratory_fulamt_ownpay_amt float64 = 0
  2604. var treat_fulamt_ownpay_amt float64 = 0
  2605. var bed_claa_sunmfee float64 = 0
  2606. var bed_clab_amt float64 = 0
  2607. var bed_other_amt float64 = 0
  2608. var operation_claa_sunmfee float64 = 0
  2609. var operation_clab_amt float64 = 0
  2610. var operation_other_amt float64 = 0
  2611. var other_claa_sunmfee float64 = 0
  2612. var other_clab_amt float64 = 0
  2613. var other_other_amt float64 = 0
  2614. var westernMedicine_claa_sunmfee float64 = 0
  2615. var westernMedicine_clab_amt float64 = 0
  2616. var westernMedicine_other_amt float64 = 0
  2617. var chineseTraditional_claa_sunmfee float64 = 0
  2618. var chineseTraditional_clab_amt float64 = 0
  2619. var chineseTraditional_other_amt float64 = 0
  2620. var check_claa_sunmfee float64 = 0
  2621. var check_clab_amt float64 = 0
  2622. var check_other_amt float64 = 0
  2623. var material_claa_sunmfee float64 = 0
  2624. var material_clab_amt float64 = 0
  2625. var material_other_amt float64 = 0
  2626. var laboratory_claa_sunmfee float64 = 0
  2627. var laboratory_clab_amt float64 = 0
  2628. var laboratory_other_amt float64 = 0
  2629. var treat_claa_sunmfee float64 = 0
  2630. var treat_clab_amt float64 = 0
  2631. var treat_other_amt float64 = 0
  2632. for _, item := range order.HisOrderInfo {
  2633. if item.MedChrgitmType == "01" { //床位费
  2634. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2635. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2636. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2637. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2638. if item.ChrgitmLv == "1" {
  2639. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2640. }
  2641. if item.ChrgitmLv == "2" {
  2642. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2643. }
  2644. if item.ChrgitmLv == "3" {
  2645. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2646. }
  2647. }
  2648. if item.MedChrgitmType == "03" { //检查费
  2649. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2650. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2651. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2652. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2653. if item.ChrgitmLv == "1" {
  2654. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2655. }
  2656. if item.ChrgitmLv == "2" {
  2657. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2658. }
  2659. if item.ChrgitmLv == "3" {
  2660. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2661. }
  2662. }
  2663. if item.MedChrgitmType == "04" { //化验费
  2664. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2665. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2666. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2667. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2668. if item.ChrgitmLv == "1" {
  2669. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2670. }
  2671. if item.ChrgitmLv == "2" {
  2672. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2673. }
  2674. if item.ChrgitmLv == "3" {
  2675. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2676. }
  2677. }
  2678. if item.MedChrgitmType == "05" { //治疗费
  2679. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2680. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2681. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2682. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2683. if item.ChrgitmLv == "1" {
  2684. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2685. }
  2686. if item.ChrgitmLv == "2" {
  2687. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2688. }
  2689. if item.ChrgitmLv == "3" {
  2690. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2691. }
  2692. }
  2693. if item.MedChrgitmType == "06" { //手术费
  2694. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2695. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2696. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2697. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2698. if item.ChrgitmLv == "1" {
  2699. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2700. }
  2701. if item.ChrgitmLv == "2" {
  2702. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2703. }
  2704. if item.ChrgitmLv == "3" {
  2705. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2706. }
  2707. }
  2708. if item.MedChrgitmType == "08" { //材料费
  2709. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2710. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2711. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2712. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2713. if item.ChrgitmLv == "1" {
  2714. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2715. }
  2716. if item.ChrgitmLv == "2" {
  2717. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2718. }
  2719. if item.ChrgitmLv == "3" {
  2720. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2721. }
  2722. }
  2723. if item.MedChrgitmType == "09" { //西药费
  2724. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2725. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2726. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2727. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2728. if item.ChrgitmLv == "1" {
  2729. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2730. }
  2731. if item.ChrgitmLv == "2" {
  2732. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2733. }
  2734. if item.ChrgitmLv == "3" {
  2735. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2736. }
  2737. }
  2738. if item.MedChrgitmType == "11" { //中成费
  2739. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2740. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2741. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2742. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2743. if item.ChrgitmLv == "1" {
  2744. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2745. }
  2746. if item.ChrgitmLv == "2" {
  2747. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2748. }
  2749. if item.ChrgitmLv == "3" {
  2750. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2751. }
  2752. }
  2753. if item.MedChrgitmType == "14" { //其他费
  2754. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2755. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2756. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2757. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2758. if item.ChrgitmLv == "1" {
  2759. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2760. }
  2761. if item.ChrgitmLv == "2" {
  2762. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2763. }
  2764. if item.ChrgitmLv == "3" {
  2765. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2766. }
  2767. }
  2768. }
  2769. var iteminfoStructs []service.IteminfoStruct
  2770. if bedCostTotal != 0 {
  2771. iteminfo.MedChrgitm = "01"
  2772. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2773. iteminfo.Amt = bedCostTotal
  2774. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2775. iteminfo.ClabAmt = bed_clab_amt
  2776. iteminfo.OthAmt = bed_other_amt
  2777. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2778. }
  2779. if checkCostTotal != 0 {
  2780. iteminfo.MedChrgitm = "03"
  2781. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2782. iteminfo.Amt = checkCostTotal
  2783. iteminfo.ClaaSumfee = check_claa_sunmfee
  2784. iteminfo.ClabAmt = check_clab_amt
  2785. iteminfo.OthAmt = check_other_amt
  2786. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2787. }
  2788. if laboratoryCostTotal != 0 {
  2789. iteminfo.MedChrgitm = "04"
  2790. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2791. iteminfo.Amt = laboratoryCostTotal
  2792. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2793. iteminfo.ClabAmt = laboratory_clab_amt
  2794. iteminfo.OthAmt = laboratory_other_amt
  2795. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2796. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2797. }
  2798. if treatCostTotal != 0 {
  2799. iteminfo.MedChrgitm = "05"
  2800. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2801. iteminfo.Amt = treatCostTotal
  2802. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2803. iteminfo.ClabAmt = treat_clab_amt
  2804. iteminfo.OthAmt = treat_other_amt
  2805. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2806. //(struct4101.IteminfoStruct, iteminfo)
  2807. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2808. }
  2809. if operationCostTotal != 0 {
  2810. iteminfo.MedChrgitm = "06"
  2811. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2812. iteminfo.Amt = operationCostTotal
  2813. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2814. iteminfo.ClabAmt = operation_clab_amt
  2815. iteminfo.OthAmt = operation_other_amt
  2816. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2817. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2818. }
  2819. if materialCostTotal != 0 {
  2820. iteminfo.MedChrgitm = "08"
  2821. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2822. iteminfo.Amt = materialCostTotal
  2823. iteminfo.ClaaSumfee = material_claa_sunmfee
  2824. iteminfo.ClabAmt = material_clab_amt
  2825. iteminfo.OthAmt = material_other_amt
  2826. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2827. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2828. }
  2829. if westernMedicineCostTotal != 0 {
  2830. iteminfo.MedChrgitm = "09"
  2831. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2832. iteminfo.Amt = westernMedicineCostTotal
  2833. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2834. iteminfo.ClabAmt = westernMedicine_clab_amt
  2835. iteminfo.OthAmt = westernMedicine_other_amt
  2836. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2837. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2838. }
  2839. if chineseTraditionalMedicineCostTotal != 0 {
  2840. iteminfo.MedChrgitm = "11"
  2841. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2842. iteminfo.Amt = westernMedicineCostTotal
  2843. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2844. iteminfo.ClabAmt = westernMedicine_clab_amt
  2845. iteminfo.OthAmt = westernMedicine_other_amt
  2846. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2847. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2848. }
  2849. if otherCostTotal != 0 {
  2850. iteminfo.MedChrgitm = "14"
  2851. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2852. iteminfo.Amt = otherCostTotal
  2853. iteminfo.ClaaSumfee = other_claa_sunmfee
  2854. iteminfo.ClabAmt = other_clab_amt
  2855. iteminfo.OthAmt = other_other_amt
  2856. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2857. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2858. }
  2859. struct4101.IteminfoStruct = iteminfoStructs
  2860. struct4101.Ntly = "中国"
  2861. struct4101.AdmCaty = "A03.06"
  2862. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2863. fmt.Println(result)
  2864. var dat map[string]interface{}
  2865. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2866. fmt.Println(dat)
  2867. } else {
  2868. fmt.Println(err)
  2869. }
  2870. userJSONBytes, _ := json.Marshal(dat)
  2871. var res ResultSeventeen
  2872. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2873. utils.ErrorLog("解析失败:%v", err)
  2874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2875. return
  2876. }
  2877. if res.Infcode != 0 {
  2878. c.ServeSuccessJSON(map[string]interface{}{
  2879. "failed_code": -10,
  2880. "msg": res.ErrMsg,
  2881. })
  2882. return
  2883. } else {
  2884. order.FaPiaoNumber = zero
  2885. order.FaPiaoCode = last_order.FaPiaoCode
  2886. service.UpdateOrder(order)
  2887. hisFundSettleListResult := &models.HisFundSettleListResult{
  2888. Number: res.Output.SetlListId,
  2889. Status: 1,
  2890. Ctime: time.Now().Unix(),
  2891. Mtime: time.Now().Unix(),
  2892. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2893. IsUpload: 1,
  2894. OrderId: order_id,
  2895. }
  2896. service.CreateUploadRecord(hisFundSettleListResult)
  2897. c.ServeSuccessJSON(map[string]interface{}{
  2898. "msg": "上传成功",
  2899. "result": hisFundSettleListResult,
  2900. })
  2901. return
  2902. }
  2903. }
  2904. func (c *HisApiController) GetBatchSettleList() {
  2905. orders, _ := service.GetAllHisOrder(10106)
  2906. for _, item := range orders {
  2907. order_id := item.ID
  2908. order, _ := service.GetHisOrderByIDTwo(order_id)
  2909. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2910. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2911. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2912. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2913. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2914. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2915. if order.ID == 0 {
  2916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2917. return
  2918. }
  2919. if his.BalanceAccountsType == 2 {
  2920. continue
  2921. }
  2922. struct4101 := service.Struct4101{
  2923. PsnNo: order.PsnNo,
  2924. MdtrtId: order.MdtrtId,
  2925. SetlId: order.SetlId,
  2926. PsnName: order.PsnName,
  2927. Gend: order.Gend,
  2928. Brdy: his.Brdy,
  2929. Age: his.Age,
  2930. Naty: order.Naty,
  2931. PatnCertType: "01",
  2932. Certno: order.Certno,
  2933. Prfs: "90",
  2934. ConerName: roles[0].UserName,
  2935. PatnRlts: "99",
  2936. ConerAddr: miConfig.OrgName,
  2937. ConerTel: admin.Mobile,
  2938. HiType: order.Insutype,
  2939. Insuplc: his.InsuplcAdmdvs,
  2940. MaindiagFlag: "1",
  2941. BillCode: order.FaPiaoCode,
  2942. BillNo: order.FaPiaoNumber,
  2943. BizSn: order.Number,
  2944. PsnSelfPay: order.PsnPartAmt,
  2945. PsnOwnPay: order.PsnPartAmt,
  2946. AcctPay: order.AcctPay,
  2947. PsnCashpay: order.PsnCashPay,
  2948. HiPaymtd: "1",
  2949. Hsorg: his.InsuplcAdmdvs,
  2950. HsorgOpter: his.InsuplcAdmdvs,
  2951. MedinsFillPsn: curRoles.UserName,
  2952. MedinsFillDept: depart.Name,
  2953. IptMedType: "2",
  2954. }
  2955. struct4101.SetlBegnDate = order.SetlTime
  2956. struct4101.SetlEndDate = order.SetlTime
  2957. //if order.SettleType == 1 {
  2958. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2959. // dateStr := t.Format("2006-01-02")
  2960. // struct4101.SetlBegnDate = dateStr
  2961. // struct4101.SetlEndDate = dateStr
  2962. //} else {
  2963. // t := time.Unix(int64(order.SettleStartTime), 0)
  2964. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2965. // dateStartStr := t.Format("2006-01-02")
  2966. // dateEndStr := t2.Format("2006-01-02")
  2967. // struct4101.SetlBegnDate = dateStartStr
  2968. // struct4101.SetlEndDate = dateEndStr
  2969. //}
  2970. var rf []CustomFundPay
  2971. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2972. var tempFunPays []service.CustomStruct
  2973. var tempFunPay610100 service.CustomStruct
  2974. for _, item := range rf {
  2975. if item.FundPayType == "610100" {
  2976. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2977. tempFunPay610100.FundPayType = item.FundPayType
  2978. } else {
  2979. var tempFunPay service.CustomStruct
  2980. tempFunPay.FundPayamt = item.FundPayamt
  2981. tempFunPay.FundPayType = item.FundPayType
  2982. tempFunPays = append(tempFunPays, tempFunPay)
  2983. }
  2984. }
  2985. tempFunPays = append(tempFunPays, tempFunPay610100)
  2986. struct4101.CustomStruct = tempFunPays
  2987. var tempDiaginfos []service.DiaginfoStructTwo
  2988. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2989. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2990. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2991. var config []*models.HisXtDiagnoseConfig
  2992. for _, item := range diagnosis_ids {
  2993. id, _ := strconv.ParseInt(item, 10, 64)
  2994. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2995. config = append(config, &diagnosisConfig)
  2996. }
  2997. for index, item := range config {
  2998. if index == 0 {
  2999. var tempDiaginfo service.DiaginfoStructTwo
  3000. tempDiaginfo.DiagCode = item.CountryCode
  3001. tempDiaginfo.DiagName = item.CountryContentName
  3002. tempDiaginfo.DiagType = "1"
  3003. tempDiaginfo.MaindiagFlag = "1"
  3004. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3005. } else {
  3006. var tempDiaginfo service.DiaginfoStructTwo
  3007. tempDiaginfo.DiagCode = item.CountryCode
  3008. tempDiaginfo.DiagName = item.CountryContentName
  3009. tempDiaginfo.DiagType = "2"
  3010. tempDiaginfo.MaindiagFlag = "0"
  3011. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3012. }
  3013. }
  3014. struct4101.Diseinfo = tempDiaginfos
  3015. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3016. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3017. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3018. tempOpspdiseinfo2.OprnOprtCode = ""
  3019. tempOpspdiseinfo2.OprnOprtName = ""
  3020. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3021. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3022. var iteminfo service.IteminfoStruct
  3023. var bedCostTotal float64 = 0 //床位总费
  3024. var bedCostSelfTotal float64 = 0 //床位自费
  3025. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3026. var examineCostTotal float64 = 0 //诊查总费
  3027. var examineCostSelfTotal float64 = 0 //诊查自费
  3028. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  3029. var nursingCostTotal float64 = 0 //护理总费
  3030. var nursingCostSelfTotal float64 = 0 //护理自费
  3031. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  3032. var chineseMedicineCostTotal float64 = 0 //中成药
  3033. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  3034. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  3035. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  3036. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  3037. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  3038. var registerCostTotal float64 = 0 //一般诊疗费
  3039. var registerCostSelfTotal float64 = 0 //一般诊疗费
  3040. var registerPartSelfTotal float64 = 0 //一般诊疗费
  3041. var operationCostTotal float64 = 0 //手术费
  3042. var operationCostSelfTotal float64 = 0 //手术费
  3043. var operationCostPartSelfTotal float64 = 0 //手术费
  3044. var otherCostTotal float64 = 0 //其他费用
  3045. var otherCostSelfTotal float64 = 0 //其他费用
  3046. var otherCostPartSelfTotal float64 = 0 //其他费用
  3047. var materialCostTotal float64 = 0 //材料费
  3048. var materialCostSelfTotal float64 = 0 //材料费
  3049. var materialCostPartSelfTotal float64 = 0 //材料费
  3050. var westernMedicineCostTotal float64 = 0 //西药费
  3051. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3052. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3053. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3054. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3055. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3056. var checkCostTotal float64 = 0 //检查费
  3057. var checkCostSelfTotal float64 = 0 //检查费
  3058. var checkCostPartSelfTotal float64 = 0 //检查费
  3059. var laboratoryCostTotal float64 = 0 //化验费
  3060. var laboratoryCostSelfTotal float64 = 0 //化验费
  3061. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3062. var treatCostTotal float64 = 0 //治疗费用
  3063. var treatCostSelfTotal float64 = 0 //治疗费用
  3064. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3065. decimal.DivisionPrecision = 2
  3066. var bed_fulamt_ownpay_amt float64 = 0
  3067. var examine_fulamt_ownpay_amt float64 = 0
  3068. var nursing_fulamt_ownpay_amt float64 = 0
  3069. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  3070. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  3071. var register_fulamt_ownpay_amt float64 = 0
  3072. var operation_fulamt_ownpay_amt float64 = 0
  3073. var other_fulamt_ownpay_amt float64 = 0
  3074. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3075. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3076. var check_fulamt_ownpay_amt float64 = 0
  3077. var material_fulamt_ownpay_amt float64 = 0
  3078. var laboratory_fulamt_ownpay_amt float64 = 0
  3079. var treat_fulamt_ownpay_amt float64 = 0
  3080. var bed_claa_sunmfee float64 = 0
  3081. var bed_clab_amt float64 = 0
  3082. var bed_other_amt float64 = 0
  3083. var examine_claa_sunmfee float64 = 0
  3084. var examine_clab_amt float64 = 0
  3085. var examine_other_amt float64 = 0
  3086. var nursing_claa_sunmfee float64 = 0
  3087. var nursing_clab_amt float64 = 0
  3088. var nursing_other_amt float64 = 0
  3089. var chinese_medicine_claa_sunmfee float64 = 0
  3090. var chinese_medicine_clab_amt float64 = 0
  3091. var chinese_medicine_other_amt float64 = 0
  3092. var commonly_treatment_claa_sunmfee float64 = 0
  3093. var commonly_treatment_clab_amt float64 = 0
  3094. var commonly_treatment_other_amt float64 = 0
  3095. var operation_claa_sunmfee float64 = 0
  3096. var operation_clab_amt float64 = 0
  3097. var operation_other_amt float64 = 0
  3098. var other_claa_sunmfee float64 = 0
  3099. var other_clab_amt float64 = 0
  3100. var other_other_amt float64 = 0
  3101. var westernMedicine_claa_sunmfee float64 = 0
  3102. var westernMedicine_clab_amt float64 = 0
  3103. var westernMedicine_other_amt float64 = 0
  3104. var chineseTraditional_claa_sunmfee float64 = 0
  3105. var chineseTraditional_clab_amt float64 = 0
  3106. var chineseTraditional_other_amt float64 = 0
  3107. var check_claa_sunmfee float64 = 0
  3108. var check_clab_amt float64 = 0
  3109. var check_other_amt float64 = 0
  3110. var material_claa_sunmfee float64 = 0
  3111. var material_clab_amt float64 = 0
  3112. var material_other_amt float64 = 0
  3113. var laboratory_claa_sunmfee float64 = 0
  3114. var laboratory_clab_amt float64 = 0
  3115. var laboratory_other_amt float64 = 0
  3116. var treat_claa_sunmfee float64 = 0
  3117. var treat_clab_amt float64 = 0
  3118. var treat_other_amt float64 = 0
  3119. var register_claa_sunmfee float64 = 0
  3120. var register_clab_amt float64 = 0
  3121. var register_other_amt float64 = 0
  3122. for _, item := range order.HisOrderInfo {
  3123. if item.MedChrgitmType == "01" { //床位费
  3124. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3125. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3126. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3127. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3128. if item.ChrgitmLv == "1" {
  3129. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3130. }
  3131. if item.ChrgitmLv == "2" {
  3132. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3133. }
  3134. if item.ChrgitmLv == "3" {
  3135. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3136. }
  3137. }
  3138. if item.MedChrgitmType == "02" { //诊查
  3139. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3140. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3141. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3142. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3143. if item.ChrgitmLv == "1" {
  3144. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3145. }
  3146. if item.ChrgitmLv == "2" {
  3147. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3148. }
  3149. if item.ChrgitmLv == "3" {
  3150. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3151. }
  3152. }
  3153. if item.MedChrgitmType == "03" { //检查费
  3154. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3155. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3156. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3157. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3158. if item.ChrgitmLv == "1" {
  3159. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3160. }
  3161. if item.ChrgitmLv == "2" {
  3162. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3163. }
  3164. if item.ChrgitmLv == "3" {
  3165. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3166. }
  3167. }
  3168. if item.MedChrgitmType == "04" { //化验费
  3169. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3170. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3171. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3172. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3173. if item.ChrgitmLv == "1" {
  3174. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3175. }
  3176. if item.ChrgitmLv == "2" {
  3177. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3178. }
  3179. if item.ChrgitmLv == "3" {
  3180. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3181. }
  3182. }
  3183. if item.MedChrgitmType == "05" { //治疗费
  3184. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3185. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3186. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3187. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3188. if item.ChrgitmLv == "1" {
  3189. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3190. }
  3191. if item.ChrgitmLv == "2" {
  3192. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3193. }
  3194. if item.ChrgitmLv == "3" {
  3195. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3196. }
  3197. }
  3198. if item.MedChrgitmType == "06" { //手术费
  3199. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3200. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3201. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3202. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3203. if item.ChrgitmLv == "1" {
  3204. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3205. }
  3206. if item.ChrgitmLv == "2" {
  3207. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3208. }
  3209. if item.ChrgitmLv == "3" {
  3210. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3211. }
  3212. }
  3213. if item.MedChrgitmType == "07" { //手术费
  3214. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3215. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3216. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3217. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3218. if item.ChrgitmLv == "1" {
  3219. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3220. }
  3221. if item.ChrgitmLv == "2" {
  3222. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3223. }
  3224. if item.ChrgitmLv == "3" {
  3225. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3226. }
  3227. }
  3228. if item.MedChrgitmType == "08" { //材料费
  3229. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3230. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3231. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3232. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3233. if item.ChrgitmLv == "1" {
  3234. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3235. }
  3236. if item.ChrgitmLv == "2" {
  3237. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3238. }
  3239. if item.ChrgitmLv == "3" {
  3240. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3241. }
  3242. }
  3243. if item.MedChrgitmType == "09" { //西药费
  3244. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3245. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3246. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3247. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3248. if item.ChrgitmLv == "1" {
  3249. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3250. }
  3251. if item.ChrgitmLv == "2" {
  3252. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3253. }
  3254. if item.ChrgitmLv == "3" {
  3255. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3256. }
  3257. }
  3258. if item.MedChrgitmType == "10" { //中药饮片
  3259. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3260. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3261. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3262. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3263. if item.ChrgitmLv == "1" {
  3264. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3265. }
  3266. if item.ChrgitmLv == "2" {
  3267. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3268. }
  3269. if item.ChrgitmLv == "3" {
  3270. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3271. }
  3272. }
  3273. if item.MedChrgitmType == "11" { //中成费
  3274. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3275. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3276. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3277. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3278. if item.ChrgitmLv == "1" {
  3279. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3280. }
  3281. if item.ChrgitmLv == "2" {
  3282. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3283. }
  3284. if item.ChrgitmLv == "3" {
  3285. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3286. }
  3287. }
  3288. if item.MedChrgitmType == "12" { //中成费
  3289. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3290. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3291. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3292. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3293. if item.ChrgitmLv == "1" {
  3294. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3295. }
  3296. if item.ChrgitmLv == "2" {
  3297. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3298. }
  3299. if item.ChrgitmLv == "3" {
  3300. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3301. }
  3302. }
  3303. if item.MedChrgitmType == "13" { //中成费
  3304. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3305. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3306. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3307. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3308. if item.ChrgitmLv == "1" {
  3309. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3310. }
  3311. if item.ChrgitmLv == "2" {
  3312. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3313. }
  3314. if item.ChrgitmLv == "3" {
  3315. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3316. }
  3317. }
  3318. if item.MedChrgitmType == "14" { //其他费
  3319. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3320. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3321. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3322. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3323. if item.ChrgitmLv == "1" {
  3324. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3325. }
  3326. if item.ChrgitmLv == "2" {
  3327. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3328. }
  3329. if item.ChrgitmLv == "3" {
  3330. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3331. }
  3332. }
  3333. }
  3334. var iteminfoStructs []service.IteminfoStruct
  3335. if bedCostTotal != 0 {
  3336. iteminfo.MedChrgitm = "01"
  3337. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3338. iteminfo.Amt = bedCostTotal
  3339. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3340. iteminfo.ClabAmt = bed_clab_amt
  3341. iteminfo.OthAmt = bed_other_amt
  3342. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3343. }
  3344. if examineCostTotal != 0 {
  3345. iteminfo.MedChrgitm = "02"
  3346. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3347. iteminfo.Amt = examineCostTotal
  3348. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3349. iteminfo.ClabAmt = examine_clab_amt
  3350. iteminfo.OthAmt = examine_other_amt
  3351. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3352. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3353. }
  3354. if checkCostTotal != 0 {
  3355. iteminfo.MedChrgitm = "03"
  3356. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3357. iteminfo.Amt = checkCostTotal
  3358. iteminfo.ClaaSumfee = check_claa_sunmfee
  3359. iteminfo.ClabAmt = check_clab_amt
  3360. iteminfo.OthAmt = check_other_amt
  3361. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3362. }
  3363. if laboratoryCostTotal != 0 {
  3364. iteminfo.MedChrgitm = "04"
  3365. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3366. iteminfo.Amt = laboratoryCostTotal
  3367. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3368. iteminfo.ClabAmt = laboratory_clab_amt
  3369. iteminfo.OthAmt = laboratory_other_amt
  3370. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3371. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3372. }
  3373. if treatCostTotal != 0 {
  3374. iteminfo.MedChrgitm = "05"
  3375. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3376. iteminfo.Amt = treatCostTotal
  3377. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3378. iteminfo.ClabAmt = treat_clab_amt
  3379. iteminfo.OthAmt = treat_other_amt
  3380. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3381. //(struct4101.IteminfoStruct, iteminfo)
  3382. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3383. }
  3384. if operationCostTotal != 0 {
  3385. iteminfo.MedChrgitm = "06"
  3386. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3387. iteminfo.Amt = operationCostTotal
  3388. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3389. iteminfo.ClabAmt = operation_clab_amt
  3390. iteminfo.OthAmt = operation_other_amt
  3391. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3392. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3393. }
  3394. if nursingCostTotal != 0 {
  3395. iteminfo.MedChrgitm = "07"
  3396. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3397. iteminfo.Amt = nursingCostTotal
  3398. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3399. iteminfo.ClabAmt = nursing_clab_amt
  3400. iteminfo.OthAmt = nursing_other_amt
  3401. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3402. }
  3403. if materialCostTotal != 0 {
  3404. iteminfo.MedChrgitm = "08"
  3405. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3406. iteminfo.Amt = materialCostTotal
  3407. iteminfo.ClaaSumfee = material_claa_sunmfee
  3408. iteminfo.ClabAmt = material_clab_amt
  3409. iteminfo.OthAmt = material_other_amt
  3410. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3411. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3412. }
  3413. if westernMedicineCostTotal != 0 {
  3414. iteminfo.MedChrgitm = "09"
  3415. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3416. iteminfo.Amt = westernMedicineCostTotal
  3417. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3418. iteminfo.ClabAmt = westernMedicine_clab_amt
  3419. iteminfo.OthAmt = westernMedicine_other_amt
  3420. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3421. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3422. }
  3423. if chineseMedicineCostTotal != 0 {
  3424. iteminfo.MedChrgitm = "10"
  3425. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3426. iteminfo.Amt = chineseMedicineCostTotal
  3427. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3428. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3429. iteminfo.OthAmt = chinese_medicine_other_amt
  3430. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3431. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3432. }
  3433. if chineseTraditionalMedicineCostTotal != 0 {
  3434. iteminfo.MedChrgitm = "11"
  3435. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3436. iteminfo.Amt = westernMedicineCostTotal
  3437. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3438. iteminfo.ClabAmt = westernMedicine_clab_amt
  3439. iteminfo.OthAmt = westernMedicine_other_amt
  3440. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3441. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3442. }
  3443. if commonlyTreatmentCostTotal != 0 {
  3444. iteminfo.MedChrgitm = "12"
  3445. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3446. iteminfo.Amt = commonlyTreatmentCostTotal
  3447. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3448. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3449. iteminfo.OthAmt = commonly_treatment_other_amt
  3450. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3451. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3452. }
  3453. if registerCostTotal != 0 {
  3454. iteminfo.MedChrgitm = "13"
  3455. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3456. iteminfo.Amt = registerCostTotal
  3457. iteminfo.ClaaSumfee = register_claa_sunmfee
  3458. iteminfo.ClabAmt = register_clab_amt
  3459. iteminfo.OthAmt = register_other_amt
  3460. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3461. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3462. }
  3463. if otherCostTotal != 0 {
  3464. iteminfo.MedChrgitm = "14"
  3465. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3466. iteminfo.Amt = otherCostTotal
  3467. iteminfo.ClaaSumfee = other_claa_sunmfee
  3468. iteminfo.ClabAmt = other_clab_amt
  3469. iteminfo.OthAmt = other_other_amt
  3470. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3471. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3472. }
  3473. struct4101.IteminfoStruct = iteminfoStructs
  3474. struct4101.Ntly = "中国"
  3475. struct4101.AdmCaty = "A03.06"
  3476. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3477. fmt.Println(result)
  3478. var dat map[string]interface{}
  3479. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3480. fmt.Println(dat)
  3481. } else {
  3482. fmt.Println(err)
  3483. }
  3484. userJSONBytes, _ := json.Marshal(dat)
  3485. var res ResultSeventeen
  3486. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3487. utils.ErrorLog("解析失败:%v", err)
  3488. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3489. adminUser := c.GetAdminUserInfo()
  3490. errlog := &models.HisOrderError{
  3491. UserOrgId: adminUser.CurrentOrgId,
  3492. Ctime: time.Now().Unix(),
  3493. Mtime: time.Now().Unix(),
  3494. ErrMsg: res.ErrMsg + "解析失败",
  3495. Status: 1,
  3496. PatientId: order_id,
  3497. Stage: 10106,
  3498. }
  3499. service.CreateErrMsgLog(errlog)
  3500. continue
  3501. }
  3502. if res.Infcode != 0 {
  3503. adminUser := c.GetAdminUserInfo()
  3504. errlog := &models.HisOrderError{
  3505. UserOrgId: adminUser.CurrentOrgId,
  3506. Ctime: time.Now().Unix(),
  3507. Mtime: time.Now().Unix(),
  3508. ErrMsg: res.ErrMsg,
  3509. Status: 1,
  3510. PatientId: order_id,
  3511. Stage: 10106,
  3512. }
  3513. service.CreateErrMsgLog(errlog)
  3514. continue
  3515. } else {
  3516. hisFundSettleListResult := &models.HisFundSettleListResult{
  3517. Number: res.Output.SetlListId,
  3518. Status: 1,
  3519. Ctime: time.Now().Unix(),
  3520. Mtime: time.Now().Unix(),
  3521. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3522. IsUpload: 1,
  3523. OrderId: order_id,
  3524. }
  3525. service.CreateUploadRecord(hisFundSettleListResult)
  3526. continue
  3527. }
  3528. }
  3529. }
  3530. func (c *HisApiController) GetOrgInfo() {
  3531. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3532. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3533. }
  3534. func (c *HisApiController) GetHisPatientInfo() {
  3535. medical_insurance_card := c.GetString("medical_insurance_card")
  3536. id_card_type, _ := c.GetInt64("id_card_type")
  3537. id_card := c.GetString("id_card")
  3538. adminInfo := c.GetAdminUserInfo()
  3539. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3540. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3541. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3542. IdCardNo := ""
  3543. if id_card_type == 1 {
  3544. IdCardNo = medical_insurance_card
  3545. } else if id_card_type == 2 {
  3546. IdCardNo = id_card
  3547. }
  3548. if config.IsOpen == 1 {
  3549. 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
  3550. resp, requestErr := http.Get(api)
  3551. if requestErr != nil {
  3552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3553. return
  3554. }
  3555. defer resp.Body.Close()
  3556. body, ioErr := ioutil.ReadAll(resp.Body)
  3557. if ioErr != nil {
  3558. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3560. return
  3561. }
  3562. var respJSON map[string]interface{}
  3563. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3564. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3566. return
  3567. }
  3568. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3569. userJSONBytes, _ := json.Marshal(userJSON)
  3570. var res ResultTwo
  3571. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3572. utils.ErrorLog("解析失败:%v", err)
  3573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3574. return
  3575. }
  3576. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3577. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3578. infoStr := string(Iinfos)
  3579. idetinfoStr := string(Idetinfos)
  3580. if res.Infcode == 0 {
  3581. his := models.VMHisPatient{
  3582. Status: 1,
  3583. Ctime: time.Now().Unix(),
  3584. Mtime: time.Now().Unix(),
  3585. PsnNo: res.Output.Baseinfo.PsnNo,
  3586. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3587. Certno: res.Output.Baseinfo.Certno,
  3588. PsnName: res.Output.Baseinfo.PsnName,
  3589. Gend: res.Output.Baseinfo.Gend,
  3590. Naty: res.Output.Baseinfo.Naty,
  3591. Brdy: res.Output.Baseinfo.Brdy,
  3592. Age: res.Output.Baseinfo.Age,
  3593. Iinfo: infoStr,
  3594. Idetinfo: idetinfoStr,
  3595. UserOrgId: adminInfo.CurrentOrgId,
  3596. IsReturn: 1,
  3597. IdCardType: id_card_type,
  3598. }
  3599. c.ServeSuccessJSON(map[string]interface{}{
  3600. "info": his,
  3601. })
  3602. } else {
  3603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3604. return
  3605. }
  3606. }
  3607. }
  3608. //func GetBasBaseInfo() (jsonStr string, err error) {
  3609. //
  3610. // handle := syscall.NewLazyDLL("SSCard.dll")
  3611. // add := handle.NewProc("ReadCardBas")
  3612. // str := make([]byte, 1024)
  3613. // str1 := make([]byte, 1024)
  3614. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3615. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3616. //
  3617. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3618. //
  3619. // fmt.Println("> Add(4,5)的结果为:", ret)
  3620. // handle.Release()
  3621. //
  3622. // return "", nil
  3623. //
  3624. //}
  3625. //func GetQRBaseInfo() (jsonStr string, err error) {
  3626. // handle := syscall.LoadDLL("SSCard.dll")
  3627. // ReadCardBas := handle.FindProc("GetQRBase")
  3628. //
  3629. // str := make([]byte, 256)
  3630. // str1 := make([]byte, 256)
  3631. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3632. //
  3633. // fmt.Println(string(str))
  3634. // fmt.Println(r)
  3635. // return string(str), nil
  3636. //}
  3637. //func CardInit() int {
  3638. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3639. // add := DllTestDef.MustFindProc("Init")
  3640. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3641. // if err != nil {
  3642. // fmt.Println("SSCard的运算结果为:", ret)
  3643. // }
  3644. // result := int(ret)
  3645. // return result
  3646. //}
  3647. //func CardInit() int {
  3648. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3649. // if err != nil {
  3650. // fmt.Println("SSCard的运算结果为:", ret)
  3651. // }
  3652. // fmt.Println(err)
  3653. // result := int(ret)
  3654. // return result
  3655. //}
  3656. func IntPtr(n int) uintptr {
  3657. return uintptr(n)
  3658. }
  3659. func StrPtr(s string) uintptr {
  3660. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3661. }
  3662. type Result2001 struct {
  3663. Cainfo interface{} `json:"cainfo"`
  3664. ErrMsg string `json:"err_msg"`
  3665. InfRefmsgid string `json:"inf_refmsgid"`
  3666. Infcode int64 `json:"infcode"`
  3667. Output struct {
  3668. Trtinfo struct {
  3669. PsnNo string `json:"psn_no"`
  3670. TrtChkType string `json:"trt_chk_type"`
  3671. FundPayType string `json:"fund_pay_type"`
  3672. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3673. Begndate string `json:"begndate"`
  3674. Enddate string `json:"enddate"`
  3675. TrtChkRslt string `json:"trt_chk_rslt"`
  3676. } `json:"trtinfo"`
  3677. } `json:"output"`
  3678. RefmsgTime string `json:"refmsg_time"`
  3679. RespondTime string `json:"respond_time"`
  3680. Signtype interface{} `json:"signtype"`
  3681. WarnMsg interface{} `json:"warn_msg"`
  3682. }
  3683. type Result2001Org10265 struct {
  3684. Cainfo interface{} `json:"cainfo"`
  3685. ErrMsg string `json:"err_msg"`
  3686. InfRefmsgid string `json:"inf_refmsgid"`
  3687. Infcode string `json:"infcode"`
  3688. Output struct {
  3689. Trtinfo struct {
  3690. PsnNo string `json:"psn_no"`
  3691. TrtChkType string `json:"trt_chk_type"`
  3692. FundPayType string `json:"fund_pay_type"`
  3693. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3694. Begndate string `json:"begndate"`
  3695. Enddate string `json:"enddate"`
  3696. TrtChkRslt string `json:"trt_chk_rslt"`
  3697. } `json:"trtinfo"`
  3698. } `json:"output"`
  3699. RefmsgTime string `json:"refmsg_time"`
  3700. RespondTime string `json:"respond_time"`
  3701. Signtype interface{} `json:"signtype"`
  3702. WarnMsg interface{} `json:"warn_msg"`
  3703. }
  3704. type ResultTwo struct {
  3705. ErrMsg string `json:"err_msg"`
  3706. InfRefmsgid string `json:"inf_refmsgid"`
  3707. Infcode int64 `json:"infcode"`
  3708. Output struct {
  3709. Baseinfo struct {
  3710. Age float64 `json:"age"`
  3711. Brdy string `json:"brdy"`
  3712. Certno string `json:"certno"`
  3713. Gend string `json:"gend"`
  3714. Naty string `json:"naty"`
  3715. PsnCertType string `json:"psn_cert_type"`
  3716. PsnName string `json:"psn_name"`
  3717. PsnNo string `json:"psn_no"`
  3718. } `json:"baseinfo"`
  3719. Idetinfo []interface{} `json:"idetinfo"`
  3720. Iinfo []struct {
  3721. Balc float64 `json:"balc"`
  3722. CvlservFlag string `json:"cvlserv_flag"`
  3723. EmpName string `json:"emp_name"`
  3724. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3725. Insutype string `json:"insutype"`
  3726. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3727. PausInsuDate string `json:"paus_insu_date"`
  3728. PsnInsuDate string `json:"psn_insu_date"`
  3729. PsnInsuStas string `json:"psn_insu_stas"`
  3730. PsnType string `json:"psn_type"`
  3731. } `json:"insuinfo"`
  3732. } `json:"output"`
  3733. RefmsgTime string `json:"refmsg_time"`
  3734. RespondTime string `json:"respond_time"`
  3735. Signtype interface{} `json:"signtype"`
  3736. WarnInfo interface{} `json:"warn_info"`
  3737. }
  3738. type ResultTwo10265 struct {
  3739. ErrMsg string `json:"err_msg"`
  3740. InfRefmsgid string `json:"inf_refmsgid"`
  3741. Infcode string `json:"infcode"`
  3742. Output struct {
  3743. Baseinfo struct {
  3744. Age float64 `json:"age"`
  3745. Brdy string `json:"brdy"`
  3746. Certno string `json:"certno"`
  3747. Gend string `json:"gend"`
  3748. Naty string `json:"naty"`
  3749. PsnCertType string `json:"psn_cert_type"`
  3750. PsnName string `json:"psn_name"`
  3751. PsnNo string `json:"psn_no"`
  3752. } `json:"baseinfo"`
  3753. Idetinfo []interface{} `json:"idetinfo"`
  3754. Iinfo []struct {
  3755. Balc float64 `json:"balc"`
  3756. CvlservFlag string `json:"cvlserv_flag"`
  3757. EmpName string `json:"emp_name"`
  3758. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3759. Insutype string `json:"insutype"`
  3760. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3761. PausInsuDate string `json:"paus_insu_date"`
  3762. PsnInsuDate string `json:"psn_insu_date"`
  3763. PsnInsuStas string `json:"psn_insu_stas"`
  3764. PsnType string `json:"psn_type"`
  3765. } `json:"insuinfo"`
  3766. } `json:"output"`
  3767. RefmsgTime string `json:"refmsg_time"`
  3768. RespondTime string `json:"respond_time"`
  3769. Signtype interface{} `json:"signtype"`
  3770. WarnInfo interface{} `json:"warn_info"`
  3771. }
  3772. type ResultThree struct {
  3773. Cainfo interface{} `json:"cainfo"`
  3774. ErrMsg string `json:"err_msg"`
  3775. InfRefmsgid string `json:"inf_refmsgid"`
  3776. Infcode int64 `json:"infcode"`
  3777. Output struct {
  3778. Data struct {
  3779. IptOtpNo string `json:"ipt_otp_no"`
  3780. MdtrtID string `json:"mdtrt_id"`
  3781. PsnNo string `json:"psn_no"`
  3782. } `json:"data"`
  3783. } `json:"output"`
  3784. RefmsgTime string `json:"refmsg_time"`
  3785. RespondTime string `json:"respond_time"`
  3786. Signtype interface{} `json:"signtype"`
  3787. WarnMsg interface{} `json:"warn_msg"`
  3788. }
  3789. type ResultThree10265 struct {
  3790. Cainfo interface{} `json:"cainfo"`
  3791. ErrMsg string `json:"err_msg"`
  3792. InfRefmsgid string `json:"inf_refmsgid"`
  3793. Infcode string `json:"infcode"`
  3794. Output struct {
  3795. Data struct {
  3796. IptOtpNo string `json:"ipt_otp_no"`
  3797. MdtrtID string `json:"mdtrt_id"`
  3798. PsnNo string `json:"psn_no"`
  3799. } `json:"data"`
  3800. } `json:"output"`
  3801. RefmsgTime string `json:"refmsg_time"`
  3802. RespondTime string `json:"respond_time"`
  3803. Signtype interface{} `json:"signtype"`
  3804. WarnMsg interface{} `json:"warn_msg"`
  3805. }
  3806. type ResultFour struct {
  3807. Cainfo string `json:"cainfo"`
  3808. ErrMsg string `json:"err_msg"`
  3809. InfRefmsgid string `json:"inf_refmsgid"`
  3810. Infcode int64 `json:"infcode"`
  3811. Output struct {
  3812. Result []struct {
  3813. BasMednFlag string `json:"bas_medn_flag"`
  3814. ChldMedcFlag string `json:"chld_medc_flag"`
  3815. ChrgitmLv string `json:"chrgitm_lv"`
  3816. Cnt float64 `json:"cnt"`
  3817. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3818. DrtReimFlag string `json:"drt_reim_flag"`
  3819. FeedetlSn string `json:"feedetl_sn"`
  3820. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3821. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3822. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3823. ListSpItemFlag string `json:"list_sp_item_flag"`
  3824. LmtUsedFlag string `json:"lmt_used_flag"`
  3825. MedChrgitmType string `json:"med_chrgitm_type"`
  3826. Memo string `json:"memo"`
  3827. OverlmtAmt float64 `json:"overlmt_amt"`
  3828. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3829. Pric float64 `json:"pric"`
  3830. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3831. SelfpayProp float64 `json:"selfpay_prop"`
  3832. } `json:"result"`
  3833. } `json:"output"`
  3834. RefmsgTime string `json:"refmsg_time"`
  3835. RespondTime string `json:"respond_time"`
  3836. Signtype string `json:"signtype"`
  3837. WarnMsg string `json:"warn_msg"`
  3838. }
  3839. type ResultFour10265 struct {
  3840. Cainfo string `json:"cainfo"`
  3841. ErrMsg string `json:"err_msg"`
  3842. InfRefmsgid string `json:"inf_refmsgid"`
  3843. Infcode string `json:"infcode"`
  3844. Output struct {
  3845. Result []struct {
  3846. BasMednFlag string `json:"bas_medn_flag"`
  3847. ChldMedcFlag string `json:"chld_medc_flag"`
  3848. ChrgitmLv string `json:"chrgitm_lv"`
  3849. Cnt float64 `json:"cnt"`
  3850. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3851. DrtReimFlag string `json:"drt_reim_flag"`
  3852. FeedetlSn string `json:"feedetl_sn"`
  3853. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3854. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3855. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3856. ListSpItemFlag string `json:"list_sp_item_flag"`
  3857. LmtUsedFlag string `json:"lmt_used_flag"`
  3858. MedChrgitmType string `json:"med_chrgitm_type"`
  3859. Memo string `json:"memo"`
  3860. OverlmtAmt float64 `json:"overlmt_amt"`
  3861. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3862. Pric float64 `json:"pric"`
  3863. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3864. SelfpayProp float64 `json:"selfpay_prop"`
  3865. } `json:"result"`
  3866. } `json:"output"`
  3867. RefmsgTime string `json:"refmsg_time"`
  3868. RespondTime string `json:"respond_time"`
  3869. Signtype string `json:"signtype"`
  3870. WarnMsg string `json:"warn_msg"`
  3871. }
  3872. type ResultFive struct {
  3873. Balc float64 `json:"balc"`
  3874. CvlservFlag string `json:"cvlserv_flag"`
  3875. EmpName string `json:"emp_name"`
  3876. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3877. Insutype string `json:"insutype"`
  3878. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3879. PausInsuDate string `json:"paus_insu_date"`
  3880. PsnInsuDate string `json:"psn_insu_date"`
  3881. PsnInsuStas string `json:"psn_insu_stas"`
  3882. PsnType string `json:"psn_type"`
  3883. }
  3884. type ResultSix struct {
  3885. Cainfo interface{} `json:"cainfo"`
  3886. ErrMsg string `json:"err_msg"`
  3887. InfRefmsgid string `json:"inf_refmsgid"`
  3888. Infcode int64 `json:"infcode"`
  3889. Output struct {
  3890. } `json:"output"`
  3891. RefmsgTime string `json:"refmsg_time"`
  3892. RespondTime string `json:"respond_time"`
  3893. Signtype interface{} `json:"signtype"`
  3894. WarnMsg interface{} `json:"warn_msg"`
  3895. }
  3896. type ResultSix10265 struct {
  3897. Cainfo interface{} `json:"cainfo"`
  3898. ErrMsg string `json:"err_msg"`
  3899. InfRefmsgid string `json:"inf_refmsgid"`
  3900. Infcode string `json:"infcode"`
  3901. Output struct {
  3902. } `json:"output"`
  3903. RefmsgTime string `json:"refmsg_time"`
  3904. RespondTime string `json:"respond_time"`
  3905. Signtype interface{} `json:"signtype"`
  3906. WarnMsg interface{} `json:"warn_msg"`
  3907. }
  3908. type ResultSeven struct {
  3909. Cainfo string `json:"cainfo"`
  3910. ErrMsg string `json:"err_msg"`
  3911. InfRefmsgid string `json:"inf_refmsgid"`
  3912. Infcode int64 `json:"infcode"`
  3913. Output struct {
  3914. Setldetail []interface{} `json:"setldetail"`
  3915. Setlinfo struct {
  3916. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3917. AcctPay float64 `json:"acct_pay"`
  3918. ActPayDedc float64 `json:"act_pay_dedc"`
  3919. Age float64 `json:"age"`
  3920. Balc float64 `json:"balc"`
  3921. Brdy string `json:"brdy"`
  3922. Certno string `json:"certno"`
  3923. ClrOptins string `json:"clr_optins"`
  3924. ClrType string `json:"clr_type"`
  3925. ClrWay string `json:"clr_way"`
  3926. CvlservFlag string `json:"cvlserv_flag"`
  3927. CvlservPay float64 `json:"cvlserv_pay"`
  3928. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3929. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3930. Gend string `json:"gend"`
  3931. HifesPay float64 `json:"hifes_pay"`
  3932. HifmiPay float64 `json:"hifmi_pay"`
  3933. HifpPay float64 `json:"hifp_pay"`
  3934. HospPartAmt float64 `json:"hosp_part_amt"`
  3935. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3936. Insutype string `json:"insutype"`
  3937. MafPay float64 `json:"maf_pay"`
  3938. MdtrtCertType string `json:"mdtrt_cert_type"`
  3939. HifobPay float64 `json:"hifob_pay"`
  3940. MdtrtID string `json:"mdtrt_id"`
  3941. MedType string `json:"med_type"`
  3942. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3943. MedinsSetlID string `json:"medins_setl_id"`
  3944. Naty string `json:"naty"`
  3945. OthPay float64 `json:"oth_pay"`
  3946. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3947. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3948. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3949. PsnCashPay float64 `json:"psn_cash_pay"`
  3950. PsnCertType string `json:"psn_cert_type"`
  3951. PsnName string `json:"psn_name"`
  3952. PsnNo string `json:"psn_no"`
  3953. PsnPartAmt float64 `json:"psn_part_amt"`
  3954. PsnType string `json:"psn_type"`
  3955. SetlID string `json:"setl_id"`
  3956. SetlTime string `json:"setl_time"`
  3957. } `json:"setlinfo"`
  3958. } `json:"output"`
  3959. RefmsgTime string `json:"refmsg_time"`
  3960. RespondTime string `json:"respond_time"`
  3961. Signtype interface{} `json:"signtype"`
  3962. WarnMsg interface{} `json:"warn_msg"`
  3963. }
  3964. type ResultSeven10265 struct {
  3965. Cainfo string `json:"cainfo"`
  3966. ErrMsg string `json:"err_msg"`
  3967. InfRefmsgid string `json:"inf_refmsgid"`
  3968. Infcode string `json:"infcode"`
  3969. Output struct {
  3970. Setldetail []interface{} `json:"setldetail"`
  3971. Setlinfo struct {
  3972. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3973. AcctPay float64 `json:"acct_pay"`
  3974. ActPayDedc float64 `json:"act_pay_dedc"`
  3975. Age float64 `json:"age"`
  3976. Balc float64 `json:"balc"`
  3977. Brdy string `json:"brdy"`
  3978. Certno string `json:"certno"`
  3979. ClrOptins string `json:"clr_optins"`
  3980. ClrType string `json:"clr_type"`
  3981. ClrWay string `json:"clr_way"`
  3982. CvlservFlag string `json:"cvlserv_flag"`
  3983. CvlservPay float64 `json:"cvlserv_pay"`
  3984. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3985. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3986. Gend string `json:"gend"`
  3987. HifesPay float64 `json:"hifes_pay"`
  3988. HifmiPay float64 `json:"hifmi_pay"`
  3989. HifpPay float64 `json:"hifp_pay"`
  3990. HospPartAmt float64 `json:"hosp_part_amt"`
  3991. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3992. Insutype string `json:"insutype"`
  3993. MafPay float64 `json:"maf_pay"`
  3994. MdtrtCertType string `json:"mdtrt_cert_type"`
  3995. HifobPay float64 `json:"hifob_pay"`
  3996. MdtrtID string `json:"mdtrt_id"`
  3997. MedType string `json:"med_type"`
  3998. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3999. MedinsSetlID string `json:"medins_setl_id"`
  4000. Naty string `json:"naty"`
  4001. OthPay float64 `json:"oth_pay"`
  4002. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4003. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4004. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4005. PsnCashPay float64 `json:"psn_cash_pay"`
  4006. PsnCertType string `json:"psn_cert_type"`
  4007. PsnName string `json:"psn_name"`
  4008. PsnNo string `json:"psn_no"`
  4009. PsnPartAmt float64 `json:"psn_part_amt"`
  4010. PsnType string `json:"psn_type"`
  4011. SetlID string `json:"setl_id"`
  4012. SetlTime string `json:"setl_time"`
  4013. } `json:"setlinfo"`
  4014. } `json:"output"`
  4015. RefmsgTime string `json:"refmsg_time"`
  4016. RespondTime string `json:"respond_time"`
  4017. Signtype interface{} `json:"signtype"`
  4018. WarnMsg interface{} `json:"warn_msg"`
  4019. }
  4020. type ResultEight struct {
  4021. Cainfo string `json:"cainfo"`
  4022. ErrMsg string `json:"err_msg"`
  4023. InfRefmsgid string `json:"inf_refmsgid"`
  4024. Infcode int64 `json:"infcode"`
  4025. Output struct {
  4026. Stmtinfo struct {
  4027. SetlOptins string `json:"setl_optins"`
  4028. StmtRslt string `json:"stmt_rslt"`
  4029. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4030. } `json:"stmtinfo"`
  4031. } `json:"output"`
  4032. RefmsgTime string `json:"refmsg_time"`
  4033. RespondTime string `json:"respond_time"`
  4034. Signtype interface{} `json:"signtype"`
  4035. WarnMsg interface{} `json:"warn_msg"`
  4036. }
  4037. type ResultEightFor10188 struct {
  4038. Cainfo string `json:"cainfo"`
  4039. ErrMsg string `json:"err_msg"`
  4040. InfRefmsgid string `json:"inf_refmsgid"`
  4041. Infcode string `json:"infcode"`
  4042. Output struct {
  4043. Stmtinfo struct {
  4044. SetlOptins string `json:"setl_optins"`
  4045. StmtRslt string `json:"stmt_rslt"`
  4046. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4047. } `json:"stmtinfo"`
  4048. } `json:"output"`
  4049. RefmsgTime string `json:"refmsg_time"`
  4050. RespondTime string `json:"respond_time"`
  4051. Signtype interface{} `json:"signtype"`
  4052. WarnMsg interface{} `json:"warn_msg"`
  4053. }
  4054. type ResultNine struct {
  4055. Cainfo string `json:"cainfo"`
  4056. ErrMsg string `json:"err_msg"`
  4057. InfRefmsgid string `json:"inf_refmsgid"`
  4058. Infcode int64 `json:"infcode"`
  4059. Output struct {
  4060. FileQuryNo string `json:"file_qury_no"`
  4061. } `json:"output"`
  4062. RefmsgTime string `json:"refmsg_time"`
  4063. RespondTime string `json:"respond_time"`
  4064. Signtype interface{} `json:"signtype"`
  4065. WarnMsg interface{} `json:"warn_msg"`
  4066. }
  4067. type ResultTen struct {
  4068. Cainfo string `json:"cainfo"`
  4069. ErrMsg string `json:"err_msg"`
  4070. InfRefmsgid string `json:"inf_refmsgid"`
  4071. Infcode int64 `json:"infcode"`
  4072. Output struct {
  4073. DldEndtime string `json:"dld_endtime"`
  4074. FileQuryNo string `json:"file_qury_no"`
  4075. Filename string `json:"filename"`
  4076. } `json:"output"`
  4077. RefmsgTime string `json:"refmsg_time"`
  4078. RespondTime string `json:"respond_time"`
  4079. Signtype interface{} `json:"signtype"`
  4080. WarnMsg interface{} `json:"warn_msg"`
  4081. }
  4082. //type Autogenerated struct {
  4083. // Output struct {
  4084. // Setlinfo struct {
  4085. // SetlTime string `json:"setl_time"`
  4086. // CvlservPay float64 `json:"cvlserv_pay"`
  4087. // Year string `json:"year"`
  4088. // MedType string `json:"med_type"`
  4089. // PsnPay float64 `json:"psn_pay"`
  4090. // OpterID string `json:"opter_id"`
  4091. // Begndate string `json:"begndate"`
  4092. // FlxempeFlag string `json:"flxempe_flag"`
  4093. // HifmiPay float64 `json:"hifmi_pay"`
  4094. // PsnNo string `json:"psn_no"`
  4095. // ActPayDedc float64 `json:"act_pay_dedc"`
  4096. // MedinsSetlID interface{} `json:"medins_setl_id"`
  4097. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4098. // ClrWay string `json:"clr_way"`
  4099. // OthPay float64 `json:"oth_pay"`
  4100. // Gend string `json:"gend"`
  4101. // MdtrtID string `json:"mdtrt_id"`
  4102. // AcctPay float64 `json:"acct_pay"`
  4103. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  4104. // Insutype string `json:"insutype"`
  4105. // Invono interface{} `json:"invono"`
  4106. // Enddate string `json:"enddate"`
  4107. // CashPayamt float64 `json:"cash_payamt"`
  4108. // PsnType string `json:"psn_type"`
  4109. // FixmedinsName string `json:"fixmedins_name"`
  4110. // HifpPay float64 `json:"hifp_pay"`
  4111. // NewFlag interface{} `json:"new_flag"`
  4112. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4113. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  4114. // PayLoc string `json:"pay_loc"`
  4115. // ClrType string `json:"clr_type"`
  4116. // RefdSetlFlag string `json:"refd_setl_flag"`
  4117. // CvlservFlag string `json:"cvlserv_flag"`
  4118. // EmpName string `json:"emp_name"`
  4119. // Brdy string `json:"brdy"`
  4120. // Naty string `json:"naty"`
  4121. // Certno string `json:"certno"`
  4122. // DiseCode string `json:"dise_code"`
  4123. // FixmedinsCode string `json:"fixmedins_code"`
  4124. // DedcHospLv string `json:"dedc_hosp_lv"`
  4125. // OpterName string `json:"opter_name"`
  4126. // Balc float64 `json:"balc"`
  4127. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4128. // PsnCertType string `json:"psn_cert_type"`
  4129. // HifobPay float64 `json:"hifob_pay"`
  4130. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  4131. // HifesPay float64 `json:"hifes_pay"`
  4132. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4133. // OptTime string `json:"opt_time"`
  4134. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4135. // SetlID string `json:"setl_id"`
  4136. // MafPay float64 `json:"maf_pay"`
  4137. // PsnName string `json:"psn_name"`
  4138. // InsuOptins interface{} `json:"insu_optins"`
  4139. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4140. // ClrOptins string `json:"clr_optins"`
  4141. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4142. // DiseName string `json:"dise_name"`
  4143. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4144. // Age float64 `json:"age"`
  4145. // DtrtCertType string `json:"dtrt_cert_type"`
  4146. // HospLv string `json:"hosp_lv"`
  4147. // } `json:"setlinfo"`
  4148. // Setldetail []struct {
  4149. // FundPayType string `json:"fund_pay_type"`
  4150. // FundPayamt float64 `json:"fund_payamt"`
  4151. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4152. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4153. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4154. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4155. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4156. // } `json:"setldetail"`
  4157. // } `json:"output"`
  4158. // Infcode int `json:"infcode"`
  4159. // WarnMsg interface{} `json:"warn_msg"`
  4160. // Cainfo interface{} `json:"cainfo"`
  4161. // ErrMsg interface{} `json:"err_msg"`
  4162. // RefmsgTime string `json:"refmsg_time"`
  4163. // Signtype interface{} `json:"signtype"`
  4164. // RespondTime string `json:"respond_time"`
  4165. // InfRefmsgid string `json:"inf_refmsgid"`
  4166. //}
  4167. type ResultEleven struct {
  4168. Cainfo string `json:"cainfo"`
  4169. ErrMsg string `json:"err_msg"`
  4170. InfRefmsgid string `json:"inf_refmsgid"`
  4171. Infcode int64 `json:"infcode"`
  4172. Output struct {
  4173. Setlinfo struct {
  4174. SetlTime string `json:"setl_time"`
  4175. CvlservPay float64 `json:"cvlserv_pay"`
  4176. Year string `json:"year"`
  4177. MedType string `json:"med_type"`
  4178. PsnPay float64 `json:"psn_pay"`
  4179. OpterID string `json:"opter_id"`
  4180. Begndate string `json:"begndate"`
  4181. FlxempeFlag string `json:"flxempe_flag"`
  4182. HifmiPay float64 `json:"hifmi_pay"`
  4183. PsnNo string `json:"psn_no"`
  4184. ActPayDedc float64 `json:"act_pay_dedc"`
  4185. MedinsSetlID interface{} `json:"medins_setl_id"`
  4186. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4187. ClrWay string `json:"clr_way"`
  4188. OthPay float64 `json:"oth_pay"`
  4189. Gend string `json:"gend"`
  4190. MdtrtID string `json:"mdtrt_id"`
  4191. AcctPay float64 `json:"acct_pay"`
  4192. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4193. Insutype string `json:"insutype"`
  4194. Invono interface{} `json:"invono"`
  4195. Enddate string `json:"enddate"`
  4196. CashPayamt float64 `json:"cash_payamt"`
  4197. PsnType string `json:"psn_type"`
  4198. FixmedinsName string `json:"fixmedins_name"`
  4199. HifpPay float64 `json:"hifp_pay"`
  4200. NewFlag interface{} `json:"new_flag"`
  4201. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4202. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4203. PayLoc string `json:"pay_loc"`
  4204. ClrType string `json:"clr_type"`
  4205. RefdSetlFlag string `json:"refd_setl_flag"`
  4206. CvlservFlag string `json:"cvlserv_flag"`
  4207. EmpName string `json:"emp_name"`
  4208. Brdy string `json:"brdy"`
  4209. Naty string `json:"naty"`
  4210. Certno string `json:"certno"`
  4211. DiseCode string `json:"dise_code"`
  4212. FixmedinsCode string `json:"fixmedins_code"`
  4213. DedcHospLv string `json:"dedc_hosp_lv"`
  4214. OpterName string `json:"opter_name"`
  4215. Balc float64 `json:"balc"`
  4216. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4217. PsnCertType string `json:"psn_cert_type"`
  4218. HifobPay float64 `json:"hifob_pay"`
  4219. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4220. HifesPay float64 `json:"hifes_pay"`
  4221. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4222. OptTime string `json:"opt_time"`
  4223. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4224. SetlID string `json:"setl_id"`
  4225. MafPay float64 `json:"maf_pay"`
  4226. PsnName string `json:"psn_name"`
  4227. InsuOptins interface{} `json:"insu_optins"`
  4228. PrefFundPay interface{} `json:"pref_fund_pay"`
  4229. ClrOptins string `json:"clr_optins"`
  4230. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4231. DiseName string `json:"dise_name"`
  4232. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4233. Age float64 `json:"age"`
  4234. DtrtCertType string `json:"dtrt_cert_type"`
  4235. HospLv string `json:"hosp_lv"`
  4236. } `json:"setlinfo"`
  4237. } `json:"output"`
  4238. RefmsgTime string `json:"refmsg_time"`
  4239. RespondTime string `json:"respond_time"`
  4240. Signtype interface{} `json:"signtype"`
  4241. WarnMsg interface{} `json:"warn_msg"`
  4242. }
  4243. type ResultEleven10265 struct {
  4244. Cainfo string `json:"cainfo"`
  4245. ErrMsg string `json:"err_msg"`
  4246. InfRefmsgid string `json:"inf_refmsgid"`
  4247. Infcode string `json:"infcode"`
  4248. Output struct {
  4249. Setlinfo struct {
  4250. SetlTime string `json:"setl_time"`
  4251. CvlservPay float64 `json:"cvlserv_pay"`
  4252. Year string `json:"year"`
  4253. MedType string `json:"med_type"`
  4254. PsnPay float64 `json:"psn_pay"`
  4255. OpterID string `json:"opter_id"`
  4256. Begndate string `json:"begndate"`
  4257. FlxempeFlag string `json:"flxempe_flag"`
  4258. HifmiPay float64 `json:"hifmi_pay"`
  4259. PsnNo string `json:"psn_no"`
  4260. ActPayDedc float64 `json:"act_pay_dedc"`
  4261. MedinsSetlID interface{} `json:"medins_setl_id"`
  4262. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4263. ClrWay string `json:"clr_way"`
  4264. OthPay float64 `json:"oth_pay"`
  4265. Gend string `json:"gend"`
  4266. MdtrtID string `json:"mdtrt_id"`
  4267. AcctPay float64 `json:"acct_pay"`
  4268. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4269. Insutype string `json:"insutype"`
  4270. Invono interface{} `json:"invono"`
  4271. Enddate string `json:"enddate"`
  4272. CashPayamt float64 `json:"cash_payamt"`
  4273. PsnType string `json:"psn_type"`
  4274. FixmedinsName string `json:"fixmedins_name"`
  4275. HifpPay float64 `json:"hifp_pay"`
  4276. NewFlag interface{} `json:"new_flag"`
  4277. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4278. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4279. PayLoc string `json:"pay_loc"`
  4280. ClrType string `json:"clr_type"`
  4281. RefdSetlFlag string `json:"refd_setl_flag"`
  4282. CvlservFlag string `json:"cvlserv_flag"`
  4283. EmpName string `json:"emp_name"`
  4284. Brdy string `json:"brdy"`
  4285. Naty string `json:"naty"`
  4286. Certno string `json:"certno"`
  4287. DiseCode string `json:"dise_code"`
  4288. FixmedinsCode string `json:"fixmedins_code"`
  4289. DedcHospLv string `json:"dedc_hosp_lv"`
  4290. OpterName string `json:"opter_name"`
  4291. Balc float64 `json:"balc"`
  4292. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4293. PsnCertType string `json:"psn_cert_type"`
  4294. HifobPay float64 `json:"hifob_pay"`
  4295. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4296. HifesPay float64 `json:"hifes_pay"`
  4297. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4298. OptTime string `json:"opt_time"`
  4299. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4300. SetlID string `json:"setl_id"`
  4301. MafPay float64 `json:"maf_pay"`
  4302. PsnName string `json:"psn_name"`
  4303. InsuOptins interface{} `json:"insu_optins"`
  4304. PrefFundPay interface{} `json:"pref_fund_pay"`
  4305. ClrOptins string `json:"clr_optins"`
  4306. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4307. DiseName string `json:"dise_name"`
  4308. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4309. Age float64 `json:"age"`
  4310. DtrtCertType string `json:"dtrt_cert_type"`
  4311. HospLv string `json:"hosp_lv"`
  4312. } `json:"setlinfo"`
  4313. } `json:"output"`
  4314. RefmsgTime string `json:"refmsg_time"`
  4315. RespondTime string `json:"respond_time"`
  4316. Signtype interface{} `json:"signtype"`
  4317. WarnMsg interface{} `json:"warn_msg"`
  4318. }
  4319. type ResultTwelve struct {
  4320. Cainfo string `json:"cainfo"`
  4321. ErrMsg string `json:"err_msg"`
  4322. InfRefmsgid string `json:"inf_refmsgid"`
  4323. Infcode int64 `json:"infcode"`
  4324. Output struct {
  4325. MdtrtId string `json:"mdtrt_id"`
  4326. ChrgBchno string `json:"chrg_bchno"`
  4327. PsnNo string `json:"psn_no"`
  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 ResultThirteen struct {
  4335. ErrMsg string `json:"err_msg"`
  4336. InfRefmsgid string `json:"inf_refmsgid"`
  4337. Infcode int64 `json:"infcode"`
  4338. Output struct {
  4339. Result struct {
  4340. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4341. } `json:"result"`
  4342. } `json:"output"`
  4343. RefmsgTime string `json:"refmsg_time"`
  4344. RespondTime string `json:"respond_time"`
  4345. Signtype interface{} `json:"signtype"`
  4346. WarnInfo interface{} `json:"warn_info"`
  4347. }
  4348. type ResultThirteen10265 struct {
  4349. ErrMsg string `json:"err_msg"`
  4350. InfRefmsgid string `json:"inf_refmsgid"`
  4351. Infcode string `json:"infcode"`
  4352. Output struct {
  4353. Result struct {
  4354. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4355. } `json:"result"`
  4356. } `json:"output"`
  4357. RefmsgTime string `json:"refmsg_time"`
  4358. RespondTime string `json:"respond_time"`
  4359. Signtype interface{} `json:"signtype"`
  4360. WarnInfo interface{} `json:"warn_info"`
  4361. }
  4362. type ResultFourteen struct {
  4363. ErrMsg string `json:"err_msg"`
  4364. InfRefmsgid string `json:"inf_refmsgid"`
  4365. Infcode int64 `json:"infcode"`
  4366. Output struct {
  4367. } `json:"output"`
  4368. RefmsgTime string `json:"refmsg_time"`
  4369. RespondTime string `json:"respond_time"`
  4370. Signtype interface{} `json:"signtype"`
  4371. WarnInfo interface{} `json:"warn_info"`
  4372. }
  4373. type ResultFourteen10265 struct {
  4374. ErrMsg string `json:"err_msg"`
  4375. InfRefmsgid string `json:"inf_refmsgid"`
  4376. Infcode string `json:"infcode"`
  4377. Output struct {
  4378. } `json:"output"`
  4379. RefmsgTime string `json:"refmsg_time"`
  4380. RespondTime string `json:"respond_time"`
  4381. Signtype interface{} `json:"signtype"`
  4382. WarnInfo interface{} `json:"warn_info"`
  4383. }
  4384. type ResultSixteen struct {
  4385. Cainfo string `json:"cainfo"`
  4386. ErrMsg string `json:"err_msg"`
  4387. InfRefmsgid string `json:"inf_refmsgid"`
  4388. Infcode int64 `json:"infcode"`
  4389. Output struct {
  4390. Setldetail []interface{} `json:"setldetail"`
  4391. Setlinfo struct {
  4392. MdtrtID string `json:"mdtrt_id"`
  4393. SetlID string `json:"setl_id"`
  4394. ClrOptins string `json:"clr_optins"`
  4395. SetlTime string `json:"setl_time"`
  4396. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4397. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4398. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4399. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4400. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4401. ActPayDedc float64 `json:"act_pay_dedc"`
  4402. HifpPay float64 `json:"hifp_pay"`
  4403. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4404. Lfpay float64 `json:"selfpay"`
  4405. CvlservPay float64 `json:"cvlserv_pay"`
  4406. HifesPay float64 `json:"hifes_pay"`
  4407. HifmiPay float64 `json:"hifmi_pay"`
  4408. HifobPay float64 `json:"hifob_pay"`
  4409. MafPay float64 `json:"maf_pay"`
  4410. OthPay float64 `json:"oth_pay"`
  4411. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4412. PsnPartAmt float64 `json:"psn_part_amt"`
  4413. AcctPay float64 `json:"acct_pay"`
  4414. Balc float64 `json:"balc"`
  4415. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4416. HospPartAmt float64 `json:"hosp_part_amt"`
  4417. MedinsSetlID string `json:"medins_setl_id"`
  4418. PdnCashPay string `json:"pdn_cash_pay"`
  4419. } `json:"setlinfo"`
  4420. } `json:"output"`
  4421. RefmsgTime string `json:"refmsg_time"`
  4422. RespondTime string `json:"respond_time"`
  4423. Signtype interface{} `json:"signtype"`
  4424. WarnMsg interface{} `json:"warn_msg"`
  4425. }
  4426. type ResultSixteen10265 struct {
  4427. Cainfo string `json:"cainfo"`
  4428. ErrMsg string `json:"err_msg"`
  4429. InfRefmsgid string `json:"inf_refmsgid"`
  4430. Infcode string `json:"infcode"`
  4431. Output struct {
  4432. Setldetail []interface{} `json:"setldetail"`
  4433. Setlinfo struct {
  4434. MdtrtID string `json:"mdtrt_id"`
  4435. SetlID string `json:"setl_id"`
  4436. ClrOptins string `json:"clr_optins"`
  4437. SetlTime string `json:"setl_time"`
  4438. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4439. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4440. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4441. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4442. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4443. ActPayDedc float64 `json:"act_pay_dedc"`
  4444. HifpPay float64 `json:"hifp_pay"`
  4445. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4446. Lfpay float64 `json:"selfpay"`
  4447. CvlservPay float64 `json:"cvlserv_pay"`
  4448. HifesPay float64 `json:"hifes_pay"`
  4449. HifmiPay float64 `json:"hifmi_pay"`
  4450. HifobPay float64 `json:"hifob_pay"`
  4451. MafPay float64 `json:"maf_pay"`
  4452. OthPay float64 `json:"oth_pay"`
  4453. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4454. PsnPartAmt float64 `json:"psn_part_amt"`
  4455. AcctPay float64 `json:"acct_pay"`
  4456. Balc float64 `json:"balc"`
  4457. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4458. HospPartAmt float64 `json:"hosp_part_amt"`
  4459. MedinsSetlID string `json:"medins_setl_id"`
  4460. PdnCashPay string `json:"pdn_cash_pay"`
  4461. } `json:"setlinfo"`
  4462. } `json:"output"`
  4463. RefmsgTime string `json:"refmsg_time"`
  4464. RespondTime string `json:"respond_time"`
  4465. Signtype interface{} `json:"signtype"`
  4466. WarnMsg interface{} `json:"warn_msg"`
  4467. }
  4468. type ResultSeventeen struct {
  4469. ErrMsg string `json:"err_msg"`
  4470. InfRefmsgid string `json:"inf_refmsgid"`
  4471. Infcode int64 `json:"infcode"`
  4472. Output struct {
  4473. SetlListId string `json:"setl_list_id"`
  4474. } `json:"output"`
  4475. RefmsgTime string `json:"refmsg_time"`
  4476. RespondTime string `json:"respond_time"`
  4477. Signtype string `json:"signtype"`
  4478. WarnInfo string `json:"warn_info"`
  4479. }
  4480. type ResultSeventeenOther struct {
  4481. ErrMsg string `json:"err_msg"`
  4482. InfRefmsgid string `json:"inf_refmsgid"`
  4483. Infcode string `json:"infcode"`
  4484. Output struct {
  4485. SetlListId string `json:"setl_list_id"`
  4486. } `json:"output"`
  4487. RefmsgTime string `json:"refmsg_time"`
  4488. RespondTime string `json:"respond_time"`
  4489. Signtype string `json:"signtype"`
  4490. WarnInfo string `json:"warn_info"`
  4491. }
  4492. type Result90991 struct {
  4493. ErrMsg string `json:"err_msg"`
  4494. InfRefmsgid string `json:"inf_refmsgid"`
  4495. Infcode int64 `json:"infcode"`
  4496. Output struct {
  4497. Result struct {
  4498. PsnNo string `json:"psn_no"`
  4499. CardStat string `json:"card_stat"`
  4500. Certno string `json:"certno"`
  4501. PsnName string `json:"psn_name"`
  4502. CheckStat string `json:"check_stat"`
  4503. SscnoCheckStat string `json:"sscno_check_stat"`
  4504. } `json:"result"`
  4505. } `json:"output"`
  4506. RefmsgTime string `json:"refmsg_time"`
  4507. RespondTime string `json:"respond_time"`
  4508. Signtype interface{} `json:"signtype"`
  4509. WarnInfo interface{} `json:"warn_info"`
  4510. }
  4511. type Result90100 struct {
  4512. ErrMsg string `json:"err_msg"`
  4513. InfRefmsgid string `json:"inf_refmsgid"`
  4514. Infcode int64 `json:"infcode"`
  4515. Output struct {
  4516. PoolareaNo string `json:"poolarea_no"`
  4517. PoolareaNoName string `json:"poolarea_no_name"`
  4518. Insutype string `json:"insutype"`
  4519. InsutypeName string `json:"insutype_name"`
  4520. ClctType string `json:"clct_type"`
  4521. ClctTypeName string `json:"clct_type_name"`
  4522. ClctFlag string `json:"clct_flag"`
  4523. ClctFlagName string `json:"clct_flag_name"`
  4524. AccrymBegn string `json:"accrym_begn"`
  4525. AccrymEnd string `json:"accrym_end"`
  4526. ClctTime string `json:"clct_time"`
  4527. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4528. } `json:"output"`
  4529. RefmsgTime string `json:"refmsg_time"`
  4530. RespondTime string `json:"respond_time"`
  4531. Signtype interface{} `json:"signtype"`
  4532. WarnInfo interface{} `json:"warn_info"`
  4533. }
  4534. type Custom struct {
  4535. DetItemFeeSumamt string
  4536. Cut string
  4537. FeedetlSn string
  4538. Price string
  4539. MedListCodg string
  4540. Type int64
  4541. AdviceId int64
  4542. ProjectId int64
  4543. ItemId int64
  4544. }
  4545. type Result5301 struct {
  4546. ErrMsg string `json:"err_msg"`
  4547. InfRefmsgid string `json:"inf_refmsgid"`
  4548. Infcode int64 `json:"infcode"`
  4549. Output struct {
  4550. Result []struct {
  4551. OpspDiseCode string `json:"opsp_dise_code"`
  4552. OpspDiseName string `json:"opsp_dise_name"`
  4553. Begndate string `json:"begndate"`
  4554. Enddate string `json:"enddate"`
  4555. } `json:"feedetail"`
  4556. } `json:"output"`
  4557. RefmsgTime string `json:"refmsg_time"`
  4558. RespondTime string `json:"respond_time"`
  4559. Signtype interface{} `json:"signtype"`
  4560. WarnInfo interface{} `json:"warn_info"`
  4561. }
  4562. type Result5301For10265 struct {
  4563. ErrMsg string `json:"err_msg"`
  4564. InfRefmsgid string `json:"inf_refmsgid"`
  4565. Infcode string `json:"infcode"`
  4566. Output struct {
  4567. Result []struct {
  4568. OpspDiseCode string `json:"opsp_dise_code"`
  4569. OpspDiseName string `json:"opsp_dise_name"`
  4570. Begndate string `json:"begndate"`
  4571. Enddate string `json:"enddate"`
  4572. } `json:"feedetail"`
  4573. } `json:"output"`
  4574. RefmsgTime string `json:"refmsg_time"`
  4575. RespondTime string `json:"respond_time"`
  4576. Signtype interface{} `json:"signtype"`
  4577. WarnInfo interface{} `json:"warn_info"`
  4578. }
  4579. //获取个人信息----挂号-----上传就诊信息
  4580. func (c *HisApiController) GetRegisterInfo() {
  4581. id, _ := c.GetInt64("id")
  4582. record_time := c.GetString("record_time")
  4583. settlementValue, _ := c.GetInt64("settlement_value")
  4584. medical_insurance_card := c.GetString("medical_insurance_card")
  4585. name := c.GetString("name")
  4586. id_card_type, _ := c.GetInt64("id_card_type")
  4587. certificates, _ := c.GetInt64("certificates")
  4588. medical_care, _ := c.GetInt64("medical_care")
  4589. birthday := c.GetString("birthday")
  4590. id_card := c.GetString("id_card")
  4591. register_type, _ := c.GetInt64("register")
  4592. doctor, _ := c.GetInt64("doctor")
  4593. department, _ := c.GetInt64("department")
  4594. gender, _ := c.GetInt64("sex")
  4595. registration_fee, _ := c.GetFloat("registration_fee")
  4596. medical_expenses, _ := c.GetFloat("medical_expenses")
  4597. social_type, _ := c.GetInt64("social_type")
  4598. med_type := c.GetString("social_type")
  4599. admin_user_id, _ := c.GetInt64("admin_user_id")
  4600. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4601. timeLayout := "2006-01-02"
  4602. loc, _ := time.LoadLocation("Local")
  4603. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4604. birthUnix := birthdays.Unix()
  4605. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4606. if err != nil {
  4607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4608. return
  4609. }
  4610. recordDateTime := theTime.Unix()
  4611. adminInfo := c.GetAdminUserInfo()
  4612. var patient service.Patients
  4613. if id == 0 {
  4614. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4615. } else {
  4616. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4617. }
  4618. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4619. if patientPrescription.ID == 0 {
  4620. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4621. }
  4622. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4623. if patient.ID == 0 {
  4624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4625. return
  4626. }
  4627. if len(patient.IdCardNo) == 0 {
  4628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4629. return
  4630. }
  4631. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4632. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4633. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4634. //就诊结算未完成,不能进行二次挂号
  4635. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4636. if len(his) >= 1 {
  4637. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4638. if len(his) >= 1 && order.ID == 0 {
  4639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4640. return
  4641. }
  4642. }
  4643. //var register_log string
  4644. if config.IsOpen == 1 {
  4645. var res ResultTwo
  4646. var res10265 ResultTwo10265
  4647. var PsnNo string
  4648. var PsnCertType string
  4649. var Certno string
  4650. var PsnName string
  4651. var Gend string
  4652. var Naty string
  4653. var Brdy string
  4654. var Age float64
  4655. var infoStr string
  4656. var idetinfoStr string
  4657. var infocode int64
  4658. var verify_number string
  4659. fmt.Println(verify_number)
  4660. if miConfig.MdtrtareaAdmvs == "421300" {
  4661. psn_info, _ := service.GetPsnByPatientId(id)
  4662. PsnNo = psn_info.PsnNo
  4663. PsnCertType = psn_info.PsnCertType
  4664. Certno = psn_info.Certno
  4665. PsnName = psn_info.PsnName
  4666. Gend = psn_info.Gend
  4667. Naty = psn_info.Naty
  4668. Brdy = psn_info.Brdy
  4669. Age = psn_info.Age
  4670. infoStr = psn_info.Insuinfo
  4671. idetinfoStr = psn_info.Idetinfo
  4672. infocode = 0
  4673. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4674. psn_info, _ := service.GetPsnByPatientId(id)
  4675. PsnNo = psn_info.PsnNo
  4676. PsnCertType = psn_info.PsnCertType
  4677. Certno = psn_info.Certno
  4678. PsnName = psn_info.PsnName
  4679. Gend = psn_info.Gend
  4680. Naty = psn_info.Naty
  4681. Brdy = psn_info.Brdy
  4682. Age = psn_info.Age
  4683. infoStr = psn_info.Insuinfo
  4684. idetinfoStr = psn_info.Idetinfo
  4685. infocode = 0
  4686. verify_number = psn_info.VerifyNumber
  4687. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4688. if id_card_type == 1 {
  4689. psn_info, _ := service.GetPsnByPatientId(id)
  4690. PsnNo = psn_info.PsnNo
  4691. PsnCertType = psn_info.PsnCertType
  4692. Certno = psn_info.Certno
  4693. PsnName = psn_info.PsnName
  4694. Gend = psn_info.Gend
  4695. Naty = psn_info.Naty
  4696. Brdy = psn_info.Brdy
  4697. Age = psn_info.Age
  4698. infoStr = psn_info.Insuinfo
  4699. idetinfoStr = psn_info.Idetinfo
  4700. infocode = 0
  4701. verify_number = psn_info.VerifyNumber
  4702. } else if id_card_type == 2 {
  4703. 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)
  4704. fmt.Println(errMsgLog)
  4705. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4706. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4707. utils.ErrorLog("解析失败:%v", err)
  4708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4709. return
  4710. }
  4711. PsnNo = res.Output.Baseinfo.PsnNo
  4712. PsnCertType = res.Output.Baseinfo.PsnCertType
  4713. Certno = res.Output.Baseinfo.Certno
  4714. PsnName = res.Output.Baseinfo.PsnName
  4715. Gend = res.Output.Baseinfo.Gend
  4716. Naty = res.Output.Baseinfo.Naty
  4717. Brdy = res.Output.Baseinfo.Brdy
  4718. Age = res.Output.Baseinfo.Age
  4719. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4720. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4721. infoStr = string(Iinfos)
  4722. idetinfoStr = string(Idetinfos)
  4723. infocode = res.Infcode
  4724. }
  4725. } else {
  4726. var result string
  4727. var requestLog string
  4728. if miConfig.UserOrgId == 10138 {
  4729. if id_card_type == 4 {
  4730. psn_info, _ := service.GetPsnByPatientId(id)
  4731. result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  4732. } else {
  4733. 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)
  4734. }
  4735. } else {
  4736. 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)
  4737. }
  4738. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4739. if miConfig.Code == "H15049901371" {
  4740. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4741. utils.ErrorLog("解析失败:%v", err)
  4742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4743. return
  4744. }
  4745. res.ErrMsg = res10265.ErrMsg
  4746. res.Output = res10265.Output
  4747. res.InfRefmsgid = res10265.InfRefmsgid
  4748. } else {
  4749. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4750. utils.ErrorLog("解析失败:%v", err)
  4751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4752. return
  4753. }
  4754. }
  4755. PsnNo = res.Output.Baseinfo.PsnNo
  4756. PsnCertType = res.Output.Baseinfo.PsnCertType
  4757. Certno = res.Output.Baseinfo.Certno
  4758. PsnName = res.Output.Baseinfo.PsnName
  4759. Gend = res.Output.Baseinfo.Gend
  4760. Naty = res.Output.Baseinfo.Naty
  4761. Brdy = res.Output.Baseinfo.Brdy
  4762. Age = res.Output.Baseinfo.Age
  4763. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4764. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4765. infoStr = string(Iinfos)
  4766. idetinfoStr = string(Idetinfos)
  4767. if miConfig.Code == "H15049901371" {
  4768. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4769. } else {
  4770. infocode = res.Infcode
  4771. }
  4772. }
  4773. if infocode == 0 {
  4774. his := models.VMHisPatient{
  4775. Name: name,
  4776. Gender: gender,
  4777. Birthday: birthUnix,
  4778. MedicalTreatmentType: medical_care,
  4779. IdType: certificates,
  4780. IdCardNo: id_card,
  4781. BalanceAccountsType: settlementValue,
  4782. SocialType: social_type,
  4783. MedicalInsuranceNumber: medical_insurance_card,
  4784. RegisterType: register_type,
  4785. RegisterCost: registration_fee,
  4786. TreatmentCost: medical_expenses,
  4787. Status: 1,
  4788. Ctime: time.Now().Unix(),
  4789. Mtime: time.Now().Unix(),
  4790. PsnNo: PsnNo,
  4791. PsnCertType: PsnCertType,
  4792. Certno: Certno,
  4793. PsnName: PsnName,
  4794. Gend: Gend,
  4795. Naty: Naty,
  4796. Brdy: Brdy,
  4797. Age: Age,
  4798. Iinfo: infoStr,
  4799. Idetinfo: idetinfoStr,
  4800. PatientId: patient.ID,
  4801. RecordDate: theTime.Unix(),
  4802. UserOrgId: adminInfo.CurrentOrgId,
  4803. AdminUserId: admin_user_id,
  4804. IsReturn: 1,
  4805. IdCardType: id_card_type,
  4806. Doctor: doctor,
  4807. Departments: department,
  4808. }
  4809. timestamp := time.Now().Unix()
  4810. tempTime := time.Unix(timestamp, 0)
  4811. timeFormat := tempTime.Format("20060102150405")
  4812. chrgBchno := rand.Intn(100000) + 10000
  4813. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4814. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4815. department, _ := service.GetDepartMentDetail(department)
  4816. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  4817. IdCardNo := ""
  4818. if id_card_type == 1 {
  4819. // IdCardNo = medical_insurance_card
  4820. IdCardNo = patient.IdCardNo
  4821. } else {
  4822. IdCardNo = patient.IdCardNo
  4823. }
  4824. var rf []*ResultFive
  4825. json.Unmarshal([]byte(his.Iinfo), &rf)
  4826. var insutypes []*ResultFive
  4827. var insutype string
  4828. var insuplc_admdvs_temp string
  4829. var is390 int = 0
  4830. var is310 int = 0
  4831. for _, item := range rf {
  4832. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4833. insutypes = append(insutypes, item)
  4834. }
  4835. }
  4836. if len(insutypes) == 1 {
  4837. insutype = insutypes[0].Insutype
  4838. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4839. } else {
  4840. for _, i := range insutypes {
  4841. if i.Insutype == "390" {
  4842. is390 = 1
  4843. }
  4844. if i.Insutype == "310" {
  4845. is310 = 1
  4846. }
  4847. }
  4848. }
  4849. if is390 == 1 {
  4850. insutype = "390"
  4851. }
  4852. if is310 == 1 {
  4853. insutype = "310"
  4854. }
  4855. if len(insutypes) == 0 {
  4856. insutype = "310"
  4857. }
  4858. if len(insutypes) == 2 {
  4859. insutype = med_type
  4860. }
  4861. if len(med_type) > 0 {
  4862. insutype = med_type
  4863. }
  4864. //for _, item := range rf {
  4865. // if item.Insutype == insutype {
  4866. // insuplc_admdvs = item.InsuplcAdmdvs
  4867. // }
  4868. //}
  4869. var infocode int64
  4870. var resThree ResultThree
  4871. var resThree10265 ResultThree10265
  4872. if len(insuplc_admdvs) == 0 {
  4873. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4874. } else {
  4875. insuplc_admdvs_temp = insuplc_admdvs
  4876. }
  4877. if miConfig.MdtrtareaAdmvs == "421300" {
  4878. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  4879. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4880. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4881. "&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
  4882. resp, requestErr := http.Get(api)
  4883. if requestErr != nil {
  4884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4885. return
  4886. }
  4887. body, ioErr := ioutil.ReadAll(resp.Body)
  4888. if ioErr != nil {
  4889. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4891. return
  4892. }
  4893. var respJSON map[string]interface{}
  4894. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4895. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4897. return
  4898. }
  4899. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4900. result, _ := json.Marshal(respJSON)
  4901. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4902. utils.ErrorLog("解析失败:%v", err)
  4903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4904. return
  4905. }
  4906. infocode = resThree.Infcode
  4907. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4908. psn_info, _ := service.GetPsnByPatientId(id)
  4909. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4910. var cert_no string
  4911. if id_card_type == 3 {
  4912. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4913. cert_no = IdCardNo
  4914. } else if id_card_type == 4 {
  4915. cert_no = IdCardNo
  4916. psn_info.VerifyNumber = psn_info.VerifyNumber
  4917. } else {
  4918. bas := strings.Split(psn_info.CardInfo, "|")
  4919. cert_no = bas[2]
  4920. }
  4921. var api string
  4922. if miConfig.MdtrtareaAdmvs == "320921" {
  4923. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4924. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4925. "&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
  4926. } else {
  4927. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4928. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4929. "&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
  4930. }
  4931. resp, requestErr := http.Get(api)
  4932. if requestErr != nil {
  4933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4934. return
  4935. }
  4936. body, ioErr := ioutil.ReadAll(resp.Body)
  4937. if ioErr != nil {
  4938. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4940. return
  4941. }
  4942. var respJSON map[string]interface{}
  4943. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4944. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4946. return
  4947. }
  4948. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4949. result, _ := json.Marshal(respJSON)
  4950. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4951. utils.ErrorLog("解析失败:%v", err)
  4952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4953. return
  4954. }
  4955. resThree.ErrMsg = resThree10265.ErrMsg
  4956. resThree.Output = resThree10265.Output
  4957. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4958. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4959. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4960. psn_info, _ := service.GetPsnByPatientId(id)
  4961. var cert_no string
  4962. if id_card_type == 1 {
  4963. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  4964. } else {
  4965. cert_no = strings.Split(psn_info.CardInfo, "|")[1]
  4966. }
  4967. fmt.Println(cert_no)
  4968. 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)
  4969. saveLog(result, requestLog, "2201", "挂号")
  4970. if miConfig.Code == "H15049901371" {
  4971. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4972. utils.ErrorLog("解析失败:%v", err)
  4973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4974. return
  4975. }
  4976. resThree.ErrMsg = resThree10265.ErrMsg
  4977. resThree.Output = resThree10265.Output
  4978. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4979. } else {
  4980. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4981. utils.ErrorLog("解析失败:%v", err)
  4982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4983. return
  4984. }
  4985. }
  4986. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4987. } else {
  4988. //Check3101(c, patient.ID, his.ID, admin_user_id)
  4989. psn_info, _ := service.GetPsnByPatientId(id)
  4990. result, requestLog := service.Gdyb2201A(res.Output.Baseinfo.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)
  4991. saveLog(result, requestLog, "2201A", "挂号")
  4992. if miConfig.Code == "H15049901371" {
  4993. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4994. utils.ErrorLog("解析失败:%v", err)
  4995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4996. return
  4997. }
  4998. resThree.ErrMsg = resThree10265.ErrMsg
  4999. resThree.Output = resThree10265.Output
  5000. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5001. } else {
  5002. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5003. utils.ErrorLog("解析失败:%v", err)
  5004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5005. return
  5006. }
  5007. }
  5008. if miConfig.Code == "H15049901371" {
  5009. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5010. } else {
  5011. infocode = resThree.Infcode
  5012. }
  5013. }
  5014. if infocode != 0 {
  5015. adminUser := c.GetAdminUserInfo()
  5016. errlog := &models.HisOrderError{
  5017. UserOrgId: adminUser.CurrentOrgId,
  5018. Ctime: time.Now().Unix(),
  5019. Mtime: time.Now().Unix(),
  5020. ErrMsg: resThree.ErrMsg,
  5021. Status: 1,
  5022. PatientId: id,
  5023. RecordTime: recordDateTime,
  5024. Stage: 2,
  5025. }
  5026. service.CreateErrMsgLog(errlog)
  5027. c.ServeSuccessJSON(map[string]interface{}{
  5028. "failed_code": -10,
  5029. "msg": resThree.ErrMsg,
  5030. })
  5031. return
  5032. }
  5033. his.Number = resThree.Output.Data.MdtrtID
  5034. his.PsnNo = resThree.Output.Data.PsnNo
  5035. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  5036. his.IdCardNo = patient.IdCardNo
  5037. his.PhoneNumber = patient.Phone
  5038. his.UserOrgId = adminInfo.CurrentOrgId
  5039. his.Insutype = insutype
  5040. his.Ctime = time.Now().Unix()
  5041. his.Mtime = time.Now().Unix()
  5042. his.InsuplcAdmdvs = insuplc_admdvs_temp
  5043. his.Status = 1
  5044. service.UpdateHisPatientStatus(&his)
  5045. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  5046. var prescriptions []*models.HisPrescription
  5047. res := Check3101(c, patient.ID, his.ID, admin_user_id, "1", record_time, prescriptions)
  5048. if res.Infcode == "0" {
  5049. if len(res.Output.Result) > 0 {
  5050. var res2 ResultSix
  5051. var resSix10265 ResultSix10265
  5052. var api3 string
  5053. if miConfig.MdtrtareaAdmvs == "320921" {
  5054. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  5055. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5056. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5057. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5058. } else {
  5059. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5060. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  5061. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5062. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5063. }
  5064. resp3, requestErr3 := http.Get(api3)
  5065. if requestErr3 != nil {
  5066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5067. return
  5068. }
  5069. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5070. if ioErr3 != nil {
  5071. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5073. return
  5074. }
  5075. var respJSON3 map[string]interface{}
  5076. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5077. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5079. return
  5080. }
  5081. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5082. userJSONBytes3, _ := json.Marshal(respJSON3)
  5083. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  5084. utils.ErrorLog("解析失败:%v", err)
  5085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5086. return
  5087. }
  5088. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5089. res2.Output = resSix10265.Output
  5090. res2.ErrMsg = resSix10265.ErrMsg
  5091. res2.Cainfo = resSix10265.Cainfo
  5092. res2.WarnMsg = resSix10265.WarnMsg
  5093. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5094. res2.Infcode = infocode
  5095. if res2.Infcode == 0 {
  5096. var msg []string
  5097. msg = append(msg, "挂号失败")
  5098. for _, item := range res.Output.Result {
  5099. msg = append(msg, item.VolaCont)
  5100. }
  5101. c.ServeSuccessJSON(map[string]interface{}{
  5102. "failed_code": -10,
  5103. "msg": msg,
  5104. })
  5105. } else {
  5106. c.ServeSuccessJSON(map[string]interface{}{
  5107. "failed_code": -10,
  5108. "msg": res2.ErrMsg,
  5109. })
  5110. }
  5111. } else {
  5112. c.ServeSuccessJSON(map[string]interface{}{
  5113. "his_info": his,
  5114. })
  5115. }
  5116. } else {
  5117. c.ServeSuccessJSON(map[string]interface{}{
  5118. "failed_code": -10,
  5119. "msg": res.ErrMsg,
  5120. })
  5121. }
  5122. } else {
  5123. adminUser := c.GetAdminUserInfo()
  5124. errlog := &models.HisOrderError{
  5125. UserOrgId: adminUser.CurrentOrgId,
  5126. Ctime: time.Now().Unix(),
  5127. Mtime: time.Now().Unix(),
  5128. ErrMsg: res.ErrMsg,
  5129. Status: 1,
  5130. PatientId: id,
  5131. RecordTime: recordDateTime,
  5132. Stage: 1,
  5133. }
  5134. service.CreateErrMsgLog(errlog)
  5135. c.ServeSuccessJSON(map[string]interface{}{
  5136. "failed_code": -10,
  5137. "msg": res.ErrMsg,
  5138. })
  5139. return
  5140. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  5141. }
  5142. }
  5143. }
  5144. //上传明细----预结算----确认订单
  5145. func (c *HisApiController) GetUploadInfo() {
  5146. id, _ := c.GetInt64("id")
  5147. record_time := c.GetString("record_time")
  5148. his_patient_id, _ := c.GetInt64("his_patient_id")
  5149. order_id, _ := c.GetInt64("order_id")
  5150. pay_way, _ := c.GetInt64("pay_way")
  5151. pay_price, _ := c.GetFloat("pay_price")
  5152. pay_card_no := c.GetString("pay_card_no")
  5153. token := c.GetString("token")
  5154. discount_price, _ := c.GetFloat("discount_price")
  5155. preferential_price, _ := c.GetFloat("preferential_price")
  5156. reality_price, _ := c.GetFloat("reality_price")
  5157. found_price, _ := c.GetFloat("found_price")
  5158. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5159. private_price, _ := c.GetFloat("private_price")
  5160. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5161. admin_user_id, _ := c.GetInt64("admin_user_id")
  5162. fapiao_code := c.GetString("fapiao_code")
  5163. fapiao_number := c.GetString("fapiao_number")
  5164. diagnosis_id := c.GetString("diagnosis")
  5165. sick_type, _ := c.GetInt64("sick_type")
  5166. reg_type, _ := c.GetInt64("p_type")
  5167. begin_time := c.GetString("begin_time")
  5168. id_str := c.GetString("ids")
  5169. ids_arr := strings.Split(id_str, ",")
  5170. timeLayout := "2006-01-02"
  5171. loc, _ := time.LoadLocation("Local")
  5172. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5173. if err != nil {
  5174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5175. return
  5176. }
  5177. recordDateTime := theTime.Unix()
  5178. adminUser := c.GetAdminUserInfo()
  5179. var tempOrder models.HisOrder
  5180. tempOrder, _ = service.GetHisOrderByID(order_id)
  5181. var prescriptions []*models.HisPrescription
  5182. var start_time int64
  5183. var end_time int64
  5184. //押金模块
  5185. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  5186. tmp_decimal := c.GetString("tmp_decimal")
  5187. var decimal float64 //本次使用的押金
  5188. var errmsg error
  5189. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  5190. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  5191. return
  5192. }
  5193. if len(tmp_decimal) > 0 {
  5194. if tmp_decimal[0] == 45 {
  5195. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  5196. return
  5197. }
  5198. }
  5199. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  5200. fmt.Println(errs)
  5201. decimal = tt
  5202. //if adminUser.CurrentOrgId == 10106{
  5203. // if len(fapiao_code) == 0{
  5204. // fapiao_code = "144072080589"
  5205. // }
  5206. // if len(fapiao_number) == 0{
  5207. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  5208. // if order.ID == 0{
  5209. // fapiao_number = "00001520"
  5210. // }else{
  5211. // //fapiao_code = "00001520"
  5212. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  5213. // var zero string
  5214. // if fpNumber >= 1000{
  5215. // zero = "0000" + strconv.Itoa(fpNumber)
  5216. // }else if fpNumber >= 10000{
  5217. // zero = "000" + strconv.Itoa(fpNumber)
  5218. // } else if fpNumber >= 100000{
  5219. // zero = "00" + strconv.Itoa(fpNumber)
  5220. // } else if fpNumber >= 1000000{
  5221. // zero = "0" + strconv.Itoa(fpNumber)
  5222. // }else {
  5223. // zero = strconv.Itoa(fpNumber)
  5224. // }
  5225. // fapiao_number = zero
  5226. // }
  5227. // }
  5228. //}
  5229. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5230. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5231. var patientPrescription models.HisPrescriptionInfo
  5232. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5233. if patientPrescription.ID == 0 {
  5234. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5235. }
  5236. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5237. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5238. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5239. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5240. var config []*models.HisXtDiagnoseConfig
  5241. for _, item := range diagnosis_ids {
  5242. id, _ := strconv.ParseInt(item, 10, 64)
  5243. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5244. config = append(config, &diagnosisConfig)
  5245. }
  5246. sickConfig, _ := service.FindSickById(sick_type)
  5247. //if tempOrder.ID == 0 {
  5248. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  5249. //}
  5250. if tempOrder.ID == 0 {
  5251. var result string
  5252. var requestLog string
  5253. var res2 ResultSix
  5254. var ressix10265 ResultSix10265
  5255. if miConfig.MdtrtareaAdmvs == "421300" {
  5256. data := make(map[string]interface{})
  5257. client := &http.Client{}
  5258. data["psn_no"] = his.PsnNo
  5259. data["mdtrt_id"] = his.Number
  5260. data["opter"] = roles.UserName
  5261. data["org_name"] = miConfig.OrgName
  5262. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5263. data["doctor_id"] = doctor_info.DoctorNumber
  5264. data["doctor_name"] = doctor_info.UserName
  5265. data["department"] = department.Name
  5266. data["fixmedins_code"] = miConfig.Code
  5267. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5268. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5269. data["secret_key"] = miConfig.SecretKey
  5270. data["sick_code"] = sickConfig.CountryCode
  5271. data["sick_name"] = sickConfig.ClassName
  5272. data["dept"] = strconv.FormatInt(department.ID, 10)
  5273. data["config"] = config
  5274. data["begin_time"] = begin_time
  5275. bytesData, _ := json.Marshal(data)
  5276. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5277. resp, _ := client.Do(req)
  5278. defer resp.Body.Close()
  5279. body, ioErr := ioutil.ReadAll(resp.Body)
  5280. if ioErr != nil {
  5281. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5283. return
  5284. }
  5285. var respJSON map[string]interface{}
  5286. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5289. return
  5290. }
  5291. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5292. userJSONBytes, _ := json.Marshal(respJSON)
  5293. fmt.Println("log")
  5294. fmt.Println(string(userJSONBytes))
  5295. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5296. utils.ErrorLog("解析失败:%v", err)
  5297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5298. return
  5299. }
  5300. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5301. //江苏地区国家医保医疗类别
  5302. //职工透析:医疗类别选特殊情况门诊9933
  5303. //居民血透门慢: 医疗类别选门诊慢病1402
  5304. //var med_type string
  5305. //if his.Insutype == "310" {
  5306. // if reg_type == 14 {
  5307. // med_type = "9933"
  5308. // } else if reg_type == 11 {
  5309. // med_type = "11"
  5310. //
  5311. // }
  5312. //} else if his.Insutype == "390" {
  5313. // if reg_type == 14 {
  5314. // med_type = "1402"
  5315. // } else if reg_type == 11 {
  5316. // med_type = "11"
  5317. // }
  5318. //}
  5319. data := make(map[string]interface{})
  5320. client := &http.Client{}
  5321. data["psn_no"] = his.PsnNo
  5322. data["mdtrt_id"] = his.Number
  5323. data["doctor"] = roles.UserName
  5324. data["department"] = department.Name
  5325. data["org_name"] = miConfig.OrgName
  5326. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5327. data["doctor_id"] = doctor_info.DoctorNumber
  5328. data["new_doctor_name"] = doctor_info.UserName
  5329. data["fixmedins_code"] = miConfig.Code
  5330. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5331. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5332. data["secret_key"] = miConfig.SecretKey
  5333. data["sick_code"] = sickConfig.CountryCode
  5334. data["sick_name"] = sickConfig.ClassName
  5335. data["url"] = miConfig.Url
  5336. data["ak"] = miConfig.AccessKey
  5337. data["begin_time"] = begin_time
  5338. data["cainfo"] = miConfig.Cainfo
  5339. data["dept"] = strconv.FormatInt(department.ID, 10)
  5340. data["config"] = config
  5341. bytesData, _ := json.Marshal(data)
  5342. var req *http.Request
  5343. if miConfig.MdtrtareaAdmvs == "320921" {
  5344. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5345. //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 +
  5346. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5347. } else {
  5348. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5349. }
  5350. resp, _ := client.Do(req)
  5351. defer resp.Body.Close()
  5352. body, ioErr := ioutil.ReadAll(resp.Body)
  5353. if ioErr != nil {
  5354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5356. return
  5357. }
  5358. var respJSON map[string]interface{}
  5359. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5362. return
  5363. }
  5364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5365. userJSONBytes, _ := json.Marshal(respJSON)
  5366. fmt.Println("log")
  5367. fmt.Println(string(userJSONBytes))
  5368. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5369. utils.ErrorLog("解析失败:%v", err)
  5370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5371. return
  5372. }
  5373. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5374. res2.Output = ressix10265.Output
  5375. res2.ErrMsg = ressix10265.ErrMsg
  5376. res2.Cainfo = ressix10265.Cainfo
  5377. res2.WarnMsg = ressix10265.WarnMsg
  5378. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5379. res2.Infcode = infocode
  5380. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5381. 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)
  5382. saveLog(result, requestLog, "2203", "上传就诊信息")
  5383. var respJSON2 map[string]interface{}
  5384. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5387. return
  5388. }
  5389. userJSONBytes2, _ := json.Marshal(respJSON2)
  5390. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5391. utils.ErrorLog("解析失败:%v", err)
  5392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5393. return
  5394. }
  5395. } else {
  5396. if miConfig.MdtrtareaAdmvs == "440781" { //
  5397. 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)
  5398. } else {
  5399. if miConfig.Code == "H15049901371" {
  5400. //赤峰地区国家医保医疗类别
  5401. //职工透析:医疗类别选特殊情况门诊990502
  5402. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5403. var med_type string
  5404. if his.Insutype == "390" {
  5405. if reg_type == 14 {
  5406. med_type = "9933"
  5407. } else if reg_type == 11 {
  5408. med_type = "11"
  5409. }
  5410. } else if his.Insutype == "310" {
  5411. if reg_type == 14 {
  5412. med_type = "990502"
  5413. } else if reg_type == 11 {
  5414. med_type = "11"
  5415. }
  5416. }
  5417. 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)
  5418. } else {
  5419. 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)
  5420. }
  5421. }
  5422. saveLog(result, requestLog, "2203", "上传就诊信息")
  5423. var respJSON2 map[string]interface{}
  5424. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5427. return
  5428. }
  5429. userJSONBytes2, _ := json.Marshal(respJSON2)
  5430. if miConfig.Code == "H15049901371" {
  5431. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5432. utils.ErrorLog("解析失败:%v", err)
  5433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5434. return
  5435. }
  5436. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5437. res2.Output = ressix10265.Output
  5438. res2.ErrMsg = ressix10265.ErrMsg
  5439. res2.Cainfo = ressix10265.Cainfo
  5440. res2.WarnMsg = ressix10265.WarnMsg
  5441. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5442. res2.Infcode = infocode
  5443. } else {
  5444. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5445. utils.ErrorLog("解析失败:%v", err)
  5446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5447. return
  5448. }
  5449. }
  5450. }
  5451. if res2.Infcode != 0 {
  5452. adminUser := c.GetAdminUserInfo()
  5453. errlog := &models.HisOrderError{
  5454. UserOrgId: adminUser.CurrentOrgId,
  5455. Ctime: time.Now().Unix(),
  5456. Mtime: time.Now().Unix(),
  5457. ErrMsg: res2.ErrMsg,
  5458. Status: 1,
  5459. PatientId: id,
  5460. RecordTime: recordDateTime,
  5461. Stage: 3,
  5462. }
  5463. service.CreateErrMsgLog(errlog)
  5464. c.ServeSuccessJSON(map[string]interface{}{
  5465. "failed_code": -10,
  5466. "msg": res2.ErrMsg,
  5467. })
  5468. return
  5469. } else {
  5470. his.Diagnosis = diagnosis_id
  5471. his.SickType = sickConfig.ID
  5472. //var p_type int64
  5473. //if reg_type == 1111 || reg_type == 1112 {
  5474. // p_type = 11
  5475. //
  5476. //}
  5477. his.PType = fmt.Sprintf("%d", reg_type)
  5478. service.UpdateHisPatientThree(&his)
  5479. data := make(map[string]interface{})
  5480. if settle_accounts_type == 1 { //日结
  5481. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5482. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5483. } else {
  5484. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5485. }
  5486. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5487. data["pre"] = prescriptions
  5488. } else { //月结
  5489. start_time_str := c.GetString("start_time")
  5490. end_time_str := c.GetString("end_time")
  5491. timeLayout := "2006-01-02"
  5492. loc, _ := time.LoadLocation("Local")
  5493. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5494. if err != nil {
  5495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5496. return
  5497. }
  5498. recordStartTime := theStartTime.Unix()
  5499. start_time = recordStartTime
  5500. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5501. if err != nil {
  5502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5503. return
  5504. }
  5505. recordEndTime := theEndTime.Unix()
  5506. end_time = recordEndTime
  5507. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5508. data["pre"] = prescriptions
  5509. }
  5510. timestamp := time.Now().Unix()
  5511. tempTime := time.Unix(timestamp, 0)
  5512. timeFormat := tempTime.Format("20060102150405")
  5513. chrgBchno := rand.Intn(100000) + 10000
  5514. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5515. strconv.FormatInt(his.PatientId, 10)
  5516. client := &http.Client{}
  5517. data["psn_no"] = his.PsnNo
  5518. data["mdtrt_id"] = his.Number
  5519. data["chrg_bchno"] = chrg_bchno
  5520. data["org_name"] = miConfig.OrgName
  5521. data["doctor"] = doctor_info.UserName
  5522. data["doctor_id"] = doctor_info.DoctorNumber
  5523. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5524. data["fixmedins_code"] = miConfig.Code
  5525. data["opter"] = roles.UserName
  5526. data["dept_code"] = department.Number
  5527. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5528. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5529. data["secret_key"] = miConfig.SecretKey
  5530. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5531. data["url"] = miConfig.Url
  5532. data["ak"] = miConfig.AccessKey
  5533. data["new_doctor_name"] = patientPrescription.Doctor
  5534. data["diag_code"] = sickConfig.CountryCode
  5535. data["cainfo"] = miConfig.Cainfo
  5536. var ids []int64
  5537. for _, item := range prescriptions {
  5538. ids = append(ids, item.ID)
  5539. }
  5540. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5541. if config.IsOpen == 1 { //对接了医保,走医保流程
  5542. var res ResultFour
  5543. var resFour10265 ResultFour10265
  5544. if miConfig.MdtrtareaAdmvs == "421300" {
  5545. bytesData, _ := json.Marshal(data)
  5546. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5547. resp, _ := client.Do(req)
  5548. defer resp.Body.Close()
  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(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. userJSONBytes, _ := json.Marshal(respJSON)
  5563. fmt.Println("log")
  5564. fmt.Println(string(userJSONBytes))
  5565. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5566. utils.ErrorLog("解析失败:%v", err)
  5567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5568. return
  5569. }
  5570. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5571. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  5572. if result3101.Infcode == "0" {
  5573. if len(result3101.Output.Result) > 0 {
  5574. var errMsgs []string
  5575. for _, item := range result3101.Output.Result {
  5576. errMsgs = append(errMsgs, item.VolaCont)
  5577. }
  5578. c.ServeSuccessJSON(map[string]interface{}{
  5579. "failed_code": -10,
  5580. "msg": errMsgs,
  5581. })
  5582. return
  5583. }
  5584. }
  5585. bytesData, _ := json.Marshal(data)
  5586. var req *http.Request
  5587. if miConfig.MdtrtareaAdmvs == "320921" {
  5588. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5589. } else {
  5590. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5591. }
  5592. resp, _ := client.Do(req)
  5593. defer resp.Body.Close()
  5594. body, ioErr := ioutil.ReadAll(resp.Body)
  5595. if ioErr != nil {
  5596. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5598. return
  5599. }
  5600. var respJSON map[string]interface{}
  5601. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5604. return
  5605. }
  5606. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5607. userJSONBytes, _ := json.Marshal(respJSON)
  5608. fmt.Println("log")
  5609. fmt.Println(string(userJSONBytes))
  5610. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5611. utils.ErrorLog("解析失败:%v", err)
  5612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5613. return
  5614. }
  5615. res.InfRefmsgid = resFour10265.InfRefmsgid
  5616. res.Output = resFour10265.Output
  5617. res.ErrMsg = resFour10265.ErrMsg
  5618. res.Cainfo = resFour10265.Cainfo
  5619. res.WarnMsg = resFour10265.WarnMsg
  5620. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5621. res.Infcode = infocode
  5622. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5623. 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)
  5624. var dat map[string]interface{}
  5625. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5626. fmt.Println(dat)
  5627. } else {
  5628. fmt.Println(err)
  5629. }
  5630. saveLog(result, request_log, "2204", "上传费用明细")
  5631. userJSONBytes, _ := json.Marshal(dat)
  5632. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5633. utils.ErrorLog("解析失败:%v", err)
  5634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5635. return
  5636. }
  5637. res.InfRefmsgid = resFour10265.InfRefmsgid
  5638. res.Output = resFour10265.Output
  5639. res.ErrMsg = resFour10265.ErrMsg
  5640. res.Cainfo = resFour10265.Cainfo
  5641. res.WarnMsg = resFour10265.WarnMsg
  5642. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5643. res.Infcode = infocode
  5644. } else {
  5645. if miConfig.Code == "H15049901371" {
  5646. 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)
  5647. var dat map[string]interface{}
  5648. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5649. fmt.Println(dat)
  5650. } else {
  5651. fmt.Println(err)
  5652. }
  5653. saveLog(result, request_log, "2204", "上传费用明细")
  5654. userJSONBytes, _ := json.Marshal(dat)
  5655. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5656. utils.ErrorLog("解析失败:%v", err)
  5657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5658. return
  5659. }
  5660. res.InfRefmsgid = resFour10265.InfRefmsgid
  5661. res.Output = resFour10265.Output
  5662. res.ErrMsg = resFour10265.ErrMsg
  5663. res.Cainfo = resFour10265.Cainfo
  5664. res.WarnMsg = resFour10265.WarnMsg
  5665. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5666. res.Infcode = infocode
  5667. } else {
  5668. 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)
  5669. var dat map[string]interface{}
  5670. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5671. fmt.Println(dat)
  5672. } else {
  5673. fmt.Println(err)
  5674. }
  5675. saveLog(result, request_log, "2204", "上传费用明细")
  5676. userJSONBytes, _ := json.Marshal(dat)
  5677. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5678. utils.ErrorLog("解析失败:%v", err)
  5679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5680. return
  5681. }
  5682. }
  5683. }
  5684. if res.Infcode == 0 {
  5685. order := &models.HisOrder{
  5686. UserOrgId: adminUser.CurrentOrgId,
  5687. HisPatientId: his.ID,
  5688. PatientId: his.PatientId,
  5689. SettleAccountsDate: recordDateTime,
  5690. MdtrtId: his.Number,
  5691. PsnNo: his.PsnNo,
  5692. MedType: strconv.FormatInt(reg_type, 10),
  5693. Ctime: time.Now().Unix(),
  5694. Mtime: time.Now().Unix(),
  5695. Status: 1,
  5696. Number: chrg_bchno,
  5697. Infcode: res.Infcode,
  5698. WarnMsg: res.WarnMsg,
  5699. Cainfo: res.Cainfo,
  5700. ErrMsg: res.ErrMsg,
  5701. RespondTime: res.RefmsgTime,
  5702. InfRefmsgid: res.InfRefmsgid,
  5703. OrderStatus: 1,
  5704. PayWay: pay_way,
  5705. PayPrice: pay_price,
  5706. PayCardNo: pay_card_no,
  5707. DiscountPrice: discount_price,
  5708. PreferentialPrice: preferential_price,
  5709. RealityPrice: reality_price,
  5710. FoundPrice: found_price,
  5711. MedicalInsurancePrice: medical_insurance_price,
  5712. PrivatePrice: private_price,
  5713. IsMedicineInsurance: 1,
  5714. SettleType: settle_accounts_type,
  5715. SettleStartTime: start_time,
  5716. SettleEndTime: end_time,
  5717. Creator: roles.AdminUserId,
  5718. Modify: roles.AdminUserId,
  5719. FaPiaoNumber: fapiao_number,
  5720. FaPiaoCode: fapiao_code,
  5721. PType: 2,
  5722. Diagnosis: diagnosis_id,
  5723. }
  5724. err = service.CreateOrder(order)
  5725. if err != nil {
  5726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5727. return
  5728. }
  5729. for _, item := range res.Output.Result {
  5730. temp := strings.Split(item.FeedetlSn, "-")
  5731. var advice_id int64 = 0
  5732. var project_id int64 = 0
  5733. var types int64 = 0
  5734. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5735. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5736. if temp[1] == "1" {
  5737. advice_id = id
  5738. project_id = 0
  5739. } else if temp[1] == "2" {
  5740. advice_id = 0
  5741. project_id = id
  5742. }
  5743. info := &models.HisOrderInfo{
  5744. OrderNumber: order.Number,
  5745. FeedetlSn: item.FeedetlSn,
  5746. UploadDate: time.Now().Unix(),
  5747. AdviceId: advice_id,
  5748. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5749. Cnt: item.Cnt,
  5750. Pric: float64(item.Pric),
  5751. PatientId: his.PatientId,
  5752. PricUplmtAmt: item.PricUplmtAmt,
  5753. SelfpayProp: item.SelfpayProp,
  5754. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5755. OverlmtAmt: item.OverlmtAmt,
  5756. PreselfpayAmt: item.PreselfpayAmt,
  5757. BasMednFlag: item.BasMednFlag,
  5758. MedChrgitmType: item.MedChrgitmType,
  5759. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5760. Status: 1,
  5761. Memo: item.Memo,
  5762. Mtime: time.Now().Unix(),
  5763. InscpScpAmt: item.InscpScpAmt,
  5764. DrtReimFlag: item.DrtReimFlag,
  5765. Ctime: time.Now().Unix(),
  5766. ListSpItemFlag: item.ListSpItemFlag,
  5767. ChldMedcFlag: item.ChldMedcFlag,
  5768. LmtUsedFlag: item.LmtUsedFlag,
  5769. ChrgitmLv: item.ChrgitmLv,
  5770. UserOrgId: adminUser.CurrentOrgId,
  5771. HisPatientId: his.ID,
  5772. OrderId: order.ID,
  5773. ProjectId: project_id,
  5774. Type: types,
  5775. }
  5776. service.CreateOrderInfo(info)
  5777. }
  5778. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5779. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5780. var total float64
  5781. for _, item := range prescriptions {
  5782. if item.Type == 1 { //药品
  5783. for _, subItem := range item.HisDoctorAdviceInfo {
  5784. total = total + (subItem.Price * subItem.PrescribingNumber)
  5785. }
  5786. }
  5787. if item.Type == 2 { //项目
  5788. for _, subItem := range item.HisPrescriptionProject {
  5789. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5790. total = total + (subItem.Price * cnt)
  5791. }
  5792. }
  5793. }
  5794. for _, item := range prescriptions {
  5795. for _, subItem := range item.HisAdditionalCharge {
  5796. total = total + (subItem.Price * float64(subItem.Count))
  5797. }
  5798. }
  5799. var allTotal string
  5800. if adminUser.CurrentOrgId == 9919 {
  5801. allTotal = fmt.Sprintf("%.4f", total)
  5802. } else {
  5803. allTotal = fmt.Sprintf("%.4f", total)
  5804. }
  5805. if res.Infcode == 0 {
  5806. var rf []*ResultFive
  5807. json.Unmarshal([]byte(his.Iinfo), &rf)
  5808. chrg_bchno := chrg_bchno
  5809. cert_no := his.Certno
  5810. var insutypes []string
  5811. var insutype string
  5812. var is390 int = 0
  5813. var is310 int = 0
  5814. for _, item := range rf {
  5815. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5816. insutypes = append(insutypes, item.Insutype)
  5817. }
  5818. }
  5819. if len(insutypes) == 1 {
  5820. insutype = insutypes[0]
  5821. } else {
  5822. for _, i := range insutypes {
  5823. if i == "390" {
  5824. is390 = 1
  5825. }
  5826. if i == "310" {
  5827. is310 = 1
  5828. }
  5829. }
  5830. }
  5831. if is390 == 1 {
  5832. insutype = "390"
  5833. }
  5834. if is310 == 1 {
  5835. insutype = "310"
  5836. }
  5837. if len(insutypes) == 0 {
  5838. insutype = "310"
  5839. }
  5840. if len(insutypes) == 2 {
  5841. insutype = strconv.FormatInt(his.SocialType, 10)
  5842. }
  5843. insutype = strconv.FormatInt(his.SocialType, 10)
  5844. //insutype = "390"
  5845. if his.IdCardType == 1 {
  5846. // cert_no = his.MedicalInsuranceNumber
  5847. cert_no = his.Certno
  5848. } else {
  5849. cert_no = his.Certno
  5850. }
  5851. var res ResultSeven
  5852. var resSeven10265 ResultSeven10265
  5853. var src_resquest string
  5854. var result2 string
  5855. var acct_used_flag string
  5856. fmt.Println("pay_way")
  5857. fmt.Println(pay_way)
  5858. fmt.Println("pay_way")
  5859. if pay_way == 4 {
  5860. acct_used_flag = "1"
  5861. } else {
  5862. acct_used_flag = "0"
  5863. }
  5864. if miConfig.MdtrtareaAdmvs == "421300" {
  5865. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5866. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5867. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5868. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5869. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5870. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5871. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5872. resp, requestErr := http.Get(api)
  5873. if requestErr != nil {
  5874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5875. return
  5876. }
  5877. body, ioErr := ioutil.ReadAll(resp.Body)
  5878. if ioErr != nil {
  5879. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5881. return
  5882. }
  5883. var respJSON map[string]interface{}
  5884. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5885. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5887. return
  5888. }
  5889. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5890. result, _ := json.Marshal(respJSON)
  5891. if miConfig.Code == "H15049901371" {
  5892. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5893. utils.ErrorLog("解析失败:%v", err)
  5894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5895. return
  5896. }
  5897. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5898. res.Output = resSeven10265.Output
  5899. res.ErrMsg = resSeven10265.ErrMsg
  5900. res.Cainfo = resSeven10265.Cainfo
  5901. res.WarnMsg = resSeven10265.WarnMsg
  5902. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5903. res.Infcode = infocode
  5904. } else {
  5905. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5906. utils.ErrorLog("解析失败:%v", err)
  5907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5908. return
  5909. }
  5910. }
  5911. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5912. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5913. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5914. bas := strings.Split(psn_info.CardInfo, "|")
  5915. if his.IdCardType == 1 {
  5916. cert_no = bas[2]
  5917. } else if his.IdCardType == 3 {
  5918. cert_no = his.Certno
  5919. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5920. } else if his.IdCardType == 4 {
  5921. cert_no = his.Certno
  5922. psn_info.VerifyNumber = token
  5923. }
  5924. var api string
  5925. if miConfig.MdtrtareaAdmvs == "320921" {
  5926. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5927. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5928. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5929. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5930. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5931. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5932. "&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
  5933. } else {
  5934. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5935. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5936. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5937. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5938. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5939. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5940. "&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
  5941. }
  5942. resp, requestErr := http.Get(api)
  5943. if requestErr != nil {
  5944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5945. return
  5946. }
  5947. body, ioErr := ioutil.ReadAll(resp.Body)
  5948. if ioErr != nil {
  5949. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5951. return
  5952. }
  5953. var respJSON map[string]interface{}
  5954. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5957. return
  5958. }
  5959. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5960. result, _ := json.Marshal(respJSON)
  5961. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5962. utils.ErrorLog("解析失败:%v", err)
  5963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5964. return
  5965. }
  5966. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5967. res.Output = resSeven10265.Output
  5968. res.ErrMsg = resSeven10265.ErrMsg
  5969. res.Cainfo = resSeven10265.Cainfo
  5970. res.WarnMsg = resSeven10265.WarnMsg
  5971. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5972. res.Infcode = infocode
  5973. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5974. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5975. var cert_no string
  5976. if his.IdCardType == 1 {
  5977. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  5978. }
  5979. fmt.Println(cert_no)
  5980. 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)
  5981. //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)
  5982. var dat map[string]interface{}
  5983. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5984. fmt.Println(dat)
  5985. } else {
  5986. fmt.Println(err)
  5987. }
  5988. saveLog(result2, src_resquest, "2207", "结算")
  5989. userJSONBytes, _ := json.Marshal(dat)
  5990. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5991. utils.ErrorLog("解析失败:%v", err)
  5992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5993. return
  5994. }
  5995. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5996. res.Output = resSeven10265.Output
  5997. res.ErrMsg = resSeven10265.ErrMsg
  5998. res.Cainfo = resSeven10265.Cainfo
  5999. res.WarnMsg = resSeven10265.WarnMsg
  6000. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6001. res.Infcode = infocode
  6002. } else {
  6003. if miConfig.Code == "H15049901371" {
  6004. //赤峰地区国家医保医疗类别
  6005. //职工透析:医疗类别选特殊情况门诊990502
  6006. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6007. var med_type string
  6008. if his.Insutype == "390" {
  6009. if reg_type == 14 {
  6010. med_type = "9933"
  6011. } else if reg_type == 11 {
  6012. med_type = "11"
  6013. }
  6014. } else if his.Insutype == "310" {
  6015. if reg_type == 14 {
  6016. med_type = "990502"
  6017. } else if reg_type == 11 {
  6018. med_type = "11"
  6019. }
  6020. }
  6021. 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)
  6022. } else {
  6023. 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)
  6024. }
  6025. //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)
  6026. var dat map[string]interface{}
  6027. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6028. fmt.Println(dat)
  6029. } else {
  6030. fmt.Println(err)
  6031. }
  6032. saveLog(result2, src_resquest, "2207", "结算")
  6033. userJSONBytes, _ := json.Marshal(dat)
  6034. if miConfig.Code == "H15049901371" {
  6035. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6036. utils.ErrorLog("解析失败:%v", err)
  6037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6038. return
  6039. }
  6040. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6041. res.Output = resSeven10265.Output
  6042. res.ErrMsg = resSeven10265.ErrMsg
  6043. res.Cainfo = resSeven10265.Cainfo
  6044. res.WarnMsg = resSeven10265.WarnMsg
  6045. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6046. res.Infcode = infocode
  6047. } else {
  6048. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6049. utils.ErrorLog("解析失败:%v", err)
  6050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6051. return
  6052. }
  6053. }
  6054. }
  6055. if res.Infcode != 0 {
  6056. errlog := &models.HisOrderError{
  6057. UserOrgId: adminUser.CurrentOrgId,
  6058. Ctime: time.Now().Unix(),
  6059. Mtime: time.Now().Unix(),
  6060. Number: chrg_bchno,
  6061. ErrMsg: res.ErrMsg,
  6062. Status: 1,
  6063. PatientId: id,
  6064. RecordTime: recordDateTime,
  6065. Stage: 6,
  6066. }
  6067. service.CreateErrMsgLog(errlog)
  6068. c.ServeSuccessJSON(map[string]interface{}{
  6069. "failed_code": -10,
  6070. "msg": res.ErrMsg,
  6071. })
  6072. return
  6073. } else {
  6074. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6075. order.OrderStatus = 2
  6076. order.Status = 1
  6077. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6078. order.SetlId = res.Output.Setlinfo.SetlID
  6079. order.PsnNo = res.Output.Setlinfo.PsnNo
  6080. order.PsnName = res.Output.Setlinfo.PsnName
  6081. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6082. order.Certno = res.Output.Setlinfo.Certno
  6083. order.Gend = res.Output.Setlinfo.Gend
  6084. order.Naty = res.Output.Setlinfo.Naty
  6085. order.Age = res.Output.Setlinfo.Age
  6086. order.Insutype = res.Output.Setlinfo.Insutype
  6087. order.PsnType = res.Output.Setlinfo.PsnType
  6088. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6089. order.SetlTime = res.Output.Setlinfo.SetlTime
  6090. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6091. if res.Output.Setlinfo.MedType == "140101" {
  6092. order.MedType = "14"
  6093. } else {
  6094. order.MedType = res.Output.Setlinfo.MedType
  6095. }
  6096. if reg_type == 1112 {
  6097. order.MedType = "1112"
  6098. }
  6099. if reg_type == 1111 {
  6100. order.MedType = "1111"
  6101. }
  6102. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6103. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6104. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6105. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6106. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6107. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6108. order.HifpPay = res.Output.Setlinfo.HifpPay
  6109. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6110. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6111. order.HifesPay = res.Output.Setlinfo.HifesPay
  6112. order.HifobPay = res.Output.Setlinfo.HifobPay
  6113. order.MafPay = res.Output.Setlinfo.MafPay
  6114. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6115. order.OthPay = res.Output.Setlinfo.OthPay
  6116. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6117. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6118. order.AcctPay = res.Output.Setlinfo.AcctPay
  6119. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6120. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6121. order.Balc = res.Output.Setlinfo.Balc
  6122. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6123. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6124. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6125. order.ClrType = res.Output.Setlinfo.ClrType
  6126. order.ClrWay = res.Output.Setlinfo.ClrWay
  6127. order.Creator = order.Creator
  6128. order.Modify = roles.AdminUserId
  6129. order.RequestLog = src_resquest
  6130. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6131. detailStr := string(setlDetail)
  6132. order.SetlDetail = detailStr
  6133. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6134. err = service.UpDateOrder(order)
  6135. if err == nil {
  6136. //判断是否使用了押金
  6137. if dec_way == "true" {
  6138. tmpstring := strconv.FormatInt(order.ID, 10)
  6139. order.Decimal = decimal
  6140. service.UpDateOrder(order)
  6141. //扣押金
  6142. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6143. if errmsg != nil {
  6144. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6145. return
  6146. }
  6147. }
  6148. c.ServeSuccessJSON(map[string]interface{}{
  6149. "msg": "结算成功",
  6150. })
  6151. } else {
  6152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6153. return
  6154. }
  6155. }
  6156. } else {
  6157. adminUser := c.GetAdminUserInfo()
  6158. errlog := &models.HisOrderError{
  6159. UserOrgId: adminUser.CurrentOrgId,
  6160. Ctime: time.Now().Unix(),
  6161. Mtime: time.Now().Unix(),
  6162. ErrMsg: res.ErrMsg,
  6163. Status: 1,
  6164. PatientId: id,
  6165. RecordTime: recordDateTime,
  6166. Stage: 4,
  6167. }
  6168. service.CreateErrMsgLog(errlog)
  6169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6170. return
  6171. }
  6172. } else {
  6173. adminUser := c.GetAdminUserInfo()
  6174. errlog := &models.HisOrderError{
  6175. UserOrgId: adminUser.CurrentOrgId,
  6176. Ctime: time.Now().Unix(),
  6177. Mtime: time.Now().Unix(),
  6178. ErrMsg: res.ErrMsg,
  6179. Status: 1,
  6180. PatientId: id,
  6181. RecordTime: recordDateTime,
  6182. Stage: 4,
  6183. }
  6184. service.CreateErrMsgLog(errlog)
  6185. c.ServeSuccessJSON(map[string]interface{}{
  6186. "failed_code": -10,
  6187. "msg": res.ErrMsg,
  6188. })
  6189. return
  6190. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6191. //return
  6192. }
  6193. }
  6194. }
  6195. } else if tempOrder.ID > 0 {
  6196. if tempOrder.IsPre == 1 {
  6197. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  6198. var rf []*ResultFive
  6199. json.Unmarshal([]byte(his.Iinfo), &rf)
  6200. chrg_bchno := tempOrder.Number
  6201. cert_no := his.Certno
  6202. var insutypes []string
  6203. var insutype string
  6204. var is390 int = 0
  6205. var is310 int = 0
  6206. for _, item := range rf {
  6207. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6208. insutypes = append(insutypes, item.Insutype)
  6209. }
  6210. }
  6211. if len(insutypes) == 1 {
  6212. insutype = insutypes[0]
  6213. } else {
  6214. for _, i := range insutypes {
  6215. if i == "390" {
  6216. is390 = 1
  6217. }
  6218. if i == "310" {
  6219. is310 = 1
  6220. }
  6221. }
  6222. }
  6223. if is390 == 1 {
  6224. insutype = "390"
  6225. }
  6226. if is310 == 1 {
  6227. insutype = "310"
  6228. }
  6229. if len(insutypes) == 0 {
  6230. insutype = "310"
  6231. }
  6232. if len(insutypes) == 2 {
  6233. insutype = strconv.FormatInt(his.SocialType, 64)
  6234. }
  6235. //insutype = "390"
  6236. if his.IdCardType == 1 {
  6237. // cert_no = his.MedicalInsuranceNumber
  6238. cert_no = his.Certno
  6239. } else {
  6240. cert_no = his.Certno
  6241. }
  6242. var res ResultSeven
  6243. var resSeven10265 ResultSeven10265
  6244. var src_resquest string
  6245. var result2 string
  6246. var acct_used_flag string
  6247. fmt.Println("pay_way")
  6248. fmt.Println(pay_way)
  6249. fmt.Println("pay_way")
  6250. if pay_way == 4 {
  6251. acct_used_flag = "1"
  6252. } else {
  6253. acct_used_flag = "0"
  6254. }
  6255. if miConfig.MdtrtareaAdmvs == "421300" {
  6256. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6257. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6258. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6259. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6260. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6261. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6262. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6263. resp, requestErr := http.Get(api)
  6264. if requestErr != nil {
  6265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6266. return
  6267. }
  6268. body, ioErr := ioutil.ReadAll(resp.Body)
  6269. if ioErr != nil {
  6270. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6272. return
  6273. }
  6274. var respJSON map[string]interface{}
  6275. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6276. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6278. return
  6279. }
  6280. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6281. result, _ := json.Marshal(respJSON)
  6282. fmt.Println("log")
  6283. fmt.Println(string(result))
  6284. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6285. utils.ErrorLog("解析失败:%v", err)
  6286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6287. return
  6288. }
  6289. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6290. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6291. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6292. //psn_info, _ := service.GetPsnByPatientId(id)
  6293. bas := strings.Split(psn_info.CardInfo, "|")
  6294. if his.IdCardType == 1 {
  6295. cert_no = bas[2]
  6296. } else {
  6297. cert_no = bas[1]
  6298. }
  6299. //江苏地区国家医保医疗类别
  6300. //职工透析:医疗类别选特殊情况门诊9933
  6301. //居民血透门慢: 医疗类别选门诊慢病1402
  6302. //var med_type string
  6303. //if his.Insutype == "310" {
  6304. // if reg_type == 14 {
  6305. // med_type = "9933"
  6306. // } else if reg_type == 11 {
  6307. // med_type = "11"
  6308. //
  6309. // }
  6310. //} else if his.Insutype == "390" {
  6311. // if reg_type == 14 {
  6312. // med_type = "1402"
  6313. // } else if reg_type == 11 {
  6314. // med_type = "11"
  6315. // }
  6316. //}
  6317. var api string
  6318. if miConfig.MdtrtareaAdmvs == "320921" {
  6319. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6320. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6321. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6322. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6323. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6324. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6325. "&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
  6326. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6327. } else {
  6328. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6329. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6330. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6331. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6332. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6333. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6334. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6335. "&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
  6336. }
  6337. resp, requestErr := http.Get(api)
  6338. if requestErr != nil {
  6339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6340. return
  6341. }
  6342. body, ioErr := ioutil.ReadAll(resp.Body)
  6343. if ioErr != nil {
  6344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6346. return
  6347. }
  6348. var respJSON map[string]interface{}
  6349. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6352. return
  6353. }
  6354. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6355. result, _ := json.Marshal(respJSON)
  6356. fmt.Println("log")
  6357. fmt.Println(string(result))
  6358. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6359. utils.ErrorLog("解析失败:%v", err)
  6360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6361. return
  6362. }
  6363. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6364. res.Output = resSeven10265.Output
  6365. res.ErrMsg = resSeven10265.ErrMsg
  6366. res.Cainfo = resSeven10265.Cainfo
  6367. res.WarnMsg = resSeven10265.WarnMsg
  6368. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6369. res.Infcode = infocode
  6370. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6371. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6372. var cert_no string
  6373. if his.IdCardType == 1 {
  6374. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6375. }
  6376. fmt.Println(cert_no)
  6377. 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)
  6378. var dat map[string]interface{}
  6379. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6380. fmt.Println(dat)
  6381. } else {
  6382. fmt.Println(err)
  6383. }
  6384. saveLog(result2, src_resquest, "2207", "结算")
  6385. userJSONBytes, _ := json.Marshal(dat)
  6386. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6387. utils.ErrorLog("解析失败:%v", err)
  6388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6389. return
  6390. }
  6391. } else {
  6392. var src_resquest string
  6393. if miConfig.Code == "H15049901371" {
  6394. //赤峰地区国家医保医疗类别
  6395. //职工透析:医疗类别选特殊情况门诊990502
  6396. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6397. var med_type string
  6398. if his.Insutype == "390" {
  6399. if reg_type == 14 {
  6400. med_type = "9933"
  6401. } else if reg_type == 11 {
  6402. med_type = "11"
  6403. }
  6404. } else if his.Insutype == "310" {
  6405. if reg_type == 14 {
  6406. med_type = "990502"
  6407. } else if reg_type == 11 {
  6408. med_type = "11"
  6409. }
  6410. }
  6411. 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)
  6412. } else {
  6413. 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)
  6414. }
  6415. var dat map[string]interface{}
  6416. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6417. fmt.Println(dat)
  6418. } else {
  6419. fmt.Println(err)
  6420. }
  6421. saveLog(result2, src_resquest, "2207", "结算")
  6422. userJSONBytes, _ := json.Marshal(dat)
  6423. if miConfig.Code == "H15049901371" {
  6424. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6425. utils.ErrorLog("解析失败:%v", err)
  6426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6427. return
  6428. }
  6429. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6430. res.Output = resSeven10265.Output
  6431. res.ErrMsg = resSeven10265.ErrMsg
  6432. res.Cainfo = resSeven10265.Cainfo
  6433. res.WarnMsg = resSeven10265.WarnMsg
  6434. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6435. res.Infcode = infocode
  6436. } else {
  6437. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6438. utils.ErrorLog("解析失败:%v", err)
  6439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6440. return
  6441. }
  6442. }
  6443. }
  6444. if res.Infcode != 0 {
  6445. errlog := &models.HisOrderError{
  6446. UserOrgId: adminUser.CurrentOrgId,
  6447. Ctime: time.Now().Unix(),
  6448. Mtime: time.Now().Unix(),
  6449. Number: chrg_bchno,
  6450. ErrMsg: res.ErrMsg,
  6451. Status: 1,
  6452. PatientId: id,
  6453. RecordTime: recordDateTime,
  6454. Stage: 6,
  6455. }
  6456. service.CreateErrMsgLog(errlog)
  6457. c.ServeSuccessJSON(map[string]interface{}{
  6458. "failed_code": -10,
  6459. "msg": res.ErrMsg,
  6460. })
  6461. return
  6462. } else {
  6463. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6464. order.OrderStatus = 2
  6465. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6466. order.SetlId = res.Output.Setlinfo.SetlID
  6467. order.PsnNo = res.Output.Setlinfo.PsnNo
  6468. order.PsnName = res.Output.Setlinfo.PsnName
  6469. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6470. order.Certno = res.Output.Setlinfo.Certno
  6471. order.Gend = res.Output.Setlinfo.Gend
  6472. order.Naty = res.Output.Setlinfo.Naty
  6473. order.Age = res.Output.Setlinfo.Age
  6474. order.Insutype = res.Output.Setlinfo.Insutype
  6475. order.PsnType = res.Output.Setlinfo.PsnType
  6476. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6477. order.SetlTime = res.Output.Setlinfo.SetlTime
  6478. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6479. //order.MedType = res.Output.Setlinfo.MedType
  6480. if reg_type == 1112 {
  6481. order.MedType = "1112"
  6482. }
  6483. if reg_type == 1111 {
  6484. order.MedType = "1111"
  6485. }
  6486. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6487. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6488. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6489. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6490. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6491. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6492. order.HifpPay = res.Output.Setlinfo.HifpPay
  6493. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6494. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6495. order.HifesPay = res.Output.Setlinfo.HifesPay
  6496. order.HifobPay = res.Output.Setlinfo.HifobPay
  6497. order.MafPay = res.Output.Setlinfo.MafPay
  6498. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6499. order.OthPay = res.Output.Setlinfo.OthPay
  6500. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6501. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6502. order.AcctPay = res.Output.Setlinfo.AcctPay
  6503. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6504. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6505. order.Balc = res.Output.Setlinfo.Balc
  6506. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6507. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6508. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6509. order.ClrWay = res.Output.Setlinfo.ClrWay
  6510. order.Creator = order.Creator
  6511. order.Modify = roles.AdminUserId
  6512. order.RequestLog = src_resquest
  6513. order.Diagnosis = diagnosis_id
  6514. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6515. detailStr := string(setlDetail)
  6516. order.SetlDetail = detailStr
  6517. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6518. err = service.UpDateOrder(order)
  6519. if err == nil {
  6520. //判断是否使用了押金
  6521. if dec_way == "true" {
  6522. tmpstring := strconv.FormatInt(order.ID, 10)
  6523. //扣押金
  6524. order.Decimal = decimal
  6525. service.UpDateOrder(order)
  6526. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6527. if errmsg != nil {
  6528. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6529. return
  6530. }
  6531. }
  6532. c.ServeSuccessJSON(map[string]interface{}{
  6533. "msg": "结算成功",
  6534. })
  6535. } else {
  6536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6537. return
  6538. }
  6539. }
  6540. }
  6541. }
  6542. }
  6543. //func (c *HisApiController) GetPreUploadInfo() {
  6544. // id, _ := c.GetInt64("id")
  6545. // record_time := c.GetString("record_time")
  6546. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6547. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6548. //
  6549. // timeLayout := "2006-01-02"
  6550. // loc, _ := time.LoadLocation("Local")
  6551. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6552. // if err != nil {
  6553. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6554. // return
  6555. // }
  6556. // recordDateTime := theTime.Unix()
  6557. // adminUser := c.GetAdminUserInfo()
  6558. //
  6559. // var prescriptions []*models.HisPrescription
  6560. //
  6561. // var start_time int64
  6562. // var end_time int64
  6563. //
  6564. // data := make(map[string]interface{})
  6565. // if settle_accounts_type == 1 { //日结
  6566. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6567. // data["pre"] = prescriptions
  6568. //
  6569. // } else { //月结
  6570. // start_time_str := c.GetString("start_time")
  6571. // end_time_str := c.GetString("end_time")
  6572. // timeLayout := "2006-01-02"
  6573. // loc, _ := time.LoadLocation("Local")
  6574. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6575. // if err != nil {
  6576. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6577. // return
  6578. // }
  6579. // recordStartTime := theStartTime.Unix()
  6580. // start_time = recordStartTime
  6581. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6582. // if err != nil {
  6583. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6584. // return
  6585. // }
  6586. // recordEndTime := theEndTime.Unix()
  6587. // end_time = recordEndTime
  6588. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6589. // data["pre"] = prescriptions
  6590. //
  6591. // }
  6592. //
  6593. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6594. //
  6595. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6596. // timestamp := time.Now().Unix()
  6597. // tempTime := time.Unix(timestamp, 0)
  6598. // timeFormat := tempTime.Format("20060102150405")
  6599. // chrgBchno := rand.Intn(100000) + 10000
  6600. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6601. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6602. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6603. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6604. // strconv.FormatInt(his.PatientId, 10)
  6605. // client := &http.Client{}
  6606. // data["psn_no"] = his.PsnNo
  6607. // data["mdtrt_id"] = his.Number
  6608. // data["chrg_bchno"] = chrg_bchno
  6609. // data["org_name"] = miConfig.OrgName
  6610. // data["doctor"] = roles.UserName
  6611. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6612. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6613. // data["fixmedins_code"] = miConfig.Code
  6614. // data["dept_code"] = department.Number
  6615. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6616. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6617. // data["secret_key"] = miConfig.SecretKey
  6618. // var ids []int64
  6619. //
  6620. // for _, item := range prescriptions {
  6621. // ids = append(ids, item.ID)
  6622. // }
  6623. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6624. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6625. // bytesData, _ := json.Marshal(data)
  6626. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6627. // resp, _ := client.Do(req)
  6628. // defer resp.Body.Close()
  6629. // body, ioErr := ioutil.ReadAll(resp.Body)
  6630. // if ioErr != nil {
  6631. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6632. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6633. // return
  6634. // }
  6635. // var respJSON map[string]interface{}
  6636. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6637. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6638. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6639. // return
  6640. // }
  6641. //
  6642. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6643. // userJSONBytes, _ := json.Marshal(respJSON)
  6644. // var res ResultFour
  6645. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6646. // utils.ErrorLog("解析失败:%v", err)
  6647. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6648. // return
  6649. // }
  6650. //
  6651. // if res.Infcode == 0 {
  6652. // order := &models.HisOrder{
  6653. // UserOrgId: adminUser.CurrentOrgId,
  6654. // HisPatientId: his.ID,
  6655. // PatientId: his.PatientId,
  6656. // SettleAccountsDate: recordDateTime,
  6657. // Ctime: time.Now().Unix(),
  6658. // Mtime: time.Now().Unix(),
  6659. // Status: 1,
  6660. // Number: chrg_bchno,
  6661. // Infcode: res.Infcode,
  6662. // WarnMsg: res.WarnMsg,
  6663. // Cainfo: res.Cainfo,
  6664. // ErrMsg: res.ErrMsg,
  6665. // RespondTime: res.RefmsgTime,
  6666. // InfRefmsgid: res.InfRefmsgid,
  6667. // OrderStatus: 1,
  6668. // IsMedicineInsurance: 1,
  6669. // SettleType: settle_accounts_type,
  6670. // SettleStartTime: start_time,
  6671. // SettleEndTime: end_time,
  6672. // Creator: roles.ID,
  6673. // Modify: roles.ID,
  6674. // PType: 2,
  6675. // }
  6676. // err = service.CreateOrder(order)
  6677. // if err != nil {
  6678. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6679. // return
  6680. // }
  6681. //
  6682. // for _, item := range res.Output.Result {
  6683. // temp := strings.Split(item.FeedetlSn, "-")
  6684. // var advice_id int64 = 0
  6685. // var project_id int64 = 0
  6686. // var types int64 = 0
  6687. //
  6688. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6689. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6690. //
  6691. // if temp[1] == "1" {
  6692. // advice_id = id
  6693. // project_id = 0
  6694. // } else if temp[1] == "2" {
  6695. // advice_id = 0
  6696. // project_id = id
  6697. // }
  6698. //
  6699. // info := &models.HisOrderInfo{
  6700. // OrderNumber: order.Number,
  6701. // FeedetlSn: item.FeedetlSn,
  6702. // UploadDate: time.Now().Unix(),
  6703. // AdviceId: advice_id,
  6704. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6705. // Cnt: item.Cnt,
  6706. // Pric: float64(item.Pric),
  6707. // PatientId: his.PatientId,
  6708. // PricUplmtAmt: item.PricUplmtAmt,
  6709. // SelfpayProp: item.SelfpayProp,
  6710. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6711. // OverlmtAmt: item.OverlmtAmt,
  6712. // PreselfpayAmt: item.PreselfpayAmt,
  6713. // BasMednFlag: item.BasMednFlag,
  6714. // MedChrgitmType: item.MedChrgitmType,
  6715. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6716. // Status: 1,
  6717. // Memo: item.Memo,
  6718. // Mtime: time.Now().Unix(),
  6719. // InscpScpAmt: item.InscpScpAmt,
  6720. // DrtReimFlag: item.DrtReimFlag,
  6721. // Ctime: time.Now().Unix(),
  6722. // ListSpItemFlag: item.ListSpItemFlag,
  6723. // ChldMedcFlag: item.ChldMedcFlag,
  6724. // LmtUsedFlag: item.LmtUsedFlag,
  6725. // ChrgitmLv: item.ChrgitmLv,
  6726. // UserOrgId: adminUser.CurrentOrgId,
  6727. // HisPatientId: his.ID,
  6728. // OrderId: order.ID,
  6729. // ProjectId: project_id,
  6730. // Type: types,
  6731. // }
  6732. // service.CreateOrderInfo(info)
  6733. //
  6734. // }
  6735. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6736. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6737. //
  6738. // var total float64
  6739. // for _, item := range prescriptions {
  6740. // if item.Type == 1 { //药品
  6741. // for _, subItem := range item.HisDoctorAdviceInfo {
  6742. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6743. // }
  6744. // }
  6745. // if item.Type == 2 { //项目
  6746. // for _, subItem := range item.HisPrescriptionProject {
  6747. // total = total + (subItem.Price * float64(subItem.Count))
  6748. // }
  6749. // }
  6750. // }
  6751. //
  6752. // for _, item := range prescriptions {
  6753. // for _, subItem := range item.HisAdditionalCharge {
  6754. // total = total + (subItem.Price * float64(subItem.Count))
  6755. // }
  6756. // }
  6757. //
  6758. // allTotal := fmt.Sprintf("%.2f", total)
  6759. // if res.Infcode == 0 {
  6760. // var rf []*ResultFive
  6761. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6762. // psn_no := his.PsnNo
  6763. // mdtrt_id := his.Number
  6764. // chrg_bchno := chrg_bchno
  6765. // cert_no := his.Certno
  6766. // insutype := rf[0].Insutype
  6767. //
  6768. // if his.IdCardType == 1 {
  6769. // cert_no = his.MedicalInsuranceNumber
  6770. //
  6771. // } else {
  6772. //
  6773. // cert_no = his.Certno
  6774. //
  6775. // }
  6776. //
  6777. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6778. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6779. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6780. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6781. // resp, requestErr := http.Get(api)
  6782. // if requestErr != nil {
  6783. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6784. // return
  6785. // }
  6786. // defer resp.Body.Close()
  6787. // body, ioErr := ioutil.ReadAll(resp.Body)
  6788. // if ioErr != nil {
  6789. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6790. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6791. // return
  6792. // }
  6793. // var respJSON map[string]interface{}
  6794. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6795. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6796. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6797. // return
  6798. // }
  6799. // fmt.Println(respJSON)
  6800. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6801. // userJSONBytes, _ := json.Marshal(respJSON)
  6802. // var res ResultSeven
  6803. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6804. // utils.ErrorLog("解析失败:%v", err)
  6805. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6806. // return
  6807. // }
  6808. // if res.Infcode != 0 {
  6809. // errlog := &models.HisOrderError{
  6810. // UserOrgId: adminUser.CurrentOrgId,
  6811. // Ctime: time.Now().Unix(),
  6812. // Mtime: time.Now().Unix(),
  6813. // Number: chrg_bchno,
  6814. // ErrMsg: res.ErrMsg,
  6815. // Status: 1,
  6816. // PatientId: id,
  6817. // RecordTime: recordDateTime,
  6818. // Stage: 7,
  6819. // }
  6820. // service.CreateErrMsgLog(errlog)
  6821. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6822. // return
  6823. // } else {
  6824. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6825. // order.OrderStatus = 1
  6826. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6827. // order.SetlId = res.Output.Setlinfo.SetlID
  6828. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6829. // order.PsnName = res.Output.Setlinfo.PsnName
  6830. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6831. // order.Certno = res.Output.Setlinfo.Certno
  6832. // order.Gend = res.Output.Setlinfo.Gend
  6833. // order.Naty = res.Output.Setlinfo.Naty
  6834. // order.Age = res.Output.Setlinfo.Age
  6835. // order.Insutype = res.Output.Setlinfo.Insutype
  6836. // order.PsnType = res.Output.Setlinfo.PsnType
  6837. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6838. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6839. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6840. // order.MedType = res.Output.Setlinfo.MedType
  6841. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6842. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6843. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6844. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6845. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6846. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6847. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6848. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6849. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6850. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6851. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6852. // order.MafPay = res.Output.Setlinfo.MafPay
  6853. // order.OthPay = res.Output.Setlinfo.OthPay
  6854. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6855. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6856. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6857. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6858. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6859. // order.Balc = res.Output.Setlinfo.Balc
  6860. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6861. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6862. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6863. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6864. // order.Creator = order.Creator
  6865. // order.Modify = roles.ID
  6866. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6867. // detailStr := string(setlDetail)
  6868. // order.SetlDetail = detailStr
  6869. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6870. // err = service.UpDateOrder(order)
  6871. // if err == nil {
  6872. // c.ServeSuccessJSON(map[string]interface{}{
  6873. // "msg": "预结算成功",
  6874. // })
  6875. // } else {
  6876. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6877. // return
  6878. // }
  6879. // }
  6880. // } else {
  6881. // adminUser := c.GetAdminUserInfo()
  6882. // errlog := &models.HisOrderError{
  6883. // UserOrgId: adminUser.CurrentOrgId,
  6884. // Ctime: time.Now().Unix(),
  6885. // Mtime: time.Now().Unix(),
  6886. // ErrMsg: res.ErrMsg,
  6887. // Status: 1,
  6888. // PatientId: id,
  6889. // RecordTime: recordDateTime,
  6890. // Stage: 4,
  6891. // }
  6892. // service.CreateErrMsgLog(errlog)
  6893. //
  6894. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6895. // return
  6896. // }
  6897. // } else {
  6898. // adminUser := c.GetAdminUserInfo()
  6899. // errlog := &models.HisOrderError{
  6900. // UserOrgId: adminUser.CurrentOrgId,
  6901. // Ctime: time.Now().Unix(),
  6902. // Mtime: time.Now().Unix(),
  6903. // ErrMsg: res.ErrMsg,
  6904. // Status: 1,
  6905. // PatientId: id,
  6906. // RecordTime: recordDateTime,
  6907. // Stage: 4,
  6908. // }
  6909. // service.CreateErrMsgLog(errlog)
  6910. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6911. // return
  6912. // }
  6913. //
  6914. // } else {
  6915. // var total float64
  6916. // for _, item := range prescriptions {
  6917. // if item.Type == 1 { //药品
  6918. // for _, subItem := range item.HisDoctorAdviceInfo {
  6919. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6920. // }
  6921. // }
  6922. // if item.Type == 2 { //项目
  6923. // for _, subItem := range item.HisPrescriptionProject {
  6924. // total = total + (subItem.Price * float64(subItem.Count))
  6925. // }
  6926. // }
  6927. //
  6928. // for _, subItem := range item.HisAdditionalCharge {
  6929. // total = total + (subItem.Price * float64(subItem.Count))
  6930. // }
  6931. // }
  6932. //
  6933. // allTotal := fmt.Sprintf("%.2f", total)
  6934. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6935. // order := &models.HisOrder{
  6936. // UserOrgId: adminUser.CurrentOrgId,
  6937. // HisPatientId: his.ID,
  6938. // PatientId: id,
  6939. // SettleAccountsDate: recordDateTime,
  6940. // Ctime: time.Now().Unix(),
  6941. // Mtime: time.Now().Unix(),
  6942. // Status: 1,
  6943. // OrderStatus: 2,
  6944. // Number: chrg_bchno,
  6945. // MedfeeSumamt: totals,
  6946. // }
  6947. // err = service.CreateOrder(order)
  6948. // if err != nil {
  6949. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6950. // return
  6951. // }
  6952. //
  6953. // var customs []*Custom
  6954. // for _, item := range prescriptions {
  6955. //
  6956. // if item.Type == 1 { //药品
  6957. // for _, subItem := range item.HisDoctorAdviceInfo {
  6958. // cus := &Custom{
  6959. // AdviceId: subItem.ID,
  6960. // ProjectId: 0,
  6961. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6962. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6963. // FeedetlSn: subItem.FeedetlSn,
  6964. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6965. // MedListCodg: subItem.MedListCodg,
  6966. // Type: 1,
  6967. // }
  6968. // customs = append(customs, cus)
  6969. // }
  6970. // }
  6971. //
  6972. // if item.Type == 2 { //项目
  6973. // for _, subItem := range item.HisPrescriptionProject {
  6974. //
  6975. // cus := &Custom{
  6976. // AdviceId: 0,
  6977. // ProjectId: subItem.ID,
  6978. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6979. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6980. // FeedetlSn: subItem.FeedetlSn,
  6981. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6982. // MedListCodg: subItem.MedListCodg,
  6983. // Type: 2,
  6984. // }
  6985. //
  6986. // customs = append(customs, cus)
  6987. // }
  6988. // }
  6989. //
  6990. // for _, item := range item.HisAdditionalCharge {
  6991. // cus := &Custom{
  6992. // ItemId: item.ID,
  6993. // AdviceId: 0,
  6994. // ProjectId: 0,
  6995. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6996. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6997. // FeedetlSn: item.FeedetlSn,
  6998. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6999. // MedListCodg: item.XtHisAddtionConfig.Code,
  7000. // Type: 3,
  7001. // }
  7002. //
  7003. // customs = append(customs, cus)
  7004. // }
  7005. //
  7006. // }
  7007. //
  7008. // for _, item := range customs {
  7009. // var advice_id int64 = 0
  7010. // var project_id int64 = 0
  7011. // var item_id int64 = 0
  7012. //
  7013. // var types int64 = 0
  7014. //
  7015. // if item.Type == 1 {
  7016. // advice_id = item.AdviceId
  7017. // project_id = 0
  7018. // item_id = 0
  7019. // } else if item.Type == 2 {
  7020. // advice_id = 0
  7021. // item_id = 0
  7022. //
  7023. // project_id = item.ProjectId
  7024. // } else if item.Type == 3 {
  7025. // advice_id = 0
  7026. // item_id = item.ItemId
  7027. // project_id = 0
  7028. // }
  7029. //
  7030. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  7031. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  7032. // pric, _ := strconv.ParseFloat(item.Price, 32)
  7033. //
  7034. // info := &models.HisOrderInfo{
  7035. // OrderNumber: order.Number,
  7036. // UploadDate: time.Now().Unix(),
  7037. // AdviceId: advice_id,
  7038. // DetItemFeeSumamt: detItemFeeSumamt,
  7039. // Cnt: cut,
  7040. // Pric: pric,
  7041. // PatientId: id,
  7042. // Status: 1,
  7043. // Mtime: time.Now().Unix(),
  7044. // Ctime: time.Now().Unix(),
  7045. // UserOrgId: adminUser.CurrentOrgId,
  7046. // HisPatientId: his.ID,
  7047. // OrderId: order.ID,
  7048. // ProjectId: project_id,
  7049. // Type: types,
  7050. // ItemId: item_id,
  7051. // }
  7052. // service.CreateOrderInfo(info)
  7053. // }
  7054. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7055. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7056. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  7057. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7058. // if err == nil {
  7059. // c.ServeSuccessJSON(map[string]interface{}{
  7060. // "msg": "结算成功",
  7061. // })
  7062. // } else {
  7063. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7064. // return
  7065. // }
  7066. // }
  7067. //}
  7068. //上传明细-预结算-
  7069. func (c *HisApiController) GetPreUploadInfo() {
  7070. id, _ := c.GetInt64("id")
  7071. record_time := c.GetString("record_time")
  7072. his_patient_id, _ := c.GetInt64("his_patient_id")
  7073. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7074. admin_user_id, _ := c.GetInt64("admin_user_id")
  7075. diagnosis_id := c.GetString("diagnosis")
  7076. sick_type, _ := c.GetInt64("sick_type")
  7077. reg_type, _ := c.GetInt64("p_type")
  7078. begin_time := c.GetString("begin_time")
  7079. id_str := c.GetString("ids")
  7080. ids_arr := strings.Split(id_str, ",")
  7081. timeLayout := "2006-01-02"
  7082. loc, _ := time.LoadLocation("Local")
  7083. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7084. if err != nil {
  7085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7086. return
  7087. }
  7088. recordDateTime := theTime.Unix()
  7089. adminUser := c.GetAdminUserInfo()
  7090. diagnosis_ids := strings.Split(diagnosis_id, ",")
  7091. var config []*models.HisXtDiagnoseConfig
  7092. for _, item := range diagnosis_ids {
  7093. id, _ := strconv.ParseInt(item, 10, 64)
  7094. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7095. config = append(config, &diagnosisConfig)
  7096. }
  7097. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  7098. sickConfig, _ := service.FindSickById(sick_type)
  7099. var prescriptions []*models.HisPrescription
  7100. var start_time int64
  7101. var end_time int64
  7102. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7103. fmt.Println(his_patient_id)
  7104. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7105. timestamp := time.Now().Unix()
  7106. tempTime := time.Unix(timestamp, 0)
  7107. timeFormat := tempTime.Format("20060102150405")
  7108. chrgBchno := rand.Intn(100000) + 10000
  7109. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7110. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7111. var patientPrescription models.HisPrescriptionInfo
  7112. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7113. if patientPrescription.ID == 0 {
  7114. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7115. }
  7116. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7117. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7118. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7119. strconv.FormatInt(his.PatientId, 10)
  7120. var res2 ResultSix
  7121. var resSix10265 ResultSix10265
  7122. var time_stamp string
  7123. if miConfig.MdtrtareaAdmvs == "421300" {
  7124. data := make(map[string]interface{})
  7125. client := &http.Client{}
  7126. data["psn_no"] = his.PsnNo
  7127. data["mdtrt_id"] = his.Number
  7128. data["department"] = department.Name
  7129. data["org_name"] = miConfig.OrgName
  7130. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7131. data["doctor_id"] = doctor_info.DoctorNumber
  7132. data["doctor_name"] = roles.UserName
  7133. data["fixmedins_code"] = miConfig.Code
  7134. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7135. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7136. data["secret_key"] = miConfig.SecretKey
  7137. data["sick_code"] = sickConfig.CountryCode
  7138. data["sick_name"] = sickConfig.ClassName
  7139. data["begin_time"] = begin_time
  7140. data["dept"] = strconv.FormatInt(department.ID, 10)
  7141. data["config"] = config
  7142. data["opter"] = roles.UserName
  7143. fmt.Println(data)
  7144. bytesData, _ := json.Marshal(data)
  7145. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7146. resp, _ := client.Do(req)
  7147. defer resp.Body.Close()
  7148. body, ioErr := ioutil.ReadAll(resp.Body)
  7149. if ioErr != nil {
  7150. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7152. return
  7153. }
  7154. var respJSON map[string]interface{}
  7155. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7158. return
  7159. }
  7160. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7161. userJSONBytes, _ := json.Marshal(respJSON)
  7162. fmt.Println("log")
  7163. fmt.Println(string(userJSONBytes))
  7164. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7165. utils.ErrorLog("解析失败:%v", err)
  7166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7167. return
  7168. }
  7169. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7170. data := make(map[string]interface{})
  7171. client := &http.Client{}
  7172. data["psn_no"] = his.PsnNo
  7173. data["mdtrt_id"] = his.Number
  7174. data["doctor"] = roles.UserName
  7175. data["department"] = department.Name
  7176. data["org_name"] = miConfig.OrgName
  7177. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7178. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  7179. data["fixmedins_code"] = miConfig.Code
  7180. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7181. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7182. data["secret_key"] = miConfig.SecretKey
  7183. data["sick_code"] = sickConfig.CountryCode
  7184. data["sick_name"] = sickConfig.ClassName
  7185. data["begin_time"] = begin_time
  7186. data["dept"] = strconv.FormatInt(department.ID, 10)
  7187. data["config"] = config
  7188. data["url"] = miConfig.Url
  7189. data["ak"] = miConfig.AccessKey
  7190. data["cainfo"] = miConfig.Cainfo
  7191. bytesData, _ := json.Marshal(data)
  7192. var req *http.Request
  7193. if miConfig.MdtrtareaAdmvs == "320921" {
  7194. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7195. //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 +
  7196. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  7197. } else {
  7198. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7199. }
  7200. resp, _ := client.Do(req)
  7201. defer resp.Body.Close()
  7202. body, ioErr := ioutil.ReadAll(resp.Body)
  7203. if ioErr != nil {
  7204. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7206. return
  7207. }
  7208. var respJSON map[string]interface{}
  7209. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7212. return
  7213. }
  7214. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  7215. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  7216. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  7217. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7218. userJSONBytes, _ := json.Marshal(respJSON)
  7219. fmt.Println("log")
  7220. fmt.Println(string(userJSONBytes))
  7221. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7222. utils.ErrorLog("解析失败:%v", err)
  7223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7224. return
  7225. }
  7226. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7227. res2.Output = resSix10265.Output
  7228. res2.ErrMsg = resSix10265.ErrMsg
  7229. res2.Cainfo = resSix10265.Cainfo
  7230. res2.WarnMsg = resSix10265.WarnMsg
  7231. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7232. res2.Infcode = infocode
  7233. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7234. 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)
  7235. saveLog(result, requestLog, "2203", "上传就诊信息")
  7236. var respJSON2 map[string]interface{}
  7237. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7238. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7240. return
  7241. }
  7242. userJSONBytes2, _ := json.Marshal(respJSON2)
  7243. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7244. utils.ErrorLog("解析失败:%v", err)
  7245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7246. return
  7247. }
  7248. } else {
  7249. var result string
  7250. var requestLog string
  7251. if miConfig.MdtrtareaAdmvs == "440781" { //
  7252. 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)
  7253. } else {
  7254. if miConfig.Code == "H15049901371" {
  7255. //赤峰地区国家医保医疗类别
  7256. //职工透析:医疗类别选特殊情况门诊990502
  7257. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7258. var med_type string
  7259. if his.Insutype == "390" {
  7260. if reg_type == 14 {
  7261. med_type = "9933"
  7262. } else if reg_type == 11 {
  7263. med_type = "11"
  7264. }
  7265. } else if his.Insutype == "310" {
  7266. if reg_type == 14 {
  7267. med_type = "990502"
  7268. } else if reg_type == 11 {
  7269. med_type = "11"
  7270. }
  7271. }
  7272. 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)
  7273. } else {
  7274. 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)
  7275. }
  7276. saveLog(result, requestLog, "2203", "上传就诊信息")
  7277. var respJSON2 map[string]interface{}
  7278. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7281. return
  7282. }
  7283. userJSONBytes2, _ := json.Marshal(respJSON2)
  7284. if miConfig.Code == "H15049901371" {
  7285. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7286. utils.ErrorLog("解析失败:%v", err)
  7287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7288. return
  7289. }
  7290. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7291. res2.Output = resSix10265.Output
  7292. res2.ErrMsg = resSix10265.ErrMsg
  7293. res2.Cainfo = resSix10265.Cainfo
  7294. res2.WarnMsg = resSix10265.WarnMsg
  7295. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7296. res2.Infcode = infocode
  7297. } else {
  7298. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7299. utils.ErrorLog("解析失败:%v", err)
  7300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7301. return
  7302. }
  7303. }
  7304. }
  7305. }
  7306. if res2.Infcode != 0 {
  7307. adminUser := c.GetAdminUserInfo()
  7308. errlog := &models.HisOrderError{
  7309. UserOrgId: adminUser.CurrentOrgId,
  7310. Ctime: time.Now().Unix(),
  7311. Mtime: time.Now().Unix(),
  7312. ErrMsg: res2.ErrMsg,
  7313. Status: 1,
  7314. PatientId: id,
  7315. RecordTime: recordDateTime,
  7316. Stage: 3,
  7317. }
  7318. service.CreateErrMsgLog(errlog)
  7319. c.ServeSuccessJSON(map[string]interface{}{
  7320. "failed_code": -10,
  7321. "msg": res2.ErrMsg,
  7322. })
  7323. return
  7324. } else {
  7325. his.Diagnosis = diagnosis_id
  7326. his.SickType = sickConfig.ID
  7327. his.PType = fmt.Sprintf("%d", reg_type)
  7328. service.UpdateHisPatientThree(&his)
  7329. data := make(map[string]interface{})
  7330. if settle_accounts_type == 1 { //日结
  7331. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7332. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7333. } else {
  7334. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7335. }
  7336. data["pre"] = prescriptions
  7337. } else { //月结
  7338. start_time_str := c.GetString("start_time")
  7339. end_time_str := c.GetString("end_time")
  7340. timeLayout := "2006-01-02"
  7341. loc, _ := time.LoadLocation("Local")
  7342. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7343. if err != nil {
  7344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7345. return
  7346. }
  7347. recordStartTime := theStartTime.Unix()
  7348. start_time = recordStartTime
  7349. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7350. if err != nil {
  7351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7352. return
  7353. }
  7354. recordEndTime := theEndTime.Unix()
  7355. end_time = recordEndTime
  7356. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7357. data["pre"] = prescriptions
  7358. }
  7359. client := &http.Client{}
  7360. data["psn_no"] = his.PsnNo
  7361. data["mdtrt_id"] = his.Number
  7362. data["chrg_bchno"] = chrg_bchno
  7363. data["org_name"] = miConfig.OrgName
  7364. data["doctor"] = roles.UserName
  7365. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7366. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7367. data["fixmedins_code"] = miConfig.Code
  7368. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7369. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7370. data["dept_code"] = "15"
  7371. } else {
  7372. data["dept_code"] = department.Number
  7373. }
  7374. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7375. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7376. data["secret_key"] = miConfig.SecretKey
  7377. data["url"] = miConfig.Url
  7378. data["ak"] = miConfig.AccessKey
  7379. data["new_doctor_name"] = patientPrescription.Doctor
  7380. data["diag_code"] = sickConfig.CountryCode
  7381. data["time_stamp"] = time_stamp
  7382. data["cainfo"] = miConfig.Cainfo
  7383. var ids []int64
  7384. for _, item := range prescriptions {
  7385. ids = append(ids, item.ID)
  7386. }
  7387. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7388. if config.IsOpen == 1 { //对接了医保,走医保流程
  7389. var res ResultFour
  7390. var resFour10265 ResultFour10265
  7391. if miConfig.MdtrtareaAdmvs == "421300" {
  7392. bytesData, _ := json.Marshal(data)
  7393. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7394. resp, _ := client.Do(req)
  7395. defer resp.Body.Close()
  7396. body, ioErr := ioutil.ReadAll(resp.Body)
  7397. if ioErr != nil {
  7398. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7400. return
  7401. }
  7402. var respJSON map[string]interface{}
  7403. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7406. return
  7407. }
  7408. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7409. userJSONBytes, _ := json.Marshal(respJSON)
  7410. fmt.Println("log")
  7411. fmt.Println(string(userJSONBytes))
  7412. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7413. utils.ErrorLog("解析失败:%v", err)
  7414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7415. return
  7416. }
  7417. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7418. bytesData, _ := json.Marshal(data)
  7419. var req *http.Request
  7420. if miConfig.MdtrtareaAdmvs == "320921" {
  7421. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7422. } else {
  7423. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7424. }
  7425. resp, _ := client.Do(req)
  7426. defer resp.Body.Close()
  7427. body, ioErr := ioutil.ReadAll(resp.Body)
  7428. if ioErr != nil {
  7429. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7431. return
  7432. }
  7433. var respJSON map[string]interface{}
  7434. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7437. return
  7438. }
  7439. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7440. userJSONBytes, _ := json.Marshal(respJSON)
  7441. fmt.Println("log")
  7442. fmt.Println(string(userJSONBytes))
  7443. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7444. utils.ErrorLog("解析失败:%v", err)
  7445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7446. return
  7447. }
  7448. res.InfRefmsgid = resFour10265.InfRefmsgid
  7449. res.Output = resFour10265.Output
  7450. res.ErrMsg = resFour10265.ErrMsg
  7451. res.Cainfo = resFour10265.Cainfo
  7452. res.WarnMsg = resFour10265.WarnMsg
  7453. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7454. res.Infcode = infocode
  7455. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7456. 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)
  7457. var dat map[string]interface{}
  7458. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7459. fmt.Println(dat)
  7460. } else {
  7461. fmt.Println(err)
  7462. }
  7463. saveLog(result, request_log, "2204", "上传费用明细")
  7464. userJSONBytes, _ := json.Marshal(dat)
  7465. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7466. utils.ErrorLog("解析失败:%v", err)
  7467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7468. return
  7469. }
  7470. } else {
  7471. if miConfig.Code == "H15049901371" {
  7472. 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)
  7473. var dat map[string]interface{}
  7474. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7475. fmt.Println(dat)
  7476. } else {
  7477. fmt.Println(err)
  7478. }
  7479. saveLog(result, request_log, "2204", "上传费用明细")
  7480. userJSONBytes, _ := json.Marshal(dat)
  7481. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7482. utils.ErrorLog("解析失败:%v", err)
  7483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7484. return
  7485. }
  7486. res.InfRefmsgid = resFour10265.InfRefmsgid
  7487. res.Output = resFour10265.Output
  7488. res.ErrMsg = resFour10265.ErrMsg
  7489. res.Cainfo = resFour10265.Cainfo
  7490. res.WarnMsg = resFour10265.WarnMsg
  7491. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7492. res.Infcode = infocode
  7493. } else {
  7494. 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)
  7495. var dat map[string]interface{}
  7496. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7497. fmt.Println(dat)
  7498. } else {
  7499. fmt.Println(err)
  7500. }
  7501. saveLog(result, request_log, "2204", "上传费用明细")
  7502. userJSONBytes, _ := json.Marshal(dat)
  7503. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7504. utils.ErrorLog("解析失败:%v", err)
  7505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7506. return
  7507. }
  7508. }
  7509. }
  7510. if res.Infcode == 0 {
  7511. order := &models.HisOrder{
  7512. UserOrgId: adminUser.CurrentOrgId,
  7513. HisPatientId: his.ID,
  7514. PatientId: his.PatientId,
  7515. SettleAccountsDate: recordDateTime,
  7516. Ctime: time.Now().Unix(),
  7517. Mtime: time.Now().Unix(),
  7518. MdtrtId: his.Number,
  7519. PsnNo: his.PsnNo,
  7520. MedType: strconv.FormatInt(reg_type, 10),
  7521. Status: 1,
  7522. Number: chrg_bchno,
  7523. Infcode: res.Infcode,
  7524. WarnMsg: res.WarnMsg,
  7525. Cainfo: res.Cainfo,
  7526. ErrMsg: res.ErrMsg,
  7527. RespondTime: res.RefmsgTime,
  7528. InfRefmsgid: res.InfRefmsgid,
  7529. OrderStatus: 1,
  7530. IsMedicineInsurance: 1,
  7531. SettleType: settle_accounts_type,
  7532. SettleStartTime: start_time,
  7533. SettleEndTime: end_time,
  7534. Creator: roles.AdminUserId,
  7535. Modify: roles.AdminUserId,
  7536. PType: 2,
  7537. Diagnosis: diagnosis_id,
  7538. }
  7539. err = service.CreateOrder(order)
  7540. if err != nil {
  7541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7542. return
  7543. }
  7544. for _, item := range res.Output.Result {
  7545. temp := strings.Split(item.FeedetlSn, "-")
  7546. var advice_id int64 = 0
  7547. var project_id int64 = 0
  7548. var types int64 = 0
  7549. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7550. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7551. if temp[1] == "1" {
  7552. advice_id = id
  7553. project_id = 0
  7554. } else if temp[1] == "2" {
  7555. advice_id = 0
  7556. project_id = id
  7557. }
  7558. info := &models.HisOrderInfo{
  7559. OrderNumber: order.Number,
  7560. FeedetlSn: item.FeedetlSn,
  7561. UploadDate: time.Now().Unix(),
  7562. AdviceId: advice_id,
  7563. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7564. Cnt: item.Cnt,
  7565. Pric: float64(item.Pric),
  7566. PatientId: his.PatientId,
  7567. PricUplmtAmt: item.PricUplmtAmt,
  7568. SelfpayProp: item.SelfpayProp,
  7569. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7570. OverlmtAmt: item.OverlmtAmt,
  7571. PreselfpayAmt: item.PreselfpayAmt,
  7572. BasMednFlag: item.BasMednFlag,
  7573. MedChrgitmType: item.MedChrgitmType,
  7574. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7575. Status: 1,
  7576. Memo: item.Memo,
  7577. Mtime: time.Now().Unix(),
  7578. InscpScpAmt: item.InscpScpAmt,
  7579. DrtReimFlag: item.DrtReimFlag,
  7580. Ctime: time.Now().Unix(),
  7581. ListSpItemFlag: item.ListSpItemFlag,
  7582. ChldMedcFlag: item.ChldMedcFlag,
  7583. LmtUsedFlag: item.LmtUsedFlag,
  7584. ChrgitmLv: item.ChrgitmLv,
  7585. UserOrgId: adminUser.CurrentOrgId,
  7586. HisPatientId: his.ID,
  7587. OrderId: order.ID,
  7588. ProjectId: project_id,
  7589. Type: types,
  7590. }
  7591. service.CreateOrderInfo(info)
  7592. }
  7593. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7594. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7595. var total float64
  7596. for _, item := range prescriptions {
  7597. if item.Type == 1 { //药品
  7598. for _, subItem := range item.HisDoctorAdviceInfo {
  7599. total = total + (subItem.Price * subItem.PrescribingNumber)
  7600. }
  7601. }
  7602. if item.Type == 2 { //项目
  7603. for _, subItem := range item.HisPrescriptionProject {
  7604. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7605. total = total + (subItem.Price * cnt)
  7606. }
  7607. }
  7608. }
  7609. for _, item := range prescriptions {
  7610. for _, subItem := range item.HisAdditionalCharge {
  7611. total = total + (subItem.Price * float64(subItem.Count))
  7612. }
  7613. }
  7614. allTotal := fmt.Sprintf("%.4f", total)
  7615. if res.Infcode == 0 {
  7616. var rf []*ResultFive
  7617. json.Unmarshal([]byte(his.Iinfo), &rf)
  7618. chrg_bchno := chrg_bchno
  7619. cert_no := his.Certno
  7620. var insutypes []string
  7621. var insutype string
  7622. var is390 int = 0
  7623. var is310 int = 0
  7624. for _, item := range rf {
  7625. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7626. insutypes = append(insutypes, item.Insutype)
  7627. }
  7628. }
  7629. if len(insutypes) == 1 {
  7630. insutype = insutypes[0]
  7631. } else {
  7632. for _, i := range insutypes {
  7633. if i == "390" {
  7634. is390 = 1
  7635. }
  7636. if i == "310" {
  7637. is310 = 1
  7638. }
  7639. }
  7640. }
  7641. if is390 == 1 {
  7642. insutype = "390"
  7643. }
  7644. if is310 == 1 {
  7645. insutype = "310"
  7646. }
  7647. if len(insutypes) == 0 {
  7648. insutype = "310"
  7649. }
  7650. if len(insutypes) == 2 {
  7651. insutype = strconv.FormatInt(his.SocialType, 64)
  7652. }
  7653. //insutype = "390"
  7654. if his.IdCardType == 1 {
  7655. cert_no = his.MedicalInsuranceNumber
  7656. } else {
  7657. cert_no = his.Certno
  7658. }
  7659. var res ResultSeven
  7660. var resSeven10265 ResultSeven10265
  7661. if miConfig.MdtrtareaAdmvs == "421300" {
  7662. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7663. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7664. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7665. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7666. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7667. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7668. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7669. resp, requestErr := http.Get(api)
  7670. if requestErr != nil {
  7671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7672. return
  7673. }
  7674. body, ioErr := ioutil.ReadAll(resp.Body)
  7675. if ioErr != nil {
  7676. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7678. return
  7679. }
  7680. var respJSON map[string]interface{}
  7681. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7684. return
  7685. }
  7686. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7687. result, _ := json.Marshal(respJSON)
  7688. fmt.Println("log")
  7689. fmt.Println(string(result))
  7690. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7691. utils.ErrorLog("解析失败:%v", err)
  7692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7693. return
  7694. }
  7695. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7696. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7697. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7698. bas := strings.Split(psn_info.CardInfo, "|")
  7699. if his.IdCardType == 1 {
  7700. cert_no = bas[2]
  7701. } else {
  7702. cert_no = bas[1]
  7703. }
  7704. //江苏地区国家医保医疗类别
  7705. //职工透析:医疗类别选特殊情况门诊9933
  7706. //居民血透门慢: 医疗类别选门诊慢病1402
  7707. //var med_type string
  7708. //if his.Insutype == "310" {
  7709. // if reg_type == 14 {
  7710. // med_type = "9933"
  7711. // } else if reg_type == 11 {
  7712. // med_type = "11"
  7713. //
  7714. // }
  7715. //} else if his.Insutype == "390" {
  7716. // if reg_type == 14 {
  7717. // med_type = "1402"
  7718. // } else if reg_type == 11 {
  7719. // med_type = "11"
  7720. // }
  7721. //}
  7722. var api string
  7723. if miConfig.MdtrtareaAdmvs == "320921" {
  7724. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7725. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7726. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7727. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7728. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7729. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7730. "&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
  7731. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7732. } else {
  7733. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7734. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7735. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7736. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7737. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7738. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7739. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7740. "&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
  7741. }
  7742. resp, requestErr := http.Get(api)
  7743. if requestErr != nil {
  7744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7745. return
  7746. }
  7747. body, ioErr := ioutil.ReadAll(resp.Body)
  7748. if ioErr != nil {
  7749. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7751. return
  7752. }
  7753. var respJSON map[string]interface{}
  7754. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7757. return
  7758. }
  7759. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7760. result, _ := json.Marshal(respJSON)
  7761. fmt.Println("log")
  7762. fmt.Println(string(result))
  7763. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7764. utils.ErrorLog("解析失败:%v", err)
  7765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7766. return
  7767. }
  7768. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7769. res.Output = resSeven10265.Output
  7770. res.ErrMsg = resSeven10265.ErrMsg
  7771. res.Cainfo = resSeven10265.Cainfo
  7772. res.WarnMsg = resSeven10265.WarnMsg
  7773. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7774. res.Infcode = infocode
  7775. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7776. 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)
  7777. var dat map[string]interface{}
  7778. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7779. fmt.Println(dat)
  7780. } else {
  7781. fmt.Println(err)
  7782. }
  7783. saveLog(result, request_log, "2206", "预结算")
  7784. userJSONBytes, _ := json.Marshal(dat)
  7785. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7786. utils.ErrorLog("解析失败:%v", err)
  7787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7788. return
  7789. }
  7790. } else {
  7791. var result string
  7792. var request_log string
  7793. if miConfig.Code == "H15049901371" {
  7794. //赤峰地区国家医保医疗类别
  7795. //职工透析:医疗类别选特殊情况门诊990502
  7796. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7797. var med_type string
  7798. if his.Insutype == "390" {
  7799. if reg_type == 14 {
  7800. med_type = "9933"
  7801. } else if reg_type == 11 {
  7802. med_type = "11"
  7803. }
  7804. } else if his.Insutype == "310" {
  7805. if reg_type == 14 {
  7806. med_type = "990502"
  7807. } else if reg_type == 11 {
  7808. med_type = "11"
  7809. }
  7810. }
  7811. 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)
  7812. } else {
  7813. 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)
  7814. }
  7815. var dat map[string]interface{}
  7816. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7817. fmt.Println(dat)
  7818. } else {
  7819. fmt.Println(err)
  7820. }
  7821. saveLog(result, request_log, "2206", "预结算")
  7822. //userJSONBytes, _ := json.Marshal(dat)
  7823. //
  7824. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7825. // utils.ErrorLog("解析失败:%v", err)
  7826. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7827. // return
  7828. //}
  7829. userJSONBytes, _ := json.Marshal(dat)
  7830. if miConfig.Code == "H15049901371" {
  7831. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7832. utils.ErrorLog("解析失败:%v", err)
  7833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7834. return
  7835. }
  7836. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7837. res.Output = resSeven10265.Output
  7838. res.ErrMsg = resSeven10265.ErrMsg
  7839. res.Cainfo = resSeven10265.Cainfo
  7840. res.WarnMsg = resSeven10265.WarnMsg
  7841. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7842. res.Infcode = infocode
  7843. } else {
  7844. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7845. utils.ErrorLog("解析失败:%v", err)
  7846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7847. return
  7848. }
  7849. }
  7850. }
  7851. if res.Infcode != 0 {
  7852. errlog := &models.HisOrderError{
  7853. UserOrgId: adminUser.CurrentOrgId,
  7854. Ctime: time.Now().Unix(),
  7855. Mtime: time.Now().Unix(),
  7856. Number: chrg_bchno,
  7857. ErrMsg: res.ErrMsg,
  7858. Status: 1,
  7859. PatientId: id,
  7860. RecordTime: recordDateTime,
  7861. Stage: 20,
  7862. }
  7863. service.CreateErrMsgLog(errlog)
  7864. c.ServeSuccessJSON(map[string]interface{}{
  7865. "failed_code": -10,
  7866. "msg": res.ErrMsg,
  7867. })
  7868. return
  7869. } else {
  7870. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7871. order.OrderStatus = 1
  7872. order.IsPre = 1
  7873. order.Status = 1
  7874. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7875. order.SetlId = res.Output.Setlinfo.SetlID
  7876. order.PsnNo = res.Output.Setlinfo.PsnNo
  7877. order.PsnName = res.Output.Setlinfo.PsnName
  7878. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7879. order.Certno = res.Output.Setlinfo.Certno
  7880. order.Gend = res.Output.Setlinfo.Gend
  7881. order.Naty = res.Output.Setlinfo.Naty
  7882. order.Age = res.Output.Setlinfo.Age
  7883. order.Insutype = res.Output.Setlinfo.Insutype
  7884. order.PsnType = res.Output.Setlinfo.PsnType
  7885. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7886. order.SetlTime = res.Output.Setlinfo.SetlTime
  7887. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7888. if res.Output.Setlinfo.MedType == "140101" {
  7889. order.MedType = "14"
  7890. } else {
  7891. order.MedType = res.Output.Setlinfo.MedType
  7892. }
  7893. if reg_type == 1112 {
  7894. order.MedType = "1112"
  7895. }
  7896. if reg_type == 1111 {
  7897. order.MedType = "1111"
  7898. }
  7899. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7900. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7901. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7902. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7903. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7904. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7905. order.HifpPay = res.Output.Setlinfo.HifpPay
  7906. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7907. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7908. order.HifesPay = res.Output.Setlinfo.HifesPay
  7909. order.HifobPay = res.Output.Setlinfo.HifobPay
  7910. order.MafPay = res.Output.Setlinfo.MafPay
  7911. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7912. order.OthPay = res.Output.Setlinfo.OthPay
  7913. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7914. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7915. order.AcctPay = res.Output.Setlinfo.AcctPay
  7916. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7917. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7918. order.Balc = res.Output.Setlinfo.Balc
  7919. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7920. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7921. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7922. order.ClrWay = res.Output.Setlinfo.ClrWay
  7923. order.Creator = order.Creator
  7924. order.Modify = roles.AdminUserId
  7925. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7926. detailStr := string(setlDetail)
  7927. order.SetlDetail = detailStr
  7928. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7929. err = service.UpDateOrder(order)
  7930. if err == nil {
  7931. c.ServeSuccessJSON(map[string]interface{}{
  7932. "msg": "预结算成功",
  7933. })
  7934. } else {
  7935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7936. return
  7937. }
  7938. }
  7939. } else {
  7940. adminUser := c.GetAdminUserInfo()
  7941. errlog := &models.HisOrderError{
  7942. UserOrgId: adminUser.CurrentOrgId,
  7943. Ctime: time.Now().Unix(),
  7944. Mtime: time.Now().Unix(),
  7945. ErrMsg: res.ErrMsg,
  7946. Status: 1,
  7947. PatientId: id,
  7948. RecordTime: recordDateTime,
  7949. Stage: 4,
  7950. }
  7951. service.CreateErrMsgLog(errlog)
  7952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7953. return
  7954. }
  7955. } else {
  7956. adminUser := c.GetAdminUserInfo()
  7957. errlog := &models.HisOrderError{
  7958. UserOrgId: adminUser.CurrentOrgId,
  7959. Ctime: time.Now().Unix(),
  7960. Mtime: time.Now().Unix(),
  7961. ErrMsg: res.ErrMsg,
  7962. Status: 1,
  7963. PatientId: id,
  7964. RecordTime: recordDateTime,
  7965. Stage: 4,
  7966. }
  7967. service.CreateErrMsgLog(errlog)
  7968. c.ServeSuccessJSON(map[string]interface{}{
  7969. "failed_code": -10,
  7970. "msg": res.ErrMsg,
  7971. })
  7972. return
  7973. }
  7974. }
  7975. }
  7976. }
  7977. //退款
  7978. func (c *HisApiController) Refund() {
  7979. order_id, _ := c.GetInt64("order_id")
  7980. admin_user_id, _ := c.GetInt64("admin_user_id")
  7981. adminUser := c.GetAdminUserInfo()
  7982. var order models.HisOrder
  7983. order, _ = service.GetHisOrderByID(order_id)
  7984. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7985. if order.ID == 0 {
  7986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7987. return
  7988. }
  7989. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7990. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7991. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7992. if config.IsOpen == 1 { //对接了医保,走医保流程
  7993. var res ResultSixteen
  7994. var resSixteen10265 ResultSixteen10265
  7995. var src_resquest string
  7996. var result string
  7997. if miConfig.MdtrtareaAdmvs == "421300" {
  7998. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7999. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8000. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8001. resp3, requestErr3 := http.Get(api3)
  8002. if requestErr3 != nil {
  8003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8004. return
  8005. }
  8006. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8007. if ioErr3 != nil {
  8008. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8010. return
  8011. }
  8012. var respJSON3 map[string]interface{}
  8013. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8016. return
  8017. }
  8018. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8019. userJSONBytes3, _ := json.Marshal(respJSON3)
  8020. fmt.Println("log")
  8021. fmt.Println(string(userJSONBytes3))
  8022. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  8023. utils.ErrorLog("解析失败:%v", err)
  8024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8025. return
  8026. }
  8027. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8028. var api3 string
  8029. if miConfig.MdtrtareaAdmvs == "320921" {
  8030. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8031. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8032. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8033. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8034. } else {
  8035. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8036. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8037. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8038. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8039. }
  8040. resp3, requestErr3 := http.Get(api3)
  8041. if requestErr3 != nil {
  8042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8043. return
  8044. }
  8045. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8046. if ioErr3 != nil {
  8047. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8049. return
  8050. }
  8051. var respJSON3 map[string]interface{}
  8052. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8055. return
  8056. }
  8057. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8058. userJSONBytes3, _ := json.Marshal(respJSON3)
  8059. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  8060. utils.ErrorLog("解析失败:%v", err)
  8061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8062. return
  8063. }
  8064. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8065. res.Output = resSixteen10265.Output
  8066. res.ErrMsg = resSixteen10265.ErrMsg
  8067. res.Cainfo = resSixteen10265.Cainfo
  8068. res.WarnMsg = resSixteen10265.WarnMsg
  8069. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8070. res.Infcode = infocode
  8071. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8072. 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)
  8073. var dat map[string]interface{}
  8074. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8075. fmt.Println(dat)
  8076. } else {
  8077. fmt.Println(err)
  8078. }
  8079. saveLog(result, src_resquest, "2208", "退费")
  8080. userJSONBytes, _ := json.Marshal(dat)
  8081. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8082. utils.ErrorLog("解析失败:%v", err)
  8083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8084. return
  8085. }
  8086. } else {
  8087. if miConfig.Code == "H15049901371" {
  8088. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8089. var dat map[string]interface{}
  8090. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8091. fmt.Println(dat)
  8092. } else {
  8093. fmt.Println(err)
  8094. }
  8095. saveLog(result, src_resquest, "2208", "退费")
  8096. userJSONBytes, _ := json.Marshal(dat)
  8097. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  8098. utils.ErrorLog("解析失败:%v", err)
  8099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8100. return
  8101. }
  8102. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8103. res.Output = resSixteen10265.Output
  8104. res.ErrMsg = resSixteen10265.ErrMsg
  8105. res.Cainfo = resSixteen10265.Cainfo
  8106. res.WarnMsg = resSixteen10265.WarnMsg
  8107. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8108. res.Infcode = infocode
  8109. } else {
  8110. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8111. var dat map[string]interface{}
  8112. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8113. fmt.Println(dat)
  8114. } else {
  8115. fmt.Println(err)
  8116. }
  8117. saveLog(result, src_resquest, "2208", "退费")
  8118. userJSONBytes, _ := json.Marshal(dat)
  8119. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8120. utils.ErrorLog("解析失败:%v", err)
  8121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8122. return
  8123. }
  8124. }
  8125. }
  8126. if res.Infcode == 0 {
  8127. var res2 ResultSix
  8128. var resSix10265 ResultSix10265
  8129. if miConfig.MdtrtareaAdmvs == "421300" {
  8130. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8131. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8132. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8133. resp3, requestErr3 := http.Get(api3)
  8134. if requestErr3 != nil {
  8135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8136. return
  8137. }
  8138. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8139. if ioErr3 != nil {
  8140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8142. return
  8143. }
  8144. var respJSON3 map[string]interface{}
  8145. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8148. return
  8149. }
  8150. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8151. userJSONBytes3, _ := json.Marshal(respJSON3)
  8152. fmt.Println("log")
  8153. fmt.Println(string(userJSONBytes3))
  8154. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8155. utils.ErrorLog("解析失败:%v", err)
  8156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8157. return
  8158. }
  8159. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8160. var api3 string
  8161. if miConfig.MdtrtareaAdmvs == "320921" {
  8162. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8163. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8164. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8165. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8166. } else {
  8167. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8168. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8169. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8170. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8171. }
  8172. resp3, requestErr3 := http.Get(api3)
  8173. if requestErr3 != nil {
  8174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8175. return
  8176. }
  8177. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8178. if ioErr3 != nil {
  8179. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8181. return
  8182. }
  8183. var respJSON3 map[string]interface{}
  8184. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8185. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8187. return
  8188. }
  8189. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8190. userJSONBytes3, _ := json.Marshal(respJSON3)
  8191. fmt.Println("log")
  8192. fmt.Println(string(userJSONBytes3))
  8193. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8194. utils.ErrorLog("解析失败:%v", err)
  8195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8196. return
  8197. }
  8198. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8199. res2.Output = resSix10265.Output
  8200. res2.ErrMsg = resSix10265.ErrMsg
  8201. res2.Cainfo = resSix10265.Cainfo
  8202. res2.WarnMsg = resSix10265.WarnMsg
  8203. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8204. res2.Infcode = infocode
  8205. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8206. 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)
  8207. var dat map[string]interface{}
  8208. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8209. fmt.Println(dat)
  8210. } else {
  8211. fmt.Println(err)
  8212. }
  8213. saveLog(result2, src_request, "2205", "撤销明细")
  8214. userJSONBytes, _ := json.Marshal(dat)
  8215. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8216. utils.ErrorLog("解析失败:%v", err)
  8217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8218. return
  8219. }
  8220. } else {
  8221. if miConfig.Code == "H15049901371" {
  8222. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8223. var dat map[string]interface{}
  8224. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8225. fmt.Println(dat)
  8226. } else {
  8227. fmt.Println(err)
  8228. }
  8229. saveLog(result2, src_request, "2205", "撤销明细")
  8230. userJSONBytes, _ := json.Marshal(dat)
  8231. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8232. utils.ErrorLog("解析失败:%v", err)
  8233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8234. return
  8235. }
  8236. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8237. res2.Output = resSix10265.Output
  8238. res2.ErrMsg = resSix10265.ErrMsg
  8239. res2.Cainfo = resSix10265.Cainfo
  8240. res2.WarnMsg = resSix10265.WarnMsg
  8241. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8242. res2.Infcode = infocode
  8243. } else {
  8244. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8245. var dat map[string]interface{}
  8246. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8247. fmt.Println(dat)
  8248. } else {
  8249. fmt.Println(err)
  8250. }
  8251. saveLog(result2, src_request, "2205", "撤销明细")
  8252. userJSONBytes, _ := json.Marshal(dat)
  8253. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8254. utils.ErrorLog("解析失败:%v", err)
  8255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8256. return
  8257. }
  8258. }
  8259. }
  8260. if res2.Infcode == 0 {
  8261. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8262. if err == nil {
  8263. //当押金不为零时产生退费记录
  8264. if order.Decimal != 0 {
  8265. tmp := strconv.FormatInt(order.ID, 10)
  8266. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8267. if err != nil {
  8268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8269. return
  8270. }
  8271. }
  8272. c.ServeSuccessJSON(map[string]interface{}{
  8273. "msg": "退费成功",
  8274. })
  8275. } else {
  8276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8277. return
  8278. }
  8279. } else {
  8280. c.ServeSuccessJSON(map[string]interface{}{
  8281. "code": -10,
  8282. "msg": res2.ErrMsg,
  8283. })
  8284. }
  8285. } else {
  8286. c.ServeSuccessJSON(map[string]interface{}{
  8287. "code": -10,
  8288. "msg": res.ErrMsg,
  8289. })
  8290. }
  8291. }
  8292. }
  8293. func (c *HisApiController) RefundNumber() {
  8294. record_time := c.GetString("record_time")
  8295. //patient_id, _ := c.GetInt64("patient_id")
  8296. admin_user_id, _ := c.GetInt64("admin_user_id")
  8297. his_patient_id, _ := c.GetInt64("id")
  8298. timeLayout := "2006-01-02"
  8299. loc, _ := time.LoadLocation("Local")
  8300. adminUser := c.GetAdminUserInfo()
  8301. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8302. fmt.Println(err)
  8303. if err != nil {
  8304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8305. return
  8306. }
  8307. recordDateTime := theTime.Unix()
  8308. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8309. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8310. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8311. //order, _ := service.GetHisOrderByID(order_id)
  8312. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8313. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8314. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8315. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8316. if count > 0 {
  8317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8318. return
  8319. }
  8320. if config.IsOpen == 1 { //对接了医保,走医保流程
  8321. var res2 ResultSix
  8322. var resSix10265 ResultSix10265
  8323. if miConfig.MdtrtareaAdmvs == "421300" {
  8324. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8325. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8326. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8327. resp3, requestErr3 := http.Get(api3)
  8328. if requestErr3 != nil {
  8329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8330. return
  8331. }
  8332. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8333. if ioErr3 != nil {
  8334. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8336. return
  8337. }
  8338. var respJSON3 map[string]interface{}
  8339. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8340. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8342. return
  8343. }
  8344. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8345. userJSONBytes3, _ := json.Marshal(respJSON3)
  8346. fmt.Println("log")
  8347. fmt.Println(string(userJSONBytes3))
  8348. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8349. utils.ErrorLog("解析失败:%v", err)
  8350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8351. return
  8352. }
  8353. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8354. var api3 string
  8355. if miConfig.MdtrtareaAdmvs == "320921" {
  8356. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8357. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8358. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8359. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8360. } else {
  8361. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8362. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8363. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8364. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8365. }
  8366. resp3, requestErr3 := http.Get(api3)
  8367. if requestErr3 != nil {
  8368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8369. return
  8370. }
  8371. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8372. if ioErr3 != nil {
  8373. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8375. return
  8376. }
  8377. var respJSON3 map[string]interface{}
  8378. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8379. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8381. return
  8382. }
  8383. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8384. userJSONBytes3, _ := json.Marshal(respJSON3)
  8385. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8386. utils.ErrorLog("解析失败:%v", err)
  8387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8388. return
  8389. }
  8390. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8391. res2.Output = resSix10265.Output
  8392. res2.ErrMsg = resSix10265.ErrMsg
  8393. res2.Cainfo = resSix10265.Cainfo
  8394. res2.WarnMsg = resSix10265.WarnMsg
  8395. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8396. res2.Infcode = infocode
  8397. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8398. 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)
  8399. var dat map[string]interface{}
  8400. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8401. fmt.Println(dat)
  8402. } else {
  8403. fmt.Println(err)
  8404. }
  8405. saveLog(result, request, "2202", "退号")
  8406. userJSONBytes, _ := json.Marshal(dat)
  8407. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8408. utils.ErrorLog("解析失败:%v", err)
  8409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8410. return
  8411. }
  8412. } else {
  8413. var api3 string
  8414. if miConfig.Code == "H15049901371" {
  8415. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8416. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8417. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8418. } else {
  8419. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8420. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8421. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8422. }
  8423. resp3, requestErr3 := http.Get(api3)
  8424. if requestErr3 != nil {
  8425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8426. return
  8427. }
  8428. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8429. if ioErr3 != nil {
  8430. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8432. return
  8433. }
  8434. var respJSON3 map[string]interface{}
  8435. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8436. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8438. return
  8439. }
  8440. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8441. userJSONBytes3, _ := json.Marshal(respJSON3)
  8442. if miConfig.Code == "H15049901371" {
  8443. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8444. utils.ErrorLog("解析失败:%v", err)
  8445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8446. return
  8447. }
  8448. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8449. res2.Output = resSix10265.Output
  8450. res2.ErrMsg = resSix10265.ErrMsg
  8451. res2.Cainfo = resSix10265.Cainfo
  8452. res2.WarnMsg = resSix10265.WarnMsg
  8453. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8454. res2.Infcode = infocode
  8455. } else {
  8456. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8457. utils.ErrorLog("解析失败:%v", err)
  8458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8459. return
  8460. }
  8461. }
  8462. }
  8463. if res2.Infcode == 0 {
  8464. if err == nil {
  8465. c.ServeSuccessJSON(map[string]interface{}{
  8466. "msg": "退号成功",
  8467. })
  8468. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8469. } else {
  8470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8471. return
  8472. }
  8473. } else {
  8474. c.ServeSuccessJSON(map[string]interface{}{
  8475. "code": -10,
  8476. "msg": res2.ErrMsg,
  8477. })
  8478. }
  8479. } else {
  8480. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8481. //if err == nil {
  8482. // c.ServeSuccessJSON(map[string]interface{}{
  8483. // "msg": "退费成功",
  8484. // })
  8485. //} else {
  8486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8487. // return
  8488. //}
  8489. }
  8490. }
  8491. func (c *HisApiController) RefundDetail() {
  8492. order_id, _ := c.GetInt64("order_id")
  8493. admin_user_id, _ := c.GetInt64("admin_user_id")
  8494. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8495. number := c.GetString("number")
  8496. record_time := c.GetString("record_time")
  8497. patient_id, _ := c.GetInt64("patient_id")
  8498. //med_type, _ := c.GetInt64("med_type")
  8499. timeLayout := "2006-01-02"
  8500. loc, _ := time.LoadLocation("Local")
  8501. adminUser := c.GetAdminUserInfo()
  8502. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8503. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8504. fmt.Println(err)
  8505. if err != nil {
  8506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8507. return
  8508. }
  8509. recordDateTime := theTime.Unix()
  8510. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8511. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8512. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8513. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8514. var order models.HisOrder
  8515. order, _ = service.GetHisOrderByID(order_id)
  8516. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8517. if config.IsOpen == 1 { //对接了医保,走医保流程
  8518. var res2 ResultSix
  8519. if miConfig.MdtrtareaAdmvs == "421300" {
  8520. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8521. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8522. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8523. resp3, requestErr3 := http.Get(api3)
  8524. if requestErr3 != nil {
  8525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8526. return
  8527. }
  8528. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8529. if ioErr3 != nil {
  8530. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8532. return
  8533. }
  8534. var respJSON3 map[string]interface{}
  8535. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8538. return
  8539. }
  8540. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8541. userJSONBytes3, _ := json.Marshal(respJSON3)
  8542. fmt.Println("log")
  8543. fmt.Println(string(userJSONBytes3))
  8544. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8545. utils.ErrorLog("解析失败:%v", err)
  8546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8547. return
  8548. }
  8549. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8550. if err == nil {
  8551. c.ServeSuccessJSON(map[string]interface{}{
  8552. "msg": "撤销明细成功",
  8553. })
  8554. return
  8555. } else {
  8556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8557. return
  8558. }
  8559. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8560. var resSix10265 ResultSix10265
  8561. var api3 string
  8562. if miConfig.MdtrtareaAdmvs == "320921" {
  8563. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8564. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8565. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8566. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8567. } else {
  8568. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8569. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8570. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8571. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8572. }
  8573. resp3, requestErr3 := http.Get(api3)
  8574. if requestErr3 != nil {
  8575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8576. return
  8577. }
  8578. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8579. if ioErr3 != nil {
  8580. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8582. return
  8583. }
  8584. var respJSON3 map[string]interface{}
  8585. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8586. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8588. return
  8589. }
  8590. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8591. userJSONBytes3, _ := json.Marshal(respJSON3)
  8592. fmt.Println("log")
  8593. fmt.Println(string(userJSONBytes3))
  8594. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8595. utils.ErrorLog("解析失败:%v", err)
  8596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8597. return
  8598. }
  8599. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8600. res2.Output = resSix10265.Output
  8601. res2.ErrMsg = resSix10265.ErrMsg
  8602. res2.Cainfo = resSix10265.Cainfo
  8603. res2.WarnMsg = resSix10265.WarnMsg
  8604. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8605. res2.Infcode = infocode
  8606. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8607. if err == nil {
  8608. c.ServeSuccessJSON(map[string]interface{}{
  8609. "msg": "撤销明细成功",
  8610. })
  8611. return
  8612. } else {
  8613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8614. return
  8615. }
  8616. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8617. 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)
  8618. var dat map[string]interface{}
  8619. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8620. fmt.Println(dat)
  8621. } else {
  8622. fmt.Println(err)
  8623. }
  8624. saveLog(result2, src_request, "2205", "撤销明细")
  8625. userJSONBytes, _ := json.Marshal(dat)
  8626. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8627. utils.ErrorLog("解析失败:%v", err)
  8628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8629. return
  8630. }
  8631. if res2.Infcode == 0 {
  8632. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8633. if err == nil {
  8634. c.ServeSuccessJSON(map[string]interface{}{
  8635. "msg": "撤销明细成功",
  8636. })
  8637. return
  8638. } else {
  8639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8640. return
  8641. }
  8642. } else {
  8643. c.ServeSuccessJSON(map[string]interface{}{
  8644. "code": -10,
  8645. "msg": res2.ErrMsg,
  8646. })
  8647. }
  8648. } else {
  8649. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8650. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8651. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8652. resp2, requestErr2 := http.Get(api2)
  8653. if requestErr2 != nil {
  8654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8655. return
  8656. }
  8657. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8658. if ioErr2 != nil {
  8659. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8661. return
  8662. }
  8663. var respJSON2 map[string]interface{}
  8664. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8665. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8667. return
  8668. }
  8669. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8670. if err == nil {
  8671. c.ServeSuccessJSON(map[string]interface{}{
  8672. "msg": "撤销明细成功",
  8673. })
  8674. return
  8675. } else {
  8676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8677. return
  8678. }
  8679. }
  8680. } else {
  8681. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8682. if err == nil {
  8683. c.ServeSuccessJSON(map[string]interface{}{
  8684. "msg": "退费成功",
  8685. })
  8686. } else {
  8687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8688. return
  8689. }
  8690. }
  8691. }
  8692. //对账
  8693. func (c *HisApiController) GetCheckAccount() {
  8694. start_time := c.GetString("start_time")
  8695. end_time := c.GetString("end_time")
  8696. insutype := c.GetString("insutype")
  8697. clr_type := c.GetString("clr_type")
  8698. clr_org := c.GetString("clr_optins")
  8699. admin_user_id, _ := c.GetInt64("admin_user_id")
  8700. adminUser := c.GetAdminUserInfo()
  8701. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8702. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8703. if len(clr_org) == 0 {
  8704. clr_org = miConfig.MdtrtareaAdmvs
  8705. }
  8706. timeLayout := "2006-01-02"
  8707. loc, _ := time.LoadLocation("Local")
  8708. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8709. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8710. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8711. fixmedins_setl_cnt := int64(len(orders))
  8712. var medfee_sumamt float64
  8713. var acct_pay float64
  8714. var fund_pay_sumamt float64
  8715. for _, item := range orders {
  8716. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8717. acct_pay = acct_pay + item.AcctPay
  8718. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8719. }
  8720. var user_name string
  8721. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8722. if role.ID == 0 {
  8723. user_name = "xxx"
  8724. } else {
  8725. user_name = role.UserName
  8726. }
  8727. var res ResultEight
  8728. var res10188 ResultEightFor10188
  8729. if config.IsOpen == 1 {
  8730. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8731. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  8732. "insutype=" + insutype +
  8733. "&clr_type=" + clr_type +
  8734. "&setl_optins=" + clr_org +
  8735. "&stmt_begndate=" + start_time +
  8736. "&stm_enddate=" + end_time +
  8737. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8738. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8739. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8740. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8741. "&fixmedins_code=" + miConfig.Code +
  8742. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8743. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8744. "&secret_key=" + miConfig.SecretKey +
  8745. "&org_name=" + miConfig.OrgName +
  8746. "&doctor=" + user_name +
  8747. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8748. fmt.Println(api)
  8749. resp, requestErr := http.Get(api)
  8750. if requestErr != nil {
  8751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8752. return
  8753. }
  8754. body, ioErr := ioutil.ReadAll(resp.Body)
  8755. fmt.Println(body)
  8756. if ioErr != nil {
  8757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8759. return
  8760. }
  8761. var respJSON map[string]interface{}
  8762. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8765. return
  8766. }
  8767. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8768. userJSONBytes, _ := json.Marshal(respJSON)
  8769. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8770. utils.ErrorLog("解析失败:%v", err)
  8771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8772. return
  8773. }
  8774. res.InfRefmsgid = res10188.InfRefmsgid
  8775. res.Output = res10188.Output
  8776. res.ErrMsg = res10188.ErrMsg
  8777. res.Cainfo = res10188.Cainfo
  8778. res.WarnMsg = res10188.WarnMsg
  8779. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8780. res.Infcode = infocode
  8781. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8782. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8783. "insutype=" + insutype +
  8784. "&clr_type=" + clr_type +
  8785. "&setl_optins=" + clr_org +
  8786. "&stmt_begndate=" + start_time +
  8787. "&stm_enddate=" + end_time +
  8788. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8789. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8790. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8791. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8792. "&fixmedins_code=" + miConfig.Code +
  8793. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8794. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8795. "&secret_key=" + miConfig.SecretKey +
  8796. "&org_name=" + miConfig.OrgName +
  8797. "&doctor=" + user_name
  8798. resp, requestErr := http.Get(api)
  8799. if requestErr != nil {
  8800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8801. return
  8802. }
  8803. body, ioErr := ioutil.ReadAll(resp.Body)
  8804. if ioErr != nil {
  8805. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8807. return
  8808. }
  8809. var respJSON map[string]interface{}
  8810. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8813. return
  8814. }
  8815. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8816. result, _ := json.Marshal(respJSON)
  8817. fmt.Println("log")
  8818. fmt.Println(string(result))
  8819. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8820. utils.ErrorLog("解析失败:%v", err)
  8821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8822. return
  8823. }
  8824. res.InfRefmsgid = res10188.InfRefmsgid
  8825. res.Output = res10188.Output
  8826. res.ErrMsg = res10188.ErrMsg
  8827. res.Cainfo = res10188.Cainfo
  8828. res.WarnMsg = res10188.WarnMsg
  8829. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8830. res.Infcode = infocode
  8831. } else {
  8832. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8833. "insutype=" + insutype +
  8834. "&clr_type=" + clr_type +
  8835. "&setl_optins=" + clr_org +
  8836. "&stmt_begndate=" + start_time +
  8837. "&stm_enddate=" + end_time +
  8838. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8839. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8840. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8841. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8842. "&fixmedins_code=" + miConfig.Code +
  8843. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8844. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8845. "&secret_key=" + miConfig.SecretKey +
  8846. "&org_name=" + miConfig.OrgName +
  8847. "&doctor=" + user_name
  8848. fmt.Println(api)
  8849. resp, requestErr := http.Get(api)
  8850. if requestErr != nil {
  8851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8852. return
  8853. }
  8854. body, ioErr := ioutil.ReadAll(resp.Body)
  8855. fmt.Println(body)
  8856. if ioErr != nil {
  8857. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8859. return
  8860. }
  8861. var respJSON map[string]interface{}
  8862. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8865. return
  8866. }
  8867. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8868. userJSONBytes, _ := json.Marshal(respJSON)
  8869. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8870. utils.ErrorLog("解析失败:%v", err)
  8871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8872. return
  8873. }
  8874. }
  8875. if res.Infcode == 0 {
  8876. if res.Output.Stmtinfo.StmtRslt == "0" {
  8877. micc := &models.MedicalInsuranceCostCompare{
  8878. StartTime: startime.Unix(),
  8879. EndTime: endtime.Unix(),
  8880. Insutype: insutype,
  8881. CheckType: 1,
  8882. Num: fixmedins_setl_cnt,
  8883. Mtime: time.Now().Unix(),
  8884. Status: 1,
  8885. UserOrgId: adminUser.CurrentOrgId,
  8886. CostTotal: medfee_sumamt,
  8887. FuncTotal: fund_pay_sumamt,
  8888. PsnPay: acct_pay,
  8889. Creator: admin_user_id,
  8890. Ctime: time.Now().Unix(),
  8891. ClrType: clr_type,
  8892. }
  8893. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8894. if err == nil {
  8895. c.ServeSuccessJSON(map[string]interface{}{
  8896. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8897. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8898. })
  8899. } else {
  8900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8901. }
  8902. } else {
  8903. c.ServeSuccessJSON(map[string]interface{}{
  8904. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8905. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8906. })
  8907. }
  8908. } else {
  8909. c.ServeSuccessJSON(map[string]interface{}{
  8910. "code": -10,
  8911. "msg": res.ErrMsg,
  8912. })
  8913. }
  8914. }
  8915. }
  8916. func (c *HisApiController) Check310() {
  8917. adminUser := c.GetAdminUserInfo()
  8918. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8919. var user_name string
  8920. user_name = "高慧裕"
  8921. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8922. "insutype=" + "310" +
  8923. "&clr_type=" + "" +
  8924. "&setl_optins=" + "441202" +
  8925. "&stmt_begndate=" + "2022-03-01" +
  8926. "&stm_enddate=" + "2022-03-31" +
  8927. "&medfee_sumamt=" + "194930.12" +
  8928. "&fund_pay_sumamt=" + "188741.46" +
  8929. "&acct_pay=" + "0" +
  8930. "&fixmedins_setl_cnt=" + "452" +
  8931. "&fixmedins_code=" + miConfig.Code +
  8932. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8933. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8934. "&secret_key=" + miConfig.SecretKey +
  8935. "&org_name=" + miConfig.OrgName +
  8936. "&doctor=" + user_name
  8937. fmt.Println(api)
  8938. resp, requestErr := http.Get(api)
  8939. if requestErr != nil {
  8940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8941. return
  8942. }
  8943. body, ioErr := ioutil.ReadAll(resp.Body)
  8944. fmt.Println(body)
  8945. if ioErr != nil {
  8946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8948. return
  8949. }
  8950. var respJSON map[string]interface{}
  8951. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8954. return
  8955. }
  8956. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8957. userJSONBytes, _ := json.Marshal(respJSON)
  8958. var res ResultEight
  8959. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8960. utils.ErrorLog("解析失败:%v", err)
  8961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8962. return
  8963. }
  8964. }
  8965. func (c *HisApiController) Check390() {
  8966. adminUser := c.GetAdminUserInfo()
  8967. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8968. var user_name string
  8969. user_name = "高慧裕"
  8970. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8971. "insutype=" + "390" +
  8972. "&clr_type=" + "" +
  8973. "&setl_optins=" + "441202" +
  8974. "&stmt_begndate=" + "2022-03-01" +
  8975. "&stm_enddate=" + "2022-03-31" +
  8976. "&medfee_sumamt=" + "1068448.89" +
  8977. "&fund_pay_sumamt=" + "1014677.62" +
  8978. "&acct_pay=" + "0" +
  8979. "&fixmedins_setl_cnt=" + "1950" +
  8980. "&fixmedins_code=" + miConfig.Code +
  8981. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8982. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8983. "&secret_key=" + miConfig.SecretKey +
  8984. "&org_name=" + miConfig.OrgName +
  8985. "&doctor=" + user_name
  8986. fmt.Println(api)
  8987. resp, requestErr := http.Get(api)
  8988. if requestErr != nil {
  8989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8990. return
  8991. }
  8992. body, ioErr := ioutil.ReadAll(resp.Body)
  8993. fmt.Println(body)
  8994. if ioErr != nil {
  8995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8997. return
  8998. }
  8999. var respJSON map[string]interface{}
  9000. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9003. return
  9004. }
  9005. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9006. userJSONBytes, _ := json.Marshal(respJSON)
  9007. var res ResultEight
  9008. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9009. utils.ErrorLog("解析失败:%v", err)
  9010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9011. return
  9012. }
  9013. }
  9014. //对账明细
  9015. func (c *HisApiController) GetCheckDetailAccount() {
  9016. start_time := c.GetString("start_time")
  9017. end_time := c.GetString("end_time")
  9018. admin_user_id, _ := c.GetInt64("admin_user_id")
  9019. adminUser := c.GetAdminUserInfo()
  9020. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9021. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9022. timeLayout := "2006-01-02"
  9023. loc, _ := time.LoadLocation("Local")
  9024. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  9025. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  9026. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  9027. rand.Seed(time.Now().UnixNano())
  9028. num := rand.Intn(30000)
  9029. Mkdir(miConfig.OrgName)
  9030. file := strconv.FormatInt(int64(num), 10)
  9031. file_name := file + ".txt"
  9032. zip_name := file + ".zip"
  9033. zip_path := miConfig.OrgName + "/" + zip_name
  9034. file_path := miConfig.OrgName + "/" + file_name
  9035. decimal.DivisionPrecision = 2
  9036. var medfee_sumamt float64
  9037. var psn_cash_pay float64
  9038. var fund_pay_sumamt float64
  9039. fixmedins_setl_cnt := int64(len(orders))
  9040. for _, item := range orders {
  9041. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  9042. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  9043. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  9044. }
  9045. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  9046. defer f.Close()
  9047. if err != nil {
  9048. fmt.Println(err.Error())
  9049. } else {
  9050. for _, item := range orders {
  9051. var refd_setl_flag string
  9052. if item.OrderStatus == 2 {
  9053. refd_setl_flag = "0"
  9054. var str string
  9055. str = item.SetlId + " " +
  9056. item.MdtrtId + " " +
  9057. item.PsnNo + " " +
  9058. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9059. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9060. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  9061. _, err = f.Write([]byte(str))
  9062. }
  9063. if item.OrderStatus == 3 {
  9064. var str string
  9065. str = item.SetlId + " " +
  9066. item.MdtrtId + " " +
  9067. item.PsnNo + " " +
  9068. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9069. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9070. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  9071. _, err = f.Write([]byte(str))
  9072. var str2 string
  9073. str2 = item.SetlId + " " +
  9074. item.MdtrtId + " " +
  9075. item.PsnNo + " " +
  9076. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  9077. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  9078. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  9079. _, err = f.Write([]byte(str2))
  9080. }
  9081. }
  9082. }
  9083. Zip(file_path, zip_path)
  9084. fmt.Println(ReadFile(zip_path))
  9085. fmt.Println(string(ReadFile(zip_path)))
  9086. if config.IsOpen == 1 {
  9087. var user_name string
  9088. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9089. if role.ID == 0 {
  9090. user_name = "管理员"
  9091. } else {
  9092. user_name = role.UserName
  9093. }
  9094. baseParams := models.BaseParams{
  9095. SecretKey: miConfig.SecretKey,
  9096. FixmedinsCode: miConfig.Code,
  9097. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9098. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9099. OrgName: miConfig.OrgName,
  9100. Doctor: user_name,
  9101. }
  9102. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  9103. var dat map[string]interface{}
  9104. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9105. fmt.Println(dat)
  9106. } else {
  9107. fmt.Println(err)
  9108. }
  9109. userJSONBytes, _ := json.Marshal(dat)
  9110. var res ResultNine
  9111. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9112. utils.ErrorLog("解析失败:%v", err)
  9113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9114. return
  9115. }
  9116. if res.Infcode == 0 {
  9117. fileNo := res.Output.FileQuryNo
  9118. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  9119. "file_qury_no=" + fileNo +
  9120. "&setl_optins=" + "定点医保中心" +
  9121. "&stmt_begndate=" + start_time +
  9122. "&stm_enddate=" + end_time +
  9123. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9124. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9125. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  9126. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9127. "&fixmedins_code=" + miConfig.Code +
  9128. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9129. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9130. "&secret_key=" + miConfig.SecretKey +
  9131. "&org_name=" + miConfig.OrgName +
  9132. "&doctor=" + user_name
  9133. resp, requestErr := http.Get(api)
  9134. if requestErr != nil {
  9135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9136. return
  9137. }
  9138. body, ioErr := ioutil.ReadAll(resp.Body)
  9139. if ioErr != nil {
  9140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9142. return
  9143. }
  9144. var respJSON map[string]interface{}
  9145. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9148. return
  9149. }
  9150. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9151. userJSONBytes, _ := json.Marshal(respJSON)
  9152. var res ResultTen
  9153. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9154. utils.ErrorLog("解析失败:%v", err)
  9155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9156. return
  9157. }
  9158. if res.Infcode == 0 {
  9159. service.Gdyb9102(baseParams, zip_name, fileNo)
  9160. micc := &models.MedicalInsuranceCostCompare{
  9161. StartTime: startime.Unix(),
  9162. EndTime: endtime.Unix(),
  9163. Insutype: "0",
  9164. CheckType: 2,
  9165. Num: fixmedins_setl_cnt,
  9166. Mtime: time.Now().Unix(),
  9167. Status: 1,
  9168. UserOrgId: adminUser.CurrentOrgId,
  9169. CostTotal: medfee_sumamt,
  9170. FuncTotal: fund_pay_sumamt,
  9171. PsnPay: psn_cash_pay,
  9172. Creator: admin_user_id,
  9173. Ctime: time.Now().Unix(),
  9174. }
  9175. service.CreateMedicalInsuranceCostCompareRecord(micc)
  9176. c.ServeSuccessJSON(map[string]interface{}{
  9177. "msg": "明细对账成功",
  9178. })
  9179. }
  9180. } else {
  9181. }
  9182. }
  9183. }
  9184. type CustomOrderInfo struct {
  9185. Name string
  9186. Spec string
  9187. Unit string
  9188. Count float64
  9189. Price float64
  9190. Total float64
  9191. }
  9192. func (c *HisApiController) GetSettleAccounts() {
  9193. //id, _ := c.GetInt64("id")
  9194. //record_time := c.GetString("record_time")
  9195. order_id, _ := c.GetInt64("order_id")
  9196. admin_user_id, _ := c.GetInt64("admin_user_id")
  9197. //timeLayout := "2006-01-02"
  9198. //loc, _ := time.LoadLocation("Local")
  9199. //
  9200. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9201. //if err != nil {
  9202. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9203. // return
  9204. //}
  9205. //recordDateTime := theTime.Unix()
  9206. adminUser := c.GetAdminUserInfo()
  9207. order, _ := service.GetHisOrderByID(order_id)
  9208. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9209. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  9210. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9211. orderInfos = append(orderInfos, orderInfos_two...)
  9212. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9213. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  9214. var diagnosis_ids []string
  9215. if his.ID > 0 {
  9216. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  9217. } else {
  9218. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  9219. }
  9220. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  9221. var dia_config []*models.HisXtDiagnoseConfig
  9222. var name string
  9223. for _, item := range diagnosis_ids {
  9224. id, _ := strconv.ParseInt(item, 10, 64)
  9225. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9226. dia_config = append(dia_config, &diagnosisConfig)
  9227. if len(name) == 0 {
  9228. name = diagnosisConfig.ClassName
  9229. } else {
  9230. name = name + "," + diagnosisConfig.ClassName
  9231. }
  9232. }
  9233. var bedCostTotal float64 = 0 //床位总费
  9234. var bedCostSelfTotal float64 = 0 //床位自费
  9235. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  9236. var operationCostTotal float64 = 0 //手术费
  9237. var operationCostSelfTotal float64 = 0 //手术费
  9238. var operationCostPartSelfTotal float64 = 0 //手术费
  9239. var otherCostTotal float64 = 0 //其他费用
  9240. var otherCostSelfTotal float64 = 0 //其他费用
  9241. var otherCostPartSelfTotal float64 = 0 //其他费用
  9242. var materialCostTotal float64 = 0 //材料费
  9243. var materialCostSelfTotal float64 = 0 //材料费
  9244. var materialCostPartSelfTotal float64 = 0 //材料费
  9245. var westernMedicineCostTotal float64 = 0 //西药费
  9246. var westernMedicineCostSelfTotal float64 = 0 //西药费
  9247. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  9248. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  9249. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  9250. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  9251. var checkCostTotal float64 = 0 //检查费
  9252. var checkCostSelfTotal float64 = 0 //检查费
  9253. var checkCostPartSelfTotal float64 = 0 //检查费
  9254. var laboratoryCostTotal float64 = 0 //化验费
  9255. var laboratoryCostSelfTotal float64 = 0 //化验费
  9256. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  9257. var treatCostTotal float64 = 0 //治疗费用
  9258. var treatCostSelfTotal float64 = 0 //治疗费用
  9259. var treatCostPartSelfTotal float64 = 0 //治疗费用
  9260. decimal.DivisionPrecision = 2
  9261. for _, item := range orderInfos {
  9262. if item.MedChrgitmType == "01" { //床位费
  9263. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9264. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9265. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9266. }
  9267. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  9268. if item.MedChrgitmType == "03" { //检查费
  9269. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9270. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9271. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9272. }
  9273. } else {
  9274. if item.MedChrgitmType == "03" { //检查费
  9275. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9276. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9277. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9278. }
  9279. }
  9280. if item.MedChrgitmType == "04" { //化验费
  9281. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9282. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9283. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9284. }
  9285. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9286. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9287. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9288. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9289. }
  9290. if item.MedChrgitmType == "06" { //手术费
  9291. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9292. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9293. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9294. }
  9295. if item.MedChrgitmType == "08" { //材料费
  9296. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9297. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9298. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9299. }
  9300. if item.MedChrgitmType == "09" { //西药费
  9301. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9302. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9303. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9304. }
  9305. if item.MedChrgitmType == "11" { //中成费
  9306. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9307. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9308. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9309. }
  9310. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9311. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9312. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9313. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9314. }
  9315. }
  9316. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9317. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9318. var user_name string
  9319. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9320. if role.ID == 0 {
  9321. user_name = "管理员"
  9322. } else {
  9323. user_name = role.UserName
  9324. }
  9325. baseParams := models.BaseParams{
  9326. SecretKey: miConfig.SecretKey,
  9327. FixmedinsCode: miConfig.Code,
  9328. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9329. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9330. OrgName: miConfig.OrgName,
  9331. Doctor: user_name,
  9332. }
  9333. businessParams := models.BusinessParams{
  9334. PsnNo: order.PsnNo,
  9335. MdtrtId: order.MdtrtId,
  9336. SetlId: order.SetlId,
  9337. }
  9338. var res ResultEleven
  9339. var resEleven10265 ResultEleven10265
  9340. if config.IsOpen == 1 {
  9341. if miConfig.MdtrtareaAdmvs == "421300" {
  9342. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9343. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9344. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9345. resp, requestErr := http.Get(api)
  9346. if requestErr != nil {
  9347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9348. return
  9349. }
  9350. body, ioErr := ioutil.ReadAll(resp.Body)
  9351. if ioErr != nil {
  9352. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9354. return
  9355. }
  9356. var respJSON map[string]interface{}
  9357. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9358. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9360. return
  9361. }
  9362. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9363. result, _ := json.Marshal(respJSON)
  9364. fmt.Println("log")
  9365. fmt.Println(string(result))
  9366. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9367. utils.ErrorLog("解析失败:%v", err)
  9368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9369. return
  9370. }
  9371. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9372. var api string
  9373. if miConfig.MdtrtareaAdmvs == "320921" {
  9374. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9375. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9376. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9377. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9378. } else {
  9379. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9380. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9381. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9382. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9383. }
  9384. resp, requestErr := http.Get(api)
  9385. if requestErr != nil {
  9386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9387. return
  9388. }
  9389. body, ioErr := ioutil.ReadAll(resp.Body)
  9390. if ioErr != nil {
  9391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9393. return
  9394. }
  9395. var respJSON map[string]interface{}
  9396. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9397. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9399. return
  9400. }
  9401. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9402. result, _ := json.Marshal(respJSON)
  9403. fmt.Println("log")
  9404. fmt.Println(string(result))
  9405. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9406. utils.ErrorLog("解析失败:%v", err)
  9407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9408. return
  9409. }
  9410. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9411. res.Output = resEleven10265.Output
  9412. res.ErrMsg = resEleven10265.ErrMsg
  9413. res.Cainfo = resEleven10265.Cainfo
  9414. res.WarnMsg = resEleven10265.WarnMsg
  9415. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9416. res.Infcode = infocode
  9417. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9418. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9419. saveLog(result, requestLog, "5203", "结算单")
  9420. var dat map[string]interface{}
  9421. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9422. fmt.Println(dat)
  9423. } else {
  9424. fmt.Println(err)
  9425. }
  9426. userJSONBytes, _ := json.Marshal(dat)
  9427. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9428. utils.ErrorLog("解析失败:%v", err)
  9429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9430. return
  9431. }
  9432. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9433. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9434. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9435. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9436. resp, requestErr := http.Get(api)
  9437. if requestErr != nil {
  9438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9439. return
  9440. }
  9441. body, ioErr := ioutil.ReadAll(resp.Body)
  9442. if ioErr != nil {
  9443. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9445. return
  9446. }
  9447. var respJSON map[string]interface{}
  9448. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9449. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9451. return
  9452. }
  9453. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9454. result, _ := json.Marshal(respJSON)
  9455. fmt.Println("log")
  9456. fmt.Println(string(result))
  9457. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9458. utils.ErrorLog("解析失败:%v", err)
  9459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9460. return
  9461. }
  9462. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9463. res.Output = resEleven10265.Output
  9464. res.ErrMsg = resEleven10265.ErrMsg
  9465. res.Cainfo = resEleven10265.Cainfo
  9466. res.WarnMsg = resEleven10265.WarnMsg
  9467. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9468. res.Infcode = infocode
  9469. } else {
  9470. result := service.Gdyb5203(baseParams, businessParams)
  9471. //service.Gdyb5204(baseParams, businessParams)
  9472. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9473. var dat map[string]interface{}
  9474. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9475. fmt.Println(dat)
  9476. } else {
  9477. fmt.Println(err)
  9478. }
  9479. userJSONBytes, _ := json.Marshal(dat)
  9480. if miConfig.Code == "H15049901371" {
  9481. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9482. utils.ErrorLog("解析失败:%v", err)
  9483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9484. return
  9485. }
  9486. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9487. res.Output = resEleven10265.Output
  9488. res.ErrMsg = resEleven10265.ErrMsg
  9489. res.Cainfo = resEleven10265.Cainfo
  9490. res.WarnMsg = resEleven10265.WarnMsg
  9491. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9492. res.Infcode = infocode
  9493. } else {
  9494. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9495. utils.ErrorLog("解析失败:%v", err)
  9496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9497. return
  9498. }
  9499. }
  9500. }
  9501. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9502. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9503. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9504. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9505. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9506. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9507. var doctor_name string
  9508. if roles.ID == 0 {
  9509. doctor_name = "管理员"
  9510. } else {
  9511. doctor_name = roles.UserName
  9512. }
  9513. yiliao_leibie := ""
  9514. switch order.MedType {
  9515. case "11":
  9516. yiliao_leibie = "普通门诊"
  9517. break
  9518. case "12":
  9519. yiliao_leibie = "门诊挂号"
  9520. break
  9521. case "13":
  9522. yiliao_leibie = "急诊"
  9523. break
  9524. case "14":
  9525. yiliao_leibie = "门诊特殊病"
  9526. break
  9527. case "15":
  9528. yiliao_leibie = "门诊统筹"
  9529. break
  9530. case "16":
  9531. yiliao_leibie = "门诊慢性病"
  9532. break
  9533. case "21":
  9534. yiliao_leibie = "普通住院"
  9535. break
  9536. }
  9537. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9538. if res.Infcode == 0 {
  9539. c.ServeSuccessJSON(map[string]interface{}{
  9540. "diagnosis": name,
  9541. "order_infos": orderInfos,
  9542. "number": order.MdtrtId,
  9543. "date": order.SettleAccountsDate,
  9544. "charge_admin": charge_admin,
  9545. "printor_admin": printor_admin,
  9546. "info": res.Output.Setlinfo,
  9547. "order": order,
  9548. "bedCostTotal": bedCostTotal,
  9549. "bedCostSelfTotal": bedCostSelfTotal,
  9550. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9551. "operationCostTotal": operationCostTotal,
  9552. "operationCostSelfTotal": operationCostSelfTotal,
  9553. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9554. "otherCostTotal": otherCostTotal,
  9555. "otherCostSelfTotal": otherCostSelfTotal,
  9556. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9557. "materialCostTotal": materialCostTotal,
  9558. "materialCostSelfTotal": materialCostSelfTotal,
  9559. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9560. "westernMedicineCostTotal": westernMedicineCostTotal,
  9561. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9562. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9563. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9564. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9565. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9566. "checkCostTotal": checkCostTotal,
  9567. "checkCostSelfTotal": checkCostSelfTotal,
  9568. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9569. "laboratoryCostTotal": laboratoryCostTotal,
  9570. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9571. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9572. "treatCostTotal": treatCostTotal,
  9573. "treatCostSelfTotal": treatCostSelfTotal,
  9574. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9575. "doctor_info": doctor_info,
  9576. "doctor_code": adminRole_two.DoctorCode,
  9577. "doctor_name": doctor_name,
  9578. "health_card_no": order.PsnNo,
  9579. "department": departments.Name,
  9580. "yiliao_leibie": yiliao_leibie,
  9581. "after_money": order.AccountPrice,
  9582. "patient": patient,
  9583. "org_name": miConfig.OrgName,
  9584. "org_code": miConfig.Code,
  9585. "order_number": order.Number,
  9586. "his_hospital": his_hospital,
  9587. "his": his,
  9588. "dia_config": dia_config,
  9589. //"check_order_info": cus_slice,
  9590. })
  9591. }
  9592. }
  9593. }
  9594. func (c *HisApiController) CheckTreatment() {
  9595. patient_id, _ := c.GetInt64("patient_id")
  9596. id_card_no := c.GetString("id_card_no")
  9597. insutype := c.GetString("insutype")
  9598. med_type := c.GetString("med_type")
  9599. admin_user_id, _ := c.GetInt64("admin_user_id")
  9600. adminUser := c.GetAdminUserInfo()
  9601. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9602. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9603. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9604. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9605. if miConfig.MdtrtareaAdmvs == "421300" {
  9606. var res ResultTwo
  9607. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9608. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9609. "&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)
  9610. resp, requestErr := http.Get(api)
  9611. if requestErr != nil {
  9612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9613. return
  9614. }
  9615. body, ioErr := ioutil.ReadAll(resp.Body)
  9616. if ioErr != nil {
  9617. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9619. return
  9620. }
  9621. var respJSON map[string]interface{}
  9622. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9623. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9625. return
  9626. }
  9627. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9628. result, _ := json.Marshal(respJSON)
  9629. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9630. utils.ErrorLog("解析失败:%v", err)
  9631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9632. return
  9633. }
  9634. if res.Infcode == 0 {
  9635. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9636. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9637. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9638. resp, requestErr := http.Get(api)
  9639. if requestErr != nil {
  9640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9641. return
  9642. }
  9643. body, ioErr := ioutil.ReadAll(resp.Body)
  9644. if ioErr != nil {
  9645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9647. return
  9648. }
  9649. var respJSON map[string]interface{}
  9650. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9653. return
  9654. }
  9655. var res Result2001
  9656. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9657. result2, _ := json.Marshal(respJSON)
  9658. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9659. utils.ErrorLog("解析失败:%v", err)
  9660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9661. return
  9662. }
  9663. if res.Infcode == 0 {
  9664. c.ServeSuccessJSON(map[string]interface{}{
  9665. "msg": res.Output.Trtinfo,
  9666. })
  9667. }
  9668. } else {
  9669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9670. return
  9671. }
  9672. } else {
  9673. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9674. var dat map[string]interface{}
  9675. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9676. fmt.Println(dat)
  9677. } else {
  9678. fmt.Println(err)
  9679. }
  9680. userJSONBytes, _ := json.Marshal(dat)
  9681. var res ResultTwo
  9682. var res10265 ResultTwo10265
  9683. if miConfig.Code == "H15049901371" {
  9684. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9685. utils.ErrorLog("解析失败:%v", err)
  9686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9687. return
  9688. }
  9689. res.ErrMsg = res10265.ErrMsg
  9690. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9691. res.Infcode = infocode
  9692. res.Output = res10265.Output
  9693. res.InfRefmsgid = res10265.InfRefmsgid
  9694. } else {
  9695. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9696. utils.ErrorLog("解析失败:%v", err)
  9697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9698. return
  9699. }
  9700. }
  9701. var user_name string
  9702. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9703. if role.ID == 0 {
  9704. user_name = "xxx"
  9705. } else {
  9706. user_name = role.UserName
  9707. }
  9708. baseParams := models.BaseParams{
  9709. SecretKey: miConfig.SecretKey,
  9710. FixmedinsCode: miConfig.Code,
  9711. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9712. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9713. OrgName: miConfig.OrgName,
  9714. Doctor: user_name,
  9715. }
  9716. if config.IsOpen == 1 {
  9717. if miConfig.Code == "H15049901371" {
  9718. if med_type == "14" {
  9719. if insutype == "390" {
  9720. med_type = "9933"
  9721. } else if insutype == "310" {
  9722. med_type = "990502"
  9723. }
  9724. } else if med_type == "11" {
  9725. med_type = "11"
  9726. }
  9727. }
  9728. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9729. var dat map[string]interface{}
  9730. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9731. fmt.Println(dat)
  9732. } else {
  9733. fmt.Println(err)
  9734. }
  9735. var res Result2001
  9736. var res10265 Result2001Org10265
  9737. if miConfig.Code == "H15049901371" {
  9738. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9739. utils.ErrorLog("解析失败:%v", err)
  9740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9741. return
  9742. }
  9743. res.ErrMsg = res10265.ErrMsg
  9744. res.Output = res10265.Output
  9745. res.InfRefmsgid = res10265.InfRefmsgid
  9746. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9747. res.Infcode = infocode
  9748. } else {
  9749. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9750. utils.ErrorLog("解析失败:%v", err)
  9751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9752. return
  9753. }
  9754. }
  9755. if res.Infcode == 0 {
  9756. c.ServeSuccessJSON(map[string]interface{}{
  9757. "msg": res.Output.Trtinfo,
  9758. })
  9759. }
  9760. }
  9761. }
  9762. }
  9763. //func (c *HisApiController) PutRecord() {
  9764. // id, _ := c.GetInt64("id")
  9765. // record_time := c.GetString("record_time")
  9766. // timeLayout := "2006-01-02"
  9767. // loc, _ := time.LoadLocation("Local")
  9768. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9769. // if err != nil {
  9770. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9771. // return
  9772. // }
  9773. // recordDateTime := theTime.Unix()
  9774. //
  9775. // adminInfo := c.GetAdminUserInfo()
  9776. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9777. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9778. //
  9779. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9780. //
  9781. // fmt.Println(miConfig.SecretKey)
  9782. //
  9783. // if patient == nil {
  9784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9785. // return
  9786. // }
  9787. // if len(patient.IdCardNo) == 0 {
  9788. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9789. // return
  9790. // }
  9791. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9792. // if config.IsOpen == 1 {
  9793. // 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
  9794. // resp, requestErr := http.Get(api)
  9795. // if requestErr != nil {
  9796. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9797. // return
  9798. // }
  9799. // defer resp.Body.Close()
  9800. // body, ioErr := ioutil.ReadAll(resp.Body)
  9801. // if ioErr != nil {
  9802. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9803. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9804. // return
  9805. // }
  9806. // var respJSON map[string]interface{}
  9807. //
  9808. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9809. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9810. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9811. // return
  9812. // }
  9813. //
  9814. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9815. // userJSONBytes, _ := json.Marshal(userJSON)
  9816. // var res ResultTwo
  9817. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9818. // utils.ErrorLog("解析失败:%v", err)
  9819. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9820. // return
  9821. // }
  9822. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9823. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9824. // infoStr := string(Iinfos)
  9825. // idetinfoStr := string(Idetinfos)
  9826. //
  9827. // if res.Infcode == 0 {
  9828. // his := models.VMHisPatient{
  9829. // Status: 1,
  9830. // Ctime: time.Now().Unix(),
  9831. // Mtime: time.Now().Unix(),
  9832. // PsnNo: res.Output.Baseinfo.PsnNo,
  9833. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9834. // Certno: res.Output.Baseinfo.Certno,
  9835. // PsnName: res.Output.Baseinfo.PsnName,
  9836. // Gend: res.Output.Baseinfo.Gend,
  9837. // Naty: res.Output.Baseinfo.Naty,
  9838. // Brdy: res.Output.Baseinfo.Brdy,
  9839. // Age: res.Output.Baseinfo.Age,
  9840. // Iinfo: infoStr,
  9841. // Idetinfo: idetinfoStr,
  9842. // PatientId: patient.ID,
  9843. // RecordDate: theTime.Unix(),
  9844. // UserOrgId: adminInfo.CurrentOrgId,
  9845. // AdminUserId: adminInfo.AdminUser.Id,
  9846. // IsReturn: 1,
  9847. // }
  9848. //
  9849. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9850. // //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")
  9851. // //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")
  9852. //
  9853. // //var dat map[string]interface{}
  9854. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9855. // // fmt.Println(dat)
  9856. // //} else {
  9857. // // fmt.Println(err)
  9858. // //}
  9859. //
  9860. // var dat2 map[string]interface{}
  9861. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9862. // fmt.Println(dat2)
  9863. // } else {
  9864. // fmt.Println(err)
  9865. // }
  9866. //
  9867. // } else {
  9868. // adminUser := c.GetAdminUserInfo()
  9869. // errlog := &models.HisOrderError{
  9870. // UserOrgId: adminUser.CurrentOrgId,
  9871. // Ctime: time.Now().Unix(),
  9872. // Mtime: time.Now().Unix(),
  9873. // ErrMsg: res.ErrMsg,
  9874. // Status: 1,
  9875. // PatientId: id,
  9876. // RecordTime: recordDateTime,
  9877. // Stage: 1,
  9878. // }
  9879. // service.CreateErrMsgLog(errlog)
  9880. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9881. // return
  9882. // }
  9883. // }
  9884. //
  9885. //}
  9886. //func (c *HisApiController) GetUploadDiag() {
  9887. // id, _ := c.GetInt64("id")
  9888. // record_time := c.GetString("record_time")
  9889. //
  9890. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9891. // sick_type, _ := c.GetInt64("sick_type")
  9892. // reg_type, _ := c.GetInt64("reg_type")
  9893. //
  9894. // timeLayout := "2006-01-02"
  9895. // loc, _ := time.LoadLocation("Local")
  9896. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9897. // if err != nil {
  9898. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9899. // return
  9900. // }
  9901. //
  9902. // var patientPrescription models.HisPrescriptionInfo
  9903. // recordDateTime := theTime.Unix()
  9904. // adminInfo := c.GetAdminUserInfo()
  9905. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9906. //
  9907. // if patientPrescription.ID == 0 {
  9908. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9909. // }
  9910. //
  9911. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9912. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9913. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9914. // sickConfig, _ := service.FindSickById(sick_type)
  9915. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9916. //
  9917. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9918. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9919. // "&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 +
  9920. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9921. // resp2, requestErr2 := http.Get(api2)
  9922. // if requestErr2 != nil {
  9923. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9924. // return
  9925. // }
  9926. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9927. // if ioErr2 != nil {
  9928. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9929. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9930. // return
  9931. // }
  9932. // var respJSON2 map[string]interface{}
  9933. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9934. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9935. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9936. // return
  9937. // }
  9938. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9939. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9940. //
  9941. // var res2 ResultSix
  9942. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9943. // utils.ErrorLog("解析失败:%v", err)
  9944. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9945. // return
  9946. // }
  9947. // if res2.Infcode != 0 {
  9948. // adminUser := c.GetAdminUserInfo()
  9949. // errlog := &models.HisOrderError{
  9950. // UserOrgId: adminUser.CurrentOrgId,
  9951. // Ctime: time.Now().Unix(),
  9952. // Mtime: time.Now().Unix(),
  9953. // ErrMsg: res2.ErrMsg,
  9954. // Status: 1,
  9955. // PatientId: id,
  9956. // RecordTime: recordDateTime,
  9957. // Stage: 3,
  9958. // }
  9959. // service.CreateErrMsgLog(errlog)
  9960. //
  9961. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9962. // return
  9963. // }
  9964. //
  9965. // c.ServeSuccessJSON(map[string]interface{}{
  9966. // "msg": "上传成功",
  9967. // })
  9968. //
  9969. //}
  9970. type QueryResult struct {
  9971. ID int64
  9972. Name string
  9973. Code string
  9974. List_type_code string
  9975. }
  9976. func (c *HisApiController) GetCheckCode() {
  9977. ids_str := c.GetString("ids")
  9978. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9979. ids_arr := strings.Split(ids_str, ",")
  9980. var queryResult []QueryResult
  9981. ids := make([]int64, 0)
  9982. for _, item := range ids_arr {
  9983. id, _ := strconv.ParseInt(item, 10, 64)
  9984. ids = append(ids, id)
  9985. }
  9986. if record_type == 1 {
  9987. drugs, _ := service.GetBatchDrugList(ids)
  9988. for _, item := range drugs {
  9989. result := QueryResult{
  9990. ID: item.ID,
  9991. Name: item.DrugName,
  9992. Code: item.MedicalInsuranceNumber,
  9993. List_type_code: "101",
  9994. }
  9995. queryResult = append(queryResult, result)
  9996. }
  9997. } else if record_type == 2 {
  9998. goods, _ := service.GetBatchGoodInformationList(ids)
  9999. for _, item := range goods {
  10000. result := QueryResult{
  10001. ID: item.ID,
  10002. Name: item.GoodName,
  10003. Code: item.MedicalInsuranceNumber,
  10004. List_type_code: "301",
  10005. }
  10006. queryResult = append(queryResult, result)
  10007. }
  10008. } else if record_type == 3 {
  10009. projects, _ := service.GetBathchMyPorjecgList(ids)
  10010. for _, item := range projects {
  10011. result := QueryResult{
  10012. ID: item.ID,
  10013. Name: item.ProjectName,
  10014. Code: item.MedicalCode,
  10015. List_type_code: "201",
  10016. }
  10017. queryResult = append(queryResult, result)
  10018. }
  10019. }
  10020. admin_user_id, _ := c.GetInt64("admin_user_id")
  10021. adminUser := c.GetAdminUserInfo()
  10022. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10023. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10024. var user_name string
  10025. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10026. if role.ID == 0 {
  10027. user_name = "xxx"
  10028. } else {
  10029. user_name = role.UserName
  10030. }
  10031. baseParams := &models.BaseParams{
  10032. SecretKey: miConfig.SecretKey,
  10033. FixmedinsCode: miConfig.Code,
  10034. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10035. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10036. OrgName: miConfig.OrgName,
  10037. Doctor: user_name,
  10038. }
  10039. if config.IsOpen == 1 {
  10040. for _, item := range queryResult {
  10041. var result string
  10042. if record_type == 1 {
  10043. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10044. } else if record_type == 2 {
  10045. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10046. } else if record_type == 3 {
  10047. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10048. }
  10049. var dat map[string]interface{}
  10050. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10051. fmt.Println(dat)
  10052. } else {
  10053. fmt.Println(err)
  10054. }
  10055. userJSONBytes, _ := json.Marshal(dat)
  10056. var res ResultSix
  10057. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10058. utils.ErrorLog("解析失败:%v", err)
  10059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10060. return
  10061. }
  10062. if res.Infcode == 0 {
  10063. if record_type == 1 {
  10064. service.UpdateBaseDrugById(item.ID)
  10065. } else if record_type == 2 {
  10066. service.UpdateGoodInformaitonByDetail(item.ID)
  10067. } else if record_type == 3 {
  10068. service.UpdateProjectById(item.ID)
  10069. }
  10070. c.ServeSuccessJSON(map[string]interface{}{
  10071. "failed_code": 0,
  10072. "msg": "目录对照成功",
  10073. })
  10074. } else {
  10075. c.ServeSuccessJSON(map[string]interface{}{
  10076. "failed_code": -10,
  10077. "msg": res.ErrMsg,
  10078. })
  10079. }
  10080. }
  10081. }
  10082. }
  10083. func (c *HisApiController) UnCheckCode() {
  10084. ids_str := c.GetString("ids")
  10085. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  10086. admin_user_id, _ := c.GetInt64("admin_user_id")
  10087. ids_arr := strings.Split(ids_str, ",")
  10088. var queryResult []QueryResult
  10089. ids := make([]int64, 0)
  10090. for _, item := range ids_arr {
  10091. id, _ := strconv.ParseInt(item, 10, 64)
  10092. ids = append(ids, id)
  10093. }
  10094. if record_type == 1 {
  10095. drugs, _ := service.GetBatchDrugList(ids)
  10096. for _, item := range drugs {
  10097. result := QueryResult{
  10098. ID: item.ID,
  10099. Name: item.DrugName,
  10100. Code: item.MedicalInsuranceNumber,
  10101. List_type_code: "101",
  10102. }
  10103. queryResult = append(queryResult, result)
  10104. }
  10105. } else if record_type == 2 {
  10106. goods, _ := service.GetBatchGoodInformationList(ids)
  10107. for _, item := range goods {
  10108. result := QueryResult{
  10109. ID: item.ID,
  10110. Name: item.GoodName,
  10111. Code: item.MedicalInsuranceNumber,
  10112. List_type_code: "301",
  10113. }
  10114. queryResult = append(queryResult, result)
  10115. }
  10116. } else if record_type == 3 {
  10117. projects, _ := service.GetBathchMyPorjecgList(ids)
  10118. for _, item := range projects {
  10119. result := QueryResult{
  10120. ID: item.ID,
  10121. Name: item.ProjectName,
  10122. Code: item.MedicalCode,
  10123. List_type_code: "201",
  10124. }
  10125. queryResult = append(queryResult, result)
  10126. }
  10127. }
  10128. adminUser := c.GetAdminUserInfo()
  10129. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10130. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10131. var user_name string
  10132. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10133. if role.ID == 0 {
  10134. user_name = "xxx"
  10135. } else {
  10136. user_name = role.UserName
  10137. }
  10138. baseParams := &models.BaseParams{
  10139. SecretKey: miConfig.SecretKey,
  10140. FixmedinsCode: miConfig.Code,
  10141. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10142. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10143. OrgName: miConfig.OrgName,
  10144. Doctor: user_name,
  10145. }
  10146. if config.IsOpen == 1 {
  10147. for _, item := range queryResult {
  10148. var result string
  10149. if record_type == 1 {
  10150. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10151. } else if record_type == 2 {
  10152. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10153. } else if record_type == 3 {
  10154. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10155. }
  10156. var dat2 map[string]interface{}
  10157. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  10158. fmt.Println(dat2)
  10159. } else {
  10160. fmt.Println(err)
  10161. }
  10162. userJSONBytes, _ := json.Marshal(dat2)
  10163. var res ResultSix
  10164. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10165. utils.ErrorLog("解析失败:%v", err)
  10166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10167. return
  10168. }
  10169. if res.Infcode == 0 {
  10170. if record_type == 1 {
  10171. service.UpdateDrugByIdDetail(item.ID)
  10172. } else if record_type == 2 {
  10173. service.UpdateGoodInfoById(item.ID)
  10174. } else if record_type == 3 {
  10175. service.UpdateMyProjectById(item.ID)
  10176. }
  10177. c.ServeSuccessJSON(map[string]interface{}{
  10178. "failed_code": 0,
  10179. "msg": "撤销目录对照成功",
  10180. })
  10181. } else {
  10182. c.ServeSuccessJSON(map[string]interface{}{
  10183. "failed_code": -10,
  10184. "msg": res.ErrMsg,
  10185. })
  10186. }
  10187. }
  10188. }
  10189. }
  10190. func (c *HisApiController) GetPatientInfo() {
  10191. id_card_no := c.GetString("id_card_no")
  10192. admin_user_id, _ := c.GetInt64("admin_user_id")
  10193. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  10194. if patient.ID == 0 {
  10195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10196. return
  10197. }
  10198. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10199. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10200. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  10201. if config.IsOpen == 1 {
  10202. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10203. var dat map[string]interface{}
  10204. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10205. fmt.Println(dat)
  10206. } else {
  10207. fmt.Println(err)
  10208. }
  10209. userJSONBytes, _ := json.Marshal(dat)
  10210. var res ResultTwo
  10211. var res10265 ResultTwo10265
  10212. if miConfig.Code == "H15049901371" {
  10213. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10214. utils.ErrorLog("解析失败:%v", err)
  10215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10216. return
  10217. }
  10218. res.ErrMsg = res10265.ErrMsg
  10219. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10220. res.Infcode = infocode
  10221. res.Output = res10265.Output
  10222. res.InfRefmsgid = res10265.InfRefmsgid
  10223. } else {
  10224. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10225. utils.ErrorLog("解析失败:%v", err)
  10226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10227. return
  10228. }
  10229. }
  10230. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10231. // utils.ErrorLog("解析失败:%v", err)
  10232. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10233. // return
  10234. //}
  10235. if res.Infcode != 0 {
  10236. c.ServeSuccessJSON(map[string]interface{}{
  10237. "failed_code": -10,
  10238. "msg": res.ErrMsg,
  10239. })
  10240. } else {
  10241. c.ServeSuccessJSON(map[string]interface{}{
  10242. "failed_code": 0,
  10243. "info": res,
  10244. })
  10245. }
  10246. }
  10247. }
  10248. func (c *HisApiController) PsnPutOnRecord() {
  10249. record_type, _ := c.GetInt64("type")
  10250. patient_id, _ := c.GetInt64("patient_id")
  10251. admin_user_id, _ := c.GetInt64("admin_user_id")
  10252. start_time := c.GetString("start_time")
  10253. end_time := c.GetString("end_time")
  10254. adminUser := c.GetAdminUserInfo()
  10255. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10256. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10257. var patients []*models.Patients
  10258. if record_type == 1 { //全部备案
  10259. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  10260. patients = append(patients, patient...)
  10261. } else { //单个备案
  10262. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10263. patients = append(patients, patient)
  10264. }
  10265. var user_name string
  10266. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10267. if role.ID == 0 {
  10268. user_name = "xxx"
  10269. } else {
  10270. user_name = role.UserName
  10271. }
  10272. if config.IsOpen == 1 {
  10273. for _, item := range patients {
  10274. 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
  10275. resp, requestErr := http.Get(api)
  10276. if requestErr != nil {
  10277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10278. return
  10279. }
  10280. defer resp.Body.Close()
  10281. body, ioErr := ioutil.ReadAll(resp.Body)
  10282. if ioErr != nil {
  10283. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10285. return
  10286. }
  10287. var respJSON map[string]interface{}
  10288. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10289. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10291. return
  10292. }
  10293. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10294. userJSONBytes, _ := json.Marshal(userJSON)
  10295. var res ResultTwo
  10296. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10297. utils.ErrorLog("解析失败:%v", err)
  10298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10299. return
  10300. }
  10301. if res.Infcode == 0 {
  10302. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10303. var dat map[string]interface{}
  10304. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10305. fmt.Println(dat)
  10306. } else {
  10307. fmt.Println(err)
  10308. }
  10309. userJSONBytes, _ := json.Marshal(dat)
  10310. var res2 ResultThirteen
  10311. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10312. utils.ErrorLog("解析失败:%v", err)
  10313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10314. return
  10315. }
  10316. if res2.Infcode == 0 {
  10317. psnResult := &models.GdybPsnRecord{
  10318. UserOrgId: adminUser.CurrentOrgId,
  10319. PatientId: item.ID,
  10320. PsnNo: res.Output.Baseinfo.PsnNo,
  10321. Ctime: time.Now().Unix(),
  10322. Mtime: time.Now().Unix(),
  10323. Status: 1,
  10324. IsCancel: 1,
  10325. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10326. }
  10327. service.CreatePsnRecord(psnResult)
  10328. } else {
  10329. c.ServeSuccessJSON(map[string]interface{}{
  10330. "failed_code": -10,
  10331. "msg": res2.ErrMsg,
  10332. })
  10333. return
  10334. }
  10335. }
  10336. }
  10337. }
  10338. }
  10339. func (c *HisApiController) PsnUnPutOnRecord() {
  10340. id, _ := c.GetInt64("id")
  10341. //record_type, _ := c.GetInt64("type")
  10342. admin_user_id, _ := c.GetInt64("admin_user_id")
  10343. adminUser := c.GetAdminUserInfo()
  10344. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10345. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10346. var user_name string
  10347. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10348. if role.ID == 0 {
  10349. user_name = "xxx"
  10350. } else {
  10351. user_name = role.UserName
  10352. }
  10353. psn_record, _ := service.GetPsnRecordById(id)
  10354. if psn_record.ID == 0 {
  10355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10356. return
  10357. }
  10358. if config.IsOpen == 1 {
  10359. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10360. var dat map[string]interface{}
  10361. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10362. fmt.Println(dat)
  10363. } else {
  10364. fmt.Println(err)
  10365. }
  10366. userJSONBytes, _ := json.Marshal(dat)
  10367. var res ResultFourteen
  10368. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10369. utils.ErrorLog("解析失败:%v", err)
  10370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10371. return
  10372. }
  10373. if res.Infcode == 0 {
  10374. psn_record.IsCancel = 2
  10375. service.CreatePsnRecord(&psn_record)
  10376. } else {
  10377. c.ServeSuccessJSON(map[string]interface{}{
  10378. "failed_code": -10,
  10379. "msg": res.ErrMsg,
  10380. })
  10381. return
  10382. }
  10383. }
  10384. }
  10385. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10386. patient_id, _ := c.GetInt64("patient_id")
  10387. insutype_two := c.GetString("insutype")
  10388. psn_no := c.GetString("psn_no")
  10389. doctor_id, _ := c.GetInt64("doctor_id")
  10390. sick_id, _ := c.GetInt64("sick_id")
  10391. department_id, _ := c.GetInt64("department_id")
  10392. start_time := c.GetString("start_time")
  10393. end_time := c.GetString("end_time")
  10394. check_time := c.GetString("check_time")
  10395. adminUser := c.GetAdminUserInfo()
  10396. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10397. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10398. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10399. sick, _ := service.FindSickById(sick_id)
  10400. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10401. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10402. var res ResultTwo
  10403. var res10265 ResultTwo10265
  10404. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10405. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10406. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10407. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10408. "&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
  10409. resp, requestErr := http.Get(api)
  10410. if requestErr != nil {
  10411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10412. return
  10413. }
  10414. body, ioErr := ioutil.ReadAll(resp.Body)
  10415. if ioErr != nil {
  10416. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10418. return
  10419. }
  10420. var respJSON map[string]interface{}
  10421. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10422. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10424. return
  10425. }
  10426. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10427. result, _ := json.Marshal(respJSON)
  10428. fmt.Println("log")
  10429. fmt.Println(string(result))
  10430. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10431. utils.ErrorLog("解析失败:%v", err)
  10432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10433. return
  10434. }
  10435. res.ErrMsg = res10265.ErrMsg
  10436. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10437. res.Infcode = infocode
  10438. res.Output = res10265.Output
  10439. res.InfRefmsgid = res10265.InfRefmsgid
  10440. } else {
  10441. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10442. if miConfig.Code == "H15049901371" {
  10443. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10444. utils.ErrorLog("解析失败:%v", err)
  10445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10446. return
  10447. }
  10448. res.ErrMsg = res10265.ErrMsg
  10449. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10450. res.Infcode = infocode
  10451. res.Output = res10265.Output
  10452. res.InfRefmsgid = res10265.InfRefmsgid
  10453. } else {
  10454. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10455. utils.ErrorLog("解析失败:%v", err)
  10456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10457. return
  10458. }
  10459. }
  10460. }
  10461. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10462. infoStr := string(Iinfos)
  10463. var rf []*ResultFive
  10464. json.Unmarshal([]byte(infoStr), &rf)
  10465. var insuplc_admdvs string
  10466. var insutype string
  10467. var is390 int = 0
  10468. var is310 int = 0
  10469. var insutypes []*ResultFive
  10470. for _, item := range rf {
  10471. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10472. insutypes = append(insutypes, item)
  10473. }
  10474. }
  10475. if len(insutypes) == 1 {
  10476. insutype = insutypes[0].Insutype
  10477. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10478. } else {
  10479. for _, i := range insutypes {
  10480. if i.Insutype == "390" {
  10481. is390 = 1
  10482. }
  10483. if i.Insutype == "310" {
  10484. is310 = 1
  10485. }
  10486. }
  10487. }
  10488. if is390 == 1 {
  10489. insutype = "390"
  10490. }
  10491. if is310 == 1 {
  10492. insutype = "310"
  10493. }
  10494. if len(insutypes) == 2 {
  10495. insutype = insutype_two
  10496. }
  10497. if len(insutypes) == 0 {
  10498. insutype = "310"
  10499. }
  10500. insutype = insutype_two
  10501. fmt.Println(insutype)
  10502. for _, item := range rf {
  10503. fmt.Println(item.Insutype)
  10504. fmt.Println(insutype)
  10505. if item.Insutype == insutype {
  10506. fmt.Println(item.Insutype)
  10507. fmt.Println(insutype)
  10508. insuplc_admdvs = item.InsuplcAdmdvs
  10509. }
  10510. }
  10511. fmt.Println(insuplc_admdvs)
  10512. var res2 ResultThirteen
  10513. var res10265_2 ResultThirteen10265
  10514. if config.IsOpen == 1 {
  10515. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10516. } else {
  10517. 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)
  10518. var dat map[string]interface{}
  10519. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10520. fmt.Println(dat)
  10521. } else {
  10522. fmt.Println(err)
  10523. }
  10524. userJSONBytes, _ := json.Marshal(dat)
  10525. if miConfig.Code == "H15049901371" {
  10526. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10527. utils.ErrorLog("解析失败:%v", err)
  10528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10529. return
  10530. }
  10531. res2.ErrMsg = res10265_2.ErrMsg
  10532. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10533. res2.Infcode = infocode
  10534. res2.Output = res10265_2.Output
  10535. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10536. } else {
  10537. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10538. utils.ErrorLog("解析失败:%v", err)
  10539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10540. return
  10541. }
  10542. }
  10543. }
  10544. if res2.Infcode == 0 {
  10545. psnResult := &models.GdybPsnNcdsRecord{
  10546. UserOrgId: adminUser.CurrentOrgId,
  10547. PatientId: patient.ID,
  10548. PsnNo: psn_no,
  10549. DoctorId: doctor.AdminUserId,
  10550. DepartmentId: department_id,
  10551. SickType: sick_id,
  10552. Insutype: insutype,
  10553. Ctime: time.Now().Unix(),
  10554. Mtime: time.Now().Unix(),
  10555. Status: 1,
  10556. IsCancel: 1,
  10557. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10558. }
  10559. service.CreatePsnNCDSRecord(psnResult)
  10560. c.ServeSuccessJSON(map[string]interface{}{
  10561. "failed_code": 0,
  10562. "msg": "备案成功",
  10563. "result": psnResult,
  10564. })
  10565. } else {
  10566. c.ServeSuccessJSON(map[string]interface{}{
  10567. "failed_code": -10,
  10568. "msg": res2.ErrMsg,
  10569. })
  10570. return
  10571. }
  10572. }
  10573. }
  10574. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10575. id, _ := c.GetInt64("id")
  10576. admin_user_id, _ := c.GetInt64("admin_user_id")
  10577. adminUser := c.GetAdminUserInfo()
  10578. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10579. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10580. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10581. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10582. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10583. //var user_name string
  10584. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10585. //if role.ID == 0 {
  10586. // user_name = "xxx"
  10587. //} else {
  10588. // user_name = role.UserName
  10589. //}
  10590. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10591. if psn_record.ID == 0 {
  10592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10593. return
  10594. }
  10595. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10596. var res ResultTwo
  10597. var res10265 ResultTwo10265
  10598. if miConfig.Code == "H15049901371" {
  10599. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10600. utils.ErrorLog("解析失败:%v", err)
  10601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10602. return
  10603. }
  10604. res.ErrMsg = res10265.ErrMsg
  10605. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10606. res.Infcode = infocode
  10607. res.Output = res10265.Output
  10608. res.InfRefmsgid = res10265.InfRefmsgid
  10609. } else {
  10610. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10611. utils.ErrorLog("解析失败:%v", err)
  10612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10613. return
  10614. }
  10615. }
  10616. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10617. infoStr := string(Iinfos)
  10618. var rf []*ResultFive
  10619. json.Unmarshal([]byte(infoStr), &rf)
  10620. var insuplc_admdvs string
  10621. var insutype string
  10622. var is390 int = 0
  10623. var is310 int = 0
  10624. var insutypes []*ResultFive
  10625. for _, item := range rf {
  10626. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10627. insutypes = append(insutypes, item)
  10628. }
  10629. }
  10630. if len(insutypes) == 1 {
  10631. insutype = insutypes[0].Insutype
  10632. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10633. } else {
  10634. for _, i := range insutypes {
  10635. if i.Insutype == "390" {
  10636. is390 = 1
  10637. }
  10638. if i.Insutype == "310" {
  10639. is310 = 1
  10640. }
  10641. }
  10642. }
  10643. if is390 == 1 {
  10644. insutype = "390"
  10645. }
  10646. if is310 == 1 {
  10647. insutype = "310"
  10648. }
  10649. if len(insutypes) == 0 {
  10650. insutype = "310"
  10651. }
  10652. insutype = psn_record.Insutype
  10653. for _, item := range rf {
  10654. if item.Insutype == insutype {
  10655. insuplc_admdvs = item.InsuplcAdmdvs
  10656. }
  10657. }
  10658. if config.IsOpen == 1 {
  10659. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10660. var dat map[string]interface{}
  10661. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10662. fmt.Println(dat)
  10663. } else {
  10664. fmt.Println(err)
  10665. }
  10666. userJSONBytes, _ := json.Marshal(dat)
  10667. var res ResultFourteen
  10668. var res10265 ResultFourteen10265
  10669. if miConfig.Code == "H15049901371" {
  10670. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10671. utils.ErrorLog("解析失败:%v", err)
  10672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10673. return
  10674. }
  10675. res.ErrMsg = res10265.ErrMsg
  10676. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10677. res.Infcode = infocode
  10678. res.Output = res10265.Output
  10679. res.InfRefmsgid = res10265.InfRefmsgid
  10680. } else {
  10681. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10682. utils.ErrorLog("解析失败:%v", err)
  10683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10684. return
  10685. }
  10686. }
  10687. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10688. // utils.ErrorLog("解析失败:%v", err)
  10689. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10690. // return
  10691. //}
  10692. if res.Infcode == 0 {
  10693. psn_record.IsCancel = 2
  10694. service.CreatePsnNCDSRecord(&psn_record)
  10695. c.ServeSuccessJSON(map[string]interface{}{
  10696. "failed_code": 0,
  10697. "msg": "撤销备案成功",
  10698. })
  10699. } else {
  10700. c.ServeSuccessJSON(map[string]interface{}{
  10701. "failed_code": -10,
  10702. "msg": res.ErrMsg,
  10703. })
  10704. return
  10705. }
  10706. }
  10707. }
  10708. func (c *HisApiController) TestTest() {
  10709. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10710. fmt.Println(patient.Iinfo)
  10711. }
  10712. type CustomData struct {
  10713. MsgId string
  10714. PsnNo string
  10715. Info string
  10716. }
  10717. func (c *HisApiController) ReversalData() {
  10718. var customData []*CustomData
  10719. custom := &CustomData{
  10720. MsgId: "H44022900158202103301714472004",
  10721. PsnNo: "44020000001101329945",
  10722. Info: "2207",
  10723. }
  10724. customData = append(customData, custom)
  10725. custom1 := &CustomData{
  10726. MsgId: "H4402290015820210330172057803",
  10727. PsnNo: "44020000001101161813",
  10728. Info: "2207",
  10729. }
  10730. customData = append(customData, custom1)
  10731. custom2 := &CustomData{
  10732. MsgId: "H44022900158202103301705198813",
  10733. PsnNo: "44190000133097375417",
  10734. Info: "2207",
  10735. }
  10736. customData = append(customData, custom2)
  10737. custom3 := &CustomData{
  10738. MsgId: "H44022900158202103301715524756",
  10739. PsnNo: "44020000001100187221",
  10740. Info: "2207",
  10741. }
  10742. customData = append(customData, custom3)
  10743. custom4 := &CustomData{
  10744. MsgId: "H44022900158202103301730376224",
  10745. PsnNo: "44020000001101959155",
  10746. Info: "2207",
  10747. }
  10748. customData = append(customData, custom4)
  10749. custom5 := &CustomData{
  10750. MsgId: "H44022900158202103301748008725",
  10751. PsnNo: "44020000001104246641",
  10752. Info: "2207",
  10753. }
  10754. customData = append(customData, custom5)
  10755. custom6 := &CustomData{
  10756. MsgId: "H44022900158202103301718096755",
  10757. PsnNo: "44020000001102211860",
  10758. Info: "2207",
  10759. }
  10760. customData = append(customData, custom6)
  10761. custom7 := &CustomData{
  10762. MsgId: "H44022900158202103301736551640",
  10763. PsnNo: "44020000001102687718",
  10764. Info: "2207",
  10765. }
  10766. customData = append(customData, custom7)
  10767. custom8 := &CustomData{
  10768. MsgId: "H44022900158202103301743097676",
  10769. PsnNo: "44020000001102127785",
  10770. Info: "2207",
  10771. }
  10772. customData = append(customData, custom8)
  10773. custom9 := &CustomData{
  10774. MsgId: "H44022900158202103301712304203",
  10775. PsnNo: "44020000001101518097",
  10776. Info: "2207",
  10777. }
  10778. customData = append(customData, custom9)
  10779. custom10 := &CustomData{
  10780. MsgId: "H44022900158202103301738448785",
  10781. PsnNo: "44020000001100500813",
  10782. Info: "2207",
  10783. }
  10784. customData = append(customData, custom10)
  10785. custom11 := &CustomData{
  10786. MsgId: "H44022900158202103301732455843",
  10787. PsnNo: "44020000001102690557",
  10788. Info: "2207",
  10789. }
  10790. customData = append(customData, custom11)
  10791. custom12 := &CustomData{
  10792. MsgId: "H44022900158202103301745421708",
  10793. PsnNo: "44020000001102211928",
  10794. Info: "2207",
  10795. }
  10796. customData = append(customData, custom12)
  10797. custom1212 := &CustomData{
  10798. MsgId: "H440229001582021033017351627",
  10799. PsnNo: "44020000001102481733",
  10800. Info: "2207",
  10801. }
  10802. customData = append(customData, custom1212)
  10803. custom13 := &CustomData{
  10804. MsgId: "H44022900158202103301740327951",
  10805. PsnNo: "44020000001103174866",
  10806. Info: "2207",
  10807. }
  10808. customData = append(customData, custom13)
  10809. custom14 := &CustomData{
  10810. MsgId: "H4402290015820210330174922668",
  10811. PsnNo: "44020000001102927272",
  10812. Info: "2207",
  10813. }
  10814. customData = append(customData, custom14)
  10815. custom15 := &CustomData{
  10816. MsgId: "H44022900158202103301752362273",
  10817. PsnNo: "44020000001102942890",
  10818. Info: "2207",
  10819. }
  10820. customData = append(customData, custom15)
  10821. custom16 := &CustomData{
  10822. MsgId: "H44022900158202103301751082917",
  10823. PsnNo: "44020000001101662162",
  10824. Info: "2207",
  10825. }
  10826. customData = append(customData, custom16)
  10827. custom17 := &CustomData{
  10828. MsgId: "H44022900158202103301754147728",
  10829. PsnNo: "44020000000229014511",
  10830. Info: "2207",
  10831. }
  10832. customData = append(customData, custom17)
  10833. adminUser := c.GetAdminUserInfo()
  10834. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10835. for _, item := range customData {
  10836. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10837. fmt.Println(result)
  10838. }
  10839. }
  10840. //func (c *HisApiController) GetAllopatry() {
  10841. // year := c.GetString("year")
  10842. // month := c.GetString("month")
  10843. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10844. // adminUser := c.GetAdminUserInfo()
  10845. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10846. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10847. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10848. //
  10849. // var dat map[string]interface{}
  10850. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10851. // fmt.Println(dat)
  10852. // } else {
  10853. // fmt.Println(err)
  10854. // }
  10855. // userJSONBytes, _ := json.Marshal(dat)
  10856. // var res models.Result9001
  10857. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10858. // utils.ErrorLog("解析失败:%v", err)
  10859. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10860. // return
  10861. // }
  10862. //
  10863. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10864. // var dat2 map[string]interface{}
  10865. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10866. // fmt.Println(dat)
  10867. // } else {
  10868. // fmt.Println(err)
  10869. // }
  10870. // userJSONBytes2, _ := json.Marshal(dat2)
  10871. // var res2 models.Result3260
  10872. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10873. // utils.ErrorLog("解析失败:%v", err)
  10874. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10875. // return
  10876. // }
  10877. // if res2.Infcode == 0 {
  10878. // c.ServeSuccessJSON(map[string]interface{}{
  10879. // "list": res2.Output.Data,
  10880. // })
  10881. // return
  10882. // } else {
  10883. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10884. // return
  10885. // }
  10886. //
  10887. //}
  10888. //func (c *HisApiController) ComfirmAllopatry() {
  10889. // year := c.GetString("year")
  10890. // month := c.GetString("month")
  10891. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10892. // adminUser := c.GetAdminUserInfo()
  10893. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10894. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10895. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10896. // var dat map[string]interface{}
  10897. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10898. // fmt.Println(dat)
  10899. // } else {
  10900. // fmt.Println(err)
  10901. // }
  10902. // userJSONBytes, _ := json.Marshal(dat)
  10903. // var res models.Result9001
  10904. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10905. // utils.ErrorLog("解析失败:%v", err)
  10906. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10907. // return
  10908. // }
  10909. //
  10910. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10911. // var dat2 map[string]interface{}
  10912. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10913. // fmt.Println(dat)
  10914. // } else {
  10915. // fmt.Println(err)
  10916. // }
  10917. // userJSONBytes2, _ := json.Marshal(dat2)
  10918. // var res2 models.Result3260
  10919. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10920. // utils.ErrorLog("解析失败:%v", err)
  10921. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10922. // return
  10923. // }
  10924. //
  10925. // if res2.Infcode == 0 {
  10926. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10927. // var dat map[string]interface{}
  10928. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10929. // fmt.Println(dat)
  10930. // } else {
  10931. // fmt.Println(err)
  10932. // }
  10933. // userJSONBytes, _ := json.Marshal(dat)
  10934. // var res3 models.Result3261
  10935. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10936. // utils.ErrorLog("解析失败:%v", err)
  10937. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10938. // return
  10939. // }
  10940. //
  10941. // if res3.Infcode == 0 {
  10942. // record := &models.HisYidiClearRecord{
  10943. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10944. // Ctime: time.Now().Unix(),
  10945. // Mtime: time.Now().Unix(),
  10946. // Status: 1,
  10947. // MsgId: msgId,
  10948. // }
  10949. // service.SaveClearRecord(record)
  10950. // c.ServeSuccessJSON(map[string]interface{}{
  10951. // "msg": "提取成功",
  10952. // })
  10953. // }
  10954. // }
  10955. //}
  10956. func (c *HisApiController) RefundAllopatry() {
  10957. year := c.GetString("year")
  10958. month := c.GetString("month")
  10959. id, _ := c.GetInt64("id")
  10960. admin_user_id, _ := c.GetInt64("admin_user_id")
  10961. adminUser := c.GetAdminUserInfo()
  10962. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10963. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10964. record, _ := service.GetClearRecordById(id)
  10965. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10966. var dat map[string]interface{}
  10967. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10968. fmt.Println(dat)
  10969. } else {
  10970. fmt.Println(err)
  10971. }
  10972. userJSONBytes, _ := json.Marshal(dat)
  10973. var empty ResultFourteen
  10974. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10975. utils.ErrorLog("解析失败:%v", err)
  10976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10977. return
  10978. }
  10979. if empty.Infcode == 0 {
  10980. c.ServeSuccessJSON(map[string]interface{}{
  10981. "msg": "撤销成功",
  10982. })
  10983. return
  10984. }
  10985. }
  10986. func (c *HisApiController) ReversalOtherData() {
  10987. var customData []*CustomData
  10988. custom := &CustomData{
  10989. MsgId: "H44022900158202103301714472004",
  10990. PsnNo: "44020000001101329945",
  10991. Info: "2208",
  10992. }
  10993. customData = append(customData, custom)
  10994. custom1 := &CustomData{
  10995. MsgId: "H4402290015820210330172057803",
  10996. PsnNo: "44020000001101161813",
  10997. Info: "2208",
  10998. }
  10999. customData = append(customData, custom1)
  11000. custom2 := &CustomData{
  11001. MsgId: "H44022900158202103301705198813",
  11002. PsnNo: "44190000133097375417",
  11003. Info: "2208",
  11004. }
  11005. customData = append(customData, custom2)
  11006. custom3 := &CustomData{
  11007. MsgId: "H44022900158202103301715524756",
  11008. PsnNo: "44020000001100187221",
  11009. Info: "2208",
  11010. }
  11011. customData = append(customData, custom3)
  11012. custom4 := &CustomData{
  11013. MsgId: "H44022900158202103301730376224",
  11014. PsnNo: "44020000001101959155",
  11015. Info: "2208",
  11016. }
  11017. customData = append(customData, custom4)
  11018. custom5 := &CustomData{
  11019. MsgId: "H44022900158202103301748008725",
  11020. PsnNo: "44020000001104246641",
  11021. Info: "2208",
  11022. }
  11023. customData = append(customData, custom5)
  11024. custom6 := &CustomData{
  11025. MsgId: "H44022900158202103301718096755",
  11026. PsnNo: "44020000001102211860",
  11027. Info: "2208",
  11028. }
  11029. customData = append(customData, custom6)
  11030. custom7 := &CustomData{
  11031. MsgId: "H44022900158202103301736551640",
  11032. PsnNo: "44020000001102687718",
  11033. Info: "2208",
  11034. }
  11035. customData = append(customData, custom7)
  11036. custom8 := &CustomData{
  11037. MsgId: "H44022900158202103301743097676",
  11038. PsnNo: "44020000001102127785",
  11039. Info: "2208",
  11040. }
  11041. customData = append(customData, custom8)
  11042. custom9 := &CustomData{
  11043. MsgId: "H44022900158202103301712304203",
  11044. PsnNo: "44020000001101518097",
  11045. Info: "2208",
  11046. }
  11047. customData = append(customData, custom9)
  11048. custom10 := &CustomData{
  11049. MsgId: "H44022900158202103301738448785",
  11050. PsnNo: "44020000001100500813",
  11051. Info: "2208",
  11052. }
  11053. customData = append(customData, custom10)
  11054. custom11 := &CustomData{
  11055. MsgId: "H44022900158202103301732455843",
  11056. PsnNo: "44020000001102690557",
  11057. Info: "2208",
  11058. }
  11059. customData = append(customData, custom11)
  11060. custom12 := &CustomData{
  11061. MsgId: "H44022900158202103301745421708",
  11062. PsnNo: "44020000001102211928",
  11063. Info: "2208",
  11064. }
  11065. customData = append(customData, custom12)
  11066. custom1212 := &CustomData{
  11067. MsgId: "H440229001582021033017351627",
  11068. PsnNo: "44020000001102481733",
  11069. Info: "2208",
  11070. }
  11071. customData = append(customData, custom1212)
  11072. custom13 := &CustomData{
  11073. MsgId: "H44022900158202103301740327951",
  11074. PsnNo: "44020000001103174866",
  11075. Info: "2208",
  11076. }
  11077. customData = append(customData, custom13)
  11078. custom14 := &CustomData{
  11079. MsgId: "H4402290015820210330174922668",
  11080. PsnNo: "44020000001102927272",
  11081. Info: "2208",
  11082. }
  11083. customData = append(customData, custom14)
  11084. custom15 := &CustomData{
  11085. MsgId: "H44022900158202103301752362273",
  11086. PsnNo: "44020000001102942890",
  11087. Info: "2208",
  11088. }
  11089. customData = append(customData, custom15)
  11090. custom16 := &CustomData{
  11091. MsgId: "H44022900158202103301751082917",
  11092. PsnNo: "44020000001101662162",
  11093. Info: "2208",
  11094. }
  11095. customData = append(customData, custom16)
  11096. custom17 := &CustomData{
  11097. MsgId: "H44022900158202103301754147728",
  11098. PsnNo: "44020000000229014511",
  11099. Info: "2208",
  11100. }
  11101. customData = append(customData, custom17)
  11102. adminUser := c.GetAdminUserInfo()
  11103. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11104. for _, item := range customData {
  11105. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11106. fmt.Println(result)
  11107. }
  11108. }
  11109. func PathExists(path string) (bool, error) {
  11110. _, err := os.Stat(path)
  11111. if err == nil {
  11112. return true, nil
  11113. }
  11114. if os.IsNotExist(err) {
  11115. return false, nil
  11116. }
  11117. return false, err
  11118. }
  11119. //创建文件夹
  11120. func Mkdir(dir string) {
  11121. // 创建文件夹
  11122. exist, err := PathExists(dir)
  11123. if err != nil {
  11124. fmt.Println(err.Error())
  11125. } else {
  11126. if exist {
  11127. fmt.Println(dir + "文件夹已存在!")
  11128. } else {
  11129. // 文件夹名称,权限
  11130. err := os.Mkdir(dir, os.ModePerm)
  11131. if err != nil {
  11132. fmt.Println(dir+"文件夹创建失败:", err.Error())
  11133. } else {
  11134. fmt.Println(dir + "文件夹创建成功!")
  11135. }
  11136. }
  11137. }
  11138. }
  11139. //压缩文件
  11140. func Zip(srcFile string, destZip string) error {
  11141. zipfile, err := os.Create(destZip)
  11142. if err != nil {
  11143. return err
  11144. }
  11145. defer zipfile.Close()
  11146. archive := zip.NewWriter(zipfile)
  11147. defer archive.Close()
  11148. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  11149. if err != nil {
  11150. return err
  11151. }
  11152. header, err := zip.FileInfoHeader(info)
  11153. if err != nil {
  11154. return err
  11155. }
  11156. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  11157. // header.Name = path
  11158. if info.IsDir() {
  11159. header.Name += "/"
  11160. } else {
  11161. header.Method = zip.Deflate
  11162. }
  11163. writer, err := archive.CreateHeader(header)
  11164. if err != nil {
  11165. return err
  11166. }
  11167. if !info.IsDir() {
  11168. file, err := os.Open(path)
  11169. if err != nil {
  11170. return err
  11171. }
  11172. defer file.Close()
  11173. _, err = io.Copy(writer, file)
  11174. }
  11175. return err
  11176. })
  11177. return err
  11178. }
  11179. func ReadFile(filePath string) []byte {
  11180. f, err := os.Open(filePath)
  11181. if err != nil {
  11182. fmt.Println("read file fail", err)
  11183. return nil
  11184. }
  11185. defer f.Close()
  11186. fd, err := ioutil.ReadAll(f)
  11187. if err != nil {
  11188. fmt.Println("read to fd fail", err)
  11189. return nil
  11190. }
  11191. return fd
  11192. }
  11193. func saveLog(result string, request string, infno string, desc string) {
  11194. org_id, _ := beego.AppConfig.Int64("org_id")
  11195. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11196. dir := miConfig.OrgName + "日志"
  11197. utils.Mkdir(dir)
  11198. month := time.Unix(1557042972, 0).Format("1")
  11199. year := time.Now().Format("2006")
  11200. month = time.Now().Format("01")
  11201. day := time.Now().Format("02")
  11202. hour := time.Now().Format("15")
  11203. min := time.Now().Format("04")
  11204. sec := time.Now().Format("05")
  11205. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  11206. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  11207. file_name := file + ".txt"
  11208. file_path := miConfig.OrgName + "日志" + "/" + file_name
  11209. exist, _ := utils.PathExists(file_path)
  11210. if exist { //存在
  11211. fmt.Println("存在")
  11212. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  11213. if err != nil {
  11214. fmt.Println("read fail")
  11215. }
  11216. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  11217. n, _ := f.Seek(0, 2)
  11218. _, err = f.WriteAt([]byte(content), n)
  11219. } else { //不存在
  11220. fmt.Println("文件不存在,创建文件")
  11221. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  11222. defer f.Close()
  11223. if err != nil {
  11224. } else {
  11225. _, err = f.Write([]byte("记录日志"))
  11226. }
  11227. }
  11228. }
  11229. type Charset string
  11230. const (
  11231. UTF8 = Charset("UTF-8")
  11232. GB18030 = Charset("GB18030")
  11233. )
  11234. func ConvertToString(src string, srcCode string, tagCode string) string {
  11235. srcCoder := mahonia.NewDecoder(srcCode)
  11236. srcResult := srcCoder.ConvertString(src)
  11237. tagCoder := mahonia.NewDecoder(tagCode)
  11238. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  11239. result := string(cdata)
  11240. return result
  11241. }
  11242. func (c *HisApiController) ReadEleCard() {
  11243. id_card_type, _ := c.GetInt64("id_card_type")
  11244. admin_user_id, _ := c.GetInt64("admin_user_id")
  11245. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  11246. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11247. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11248. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11249. var api string
  11250. if miConfig.MdtrtareaAdmvs == "320921" {
  11251. 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 +
  11252. "&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
  11253. fmt.Println(api)
  11254. } else {
  11255. 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 +
  11256. "&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
  11257. }
  11258. resp, requestErr := http.Get(api)
  11259. if requestErr != nil {
  11260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11261. return
  11262. }
  11263. body, ioErr := ioutil.ReadAll(resp.Body)
  11264. if ioErr != nil {
  11265. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11267. return
  11268. }
  11269. var respJSON map[string]interface{}
  11270. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11273. return
  11274. }
  11275. var status string
  11276. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11277. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11278. var token string
  11279. var res ResultTwo //1101结果
  11280. var res10265 ResultTwo10265 //1101结果
  11281. if status == "0" { //读卡成功
  11282. var card_info string //卡信息
  11283. var busi_card_info string
  11284. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11285. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11286. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11287. fmt.Println(card_info)
  11288. fmt.Println(busi_card_info)
  11289. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11290. result, _ := json.Marshal(respJSON)
  11291. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11292. utils.ErrorLog("解析失败:%v", err)
  11293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11294. return
  11295. }
  11296. res.ErrMsg = res10265.ErrMsg
  11297. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11298. res.Infcode = infocode
  11299. res.Output = res10265.Output
  11300. res.InfRefmsgid = res10265.InfRefmsgid
  11301. if res.Infcode == 0 {
  11302. c.ServeSuccessJSON(map[string]interface{}{
  11303. "number": token,
  11304. })
  11305. }
  11306. } else {
  11307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11308. return
  11309. }
  11310. } else { //读卡失败
  11311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11312. return
  11313. }
  11314. }
  11315. func DeleteExtraSpaceTwo(s string) string {
  11316. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11317. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11318. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11319. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11320. s2 := make([]byte, len(s1)) //定义字符数组切片
  11321. copy(s2, s1) //将字符串复制到切片
  11322. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11323. for len(spc_index) > 0 { //找到适配项
  11324. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11325. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11326. }
  11327. return string(s2)
  11328. }
  11329. func Remove0000(s string) string {
  11330. str := make([]rune, 0, len(s))
  11331. for _, v := range []rune(s) {
  11332. if v == 0 {
  11333. continue
  11334. }
  11335. str = append(str, v)
  11336. }
  11337. return string(str)
  11338. }
  11339. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  11340. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  11341. readCard := DllDef.MustFindProc("EcQuery")
  11342. pCardInfo := make([]byte, 8192)
  11343. pBusiCardInfo := make([]byte, 8192)
  11344. data := make(map[string]interface{})
  11345. //pData := make(map[string]interface{})
  11346. inputData := make(map[string]interface{})
  11347. inputData["orgId"] = code
  11348. inputData["businessType"] = "01101"
  11349. inputData["operatorId"] = operator_id
  11350. inputData["operatorName"] = operator_name
  11351. inputData["officeId"] = "001"
  11352. inputData["officeName"] = "血透室"
  11353. //
  11354. data["data"] = inputData
  11355. data["transType"] = "ec.query"
  11356. data["orgId"] = code
  11357. bytesData, _ := json.Marshal(data)
  11358. pCardInfo = bytesData
  11359. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11360. fmt.Println(ret2)
  11361. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  11362. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11363. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  11364. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11365. if ret2 != 0 {
  11366. return "", ""
  11367. }
  11368. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  11369. }
  11370. func DeleteExtraSpace(s string) string {
  11371. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11372. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11373. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11374. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11375. s2 := make([]byte, len(s1)) //定义字符数组切片
  11376. copy(s2, s1) //将字符串复制到切片
  11377. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11378. for len(spc_index) > 0 { //找到适配项
  11379. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11380. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11381. }
  11382. return string(s2)
  11383. }